PageSourceSearch

https://shop.chessbase.com/Scripts/all-classes.js

js chessbase.com collected 2026-09-24 08:53:37 UTC 3,175,242 bytes, 6,324 lines download raw bytes

1/*
2 Sizzle CSS Selector Engine
3 Copyright 2012 JQXLite Foundation and other contributors
4 Released under the MIT license
5 http://sizzlejs.com/
6 localForage -- Offline Storage, Improved
7    Version 1.7.3
8    https://localforage.github.io/localForage
9    (c) 2013-2017 Mozilla, Apache License 2.0
10 @overview es6-promise - a tiny implementation of Promises/A+.
11 @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
12 @license   Licensed under MIT license
13            See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
14 @version   v4.2.2+97478eb6
15 Hammer.JS - v2.0.8 - 2016-04-23
16 http://hammerjs.github.io/
17
18 Copyright (c) 2016 Jorik Tangelder;
19 Licensed under the MIT license  QRious v4.0.2 | (C) 2017 Alasdair Mercer | GPL v3 License
20Based on jsqrencode | (C) 2010 [email protected] | GPL v3 License
21  _noScroll &&  this.dirty || forceDraw*/
22(function(a,b,c){function d(m,n){m=b(m);m.data("JSGrid",this);this._container=m;this.data=[];this.fields=[];this._sortField=this._editingRow=null;this._sortOrder="asc";this._firstDisplayingPage=1;this._init(n);this.render()}var e=function(m,n){return b.isFunction(m)?m.apply(n,b.makeArray(arguments).slice(2)):m},f=function(m){var n=b.Deferred();m&&m.then?m.then(function(){n.resolve.apply(n,arguments)},function(){n.reject.apply(n,arguments)}):n.resolve(m);return n.promise()},g={loadData:b.noop,insertItem:b.noop,
23updateItem:b.noop,deleteItem:b.noop};d.prototype={width:"auto",height:"auto",updateOnResize:!0,rowClass:b.noop,rowRenderer:null,rowClick:function(m){this.editing&&this.editItem(b(m.event.target).closest("tr"))},rowDoubleClick:b.noop,noDataContent:"Not found",noDataRowClass:"jsgrid-nodata-row",heading:!0,headerRowRenderer:null,headerRowClass:"jsgrid-header-row",headerCellClass:"jsgrid-header-cell",filtering:!1,filterRowRenderer:null,filterRowClass:"jsgrid-filter-row",inserting:!1,insertRowRenderer:null,
24insertRowClass:"jsgrid-insert-row",editing:!1,editRowRenderer:null,editRowClass:"jsgrid-edit-row",confirmDeleting:!0,deleteConfirm:"Are you sure?",selecting:!0,selectedRowClass:"jsgrid-selected-row",oddRowClass:"jsgrid-row",evenRowClass:"jsgrid-alt-row",cellClass:"jsgrid-cell",sorting:!1,sortableClass:"jsgrid-header-sortable",sortAscClass:"jsgrid-header-sort jsgrid-header-sort-asc",sortDescClass:"jsgrid-header-sort jsgrid-header-sort-desc",paging:!1,pagerContainer:null,pageIndex:1,pageSize:20,pageButtonCount:15,
25pagerFormat:"Pages: {first} {prev} {pages} {next} {last}    {pageIndex} of {pageCount}",pagePrevText:"Prev",pageNextText:"Next",pageFirstText:"First",pageLastText:"Last",pageNavigatorNextText:"...",pageNavigatorPrevText:"...",pagerContainerClass:"jsgrid-pager-container",pagerClass:"jsgrid-pager",pagerNavButtonClass:"jsgrid-pager-nav-button",pagerNavButtonInactiveClass:"jsgrid-pager-nav-inactive-button",pageClass:"jsgrid-pager-page",currentPageClass:"jsgrid-pager-current-page",customLoading:!1,
26pageLoading:!1,autoload:!1,controller:g,loadIndication:!0,loadIndicationDelay:500,loadMessage:"Please, wait...",loadShading:!0,invalidMessage:"Invalid data entered!",invalidNotify:function(m){m=b.map(m.errors,function(n){return n.message||null});a.alert([this.invalidMessage].concat(m).join("\n"))},onInit:b.noop,onRefreshing:b.noop,onRefreshed:b.noop,onPageChanged:b.noop,onItemDeleting:b.noop,onItemDeleted:b.noop,onItemInserting:b.noop,onItemInserted:b.noop,onItemEditing:b.noop,onItemUpdating:b.noop,
27onItemUpdated:b.noop,onItemInvalid:b.noop,onDataLoading:b.noop,onDataLoaded:b.noop,onOptionChanging:b.noop,onOptionChanged:b.noop,onSorted:b.noop,onError:b.noop,invalidClass:"jsgrid-invalid",containerClass:"jsgrid",tableClass:"jsgrid-table",gridHeaderClass:"jsgrid-grid-header",gridBodyClass:"jsgrid-grid-body",_init:function(m){b.extend(this,m);this._initLoadStrategy();this._initController();this._initFields();this._attachWindowLoadResize();this._attachWindowResizeCallback();this._callEventHandler(this.onInit)},
28loadStrategy:function(){return this.pageLoading?new jsGrid.loadStrategies.PageLoadingStrategy(this):new jsGrid.loadStrategies.DirectLoadingStrategy(this)},_initLoadStrategy:function(){this._loadStrategy=e(this.loadStrategy,this)},_initController:function(){this._controller=b.extend({},g,e(this.controller,this))},renderTemplate:function(m,n,r){args=[];for(var t in r)args.push(r[t]);args.unshift(m,n);m=e.apply(null,args);return m===c||null===m?"":m},loadIndicator:function(m){return new jsGrid.LoadIndicator(m)},
29validation:function(m){return jsGrid.Validation&&new jsGrid.Validation(m)},_initFields:function(){var m=this;m.fields=b.map(m.fields,function(n){b.isPlainObject(n)&&(n=new (n.type&&jsGrid.fields[n.type]||jsGrid.Field)(n));n._grid=m;return n})},_attachWindowLoadResize:function(){b(a).on("load",b.proxy(this._refreshSize,this))},_attachWindowResizeCallback:function(){if(this.updateOnResize)b(a).on("resize",b.proxy(this._refreshSize,this))},_detachWindowResizeCallback:function(){b(a).off("resize",this._refreshSize)},
30option:function(m,n){if(1===arguments.length)return this[m];var r={option:m,oldValue:this[m],newValue:n};this._callEventHandler(this.onOptionChanging,r);this._handleOptionChange(r.option,r.newValue);this._callEventHandler(this.onOptionChanged,{option:r.option,value:r.newValue})},fieldOption:function(m,n,r){m=this._normalizeField(m);if(2===arguments.length)return m[n];m[n]=r;this._renderGrid()},_handleOptionChange:function(m,n){this[m]=n;switch(m){case "width":case "height":this._refreshSize();break;
31case "rowClass":case "rowRenderer":case "rowClick":case "rowDoubleClick":case "noDataRowClass":case "noDataContent":case "selecting":case "selectedRowClass":case "oddRowClass":case "evenRowClass":this._refreshContent();break;case "pageButtonCount":case "pagerFormat":case "pagePrevText":case "pageNextText":case "pageFirstText":case "pageLastText":case "pageNavigatorNextText":case "pageNavigatorPrevText":case "pagerClass":case "pagerNavButtonClass":case "pageClass":case "currentPageClass":case "pagerRenderer":this._refreshPager();
32break;case "fields":this._initFields();this.render();break;case "data":case "editing":case "heading":case "filtering":case "inserting":case "paging":this.refresh();break;case "loadStrategy":case "pageLoading":this._initLoadStrategy();this.search();break;case "pageIndex":this.openPage(n);break;case "pageSize":this.refresh();this.search();break;case "editRowRenderer":case "editRowClass":this.cancelEdit();break;case "updateOnResize":this._detachWindowResizeCallback();this._attachWindowResizeCallback();
33break;case "invalidNotify":case "invalidMessage":break;default:this.render()}},destroy:function(){this._detachWindowResizeCallback();this._clear();this._container.removeData("JSGrid")},render:function(){this._renderGrid();return this.autoload?this.loadData():b.Deferred().resolve().promise()},_renderGrid:function(){this._clear();this._container.addClass(this.containerClass).css("position","relative").append(this._createHeader()).append(this._createBody());this._pagerContainer=this._createPagerContainer();
34this._loadIndicator=this._createLoadIndicator();
34this._validation=this._createValidation();this.refresh()},_createLoadIndicator:function(){return e(this.loadIndicator,this,{message:this.loadMessage,shading:this.loadShading,container:this._container})},_createValidation:function(){return e(this.validation,this)},_clear:function(){this.cancelEdit();clearTimeout(this._loadingTimer);this._pagerContainer&&this._pagerContainer.empty();this._container.empty().css({position:"",width:"",height:""})},_createHeader:function(){var m=
35this._headerRow=this._createHeaderRow(),n=this._filterRow=this._createFilterRow(),r=this._insertRow=this._createInsertRow();m=this._headerGrid=b("<table>").addClass(this.tableClass).append(m).append(n).append(r);return this._header=b("<div>").addClass(this.gridHeaderClass).addClass(this._scrollBarWidth()?"jsgrid-header-scrollbar":"").append(m)},_createBody:function(){var m=this._content=b("<tbody>");m=this._bodyGrid=b("<table>").addClass(this.tableClass).append(m);return this._body=b("<div>").addClass(this.gridBodyClass).append(m).on("scroll",
36b.proxy(function(n){this._header.scrollLeft(n.target.scrollLeft)},this))},_createPagerContainer:function(){var m=this.pagerContainer||b("<div>").appendTo(this._container);return b(m).addClass(this.pagerContainerClass)},_eachField:function(m){var n=this;b.each(this.fields,function(r,t){t.visible&&m.call(n,t,r)})},_createHeaderRow:function(){if(b.isFunction(this.headerRowRenderer))return b(this.renderTemplate(this.headerRowRenderer,this));var m=b("<tr>").addClass(this.headerRowClass);this._eachField(function(n,
37r){var t=this._prepareCell("<th>",n,"headercss",this.headerCellClass).append(this.renderTemplate(n.headerTemplate,n)).appendTo(m);if(this.sorting&&n.sorting)t.addClass(this.sortableClass).on("click",b.proxy(function(){this.sort(r)},this))});return m},_prepareCell:function(m,n,r,t){return b(m).css("width",n.width).addClass(t||this.cellClass).addClass(r&&n[r]||n.css).addClass(n.align?"jsgrid-align-"+n.align:"")},_createFilterRow:function(){if(b.isFunction(this.filterRowRenderer))return b(this.renderTemplate(this.filterRowRenderer,
38this));var m=b("<tr>").addClass(this.filterRowClass);this._eachField(function(n){this._prepareCell("<td>",n,"filtercss").append(this.renderTemplate(n.filterTemplate,n)).appendTo(m)});return m},_createInsertRow:function(){if(b.isFunction(this.insertRowRenderer))return b(this.renderTemplate(this.insertRowRenderer,this));var m=b("<tr>").addClass(this.insertRowClass);this._eachField(function(n){this._prepareCell("<td>",n,"insertcss").append(this.renderTemplate(n.insertTemplate,n)).appendTo(m)});return m},
39_callEventHandler:function(m,n){m.call(this,b.extend(n,{grid:this}));return n},reset:function(){this._resetSorting();this._resetPager();return this._loadStrategy.reset()},_resetPager:function(){this._firstDisplayingPage=1;this._setPage(1)},_resetSorting:function(){this._sortField=null;this._sortOrder="asc";this._clearSortingCss()},refresh:function(){this._callEventHandler(this.onRefreshing);this.cancelEdit();this._refreshHeading();this._refreshFiltering();this._refreshInserting();this._refreshContent();
40this._refreshPager();this._refreshSize();this._callEventHandler(this.onRefreshed)},_refreshHeading:function(){this._headerRow.toggle(this.heading)},_refreshFiltering:function(){this._filterRow.toggle(this.filtering)},_refreshInserting:function(){this._insertRow.toggle(this.inserting)},_refreshContent:function(){var m=this._content;m.empty();if(!this.data.length)return m.append(this._createNoDataRow()),this;for(var n=this._loadStrategy.firstDisplayIndex(),r=this._loadStrategy.lastDisplayIndex();n<
41r;n++)m.append(this._createRow(this.data[n],n))},_createNoDataRow:function(){var m=0;this._eachField(function(){m++});return b("<tr>").addClass(this.noDataRowClass).append(b("<td>").addClass(this.cellClass).attr("colspan",m).append(this.renderTemplate(this.noDataContent,this)))},_createRow:function(m,n){if(b.isFunction(this.rowRenderer))var r=this.renderTemplate(this.rowRenderer,this,{item:m,itemIndex:n});else r=b("<tr>"),this._renderCells(r,m);r.addClass(this._getRowClasses(m,n)).data("JSGridItem",
42m).on("click",b.proxy(function(t){this.rowClick({item:m,itemIndex:n,event:t})},this)).on("dblclick",b.proxy(function(t){this.rowDoubleClick({item:m,itemIndex:n,event:t})},this));this.selecting&&this._attachRowHover(r);return r},_getRowClasses:function(m,n){var r=[];r.push((n+1)%2?this.oddRowClass:this.evenRowClass);r.push(e(this.rowClass,this,m,n));return r.join(" ")},_attachRowHover:function(m){var n=this.selectedRowClass;m.hover(function(){b(this).addClass(n)},function(){b(this).removeClass(n)})},
43_renderCells:function(m,n){this._eachField(function(r){m.append(this._createCell(n,r))});return this},_createCell:function(m,n){var r=this._getItemFieldValue(m,n);m={value:r,item:m};r=b.isFunction(n.cellRenderer)?this.renderTemplate(n.cellRenderer,n,m):b("<td>").append(this.renderTemplate(n.itemTemplate||r,n,m));return this._prepareCell(r,n)},_getItemFieldValue:function(m,n){n=n.name.split(".");for(m=m[n.shift()];m&&n.length;)m=m[n.shift()];return m},_setItemFieldValue:function(m,n,r){n=n.name.split(".");
44for(var t=m,u=n[0];t&&n.length;)m=t,u=n.shift(),t=m[u];if(!t)for(;n.length;)m=m[u]={},u=n.shift();m[u]=r},sort:function(m,n){b.isPlainObject(m)&&(n=m.order,m=m.field);this._clearSortingCss();this._setSortingParams(m,n);this._setSortingCss();return this._loadStrategy.sort()},_clearSortingCss:function(){this._headerRow.find("th").removeClass(this.sortAscClass).removeClass(this.sortDe
44scClass)},_setSortingParams:function(m,n){m=this._normalizeField(m);n=n||(this._sortField===m?this._reversedSortOrder(this._sortOrder):
45"asc");this._sortField=m;this._sortOrder=n},_normalizeField:function(m){return b.isNumeric(m)?this.fields[m]:"string"===typeof m?b.grep(this.fields,function(n){return n.name===m})[0]:m},_reversedSortOrder:function(m){return"asc"===m?"desc":"asc"},_setSortingCss:function(){var m=this._visibleFieldIndex(this._sortField);this._headerRow.find("th").eq(m).addClass("asc"===this._sortOrder?this.sortAscClass:this.sortDescClass)},_visibleFieldIndex:function(m){return b.inArray(m,b.grep(this.fields,function(n){return n.visible}))},
46_sortData:function(){var m=this._sortFactor(),n=this._sortField;n&&this.data.sort(function(r,t){return m*n.sortingFunc(r[n.name],t[n.name])})},_sortFactor:function(){return"asc"===this._sortOrder?1:-1},_itemsCount:function(){return this._loadStrategy.itemsCount()},_pagesCount:function(){var m=this._itemsCount(),n=this.pageSize;return Math.floor(m/n)+(m%n?1:0)},_refreshPager:function(){var m=this._pagerContainer;m.empty();this.paging&&m.append(this._createPager());var n=this.paging&&1<this._pagesCount();
47m.toggle(n)},_createPager:function(){var m=b.isFunction(this.pagerRenderer)?b(this.pagerRenderer({pageIndex:this.pageIndex,pageCount:this._pagesCount()})):b("<div>").append(this._createPagerByFormat());m.addClass(this.pagerClass);return m},_createPagerByFormat:function(){var m=this.pageIndex,n=this._pagesCount(),r=this._itemsCount(),t=this.pagerFormat.split(" ");return b.map(t,b.proxy(function(u){var x=u;"{pages}"===u?x=this._createPages():"{first}"===u?x=this._createPagerNavButton(this.pageFirstText,
481,1<m):"{prev}"===u?x=this._createPagerNavButton(this.pagePrevText,m-1,1<m):"{next}"===u?x=this._createPagerNavButton(this.pageNextText,m+1,m<n):"{last}"===u?x=this._createPagerNavButton(this.pageLastText,n,m<n):"{pageIndex}"===u?x=m:"{pageCount}"===u?x=n:"{itemCount}"===u&&(x=r);return b.isArray(x)?x.concat([" "]):[x," "]},this))},_createPages:function(){var m=this._pagesCount(),n=this.pageButtonCount,r=this._firstDisplayingPage,t=[];1<r&&t.push(this._createPagerPageNavButton(this.pageNavigatorPrevText,
49this.showPrevPages));for(var u=0,x=r;u<n&&x<=m;u++,x++)t.push(x===this.pageIndex?this._createPagerCurrentPage():this._createPagerPage(x));r+n-1<m&&t.push(this._createPagerPageNavButton(this.pageNavigatorNextText,this.showNextPages));return t},_createPagerNavButton:function(m,n,r){return this._createPagerButton(m,this.pagerNavButtonClass+(r?"":" "+this.pagerNavButtonInactiveClass),r?function(){this.openPage(n)}:b.noop)},_createPagerPageNavButton:function(m,n){return this._createPagerButton(m,this.pagerNavButtonClass,
50n)},_createPagerPage:function(m){return this._createPagerButton(m,this.pageClass,function(){this.openPage(m)})},_createPagerButton:function(m,n,r){m=b("<a>").attr("href","javascript:void(0);").html(m).on("click",b.proxy(r,this));return b("<span>").addClass(n).append(m)},_createPagerCurrentPage:function(){return b("<span>").addClass(this.pageClass).addClass(this.currentPageClass).text(this.pageIndex)},_refreshSize:function(){this._refreshHeight();this._refreshWidth()},_refreshWidth:function(){var m=
51this._headerGrid,n=this._bodyGrid,r=this.width;"auto"===r&&(m.width("auto"),r=m.outerWidth());m.width("");n.width("");this._container.width(r);r=m.outerWidth();n.width(r)},_scrollBarWidth:function(){var m;return function(){if(m===c){var n=b("<div style='width:50px;height:50px;overflow:hidden;position:absolute;top:-10000px;left:-10000px;'></div>"),r=b("<div style='height:100px;'></div>");n.append(r).appendTo("body");var t=r.innerWidth();n.css("overflow-y","auto");r=r.innerWidth();n.remove();m=t-r}return m}}(),
52_refreshHeight:function(){var m=this._container,n=this._pagerContainer,r=this.height;m.height(r);if("auto"!==r){r=m.height();var t=this._header.outerHeight(!0);n.parents(m).length&&(t+=n.outerHeight(!0));this._body.outerHeight(r-t)}},showPrevPages:function(){var m=this._firstDisplayingPage,n=this.pageButtonCount;this._firstDisplayingPage=m>n?m-n:1;this._refreshPager()},showNextPages:function(){var m=this._firstDisplayingPage,n=this.pageButtonCount,r=this._pagesCount();this._firstDisplayingPage=m+
532*n>r?r-n+1:m+n;this._refreshPager()},openPage:function(m){1>m||m>this._pagesCount()||(this._setPage(m),this._loadStrategy.openPage(m))},_setPage:function(m){var n=this._firstDisplayingPage,r=this.pageButtonCount;this.pageIndex=m;m<n&&(this._firstDisplayingPage=m);m>
53n+r-1&&(this._firstDisplayingPage=m-r+1);this._callEventHandler(this.onPageChanged,{pageIndex:m})},_controllerCall:function(m,n,r,t){if(r)return b.Deferred().reject().promise();this._showLoading();r=this._controller;if(!r||!r[m])throw Error("controller has no method '"+
54m+"'");return f(r[m](n)).done(b.proxy(t,this)).fail(b.proxy(this._errorHandler,this)).always(b.proxy(this._hideLoading,this))},_errorHandler:function(){this._callEventHandler(this.onError,{args:b.makeArray(arguments)})},_showLoading:function(){this.loadIndication&&(clearTimeout(this._loadingTimer),this._loadingTimer=setTimeout(b.proxy(function(){this._loadIndicator.show()},this),this.loadIndicationDelay))},_hideLoading:function(){this.loadIndication&&(clearTimeout(this._loadingTimer),this._loadIndicator.hide())},
55search:function(m){this._resetSorting();this._resetPager();return this.loadData(m)},loadData:function(m){m=m||(this.filtering?this.getFilter():{});b.extend(m,this._loadStrategy.loadParams(),this._sortingParams());var n=this._callEventHandler(this.onDataLoading,{filter:m});return this._controllerCall("loadData",m,n.cancel,function(r){r&&(this._loadStrategy.finishLoad(r),this._callEventHandler(this.onDataLoaded,{data:r}))})},getFilter:function(){var m={};this._eachField(function(n){n.filtering&&this._setItemFieldValue(m,
56n,n.filterValue())});return m},_sortingParams:function(){return this.sorting&&this._sortField?{sortField:this._sortField.name,sortOrder:this._sortOrder}:{}},getSorting:function(){var m=this._sortingParams();return{field:m.sortField,order:m.sortOrder}},clearFilter:function(){var m=this._createFilterRow();this._filterRow.replaceWith(m);this._filterRow=m;return this.search()},insertItem:function(m){var n=m||this._getValidatedInsertItem();if(!n)return b.Deferred().reject().promise();m=this._callEventHandler(this.onItemInserting,
57{item:n});return this._controllerCall("insertItem",n,m.cancel,function(r){r=r||n;this._loadStrategy.finishInsert(r);this._callEventHandler(this.onItemInserted,{item:r})})},_getValidatedInsertItem:function(){var m=this._getInsertItem();return this._validateItem(m,this._insertRow)?m:null},_getInsertItem:function(){var m={};this._eachField(function(n){n.inserting&&this._setItemFieldValue(m,n,n.insertValue())});return m},_validateItem:function(m,n){var r=[],t={item:m,itemIndex:this._rowIndex(n),row:n};
58this._eachField(function(x){if(x.validate){var B=this._getItemFieldValue(m,x);B!==c&&(B=this._validation.validate(b.extend({value:B,rules:x.validate},t)),this._setCellValidity(n.children().eq(this._visibleFieldIndex(x)),B),B.length&&r.push.apply(r,b.map(B,function(y){return{field:x,message:y}})))}});if(!r.length)return!0;var u=b.extend({errors:r},t);this._callEventHandler(this.onItemInvalid,u);this.invalidNotify(u);return!1},_setCellValidity:function(m,n){m.toggleClass(this.invalidClass,!!n.length).attr("title",
59n.join("\n"))},clearInsert:function(){var m=this._createInsertRow();this._insertRow.replaceWith(m);this._insertRow=m;this.refresh()},editItem:function(m){m=this.rowByItem(m);m.length&&this._editRow(m)},rowByItem:function(m){return m.jquery||m.nodeType?b(m):this._content.find("tr").filter(function(){return b.data(this,"JSGridItem")===m})},_editRow:function(m){if(this.editing){var n=m.data("JSGridItem");this._callEventHandler(this.onItemEditing,{row:m,item:n,itemIndex:this._itemIndex(n)}).cancel||(this._editingRow&&
60this.cancelEdit(),n=this._createEditRow(n),this._editingRow=m,m.hide(),n.insertBefore(m),m.data("JSGridEditRow",n))}},_createEditRow:function(m){if(b.isFunction(this.editRowRenderer))return b(this.renderTemplate(field.editRowRenderer,field,{item:m,itemIndex:this._itemIndex(m)}));var n=b("<tr>").addClass(this.editRowClass);this._eachField(function(r){var t=this._getItemFieldValue(m,r);this._prepareCell("<td>",r,"editcss").append(this.renderTemplate(r.editTemplate||"",r,{value:t,item:m})).appendTo(n)});
61return n},updateItem:function(m,n){1===arguments.length&&(n=m);var r=m?this.rowByItem(m):this._editingRow;if(n=n||this._getValidatedEditedItem())return this._updateRow(r,n)},_getValidatedEditedItem:function(){var m=this._getEditedItem();
61return this._validateItem(m,this._getEditRow())?m:null},_updateRow:function(m,n){var r=m.data("JSGridItem"),t=this._itemIndex(r),u=b.extend(!0,{},r);b.extend(!0,r,n);n=this._callEventHandler(this.onItemUpdating,{row:m,item:r,itemIndex:t,previousItem:u});return this._controllerCall("updateItem",
62r,n.cancel,function(x){x=x||r;var B=this._finishUpdate(m,x,t);this._callEventHandler(this.onItemUpdated,{row:B,item:x,itemIndex:t,previousItem:u})})},_rowIndex:function(m){return this._content.children().index(b(m))},_itemIndex:function(m){return b.inArray(m,this.data)},_finishUpdate:function(m,n,r){this.cancelEdit();this.data[r]=n;n=this._createRow(n,r);m.replaceWith(n);return n},_getEditedItem:function(){var m={};this._eachField(function(n){n.editing&&this._setItemFieldValue(m,n,n.editValue())});
63return m},cancelEdit:function(){this._editingRow&&(this._getEditRow().remove(),this._editingRow.show(),this._editingRow=null)},_getEditRow:function(){return this._editingRow.data("JSGridEditRow")},deleteItem:function(m){m=this.rowByItem(m);if(m.length&&(!this.confirmDeleting||a.confirm(e(this.deleteConfirm,this,m.data("JSGridItem")))))return this._deleteRow(m)},_deleteRow:function(m){var n=m.data("JSGridItem"),r=this._itemIndex(n),t=this._callEventHandler(this.onItemDeleting,{row:m,item:n,itemIndex:r});
64return this._controllerCall("deleteItem",n,t.cancel,function(){this._loadStrategy.finishDelete(n,r);this._callEventHandler(this.onItemDeleted,{row:m,item:n,itemIndex:r})})}};b.fn.jsGrid=function(m){var n=b.makeArray(arguments).slice(1),r=this;this.each(function(){var t=b(this),u=t.data("JSGrid");if(u)if("string"===typeof m){if(t=u[m].apply(u,n),t!==c&&t!==u)return r=t,!1}else u._detachWindowResizeCallback(),u._init(m),u.render();else new d(t,m)});return r};var h={},k={},l=function(m,n){b.each(n,function(r,
65t){b.isPlainObject(t)?l(m[r]||m[r[0].toUpperCase()+r.slice(1)],t):m.hasOwnProperty(r)?m[r]=t:m.prototype[r]=t})};a.jsGrid={Grid:d,fields:h,setDefaults:function(m,n){if(b.isPlainObject(m))var r=d.prototype;else r=h[m].prototype,m=n||{};b.extend(r,m)},locales:k,locale:function(m){var n=b.isPlainObject(m)?m:k[m];if(!n)throw Error("unknown locale "+m);l(jsGrid,n)},version:"1.5.2"}})(window,jQuery);
66(function(a,b,c){function d(e){this._init(e)}d.prototype={container:"body",message:"Loading...",shading:!0,zIndex:1E3,shaderClass:"jsgrid-load-shader",loadPanelClass:"jsgrid-load-panel",_init:function(e){b.extend(!0,this,e);this._initContainer();this._initShader();this._initLoadPanel()},_initContainer:function(){this._container=b(this.container)},_initShader:function(){this.shading&&(this._shader=b("<div>").addClass(this.shaderClass).hide().css({position:"absolute",top:0,right:0,bottom:0,left:0,zIndex:this.zIndex}).appendTo(this._container))},
67_initLoadPanel:function(){this._loadPanel=b("<div>").addClass(this.loadPanelClass).text(this.message).hide().css({position:"absolute",top:"50%",left:"50%",zIndex:this.zIndex}).appendTo(this._container)},show:function(){var e=this._loadPanel.show(),f=e.outerWidth(),g=e.outerHeight();e.css({marginTop:-g/2,marginLeft:-f/2});this._shader.show()},hide:function(){this._loadPanel.hide();this._shader.hide()}};a.LoadIndicator=d})(jsGrid,jQuery);
68(function(a,b,c){function d(f){this._grid=f}function e(f){this._grid=f;this._itemsCount=0}d.prototype={firstDisplayIndex:function(){var f=this._grid;return f.option("paging")?(f.option("pageIndex")-1)*f.option("pageSize"):0},lastDisplayIndex:function(){var f=this._grid,g=f.option("data").length;return f.option("paging")?Math.min(f.option("pageIndex")*f.option("pageSize"),g):g},itemsCount:function(){return this._grid.option("data").length},openPage:function(f){this._grid.refresh()},loadParams:function(){return{}},
69sort:function(){this._grid._sortData();this._grid.refresh();this._grid.onSorted&&this._grid._callEventHandler(this._grid.onSorted,{});return b.Deferred().resolve().promise()},reset:function(){this._grid.refresh();return b.Deferred().resolve().promise()},finishLoad:function(f){this._grid.option("data",f)},finishInsert:function(f){var g=this._grid;g.option("data").push(f);g.refresh()},finishDelete:function(f,g){f=this._grid;f.option("data").splice(g,1);f.reset()}};e.prototype={firstDisplayIndex:function(){return 0},
70lastDisplayIndex:function(){return this._grid.option("data").length},itemsCount:function(){return this._itemsCount}
70,openPage:function(f){this._grid.loadData()},loadParams:function(){var f=this._grid;return{pageIndex:f.option("pageIndex"),pageSize:f.option("pageSize")}},reset:function(){return this._grid.loadData()},sort:function(){return this._grid.loadData()},finishLoad:function(f){this._itemsCount=f.itemsCount;this._grid.option("data",f.data)},finishInsert:function(f){this._grid.search()},finishDelete:function(f,
71g){this._grid.search()}};a.loadStrategies={DirectLoadingStrategy:d,PageLoadingStrategy:e}})(jsGrid,jQuery);(function(a,b,c){var d=function(e){return"undefined"!==typeof e&&null!==e};a.sortStrategies={string:function(e,f){return d(e)||d(f)?d(e)?d(f)?(""+e).localeCompare(""+f):1:-1:0},number:function(e,f){return e-f},date:function(e,f){return e-f},numberAsString:function(e,f){return parseFloat(e)-parseFloat(f)}}})(jsGrid,jQuery);
72(function(a,b,c){function d(f){this._init(f)}d.prototype={_init:function(f){b.extend(!0,this,f)},validate:function(f){var g=[];b.each(this._normalizeRules(f.rules),function(h,k){k.validator(f.value,f.item,k.param)||(h=b.isFunction(k.message)?k.message(f.value,f.item):k.message,g.push(h))});return g},_normalizeRules:function(f){b.isArray(f)||(f=[f]);return b.map(f,b.proxy(function(g){return this._normalizeRule(g)},this))},_normalizeRule:function(f){"string"===typeof f&&(f={validator:f});b.isFunction(f)&&
73(f={validator:f});if(b.isPlainObject(f))f=b.extend({},f);else throw Error("wrong validation config specified");return b.isFunction(f.validator)?f:this._applyNamedValidator(f,f.validator)},_applyNamedValidator:function(f,g){delete f.validator;var h=e[g];if(!h)throw Error('unknown validator "'+g+'"');b.isFunction(h)&&(h={validator:h});return b.extend({},h,f)}};a.Validation=d;var e={required:{message:"Field is required",validator:function(f){return f!==c&&null!==f&&""!==f}},rangeLength:{message:"Field value length is out of the defined range",
74validator:function(f,g,h){return f.length>=h[0]&&f.length<=h[1]}},minLength:{message:"Field value is too short",validator:function(f,g,h){return f.length>=h}},maxLength:{message:"Field value is too long",validator:function(f,g,h){return f.length<=h}},pattern:{message:"Field value is not matching the defined pattern",validator:function(f,g,h){"string"===typeof h&&(h=new RegExp("^(?:"+h+")$"));return h.test(f)}},range:{message:"Field value is out of the defined range",validator:function(f,g,h){return f>=
75h[0]&&f<=h[1]}},min:{message:"Field value is too small",validator:function(f,g,h){return f>=h}},max:{message:"Field value is too large",validator:function(f,g,h){return f<=h}}};a.validators=e})(jsGrid,jQuery);
76(function(a,b,c){function d(e){b.extend(!0,this,e);this.sortingFunc=this._getSortingFunc()}d.prototype={name:"",title:null,css:"",align:"",width:100,visible:!0,filtering:!0,inserting:!0,editing:!0,sorting:!0,sorter:"string",headerTemplate:function(){return this.title===c||null===this.title?this.name:this.title},itemTemplate:function(e,f){return e},filterTemplate:function(){return""},insertTemplate:function(){return""},editTemplate:function(e,f){this._value=e;return this.itemTemplate(e,f)},filterValue:function(){return""},
77insertValue:function(){return""},editValue:function(){return this._value},_getSortingFunc:function(){var e=this.sorter;if(b.isFunction(e))return e;if("string"===typeof e)return a.sortStrategies[e];throw Error('wrong sorter for the field "'+this.name+'"!');}};a.Field=d})(jsGrid,jQuery);
78(function(a,b,c){function d(f){e.call(this,f)}var e=a.Field;d.prototype=new e({autosearch:!0,readOnly:!1,filterTemplate:function(){if(!this.filtering)return"";var f=this._grid,g=this.filterControl=this._createTextBox();if(this.autosearch)g.on("keypress",function(h){13===h.which&&(f.search(),h.preventDefault())});return g},insertTemplate:function(){return this.inserting?this.insertControl=this._createTextBox():""},editTemplate:function(f){if(!this.editing)return this.itemTemplate(f);var g=this.editControl=
79this._createTextBox();g.val(f);return g},filterValue:function(){return this.filterControl.val()},insertValue:function(){return this.insertControl.val()},editValue:function(){return this.editControl.val()},_createTextBox:function(){return b("<input>").attr("type","text").prop("readonly",!!this.readOnly)}});a.fields.text=a.TextField=d})(jsGrid,jQuery);
80(function(a,b,c){function d(f){e.call(this,f)}var e=a.TextField;d.prototype=new e({sorter:"number",align:"right",readOnly:!1,filterValue:function(){return parseInt(this.filterControl.val()||0,10)},insertValue:function(){return parseInt(this.insertControl.val()||0,10)},editValue:function(){return parseInt(this.editControl.val()||0,10)},_createTextBox:function(){return b("<input>").attr("type","number").prop("readonly",!!this.readOnly)}});a.fields.number=a.NumberField=d})(jsGrid,jQuery);
81(function(a,b,c){function d(f){e.call(this,f)}var e=a.TextField;d.prototype=new e({insertTemplate:function(){return this.inserting?this.insertControl=this._createTextArea():""},editTemplate:function(f){if(!this.editing)return this.itemTemplate(f);var g=this.editControl=this._createTextArea();g.val(f);return g},_createTextArea:function(){return b("<textarea>").prop("readonly",!!this.readOnly)}});a.fields.textarea=a.TextAreaField=d})(jsGrid,jQuery);
82(function(a,b,c){function d(f){this.items=[];this.selectedIndex=-1;this.textField=this.valueField="";f.valueField&&f.items.length&&(this.valueType="number"===typeof f.items[0][f.valueField]?"number":"string");this.sorter=this.valueType;e.call(this,f)}var e=a.NumberField;d.prototype=new e({align:"center",valueType:"number",itemTemplate:function(f){var g=this.items,h=this.valueField,k=this.textField;g=h?b.grep(g,function(l,m){return l[h]===f})[0]||{}:g[f];k=k?g[k]:g;return k===c||null===k?"":k},filterTemplate:function(){if(!this.filtering)return"";
83var f=this._grid,g=this.filterControl=this._createSelect();if(this.autosearch)g.on("change",function(h){f.search()});return g},insertTemplate:function(){return this.inserting?this.insertControl=this._createSelect():""},editTemplate:function(f){if(!this.editing)return this.itemTemplate(f);var g=this.editControl=this._createSelect();f!==c&&g.val(f);return g},filterValue:function(){var f=this.filterControl.val();return"number"===this.valueType?parseInt(f||0,10):f},insertValue:function(){var f=this.insertControl.val();
84return"number"===this.valueType?parseInt(f||0,10):f},editValue:function(){var f=this.editControl.val();return"number"===this.valueType?parseInt(f||0,10):f},_createSelect:function(){var f=b("<select>"),g=this.valueField,h=this.textField,k=this.selectedIndex;b.each(this.items,function(l,m){var n=g?m[g]:l;m=h?m[h]:m;b("<option>").attr("value",n).text(m).appendTo(f).prop("selected",k===l)});f.prop("disabled",!!this.readOnly);return f}});a.fields.select=a.SelectField=d})(jsGrid,jQuery);
85(function(a,b,c){function d(f){e.call(this,f)}var e=a.Field;d.prototype=new e({sorter:"number",align:"center",autosearch:!0,itemTemplate:function(f){return this._createCheckbox().prop({checked:f,disabled:!0})},filterTemplate:function(){if(!this.filtering)return"";var f=this._grid,g=this.filterControl=this._createCheckbox();g.prop({readOnly:!0,indeterminate:!0});g.on("click",function(){var h=b(this);h.prop("readOnly")?h.prop({checked:!1,readOnly:!1}):h.prop("checked")||h.prop({readOnly:!0,indeterminate:!0})});
86if(this.autosearch)g.on("click",function(){f.search()});return g},insertTemplate:function(){return this.inserting?this.insertControl=this._createCheckbox():""},editTemplate:function(f){if(!this.editing)return this.itemTemplate(f);var g=this.editControl=this._createCheckbox();g.prop("checked",f);return g},filterValue:function(){return this.filterControl.get(0).indeterminate?c:this.filterControl.is(":checked")},insertValue:function(){return this.insertControl.is(":checked")},editValue:function(){return this.editControl.is(":checked")},
87_createCheckbox:function(){return b("<input>").attr("type","checkbox")}
87});a.fields.checkbox=a.CheckboxField=d})(jsGrid,jQuery);
88(function(a,b,c){function d(f){e.call(this,f);this._configInitialized=!1}var e=a.Field;d.prototype=new e({css:"jsgrid-control-field",align:"center",width:50,filtering:!1,inserting:!1,editing:!1,sorting:!1,buttonClass:"jsgrid-button",modeButtonClass:"jsgrid-mode-button",modeOnButtonClass:"jsgrid-mode-on-button",searchModeButtonClass:"jsgrid-search-mode-button",insertModeButtonClass:"jsgrid-insert-mode-button",editButtonClass:"jsgrid-edit-button",deleteButtonClass:"jsgrid-delete-button",searchButtonClass:"jsgrid-search-button",
89clearFilterButtonClass:"jsgrid-clear-filter-button",insertButtonClass:"jsgrid-insert-button",updateButtonClass:"jsgrid-update-button",cancelEditButtonClass:"jsgrid-cancel-edit-button",searchModeButtonTooltip:"Switch to searching",insertModeButtonTooltip:"Switch to inserting",editButtonTooltip:"Edit",deleteButtonTooltip:"Delete",searchButtonTooltip:"Search",clearFilterButtonTooltip:"Clear filter",insertButtonTooltip:"Insert",updateButtonTooltip:"Update",cancelEditButtonTooltip:"Cancel edit",editButton:!0,
90deleteButton:!0,clearFilterButton:!0,modeSwitchButton:!0,_initConfig:function(){this._hasFiltering=this._grid.filtering;(this._hasInserting=this._grid.inserting)&&this.modeSwitchButton&&(this._grid.inserting=!1);this._configInitialized=!0},headerTemplate:function(){this._configInitialized||this._initConfig();var f=this._hasFiltering,g=this._hasInserting;return this.modeSwitchButton&&(f||g)?f&&!g?this._createFilterSwitchButton():g&&!f?this._createInsertSwitchButton():this._createModeSwitchButton():
91""},itemTemplate:function(f,g){f=b([]);this.editButton&&(f=f.add(this._createEditButton(g)));this.deleteButton&&(f=f.add(this._createDeleteButton(g)));return f},filterTemplate:function(){var f=this._createSearchButton();return this.clearFilterButton?f.add(this._createClearFilterButton()):f},insertTemplate:function(){return this._createInsertButton()},editTemplate:function(){return this._createUpdateButton().add(this._createCancelEditButton())},_createFilterSwitchButton:function(){return this._createOnOffSwitchButton("filtering",
92this.searchModeButtonClass,!0)},_createInsertSwitchButton:function(){return this._createOnOffSwitchButton("inserting",this.insertModeButtonClass,!1)},_createOnOffSwitchButton:function(f,g,h){var k=h,l=b.proxy(function(){m.toggleClass(this.modeOnButtonClass,k)},this),m=this._createGridButton(this.modeButtonClass+" "+g,"",function(n){k=!k;n.option(f,k);l()});l();return m},_createModeSwitchButton:function(){var f=!1,g=b.proxy(function(){h.attr("title",f?this.searchModeButtonTooltip:this.insertModeButtonTooltip).toggleClass(this.insertModeButtonClass,
93!f).toggleClass(this.searchModeButtonClass,f)},this),h=this._createGridButton(this.modeButtonClass,"",function(k){f=!f;k.option("inserting",f);k.option("filtering",!f);g()});g();return h},_createEditButton:function(f){return this._createGridButton(this.editButtonClass,this.editButtonTooltip,function(g,h){g.editItem(f);h.stopPropagation()})},_createDeleteButton:function(f){return this._createGridButton(this.deleteButtonClass,this.deleteButtonTooltip,function(g,h){g.deleteItem(f);h.stopPropagation()})},
94_createSearchButton:function(){return this._createGridButton(this.searchButtonClass,this.searchButtonTooltip,function(f){f.search()})},_createClearFilterButton:function(){return this._createGridButton(this.clearFilterButtonClass,this.clearFilterButtonTooltip,function(f){f.clearFilter()})},_createInsertButton:function(){return this._createGridButton(this.insertButtonClass,this.insertButtonTooltip,function(f){f.insertItem().done(function(){f.clearInsert()})})},_createUpdateButton:function(){return this._createGridButton(this.updateButtonClass,
95this.updateButtonTooltip,function(f,g){f.updateItem();g.stopPropagation()})},_createCancelEditButton:function(){return this._createGridButton(this.cancelEditButtonClass,this.cancelEditButtonTooltip,function(f,g){f.cancelEdit();g.stopPropagation()})},_createGridButton:function(f,g,h){var k=this._grid;return b("<input>").addClass(this.buttonClass).addClass(f).attr({type:"button",title:g}).on("click",function(l){h(k,l)})},editValue:function(){return""}});a.fields.control=a.ControlField=d})(jsGrid,jQuery);
96var oldBrowser=document.all&&!document.addEventListener;
97oldBrowser||function(a,b){function c(w){var M=ua[w]={};I.each(w.split(db),function(Y,ka){M[ka]=!0});return M}function d(w,M,Y){if(Y===b&&1===w.nodeType)if(Y="data-"+M.replace(Da,"-$1").toLowerCase(),Y=w.getAttribute(Y),"string"===typeof Y){try{Y="true"===Y?!0:"false"===Y?!1:"null"===Y?null:+Y+""===Y?+Y:wa.test(Y)?I.parseJSON(Y):Y}catch(ka){}I.data(w,M,Y)}else Y=b;return Y}function e(w){for(var M in w)if(("data"!==M||!I.isEmptyObject(w[M]))&&"toJSON"!==M)return!1;return!0}function f(){return!1}function g(){return!0}
98function h(w){return!w||!w.parentNode||11===w.parentNode.nodeType}function k(w,M){do w=w[M];while(w&&1!==w.nodeType);return w}function l(w,M,Y){M=M||0;if(I.isFunction(M))return I.grep(w,function(pa,oa){return!!M.call(pa,oa,pa)===Y});if(M.nodeType)return I.grep(w,function(pa,oa){return pa===M===Y});if("string"===typeof M){var ka=I.grep(w,function(pa){return 1===pa.nodeType});if(Xa.test(M))return I.filter(M,ka,!Y);M=I.filter(M,ka)}return I.grep(w,function(pa,oa){return 0<=I.inArray(pa,M)===Y})}function m(w){var M=
99ob.split("|");w=w.createDocumentFragment();if(w.createElement)for(;M.length;)w.createElement(M.pop());return w}function n(w,M){return w.getElementsByTagName(M)[0]||w.appendChild(w.ownerDocument.createElement(M))}function r(w,M){if(1===M.nodeType&&I.hasData(w)){var Y,ka;var pa=I._data(w);w=I._data(M,pa);var oa=pa.events;if(oa)for(Y in delete w.handle,w.events={},oa)for(pa=0,ka=oa[Y].length;pa<ka;pa++)I.event.add(M,Y,oa[Y][pa]);w.data&&(w.data=I.extend({},w.data))}}function t(w,M){if(1===M.nodeType){M.clearAttributes&&
100M.clearAttributes();M.mergeAttributes&&M.mergeAttributes(w);var Y=M.nodeName.toLowerCase();"object"===Y?(M.parentNode&&(M.outerHTML=w.outerHTML),I.support.html5Clone&&w.innerHTML&&!I.trim(M.innerHTML)&&(M.innerHTML=w.innerHTML)):"input"===Y&&pc.test(w.type)?(M.defaultChecked=M.checked=w.checked,M.value!==w.value&&(M.value=w.value)):"option"===Y?M.selected=w.defaultSelected:"input"===Y||"textarea"===Y?M.defaultValue=w.defaultValue:"script"===Y&&M.text!==w.text&&(M.text=w.text);M.removeAttribute(I.expando)}}
101function u(w){return"undefined"!==typeof w.getElementsByTagName?w.getElementsByTagName("*"):"undefined"!==typeof w.querySelectorAll?w.querySelectorAll("*"):[]}function x(w){pc.test(w.type)&&(w.defaultChecked=w.checked)}function B(w,M){if(M in w)return M;for(var Y=M.charAt(0).toUpperCase()+M.slice(1),ka=M,pa=zb.length;pa--;)if(M=zb[pa]+Y,M in w)return M;return ka}function y(w,M){w=M||w;
101return"none"===I.css(w,"display")||!I.contains(w.ownerDocument,w)}function A(w,M){for(var Y,ka,pa=[],oa=0,Ha=w.length;oa<
102Ha;oa++)Y=w[oa],Y.style&&(pa[oa]=I._data(Y,"olddisplay"),M?(pa[oa]||"none"!==Y.style.display||(Y.style.display=""),""===Y.style.display&&y(Y)&&(pa[oa]=I._data(Y,"olddisplay",V(Y.nodeName)))):(ka=Lb(Y,"display"),pa[oa]||"none"===ka||I._data(Y,"olddisplay",ka)));for(oa=0;oa<Ha;oa++)Y=w[oa],!Y.style||M&&"none"!==Y.style.display&&""!==Y.style.display||(Y.style.display=M?pa[oa]||"":"none");return w}function aa(w,M,Y){return(w=$b.exec(M))?Math.max(0,w[1]-(Y||0))+(w[2]||"px"):M}function ha(w,M,Y,ka){M=Y===
103(ka?"border":"content")?4:"width"===M?1:0;for(var pa=0;4>M;M+=2)"margin"===Y&&(pa+=I.css(w,Y+pb[M],!0)),ka?("content"===Y&&(pa-=parseFloat(Lb(w,"padding"+pb[M]))||0),"margin"!==Y&&(pa-=parseFloat(Lb(w,"border"+pb[M]+"Width"))||0)):(pa+=parseFloat(Lb(w,"padding"+pb[M]))||0,"padding"!==Y&&(pa+=parseFloat(Lb(w,"border"+pb[M]+"Width"))||0));return pa}function z(w,M,Y){var ka="width"===M?w.offsetWidth:w.offsetHeight,pa=!0,oa=I.support.boxSizing&&"border-box"===I.css(w,"boxSizing");if(0>=ka||null==ka){ka=
104Lb(w,M);if(0>ka||null==ka)ka=w.style[M];if(dc.test(ka))return ka;pa=oa&&(I.support.boxSizingReliable||ka===w.style[M]);ka=parseFloat(ka)||0}return ka+ha(w,M,Y||(oa?"border":"content"),pa)+"px"}function V(w){if(Ia[w])return Ia[w];var M=I("<"+w+">").appendTo(na.body),Y=M.css("display");M.remove();if("none"===Y||""===Y)Wb=na.body.appendChild(Wb||I.extend(na.createElement("iframe"),{frameBorder:0,width:0,height:0})),Xb&&Wb.createElement||(Xb=(Wb.contentWindow||Wb.contentDocument).document,Xb.write("<!doctype html><html><body>"),
105Xb.close()),M=Xb.body.appendChild(Xb.createElement(w)),Y=Lb(M,"display"),na.body.removeChild(Wb);return Ia[w]=Y}function ba(w,M,Y,ka){var pa;if(I.isArray(M))I.each(M,function(oa,Ha){Y||ac.test(w)?ka(w,Ha):ba(w+"["+("object"===typeof Ha?oa:"")+"]",Ha,Y,ka)});else if(Y||"object"!==I.type(M))ka(w,M);else for(pa in M)ba(w+"["+pa+"]",M[pa],Y,ka)}function v(){setTimeout(function(){sc=b},0);return sc=I.now()}function K(w,M){I.each(M,function(Y,ka){for(var pa=(xc[Y]||[]).concat(xc["*"]),oa=0,Ha=pa.length;oa<
106Ha&&!pa[oa].call(w,Y,ka);oa++);})}function C(w,M,Y){var ka=0,pa=Ac.length,oa=I.Deferred().always(function(){delete Ha.elem}),Ha=function(){var Va=sc||v();Va=Math.max(0,Ma.startTime+Ma.duration-Va);for(var lb=1-(Va/Ma.duration||0),gb=0,mb=Ma.tweens.length;gb<mb;gb++)Ma.tweens[gb].run(lb);oa.notifyWith(w,[Ma,lb,Va]);if(1>lb&&mb)return Va;oa.resolveWith(w,[Ma]);return!1},Ma=oa.promise({elem:w,props:I.extend({},M),opts:I.extend(!0,{specialEasing:{}},Y),originalProperties:M,originalOptions:Y,startTime:sc||
107v(),duration:Y.duration,tweens:[],createTween:function(Va,lb,gb){Va=I.Tween(w,Ma.opts,Va,lb,Ma.opts.specialEasing[Va]||Ma.opts.easing);Ma.tweens.push(Va);return Va},stop:function(Va){for(var lb=0,gb=Va?Ma.tweens.length:0;lb<gb;lb++)Ma.tweens[lb].run(1);Va?oa.resolveWith(w,[Ma,Va]):oa.rejectWith(w,[Ma,Va]);return this}});Y=Ma.props;for(da(Y,Ma.opts.specialEasing);ka<pa;ka++)if(M=Ac[ka].call(Ma,w,Y,Ma.opts))return M;K(Ma,Y);I.isFunction(Ma.opts.start)&&Ma.opts.start.call(w,Ma);I.fx.timer(I.extend(Ha,
108{anim:Ma,queue:Ma.opts.queue,elem:w}));return Ma.progress(Ma.opts.progress).done(Ma.opts.done,Ma.opts.complete).fail(Ma.opts.fail).always(Ma.opts.always)}function da(w,M){var Y,ka;for(Y in w){var pa=I.camelCase(Y);var oa=M[pa];var Ha=w[Y];I.isArray(Ha)&&(oa=Ha[1],Ha=w[Y]=Ha[0]);Y!==pa&&(w[pa]=Ha,delete w[Y]);if((ka=I.cssHooks[pa])&&"expand"in ka)for(Y in Ha=ka.expand(Ha),delete w[pa],Ha)Y in w||(w[Y]=Ha[Y],M[Y]=oa);else M[pa]=oa}}function ja(w,M,Y,ka,pa){return new ja.prototype.init(w,M,Y,ka,pa)}
109function ea(w,M){var Y={height:w},ka=0;for(M=M?1:0;4>ka;ka+=2-M){var pa=pb[ka];Y["margin"+pa]=Y["padding"+pa]=w}M&&(Y.opacity=Y.width=w);return Y}function ra(w){return I.isWindow(w)?w:9===w.nodeType?w.defaultView||w.parentWindow:!1}var za,na=a.document,qa=a.navigator,Ba=a.JQXLite,Ua=a.$,Ja=Array.prototype.push,Pa=Array.prototype.slice,Ca=Array.prototype.indexOf,xa=Object.prototype.toString,Fa=Object.prototype.hasOwnProperty,Na=String.prototype.trim,I=function(w,M){return new I.fn.init(w,M,ma)},Ta=
110/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,Sa=/\S/,db=/\s+/,ab=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,Oa=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,Ga=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,la=/^[\],:{}\s]*$/,ta=/(?:^|:|,)(?:\s*\[)+/g,va=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,p=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,E=/^-ms-/,L=/-([\da-z])/gi,ca=function(w,M){return(M+"").toUpperCase()},fa=function(){na.addEventListener?(na.removeEventListener("DOMContentLoaded",fa,!1),I.ready()):
111"complete"===na.readyState&&(na.detachEvent("onreadystatechange",fa),I.ready())},ia={};I.fn=I.prototype={constructor:I,init:function(w,M,Y){if(!w)return this;if(w.nodeType)return this.context=this[0]=w,this.length=1,this;if("string"===typeof w){var ka="<"===w.charAt(0)&&">"===w.charAt(w.length-1)&&3<=w.length?[null,w,null]:Oa.exec(w);if(!ka||!ka[1]&&M)return!M||M.jqx?(M||Y).find(w):this.constructor(M).find(w);if(ka[1])return w=(M=M instanceof I?M[0]:M)&&M.nodeType?M.ownerDocument||M:na,w=I.parseHTML(ka[1],
112w,!0),Ga.test(ka[1])&&I.isPlainObject(M)&&this.attr.call(w,M,!0),I.merge(this,w);if((M=na.getElementById(ka[2]))&&M.parentNode){if(M.id!==ka[2])return Y.find(w);this.length=1;this[0]=M}this.context=na;this.selector=w;return this}if(I.isFunction(w))return Y.ready(w);w.selector!==b&&(this.selector=w.selector,this.context=w.context);return I.makeArray(w,this)},selector:"",jqx:"4.5.0",length:0,size:function(){return this.length},toArray:function(){return Pa.call(this)},get:function(w){return null==w?
113this.toArray():0>w?this[this.length+w]:this[w]},pushStack:function(w,M,Y){w=I.merge(this.constructor(),w);w.prevObject=this;w.context=this.context;"find"===M?w.selector=this.selector+(this.selector?" ":"")+Y:M&&(w.selector=this.selector+"."+M+"("+Y+")");return w},each:function(w,M){return I.each(this,w,M)},ready:function(w){I.ready.promise().done(w);return this}
113,eq:function(w){w=+w;return-1===w?this.slice(w):this.slice(w,w+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},
114slice:function(){return this.pushStack(Pa.apply(this,arguments),"slice",Pa.call(arguments).join(","))},map:function(w){return this.pushStack(I.map(this,function(M,Y){return w.call(M,Y,M)}))},end:function(){return this.prevObject||this.constructor(null)},push:Ja,sort:[].sort,splice:[].splice};I.fn.init.prototype=I.fn;I.extend=I.fn.extend=function(){var w,M,Y,ka=arguments[0]||{},pa=1,oa=arguments.length,Ha=!1;"boolean"===typeof ka&&(Ha=ka,ka=arguments[1]||{},pa=2);"object"===typeof ka||I.isFunction(ka)||
115(ka={});oa===pa&&(ka=this,--pa);for(;pa<oa;pa++)if(null!=(w=arguments[pa]))for(M in w){var Ma=ka[M];var Va=w[M];ka!==Va&&(Ha&&Va&&(I.isPlainObject(Va)||(Y=I.isArray(Va)))?(Y?(Y=!1,Ma=Ma&&I.isArray(Ma)?Ma:[]):Ma=Ma&&I.isPlainObject(Ma)?Ma:{},ka[M]=I.extend(Ha,Ma,Va)):Va!==b&&(ka[M]=Va))}return ka};I.extend({noConflict:function(w){a.$===I&&(a.$=Ua);w&&a.JQXLite===I&&(a.JQXLite=Ba);return I},isReady:!1,readyWait:1,holdReady:function(w){w?I.readyWait++:I.ready(!0)},ready:function(w){if(!0===w?!--I.readyWait:
116!I.isReady){if(!na.body)return setTimeout(I.ready,1);I.isReady=!0;!0!==w&&0<--I.readyWait||(za.resolveWith(na,[I]),I.fn.trigger&&I(na).trigger("ready").off("ready"))}},isFunction:function(w){return"function"===I.type(w)},isArray:Array.isArray||function(w){return"array"===I.type(w)},isWindow:function(w){return null!=w&&w==w.window},isNumeric:function(w){return!isNaN(parseFloat(w))&&isFinite(w)},type:function(w){return null==w?String(w):ia[xa.call(w)]||"object"},isPlainObject:function(w){if(!w||"object"!==
117I.type(w)||w.nodeType||I.isWindow(w))return!1;try{if(w.constructor&&!Fa.call(w,"constructor")&&!Fa.call(w.constructor.prototype,"isPrototypeOf"))return!1}catch(Y){return!1}for(var M in w);return M===b||Fa.call(w,M)},isEmptyObject:function(w){for(var M in w)return!1;return!0},error:function(w){throw Error(w);},parseHTML:function(w,M,Y){var ka;if(!w||"string"!==typeof w)return null;"boolean"===typeof M&&(Y=M,M=0);M=M||na;if(ka=Ga.exec(w))return[M.createElement(ka[1])];ka=I.buildFragment([w],M,Y?null:
118[]);return I.merge([],(ka.cacheable?I.clone(ka.fragment):ka.fragment).childNodes)},parseJSON:function(w){if(!w||"string"!==typeof w)return null;w=I.trim(w);if(a.JSON&&a.JSON.parse)return a.JSON.parse(w);if(la.test(w.replace(va,"@").replace(p,"]").replace(ta,"")))return(new Function("return "+w))();I.error("Invalid JSON: "+w)},parseXML:function(w){if(!w||"string"!==typeof w)return null;try{if(a.DOMParser){var M=new DOMParser;var Y=M.parseFromString(w,"text/xml")}else Y=new ActiveXObject("Microsoft.XMLDOM"),
119Y.async="false",Y.loadXML(w)}catch(ka){Y=b}Y&&Y.documentElement&&!Y.getElementsByTagName("parsererror").length||I.error("Invalid XML: "+w);return Y},noop:function(){},globalEval:function(w){w&&Sa.test(w)&&(a.execScript||function(M){a.eval.call(a,M)})(w)},camelCase:function(w){return w.replace(E,"ms-").replace(L,ca)},nodeName:function(w,M){return w.nodeName&&w.nodeName.toLowerCase()===M.toLowerCase()},each:function(w,M,Y){var ka,pa=0,oa=w.length,Ha=oa===b||I.isFunction(w);if(Y)if(Ha)for(ka in w){if(!1===
120M.apply(w[ka],Y))break}else for(;pa<oa&&!1!==M.apply(w[pa++],Y););else if(Ha)for(ka in w){if(!1===M.call(w[ka],ka,w[ka]))break}else for(;pa<oa&&!1!==M.call(w[pa],pa,w[pa++]););return w},trim:Na&&!Na.call("\ufeff\u00a0")?function(w){return null==w?"":Na.call(w)}:function(w){return null==w?"":(w+"").replace(ab,"")},makeArray:function(w,M){var Y=M||[];null!=w&&(M=I.type(w),null==w.length||"string"===M||"function"===M||"regexp"===M||I.isWindow(w)?Ja.call(Y,w):I.merge(Y,w));return Y},inArray:function(w,
121M,Y){if(M){if(Ca)return Ca.call(M,w,Y);var ka=M.length;for(Y=Y?0>Y?Math.max(0,ka+Y):Y:0;Y<ka;Y++)if(Y in M&&M[Y]===w)return Y}return-1},merge:function(w,M){var Y=M.length,ka=w.length,pa=0;if("number"===typeof Y)for(;pa<Y;pa++)w[ka++]=M[pa];else for(;M[pa]!==b;)w[ka++]=M[pa++];w.length=ka;return w},grep:function(w,M,Y){var ka=[],pa=0,oa=w.length;for(Y=!!Y;pa<oa;pa++){var Ha=!!M(w[pa],pa);Y!==Ha&&ka.push(w[pa])}return ka},map:function(w,M,Y){var ka,pa=[],oa=0,Ha=w.length;if(w instanceof I||Ha!==b&&
122"number"===typeof Ha&&(0<Ha&&w[0]&&w[Ha-1]||0===Ha||I.isArray(w)))for(;oa<Ha;oa++){var Ma=M(w[oa],oa,Y);null!=Ma&&(pa[pa.length]=Ma)}else for(ka in w)Ma=M(w[ka],ka,Y),null!=Ma&&(pa[pa.length]=Ma);return pa.concat.apply([],pa)},guid:1,proxy:function(w,M){if("string"===typeof M){var Y=w[M];M=w;w=Y}if(!I.isFunction(w))return b;var ka=Pa.call(arguments,2);Y=function(){return w.apply(M,ka.concat(Pa.call(arguments)))};Y.guid=w.guid=w.guid||I.guid++;return Y},access:function(w,M,Y,ka,pa,oa,Ha){var Ma=null==
123Y,Va=0,lb=w.length;if(Y&&"object"===typeof Y){for(Va in Y)I.access(w,M,Va,Y[Va],1,oa,ka);pa=1}else if(ka!==b){var gb=Ha===b&&I.isFunction(ka);Ma&&(gb?(gb=M,M=function(mb,xb,Gb){return gb.call(I(mb),Gb)}):(M.call(w,ka),M=null));if(M)for(;Va<lb;Va++)M(w[Va],Y,gb?ka.call(w[Va],Va,M(w[Va],Y)):ka,Ha);pa=1}return pa?w:Ma?M.call(w):lb?M(w[0],Y):oa},now:function(){return(new Date).getTime()}});I.ready.promise=function(w){if(!za)if(za=I.Deferred(),"complete"===na.readyState)setTimeout(I.ready,1);else if(na.addEventListener)na.addEventListener("DOMContentLoaded",
124fa,!1),a.addEventListener("load",I.ready,!1);else{na.attachEvent("onreadystatechange",fa);a.attachEvent("onload",I.ready);var M=!1;try{M=null==a.frameElement&&na.documentElement}catch(Y){}M&&M.doScroll&&function ka(){if(!I.isReady){try{M.doScroll("left")}catch(pa){return setTimeout(ka,50)}I.ready()}}()}return za.promise(w)};I.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(w,M){ia["[object "+M+"]"]=M.toLowerCase()});var ma=I(na);var ua={};
124I.Callbacks=function(w){w=
125"string"===typeof w?ua[w]||c(w):I.extend({},w);var M,Y,ka,pa,oa,Ha,Ma=[],Va=!w.once&&[],lb=function(mb){M=w.memory&&mb;Y=!0;Ha=pa||0;pa=0;oa=Ma.length;for(ka=!0;Ma&&Ha<oa;Ha++)if(!1===Ma[Ha].apply(mb[0],mb[1])&&w.stopOnFalse){M=!1;break}ka=!1;Ma&&(Va?Va.length&&lb(Va.shift()):M?Ma=[]:gb.disable())},gb={add:function(){if(Ma){var mb=Ma.length;(function Rb(Gb){I.each(Gb,function(Tb,ec){Tb=I.type(ec);"function"===Tb?w.unique&&gb.has(ec)||Ma.push(ec):ec&&ec.length&&"string"!==Tb&&Rb(ec)})})(arguments);
126ka?oa=Ma.length:M&&(pa=mb,lb(M))}return this},remove:function(){Ma&&I.each(arguments,function(mb,xb){for(var Gb;-1<(Gb=I.inArray(xb,Ma,Gb));)Ma.splice(Gb,1),ka&&(Gb<=oa&&oa--,Gb<=Ha&&Ha--)});return this},has:function(mb){return-1<I.inArray(mb,Ma)},empty:function(){Ma=[];return this},disable:function(){Ma=Va=M=b;return this},disabled:function(){return!Ma},lock:function(){Va=b;M||gb.disable();return this},locked:function(){return!Va},fireWith:function(mb,xb){xb=xb||[];xb=[mb,xb.slice?xb.slice():xb];
127!Ma||Y&&!Va||(ka?Va.push(xb):lb(xb));return this},fire:function(){gb.fireWith(this,arguments);return this},fired:function(){return!!Y}};return gb};I.extend({Deferred:function(w){var M=[["resolve","done",I.Callbacks("once memory"),"resolved"],["reject","fail",I.Callbacks("once memory"),"rejected"],["notify","progress",I.Callbacks("memory")]],Y="pending",ka={state:function(){return Y},always:function(){pa.done(arguments).fail(arguments);return this},then:function(){var oa=arguments;return I.Deferred(function(Ha){I.each(M,
128function(Ma,Va){var lb=Va[0],gb=oa[Ma];pa[Va[1]](I.isFunction(gb)?function(){var mb=gb.apply(this,arguments);if(mb&&I.isFunction(mb.promise))mb.promise().done(Ha.resolve).fail(Ha.reject).progress(Ha.notify);else Ha[lb+"With"](this===pa?Ha:this,[mb])}:Ha[lb])});oa=null}).promise()},promise:function(oa){return null!=oa?I.extend(oa,ka):ka}},pa={};ka.pipe=ka.then;I.each(M,function(oa,Ha){var Ma=Ha[2],Va=Ha[3];ka[Ha[1]]=Ma.add;Va&&Ma.add(function(){Y=Va},M[oa^1][2].disable,M[2][2].lock);pa[Ha[0]]=Ma.fire;
129pa[Ha[0]+"With"]=Ma.fireWith});ka.promise(pa);w&&w.call(pa,pa);return pa},when:function(w){var M=0,Y=Pa.call(arguments),ka=Y.length,pa=1!==ka||w&&I.isFunction(w.promise)?ka:0,oa=1===pa?w:I.Deferred(),Ha=function(gb,mb,xb){return function(Gb){mb[gb]=this;xb[gb]=1<arguments.length?Pa.call(arguments):Gb;xb===Va?oa.notifyWith(mb,xb):--pa||oa.resolveWith(mb,xb)}},Ma;if(1<ka){var Va=Array(ka);var lb=Array(ka);for(Ma=Array(ka);M<ka;M++)Y[M]&&I.isFunction(Y[M].promise)?Y[M].promise().done(Ha(M,Ma,Y)).fail(oa.reject).progress(Ha(M,
130lb,Va)):--pa}pa||oa.resolveWith(Ma,Y);return oa.promise()}});I.support=function(){var w,M=na.createElement("div");M.setAttribute("className","t");M.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";var Y=M.getElementsByTagName("*");var ka=M.getElementsByTagName("a")[0];if(!Y||!ka||!Y.length)return{};var pa=na.createElement("select");var oa=pa.appendChild(na.createElement("option"));Y=M.getElementsByTagName("input")[0];ka.style.cssText="top:1px;float:left;opacity:.5";var Ha=
131{leadingWhitespace:3===M.firstChild.nodeType,tbody:!M.getElementsByTagName("tbody").length,htmlSerialize:!!M.getElementsByTagName("link").length,style:/top/.test(ka.getAttribute("style")),hrefNormalized:"/a"===ka.getAttribute("href"),opacity:/^0.5/.test(ka.style.opacity),cssFloat:!!ka.style.cssFloat,checkOn:"on"===Y.value,optSelected:oa.selected,getSetAttribute:"t"!==M.className,enctype:!!na.createElement("form").enctype,html5Clone:"<:nav></:nav>"!==na.createElement("nav").cloneNode(!0).outerHTML,
132boxModel:"CSS1Compat"===na.compatMode,submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1};Y.checked=!0;Ha.noCloneChecked=Y.cloneNode(!0).checked;pa.disabled=!0;Ha.optDisabled=!oa.disabled;try{delete M.test}catch(Va){Ha.deleteExpando=!1}!M.addEventListener&&M.attachEvent&&M.fireEvent&&(M.attachEvent("onclick",ka=function(){Ha.noCloneEvent=!1}),M.cloneNode(!0).fireEvent("onclick"),
133M.detachEvent("onclick",ka));Y=na.createElement("input");Y.value="t";Y.setAttribute("type","radio");Ha.radioValue="t"===Y.value;Y.setAttribute("checked","checked");Y.setAttribute("name","t");M.appendChild(Y);ka=na.createDocumentFragment();ka.appendChild(M.lastChild);
133Ha.checkClone=ka.cloneNode(!0).cloneNode(!0).lastChild.checked;Ha.appendChecked=Y.checked;ka.removeChild(Y);ka.appendChild(M);if(M.attachEvent)for(w in{submit:!0,change:!0,focusin:!0}){Y="on"+w;var Ma=Y in M;Ma||(M.setAttribute(Y,"return;"),
134Ma="function"===typeof M[Y]);Ha[w+"Bubbles"]=Ma}I(function(){var Va=na.getElementsByTagName("body")[0];if(Va){var lb=na.createElement("div");lb.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px";Va.insertBefore(lb,Va.firstChild);var gb=na.createElement("div");lb.appendChild(gb);gb.innerHTML="<table><tr><td></td><td>t</td></tr></table>";var mb=gb.getElementsByTagName("td");mb[0].style.cssText="padding:0;margin:0;border:0;display:none";Ma=0===mb[0].offsetHeight;
135mb[0].style.display="";mb[1].style.display="none";Ha.reliableHiddenOffsets=Ma&&0===mb[0].offsetHeight;gb.innerHTML="";gb.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";Ha.boxSizing=4===gb.offsetWidth;Ha.doesNotIncludeMarginInBodyOffset=1!==Va.offsetTop;a.getComputedStyle&&(Ha.pixelPosition="1%"!==(a.getComputedStyle(gb,null)||{}).top,Ha.boxSizingReliable="4px"===(a.getComputedStyle(gb,
136null)||{width:"4px"}).width,mb=na.createElement("div"),mb.style.cssText=gb.style.cssText="padding:0;margin:0;border:0;display:block;overflow:hidden;",mb.style.marginRight=mb.style.width="0",gb.style.width="1px",gb.appendChild(mb),Ha.reliableMarginRight=!parseFloat((a.getComputedStyle(mb,null)||{}).marginRight));"undefined"!==typeof gb.style.zoom&&(gb.innerHTML="",gb.style.cssText="padding:0;margin:0;border:0;display:block;overflow:hidden;width:1px;padding:1px;display:inline;zoom:1",Ha.inlineBlockNeedsLayout=
1373===gb.offsetWidth,gb.style.display="block",gb.style.overflow="visible",gb.innerHTML="<div></div>",gb.firstChild.style.width="5px",Ha.shrinkWrapBlocks=3!==gb.offsetWidth,lb.style.zoom=1);Va.removeChild(lb)}});ka.removeChild(M);Y=ka=pa=oa=Y=ka=M=null;return Ha}();var wa=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,Da=/([A-Z])/g;I.extend({cache:{},deletedIds:[],uuid:0,expando:"JQXLite"+(I.fn.jqx+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(w){w=
138w.nodeType?I.cache[w[I.expando]]:w[I.expando];return!!w&&!e(w)},data:function(w,M,Y,ka){if(I.acceptData(w)){var pa=I.expando,oa="string"===typeof M,Ha=w.nodeType,Ma=Ha?I.cache:w,Va=Ha?w[pa]:w[pa]&&pa;if(Va&&Ma[Va]&&(ka||Ma[Va].data)||!oa||Y!==b){Va||(Ha?w[pa]=Va=I.deletedIds.pop()||I.guid++:Va=pa);Ma[Va]||(Ma[Va]={},Ha||(Ma[Va].toJSON=I.noop));if("object"===typeof M||"function"===typeof M)ka?Ma[Va]=I.extend(Ma[Va],M):Ma[Va].data=I.extend(Ma[Va].data,M);w=Ma[Va];ka||(w.data||(w.data={}),w=w.data);
139Y!==b&&(w[I.camelCase(M)]=Y);oa?(Y=w[M],null==Y&&(Y=w[I.camelCase(M)])):Y=w;return Y}}},removeData:function(w,M,Y){if(I.acceptData(w)){var ka,pa,oa=w.nodeType,Ha=oa?I.cache:w,Ma=oa?w[I.expando]:I.expando;if(Ha[Ma]){if(M&&(ka=Y?Ha[Ma]:Ha[Ma].data)){I.isArray(M)||(M in ka?M=[M]:(M=I.camelCase(M),M=M in ka?[M]:M.split(" ")));var Va=0;for(pa=M.length;Va<pa;Va++)delete ka[M[Va]];if(!(Y?e:I.isEmptyObject)(ka))return}if(!Y&&(delete Ha[Ma].data,!e(Ha[Ma])))return;oa?I.cleanData([w],!0):I.support.deleteExpando||
140Ha!=Ha.window?delete Ha[Ma]:Ha[Ma]=null}}},_data:function(w,M,Y){return I.data(w,M,Y,!0)},acceptData:function(w){var M=w.nodeName&&I.noData[w.nodeName.toLowerCase()];return!M||!0!==M&&w.getAttribute("classid")===M}});I.fn.extend({data:function(w,M){var Y,ka=this[0],pa=0,oa=null;if(w===b){if(this.length&&(oa=I.data(ka),1===ka.nodeType&&!I._data(ka,"parsedAttrs"))){var Ha=ka.attributes;for(Y=Ha.length;pa<Y;pa++){var Ma=Ha[pa].name;Ma.indexOf("data-")||(Ma=I.camelCase(Ma.substring(5)),d(ka,Ma,oa[Ma]))}I._data(ka,
141"parsedAttrs",!0)}return oa}if("object"===typeof w)return this.each(function(){I.data(this,w)});var Va=w.split(".",2);Va[1]=Va[1]?"."+Va[1]:"";var lb=Va[1]+"!";return I.access(this,function(gb){if(gb===b)return oa=this.triggerHandler("getData"+lb,[Va[0]]),oa===b&&ka&&(oa=I.data(ka,w),oa=d(ka,w,oa)),oa===b&&Va[1]?this.data(Va[0]):oa;Va[1]=gb;this.each(function(){var mb=I(this);mb.triggerHandler("setData"+lb,Va);I.data(this,w,gb);mb.triggerHandler("changeData"+lb,Va)})},null,M,1<arguments.length,null,
142!1)},removeData:function(w){return this.each(function(){I.removeData(this,w)})}});I.extend({queue:function(w,M,Y){if(w){M=(M||"fx")+"queue";var ka=I._data(w,M);Y&&(!ka||I.isArray(Y)?ka=I._data(w,M,I.makeArray(Y)):ka.push(Y));return ka||[]}},dequeue:function(w,M){M=M||"fx";var Y=I.queue(w,M),ka=Y.length,pa=Y.shift(),oa=I._queueHooks(w,M),Ha=function(){I.dequeue(w,M)};"inprogress"===pa&&(pa=Y.shift(),ka--);pa&&("fx"===M&&Y.unshift("inprogress"),delete oa.stop,pa.call(w,Ha,oa));!ka&&oa&&oa.empty.fire()},
143_queueHooks:function(w,M){var Y=M+"queueHooks";
143return I._data(w,Y)||I._data(w,Y,{empty:I.Callbacks("once memory").add(function(){I.removeData(w,M+"queue",!0);I.removeData(w,Y,!0)})})}});I.fn.extend({queue:function(w,M){var Y=2;"string"!==typeof w&&(M=w,w="fx",Y--);return arguments.length<Y?I.queue(this[0],w):M===b?this:this.each(function(){var ka=I.queue(this,w,M);I._queueHooks(this,w);"fx"===w&&"inprogress"!==ka[0]&&I.dequeue(this,w)})},dequeue:function(w){return this.each(function(){I.dequeue(this,
144w)})},delay:function(w,M){w=I.fx?I.fx.speeds[w]||w:w;return this.queue(M||"fx",function(Y,ka){var pa=setTimeout(Y,w);ka.stop=function(){clearTimeout(pa)}})},clearQueue:function(w){return this.queue(w||"fx",[])},promise:function(w,M){var Y,ka=1,pa=I.Deferred(),oa=this,Ha=this.length,Ma=function(){--ka||pa.resolveWith(oa,[oa])};"string"!==typeof w&&(M=w,w=b);for(w=w||"fx";Ha--;)(Y=I._data(oa[Ha],w+"queueHooks"))&&Y.empty&&(ka++,Y.empty.add(Ma));Ma();return pa.promise(M)}});var Ea=/[\t\r\n]/g,Aa=/\r/g,
145Ka=/^(?:button|input)$/i,Ra=/^(?:button|input|object|select|textarea)$/i,cb=/^a(?:rea|)$/i,ib=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,fb=I.support.getSetAttribute;I.fn.extend({attr:function(w,M){return I.access(this,I.attr,w,M,1<arguments.length)},removeAttr:function(w){return this.each(function(){I.removeAttr(this,w)})},prop:function(w,M){return I.access(this,I.prop,w,M,1<arguments.length)},removeProp:function(w){w=
146I.propFix[w]||w;return this.each(function(){try{this[w]=b,delete this[w]}catch(M){}})},addClass:function(w){var M,Y;if(I.isFunction(w))return this.each(function(Va){I(this).addClass(w.call(this,Va,this.className))});if(w&&"string"===typeof w){var ka=w.split(db);var pa=0;for(M=this.length;pa<M;pa++){var oa=this[pa];if(1===oa.nodeType)if(oa.className||1!==ka.length){var Ha=" "+oa.className+" ";var Ma=0;for(Y=ka.length;Ma<Y;Ma++)0>Ha.indexOf(" "+ka[Ma]+" ")&&(Ha+=ka[Ma]+" ");oa.className=I.trim(Ha)}else oa.className=
147w}}return this},removeClass:function(w){var M,Y;if(I.isFunction(w))return this.each(function(Va){I(this).removeClass(w.call(this,Va,this.className))});if(w&&"string"===typeof w||w===b){var ka=(w||"").split(db);var pa=0;for(Y=this.length;pa<Y;pa++){var oa=this[pa];if(1===oa.nodeType&&oa.className){var Ha=(" "+oa.className+" ").replace(Ea," ");var Ma=0;for(M=ka.length;Ma<M;Ma++)for(;0<=Ha.indexOf(" "+ka[Ma]+" ");)Ha=Ha.replace(" "+ka[Ma]+" "," ");oa.className=w?I.trim(Ha):""}}}return this},toggleClass:function(w,
148M){var Y=typeof w,ka="boolean"===typeof M;return I.isFunction(w)?this.each(function(pa){I(this).toggleClass(w.call(this,pa,this.className,M),M)}):this.each(function(){if("string"===Y)for(var pa,oa=0,Ha=I(this),Ma=M,Va=w.split(db);pa=Va[oa++];)Ma=ka?Ma:!Ha.hasClass(pa),Ha[Ma?"addClass":"removeClass"](pa);else if("undefined"===Y||"boolean"===Y)this.className&&I._data(this,"__className__",this.className),this.className=this.className||!1===w?"":I._data(this,"__className__")||""})},hasClass:function(w){w=
149" "+w+" ";for(var M=0,Y=this.length;M<Y;M++)if(1===this[M].nodeType&&0<=(" "+this[M].className+" ").replace(Ea," ").indexOf(w))return!0;return!1},val:function(w){var M,Y,ka=this[0];if(arguments.length){var pa=I.isFunction(w);return this.each(function(oa){var Ha=I(this);1===this.nodeType&&(oa=pa?w.call(this,oa,Ha.val()):w,null==oa?oa="":"number"===typeof oa?oa+="":I.isArray(oa)&&(oa=I.map(oa,function(Ma){return null==Ma?"":Ma+""})),M=I.valHooks[this.type]||I.valHooks[this.nodeName.toLowerCase()],M&&
150"set"in M&&M.set(this,oa,"value")!==b||(this.value=oa))})}if(ka){if((M=I.valHooks[ka.type]||I.valHooks[ka.nodeName.toLowerCase()])&&"get"in M&&(Y=M.get(ka,"value"))!==b)return Y;Y=ka.value;return"string"===typeof Y?Y.replace(Aa,""):null==Y?"":Y}}});I.extend({valHooks:{option:{get:function(w){var M=w.attributes.value;return!M||M.specified?w.value:w.text}},select:{get:function(w){for(var M,Y=w.options,ka=w.selectedIndex,pa=(w="select-one"===w.type||0>ka)?null:[],oa=w?ka+1:Y.length,Ha=0>ka?oa:w?ka:0;Ha<
151oa;Ha++)if(M=Y[Ha],!(!M.selected&&Ha!==ka||(I.support.optDisabled?M.disabled:null!==M.getAttribute("disabled"))||M.parentNode.disabled&&I.nodeName(M.parentNode,"optgroup"))){M=I(M).val();if(w)return M;pa.push(M)}return pa},set:function(w,M){var Y=I.makeArray(M);I(w).find("option").each(function(){this.selected=0<=I.inArray(I(this).val(),Y)});Y.length||(w.selectedIndex=-1);return Y}}},attrFn:{},attr:function(w,M,Y,ka){var pa,oa=w.nodeType;if(w&&3!==oa&&8!==oa&&2!==oa){if(ka&&I.isFunction(I.fn[M]))return I(w)[M](Y);
152if("undefined"===typeof w.getAttribute)return I.prop(w,M,Y);if(ka=1!==oa||!I.isXMLDoc(w)){M=M.toLowerCase();var Ha=I.attrHooks[M]||(ib.test(M)?bb:void 0)}if(Y!==b)if(null===Y)I.removeAttr(w,M);else{if(Ha&&"set"in Ha&&ka&&(pa=Ha.set(w,Y,M))!==b)return pa;w.setAttribute(M,Y+"");return Y}else{if(Ha&&"get"in Ha&&ka&&null!==(pa=Ha.get(w,M)))return pa;pa=w.getAttribute(M);return null===pa?b:pa}}},removeAttr:function(w,M){var Y,ka,pa,oa=0;if(M&&1===w.nodeType)for(Y=M.split(db);oa<Y.length;oa++)if(ka=Y[oa])M=
153I.propFix[ka]||ka,(pa=ib.test(ka))||I.attr(w,ka,""),w.removeAttribute(fb?ka:M),pa&&M in w&&(w[M]=!1)},attrHooks:{type:{set:function(w,M){if(Ka.test(w.nodeName)&&w.parentNode)I.error("type property can't be changed");else if(!I.support.radioValue&&"radio"===M&&I.nodeName(w,"input")){var Y=w.value;w.setAttribute("type",M);Y&&(w.value=Y);return M}}},value:{get:function(w,M){return M in w?w.value:null},set:function(w,M,Y){w.value=M}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",
154maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(w,M,Y){var ka,pa=w.nodeType;if(w&&3!==pa&&8!==pa&&2!==pa){if(1!==pa||!I.isXMLDoc(w)){M=I.propFix[M]||M;var oa=I.propHooks[M]}return Y!==b?oa&&"set"in oa&&(ka=oa.set(w,Y,M))!==b?ka:w[M]=Y:oa&&"get"in oa&&null!==(ka=oa.get(w,M))?ka:w[M]}},propHooks:{tabIndex:{get:function(w){var M=w.getAttributeNode("tabindex");
155return M&&M.specified?parseInt(M.value,10):Ra.test(w.nodeName)||cb.test(w.nodeName)&&w.href?0:b}}}});var bb={get:function(w,M){var Y,ka=I.prop(w,M);return!0===ka||"boolean"!==typeof ka&&(Y=w.getAttributeNode(M))&&!1!==Y.nodeValue?M.toLowerCase():b},set:function(w,M,Y){!1===M?I.removeAttr(w,Y):(M=I.propFix[Y]||Y,M in w&&(w[M]=!0),w.setAttribute(Y,Y.toLowerCase()));return Y}};I.support.enctype||(I.propFix.enctype="encoding");var eb=/^([^\.]*|)(?:\.(.+)|)$/,kb=/(?:^|\s)hover(\.\S+|)\b/,rb=/^key/,$a=
156/^(?:mouse|contextmenu)|click/,nb=/^(?:focusinfocus|focusoutblur)$/,vb=function(w){return I.event.special.hover?w:w.replace(kb,"mouseenter$1 mouseleave$1")};I.event={add:function(w,M,Y,ka,pa){var oa;if(3!==w.nodeType&&8!==w.nodeType&&M&&Y&&(oa=I._data(w))){if(Y.handler){var Ha=Y;Y=Ha.handler;pa=Ha.selector}Y.guid||(Y.guid=I.guid++);var Ma=oa.events;Ma||(oa.events=Ma={});var Va=oa.handle;Va||(oa.handle=Va=function(Rb){return"undefined"===typeof I||Rb&&I.event.triggered===Rb.type?b:I.event.dispatch.apply(Va.elem,
157arguments)},Va.elem=w);M=I.trim(vb(M)).split(" ");for(oa=0;oa<M.length;oa++){var lb=eb.exec(M[oa])||[];var gb=lb[1];var mb=(lb[2]||"").split(".").sort();var xb=I.event.special[gb]||{};gb=(pa?xb.delegateType:xb.bindType)||gb;xb=I.event.special[gb]||{};lb=I.extend({type:gb,origType:lb[1],data:ka,handler:Y,guid:Y.guid,selector:pa,needsContext:pa&&I.expr.match.needsContext.test(pa),namespace:mb.join(".")},Ha);var Gb=Ma[gb];Gb||(Gb=Ma[gb]=[],Gb.delegateCount=0,xb.setup&&!1!==xb.setup.call(w,ka,mb,Va)||
158(w.addEventListener?ka&&ka.passive!==b?w.addEventListener(gb,Va,ka):w.addEventListener(gb,Va,!1):w.attachEvent&&w.attachEvent("on"+gb,Va)));xb.add&&(xb.add.call(w,lb),lb.handler.guid||(lb.handler.guid=Y.guid));pa?Gb.splice(Gb.delegateCount++,0,lb):Gb.push(lb);I.event.global[gb]=!0}w=null}},global:{},remove:function(w,M,Y,ka,pa){var oa,Ha,Ma,Va,lb=I.hasData(w)&&I._data(w);if(lb&&(Va=lb.events)){M=I.trim(vb(M||"")).split(" ");for(oa=0;oa<M.length;oa++){var gb=eb.exec(M[oa])||[];var mb=Ha=gb[1];gb=gb[2];
159if(mb){var xb=I.event.special[mb]||{};mb=(ka?xb.delegateType:xb.bindType)||mb;var Gb=Va[mb]||[];var Rb=Gb.length;gb=gb?new RegExp("(^|\\.)"+gb.split(".").sort().join("\\.(?:.*\\.|)")+"(\\.|$)"):null;for(Ma=0;Ma<Gb.length;Ma++){var Tb=Gb[Ma];!pa&&Ha!==Tb.origType||Y&&Y.guid!==Tb.guid||gb&&!gb.test(Tb.namespace)||ka&&ka!==Tb.selector&&("**"!==ka||!Tb.selector)||(Gb.splice(Ma--,1),Tb.selector&&Gb.delegateCount--,xb.remove&&xb.remove.call(w,Tb))}0===Gb.length&&Rb!==Gb.length&&(xb.teardown&&!1!==xb.teardown.call(w,
160gb,lb.handle)||I.removeEvent(w,mb,lb.handle),delete Va[mb])}else for(mb in Va)I.event.remove(w,mb+M[oa],Y,ka,!0)}I.isEmptyObject(Va)&&(delete lb.handle,I.removeData(w,"events",!0))}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(w,M,Y,ka){if(!Y||3!==Y.nodeType&&8!==Y.nodeType){var pa,oa=w.type||w;var Ha=[];
160if(!nb.test(oa+I.event.triggered)){if(0<=oa.indexOf("!")){oa=oa.slice(0,-1);var Ma=!0}0<=oa.indexOf(".")&&(Ha=oa.split("."),oa=Ha.shift(),Ha.sort());if(Y&&!I.event.customEvent[oa]||
161I.event.global[oa])if(w="object"===typeof w?w[I.expando]?w:new I.Event(oa,w):new I.Event(oa),w.type=oa,w.isTrigger=!0,w.exclusive=Ma,w.namespace=Ha.join("."),w.namespace_re=w.namespace?new RegExp("(^|\\.)"+Ha.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,Ha=0>oa.indexOf(":")?"on"+oa:"",Y){w.result=b;w.target||(w.target=Y);M=null!=M?I.makeArray(M):[];M.unshift(w);var Va=I.event.special[oa]||{};if(!Va.trigger||!1!==Va.trigger.apply(Y,M)){var lb=[[Y,Va.bindType||oa]];if(!ka&&!Va.noBubble&&!I.isWindow(Y)){var gb=
162Va.delegateType||oa;Ma=nb.test(gb+oa)?Y:Y.parentNode;for(pa=Y;Ma;Ma=Ma.parentNode)lb.push([Ma,gb]),pa=Ma;pa===(Y.ownerDocument||na)&&lb.push([pa.defaultView||pa.parentWindow||a,gb])}for(pa=0;pa<lb.length&&!w.isPropagationStopped();pa++)Ma=lb[pa][0],w.type=lb[pa][1],(gb=(I._data(Ma,"events")||{})[w.type]&&I._data(Ma,"handle"))&&gb.apply(Ma,M),(gb=Ha&&Ma[Ha])&&I.acceptData(Ma)&&gb.apply&&!1===gb.apply(Ma,M)&&w.preventDefault();w.type=oa;ka||w.isDefaultPrevented()||Va._default&&!1!==Va._default.apply(Y.ownerDocument,
163M)||"click"===oa&&I.nodeName(Y,"a")||!I.acceptData(Y)||!Ha||!Y[oa]||("focus"===oa||"blur"===oa)&&0===w.target.offsetWidth||I.isWindow(Y)||((pa=Y[Ha])&&(Y[Ha]=null),I.event.triggered=oa,Y[oa](),I.event.triggered=b,pa&&(Y[Ha]=pa));return w.result}}else for(pa in Y=I.cache,Y)Y[pa].events&&Y[pa].events[oa]&&I.event.trigger(w,M,Y[pa].handle.elem,!0)}}},dispatch:function(w){w=I.event.fix(w||a.event);var M,Y,ka=(I._data(this,"events")||{})[w.type]||[],pa=ka.delegateCount,oa=Pa.call(arguments),Ha=!w.exclusive&&
164!w.namespace,Ma=I.event.special[w.type]||{},Va=[];oa[0]=w;w.delegateTarget=this;if(!Ma.preDispatch||!1!==Ma.preDispatch.call(this,w)){if(pa&&(!w.button||"click"!==w.type))for(Y=w.target;Y!=this;Y=Y.parentNode||this)if(!0!==Y.disabled||"click"!==w.type){var lb={};var gb=[];for(M=0;M<pa;M++){var mb=ka[M];var xb=mb.selector;lb[xb]===b&&(lb[xb]=mb.needsContext?0<=I(xb,this).index(Y):I.find(xb,this,null,[Y]).length);lb[xb]&&gb.push(mb)}gb.length&&Va.push({elem:Y,matches:gb})}ka.length>pa&&Va.push({elem:this,
165matches:ka.slice(pa)});for(M=0;M<Va.length&&!w.isPropagationStopped();M++)for(lb=Va[M],w.currentTarget=lb.elem,Y=0;Y<lb.matches.length&&!w.isImmediatePropagationStopped();Y++)if(mb=lb.matches[Y],Ha||!w.namespace&&!mb.namespace||w.namespace_re&&w.namespace_re.test(mb.namespace))w.data=mb.data,w.handleObj=mb,mb=((I.event.special[mb.origType]||{}).handle||mb.handler).apply(lb.elem,oa),mb!==b&&(w.result=mb,!1===mb&&(w.preventDefault(),w.stopPropagation()));Ma.postDispatch&&Ma.postDispatch.call(this,w);
166return w.result}},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:["char","charCode","key","keyCode"],filter:function(w,M){null==w.which&&(w.which=null!=M.charCode?M.charCode:M.keyCode);return w}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(w,
167M){var Y=M.button,ka=M.fromElement;if(null==w.pageX&&null!=M.clientX){var pa=w.target.ownerDocument||na;var oa=pa.documentElement;pa=pa.body;w.pageX=M.clientX+(oa&&oa.scrollLeft||pa&&pa.scrollLeft||0)-(oa&&oa.clientLeft||pa&&pa.clientLeft||0);w.pageY=M.clientY+(oa&&oa.scrollTop||pa&&pa.scrollTop||0)-(oa&&oa.clientTop||pa&&pa.clientTop||0)}!w.relatedTarget&&ka&&(w.relatedTarget=ka===w.target?M.toElement:ka);w.which||Y===b||(w.which=Y&1?1:Y&2?3:Y&4?2:0);return w}},fix:function(w){if(w[I.expando])return w;
168var M,Y=w,ka=I.event.fixHooks[w.type]||{},pa=ka.props?this.props.concat(ka.props):this.props;w=I.Event(Y);for(M=pa.length;M;){var oa=pa[--M];w[oa]=Y[oa]}w.target||(w.target=Y.srcElement||na);3===w.target.nodeType&&(w.target=w.target.parentNode);w.metaKey=!!w.metaKey;return ka.filter?ka.filter(w,Y):w},special:{load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(w,M,Y){I.isWindow(this)&&(this.onbeforeunload=Y)},teardown:function(w,M){this.onbeforeunload===
169M&&(this.onbeforeunload=null)}}},simulate:function(w,M,Y,ka){w=I.extend(new I.Event,Y,{type:w,isSimulated:!0,originalEvent:{}});ka?I.event.trigger(w,null,M):I.event.dispatch.call(M,w);w.isDefaultPrevented()&&Y.preventDefault()}};I.event.handle=I.event.dispatch;I.removeEvent=na.removeEventListener?function(w,M,Y){w.removeEventListener&&w.removeEventListener(M,Y,!1)}:function(w,M,Y){M="on"+M;w.detachEvent&&("undefined"===typeof w[M]&&(w[M]=null),w.detachEvent(M,Y))};I.Event=function(w,M){if(!(this instanceof
170I.Event))return new I.Event(w,M);w&&w.type?(this.originalEvent=w,this.type=w.type,this.isDefaultPrevented=w.defaultPrevented||!1===w.returnValue||w.getPreventDefault&&w.getPreventDefault()?g:f):this.type=w;M&&I.extend(this,M);this.timeStamp=w&&w.timeStamp||I.now();this[I.expando]=!0};I.Event.prototype={preventDefault:function(){this.isDefaultPrevented=g;var w=this.originalEvent;w&&(w.preventDefault?w.preventDefault():w.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=g;var w=
171this.originalEvent;w&&(w.stopPropagation&&w.stopPropagation(),w.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=g;this.stopPropagation()},isDefaultPrevented:f,isPropagationStopped:f,isImmediatePropagationStopped:f};
171I.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(w,M){I.event.special[w]={delegateType:M,bindType:M,handle:function(Y){var ka=Y.relatedTarget,pa=Y.handleObj;if(!ka||ka!==this&&!I.contains(this,ka)){Y.type=pa.origType;var oa=pa.handler.apply(this,
172arguments);Y.type=M}return oa}}});I.fn.extend({on:function(w,M,Y,ka,pa){var oa;if("object"===typeof w){"string"!==typeof M&&(Y=Y||M,M=b);for(oa in w)this.on(oa,M,Y,w[oa],pa);return this}null==Y&&null==ka?(ka=M,Y=M=b):null==ka&&("string"===typeof M?(ka=Y,Y=b):(ka=Y,Y=M,M=b));if(!1===ka)ka=f;else if(!ka)return this;if(1===pa){var Ha=ka;ka=function(Ma){I().off(Ma);return Ha.apply(this,arguments)};ka.guid=Ha.guid||(Ha.guid=I.guid++)}return this.each(function(){I.event.add(this,w,ka,Y,M)})},off:function(w,
173M,Y){if(w&&w.preventDefault&&w.handleObj){var ka=w.handleObj;I(w.delegateTarget).off(ka.namespace?ka.origType+"."+ka.namespace:ka.origType,ka.selector,ka.handler);return this}if("object"===typeof w){for(ka in w)this.off(ka,M,w[ka]);return this}if(!1===M||"function"===typeof M)Y=M,M=b;!1===Y&&(Y=f);return this.each(function(){I.event.remove(this,w,Y,M)})},delegate:function(w,M,Y,ka){return this.on(M,w,Y,ka)},undelegate:function(w,M,Y){return 1===arguments.length?this.off(w,"**"):this.off(M,w||"**",
174Y)},trigger:function(w,M){return this.each(function(){I.event.trigger(w,M,this)})},triggerHandler:function(w,M){if(this[0])return I.event.trigger(w,M,this[0],!0)},toggle:function(w){var M=arguments,Y=w.guid||I.guid++,ka=0,pa=function(oa){var Ha=(I._data(this,"lastToggle"+w.guid)||0)%ka;I._data(this,"lastToggle"+w.guid,Ha+1);oa.preventDefault();return M[Ha].apply(this,arguments)||!1};for(pa.guid=Y;ka<M.length;)M[ka++].guid=Y;return this.click(pa)},hover:function(w,M){return this.mouseenter(w).mouseleave(M||
175w)}});I.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(w,M){I.fn[M]=function(Y,ka){null==ka&&(ka=Y,Y=null);return 0<arguments.length?this.on(M,null,Y,ka):this.trigger(M)};rb.test(M)&&(I.event.fixHooks[M]=I.event.keyHooks);$a.test(M)&&(I.event.fixHooks[M]=I.event.mouseHooks)});(function(w,M){function Y(ya,La,Wa,tb){Wa=Wa||
176[];La=La||fc;var sb,qb,hb,yb=La.nodeType;if(!ya||"string"!==typeof ya)return Wa;if(1!==yb&&9!==yb)return[];var ub=Ic(La);if(!ub&&!tb&&(sb=Zc.exec(ya)))if(hb=sb[1])if(9===yb)if((qb=La.getElementById(hb))&&qb.parentNode){if(qb.id===hb)return Wa.push(qb),Wa}else return Wa;else{if(La.ownerDocument&&(qb=La.ownerDocument.getElementById(hb))&&$c(La,qb)&&qb.id===hb)return Wa.push(qb),Wa}else{if(sb[2])return tc.apply(Wa,uc.call(La.getElementsByTagName(ya),0)),Wa;if((hb=sb[3])&&Pc&&La.getElementsByClassName)return tc.apply(Wa,
177uc.call(La.getElementsByClassName(hb),0)),Wa}return Rb(ya.replace(Bc,"$1"),La,Wa,tb,ub)}function ka(ya){return function(La){return"input"===La.nodeName.toLowerCase()&&La.type===ya}}function pa(ya){return function(La){var Wa=La.nodeName.toLowerCase();return("input"===Wa||"button"===Wa)&&La.type===ya}}function oa(ya){return bc(function(La){La=+La;return bc(function(Wa,tb){for(var sb,qb=ya([],Wa.length,La),hb=qb.length;hb--;)Wa[sb=qb[hb]]&&(Wa[sb]=!(tb[sb]=Wa[sb]))})})}function Ha(ya,La,Wa){if(ya===
178La)return Wa;for(ya=ya.nextSibling;ya;){if(ya===La)return-1;ya=ya.nextSibling}return 1}function Ma(ya,La){var Wa,tb,sb,qb,hb;if(qb=Qc[Ob][ya+" "])return La?0:qb.slice(0);qb=ya;var yb=[];for(hb=Mb.preFilter;qb;){if(!ub||(Wa=ad.exec(qb)))Wa&&(qb=qb.slice(Wa[0].length)||qb),yb.push(tb=[]);var ub=!1;if(Wa=bd.exec(qb))tb.push(ub=new Rc(Wa.shift())),qb=qb.slice(ub.length),ub.type=Wa[0].replace(Bc," ");for(sb in Mb.filter)!(Wa=Cc[sb].exec(qb))||hb[sb]&&!(Wa=hb[sb](Wa))||(tb.push(ub=new Rc(Wa.shift())),qb=
179qb.slice(ub.length),ub.type=sb,ub.matches=Wa);if(!ub)break}return La?qb.length:qb?Y.error(ya):Qc(ya,yb).slice(0)}function Va(ya,La,Wa){var tb=La.dir,sb=Wa&&"parentNode"===La.dir,qb=cd++;return La.first?function(hb,yb,ub){for(;hb=hb[tb];)if(sb||1===hb.nodeType)return ya(hb,yb,ub)}:function(hb,yb,ub){if(!ub)for(var Db,Ib=Dc+" "+qb+" ",Pb=Ib+ec;hb=hb[tb];){if(sb||1===hb.nodeType){if((Db=hb[Ob])===Pb)return hb.sizset;if("string"===typeof Db&&0===Db.indexOf(Ib)){if(hb.sizset)return hb}else{hb[Ob]=Pb;if(ya(hb,
180yb,ub))return hb.sizset=!0,hb;hb.sizset=!1}}}else for(;hb=hb[tb];)if((sb||1===hb.nodeType)&&ya(hb,yb,ub))return hb}}function lb(ya){return 1<ya.length?function(La,Wa,tb){for(var sb=ya.length;sb--;)if(!ya[sb](La,Wa,tb))return!1;return!0}:ya[0]}function gb(ya,La,Wa,tb,sb){for(var qb,hb=[],yb=0,ub=ya.length,Db=null!=La;yb<ub;yb++)if(qb=ya[yb])if(!Wa||Wa(qb,tb,sb))hb.push(qb),Db&&La.push(yb);return hb}function mb(ya,La,Wa,tb,sb,qb){tb&&!tb[Ob]&&(tb=mb(tb));sb&&!sb[Ob]&&(sb=mb(sb,qb));return bc(function(hb,
181yb,ub,Db){var Ib,Pb=[],Qb=[],Ub=yb.length,Jb;if(!(Jb=hb)){Jb=La||"*";for(var Hb=ub.nodeType?[ub]:ub,kc=[],vc=0,Jc=Hb.length;vc<Jc;vc++)Y(Jb,Hb[vc],kc);Jb=kc}Jb=!ya||!hb&&La?Jb:gb(Jb,Pb,ya,ub,Db);Hb=Wa?sb||(hb?ya:Ub||tb)?[]:yb:Jb;Wa&&Wa(Jb,Hb,ub,Db);if(tb){var Yb=gb(Hb,Qb);tb(Yb,[],ub,Db);for(ub=Yb.length;ub--;)if(Ib=Yb[ub])Hb[Qb[ub]]=!(Jb[Qb[ub]]=Ib)}if(hb){if(sb||ya){if(sb){Yb=[];for(ub=Hb.length;ub--;)(Ib=Hb[ub])&&Yb.push(Jb[ub]=Ib);sb(null,Hb=[],Yb,Db)}for(ub=Hb.length;ub--;)(Ib=Hb[ub])&&-1<(Yb=
182sb?Kc.call(hb,Ib):Pb[ub])&&(hb[Yb]=!(yb[Yb]=Ib))}}else Hb=gb(Hb===yb?Hb.splice(Ub,Hb.length):Hb),sb?sb(null,yb,Hb,Db):tc.apply(yb,Hb)})}function xb(ya){var La,Wa,tb=ya.length,sb=Mb.relative[ya[0].type];var qb=sb||Mb.relative[" "];for(var hb=sb?1:0,yb=Va(function(Ib){return Ib===La},qb,!0),ub=Va(function(Ib){return-1<Kc.call(La,Ib)},qb,!0),Db=[function(Ib,Pb,Qb){return!sb&&(Qb||Pb!==Ec)||((La=Pb).nodeType?yb(Ib,Pb,Qb):ub(Ib,Pb,Qb))}];hb<tb;hb++)if(qb=Mb.relative[ya[hb].type])Db=[Va(lb(Db),qb)];else{qb=
183Mb.filter[ya[hb].type].apply(null,ya[hb].matches);if(qb[Ob]){for(Wa=++hb;Wa<tb&&!Mb.relative[ya[Wa].type];Wa++);return mb(1<hb&&lb(Db),1<hb&&ya.slice(0,hb-1).join("").replace(Bc,"$1"),qb,hb<Wa&&xb(ya.slice(hb,Wa)),Wa<tb&&xb(ya=ya.slice(Wa)),Wa<tb&&ya.join(""))}Db.push(qb)}return lb(Db)}function Gb(ya,La){var Wa=0<La.length,tb=0<ya.length,sb=function(qb,hb,yb,ub,Db){var Ib,Pb,Qb=[],Ub=0,Jb="0",Hb=qb&&[],kc=null!=Db,vc=Ec,Jc=qb||tb&&Mb.find.TAG("*",Db&&hb.parentNode||hb),Yb=Dc+=null==vc?1:Math.E;kc&&
184(Ec=hb!==fc&&hb,ec=sb.el);for(;null!=(Db=Jc[Jb]);Jb++){if(tb&&Db){for(Ib=0;Pb=ya[Ib];Ib++)if(Pb(Db,hb,yb)){ub.push(Db);break}kc&&(Dc=Yb,ec=++sb.el)}Wa&&((Db=!Pb&&Db)&&Ub--,qb&&Hb.push(Db))}Ub+=Jb;if(Wa&&Jb!==Ub){for(Ib=0;Pb=La[Ib];Ib++)Pb(Hb,Qb,hb,yb);if(qb){if(0<Ub)for(;Jb--;)Hb[Jb]||Qb[Jb]||(Qb[Jb]=dd.call(ub));Qb=gb(Qb)}tc.apply(ub,Qb);kc&&!qb&&0<Qb.length&&1<Ub+La.length&&Y.uniqueSort(ub)}kc&&(Dc=Yb,Ec=vc);return Hb};sb.el=0;return Wa?bc(sb):sb}function Rb(ya,La,Wa,tb,sb){var qb,hb,yb,ub=Ma(ya);
185if(!tb&&1===ub.length){var Db=ub[0]=ub[0].slice(0);if(2<Db.length&&"ID"===(hb=Db[0]).type&&9===La.nodeType&&!sb&&Mb.relative[Db[1].type]){La=Mb.find.ID(hb.matches[0].replace(qc,""),La,sb)[0];if(!La)return Wa;ya=ya.slice(Db.shift().length)}for(qb=Cc.POS.test(ya)?-1:Db.length-1;0<=qb;qb--){hb=Db[qb];if(Mb.relative[yb=hb.type])break;if(yb=Mb.find[yb])if(tb=yb(hb.matches[0].replace(qc,""),Lc.test(Db[0].type)&&La.parentNode||La,sb)){Db.splice(qb,1);ya=tb.length&&Db.join("");if(!ya)return tc.apply(Wa,uc.call(tb,
1860)),Wa;break}}}Sc(ya,ub)(tb,La,sb,Wa,Lc.test(ya));return Wa}function Tb(){}var ec,Mc,yc,Ec,Tc=!0,Ob=("sizcache"+Math.random()).replace(".",""),Rc=String,fc=w.document,Zb=fc.documentElement,Dc=0,cd=0,dd=[].pop,tc=[].push,uc=[].slice,Kc=[].indexOf||function(ya){for(var La=0,Wa=this.length;La<Wa;La++)if(this[La]===ya)return La;return-1}
186,bc=function(ya,La){ya[Ob]=null==La||La;return ya};w=function(){var ya={},La=[];return bc(function(Wa,tb){La.push(Wa)>Mb.cacheLength&&delete ya[La.shift()];return ya[Wa+
187" "]=tb},ya)};var Uc=w(),Qc=w(),Vc=w(),Bc=RegExp("^[\\x20\\t\\r\\n\\f]+|((?:^|[^\\\\])(?:\\\\.)*)[\\x20\\t\\r\\n\\f]+$","g"),ad=RegExp("^[\\x20\\t\\r\\n\\f]*,[\\x20\\t\\r\\n\\f]*"),bd=RegExp("^[\\x20\\t\\r\\n\\f]*([\\x20\\t\\r\\n\\f>+~])[\\x20\\t\\r\\n\\f]*"),ed=RegExp(":((?:\\\\.|[-\\w]|[^\\x00-\\xa0])+)(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:\\[[\\x20\\t\\r\\n\\f]*((?:\\\\.|[-\\w]|[^\\x00-\\xa0])+)[\\x20\\t\\r\\n\\f]*(?:([*^$|!~]?=)[\\x20\\t\\r\\n\\f]*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[-\\w#]|[^\\x00-\\xa0])+)|)|)[\\x20\\t\\r\\n\\f]*\\])|[^:]|\\\\.)*|.*))\\)|)"),
188Zc=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,Lc=/[\x20\t\r\n\f]*[+~]/,fd=/h\d/i,gd=/input|select|textarea|button/i,qc=/\\(?!\\)/g,Cc={ID:RegExp("^#((?:\\\\.|[-\\w]|[^\\x00-\\xa0])+)"),CLASS:RegExp("^\\.((?:\\\\.|[-\\w]|[^\\x00-\\xa0])+)"),NAME:RegExp("^\\[name=['\"]?((?:\\\\.|[-\\w]|[^\\x00-\\xa0])+)['\"]?\\]"),TAG:RegExp("^((?:\\\\.|[-\\w*]|[^\\x00-\\xa0])+)"),ATTR:RegExp("^\\[[\\x20\\t\\r\\n\\f]*((?:\\\\.|[-\\w]|[^\\x00-\\xa0])+)[\\x20\\t\\r\\n\\f]*(?:([*^$|!~]?=)[\\x20\\t\\r\\n\\f]*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[-\\w#]|[^\\x00-\\xa0])+)|)|)[\\x20\\t\\r\\n\\f]*\\]"),
189PSEUDO:RegExp("^:((?:\\\\.|[-\\w]|[^\\x00-\\xa0])+)(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:\\[[\\x20\\t\\r\\n\\f]*((?:\\\\.|[-\\w]|[^\\x00-\\xa0])+)[\\x20\\t\\r\\n\\f]*(?:([*^$|!~]?=)[\\x20\\t\\r\\n\\f]*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[-\\w#]|[^\\x00-\\xa0])+)|)|)[\\x20\\t\\r\\n\\f]*\\])|[^:]|\\\\.)*|.*))\\)|)"),POS:RegExp(":(even|odd|eq|gt|lt|nth|first|last)(?:\\([\\x20\\t\\r\\n\\f]*((?:-\\d)?\\d*)[\\x20\\t\\r\\n\\f]*\\)|)(?=[^-]|$)","i"),CHILD:RegExp("^:(only|nth|first|last)-child(?:\\([\\x20\\t\\r\\n\\f]*(even|odd|(([+-]|)(\\d*)n|)[\\x20\\t\\r\\n\\f]*(?:([+-]|)[\\x20\\t\\r\\n\\f]*(\\d+)|))[\\x20\\t\\r\\n\\f]*\\)|)",
190"i"),needsContext:RegExp("^[\\x20\\t\\r\\n\\f]*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\([\\x20\\t\\r\\n\\f]*((?:-\\d)?\\d*)[\\x20\\t\\r\\n\\f]*\\)|)(?=[^-]|$)","i")},lc=function(ya){var La=fc.createElement("div");try{return ya(La)}catch(Wa){return!1}finally{}};w=lc(function(ya){ya.appendChild(fc.createComment(""));return!ya.getElementsByTagName("*").length});var hd=lc(function(ya){ya.innerHTML="<a href='#'></a>";return ya.firstChild&&"undefined"!==typeof ya.firstChild.getAttribute&&"#"===ya.firstChild.getAttribute("href")}),
191id=lc(function(ya){ya.innerHTML="<select></select>";ya=typeof ya.lastChild.getAttribute("multiple");return"boolean"!==ya&&"string"!==ya}),Pc=lc(function(ya){ya.innerHTML="<div class='hidden e'></div><div class='hidden'></div>";if(!ya.getElementsByClassName||!ya.getElementsByClassName("e").length)return!1;ya.lastChild.className="e";return 2===ya.getElementsByClassName("e").length}),jd=lc(function(ya){ya.id=Ob+0;ya.innerHTML="<a name='"+Ob+"'></a><div name='"+Ob+"'></div>";Zb.insertBefore(ya,Zb.firstChild);
192var La=fc.getElementsByName&&fc.getElementsByName(Ob).length===2+fc.getElementsByName(Ob+0).length;Mc=!fc.getElementById(Ob);Zb.removeChild(ya);return La});try{uc.call(Zb.childNodes,0)[0].nodeType}catch(ya){uc=function(La){for(var Wa,tb=[];Wa=this[La];La++)tb.push(Wa);return tb}}Y.matches=function(ya,La){return Y(ya,null,null,La)};Y.matchesSelector=function(ya,La){return 0<Y(La,null,null,[ya]).length};var Nc=Y.getText=function(ya){var La,Wa="",tb=0;if(La=ya.nodeType)if(1===La||9===La||11===La){if("string"===
193typeof ya.textContent)return ya.textContent;for(ya=ya.firstChild;ya;ya=ya.nextSibling)Wa+=Nc(ya)}else{if(3===La||4===La)return ya.nodeValue}else for(;La=ya[tb];tb++)Wa+=Nc(La);return Wa};var Ic=Y.isXML=function(ya){return(ya=ya&&(ya.ownerDocument||ya).documentElement)?"HTML"!==ya.nodeName:!1};var $c=Y.contains=Zb.contains?function(ya,La){var Wa=9===ya.nodeType?ya.documentElement:ya;La=La&&La.parentNode;return ya===La||!!(La&&1===La.nodeType&&Wa.contains&&Wa.contains(La))}:Zb.compareDocumentPosition?
194function(ya,La){return La&&!!(ya.compareDocumentPosition(La)&16)}:function(ya,La){for(;La=La.parentNode;)if(La===ya)return!0;return!1};Y.attr=function(ya,La){var Wa,tb=Ic(ya);tb||(La=La.toLowerCase());return(Wa=Mb.attrHandle[La])?Wa(ya):tb||id?ya.getAttribute(La):(Wa=ya.getAttributeNode(La))?"boolean"===typeof ya[La]?ya[La]?La:null:Wa.specified?Wa.value:null:null};var Mb=Y.selectors={cacheLength:50,createPseudo:bc,match:Cc,attrHandle:hd?{}:{href:function(ya){return ya.getAttribute("href",2)},type:function(ya){return ya.getAttribute("type")}},
195find:{ID:Mc?function(ya,La,Wa){if("undefined"!==typeof La.getElementById&&!Wa)return(ya=La.getElementById(ya))&&ya.parentNode?[ya]:[]}:function(ya,La,Wa){if("undefined"!==typeof La.getElementById&&!Wa)return(La=La.getElementById(ya))?La.id===ya||"undefined"!==typeof La.getAttributeNode&&La.getAttributeNode("id").value===ya?[La]:M:[]},TAG:w?function(ya,La){if("undefined"!==typeof La.getElementsByTagName)return La.getElementsByTagName(ya)}:function(ya,La){La=La.getElementsByTagName(ya);if("*"===ya){for(var Wa=
196[],tb=0;ya=La[tb];tb++)1===ya.nodeType&&Wa.push(ya);return Wa}return La},NAME:jd&&function(ya,La){if("undefined"!==typeof La.getElementsByName)return La.getElementsByName(name)},CLASS:Pc&&function(ya,La,Wa){if("undefined"!==typeof La.getElementsByClassName&&!Wa)return La.getElementsByClassName(ya)}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(ya){ya[1]=ya[1].replace(qc,"");ya[3]=(ya[4]||
197ya[5]||"").replace(qc,"");"~="===ya[2]&&(ya[3]=" "+ya[3]+" ");return ya.slice(0,4)},CHILD:function(ya){ya[1]=ya[1].toLowerCase();"nth"===ya[1]?(ya[2]||Y.error(ya[0]),ya[3]=+(ya[3]?ya[4]+(ya[5]||1):2*("even"===ya[2]||"odd"===ya[2])),ya[4]=+(ya[6]+ya[7]||"odd"===ya[2])):ya[2]&&Y.error(ya[0]);return ya},PSEUDO:function(ya){var La,Wa;if(Cc.CHILD.test(ya[0]))return null;if(ya[3])ya[2]=ya[3];else if(La=ya[4])ed.test(La)&&(Wa=Ma(La,!0))&&(Wa=La.indexOf(")",La.length-Wa)-La.length)&&(La=La.slice(0,Wa),ya[0]=
198ya[0].slice(0,Wa)),ya[2]=La;return ya.slice(0,3)}},filter:{ID:Mc?function(ya){ya=ya.replace(qc,"");return function(La){return La.getAttribute("id")===ya}}:function(ya){ya=ya.replace(qc,"");return function(La){return(La="undefined"!==typeof La.getAttributeNode&&La.getAttributeNode("id"))&&La.value===ya}},TAG:function(ya){if("*"===ya)return function(){return!0};ya=ya.replace(qc,"").toLowerCase();return function(La){return La.nodeName&&La.nodeName.toLowerCase()===ya}},CLASS:function(ya){var La=Uc[Ob][ya+
199" "];return La||(La=new RegExp("(^|[\\x20\\t\\r\\n\\f])"+ya+"([\\x20\\t\\r\\n\\f]|$)"),Uc(ya,function(Wa){return La.test(Wa.className||"undefined"!==typeof Wa.getAttribute&&Wa.getAttribute("class")||"")}))},ATTR:function(ya,La,Wa){return function(tb,sb){tb=Y.attr(tb,ya);if(null==tb)return"!="===La;if(!La)return!0;tb+="";return"="===La?tb===Wa:"!="===La?tb!==Wa:"^="===La?Wa&&0===tb.indexOf(Wa):"*="===La?Wa&&-1<tb.indexOf(Wa):"$="===La?Wa&&tb.substr(tb.length-Wa.length)===Wa:"~="===La?-1<(" "+tb+" ").indexOf(Wa):
200"|="===La?tb===Wa||tb.substr(0,Wa.length+1)===Wa+"-":!1}},CHILD:function(ya,La,Wa,tb){return"nth"===ya?function(sb){var qb=sb.parentNode;if(1===Wa&&0===tb)return!0;if(qb){var hb=0;for(qb=qb.firstChild;qb&&(1!==qb.nodeType||(hb++,sb!==qb));qb=qb.nextSibling);}hb-=tb;return hb===Wa||0===hb%Wa&&0<=hb/Wa}:function(sb){var qb=sb;switch(ya){case "only":case "first":for(;qb=qb.previousSibling;)if(1===qb.nodeType)return!1;if("first"===ya)return!0;qb=sb;case "last":for(;qb=qb.nextSibling;)if(1===qb.nodeType)return!1;
201return!0}}},PSEUDO:function(ya,La){var Wa=Mb.pseudos[ya]||Mb.setFilters[ya.toLowerCase()]||Y.error("unsupported pseudo: "+ya);if(Wa[Ob])return Wa(La);if(1<Wa.length){var tb=[ya,ya,"",La];return Mb.setFilters.hasOwnProperty(ya.toLowerCase())?bc(function(sb,qb){for(var hb,yb=Wa(sb,La),ub=yb.length;ub--;)hb=Kc.call(sb,yb[ub]),sb[hb]=!(qb[hb]=yb[ub])}):function(sb){return Wa(sb,0,tb)}}return Wa}},pseudos:{not:bc(function(ya){var La=[],Wa=[],tb=Sc(ya.replace(Bc,"$1"));return tb[Ob]?bc(function(sb,qb,hb,
202yb){yb=tb(sb,null,yb,[]);for(var ub=sb.length;ub--;)if(hb=yb[ub])sb[ub]=!(qb[ub]=hb)}):function(sb,qb,hb){La[0]=sb;tb(La,null,hb,Wa);return!Wa.pop()}}),has:bc(function(ya){return function(La){return 0<Y(ya,La).length}}
202),contains:bc(function(ya){return function(La){return-1<(La.textContent||La.innerText||Nc(La)).indexOf(ya)}}),enabled:function(ya){return!1===ya.disabled},disabled:function(ya){return!0===ya.disabled},checked:function(ya){var La=ya.nodeName.toLowerCase();return"input"===La&&!!ya.checked||
203"option"===La&&!!ya.selected},selected:function(ya){ya.parentNode&&ya.parentNode.selectedIndex;return!0===ya.selected},parent:function(ya){return!Mb.pseudos.empty(ya)},empty:function(ya){var La;for(ya=ya.firstChild;ya;){if("@"<ya.nodeName||3===(La=ya.nodeType)||4===La)return!1;ya=ya.nextSibling}return!0},header:function(ya){return fd.test(ya.nodeName)},text:function(ya){var La,Wa;return"input"===ya.nodeName.toLowerCase()&&"text"===(La=ya.type)&&(null==(Wa=ya.getAttribute("type"))||Wa.toLowerCase()===
204La)},radio:ka("radio"),checkbox:ka("checkbox"),file:ka("file"),password:ka("password"),image:ka("image"),submit:pa("submit"),reset:pa("reset"),button:function(ya){var La=ya.nodeName.toLowerCase();return"input"===La&&"button"===ya.type||"button"===La},input:function(ya){return gd.test(ya.nodeName)},focus:function(ya){var La=ya.ownerDocument;return ya===La.activeElement&&(!La.hasFocus||La.hasFocus())&&!!(ya.type||ya.href||~ya.tabIndex)},active:function(ya){return ya===ya.ownerDocument.activeElement},
205first:oa(function(){return[0]}),last:oa(function(ya,La){return[La-1]}),eq:oa(function(ya,La,Wa){return[0>Wa?Wa+La:Wa]}),even:oa(function(ya,La){for(var Wa=0;Wa<La;Wa+=2)ya.push(Wa);return ya}),odd:oa(function(ya,La){for(var Wa=1;Wa<La;Wa+=2)ya.push(Wa);return ya}),lt:oa(function(ya,La,Wa){for(La=0>Wa?Wa+La:Wa;0<=--La;)ya.push(La);return ya}),gt:oa(function(ya,La,Wa){for(Wa=0>Wa?Wa+La:Wa;++Wa<La;)ya.push(Wa);return ya})}};var Wc=Zb.compareDocumentPosition?function(ya,La){return ya===La?(yc=!0,0):(ya.compareDocumentPosition&&
206La.compareDocumentPosition?ya.compareDocumentPosition(La)&4:ya.compareDocumentPosition)?-1:1}:function(ya,La){if(ya===La)return yc=!0,0;if(ya.sourceIndex&&La.sourceIndex)return ya.sourceIndex-La.sourceIndex;var Wa=[],tb=[];var sb=ya.parentNode;var qb=La.parentNode;var hb=sb;if(sb===qb)return Ha(ya,La);if(!sb)return-1;if(!qb)return 1;for(;hb;)Wa.unshift(hb),hb=hb.parentNode;for(hb=qb;hb;)tb.unshift(hb),hb=hb.parentNode;sb=Wa.length;qb=tb.length;for(hb=0;hb<sb&&hb<qb;hb++)if(Wa[hb]!==tb[hb])return Ha(Wa[hb],
207tb[hb]);return hb===sb?Ha(ya,tb[hb],-1):Ha(Wa[hb],La,1)};[0,0].sort(Wc);Tc=!yc;Y.uniqueSort=function(ya){var La,Wa=[],tb=1,sb=0;yc=Tc;ya.sort(Wc);if(yc){for(;La=ya[tb];tb++)La===ya[tb-1]&&(sb=Wa.push(tb));for(;sb--;)ya.splice(Wa[sb],1)}return ya};Y.error=function(ya){throw Error("Syntax error, unrecognized expression: "+ya);};var Sc=Y.compile=function(ya,La){var Wa,tb=[],sb=[],qb=Vc[Ob][ya+" "];if(!qb){La||=Ma(ya);for(Wa=La.length;Wa--;)qb=xb(La[Wa]),qb[Ob]?tb.push(qb):sb.push(qb);qb=Vc(ya,Gb(sb,
208tb))}return qb};fc.querySelectorAll&&function(){var ya,La=Rb,Wa=/'|\\/g,tb=/=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,sb=[":focus"],qb=[":active"],hb=Zb.matchesSelector||Zb.mozMatchesSelector||Zb.webkitMatchesSelector||Zb.oMatchesSelector||Zb.msMatchesSelector;lc(function(yb){yb.innerHTML="<select><option selected=''></option></select>";yb.querySelectorAll("[selected]").length||sb.push("\\[[\\x20\\t\\r\\n\\f]*(?:checked|disabled|ismap|multiple|readonly|selected|value)");yb.querySelectorAll(":checked").length||
209sb.push(":checked")});lc(function(yb){yb.innerHTML="<p test=''></p>";yb.querySelectorAll("[test^='']").length&&sb.push("[*^$]=[\\x20\\t\\r\\n\\f]*(?:\"\"|'')");yb.innerHTML="<input type='hidden'/>";yb.querySelectorAll(":enabled").length||sb.push(":enabled",":disabled")});sb=new RegExp(sb.join("|"));Rb=function(yb,ub,Db,Ib,Pb){if(!Ib&&!Pb&&!sb.test(yb)){var Qb=!0,Ub=Ob;var Jb=ub;var Hb=9===ub.nodeType&&yb;if(1===ub.nodeType&&"object"!==ub.nodeName.toLowerCase()){Hb=Ma(yb);(Qb=ub.getAttribute("id"))?
210Ub=Qb.replace(Wa,"\\$&"):ub.setAttribute("id",Ub);Ub="[id='"+Ub+"'] ";for(Jb=Hb.length;Jb--;)Hb[Jb]=Ub+Hb[Jb].join("");Jb=Lc.test(yb)&&ub.parentNode||ub;Hb=Hb.join(",")}if(Hb)try{return tc.apply(Db,uc.call(Jb.querySelectorAll(Hb),0)),Db}catch(kc){}finally{Qb||ub.removeAttribute("id")}}return La(yb,ub,Db,Ib,Pb)};hb&&(lc(function(yb){ya=hb.call(yb,"div");try{hb.call(yb,"[test!='']:sizzle"),qb.push("!=",":((?:\\\\.|[-\\w]|[^\\x00-\\xa0])+)(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:\\[[\\x20\\t\\r\\n\\f]*((?:\\\\.|[-\\w]|[^\\x00-\\xa0])+)[\\x20\\t\\r\\n\\f]*(?:([*^$|!~]?=)[\\x20\\t\\r\\n\\f]*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[-\\w#]|[^\\x00-\\xa0])+)|)|)[\\x20\\t\\r\\n\\f]*\\])|[^:]|\\\\.)*|.*))\\)|)")}catch(ub){}}),
211qb=new RegExp(qb.join("|")),Y.matchesSelector=function(yb,ub){ub=ub.replace(tb,"='$1']");if(!Ic(yb)&&!qb.test(ub)&&!sb.test(ub))try{var Db=hb.call(yb,ub);if(Db||ya||yb.document&&11!==yb.document.nodeType)return Db}catch(Ib){}return 0<Y(ub,null,null,[yb]).length})}();Mb.pseudos.nth=Mb.pseudos.eq;Mb.filters=Tb.prototype=Mb.pseudos;Mb.setFilters=new Tb;Y.attr=I.attr;I.find=Y;I.expr=Y.selectors;I.expr[":"]=I.expr.pseudos;I.unique=Y.uniqueSort;I.text=Y.getText;I.isXMLDoc=Y.isXML;I.contains=Y.contains})(a);
212var jb=/Until$/,Ya=/^(?:parents|prev(?:Until|All))/,Xa=/^.[^:#\[\.,]*$/,wb=I.expr.match.needsContext,Bb={children:!0,contents:!0,next:!0,prev:!0};I.fn.extend({find:function(w){var M,Y,ka,pa=this;if("string"!==typeof w)return I(w).filter(function(){Ha=0;for(M=pa.length;Ha<M;Ha++)if(I.contains(pa[Ha],this))return!0});var oa=this.pushStack("","find",w);var Ha=0;for(M=this.length;Ha<M;Ha++){var Ma=oa.length;I.find(w,this[Ha],oa);if(0<Ha)for(Y=Ma;Y<oa.length;Y++)for(ka=0;ka<Ma;ka++)if(oa[ka]===oa[Y]){oa.splice(Y--,
2131);break}}return oa},has:function(w){var M,Y=I(w,this),ka=Y.length;return this.filter(function(){for(M=0;M<ka;M++)if(I.contains(this,Y[M]))return!0})},not:function(w){return this.pushStack(l(this,w,!1),"not",w)},filter:function(w){return this.pushStack(l(this,w,!0),"filter",w)},is:function(w){return!!w&&("string"===typeof w?wb.test(w)?0<=I(w,this.context).index(this[0]):0<I.filter(w,this).length:0<this.filter(w).length)},closest:function(w,M){for(var Y,ka=0,pa=this.length,oa=[],Ha=wb.test(w)||"string"!==
214typeof w?I(w,M||this.context):0;ka<pa;ka++)for(Y=this[ka];Y&&Y.ownerDocument&&Y!==M&&11!==Y.nodeType;){if(Ha?-1<Ha.index(Y):I.find.matchesSelector(Y,w)){oa.push(Y);break}Y=Y.parentNode}oa=1<oa.length?I.unique(oa):oa;return this.pushStack(oa,"closest",w)},index:function(w){return w?"string"===typeof w?I.inArray(this[0],I(w)):I.inArray(w.jqx?w[0]:w,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(w,M){w="string"===typeof w?I(w,M):I.makeArray(w&&w.nodeType?[w]:w);M=I.merge(this.get(),
215w);return this.pushStack(h(w[0])||h(M[0])?M:I.unique(M))},addBack:function(w){return this.add(null==w?this.prevObject:this.prevObject.filter(w))}});I.fn.andSelf=I.fn.addBack;I.each({parent:function(w){return(w=w.parentNode)&&11!==w.nodeType?w:null},parents:function(w){return I.dir(w,"parentNode")},parentsUntil:function(w,M,Y){return I.dir(w,"parentNode",Y)},next:function(w){return k(w,"nextSibling")},prev:function(w){return k(w,"previousSibling")},nextAll:function(w){return I.dir(w,"nextSibling")},
216prevAll:function(w){return I.dir(w,"previousSibling")},nextUntil:function(w,M,Y){return I.dir(w,"nextSibling",Y)},prevUntil:function(w,M,Y){return I.dir(w,"previousSibling",Y)},siblings:function(w){return I.sibling((w.parentNode||{}).firstChild,w)},children:function(w){return I.sibling(w.firstChild)},contents:function(w){return I.nodeName(w,"iframe")?w.contentDocument||w.contentWindow.document:I.merge([],w.childNodes)}},function(w,M){I.fn[w]=function(Y,ka){var pa=I.map(this,M,Y);jb.test(w)||(ka=Y);
217ka&&"string"===typeof ka&&(pa=I.filter(ka,pa));pa=1<this.length&&!Bb[w]?I.unique(pa):pa;1<this.length&&Ya.test(w)&&(pa=pa.reverse());return this.pushStack(pa,w,Pa.call(arguments).join(","))}});I.extend({filter:function(w,M,Y){Y&&(w=":not("+w+")");return 1===M.length?I.find.matchesSelector(M[0],w)?[M[0]]:[]:I.find.matches(w,M)},dir:function(w,M,Y){var ka=[];for(w=w[M];w&&9!==w.nodeType&&(Y===b||1!==w.nodeType||!I(w).is(Y));)1===w.nodeType&&ka.push(w),w=w[M];return ka},sibling:function(w,M){for(var Y=
218[];w;w=w.nextSibling)1===w.nodeType&&w!==M&&Y.push(w);return Y}});var ob="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",Ab=/ JQXLite\d+="(?:null|\d+)"/g,Cb=/^\s+/,Eb=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Nb=/<([\w:]+)/,ic=/<tbody/i,mc=/<|&#?\w+;/,gc=/<(?:script|style|link)/i,jc=/<(?:script|object|embed|option|style)/i,hc=new RegExp("<(?:"+ob+")[\\s/>]",
219"i"),pc=/^(?:checkbox|radio)$/,Fc=/checked\s*(?:[^=]|=\s*.checked.)/i,Oc=/\/(java|ecma)script/i,Gc=/^\s*<!(?:\[CDATA\[|\-\-)|[\]\-]{2}>\s*$/g,Sb={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},zc=m(na),rc=zc.appendChild(na.createElement("div"));
220Sb.optgroup=Sb.option;Sb.tbody=Sb.tfoot=Sb.colgroup=Sb.caption=Sb.thead;
220Sb.th=Sb.td;I.support.htmlSerialize||(Sb._default=[1,"X<div>","</div>"]);I.fn.extend({text:function(w){return I.access(this,function(M){return M===b?I.text(this):this.empty().append((this[0]&&this[0].ownerDocument||na).createTextNode(M))},null,w,arguments.length)},wrapAll:function(w){if(I.isFunction(w))return this.each(function(Y){I(this).wrapAll(w.call(this,Y))});if(this[0]){var M=I(w,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&
221M.insertBefore(this[0]);M.map(function(){for(var Y=this;Y.firstChild&&1===Y.firstChild.nodeType;)Y=Y.firstChild;return Y}).append(this)}return this},wrapInner:function(w){return I.isFunction(w)?this.each(function(M){I(this).wrapInner(w.call(this,M))}):this.each(function(){var M=I(this),Y=M.contents();Y.length?Y.wrapAll(w):M.append(w)})},wrap:function(w){var M=I.isFunction(w);return this.each(function(Y){I(this).wrapAll(M?w.call(this,Y):w)})},unwrap:function(){return this.parent().each(function(){I.nodeName(this,
222"body")||I(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(w){1!==this.nodeType&&11!==this.nodeType||this.appendChild(w)})},prepend:function(){return this.domManip(arguments,!0,function(w){1!==this.nodeType&&11!==this.nodeType||this.insertBefore(w,this.firstChild)})},before:function(){if(!h(this[0]))return this.domManip(arguments,!1,function(M){this.parentNode.insertBefore(M,this)});if(arguments.length){var w=I.clean(arguments);return this.pushStack(I.merge(w,
223this),"before",this.selector)}},after:function(){if(!h(this[0]))return this.domManip(arguments,!1,function(M){this.parentNode.insertBefore(M,this.nextSibling)});if(arguments.length){var w=I.clean(arguments);return this.pushStack(I.merge(this,w),"after",this.selector)}},remove:function(w,M){for(var Y,ka=0;null!=(Y=this[ka]);ka++)if(!w||I.filter(w,[Y]).length)M||1!==Y.nodeType||(I.cleanData(Y.getElementsByTagName("*")),I.cleanData([Y])),Y.parentNode&&Y.parentNode.removeChild(Y);return this},empty:function(){for(var w,
224M=0;null!=(w=this[M]);M++)for(1===w.nodeType&&I.cleanData(w.getElementsByTagName("*"));w.firstChild;)w.removeChild(w.firstChild);return this},clone:function(w,M){w=null==w?!1:w;M=null==M?w:M;return this.map(function(){return I.clone(this,w,M)})},html:function(w){return I.access(this,function(M){var Y=this[0]||{},ka=0,pa=this.length;if(M===b)return 1===Y.nodeType?Y.innerHTML.replace(Ab,""):b;if(!("string"!==typeof M||gc.test(M)||!I.support.htmlSerialize&&hc.test(M)||!I.support.leadingWhitespace&&Cb.test(M)||
225Sb[(Nb.exec(M)||["",""])[1].toLowerCase()])){M=M.replace(Eb,"<$1></$2>");try{for(;ka<pa;ka++)Y=this[ka]||{},1===Y.nodeType&&(I.cleanData(Y.getElementsByTagName("*")),Y.innerHTML=M);Y=0}catch(oa){}}Y&&this.empty().append(M)},null,w,arguments.length)},replaceWith:function(w){if(!h(this[0])){if(I.isFunction(w))return this.each(function(M){var Y=I(this),ka=Y.html();Y.replaceWith(w.call(this,M,ka))});"string"!==typeof w&&(w=I(w).detach());return this.each(function(){var M=this.nextSibling,Y=this.parentNode;
226I(this).remove();M?I(M).before(w):I(Y).append(w)})}return this.length?this.pushStack(I(I.isFunction(w)?w():w),"replaceWith",w):this},detach:function(w){return this.remove(w,!0)},domManip:function(w,M,Y){w=[].concat.apply([],w);var ka=0,pa=w[0],oa=[],Ha=this.length;if(!I.support.checkClone&&1<Ha&&"string"===typeof pa&&Fc.test(pa))return this.each(function(){I(this).domManip(w,M,Y)});if(I.isFunction(pa))return this.each(function(gb){var mb=I(this);w[0]=pa.call(this,gb,M?mb.html():b);mb.domManip(w,M,
227Y)});if(this[0]){var Ma=I.buildFragment(w,this,oa);var Va=Ma.fragment;var lb=Va.firstChild;1===Va.childNodes.length&&(Va=lb);if(lb)for(M=M&&I.nodeName(lb,"tr"),Ma=Ma.cacheable||Ha-1;ka<Ha;ka++)Y.call(M&&I.nodeName(this[ka],"table")?n(this[ka],"tbody"):this[ka],ka===Ma?Va:I.clone(Va,!0,!0));Va=lb=null;oa.length&&I.each(oa,function(gb,mb){mb.src?I.ajax?I.ajax({url:mb.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):I.error("no ajax"):I.globalEval((mb.text||mb.textContent||mb.innerHTML||
228"").replace(Gc,""));mb.parentNode&&mb.parentNode.removeChild(mb)})}return this}});I.buildFragment=function(w,M,Y){var ka=w[0];M=M||na;M=!M.nodeType&&M[0]||M;M=M.ownerDocument||M;if(1===w.length&&"string"===typeof ka&&512>ka.length&&M===na&&"<"===ka.charAt(0)&&!jc.test(ka)&&(I.support.checkClone||!Fc.test(ka))&&(I.support.html5Clone||!hc.test(ka))){var pa=!0;var oa=I.fragments[ka];var Ha=oa!==b}oa||(oa=M.createDocumentFragment(),I.clean(w,M,oa,Y),pa&&(I.fragments[ka]=Ha&&oa));return{fragment:oa,cacheable:pa}};
229I.fragments={};I.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(w,M){I.fn[w]=function(Y){var ka=0,pa=[];Y=I(Y);var oa=Y.length;var Ha=1===this.length&&this[0].parentNode;if((null==Ha||Ha&&11===Ha.nodeType&&1===Ha.childNodes.length)&&1===oa)return Y[M](this[0]),this;for(;ka<oa;ka++)Ha=(0<ka?this.clone(!0):this).get(),I(Y[ka])[M](Ha),pa=pa.concat(Ha);return this.pushStack(pa,w,Y.selector)}});I.extend({clone:function(w,M,Y){var ka;
230if(I.support.html5Clone||I.isXMLDoc(w)||!hc.test("<"+w.nodeName+">
230"))var pa=w.cloneNode(!0);else rc.innerHTML=w.outerHTML,rc.removeChild(pa=rc.firstChild);if(!(I.support.noCloneEvent&&I.support.noCloneChecked||1!==w.nodeType&&11!==w.nodeType||I.isXMLDoc(w))){t(w,pa);var oa=u(w);var Ha=u(pa);for(ka=0;oa[ka];++ka)Ha[ka]&&t(oa[ka],Ha[ka])}if(M&&(r(w,pa),Y))for(oa=u(w),Ha=u(pa),ka=0;oa[ka];++ka)r(oa[ka],Ha[ka]);return pa},clean:function(w,M,Y,ka){var pa,oa,Ha=M===na&&zc,Ma=[];M&&"undefined"!==typeof M.createDocumentFragment||
231(M=na);for(pa=0;null!=(oa=w[pa]);pa++)if("number"===typeof oa&&(oa+=""),oa){if("string"===typeof oa)if(mc.test(oa)){Ha=Ha||m(M);var Va=M.createElement("div");Ha.appendChild(Va);oa=oa.replace(Eb,"<$1></$2>");var lb=(Nb.exec(oa)||["",""])[1].toLowerCase();var gb=Sb[lb]||Sb._default;var mb=gb[0];for(Va.innerHTML=gb[1]+oa+gb[2];mb--;)Va=Va.lastChild;if(!I.support.tbody)for(mb=ic.test(oa),gb="table"!==lb||mb?"<table>"!==gb[1]||mb?[]:Va.childNodes:Va.firstChild&&Va.firstChild.childNodes,lb=gb.length-1;0<=
232lb;--lb)I.nodeName(gb[lb],"tbody")&&!gb[lb].childNodes.length&&gb[lb].parentNode.removeChild(gb[lb]);!I.support.leadingWhitespace&&Cb.test(oa)&&Va.insertBefore(M.createTextNode(Cb.exec(oa)[0]),Va.firstChild);oa=Va.childNodes;Va.parentNode.removeChild(Va)}else oa=M.createTextNode(oa);oa.nodeType?Ma.push(oa):I.merge(Ma,oa)}Va&&(oa=Va=Ha=null);if(!I.support.appendChecked)for(pa=0;null!=(oa=Ma[pa]);pa++)I.nodeName(oa,"input")?x(oa):"undefined"!==typeof oa.getElementsByTagName&&I.grep(oa.getElementsByTagName("input"),
233x);if(Y)for(w=function(xb){if(!xb.type||Oc.test(xb.type))return ka?ka.push(xb.parentNode?xb.parentNode.removeChild(xb):xb):Y.appendChild(xb)},pa=0;null!=(oa=Ma[pa]);pa++)I.nodeName(oa,"script")&&w(oa)||(Y.appendChild(oa),"undefined"!==typeof oa.getElementsByTagName&&(oa=I.grep(I.merge([],oa.getElementsByTagName("script")),w),Ma.splice.apply(Ma,[pa+1,0].c
233oncat(oa)),pa+=oa.length));return Ma},cleanData:function(w,M){for(var Y,ka,pa,oa,Ha=0,Ma=I.expando,Va=I.cache,lb=I.support.deleteExpando,gb=I.event.special;null!=
234(pa=w[Ha]);Ha++)if(M||I.acceptData(pa))if(Y=(ka=pa[Ma])&&Va[ka]){if(Y.events)for(oa in Y.events)gb[oa]?I.event.remove(pa,oa):I.removeEvent(pa,oa,Y.handle);Va[ka]&&(delete Va[ka],lb?delete pa[Ma]:pa.removeAttribute?pa.removeAttribute(Ma):pa[Ma]=null,I.deletedIds.push(ka))}}});(function(){I.uaMatch=function(Y){Y=Y.toLowerCase();Y=/(chrome)[ \/]([\w.]+)/.exec(Y)||/(webkit)[ \/]([\w.]+)/.exec(Y)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(Y)||/(msie) ([\w.]+)/.exec(Y)||0>Y.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(Y)||
235[];return{browser:Y[1]||"",version:Y[2]||"0"}};var w=I.uaMatch(qa.userAgent);var M={};w.browser&&(M[w.browser]=!0,M.version=w.version);M.chrome?M.webkit=!0:M.webkit&&(M.safari=!0);I.browser=M;I.sub=function(){function Y(pa,oa){return new Y.fn.init(pa,oa)}I.extend(!0,Y,this);Y.superclass=this;Y.fn=Y.prototype=this();Y.fn.constructor=Y;Y.sub=this.sub;Y.fn.init=function(pa,oa){oa&&oa instanceof I&&!(oa instanceof Y)&&(oa=Y(oa));return I.fn.init.call(this,pa,oa,ka)};Y.fn.init.prototype=Y.fn;var ka=Y(na);
236return Y}})();var Lb,Wb,Xb,nc=/alpha\([^)]*\)/i,wc=/opacity=([^)]*)/,Vb=/^(top|right|bottom|left)$/,oc=/^(none|table(?!-c[ea]).+)/,cc=/^margin/,$b=new RegExp("^("+Ta+")(.*)$","i"),dc=new RegExp("^("+Ta+")(?!px)[a-z%]+$","i"),sa=new RegExp("^([-+])=("+Ta+")","i"),Ia={BODY:"block"},Qa={position:"absolute",visibility:"hidden",display:"block"},Za={letterSpacing:0,fontWeight:400},pb=["Top","Right","Bottom","Left"],zb=["Webkit","O","Moz","ms"],Fb=I.fn.toggle;I.fn.extend({css:function(w,M){return I.access(this,
237function(Y,ka,pa){return pa!==b?I.style(Y,ka,pa):I.css(Y,ka)},w,M,1<arguments.length)},show:function(){return A(this,!0)},hide:function(){return A(this)},toggle:function(w,M){var Y="boolean"===typeof w;return I.isFunction(w)&&I.isFunction(M)?Fb.apply(this,arguments):this.each(function(){(Y?w:y(this))?I(this).show():I(this).hide()})}});I.extend({cssHooks:{opacity:{get:function(w,M){if(M)return w=Lb(w,"opacity"),""===w?"1":w}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,
238widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":I.support.cssFloat?"cssFloat":"styleFloat"},style:function(w,M,Y,ka){if(w&&3!==w.nodeType&&8!==w.nodeType&&w.style){var pa,oa=I.camelCase(M),Ha=w.style;M=I.cssProps[oa]||(I.cssProps[oa]=B(Ha,oa));var Ma=I.cssHooks[M]||I.cssHooks[oa];if(Y!==b){var Va=typeof Y;"string"===Va&&(pa=sa.exec(Y))&&(Y=(pa[1]+1)*pa[2]+parseFloat(I.css(w,M)),Va="number");if(!(null==Y||"number"===Va&&isNaN(Y)||("number"!==Va||I.cssNumber[oa]||(Y+="px"),Ma&&"set"in Ma&&(Y=Ma.set(w,
239Y,ka))===b)))try{Ha[M]=Y}catch(lb){}}else return Ma&&"get"in Ma&&(pa=Ma.get(w,!1,ka))!==b?pa:Ha[M]}},css:function(w,M,Y,ka){var pa;var oa=I.camelCase(M);M=I.cssProps[oa]||(I.cssProps[oa]=B(w.style,oa));(oa=I.cssHooks[M]||I.cssHooks[oa])&&"get"in oa&&(pa=oa.get(w,!0,ka));pa===b&&(pa=Lb(w,M));
239"normal"===pa&&M in Za&&(pa=Za[M]);return Y||ka!==b?(w=parseFloat(pa),Y||I.isNumeric(w)?w||0:pa):pa},swap:function(w,M,Y){var ka,pa={};for(ka in M)pa[ka]=w.style[ka],w.style[ka]=M[ka];Y=Y.call(w);for(ka in M)w.style[ka]=
240pa[ka];return Y}});a.getComputedStyle?Lb=function(w,M){var Y=a.getComputedStyle(w,null),ka=w.style;if(Y){var pa=Y.getPropertyValue(M)||Y[M];""!==pa||I.contains(w.ownerDocument,w)||(pa=I.style(w,M));if(dc.test(pa)&&cc.test(M)){w=ka.width;M=ka.minWidth;var oa=ka.maxWidth;ka.minWidth=ka.maxWidth=ka.width=pa;pa=Y.width;ka.width=w;ka.minWidth=M;ka.maxWidth=oa}}return pa}:na.documentElement.currentStyle&&(Lb=function(w,M){var Y,ka=w.currentStyle&&w.currentStyle[M],pa=w.style;null==ka&&pa&&pa[M]&&(ka=pa[M]);
241if(dc.test(ka)&&!Vb.test(M)){var oa=pa.left;if(Y=w.runtimeStyle&&w.runtimeStyle.left)w.runtimeStyle.left=w.currentStyle.left;pa.left="fontSize"===M?"1em":ka;ka=pa.pixelLeft+"px";pa.left=oa;Y&&(w.runtimeStyle.left=Y)}return""===ka?"auto":ka});I.each(["height","width"],function(w,M){I.cssHooks[M]={get:function(Y,ka,pa){if(ka)return 0===Y.offsetWidth&&oc.test(Lb(Y,"display"))?I.swap(Y,Qa,function(){return z(Y,M,pa)}):z(Y,M,pa)},set:function(Y,ka,pa){return aa(Y,ka,pa?ha(Y,M,pa,I.support.boxSizing&&"border-box"===
242I.css(Y,"boxSizing")):0)}}});I.support.opacity||(I.cssHooks.opacity={get:function(w,M){return wc.test((M&&w.currentStyle?w.currentStyle.filter:w.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":M?"1":""},set:function(w,M){var Y=w.style;w=w.currentStyle;var ka=I.isNumeric(M)?"alpha(opacity="+100*M+")":"",pa=w&&w.filter||Y.filter||"";Y.zoom=1;if(1<=M&&""===I.trim(pa.replace(nc,""))&&Y.removeAttribute&&(Y.removeAttribute("filter"),w&&!w.filter))return;Y.filter=nc.test(pa)?pa.replace(nc,ka):pa+" "+ka}});
243I(function(){I.support.reliableMarginRight||(I.cssHooks.marginRight={get:function(w,M){return I.swap(w,{display:"inline-block"},function(){if(M)return Lb(w,"marginRight")})}});!I.support.pixelPosition&&I.fn.position&&I.each(["top","left"],function(w,M){I.cssHooks[M]={get:function(Y,ka){if(ka)return ka=Lb(Y,M),dc.test(ka)?I(Y).position()[M]+"px":ka}}})});I.expr&&I.expr.filters&&(I.expr.filters.hidden=function(w){return 0===w.offsetWidth&&0===w.offsetHeight||!I.support.reliableHiddenOffsets&&"none"===
244(w.style&&w.style.display||Lb(w,"display"))},I.expr.filters.visible=function(w){return!I.expr.filters.hidden(w)});I.each({margin:"",padding:"",border:"Width"},function(w,M){I.cssHooks[w+M]={expand:function(Y){var ka="string"===typeof Y?Y.split(" "):[Y],pa={};for(Y=0;4>Y;Y++)pa[w+pb[Y]+M]=ka[Y]||ka[Y-2]||ka[0];return pa}};cc.test(w)||(I.cssHooks[w+M].set=aa)});var Kb=/%20/g,ac=/\[\]$/,Xc=/\r?\n/g,kd=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
245ld=/^(?:select|textarea)/i;I.fn.extend({serialize:function(){return I.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?I.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ld.test(this.nodeName)||kd.test(this.type))}).map(function(w,M){w=I(this).val();return null==w?null:I.isArray(w)?I.map(w,function(Y,ka){return{name:M.name,value:Y.replace(Xc,"\r\n")}}):{name:M.name,value:w.replace(Xc,"\r\n")}}).get()}});
246I.param=function(w,M){var Y,ka=[],pa=function(oa,Ha){Ha=I.isFunction(Ha)?Ha():null==Ha?"":Ha;ka[ka.length]=encodeURIComponent(oa)+"="+encodeURIComponent(Ha)};M===b&&(M=I.ajaxSettings&&I.ajaxSettings.traditional);if(I.isArray(w)||w.jqx&&!I.isPlainObject(w))I.each(w,function(){pa(this.name,this.value)});else for(Y in w)ba(Y,w[Y],M,pa);return ka.join("&").replace(Kb,"+")};I.support.ajax&&I.ajaxTransport(function(w){if(!w.crossDomain||I.support.cors){var M;return{send:function(Y,ka){var pa,oa=w.xhr();
247w.username?oa.open(w.type,w.url,w.async,w.username,w.password):oa.open(w.type,w.url,w.async);if(w.xhrFields)for(pa in w.xhrFields)oa[pa]=w.xhrFields[pa];w.mimeType&&oa.overrideMimeType&&oa.overrideMimeType(w.mimeType);w.crossDomain||Y["X-Requested-With"]||(Y["X-Requested-With"]="XMLHttpRequest");try{for(pa in Y)oa.setRequestHeader(pa,Y[pa])}catch(Ma){}oa.send(w.hasContent&&w.data||null);M=function(Ma,Va){var lb;try{if(M&&(Va||4===oa.readyState))if(M=b,Ha&&(oa.onreadystatechange=I.noop,xhrOnUnloadAbort&&
248delete xhrCallbacks[Ha]),Va)4!==oa.readyState&&oa.abort();else{var gb=oa.status;var mb=oa.getAllResponseHeaders();var xb={};(lb=oa.responseXML)&&lb.documentElement&&(xb.xml=lb);try{xb.text=oa.responseText}catch(Rb){}try{var Gb=oa.statusText}catch(Rb){Gb=""}gb||!w.isLocal||w.crossDomain?1223===gb&&(gb=204):gb=xb.text?200:404}}catch(Rb){Va||ka(-1,Rb)}xb&&ka(gb,Gb,xb,mb)};
248if(w.async)if(4===oa.readyState)setTimeout(M,0);else{var Ha=++xhrId;xhrOnUnloadAbort&&(xhrCallbacks||(xhrCallbacks={},I(a).unload(xhrOnUnloadAbort)),
249xhrCallbacks[Ha]=M);oa.onreadystatechange=M}else M()},abort:function(){M&&M(0,1)}}}});var sc,Hc,md=/^(?:toggle|show|hide)$/,nd=new RegExp("^(?:([-+])=|)("+Ta+")([a-z%]*)$","i"),od=/queueHooks$/,Ac=[function(w,M,Y){var ka,pa=this,oa=w.style,Ha={},Ma=[],Va=w.nodeType&&y(w);if(!Y.queue){var lb=I._queueHooks(w,"fx");if(null==lb.unqueued){lb.unqueued=0;var gb=lb.empty.fire;lb.empty.fire=function(){lb.unqueued||gb()}}lb.unqueued++;pa.always(function(){pa.always(function(){lb.unqueued--;I.queue(w,"fx").length||
250lb.empty.fire()})})}1===w.nodeType&&("height"in M||"width"in M)&&(Y.overflow=[oa.overflow,oa.overflowX,oa.overflowY],"inline"===I.css(w,"display")&&"none"===I.css(w,"float")&&(I.support.inlineBlockNeedsLayout&&"inline"!==V(w.nodeName)?oa.zoom=1:oa.display="inline-block"));Y.overflow&&(oa.overflow="hidden",I.support.shrinkWrapBlocks||pa.done(function(){oa.overflow=Y.overflow[0];oa.overflowX=Y.overflow[1];oa.overflowY=Y.overflow[2]}));for(ka in M){var mb=M[ka];if(md.exec(mb)){delete M[ka];var xb=xb||
251"toggle"===mb;mb!==(Va?"hide":"show")&&Ma.push(ka)}}if(M=Ma.length)for(mb=I._data(w,"fxshow")||I._data(w,"fxshow",{}),("hidden"in mb)&&(Va=mb.hidden),xb&&(mb.hidden=!Va),Va?I(w).show():pa.done(function(){I(w).hide()}),pa.done(function(){var Rb;I.removeData(w,"fxshow",!0);for(Rb in Ha)I.style(w,Rb,Ha[Rb])}),ka=0;ka<M;ka++){xb=Ma[ka];var Gb=pa.createTween(xb,Va?mb[xb]:0);Ha[xb]=mb[xb]||I.style(w,xb);xb in mb||(mb[xb]=Gb.start,Va&&(Gb.end=Gb.start,Gb.start="width"===xb||"height"===xb?1:0))}}],xc={"*":[function(w,
252M){var Y=this.createTween(w,M),ka=nd.exec(M),pa=Y.cur(),oa=+pa||0,Ha=1,Ma=20;if(ka){M=+ka[2];var Va=ka[3]||(I.cssNumber[w]?"":"px");if("px"!==Va&&oa){oa=I.css(Y.elem,w,!0)||M||1;do Ha=Ha||".5",oa/=Ha,I.style(Y.elem,w,oa+Va);while(Ha!==(Ha=Y.cur()/pa)&&1!==Ha&&--Ma)}Y.unit=Va;Y.start=oa;Y.end=ka[1]?oa+(ka[1]+1)*M:M}return Y}]};I.Animation=I.extend(C,{tweener:function(w,M){I.isFunction(w)?(M=w,w=["*"]):w=w.split(" ");for(var Y,ka=0,pa=w.length;ka<pa;ka++)Y=w[ka],xc[Y]=xc[Y]||[],xc[Y].unshift(M)},prefilter:function(w,
253M){M?Ac.unshift(w):Ac.push(w)}});I.Tween=ja;ja.prototype={constructor:ja,init:function(w,M,Y,ka,pa,oa){this.elem=w;this.prop=Y;this.easing=pa||"swing";this.options=M;this.start=this.now=this.cur();this.end=ka;this.unit=oa||(I.cssNumber[Y]?"":"px")},cur:function(){var w=ja.propHooks[this.prop];return w&&w.get?w.get(this):ja.propHooks._default.get(this)},run:function(w){var M,Y=ja.propHooks[this.prop];this.pos=this.options.duration?M=I.easing[this.easing](w,this.options.duration*w,0,1,this.options.duration):
254M=w;this.now=(this.end-this.start)*M+this.start;this.options.step&&this.options.step.call(this.elem,this.now,this);Y&&Y.set?Y.set(this):ja.propHooks._default.set(this);return this}};ja.prototype.init.prototype=ja.prototype;ja.propHooks={_default:{get:function(w){return null==w.elem[w.prop]||w.elem.style&&null!=w.elem.style[w.prop]?(w=I.css(w.elem,w.prop,!1,""))&&"auto"!==w?w:0:w.elem[w.prop]},set:function(w){if(I.fx.step[w.prop])I.fx.step[w.prop](w);else w.elem.style&&(null!=w.elem.style[I.cssProps[w.prop]]||
255I.cssHooks[w.prop])?I.style(w.elem,w.prop,w.now+w.unit):w.elem[w.prop]=w.now}}};ja.propHooks.scrollTop=ja.propHooks.scrollLeft={set:function(w){w.elem.nodeType&&w.elem.parentNode&&(w.elem[w.prop]=w.now)}};I.each(["toggle","show","hide"],function(w,M){var Y=I.fn[M];I.fn[M]=function(ka,pa,oa){return null==ka||"boolean"===typeof ka||!w&&I.isFunction(ka)&&I.isFunction(pa)?Y.apply(this,arguments):this.animate(ea(M,!0),ka,pa,oa)}});I.fn.extend({fadeTo:function(w,M,Y,ka){return this.filter(y).css("opacity",
2560).show().end().animate({opacity:M},w,Y,ka)},animate:function(w,M,Y,ka){var pa=I.isEmptyObject(w),oa=I.speed(M,Y,ka);M=function(){var Ha=C(this,I.extend({},w),oa);pa&&Ha.stop(!0)};return pa||!1===oa.queue?this.each(M):this.queue(oa.queue,M)},stop:function(w,M,Y){var ka=function(pa){var oa=pa.stop;delete pa.stop;oa(Y)};"string"!==typeof w&&(Y=M,M=w,w=b);M&&!1!==w&&this.queue(w||"fx",[]);return this.each(function(){var pa=!0,oa=null!=w&&w+"queueHooks",Ha=I.timers,Ma=I._data(this);if(oa)Ma[oa]&&Ma[oa].stop&&
257ka(Ma[oa]);else for(oa in Ma)Ma[oa]&&Ma[oa].stop&&od.test(oa)&&ka(Ma[oa]);for(oa=Ha.length;oa--;)Ha[oa].elem!==this||null!=w&&Ha[oa].queue!==w||(Ha[oa].anim.stop(Y),pa=!1,Ha.splice(oa,1));!pa&&Y||I.dequeue(this,w)})}});I.each({slideDown:ea("show"),slideUp:ea("hide"),slideToggle:ea("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(w,M){I.fn[w]=function(Y,ka,pa){return this.animate(M,Y,ka,pa)}});I.speed=function(w,M,Y){var ka=w&&"object"===typeof w?I.extend({},
258w):{complete:Y||!Y&&M||I.isFunction(w)&&w,duration:w,easing:Y&&M||M&&!I.isFunction(M)&&M};ka.duration=I.fx.off?0:"number"===typeof ka.duration?ka.duration:ka.duration in I.fx.speeds?I.fx.speeds[ka.duration]:I.fx.speeds._default;if(null==ka.queue||!0===ka.queue)ka.queue="fx";ka.old=ka.complete;ka.complete=function(){I.isFunction(ka.old)&&ka.old.call(this);ka.queue&&I.dequeue(this,ka.queue)};return ka};I.easing={linear:function(w){return w},swing:function(w){return.5-Math.cos(w*Math.PI)/2}};I.timers=
259[];I.fx=ja.prototype.init;I.fx.tick=function(){var w=I.timers,M=0;for(sc=I.now();M<w.length;M++){var Y=w[M];Y()||w[M]!==Y||w.splice(M--,1)}w.length||I.fx.stop();sc=b};
259I.fx.timer=function(w){w()&&I.timers.push(w)&&!Hc&&(Hc=setInterval(I.fx.tick,I.fx.interval))};I.fx.interval=13;I.fx.stop=function(){clearInterval(Hc);Hc=null};I.fx.speeds={slow:600,fast:200,_default:400};I.fx.step={};I.expr&&I.expr.filters&&(I.expr.filters.animated=function(w){return I.grep(I.timers,function(M){return w===M.elem}).length});
260var Yc=/^(?:body|html)$/i;I.fn.offset=function(w){if(arguments.length)return w===b?this:this.each(function(Ma){I.offset.setOffset(this,w,Ma)});var M,Y,ka,pa={top:0,left:0};if(ka=(Y=this[0])&&Y.ownerDocument){if((M=ka.body)===Y)return I.offset.bodyOffset(Y);var oa=ka.documentElement;if(!I.contains(oa,Y))return pa;"undefined"!==typeof Y.getBoundingClientRect&&(pa=Y.getBoundingClientRect());Y=ra(ka);ka=oa.clientTop||M.clientTop||0;M=oa.clientLeft||M.clientLeft||0;var Ha=Y.pageYOffset||oa.scrollTop;return{top:pa.top+
261Ha-ka,left:pa.left+(Y.pageXOffset||oa.scrollLeft)-M}}};I.offset={bodyOffset:function(w){var M=w.offsetTop,Y=w.offsetLeft;I.support.doesNotIncludeMarginInBodyOffset&&(M+=parseFloat(I.css(w,"marginTop"))||0,Y+=parseFloat(I.css(w,"marginLeft"))||0);return{top:M,left:Y}},setOffset:function(w,M,Y){var ka=I.css(w,"position");"static"===ka&&(w.style.position="relative");var pa=I(w),oa=pa.offset(),Ha=I.css(w,"top"),Ma=I.css(w,"left"),Va={};("absolute"===ka||"fixed"===ka)&&-1<I.inArray("auto",[Ha,Ma])?(Ma=
262pa.position(),ka=Ma.top,Ma=Ma.left):(ka=parseFloat(Ha)||0,Ma=parseFloat(Ma)||0);I.isFunction(M)&&(M=M.call(w,Y,oa));null!=M.top&&(Va.top=M.top-oa.top+ka);null!=M.left&&(Va.left=M.left-oa.left+Ma);"using"in M?M.using.call(w,Va):pa.css(Va)}};I.fn.extend({isRendered:function(){var w=this[0];return null==w.parentNode||0===w.offsetWidth||0===w.offsetHeight?!1:!0},getSizeFromStyle:function(){var w=null,M=null,Y=this[0];Y.style.width&&(w=Y.style.width);Y.style.height&&(M=Y.style.height);if(Y=a.getComputedStyle?
263getComputedStyle(Y,null):Y.currentStyle)Y.width&&(w=Y.width),Y.height&&(M=Y.height);"0px"===w&&(w=0);"0px"===M&&(M=0);null===w&&(w=0);null===M&&(M=0);return{width:w,height:M}},initAnimate:function(){},sizeStyleChanged:function(w){var M=this,Y=function(pa){var oa=ka;pa&&pa[0]&&"style"===pa[0].attributeName&&"attributes"===pa[0].type&&(oa.element.offsetWidth!==oa.offsetWidth||oa.element.offsetHeight!==oa.offsetHeight)&&(oa.offsetWidth=oa.element.offsetWidth,oa.offsetHeight=oa.element.offsetHeight,M.isRendered()&&
264oa.callback())};var ka={element:M[0],offsetWidth:M[0].offsetWidth,offsetHeight:M[0].offsetHeight,callback:w};try{M.elementStyleObserver||(M.elementStyleObserver=new MutationObserver(Y),M.elementStyleObserver.observe(M[0],{attributes:!0,childList:!1,characterData:!1}))}catch(pa){}},position:function(){if(this[0]){var w=this[0],M=this.offsetParent(),Y=this.offset(),ka=Yc.test(M[0].nodeName)?{top:0,left:0}:M.offset();Y.top-=parseFloat(I.css(w,"marginTop"))||0;Y.left-=parseFloat(I.css(w,"marginLeft"))||
2650;ka.top+=parseFloat(I.css(M[0],"borderTopWidth"))||0;ka.left+=parseFloat(I.css(M[0],"borderLeftWidth"))||0;return{top:Y.top-ka.top,left:Y.left-ka.left}}},offsetParent:function(){return this.map(function(){for(var w=this.offsetParent||na.body;w&&!Yc.test(w.nodeName)&&"static"===I.css(w,"position");)w=w.offsetParent;return w||na.body})}});I.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(w,M){var Y=/Y/.test(M);I.fn[w]=function(ka){return I.access(this,function(pa,oa,Ha){var Ma=ra(pa);
266if(Ha===b)return Ma?M in Ma?Ma[M]:Ma.document.documentElement[oa]:pa[oa];Ma?Ma.scrollTo(Y?I(Ma).scrollLeft():Ha,Y?Ha:I(Ma).scrollTop()):pa[oa]=Ha},w,ka,arguments.length,null)}});I.each({Height:"height",Width:"width"},function(w,M){I.each({padding:"inner"+w,content:M,"":"outer"+w},function(Y,ka){I.fn[ka]=function(pa,oa){var Ha=arguments.length&&(Y||"boolean"!==typeof pa),Ma=Y||(!0===pa||!0===oa?"margin":"border");return I.access(this,function(Va,lb,gb){return I.isWindow(Va)?Va.document.documentElement["client"+
267w]:9===Va.nodeType?(lb=Va.documentElement,Math.max(Va.body["scroll"+w],lb["scroll"+w],Va.body["offset"+w],lb["offset"+w],lb["client"+w])):gb===b?I.css(Va,lb,gb,Ma):I.style(Va,lb,gb,Ma)},M,Ha?pa:b,Ha,null)}})});a.JQXLite=a.jqxHelper=I;"function"===typeof define&&define.amd&&define.amd.JQXLite&&define("jqx",[],function(){return I})}(window);(function(a){a.jqxCore?(a.$$=a.minQuery=a.JQXLite,a.$||(a.$=a.minQuery)):a.jQuery?a.minQuery=a.JQXLite=a.jQuery:a.$?a.minQuery=a.JQXLite=a.$:a.$=a.minQuery=a.JQXLite})(window);
268JQXLite.generateID=function(){var a=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)},b="";do b="jqx"+a()+a()+a();while(0<$("#"+b).length);return b};var jqxBaseFramework=window.jqxBaseFramework=window.minQuery||window.jQuery;
269(function(a){a.jqx=a.jqx||{};window.jqx=a.jqx;var b={createInstance:function(c,d,e){if("jqxDataAdapter"==d)return new a.jqx.dataAdapter(e[0],e[1]||{});a(c)[d](e||{});return a(c)[d]("getInstance")}};window.jqwidgets=b;a.jqx.define=function(c,d,e){c[d]=function(){this.baseType&&(this.base=new c[this.baseType],this.base.defineInstance());this.defineInstance();this.metaInfo()};c[d].prototype.defineInstance=function(){};c[d].prototype.metaInfo=function(){};
269c[d].prototype.base=null;c[d].prototype.baseType=
270void 0;e&&c[e]&&(c[d].prototype.baseType=e)};a.jqx.invoke=function(c,d){if(0!=d.length){var e=typeof d==Array||0<d.length?d[0]:d;for(d=typeof d==Array||1<d.length?Array.prototype.slice.call(d,1):a({}).toArray();void 0==c[e]&&null!=c.base;){if(void 0!=c[e]&&a.isFunction(c[e]))return c[e].apply(c,d);if("string"==typeof e){var f=e.toLowerCase();if(void 0!=c[f]&&a.isFunction(c[f]))return c[f].apply(c,d)}c=c.base}if(void 0!=c[e]&&a.isFunction(c[e]))return c[e].apply(c,d);if("string"==typeof e&&(f=e.toLowerCase(),
271void 0!=c[f]&&a.isFunction(c[f])))return c[f].apply(c,d)}};a.jqx.getByPriority=function(c){for(var d=void 0,e=0;e<c.length&&void 0==d;e++)void 0==d&&void 0!=c[e]&&(d=c[e]);return d};a.jqx.hasProperty=function(c,d){if("object"==typeof d)for(var e in d){for(;c;){if(c.hasOwnProperty(e)||c.hasOwnProperty(e.toLowerCase()))return!0;c=c.base}break}else for(;c;){if(c.hasOwnProperty(d)||c.hasOwnProperty(d.toLowerCase()))return!0;c=c.base}return!1};a.jqx.hasFunction=function(c,d){if(0==d.length||void 0==c)return!1;
272var e=typeof d==Array||0<d.length?d[0]:d;for((typeof d==Array||1<d.length)&&Array.prototype.slice.call(d,1);void 0==c[e]&&null!=c.base;){if(c[e]&&a.isFunction(c[e])||"string"==typeof e&&(d=e.toLowerCase(),c[d]&&a.isFunction(c[d])))return!0;c=c.base}return c[e]&&a.isFunction(c[e])||"string"==typeof e&&(d=e.toLowerCase(),c[d]&&a.isFunction(c[d]))?!0:!1};a.jqx.isPropertySetter=function(c,d){return 1==d.length&&"object"==typeof d[0]||2==d.length&&"string"==typeof d[0]&&!a.jqx.hasFunction(c,d)?!0:!1};
273a.jqx.validatePropertySetter=function(c,d,e){if(!a.jqx.propertySetterValidation)return!0;if(1==d.length&&"object"==typeof d[0]){for(var f in d[0]){for(d=c;!d.hasOwnProperty(f)&&d.base;)d=d.base;if(!d||!d.hasOwnProperty(f)){if(!e)if(d.hasOwnProperty(f.toString().toLowerCase()))break;else throw"Invalid property: "+f;return!1}}return!0}if(2!=d.length){if(!e)throw 0<="Invalid property: "+d.length?d[0]:"";return!1}for(;!c.hasOwnProperty(d[0])&&c.base;)c=c.base;if(!c||!c.hasOwnProperty(d[0])){if(!e)throw"Invalid property: "+
274d[0];return!1}return!0};Object.keys||(Object.keys=function(){var c=Object.prototype.hasOwnProperty,d=!{toString:null}.propertyIsEnumerable("toString"),e="toString toLocaleString valueOf hasOwnProperty isPrototypeOf propertyIsEnumerable constructor".split(" "),f=e.length;return function(g){if("object"!==typeof g&&("function"!==typeof g||null===g))throw new TypeError("Object.keys called on non-object");var h=[],k;for(k in g)c.call(g,k)&&h.push(k);if(d)for(k=0;k<f;k++)c.call(g,e[k])&&h.push(e[k]);return h}}());
275a.jqx.set=function(c,d){var e=0;if(1==d.length&&"object"==typeof d[0]){if(c.isInitialized&&Object.keys&&1<Object.keys(d[0]).length){var f=a.data(c.base?c.base.element:c.element,c.widgetName).initArgs;if(f&&JSON&&JSON.stringify&&d[0]&&f[0])try{if(JSON.stringify(d[0])==JSON.stringify(f[0])){var g=!0;a.each(d[0],function(l,m){if(c[l]!=m)return g=!1});if(g)return}}catch(l){}c.batchUpdate=d[0];var h={},k={};a.each(d[0],function(l,m){for(var n=c;!n.hasOwnProperty(l)&&null!=n.base;)n=n.base;n.hasOwnProperty(l)?
276c[l]!=m&&(h[l]=c[l],k[l]=m,e++):n.hasOwnProperty(l.toLowerCase())&&c[l.toLowerCase()]!=m&&(h[l.toLowerCase()]=c[l.toLowerCase()],k[l.toLowerCase()]=m,e++)});2>e&&(c.batchUpdate=null)}a.each(d[0],function(l,m){for(var n=c;!n.hasOwnProperty(l)&&null!=n.base;)n=n.base;if(n.hasOwnProperty(l))a.jqx.setvalueraiseevent(n,l,m);else if(n.hasOwnProperty(l.toLowerCase()))a.jqx.setvalueraiseevent(n,l.toLowerCase(),m);else if(a.jqx.propertySetterValidation)throw"jqxCore: invalid property '"+l+"'";});null!=c.batchUpdate&&
277(c.batchUpdate=null,c.propertiesChangedHandler&&1<e&&c.propertiesChangedHandler(c,h,k))}else if(2==d.length){for(;!c.hasOwnProperty(d[0])&&c.base;)c=c.base;if(c.hasOwnProperty(d[0]))a.jqx.setvalueraiseevent(c,d[0],d[1]);else if(c.hasOwnProperty(d[0].toLowerCase()))a.jqx.setvalueraiseevent(c,d[0].toLowerCase(),d[1]);else if(a.jqx.propertySetterValidation)throw"jqxCore: invalid property '"+d[0]+"'";}};a.jqx.setvalueraiseevent=function(c,d,e){var f=c[d];c[d]=e;
277if(c.isInitialized&&(void 0!=c.propertyChangedHandler&&
278c.propertyChangedHandler(c,d,f,e),void 0!=c.propertyChangeMap&&void 0!=c.propertyChangeMap[d]))c.propertyChangeMap[d](c,d,f,e)};a.jqx.get=function(c,d){if(void 0!=d&&null!=d){if(c.propertyMap){var e=c.propertyMap(d);if(null!=e)return e}if(c.hasOwnProperty(d))return c[d];if(c.hasOwnProperty(d.toLowerCase()))return c[d.toLowerCase()];e=void 0;if(typeof d==Array){if(1!=d.length)return;e=d[0]}else"string"==typeof d&&(e=d);for(;!c.hasOwnProperty(e)&&c.base;)c=c.base;if(c)return c[e]}};a.jqx.serialize=
279function(c){if(a.isArray(c)){var d="[";for(var e=0;e<c.length;e++)0<e&&(d+=", "),d+=a.jqx.serialize(c[e]);d+="]"}else if("object"==typeof c){d="{";var f=0;for(e in c)0<f++&&(d+=", "),d+=e+": "+a.jqx.serialize(c[e]);d+="}"}else d=c.toString();return d};a.jqx.propertySetterValidation=!0;a.jqx.jqxWidgetProxy=function(c,d,e){a(d);c=a.data(d,c);if(void 0!=c){c=c.instance;if(a.jqx.hasFunction(c,e))return a.jqx.invoke(c,e);if(a.jqx.isPropertySetter(c,e)){if(a.jqx.validatePropertySetter(c,e)){a.jqx.set(c,
280e);return}}else{if("object"==typeof e&&0==e.length)return;if("object"==typeof e&&1==e.length&&a.jqx.hasProperty(c,e[0]))return a.jqx.get(c,e[0]);if("string"==typeof e&&a.jqx.hasProperty(c,e[0]))return a.jqx.get(c,e)}throw"jqxCore: Invalid parameter '"+a.jqx.serialize(e)+"' does not exist.";}};a.jqx.applyWidget=function(c,d,e,f){var g=!1;try{g=void 0!=window.MSApp}catch(n){}var h=a(c);f?(f.host=h,f.element=c):f=new a.jqx["_"+d];""==c.id&&(c.id=a.jqx.utilities.createId());var k={host:h,element:c,instance:f,
281initArgs:e};f.widgetName=d;a.data(c,d,k);a.data(c,"jqxWidget",k.instance);var l=[];for(f=k.instance;f;)f.isInitialized=!1,l.push(f),f=f.base;l.reverse();l[0].theme=a.jqx.theme||"";a.jqx.jqxWidgetProxy(d,c,e);for(var m in l)f=l[m],0==m&&(f.host=h,f.element=c,f.WinJS=g),void 0!=f&&(f.definedInstance&&f.definedInstance(),null!=f.createInstance&&(g?MSApp.execUnsafeLocalFunction(function(){f.createInstance(e)}):f.createInstance(e)));for(m in l)void 0!=l[m]&&(l[m].isInitialized=!0);g?MSApp.execUnsafeLocalFunction(function(){k.instance.refresh(!0)}):
282k.instance.refresh(!0)};a.jqx.jqxWidget=function(c,d,e){try{Array.prototype.slice.call(e,0)}catch(k){}var f="";d&&(f="_"+d);a.jqx.define(a.jqx,"_"+c,f);var g=[];if(!window[c]){var h=function(k){if(null==k)return"";switch(a.type(k)){case "string":case "number":case "date":case "boolean":case "bool":return null===k?"":k.toString()}var l="";a.each(k,function(m,n){0<m&&(l+=", ");l+="[";var r=0;if("object"==a.type(n))for(var t in n)0<r&&(l+=", "),l+="{"+t+":"+n[t]+"}",r++;else 0<r&&(l+=", "),l+="{"+m+
283":"+n+"}";l+="]"});return l};b[c]=window[c]=function(k,l){var m=[];l||={};m.push(l);var n=k;"object"===a.type(n)&&k[0]?(n=k[0].id,""===n&&(n=k[0].id=a.jqx.utilities.createId())):"object"===a.type(k)&&k&&k.nodeName&&(n=k.id,""===n&&(n=k.id=a.jqx.utilities.createId()));if(window.jqxWidgets&&window.jqxWidgets[n]){l&&a.each(window.jqxWidgets[n],function(x){if((x=a(this.element).data())&&x.jqxWidget)a(this.element)[c](l)});if(1==window.jqxWidgets[n].length){var r=a(window.jqxWidgets[n][0].widgetInstance.element).data();
284if(r&&r.jqxWidget)return window.jqxWidgets[n][0]}if((r=a(window.jqxWidgets[n][0].widgetInstance.element).data())&&r.jqxWidget)return window.jqxWidgets[n]}var t=a(k);if(0===t.length){t=a("<div></div>");if("jqxInput"===c||"jqxPasswordInput"===c||"jqxMaskedInput"===c)t=a("<input/>");"jqxTextArea"===c&&(t=a("<textarea></textarea>"));if("jqxButton"===c||"jqxRepeatButton"===c||"jqxToggleButton"===c)t=a("<button/>");"jqxSplitter"===c&&(t=a("<div><div>Panel 1</div><div>Panel 2</div></div>"));"jqxTabs"===
285c&&(t=a("<div><ul><li>Tab 1</li><li>Tab 2</li></ul><div>Content 1</div><div>Content 2</div></div>"));"jqxRibbon"===c&&(t=a("<div><ul><li>Tab 1</li><li>Tab 2</li></ul><div><div>Content 1</div><div>Content 2</div></div></div>"));"jqxDocking"===c&&(t=a("<div><div><div><div>Title 1</div><div>Content 1</div></div></div></div>"));"jqxWindow"===c&&(t=a("<div><div>Title 1</div><div>Content 1</div></div>"))}var u=[];a.each(t,function(x){x=t[x];a.jqx.applyWidget(x,c,m,void 0);if(!g[c]){var B=a.data(x,"jqxWidget");
286B=a.jqx["_"+c].prototype.defineInstance();a.jqx["_"+c].prototype.metaInfo&&a.jqx["_"+c].prototype.metaInfo();"jqxDockingLayout"==c&&(B=a.extend(B,a.jqx._jqxLayout.prototype.defineInstance()));if("jqxToggleButton"==c||"jqxRepeatButton"==c)B=a.extend(B,a.jqx._jqxButton.prototype.defineInstance());"jqxTreeGrid"==c&&(B=a.extend(B,a.jqx._jqxDataTable.prototype.defineInstance()));var y=function(A){this.widgetInstance=A=a.data(A,"jqxWidget");var aa=a.extend(this,A);aa.on=aa.addEventListener=function(z,V){aa.addHandler(aa.base?
287aa.base.host:aa.host,z,V)};aa.off=aa.removeEventListener=function(z){aa.removeHandler(aa.base?aa.base.host:aa.host,z)};for(var ha in A)"function"==a.type(A[ha])&&(aa[ha]=a.proxy(A[ha],A));return aa};g[c]=y;a.each(B,function(A,aa){Object.defineProperty(y.prototype,A,{get:function(){return this.widgetInstance?this.widgetInstance[A]:aa},set:function(ha){if(this.widgetInstance&&(this.widgetInstance[A]!=ha||"width"===A||"height"===A)){var z=this.widgetInstance[A],V=a.type(z),ba=a.type(ha),v=!1;if(V!=ba||
288"source"===A||"width"===A||"height"===A)v=!0;if(v||h(z)!=h(ha)){V={};V[A]=ha;if(this.widgetInstance.host)this.widgetInstance.host[c](V);else this.widgetInstance.base.host[c](V);this.widgetInstance[A]=ha;this.widgetInstance.propertyUpdated&&this.widgetInstance.propertyUpdated(A,z,ha)}}}})})}B=new g[c](x);u.push(B);window.jqxWidgets||(window.jqxWidgets=[]);window.jqxWidgets[n]||(window.jqxWidgets[n]=[]);window.jqxWidgets[n].push(B)});return 1===u.length?u[0]:u}}a.fn[c]=function(){var k=Array.prototype.slice.call(arguments,
2890);
289if(0==k.length||1==k.length&&"object"==typeof k[0]){if(0==this.length){if(this.selector)throw Error("Invalid Selector - "+this.selector+"! Please, check whether the used ID or CSS Class name is correct.");throw Error("Invalid Selector! Please, check whether the used ID or CSS Class name is correct.");}return this.each(function(){a(this);null==a.data(this,c)?a.jqx.applyWidget(this,c,k,void 0):a.jqx.jqxWidgetProxy(c,this,k)})}if(0==this.length){if(this.selector)throw Error("Invalid Selector - "+
290this.selector+"! Please, check whether the used ID or CSS Class name is correct.");throw Error("Invalid Selector! Please, check whether the used ID or CSS Class name is correct.");}var l=null,m=0;this.each(function(){var n=a.jqx.jqxWidgetProxy(c,this,k);if(0==m)l=n,m++;else{if(1==m){var r=[];r.push(l);l=r}l.push(n)}});return l};try{a.extend(a.jqx["_"+c].prototype,Array.prototype.slice.call(e,0)[0])}catch(k){}a.extend(a.jqx["_"+c].prototype,{toThemeProperty:function(k,l){return a.jqx.toThemeProperty(this,
291k,l)},isMaterialized:function(){if(!this.theme)return!1;if("light"===this.theme||"dark"===this.theme||"deepblue"===this.theme||0<=this.theme.indexOf("material"))return!0},isModern:function(){if(!this.theme)return!1;if(0<=this.theme.indexOf("light")||"dark"===this.theme)return!0},_addBarAndLabel:function(k){var l=a("<label></label");l[0].innerHTML=this.placeHolder;l.addClass(this.toThemeProperty("jqx-input-label"));k.after(l);this.label=l;
291l=a("<span></span>");k.after(l);l.addClass(this.toThemeProperty("jqx-input-bar"));
292this.bar=l;this.bar.css("top",this.host.height())}});a.jqx["_"+c].prototype.refresh=function(){this.base&&this.base.refresh(!0)};a.jqx["_"+c].prototype.createInstance=function(){};a.jqx["_"+c].prototype.addEventHandler=function(k,l){if(this.base)this.base.host.on(k,l);else this.host.on(k,l)};a.jqx["_"+c].prototype.removeEventHandler=function(k,l){this.base?this.base.host.off(k):this.host.off(k)};a.jqx["_"+c].prototype.applyTo=function(k,l){if(!(l instanceof Array)){var m=[];m.push(l);l=m}a.jqx.applyWidget(k,
293c,l,this)};a.jqx["_"+c].prototype.getInstance=function(){return this};a.jqx["_"+c].prototype.propertyChangeMap={};a.jqx["_"+c].prototype.addHandler=function(k,l,m,n){a.jqx.addHandler(a(k),l,m,n)};a.jqx["_"+c].prototype.removeHandler=function(k,l,m){a.jqx.removeHandler(a(k),l,m)};a.jqx["_"+c].prototype.setOptions=function(){if(this.host&&this.host.length&&1==this.host.length)return a.jqx.jqxWidgetProxy(c,this.host[0],arguments)}};a.jqx.toThemeProperty=function(c,d,e){if(""==c.theme)return d;d=d.split(" ");
294for(var f="",g=0;g<d.length;g++){0<g&&(f+=" ");var h=d[g];f=null!=e&&e?f+(h+"-"+c.theme):f+(h+" "+h+"-"+c.theme)}return f};a.jqx.addHandler=function(c,d,e,f){d=d.split(" ");for(var g=0;g<d.length;g++){var h=d[g];if(window.addEventListener)switch(h){case "mousewheel":a.jqx.browser.mozilla?c[0].addEventListener("DOMMouseScroll",e,!1):c[0].addEventListener("mousewheel",e,!1);continue;case "mousemove":if(!f){c[0].addEventListener("mousemove",e,!1);continue}break;case "touchmove":if(!f){c[0].addEventListener("touchmove",
295e,!1);continue}else if(f&&f.passive){c[0].addEventListener("touchmove",e,f);continue}}if(void 0==f||null==f)if(c.on)c.on(h,e);else c.bind(h,e);else if(c.on)c.on(h,f,e);else c.bind(h,f,e)}};a.jqx.removeHandler=function(c,d,e){if(d){d=d.split(" ");for(var f=0;f<d.length;f++){var g=d[f];if(window.removeEventListener)switch(g){case "mousewheel":a.jqx.browser.mozilla?c[0].removeEventListener("DOMMouseScroll",e,!1):c[0].removeEventListener("mousewheel",e,!1);continue;case "mousemove":if(e){c[0].removeEventListener("mousemove",
296e,!1);continue}break;case "touchmove":if(e){c[0].removeEventListener("touchmove",e,!1);continue}}void 0==g?c.off?c.off():c.unbind():void 0==e?c.off?c.off(g):c.unbind(g):c.off?c.off(g,e):c.unbind(g,e)}}else c.off?c.off():c.unbind()};a.jqx.credits=a.jqx.credits||"";a.jqx.theme=a.jqx.theme||"";a.jqx.scrollAnimation=a.jqx.scrollAnimation||!1;a.jqx.resizeDelay=a.jqx.resizeDelay||10;a.jqx.ready=function(){a(window).trigger("jqxReady")};a.jqx.init=function(c){a.each(c,function(d,e){"theme"==d&&(a.jqx.theme=
297e);"scrollBarSize"==d&&(a.jqx.utilities.scrollBarSize=e);"touchScrollBarSize"==d&&(a.jqx.utilities.touchScrollBarSize=e);"scrollBarButtonsVisibility"==d&&(a.jqx.utilities.scrollBarButtonsVisibility=e)})};a.jqx.utilities=a.jqx.utilities||{};a.extend(a.jqx.utilities,{scrollBarSize:13,touchScrollBarSize:8,scrollBarButtonsVisibility:"visible",createId:function(){var c=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return"jqxWidget"+c()+c()+c()},setTheme:function(c,d,e){if("undefined"!==
298typeof e&&e[0].className.split){void 0===c&&(c="");void 0===d&&(d="");for(var f=e[0].className.split(" "),g=[],h=[],k=e.children(),l=0;l<f.length;l+=1)0<=f[l].indexOf(c)&&(0<c.length?(g.push(f[l]),h.push(f[l].replace(c,d))):h.push(f[l].replace("-"+d,"")+"-"+d));this._removeOldClasses(g,e);this._addNewClasses(h,e);for(l=0;l<k.length;l+=1)this.setTheme(c,d,a(k[l]))}},_removeOldClasses:function(c,d){for(var e=0;e<c.length;e+=1)d.removeClass(c[e])},_addNewClasses:function(c,d){for(var e=0;e<c.length;e+=
2991)d.addClass(c[e])},getOffset:function(c){var d=a.jqx.mobile.getLeftPos(c[0]);return{top:a.jqx.mobile.getTopPos(c[0]),left:d}},resize:function(c,d,e,f){void 0===f&&(f=!0);var g=-1,h=this,k=function(t){if(!h.hiddenWidgets)return-1;for(var u=-1,x=0;x<h.hiddenWidgets.length;x++)if(t.id){if(h.hiddenWidgets[x].id==t.id){u=x;break}}else if(h.hiddenWidgets[x].id==t[0].id){u=x;break}return u};if(this.resizeHandlers){for(var l=0;l<this.resizeHandlers.length;
299l++)if(c.id){if(this.resizeHandlers[l].id==c.id){g=
300l;break}}else if(this.resizeHandlers[l].id==c[0].id){g=l;break}if(!0===e){-1!=g&&(this.resizeHandlers.splice(g,1),this.watchedElementData&&0<this.watchedElementData.length&&this.watchedElementData.splice(g,1));0==this.resizeHandlers.length&&(e=a(window),e.off?(e.off("resize.jqx"),e.off("orientationchange.jqx"),e.off("orientationchanged.jqx")):(e.unbind("resize.jqx"),e.unbind("orientationchange.jqx"),e.unbind("orientationchanged.jqx")),this.resizeHandlers=null);c=k(c);-1!=c&&this.hiddenWidgets&&this.hiddenWidgets.splice(c,
3011);return}}else if(!0===e){c=k(c);-1!=c&&this.hiddenWidgets&&this.hiddenWidgets.splice(c,1);return}h=this;var m=function(t,u){if(h.resizeHandlers){var x=function(K){var C=-1;for(K=K.parentNode;K;)C++,K=K.parentNode;return C},B=function(K,C){if(!K.widget||!C.widget)return 0;K=x(K.widget[0]);C=x(C.widget[0]);return K<C?-1:K>C?1:0},y=function(K){if(0<h.hiddenWidgets.length){h.hiddenWidgets.sort(B);var C=function(){for(var da=!1,ja=[],ea=0;ea<h.hiddenWidgets.length;ea++){var ra=h.hiddenWidgets[ea];a.jqx.isHidden(ra.widget)?
302(da=!0,ja.push(ra)):ra.callback&&ra.callback(u)}h.hiddenWidgets=ja;da||clearInterval(h.__resizeInterval)};0==K?(C(),h.__resizeInterval&&clearInterval(h.__resizeInterval)):(h.__resizeInterval&&clearInterval(h.__resizeInterval),h.__resizeInterval=setInterval(function(){C()},100))}};h.hiddenWidgets&&0<h.hiddenWidgets.length&&y(!1);h.hiddenWidgets=[];h.resizeHandlers.sort(B);for(var A=0;A<h.resizeHandlers.length;A++){var aa=h.resizeHandlers[A],ha=aa.widget,z=aa.data;if(z&&z.jqxWidget){var V=z.jqxWidget.width,
303ba=z.jqxWidget.height;z.jqxWidget.base&&(void 0==V&&(V=z.jqxWidget.base.width),void 0==ba&&(ba=z.jqxWidget.base.height));void 0===V&&void 0===ba&&(V=z.jqxWidget.element.style.width,ba=z.jqxWidget.element.style.height);var v=!1;null!=V&&-1!=V.toString().indexOf("%")&&(v=!0);null!=ba&&-1!=ba.toString().indexOf("%")&&(v=!0);if(a.jqx.isHidden(ha))-1===k(ha)&&(v||!0===t)&&!0!==aa.data.nestedWidget&&h.hiddenWidgets.push(aa);else if(void 0===t||!0!==t){if(v){aa.callback(u);if(h.watchedElementData)for(ha=
3040;ha<h.watchedElementData.length;ha++)if(h.watchedElementData[ha].element==z.jqxWidget.element){h.watchedElementData[ha].offsetWidth=z.jqxWidget.element.offsetWidth;h.watchedElementData[ha].offsetHeight=z.jqxWidget.element.offsetHeight;break}0<=h.hiddenWidgets.indexOf(aa)&&h.hiddenWidgets.splice(h.hiddenWidgets.indexOf(aa),1)}z.jqxWidget.element&&(aa=z.jqxWidget.element.className,!((0<=aa.indexOf("dropdownlist")||0<=aa.indexOf("datetimeinput")||0<=aa.indexOf("combobox")||0<=aa.indexOf("menu"))&&z.jqxWidget.isOpened&&
305z.jqxWidget.isOpened())||u&&"resize"==u&&a.jqx.mobile.isTouchDevice()||z.jqxWidget.close())}}}y()}};this.resizeHandlers||(this.resizeHandlers=[],e=a(window),e.on?(this._initResize=this._resizeTimer=null,e.on("resize.jqx",function(t){void 0!=h._resizeTimer&&clearTimeout(h._resizeTimer);h._initResize?h._resizeTimer=setTimeout(function(){m(null,"resize")},a.jqx.resizeDelay):(h._initResize=!0,m(null,"resize"))}),e.on("orientationchange.jqx",function(t){m(null,"orientationchange")}),e.on("orientationchanged.jqx",
306function(t){m(null,"orientationchange")})):(e.bind("resize.jqx",function(t){m(null,"orientationchange")}),e.bind("orientationchange.jqx",function(t){m(null,"orientationchange")}),e.bind("orientationchanged.jqx",function(t){m(null,"orientationchange")})));e=c.data();f&&-1===g&&this.resizeHandlers.push({id:c[0].id,widget:c,callback:d,data:e});try{var n=e.jqxWidget.width,r=e.jqxWidget.height;e.jqxWidget.base&&(void 0==n&&(n=e.jqxWidget.base.width),void 0==r&&(r=e.jqxWidget.base.height));void 0===n&&
307void 0===r&&(n=e.jqxWidget.element.style.width,r=e.jqxWidget.element.style.height);g=!1;null!=n&&-1!=n.toString().indexOf("%")&&(g=!0);null!=r&&-1!=r.toString().indexOf("%")&&(g=!0);g&&(this.watchedElementData||(this.watchedElementData=[]),h=this,n=function(t){h.watchedElementData.forEach&&h.watchedElementData.forEach(function(u){if(u.element.offsetWidth!==u.offsetWidth||u.element.offsetHeight!==u.offsetHeight)u.offsetWidth=u.element.offsetWidth,u.offsetHeight=u.element.offsetHeight,u.timer&&clearTimeout(u.timer),
308u.timer=setTimeout(function(){a.jqx.isHidden(a(u.element))?u.timer=setInterval(function(){a.jqx.isHidden(a(u.element))||(clearInterval(u.timer),u.callback())},100):u.callback()})})},h.watchedElementData.push({element:c[0],offsetWidth:c[0].offsetWidth,offsetHeight:c[0].offsetHeight,callback:d}),h.observer||(h.observer=new MutationObserver(n),h.observer.observe(document.body,{attributes:!0,childList:!0,characterData:!0}
308)))}catch(t){}a.jqx.isHidden(c)&&!0===f&&m(!0);a.jqx.resize=function(){m(null,"resize")}},
309parseJSON:function(c){if(!c||"string"!==typeof c)return null;c=a.trim(c);if(window.JSON&&window.JSON.parse)return window.JSON.parse(c);if(/^[\],:{}\s]*$/.test(c.replace(/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,"@").replace(/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return(new Function("return "+c))();throw Error("Invalid JSON: "+c);},html:function(c,d){if(!a(c).on)return a(c).html(d);try{return a.access(c,function(e){var f=c[0]||{},g=
3100,h=c.length;if(void 0===e)return 1===f.nodeType?f.innerHTML.replace(rinlinejQuery,""):void 0;var k=/<(?:script|style|link)/i,l=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,m=/<([\w:]+)/,n=RegExp("<(?:abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video)[\\s/>]","i"),r=/^\s+/,t={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],
311thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};if(!("string"!==typeof e||k.test(e)||!a.support.htmlSerialize&&n.test(e)||!a.support.leadingWhitespace&&r.test(e)||t[(m.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(l,"<$1></$2>");try{for(;g<h;g++)f=this[g]||{},1===f.nodeType&&(a.cleanData(f.getElementsByTagName("*")),
312f.innerHTML=e);f=0}catch(u){}}f&&c.empty().append(e)},null,d,arguments.length)}catch(e){return a(c).html(d)}},hasTransform:function(c){var d=c.css("transform");if(""==d||"none"==d)if(d=c.parents().css("transform"),""==d||"none"==d){var e=a.jqx.utilities.getBrowser();if("msie"==e.browser){if(d=c.css("-ms-transform"),""==d||"none"==d)d=c.parents().css("-ms-transform")}else if("chrome"==e.browser){if(d=c.css("-webkit-transform"),""==d||"none"==d)d=c.parents().css("-webkit-transform")}else if("opera"==
313e.browser){if(d=c.css("-o-transform"),""==d||"none"==d)d=c.parents().css("-o-transform")}else"mozilla"==e.browser&&(d=c.css("-moz-transform"),""==d||"none"==d)&&(d=c.parents().css("-moz-transform"))}else return""!=d&&"none"!=d;if(""==d||"none"==d)d=a(document.body).css("transform");return""!=d&&"none"!=d&&null!=d},getBrowser:function(){var c=navigator.userAgent.toLowerCase(),d=/(chrome)[ \/]([\w.]+)/.exec(c)||/(webkit)[ \/]([\w.]+)/.exec(c)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(c)||/(msie) ([\w.]+)/.exec(c)||
3140>c.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(c)||[],e={browser:d[1]||"",version:d[2]||"0"};0<=c.indexOf("rv:11.0")&&0<=c.indexOf(".net4.0c")&&(e.browser="msie",e.version="11",d[1]="msie");0<=c.indexOf("edge")&&(e.browser="msie",e.version="12",d[1]="msie");e[d[1]]=d[1];return e}});a.jqx.browser=a.jqx.utilities.getBrowser();a.jqx.isHidden=function(c){if(!c||!c[0])return!1;var d=c[0].offsetHeight;return 0===c[0].offsetWidth||0===d?!0:!1};a.jqx.ariaEnabled=!0;a.jqx.aria=function(c,
315d,e){if(a.jqx.ariaEnabled)if(void 0==d)a.each(c.aria,function(f,g){var h=c.base?c.base.host.attr(f):c.host.attr(f);if(void 0==h||a.isFunction(h)){h=c[g.name];a.isFunction(h)&&(h=c[g.name]());void 0==h&&(h="");try{c.base?c.base.host.attr(f,h.toString()):c.host.attr(f,h.toString())}catch(k){}}else{f=h;switch(g.type){case "number":f=new Number(h);isNaN(f)&&(f=h);break;case "boolean":f="true"==h?!0:!1;break;
315case "date":if(f=new Date(h),"Invalid Date"==f||isNaN(f))f=h}c[g.name]=f}});else try{c.host?c.base?
316c.base.host?c.base.host.attr(d,e.toString()):c.attr(d,e.toString()):c.host?c.element.setAttribute?c.element.setAttribute(d,e.toString()):c.host.attr(d,e.toString()):c.attr(d,e.toString()):c.setAttribute&&c.setAttribute(d,e.toString())}catch(f){}};Array.prototype.indexOf||(Array.prototype.indexOf=function(c,d){var e=this.length;d=Number(d)||0;d=0>d?Math.ceil(d):Math.floor(d);for(0>d&&(d+=e);d<e;d++)if(d in this&&this[d]===c)return d;return-1});a.jqx.mobile=a.jqx.mobile||{};a.jqx.position=function(c){var d=
317parseInt(c.pageX),e=parseInt(c.pageY);a.jqx.mobile.isTouchDevice()&&(c=a.jqx.mobile.getTouches(c)[0],d=parseInt(c.pageX),e=parseInt(c.pageY));return{left:d,top:e}};a.extend(a.jqx.mobile,{_touchListener:function(c,d){d={mousedown:"touchstart",mouseup:"touchend",mousemove:"touchmove"};var e=d[c.type],f=document.createEvent("MouseEvents");f.initMouseEvent(e,c.bubbles,c.cancelable,c.view,c.detail,c.screenX,c.screenY,c.clientX,c.clientY,c.ctrlKey,c.altKey,c.shiftKey,c.metaKey,c.button,c.relatedTarget);
318f._pageX=c.pageX;f._pageY=c.pageY;c.target.dispatchEvent(f);d=c.target["on"+d[c.type]];"function"===typeof d&&d(c)},setMobileSimulator:function(c,d){if(!this.isTouchDevice()&&(this.simulatetouches=!0,0==d&&(this.simulatetouches=!1),d={mousedown:"touchstart",mouseup:"touchend",mousemove:"touchmove"},window.addEventListener))for(var e in d)c.addEventListener&&(c.removeEventListener(e,this._touchListener),c.addEventListener(e,this._touchListener,!1))},isTouchDevice:function(){if(void 0!=this.touchDevice)return this.touchDevice;
319var c="Browser CodeName: "+navigator.appCodeName;c+="Browser Name: "+navigator.appName;c+="Browser Version: "+navigator.appVersion;c+="Platform: "+navigator.platform;c+="User-agent header: "+navigator.userAgent;if(-1!=c.indexOf("Android")||-1!=c.indexOf("IEMobile")||-1!=c.indexOf("Windows Phone")||-1!=c.indexOf("WPDesktop")||-1!=c.indexOf("ZuneWP7")||-1!=c.indexOf("BlackBerry")&&-1!=c.indexOf("Mobile Safari")||-1!=c.indexOf("ipod")||-1!=c.indexOf("nokia")||-1!=c.indexOf("Nokia"))return!0;if(-1!=c.indexOf("Chrome/17")||
320-1!=c.indexOf("CrOS")||-1!=c.indexOf("Opera")&&-1==c.indexOf("Mobi")&&-1==c.indexOf("Mini")&&-1!=c.indexOf("Platform: Win"))return!1;if(-1!=c.indexOf("HybridDeviceTouch"))return!0;if(-1!=c.indexOf("HybridDeviceMouse"))return!1;if(-1!=c.indexOf("Opera")&&-1!=c.indexOf("Mobi")&&-1!=c.indexOf("Opera Mobi"))return!0;if(-1!=c.indexOf("Mozilla/5.0 (X11; Linux x86_64)"))return!1;var d={ios:"i(?:Pad|Phone|Pod)(?:.*)CPU(?: iPhone)? OS ",android:"(Android |HTC_|Silk/)",blackberry:"BlackBerry(?:.*)Version/",
321rimTablet:"RIM Tablet OS ",webos:"(?:webOS|hpwOS)/",bada:"Bada/"};try{if(void 0!=this.touchDevice)return this.touchDevice;this.touchDevice=!1;for(var e in d)if(d.hasOwnProperty(e)&&c.match(new RegExp("(?:"+d[e]+")([^\\s;]+)")))return"blackberry"==e.toString()?this.touchDevice=!1:this.touchDevice=!0;var f=navigator.userAgent;if(-1!=navigator.platform.toLowerCase().indexOf("win")){if(0<=f.indexOf("Windows Phone")||0<=f.indexOf("WPDesktop")||0<=f.indexOf("IEMobile")||0<=f.indexOf("ZuneWP7"))return this.touchDevice=
322!0;if(0<=f.indexOf("Touch"))return"MSPointerDown"in window||"pointerdown"in window||0<=f.indexOf("ARM")?this.touchDevice=!0:this.touchDevice=!1}if(-1!=navigator.platform.toLowerCase().indexOf("win"))return this.touchDevice=!1;if("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)this.touchDevice=!0;return this.touchDevice}catch(g){return this.touchDevice=!1}},getLeftPos:function(c){for(var d=c.offsetLeft;null!=(c=c.offsetParent);)"HTML"!=c.tagName&&(d+=c.offsetLeft,document.all&&
323(d+=c.clientLeft));return d},getTopPos:function(c){for(var d=c.offsetTop,e=a(c).coord();null!=(c=c.offsetParent);)"HTML"!=c.tagName&&(d+=c.offsetTop-c.scrollTop,document.all&&(d+=c.clientTop));c=navigator.userAgent.toLowerCase();if((-1!=c.indexOf("windows phone")||-1!=c.indexOf("WPDesktop")||-1!=c.indexOf("ZuneWP7")||-1!=c.indexOf("msie 9")||-1!=c.indexOf("msie 11")||-1!=c.indexOf("msie 10"))&&-1!=c.indexOf("touch"))return e.top;if(this.isSafariMobileBrowser()){if(this.isSafari4MobileBrowser()&&this.isIPadSafariMobileBrowser())return d;
324if(-1!=c.indexOf("version/7"))return e.top;if(-1!=c.indexOf("version/6")||-1!=c.indexOf("version/5"))d+=a(window).scrollTop();return/(Android.*Chrome\/[.0-9]* (!?Mobile))/.exec(navigator.userAgent)||/(Android.*Chrome\/[.0-9]* Mobile)/.exec(navigator.userAgent)?d+a(window).scrollTop():e.top}return d},isChromeMobileBrowser:function(){return-1!=navigator.userAgent.toLowerCase().indexOf("android")},isOperaMiniMobileBrowser:function(){var c=navigator.userAgent.toLowerCase();return-1!=c.indexOf("opera mini")||
325-1!=c.indexOf("opera mobi")},isOperaMiniBrowser:function(){return-1!=navigator.userAgent.toLowerCase().indexOf("opera mini")},isNewSafariMobileBrowser:function(){var c=navigator.userAgent.toLowerCase(),d=-1!=c.indexOf("ipad")||-1!=c.indexOf("iphone")||-1!=c.indexOf("ipod");return d=d&&-1!=c.indexOf("version/5")},isSafari4MobileBrowser:function(){var c=navigator.userAgent.toLowerCase(),d=-1!=c.indexOf("ipad")||-1!=c.indexOf("iphone")||-1!=c.indexOf("ipod");return d=d&&-1!=c.indexOf("version/4")},isWindowsPhone:function(){var c=
326navigator.userAgent.toLowerCase();return-1!=c.indexOf("windows phone")||-1!=c.indexOf("WPDesktop")||-1!=c.indexOf("ZuneWP7")||-1!=c.indexOf("msie 9")||-1!=c.indexOf("msie 11")||-1!=c.indexOf("msie 10")&&-1!=c.indexOf("touch")},isSafariMobileBrowser:function(){var c=navigator.userAgent.toLowerCase();return/(Android.*Chrome\/[.0-9]* (!?Mobile))/.exec(navigator.userAgent)||/(Android.*Chrome\/[.0-9]* Mobile)/.exec(navigator.userAgent)?!0:-1!=c.indexOf("ipad")||-1!=c.indexOf("iphone")||-1!=c.indexOf("ipod")||
327-1!=c.indexOf("mobile safari")},isIPadSafariMobileBrowser:function(){return-1!=navigator.userAgent.toLowerCase().indexOf("ipad")},isMobileBrowser:function(){var c=navigator.userAgent.toLowerCase();return-1!=c.indexOf("ipad")||-1!=c.indexOf("iphone")||-1!=c.indexOf("android")},getTouches:function(c){if(c.originalEvent){if(c.originalEvent.touches&&c.originalEvent.touches.length)return c.originalEvent.touches;if(c.originalEvent.changedTouches&&c.originalEvent.changedTouches.length)return c.originalEvent.changedTouches}c.touches||
328(c.touches=[],c.touches[0]=void 0!=c.originalEvent?c.originalEvent:c,void 0!=c.originalEvent&&c.pageX&&(c.touches[0]=c),"mousemove"==c.type&&(c.touches[0]=c));return c.touches},getTouchEventName:function(c){if(this.isWindowsPhone()){if(-1!=navigator.userAgent.toLowerCase().indexOf("windows phone 7")){if(-1!=c.toLowerCase().indexOf("start"))return"MSPointerDown";if(-1!=c.toLowerCase().indexOf("move"))return"MSPointerMove";if(-1!=c.toLowerCase().indexOf("end"))return"MSPointerUp"}if(-1!=c.toLowerCase().indexOf("start"))return"pointerdown";
329if(-1!=c.toLowerCase().indexOf("move"))return"pointermove";if(-1!=c.toLowerCase().indexOf("end"))return"pointerup"}else return c},dispatchMouseEvent:function(c,d,e){if(!this.simulatetouches){var f=document.createEvent("MouseEvent");
329f.initMouseEvent(c,!0,!0,d.view,1,d.screenX,d.screenY,d.clientX,d.clientY,!1,!1,!1,!1,0,null);null!=e&&e.dispatchEvent(f)}},getRootNode:function(c){for(;1!==c.nodeType;)c=c.parentNode;return c},setTouchScroll:function(c,d){this.enableScrolling||(this.enableScrolling=[]);
330this.enableScrolling[d]=c},touchScroll:function(c,d,e,f,g,h){function k(Sa){return Sa.targetTouches&&1<=Sa.targetTouches.length?Sa.targetTouches[0].clientY:Sa.originalEvent&&void 0!==Sa.originalEvent.clientY?Sa.originalEvent.clientY:r.getTouches(Sa)[0].clientY}function l(Sa){return Sa.targetTouches&&1<=Sa.targetTouches.length?Sa.targetTouches[0].clientX:Sa.originalEvent&&void 0!==Sa.originalEvent.clientX?Sa.originalEvent.clientX:r.getTouches(Sa)[0].clientX}function m(){if(ea){var Sa=Date.now()-da;
331Sa=-ea*Math.exp(-Sa/Ca);.5<Sa||-.5>Sa?(Na(ra+Sa),requestAnimationFrame(m)):Na(ra)}}function n(){if(ea){var Sa=Date.now()-da;Sa=-ea*Math.exp(-Sa/Ca);.5<Sa||-.5>Sa?(I(za+Sa),requestAnimationFrame(n)):I(za)}}if(null!=c){var r=this;this.scrolling||(this.scrolling=[]);var t=this.scrolling[f]=!1;c=a(c);var u=["select","input","textarea"],x=0;this.enableScrolling||(this.enableScrolling=[]);this.enableScrolling[f]=!0;var B=this.getTouchEventName("touchstart")+".touchScroll",y=this.getTouchEventName("touchend")+
332".touchScroll",A=this.getTouchEventName("touchmove")+".touchScroll",aa,ha,z,V,ba,v,K,C,da,ja,ea,ra,za,na;var qa=d;var Ba=z=0,Ua=0,Ja=0;var Pa=g.jqxScrollBar("max");var Ca=325;var xa=function(){var Sa=Date.now();var db=Sa-da;da=Sa;Sa=z-C;var ab=Ba-aa;C=z;aa=Ba;ba=!0;v=1E3*Sa/(1+db)*.8+.2*v;K=1E3*ab/(1+db)*.8+.2*K},Fa=!1;x=function(Sa){if(!r.enableScrolling[f])return!0;if(-1===a.inArray(Sa.target.tagName.toLowerCase(),u)){z=h.jqxScrollBar("value");Ba=g.jqxScrollBar("value");var db=r.getTouches(Sa),
333ab=db[0];1==db.length&&r.dispatchMouseEvent("mousedown",ab,r.getRootNode(ab.target));Pa=g.jqxScrollBar("max");qa=h.jqxScrollBar("max");Fa=!1;ba=!0;V=k(Sa);na=l(Sa);v=ea=K=0;C=z;aa=Ba;da=Date.now();clearInterval(ja);ja=setInterval(xa,100);Ua=z;Ja=Ba;t=!1;return r.scrolling[f]=!0}};if(c.on)c.on(B,x);else c.bind(B,x);var Na=function(Sa,db){z=Sa>qa?qa:0>Sa?0:Sa;e(null,Sa,0,0,db);return Sa>qa?"max":0>Sa?"min":"value"},I=function(Sa,db){Ba=Sa>Pa?Pa:0>Sa?0:Sa;e(Sa,null,0,0,db);return Sa>Pa?"max":0>Sa?"min":
334"value"};d=function(Sa){function db(Ga){if(ba){var la=k(Ga);var ta=l(Ga);var va=V-la;ha=na-ta;if(2<va||-2>va){V=la;la=Na(z+va,Ga);xa();if("min"==la&&0===Ua||"max"==la&&Ua===qa||!Oa)return!0;Ga.preventDefault();Ga.stopPropagation();Fa=!0;return!1}if(2<ha||-2>ha){na=ta;la=I(Ba+ha,Ga);xa();if("min"==la&&0===Ja||"max"==la&&Ja===Pa||!ab)return!0;Fa=!0;Ga.preventDefault();Ga.stopPropagation();return!1}Ga.preventDefault()}}if(!r.enableScrolling[f]||!r.scrolling[f])return!0;Fa&&(Sa.preventDefault(),Sa.stopPropagation());
335if(1<r.getTouches(Sa).length)return!0;t=!0;var ab=null!=g?"hidden"!=g[0].style.visibility:!0,Oa=null!=h?"hidden"!=h[0].style.visibility:!0;(ab||Oa)&&(ab||Oa)&&db(Sa)};if(c.on)c.on(A,d);else c.bind(A,d);var Ta=function(Sa){if(!r.enableScrolling[f])return!0;var db=r.getTouches(Sa)[0];if(!r.scrolling[f])return!0;ba=!1;clearInterval(ja);if(10<v||-10>v)ea=.8*v,ra=Math.round(z+ea),da=Date.now(),requestAnimationFrame(m);else if(10<K||-10>K)ea=.8*K,za=Math.round(Ba+ea),da=Date.now(),requestAnimationFrame(n);
336r.scrolling[f]=!1;if(t)r.dispatchMouseEvent("mouseup",db,Sa.target);else return db=r.getTouches(Sa)[0],Sa=r.getRootNode(db.target),r.dispatchMouseEvent("mouseup",db,Sa),r.dispatchMouseEvent("click",db,Sa),!0};this.simulatetouches&&(void 0!=a(window).on||a(window),d=function(Sa){try{Ta(Sa)}catch(db){}r.scrolling[f]=!1},void 0!=a(window).on?a(document).on("mouseup.touchScroll",d):a(document).bind("mouseup.touchScroll",d),window.frameElement&&null!=window.top&&(d=function(Sa){try{Ta(Sa)}catch(db){}r.scrolling[f]=
337!1},window.top.document&&(a(window.top.document).on?a(window.top.document).on("mouseup",d):a(window.top.document).bind("mouseup",d))),void 0!=a(document).on||a(document),d=function(Sa){if(!r.scrolling[f])return!0;r.scrolling[f]=!1;Sa=r.getTouches(Sa)[0];var db=r.getRootNode(Sa.target);
337r.dispatchMouseEvent("mouseup",Sa,db);r.dispatchMouseEvent("click",Sa,db)},void 0!=a(document).on?a(document).on("touchend",d):a(document).bind("touchend",d));c.on&&(c.on("dragstart",function(Sa){Sa.preventDefault()}),
338c.on("selectstart",function(Sa){Sa.preventDefault()}));c.on?c.on(y+" touchcancel.touchScroll",Ta):c.bind(y+" touchcancel.touchScroll",Ta)}}});a.jqx.cookie=a.jqx.cookie||{};a.extend(a.jqx.cookie,{cookie:function(c,d,e){if(1<arguments.length&&"[object Object]"!==String(d)){e=a.extend({},e);if(null===d||void 0===d)e.expires=-1;if("number"===typeof e.expires){var f=e.expires,g=e.expires=new Date;g.setDate(g.getDate()+f)}d=String(d);return document.cookie=[encodeURIComponent(c),"=",e.raw?d:encodeURIComponent(d),
339e.expires?"; expires="+e.expires.toUTCString():"",e.path?"; path="+e.path:"",e.domain?"; domain="+e.domain:"",e.secure?"; secure":""].join("")}e=d||{};g=e.raw?function(h){return h}:decodeURIComponent;return(f=(new RegExp("(?:^|; )"+encodeURIComponent(c)+"=([^;]*)")).exec(document.cookie))?g(f[1]):null}});a.jqx.string=a.jqx.string||{};a.extend(a.jqx.string,{replace:function(c,d,e){if(d===e)return this;for(var f=c.indexOf(d);-1!=f;)c=c.replace(d,e),f=c.indexOf(d);return c},contains:function(c,d){return null==
340c||null==d?!1:-1!=c.indexOf(d)},containsIgnoreCase:function(c,d){return null==c||null==d?!1:-1!=c.toString().toUpperCase().indexOf(d.toString().toUpperCase())},equals:function(c,d){if(null==c||null==d)return!1;c=this.normalize(c);return d.length==c.length?c.slice(0,d.length)==d:!1},equalsIgnoreCase:function(c,d){if(null==c||null==d)return!1;c=this.normalize(c);return d.length==c.length?c.toUpperCase().slice(0,d.length)==d.toUpperCase():!1},startsWith:function(c,d){return null==c||null==d?!1:c.slice(0,
341d.length)==d},startsWithIgnoreCase:function(c,d){return null==c||null==d?!1:c.toUpperCase().slice(0,d.length)==d.toUpperCase()},normalize:function(c){65279==c.charCodeAt(c.length-1)&&(c=c.substring(0,c.length-1));return c},endsWith:function(c,d){if(null==c||null==d)return!1;c=this.normalize(c);return c.slice(-d.length)==d},endsWithIgnoreCase:function(c,d){if(null==c||null==d)return!1;c=this.normalize(c);return c.toUpperCase().slice(-d.length)==d.toUpperCase()}});a.extend(a.easing,{easeOutBack:function(c,
342d,e,f,g,h){void 0==h&&(h=1.70158);return f*((d=d/g-1)*d*((h+1)*d+h)+1)+e},easeInQuad:function(c,d,e,f,g){return f*(d/=g)*d+e},easeInOutCirc:function(c,d,e,f,g){return 1>(d/=g/2)?-f/2*(Math.sqrt(1-d*d)-1)+e:f/2*(Math.sqrt(1-(d-=2)*d)+1)+e},easeInCubic:function(c,d,e,f,g){return f*(d/=g)*d*d+e},easeOutCubic:function(c,d,e,f,g){return f*((d=d/g-1)*d*d+1)+e},easeInOutCubic:function(c,d,e,f,g){return 1>(d/=g/2)?f/2*d*d*d+e:f/2*((d-=2)*d*d+2)+e},easeInSine:function(c,d,e,f,g){return-f*Math.cos(d/g*(Math.PI/
3432))+f+e},easeOutSine:function(c,d,e,f,g){return f*Math.sin(d/g*(Math.PI/2))+e},easeInOutSine:function(c,d,e,f,g){return-f/2*(Math.cos(Math.PI*d/g)-1)+e}})})(jqxBaseFramework);
344(function(a){a.event&&a.event.special&&a.extend(a.event.special,{close:{noBubble:!0},open:{noBubble:!0},cellclick:{noBubble:!0},rowclick:{noBubble:!0},tabclick:{noBubble:!0},selected:{noBubble:!0},expanded:{noBubble:!0},collapsed:{noBubble:!0},valuechanged:{noBubble:!0},expandedItem:{noBubble:!0},collapsedItem:{noBubble:!0},expandingItem:{noBubble:!0},collapsingItem:{noBubble:!0}});a.fn.extend&&a.fn.extend({ischildof:function(c){if(!a(this).parents)return c.element.contains(this.element);for(var d=
345a(this).parents().get(),e=0;e<d.length;e++)if("string"!=typeof c){var f=d[e];if(void 0!==c&&f==c[0])return!0}else if(void 0!==c&&a(d[e]).is(c))return!0;return!1}});a.fn.jqxProxy=function(){var c=a(this).data().jqxWidget,d=Array.prototype.slice.call(arguments,0),e=c.element;e||(e=c.base.element);return a.jqx.jqxWidgetProxy(c.widgetName,e,d)};var b=a.originalVal=a.fn.val;a.fn.val=function(c){if("undefined"==typeof c){if(a(this).hasClass("jqx-widget")){var d=a(this).data().jqxWidget;if(d&&d.val)return d.val()}return this[0]&&
3460<=this[0].tagName.toLowerCase().indexOf("angular")&&(d=a(this).find(".jqx-widget").data().jqxWidget)&&d.val?d.val():b.call(this)}return a(this).hasClass("jqx-widget")&&(d=a(this).data().jqxWidget)&&d.val||this[0]&&0<=this[0].tagName.toLowerCase().indexOf("angular")&&(d=a(this).find(".jqx-widget").data().jqxWidget)&&d.val?2!=arguments.length?d.val(c):d.val(c,arguments[1]):b.call(this,c)};a.fn.modal&&a.fn.modal.Constructor&&(a.fn.modal.Constructor.prototype.enforceFocus=function(){a(document).off("focusin.bs.modal").on("focusin.bs.modal",
347a.proxy(function(c){if(this.$element[0]!==c.target&&!this.$element.has(c.target).length){if(a(c.target).parents().hasClass("jqx-popup"))return!0;this.$element.trigger("focus")}},this))});a.fn.coord=function(c){var d,e={top:0,left:0},f=(d=this[0])&&d.ownerDocument;if(f){var g=f.documentElement;if(!a.contains(g,d))return e;e=d.getBoundingClientRect();d=a.isWindow(f)?f:9===f.nodeType?f.defaultView||f.parentWindow:!1;var h=f=0,k=navigator.userAgent.toLowerCase();if(-1!=k.indexOf("ipad")||-1!=k.indexOf("iphone"))f=
3482;1==c&&"static"!=document.body.style.position&&""!=document.body.style.position&&(c=a(document.body).coord(),f=-c.left,h=-c.top);return{top:h+e.top+(d.pageYOffset||g.scrollTop)-(g.clientTop||0),left
348:f+e.left+(d.pageXOffset||g.scrollLeft)-(g.clientLeft||0)}}};a.jqx.ripplers=[];a.jqx.ripple=function(c,d,e){d||=c;var f=a(c);f.append("<span class='ink'></span>");for(var g=f.find(".ink"),h=!1,k=0;k<a.jqx.ripplers.length;k++)if(a.jqx.ripplers[k].element[0]===c[0]){h=!0;break}h||a.jqx.ripplers.push({ink:g,
349element:c,hostElement:d,hostElementType:e});if("checkbox"===e||"radiobutton"===e)h=Math.max(f.outerWidth(),f.outerHeight()),g.css({height:h,width:h}),h=f.width()/2-g.width()/2,f=f.height()/2-g.height()/2,g.css({top:f+"px",left:h+"px"});if(1===a.jqx.ripplers.length)a(document).on("mouseup",function(l){a.jqx.ripple.mouseCaptured=!1;for(l=0;l<a.jqx.ripplers.length;l++){var m=a.jqx.ripplers[l];m.ink.removeClass("active");m.element.removeClass("active");"checkbox"!==e&&"radiobutton"!==e&&m.ink.hasClass("animate")&&
350m.ink.removeClass("animate")}});d.off("mousedown.ripple");d.on("mousedown.ripple",function(l){var m=a(c);a.jqx.ripple.mouseCaptured=!0;setTimeout(function(){0==m.find(".ink").length&&m.append("<span class='ink'></span>");var n=m.find(".ink");n.removeClass("animate");if(!n.height()&&!n.width()){var r=Math.max(m.outerWidth(),m.outerHeight());n.css({height:r,width:r})}if("checkbox"===e||"radiobutton"===e){if(!("checkbox"===e&&d.jqxCheckBox("disabled")||"radiobutton"===e&&d.jqxRadioButton("disabled"))){r=
351m.width()/2-n.width()/2;var t=m.height()/2-n.height()/2;n.css({top:t+"px",left:r+"px"}).addClass("animate");n.on("animationend",function(){a.jqx.ripple.mouseCaptured&&(n.removeClass("animate"),n.addClass("active"),c.addClass("active"))})}}else r=l.pageX-m.offset().left-n.width()/2,t=l.pageY-m.offset().top-n.height()/2,n.css({top:t+"px",left:r+"px"}).addClass("animate")})})}})(jqxBaseFramework);
352(function(a){function b(v){return function(K,C){"string"!==typeof K&&(C=K,K="*");var da=K.toLowerCase().split(r),ja=0,ea=da.length;if(a.isFunction(C))for(;ja<ea;ja++){var ra=da[ja];(K=/^\+/.test(ra))&&(ra=ra.substr(1)||"*");ra=v[ra]=v[ra]||[];ra[K?"unshift":"push"](C)}}}function c(v,K,C,da,ja,ea){ja=ja||K.dataTypes[0];ea=ea||{};ea[ja]=!0;ja=v[ja];for(var ra=0,za=ja?ja.length:0,na=v===t;ra<za&&(na||!qa);ra++){var qa=ja[ra](K,C,da);"string"===typeof qa&&(!na||ea[qa]?qa=void 0:(K.dataTypes.unshift(qa),
353qa=c(v,K,C,da,qa,ea)))}!na&&qa||ea["*"]||(qa=c(v,K,C,da,"*",ea));return qa}function d(v,K){var C,da,ja=a.jqx.data.ajaxSettings.flatOptions||{};for(C in K)void 0!==K[C]&&((ja[C]?v:da||={})[C]=K[C]);da&&a.extend(!0,v,da)}function e(){try{return new window.XMLHttpRequest}catch(v){}}Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(v,K){if(null==this)throw TypeError('"this" is null or not defined');var C=Object(this),da=C.length>>>0;if("function"!==typeof v)throw TypeError("predicate must be a function");
354for(var ja=0;ja<da;){var ea=C[ja];if(v.call(K,ea,ja,C))return ea;ja++}},configurable:!0,writable:!0});a.jqx.observableArray=function(v,K){"string"==typeof v&&(v=a.parseJSON(v));var C;if(!(C=!Object.defineProperty)){try{Object.defineProperty({},"x",{});var da=!0}catch(na){da=!1}C=!da}if(C){var ja=Object.defineProperty;Object.defineProperty=function(na,qa,Ba){if(ja)try{return ja(na,qa,Ba)}catch(Ua){}if(na!==Object(na))throw TypeError("Object.defineProperty called on non-object");Object.prototype.__defineGetter__&&
355"get"in Ba&&Object.prototype.__defineGetter__.call(na,qa,Ba.get);Object.prototype.__defineSetter__&&"set"in Ba&&Object.prototype.__defineSetter__.call(na,qa,Ba.set);"value"in Ba?na[qa]=Ba.value:na[qa]||(na[qa]=Ba);return na}}Array.prototype.forEach||(Array.prototype.forEach=function(na,qa){if(void 0===this||null===this)throw TypeError();var Ba=Object(this),Ua=Ba.length>>>0;if("function"!==typeof na)throw TypeError();var Ja;for(Ja=0;Ja<Ua;Ja++)Ja in Ba&&na.call(qa,Ba[Ja],Ja,Ba)});"function"!==typeof Object.getOwnPropertyNames&&
356(Object.getOwnPropertyNames=function(na){if(na!==Object(na))throw TypeError("Object.getOwnPropertyNames called on non-object");var qa=[],Ba;for(Ba in na)Object.prototype.hasOwnProperty.call(na,Ba)&&qa.push(Ba);return qa});var ea=this,ra=[];ea.notifier=null;ea.name="observableArray";ea.observing=!0;ea.changes=[];ea.observe=function(){ea.observing=!0;1==arguments.length&&(K=arguments[0])};ea.unobserve=function(){ea.observing=!1};ea.toArray=function(){return ra.slice(0)};ea.toJSON=function(na,qa){function Ba(Na){return'"'+
357Na.replace(xa,function(I){var Ta=Fa[I];return"string"===typeof Ta?Ta:"\\u"+("0000"+I.charCodeAt(0).toString(16)).slice(-4)})+'"'}function Ua(Na){return 10>Na?"0"+Na:Na}function Ja(Na,I){switch(I){case "string":return Ba(Na);case "number":case "float":case "integer":case "int":return isFinite(Na)?Na:"null";case "boolean":return Na}return"null"}function Pa(Na,I){I=I[Na];var Ta=typeof I;I&&"object"===typeof I&&"function"===typeof I.toJSON&&(I=I.toJSON(Na),Ta=typeof I);if(/(number|float|int|integer|string|boolean)/.test(Ta)||
358!I&&"object"===Ta)return Ja(I,Ta);a:{Na=I;switch(Object.prototype.toString.call(Na)){case "[object Date]":var Sa=isFinite(Na.valueOf())?Na.getUTCFullYear()+"-"+Ua(Na.getUTCMonth()+1)+"-"+Ua(Na.getUTCDate())+"T"+Ua(Na.getUTCHours())+":"+Ua(Na.getUTCMinutes())+":"+Ua(Na.getUTCSeconds())+'Z"':"null";break a;case "[object Array]":Sa=Na.length;I=[];for(Ta=0;Ta<Sa;Ta++)I.push(Pa(Ta,Na)||"null");Sa="["+I.join(",")+"]";break a}I=[];for(Sa in Na)!Object.prototype.hasOwnProperty.call(Na,Sa)||""!=Sa&&na&&-1===
359na.indexOf(Sa)||(Ta=Pa(Sa,Na))&&I.push(Ba(Sa)+":"+Ta);Sa="{"+I.join(",")+"}"}return Sa}var Ca=ra;qa&&(Ca=qa);var xa=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,Fa={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return!na&&window.JSON&&"function"===typeof window.JSON.stringify?window.JSON.stringify(Ca):Pa("",{"":Ca})};ea.defineIndexProperty=function(na){if(!(na in ea)){var qa=function(Ua,Ja,
360Pa,Ca){var xa=Ua[Ja],Fa=xa;Pa=function(){return Fa};var Na=function(I){xa=I;if(Fa!==xa&&(I=Fa,Fa=xa,"function"===typeof za)){var Ta=ra.indexOf(Ca),Sa="",db=function(ab,Oa){Object.getOwnPropertyNames(ab).forEach(function(Ga){var la=a.type(ab[Ga]);"array"==la||"object"==la?db(ab[Ga],Oa+"."+Ga):Ja===Ga&&(Sa=Oa+"."+Ga)})};db(Ca,Ta);za({object:ea,type:"update",path:Sa,index:Ta,name:Ja,newValue:xa,oldValue:I})}return Fa=xa};void 0!=Ua[Ja]&&"length"!=Ja&&(Object.defineProperty?Object.defineProperty(Ua,Ja,
361{get:Pa,set:Na}):Object.prototype.__defineGetter__&&Object.prototype.__defineSetter__&&(Object.prototype.__defineGetter__.call(Ua,Ja,Pa),Object.prototype.__defineSetter__.call(Ua,Ja,Na)))},Ba=function(Ua,Ja,Pa){var Ca=a.type(Ua);/(number|float|int|integer|string|boolean)/.test(Ca)||void 0!==Ua&&Object.getOwnPropertyNames(Ua).forEach(function(xa){var Fa=a.type(Ua[xa]);"array"==Fa||"object"==Fa?(qa(Ua,xa,Ja+"."+xa,Pa),Ba(Ua[xa],Ja+"."+xa,Pa)):qa(Ua,xa,Ja+"."+xa,Pa)})};Object.defineProperty(ea,na,{configurable:!0,
362enumerable:!0,get:function(){return ra[na]},set:function(Ua){var Ja=ra[na];ea.toJSON(null,Ja)!=ea.toJSON(null,Ua)&&(ra[na]=Ua,"function"===typeof za&&za({object:ea,type:"update",path:na.toString(),index:na,name:"index",newValue:Ua,oldValue:Ja}),Ba(Ua,na,Ua))}});Ba(ea[na],na,ea[na])}};ea.push=function(){for(var na,qa=0,Ba=arguments.length;qa<Ba;qa++)na=ra.length,ra.push(arguments[qa]),ea.defineIndexProperty(na),"function"===typeof za&&za({object:ea,type:"add",name:"length",index:na,newValue:ra.length,
363oldValue:na});return ra.length};ea.pop=function(){if(~ra.length){var na=ra.length-1,qa=ra.pop();delete ea[na];"function"===typeof za&&za({object:ea,type:"delete",name:"length",index:na,newValue:ra.length,oldValue:na});return qa}};ea.unshift=function(){for(var na=ra.length,qa=0,Ba=arguments.length;qa<Ba;qa++)ra.splice(qa,0,arguments[qa]),ea.defineIndexProperty(ra.length-1);"function"===typeof za&&za({object:ea,type:"add",index:0,name:"length",newValue:ra.length,oldValue:na});return ra.length};ea.shift=
364function(){var na=ra.length;if(~ra.length){var qa=ra.shift();0===ra.length&&delete ea[na];"function"===typeof za&&za({object:ea,type:"delete",index:na,name:"length",newValue:ra.length,oldValue:na});return qa}};ea.slice=function(na,qa,Ba){na=ra.slice(na,qa);return new a.jqx.observableArray(na,Ba)};ea.splice=function(na,qa,Ba){var Ua=[];na=~na?na:ra.length-na;for(qa=(null==qa?ra.length-na:qa)||0;qa--;){var Ja=ra.splice(na,1)[0];Ua.push(Ja);delete ea[ra.length];"function"===typeof za&&za({object:ea,
365type:"delete",index:na,name:"length",newValue:-1,oldValue:na})}Ja=2;for(var Pa=arguments.length;Ja<Pa;Ja++)ra.splice(na,0,arguments[Ja]),this.defineIndexProperty(ra.length-1),"function"===typeof za&&za({object:ea,type:"add",index:na,name:"length",newValue:ra.length-1,oldValue:na}),na++;return new a.jqx.observableArray(Ua,Ba)};Object.defineProperty(ea,"length",{configurable:!1,enumerable:!0,get:function(){return ra.length},set:function(na){var qa=Number(na);if(0===qa%1&&0<=qa)qa<ra.length?ea.splice(qa):
366qa>ra.length&&ea.push.apply(ea,Array(qa-ra.length));else throw new RangeError("Invalid array length");return na}});a.jqx.observableArray.prototype.fromArray=function(na,qa){return new a.jqx.observableArray(na,qa)};a.jqx.observableArray.prototype.clone=function(){var na=new a.jqx.observableArray(ra,K);na.observing=ea.observing;na.changes=ea.changes;na.notifier=ea.notifier;return na};ea.remove=function(na){if(0>na||na>=ea.length)throw Error("Invalid index : "+na);if(ea.hasOwnProperty(na)){var qa=ea[na];
367ea[na]=void 0;ra[na]=void 0;"function"===typeof za&&za({object:ea,type:"delete",index:na,name:"index",newValue:void 0,oldValue:qa});return!0}return!1};ea.concat=function(na,qa){na=ra.concat(na);return new a.jqx.observableArray(na,qa)};Object.getOwnPropertyNames(Array.prototype).forEach(function(na){na in ea||Object.defineProperty(ea,na,{configurable:!1,enumerable:!0,writeable:!1,value:function(){var qa=ea.observing;ea.observing=!1;var Ba=ra[na].apply(ra,arguments);ea.observing=qa;return Ba}})});ea.set=
368function(na,qa){if("string"==a.type(na)&&1<na.split(".").length){for(var Ba=na.split("."),Ua=ea,Ja=0;Ja<Ba.length;Ja++){if(0===Ja&&Ba[Ja]>=ea.length)throw Error("Invalid Index: "+na);Ja<Ba.length-1?Ua=Ua[Ba[Ja]]:Ua[Ba[Ja]]=qa}return!0}na>=ea.length?ea.push(qa):ea[na]=qa;return!0};ea.get=function(na){return ea[na]};v instanceof Array&&ea.push.apply(ea,v);var za=function(){ea.observing&&(arguments&&arguments[0]&&ea.changes.push(arguments[0]),K&&K.apply(ea,arguments),ea.notifier&&ea.notifier.apply(ea,
369arguments))};return ea};a.jqx.formatDate=function(v,K,C){return a.jqx.dataFormat.formatdate(v,K,C)};a.jqx.formatNumber=function(v,K,C){return a.jqx.dataFormat.formatnumber(v,K,C)};a.jqx.dataAdapter=function(v,K){void 0!=v&&(void 0!==v.dataFields&&(v.datafields=v.dataFields),void 0!==v.dataType&&(v.datatype=v.dataType),void 0!==v.localData&&(v.localdata=v.localData),void 0!==v.sortColumn&&(v.sortcolumn=v.sortColumn),void 0!==v.sortDirection&&(v.sortdirection=v.sortDirection),void 0!==v.sortColumns&&
370(v.sortcolumns=v.sortColumns),void 0!==v.sortDirections&&(v.sortdirections=v.sortDirections),void 0!==v.sortOrder&&(v.sortdirection=v.sortOrder),void 0!==v.formatData&&(v.formatdata=v.formatData),void 0!==v.processData&&(v.processdata=v.processData),void 0!==v.pageSize&&(v.pagesize=v.pageSize),void 0!==v.pageNum&&(v.pagenum=v.pageNum),void 0!==v.updateRow&&(v.updaterow=v.updateRow),void 0!==v.addRow&&(v.addrow=v.addRow),void 0!==v.deleteRow&&(v.deleterow=v.deleteRow),void 0!==v.contentType&&(v.contenttype=
371v.contentType),void 0!=v.totalRecords&&(v.totalrecords=v.totalRecords),void 0!=v.loadError&&(v.loadError=v.loadError),void 0!=v.sortComparer&&(v.sortcomparer=v.sortComparer));this._source=v;this._options=K||{};void 0!=v.beforeLoadComplete&&(this._options.beforeLoadComplete=this._source.beforeLoadComplete);void 0!=v.downloadComplete&&(this._options.downloadComplete=this._source.downloadComplete);void 0!=v.loadComplete&&(this._options.loadComplete=this._source.loadComplete);void 0!=v.autoBind&&(this._options.downloadComplete=
372this._source.autoBind);void 0!=v.formatData&&(this._options.formatData=this._source.formatData);void 0!=v.loadError&&(this._options.loadError=this._source.loadError);void 0!=v.beforeSend&&(this._options.beforeSend=this._source.beforeSend);void 0!=v.contentType&&(this._options.contentType=this._source.contentType);void 0!=v.async&&(this._options.async=this._source.async);void 0!=v.loadServerData&&(this._options.loadServerData=this._source.loadServerData);void 0!=v.uniqueDataFields&&(this._options.uniqueDataFields=
373this._source.uniqueDataFields);this.records=[];this._downloadComplete=[];this._bindingUpdate=[];
373if(void 0!=v&&null!=v.localdata&&"function"==typeof v.localdata&&(K=v.localdata(),null!=K)){v._localdata=v.localdata;var C=this;v._localdata.subscribe&&(C._oldlocaldata=[],v._localdata.subscribe(function(da){var ja=function(ea){return a.isArray(ea)?a.makeArray(ja(a(ea))):a.extend(!0,{},ea)};if(0==C.suspendKO||void 0==C.suspendKO||0==C._oldlocaldata.length)C._oldlocaldata=ja(da)},v._localdata,"beforeChange"),
374v._localdata.subscribe(function(da){if(0==C.suspendKO||void 0==C.suspendKO){var ja="";C._oldrecords=C.records;0==C._oldlocaldata.length&&(v.localdata=v._localdata());0==C._oldlocaldata.length?ja="change":da&&(C._oldlocaldata.length==da.length&&(ja="update"),C._oldlocaldata.length>da.length&&(ja="remove"),C._oldlocaldata.length<da.length&&(ja="add"));C.dataBind(null,ja)}},v._localdata,"change"),C._knockoutdatasource=!0);v.localdata=K}1==this._options.autoBind&&this.dataBind()};a.jqx.dataAdapter.prototype=
375{getrecords:function(){return this.records},beginUpdate:function(){this.isUpdating=!0},endUpdate:function(v){this.isUpdating=!1;0!=v&&(this._changedrecords&&0<this._changedrecords.length?(this.callBindingUpdate("update"),this._changedrecords=[]):this.dataBind(null,""))},formatDate:function(v,K,C){return a.jqx.dataFormat.formatdate(v,K,C)},formatNumber:function(v,K,C){return a.jqx.dataFormat.formatnumber(v,K,C)},dataBind:function(v,K){if(1!=this.isUpdating){var C=this._source;if(C){C.generatedfields&&
376(C.datafields=null,C.generatedfields=null);a.jqx.dataFormat.datescache=[];null!=C.dataFields&&(C.datafields=C.dataFields);void 0==C.recordstartindex&&(C.recordstartindex=0);void 0==C.recordendindex&&(C.recordendindex=0);void 0==C.loadallrecords&&(C.loadallrecords=!0);void 0==C.root&&(C.root="");void 0==C.record&&(C.record="");void 0!=C.sort&&(this.sort=C.sort);this.filter=void 0!=C.filter?C.filter:null;void 0!=C.sortcolumn&&(this.sortcolumn=C.sortcolumn);void 0!=C.sortdirection&&(this.sortdirection=
377C.sortdirection);void 0!=C.sortcolumns&&(this.sortcolumns=C.sortcolumns);void 0!=C.sortdirections&&(this.sortdirections=C.sortdirections);void 0!=C.sortcomparer&&(this.sortcomparer=C.sortcomparer);this.records=[];var da=this._options||{};this.virtualmode=void 0!=da.virtualmode?da.virtualmode:!1;this.totalrecords=void 0!=da.totalrecords?da.totalrecords:0;this.pageable=void 0!=da.pageable?da.pageable:!1;this.pagesize=void 0!=da.pagesize?da.pagesize:0;this.pagenum=void 0!=da.pagenum?da.pagenum:0;this.cachedrecords=
378void 0!=da.cachedrecords?da.cachedrecords:[];this.originaldata=[];this.recordids=[];this.updaterow=void 0!=da.updaterow?da.updaterow:null;this.addrow=void 0!=da.addrow?da.addrow:null;this.deleterow=void 0!=da.deleterow?da.deleterow:null;this.cache=void 0!=da.cache?da.cache:!1;this.unboundmode=!1;void 0!=C.formatdata&&(da.formatData=C.formatdata);void 0!=C.data&&(void 0==da.data&&(da.data={}),a.extend(da.data,C.data));void 0!=C.mapChar&&(C.mapchar=C.mapChar);this.mapChar=void 0!=C.mapchar?C.mapchar?
379C.mapchar:">":da.mapChar?da.mapChar:">";if(da.unboundmode||C.unboundmode)this.unboundmode=da.unboundmode||C.unboundmode;void 0!=C.cache&&(this.cache=C.cache);if(this.koSubscriptions)for(v=0;v<this.koSubscriptions.length;v++)this.koSubscriptions[v].dispose();this.koSubscriptions=[];0>this.pagenum&&(this.pagenum=0);var ja=this,ea=C.datatype;if("csv"===C.datatype||"tab"===C.datatype||"tsv"===C.datatype||"text"==C.datatype)ea="text";v=void 0!=da.async?da.async:!0;void 0!=C.async&&(v=C.async);if("xlsx"===
380ea&&C.url&&(C.localdata=[],ea="array",window.jqxDataSource)){var ra=new window.jqxDataSource({dataSource:C.url,async:!1,dataFields:C.datafields});ra.notify(function(){C.url=null;C.localdata=ra.boundSource;C.datatype="array";ja.dataBind()})}switch(ea){default:if(void 0==C.localdata&&C.length)for(C.localdata=[],v=0;v<C.length;v++)C.localdata[C.localdata.length]=C[v],C[v].uid=v;C.beforeprocessing&&a.isFunction(C.beforeprocessing)&&C.beforeprocessing(C.localdata);var za=C.localdata.length;this.totalrecords=
381this.virtualmode?C.totalrecords||za:za;if(this.unboundmode){this.totalrecords=this.unboundmode?C.totalrecords||za:za;var na=C.datafields?C.datafields.length:0;if(0<na)for(v=0;v<this.totalrecords;v++){var qa={};for(za=0;za<na;za++)qa[C.datafields[za].name]="";qa.uid=v;C.localdata[C.localdata.length]=qa}}void 0==this.totalrecords&&(this.totalrecords=0);na=C.datafields?C.datafields.length:0;var Ba=function(xa,Fa){for(var Na={},I=0;I<Fa;I++){var Ta=C.datafields?C.datafields[I]:{},Sa="";if(void 0!=Ta&&
382null!=Ta){if(Ta.map){if(a.isFunction(Ta.map))Sa=Ta.map(xa);else if(Sa=Ta.map.split(ja.mapChar),0<Sa.length){for(var db=xa,ab=0;ab<Sa.length;ab++)db&&=db[Sa[ab]];Sa=db}else Sa=xa[Ta.map];void 0!=Sa&&null!=Sa?Sa=Sa.toString():void 0==Sa&&null!=Sa&&(Sa="")}db=!1;""==Sa&&(db=!0,Sa=xa[Ta.name],void 0!=Sa&&null!=Sa&&(C._localdata&&Sa.subscribe?Sa=Sa():"array"!=Ta.type&&"date"!==Ta.type&&(Sa=Sa.toString())));"[object Object]"==Sa&&Ta.map&&db&&(Sa="");Sa=ja.getvaluebytype(Sa,Ta);void 0!=Ta.displayname?Na[Ta.displayname]=
383Sa:Na[Ta.name]=Sa}}return Na};if(C._localdata)if(this._changedrecords=[],this.records=[],v=C._localdata(),a.each(v,function(xa,Fa){if("string"===typeof Fa)ja.records.push(Fa);else{var Na={},I=0,Ta=this;a.each(this,function(Sa,db){db=null;var ab="string",Oa=Sa;if(0<na){for(var Ga=!1,la=!1,ta=0;ta<na;ta++){var va=C.datafields[ta];if(void 0!=va&&va.name==Sa){Ga=!0;db=va.map;ab=va.type;Oa=va.name;break}else if(void 0!=va&&va.map&&0<=va.map.indexOf(Sa)){Ga=!0;db=va.map;ab=va.type;Oa=va.name;la=!0;va=Ta[Sa];
384if(null!=db)if(va=db.split(ja.mapChar),0<va.length){for(var p=Ta,E=0;E<va.length;E++)p=p[va[E]];va=p}else va=Ta[db];"string"!=ab&&(va=ja.getvaluebytype(va,{type:ab}));Na[Oa]=va;void 0!=Na[Oa]&&(I+=Na[Oa].toString().length+Na[Oa].toString().substr(0,1))}}if(!Ga||la)return!0}if(a.isFunction(Ta[Sa]))va=Ta[Sa](),"string"!=ab&&(va=ja.getvaluebytype(va,{type:ab})),Na[Sa]=va,Ta[Sa].subscribe&&(ja.koSubscriptions[ja.koSubscriptions.length]=Ta[Sa].subscribe(function(L){Na[Sa]=L;ja._changedrecords.push({index:xa,
385oldrecord:Na,record:Na});if(!ja.isUpdating)return ja.callBindingUpdate("update"),ja._changedrecords=[],!1}));else{va=Ta[Sa];if(null!=db)if(va=db.split(ja.mapChar),0<va.length){p=Ta;for(E=0;E<va.length;E++)p=p[va[E]];va=p}else va=Ta[db];"string"!=ab&&(va=ja.getvaluebytype(va,{type:ab}));Na[Oa]=va;void 0!=Na[Oa]&&(I+=Na[Oa].toString().length+Na[Oa].toString().substr(0,1))}});Fa=ja.getid(C.id,Ta,xa);Na.uid=Fa;ja.records.push(Na);Na._koindex=I;ja._oldrecords&&(Fa=ja.records.length-1,"update"==K&&ja._oldrecords[Fa]._koindex!=
386I&&ja._changedrecords.push({index:Fa,oldrecord:ja._oldrecords[Fa],record:Na}))}}),"add"==K)for(za=ja.records.length,v=0;v<za;v++){qa=ja.records[v];for(var Ua=!1,Ja=0;Ja<ja._oldrecords.length;Ja++)if(ja._oldrecords[Ja]._koindex===qa._koindex){Ua=!0;break}Ua||ja._changedrecords.push({index:v,oldrecord:null,record:qa,position:0!=v?"last":"first"})}else{if("remove"==K)for(za=ja._oldrecords.length,v=0;v<za;v++)qa=ja._oldrecords[v],ja.records[v]?ja.records[v]._koindex!=qa._koindex&&ja._changedrecords.push({index:v,
387oldrecord:qa,record:null}):ja._changedrecords.push({index:v,oldrecord:qa,record:null})}
387else if(a.isArray(C.localdata))0==na?(Pa=0,Ca=[],a.each(C.localdata,function(xa,Fa){var Na=Object(this);if("string"===typeof Fa)return ja.records=C.localdata,!1;Fa=ja.getid(C.id,Na,xa);"object"===typeof Fa&&(Fa=xa);Na.uid=Fa;if(0==xa){for(var I in this)Pa++,xa=a.type(this[I]),Ca.push({name:I,type:xa});na=Pa;C.datafields=Ca;C.generatedfields=Ca}0<na?(Na=Ba(Na,na),Na.uid=Fa,ja.records[ja.records.length]=Na):ja.records[ja.records.length]=
388Na})):a.each(C.localdata,function(xa){var Fa=Ba(this,na),Na=ja.getid(C.id,Fa,xa);"object"===typeof Na&&(Na=xa);xa=Object(Fa);xa.uid=Na;ja.records[ja.records.length]=xa});else{this.records=[];var Pa=0,Ca=[];a.each(C.localdata,function(xa){xa=ja.getid(C.id,this,xa);if(0==na&&!("string"===typeof this||this instanceof String)){for(var Fa in this){Pa++;var Na=a.type(this[Fa]);Ca.push({name:Fa,type:Na})}na=Pa;C.datafields=Ca;C.generatedfields=Ca}0<na?(Fa=Ba(this,na),Fa.uid=xa,ja.records[ja.records.length]=
389Fa):(this.uid=xa,ja.records[ja.records.length]=this)})}this.originaldata=C.localdata;this.cachedrecords=this.records;this.addForeignValues(C);da.uniqueDataFields&&(this.cachedrecords=this.records=v=this.getUniqueRecords(this.records,da.uniqueDataFields));da.beforeLoadComplete&&(v=da.beforeLoadComplete(ja.records,this.originaldata),void 0!=v&&(ja.records=v,ja.cachedrecords=v));da.autoSort&&da.autoSortField&&(v=Object.prototype.toString,Object.prototype.toString="function"==typeof field?field:function(){return this[da.autoSortField]},
390ja.records.sort(function(xa,Fa){void 0===xa&&(xa=null);void 0===Fa&&(Fa=null);if(null===xa&&null===Fa)return 0;if(null===xa&&null!==Fa)return 1;if(null!==xa&&null===Fa)return-1;xa=xa.toString();Fa=Fa.toString();if(null===xa&&null===Fa)return 0;if(null===xa&&null!==Fa)return 1;if(null!==xa&&null===Fa)return-1;if(a.jqx.dataFormat.isNumber(xa)&&a.jqx.dataFormat.isNumber(Fa)||a.jqx.dataFormat.isDate(xa)&&a.jqx.dataFormat.isDate(Fa))return xa<Fa?-1:xa>Fa?1:0;a.jqx.dataFormat.isNumber(xa)||a.jqx.dataFormat.isNumber(Fa)||
391(xa=String(xa).toLowerCase(),Fa=String(Fa).toLowerCase());return xa<Fa?-1:xa>Fa?1:0}),Object.prototype.toString=v);ja.loadedData=C.localdata;ja.buildHierarchy();a.isFunction(da.loadComplete)&&da.loadComplete(C.localdata,ja.records);break;case "json":case "jsonp":case "xml":case "xhtml":case "script":case "text":case "ics":if(null!=C.localdata&&!C.url){a.isFunction(C.beforeprocessing)&&C.beforeprocessing(C.localdata);"xml"===C.datatype?ja.loadxml(C.localdata,C.localdata,C):"text"===ea?ja.loadtext(C.localdata,
392C):"ics"===ea?ja.loadics(C.localdata,C):ja.loadjson(C.localdata,C.localdata,C);ja.addForeignValues(C);da.uniqueDataFields&&(v=ja.getUniqueRecords(ja.records,da.uniqueDataFields),ja.records=v,ja.cachedrecords=v);da.beforeLoadComplete&&(v=da.beforeLoadComplete(ja.records,this.originaldata),void 0!=v&&(ja.records=v,ja.cachedrecords=v));ja.loadedData=C.localdata;ja.buildHierarchy.call(ja);a.isFunction(da.loadComplete)&&da.loadComplete(C.localdata,ja.records);ja.callBindingUpdate(K);return}za=void 0!=
393da.data?da.data:{};C.processdata&&C.processdata(za);a.isFunction(da.processData)&&da.processData(za);a.isFunction(da.formatData)&&(qa=da.formatData(za),void 0!=qa&&(za=qa));qa="application/x-www-form-urlencoded";da.contentType&&(qa=da.contentType);Ua="GET";C.type&&(Ua=C.type);da.type&&(Ua=da.type);Ja=ea;"ics"==ea&&(Ja="text");C.url&&0<C.url.length?a.isFunction(da.loadServerData)?ja._requestData(za,C,da):this.xhr=a.jqx.data.ajax({dataType:Ja,cache:this.cache,type:Ua,url:C.url,async:v,timeout:C.timeout,
394contentType:qa,data:za,success:function(xa,Fa,Na){if(a.isFunction(C.beforeprocessing)){var I=C.beforeprocessing(xa,Fa,Na);void 0!=I&&(xa=I)}a.isFunction(da.downloadComplete)&&(I=da.downloadComplete(xa,Fa,Na),void 0!=I&&(xa=I));null==xa?(ja.records=[],ja.cachedrecords=[],ja.originaldata=[],ja.callDownloadComplete(),a.isFunction(da.loadComplete)&&da.loadComplete([])):(I=xa,xa.records&&(I=xa.records),void 0!=xa.totalrecords?C.totalrecords=xa.totalrecords:void 0!=xa.totalRecords&&(C.totalrecords=xa.totalRecords),
395"xml"===C.datatype?ja.loadxml(null,I,C):"text"===ea?ja.loadtext(I,C):"ics"===ea?ja.loadics(I,C):ja.loadjson(null,I,C),ja.addForeignValues(C),da.uniqueDataFields&&(I=ja.getUniqueRecords(ja.records,da.uniqueDataFields),ja.records=I,ja.cachedrecords=I),da.beforeLoadComplete&&(I=da.beforeLoadComplete(ja.records,xa),void 0!=I&&(ja.records=I,ja.cachedrecords=I)),ja.loadedData=xa,ja.buildHierarchy.call(ja),ja.callDownloadComplete(),a.isFunction(da.loadComplete)&&da.loadComplete(xa,Fa,Na,ja.records))},error:function(xa,
396Fa,Na){a.isFunction(C.loaderror)&&C.loaderror(xa,Fa,Na);a.isFunction(da.loadError)&&da.loadError(xa,Fa,Na);ja.callDownloadComplete()},beforeSend:function(xa,Fa){a.isFunction(da.beforeSend)&&da.beforeSend(xa,Fa);a.isFunction(C.beforesend)&&C.beforesend(xa,Fa)}}):(ja.buildHierarchy([]),ja.callDownloadComplete(),a.isFunction(da.loadComplete)&&(ra||={},da.loadComplete(ra)))}this.callBindingUpdate(K)}}},buildHierarchy:function(v){var K=this._source,C=[];if(K.datafields){if(K.hierarchy&&!K.hierarchy.reservedNames)K.hierarchy.reservedNames=
397{leaf:"leaf",parent:"parent",expanded:"expanded",checked:"checked",selected:"selected",level:"level",icon:"icon",data:"data"};else if(K.hierarchy){var da=K.hierarchy.reservedNames;da.leaf||(da.leaf="leaf");da.parent||(da.parent="parent");da.expanded||(da.expanded="expanded");da.checked||(da.checked="checked");da.selected||(da.selected="selected");da.level||(da.level="level");da.data||(da.data="data")}if(K.hierarchy){var ja=this;da=K.hierarchy.reservedNames;if(K.hierarchy.root){if("xml"==K.dataType)return this.hierarchy=
398C=this.getRecordsHierarchy("uid","parentuid","records",null,v);this.hierarchy=this.records;var ea=K.hierarchy.root;for(C=0;C<this.records.length;C++)if(v=this.records[C]){var ra=function(qa){if(K.hierarchy.record)qa.records=qa[ea][K.hierarchy.record];else{var Ba=ea.split(ja.mapChar);if(1<Ba.length){for(var Ua=qa,Ja=0;Ja<Ba.length;Ja++)void 0!=Ua&&(Ua=Ua[Ba[Ja]]);Ba=Ua}else Ba=qa[ea];qa.records=Ba}
398if(null==qa.records||qa.records&&0==qa.records.length)qa[da.leaf]=!0};ra(v);v[da.level]=0;var za=this.getid(K.id,
399v,C);v.uid=za;v[da.parent]=null;v[da.data]=v;void 0===v[da.expanded]&&(v[da.expanded]=!1);var na=function(qa,Ba){if(Ba)for(var Ua=0;Ua<Ba.length;Ua++){var Ja=Ba[Ua];if(Ja){ra(Ja);Ja[da.level]=qa[da.level]+1;Ja[da.parent]=qa;Ja[da.data]=Ja;var Pa=ja.getid(K.id,Ja,Ua);Ja.uid=Pa==Ua&&null==K.id?qa.uid+"_"+Pa:Pa;void 0===Ja[da.expanded]&&(Ja[da.expanded]=!1);na(Ja,Ja.records)}}else qa.records=[]};na(v,v.records)}return this.hierarchy}if(K.hierarchy.keyDataField&&K.hierarchy.parentDataField)return this.hierarchy=
400C=this.getRecordsHierarchy(K.hierarchy.keyDataField.name,K.hierarchy.parentDataField.name,"records",null,v);if(K.hierarchy.groupingDataFields){za=[];for(C=0;C<K.hierarchy.groupingDataFields.length;C++)za.push(K.hierarchy.groupingDataFields[C].name);return this.hierarchy=C=this.getGroupedRecords(za,"records","label",null,"data",null,"parent",v)}}}},addRecord:function(v,K,C,da){var ja=this,ea=function(){return{leaf:"leaf",parent:"parent",expanded:"expanded",checked:"checked",selected:"selected",level:"level",
401icon:"icon",data:"data"}};if(void 0!=v)if(void 0!=C){if(0<this.hierarchy.length){var ra=function(za){if(za)for(var na=0;na<za.length;na++){var qa=za[na];if(qa.uid==C)return za=ja._source&&ja._source.hierarchy?ja._source.hierarchy.reservedNames:null,null==za&&(za=ea()),v[za.parent]=qa,v[za.level]=qa[za.level]+1,qa.records||(qa.records=[]),qa[za.leaf]=!1,"last"==K?qa.records.push(v):"number"===typeof K&&isFinite(K)?qa.records.splice(K,0,v):qa.records.splice(0,0,v),!0;qa.records&&ra(qa.records)}};ra(this.hierarchy)}}else return this.hierarchy&&
4020<=this.hierarchy.length&&(this._source.hierarchy||da)?(da=ja._source&&ja._source.hierarchy?ja._source.hierarchy.reservedNames:null,null==da&&(da=ea()),v[da.level]=0,"last"==K?this.hierarchy.push(v):"number"===typeof K&&isFinite(K)?this.hierarchy.splice(K,0,v):this.hierarchy.splice(0,0,v)):"last"==K?this.records.push(v):"number"===typeof K&&isFinite(K)?this.records.splice(K,0,v):this.records.splice(0,0,v),!0;return!1},deleteRecord:function(v){var K=this;if(0<this.hierarchy.length){var C=function(ja){if(ja)for(var ea=
4030;ea<ja.length;ea++){var ra=ja[ea];if(ra.uid==v){ja.splice(ea,1);K.recordids[v]&&delete K.recordids[v];var za=function(na){for(var qa=0;qa<na.length;qa++){for(var Ba=na[qa].uid,Ua=0;Ua<K.records.length;Ua++)if(K.records[Ua].uid==Ba){K.records.splice(Ua,1);break}na[qa].records&&za(na[qa].records)}};ra.records&&za(ra.records);for(ja=0;ja<K.records.length;ja++)if(ra=K.records[ja],ra.uid==v){K.records.splice(ja,1);break}return!0}ra.records&&C(ra.records)}};C(this.hierarchy)}else for(var da=0;da<this.records.length;da++)if(this.records[da].uid==
404v)return this.records.splice(da,1),!0;return!1},addForeignValues:function(v){for(var K=v.datafields?v.datafields.length:0,C=0;C<K;C++){var da=v.datafields[C];if(void 0!=da)if(void 0!=da.values){void 0==da.value&&(da.value=da.name);void 0==da.values.value&&(da.values.value=da.value);var ja=[];if(this.pageable&&this.virtualmode){var ea=this.pagenum*this.pagesize;var ra=ea+this.pagesize;ra>this.totalrecords&&(ra=this.totalrecords)}else this.virtualmode?(ea=v.recordstartindex,ra=v.recordendindex,ra>this.totalrecords&&
405(ra=this.totalrecords)):(ea=0,ra=this.records.length);for(;ea<ra;ea++){var za=this.records[ea],na=da.name,qa=za[da.value];if(void 0!=ja[qa])za[na]=ja[qa];else for(var Ba=0;Ba<da.values.source.length;Ba++){var Ua=da.values.source[Ba],Ja=Ua[da.values.value];void 0==Ja&&(Ja=Ua.uid);if(Ja==qa){Ba=Ua[da.values.name];za[na]=Ba;ja[qa]=Ba;break}}}}else if(void 0!=da.value)for(ea=0;ea<this.records.length;ea++)za=this.records[ea],za[da.name]=za[da.value]}},abort:function(){this.xhr&&4!=this.xhr.readyState&&
406(this.xhr.abort(),this.callDownloadComplete())},_requestData:function(v,K,C){var da=this;C.loadServerData(v,K,function(ja){ja.totalrecords&&(K.totalrecords=ja.totalrecords,da.totalrecords=ja.totalrecords);ja.records&&(da.records=ja.records,da.cachedrecords=ja.records);da.addForeignValues(K);if(C.uniqueDataFields){var ea=da.getUniqueRecords(da.records,C.uniqueDataFields);da.records=ea;da.cachedrecords=ea}C.beforeLoadComplete&&(ea=C.beforeLoadComplete(da.records,ja),void 0!=ea&&(da.records=ea,da.cachedrecords=
407ea));for(ea=0;ea<da.records.length;ea++){var ra=da.records[ea];void 0!=ra&&void 0==ra.uid&&(ra.uid=da.getid(K.id,ra,ea))}
407da.buildHierarchy.call(da);a.isFunction(C.loadComplete)&&C.loadComplete(ja);da.callDownloadComplete()})},getUniqueRecords:function(v,K){if(v&&K)for(var C=v.length,da=K.length,ja=[],ea=[],ra=0;ra<C;ra++){var za=v[ra],na="";if(void 0!=za){for(var qa=0;qa<da;qa++){var Ba=K[qa];void 0!==za[Ba]&&(na+=za[Ba]+"_")}!ea[na]&&na&&(ja[ja.length]=za);ea[na]=!0}}return ja},getAggregatedData:function(v,
408K,C,da){var ja=C;ja||(ja=this.records);var ea={};C=[];var ra=ja.length;if(0!=ra&&void 0!=ra){for(var za=0;za<ra;za++)for(var na=ja[za],qa=0;qa<v.length;qa++){var Ba=v[qa],Ua=na[Ba.name];if(Ba.aggregates){ea[Ba.name]=ea[Ba.name]||{};C[Ba.name]=C[Ba.name]||0;C[Ba.name]++;var Ja=function(Ca){for(var xa in Ca){var Fa=ea[Ba.name][xa];null==Fa&&(Fa=ea[Ba.name][xa]=0);a.isFunction(Ca[xa])&&(Fa=Ca[xa](Fa,Ua,Ba.name,na,da));ea[Ba.name][xa]=Fa}},Pa=parseFloat(Ua);(Pa=isNaN(Pa)?!1:!0)&&(Ua=parseFloat(Ua));"number"===
409typeof Ua&&isFinite(Ua)?a.each(Ba.aggregates,function(){var Ca=ea[Ba.name][this];null==Ca&&(Ca=0,"min"==this&&(Ca=9999999999999),"max"==this&&(Ca=-9999999999999));if("sum"==this||"avg"==this||"stdev"==this||"stdevp"==this||"var"==this||"varp"==this)Ca+=parseFloat(Ua);else if("product"==this)Ca=0==za?parseFloat(Ua):Ca*parseFloat(Ua);else if("min"==this)Ca=Math.min(Ca,parseFloat(Ua));else if("max"==this)Ca=Math.max(Ca,parseFloat(Ua));else if("count"==this)Ca++;else if("object"==typeof this){Ja(this);
410return}ea[Ba.name][this]=Ca}):a.each(Ba.aggregates,function(){if("min"==this||"max"==this||"count"==this||"product"==this||"sum"==this||"avg"==this||"stdev"==this||"stdevp"==this||"var"==this||"varp"==this){if(null===Ua)return!0;var Ca=ea[Ba.name][this];null==Ca&&(Ca=0);ea[Ba.name][this]=Ca;return!0}"object"==typeof this&&Ja(this)})}}for(qa=0;qa<v.length;qa++)Ba=v[qa],ea[Ba.name]||(ea[Ba.name]={},a.each(Ba.aggregates,function(Ca){ea[Ba.name][this]=0})),void 0!=ea[Ba.name].avg?(Ua=ea[Ba.name].avg,
411Pa=C[Ba.name],ea[Ba.name].avg=0===Pa||void 0==Pa?0:Ua/Pa):void 0!=ea[Ba.name].count&&(ea[Ba.name].count=ra),(ea[Ba.name].stdev||ea[Ba.name].stdevp||ea[Ba.name]["var"]||ea[Ba.name].varp)&&a.each(Ba.aggregates,function(Ca){if("stdev"==this||"var"==this||"varp"==this||"stdevp"==this){for(var xa=ea[Ba.name][this]/ra,Fa=Ca=0;Fa<ra;Fa++){var Na=ja[Fa][Ba.name];Ca+=(Na-xa)*(Na-xa)}xa="stdevp"==this||"varp"==this?ra:ra-1;0==xa&&(xa=1);if("var"==this||"varp"==this)ea[Ba.name][this]=Ca/xa;else if("stdevp"==
412this||"stdev"==this)ea[Ba.name][this]=Math.sqrt(Ca/xa)}}),Ba.formatStrings&&a.each(Ba.aggregates,function(Ca){if(Ca=Ba.formatStrings[Ca])if("min"==this||"max"==this||"count"==this||"product"==this||"sum"==this||"avg"==this||"stdev"==this||"stdevp"==this||"var"==this||"varp"==this){var xa=ea[Ba.name][this];ea[Ba.name][this]=a.jqx.dataFormat.formatnumber(xa,Ca,K)}else if("object"==typeof this)for(var Fa in this)xa=ea[Ba.name][Fa],ea[Ba.name][Fa]=a.jqx.dataFormat.formatnumber(xa,Ca,K)});return ea}},
413bindDownloadComplete:function(v,K){this._downloadComplete[this._downloadComplete.length]={id:v,func:K}},unbindDownloadComplete:function(v){for(var K=0;K<this._downloadComplete.length;K++)if(this._downloadComplete[K].id==v){this._downloadComplete[K].func=null;this._downloadComplete.splice(K,1);break}},callDownloadComplete:function(){for(var v=0;v<this._downloadComplete.length;v++){var K=this._downloadComplete[v];null!=K.func&&K.func()}},setSource:function(v){this._source=v},generatekey:function(){var v=
414function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return v()+v()+"-"+v()+"-"+v()+"-"+v()+"-"+v()+v()+v()},getGroupedRecords:function(v,K,C,da,ja,ea,ra,za,na){na||=0;for(var qa=[],Ba=0;Ba<v.length;Ba++)qa[Ba]=this.generatekey();K||="items";C||="group";ja||="record";ra||="parentItem";void 0===ea&&(ea="value");var Ua=[],Ja=0,Pa=[],Ca=v.length;za||(za=this.records);for(var xa=za.length,Fa=function(la){da&&a.each(da,function(){this.name&&this.map&&(la[this.map]=la[this.name])});return la},
415Na=0;Na<xa;Na++){var I=Fa(za[Na]),Ta=[],Sa=0;for(Ba=0;Ba<Ca;Ba++){var db=I[v[Ba]];null!=db&&(Ta[Sa++]={value:db,hash:qa[Ba]})}if(Ta.length!=Ca)break;Ba=null;Sa="";db=-1;for(var ab=0;ab<Ta.length;
415ab++){db++;var Oa=Ta[ab].value;Sa=Sa+"_"+Ta[ab].hash+"_"+Oa;if(void 0!=Pa[Sa]&&null!=Pa[Sa])Ba=Pa[Sa];else{if(null==Ba){Ba={level:0};Ba[ra]=null;Ba[C]=Oa;Ba[ja]=I;Ba.expanded=void 0!==I.expanded?I.expanded:!1;ea&&(Ba[ea]=I[ea]);Ba[K]=[];Oa=Ua.length+na;if(!this._source.id||"number"===typeof I.uid||isFinite(I.uid))Oa=
416"Row"+Oa;Ba.uid=Oa;Ua[Ja++]=Ba}else{var Ga={level:Ba.level+1};Ga[ra]=Ba;Ga[C]=Oa;Ga[K]=[];Ga[ja]=I;Ga.expanded=void 0!==I.expanded?I.expanded:!1;ea&&(Ga[ea]=I[ea]);Ga.uid=Ba.uid+"_"+Ba[K].length;Ba=Ba[K][Ba[K].length]=Ga}Pa[Sa]=Ba}}I&&(I.leaf=!0);null!=Ba?(null==this._source.id&&(void 0==I.uid?I.uid=Ba.uid+"_"+Ba[K].length:-1==I.uid.toString().indexOf(Ba.uid)&&(I.uid=Ba.uid+"_"+I.uid)),I[ra]=Ba,I.level=Ba.level+1,Ba[K][Ba[K].length]=I):void 0==I.uid&&(I.uid=this.generatekey())}return Ua},getRecordsHierarchy:function(v,
417K,C,da,ja){var ea=[],ra=this.records;ja&&(ra=ja);if(0==this.records.length)return null;var za=null!=C?C:"items";C=[];ja=ra.length;for(var na=this._source&&this._source.hierarchy?this._source.hierarchy.reservedNames:null,qa=function(I){da&&a.each(da,function(){this.name&&this.map&&(I[this.map]=I[this.name])});return I},Ba=0;Ba<ja;Ba++){var Ua=a.extend({},ra[Ba]),Ja=Ua[K],Pa=Ua[v];C[Pa]={parentid:Ja,item:Ua}}for(Ba=0;Ba<ja;Ba++)if(Ua=a.extend({},ra[Ba]),Ja=Ua[K],Pa=Ua[v],void 0!=C[Ja]){Ua={parentid:Ja,
418item:C[Pa].item};var Ca=C[Ja].item;Ca[za]||(Ca[za]=[]);var xa=Ca[za].length,Fa=Ua.item;na?void 0==Fa[na.parent]&&(Fa[na.parent]=Ca):void 0==Fa.parent&&(Fa.parent=Ca);Fa=qa(Fa);Ca[za][xa]=Fa;C[Ja].item=Ca;C[Pa]=Ua}else Fa=C[Pa].item,na?void 0==Fa[na.parent]&&(Fa[na.parent]=null):void 0==Fa.parent&&(Fa.parent=null),Fa=qa(Fa),na?Fa[na.level]=0:Fa.level=0,ea[ea.length]=Fa;if(0!=ea.length){var Na=function(I,Ta){for(var Sa=0;Sa<Ta.length;Sa++){na?Ta[Sa][na.level]=I:Ta[Sa].level=I;var db=Ta[Sa][za];db?0<
419db.length?Na(I+1,db):na?Ta[Sa][na.leaf]=!0:Ta[Sa].leaf=!0:na?Ta[Sa][na.leaf]=!0:Ta[Sa].leaf=!0}};Na(0,ea)}return ea},bindBindingUpdate:function(v,K){this._bindingUpdate[this._bindingUpdate.length]={id:v,func:K}},unbindBindingUpdate:function(v){for(var K=0;K<this._bindingUpdate.length;K++)if(this._bindingUpdate[K].id==v){this._bindingUpdate[K].func=null;this._bindingUpdate.splice(K,1);break}},callBindingUpdate:function(v){for(var K=0;K<this._bindingUpdate.length;K++){var C=this._bindingUpdate[K];null!=
420C.func&&C.func(v)}},getid:function(v,K,C){if(null!=v&&void 0!=v.name&&v.name){var da=a(K).attr(v.name);if(null!=da&&0<da.toString().length)return da;if(v.map)try{da=a(K).attr(v.map);if(null!=da&&0<da.toString().length)return da;if(0<a(v.map,K).length)return a(v.map,K).text();if(0<a(v.name,K).length)return a(v.name,K).text()}catch(ja){return C}}else{if(0<a(v,K).length)return a(v,K).text();if(v&&0<v.toString().length){da=a(K).attr(v);if(null!=da&&0<da.toString().length)return a.trim(da).split(" ").join("").replace(/([ #;?%&,.+*~':"!^$[\]()=>|\/\\@])/g,
421"");da=v.split(this.mapChar);if(1<da.length){v=K;for(K=0;K<da.length;K++)void 0!=v&&(v=v[da[K]]);if(void 0!=v)return v}else if(void 0!=K[v])return K[v]}return C}},loadjson:function(v,K,C){"string"==typeof v&&(v=a.parseJSON(v));void 0==C.root&&(C.root="");void 0==C.record&&(C.record="");(v=v||K)||(v=[]);var da=this;if(""!=C.root){var ja=C.root.split(da.mapChar);if(1<ja.length){K=v;for(var ea=0;ea<ja.length;ea++)void 0!=K&&(K=K[ja[ea]]);v=K}else if(void 0!==v[C.root]?v=v[C.root]:v[0]&&void 0!==v[0][C.root]?
422v=v[0][C.root]:a.each(v,function(Ta){if(this==C.root)return v=this,!1;void 0!=this[C.root]&&(v=this[C.root])}),!v&&(ja=C.root.split(da.mapChar),0<ja.length)){K=v;for(ea=0;ea<ja.length;ea++)void 0!=K&&(K=K[ja[ea]]);v=K}}else if(!v.length)for(var ra in v)if(a.isArray(v[ra])){v=v[ra];break}null!=v&&void 0==v.length&&(v=a.makeArray(v));if(null==v||void 0==v||"undefined"==v||void 0==v.length)throw Error("jqxDataAdapter: JSON Parse error! Invalid JSON. Please, check your JSON or your jqxDataAdapter initialization!");
423if(0==v.length)this.totalrecords=0;else{K=v.length;this.totalrecords=this.virtualmode?C.totalrecords||K:K;this.records=[];this.originaldata=[];var za=this.records,na=this.pageable?this.pagesize*this.pagenum:C.recordstartindex;this.recordids=[];C.loadallrecords&&(na=0,K=this.totalrecords);var qa=0;this.virtualmode&&(qa=na=this.pageable?this.pagesize*this.pagenum:C.recordstartindex,na=0,K=this.totalrecords);var Ba=C.datafields?C.datafields.length:0;if(0==Ba){ja=v[0];ea=[];for(ra in ja)ea[ea.length]=
424{name:ra};C.datafields=ea;C.generatedfields=C.datafields;Ba=ea.length}for(var Ua=ra=na;Ua<K;Ua++){var Ja=v[Ua];if(void 0==Ja)break;if(C.record&&""!=C.record&&(Ja=Ja[C.record],void 0==Ja))continue;var Pa=this.getid(C.id,Ja,Ua);"object"===typeof Pa&&(Pa=Ua);if(!this.recordids[Pa]){this.recordids[Pa]=Ja;for(var Ca={},xa=0;xa<Ba;xa++){var Fa=C.datafields[xa];ja="";if(void 0!=Fa&&null!=Fa){if(Fa.map){if(a.isFunction(Fa.map))ja=Fa.map(Ja);else if(ja=Fa.map.split(da.mapChar),0<ja.length){var Na=Ja;for(ea=
4250;ea<ja.length;ea++)void 0!=Na&&(Na=Na[ja[ea]]);ja=Na}else ja=Ja[Fa.map];void 0!=ja&&null!=ja?ja=this.getvaluebytype(ja,Fa):void 0==ja&&null!=ja&&(ja="")}""!=ja||Fa.map||(ja=Ja[Fa.name],void 0==ja&&null!=ja&&(ja=""),void 0!=Fa.value&&void 0!=ja&&(ea=ja[Fa.value],void 0!=ea&&(ja=ea)));ja=this.getvaluebytype(ja,Fa);void 0!=Fa.displayname?Ca[Fa.displayname]=ja:Ca[Fa.name]=ja;if("array"===Fa.type){var I=function(Ta){if(Ta)for(var Sa=0;Sa<Ta.length;Sa++){var db=Ta[Sa];if(db)for(var ab=0;ab<Ba;ab++){var Oa=
426C.datafields[ab],Ga="";if(void 0!=Oa&&null!=Oa){if(Oa.map){if(a.isFunction(Oa.map))Ga=Oa.map(db);else if(Ga=Oa.map.split(da.mapChar),0<Ga.length){for(var la=db,ta=0;ta<Ga.length;ta++)void 0!=la&&(la=la[Ga[ta]]);Ga=la}else Ga=db[Oa.map];void 0!=Ga&&null!=Ga?Ga=this.getvaluebytype(Ga,Oa):void 0==Ga&&null!=Ga&&(Ga="")}
426""!=Ga||Oa.map||(Ga=db[Oa.name],void 0==Ga&&null!=Ga&&(Ga=""),void 0!=Oa.value&&void 0!=Ga&&(la=Ga[Oa.value],void 0!=la&&(Ga=la)));Ga=this.getvaluebytype(Ga,Oa);void 0!=Oa.displayname?
427db[Oa.displayname]=Ga:db[Oa.name]=Ga;"array"===Oa.type&&I.call(this,Ga)}}}};I.call(this,ja)}}}if(0>=C.recordendindex||na<C.recordendindex)za[qa+ra]=Object(Ca),za[qa+ra].uid=Pa,this.originaldata[qa+ra]=Object(za[Ua]),ra++}}this.cachedrecords=this.records=za}},loadxml:function(v,K,C){"string"==typeof v&&(K=a(a.parseXML(v)),v=null);void 0==C.root&&(C.root="");void 0==C.record&&(C.record="");(v=a.jqx.browser.msie&&K?void 0!=K.xml?a(C.root+" "+C.record,a.parseXML(K.xml)):v||a(C.root+" "+C.record,K):v||
428a(C.root+" "+C.record,K))||(v=[]);K=v.length;if(0!=v.length){this.totalrecords=this.virtualmode?C.totalrecords||K:K;this.records=[];this.originaldata=[];var da=this.records,ja=this.pageable?this.pagesize*this.pagenum:C.recordstartindex;this.recordids=[];C.loadallrecords&&(ja=0,K=this.totalrecords);var ea=0;this.virtualmode&&(ea=ja=this.pageable?this.pagesize*this.pagenum:C.recordstartindex,ja=0,K=this.totalrecords);var ra=C.datafields?C.datafields.length:0;if(0==ra){ra=v[0];var za=[],na;for(na in ra)za[za.length]=
429{name:na};C.datafields=za;C.generatedfields=C.datafields;ra=za.length}var qa=ja;for(na=ja;na<K;na++){za=v[na];if(void 0==za)break;var Ba=this.getid(C.id,za,na);if(!this.recordids[Ba]){this.recordids[Ba]=za;var Ua={},Ja=!1;C.hierarchy&&C.hierarchy.root&&(Ja=!0);for(var Pa=0;Pa<ra;Pa++){var Ca=C.datafields[Pa],xa="";if(void 0!=Ca&&null!=Ca){if(Ca.map)if(a.isFunction(Ca.map))xa=Ca.map(za);else{var Fa=Ca.map.indexOf("[");if(0>Fa)if(xa=a(Ca.map,za),1==xa.length)xa=xa.text();else{Fa=[];for(var Na=0;Na<
430xa.length;Na++)Fa.push(a(xa[Na]).text());xa=Fa;Ja&&0<Fa.length&&(xa=Fa[0])}else xa=Ca.map.substring(0,Fa-1),Na=Ca.map.indexOf("]"),Fa=Ca.map.substring(Fa+1,Na),xa=a(xa,za).attr(Fa),void 0==xa&&(xa=a(za).attr(Fa)),void 0==xa&&(xa="");""==xa&&(xa=a(za).attr(Ca.map),void 0==xa&&(xa=""))}if(""==xa){xa=a(Ca.name,za);if(1==xa.length)xa=xa.text();else{Fa=[];for(Na=0;Na<xa.length;Na++)Fa.push(a(xa[Na]).text());xa=Fa;Ja&&0<Fa.length&&(xa=Fa[0])}""==xa&&(xa=a(za).attr(Ca.name),void 0==xa&&(xa=""));""==xa&&
431za.nodeName&&za.nodeName==Ca.name&&za.firstChild&&(xa=a(za.firstChild).text())}xa=this.getvaluebytype(xa,Ca);void 0!=Ca.displayname?Ua[Ca.displayname]=xa:Ua[Ca.name]=xa}}if(0>=C.recordendindex||ja<C.recordendindex)da[ea+qa]=a.extend({},Ua),da[ea+qa].uid=Ba,this.originaldata[ea+qa]=a.extend({},da[na]),qa++}}if(C.hierarchy&&C.hierarchy.root)for(na=ja;na<K;na++)za=v[na],ja=da[na],0<a(za).parent().length?(Ba=this.getid(C.id,a(za).parents(C.hierarchy.record+":first")),ja.parentuid=Ba):ja.parentuid=null;
432this.cachedrecords=this.records=da}},loadics:function(v,K){if(null!=v){K=v.split(K.rowDelimiter||this.rowDelimiter||"\n");var C=K.length;v=v.split("\r");1==C&&1<v.length&&(K=v,C=K.length);this.records=[];this.originaldata=[];v=this.records;this.recordids=[];for(var da=function(za){var na=/^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z)?$/.exec(za);if(!na)throw Error("Invalid UNTIL value: "+za);return new Date(Date.UTC(na[1],na[2]-1,na[3],na[5]||0,na[6]||0,na[7]||0))},ja=0;ja<C;ja++){var ea=K[ja];
433if("BEGIN:VEVENT"==ea)var ra={};else 0<=ea.indexOf("SUMMARY")?ra.SUMMARY=ea.substring(ea.indexOf("SUMMARY")+8):0<=ea.indexOf("LOCATION")?ra.LOCATION=ea.substring(ea.indexOf("LOCATION")+9):0<=ea.indexOf("DESCRIPTION")?ra.DESCRIPTION=ea.substring(ea.indexOf("DESCRIPTION")+12):0<=ea.indexOf("RRULE")?ra.RRULE=ea.substring(ea.indexOf("RRULE")+6):0<=ea.indexOf("EXDATE")?(ea=ea.substring(ea.indexOf("EXDATE")+7),ra.EXDATE=ea):0<=ea.indexOf("DTEND")?ra.DTEND=da(ea.substring(ea.indexOf("DTEND")+6)):0<=ea.indexOf("DTSTART")?
434ra.DTSTART=da(ea.substring(ea.indexOf("DTSTART")+8)):0<=ea.indexOf("UID")?ra.uid=ra.UID=ea.substring(ea.indexOf("UID")+4):0<=ea.indexOf("STATUS")?ra.STATUS=ea.substring(ea.indexOf("STATUS")+7):"END:VEVENT"==ea&&v.push(ra)}this.cachedrecords=this.records=v}},loadtext:function(v,K){if(null!=v){var C=v.split(K.rowDelimiter||this.rowDelimiter||"\n"),da=C.length;v=v.split("\r");1==da&&1<v.length&&(C=v,da=C.length);this.totalrecords=this.virtualmode?K.totalrecords||da:da;this.records=[];this.originaldata=
435[];v=this.records;var ja=this.pageable?this.pagesize*this.pagenum:K.recordstartindex;this.recordids=[];K.loadallrecords&&(ja=0,da=this.totalrecords);var ea=0;this.virtualmode&&(ea=ja=this.pageable?this.pagesize*this.pagenum:K.recordstartindex,ja=0,da=this.totalrecords);var ra=K.datafields.length,za=K.columnDelimiter||this.columnDelimiter;for(za||="tab"===K.datatype||"tsv"===K.datatype?"\t":",";ja<da;
435ja++){var na=C[ja],qa=null;if(!this.recordids[qa]){null==K.id&&(qa=ja,this.recordids[qa]=na);for(var Ba=
436{},Ua=C[ja].split(za),Ja=0;Ja<ra;Ja++)if(!(Ja>=Ua.length)){var Pa=K.datafields[Ja],Ca=Ua[Ja];Pa.map&&a.isFunction(Pa.map)&&(Ca=Pa.map(na));Pa.type&&(Ca=this.getvaluebytype(Ca,Pa));Ba[Pa.map||Pa.name||Ja.toString()]=Ca;null!=K.id&&K.id===Pa.name&&(qa=Ca,this.recordids[qa]=na)}null==qa&&(qa=ja);v[ea+ja]=a.extend({},Ba);v[ea+ja].uid=qa;this.originaldata[ea+ja]=a.extend({},v[ja])}}this.cachedrecords=this.records=v}},getvaluebytype:function(v,K){var C=v;if(null==v)return v;if(a.isArray(v)&&"array"!=K.type){for(C=
4370;C<v.length;C++)v[C]=this.getvaluebytype(v[C],K);return v}if("date"==K.type)if("NaN"==v)v="";else{if(v&&v instanceof Date)return v;var da=new Date(v);"string"==typeof v&&K.format&&(K=a.jqx.dataFormat.parsedate(v,K.format),null!=K&&(da=K));v="NaN"==da.toString()||"Invalid Date"==da.toString()?a.jqx.dataFormat?a.jqx.dataFormat.tryparsedate(v):da:da;null==v&&(v=C)}else if("float"==K.type||"number"==K.type||"decimal"==K.type)"NaN"==v?v="":(v=parseFloat(v),isNaN(v)&&(v=C));else if("int"==K.type||"integer"==
438K.type)v=parseInt(v),isNaN(v)&&(v=C);else if("bool"==K.type||"boolean"==K.type)null!=v&&void 0!=v.toLowerCase&&("false"==v.toLowerCase()?v=!1:"true"==v.toLowerCase()&&(v=!0)),v=1==v?!0:0==v&&""!==v?!1:"";return v}};a.jqx.dataFormat={};a.extend(a.jqx.dataFormat,{regexTrim:/^\s+|\s+$/g,regexInfinity:/^[+-]?infinity$/i,regexHex:/^0x[a-f0-9]+$/i,regexParseFloat:/^[+-]?\d*\.?\d*(e[+-]?\d+)?$/,toString:Object.prototype.toString,isBoolean:function(v){return"boolean"===typeof v},isObject:function(v){return v&&
439("object"===typeof v||a.isFunction(v))||!1},isDate:function(v){return v instanceof Date},arrayIndexOf:function(v,K){if(v.indexOf)return v.indexOf(K);for(var C=0,da=v.length;C<da;C++)if(v[C]===K)return C;return-1},isString:function(v){return"string"===typeof v},isNumber:function(v){return"number"===typeof v&&isFinite(v)},isNull:function(v){return null===v},isUndefined:function(v){return"undefined"===typeof v},isValue:function(v){return this.isObject(v)||this.isString(v)||this.isNumber(v)||this.isBoolean(v)},
440isEmpty:function(v){if(!this.isString(v)&&this.isValue(v))return!1;if(!this.isValue(v))return!0;v=a.trim(v).replace(/&nbsp;/ig,"").replace(/&#160;/ig,"");return""===v},startsWith:function(v,K){return 0===v.indexOf(K)},endsWith:function(v,K){return v.substr(v.length-K.length)===K},trim:function(v){return(v+"").replace(this.regexTrim,"")},isArray:function(v){return"[object Array]"===this.toString.call(v)},defaultcalendar:function(){return{"/":"/",":":":",firstDay:0,days:{names:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),
441namesAbbr:"Sun Mon Tue Wed Thu Fri Sat".split(" "),namesShort:"Su Mo Tu We Th Fr Sa".split(" ")},months:{names:"January February March April May June July August September October November December ".split(" "),namesAbbr:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ".split(" ")},AM:["AM","am","AM"],PM:["PM","pm","PM"],eras:[{name:"A.D.",start:null,offset:0}],twoDigitYearMax:2029,patterns:{d:"M/d/yyyy",D:"dddd, MMMM dd, yyyy",t:"h:mm tt",T:"h:mm:ss tt",f:"dddd, MMMM dd, yyyy h:mm tt",F:"dddd, MMMM dd, yyyy h:mm:ss tt",
442M:"MMMM dd",Y:"yyyy MMMM",S:"yyyy'-'MM'-'dd'T'HH':'mm':'ss",ISO:"yyyy-MM-dd hh:mm:ss",ISO2:"yyyy-MM-dd HH:mm:ss",d1:"dd.MM.yyyy",d2:"dd-MM-yyyy",d3:"MM-dd-yyyy",zone1:"yyyy-MM-ddTHH:mm:ss-HH:mm",zone2:"yyyy-MM-ddTHH:mm:ss+HH:mm",custom:"yyyy-MM-ddTHH:mm:ss.fff",custom2:"yyyy-MM-dd HH:mm:ss.fff"},percentsymbol:"%",currencysymbol:"$",currencysymbolposition:"before",decimalseparator:".",thousandsseparator:","}},expandFormat:function(v,K){K=K||"F";v=v.patterns;var C=K.length;if(1===C){v=v[K];if(!v)throw"Invalid date format string '"+
443K+"'.";K=v}else 2===C&&"%"===K.charAt(0)&&(K=K.charAt(1));return K},getEra:function(v,K){if(!K||"string"===typeof v)return 0;for(var C=v.getTime(),da=0,ja=K.length;da<ja;da++)if(v=K[da].start,null===v||C>=v)return da;return 0},toUpperArray:function(v){for(var K=[],C=0,da=v.length;C<da;C++)K[C]=this.toUpper(v[C]);return K},getEraYear:function(v,K,C,da){v=v.getFullYear();
443!da&&K.eras&&(v-=K.eras[C].offset);return v},toUpper:function(v){return v?v.toUpperCase():""},getDayIndex:function(v,K,C){var da=
444v.days,ja=v._upperDays;ja||(v._upperDays=ja=[this.toUpperArray(da.names),this.toUpperArray(da.namesAbbr),this.toUpperArray(da.namesShort)]);K=K.toUpperCase();C?(v=this.arrayIndexOf(ja[1],K),-1===v&&(v=this.arrayIndexOf(ja[2],K))):v=this.arrayIndexOf(ja[0],K);return v},getMonthIndex:function(v,K,C){var da=v.months,ja=v.monthsGenitive||v.months,ea=v._upperMonths,ra=v._upperMonthsGen;ea||(v._upperMonths=ea=[this.toUpperArray(da.names),this.toUpperArray(da.namesAbbr)],v._upperMonthsGen=ra=[this.toUpperArray(ja.names),
445this.toUpperArray(ja.namesAbbr)]);K=this.toUpper(K);v=this.arrayIndexOf(C?ea[1]:ea[0],K);0>v&&(v=this.arrayIndexOf(C?ra[1]:ra[0],K));return v},appendPreOrPostMatch:function(v,K){for(var C=0,da=!1,ja=0,ea=v.length;ja<ea;ja++){var ra=v.charAt(ja);switch(ra){case "'":da?K.push("'"):C++;da=!1;break;case "\\":da&&K.push("\\");da=!da;break;default:K.push(ra),da=!1}}return C},getTokenRegExp:function(){return/\/|dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z|gg|g/g},formatlink:function(v,
446K){var C="";K&&K.target&&(C="target="+K.target);return""!=C?"<a "+C+' href="'+v+'">'+v+"</a>":'<a href="'+v+'">'+v+"</a>"},formatemail:function(v){return'<a href="mailto:'+v+'">'+v+"</a>"},formatNumber:function(v,K,C){return this.formatnumber(v,K,C)},formatnumber:function(v,K,C){if(void 0==C||null==C||""==C)C=this.defaultcalendar(
446);if(""===K||null===K)return v;this.isNumber(v)||(v*=1);var da;1<K.length&&(da=parseInt(K.slice(1),10));var ja,ea,ra=K.charAt(0).toUpperCase();K=C.thousandsseparator;var za=
447C.decimalseparator;switch(ra){case "D":case "d":case "F":case "f":break;case "N":case "n":da=0;break;case "C":case "c":"before"==C.currencysymbolposition?ja=C.currencysymbol:ea=C.currencysymbol;break;case "P":case "p":ea=C.percentsymbol;break;default:throw"Bad number format specifier: "+ra;}if(this.isNumber(v)){C=0>v;za=za?za:".";if(this.isNumber(da)){var na=da;da=Math.pow(10,na);v=(v*da).toFixed(0)/da+"";da=v.lastIndexOf(".");if(0<na)for(0>da?(v+=za,da=v.length-1):"."!==za&&(v=v.replace(".",za));v.length-
4481-da<na;)v+="0"}else v+="",da=v.lastIndexOf("."),0<da&&void 0==na&&"."!==za&&(v=v.replace(".",za));if(K){da=v.lastIndexOf(za);da=-1<da?da:v.length;na=v.substring(da);za=-1;for(ra=da;0<ra;ra--)za++,0===za%3&&ra!==da&&(!C||1<ra)&&(na=K+na),na=v.charAt(ra-1)+na;v=na}v=ja?ja+v:v;return ea?v+ea:v}return v},tryparsedate:function(v,K){if(void 0==K||null==K)K=this.defaultcalendar(
448);if(""==v)return null;null==v||v.substring||(v=v.toString());if(null!=v&&"/Date("==v.substring(0,6)){K=/^\/Date\((-?\d+)(\+|-)?(\d+)?\)\/$/;
449var C=new Date(+v.replace(/\/Date\((\d+)\)\//,"$1"));if("Invalid Date"==C){var da=v.match(/^\/Date\((\d+)([-+]\d\d)(\d\d)\)\/$/);C=null;da&&(C=new Date(1*da[1]+36E5*da[2]+6E4*da[3]))}if(null==C||"Invalid Date"==C||isNaN(C))if(v=K.exec(v)){var ja=new Date(parseInt(v[1]));v[2]&&(K=parseInt(v[3]),"-"===v[2]&&(K=-K),v=ja.getUTCMinutes(),ja.setUTCMinutes(v-K));if(!isNaN(ja.valueOf()))return ja}return C}var ea=K.patterns;for(za in ea)if(C=this.parsedate(v,ea[za],K))return"ISO"==za&&(K=this.parsedate(v,
450ea.ISO2,K))?K:C;if(null!=v){ja=[":","/","-"];C=!0;for(var ra=0;ra<ja.length;ra++)-1!=v.indexOf(ja[ra])&&(C=!1);if(C&&(C=new Number(v),!isNaN(C)))return new Date(C)}if("string"===a.type(v)){v=this.trim(v);var za=[":","/","-"," ",","];v=v.replace(RegExp(", ","g"),",");ea="";var na=v;0<=v.indexOf(":")?(ea=v.substring(v.indexOf(":")-2),ea=this.trim(ea),na=v.substring(0,v.indexOf(":")-2)):0<=v.toUpperCase().indexOf("AM")?(ea=v.substring(v.toUpperCase().indexOf("AM")-2),ea=this.trim(ea),na=v.substring(0,
451v.toUpperCase().indexOf("AM")-2)):0<=v.toUpperCase().indexOf("PM")&&(ea=v.substring(v.toUpperCase().indexOf("PM")-2),ea=this.trim(ea),na=v.substring(0,v.toUpperCase().indexOf("PM")-2));v=new Date;C=!1;if(na){for(da=0;da<za.length;da++)if(0<=na.indexOf(za[da])){ja=na.split(za[da]);break}za=[];na=[];var qa=[],Ba=null,Ua=null;for(da=0;da<ja.length;da++){ra=ja[da];var Ja=this.parsedate(ra,"d",K)||this.parsedate(ra,"dd",K)||this.parsedate(ra,"ddd",K)||this.parsedate(ra,"dddd",K);if(Ja&&2>=ra.length){Ba=
452da;za.push(Ja.getDate());break}}for(da=0;da<ja.length;da++)if(ra=ja[da],(Ja=this.parsedate(ra,"M",K)||this.parsedate(ra,"MM",K)||this.parsedate(ra,"MMM",K)||this.parsedate(ra,"MMMM",K))&&(void 0==Ba||Ba!=da)&&(na.push(Ja.getMonth()),2<ra.length)){Ua=da;break}for(da=0;da<ja.length;da++)ra=ja[da],ra=this.parsedate(ra,"yyyy",K),!ra||void 0!=Ba&&Ba==da||(void 0==Ua||Ua!=da)&&qa.push(ra.getFullYear());ra=[];for(Ba=0;Ba<za.length;Ba++)for(da=0;da<na.length;da++)for(Ua=0;Ua<qa.length;Ua++)ja=new Date(qa[Ua],
453na[da],za[Ba]),1970>qa[Ua]&&ja.setFullYear(qa[Ua]),NaN!=ja.getTime()&&ra.push(ja);0<ra.length&&(v=ra[0],C=!0)}ea&&(ja=0<=ea.indexOf(":")?ea.split(":"):ea,K=this.parsedate(ea,"h:mm tt",K)||this.parsedate(ea,"h:mm:ss tt",K)||this.parsedate(ea,"HH:mm:ss.fff",K)||this.parsedate(ea,"HH:mm:ss.ff",K)||this.parsedate(ea,"HH:mm:ss.tttt",K)||this.parsedate(ea,"HH:mm:ss",K)||this.parsedate(ea,"HH:mm",K)||this.parsedate(ea,"HH",K),qa=na=za=ea=0,K&&NaN!=K.getTime()?(ea=K.getHours(),za=K.getMinutes(),na=K.getSeconds(),
454qa=K.getMilliseconds()):(1==ja.length&&(ea=parseInt(ja[0])),2==ja.length&&(ea=parseInt(ja[0]),za=parseInt(ja[1])),3==ja.length&&(ea=parseInt(ja[0]),za=parseInt(ja[1]),0<=ja[2].indexOf(".")?(na=parseInt(ja[2].toString().split(".")[0]),qa=parseInt(ja[2].toString().split(".")[1])):na=parseInt(ja[2])),4==ja.length&&(ea=parseInt(ja[0]),za=parseInt(ja[1]),na=parseInt(ja[2]),qa=parseInt(ja[3]))),!v||isNaN(ea)||isNaN(za)||isNaN(na)||isNaN(qa)||(v.setHours(ea,za,na,qa),C=!0));if(C)return v}return null},getparseregexp:function(v,
455K){var C=v._parseRegExp;if(C){var da=C[K];if(da)return da}else v._parseRegExp=C={};da=this.expandFormat(v,K).replace(/([\^\$\.\*\+\?\|\[\]\(\)\{\}])/g,"\\\\$1");for(var ja=["^"],ea=[],ra=0,za=0,na=this.getTokenRegExp(),qa;null!==(qa=na.exec(da));){var Ba=da.slice(ra,qa.index);ra=na.lastIndex;za+=this.appendPreOrPostMatch(Ba,ja);if(za%2)ja.push(qa[0]);else{Ba=qa[0];var Ua=Ba.length;switch(Ba){case "dddd":case "ddd":case "MMMM":case "MMM":case "gg":case "g":Ba="(\\D+)";break;case "tt":case "t":Ba="(\\D*)";
456break;case "yyyy":case "fff":case "ff":case "f":Ba="(\\d{"+Ua+"})";break;case "dd":case "d":case "MM":case "M":case "yy":case "y":case "HH":case "H":case "hh":case "h":case "mm":case "m":case "ss":case "s":Ba="(\\d\\d?)";break;case "zzz":Ba="([+-]?\\d\\d?:\\d{2})";break;case "zz":case "z":Ba="([+-]?\\d\\d?)";break;case "/":Ba="(\\"+v["/"]+")";break;default:throw"Invalid date format pattern '"+Ba+"'.";}Ba&&ja.push(Ba);ea.push(qa[0])}}this.appendPreOrPostMatch(da.slice(ra),ja);ja.push("$");v={regExp:ja.join("").replace(/\s+/g,
457"\\s+"),groups:ea};return C[K]=v},outOfRange:function(v,K,C){return v<K||v>C},expandYear:function(v,K){var C=new Date,da=this.getEra(C);if(100>K){var ja=v.twoDigitYearMax;ja="string"===typeof ja?(new Date).getFullYear()%100+parseInt(ja,10):ja;v=this.getEraYear(C,v,da);K+=v-v%100;K>ja&&(K-=100)}return K},parsedate:function(v,K,C){if(void 0==C||null==C)C=this.defaultcalendar(
457);v=this.trim(v);K=this.getparseregexp(C,K);var da=(new RegExp(K.regExp)).exec(v);if(null===da)return null;var ja=K.groups,ea=
458K=v=null,ra=null,za=null,na=0,qa=0,Ba=0,Ua=0;var Ja=null;for(var Pa=!1,Ca=0,xa=ja.length;Ca<xa;Ca++){var Fa=da[Ca+1];if(Fa){var Na=ja[Ca],I=Na.length,Ta=parseInt(Fa,10);switch(Na){case "dd":case "d":ra=Ta;if(this.outOfRange(ra,1,31))return null;break;case "MMM":case "MMMM":ea=this.getMonthIndex(C,Fa,3===I);if(this.outOfRange(ea,0,11))return null;break;case "M":case "MM":ea=Ta-1;if(this.outOfRange(ea,0,11))return null;break;case "y":case "yy":case "yyyy":K=4>I?this.expandYear(C,Ta):Ta;if(this.outOfRange(K,
4590,9999))return null;break;case "h":case "hh":na=Ta;12===na&&(na=0);if(this.outOfRange(na,0,11))return null;break;case "H":case "HH":na=Ta;if(this.outOfRange(na,0,23))return null;break;case "m":case "mm":qa=Ta;if(this.outOfRange(qa,0,59))return null;break;case "s":case "ss":Ba=Ta;if(this.outOfRange(Ba,0,59))return null;break;case "tt":case "t":Pa=C.PM&&(Fa===C.PM[0]||Fa===C.PM[1]||Fa===C.PM[2]);if(!Pa&&(!C.AM||Fa!==C.AM[0]&&Fa!==C.AM[1]&&Fa!==C.AM[2]))return null;break;case "f":case "ff":case "fff":Ua=
460Ta*Math.pow(10,3-I);if(this.outOfRange(Ua,0,999))return null;break;case "ddd":case "dddd":za=this.getDayIndex(C,Fa,3===I);if(this.outOfRange(za,0,6))return null;break;case "zzz":Na=Fa.split(/:/);if(2!==Na.length)return null;Ja=parseInt(Na[0],10);if(this.outOfRange(Ja,-12,13))return null;Na=parseInt(Na[1],10);if(this.outOfRange(Na,0,59))return null;Ja=60*Ja+(this.startsWith(Fa,"-")?-Na:Na);break;case "z":case "zz":Ja=Ta;if(this.outOfRange(Ja,-12,13))return null;Ja*=60;break;case "g":case "gg":if(!Fa||
461!C.eras)return null;Fa=this.trim(Fa.toLowerCase());Na=0;for(I=C.eras.length;Na<I;Na++)if(Fa===C.eras[Na].name.toLowerCase()){v=Na;break}if(null===v)return null}}}da=new Date;Ca=C.convert;ja=da.getFullYear();null===K?K=ja:C.eras&&(K+=C.eras[v||0].offset);null===ea&&(ea=0);null===ra&&(ra=1);if(Ca){if(da=Ca.toGregorian(K,ea,ra),null===da)return null}else if(da.setFullYear(K,ea,ra),da.getDate()!==ra||null!==za&&da.getDay()!==za)return null;Pa&&12>na&&(na+=12);da.setHours(na,qa,Ba,Ua);null!==Ja&&(C=da.getMinutes()-
462(Ja+da.getTimezoneOffset()),da.setHours(da.getHours()+parseInt(C/60,10),C%60));return da},cleardatescache:function(){this.datescache=[]},formatDate:function(v,K,C){return this.formatdate(v,K,C)},formatdate:function(v,K,C){function da(xa,Fa){xa+="";return 1<Fa&&xa.length<Fa?(xa=Ba[Fa-2]+xa,xa.substr(xa.length-Fa,Fa)):xa}function ja(xa,Fa){if(Pa)return Pa[Fa];if(void 0!=xa.getMonth)switch(Fa){case 0:return xa.getFullYear();case 1:return xa.getMonth();case 2:return xa.getDate()}}if(void 0==C||null==
463C)C=this.defaultcalendar();if("string"===typeof v)return v;var ea=v.toString()+"_"+K;if(this.datescache&&this.datescache[ea]&&-1==K.indexOf("f"))return this.datescache[ea];if(!K||!K.length||"i"===K){var ra;return ra=this.formatDate(v,C.patterns.F,C)}var za=C.eras,na="s"===K;K=this.expandFormat(C,K);ra=[];for(var qa,Ba=["0","00","000"],Ua=0,Ja=this.getTokenRegExp(),Pa;;){qa=Ja.lastIndex;var Ca=Ja.exec(K);qa=K.slice(qa,Ca?Ca.index:K.length);Ua+=this.appendPreOrPostMatch(qa,ra);if(!Ca)break;if(Ua%2)ra.push(Ca[0]);
464else switch(qa=Ca[0],Ca=qa.length,qa){case "ddd":case "dddd":ra.push((3===Ca?C.days.namesAbbr:C.days.names)[v.getDay()]);break;case "d":case "dd":ra.push(da(ja(v,2),Ca));break;case "MMM":case "MMMM":qa=ja(v,1);ra.push(C.months[3===Ca?"namesAbbr":"names"][qa]);break;case "M":case "MM":ra.push(da(ja(v,1)+1,Ca));break;case "y":case "yy":case "yyyy":qa=this.getEraYear(v,C,this.getEra(v,za),na);4>Ca&&(qa%=100);ra.push(da(qa,Ca));break;case "h":case "hh":qa=v.getHours()%12;0===qa&&(qa=12);ra.push(da(qa,
465Ca));break;case "H":case "HH":ra.push(da(v.getHours(),Ca));break;case "m":case "mm":ra.push(da(v.getMinutes(),Ca));break;case "s":case "ss":ra.push(da(v.getSeconds(),Ca));break;case "t":case "tt":qa=12>v.getHours()?C.AM?C.AM[0]:" ":C.PM?C.PM[0]:" ";ra.push(1===Ca?qa.charAt(0):qa);break;case "f":case "ff":case "fff":ra.push(da(v.getMilliseconds(),3).substr(0,Ca));break;case "z":case "zz":qa=v.getTimezoneOffset()/60;ra.push((0>=qa?"+":"-")+da(Math.floor(Math.abs(qa)),Ca));break;case "zzz":qa=v.getTimezoneOffset()/
46660;ra.push((0>=qa?"+":"-")+da(Math.floor(Math.abs(qa)),2)+":"+da(Math.abs(v.getTimezoneOffset()%60),2));break;case "g":case "gg":C.eras&&ra.push(C.eras[this.getEra(v,za)].name);break;case "/":ra.push(C["/"]);break;default:throw"Invalid date format pattern '"+qa+"'.";}}v=ra.join("");this.datescache||(this.datescache=[]);return this.datescache[ea]=v}});a.jqx.data={};var f=/#.*$/,g=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,h=/^(?:GET|HEAD)$/,k=/^\/\//,l=/\?/,m=/([?&])_=[^&]*/,n=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,
467r=/\s+/,t={},u={};try{var x=location.href}catch(v){x=document.createElement("a"),x.href="",x=x.href}var B=n.exec(x.toLowerCase())||[];a.extend(a.jqx.data,{ajaxSetup:function(v,K){K?d(v,a.jqx.data.ajaxSettings):(K=v,v=a.jqx.data.ajaxSettings);d(v,K);return v},ajaxSettings:{url:x,isLocal:/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/.test(B[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",
468html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":window.String,"text html":!0,"text json":a.parseJSON,"text xml":a.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:b(t),ajaxTransport:b(u),ajax:function(v,K){function C(ab,Oa,Ga,la){var ta=Oa;if(2!==Fa){Fa=2;ra&&clearTimeout(ra);ea=void 0;da=la||"";I.readyState=0<ab?4:0;if(Ga){var va=
469na;la=I;var p,E,L=va.contents,ca=va.dataTypes,fa=va.responseFields;for(Ea in fa)Ea in Ga&&(la[fa[Ea]]=Ga[Ea]);for(;"*"===ca[0];)ca.shift(),void 0===p&&(p=va.mimeType||la.getResponseHeader("content-type"));if(p)for(Ea in L)if(L[Ea]&&L[Ea].test(p)){ca.unshift(Ea);break}if(ca[0]in Ga)var ia=ca[0];else{for(Ea in Ga){if(!ca[0]||va.converters[Ea+" "+ca[0]]){ia=Ea;break}E||=Ea}ia=ia||E}ia?(ia!==ca[0]&&ca.unshift(ia),va=Ga[ia]):va=void 0}if(200<=ab&&300>ab||304===ab)if(na.ifModified&&((Ga=I.getResponseHeader("Last-Modified"))&&
470(a.lastModified[Sa]=Ga),(Ga=I.getResponseHeader("Etag"))&&(a.etag[Sa]=Ga)),304===ab){ta="notmodified";var ma=!0}else{a:{var ua=na;var wa=va;var Da;ta=ua.dataTypes.slice();p=ta[0];var Ea={};ia=0;ua.dataFilter&&(wa=ua.dataFilter(wa,ua.dataType));if(ta[1])for(Aa in ua.converters)Ea[Aa.toLowerCase()]=ua.converters[Aa];for(;Ga=ta[++ia];)if("*"!==Ga){if("*"!==p&&p!==Ga){var Aa=Ea[p+" "+Ga]||Ea["* "+Ga];if(!Aa)for(Da in Ea)if(ma=Da.split(" "),ma[1]===Ga&&(Aa=Ea[p+" "+ma[0]]||Ea["* "+ma[0]])){!0===Aa?Aa=
471Ea[Da]:!0!==Ea[Da]&&(Ga=ma[0],ta.splice(ia--,0,Ga));break}if(!0!==Aa)if(Aa&&ua["throws"])wa=Aa(wa);else try{wa=Aa(wa)}catch(Ka){ma={state:"parsererror",error:Aa?Ka:"No conversion from "+p+" to "+Ga};break a}}p=Ga}ma={state:"success",data:wa}}ta=ma.state;ua=ma.data;wa=ma.error;ma=!wa}else if(wa=ta,!ta||ab)ta="error",0>ab&&(ab=0);I.status=ab;I.statusText=(Oa||ta)+"";
471ma?Ua.resolveWith(qa,[ua,ta,I]):Ua.rejectWith(qa,[I,ta,wa]);I.statusCode(Pa);Pa=void 0;Ta&&Ba.trigger("ajax"+(ma?"Success":"Error"),[I,
472na,ma?ua:wa]);Ja.fireWith(qa,[I,ta]);Ta&&(Ba.trigger("ajaxComplete",[I,na]),--a.active||a.event.trigger("ajaxStop"))}}"object"===typeof v&&(K=v,v=void 0);K=K||{};var da,ja,ea,ra,za,na=a.jqx.data.ajaxSetup({},K),qa=na.context||na,Ba=qa!==na&&(qa.nodeType||qa instanceof a)?a(qa):a.event,Ua=a.Deferred(),Ja=a.Callbacks("once memory"),Pa=na.statusCode||{},Ca={},xa={},Fa=0,Na="canceled",I={readyState:0,setRequestHeader:function(ab,Oa){if(!Fa){var Ga=ab.toLowerCase();ab=xa[Ga]=xa[Ga]||ab;Ca[ab]=Oa}return this},
473getAllResponseHeaders:function(){return 2===Fa?da:null},getResponseHeader:function(ab){var Oa;if(2===Fa){if(!ja)for(ja={};Oa=g.exec(da);)ja[Oa[1].toLowerCase()]=Oa[2];Oa=ja[ab.toLowerCase()]}return void 0===Oa?null:Oa},overrideMimeType:function(ab){Fa||(na.mimeType=ab);return this},abort:function(ab){ab=ab||Na;ea&&ea.abort(ab);C(0,ab);return this}};Ua.promise(I);I.success=I.done;I.error=I.fail;I.complete=Ja.add;I.statusCode=function(ab){if(ab)if(2>Fa)for(Oa in ab)Pa[Oa]=[Pa[Oa],ab[Oa]];else{var Oa=
474ab[I.status];I.always(Oa)}return this};na.url=((v||na.url)+"").replace(f,"").replace(k,B[1]+"//");na.dataTypes=a.trim(na.dataType||"*").toLowerCase().split(r);null==na.crossDomain&&(v=n.exec(na.url.toLowerCase()),na.crossDomain=!(!v||v[1]===B[1]&&v[2]===B[2]&&(v[3]||("http:"===v[1]?80:443))==(B[3]||("http:"===B[1]?80:443))));na.data&&na.processData&&"string"!==typeof na.data&&(na.data=a.param(na.data,na.traditional));c(t,na,K,I);if(2===Fa)return I;var Ta=na.global;na.type=na.type.toUpperCase();na.hasContent=
475!h.test(na.type);Ta&&0===a.active++&&a.event.trigger("ajaxStart");if(!na.hasContent){na.data&&(na.url+=(l.test(na.url)?"&":"?")+na.data,delete na.data);var Sa=na.url;if(!1===na.cache){v=(new Date).getTime();var db=na.url.replace(m,"$1_="+v);na.url=db+(db===na.url?(l.test(na.url)?"&":"?")+"_="+v:"")}}(na.data&&na.hasContent&&!1!==na.contentType||K.contentType)&&I.setRequestHeader("Content-Type",na.contentType);na.ifModified&&(Sa=Sa||na.url,a.lastModified[Sa]&&I.setRequestHeader("If-Modified-Since",
476a.lastModified[Sa]),a.etag[Sa]&&I.setRequestHeader("If-None-Match",a.etag[Sa]));I.setRequestHeader("Accept",na.dataTypes[0]&&na.accepts[na.dataTypes[0]]?na.accepts[na.dataTypes[0]]+("*"!==na.dataTypes[0]?", */*; q=0.01":""):na.accepts["*"]);for(za in na.headers)I.setRequestHeader(za,na.headers[za]);if(na.beforeSend&&(!1===na.beforeSend.call(qa,I,na)||2===Fa))return I.abort();Na="abort";for(za in{success:1,error:1,complete:1})I[za](na[za]);if(ea=c(u,na,K,I)){I.readyState=1;Ta&&Ba.trigger("ajaxSend",
477[I,na]);na.async&&0<na.timeout&&(ra=setTimeout(function(){I.abort("timeout")},na.timeout));try{Fa=1,ea.send(Ca,C)}catch(ab){if(2>Fa)C(-1,ab);else throw ab;}}else C(-1,"No Transport");return I},active:0,lastModified:{},etag:{}});var y=[],A=/\?/,aa=/(=)\?(?=&|$)|\?\?/,ha=(new Date).getTime();a.jqx.data.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var v=y.pop()||a.expando+"_"+ha++;this[v]=!0;return v}});a.jqx.data.ajaxPrefilter("json jsonp",function(v,K,C){var da,ja=v.data,ea=v.url,ra=!1!==v.jsonp,
478za=ra&&aa.test(ea),na=ra&&!za&&"string"===typeof ja&&!(v.contentType||"").indexOf("application/x-www-form-urlencoded")&&aa.test(ja);if("jsonp"===v.dataTypes[0]||za||na){var qa=v.jsonpCallback=a.isFunction(v.jsonpCallback)?v.jsonpCallback():v.jsonpCallback;var Ba=window[qa];za?v.url=ea.replace(aa,"$1"+qa):na?v.data=ja.replace(aa,"$1"+qa):ra&&(v.url+=(A.test(ea)?"&":"?")+v.jsonp+"="+qa);v.converters["script json"]=function(){da||a.error(qa+" was not called");return da[0]};v.dataTypes[0]="json";window[qa]=
479function(){da=arguments};C.always(function(){window[qa]=Ba;v[qa]&&(v.jsonpCallback=K.jsonpCallback,y.push(qa));da&&a.isFunction(Ba)&&Ba(da[0]);da=Ba=void 0});return"script"}});a.jqx.data.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(v){a.globalEval(v);return v}}});a.jqx.data.ajaxPrefilter("script",function(v){void 0===v.cache&&(v.cache=!1);v.crossDomain&&
480(v.type="GET",v.global=!1)});a.jqx.data.ajaxTransport("script",function(v){if(v.crossDomain){var K,C=document.head||document.getElementsByTagName("head")[0]||document.documentElement;return{send:function(da,ja){K=document.createElement("script");K.async="async";v.scriptCharset&&(K.charset=v.scriptCharset);K.src=v.url;K.onload=K.onreadystatechange=function(ea,ra){if(ra||!K.readyState||/loaded|complete/.test(K.readyState))K.onload=K.onreadystatechange=null,C&&K.parentNode&&C.removeChild(K),K=void 0,
481ra||ja(200,"success")};C.insertBefore(K,C.firstChild)},abort:function(){if(K)K.onload(0,1)}}}});var z,V=window.ActiveXObject?function(){for(var v in z)z[v](0,1)}:!1,ba=0;a.jqx.data.ajaxSettings.xhr=window.ActiveXObject?function(){var v;if(!(v=!this.isLocal&&e()))a:{try{v=new window.ActiveXObject("Microsoft.XMLHTTP");break a}catch(K){}v=void 0}return v}:e;(function(v){a.extend(a.support,{ajax:!!v,cors:!!v&&"withCredentials"in v})})(a.jqx.data.ajaxSettings.xhr());a.support||(a.support={ajax:!0});a.support.ajax&&
482a.jqx.data.ajaxTransport(function(v){if(!v.crossDomain||a.support.cors){var K;
482return{send:function(C,da){var ja,ea=v.xhr();v.username?ea.open(v.type,v.url,v.async,v.username,v.password):ea.open(v.type,v.url,v.async);if(v.xhrFields)for(ja in v.xhrFields)ea[ja]=v.xhrFields[ja];v.mimeType&&ea.overrideMimeType&&ea.overrideMimeType(v.mimeType);v.crossDomain||C["X-Requested-With"]||(C["X-Requested-With"]="XMLHttpRequest");try{for(ja in C)ea.setRequestHeader(ja,C[ja])}catch(za){}ea.send(v.hasContent&&v.data||
483null);K=function(za,na){var qa;try{if(K&&(na||4===ea.readyState))if(K=void 0,ra&&(ea.onreadystatechange=function(){},V&&delete z[ra]),na)4!==ea.readyState&&ea.abort();else{var Ba=ea.status;var Ua=ea.getAllResponseHeaders();var Ja={};(qa=ea.responseXML)&&qa.documentElement&&(Ja.xml=qa);try{Ja.text=ea.responseText}catch(Ca){}try{var Pa=ea.statusText}catch(Ca){Pa=""}Ba||!v.isLocal||v.crossDomain?1223===Ba&&(Ba=204):Ba=Ja.text?200:404}}catch(Ca){na||da(-1,Ca)}Ja&&da(Ba,Pa,Ja,Ua)};if(v.async)if(4===ea.readyState)setTimeout(K,
4840);else{var ra=++ba;V&&(z||(z={},a(window).unload(V)),z[ra]=K);ea.onreadystatechange=K}else K()},abort:function(){K&&K(0,1)}}}});a.jqx.filter=function(){this.operator="and";var v="EMPTY NOT_EMPTY CONTAINS CONTAINS_CASE_SENSITIVE DOES_NOT_CONTAIN DOES_NOT_CONTAIN_CASE_SENSITIVE STARTS_WITH STARTS_WITH_CASE_SENSITIVE ENDS_WITH ENDS_WITH_CASE_SENSITIVE EQUAL EQUAL_CASE_SENSITIVE NULL NOT_NULL".split(" "),K="EQUAL NOT_EQUAL LESS_THAN LESS_THAN_OR_EQUAL GREATER_THAN GREATER_THAN_OR_EQUAL NULL NOT_NULL".split(" "),
485C="EQUAL NOT_EQUAL LESS_THAN LESS_THAN_OR_EQUAL GREATER_THAN GREATER_THAN_OR_EQUAL NULL NOT_NULL".split(" "),da=["EQUAL","NOT_EQUAL"],ja=[],ea=[];this.evaluate=function(Ja){for(var Pa=!0,Ca=0;Ca<ja.length;Ca++){var xa=ja[Ca].evaluate(Ja);Pa=0==Ca?xa:1==ea[Ca]||"or"==ea[Ca]?Pa||xa:Pa&&xa}return Pa};this.getfilterscount=function(){return ja.length};this.setoperatorsbyfiltertype=function(Ja,Pa){switch(Ja){case "numericfilter":K=Pa;break;case "stringfilter":v=Pa;break;case "datefilter":C=Pa;break;case "booleanfilter":da=
486Pa}};this.getoperatorsbyfiltertype=function(Ja){var Pa=[];switch(Ja){case "numericfilter":Pa=K.slice(0);break;case "stringfilter":Pa=v.slice(0);break;case "datefilter":Pa=C.slice(0);break;case "booleanfilter":Pa=da.slice(0)}return Pa};var ra=function(){var Ja=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return Ja()+"-"+Ja()+"-"+Ja()};this.createfilter=function(Ja,Pa,Ca,xa,Fa,Na){if(null==Ja||void 0==Ja)return null;switch(Ja){case "numericfilter":return new qa(Pa,Ca.toUpperCase());
487case "stringfilter":return new za(Pa,Ca.toUpperCase());case "datefilter":return new Ba(Pa,Ca.toUpperCase(),Fa,Na);case "booleanfilter":return new na(Pa,Ca.toUpperCase());case "custom":return new Ua(Pa,Ca.toUpperCase(),xa)}throw Error("jqxGrid: There is no such filter type. The available filter types are: 'numericfilter', 'stringfilter', 'datefilter' and 'booleanfilter'");};this.getfilters=function(){for(var Ja=[],Pa=0;Pa<ja.length;Pa++){var Ca={value:ja[Pa].filtervalue,condition:ja[Pa].comparisonoperator,
488operator:ea[Pa],type:ja[Pa].type};ja[Pa].data&&(Ca.id=ja[Pa].data);Ja[Pa]=Ca}return Ja};this.addfilter=function(Ja,Pa){ja[ja.length]=Pa;Pa.key=ra();ea[ea.length]=Ja};this.removefilter=function(Ja){for(var Pa=0;Pa<ja.length;Pa++)if(ja[Pa].key==Ja.key){ja.splice(Pa,1);ea.splice(Pa,1);break}};this.getoperatorat=function(Ja){return void 0==Ja||null==Ja||0>Ja||Ja>ja.length?null:ea[Ja]};this.setoperatorat=function(Ja,Pa){if(void 0==Ja||null==Ja||0>Ja||Ja>ja.length)return null;ea[Pa]=Pa};this.getfilterat=
489function(Ja){return void 0==Ja||null==Ja||0>Ja||Ja>ja.length?null:ja[Ja]};this.setfilterat=function(Ja,Pa){if(void 0==Ja||null==Ja||0>Ja||Ja>ja.length)return null;Pa.key=ra();ja[Ja]=Pa};this.clear=function(){ja=[];ea=[]};var za=function(Ja,Pa){this.filtervalue=Ja;this.comparisonoperator=Pa;this.type="stringfilter";this.evaluate=function(Ca){var xa=this.filtervalue,Fa=this.comparisonoperator;if(null==Ca||void 0==Ca||""==Ca){if("NULL"==Fa)return!0;if("NOT_NULL"==Fa)return!1;if("EQUAL"==Fa&&Ca==xa||
490"NOT_EQUAL"==Fa&&Ca!=xa)return!0;if("EMPTY"!=Fa)return!1;if(""==Ca)return!0}var Na="";try{Na=Ca.toString()}catch(la){return!0}var I=function(la,ta){switch(Fa){case "EQUAL":return a.jqx.string.equalsIgnoreCase(la,ta);case "EQUAL_CASE_SENSITIVE":return a.jqx.string.equals(la,ta);case "NOT_EQUAL":return!a.jqx.string.equalsIgnoreCase(la,ta);case "NOT_EQUAL_CASE_SENSITIVE":return!a.jqx.string.equals(la,ta);case "CONTAINS":return a.jqx.string.containsIgnoreCase(la,ta);case "CONTAINS_CASE_SENSITIVE":return a.jqx.string.contains(la,
491ta);case "DOES_NOT_CONTAIN":return!a.jqx.string.containsIgnoreCase(la,ta);case "DOES_NOT_CONTAIN_CASE_SENSITIVE":return!a.jqx.string.contains(la,ta);case "EMPTY":return""==la;case "NOT_EMPTY":return""!=la;case "NOT_NULL":return null!=la;case "STARTS_WITH":return a.jqx.string.startsWithIgnoreCase(la,ta);case "ENDS_WITH":return a.jqx.string.endsWithIgnoreCase(la,ta);case "ENDS_WITH_CASE_SENSITIVE":return a.jqx.string.endsWith(la,ta);case "STARTS_WITH_CASE_SENSITIVE":return a.jqx.string.startsWith(la,
492ta);default:return!1}},Ta=[];if(xa&&xa.indexO&&"NOT_EQUAL"!==Fa&&(0<=xa.indexOf("|")||0<=xa.indexOf(" AND ")||0<=xa.indexOf(" OR ")||0<=xa.indexOf(" and ")||0<=xa.indexOf(" or "))){if(Ca=I(Na,xa))return Ca;var Sa=0<=xa.indexOf(" AND ")?xa.split(" AND "):[];Ca=0<=xa.indexOf(" OR ")?xa.split(" OR "):[];var db=0<=xa.indexOf(" and ")?xa.split(" and "):[],ab=0<=xa.indexOf(" or ")?xa.split(" or "):[],Oa=0<=xa.indexOf("|")?xa.split("|"):[];if(0<Oa.length)for(var Ga=0;Ga<Oa.length;Ga++)Oa[Ga]=a.trim(Oa[Ga]);
493xa=0<=xa.indexOf(" ")?xa.split(" "):[];if(0<xa.length)for(Ga=0;Ga<xa.length;Ga++)xa[Ga]=a.trim(xa[Ga]);Sa=Sa.concat(xa);Sa=Sa.concat(db);Ca=Ca.concat(Oa);Ca=Ca.concat(ab);if(0<Sa.length)for(Ga=0;Ga<Sa.length;Ga++)0<=!Sa[Ga].indexOf(" OR ")&&Ta.push(Sa[Ga]);if(0<Ca.length)for(Ga=0;Ga<Ca.length;Ga++)0<=!Ca[Ga].indexOf(" AND ")&&Ta.push(Ca[Ga]);xa=void 0;for(db=0;db<Ta.length;db++)Ca=Ta[db],Ca=I(Na,Ca),ab=db<Sa.length?"and":"or",xa=void 0==xa?Ca:"or"==ab?xa||Ca:xa&&Ca;return xa}return I(Na,xa)}},na=
494function(Ja,Pa){this.filtervalue=Ja;this.comparisonoperator=Pa;this.type="booleanfilter";this.evaluate=function(Ca){var xa=this.filtervalue,Fa=this.comparisonoperator;if(null==Ca||void 0==Ca)return"NULL"==Fa?!0:!1;switch(Fa){case "EQUAL":return Ca==xa||Ca.toString()==xa.toString();case "NOT_EQUAL":return Ca!=xa&&Ca.toString()!=xa.toString();default:return!1}}},qa=function(Ja,Pa){this.filtervalue=Ja;this.comparisonoperator=Pa;this.type="numericfilter";this.evaluate=function(Ca){var xa=this.filtervalue,
495Fa=this.comparisonoperator;
495if(null===Ca||void 0===Ca||""===Ca){if("NOT_NULL"==Fa)return!1;if("NULL"==Fa)return!0;switch(Fa){case "EQUAL":return Ca==xa;case "NOT_EQUAL":return Ca!=xa}return!1}if("NULL"==Fa)return!1;if("NOT_NULL"==Fa)return!0;var Na=Ca;try{Na=parseFloat(Na)}catch(Ga){if(""!=Ca.toString())return!1}var I=function(Ga,la){switch(Fa){case "EQUAL":return Ga==la;case "NOT_EQUAL":return Ga!=la;case "GREATER_THAN":return Ga>la;case "GREATER_THAN_OR_EQUAL":return Ga>=la;case "LESS_THAN":return Ga<
496la;case "LESS_THAN_OR_EQUAL":return Ga<=la;case "STARTS_WITH":return a.jqx.string.startsWithIgnoreCase(Ga.toString(),la.toString());case "ENDS_WITH":return a.jqx.string.endsWithIgnoreCase(Ga.toString(),la.toString());case "ENDS_WITH_CASE_SENSITIVE":return a.jqx.string.endsWith(Ga.toString(),la.toString());case "STARTS_WITH_CASE_SENSITIVE":return a.jqx.string.startsWith(Ga.toString(),la.toString());case "CONTAINS":return a.jqx.string.containsIgnoreCase(Ga.toString(),la.toString());case "CONTAINS_CASE_SENSITIVE":return a.jqx.string.contains(Ga.toString(),
497la.toString());case "DOES_NOT_CONTAIN":return!a.jqx.string.containsIgnoreCase(Ga.toString(),la.toString());case "DOES_NOT_CONTAIN_CASE_SENSITIVE":return!a.jqx.string.contains(Ga.toString(),la.toString());default:return!0}},Ta=[];xa&&xa.indexOf&&(xa=xa.replace("$",""));if(xa&&xa.indexOf&&(0<=xa.indexOf("|")||0<=xa.indexOf(" AND ")||0<=xa.indexOf(" OR ")||0<=xa.indexOf(" and ")||0<=xa.indexOf(" or "))){var Sa=I(Na,xa);if(Sa)return Sa;xa=xa.toString();var db=0<=xa.indexOf(" AND ")?xa.split(" AND "):
498[],ab=0<=xa.indexOf(" OR ")?xa.split(" OR "):[];Ca=0<=xa.indexOf(" and ")?xa.split(" and "):[];var Oa=0<=xa.indexOf(" or ")?xa.split(" or "):[];db=db.concat(Ca);ab=ab.concat(Oa);xa=0<=xa.indexOf("|")?xa.split("|"):[];if(0<xa.length)for(Ca=0;Ca<xa.length;Ca++)xa[Ca]=a.trim(xa[Ca]);ab=ab.concat(xa);if(0<db.length)for(Ca=0;Ca<db.length;Ca++)0<=!db[Ca].indexOf(" OR ")&&Ta.push(db[Ca]);if(0<ab.length)for(Ca=0;Ca<ab.length;Ca++)0<=!ab[Ca].indexOf(" AND ")&&Ta.push(ab[Ca]);ab=void 0;for(xa=0;xa<Ta.length;xa++)(Ca=
499Ta[xa])&&Ca.indexOf&&0<=Ca.indexOf("..")?(Ca=Ca.toString().split(".."),2==Ca.length&&(Sa=Na>=Ca[0]&&Na<=Ca[1])):Sa=I(Na,Ca),Ca=xa<db.length?"and":"or",ab=void 0==ab?Sa:"or"==Ca?ab||Sa:ab&&Sa;return ab}return xa&&xa.indexOf&&0<=xa.indexOf("..")&&(Ta=xa.toString().split(".."),2==Ta.length)?Na>=Ta[0]&&Na<=Ta[1]:I(Na,xa)}},Ba=function(Ja,Pa,Ca,xa){this.filtervalue=Ja;this.type="datefilter";var Fa=this;if(void 0!=Ca&&void 0!=xa){var Na=a.jqx.dataFormat.parsedate(Ja,Ca,xa);null!=Na?this.filterdate=Na:(Na=
500a.jqx.dataFormat.tryparsedate(Ja,xa),null!=Na&&(this.filterdate=Na))}else Na=new Date(Ja),this.filterdate="NaN"==Na.toString()||"Invalid Date"==Na.toString()?a.jqx.dataFormat.tryparsedate(Ja):Na;this.filterdate||(Na=new Date(Ja),this.filterdate="NaN"==Na.toString()||"Invalid Date"==Na.toString()?a.jqx.dataFormat.tryparsedate(Ja):Na);this.comparisonoperator=Pa;this.evaluate=function(I){var Ta=this.filtervalue,Sa=this.comparisonoperator;if(null==I||void 0==I||""==I){if("NOT_NULL"==Sa)return!1;if("NULL"==
501Sa)return!0;switch(Sa){case "EQUAL":return I==Ta;case "NOT_EQUAL":return I!=Ta}return!1}if("NULL"==Sa)return!1;if("NOT_NULL"==Sa)return!0;var db=new Date;db.setFullYear(1900,0,1);db.setHours(12,0,0,0);try{var ab=new Date(I);db=I="NaN"==ab.toString()||"Invalid Date"==ab.toString()?a.jqx.dataFormat.tryparsedate(I):ab;var Oa=!1;if(void 0!=Ca&&void 0!=xa&&(0<=Ca.indexOf("t")||0<=Ca.indexOf("T")||0<=Ca.indexOf(":")||0<=Ca.indexOf("f"))&&(Oa=!0,Ta&&-1==Ta.toString().indexOf(":"))){var Ga=a.jqx.dataFormat.tryparsedate(Ta.toString()+
502":00",xa);null!=Ga&&(Fa.filterdate=Ga)}void 0!=Ca&&(0<=Ca.indexOf("hh")||0<=Ca.indexOf("t"))&&(Oa=!0);Oa||(db.setHours(0),db.setMinutes(0),db.setSeconds(0))}catch(p){if(""!=I.toString())return!1}if(null!=Fa.filterdate)Ta=Fa.filterdate;else if(Ta&&Ta.indexOf&&(-1!=Ta.indexOf(":")||!isNaN(parseInt(Ta)))){Ga=new Date(db);Ga.setHours(12,0,0,0);ab=Ta.split(":");for(Ta=0;Ta<ab.length;Ta++)0==Ta&&Ga.setHours(ab[Ta]),1==Ta&&Ga.setMinutes(ab[Ta]),2==Ta&&Ga.setSeconds(ab[Ta]);Ta=Ga}Oa&&Ta&&Ta.setFullYear&&
503db&&db.getFullYear&&-1==Ca.indexOf("d")&&-1==Ca.indexOf("M")&&-1==Ca.indexOf("y")&&Ta.setFullYear(db.getFullYear(),db.getMonth(),db.getDate());Oa=function(p,E){null==p&&(p="");switch(Sa){case "EQUAL":return p.toString()==E.toString();case "NOT_EQUAL":return p.toString()!=E.toString();case "GREATER_THAN":return p>E;case "GREATER_THAN_OR_EQUAL":return p>=E;case "LESS_THAN":return p<E;case "LESS_THAN_OR_EQUAL":return p<=E;case "STARTS_WITH":return a.jqx.string.startsWithIgnoreCase(p.toString(),E.toString());
504case "ENDS_WITH":return a.jqx.string.endsWithIgnoreCase(p.toString(),E.toString());case "ENDS_WITH_CASE_SENSITIVE":return a.jqx.string.endsWith(p.toString(),E.toString());case "STARTS_WITH_CASE_SENSITIVE":return a.jqx.string.startsWith(p.toString(),E.toString());case "CONTAINS":return a.jqx.string.containsIgnoreCase(p.toString(),E.toString());case "CONTAINS_CASE_SENSITIVE":return a.jqx.string.contains(p.toString(),E.toString());case "DOES_NOT_CONTAIN":return!a.jqx.string.containsIgnoreCase(p.toString(),
505E.toString());case "DOES_NOT_CONTAIN_CASE_SENSITIVE":return!a.jqx.string.contains(p.toString(),E.toString());default:return!0}};ab=[];
505if(Ta&&Ta.indexOf&&(0<=Ta.indexOf("|")||0<=Ta.indexOf(" AND ")||0<=Ta.indexOf(" OR ")||0<=Ta.indexOf(" and ")||0<=Ta.indexOf(" or "))){if(Ga=Oa(db,Ta))return Ga;var la=0<=Ta.indexOf(" AND ")?Ta.split(" AND "):[];I=0<=Ta.indexOf(" OR ")?Ta.split(" OR "):[];var ta=0<=Ta.indexOf(" and ")?Ta.split(" and "):[],va=0<=Ta.indexOf(" or ")?Ta.split(" or "):[];la=la.concat(ta);
506I=I.concat(va);ta=0<=Ta.indexOf("|")?Ta.split("|"):[];if(0<ta.length)for(Ta=0;Ta<ta.length;Ta++)ta[Ta]=a.trim(ta[Ta]);I=I.concat(ta);if(0<la.length)for(Ta=0;Ta<la.length;Ta++)0<=!la[Ta].indexOf(" OR ")&&ab.push(la[Ta]);if(0<I.length)for(Ta=0;Ta<I.length;Ta++)0<=!I[Ta].indexOf(" AND ")&&ab.push(I[Ta]);Ta=void 0;for(ta=0;ta<ab.length;ta++)(I=ab[ta])&&I.indexOf&&0<=I.indexOf("..")?(I=I.toString().split(".."),2==I.length&&(Ga=db>=I[0]&&db<=I[1])):Ga=Oa(db,I),I=ta<la.length?"and":"or",Ta=void 0==Ta?Ga:
507"or"==I?Ta||Ga:Ta&&Ga;return Ta}return Ta&&Ta.indexOf&&0<=Ta.indexOf("..")&&(ab=Ta.toString().split(".."),2==ab.length)?db>=ab[0]&&db<=ab[1]:Oa(db,Ta)}},Ua=function(Ja,Pa,Ca){this.filtervalue=Ja;this.comparisonoperator=Pa;this.evaluate=function(xa,Fa){return Ca(this.filtervalue,xa,this.comparisonoperator)}}}})(jqxBaseFramework);
508(function(a){a.jqx.cssroundedcorners=function(b){var c={all:"jqx-rc-all",top:"jqx-rc-t",bottom:"jqx-rc-b",left:"jqx-rc-l",right:"jqx-rc-r","top-right":"jqx-rc-tr","top-left":"jqx-rc-tl","bottom-right":"jqx-rc-br","bottom-left":"jqx-rc-bl"},d;for(d in c)if(c.hasOwnProperty(d)&&b==d)return c[d]};a.jqx.jqxWidget("jqxButton","",{});a.extend(a.jqx._jqxButton.prototype,{defineInstance:function(){var b={type:"",cursor:"arrow",roundedCorners:"all",disabled:!1,height:null,width:null,overrideTheme:!1,enableHover:!0,
509enableDefault:!0,enablePressed:!0,imgPosition:"center",imgSrc:"",imgWidth:16,imgHeight:16,value:null,textPosition:"",textImageRelation:"overlay",rtl:!1,_ariaDisabled:!1,_scrollAreaButton:!1,template:"default",aria:{"aria-disabled":{name:"disabled",type:"boolean"}}};if(this===a.jqx._jqxButton.prototype)return b;a.extend(!0,this,b);return b},_addImage:function(b){if("input"==this.element.nodeName.toLowerCase()||"button"==this.element.nodeName.toLowerCase()||"div"==this.element.nodeName.toLowerCase()){if(this._img)this._img.setAttribute("src",
510this.imgSrc),this._img.setAttribute("width",this.imgWidth),this._img.setAttribute("height",this.imgHeight),this._text.innerHTML=this.value;else{this.field=this.element;this.field.className&&(this._className=this.field.className);var c=this.field.title,d=null;this.field.getAttribute("value")?d=this.field.getAttribute("value"):"input"!=this.element.nodeName.toLowerCase()&&(d=this.element.innerHTML);this.value&&(d=this.value);b=this.field.id.length?this.field.id.replace(/[^\w]/g,"_")+"_"+b:a.jqx.utilities.createId()+
511"_"+b;var e=document.createElement("div");e.id=b;e.title=c;e.style.cssText=this.field.style.cssText;e.style.boxSizing="border-box";c=document.createElement("img");c.setAttribute("src",this.imgSrc);c.setAttribute("width",this.imgWidth);c.setAttribute("height",this.imgHeight);e.appendChild(c);this._img=c;c=document.createElement("span");d&&(this.value=c.innerHTML=d);e.appendChild(c);this._text=c;this.field.style.display="none";this.field.parentNode&&this.field.parentNode.insertBefore(e,this.field.nextSibling);
512d=this.host.data();this.host=a(e);this.host.data(d);this.element=e;this.element.id=this.field.id;this.field.id=b;b=new a(this.element);d=new a(this.field);this._className&&(b.addClass(this._className),d.removeClass(this._className));this.field.tabIndex&&(b=this.field.tabIndex,this.field.tabIndex=-1,this.element.tabIndex=b)}this._img.style.display=this.imgSrc?"inline":"none";this._text.style.display=this.value?"inline":"none";this._positionTextAndImage()}},_positionTextAndImage:function(){var b=this.element.offsetWidth,
513c=this.element.offsetHeight,d=this.imgWidth,e=this.imgHeight;""==this.imgSrc&&(e=d=0);var f=this._text.offsetWidth,g=this._text.offsetHeight,h=0,k=0;switch(this.textImageRelation){case "imageBeforeText":case "textBeforeImage":h=d+f+8+4+8;k=Math.max(e,g)+8+4+8;break;case "imageAboveText":case "textAboveImage":h=Math.max(d,f)+8;k=e+g+4+8+8;break;case "overlay":h=Math.max(d,f)+8,k=Math.max(e,g)+8}this.width||(this.element.style.width=h+"px",b=h);this.height||(this.element.style.height=k+"px",c=k);this._img.style.position=
514"absolute";this._text.style.position="absolute";this.element.style.position="relative";this.element.style.overflow="hidden";h={};k={};var l=function(A,aa,ha,z,V){aa.width<z&&(aa.width=z);aa.height<V&&(aa.height=V);
514switch(ha){case "left":A.style.left=aa.left+"px";A.style.top=aa.top+aa.height/2-V/2+"px";break;case "topLeft":A.style.left=aa.left+"px";A.style.top=aa.top+"px";break;case "bottomLeft":A.style.left=aa.left+"px";A.style.top=aa.top+aa.height-V+"px";break;default:case "center":A.style.left=
515aa.left+aa.width/2-z/2+"px";A.style.top=aa.top+aa.height/2-V/2+"px";break;case "top":A.style.left=aa.left+aa.width/2-z/2+"px";A.style.top=aa.top+"px";break;case "bottom":A.style.left=aa.left+aa.width/2-z/2+"px";A.style.top=aa.top+aa.height-V+"px";break;case "right":A.style.left=aa.left+aa.width-z+"px";A.style.top=aa.top+aa.height/2-V/2+"px";break;case "topRight":A.style.left=aa.left+aa.width-z+"px";A.style.top=aa.top+"px";break;case "bottomRight":A.style.left=aa.left+aa.width-z+"px",A.style.top=aa.top+
516aa.height-V+"px"}},m=0,n=0,r=(b-m)/2,t=(c-n)/2,u=this._img,x=this._text,B=c-n,y=b-m;m+=4;n+=4;b=b-4-2;y=y-8-2;B=B-8-2;switch(this.textImageRelation){case "imageBeforeText":switch(this.imgPosition){case "left":case "topLeft":case "bottomLeft":k={left:m,top:n,width:m+d,height:B};h={left:m+d+4,top:n,width:y-d-4,height:B};break;case "center":case "top":case "bottom":k={left:r-f/2-d/2-2,top:n,width:d,height:B};h={left:k.left+d+4,top:n,width:b-k.left-d-4,height:B};break;case "right":case "topRight":case "bottomRight":k=
517{left:b-f-d-4,top:n,width:d,height:B},h={left:k.left+d+4,top:n,width:b-k.left-d-4,height:B}}l(u,k,this.imgPosition,d,e);l(x,h,this.textPosition,f,g);break;case "textBeforeImage":switch(this.textPosition){case "left":case "topLeft":case "bottomLeft":h={left:m,top:n,width:m+f,height:B};k={left:m+f+4,top:n,width:y-f-4,height:B};break;case "center":case "top":case "bottom":h={left:r-f/2-d/2-2,top:n,width:f,height:B};k={left:h.left+f+4,top:n,width:b-h.left-f-4,height:B};break;case "right":case "topRight":case "bottomRight":h=
518{left:b-f-d-4,top:n,width:f,height:B},k={left:h.left+f+4,top:n,width:b-h.left-f-4,height:B}}l(u,k,this.imgPosition,d,e);l(x,h,this.textPosition,f,g);break;case "imageAboveText":switch(this.imgPosition){case "topRight":case "top":case "topLeft":k={left:m,top:n,width:y,height:e};h={left:m,top:n+e+4,width:y,height:B-e-4};break;case "left":case "center":case "right":k={left:m,top:t-e/2-g/2-2,width:y,height:e};h={left:m,top:k.top+4+e,width:y,height:B-k.top-4-e};break;case "bottomLeft":case "bottom":case "bottomRight":k=
519{left:m,top:c-e-g-4,width:y,height:e},h={left:m,top:k.top+4+e,width:y,height:g}}l(u,k,this.imgPosition,d,e);l(x,h,this.textPosition,f,g);break;case "textAboveImage":switch(this.textPosition){case "topRight":case "top":case "topLeft":h={left:m,top:n,width:y,height:g};k={left:m,top:n+g+4,width:y,height:B-g-4};break;case "left":case "center":case "right":h={left:m,top:t-e/2-g/2-2,width:y,height:g};k={left:m,top:h.top+4+g,width:y,height:B-h.top-4-g};break;case "bottomLeft":case "bottom":case "bottomRight":h=
520{left:m,top:c-e-g-4,width:y,height:g},k={left:m,top:h.top+4+g,width:y,height:e}}l(u,k,this.imgPosition,d,e);l(x,h,this.textPosition,f,g);break;default:h={left:m,top:n,width:y,height:B},k={left:m,top:n,width:y,height:B},l(u,k,this.imgPosition,d,e),l(x,h,this.textPosition,f,g)}},createInstance:function(b){var c=this;c._setSize();c.isMaterialized();c.buttonObj=new a(c.element);if(""!=c.imgSrc||""!=c.textPosition||c.element.value&&0<=c.element.value.indexOf("<")||null!=c.value)c.refresh(),c._addImage("jqxButton"),
521c.buttonObj=new a(c.element);c._ariaDisabled||c.element.setAttribute("role","button");""!==c.type&&c.element.setAttribute("type",c.type);c.overrideTheme||(c.buttonObj.addClass(c.toThemeProperty(a.jqx.cssroundedcorners(c.roundedCorners))),c.enableDefault&&c.buttonObj.addClass(c.toThemeProperty("jqx-button")),c.buttonObj.addClass(c.toThemeProperty("jqx-widget")));c.isTouchDevice=a.jqx.mobile.isTouchDevice();c._ariaDisabled||a.jqx.aria(this);"arrow"!=c.cursor&&(c.element.style.cursor=c.disabled?"arrow":
522c.cursor);b="mouseenter mouseleave mousedown focus blur";c._scrollAreaButton&&(b="mousedown");c.isTouchDevice&&(c.addHandler(c.host,a.jqx.mobile.getTouchEventName("touchstart"),function(d){c.isPressed=!0;c.refresh()}),c.addHandler(a(document),a.jqx.mobile.getTouchEventName("touchend")+"."+c.element.i
522d,function(d){c.isPressed=!1;c.refresh()}));c.addHandler(c.host,b,function(d){switch(d.type){case "mouseenter":c.isTouchDevice||c.disabled||!c.enableHover||(c.isMouseOver=!0,c.refresh());break;case "mouseleave":c.isTouchDevice||
523c.disabled||!c.enableHover||(c.isMouseOver=!1,c.refresh());break;case "mousedown":c.disabled||(c.isPressed=!0,c.refresh());break;case "focus":c.disabled||(c.isFocused=!0,c.refresh());break;case "blur":c.disabled||(c.isFocused=!1,c.refresh())}});c.mouseupfunc=function(d){c.disabled||!c.isPressed&&!c.isMouseOver||(c.isPressed=!1,c.refresh())};c.addHandler(document,"mouseup.button"+c.element.id,c.mouseupfunc);try{""==document.referrer&&!window.frameElement||null==window.top||window.top==window.that||
524(b="",window.parent&&document.referrer&&(b=document.referrer),-1!=b.indexOf(document.location.host)&&window.top.document&&window.top.document.addEventListener("mouseup",c._topDocumentMouseupHandler))}catch(d){}c.propertyChangeMap.roundedCorners=function(d,e,f,g){d.buttonObj.removeClass(d.toThemeProperty(a.jqx.cssroundedcorners(f)));d.buttonObj.addClass(d.toThemeProperty(a.jqx.cssroundedcorners(g)))};c.propertyChangeMap.disabled=function(d,e,f,g){f!=g&&(d.refresh(),d.element.setAttribute("disabled",
525g),d.element.disabled=g,d.element.style.cursor=g?"default":d.cursor,a.jqx.aria(d,"aria-disabled",d.disabled))};c.propertyChangeMap.rtl=function(d,e,f,g){f!=g&&d.refresh()};c.propertyChangeMap.template=function(d,e,f,g){f!=g&&(d.buttonObj.removeClass(d.toThemeProperty("jqx-"+f)),d.refresh())};c.propertyChangeMap.theme=function(d,e,f,g){d.buttonObj.removeClass(d.element);f&&(d.buttonObj.removeClass("jqx-button-"+f),d.buttonObj.removeClass("jqx-widget-"+f),d.buttonObj.removeClass("jqx-fill-state-normal-"+
526f),d.buttonObj.removeClass(d.toThemeProperty(a.jqx.cssroundedcorners(d.roundedCorners))+"-"+f));d.enableDefault&&d.buttonObj.addClass(d.toThemeProperty("jqx-button"));d.buttonObj.addClass(d.toThemeProperty("jqx-widget"));d.overrideTheme||d.buttonObj.addClass(d.toThemeProperty(a.jqx.cssroundedcorners(d.roundedCorners)));d._oldCSSCurrent=null;d.refresh()};c.disabled&&(c.element.disabled=!0,c.element.setAttribute("disabled","true"))},resize:function(b,c){this.width=b;this.height=c;this._setSize()},val:function(b){var c=
527this.host.find("input");if(0<c.length){if(0==arguments.length||"object"==typeof b)return c.val();c.val(b);this.refresh();return c.val()}if(0==arguments.length||"object"==typeof b)return"button"==this.element.nodeName.toLowerCase()?a(this.element).text():this.element.value;0<arguments.length&&this._text?this._text.innerHTML=arguments[0]:(0<arguments.length&&"DIV"===this.element.nodeName&&(this.element.innerHTML=arguments[0],this.refresh()),this.element.value=arguments[0],"button"==this.element.nodeName.toLowerCase()&&
528a(this.element).html(arguments[0]));this.refresh()},_setSize:function(){var b=this.height,c=this.width;b&&(isNaN(b)||(b+="px"),this.element.style.height=b);c&&(isNaN(c)||(c+="px"),this.element.style.width=c)},_removeHandlers:function(){this.removeHandler(this.host,"selectstart");this.removeHandler(this.host,"click");this.removeHandler(this.host,"focus");this.removeHandler(this.host,"blur");this.removeHandler(this.host,"mouseenter");this.removeHandler(this.host,"mouseleave");this.removeHandler(this.host,
529"mousedown");this.removeHandler(a(document),"mouseup.button"+this.element.id,this.mouseupfunc);this.isTouchDevice&&(this.removeHandler(this.host,a.jqx.mobile.getTouchEventName("touchstart")),this.removeHandler(a(document),a.jqx.mobile.getTouchEventName("touchend")+"."+this.element.id));this.mouseupfunc=null;delete this.mouseupfunc},focus:function(){this.host.focus()},destroy:function(){this._removeHandlers();var b=a.data(this.element,"jqxButton");b&&delete b.instance;this.host.removeClass();this.host.removeData();
530this.host.remove();delete this.set;delete this.get;delete this.call;delete this.element;delete this.host},render:function(){this.refresh()},propertiesChangedHandler:function(b,c,d){d&&d.width&&d.height&&2==Object.keys(d).length&&(b._setSize(),b.refresh())}
530,propertyChangedHandler:function(b,c,d,e){if(void 0!=this.isInitialized&&0!=this.isInitialized&&e!=d&&!(b.batchUpdate&&b.batchUpdate.width&&b.batchUpdate.height&&2==Object.keys(b.batchUpdate).length)){"type"===c&&b.element.setAttribute("type",e);
531if("textImageRelation"==c||"textPosition"==c||"imgPosition"==c)b._img?b._positionTextAndImage():b._addImage("jqxButton");"imgSrc"!=c&&"imgWidth"!=c&&"imgHeight"!=c||b._addImage("jqxButton");"value"===c&&b.val(e);if("width"==c||"height"==c)b._setSize(),b.refresh()}},refresh:function(){if(!this.overrideTheme){var b=this.toThemeProperty("jqx-fill-state-focus"),c=this.toThemeProperty("jqx-fill-state-disabled"),d=this.toThemeProperty("jqx-fill-state-normal");this.enableDefault||(d="");var e=this.toThemeProperty("jqx-fill-state-hover"),
532f=this.toThemeProperty("jqx-fill-state-pressed"),g=this.toThemeProperty("jqx-fill-state-pressed");this.enablePressed||(f="");this.host&&((this.element.disabled=this.disabled)?(this._oldCSSCurrent&&this.buttonObj.removeClass(this._oldCSSCurrent),c=d+" "+c,"default"!==this.template&&""!==this.template&&(c+=" jqx-"+this.template,""!=this.theme&&(c+=" jqx-"+this.template+"-"+this.theme)),this.buttonObj.addClass(c),this._oldCSSCurrent=c):(c=this.isMouseOver&&!this.isTouchDevice?this.isPressed?g:e:this.isPressed?
533f:d,this.isFocused&&(c+=" "+b),"default"!==this.template&&""!==this.template&&(c+=" jqx-"+this.template,""!=this.theme&&(c+=" jqx-"+this.template+"-"+this.theme)),c!=this._oldCSSCurrent&&(this._oldCSSCurrent&&this.buttonObj.removeClass(this._oldCSSCurrent),this.buttonObj.addClass(c),this._oldCSSCurrent=c),this.rtl&&(this.buttonObj.addClass(this.toThemeProperty("jqx-rtl")),this.element.style.direction="rtl"),this.isMaterialized()&&this.host.addClass("buttonRipple")))}}});a.jqx.jqxWidget("jqxLinkButton",
534"",{});a.extend(a.jqx._jqxLinkButton.prototype,{defineInstance:function(){this.disabled=!1;this.width=this.height=null;this.rtl=!1;this.href=null},createInstance:function(b){var c=this;this.host.onselectstart=function(){return!1};this.host.attr("role","button");var d=this.height||this.element.offsetHeight,e=this.width||this.element.offsetWidth;this.href=this.element.getAttribute("href");this.target=this.element.getAttribute("target");this.content=this.host.text();this.element.innerHTML="";var f=document.createElement("input");
535f.type="button";f.className="jqx-wrapper "+this.toThemeProperty("jqx-reset");this._setSize(f,e,d);f.value=this.content;(new a(this.element)).addClass(this.toThemeProperty("jqx-link"));this.element.style.color="inherit";this.element.appendChild(f);this._setSize(f,e,d);b=void 0==b?{}:b[0]||{};a(f).jqxButton(b);this.wrapElement=f;this.disabled&&(this.element.disabled=!0);this.propertyChangeMap.disabled=function(g,h,k,l){g.element.disabled=l;g.wrapElement.jqxButton({disabled:l})};this.addHandler(a(f),
536"click",function(g){if(!this.disabled)c.onclick(g);return!1})},_setSize:function(b,c,d){d&&(isNaN(d)||(d+="px"),b.style.height=d);c&&(isNaN(c)||(c+="px"),b.style.width=c)},onclick:function(b){null!=this.target?window.open(this.href,this.target):window.location=this.href}});a.jqx.jqxWidget("jqxRepeatButton","jqxButton",{});a.extend(a.jqx._jqxRepeatButton.prototype,{defineInstance:function(){this.delay=50},createInstance:function(b){var c=this,d=a.jqx.mobile.isTouchDevice();b=d?"touchend."+this.base.element.id:
537"mouseup."+this.base.element.id;var e=d?"touchstart."+this.base.element.id:"mousedown."+this.base.element.id;this.addHandler(a(document),b,function(f){null!=c.timeout&&(clearTimeout(c.timeout),c.timeout=null,c.refresh());void 0!=c.timer&&(clearInterval(c.timer),c.timer=null,c.refresh())});this.addHandler(this.base.host,e,function(f){null!=c.timer&&clearInterval(c.timer);c.timeout=setTimeout(function(){clearInterval(c.timer);c.timer=setInterval(function(g){c.ontimer(g)},c.delay)},150)});this.mousemovefunc=
538function(f){d||0!=f.which||null==c.timer||(clearInterval(c.timer),c.timer=null)};this.addHandler(this.base.host,"mousemove",this.mousemovefunc)},destroy:function(){var b=a.jqx.mobile.isTouchDevice(),c=b?"touchend."+this.base.element.i
538d:"mouseup."+this.base.element.id;b=b?"touchstart."+this.base.element.id:"mousedown."+this.base.element.id;this.removeHandler(this.base.host,"mousemove",this.mousemovefunc);this.removeHandler(this.base.host,b);this.removeHandler(a(document),c);this.timer=null;delete this.mousemovefunc;
539delete this.timer;(c=a.data(this.base.element,"jqxRepeatButton"))&&delete c.instance;a(this.base.element).removeData();this.base.destroy();delete this.base},stop:function(){clearInterval(this.timer);this.timer=null},ontimer:function(b){b=new a.Event("click");null!=this.base&&null!=this.base.host&&this.base.host.trigger(b)}});a.jqx.jqxWidget("jqxToggleButton","jqxButton",{});a.extend(a.jqx._jqxToggleButton.prototype,{defineInstance:function(){this.toggled=!1;this.uiToggle=!0;this.aria={"aria-checked":{name:"toggled",
540type:"boolean"},"aria-disabled":{name:"disabled",type:"boolean"}}},createInstance:function(b){var c=this;c.base.overrideTheme=!0;c.isTouchDevice=a.jqx.mobile.isTouchDevice();a.jqx.aria(this);c.propertyChangeMap.roundedCorners=function(d,e,f,g){d.base.buttonObj.removeClass(d.toThemeProperty(a.jqx.cssroundedcorners(f)));d.base.buttonObj.addClass(d.toThemeProperty(a.jqx.cssroundedcorners(g)))};c.propertyChangeMap.toggled=function(d,e,f,g){d.refresh()};c.propertyChangeMap.disabled=function(d,e,f,g){d.base.disabled=
541g;d.refresh()};c.addHandler(c.base.host,"click",function(d){!c.base.disabled&&c.uiToggle&&c.toggle()});c.isTouchDevice||(c.addHandler(c.base.host,"mouseenter",function(d){c.base.disabled||c.refresh()}),c.addHandler(c.base.host,"mouseleave",function(d){c.base.disabled||c.refresh()}));c.addHandler(c.base.host,"mousedown",function(d){c.base.disabled||c.refresh()});c.addHandler(a(document),"mouseup.togglebutton"+c.base.element.id,function(d){c.base.disabled||c.refresh()})},destroy:function(){this._removeHandlers();
542this.base.destroy()},_removeHandlers:function(){this.removeHandler(this.base.host,"click");this.removeHandler(this.base.host,"mouseenter");this.removeHandler(this.base.host,"mouseleave");this.removeHandler(this.base.host,"mousedown");this.removeHandler(a(document),"mouseup.togglebutton"+this.base.element.id)},toggle:function(){this.toggled=!this.toggled;this.refresh();a.jqx.aria(this,"aria-checked",this.toggled)},unCheck:function(){this.toggled=!1;this.refresh()},check:function(){this.toggled=!0;
543this.refresh()},refresh:function(){var b=this.base.toThemeProperty("jqx-fill-state-disabled"),c=this.base.toThemeProperty("jqx-fill-state-normal");this.base.enableDefault||(c="");var d=this.base.toThemeProperty("jqx-fill-state-hover"),e=this.base.toThemeProperty("jqx-fill-state-pressed"),f=this.base.toThemeProperty("jqx-fill-state-pressed");if(this.base.element.disabled=this.base.disabled)this.base.buttonObj.addClass(c+" "+b);else{var g=this.base.isMouseOver&&!this.isTouchDevice?this.base.isPressed||
544this.toggled?f:d:this.base.isPressed||this.toggled?e:c;"default"!==this.base.template&&""!==this.base.template&&(g+=" jqx-"+this.base.template,""!=this.base.theme&&(g+=" jqx-"+this.template+"-"+this.base.theme));this.base.buttonObj.hasClass(b)&&b!=g&&this.base.buttonObj.removeClass(b);this.base.buttonObj.hasClass(c)&&c!=g&&this.base.buttonObj.removeClass(c);this.base.buttonObj.hasClass(d)&&d!=g&&this.base.buttonObj.removeClass(d);this.base.buttonObj.hasClass(e)&&e!=g&&this.base.buttonObj.removeClass(e);
545this.base.buttonObj.hasClass(f)&&f!=g&&this.base.buttonObj.removeClass(f);this.base.buttonObj.hasClass(g)||this.base.buttonObj.addClass(g)}},_topDocumentMouseupHandler:function(b){this.isPressed=!1;this.refresh()}})})(jqxBaseFramework);
546(function(a){a.jqx.jqxWidget("jqxScrollBar","",{});a.extend(a.jqx._jqxScrollBar.prototype,{defineInstance:function(){var b={height:null,width:null,vertical:!1,min:0,max:1E3,value:0,step:10,largestep:50,thumbMinSize:10,thumbSize:0,thumbStep:"auto",roundedCorners:"all",showButtons:!0,disabled:!1,touchMode:"auto",touchModeStyle:"auto",thumbTouchSize:0,_triggervaluechanged:!0,rtl:!1,areaDownCapture:!1,areaUpCapture:!1,_initialLayout:!1,offset:0,reference:0,velocity:0,frame:0,timestamp:0,ticker:null,amplitude:0,
547target:0};if(this===a.jqx._jqxScrollBar.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(b){this.render()},render:function(){this._mouseup=new Date;var b=this;a.jqx.utilities&&"hidden"==a.jqx.utilities.scrollBarButtonsVisibility&&(this.showButtons=!1);b.WinJS?MSApp.execUnsafeLocalFunction(function(){b.host.html("<div id='jqxScrollOuterWrap' style='box-sizing: content-box; width:100%; height: 100%; align:left; border: 0px; valign:top; position: relative;'><div id='jqxScrollWrap' style='box-sizing: content-box; width:100%; height: 100%; left: 0px; top: 0px; align:left; valign:top; position: absolute;'><div id='jqxScrollBtnUp' style='box-sizing: content-box; align:left; valign:top; left: 0px; top: 0px; position: absolute;'><div></div></div><div id='jqxScrollAreaUp' style='box-sizing: content-box; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div><div id='jqxScrollThumb' style='box-sizing: content-box; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div><div id='jqxScrollAreaDown' style='box-sizing: content-box; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div><div id='jqxScrollBtnDown' style='box-sizing: content-box; align:left; valign:top; left: 0px; top: 0px; position: absolute;'><div></div></div></div></div>")}):
548this.element.innerHTML="<div id='jqxScrollOuterWrap' style='box-sizing: content-box; width:100%; height: 100%; align:left; border: 0px; valign:top; position: relative;'><div id='jqxScrollWrap' style='box-sizing: content-box; width:100%; height: 100%; left: 0px; top: 0px; align:left; valign:top; position: absolute;'><div id='jqxScrollBtnUp' style='box-sizing: content-box; align:left; valign:top; left: 0px; top: 0px; position: absolute;'><div></div></div><div id='jqxScrollAreaUp' style='box-sizing: content-box; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div><div id='jqxScrollThumb' style='box-sizing: content-box; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div><div id='jqxScrollAreaDown' style='box-sizing: content-box; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div><div id='jqxScrollBtnDown' style='box-sizing: content-box; align:left; valign:top; left: 0px; top: 0px; position: absolute;'><div></div></div></div></div>";
549void 0!=this.width&&0<parseInt(this.width)&&this.host.width(parseInt(this.width));void 0!=this.height&&0<parseInt(this.height)&&this.host.height(parseInt(this.height));this.isPercentage=!1;null!=this.width&&-1!=this.width.toString().indexOf("%")&&(this.host.width(this.width),this.isPercentage=!0);null!=this.height&&-1!=this.height.toString().indexOf("%")&&(this.host.height(this.height),this.isPercentage=!0);if(this.isPercentage){var c=this;a.jqx.utilities.resize(this.host,function(){c._arrange()},
550!1)}this.thumbCapture=!1;this.scrollOuterWrap=a(this.element.firstChild);this.scrollWrap=a(this.scrollOuterWrap[0].firstChild);this.btnUp=a(this.scrollWrap[0].firstChild);this.areaUp=a(this.btnUp[0].nextSibling);this.btnThumb=a(this.areaUp[0].nextSibling);this.arrowUp=a(this.btnUp[0].firstChild);this.areaDown=a(this.btnThumb[0].nextSibling);this.btnDown=a(this.areaDown[0].nextSibling);this.arrowDown=a(this.btnDown[0].firstChild);
550var d=this.element.id;this.btnUp[0].id="jqxScrollBtnUp"+d;this.btnDown[0].id=
551"jqxScrollBtnDown"+d;this.btnThumb[0].id="jqxScrollThumb"+d;this.areaUp[0].id="jqxScrollAreaUp"+d;this.areaDown[0].id="jqxScrollAreaDown"+d;this.scrollWrap[0].id="jqxScrollWrap"+d;this.scrollOuterWrap[0].id="jqxScrollOuterWrap"+d;if(!this.host.jqxRepeatButton)throw Error("jqxScrollBar: Missing reference to jqxbuttons.js.");this.btnUp.jqxRepeatButton({_ariaDisabled:!0,overrideTheme:!0,disabled:this.disabled});this.btnDown.jqxRepeatButton({_ariaDisabled:!0,overrideTheme:!0,disabled:this.disabled});
552this.btnDownInstance=a.data(this.btnDown[0],"jqxRepeatButton").instance;this.btnUpInstance=a.data(this.btnUp[0],"jqxRepeatButton").instance;this.areaUp.jqxRepeatButton({_scrollAreaButton:!0,_ariaDisabled:!0,overrideTheme:!0});this.areaDown.jqxRepeatButton({_scrollAreaButton:!0,_ariaDisabled:!0,overrideTheme:!0});this.btnThumb.jqxButton({_ariaDisabled:!0,overrideTheme:!0,disabled:this.disabled});this.propertyChangeMap.value=function(e,f,g,h){isNaN(h)||g!=h&&e.setPosition(parseFloat(h),!0)};this.propertyChangeMap.width=
553function(e,f,g,h){void 0!=e.width&&0<parseInt(e.width)&&(e.host.width(parseInt(e.width)),e._arrange())};this.propertyChangeMap.height=function(e,f,g,h){void 0!=e.height&&0<parseInt(e.height)&&(e.host.height(parseInt(e.height)),e._arrange())};this.propertyChangeMap.theme=function(e,f,g,h){e.setTheme()};this.propertyChangeMap.max=function(e,f,g,h){isNaN(h)||g==h||(e.max=parseInt(h),e.min>e.max&&(e.max=e.min+1),e._arrange(),e.setPosition(e.value))};this.propertyChangeMap.min=function(e,f,g,h){isNaN(h)||
554g==h||(e.min=parseInt(h),e.min>e.max&&(e.max=e.min+1),e._arrange(),e.setPosition(e.value))};this.propertyChangeMap.disabled=function(e,f,g,h){g!=h&&(h?e.host.addClass(e.toThemeProperty("jqx-fill-state-disabled")):e.host.removeClass(e.toThemeProperty("jqx-fill-state-disabled")),e.btnUp.jqxRepeatButton("disabled",e.disabled),e.btnDown.jqxRepeatButton("disabled",e.disabled),e.btnThumb.jqxButton("disabled",e.disabled))};this.propertyChangeMap.touchMode=function(e,f,g,h){g!=h&&(e._updateTouchBehavior(),
555!0===h?(e.showButtons=!1,e.refresh()):!1===h&&(e.showButtons=!0,e.refresh()))};this.propertyChangeMap.rtl=function(e,f,g,h){g!=h&&e.refresh()};this.buttonDownCapture=this.buttonUpCapture=!1;this._updateTouchBehavior();this.setPosition(this.value);this._addHandlers();this.setTheme()},resize:function(b,c){this.width=b;this.height=c;this._arrange()},_updateTouchBehavior:function(){this.isTouchDevice=a.jqx.mobile.isTouchDevice();1==this.touchMode?(a.jqx.browser.msie&&9>a.jqx.browser.version||(this.isTouchDevice=
556!0,a.jqx.mobile.setMobileSimulator(this.btnThumb[0]),this._removeHandlers(),this._addHandlers()),this.setTheme()):0==this.touchMode&&(this.isTouchDevice=!1)},_addHandlers:function(){var b=this,c=!1;try{if("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)this._touchSupport=c=!0}catch(e){}if(b.isTouchDevice||c)this.addHandler(this.btnThumb,a.jqx.mobile.getTouchEventName("touchend"),function(e){var f=b.vertical?b.toThemeProperty("jqx-scrollbar-thumb-state-pressed"):b.toThemeProperty("jqx-scrollbar-thumb-state-pressed-horizontal"),
557g=b.toThemeProperty("jqx-fill-state-pressed");b.btnThumb.removeClass(f);b.btnThumb.removeClass(g);b.disabled||b.handlemouseup(b,e);return!1}),this.addHandler(this.btnThumb,a.jqx.mobile.getTouchEventName("touchstart"),function(e){b.disabled||(1==b.touchMode?(e.clientX=e.originalEvent.clientX,e.clientY=e.originalEvent.clientY):e.originalEvent.touches&&e.originalEvent.touches.length?(e.clientX=e.originalEvent.touches[0].clientX,e.clientY=e.originalEvent.touches[0].clientY):(e.clientX=e.originalEvent.clientX,
558e.clientY=e.originalEvent.clientY),b.handlemousedown(e),e.preventDefault&&e.preventDefault())}),a.jqx.mobile.touchScroll(this.element,b.max,function(e,f,g,h,k){"visible"==b.host.css("visibility")&&(k&&(1==b.touchMode?(k.clientX=k.originalEvent.clientX,k.clientY=k.originalEvent.clientY):k.originalEvent.touches&&k.originalEvent.touches.length?(k.clientX=k.originalEvent.touches[0].clientX,k.clientY=k.originalEvent.touches[0].clientY):(k.clientX=k.originalEvent.clientX,k.clientY=k.originalEvent.clientY)),
559e=b.vertical?b.toThemeProperty("jqx-scrollbar-thumb-state-pressed"):b.toThemeProperty("jqx-scrollbar-thumb-state-pressed-horizontal"),b.btnThumb.addClass(e),b.btnThumb.addClass(b.toThemeProperty("jqx-fill-state-pressed")),b.thumbCapture=!0,b.handlemousemove(k))}
559,b.element.id,b.host,b.host);if(!this.isTouchDevice){try{""==document.referrer&&!window.frameElement||null==window.top||window.top==window.self||(c=null,window.parent&&document.referrer&&(c=document.referrer),c&&-1!=c.indexOf(document.location.host)&&
560(c=function(e){b.disabled||b.handlemouseup(b,e)},window.top.document.addEventListener?window.top.document.addEventListener("mouseup",c,!1):window.top.document.attachEvent&&window.top.document.attachEvent("onmouseup",c)))}catch(e){}this.addHandler(this.btnDown,"click mouseup mousedown",function(e){var f=b.step;Math.abs(b.max-b.min)<=f&&(f=1);b.rtl&&!b.vertical&&(f=-b.step);switch(e.type){case "click":b.buttonDownCapture&&!b.isTouchDevice?b.disabled||b.setPosition(b.value+f):!b.disabled&&b.isTouchDevice&&
561b.setPosition(b.value+f);break;case "mouseup":if(!b.btnDownInstance.base.disabled&&b.buttonDownCapture)return b.buttonDownCapture=!1,b.btnDown.removeClass(b.toThemeProperty("jqx-scrollbar-button-state-pressed")),b.btnDown.removeClass(b.toThemeProperty("jqx-fill-state-pressed")),b._removeArrowClasses("pressed","down"),b.handlemouseup(b,e),b.setPosition(b.value+f),!1;break;case "mousedown":if(!b.btnDownInstance.base.disabled)return b.buttonDownCapture=!0,b.btnDown.addClass(b.toThemeProperty("jqx-fill-state-pressed")),
562b.btnDown.addClass(b.toThemeProperty("jqx-scrollbar-button-state-pressed")),b._addArrowClasses("pressed","down"),!1}});this.addHandler(this.btnUp,"click mouseup mousedown",function(e){var f=b.step;Math.abs(b.max-b.min)<=f&&(f=1);b.rtl&&!b.vertical&&(f=-b.step);switch(e.type){case "click":b.buttonUpCapture&&!b.isTouchDevice?b.disabled||b.setPosition(b.value-f):!b.disabled&&b.isTouchDevice&&b.setPosition(b.value-f);break;case "mouseup":if(!b.btnUpInstance.base.disabled&&b.buttonUpCapture)return b.buttonUpCapture=
563!1,b.btnUp.removeClass(b.toThemeProperty("jqx-scrollbar-button-state-pressed")),b.btnUp.removeClass(b.toThemeProperty("jqx-fill-state-pressed")),b._removeArrowClasses("pressed","up"),b.handlemouseup(b,e),b.setPosition(b.value-f),!1;break;case "mousedown":if(!b.btnUpInstance.base.disabled)return b.buttonUpCapture=!0,b.btnUp.addClass(b.toThemeProperty("jqx-fill-state-pressed")),b.btnUp.addClass(b.toThemeProperty("jqx-scrollbar-button-state-pressed")),b._addArrowClasses("pressed","up"),!1}})}c="click";
564this.isTouchDevice&&(c=a.jqx.mobile.getTouchEventName("touchend"));this.addHandler(this.areaUp,c,function(e){if(!b.disabled)return e=b.largestep,b.rtl&&!b.vertical&&(e=-b.largestep),b.setPosition(b.value-e),!1});this.addHandler(this.areaDown,c,function(e){if(!b.disabled)return e=b.largestep,b.rtl&&!b.vertical&&(e=-b.largestep),b.setPosition(b.value+e),!1});this.addHandler(this.areaUp,"mousedown",function(e){if(!b.disabled)return b.areaUpCapture=!0,!1});this.addHandler(this.areaDown,"mousedown",function(e){if(!b.disabled)return b.areaDownCapture=
565!0,!1});this.addHandler(this.btnThumb,"mousedown dragstart",function(e){if("dragstart"===e.type)return!1;b.disabled||b.handlemousedown(e);e.preventDefault&&e.preventDefault()});this.addHandler(a(document),"mouseup."+this.element.id,function(e){b.disabled||b.handlemouseup(b,e)});if(!this.isTouchDevice&&(this.mousemoveFunc=function(e){b.disabled||b.handlemousemove(e)},this.addHandler(a(document),"mousemove."+this.element.id,this.mousemoveFunc),this.addHandler(a(document),"mouseleave."+this.element.id,
566function(e){b.disabled||b.handlemouseleave(e)}),this.addHandler(a(document),"mouseenter."+this.element.id,function(e){b.disabled||b.handlemouseenter(e)}),!b.disabled)){this.addHandler(this.btnUp,"mouseenter mouseleave",function(e){"mouseenter"===e.type?b.disabled||b.btnUpInstance.base.disabled||1==b.touchMode||(b.btnUp.addClass(b.toThemeProperty("jqx-scrollbar-button-state-hover")),b.btnUp.addClass(b.toThemeProperty("jqx-fill-state-hover")),b._addArrowClasses("hover","up")):b.disabled||b.btnUpInstance.base.disabled||
5671==b.touchMode||(b.btnUp.removeClass(b.toThemeProperty("jqx-scrollbar-button-state-hover")),b.btnUp.removeClass(b.toThemeProperty("jqx-fill-state-hover")),b._removeArrowClasses("hover","up"))});var d=b.toThemeProperty("jqx-scrollbar-thumb-state-hover");b.vertical||(d=b.toThemeProperty("jqx-scrollbar-thumb-state-hover-horizontal"));this.addHandler(this.btnThumb,"mouseenter mouseleave",function(e){"mouseenter"
567===e.type?b.disabled||1==b.touchMode||(b.btnThumb.addClass(d),b.btnThumb.addClass(b.toThemeProperty("jqx-fill-state-hover"))):
568b.disabled||1==b.touchMode||(b.btnThumb.removeClass(d),b.btnThumb.removeClass(b.toThemeProperty("jqx-fill-state-hover")))});this.addHandler(this.btnDown,"mouseenter mouseleave",function(e){"mouseenter"===e.type?b.disabled||b.btnDownInstance.base.disabled||1==b.touchMode||(b.btnDown.addClass(b.toThemeProperty("jqx-scrollbar-button-state-hover")),b.btnDown.addClass(b.toThemeProperty("jqx-fill-state-hover")),b._addArrowClasses("hover","down")):b.disabled||b.btnDownInstance.base.disabled||1==b.touchMode||
569(b.btnDown.removeClass(b.toThemeProperty("jqx-scrollbar-button-state-hover")),b.btnDown.removeClass(b.toThemeProperty("jqx-fill-state-hover")),b._removeArrowClasses("hover","down"))})}},destroy:function(){var b=this.btnUp,c=this.btnDown,d=this.btnThumb,e=this.areaUp,f=this.areaDown;this.arrowUp.remove();delete this.arrowUp;this.arrowDown.remove();delete this.arrowDown;f.removeClass();e.removeClass();c.removeClass();b.removeClass();d.removeClass();b.jqxRepeatButton("destroy");c.jqxRepeatButton("destroy");
570e.jqxRepeatButton("destroy");f.jqxRepeatButton("destroy");d.jqxButton("destroy");b=a.data(this.element,"jqxScrollBar");this._removeHandlers();this.scrollOuterWrap=this.areaDown=this.areaUp=this.scrollWrap=this.btnDown=this.btnUp=null;delete this.mousemoveFunc;delete this.btnDownInstance;delete this.btnUpInstance;delete this.scrollOuterWrap;delete this.scrollWrap;delete this.btnDown;delete this.areaDown;delete this.areaUp;delete this.btnDown;delete this.btnUp;delete this.btnThumb;delete this.propertyChangeMap.value;
571delete this.propertyChangeMap.min;delete this.propertyChangeMap.max;delete this.propertyChangeMap.touchMode;delete this.propertyChangeMap.disabled;delete this.propertyChangeMap.theme;delete this.propertyChangeMap;b&&delete b.instance;this.host.removeData();this.host.remove();delete this.host;delete this.set;delete this.get;delete this.call;delete this.element},_removeHandlers:function(){this.removeHandler(this.btnUp,"mouseenter");this.removeHandler(this.btnDown,"mouseenter");this.removeHandler(this.btnThumb,
572"mouseenter");this.removeHandler(this.btnUp,"mouseleave");this.removeHandler(this.btnDown,"mouseleave");this.removeHandler(this.btnThumb,"mouseleave");this.removeHandler(this.btnUp,"click");this.removeHandler(this.btnDown,"click");this.removeHandler(this.btnDown,"mouseup");this.removeHandler(this.btnUp,"mouseup");this.removeHandler(this.btnDown,"mousedown");this.removeHandler(this.btnUp,"mousedown");this.removeHandler(this.areaUp,"mousedown");this.removeHandler(this.areaDown,"mousedown");this.removeHandler(this.areaUp,
573"click");this.removeHandler(this.areaDown,"click");this.removeHandler(this.btnThumb,"mousedown");this.removeHandler(this.btnThumb,"dragstart");this.removeHandler(a(document),"mouseup."+this.element.id);this.mousemoveFunc?this.removeHandler(a(document),"mousemove."+this.element.id,this.mousemoveFunc):this.removeHandler(a(document),"mousemove."+this.element.id);this.removeHandler(a(document),"mouseleave."+this.element.id);this.removeHandler(a(document),"mouseenter."+this.element.id)},_addArrowClasses:function(b,
574c){"pressed"==b&&(b="selected");""!=b&&(b="-"+b);this.vertical?("up"!=c&&void 0!=c||this.arrowUp.addClass(this.toThemeProperty("jqx-icon-arrow-up"+b)),"down"!=c&&void 0!=c||this.arrowDown.addClass(this.toThemeProperty("jqx-icon-arrow-down"+b))):("up"!=c&&void 0!=c||this.arrowUp.addClass(this.toThemeProperty("jqx-icon-arrow-left"+b)),"down"!=c&&void 0!=c||this.arrowDown.addClass(this.toThemeProperty("jqx-icon-arrow-right"+b)))},_removeArrowClasses:function(b,c){"pressed"==b&&(b="selected");""!=b&&
575(b="-"+b);this.vertical?("up"!=c&&void 0!=c||this.arrowUp.removeClass(this.toThemeProperty("jqx-icon-arrow-up"+b)),"down"!=c&&void 0!=c||this.arrowDown.removeClass(this.toThemeProperty("jqx-icon-arrow-down"+b))):("up"!=c&&void 0!=c||this.arrowUp.removeClass(this.toThemeProperty("jqx-icon-arrow-left"+b)),"down"!=c&&void 0!=c||this.arrowDown.removeClass(this.toThemeProperty("jqx-icon-arrow-right"+b)))},setTheme:function(){var b=this.btnUp,c=this.btnDown,d=this.btnThumb,e=this.scrollWrap,f=this.arrowUp,
576g=this.arrowDown;this.scrollWrap[0].className=this.toThemeProperty("jqx-reset");this.scrollOuterWrap[0].className=this.toThemeProperty("jqx-reset");var h=this.toThemeProperty("jqx-reset");this.areaDown[0].className=h;this.areaUp[0].className=h;var k=this.toThemeProperty("jqx-scrollbar")+" "+this.toThemeProperty("jqx-widget")+" "+this.toThemeProperty("jqx-widget-content");this.host.addClass(k);this.isTouchDevice&&this.host.addClass(this.toThemeProperty("jqx-scrollbar-mobile"));c[0].className=this.toThemeProperty("jqx-scrollbar-button-state-normal");
577b[0].className=this.toThemeProperty("jqx-scrollbar-button-state-normal");this.vertical?(f[0].className=h+" "+this.toThemeProperty("jqx-icon-arrow-up"),g[0].className=h+" "+this.toThemeProperty("jqx-icon-arrow-down"),f=this.toThemeProperty("jqx-scrollbar-thumb-state-normal")):(f[0].className=h+" "+this.toThemeProperty("jqx-icon-arrow-left"),g[0].className=h+" "+this.toThemeProperty("jqx-icon-arrow-right"),f=this.toThemeProperty("jqx-scrollbar-thumb-state-normal-horizontal"));f+=" "+this.toThemeProperty("jqx-fill-state-normal");
578d[0].className=f;this.disabled?(e.addClass(this.toThemeProperty("jqx-fill-state-disabled")),e.removeClass(this.toThemeProperty("jqx-scrollbar-state-normal"))):(e.addClass(this.toThemeProperty("jqx-scrollbar-state-normal")),e.removeClass(this.toThemeProperty("jqx-fill-state-disabled")));"all"==this.roundedCorners?(this.host.addClass(this.toThemeProperty("jqx-rc-all")),this.vertical?(e=a.jqx.cssroundedcorners("top"),e=this.toThemeProperty(e),b.addClass(e),e=a.jqx.cssroundedcorners("bottom"),e=this.toThemeProperty(e),
579c.addClass(e)):(e=a.jqx.cssroundedcorners("left"),e=this.toThemeProperty(e),b.addClass(e),e=a.jqx.cssroundedcorners("right"),e=this.toThemeProperty(e),c.addClass(e))):(e=a.jqx.cssroundedcorners(this.roundedCorners),e=this.toThemeProperty(e),b.addClass(e),c.addClass(e));e=a.jqx.cssroundedcorners(this.roundedCorners);e=this.toThemeProperty(e);d.hasClass(e)||d.addClass(e);"none"===b.css("display")&&(this.showButtons=!1,this.touchModeStyle=!0,d.addClass(this.toThemeProperty("jqx-scrollbar-thumb-state-normal-touch")));
580this.isTouchDevice&&0!=this.touchModeStyle&&(this.showButtons=!1,d.addClass(this.toThemeProperty("jqx-scrollbar-thumb-state-normal-touch")))},isScrolling:function(){return void 0==this.thumbCapture||void 0==this.buttonDownCapture||void 0==this.buttonUpCapture||void 0==this.areaDownCapture||void 0==this.areaUpCapture?!1:this.thumbCapture||this.buttonDownCapture||this.buttonUpCapture||this.areaDownCapture||this.areaUpCapture},track:function(){var b=Date.now();var c=b-this.timestamp;this.timestamp=b;
581b=this.offset-this.frame;this.frame=this.offset;this.velocity=1E3*b/(1+c)*.2+.2*this.velocity},handlemousedown:function(b){function c(f){e.reference=parseInt(e.btnThumb[0].style.top);e.offset=parseInt(e.btnThumb[0].style.top);e.vertical||(e.reference=parseInt(e.btnThumb[0].style.left),e.offset=parseInt(e.btnThumb[0].style.left));e.velocity=e.amplitude=0;e.frame=e.offset;e.timestamp=Date.now();clearInterval(e.ticker);e.ticker=setInterval(function(){e.track()},100)}if(void 0==this.thumbCapture||0==
582this.thumbCapture){this.thumbCapture=!0;var d=this.btnThumb;null!=d&&(d.addClass(this.toThemeProperty("jqx-fill-state-pressed")),this.vertical?d.addClass(this.toThemeProperty("jqx-scrollbar-thumb-state-pressed")):d.addClass(this.toThemeProperty("jqx-scrollbar-thumb-state-pressed-horizontal")))}var e=this;this.thumbCapture&&a.jqx.scrollAnimation&&c(b);this.dragStartX=b.clientX;this.dragStartY=b.clientY;this.dragStartValue=this.value},toggleHover:function(b,c){},refresh:function(){this._arrange()},
583_setElementPosition:function(b,c,d){isNaN(c)||parseInt(b[0].style.left)==parseInt(c)||(b[0].style.left=c+"px");isNaN(d)||parseInt(b[0].style.top)==parseInt(d)||(b[0].style.top=d+"px")},_setElementTopPosition:function(b,c){isNaN(c)||(b[0].style.top=c+"px")},_setElementLeftPosition:function(b,c){isNaN(c)||(b[0].style.left=c+"px")},handlemouseleave:function(b){b=this.btnUp;var c=this.btnDown;if(this.buttonDownCapture||this.buttonUpCapture)b.removeClass(this.toThemeProperty("jqx-scrollbar-button-state-pressed")),
584c.removeClass(this.toThemeProperty("jqx-scrollbar-button-state-pressed")),this._removeArrowClasse
584s("pressed");1==this.thumbCapture&&(b=this.btnThumb,c=this.vertical?this.toThemeProperty("jqx-scrollbar-thumb-state-pressed"):this.toThemeProperty("jqx-scrollbar-thumb-state-pressed-horizontal"),b.removeClass(c),b.removeClass(this.toThemeProperty("jqx-fill-state-pressed")))},handlemouseenter:function(b){b=this.btnUp;var c=this.btnDown;this.buttonUpCapture&&(b.addClass(this.toThemeProperty("jqx-scrollbar-button-state-pressed")),
585b.addClass(this.toThemeProperty("jqx-fill-state-pressed")),this._addArrowClasses("pressed","up"));this.buttonDownCapture&&(c.addClass(this.toThemeProperty("jqx-scrollbar-button-state-pressed")),c.addClass(this.toThemeProperty("jqx-fill-state-pressed")),this._addArrowClasses("pressed","down"));1==this.thumbCapture&&(b=this.btnThumb,this.vertical?b.addClass(this.toThemeProperty("jqx-scrollbar-thumb-state-pressed")):b.addClass(this.toThemeProperty("jqx-scrollbar-thumb-state-pressed-horizontal")),b.addClass(this.toThemeProperty("jqx-fill-state-pressed")))},
586handlemousemove:function(b){var c=this.btnUp,d=this.btnDown;if(null!=d&&null!=c){null!=c&&null!=d&&void 0!=this.buttonDownCapture&&void 0!=this.buttonUpCapture&&(this.buttonDownCapture&&0==b.which?(d.removeClass(this.toThemeProperty("jqx-scrollbar-button-state-pressed")),d.removeClass(this.toThemeProperty("jqx-fill-state-pressed")),this._removeArrowClasses("pressed","down"),this.buttonDownCapture=!1):this.buttonUpCapture&&0==b.which&&(c.removeClass(this.toThemeProperty("jqx-scrollbar-button-state-pressed")),
587c.removeClass(this.toThemeProperty("jqx-fill-state-pressed")),this._removeArrowClasses("pressed","up"),this.buttonUpCapture=!1));if(1!=this.thumbCapture)return!1;var e=this.btnThumb;if(0==b.which&&!this.isTouchDevice&&!this._touchSupport)return this.thumbCapture=!1,this._arrange(),b=this.vertical?this.toThemeProperty("jqx-scrollbar-thumb-state-pressed"):this.toThemeProperty("jqx-scrollbar-thumb-state-pressed-horizontal"),e.removeClass(b),e.removeClass(this.toThemeProperty("jqx-fill-state-pressed")),
588!0;void 0!=b.preventDefault&&b.preventDefault();null!=b.originalEvent&&(b.originalEvent.mouseHandled=!0);void 0!=b.stopPropagation&&b.stopPropagation();var f=0;try{f=this.vertical?b.clientY-this.dragStartY:b.clientX-this.dragStartX;var g=this._btnAndThumbSize;this._btnAndThumbSize||(g=this.vertical?c.height()+d.height()+e.height():c.width()+d.width()+e.width());var h=(this.max-this.min)/(this.scrollBarSize-g);if("auto"==this.thumbStep)f*=h;else{f*=h;if(Math.abs(this.dragStartValue+f-this.value)>=
589parseInt(this.thumbStep)){var k=Math.round(parseInt(f)/this.thumbStep)*this.thumbStep;this.rtl&&!this.vertical?this.setPosition(this.dragStartValue-k):this.setPosition(this.dragStartValue+k)}return!1}k=f;this.rtl&&!this.vertical&&(k=-f);this.setPosition(this.dragStartValue+k);this.offset=parseInt(e[0].style.left);this.vertical&&(this.offset=parseInt(e[0].style.top))}catch(l){alert(l)}return!1}},handlemouseup:function(b,c){b=!1;if(this.thumbCapture){this.thumbCapture=!1;b=this.btnThumb;var d=this.vertical?
590this.toThemeProperty("jqx-scrollbar-thumb-state-pressed"):this.toThemeProperty("jqx-scrollbar-thumb-state-pressed-horizontal");b.removeClass(d);b.removeClass(this.toThemeProperty("jqx-fill-state-pressed"));b=!0;this._mouseup=new Date;if(a.jqx.scrollAnimation){var e=this;function f(){if(e.amplitude){var g=Date.now()-e.timestamp;g=-e.amplitude*Math.exp(-g/325);if(.5<g||-.5>g){var h=(e.max-e.min)/(e.scrollBarSize-e._btnAndThumbSize);h=g=h*(e.target+g);e.rtl&&!e.vertical&&(h=-g);e.setPosition(e.dragStartValue+
591h);requestAnimationFrame(f)}else h=(e.max-e.min)/(e.scrollBarSize-e._btnAndThumbSize),h=g=h*(e.target+g),e.rtl&&!e.vertical&&(h=-g),e.setPosition(e.dragStartValue+h)}}clearInterval(this.ticker);
591if(25<this.velocity||-25>this.velocity)this.amplitude=.8*this.velocity,this.target=Math.round(this.offset+this.amplitude),this.target-=this.reference,this.timestamp=Date.now(),requestAnimationFrame(f)}}this.areaDownCapture=this.areaUpCapture=!1;if(this.buttonUpCapture||this.buttonDownCapture)b=this.btnUp,d=
592this.btnDown,this.buttonDownCapture=this.buttonUpCapture=!1,b.removeClass(this.toThemeProperty("jqx-scrollbar-button-state-pressed")),d.removeClass(this.toThemeProperty("jqx-scrollbar-button-state-pressed")),b.removeClass(this.toThemeProperty("jqx-fill-state-pressed")),d.removeClass(this.toThemeProperty("jqx-fill-state-pressed")),this._removeArrowClasses("pressed"),b=!0,this._mouseup=new Date;b&&(void 0!=c.preventDefault&&c.preventDefault(),null!=c.originalEvent&&(c.originalEvent.mouseHandled=!0),
593void 0!=c.stopPropagation&&c.stopPropagation())},setPosition:function(b,c){if(void 0==b||NaN==b)b=this.min;b>=this.max&&(b=this.max);b<this.min&&(b=this.min);if(this.value!==b||1==c){b==this.max&&(c=new a.Event("complete"),this.host.trigger(c));c=this.value;if(this._triggervaluechanged){var d=new a.Event("valueChanged");d.previousValue=this.value;d.currentValue=b}this.value=b;this._positionelements();this._triggervaluechanged&&this.host.trigger(d);this.valueChanged&&this.valueChanged({currentValue:this.value,
594previousvalue:c})}return b},val:function(b){a:{for(c in b)if(b.hasOwnProperty(c)){var c=!1;break a}c="number"==typeof b||"date"==typeof b||"boolean"==typeof b||"string"==typeof b?!1:!0}if(c||0==arguments.length)return this.value;this.setPosition(b);return b},_getThumbSize:function(b){var c=this.max-this.min,d=0;1<c?d=b/(c+b)*b:1==c?d=b-1:0==c&&(d=b);0<this.thumbSize&&(d=this.thumbSize);d<this.thumbMinSize&&(d=this.thumbMinSize);return Math.min(d,b)},_positionelements:function(){var b=this.areaUp,
595c=this.areaDown,d=this.btnThumb,e=this._height?this._height:this.host.height(),f=this._width?this._width:this.host.width(),g=this.vertical?f:e;this.showButtons||(g=0);var h=this.vertical?e:f;this.scrollBarSize=h;e=this._getThumbSize(h-2*g);e=Math.floor(e);e<this.thumbMinSize&&(e=this.thumbMinSize);this.btnSize=g+=2;var k=this._btnAndThumbSize;this._btnAndThumbSize||(k=this.vertical?2*this.btnSize+d.outerHeight():2*this.btnSize+d.outerWidth(),k=Math.round(k));f=(h-k)/(this.max-this.min)*(this.value-
596this.min);this.rtl&&!this.vertical&&(f=(h-k)/(this.max-this.min)*(this.max-this.value-this.min));f=Math.round(f);0>f&&(f=0);this.vertical?(h=h-f-k,0>h&&(h=0),c[0].style.height=h+"px",b[0].style.height=f+"px",this._setElementTopPosition(b,g),this._setElementTopPosition(d,g+f),this._setElementTopPosition(c,g+f+e)):(b[0].style.width=f+"px",c[0].style.width=0<=h-f-k?h-f-k+"px":"0px",this._setElementLeftPosition(b,g),this._setElementLeftPosition(d,g+f),this._setElementLeftPosition(c,2+g+f+e))},_arrange:function(){if(this._initialLayout)this._initialLayout=
597!1;else{if(this.min>this.max){var b=this.min;this.min=this.max;this.max=b}0>this.min&&(b=this.max-this.min,this.min=0,this.max=b);b=this.areaUp;var c=this.areaDown,d=this.btnUp,e=this.btnDown,f=this.btnThumb,g=this.scrollWrap,h=parseInt(this.element.style.height),k=parseInt(this.element.style.width);this.isPercentage&&(h=this.host.height(),k=this.host.width());isNaN(h)&&(h=0);isNaN(k)&&(k=0);this._width=k;this._height=h;var l=this.vertical?k:h;this.showButtons||(l=0);d[0].style.width=l+"px";d[0].style.height=
598l+"px";e[0].style.width=l+"px";e[0].style.height=l+"px";this.vertical?g[0].style.width=k+2+"px":g[0].style.height=h+2+"px";this._setElementPosition(d,0,0);d=l+2;this.vertical?this._setElementPosition(e,0,h-d):this._setElementPosition(e,k-d,0);var m=this.vertical?h:k;this.scrollBarSize=m;e=this._getThumbSize(m-2*d);e=Math.floor(e-2);e<this.thumbMinSize&&(e=this.thumbMinSize);g=!1;this.isTouchDevice&&0!=this.touchModeStyle&&(g=!0);this.vertical?(f[0].style.width=k+"px",f[0].style.height=e+"px",g&&0!==
599this.thumbTouchSize&&(f.css({width:this.thumbTouchSize+"px"}),f.css("margin-left",(this.host.width()-this.thumbTouchSize)/2))):(f[0].style.width=e+"px",f[0].style.height=h+"px",g&&0!==this.thumbTouchSize&&(f.css({height:this.thumbTouchSize+"px"}),f.css("margin-top",(this.host.height()-this.thumbTouchSize)/2)));if(NaN==h||10>h)h=10;if(NaN==k||10>k)k=10;this.btnSize=l;g=this.vertical?2*d+(2+parseInt(f[0].style.height)):2*d+(2+parseInt(f[0].style.width));this._btnAndThumbSize=g=Math.round(g);var n=(m-
600g)/(this.max-this.min)*(this.value-this.min);this.rtl&&!this.vertical&&(n=(m-g)/(this.max-this.min)*(this.max-this.value-this.min));n=Math.round(n);if(isNaN(n)||0>n||-Infinity===n||Infinity===n)n=0;if(this.vertical){h=m-n-g;0>h&&(h=0);c[0].style.height=h+"px";c[0].style.width=k+"px";b[0].style.height=n+"px";b[0].style.width=k+"px";h=parseInt(this.element.style.height);this.isPercentage&&(h=this.host.height());f[0].style.visibility="inherit";if(0>h-3*parseInt(l)||h<g)f[0].style.visibility="hidden";
601this._setElementPosition(b,0,d);this._setElementPosition(f,0,d+n);this._setElementPosition(c,0,d+n+e)}else{0<n&&(b[0].style.width=n+"px");0<h&&(b[0].style.height=h+"px");k=m-n-g;0>k&&(k=0);c[0].style.width=k+"px";c[0].style.height=h+"px";h=parseInt(this.element.style.width);this.isPercentage&&(h=this.host.width());f[0].style.visibility="inherit";if(0>h-3*parseInt(l)||h<g)f[0].style.visibility="hidden";this._setElementPosition(b,d,0);this._setElementPosition(f,d+n,0);this._setElementPosition(c,d+n+
602e,0)}}}})})(jqxBaseFramework);
603(function(a){a.jqx.jqxWidget("jqxMenu","",{});a.extend(a.jqx._jqxMenu.prototype,{defineInstance:function(){var b={items:[],mode:"horizontal",width:null,height:null,minimizeWidth:"auto",easing:"easeInOutSine",animationShowDuration:200,animationHideDuration:200,autoCloseInterval:0,animationHideDelay:100,animationShowDelay:10,menuElements:[],autoSizeMainItems:!1,autoCloseOnClick:!0,autoCloseOnMouseLeave:!0,enableRoundedCorners:!0,disabled:!1,autoOpenPopup:!0,enableHover:!0,autoOpen:!0,autoGenerate:!0,
604clickToOpen:!1,showTopLevelArrows:!1,touchMode:"auto",source:null,popupZIndex:1E3,rtl:!1,keyboardNavigation:!1,lockFocus:!1,title:"",events:"shown closed itemclick initialized open close".split(" ")};if(this===a.jqx._jqxMenu.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(b){var c=this;this.host.attr("role","menubar");a.jqx.utilities.resize(this.host,function(){c.refresh()},!1,"popup"!=this.mode);"auto"!=this.minimizeWidth&&null!=this.minimizeWidth&&this.width&&-1==this.width.toString().indexOf("%")&&
605a(window).resize(function(){c.refresh()});c.isMaterialized()&&(b=window.getComputedStyle(this.element).getPropertyValue("--jqx-dropdown-animation"))&&(this.animationType=b.trim(),"transform"===this.animationType&&(this.animationShowDelay=this.animationHideDuration=this.animationShowDuration=0));this.host.css("outline","none");this.source&&null!=this.source&&(b=this.loadItems(this.source),this.element.innerHTML=b);this._tmpHTML=this.element.innerHTML;this.element.innerHTML.indexOf("UL")&&(b=this.host.find("ul:first"),
6060<b.length&&this._createMenu(b[0]));this.host.data("autoclose",{});this._render();this._setSize();a.jqx.browser.msie&&8>a.jqx.browser.version&&this.host.attr("hideFocus",!0)},focus:function(){try{if("popup"===this.mode&&this.keyboardNavigation&&this.host.closest("div.jqx-menu-wrapper").focus(),this.keyboardNavigation){this.host.focus();var b=this,c=function(){if(a.jqx.isHidden(a(b.items[0].element))){var d=b._nextVisibleItem(b.items[0],0);d&&(a(d.element).addClass(b.toThemeProperty("jqx-fill-state-focus")),
607b.activeItem=d)}else a(b.items[0].element).addClass(b.toThemeProperty("jqx-fill-state-focus")),b.activeItem=b.items[0]};this.activeItem?a.jqx.isHidden(a(this.activeItem.element))?(a(this.activeItem.element).removeClass(this.toThemeProperty("jqx-fill-state-focus")),c()):a(this.activeItem.element).addClass(this.toThemeProperty("jqx-fill-state-focus")):c()}}catch(d){}},loadItems:function(b,c){if(null!=b){if(0==b.length)return"";var d=this;this.items=[];var e='<ul class="jqx-menu-ul">';c&&(e='<ul class="jqx-menu-ul" style="width:'+
608c+';">');a.map(b,function(f){if(void 0==f)return null;e+=d._parseItem(f)});return e+="</ul>"}},_parseItem:function(b){if(void 0==b)return null;var c=b.label;!b.label&&b.html&&(c=b.html);c||="Item";"string"===typeof b&&(c=b);var d=!1;void 0!=b.disabled&&b.disabled&&(d=!0);var e="<li";d&&(e+=' item-disabled="true" ');b.label&&!b.html&&(e+=' item-label="'+c+'" ');null!=b.value&&(e+=' item-value="'+b.value+'" ');void 0!=b.id&&(e+=' id="'+b.id+'" ');e+=">"+c;b.items&&(e=b.subMenuWidth?e+this.loadItems(b.items,
609b.subMenuWidth):e+this.loadItems(b.items));return e+"</li>"},_setSize:function(){null!=this.width&&-1!=this.width.toString().indexOf("%")?this.host.width(this.width):null!=this.width&&-1!=this.width.toString().indexOf("px")?this.host.width(this.width):void 0==this.width||isNaN(this.width)||this.host.width(this.width);null!=this.height&&-1!=this.height.toString().indexOf("%")?this.host.height(this.height):null!=this.height&&-1!=this.height.toString().indexOf("px")?this.host.height(this.height):void 0==
610this.height||isNaN(this.height)||this.host.height(this.height);null===this.height&&this.host.height("auto");if(null!=this.minimizeWidth&&"popup"!=this.mode){var b=a(window).width();if(!a.jqx.response){var c=!1;navigator.userAgent.match(/Windows|Linux|MacOS/)&&(0<=navigator.userAgent.indexOf("Windows Phone")||0<=navigator.userAgent.indexOf("WPDesktop")||0<=navigator.userAgent.indexOf("IEMobile")||0<=navigator.userAgent.indexOf("ZuneWP7")||(c=!0));var d=this.minimizeWidth;if(c&&"auto"==this.minimizeWidth)return}if("auto"==
611this.minimizeWidth&&a.jqx.response){if(b=new a.jqx.response,"Phone"==b.device.type||"Tablet"==b.device.type)this.minimized||this.minimize()}else b<d&&!this.minimized?this.minimize():this.minimized&&b>=d&&this.restore()}},minimize:function(){if(!this.minimized){var b=this;this.host.addClass(this.toThemeProperty("jqx-menu-minimized"));this.minimized=!0;this._tmpMode=this.mode;this.mode="simple";var c=this.host.closest("div.jqx-menu-wrapper");c.remove();a("#menuWrapper"+this.element.id).remove();a.each(this.items,
612function(){a(this.element);a(this.subMenuElement).closest("div.jqx-menu-popup").remove()});if(this.source){var d=this.loadItems(this.source);this.element.innerHTML=d;this._tmpHTML=this.element.innerHTML}this.element.innerHTML=this._tmpHTML;this.element.innerHTML.indexOf("UL")&&(d=this.host.find("ul:first"),0<d.length&&this._createMenu(d[0]));this._render();d=this.host.find("ul:first");d.wrap('<div class="jqx-menu-wrapper" style="z-index:'+this.popupZIndex+'; padding: 0px; display: none; margin: 0px; height: auto; width: auto; position: absolute; top: 0; left: 0; display: block; visibility: visible;"></div>');
613c=d.closest("div.jqx-menu-wrapper");c[0].id="menuWrapper"+this.element.id;c.detach();c.appendTo(a(document.body));c.addClass(this.toThemeProperty("jqx-widget"));c.addClass(this.toThemeProperty("jqx-menu"));c.addClass(this.toThemeProperty("jqx-menu-minimized"));c.addClass(this.toThemeProperty("jqx-widget-header"));d.children().hide();c.hide();c.find("ul").addClass(this.toThemeProperty("jqx-menu-ul-minimized"));this.minimizedItem=a("<div></div>");this.minimizedItem.addClass(this.toThemeProperty("jqx-item"));
614this.minimizedItem.addClass(this.toThemeProperty("jqx-menu-item-top"));this.addHandler(c,"keydown",function(g){return b.handleKeyDown(g)});this.minimizedItem.addClass(this.toThemeProperty("jqx-menu-minimized-button"));this.minimizedItem.prependTo(this.host);this.titleElement=a("<div>"+this.title+"</div>");this.titleElement.addClass(this.toThemeProperty("jqx-item"));this.titleElement.addClass(this.toThemeProperty("jqx-menu-title"));this.titleElement.prependTo(this.host);a("<div style='clear:both;'></div>").insertAfter(this.minimizedItem);
615b.minimizedHidden=!0;var e=function(g){b.minimizedHidden=!0;b.minimizedItem.show();g=!1;"right"==b.minimizedItem.css("float")&&(g=!0);c.animate({left:g?b.host.coord().left+b.host.width()+c.width():-c.outerWidth(),opacity:0},b.animationHideDuration,function(){c.find("ul:first").children().hide();c.hide()})},f=function(g){if(b.minimizedHidden){c.find("ul:first").children().show();b.minimizedHidden=!1;c.show();c.css("opacity",0);c.css("left",-c.outerWidth());var h=!1,k=c.width();"right"==b.minimizedItem.css("float")&&
616(c.css("left",b.host.coord().left+b.host.width()+k),h=!0);c.css("top",b.host.coord().top+b.host.height());c.animate({left:h?b.host.coord().left+b.host.width()-k:b.host.coord().left,opacity:.95},b.animationShowDuration,function(){})}else e(g);b._raiseEvent("2",{type:"mouse",item:b.minimizedItem[0],event:g});b._setSize()};this.addHandler(a(window),"orientationchange.jqxmenu"+this.element.i
616d,function(g){setTimeout(function(){if(!b.minimizedHidden){c.width();var h=!1;var k=c.width();"right"==b.minimizedItem.css("float")&&
617(h=!0);c.css("top",b.host.coord().top+b.host.height());c.css({left:h?b.host.coord().left+b.host.width()-k:b.host.coord().left})}},25)});this.addHandler(this.minimizedItem,"click",function(g){f(g)})}},restore:function(){if(this.minimized){this.host.find("ul").removeClass(this.toThemeProperty("jqx-menu-ul-minimized"));this.host.removeClass(this.toThemeProperty("jqx-menu-minimized"));this.minimized=!1;this.mode=this._tmpMode;this.minimizedItem&&this.minimizedItem.remove();a("#menuWrapper"+this.element.id).remove();
618if(this.source){var b=this.loadItems(this.source);this._tmpHTML=this.element.innerHTML=b}this.element.innerHTML=this._tmpHTML;this.element.innerHTML.indexOf("UL")&&(b=this.host.find("ul:first"),0<b.length&&this._createMenu(b[0]));this._setSize();this._render()}},isTouchDevice:function(){if(void 0!=this._isTouchDevice)return this._isTouchDevice;var b=a.jqx.mobile.isTouchDevice();1==this.touchMode?b=!0:0==this.touchMode&&(b=!1);b&&(this.host.addClass(this.toThemeProperty("jqx-touch")),a(".jqx-menu-item").addClass(this.toThemeProperty("jqx-touch")));
619return this._isTouchDevice=b},refresh:function(b){b||this._setSize()},resize:function(b,c){this.width=b;this.height=c;this.refresh()},_closeAll:function(b){var c=null!=b?b.data:this;a.each(c.items,function(){1==this.hasItems&&this.isOpen&&c._closeItem(c,this)});"popup"==c.mode&&null!=b&&(c._isRightClick(b)||c.close())},closeItem:function(b){if(null==b)return!1;var c=document.getElementById(b),d=this;a.each(d.items,function(){1==this.isOpen&&this.element==c&&d._closeItem(d,this)});return!0},openItem:function(b){if(null==
620b)return!1;var c=document.getElementById(b),d=this;a.each(d.items,function(){0==this.isOpen&&this.element==c&&(d._openItem(d,this),this.parentId&&d.openItem(this.parentId))});return!0},_getClosedSubMenuOffset:function(b){var c=a(b.subMenuElement),d=-c.outerHeight(),e=-c.outerWidth(),f=0==b.level&&"horizontal"==this.mode;f?e=0:d=0;switch(b.openVerticalDirection){case "up":case "center":d=c.outerHeight()}switch(b.openHorizontalDirection){case this._getDir("left"):e=f?0:c.outerWidth();break;case "center":e=
621f?0:c.outerWidth()}return{left:e,top:d}},_closeItem:function(b,c,d,e){if(null==b||null==c)return!1;var f=a(c.subMenuElement),g=0==c.level&&"horizontal"==this.mode,h=this._getClosedSubMenuOffset(c),k=h.top,l=h.left;a(c.element);var m=f.closest("div.jqx-menu-popup");if(null!=m){m.removeClass("show");h=b.animationHideDelay;1==e&&(h=0);f.data("timer")&&null!=f.data("timer").show&&(clearTimeout(f.data("timer").show),f.data("timer").show=null);var n=function(){c.isOpen=!1;g?f.stop().animate({top:k},b.animationHideDuration,
622function(){a(c.element).removeClass(b.toThemeProperty("jqx-fill-state-pressed"));a(c.element).removeClass(b.toThemeProperty("jqx-menu-item-top-selected"));a(c.element).removeClass(b.toThemeProperty("jqx-rc-b-expanded"));m.removeClass(b.toThemeProperty("jqx-rc-t-expanded"));var r=a(c.arrow);0<r.length&&b.showTopLevelArrows&&(r.removeClass(),"down"==c.openVerticalDirection?(r.addClass(b.toThemeProperty("jqx-menu-item-arrow-down")),r.addClass(b.toThemeProperty("jqx-icon-arrow-down"))):(r.addClass(b.toThemeProperty("jqx-menu-item-arrow-up")),
623r.addClass(b.toThemeProperty("jqx-icon-arrow-up"))));a.jqx.aria(a(c.element),"aria-expanded",!1);m.css({display:"none"});0==b.animationHideDuration&&f.css({top:k});b._raiseEvent("1",c)}):f.stop().animate({left:l},b.animationHideDuration,function(){0==b.animationHideDuration&&f.css({left:l});if(0<c.level){a(c.element).removeClass(b.toThemeProperty("jqx-fill-state-pressed"));a(c.element).removeClass(b.toThemeProperty("jqx-menu-item-selected"));var r=a(c.arrow);0<r.length&&(r.removeClass(),"left"!=c.openHorizontalDirection?
624(r.addClass(b.toThemeProperty("jqx-menu-item-arrow-"+b._getDir("right"))),r.addClass(b.toThemeProperty("jqx-icon-arrow-"+b._getDir("right")))):(r.addClass(b.toThemeProperty("jqx-menu-item-arrow-"+b._getDir("left"))),r.addClass(b.toThemeProperty("jqx-icon-arrow-"+b._getDir("left")))))}else a(c.element).removeClass(b.toThemeProperty("jqx-fill-state-pressed")),a(c.element).removeClass(b.toThemeProperty("jqx-menu-item-top-selected")),r=a(c.arrow),0<r.length&&(r.removeClass(),"left"!=c.openHorizontalDirection?
625(r.addClass(b.toThemeProperty("jqx-menu-item-arrow-top-"+b._getDir("right"))),r.addClass(b.toThemeProperty("jqx-icon-arrow-"+b._getDir("right")))):(r.addClass(b.toThemeProperty("jqx-menu-item-arrow-top-"+b._getDir("left"))),r.addClass(b.toThemeProperty("jqx-icon-arrow-"+b._getDir("left")))));a.jqx.aria(a(c.element),"aria-expanded",!1);m.css({display:"none"});b._raiseEvent("1",c)})};0<h?f.data("timer")&&(f.data("timer").hide=setTimeout(function(){n()},h)):n();void 0!=d&&d&&(d=f.children(),a.each(d,
626function(){b.menuElements[this.id]&&b.menuElements[this.id].isOpen&&(a(b.menuElements[this.id].subMenuElement),b._closeItem(b,b.menuElements[this.id],!0,!0))}))}},getSubItems:function(b,c){if(null==b)return!1;var d=this,e=[];null!=c&&a.extend(e,c);b=a(this.menuElements[b].subMenuElement).find(".jqx-menu-item");a.each(b,function(){e[this.id]=d.menuElements[this.id];var f=d.getSubItems(this.id,e);a.extend(e,f)});return e},disable:function(b,c){if(null!=b&&this.menuElements[b]){b=this.menuElements[b];
627b.disabled=c;var d=a(b.element);b.element.disabled=c;a.each(d.children(),function(){this.disabled=c});c?(d.addClass(this.toThemeProperty("jqx-menu-item-disabled")),d.addClass(this.toThemeProperty("jqx-fill-state-disabled"))):(d.removeClass(this.toThemeProperty("jqx-menu-item-disabled")),d.removeClass(this.toThemeProperty("jqx-fill-state-disabled")))}},getItem:function(b){return this.menuElements[b]?this.menuElements[b]:null},disableItem:function(b){this.disable(b,!0)},hideItem:function(b){this.menuElements[b]&&
628a(this.menuElements[b].element).hide()},showItem:function(b){this.menuElements[b]&&a(this.menuElements[b].element).show()},enableItem:function(b){this.disable(b,!1)},_setItemProperty:function(b,c,d){null!=b&&this.menuElements[b]&&(b=this.menuElements[b],b[c]&&(b[c]=d))},setItemOpenDirection:function(b,c,d){if(null!=b){var e=a.jqx.browser.msie&&8>a.jqx.browser.version;if(this.menuElements[b]){b=this.menuElements[b];if(null!=c&&(b.openHorizontalDirection=c,b.hasItems&&0<b.level&&(c=a(b.element),void 0!=
629c))){var f=a(b.arrow);null==b.arrow&&(f=a('<span id="arrow'+c[0].id+'"></span>'),e?f.appendTo(c):f.prependTo(c),b.arrow=f[0]);f.removeClass();"left"==b.openHorizontalDirection?(f.addClass(this.toThemeProperty("jqx-menu-item-arrow-"+this._getDir("left"))),f.addClass(this.toThemeProperty("jqx-icon-arrow-"+this._getDir("left")))):(f.addClass(this.toThemeProperty("jqx-menu-item-arrow-"+this._getDir("right"))),f.addClass(this.toThemeProperty("jqx-icon-arrow-"+this._getDir("right"))));f.css("visibility",
630"inherit");e?(f.css("display","inline-block"),f.css("float","none")):(f.css("display","block"),f.css("float","right"))}null!=d&&(b.openVerticalDirection=d,f=a(b.arrow),c=a(b.element),this.showTopLevelArrows&&void 0!=c&&(null==b.arrow&&(f=a('<span id="arrow'+c[0].id+'"></span>'),e?f.appendTo(c):f.prependTo(c),b.arrow=f[0]),f.removeClass(),"down"==b.openVerticalDirection?(f.addClass(this.toThemeProperty("jqx-menu-item-arrow-down")),f.addClass(this.toThemeProperty("jqx-icon-arrow-down"))):(f.addClass(this.toThemeProperty("jqx-menu-item-arrow-up")),
631f.addClass(this.toThemeProperty("jqx-icon-arrow-up"))),f.css("visibility","inherit"),e?(f.css("display","inline-block"),f.css("float","none")):(f.css("display","block"),f.css("float","right"))))}}},_getSiblings:function(b){for(var c=[],d=0,e=0;e<this.items.length;e++)this.items[e]!=b&&this.items[e].parentId==b.parentId&&this.items[e].hasItems&&(c[d++]=this.items[e]);return c},_openItem:function(b,c,d){if(null==b||null==c||c.isOpen||c.disabled||b.disabled)return!1;var e=b.popupZIndex;void 0!=d&&(e=
632d);d=b.animationHideDuration;b.animationHideDuration=0;b._closeItem(b,c,!0,!0);b.animationHideDuration=d;a(c.element).focus();d=[5,5];var f=a(c.subMenuElement);null!=f&&f.stop();f.data("timer")&&null!=f.data("timer").hide&&clearTimeout(f.data("timer").hide);var g=f.closest("div.jqx-menu-popup"),h=a(c.element),k=0==c.level?this._getOffset(c.element):h.position();
632if(0<c.level&&this.hasTransform){var l=parseInt(h.coord().top)-parseInt(this._getOffset(c.element).top);k.top+=l}0==c.level&&"popup"==this.mode&&
633(k=h.coord());var m=0==c.level&&"horizontal"==this.mode;l=m?k.left:null!=this.menuElements[c.parentId]&&null!=this.menuElements[c.parentId].subMenuElement?parseInt(a(a(this.menuElements[c.parentId].subMenuElement).closest("div.jqx-menu-popup")).outerWidth())-d[0]:parseInt(f.outerWidth());g.css({visibility:"visible",display:"block",left:l,top:m?k.top+h.outerHeight():k.top,zIndex:e});f.css("display","block");"horizontal"!=this.mode&&0==c.level?(l=this._getOffset(this.element),g.css("left",-1+l.left+
634this.host.outerWidth()),f.css("left",-f.outerWidth())):(l=this._getClosedSubMenuOffset(c),f.css("left",l.left),f.css("top",l.top));g.css({height:parseInt(f.outerHeight())+parseInt(d[1])+"px"});var n=0,r=0;switch(c.openVerticalDirection){case "up":m?(f.css("top",f.outerHeight()),n=d[1],l=parseInt(f.parent().css("padding-bottom")),isNaN(l)&&(l=0),0<l&&g.addClass(this.toThemeProperty("jqx-menu-popup-clear")),f.css("top",f.outerHeight()-l),g.css({display:"block",top:k.top-g.outerHeight(),zIndex:e})):
635(n=d[1],f.css("top",f.outerHeight()),g.css({display:"block",top:k.top-g.outerHeight()+d[1]+h.outerHeight(),zIndex:e}));break;case "center":m?(f.css("top",0),g.css({display:"block",top:k.top-g.outerHeight()/2+d[1],zIndex:e})):(f.css("top",0),g.css({display:"block",top:k.top+h.outerHeight()/2-g.outerHeight()/2+d[1],zIndex:e}))}switch(c.openHorizontalDirection){case this._getDir("left"):m?g.css({left:k.left-(g.outerWidth()-h.outerWidth()-d[0])}):(r=0,f.css("left",g.outerWidth()),g.css({left:k.left-g.outerWidth()+
6362*c.level}));break;case "center":m?g.css({left:k.left-(g.outerWidth()/2-h.outerWidth()/2-d[0]/2)}):(g.css({left:k.left-(g.outerWidth()/2-h.outerWidth()/2-d[0]/2)}),f.css("left",g.outerWidth()))}if(m){if(parseInt(f.css("top"))==n){c.isOpen=!0;return}}else if(parseInt(f.css("left"))==r){1==c.isOpen;return}a.each(b._getSiblings(c),function(){b._closeItem(b,this,!0,!0)});e=a.data(b.element,"animationHideDelay");b.animationHideDelay=e;0<this.autoCloseInterval&&(null!=this.host.data("autoclose")&&null!=
637this.host.data("autoclose").close&&clearTimeout(this.host.data("autoclose").close),null!=this.host.data("autoclose")&&(this.host.data("autoclose").close=setTimeout(function(){b._closeAll()},this.autoCloseInterval)));f.data("timer")&&(f.data("timer").show=setTimeout(function(){if(null!=g)if(m){f.stop();f.css("left",r);h.addClass(b.toThemeProperty("jqx-fill-state-pressed"));h.addClass(b.toThemeProperty("jqx-menu-item-top-selected"));"down"==c.openVerticalDirection?(a(c.element).addClass(b.toThemeProperty("jqx-rc-b-expanded")),
638g.addClass(b.toThemeProperty("jqx-rc-t-expanded"))):(a(c.element).addClass(b.toThemeProperty("jqx-rc-t-expanded")),g.addClass(b.toThemeProperty("jqx-rc-b-expanded")));g.addClass(b.toThemeProperty("show"));var t=a(c.arrow);0<t.length&&b.showTopLevelArrows&&(t.removeClass(),"down"==c.openVerticalDirection?(t.addClass(b.toThemeProperty("jqx-menu-item-arrow-down-selected")),t.addClass(b.toThemeProperty("jqx-icon-arrow-down"))):(t.addClass(b.toThemeProperty("jqx-menu-item-arrow-up-selected")),t.addClass(b.toThemeProperty("jqx-icon-arrow-up"))));
6390==b.animationShowDuration?(f.css({top:n}),c.isOpen=!0,b._raiseEvent("0",c),a.jqx.aria(a(c.element),"aria-expanded",!0)):f.animate({top:n},b.animationShowDuration,b.easing,function(){c.isOpen=!0;a.jqx.aria(a(c.element),"aria-expanded",!0);b._raiseEvent("0",c)})}else f.stop(),f.css("top",n),g.addClass(b.toThemeProperty("show")),0<c.level?(h.addClass(b.toThemeProperty("jqx-fill-state-pressed")),h.addClass(b.toThemeProperty("jqx-menu-item-selected"))):(h.addClass(b.toThemeProperty("jqx-fill-state-pressed")),
640h.addClass(b.toThemeProperty("jqx-menu-item-top-selected"))),t=a(c.arrow),0<t.length&&(t.removeClass(),"left"!=c.openHorizontalDirection?(t.addClass(b.toThemeProperty("jqx-menu-item-arrow-"+b._getDir("right")+"-selected")),t.addClass(b.toThemeProperty("jqx-icon-arrow-"+b._getDir("right")))):(t.addClass(b.toThemeProperty("jqx-menu-item-arrow-"+b._getDir("left")+"-selected")),t.addClass(b.toThemeProperty("jqx-icon-arrow-"+b._getDir("left"))))),0==b.animationShowDuration?(f.css({left:r}),b._raiseEvent("0",
641c),c.isOpen=!0,a.jqx.aria(a(c.element),"aria-expanded",!0)):f.animate({left:r},b.animationShowDuration,b.easing,function(){b._raiseEvent("0",c);c.isOpen=!0;a.jqx.aria(a(c.element),"aria-expanded",!0)})},this.animationShowDelay))}
641,_getDir:function(b){switch(b){case "left":return this.rtl?"right":"left";case "right":return this.rtl?"left":"right"}return"left"},_applyOrientation:function(b,c){var d=this,e=0;d.host.removeClass(d.toThemeProperty("jqx-menu-horizontal"));d.host.removeClass(d.toThemeProperty("jqx-menu-vertical"));
642d.host.removeClass(d.toThemeProperty("jqx-menu"));d.host.removeClass(d.toThemeProperty("jqx-widget"));d.host.addClass(d.toThemeProperty("jqx-widget"));d.host.addClass(d.toThemeProperty("jqx-menu"));void 0!=b&&void 0!=c&&"popup"==c?0<d.host.parent().length&&0<d.host.parent().parent().length&&d.host.parent().parent()[0]==document.body&&(b=a.data(document.body,"jqxMenuOldHost"+d.element.id),null!=b&&(c=d.host.closest("div.jqx-menu-wrapper"),c.remove(),c.appendTo(b),d.host.css("display","block"),d.host.css("visibility",
643"visible"),c.css("display","block"),c.css("visibility","visible"))):void 0==b&&void 0==c&&a.data(document.body,"jqxMenuOldHost"+d.element.id,d.host.parent()[0]);d.autoOpenPopup?"popup"==d.mode?(d.addHandler(a(document),"contextmenu."+d.element.id,function(f){return!1}),d.addHandler(a(document),"mousedown.menu"+d.element.id,function(f){d._openContextMenu(f)})):(d.removeHandler(a(document),"contextmenu."+d.element.id),d.removeHandler(a(document),"mousedown.menu"+d.element.id)):(d.removeHandler(a(document),
644"contextmenu."+d.element.id),d.removeHandler(a(document),"mousedown.menu"+d.element.id),d.addHandler(a(document),"contextmenu."+d.element.id,function(f){if(f.target&&f.target.className.indexOf&&0<=f.target.className.indexOf("jqx-menu"))return!1}));d.rtl&&d.host.addClass(d.toThemeProperty("jqx-rtl"));switch(d.mode){case "horizontal":d.host.addClass(d.toThemeProperty("jqx-widget-header"));d.host.addClass(d.toThemeProperty("jqx-menu-horizontal"));a.each(d.items,function(){var f=a(this.element),g=a(this.arrow);
645g.removeClass();this.hasItems&&0<this.level&&(g=a('<span style="border: none; background-color: transparent;" id="arrow'+f[0].id+'"></span>'),g.prependTo(f),g.css("float",d._getDir("right")),g.addClass(d.toThemeProperty("jqx-menu-item-arrow-"+d._getDir("right"))),g.addClass(d.toThemeProperty("jqx-icon-arrow-"+d._getDir("right"))),this.arrow=g[0]);if(0==this.level){a(this.element).css("float",d._getDir("left"));if(!this.ignoretheme&&this.hasItems&&d.showTopLevelArrows){g=a('<span style="border: none; background-color: transparent;" id="arrow'+
646f[0].id+'"></span>');var h=a.jqx.browser.msie&&8>a.jqx.browser.version;null==this.arrow?h?g.appendTo(f):g.prependTo(f):g=a(this.arrow);"down"==this.openVerticalDirection?(g.addClass(d.toThemeProperty("jqx-menu-item-arrow-down")),g.addClass(d.toThemeProperty("jqx-icon-arrow-down"))):(g.addClass(d.toThemeProperty("jqx-menu-item-arrow-up")),g.addClass(d.toThemeProperty("jqx-icon-arrow-up")));g.css("visibility","inherit");h?g.css("display","inline-block"):(g.css("display","block"),g.css("float","right"));
647this.arrow=g[0]}else this.ignoretheme||!this.hasItems||d.showTopLevelArrows||null==this.arrow||(g=a(this.arrow),g.remove(),this.arrow=null);e=Math.max(e,f.height())}});break;case "vertical":case "popup":case "simple":d.host.addClass(d.toThemeProperty("jqx-menu-vertical")),a.each(d.items,function(){var f=a(this.element);if(this.hasItems&&!this.ignoretheme){this.arrow&&a(this.arrow).remove();if("simple"==d.mode)return!0;var g=a('<span style="border: none; background-color: transparent;" id="arrow'+
648f[0].id+'"></span>');g.prependTo(f);g.css("float","right");0==this.level?g.addClass(d.toThemeProperty("jqx-menu-item-arrow-top-"+d._getDir("right"))):g.addClass(d.toThemeProperty("jqx-menu-item-arrow-"+d._getDir("right")));g.addClass(d.toThemeProperty("jqx-icon-arrow-"+d._getDir("right")));this.arrow=g[0]}f.css("float","none")}),"popup"==d.mode?(d.host.addClass(d.toThemeProperty("jqx-widget-content")),d.host.wrap('<div tabindex=0 class="jqx-menu-wrapper" style="z-index:'+d.popupZIndex+'; border: none; background-color: transparent; padding: 0px; margin: 0px; position: absolute; top: 0; left: 0; display: block; visibility: visible;"></div>'),
649c=d.host.closest("div.jqx-menu-wrapper"),d.host.addClass(d.toThemeProperty("jqx-popup")),c[0].id="menuWrapper"+d.element.i
649d,c.appendTo(a(document.body)),d.addHandler(c,"keydown",function(f){return d.handleKeyDown(f)})):d.host.addClass(d.toThemeProperty("jqx-widget-header")),"popup"==d.mode&&(b=d.host.height(),d.host.css("position","absolute"),d.host.css("top","0"),d.host.css("left","0"),"simple"!=d.mode&&(d.host.height(b),d.host.css("display","none")))}b=d.isTouchDevice();d.autoCloseOnClick&&(d.removeHandler(a(document),
650"mousedown.menu"+d.element.id,d._closeAfterClick),d.addHandler(a(document),"mousedown.menu"+d.element.id,d._closeAfterClick,d),b&&(d.removeHandler(a(document),a.jqx.mobile.getTouchEventName("touchstart")+".menu"+d.element.id,d._closeAfterClick,d),d.addHandler(a(document),a.jqx.mobile.getTouchEventName("touchstart")+".menu"+d.element.id,d._closeAfterClick,d)))},_getBodyOffset:function(){var b=0,c=0;"0px"!=a("body").css("border-top-width")&&(b=parseInt(a("body").css("border-top-width")),isNaN(b)&&(b=
6510));"0px"!=a("body").css("border-left-width")&&(c=parseInt(a("body").css("border-left-width")),isNaN(c)&&(c=0));return{left:c,top:b}},_getOffset:function(b){var c=a.jqx.mobile.isSafariMobileBrowser(),d=a(b).coord(!0),e=d.top;d=d.left;"0px"!=a("body").css("border-top-width")&&(e=parseInt(e)+this._getBodyOffset().top);"0px"!=a("body").css("border-left-width")&&(d=parseInt(d)+this._getBodyOffset().left);var f=a.jqx.mobile.isWindowsPhone(),g=a.jqx.mobile.isTouchDevice();return this.hasTransform||null!=
652c&&c||f||g?{left:a.jqx.mobile.getLeftPos(b),top:a.jqx.mobile.getTopPos(b)}:{left:d,top:e}},_isRightClick:function(b){var c;b||(b=window.event);b.which?c=3==b.which:b.button&&(c=2==b.button);return c},_openContextMenu:function(b){this._isRightClick(b)&&this.open(parseInt(b.clientX)+5,parseInt(b.clientY)+5)},close:function(){var b=this;a.data(this.element,"contextMenuOpened"+this.element.id)&&(b.host.removeClass("jqx-popup-show"),a.each(b.items,function(){this.hasItems&&b._closeItem(b,this)}),a.each(b.items,
653function(){1==this.isOpen&&a(this.subMenuElement).closest("div.jqx-menu-popup").hide(this.animationHideDuration)}),this.host.hide(this.animationHideDuration),a.data(b.element,"contextMenuOpened"+this.element.id,!1),b._raiseEvent("1",b),b._raiseEvent("5"))},open:function(b,c){if("popup"==this.mode){var d=0;"block"==this.host.css("display")&&(this.close(),d=this.animationHideDuration);var e=this;if(void 0==b||null==b)b=0;if(void 0==c||null==c)c=0;setTimeout(function(){e.host.show(e.animationShowDuration);
654e.host.css("visibility","visible");e.host.addClass("jqx-popup-show");a.data(e.element,"contextMenuOpened"+e.element.id,!0);e._raiseEvent("0",e);e._raiseEvent("4",{left:b,top:c});e.host.css("z-index",e.popupZIndex);void 0!=b&&void 0!=c&&e.host.css({left:b,top:c});e.focus()},d)}},_renderHover:function(b,c,d){var e=this;c.ignoretheme||(this.addHandler(b,"mouseenter",function(){e.hoveredItem=c;c.disabled||c.separator||!e.enableHover||e.disabled||(0<c.level?(b.addClass(e.toThemeProperty("jqx-fill-state-hover")),
655b.addClass(e.toThemeProperty("jqx-menu-item-hover"))):(b.addClass(e.toThemeProperty("jqx-fill-state-hover")),b.addClass(e.toThemeProperty("jqx-menu-item-top-hover"))))}),this.addHandler(b,"mouseleave",function(){c.disabled||c.separator||!e.enableHover||e.disabled||(0<c.level?(b.removeClass(e.toThemeProperty("jqx-fill-state-hover")),b.removeClass(e.toThemeProperty("jqx-menu-item-hover"))):(b.removeClass(e.toThemeProperty("jqx-fill-state-hover")),b.removeClass(e.toThemeProperty("jqx-menu-item-top-hover"))))}))},
656_closeAfterClick:function(b){var c=null!=b?b.data:this,d=!1;c.autoCloseOnClick&&(a.each(a(b.target).parents(),function(){if(this.className.indexOf&&-1!=this.className.indexOf("jqx-menu"))return d=!0,!1}),d||(b.data=c,c._closeAll(b)))},_autoSizeHorizontalMenuItems:function(){var b=this;if(b.autoSizeMainItems&&"horizontal"==this.mode){var c=this.maxHeight;parseInt(c)>parseInt(this.host.height())&&(c=parseInt(this.host.height()));c=parseInt(this.host.height());a.each(this.items,function(){var d=a(this.element);
657if(0==this.level&&0<c){var e=0<d.children().length?parseInt(d.children().height()):d.height(),f=b.host.find("ul:first"),g=parseInt(f.css("padding-top"));f=parseInt(f.css("margin-top"));g=c-2*(f+g);f=parseInt(g)/2-e/2;e=parseInt(f);f=parseInt(f);d.css("padding-top",e);d.css("padding-bottom",f);parseInt(d.outerHeight())>g&&d.css("padding-top",e-1)}})}a.each(this.items,function(){a(this.element);if(this.hasItems&&0<this.level&&this.arrow){var d=a(this.arrow),e=a(this.element).height();15<e&&d.css("margin-top",
658(e-15)/2)}})},_nextVisibleItem:function(b,c){if(null==b||void 0==b)return null;for(;null!=b;)if(b=b.nextItem,this._isVisible(b)&&!b.disabled&&"separator"!==b.type&&(this.minimized||void 0==c||!b||b.level==c))return b;return null},_prevVisibleItem:function(b,c){if(null==b||void 0==b)return null;for(;null!=b;)if(b=b.prevItem,this._isVisible(b)&&!b.disabled&&"separator"!==b.type&&(this.minimized||void 0==c||!b||b.level==c))return b;return null},_parentItem:function(b){if(null==b||void 0==b)return null;
659var c=b.parentElement;if(!c)return null;var d=null;a.each(this.items,function(){if(this.element==c)return d=this,!1});return d},_isElementVisible:function(b){return null==b?!1:"none"!=a(b).css("display")&&"hidden"!=a(b).css("visibility")?!0:!1},_isVisible:function(b){if(null==b||void 0==b||!this._isElementVisible(b.element))return!1;b=this._parentItem(b);if(null==b||this.minimized)return!0;if(null!=b)if(this._isElementVisible(b.element)&&(b.isOpen||this.minimized))for(;null!=b;){if(b=this._parentItem(b),
660null!=b&&!this._isElementVisible(b.element)||null!=b&&!b.isOpen)return!1}else return!1;return!0},_render:function(b,c){this.disabled&&(this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled")),this.host.addClass(this.toThemeProperty("jqx-menu-disabled")));void 0==this.host.attr("tabindex")&&this.host.attr("tabindex",0);var d=this.popupZIndex,e=[5,5],f=this;a.data(f.element,"animationHideDelay",f.animationHideDelay);var g=this.isTouchDevice(),h=g&&(a.jqx.mobile.isWindowsPhone()||0<=navigator.userAgent.indexOf("Touch"));
661-1!=navigator.platform.toLowerCase().indexOf("win")&&(0<=navigator.userAgent.indexOf("Windows Phone")||0<=navigator.userAgent.indexOf("WPDesktop")||0<=navigator.userAgent.indexOf("IEMobile")||0<=navigator.userAgent.indexOf("ZuneWP7")?this.touchDevice=!0:0<=navigator.userAgent.indexOf("Touch")&&("MSPointerDown"in window||a.jqx.mobile.isWindowsPhone()||0<=navigator.userAgent.indexOf("ARM"))&&(h=!0,f.clickToOpen=!0,f.autoCloseOnClick=!1,f.enableHover=!1));a.data(document.body,"menuel",this);this.hasTransform=
662a.jqx.utilities.hasTransform(this.host);this._applyOrientation(b,c);this.removeHandler(this.host,"blur");this.removeHandler(this.host,"focus");this.addHandler(this.host,"blur",function(k){!f.keyboardNavigation||!f.activeItem||"popup"===f.mode&&document.activeElement&&0<=document.activeElement.className.indexOf("jqx-menu-wrapper")||(a(f.activeItem.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=null)});this.addHandler(this.host,"focus",function(k){f.keyboardNavigation&&
663!f.activeItem&&(f.hoveredItem?(a(f.hoveredItem.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=f.hoveredItem):(k=function(){if(a.jqx.isHidden(a(f.items[0].element))){var l=f._nextVisibleItem(f.items[0],0);l&&(a(l.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=l)}else a(f.items[0].element).addClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=f.items[0]},f.activeItem?a.jqx.isHidden(a(f.activeItem.element))?(a(f.activeItem.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),
664k()):a(f.activeItem.element).addClass(f.toThemeProperty("jqx-fill-state-focus")):k()))});this.removeHandler(this.host,"keydown.menu"+this.element.id);f.handleKeyDown=function(k){if(f.keyboardNavigation){if("input"===k.target.nodeName.toLowerCase())return!0;var l=null,m=null;a.each(f.items,function(){if(this.disabled)return!0;0<=this.element.className.indexOf("pressed")&&(m=this);if(0<=this.element.className.indexOf("focus"))return l=this,!1});if(!l&&m)return l=m,!1;if(!l)return a(f.items[0].element).addClass(f.toThemeProperty("jqx-fill-state-focus")),
665f.activeItem=f.items[0],l=f.activeItem,!1;if(27==k.keyCode&&(k.data=f,f._closeAll(k),l))for(var n=l;null!=n;)n.parentItem||(a(f.activeItem.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=n,a(f.activeItem.element).addClass(f.toThemeProperty("jqx-fill-state-focus"))),n=n.parentItem;if(13==k.keyCode&&l){f._raiseEvent("2",{item:l.element,event:k,type:"keyboard"});var r=null!=l.anchor?a(l.anchor):null;null!=r&&0<r.length&&(n=r.attr("href"),r=r.attr("target"),null!=n&&(null!=
666r?window.open(n,r):window.location=n));k.preventDefault();k.stopPropagation();a(l.element).focus()}r=function(B){if(null==B)return[];for(var y=[],A=0,aa=0;aa<f.items.length;aa++)f.items[aa].parentId==B.parentId&&(y[A++]=f.items[aa]);return y};var t="";switch(k.keyCode){case 40:t="down";break;case 38:t="up";break;case 39:t="right";break;case 37:t="left"}l&&"left"===l.openHorizontalDirection&&"left"===t&&(t="right");l&&"left"===l.openHorizontalDirection&&"right"===t&&(t="left");l&&"top"===l.openVerticalDirection&&
667"top"===t&&(t="bottom");l&&"top"===l.openVerticalDirection&&"bottom"===t&&(t="top");f.rtl&&("right"===t?t="left":"left"===t&&(t="right"));
667if("right"===t&&!f.minimized){if(k.altKey&&(0!=l.level&&l.hasItems||"horizontal"!=f.mode))f._openItem(f,l);else{var u=f._nextVisibleItem(l,0),x=f._nextVisibleItem(l);n=r(x);u||=x;u&&(u.parentId===l.parentId&&0==u.level&&"horizontal"==f.mode||x.id==n[0].id&&0!=x.level)&&(x.id==n[0].id&&(0!=l.level||0==l.level&&"horizontal"!=f.mode)&&(u=x),a(u.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),
668a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=u)}k.preventDefault();k.stopPropagation()}"left"!==t||f.minimized||(k.altKey&&(0!=l.level&&"horizontal"!==f.mode||1<l.level&&"horizontal"===f.mode||1==l.level&&l.hasItems&&"horizontal"===f.mode)?l.hasItems?f._closeItem(f,l):l.parentItem&&(f._closeItem(f,l.parentItem),a(l.parentItem.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=
669l.parentItem):(u=f._prevVisibleItem(l,0),n=l.parentItem,u&&u.parentId===l.parentId&&0==u.level&&"horizontal"==f.mode?(a(u.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=u):n&&0==n.level&&"horizontal"==f.mode||!n||n.level!=l.level-1||(a(n.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=n)),k.preventDefault(),k.stopPropagation());
670if("down"===t)k.altKey?(0==l.level&&l.hasItems&&f._openItem(f,l),f.minimized&&f.minimizedHidden&&f.minimizedItem.trigger("click")):(u=f._nextVisibleItem(l,l.level),n=r(u),f.minimized&&u?(a(u.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=u):(!u||u.parentId!==l.parentId&&(u.id!=n[0].id||"horizontal"!=f.mode)||0==u.level&&"horizontal"==f.mode||(a(u.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),
671a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=u),"horizontal"===f.mode&&0===l.level&&l.isOpen&&l.hasItems&&(u=f._nextVisibleItem(l),a(u.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=u))),k.preventDefault(),k.stopPropagation();else if("up"===t){if(k.altKey)l.parentItem&&0==l.parentItem.level?(f._closeItem(f,l.parentItem),a(l.parentItem.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),
672a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=l.parentItem):null===l.parentItem&&0===l.level&&"horizontal"===f.mode&&f._closeItem(f,l),f.minimized&&(f.minimizedHidden||f.minimizedItem.trigger("click"));else if(u=f._prevVisibleItem(l,l.level),n=r(l),f.minimized&&u)a(u.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=u;else if(u&&(u.parentId===l.parentId||u.id==l.parentId&&
6730==u.level&&"horizontal"==f.mode)){if(0!=u.level||"horizontal"!==f.mode||0!==l.level)a(u.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=u}else l&&l.id==n[0].id&&l.parentItem&&0===l.parentItem.level&&"horizontal"===f.mode&&(u=l.parentItem,a(u.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=u);k.preventDefault();
674k.stopPropagation()}if(9==k.keyCode)if(u=k.shiftKey?f._prevVisibleItem(l):f._nextVisibleItem(l))a(u.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=u,k.preventDefault(),k.stopPropagation();else if(f.lockFocus){n=[];for(t=r=0;t<f.items.length;t++)f.items[t]!=l&&f.items[t].parentId==l.parentId&&(n[r++]=f.items[t]);0<n.length&&(k.shiftKey?(a(n[n.length-1].element).addClass(f.toThemeProperty("jqx-fill-state-focus")),
675f.activeItem=n[n.length-1]):(a(n[0].element).addClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=n[0]),a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")));k.preventDefault();k.stopPropagation()}else l&&(a(l.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=null)}else return!0};
675this.addHandler(this.host,"keydown.menu"+this.element.id,function(k){f.handleKeyDown(k)});f.enableRoundedCorners&&this.host.addClass(f.toThemeProperty("jqx-rc-all"));
676a.each(this.items,function(){var k=this,l=a(k.element);l.attr("role","menuitem");f.enableRoundedCorners&&l.addClass(f.toThemeProperty("jqx-rc-all"));f.removeHandler(l,"click");f.addHandler(l,"click",function(y){if(!k.disabled&&!f.disabled&&(f.keyboardNavigation&&(f.activeItem&&a(f.activeItem.element).removeClass(f.toThemeProperty("jqx-fill-state-focus")),f.activeItem=k,a(k.element).addClass(f.toThemeProperty("jqx-fill-state-focus")),f.minimized&&y.stopPropagation()),f._raiseEvent("2",{type:"mouse",
677item:k.element,event:y}),f.autoOpen?f.autoCloseOnClick&&!g&&!f.clickToOpen&&k.closeOnClick&&(y.data=f,f._closeAll(y)):0<k.level&&f.autoCloseOnClick&&!g&&!f.clickToOpen&&(y.data=f,f._closeAll(y)),g&&f.autoCloseOnClick&&(y.data=f,k.hasItems||f._closeAll(y)),"A"!=y.target.tagName&&"a"!=y.target.tagName)){var A=null!=k.anchor?a(k.anchor):null;null!=A&&0<A.length&&(y=A.attr("href"),A=A.attr("target"),null!=y&&(null!=A?window.open(y,A):window.location=y))}});f.removeHandler(l,"mouseenter");f.removeHandler(l,
678"mouseleave");h||"simple"==f.mode||f._renderHover(l,k,g);if(null!=k.subMenuElement){var m=a(k.subMenuElement);if("simple"==f.mode)return m.show(),!0;m.wrap('<div class="jqx-menu-popup '+f.toThemeProperty("jqx-menu-popup")+'" style="border: none; background-color: transparent; z-index:'+d+'; padding: 0px; margin: 0px; position: absolute; top: 0; left: 0; display: block; visibility: hidden;"><div style="background-color: transparent; border: none; position:absolute; overflow:hidden; left: 0; top: 0; right: 0; width: 100%; height: 100%;"></div></div>');
679m.css({overflow:"hidden",position:"absolute",left:0,display:"inherit",top:-m.outerHeight()});m.data("timer",{});0<k.level?m.css("left",-m.outerWidth()):"horizontal"==f.mode&&m.css("left",0);d++;var n=a(k.subMenuElement).closest("div.jqx-menu-popup").css({width:parseInt(a(k.subMenuElement).outerWidth())+parseInt(e[0])+"px",height:parseInt(a(k.subMenuElement).outerHeight())+parseInt(e[1])+"px"}),r=l.closest("div.jqx-menu-popup");if(0<r.length){var t=m.css("margin-left"),u=m.css("margin-right"),x=m.css("padding-left"),
680B=m.css("padding-right");n.addClass("horizontal");n.appendTo(r)}else t=m.css("margin-left"),u=m.css("margin-right"),x=m.css("padding-left"),B=m.css("padding-right"),"horizontal"===f.mode?n.addClass("top"):n.addClass("horizontal"),n.appendTo(a(document.body));m.css("margin-left",t);m.css("margin-right",u);m.css("padding-left",x);m.css("padding-right",B);if(f.clickToOpen)f.removeHandler(l,"mousedown"),f.addHandler(l,"mousedown",function(y){clearTimeout(m.data("timer").hide);null!=m&&m.stop();0!=k.level||
681k.isOpen||(y.data=f,f._closeAll(y));k.isOpen?f._closeItem(f,k,!0):f._openItem(f,k)});else{if(g||h)f.removeHandler(l,a.jqx.mobile.getTouchEventName("touchstart")),f.addHandler(l,a.jqx.mobile.getTouchEventName("touchstart"),function(y){clearTimeout(m.data("timer").hide);null!=m&&m.stop();0!=k.level||k.isOpen||"popup"==f.mode||(y.data=f,f._closeAll(y));k.isOpen?f._closeItem(f,k,!0):f._openItem(f,k);return!1});h||(f.addHandler(l,"mouseenter",function(){(f.autoOpen||0<k.level&&!f.autoOpen)&&clearTimeout(m.data("timer").hide);
682if(!k.parentId||0==k.parentId||!f.menuElements[k.parentId]||f.menuElements[k.parentId].isOpen)return(f.autoOpen||0<k.level&&!f.autoOpen)&&f._openItem(f,k),!1}),f.addHandler(l,"mousedown",function(){f.autoOpen||0!=k.level||(clearTimeout(m.data("timer").hide),null!=m&&m.stop(),k.isOpen?f._closeItem(f,k,!0):f._openItem(f,k))}),f.addHandler(l,"mouseleave",function(y){if(f.autoCloseOnMouseLeave){clearTimeout(m.data("timer").hide);var A=a(k.subMenuElement),aa=parseInt(y.pageX);y=parseInt(y.pageY);var ha=
683parseInt(A.coord().left),z=parseInt(A.coord().top),V=parseInt(A.outerWidth());A=parseInt(A.outerHeight());var ba=!0;ha-5<=aa&&aa<=ha+V+5&&z<=y&&y<=z+A&&(ba=!1);ba&&f._closeItem(f,k,!0)}}),f.removeHandler(n,"mouseenter"),f.addHandler(n,"mouseenter",function(){clearTimeout(m.data("timer").hide)}),f.removeHandler(n,"mouseleave"),f.addHandler(n,"mouseleave",function(y){f.autoCloseOnMouseLeave&&(clearTimeout(m.data("timer").hide),clearTimeout(m.data("timer").show),null!=m&&m.stop(),f._closeItem(f,k,!0))}))}}});
684"simple"==this.mode&&this._renderSimpleMode();this._autoSizeHorizontalMenuItems();this._raiseEvent("3",this)},_renderSimpleMode:function(){this.host.show()},createID:function(){var b=Math.random()+"";b=b.replace(".","");for(b=("99"+b)/1;this.items[b];)b=Math.random()+"",b=b.replace(".",""),b/=1;return"menuItem"+b},_createMenu:function(b,c){if(null!=b){void 0==c&&(c=!0);null==c&&(c=!0);a(b).addClass("jqx-menu-ul");b=a(b).find("li");var d=0;this.itemMapping=[];for(var e=0;e<b.length;e++){var f=b[e],
685g=a(f);
685if(-1!=f.className.indexOf("jqx-menu")||0!=this.autoGenerate){var h=f.id;h||=this.createID();c&&(f.id=h,this.items[d]=new a.jqx._jqxMenu.jqxMenuItem,this.menuElements[h]=this.items[d]);d+=1;var k=0,l=this;g.children().each(function(){c||(this.className="",l.autoGenerate&&(a(l.items[d-1].subMenuElement)[0].className="",l.minimized||a(l.items[d-1].subMenuElement).addClass(l.toThemeProperty("jqx-widget-content")),a(l.items[d-1].subMenuElement).addClass(l.toThemeProperty("jqx-menu-dropdown")),
686a(l.items[d-1].subMenuElement).addClass(l.toThemeProperty("jqx-popup"))));if(-1!=this.className.indexOf("jqx-menu-dropdown"))return c&&(l.items[d-1].subMenuElement=this),!1;if(l.autoGenerate&&("ul"==this.tagName||"UL"==this.tagName))return c&&(l.items[d-1].subMenuElement=this),this.className="",l.minimized||a(this).addClass(l.toThemeProperty("jqx-widget-content")),a(this).addClass(l.toThemeProperty("jqx-menu-dropdown")),a(this).addClass(l.toThemeProperty("jqx-popup")),a(this).attr("role","menu"),
687l.rtl?a(this).addClass(l.toThemeProperty("jqx-rc-l")):a(this).addClass(l.toThemeProperty("jqx-rc-r")),a(this).addClass(l.toThemeProperty("jqx-rc-b")),!1});g.parents().each(function(){if(-1!=this.className.indexOf("jqx-menu-item")||l.autoGenerate&&("li"==this.tagName||"LI"==this.tagName))return k=this.id,!1});var m=!1,n=f.getAttribute("type"),r=f.getAttribute("ignoretheme")||f.getAttribute("data-ignoretheme");if(r){if("true"==r||1==r)r=!0}else r=!1;n?"separator"==n&&(m=!0):n=f.type;m||(n=k?"sub":"top");
688var t=this.items[d-1];c&&(t.id=h,t.parentId=k,t.type=n,t.separator=m,t.element=b[e],h=g.children("a"),t.disabled="true"==f.getAttribute("item-disabled")?!0:!1,t.level=g.parents("li").length,t.anchor=0<h.length?h:null,t.anchor&&a(t.anchor).attr("tabindex",-1));t.ignoretheme=r;f=this.menuElements[k];null!=f&&(f.ignoretheme&&(r=t.ignoretheme=f.ignoretheme),t.parentItem=f,t.parentElement=f.element);this.autoGenerate&&("separator"==n?(g.removeClass(),g.addClass(this.toThemeProperty("jqx-menu-item-separator")),
689g.attr("role","separator")):r||(0<=g[0].className.indexOf("jqx-grid-menu-item-touch")?g[0].className=this.toThemeProperty("jqx-grid-menu-item-touch"):g[0].className="",this.rtl&&g.addClass(this.toThemeProperty("jqx-rtl")),0<t.level&&!l.minimized?(g.addClass(this.toThemeProperty("jqx-item")),g.addClass(this.toThemeProperty("jqx-menu-item"))):(g.addClass(this.toThemeProperty("jqx-item")),g.addClass(this.toThemeProperty("jqx-menu-item-top")))));t.disabled&&(g.addClass(l.toThemeProperty("jqx-menu-item-disabled")),
690g.addClass(l.toThemeProperty("jqx-fill-state-disabled")));this.itemMapping[e]={element:b[e],item:t};this.itemMapping["id"+b[e].id]=this.itemMapping[e];c&&!r&&(t.hasItems=0<g.find("li").length,t.hasItems&&t.element&&(a.jqx.aria(a(t.element),"aria-haspopup",!0),t.subMenuElement.id||(t.subMenuElement.id=a.jqx.utilities.createId()),a.jqx.aria(a(t.element),"aria-owns",t.subMenuElement.id)))}}for(e=0;e<b.length;e++)if(t=b[e],this.itemMapping["id"+t.id]&&(t=this.itemMapping["id"+t.id].item))t.prevItem=null,
691t.nextItem=null,0<e&&this.itemMapping["id"+b[e-1].id]&&(t.prevItem=this.itemMapping["id"+b[e-1].id].item),e<b.length-1&&this.itemMapping["id"+b[e+1].id]&&(t.nextItem=this.itemMapping["id"+b[e+1].id].item)}},destroy:function(){var b=this;a.jqx.utilities.resize(b.host,null,!0);var c=b.host.closest("div.jqx-menu-wrapper");b.removeHandler(c,"keydown");c.remove();b.removeHandler(a("#menuWrapper"+b.element.id),"keydown");a("#menuWrapper"+b.element.id).remove();b.removeHandler(b.host,"keydown");b.removeHandler(b.host,
692"focus");b.removeHandler(b.host,"blur");b.removeHandler(a(document),"mousedown.menu"+b.element.id,b._closeAfterClick);b.removeHandler(a(document),"mouseup.menu"+b.element.id,b._closeAfterClick);b.removeHandler(a(document),"contextmenu."+b.element.id);b.removeHandler(b.host,"contextmenu."+b.element.id);a.data(document.body,"jqxMenuOldHost"+b.element.id,null);b.isTouchDevice()&&b.removeHandler(a(document),a.jqx.mobile.getTouchEventName("touchstart")+".menu"+b.element.id,b._closeAfterClick,this);a(window).off&&
693a(window).off("resize.menu"+b.element.id);a.each(b.items,function(){var d=a(this.element);b.removeHandler(d,"click");b.removeHandler(d,"selectstart");b.removeHandler(d,"mouseenter");b.removeHandler(d,"mouseleave");b.removeHandler(d,"mousedown");b.removeHandler(d,"mouseleave");a(this.subMenuElement).closest("div.jqx-menu-popup").remove();delete this.subMenuElement;delete this.element});a.data(document.body,"menuel",null);delete b.menuElements;b.items=[];delete b.items;(c=a.data(b.element,"jqxMenu"))&&
694delete c.instance;b.host.removeClass();b.host.remove();delete b.host;delete b.element},_raiseEvent:function(b,c){void 0==c&&(c={owner:null});var d=this.events[b],e=c;e.owner=this;d=new a.Event(d);"2"==b&&(e=c.item,e.owner=this,e.clickType=c.type,a.extend(d,c.event),d.type="itemclick");d.owner=this;d.args=e;return this.host.trigger(d)},propertiesChangedHandler:function(b,c,d){d.width&&d.height&&2==Object.keys(d).length&&(b._setSize(),"popup"===b.mode&&(this.host.closest("div.jqx-menu-wrapper")[c](d),
695a("#"+this.host[0].id)[c](d)))},propertyChangedHandler:function(b,c,d,e){if(void 0!=this.isInitialized&&0!=this.isInitialized&&!(b.batchUpdate&&b.batchUpdate.width&&b.batchUpdate.height&&2==Object.keys(b.batchUpdate).length)&&("disabled"==c&&(b.disabled?(b.host.addClass(b.toThemeProperty("jqx-fill-state-disabled")),b.host.addClass(b.toThemeProperty("jqx-menu-disabled"))):(b.host.removeClass(b.toThemeProperty("jqx-fill-state-disabled")),b.host.removeClass(b.toThemeProperty("jqx-menu-disabled")))),
696e!=d))if("touchMode"==c&&(this._isTouchDevice=null,b._render(e,d)),"width"===c||"height"===c)b._setSize(),"popup"===b.mode&&(this.host.closest("div.jqx-menu-wrapper")[c](e),a("#"+this.host[0].id)[c](e));else{if("source"==c&&null!=b.source){var f=b.loadItems(b.source);b.element.innerHTML=f;f=b.host.find("ul:first");0<f.length&&(b.refresh(),b._createMenu(f[0]),b._render())}"autoCloseOnClick"==c?0==e?b.removeHandler(a(document),"mousedown.menu"+this.element.id,b._closeAll):b.addHandler(a(document),"mousedown.menu"+
697this.element.id,b,b._closeAll):"mode"==c||"width"==c||"height"==c||"showTopLevelArrows"==c?(b.refresh(),"mode"==c?b._render(e,d):b._applyOrientation()):"theme"==c&&a.jqx.utilities.setTheme(d,e,b.host)}}})})(jqxBaseFramework);(function(a){a.jqx._jqxMenu.jqxMenuItem=function(b,c,d){return{id:b,parentId:c,parentItem:null,anchor:null,type:d,disabled:!1,level:0,isOpen:!1,hasItems:!1,element:null,subMenuElement:null,arrow:null,openHorizontalDirection:"right",openVerticalDirection:"down",closeOnClick:!0}}})(jqxBaseFramework);
698(function(a){function b(d,e){this.owner=d;this.displayfield=this.datafield=null;this.text="";this.createfilterpanel=null;this.editable=this.hideable=this.sortable=!0;this.adaptivehidden=this.hidden=!1;this.groupable=!0;this.checkchange=this.cellsrenderer=this.renderer=null;this.threestatecheckbox=!1;this.columntype=this.buttonclick=null;this.cellsformat="";this.cellsalign=this.align="left";this.width="auto";this.minwidth=25;this.maxwidth="auto";this.pinned=!1;this.visibleindex=-1;this.filterable=
699!0;this.filter=null;this.filteritems=[];this.resizable=!0;this.validation=this.geteditorvalue=this.destroyeditor=this.destroywidget=this.initwidget=this.createwidget=this.createeditor=this.initeditor=null;this.cellclassname=this.classname="";this.aggregatesrenderer=this.aggregates=this.cellvaluechanging=this.cellbeginedit=this.cellendedit=null;this.menu=!0;this.createfilterwidget=null;this.filtertype="default";this.rendered=this.filtercondition=null;this.exportable=!0;this.exporting=!1;this.clipboard=
700this.nullable=this.draggable=!0;this.selectable=!1;this.autofill=!0;this._applyStyle=function(){this.hovered?(this.style.headerBackgroundHoveredColor&&(this.element.style.backgroundColor=this.style.headerBackgroundHoveredColor),this.style.headerHoveredColor&&(this.element.style.color=this.style.headerHoveredColor)):this.selected?(this.style.headerBackgroundSelectedColor&&(this.element.style.backgroundColor=this.style.headerBackgroundSelectedColor),this.style.headerSelectedColor&&(this.element.style.color=
701this.style.headerSelectedColor)):(this.element.style.backgroundColor=this.style.headerBackgroun
701dColor?this.style.headerBackgroundColor:"",this.element.style.color=this.style.headerColor?this.style.headerColor:"")};this._applyCellStyle=function(f){var g=!1;if(f.length)for(g=0;g<f.length;g++)this._applyCellStyle(f[g]);else{if(this.style.backgroundColor||this.style.color||this.style.hoveredColor||this.style.hoveredColor||this.style.backgroundSelectedColor||this.style.selectedColor)g=!0;g&&(0<=f.className.indexOf("hover")?
702(this.style.backgroundHoveredColor&&(f.style.backgroundColor=this.style.backgroundHoveredColor),this.style.hoveredColor&&(f.style.color=this.style.hoveredColor)):0<=f.className.indexOf("selected")?(this.style.backgroundSelectedColor&&(f.style.backgroundColor=this.style.backgroundSelectedColor),this.style.selectedColor&&(f.style.color=this.style.selectedColor)):(this.style.backgroundColor&&(f.style.backgroundColor=this.style.backgroundColor),this.style.color&&(f.style.color=this.style.color)))}};this.style=
703{headerBackgroundColor:"",headerColor:"",headerBackgroundHoveredColor:"",headerHoveredColor:"",headerBackgroundSelectedColor:"",headerSelectedColor:"",backgroundColor:"",color:"",backgroundHoveredColor:"",hoveredColor:"",backgroundSelectedColor:"",selectedColor:""};this.enabletooltips=!0;this.columngroup=null;this.filterdelay=800;this.destroyeverpresentrowwidget=this.validateeverpresentrowwidgetvalue=this.initeverpresentrowwidget=this.createeverpresentrowwidget=this.geteverpresentrowwidgetvalue=this.reseteverpresentrowwidgetvalue=
704null;this.getcolumnproperties=function(){return{nullable:this.nullable,sortable:this.sortable,hideable:this.hideable,hidden:this.hidden,groupable:this.groupable,width:this.width,align:this.align,editable:this.editable,minwidth:this.minwidth,maxwidth:this.maxwidth,resizable:this.resizable,datafield:this.datafield,text:this.text,exportable:this.exportable,cellsalign:this.cellsalign,pinned:this.pinned,cellsformat:this.cellsformat,columntype:this.columntype,classname:this.classname,cellclassname:this.cellclassname,
705menu:this.menu}};this.setproperty=function(f,g){if(this[f]){var h=this[f];this[f]=g;this.owner._columnPropertyChanged(this,f,g,h)}else this[f.toLowerCase()]&&(h=this[f.toLowerCase()],this[f.toLowerCase()]=g,this.owner._columnPropertyChanged(this,f.toLowerCase(),g,h))};this._initfields=function(f){if(null!=f){var g=this.that;a.jqx.hasProperty(f,"dataField")&&(this.datafield=a.jqx.get(f,"dataField"));a.jqx.hasProperty(f,"selectable")&&(this.selectable=a.jqx.get(f,"selectable"));a.jqx.hasProperty(f,
706"displayField")?this.displayfield=a.jqx.get(f,"displayField"):this.displayfield=this.datafield;a.jqx.hasProperty(f,"enableTooltips")&&(this.enabletooltips=a.jqx.get(f,"enableTooltips"));a.jqx.hasProperty(f,"text")?this.text=a.jqx.get(f,"text"):this.text=this.displayfield;a.jqx.hasProperty(f,"style")&&(this.style=a.jqx.get(f,"style"));a.jqx.hasProperty(f,"createfilterpanel")&&(this.createfilterpanel=a.jqx.get(f,"createfilterpanel"));a.jqx.hasProperty(f,"sortable")&&(this.sortable=a.jqx.get(f,"sortable"));
707a.jqx.hasProperty(f,"hideable")&&(this.hideable=a.jqx.get(f,"hideable"));a.jqx.hasProperty(f,"hidden")&&(this.hidden=a.jqx.get(f,"hidden"));a.jqx.hasProperty(f,"adaptivehidden")&&(this.adaptivehidden=a.jqx.get(f,"adaptivehidden"));a.jqx.hasProperty(f,"groupable")&&(this.groupable=a.jqx.get(f,"groupable"));a.jqx.hasProperty(f,"renderer")&&(this.renderer=a.jqx.get(f,"renderer"));a.jqx.hasProperty(f,"align")&&(this.align=a.jqx.get(f,"align"));a.jqx.hasProperty(f,"cellsAlign")&&(this.cellsalign=a.jqx.get(f,
708"cellsAlign"));a.jqx.hasProperty(f,"clipboard")&&(this.clipboard=a.jqx.get(f,"clipboard"));a.jqx.hasProperty(f,"cellsFormat")&&(this.cellsformat=a.jqx.get(f,"cellsFormat"));a.jqx.hasProperty(f,"width")&&(this.width=a.jqx.get(f,"width"));a.jqx.hasProperty(f,"autofill")&&(this.autofill=a.jqx.get(f,"autofill"));a.jqx.hasProperty(f,"minWidth")&&(this.minwidth=parseInt(a.jqx.get(f,"minWidth")),isNaN(this.minwidth)&&(this.minwidth=25));a.jqx.hasProperty(f,"maxWidth")&&(this.maxwidth=parseInt(a.jqx.get(f,
709"maxWidth")),isNaN(this.maxwidth)&&(this.maxwidth="auto"));a.jqx.hasProperty(f,"cellsRenderer")?this.cellsrenderer=a.jqx.get(f,"cellsRenderer"):f.cellsRenderer&&(this.cellsrenderer=f.cellsRenderer);a.jqx.hasProperty(f,"columnType")&&(this.columntype=a.jqx.get(f,"columnType"));a.jqx.hasProperty(f,"checkChange")&&(this.checkchange=a.jqx.get(f,"checkChange"));a.jqx.hasProperty(f,"buttonClick")?this.buttonclick=a.jqx.get(f,"buttonClick"):f.buttonClick&&(this.buttonclick=f.buttonClick);a.jqx.hasProperty(f,
710"pinned")&&(this.pinned=a.jqx.get(f,"pinned"));a.jqx.hasProperty(f,"visibleIndex")&&(this.visibleindex=a.jqx.get(f,"visibleIndex"));a.jqx.hasProperty(f,"filterable")&&(this.filterable=a.jqx.get(f,"filterable"));a.jqx.hasProperty(f,"filter")&&(this.filter=a.jqx.get(f,"filter"));a.jqx.hasProperty(f,"resizable")&&(this.resizable=a.jqx.get(f,"resizable"));a.jqx.hasProperty(f,"editable")&&(this.editable=a.jqx.get(f,"editable"));a.jqx.hasProperty(f,"initEditor")?this.initeditor=a.jqx.get(f,"initEditor"):
711f.initEditor&&(this.initeditor=f.initEditor);a.jqx.hasProperty(f,"createEditor")?this.createeditor=a.jqx.get(f,"createEditor"):f.createEditor&&(this.createeditor=f.createEditor);a.jqx.hasProperty(f,"initWidget")?this.initwidget=a.jqx.get(f,"initWidget"):f.initWidget&&(this.initwidget=f.initWidget);a.jqx.hasProperty(f,"createWidget")?this.createwidget=a.jqx.get(f,"createWidget"):f.createWidget&&(this.createwidget=f.createWidget);a.jqx.hasProperty(f,"destroyWidget")?this.destroywidget=a.jqx.get(f,"destroyWidget"):
712f.destroyWidget&&(this.destroywidget=f.destroyWidget);a.jqx.hasProperty(f,"reseteverpresentrowwidgetvalue")||a.jqx.hasFunction(f,"reseteverpresentrowwidgetvalue")?this.reseteverpresentrowwidgetvalue=a.jqx.get(f,"reseteverpresentrowwidgetvalue"):f.resetEverPresentRowWidgetValue&&(this.reseteverpresentrowwidgetvalue=f.resetEverPresentRowWidgetValue);a.jqx.hasProperty(f,"geteverpresentrowwidgetvalue")||a.jqx.hasFunction(f,"geteverpresentrowwidgetvalue")?this.geteverpresentrowwidgetvalue=a.jqx.get(f,
713"geteverpresentrowwidgetvalue"):f.getEverPresentRowWidgetValue&&(this.geteverpresentrowwidgetvalue=f.getEverPresentRowWidgetValue);a.jqx.hasProperty(f,"createeverpresentrowwidget")||a.jqx.hasFunction(f,"createeverpresentrowwidget")?this.createeverpresentrowwidget=a.jqx.get(f,"createeverpresentrowwidget"):f.createEverPresentRowWidget&&(this.createeverpresentrowwidget=f.createEverPresentRowWidget);a.jqx.hasProperty(f,"initeverpresentrowwidget")||a.jqx.hasFunction(f,"initeverpresentrowwidget")?this.initeverpresentrowwidget=
714a.jqx.get(f,"initeverpresentrowwidget"):f.initEverPresentRowWidget&&(this.initeverpresentrowwidget=f.initEverPresentRowWidget);a.jqx.hasProperty(f,"validateeverpresentrowwidgetvalue")?this.validateeverpresentrowwidgetvalue=a.jqx.get(f,"validateeverpresentrowwidgetvalue"):f.validateEverPresentRowWidgetValue&&(this.validateeverpresentrowwidgetvalue=f.validateEverPresentRowWidgetValue);a.jqx.hasProperty(f,"destroyeverpresentrowwidget")||a.jqx.hasFunction(f,"destroyeverpresentrowwidget")?this.destroyeverpresentrowwidget=
715a.jqx.get(f,"destroyeverpresentrowwidget"):f.destroyEverPresentRowWidget&&(this.destroyEverPresentRowWidget=f.destroyEverPresentRowWidget);a.jqx.hasProperty(f,"destroyEditor")?this.destroyeditor=a.jqx.get(f,"destroyEditor"):f.destroyEditor&&(this.destroyeditor=f.destroyEditor);a.jqx.hasProperty(f,"getEditorValue")?this.geteditorvalue=a.jqx.get(f,"getEditorValue"):f.getEditorValue&&(this.geteditorvalue=f.getEditorValue);a.jqx.hasProperty(f,"validation")?this.validation=a.jqx.get(f,"validation"):f.validation&&
716(this.validation=f.validation);a.jqx.hasProperty(f,"cellBeginEdit")?this.cellbeginedit=a.jqx.get(f,"cellBeginEdit"):f.cellBeginEdit&&(this.cellbeginedit=f.cellBeginEdit);a.jqx.hasProperty(f,"cellEndEdit")?this.cellendedit=a.jqx.get(f,"cellEndEdit"):f.cellEndEdit&&(this.cellendedit=f.cellEndEdit);a.jqx.hasProperty(f,"className")&&(this.classname=a.jqx.get(f,"className"));a.jqx.hasProperty(f,"cellClassName")?this.cellclassname=a.jqx.get(f,"cellClassName"):f.cellClassName&&(this.cellclassname=f.cellClassName);
717a.jqx.hasProperty(f,"menu")&&(this.menu=a.jqx.get(f,"menu"));a.jqx.hasProperty(f,"aggregates")&&(this.aggregates=a.jqx.get(f,"aggregates"));a.jqx.hasProperty(f,"aggregatesRenderer")&&(this.aggregatesrenderer=a.jqx.get(f,"aggregatesRenderer"));a.jqx.hasProperty(f,"createFilterWidget")&&(this.createfilterwidget=a.jqx.get(f,"createFilterWidget"));a.jqx.hasProperty(f,"filterType")&&(this.filtertype=a.jqx.get(f,"filterType"));a.jqx.hasProperty(f,"filterDelay")&&(this.filterdelay=a.jqx.get(f,"filterDelay"));
718a.jqx.hasProperty(f,"rendered")&&(this.rendered=a.jqx.get(f,"rendered"));a.jqx.hasProperty(f,"exportable")&&(this.exportable=a.jqx.get(f,"exportable"));a.jqx.hasProperty(f,"filterItems")&&(this.filteritems=a.jqx.get(f,"filterItems"));a.jqx.hasProperty(f,"cellValueChanging")&&(this.cellvaluechanging=a.jqx.get(f,"cellValueChanging"));a.jqx.hasProperty(f,"draggable")&&(this.draggable=a.jqx.get(f,"draggable"));a.jqx.hasProperty(f,"filterCondition")&&(this.filtercondition=a.jqx.get(f,"filterCondition"));
719a.jqx.hasProperty(f,"threeStateCheckbox")&&(this.threestatecheckbox=a.jqx.get(f,"threeStateCheckbox"));
719a.jqx.hasProperty(f,"nullable")&&(this.nullable=a.jqx.get(f,"nullable"));a.jqx.hasProperty(f,"columnGroup")&&(this.columngroup=a.jqx.get(f,"columnGroup"));if(!f instanceof String&&"string"!=typeof f)for(var h in f)if(!g.hasOwnProperty(h)&&!g.hasOwnProperty(h.toLowerCase()))throw d.host.remove(),Error("jqxGrid: Invalid property name - "+h+".");}};this._initfields(e);return this}function c(d,e){this.setdata=
720function(f){null!=f&&(this.bounddata=f,this.boundindex=f.boundindex,this.visibleindex=f.visibleindex,this.group=f.group,this.parentbounddata=f.parentItem,this.uniqueid=f.uniqueid,this.level=f.level)};this.setdata(e);this.parentrow=null;this.subrows=[];this.owner=d;this.height=25;this.hidden=!1;this.rowdetails=null;this.rowdetailsheight=100;this.rowdetailshidden=!0;this.top=-1;this.setrowinfo=function(f){this.hidden=f.hidden;this.rowdetails=f.rowdetails;this.rowdetailsheight=f.rowdetailsheight;this.rowdetailshidden=
721!f.showdetails;this.height=f.height};return this}a.jqx.jqxWidget("jqxGrid","",{});a.extend(a.jqx._jqxGrid.prototype,{defineInstance:function(){var d={adaptive:!1,adaptivewidth:600,disabled:!1,width:600,height:400,pagerheight:40,groupsheaderheight:34,pagesize:10,pagesizeoptions:["5","10","20"],rowsheight:32,columnsheight:36,filterrowheight:36,groupindentwidth:30,rowdetails:!1,enablerowdetailsindent:!0,enablemousewheel:!0,initrowdetails:null,layoutrowdetails:null,editable:!1,editmode:"selectedcell",
722pageable:!1,pagermode:"default",pagerbuttonscount:5,groupable:!1,sortable:!1,sortmode:"one",filterable:!1,filtermode:"default",filterbarmode:"default",autoshowfiltericon:!0,showfiltercolumnbackground:!0,showpinnedcolumnbackground:!0,showsortcolumnbackground:!0,altrows:!1,altstart:1,altstep:1,showrowdetailscolumn:!0,showrowlines:!0,showcolumnlines:!0,showcolumnheaderlines:!0,showtoolbar:!1,showfilterbar:!1,toolbarheight:36,showstatusbar:!1,statusbarheight:36,enableellipsis:!0,groups:[],groupsrenderer:null,
723groupcolumnrenderer:null,groupsexpandedbydefault:!1,pagerrenderer:null,touchmode:"auto",columns:[],selectedrowindex:-1,selectedrowindexes:[],selectedcells:[],autobind:!0,selectedcell:null,tableZIndex:79,headerZIndex:29,updatefilterconditions:null,showgroupaggregates:!1,showaggregates:!1,showfilterrow:!1,showeverpresentrow:!1,everpresentrowposition:"top",everpresentrowactions:"add reset",everpresentrowactionsmode:"buttons",everpresentrowheight:30,autorowheight:!1,autokoupdates:!0,handlekeyboardnavigation:null,
724showsortmenuitems:!0,showfiltermenuitems:!0,showgroupmenuitems:!0,enablebrowserselection:!1,enablekeyboarddelete:!0,clipboard:!0,clipboardbegin:null,clipboardend:null,copytoclipboardwithheaders:!1,copytoclipboardhiddencolumns:!1,ready:null,updatefilterpanel:null,autogeneratecolumns:!1,rowdetailstemplate:null,scrollfeedback:null,rendertoolbar:null,renderstatusbar:null,rendered:null,multipleselectionbegins:null,columngroups:null,cellhover:null,source:{beforeprocessing:null,beforesend:null,loaderror:null,
725localdata:null,data:null,datatype:"array",datafields:[],url:"",root:"",record:"",id:"",totalrecords:0,recordstartindex:0,recordendindex:0,loadallrecords:!0,sortcolumn:null,sortdirection:null,sort:null,filter:null,sortcomparer:null},filter:null,dataview:null,updatedelay:null,autoheight:!1,autowidth:!1,showheader:!0,showgroupsheader:!0,closeablegroups:!0,scrollbarsize:a.jqx.utilities.scrollBarSize,touchscrollbarsize:a.jqx.utilities.touchScrollBarSize,scrollbarautoshow:a.jqx.utilities.scrollBarAutoShow,
726virtualmode:!1,sort:null,columnsmenu:!0,columnsresize:!1,columnsautoresize:!0,columnsreorder:!1,columnsmenuwidth:16,autoshowcolumnsmenubutton:!0,showcolumnsactionbutton:!1,popupwidth:"auto",popupheight:"auto",columnmenuopening:null,columnmenuclosing:null,sorttogglestates:2,rendergridrows:null,enableanimations:!0,enablecolumnsvirtualization:!0,enabletooltips:!1,selectionmode:"singlerow",autofill:!1,enableoptimization:!1,enablehover:!0,loadingerrormessage:"The data is still loading. When the data binding is completed, the Grid raises the 'bindingcomplete' event. Call this function in the 'bindingcomplete' event handler.",
727verticalscrollbarstep:30,verticalscrollbarlargestep:400,horizontalscrollbarstep:10,horizontalscrollbarlargestep:50,keyboardnavigation:!0,keyboardmenunavigation:!0,touchModeStyle:"auto",autoshowloadelement:!0,showdefaultloadelement:!0,showemptyrow:!0,autosavestate:!1,autoloadstate:!1,
727cardview:!1,cardviewcolumns:["20%","20%","20%","20%","20%"],cardheight:250,cardsize:3,_updating:!1,_pagescache:[],_pageviews:[],_cellscache:[],_rowdetailscache:[],_rowdetailselementscache:[],_requiresupdate:!1,_hasOpenedMenu:!1,
728scrollmode:"physical",deferreddatafields:null,localization:null,rtl:!1,menuitemsarray:[],charting:{appendTo:null,colorScheme:"scheme02",dialog:{header:"Data Visualization",height:400,width:400,position:"center",enabled:!0},ready:null,formatSettings:{}},events:"initialized rowClick rowSelect rowUnselect groupExpand groupCollapse sort columnClick cellClick pageChanged pageSizeChanged bindingComplete groupsChanged filter columnResized cellSelect cellUnselect cellBeginEdit cellEndEdit cellValueChanged rowExpand rowCollapse rowDoubleClick cellDoubleClick columnReordered pageChanging".split(" ")};
729if(this===a.jqx._jqxGrid.prototype)return d;a.extend(!0,this,d);return d},_applyThemeSettings:function(){if(this.isMaterialized()){var d=window.getComputedStyle(this.element),e=d.getPropertyValue("--jqx-grid-row-height"),f=d.getPropertyValue("--jqx-grid-column-height"),g=d.getPropertyValue("--jqx-grid-show-column-lines"),h=d.getPropertyValue("--jqx-grid-filter-menu-items-height");d=d.getPropertyValue("--jqx-scrollbar-size");e&&32===this.rowsheight&&!this.cardview&&(this.rowsheight=parseInt(e));f&&
73036===this.columnsheight&&(this.columnsheight=parseInt(f));g&&(this.showcolumnlines=this.showcolumnheaderlines=parseInt(g));this.filterMenuItemsHeight=h?parseInt(h):23;d&&(this.scrollbarsize=d,a.jqx.utilities.scrollBarSize=d)}},createInstance:function(d){this.that=this;this.pagesize=parseInt(this.pagesize);this.toolbarheight=parseInt(this.toolbarheight);this.columnsheight=parseInt(this.columnsheight);this.filterrowheight=parseInt(this.filterrowheight);this.statusbarheight=parseInt(this.statusbarheight);
731this.groupsheaderheight=parseInt(this.groupsheaderheight);
731this._undoRedo=[];this._undoRedoIndex=-1;this.cardview&&(this.__rowsheight=this.rowsheight,this.rowsheight=this.cardheight);this._applyThemeSettings();this.detailsVisibility=[];this.savedArgs=d&&0<d.length?d[0]:null;d="<div class='jqx-clear jqx-border-reset jqx-overflow-hidden jqx-max-size jqx-position-relative'><div tabindex='1' class='jqx-clear jqx-max-size jqx-position-relative jqx-overflow-hidden jqx-background-reset' id='wrapper"+this.element.id+
732"'><div class='jqx-clear jqx-position-absolute' id='toolbar' style='visibility: hidden;'></div><div class='jqx-clear jqx-position-absolute' id='groupsheader' style='visibility: hidden;'></div><div class='jqx-clear jqx-position-absolute' id='filter' style='visibility: hidden;'></div><div class='jqx-clear jqx-overflow-hidden jqx-position-absolute jqx-border-reset jqx-background-reset' id='content"+this.element.id+"'></div><div class='jqx-clear jqx-position-absolute' id='verticalScrollBar"+this.element.id+
733"'></div><div class='jqx-clear jqx-position-absolute' id='horizontalScrollBar"+this.element.id+"'></div><div class='jqx-clear jqx-position-absolute jqx-border-reset' id='bottomRight'></div><div class='jqx-clear jqx-position-absolute' id='addrow'></div><div class='jqx-clear jqx-position-absolute' id='statusbar'></div><div class='jqx-clear jqx-position-absolute' id='pager' style='z-index: 20;'></div></div></div>";this.element.innerHTML="";if(this.source){if(!this.source.dataBind){if(!a.jqx.dataAdapter)throw Error("jqxGrid: Missing reference to jqxdata.js");
734this.source=new a.jqx.dataAdapter(this.source)}var e=this.source._source.datafields;e&&0<e.length&&(this.editmode=this.editmode.toLowerCase(),this.selectionmode=this.selectionmode.toLowerCase())}this.host.attr("role","grid");this.host.attr("align","left");this.element.innerHTML=d;this.host.addClass(this.toTP("jqx-grid"));this.host.addClass(this.toTP("jqx-reset"));this.host.addClass(this.toTP("jqx-rc-all"));this.host.addClass(this.toTP("jqx-widget"));this.host.addClass(this.toTP("jqx-widget-content"));
735this.wrapper=this.host.find("#wrapper"+this.element.id);this.content=this.host.find("#content"+this.element.id);this.content.addClass(this.toTP("jqx-reset"));this.filterbar=this.host.find("#filter");this.filterbar[0].id="filter"+this.element.id;this.filterbar.addClass(this.toTP("jqx-widget-header"));this.filterbar.addClass(this.toTP("jqx-grid-toolbar"));d=this.host.find("#verticalScrollBar"+this.element.id);e=this.host.find("#horizontalScrollBar"+this.element.id);this.bottomRight=this.host.find("#bottomRight").addClass(this.toTP("jqx-grid-bottomright jqx-scrollbar-state-normal"));
736if(!d.jqxScrollBar)throw Error("jqxGrid: Missing reference to jqxscrollbar.js");this.editors=[];this.vScrollBar=d.jqxScrollBar({vertical:!0,rtl:this.rtl,touchMode:this.touchmode,step:this.verticalscrollbarstep,largestep:this.verticalscrollbarlargestep,theme:this.theme,_triggervaluechanged:!1});this.hScrollBar=e.jqxScrollBar({vertical:!1,rtl:this.rtl,touchMode:this.touchmode,step:this.horizontalscrollbarstep,largestep:this.horizontalscrollbarlargestep,theme:this.theme,_triggervaluechanged:!1});this.addnewrow=
737this.host.find("#addrow");this.addnewrow[0].id="addrow"+this.element.id;this.addnewrow.addClass(this.toTP("jqx-widget-header"));this.pager=this.host.find("#pager");this.pager[0].id="pager"+this.element.id;this.toolbar=this.host.find("#toolbar");this.toolbar[0].id="toolbar"+this.element.id;this.toolbar.addClass(this.toTP("jqx-grid-toolbar"));this.toolbar.addClass(this.toTP("jqx-widget-header"));this.statusbar=this.host.find("#statusbar");this.statusbar[0].id="statusbar"+this.element.id;this.statusbar.addClass(this.toTP("jqx-grid-statusbar"));
738this.statusbar.addClass(this.toTP("jqx-widget-header"));this.pager.addClass(this.toTP("jqx-grid-pager"));this.pager.addClass(this.toTP("jqx-widget-header"));this.groupsheader=this.host.find("#groupsheader");this.groupsheader.addClass(this.toTP("jqx-grid-groups-header"));this.groupsheader.addClass(this.toTP("jqx-widget-header"));this.groupsheader[0].id="groupsheader"+this.element.id;this.vScrollBar.css("visibility","hidden");this.hScrollBar.css("visibility","hidden");this.vScrollInstance=a.data(this.vScrollBar[0],
739"jqxScrollBar").instance;this.hScrollInstance=a.data(this.hScrollBar[0],"jqxScrollBar").instance;this.gridtable=null;this.isNestedGrid=this.host.parent()?299==this.host.parent().css("z-index"):!1;this.touchdevice=this.isTouchDevice();this.localizestrings&&(this.localizestrings(),null!=this.localization&&this.localizestrings(this.localization,!1));
739this.rowdetailstemplate&&"function"!==typeof this.rowdetailstemplate&&(void 0==this.rowdetailstemplate.rowdetails&&(this.rowdetailstemplate.rowdetails="<div></div>"),
740void 0==this.rowdetailstemplate.rowdetailsheight&&(this.rowdetailstemplate.rowdetailsheight=200),void 0==this.rowdetailstemplate.rowdetailshidden&&(this.rowdetailstemplate.rowdetailshidden=!0));if(this.showfilterrow&&!this.filterable)throw Error('jqxGrid: "showfilterrow" requires setting the "filterable" property to true!');if(!this.autorowheight||this.autoheight||this.pageable){if(this.virtualmode&&null==this.rendergridrows)throw Error('jqxGrid: "virtualmode" requires setting the "rendergridrows"!');
741if(this.virtualmode&&!this.pageable&&this.groupable)throw Error('jqxGrid: "grouping" in "virtualmode" without paging is not supported!');if(!this._testmodules()){this._builddataloadelement();(this._cachedcolumns=this.columns)&&this.columns.length>this.headerZIndex&&(this.headerZIndex=this.columns.length+100);if(this.theme&&0<=this.theme.indexOf("material")){e=a("<span>Test</span>");d=a("<span>Test</span>");e.addClass(this.toTP("jqx-grid-row-cell"));d.addClass(this.toTP("jqx-grid-column-header-cell"));
742this.host.append(e);this.host.append(d);var f=e.outerHeight(),g=d.outerHeight();f>this.rowsheight&&(this._cellheight=this.rowsheight=f);g>this.columnsheight&&(this._columnHeight=this.columnsheight=g);e.remove();d.remove()}31!=this.rowsheight&&this._measureElement("cell");(32!=this.columnsheight||this.columngroups)&&this._measureElement("column");if(this.source&&(e=this.source.datafields,null==e&&this.source._source&&(e=this.source._source.datafields),e))for(f=0;f<this.columns.length;f++)if((d=this.columns[f])&&
743d.cellsformat&&2<d.cellsformat.length)for(g=0;g<e.length;g++)if(e[g].name==d.datafield&&!e[g].format){e[g].format=d.cellsformat;break}this.databind(this.source);this.showtoolbar&&this.toolbar.css("visibility","inherit");this.showfilterbar&&this.filterbar.css("visibility","inherit");this.showstatusbar&&this.statusbar.css("visibility","inherit");this._arrange();this.pageable&&this._initpager&&this._initpager();this.tableheight=null;var h=this.that,k=function(){h.content&&(h.content[0].scrollTop=0,h.content[0].scrollLeft=
7440);h.gridcontent&&(h.gridcontent[0].scrollLeft=0,h.gridcontent[0].scrollTop=0)};this.addHandler(this.content,"mousedown",function(){k()});this.addHandler(this.content,"scroll",function(l){k();return!1});this.showfilterrow||(this.showstatusbar||this.showtoolbar||this.host.addClass("jqx-disableselect"),this.content.addClass("jqx-disableselect"));this.enablebrowserselection&&(this.content.removeClass("jqx-disableselect"),this.host.removeClass("jqx-disableselect"));this._resizeWindow();this.disabled&&
745this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled"));this.hasTransform=a.jqx.utilities.hasTransform(this.host);"logical"==this.scrollmode&&(this.vScrollInstance.thumbStep=this.rowsheight,this.vScrollInstance.step=this.rowsheight);a.jqx.isHidden(this.host)||(this.filterable||this.groupable||this.sortable)&&this._initmenu()}}else throw Error('jqxGrid: "autorowheight" requires setting the "autoheight" or "pageable" property to true!');},_resizeWindow:function(){var d=this.that;if(null!=
746this.width&&-1!=this.width.toString().indexOf("%")||null!=this.height&&-1!=this.height.toString().indexOf("%")){this._updatesizeonwindowresize=!0;a.jqx.utilities.resize(this.host,function(g){var h=a(window).width(),k=a(window).height(),l=d.host.width(),m=d.host.height();if(d.pageable){var n=d.host.find(".jqx-grid-pager-input");350>h?n.hide():n.show()}d.autoheight&&(d._lastHostWidth=k);if(d._lastHostWidth!=l||d._lastHostHeight!=m){if(d.touchdevice&&d.editcell&&"orientationchange"!==g)return;d._updatesize(d._lastHostWidth!=
747l,d._lastHostHeight!=m)}d._lastWidth=h;d._lastHeight=k;d._lastHostWidth=l;d._lastHostHeight=m});var e=d.host.width(),f=d.host.height();d._lastHostWidth=e;d._lastHostHeight=f}},_builddataloadelement:function(){this.dataloadelement&&this.dataloadelement.remove();this.dataloadelement=a('<div style="overflow: hidden; position: absolute;"></div>');if(this.showdefaultloadelement){var d=a('<div style="z-index: 99; margin-left: -66px; left: 50%; top: 50%; margin-top: -24px; position: relative; width: 100px; height: 33px; padding: 5px; font-family: verdana; font-size: 12px; color: #767676; border-color: #898989; border-width: 1px; border-style: solid; background: #f6f6f6; border-collapse: collapse;"><div style="float: left;"><div style="float: left; overflow: hidden; width: 32px; height: 32px;" class="jqx-grid-load"/><span style="margin-top: 10px; float: left; display: block; margin-left: 5px;" >'+
748this.gridlocalization.loadtext+"</span></div></div>");d.addClass(this.toTP("jqx-rc-all"));this.dataloadelement.addClass(this.toTP("jqx-rc-all"));d.addClass(this.toTP("jqx-fill-state-normal"));this.dataloadelement.append(d)}else this.dataloadelement.addClass(this.toTP("jqx-grid-load"));this.dataloadelement.width(this.host.width());this.dataloadelement.height(this.host.height());this.wrapper.prepend(this.dataloadelement)}
748,_measureElement:function(d){var e=a("<span style='visibility: hidden; white-space: nowrap;'>measure Text</span>");
749e.addClass(this.toTP("jqx-widget"));a(document.body).append(e);"cell"==d?this._cellheight=e.height():this._columnheight=e.height();e.remove()},_measureMenuElement:function(){var d=a("<span style='visibility: hidden; white-space: nowrap;'>measure Text</span>");d.addClass(this.toTP("jqx-widget"));d.addClass(this.toTP("jqx-menu"));d.addClass(this.toTP("jqx-menu-item-top"));d.addClass(this.toTP("jqx-fill-state-normal"));this.isTouchDevice()&&d.addClass(this.toTP("jqx-grid-menu-item-touch"));a(document.body).append(d);
750var e=d.outerHeight();"light"!==this.theme&&"dark"!==this.theme||this._isIE10()||(e+=10,36<e&&(e=36));d.remove();return e},_measureElementWidth:function(d){d=a("<span style='visibility: hidden; white-space: nowrap;'>"+d+"</span>");d.addClass(this.toTP("jqx-widget"));d.addClass(this.toTP("jqx-grid"));d.addClass(this.toTP("jqx-grid-column-header"));d.addClass(this.toTP("jqx-widget-header"));a(document.body).append(d);var e=d.outerWidth()+20;d.remove();return e},_getBodyOffset:function(){var d=0,e=0;
751"0px"!=a("body").css("border-top-width")&&(d=parseInt(a("body").css("border-top-width")),isNaN(d)&&(d=0));"0px"!=a("body").css("border-left-width")&&(e=parseInt(a("body").css("border-left-width")),isNaN(e)&&(e=0));return{left:e,top:d}},_testmodules:function(){var d="",e=this.that,f=function(){""!=d.length&&(d+=",")};this.columnsmenu&&!this.host.jqxMenu&&(this.sortable||this.groupable||this.filterable)&&(f(),d+=" jqxmenu.js");this.host.jqxScrollBar||(f(),d+=" jqxscrollbar.js");this.host.jqxButton||
752(f(),d+=" jqxbuttons.js");a.jqx.dataAdapter||(f(),d+=" jqxdata.js");this.pageable&&!this.gotopage&&(f(),d+="jqxgrid.pager.js");this.filterable&&!this.applyfilters&&(f(),d+=" jqxgrid.filter.js");this.groupable&&!this._initgroupsheader&&(f(),d+=" jqxgrid.grouping.js");this.columnsresize&&!this.autoresizecolumns&&(f(),d+=" jqxgrid.columnsresize.js");this.columnsreorder&&!this.setcolumnindex&&(f(),d+=" jqxgrid.columnsreorder.js");this.sortable&&!this.sortby&&(f(),d+=" jqxgrid.sort.js");this.editable&&
753!this.begincelledit&&(f(),d+=" jqxgrid.edit.js");this.showaggregates&&!this.getcolumnaggregateddata&&(f(),d+=" jqxgrid.aggregates.js");this.keyboardnavigation&&!this.selectrow&&(f(),d+=" jqxgrid.selection.js");if(""!=d||this.editable||this.filterable||this.pageable){var g=[],h=function(m){switch(m){case "checkbox":e.host.jqxCheckBox||g.checkbox||(g.checkbox=!0,f(),d+=" jqxcheckbox.js");break;case "numberinput":e.host.jqxNumberInput||g.numberinput||(g.numberinput=!0,f(),d+=" jqxnumberinput.js");break;
754case "datetimeinput":e.host.jqxDateTimeInput||g.datetimeinput?e.host.jqxCalendar||g.calendar||(f(),d+=" jqxcalendar.js"):(f(),g.datetimeinput=!0,d+=" jqxdatetimeinput.js(requires: jqxcalendar.js)");break;case "combobox":e.host.jqxComboBox||g.combobox?e.host.jqxListBox||g.listbox||(f(),g.listbox=!0,d+=" jqxlistbox.js"):(f(),g.combobox=!0,d+=" jqxcombobox.js(requires: jqxlistbox.js)");break;case "dropdownlist":e.host.jqxDropDownList||g.dropdownlist?e.host.jqxListBox||g.listbox||(f(),g.listbox=!0,d+=
755" jqxlistbox.js"):(f(),g.dropdownlist=!0,d+=" jqxdropdownlist.js(requires: jqxlistbox.js)")}};(this.filterable||this.pageable)&&h("dropdownlist");for(var k=0;k<this.columns.length;k++)if(void 0!=this.columns[k]){var l=this.columns[k].columntype;h(l);this.filterable&&this.showfilterrow&&(l=this.columns[k].filtertype,"checkedlist"!=l&&"bool"!=l||h("checkbox"),"date"==l&&h("datetimeinput"))}if(""!=d)throw Error("jqxGrid: Missing references to the following module(s): "+d);}return!1},focus:function(){try{this.wrapper.focus();
756var d=this.that;setTimeout(function(){d.wrapper.focus()},25);this.focused=!0}catch(e){}},hiddenParent:function(){return a.jqx.isHidden(this.host)},resize:function(d,e){this.width=d;this.height=e;this._updatesize(!0,!0)},_updatesize:function(d,e){if(!this._loading){var f=this.that;f._newmax=null;var g=f.host.width(),h=f.host.height();f._oldWidth||(f._oldWidth=g);f._oldHeight||(f._oldHeight=h);f._resizeTimer&&clearTimeout(f._resizeTimer);f.resizingGrid=!0;if(!a.jqx.isHidden(f.host)){f.editcell&&(f.endcelledit(f.editcell.row,
757f.editcell.column,!0,!0),f._oldselectedcell=null);if(h!=f._oldHeight||1==e){var k=f.groupable&&0<f.groups.length,l=f.vScrollBar.css("visibility");if(!f.autoheight){f.virtualmode&&(f._pageviews=[]);
757if(k||f.rowdetails||f.pageable){f._arrange();f.prerenderrequired=!0;h=Math.round(f.host.height())+2*f.rowsheight;f._gettableheight();k=Math.round(h/f.rowsheight);var m=Math.max(f.dataview.totalrows,f.dataview.totalrecords);f.pageable&&(m=f.pagesize,f.pagesize>Math.max(f.dataview.totalrows,f.dataview.totalrecords)&&
758f.autoheight?m=Math.max(f.dataview.totalrows,f.dataview.totalrecords):f.autoheight||f.dataview.totalrows<f.pagesize&&(m=Math.max(f.dataview.totalrows,f.dataview.totalrecords)));f._getpagesize();!f.pageable&&f.autoheight&&(k=m);f.virtualsizeinfo&&(f.virtualsizeinfo.visiblerecords=k);f.rendergridcontent(!0,!1);f._renderrows(f.virtualsizeinfo)}else f._arrange(),f.virtualsizeinfo=f._calculatevirtualheight(),h=Math.round(f.host.height())+2*f.rowsheight,parseInt(h)>=parseInt(f._oldHeight)&&(f.prerenderrequired=
759!0),f._renderrows(f.virtualsizeinfo),f.rtl&&(f._updatecolumnwidths(),f.table&&f.table.width(f.columnsheader.width()),f._updatecellwidths());l!=f.vScrollBar.css("visibility")&&(f.vScrollInstance.setPosition(0),f._arrange(),f._updatecolumnwidths(),f.table&&f.table.width(f.columnsheader.width()),f._updatecellwidths())}}if(g!=f._oldWidth||1==d){l=!1;if(f.editcell&&f.editcell.editor)switch(f.editcell.columntype){case "dropdownlist":if(l=f.editcell.editor.jqxDropDownList("isOpened")||f.editcell.editor.jqxDropDownList("isanimating")&&
760!f.editcell.editor.jqxDropDownList("ishiding")){f.editcell.editor.jqxDropDownList({openDelay:0});f.editcell.editor.jqxDropDownList("open");f.editcell.editor.jqxDropDownList({openDelay:250});return}break;case "combobox":if(l=f.editcell.editor.jqxComboBox("isOpened")||f.editcell.editor.jqxComboBox("isanimating")&&!f.editcell.editor.jqxComboBox("ishiding")){f.editcell.editor.jqxComboBox({openDelay:0});f.editcell.editor.jqxComboBox("open");f.editcell.editor.jqxComboBox({openDelay:250});return}break;case "datetimeinput":if(l){l=
761f.editcell.editor.jqxDateTimeInput("isOpened")||f.editcell.editor.jqxDateTimeInput("isanimating")&&!f.editcell.editor.jqxDateTimeInput("ishiding");f.editcell.editor.jqxDateTimeInput({openDelay:0});f.editcell.editor.jqxDateTimeInput("open");f.editcell.editor.jqxDateTimeInput({openDelay:250});return}}l=f.hScrollBar.css("visibility");f._arrange();f._updatecolumnwidths();f.table&&f.table.width(f.columnsheader.width());f._updatecellwidths();0==d&&f._oldWidth>g||e&&0!=f.dataview.rows.length||f._renderrows(f.virtualsizeinfo);
762l!=f.hScrollBar.css("visibility")&&f.hScrollInstance.setPosition(0);if(f.adaptive&&f.element.offsetWidth<=f.adaptivewidth){var n=0,r=f.element.offsetWidth-2;a.each(f.columns.records,function(t,u){n+=this.width;if("adaptive"===this.columntype)return!0;n>=r&&(this.adaptivehidden=!0)});f._updatecolumnwidths();f._updatecellwidths();f._renderrows(f.virtualsizeinfo)}else f.adaptive&&(a.each(f.columns.records,function(t,u){if("adaptive"===this.columntype)return!0;this.adaptivehidden=!1;delete this.adaptivewidth}),
763f._updatecolumnwidths(),f._updatecellwidths(),f._renderrows(f.virtualsizeinfo))}f._oldWidth=g;f._oldHeight=h;f.resizingGrid=!1}}},getTouches:function(d){return a.jqx.mobile.getTouches(d)},_updateTouchScrolling:function(){var d=this.that;if(d.isTouchDevice()){d.scrollmode="logical";d.vScrollInstance.thumbStep=d.rowsheight;var e=a.jqx.mobile.getTouchEventName("touchstart"),f=a.jqx.mobile.getTouchEventName("touchend"),g=a.jqx.mobile.getTouchEventName("touchmove");d.enablehover=!1;d.gridcontent&&(d.removeHandler(d.gridcontent,
764e+".touchScroll"),d.removeHandler(d.gridcontent,g+".touchScroll"),d.removeHandler(d.gridcontent,f+".touchScroll"),d.removeHandler(d.gridcontent,"touchcancel.touchScroll"),a.jqx.mobile.touchScroll(d.gridcontent[0],d.vScrollInstance.max,function(h,k){null!=k&&"visible"==d.vScrollBar.css("visibility")&&d.vScrollInstance.setPosition(k);null!=h&&"visible"==d.hScrollBar.css("visibility")&&d.hScrollInstance.setPosition(h);d.vScrollInstance.thumbCapture=!0;d._lastScroll=new Date},this.element.id,this.hScrollBar,
765this.vScrollBar),d._overlayElement&&(d.removeHandler(d._overlayElement,e+".touchScroll"),d.removeHandler(d._overlayElement,g+".touchScroll"),d.removeHandler(d._overlayElement,f+".touchScroll"),d.removeHandler(d._overlayElement,"touchcancel.touchScroll"),a.jqx.mobile.touchScroll(d._overlayElement[0],d.vScrollInstance.max,function(h,k){null!=k&&"visible"==d.vScrollBar.css("visibility")&&d.vScrollInstance.setPosition(k);null!=h&&"visible"==d.hScrollBar.css("visibility")&&d.hScrollInstance.setPosition(h);
766d.vScrollInstance.thumbCapture=!0;
766d._lastScroll=new Date},this.element.id,this.hScrollBar,this.vScrollBar),this.addHandler(this.host,e,function(){d.editcell?d._overlayElement.css("visibility","hidden"):d._overlayElement.css("visibility","visible")}),this.addHandler(this.host,f,function(){d.editcell?d._overlayElement.css("visibility","hidden"):d._overlayElement.css("visibility","visible")})))}},_rendercelltexts:function(){},isTouchDevice:function(){if(void 0!=this.touchDevice)return this.touchDevice;
767var d=a.jqx.mobile.isTouchDevice();this.touchDevice=d;if(1==this.touchmode){if(a.jqx.browser.msie&&9>a.jqx.browser.version)return this.enablehover=!1;d=!0;a.jqx.mobile.setMobileSimulator(this.element);this.touchDevice=d}else 0==this.touchmode&&(d=!1);d&&0!=this.touchModeStyle&&(this.touchDevice=!0,this.host.addClass(this.toThemeProperty("jqx-touch")),this.host.find("jqx-widget-content").addClass(this.toThemeProperty("jqx-touch")),this.host.find("jqx-widget-header").addClass(this.toThemeProperty("jqx-touch")),
768this.scrollbarsize=this.touchscrollbarsize);return d},toTP:function(d){return this.toThemeProperty(d)},localizestrings:function(d,e){this._cellscache=[];a.jqx.dataFormat&&a.jqx.dataFormat.cleardatescache();if(this._loading)throw Error("jqxGrid: "+this.loadingerrormessage);if(null!=d){for(var f in d)f.toLowerCase()!==f&&(d[f.toLowerCase()]=d[f]);d.okstring&&(this.gridlocalization.okstring=d.okstring);d.cancelstring&&(this.gridlocalization.cancelstring=d.cancelstring);d.pagergotopagestring&&(this.gridlocalization.pagergotopagestring=
769d.pagergotopagestring);d.pagershowrowsstring&&(this.gridlocalization.pagershowrowsstring=d.pagershowrowsstring);d.pagerrangestring&&(this.gridlocalization.pagerrangestring=d.pagerrangestring);d.pagernextbuttonstring&&(this.gridlocalization.pagernextbuttonstring=d.pagernextbuttonstring);d.pagerpreviousbuttonstring&&(this.gridlocalization.pagerpreviousbuttonstring=d.pagerpreviousbuttonstring);d.pagerfirstbuttonstring&&(this.gridlocalization.pagerfirstbuttonstring=d.pagerfirstbuttonstring);d.pagerlastbuttonstring&&
770(this.gridlocalization.pagerlastbuttonstring=d.pagerlastbuttonstring);d.groupsheaderstring&&(this.gridlocalization.groupsheaderstring=d.groupsheaderstring);d.sortascendingstring&&(this.gridlocalization.sortascendingstring=d.sortascendingstring);d.sortdescendingstring&&(this.gridlocalization.sortdescendingstring=d.sortdescendingstring);d.sortremovestring&&(this.gridlocalization.sortremovestring=d.sortremovestring);d.groupbystring&&(this.gridlocalization.groupbystring=d.groupbystring);d.groupremovestring&&
771(this.gridlocalization.groupremovestring=d.groupremovestring);d.firstDay&&(this.gridlocalization.firstDay=d.firstDay);d.days&&(this.gridlocalization.days=d.days);d.months&&(this.gridlocalization.months=d.months);d.AM&&(this.gridlocalization.AM=d.AM);d.PM&&(this.gridlocalization.PM=d.PM);d.patterns&&(this.gridlocalization.patterns=d.patterns);d.percentsymbol&&(this.gridlocalization.percentsymbol=d.percentsymbol);d.currencysymbol&&(this.gridlocalization.currencysymbol=d.currencysymbol);d.currencysymbolposition&&
772(this.gridlocalization.currencysymbolposition=d.currencysymbolposition);void 0!=d.decimalseparator&&(this.gridlocalization.decimalseparator=d.decimalseparator);void 0!=d.thousandsseparator&&(this.gridlocalization.thousandsseparator=d.thousandsseparator);d.filterclearstring&&(this.gridlocalization.filterclearstring=d.filterclearstring);d.filterstring&&(this.gridlocalization.filterstring=d.filterstring);d.filtershowrowstring&&(this.gridlocalization.filtershowrowstring=d.filtershowrowstring);d.filtershowrowdatestring&&
773(this.gridlocalization.filtershowrowdatestring=d.filtershowrowdatestring);d.filterselectallstring&&(this.gridlocalization.filterselectallstring=d.filterselectallstring);d.filterchoosestring&&(this.gridlocalization.filterchoosestring=d.filterchoosestring);d.filterorconditionstring&&(this.gridlocalization.filterorconditionstring=d.filterorconditionstring);d.filterandconditionstring&&(this.gridlocalization.filterandconditionstring=d.filterandconditionstring);d.filterstringcomparisonoperators&&(this.gridlocalization.filterstringcomparisonoperators=
774d.filterstringcomparisonoperators);d.filternumericcomparisonoperators&&(this.gridlocalization.filternumericcomparisonoperators=d.filternumericcomparisonoperators);
774d.filterdatecomparisonoperators&&(this.gridlocalization.filterdatecomparisonoperators=d.filterdatecomparisonoperators);d.filterbooleancomparisonoperators&&(this.gridlocalization.filterbooleancomparisonoperators=d.filterbooleancomparisonoperators);d.emptydatastring&&(this.gridlocalization.emptydatastring=d.emptydatastring);d.filterselectstring&&
775(this.gridlocalization.filterselectstring=d.filterselectstring);d.todaystring&&(this.gridlocalization.todaystring=d.todaystring);d.clearstring&&(this.gridlocalization.clearstring=d.clearstring);d.validationstring&&(this.gridlocalization.validationstring=d.validationstring);d.loadtext&&(this.gridlocalization.loadtext=d.loadtext);d.addrowstring&&(this.gridlocalization.addrowstring=d.addrowstring);d.udpaterowstring&&(this.gridlocalization.udpaterowstring=d.udpaterowstring);d.deleterowstring&&(this.gridlocalization.deleterowstring=
776d.deleterowstring);d.resetrowstring&&(this.gridlocalization.resetrowstring=d.resetrowstring);d.everpresentrowplaceholder&&(this.gridlocalization.everpresentrowplaceholder=d.everpresentrowplaceholder);if(!1!==e){this._initpager&&this._initpager();this._initgroupsheader&&this._initgroupsheader();this._initmenu&&this._initmenu();this._builddataloadelement();a(this.dataloadelement).css("visibility","hidden");a(this.dataloadelement).css("display","none");if(this.filterable&&this.showfilterrow&&this._updatefilterrow){for(f in this._filterrowcache)a(this._filterrowcache[f]).remove();
777this._filterrowcache=[];this._updatefilterrow()}this.showaggregates&&this.refresheaggregates&&this.refresheaggregates();this._renderrows(this.virtualsizeinfo)}}else this.gridlocalization={"/":"/",":":":",firstDay:0,days:{names:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),namesAbbr:"Sun Mon Tue Wed Thu Fri Sat".split(" "),namesShort:"Su Mo Tu We Th Fr Sa".split(" ")},months:{names:"January February March April May June July August September October November December ".split(" "),
778namesAbbr:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ".split(" ")},AM:["AM","am","AM"],PM:["PM","pm","PM"],eras:[{name:"A.D.",start:null,offset:0}],twoDigitYearMax:2029,patterns:{d:"M/d/yyyy",D:"dddd, MMMM dd, yyyy",t:"h:mm tt",T:"h:mm:ss tt",f:"dddd, MMMM dd, yyyy h:mm tt",F:"dddd, MMMM dd, yyyy h:mm:ss tt",M:"MMMM dd",Y:"yyyy MMMM",S:"yyyy'-'MM'-'dd'T'HH':'mm':'ss",ISO:"yyyy-MM-dd hh:mm:ss",ISO2:"yyyy-MM-dd HH:mm:ss",d1:"dd.MM.yyyy",d2:"dd-MM-yyyy",d3:"dd-MMMM-yyyy",d4:"dd-MM-yy",d5:"H:mm",
779d6:"HH:mm",d7:"HH:mm tt",d8:"dd/MMMM/yyyy",d9:"MMMM-dd",d10:"MM-dd",d11:"MM-dd-yyyy"},percentsymbol:"%",currencysymbol:"$",currencysymbolposition:"before",decimalseparator:".",thousandsseparator:",",pagergotopagestring:"Go to page:",pagershowrowsstring:"Show rows:",pagerrangestring:" of ",pagerpreviousbuttonstring:"previous",pagernextbuttonstring:"next",pagerfirstbuttonstring:"first",pagerlastbuttonstring:"last",groupsheaderstring:"Drag a column and drop it here to group by that column",sortascendingstring:"Sort Ascending",
780sortdescendingstring:"Sort Descending",sortremovestring:"Remove Sort",groupbystring:"Group By this column",groupremovestring:"Remove from groups",filterclearstring:"Clear",filtersearchstring:"Search:",filterstring:"Filter",filtershowrowstring:"Show rows where:",filtershowrowdatestring:"Show rows where date:",filterorconditionstring:"Or",filterandconditionstring:"And",filterselectallstring:"(Select All)",filterchoosestring:"Please Choose:",filterstringcomparisonoperators:"empty;not empty;contains;contains(match case);does not contain;does not contain(match case);starts with;starts with(match case);ends with;ends with(match case);equal;equal(match case);null;not null".split(";"),
781filternumericcomparisonoperators:"equal;not equal;less than;less than or equal;greater than;greater than or equal;null;not null".split(";"),filterdatecomparisonoperators:"equal;not equal;less than;less than or equal;greater than;greater than or equal;null;not null".split(";"),filterbooleancomparisonoperators:["equal","not equal"],validationstring:"Entered value is not valid",emptydatastring:"No data to display",filterselectstring:"Select Filter",loadtext:"Loading...",clearstring:"Clear",todaystring:"Today",
782addrowstring:"Add",udpaterowstring:"Update",deleterowstring:"Delete",resetrowstring:"Reset",everpresentrowplaceholder:"Enter ",okstring:"Ok",cancelstring:"Cancel"}},_getmenudefaultheight:function(){var d=0;this.sortable&&this._togglesort&&this.showsortmenuitems&&(d=3);this.groupable&&this._initgroupsheader&&this.showgroupmenuitems&&(d+=2);var e=this._measureMenuElement();d=d*e+9;this.filterable&&!this.showfilterrow&&this.showfiltermenuitems&&(d+=224,a.jqx.browser.msie&&8>a.jqx.browser.version&&(d+=
78320));return d},_initmenu:function(){var d=this.that;if(this.host.jqxMenu){if(this.gridmenu){if(this._hasOpenedMenu)return;this.filterable&&this._destroyfilterpanel&&this._destroyfilterpanel();this.removeHandler(this.gridmenu,"keydown");this.removeHandler(this.gridmenu,"closed");this.removeHandler(this.gridmenu,"itemclick");this.gridmenu.jqxMenu("destroy");this.gridmenu.removeData();this.gridmenu.remove()}this.menuitemsarray=[];var e="";this.isTouchDevice()&&(e="jqx-grid-menu-item-touch");this.gridmenu=
784a('<div tabindex=0 id="gridmenu'+this.element.id+'" style="z-index: 99;"></div>');this.host.append(this.gridmenu);var f=a("<ul></ul>"),g=a('<li class="'+e+'"><div class="jqx-grid-sortasc-icon"></div>'+this.gridlocalization.sortascendingstring+"</li>"),h=a('<li class="'+e+'"><div class="jqx-grid-sortdesc-icon"></div>'+this.gridlocalization.sortdescendingstring+"</li>"),k=a('<li class="'+e+'"><div class="jqx-grid-sortremove-icon"></div>'+this.gridlocalization.sortremovestring+"</li>"),l=a('<li class="'+
785e+'"><div class="jqx-grid-groupby-icon"></div>'+this.gridlocalization.groupbystring+"</li>"),m=a('<li class="'+e+'"><div class="jqx-grid-groupby-icon"></div>'+this.gridlocalization.groupremovestring+"</li>"),n=a('<li type="separator"></li>'),r=a('<li class="filter '+e+'" style="height: 224px;" ignoretheme="true"><div class="filter"></div></li>');this.gridmenu.addClass("jqx-grid-menu");e=this.gridlocalization.sortascendingstring.length;var t=this.gridlocalization.sortascendingstring;this.gridlocalization.sortdescendingstring.length>
786e&&(e=this.gridlocalization.sortdescendingstring.length,t=this.gridlocalization.sortdescendingstring);this.gridlocalization.sortremovestring.length>e&&(e=this.gridlocalization.sortremovestring.length,t=this.gridlocalization.sortremovestring);this.groupable&&this._initgroupsheader&&this.showgroupmenuitems&&(this.gridlocalization.groupbystring.length>e&&(e=this.gridlocalization.groupbystring.length,t=this.gridlocalization.groupbystring),this.gridlocalization.groupremovestring.length>e&&(e=this.gridlocalization.groupremovestring.length,
787t=this.gridlocalization.groupremovestring));e=200;t=a.trim(t).replace(/&nbsp;/ig,"").replace(/&#160;/ig,"");t=a("<span>"+t+"</span>");t.addClass(this.toThemeProperty("jqx-menu-item"));this.host.append(t);e=t.outerWidth()+60;t.remove();t=0;this.sortable&&this._togglesort&&this.showsortmenuitems&&(f.append(g),this.menuitemsarray[0]=g[0],f.append(h),this.menuitemsarray[1]=h[0],f.append(k),this.menuitemsarray[2]=k[0],t=3);this.groupable&&this._initgroupsheader&&this.showgroupmenuitems&&(f.append(l),this.menuitemsarray[3]=
788l[0],f.append(m),this.menuitemsarray[4]=m[0],t+=2);var u=this._measureMenuElement();t=t*u+9;u=!0;if(this.filterable&&!this.showfilterrow&&this.showfiltermenuitems)if(this._initfilterpanel)this.menuitemsarray[5]=r[0],this.menuitemsarray[6]=r[0],f.append(n),f.append(r),t+=220,a.jqx.browser.msie&&8>a.jqx.browser.version&&(t+=20),this.isTouchDevice()&&(t+=30),n=a(r).find("div:first"),this.excelfilterpanel=a("<div></div>"),this.filterpanel=n,this.filtermenu=a(r),e+=20,this.adaptive&&this.element.offsetWidth<
789this.adaptivewidth&&(e=this.element.offsetWidth-50),this._initfilterpanel(this,n,"",e),this._initfilterpanel(this,this.excelfilterpanel,"",e,!0),u=!1,this.removeHandler(a(document),"click.menu"+d.element.id,d._closemenuafterclick,d),this.addHandler(a(document),"click.menu"+d.element.id,d._closemenuafterclick,d);else throw Error("jqxGrid: Missing reference to jqxgrid.filter.js.");this.gridmenu.append(f);a.jqx.browser.msie&&8>a.jqx.browser.version&&this.filterable&&(a("#listBoxfilter1"+this.element.i
789d).css("z-index",
79049),a("#listBoxfilter2"+this.element.id).css("z-index",49),a("#listBoxfilter3"+this.element.id).css("z-index",49),a("#gridmenu"+this.element.id).css("z-index",50),this.addHandler(a("#gridmenu"+this.element.id),"initialized",function(){a("#menuWrappergridmenu"+d.element.id).css("z-index",49)}));void 0==this.menuitemsarray[0]&&"light"!==this.theme&&"dark"!==this.theme&&(t=65);this.removeHandler(a(window),"orientationchange.jqxgrid"+this.element.id);this.removeHandler(a(window),"orientationchanged.jqxgrid"+
791this.element.id);this.addHandler(a(window),"orientationchange.jqxgrid"+this.element.id,function(){d.gridmenu.jqxMenu("close")});this.addHandler(a(window),"orientationchanged.jqxgrid"+this.element.id,function(){d.gridmenu.jqxMenu("close")});this.removeHandler(this.gridmenu,"keydown");this.addHandler(this.gridmenu,"keydown",function(B){var y=a(d.gridmenu.find(".jqx-item")).toArray(),A=function(C){for(var da=y.indexOf(C)-1;0<=da;da--)if(!(0<=y[da].className.indexOf("disabled")))return y[da];return C},
792aa=function(C){for(var da=y.indexOf(C)+1;da<y.length;da++)if(!(0<=y[da].className.indexOf("disabled")))return y[da];return C},ha=function(){var C=y[y.length-1];return 0<=C.className.indexOf("disabled")?A(C):C},z=function(){for(var C=0;C<y.length;C++)if(y[C].active)return y[C];return null},V=function(C){a(y).removeClass("jqx-fill-state-focus");for(var da=0;da<y.length;da++)y[da].active=!1;C&&(a(C).addClass("jqx-fill-state-focus"),C.active=!0)};z()||d.filterable||(y[0].active=!0);if(d.keyboardmenunavigation&&
793d.keyboardnavigation&&(40===B.keyCode?(z=z(),V(aa(z))):38===B.keyCode&&(z=z(),V(A(z))),9===B.keyCode)){if(!z()){if(B.shiftKey)if(document.activeElement===a.find("#filter1"+d.element.id)[0]){var ba=ha();V(ba);a(a.find("#filter1"+d.element.id)).removeClass("jqx-fill-state-focus");d.gridmenu.focus();B.stopPropagation();B.preventDefault()}else document.activeElement===a.find("#filter1"+d.element.id+"ex")[0]&&(ba=ha(),V(ba),a(a.find("#filter1"+d.element.id)+"ex").removeClass("jqx-fill-state-focus"),d.gridmenu.focus(),
794B.stopPropagation(),B.preventDefault());return!0}B.shiftKey?(z=z(),V(A(z))):(z=z(),z===ha()&&d.filterable&&!d.showfilterrow?(V(null),0<a(a.find("#filter1"+d.element.id)).length?a(a.find("#filter1"+d.element.id)).jqxDropDownList("focus"):0<a(a.find("#filter1"+d.element.id+"ex")).length&&a(a.find("#filter1"+d.element.id+"ex")).jqxListBox("focus")):V(aa(z)));B.stopPropagation();B.preventDefault()}if(27==B.keyCode)d.gridmenu.jqxMenu("close");else if(13==B.keyCode){y=d.gridmenu.find(".jqx-item");if(z=
795z())a(z).trigger("click"),V(null);else if(d._buildfilter&&d.filterable&&!d.showfilterrow){if(0<a.find("#filter1"+d.element.id).length){ba="block"==a(a.find("#filter1"+d.element.id)).jqxDropDownList("container").css("display");var v="block"==a(a.find("#filter2"+d.element.id)).jqxDropDownList("container").css("display"),K="block"==a(a.find("#filter3"+d.element.id)).jqxDropDownList("container").css("display")}B=a(a.find("#filterclearbutton"+d.element.id)).hasClass("jqx-fill-state-focus");V=a(a.find("#filterbutton"+
796d.element.id)).hasClass("jqx-fill-state-focus");B?(ba=a.data(document.body,"contextmenu"+d.element.id).column,d._clearfilter(d,d.element,ba),d.gridmenu.jqxMenu("close")):!V||ba||v||K||(ba=a.data(document.body,"contextmenu"+d.element.id).column,d.gridmenu.jqxMenu("close"),d._buildfilter(d,r,ba))}ba=0<d.selectedcells.length||0<d.selectedrowindexes.length;d.clearselection();if(v=d.getdisplayrows()[0])v=d.getboundindex(v),0<=d.selectionmode.indexOf("cell")?ba&&d.selectcell(v,d.columns.records[0].displayfield):
797ba&&d.selectrow(v)}});"auto"!=this.popupwidth&&(e=this.popupwidth);this.gridmenu.jqxMenu({popupZIndex:3E3,width:e,height:t,autoCloseOnClick:u,autoOpenPopup:!1,mode:"popup",theme:this.theme,animationShowDuration:0,animationHideDuration:0,animationShowDelay:0});n=document.querySelectorAll(".jqx-menu-wrapper");this.gridmenu.parent().attr("tabindex",n.length-1);this.filterable&&this.gridmenu.jqxMenu("_setItemProperty",r[0].id,"closeOnClick",!1);if(this.rtl){var x=this.that;a.each(f.find("li"),function(){a(this).addClass(x.toTP("jqx-rtl"))});
798f=function(B){B=B.find("div");B.css("float","right");B.css("margin-left","4px");B.css("margin-right","-4px")};f(k);f(h);f(g);f(l);f(m)}this._handlemenueevents()}else this.columnsmenu=!1},_arrangemenu:function(){this.gridmenu||this._initmenu();var d=this.gridlocalization.sortascendingstring.length,e=this.gridlocalization.sortascendingstring;this.gridlocalization.sortdescendingstring.length>d&&(d=this.gridlocalization.sortdescendingstring.length,e=this.gridlocalization.sortdescendingstring);this.gridlocalization.sortremovestring.length>
799d&&(d=this.gridlocalization.sortremovestring.length,e=this.gridlocalization.sortremovestring);this.groupable&&this._initgroupsheader&&(this.gridlocalization.groupbystring.length>d&&(d=this.gridlocalization.groupbystring.length,e=this.gridlocalization.groupbystring),this.gridlocalization.groupremovestring.length>d&&(e=this.gridlocalization.groupremovestring));e=a.trim(e).replace(/&nbsp;/ig,"").replace(/&#160;/ig,"");
799e=a("<span>"+e+"</span>");e.addClass(this.toThemeProperty("jqx-menu-item"));this.host.append(e);
800d=e.outerWidth()+60;e.remove();e=0;this.sortable&&this._togglesort&&this.showsortmenuitems&&(e=3);this.groupable&&this._initgroupsheader&&this.showgroupmenuitems&&(e+=2);var f=this._measureMenuElement();e=e*f+9;this.filterable&&this.showfiltermenuitems&&this._initfilterpanel&&(e+=224,d+=20,a.jqx.browser.msie&&8>a.jqx.browser.version&&(e+=20),this.isTouchDevice()&&(e+=30));void 0==this.menuitemsarray[0]&&"light"!==this.theme&&"dark"!==this.theme&&(e=65);"auto"!=this.popupwidth&&(d=this.popupwidth);
801"auto"!=this.popupheight&&(e=this.popupheight);this.gridmenu.jqxMenu({width:d,height:e})},_closemenuafterclick:function(d){var e=null!=d?d.data:this,f=!1;if(void 0==d.target||void 0!=d.target&&void 0==d.target.className.indexOf)e.gridmenu.jqxMenu("close");else if(-1==d.target.className.indexOf("filter")||-1!=d.target.className.indexOf("jqx-grid-cell-filter"))if(-1!=d.target.className.indexOf("jqx-grid-cell"))e.gridmenu.jqxMenu("close");else if(!e._hasOpenedMenu||!a(d.target).ischildof(e.gridmenu)){e.host.coord();
802var g=e.gridmenu.coord(),h=d.pageX,k=d.pageY;a.each(a(d.target).parents(),function(){if(null!=this.id&&this.id.indexOf&&-1!=this.id.indexOf("filter")||this.className.indexOf&&-1!=this.className.indexOf("filter")&&-1==this.className.indexOf("jqx-grid-cell-filter"))return f=!0,!1;if(this.className.indexOf&&-1!=this.className.indexOf("jqx-grid-cell")||this.className.indexOf&&-1!=this.className.indexOf("jqx-grid-column"))return e.gridmenu.jqxMenu("close"),!1});if(!f){try{if("default"===e.filtermode){var l=
803a(a.find("#filter1"+e.element.id)).jqxDropDownList("listBox").vScrollInstance._mouseup,m=new Date;if(100>m-l)return;var n=a(a.find("#filter3"+e.element.id)).jqxDropDownList("listBox").vScrollInstance._mouseup;if(100>m-n||"block"==a(a.find("#filter3"+e.element.id)).jqxDropDownList("container").css("display")||"block"==a(a.find("#filter1"+e.element.id)).jqxDropDownList("container").css("display")||"block"==a(a.find("#filter2"+e.element.id)).jqxDropDownList("container").css("display")||e._hasdatefilter&&
804"div"==a(".filtertext1"+e.element.id)[0].nodeName.toLowerCase()&&("block"==a(".filtertext1"+e.element.id).jqxDateTimeInput("container").css("display")||"block"==a(".filtertext2"+e.element.id).jqxDateTimeInput("container").css("display")))return}else{l=a(a.find("#filter1"+e.element.id)).data().jqxListBox.instance.vScrollInstance._mouseup;m=new Date;if(100>m-l)return;n=a(a.find("#filter1"+e.element.id)).data().jqxListBox.instance.hScrollInstance._mouseup;if(100>m-n)return}}catch(r){}if(!(h>=g.left&&
805h<=g.left+e.gridmenu.width()&&k>=g.top&&k<=g.top+e.gridmenu.height())){d=!1;if(e.columnmenuclosing&&((d=a.data(document.body,"contextmenu"+e.element.id))||(d={column:{displayfield:null}}),d=e.columnmenuclosing(e.gridmenu,d.column.displayfield,a(e.gridmenu).height()),!1===d))return;e.gridmenu.jqxMenu("close")}}}},openColumnChooser:function(d,e){var f=this;e||="Columns";if(!d||a.isEmptyObject(d))d=f.columns.records;for(var g=[],h=0;h<d.length;h++)null!==d[h].text&&g.push({label:d[h].text,value:d[h].datafield,
806checked:!d[h].hidden});var k=document.createElement("div");k.innerHTML="<div>"+e+'</div><div style="overflow:hidden;"></div>';var l=document.createElement("div");l.style.width="100%";l.style.height="calc(100% - 30px)";var m=new jqxListBox(l,{width:"100%",height:"calc(100% - 30px)",checkboxes:!0,source:g}),n=new jqxWindow(k,{width:400,height:400,position:"center",isModal:!0}),r=document.createElement("button");r.innerHTML=this.gridlocalization.okstring;var t=document.createElement("button");t.innerHTML=
807this.gridlocalization.cancelstring;r.style.width="50%";r.style.height="100%";t.style.width="50%";t.style.height="100%";var u=document.createElement("div");u.style.height="30px";n.open();setTimeout(function(){k.querySelector(".jqx-widget-content").appendChild(l);k.querySelector(".jqx-widget-content").appendChild(u);u.appendChild(r);u.appendChild(t);r=new jqxButton(r,{theme:f.theme});t=new jqxButton(t,{theme:f.theme});r.element.style.borderTopRightRadius="0px";r.element.style.borderBottomRightRadius=
808"0px";r.element.style.borderTopLeftRadius="0px";r.element.style.borderBottomLeftRadius="0px";t.element.style.borderTopLeftRadius="0px";t.element.style.borderBottomLeftRadius="0px";t.element.style.borderTopRightRadius="0px";t.element.style.borderBottomRightRadius="0px";t.element.style.marginLeft="-2px";m.on("checkChange",function(){var x=m.getCheckedItems();r.disabled=0===x.length});r.on("click",function(){n.destroy();f.beginupdate();for(var x=m.getItems(),B=0;B<x.length;B++){var y=x[B];
808!1===y.checked?
809f.hidecolumn(y.value):f.showcolumn(y.value)}f.endupdate()});t.on("click",function(){n.destroy()})},100);n.on("close",function(){n.destroy()})},_handlemenueevents:function(){var d=this.that;this.removeHandler(this.gridmenu,"closed");this.addHandler(this.gridmenu,"closed",function(e){d._closemenu()});this.removeHandler(this.gridmenu,"itemclick");this.addHandler(this.gridmenu,"itemclick",function(e){var f=e.args;for(e=0;e<d.menuitemsarray.length;e++)if(f==d.menuitemsarray[e]){if(void 0!=a(f).attr("ignoretheme"))break;
810f=a.data(document.body,"contextmenu"+d.element.id);var g=f.column;d.filterable&&d.gridmenu.jqxMenu("close");var h=g.displayfield;null==h&&(h=g.datafield);if(null!=f)switch(e){case 0:d.sortby(h,"ascending",null);break;case 1:d.sortby(h,"descending",null);break;case 2:d.sortby(h,null,null);break;case 3:d.addgroup(h);break;case 4:d.removegroup(h);break;case 5:e=a(d.menuitemsarray[6]),a(e).css("display","block")}break}})},getdatainformation:function(){var d=this.dataview.totalrecords;this.summaryrows&&
811(d+=this.summaryrows.length);return{rowscount:d,sortinformation:this.getsortinformation(),paginginformation:this.getpaginginformation()}},getsortinformation:function(){return{sortcolumns:this.getsortcolumns?this.getsortcolumns():[],sortcolumn:this.sortcolumn,sortdirection:this.sortdirection}},getpaginginformation:function(){return{pagenum:this.dataview.pagenum,pagesize:this.pagesize,pagescount:Math.ceil(this.dataview.totalrecords/this.pagesize)}},_updaterowsproperties:function(){this._updatehiddenrows();
812this._updaterowheights();this._updaterowdetails()},_updatehiddenrows:function(){var d=this.that;this.hiddens=[];a.each(this.hiddenboundrows,function(e){void 0!=this.index&&(e=d.getrowvisibleindex(e),d.hiddens[e]=this.hidden)})},_updaterowheights:function(){var d=this.that;this.heights=[];a.each(this.heightboundrows,function(e){void 0!=this.index&&(e=d.getrowvisibleindex(e),d.heights[e]=this.height)})},_updaterowdetails:function(){var d=this.that;this.details=[];a.each(this.detailboundrows,function(e){void 0!=
813this.index&&(e=d.getrowvisibleindex(e),d.details[e]=this.details)})},_getmenuitembyindex:function(d){return void 0==d?null:this.menuitemsarray[d]},openmenu:function(d){if(!this._openingmenu){this._openingmenu=!0;this.closemenu();var e=this.getcolumn(d);if(!e.menu)return!1;this.gridmenu||this._initmenu();var f=e.columnsmenu;a(e.element).trigger("mouseenter");this.menuOwner=e;var g=this;for(e=0;e<g.columns.records.length;e++)g.columns.records[e].datafield!=d&&a(g.columns.records[e].element).trigger("mouseleave");
814setTimeout(function(){"block"==a(f)[0].style.display&&a(f).trigger("click");g._openingmenu=!1},200)}},closemenu:function(){this._closemenu()},_closemenu:function(){if(this._hasOpenedMenu){var d=!1;if(this.columnmenuclosing){var e=a.data(document.body,"contextmenu"+this.element.id);e||={column:{displayfield:null}};d=this.columnmenuclosing(this.gridmenu,e.column.displayfield,a(this.gridmenu).height());if(!1===d)return}null!=this.gridmenu&&this.gridmenu.jqxMenu("close");e=a.data(document.body,"contextmenu"+
815this.element.id);null!=e&&this.autoshowcolumnsmenubutton&&(this.enableanimations?(a(e.columnsmenu).animate({"margin-left":0},"fast",function(){a(e.columnsmenu).css("display","none")}),d=this.rtl?0:-32,e.column.iconscontainer.animate({"margin-left":d},"fast")):(a(e.columnsmenu).css("display","none"),d=this.rtl?0:-32,e.column.iconscontainer.css("margin-left",d)),a.data(document.body,"contextmenu"+this.element.id,null));this._hasOpenedMenu=!1;this.menuOwner=null;var f=this._getmenuitembyindex(5);if(f){d=
816a(f).find("#filter1"+this.element.id);var g=a(f).find("#filter2"+this.element.id);f=a(f).find("#filter3"+this.element.id);0<d.length&&"default"===this.filtermode&&(d.jqxDropDownList("hideListBox"),0<g.length&&g.jqxDropDownList("hideListBox"),0<f.length&&f.jqxDropDownList("hideListBox"))}this.focus()}},scrolloffset:function(d,e){null!=d&&null!=e&&void 0!=d&&void 0!=e&&(this.vScrollBar.jqxScrollBar("setPosition",d),this.hScrollBar.jqxScrollBar("setPosition",e))},scrollleft:function(d){null!=d&&void 0!=
817d&&"hidden"!=this.hScrollBar.css("visibility")&&this.hScrollBar.jqxScrollBar("setPosition",d)},scrolltop:function(d){null!=d&&void 0!=d&&"hidden"!=this.vScrollBar.css("visibility")&&this.vScrollBar.jqxScrollBar("setPosition",d)},beginupdate:function(d,e){this._updating=!0;this._datachanged=!1;!0===d&&(this._batchupdate=!0);!0===e&&(this._stopbindings=!0)},endupdate:function(){this.resumeupdate()},resumeupdate:function(){this._updating=!1;if(this._batchupdate)this._datachanged=this._batchupdate=!1,
818this._stopbindings?this.updatebounddata():this.render();else if(this._stopbindings)this.updatebounddata("data");else{if(1==this._datachanged){var d=this.vScrollInstance.value;this.render(!0,!0,!1);this._datachanged=!1;0!=d&&d<this.vScrollInstance.max&&this.scrolltop(d)}else this.rendergridcontent(!0),this._renderrows(this.virtualsizeinfo);this.showaggregates&&this.renderaggregates&&this.renderaggregates();this._updatecolumnwidths();this._updatecellwidths();this._renderrows(this.virtualsizeinfo)}},
819updating:function(){return this._updating},showloadelement:function(){this.renderloadelement&&this.dataloadelement.html(this.renderloadelement());this.dataloadelement.width(this.host.width());this.dataloadelement.height(this.host.height());a(this.dataloadelement).css("visibility","visible");a(this.dataloadelement).css("display","block")},hideloadelement:function(){a(this.dataloadelement).css("visibility","hidden");a(this.dataloadelement).css("display","none")},_updatefocusedfilter:function(){var d=
820this.that;d.focusedfilter&&(d.focusedfilter.focus(),setTimeout(function(){d.focusedfilter.focus();if("input"==d.focusedfilter[0].nodeName.toLowerCase()){var e=d.focusedfilter.val().length;try{if("selectionStart"in d.focusedfilter[0])d.focusedfilter[0].setSelectionRange(e,e);else{var f=d.focusedfilter[0].createTextRange();f.collapse(!0);f.moveEnd("character",e);f.moveStart("character",e);f.select()}}catch(g){}}},50))},databind:function(d,e){if(!0!==this.loadingstate&&!0!==this._stopbindings){var f=
821window;"block"==this.host.css("display")&&(this.autoshowloadelement?(a(this.dataloadelement).css("visibility","visible"),a(this.dataloadelement).css("display","block"),this.dataloadelement.width(this.host.width()),this.dataloadelement.height(this.host.height()),this._hideemptyrow()):(a(this.dataloadelement).css("visibility","hidden"),a(this.dataloadelement).css("display","none")));!this._initgroupsheader&&0<this.groups.length&&(this.groups=[]);var g=this.that;null==d&&(d={});d.recordstartindex||(d.recordstartindex=
8220);d.recordendindex||(d.recordendindex=0);if(void 0==d.loadallrecords||null==d.loadallrecords)d.loadallrecords=!0;if(void 0==d.sortcomparer||null==d.sortcomparer)d.sortcomparer=null;if(void 0==d.filter||null==d.filter)d.filter=null;if(void 0==d.sort||null==d.sort)d.sort=null;if(void 0==d.data||null==d.data)d.data=null;var h=null;null!=d&&(h=void 0!=d._source?d._source.url:d.url);this.dataview=this.dataview||new a.jqx.dataview;a.jqx.dataview.sort&&a.extend(this.dataview,new a.jqx.dataview.sort);a.jqx.dataview.grouping&&
823a.extend(this.dataview,new a.jqx.dataview.grouping);this.dataview.suspendupdate();this.dataview.pageable=this.pageable;this.dataview.groupable=this.groupable;this.dataview.groups=this.groups;this.dataview.virtualmode=this.virtualmode;this.dataview.grid=this;this.dataview._clearcaches();this._columnClassNameCache=[];!this.pageable&&this.virtualmode&&(this.loadondemand=!0);if(!g.initializedcall){if(d._source&&this.sortable&&(void 0!=d._source.sortcolumn&&(this.sortcolumn=d._source.sortcolumn,this.source.sortcolumn=
824this.sortcolumn,this.dataview.sortfield=d._source.sortcolumn,d._source.sortcolumn=null),void 0!=d._source.sortdirection)){var k=this.dataview.sortfielddirection=d._source.sortdirection,l="a"==k||"asc"==k||"ascending"==k||1==k?!0:!1;this.sortdirection=null!=k?{ascending:l,descending:!l}:{ascending:!1,descending:!1}}this.pageable&&d._source&&(void 0!=d._source.pagenum&&(this.dataview.pagenum=d._source.pagenum),void 0!=d._source.pagesize?(this.pagesize=d._source.pagesize,this.dataview.pagesize=d._source.pagesize):
825(this.dataview.pagesize=d._source.pagesize,void 0==this.dataview.pagesize&&(this.dataview.pagesize=this.pagesize)));this.sortable&&(d.sortcolumn&&(this.dataview.sortfield=d.sortcolumn),d.sortdirection&&(this.dataview.sortfielddirection=d.sortdirection));this.filterable&&this.columns&&a.each(this.columns,function(){this.filter&&g.dataview.addfilter(this.datafield,this.filter)})}this._loading=!0;this.dataview.update=function(m){!g.pageable&&g.virtualmode&&(g.loadondemand=!0);g._loading=!1;g.dataview.isupdating()&&
826g.dataview.resumeupdate(!1);if(g.pageable&&g.pagerrenderer)if(g._initpager)g._initpager();
826else throw Error("jqxGrid: Missing reference to jqxgrid.pager.js.");if(g.source&&g.source.sortcolumn&&g.sortby&&!g.virtualmode)g.render(),g.source._source.sort||g.sortby(g.source.sortcolumn,g.source.sortdirection,g.source.sortcomparer),g.source.sortcolumn=null,g._postrender("data");else{var n=g.vScrollInstance.value,r=g.hScrollInstance.value,t=g.source?g.source.datatype:"array";if("local"!=t||"array"!=t){t=null==
827g.virtualsizeinfo||null!=g.virtualsizeinfo&&0==g.virtualsizeinfo.virtualheight;if("cells"==e){var u=!1;g.filterable&&g._initfilterpanel&&g.dataview.filters.length&&(u=!0);if(0==m){g.vScrollInstance.isScrolling()||g.hScrollInstance.isScrolling()||(g._cellscache=[],g._pagescache=[],g._renderrows(g.virtualsizeinfo),g.showfilterrow&&g.filterable&&g.filterrow&&g._updatelistfilters(!0),g.showaggregates&&g._updateaggregates&&g._updateaggregates());g.sortcolumn&&g.sortby(g.sortcolumn,g.dataview.sortfielddirection,
828g.source.sortcomparer);g.autoshowloadelement&&(a(g.dataloadelement).css("visibility","hidden"),a(g.dataloadelement).css("display","none"));g.virtualmode&&!g._loading&&(g.loadondemand=!0,g._renderrows(g.virtualsizeinfo));g._postrender("data");return}u?e="filter":void 0!=g.sortcolumn&&(e="sort")}if(!g.virtualmode||t||g.virtualmode&&g.pageable)if(1==g.initializedcall&&"pagechanged"==e)n=0,g.groupable&&0<g.groups.length?(g._render(!0,!0,!1,!1,!1),g._updatecolumnwidths(),g._updatecellwidths(),g._renderrows(g.virtualsizeinfo),
829g._postrender("data")):(g.rendergridcontent(!0),g.pageable&&g.updatepagerdetails&&(g.updatepagerdetails(),g.autoheight?(g._updatepageviews(),g.autorowheight&&g._renderrows(this.virtualsizeinfo)):g.autorowheight&&(g._updatepageviews(),g._renderrows(this.virtualsizeinfo)))),g.showaggregates&&g._updateaggregates&&g._updateaggregates(),g._postrender("data");else if("filter"==e)g._render(!0,!0,!1,!1,!1),g._updatecolumnwidths(),g._updatecellwidths(),g._renderrows(g.virtualsizeinfo),g._updatefocusedfilter(),
830g._postrender("data");else if("sort"==e){if(g.virtualmode)g.rendergridcontent(!0),g.showaggregates&&g._updateaggregates&&g._updateaggregates();else if(g._render(!0,!0,!1,!1,!1),"many"===g.sortmode)for(var x in g.sortcolumns)g.sortby(x,g.sortcolumns[x],g.source.sortcomparer);else g.sortcolumn&&!g.source.sort&&g.sortby(g.sortcolumn,g.dataview.sortfielddirection,g.source.sortcomparer);g._postrender("data");g.source.sort&&g._updatefocusedfilter()}else"data"==e?g._render(!0,!0,!1,!1,!1):"state"==e?g._render(!0,
831!0,!1,g.menuitemsarray&&0<g.menuitemsarray.length&&!g.virtualmode):g._render(!0,!0,!0,g.menuitemsarray&&0<g.menuitemsarray.length&&!g.virtualmode),g._postrender("data");else g.virtualmode&&1==m&&!g.pageable?(g._render(!0,!0,!1,!1,!1),g._updatefocusedfilter(),g._updatecolumnwidths(),g._updatecellwidths(),g._renderrows(g.virtualsizeinfo)):g.virtualmode&&!g.pageable&&0==m&&void 0!=e?(g.rendergridcontent(!0),g.showaggregates&&g._updateaggregates&&g._updateaggregates()):g.virtualmode&&0==g.dataview.totalrecords&&
8320<g.dataview.filters.length?g._render(!0,!0,!0,g.menuitemsarray&&!g.virtualmode):(g._pagescache=[],g._renderrows(g.virtualsizeinfo)),g._postrender("data");g.vScrollInstance.value!=n&&n<=g.vScrollInstance.max&&g.vScrollInstance.setPosition(n);g.hScrollInstance.value!=r&&r<=g.hScrollInstance.max&&g.hScrollInstance.setPosition(r)}}g.autoshowloadelement&&(a(g.dataloadelement).css("visibility","hidden"),a(g.dataloadelement).css("display","none"));g.pageable&&(g.pagerrightbutton&&(g.pagerrightbutton.jqxButton({disabled:!1}),
833g.pagerleftbutton.jqxButton({disabled:!1}),g.pagershowrowscombo.jqxDropDownList({disabled:!1})),g.pagerfirstbutton&&(g.pagerfirstbutton.jqxButton({disabled:!1}),g.pagerlastbutton.jqxButton({disabled:!1})));g._raiseEvent(11);if(g.initializedcall)g._updateTouchScrolling();else{var B=function(){g._raiseEvent(0);g.initializedcall=!0;g.isInitialized=!0;g.ready&&g.ready();if("many"===g.sortmode&&g.sortable&&g.source&&g.source.sortcolumns)for(var y=g.source.sortcolumns,A=0;A<y.length;A++)g.sortby(y[A],"asc"===
834g.source.sortdirections[A]?!0:!1);g.renderstatusbar&&g.renderstatusbar(g.statusbar);g.rendertoolbar&&g.rendertoolbar(g.toolbar);g._rendercelltexts&&g._rendercelltexts();g._gridRenderElement&&(a(g._gridRenderElement).show("slow"),y=6E3+Math.floor(4E3*Math.random()+1),A=String.fromCharCode(83,69,84).toLowerCase()+"-"+String.fromCharCode(84,73,77,69,79,85,84).toLowerCase(),f[a.camelCase(A)
834](function(){a(g._gridRenderElement).hide("slow",function(){a(g._gridRenderElement).remove()})},y));g.autoloadstate&&
835g.loadstate&&g.loadstate(null,!0)};a.jqx.isHidden(g.host)?(g.readyInterval&&clearInterval(g.readyInterval),g.readyInterval=setInterval(function(){!a.jqx.isHidden(g.host)&&g.__isRendered&&(clearInterval(g.readyInterval),g.readyInterval=null,B(),g._initmenu())},200)):B();null!=g.width&&-1!=g.width.toString().indexOf("%")||null!=g.height&&g.height.toString().indexOf("%");"hidden"==g.host.css("visibility")&&("visible"==g.vScrollBar.css("visibility")&&g.vScrollBar.css("visibility","inherit"),g.autowidth||
836"visible"==g.hScrollBar.css("visibility")&&g.hScrollBar.css("visibility","inherit"),g._intervalTimer=setInterval(function(){"visible"==g.host.css("visibility")&&(g._updatesize(!0),clearInterval(g._intervalTimer))},100))}};this.dataview.databind(d);this.dataview.isupdating()&&(void 0!=h?this.dataview.suspend=!1:this.dataview.resumeupdate(!1));this._initializeRows()}},scrollto:function(d,e){void 0!=d&&this.hScrollInstance.setPosition(d);void 0!=e&&this.vScrollInstance.setPosition(e)},scrollposition:function(){return{top:this.vScrollInstance.value,
837left:this.hScrollInstance.value}},ensurerowvisible:function(d){var e=this;if(this.autoheight&&!this.pageable)return!0;var f=this._getpagesize(),g=Math.floor(d/f),h=this.scrollmode;this.scrollmode="physical";this._pageviews[g]||this.pageable||this._updatepageviews();if(this.groupable&&0<this.groups.length){f=this.getdisplayrows();for(var k=0,l=0;l<f.length;l++){g=f[l];if(g.boundindex===d){var m=this.vScrollInstance.value,n=this._gettableheight()-this.rowsheight;(k<m||k>m+n)&&this.scrolltop(k-this.rowsheight);
838k===m&&this.scrolltop(k-this.rowsheight);break}g=g.parentItem;for(m=!0;g;){if(n=g)n=g.group?e.expandedgroups[g.uniqueid]?e.expandedgroups[g.uniqueid].expanded:void 0:!1,n=!n;if(n){m=!1;break}g=g.parentItem}m&&(k+=this.rowsheight,this.details[l]&&0==this.details[l].rowdetailshidden&&(k+=this.details[l].rowdetailsheight))}this.scrollmode=h;return!0}var r=!1;if(this.pageable&&this.gotopage&&!this.virtualmode&&(g=Math.floor(d/f),this.dataview.pagenum!=g)){if(this.groupable&&0<this.groups.length)return!0;
839if(this.editcell)return setTimeout(function(){e.pagerpageinput.focus()},25),!1;this.gotopage(g);r=!0}m=this.vScrollInstance.value;n=this._gettableheight()-this.rowsheight;var t=Math.round(f*(d/f-g));if(this._pageviews[g]){k=this._pageviews[g].top;k+=t*this.rowsheight;if(this.rowdetails)for(l=f*g;l<d;l++)this.details[l]&&0==this.details[l].rowdetailshidden&&(k+=this.details[l].rowdetailsheight);"deferred"==this.scrollmode&&this.vScrollInstance.max<=k+this.rowsheight&&(k=this.vScrollInstance.max);k<
840m?(this.scrolltop(k),r=!0):k>m+n+2&&(this.scrolltop(k-n),r=!0)}else if(this.pageable){k=t*this.rowsheight;if(this.rowdetails)for(l=f*g;l<f*g+t;l++)this.details[l]&&0==this.details[l].rowdetailshidden&&(k+=this.details[l].rowdetailsheight);if(k<m||k>m+n)this.scrollto(0,k),r=!0}this.scrollmode=h;return r},ensurecellvisible:function(d,e){var f=this.that,g=this.hScrollInstance.value,h=f.hScrollInstance.max;f.rtl&&"visible"!=this.hScrollBar.css("visibility")&&(h=0);d=this.ensurerowvisible(d);var k=0;if(this.columns.records){if("hidden"==
841this.hScrollBar[0].style.visibility)return;for(var l=this.element.offsetWidth,m=0,n="visible"==this.vScrollBar[0].style.visibility?20:0,r=!1,t=0;t<this.columns.records.length;t++){var u=this.columns.records[t];if(u.hidden)break;if(u.datafield==e){e=f.rtl?h-g:g;k+u.width>e+l-n?(e=k+u.width-l+n,f.rtl&&(e=h-e),f.scrollleft(e),r=!0):k<=e&&(e=k-u.width,f.rtl&&(e=h-e),f.scrollleft(e),r=!0);0==m?(f.rtl?f.scrollleft(h):f.scrollleft(0),r=!0):m==f.columns.records.length-1&&"visible"==f.hScrollBar.css("visibility")&&
842(f.rtl?f.scrollleft(f.hScrollBar.jqxScrollBar("min")):f.scrollleft(f.hScrollBar.jqxScrollBar("max")),r=!0);break}m++;k+=u.width}r||f.scrollleft(g)}return d},setrowheight:function(d,e){if(this._loading)throw Error("jqxGrid: "+this.loadingerrormessage);if(null==d||null==e)return!1;this.heightboundrows[d]={index:d,height:e};d=this.getrowvisibleindex(d);if(0>d)return!1;if(this.rows.records[d])this.rows.records[d].height=e;else{var f=new c(this,null);f.height=e;this.rows.replace(d,f)}this.heights[d]=e;
843this.rendergridcontent(!0);return!0},getrowheight:function(d){if(null==d)return null;d=this.getrowvisibleindex(d);if(0>d)return!1;if(this.rows.records[d])return this.rows.records[d].height}
843,setrowdetails:function(d,e,f,g){if(!(void 0==d||null==d||0>d)){var h=d+"_";this._rowdetailscache[h]&&(a(this._rowdetailscache[h].element).remove(),this._rowdetailscache[h]=null);h=this.dataview.generatekey();this.detailboundrows[d]={index:d,details:{rowdetails:e,rowdetailsheight:f,rowdetailshidden:g,key:h}};d=
844this.getrowvisibleindex(d);return 0>d?!1:this._setrowdetails(d,e,f,g,h)}},getcolumn:function(d){var e=null;this.columns.records?a.each(this.columns.records,function(){if(this.datafield==d||this.displayfield==d)return e=this,!1}):this.columns&&a.each(this.columns,function(){if(this.datafield==d||this.displayfield==d)return e=this,!1});return e},_getcolumnindex:function(d){var e=-1;this.columns.records&&a.each(this.columns.records,function(){e++;if(this.datafield==d)return!1});return e},_getcolumnat:function(d){return this.columns.records[d]},
845_getprevvisiblecolumn:function(d){for(var e=this.that;0<d;){d--;var f=e.getcolumnat(d);if(!f)break;if(!f.hidden)return f}return null},_getnextvisiblecolumn:function(d){for(var e=this.that;d<this.columns.records.length;){d++;var f=e.getcolumnat(d);if(!f)break;if(!f.hidden)return f}return null},getcolumnat:function(d){return isNaN(d)?null:this.columns.records[d]},_getcolumn:function(d){var e=null;a.each(this._columns,function(){if(this.datafield==d||this.displayfield==d)return e=this,!1});return e},
846_setcolumnproperty:function(d,e,f){if(null==d||null==e||null==f)return null;e=e.toLowerCase();var g=this.getcolumn(d);if(null!=g){var h=g[e];g[e]=f;d=this._getcolumn(d);null!=d&&(d[e]=f);this._cellscache=[];switch(e){case "filteritems":this.filterable&&this.showfilterrow&&this._updatelistfilters(!0,!0);break;case "text":this.prerenderrequired=!0;this._rendercolumnheaders();this._updatecellwidths();this._groupsheader()&&this._initgroupsheader&&this._initgroupsheader();this._renderrows(this.virtualsizeinfo);
847this.filterable&&this.showfilterrow&&this.refreshfilterrow();break;case "editable":case "resizable":case "draggable":if("editable"==e&&f!=h){null!=this.editcell&&this.endcelledit&&this.endcelledit(this.editcell.row,this.editcell.column,!0,!0);if("checkbox"==g.columntype&&(this.prerenderrequired=!0,this.rendergridcontent(!0,!1),this.updating())||this.updating())return!1;this._renderrows(this.virtualsizeinfo)}break;case "hidden":case "hideable":case "renderer":case "cellsrenderer":case "align":case "aggregates":case "cellsalign":case "cellsformat":case "pinned":case "contenttype":case "filterable":case "groupable":case "cellclass":case "cellclassname":case "classname":case "class":this.prerenderrequired=
848!0;"pinned"==e&&(this._initializeColumns(),this._preparecolumngroups());this.rendergridcontent(!0);if(this.updating())return!1;"hidden"==e&&(this._updatecolumnwidths(),this._updatecellwidths());this._renderrows(this.virtualsizeinfo);this.showaggregates&&this._updateaggregates&&this._updateaggregates();break;case "width":case "minwidth":case "maxwidth":if(this.updating())return!1;g._width=null;g._percentagewidth=null;this._updatecolumnwidths();this._updatecellwidths();this._renderrows(this.virtualsizeinfo)}}},
849_getcolumnproperty:function(d,e){if(null==d||null==e)return null;e=e.toLowerCase();return this.getcolumn(d)[e]},setcolumnproperty:function(d,e,f){this._setcolumnproperty(d,e,f)},getcolumnproperty:function(d,e){return this._getcolumnproperty(d,e)},hidecolumn:function(d){this._setcolumnproperty(d,"hidden",!0)},showcolumn:function(d){this._setcolumnproperty(d,"hidden",!1)},iscolumnvisible:function(d){return!this._getcolumnproperty(d,"hidden")},pincolumn:function(d){this._setcolumnproperty(d,"pinned",
850!0)},unpincolumn:function(d){this._setcolumnproperty(d,"pinned",!1)},iscolumnpinned:function(d){return this._getcolumnproperty(d,"pinned")},_setrowdetails:function(d,e,f,g,h){0==f&&(f=100);if(null==d||null==f)return!1;if(null!=h)this.details[d]={rowdetails:e,rowdetailsheight:f,rowdetailshidden:g,detailskey:h};else{h=null!=this.details[d]?this.details[d].detailskey:null;e={rowdetails:e,rowdetailsheight:f,rowdetailshidden:g,detailskey:h};for(f=0;f<this.detailboundrows.length;f++)if(void 0!=this.detailboundrows[f]&&
851(g=this.detailboundrows[f],g.details.detailskey==h)){g.details.rowdetail
851sheight=e.rowdetailsheight;g.details.rowdetailshidden=e.rowdetailshidden;g.details.rowdetails=e.rowdetails;break}this.details[d]=e}if(!this._detailsUpdate)return this.rendergridcontent(!0),this._updatecolumnwidths(),this._updatecellwidths(),this._renderrows(this.virtualsizeinfo),!0},getrowdetails:function(d){if(null==d)return!1;d=this.getrowvisibleindex(d);return this._getrowdetails(d)},_getrowdetails:function(d){if(null==d||
8520>d)return!1;if(this.details[d])return this.details[d];if(this.rowdetailstemplate)return"function"===typeof this.rowdetailstemplate?(d=this.rowdetailstemplate(d),void 0===d.rowdetailshidden&&(d.rowdetailshidden=!0),void 0===d.rowdetailsheight&&(d.rowdetailsheight=200),void 0===d.rowdetails&&(d.rowdetails="<div></div>"),d):this.rowdetailstemplate},getrecordscount:function(){return this.dataview.totalrecords},showrowdetails:function(d){if(this._loading)throw Error("jqxGrid: "+this.loadingerrormessage);
853if(null==d)return!1;this.detailsVisibility||(this.detailsVisibility=[]);this.detailsVisibility[d]=!1;d=this.getrowvisibleindex(d);if(0>d)return!1;
853var e=this._getrowdetails(d);return this._setrowdetailsvisibility(d,e,!1)},hiderowdetails:function(d){if(this._loading)throw Error("jqxGrid: "+this.loadingerrormessage);this.detailsVisibility||(this.detailsVisibility=[]);this.detailsVisibility[d]=!0;d=this.getrowvisibleindex(d);if(0>d)return!1;var e=this._getrowdetails(d);return this._setrowdetailsvisibility(d,
854e,!0)},_togglerowdetails:function(d){this.detailsVisibility||(this.detailsVisibility=[]);var e=d.visibleindex,f=this._getrowdetails(e);if(null!=f){var g=this.vScrollInstance.value,h=!f.rowdetailshidden;d=this.getboundindex(d);void 0!=d&&(this.detailsVisibility[d]=h);e=this._setrowdetailsvisibility(e,f,h);0!==g&&"hidden"!==this.vScrollBar.css("visibility")&&(g<=this.vScrollInstance.max?this.vScrollInstance.setPosition(g):this.vScrollInstance.setPosition(this.vScrollInstance.max));return e}return!1},
855_setrowdetailsvisibility:function(d,e,f){if(this.rowdetailstemplate&&(this.details||(this.details=[]),!this.details[d])){var g="function"===typeof this.rowdetailstemplate?this.rowdetailstemplate(d):this.rowdetailstemplate;void 0===g.rowdetailshidden&&(g.rowdetailshidden=!0);void 0===g.rowdetailsheight&&(g.rowdetailsheight=200);void 0===g.rowdetails&&(g.rowdetails="<div></div>");this.details[d]={rowdetailshidden:g.rowdetailshidden,rowdetailsheight:g.rowdetailsheight,rowdetails:g.rowdetails};g=this.dataview.generatekey();
856this.details[d].detailskey=g;this.detailboundrows[d]={index:d,details:this.details[d]}}if(null!=e)this.details[d].rowdetailshidden=f;else return!1;e=this.details[d];
856f?this._raiseEvent(21,{rowindex:d,details:e.rowdetails,height:e.rowdetailsheight}):this._raiseEvent(20,{rowindex:d,details:e.rowdetails,height:e.rowdetailsheight});return this._setrowdetails(d,e.rowdetails,e.rowdetailsheight,e.rowdetailshidden)},getrowvisibleindex:function(d){return void 0==d||null==d||0>d?!1:this.virtualmode?(d=this.dataview.loadedrecords[d],
857void 0==d?-1:d.visibleindex):this.getrowdisplayindex(d)},hiderow:function(d){if(this._loading)throw Error("jqxGrid: "+this.loadingerrormessage);if(void 0==d||null==d||0>d||null==d)return!1;this.hiddenboundrows[d]={index:d,hidden:!0};d=this.getrowvisibleindex(d);return this._setrowvisibility(d,!0)},showrow:function(d){if(this._loading)throw Error("jqxGrid: "+this.loadingerrormessage);if(void 0==d||null==d||0>d||null==d)return!1;this.hiddenboundrows[d]={index:d,hidden:!1};d=this.getrowvisibleindex(d);
858return this._setrowvisibility(d,!1)},isrowhiddenat:function(d){if(null==d)return null;d=this.getrowvisibleindex(d);if(this.rows.records[d])return this.rows.records[d].hidden},_setrowvisibility:function(d,e,f){if(null==d)return!1;this.hiddens[d]=e;return void 0==f||f?(this.rendergridcontent(!0),!0):!1},_loadrows:function(){if(this._pageviews[this.dataview.pagenum]||this.pageable){var d=this.pageable?0:this._pageviews[this.dataview.pagenum].top;if(!this.pageable&&void 0!=this._pagescache[this.dataview.pagenum])return null;
859if(this.virtualsizeinfo){var e=this.that,f=[],g=[],h=e.groupable&&0<e.groups.length,k=0;this.rows.beginupdate();var l=this.dataview.pagesize;this.pageable&&h&&(l=this.dataview.rows.length);for(var m=0;m<l&&!(m>=this.dataview.rows.length);m++){var n=this.dataview.rows[m];if(e.rows.records[n.visibleindex]){var r=e.rows.records[n.visibleindex];r.setdata(n)}else r=new c(e,n);r.hidden=this.hiddens[r.visibleindex];if(this.rowdetailstemplate){var t="function"===typeof this.rowdetailstemplate?this.rowdetailstemplate(r.boundindex):
860this.rowdetailstemplate;
860r.rowdetails=t.rowdetails;r.rowdetailsheight=t.rowdetailsheight;r.rowdetailshidden=t.rowdetailshidden;void 0===r.rowdetailshidden&&(r.rowdetailshidden=!0);void 0===r.rowdetailsheight&&(r.rowdetailsheight=200);void 0===r.rowdetails&&(r.rowdetails="<div></div>")}(t=this.details[r.visibleindex])?(r.rowdetails=t.rowdetails,r.rowdetailsheight=t.rowdetailsheight,r.rowdetailshidden=t.rowdetailshidden,void 0===r.rowdetailshidden&&(r.rowdetailshidden=!0),void 0===r.rowdetailsheight&&
861(r.rowdetailsheight=200),void 0===r.rowdetails&&(r.rowdetails="<div></div>")):this.rowdetailstemplate||(r.rowdetails=null);if(h&&this.pageable&&null!=r.parentbounddata){t=f[r.parentbounddata.uniqueid];if(null!=t){var u=this._findgroupstate(t.uniqueid);this._setsubgroupsvisibility&&this._setsubgroupsvisibility(this,r.parentbounddata,!u,!1);r.hidden=this.hiddens[r.visibleindex]}null!=t&&void 0!=t&&(r.parentrow=t,t.subrows[t.subrows.length++]=r)}r.hidden||(n=n.visibleindex,t=this.rowsheight,this.cardview&&
862(t=this.cardheight),this.heights[n]||(this.heights[n]=t),r.height=this.heights[n],this.rowdetails&&r.rowdetail
862s&&!r.rowdetailshidden&&(r.height+=r.rowdetailsheight),f[r.uniqueid]=r,g[k++]=r,r.top=d,d+=r.height,e.rows.replace(n,r))}(this.autoheight||this.pageable)&&this.autorowheight&&this._pageviews&&0<this._pageviews.length&&(this._pageviews[0].height=d);this.rows.resumeupdate();0<g.length&&(this._pagescache[this.dataview.pagenum]=g)}}},escape_HTML:function(d){return d.replace(/[&<>"]/g,function(e){return{"&":"&",
863"<":"<",">":">",'"':'"'}[e]||e})},_updateaddnewrowui:function(d){for(var e="bottom"!=this.everpresentrowposition?this.addnewrowtop:this.addnewrowbottom,f=this.columns.records.length,g=d=0;g<f;g++){var h=this.columns.records[g];h.addnewrowwidget&&a(h.addnewrowwidget).detach()}for(g=0;g<f;g++){h=this.columns.records[g];var k=h.width;k<h.minwidth&&(k=h.minwidth);k>h.maxwidth&&(k=h.maxwidth);var l=a(e[0].cells[g]);l.css("left",d);l.width();l.width(k);l[0].left=d;h.addnewrowwidget&&(l.html(""),l.append(h.addnewrowwidget));
864h.hidden&&h.hideable||h.adaptivehidden?l.css("display","none"):d+=k}f=this.everpresentrowactions.split(" ");this.addnewrowbutton.show();this.addnewrowupdatebutton.show();this.addnewrowresetbutton.show();this.addnewrowdeletebutton.show();-1==f.indexOf("add")&&-1==f.indexOf("addBottom")&&this.addnewrowbutton.hide();-1==f.indexOf("update")&&this.addnewrowupdatebutton.hide();-1==f.indexOf("reset")&&this.addnewrowresetbutton.hide();-1==f.indexOf("delete")&&this.addnewrowdeletebutton.hide();e=a(e.children()[0]);
865e.width(parseInt(d)+2);e.height(this.everpresentrowheight);e.css("max-height",this.everpresentrowheight+"px")},_removeaddnewrow:function(){for(var d=this.columns.records.length,e=0;e<d;e++){var f=this.columns.records[e];f.addnewrowwidget&&(f.destroyeverpresentrowwidget?f.destroyeverpresentrowwidget(f.addnewrowwidget):f.addnewrowwidget.remove(),f.addnewrowwidget=null)}this.addnewrowbutton&&this.addnewrowbutton.remove();this.addnewrowupdatebutton&&this.addnewrowupdatebutton.remove();this.addnewrowdeletebutton&&
866this.addnewrowdeletebutton.remove();this.addnewrowresetbutton&&this.addnewrowresetbutton.remove();this.addnewrowpopup&&(this.addnewrowpopup.remove(),this.addnewrowpopup=null);this.addnewrowtop&&(this.addnewrowtop.remove(),this.addnewrowtop=null);this.addnewrowbottom&&(this.addnewrowbottom.remove(),this.addnewrowbottom=null)},_updateaddnewrow:function(){var d=this,e="bottom"!=d.everpresentrowposition?d.addnewrowtop:d.addnewrowbottom,f=a('<div style="position: relative;" id="row000'+d.element.id+'"></div>'),
867g=0,h=d.columns.records.length,k=d.toThemeProperty("jqx-grid-cell");k+=" "+d.toThemeProperty("jqx-grid-cell-add-new-row");k+=" "+d.toThemeProperty("jqx-grid-cell-filter-row");var l=h+10,m=[];e[0].cells=m;f.height(d.everpresentrowheight);d.showfilterrow||"bottom"==d.everpresentrowposition?d.showfilterrow&&"bottom"!=d.everpresentrowposition&&e.css("max-height",d.everpresentrowheight-3+"px"):e.css("max-height",d.everpresentrowheight-1+"px");f.css("max-height",d.everpresentrowheight+"px");e.append(f);
868var n=a("<div style='border-width: 1px; border-style: solid; padding: 5px; z-index: 99; display: none; position: absolute;'><div>").appendTo(a(document.body)),r=a("<button style='position: relative; float: left; margin: 2px; border-radius: 0px; padding: 4px 8px;'>"+d.gridlocalization.addrowstring+"</button>"),t=a("<button style='position: relative; float: left; margin: 2px; border-radius: 0px; padding: 4px 8px;'>"+d.gridlocalization.udpaterowstring+"</button>"),u=a("<button style='position: relative; float: left; margin: 2px; border-radius: 0px; padding: 4px 8px;'>"+
869d.gridlocalization.deleterowstring+"</button>"),x=a("<button style='position: relative; float: left; margin: 2px; border-radius: 0px; padding: 4px 8px;'>"+d.gridlocalization.resetrowstring+"</button>");n.addClass(d.toThemeProperty("jqx-popup"));n.addClass(d.toThemeProperty("jqx-rc-all"));n.addClass(d.toThemeProperty("jqx-fill-state-normal"));n.addClass(d.toThemeProperty("jqx-shadow"));n.append(r);n.append(t);n.append(u);n.append(x);var B=d.everpresentrowactions.split(" ");-1==B.indexOf("add")&&-1==
870B.indexOf("addBottom")&&r.hide();-1==B.indexOf("update")&&t.hide();-1==B.indexOf("reset")&&x.hide();-1==B.indexOf("delete")&&u.hide();d.addnewrowpopup=n;d.addnewrowbutton=r;d.addnewrowupdatebutton=t;d.addnewrowdeletebutton=u;d.addnewrowresetbutton=x;r.jqxButton({template:"success",theme:d.theme});u.jqxButton({template:"danger",theme:d.theme});t.jqxButton({template:"primary",theme:d.theme});x.jqxButton({template:"warning",theme:d.theme});t.mousedown(function(z){for(var V={},ba={},v=0;v<h;v++){var K=
871d.columns.records[v];if(K.geteverpresentrowwidgetvalue){var C=K.geteverpresentrowwidgetvalue(K.displayfield,K.addnewrowwidget);ba[K.datafield]=C;K.datafield!=K.displayfield&&(ba[K.datafield]=C.value,ba[K.displayfield]=C.label)}}var da=!1;for(v=0;v<h;v++)if(K=d.columns.records[v],K.geteverpresentrowwidgetvalue){C=K.geteverpresentrowwidgetvalue(K.displayfield,K.addnewrowwidget);if(K.createeverpresentrowwidget&&K.validateeverpresentrowwidgetvalue){var ja=K.validateeverpresentrowwidgetvalue(K.displayfield,
872C,ba),ea=d.gridlocalization.validationstring;void 0!=ja.message&&(ea=ja.message);("boolean"==typeof ja?ja:ja.result)?(K.addnewrowwidget.attr("title",""),K.addnewrowwidget.removeClass(d.toThemeProperty("jqx-input-invalid"))):(C="invalid editor state",K.addnewrowwidget.attr("title",ea),K.addnewrowwidget.addClass(d.toThemeProperty("jqx-input-invalid")))}"invalid editor state"===C&&(z.preventDefault(),z.stopPropagation(),da=!0)}if(!da){for(v=0;v<h;v++)K=d.columns.records[v],K.geteverpresentrowwidgetvalue&&
873(C=K.geteverpresentrowwidgetvalue(K.displayfield,K.addnewrowwidget),V[K.datafield]=C,K.datafield!=K.displayfield&&(V[K.datafield]=C.value,V[K.displayfield]=C.label),K.reseteverpresentrowwidgetvalue&&K.reseteverpresentrowwidgetvalue(K.displayfield,K.addnewrowwidget));if(0<d.selectedcells.length||0<d.selectedrowindexes.length)z=0<=d.selectionmode.indexOf("cell")?d.getselectedcells()[0].rowindex:d.selectedrowindexes[0],(z=d.getrowdata(z))&&d.updaterow(z.uid,V)}n.hide();d.focus()});u.mousedown(function(z){if(0<
874d.selectedcells.length||0<d.selectedrowindexes.length)z=0<=d.selectionmode.indexOf("cell")?d.getselectedcells()[0].rowindex:d.selectedrowindexes[0],(z=d.getrowdata(z))&&d.deleterow(z.uid);for(z=0;z<h;z++){var V=d.columns.records[z];V.reseteverpresentrowwidgetvalue&&V.reseteverpresentrowwidgetvalue(V.displayfield,V.addnewrowwidget)}n.hide();d.focus();d.updateeverpresentrow()});r.mousedown(function(z){for(var V={},ba={},v=0;v<h;v++){var K=d.columns.records[v];if(K.geteverpresentrowwidgetvalue){var C=
875K.geteverpresentrowwidgetvalue(K.displayfield,K.addnewrowwidget);ba[K.datafield]=C;K.datafield!=K.displayfield&&(ba[K.datafield]=C.value,ba[K.displayfield]=C.label);K.datafield!=K.displayfield&&(ba[K.datafield]=C.label,ba[K.displayfield]=C.value)}}var da=!1;for(v=0;v<h;v++)if(K=d.columns.records[v],K.geteverpresentrowwidgetvalue){C=K.geteverpresentrowwidgetvalue(K.displayfield,K.addnewrowwidget);if(K.createeverpresentrowwidget&&K.validateeverpresentrowwidgetvalue){var ja=K.validateeverpresentrowwidgetvalue(K.displayfield,
876C,ba),ea=d.gridlocalization.validationstring;void 0!=ja.message&&(ea=ja.message);("boolean"==typeof ja?ja:ja.result)?(K.addnewrowwidget.attr("title",""),K.addnewrowwidget.removeClass(d.toThemeProperty("jqx-input-invalid"))):(C="invalid editor state",K.addnewrowwidget.attr("title",ea),K.addnewrowwidget.addClass(d.toThemeProperty("jqx-input-invalid")))}"invalid editor state"===C&&(z.preventDefault(),z.stopPropagation(),da=!0)}if(!da){for(v=0;v<h;v++)K=d.columns.records[v],K.geteverpresentrowwidgetvalue&&
877(C=K.geteverpresentrowwidgetvalue(K.displayfield,K.addnewrowwidget),V[K.datafield]=C,K.datafield!=K.displayfield&&(ba[K.datafield]=C.label,ba[K.displayfield]=C.value),K.reseteverpresentrowwidgetvalue&&K.reseteverpresentrowwidgetvalue(K.displayfield,K.addnewrowwidget));z=0<=d.everpresentrowactions.indexOf("addBottom")?"last":"first";d.addrow(null,V,z)}n.hide();d.focus()});x.mousedown(function(z){for(z=0;z<h;z++){var V=d.columns.records[z];V.reseteverpresentrowwidgetvalue&&V.reseteverpresentrowwidgetvalue(V.displayfield,
878V.addnewrowwidget);V.addnewrowwidget&&(V.addnewrowwidget.attr("title",""),V.addnewrowwidget.removeClass(d.toThemeProperty("jqx-input-invalid")))}n.hide();d.focus()});for(B=0;B<h;B++){var y=d.columns.records[B],A=y.width;A<y.minwidth&&(A=y.minwidth);A>y.maxwidth&&(A=y.maxwidth);var aa=a('<div style="overflow: hidden; position: absolute; height: 100%;" class="'+k+'"></div>');f.append(aa);aa.css("left",g);d.rtl?(aa.css("z-index",l++),aa.css("border-left-width","1px")):aa.css("z-index",l--);"auto"==A&&
879(A=0);aa[0].style.width=parseFloat(A)+"px";aa[0].left=g;y.hidden&&y.hideable||y.adaptivehidden?aa.css("display","none"):g+=A;m[m.length]=aa[0];if(y.checkboxcolumn)y=d.toThemeProperty("jqx-grid-cell"),y+=" "+d.toThemeProperty("jqx-grid-cell-filter-row"),y+=" "+d.toThemeProperty("jqx-grid-cell-pinned"),aa.removeClass().addClass(y);else{A=!0;
879if(d.rtl)d.groupable&&(ha=d.showrowdetailscolumn&&d.rowdetails?1:0,d.groups.length+ha+B>h-1&&(A=!1)),d.showrowdetailscolumn&&d.rowdetails&&B==h-1&&(A=!1);else{if(d.groupable){var ha=
880d.showrowdetailscolumn&&d.rowdetails?1:0;d.groups.length+ha>B&&(A=!1)}d.showrowdetailscolumn&&d.rowdetails&&0==B&&(A=!1)}d.updateeverpresentrow=function(){var z=null;if(0<d.selectedcells.length||0<d.selectedrowindexes.length){var V=0<=d.selectionmode.indexOf("cell")?d.getselectedcells()[0].rowindex:d.selectedrowindexes[0];z=d.getrowdata(V)}if(z)for(z=0;z<d.columns.records.length;z++){var ba=d.columns.records[z];if(ba.seteverpresentrowwidgetvalue){var v=d.getcelltext(V,ba.displayfield);ba.seteverpresentrowwidgetvalue(ba.addnewrowwidget,
881v)}}};A&&(y.createeverpresentrowwidget?(y.addnewrowwidget=y.createeverpresentrowwidget(y.datafield,aa,n,function(){r.trigger("mousedown")}),y.initeverpresentrowwidget&&y.initeverpresentrowwidget(y.datafield,aa,n)):(d._measureElement("column"),A=d.everpresentrowheight/2-d._columnheight/2,0>A&&(A=6),A+="px","addButtonColumn"===y.datafield?(y=a('<div style="padding-bottom: 2px; text-align: center; margin-top: '+A+';"><a href="#">'+d.gridlocalization.addrowstring+"</a></div>"),aa.append(y),y.mousedown(function(){r.trigger("mousedown")})):
882"resetButtonColumn"===y.datafield?(y=a('<div style="padding-bottom: 2px; text-align: center; margin-top: '+A+';"><a href="#">'+d.gridlocalization.resetrowstring+"</a></div>"),aa.append(y),y.mousedown(function(){x.trigger("mousedown")})):function(z,V,ba){var v=a('<input style="box-sizing: border-box; padding-right: 4px; padding-left: 4px; border:none;" autocomplete="off" type="textarea"/>');v[0].id=a.jqx.utilities.createId();v.addClass(z.toThemeProperty("jqx-widget"));v.addClass(z.toThemeProperty("jqx-input"));
883v.addClass(z.toThemeProperty("jqx-widget-content"));v.addClass(z.toThemeProperty("jqx-enableselect"));v.addClass(z.toThemeProperty("jqx-grid-cell-add-new-row"));v.css("text-align",ba.cellsalign);z.rtl&&v.css("direction","rtl");z.disabled&&v.attr("disabled",!0);v.attr("disabled",!1);v.attr("placeholder",z.gridlocalization.everpresentrowplaceholder+ba.text);v.appendTo(V);v.css("width","100%");v.css("height",z.everpresentrowheight+"px");v.css("line-height",z.everpresentrowheight+"px");v.css("max-height",
884z.everpresentrowheight+"px");v.css("margin","0px");v.focus(function(){(0<d.selectedcells.length||0<d.selectedrowindexes.length)&&0<=d.selectionmode.indexOf("cell")&&d.getselectedcells();v.addClass(z.toThemeProperty("jqx-fill-state-focus"));var K=z.columns.records.indexOf(ba);"columns"!==z.everpresentrowactionsmode&&n.css({display:"block",top:v.coord().top+z.everpresentrowheight-1,left:0<K?v.coord().left:v.coord().left-1});K=n.children().width();"right"===ba.cellsalign?(K=r.width()+x.width(),n.children().css("left",
885K-K+"px")):n.children().css("left","0px");z.content[0].scrollLeft=0;z.content[0].scrollTop=0;setTimeout(function(){z.content[0].scrollLeft=0;z.content[0].scrollTop=0},50);return!1});ba.addnewrowwidget=v;ba.reseteverpresentrowwidgetvalue||(ba.reseteverpresentrowwidgetvalue=function(K,C){C.val("");C.focus();C.blur();C.removeClass(d.toThemeProperty("jqx-input-invalid"));C.attr("title","")});ba.seteverpresentrowwidgetvalue||(ba.seteverpresentrowwidgetvalue=function(K,C){K.val(C)});ba.geteverpresentrowwidgetvalue||
886(ba.geteverpresentrowwidgetvalue=function(K,C,da){K=C.val();if(!1!==da&&ba.validateeverpresentrowwidgetvalue){da={};for(C=0;C<h;C++){var ja=d.columns.records[C];if(ja.geteverpresentrowwidgetvalue){var ea=ja.geteverpresentrowwidgetvalue(ja.displayfield,ja.addnewrowwidget,!1);da[ja.datafield]=ea;ja.datafield!=ja.displayfield&&(da[ja.datafield]=ea.value,da[ja.displayfield]=ea.label)}}da=ba.validateeverpresentrowwidgetvalue(ba.displayfield,K,da);C=d.gridlocalization.validationstring;void 0!=da.message&&
887(C=da.message);if("boolean"==typeof da?da:da.result)v.removeClass(d.toThemeProperty("jqx-input-invalid")),v.attr("title","");else return v.addClass(d.toThemeProperty("jqx-input-invalid")),v.attr("title",C),"invalid editor state"}da="string";if(C=d.source.datafields||(d.source._source?d.source._source.datafields:null)){var ra="";a.each(C,function(){if(this.name==ba.displayfield)return this.type&&(ra=this.type),!1});ra&&(da=ra)}return"number"===da&&(C=parseFloat(K),isNaN(C))?null:"date"===da?a.jqx.dataFormat.tryparsedate(K,
888d.gridlocalization):"bool"===da||"boolean"===da?"true"===K||"1"==K?!0:"false"===K||"0"==K?!1:!0===K||!1===K?K:!1:K});v.keydown(function(K){13===K.keyCode&&(0<=d.everpresentrowactions.indexOf("add")?r.trigger("mousedown"):0<=d.everpresentrowactions.indexOf("update")?t.trigger("mousedown"):0<=d.everpresentrowactions.indexOf("delete")&&u.trigger("mousedown"))});v.blur(function(){v.removeClass(z.toThemeProperty("jqx-fill-state-focus"));n.css("display","none")});ba.initeverpresentrowwidget&&ba.initeverpresentrowwidget(ba.datafield,
889V,n)}(this,aa,y)))}}a.jqx.browser.msie&&8>a.jqx.browser.version&&f.css("z-index",l--);f.width(parseFloat(g)+2);e.addClass(k);e.css("border-bottom-width","0px");d.showfilterrow?e.css("border-top-width","0px"):e.css("border-top-width","1px");e.css("box-sizing","border-box");e.css("border-right-width","0px")},_gettableheight:function(){if(void 0!=this.tableheight)return this.tableheight;var d=this.host.height();if(this.columnsheader){var e=this.columnsheader.outerHeight();this.showheader||(e=0)}d-=e;
890"visible"==this.hScrollBar[0].style.visibility&&(d-=this.hScrollBar.outerHeight());this.pageable&&(d-=this.pager.outerHeight());this._groupsheader()&&(d-=this.groupsheader.outerHeight());this.showtoolbar&&(d-=this.toolbarheight);this.showfilterbar&&(d-=this.toolbarheight);this.showstatusbar&&(d-=this.statusbarheight);this.showeverpresentrow&&"bottom"===this.everpresentrowposition&&(d-=this.everpresentrowheight);return 0<d?this.tableheight=d:this.host.height()},_getpagesize:function(){if(this.pageable)return this.pagesize;
891if(this.virtualmode){var d=Math.round(this.host.height())+2*this.rowsheight;return Math.round(d/this.rowsheight)}return this.autoheight||this.autorowheight?0==this.dataview.totalrows?1:this.dataview.totalrows:100>this.dataview.totalrows&&100>
891this.dataview.totalrecords&&0<this.dataview.totalrows?this.dataview.totalrows:100},_calculatevirtualheight:function(){var d=Math.round(this.host.height())+2*this.rowsheight,e=this._gettableheight();d=Math.round(d/this.rowsheight);this.heights=[];this.hiddens=
892[];this.details=[];this.expandedgroups=[];this.hiddenboundrows=[];this.heightboundrows=[];this.detailboundrows=[];var f=Math.max(this.dataview.totalrows,this.dataview.totalrecords);this.pageable&&(f=this.pagesize,this.pagesize>Math.max(this.dataview.totalrows,this.dataview.totalrecords)&&this.autoheight?f=Math.max(this.dataview.totalrows,this.dataview.totalrecords):this.autoheight||this.dataview.totalrows<this.pagesize&&(f=Math.max(this.dataview.totalrows,this.dataview.totalrecords)));var g=f*this.rowsheight;
893this.cardview&&(g-=d*this.rowsheight);var h=0,k=0,l=0,m=this._getpagesize(),n=m*this.rowsheight,r=0;!this.pageable&&this.autoheight&&(d=f);if(0<f+m)for(;r<=f+m;){h+=n;if(r-m<f&&r>=f){r-=f;0<r&&(l-=n,this._pageviews[k-1]={top:l,height:n-r*this.rowsheight});break}else this._pageviews[k++]={top:l,height:n};l=h;r+=m}1!=this.resizingGrid&&this.vScrollBar.jqxScrollBar({value:0});if("hidden"==this.hScrollBar.css("visibility")&&(k=0,this.columns&&this.columns.records)){for(r=0;r<this.columns.records.length;r++)k+=
894isNaN(this.columns.records[r].width)?this.columns.records[r].minwidth:this.columns.records[r].width;!isNaN(k)&&parseInt(k)>this.host.width()&&(e-=30)}g>e&&!this.autoheight?(this.vScrollBar.css("visibility","visible"),"deferred"==this.scrollmode?this.vScrollBar.jqxScrollBar({max:g}):(this.vScrollBar.jqxScrollBar({max:g-e}),this.cardview&&this.vScrollBar.jqxScrollBar({step:this.cardheight}))):this.vScrollBar.css("visibility","hidden");this.dataview.pagesize=m;this.dataview.updateview();return{visiblerecords:d,
895virtualheight:g}},_updatepageviews:function(){if(!this.updating()){this._pagescache=[];this._pageviews=[];this.tableheight=null;var d=this.that,e=Math.round(this.host.height())+2*this.rowsheight;e=Math.round(e/this.rowsheight);var f=Math.max(this.dataview.totalrows,this.dataview.totalrecords),g=f*this.rowsheight,h=0,k=0,l=0,m=0,n=0,r=this._getpagesize();if(this.pageable)this._updatepagedview&&(g=this._updatepagedview(f,g,0)),this.autoheight&&this._arrange();else for(var t=0;t<f;t++){var u=this.heights[t],
896x=this.hiddens[t],B=this.details[t];void 0==this.heights[t]&&(u=this.heights[t]=this.rowsheight);void 0==this.hiddens[t]&&(x=this.hiddens[t]=!1);void 0==this.details[t]&&(this.details[t]=null);u!=d.rowsheight&&(g-=d.rowsheight,g+=u);x?g-=u:(k+=u,x=0,this.rowdetails&&(this.rowdetailstemplate&&!B&&(B="function"===typeof this.rowdetailstemplate?this.rowdetailstemplate():this.rowdetailstemplate,void 0===B.rowdetailshidden&&(B.rowdetailshidden=!0),void 0===B.rowdetailsheight&&(B.rowdetailsheight=200),
897void 0===B.rowdetails&&(B.rowdetails="<div></div>")),B&&B.rowdetails&&!B.rowdetailshidden&&(x=B.rowdetailsheight,k+=x,g+=x)),h+=u+x);n++;if(n>=r||t==f-1)this._pageviews[l++]={top:m,height:k},k=0,m=h,n=0}d=this._gettableheight();g>d?(this.pageable&&this.gotopage&&(g=this._pageviews[0].height,0>g&&(g=this._pageviews[0].height)),"visible"!=this.vScrollBar.css("visibility")&&this.vScrollBar.css("visibility","visible"),(g<=d||this.autoheight)&&this.vScrollBar.css("visibility","hidden"),0<g-d?"deferred"!=
898this.scrollmode?(d=g-d,f=this.vScrollInstance.max,this.vScrollBar.jqxScrollBar({max:d}),d!=f&&this.vScrollBar.jqxScrollBar({value:0})):this.vScrollBar.jqxScrollBar({value:0,max:g}):this.vScrollBar.jqxScrollBar({value:0,max:g})):(this._loading||this.vScrollBar.css("visibility","hidden"),this.vScrollBar.jqxScrollBar({value:0}));this._arrange();this.autoheight&&(e=Math.round(this.host.height()/this.rowsheight));this.virtualsizeinfo={visiblerecords:e,virtualheight:g}}},updatebounddata:function(d){if("data"!=
899d&&"sort"!=d&&"filter"!=d&&"cells"!=d&&"pagechanged"!=d&&"pagesizechanged"!=d&&!this.virtualmode){this.virtualsizeinfo=null;if(this.columns&&this.columns.records)for(var e=0;e<this.columns.records.length;e++){var f=this.columns.records[e];f.destroywidget&&f.widget&&f.destroywidget&&f.destroywidget(f.widget)}this.showfilterrow&&this.filterable&&this.filterrow?(this.clearfilters&&this.clearfilters(!1),this.filterable&&this._destroyedfilters&&this.showfilterrow&&this._destroyedfilters(),this.filterrow.remove(),
900this._filterrowcache=[],this.filterrow=null):this.filterable&&this.clearfilters&&this.clearfilters(!1);this.showeverpresentrow&&this._removeaddnewrow();this.detailsVisibility=[];this.groupsVisibility=[];this.groupable&&(this.dataview.groups=[],this.groups=[]);this.pageable&&(this.pagenum=0,this.dataview.pagenum=0);this.sortable&&(this.sortcolumn=null,this.sortdirection="",this.dataview.sortfielddirection="",this.dataview.clearsortdata())}this.databind(this.source,d)},refreshdata:function(){this._refreshdataview();
901this.render()},_updatevscrollbarmax:function(){if(this._pageviews&&0<this._pageviews.length){var d=this._pageviews[0].height;if(this.virtualmode||!this.pageable)d=this.virtualsizeinfo.virtualheight;var e=this._gettableheight();d>e?(this.pageable&&this.gotopage&&(d=this._pageviews[0].height,0>d&&(d=this._pageviews[0].height)),"visible"!=this.vScrollBar.css("visibility")&&this.vScrollBar.css("visibility","visible"),(d<=e||this.autoheight)&&this.vScrollBar.css("visibility","hidden"),0<d-e?this.vScrollBar.jqxScrollBar({max:d-
902e}):this.vScrollBar.jqxScrollBar({value:0,max:d})):(this.vScrollBar.css("visibility","hidden"),this.vScrollBar.jqxScrollBar({value:0}))}},_refreshdataview:function(){this.dataview.refresh()},refresh:function(d){1==d||a.jqx.isHidden(this.host)||null==this.virtualsizeinfo||(this._cellscache=[],this._renderrows(this.virtualsizeinfo),this._updatesize())},render:function(){this._render(!0,!0,!0,!0)},invalidate:function(){this.virtualsizeinfo&&(this._updatecolumnwidths(),this._updatecellwidths(),this._renderrows(this.virtualsizeinfo))},
903clear:function(){this.databind(null);this.render()},_preparecolumngroups:function(){var d=this.columnsheight;if(this.columngroups){this.columnshierarchy=[];if(this.columngroups.length){var e=this;for(d=0;d<this.columngroups.length;d++)this.columngroups[d].parent=null,this.columngroups[d].groups=null;for(d=0;d<this.columns.records.length;d++)this.columns.records[d].parent=null,this.columns.records[d].groups=null;var f=function(n){for(var r=0;r<e.columngroups.length;r++){var t=e.columngroups[r];if(t.name===
904n)return t}return null};for(d=0;d<this.columngroups.length;d++){var g=this.columngroups[d];g.groups||(g.groups=null);if(g.parentgroup){var h=f(g.parentgroup);h&&(g.parent=h,h.groups||(h.groups=[]),-1===h.groups.indexOf(g)&&h.groups.push(g))}}for(d=0;d<this.columns.records.length;d++)if(g=this.columns.records[d],g.columngroup&&(h=f(g.columngroup)))h.groups||(h.groups=[]),g.parent=h,-1===h.groups.indexOf(g)&&h.groups.push(g);for(d=f=0;d<this.columns.records.length;d++){h=g=this.columns.records[d];for(g.level=
9050;h.parent;)h=h.parent,g.level++;h=g;var k=g.level;for(f=Math.max(f,g.level);h.parent;)if(h=h.parent)h.level=--k}var l=function(n){var r=[];n.columngroup&&r.push(n);if(n.groups)for(var t=0;t<n.groups.length;t++)if(n.groups[t].columngroup)r.push(n.groups[t]);else if(n.groups[t].groups)for(var u=l(n.groups[t]),x=0;x<u.length;x++)r.push(u[x]);return r};for(d=0;d<this.columngroups.length;d++){g=this.columngroups[d];h=l(g);g.columns=h;g=[];for(var m=k=0;m<h.length;m++)g.push(this.columns.records.indexOf(h[m])),
906h[m].pinned&&k++;
906if(0!=k)throw Error("jqxGrid: Column Groups initialization Error. Please, check the initialization of the jqxGrid's columns array. The columns in a column group cannot be pinned.");g.sort(function(n,r){n=parseInt(n);r=parseInt(r);return n<r?-1:n>r?1:0});for(h=1;h<g.length;h++)if(g[h]!=g[h-1]+1)throw Error("jqxGrid: Column Groups initialization Error. Please, check the initialization of the jqxGrid's columns array. The columns in a column group are expected to be siblings in the columns array.");
907}}this.columngroupslevel=1+f;d=this.columngroupslevel*this.columnsheight}return d},_render:function(d,e,f,g,h){if(null!=this.dataview&&!this._loading&&!this._batchupdate)if(a.jqx.isHidden(this.host)){var k=this;k.___hiddenTimer&&(clearInterval(k.___hiddenTimer),k.___hiddenTimer=null);this.___hiddenTimer=setInterval(function(){a.jqx.isHidden(k.host)||(clearInterval(k.___hiddenTimer),k.render())},300)}else{null!=this.editcell&&this.endcelledit&&this.endcelledit(this.editcell.row,this.editcell.column,
908!0,!1);this.validationpopup=null;this._removeHandlers();this._addHandlers();this._initializeRows();this._requiresupdate=void 0!=e?e:!0;this._newmax=null;if(f)if(this._requiresupdate||0!=g&&this._initmenu(),null==this.columns)this.columns=new a.jqx.collection(this.element);else{var l=this;this.columns&&"observableArray"===this.columns.name&&(this.columns.notifier=function(m){switch(m.type){case "add":l.columns=l._columns;l.render();break;case "update":if("index"===m.name){l.beginupdate();for(var n in m.newValue)l.setcolumnproperty(m.newValue.datafield,
909n,m.newValue[n]);l.endupdate()}else n=m.path.split("."),l.setcolumnproperty(l.columns[n[0]].datafield,m.name,m.newValue);break;case "delete":l.columns=l._columns,l.render()}});this.columngroups&&"observableArray"===this.columngroups.name&&(this.columngroups.notifier=function(m){l.render()});this._initializeColumns()}this.tableheight=null;this._pagescache=[];this._pageviews=[];this.visiblerows=[];this.hittestinfo=[];this._requiresupdate&&(this._clearcaches(),1==g&&this._initmenu());this.virtualsizeinfo=
910null;this.prerenderrequired=!0;(this.groupable&&0<this.groups.length&&this.rowdetails||this.rowdetails)&&this.gridcontent&&(this._rowdetailscache=[],this._rowdetailselementscache=[],this.detailboundrows=[],this.details=[],a.jqx.utilities.html(this.gridcontent,""),this.gridcontent=null);this.gridcontent&&this.editable&&this._destroyeditors&&this._destroyeditors();f?(this.filterrow&&this.filterrow.detach(),a.jqx.utilities.html(this.content,""),this.columnsheader=this.columnsheader||a('<div style="overflow: hidden;"></div>'),
911this.columnsheader.remove(),this.columnsheader.addClass(this.toTP("jqx-widget-header")),this.columnsheader.addClass(this.toTP("jqx-grid-header"))):this.gridcontent&&a.jqx.utilities.html(this.gridcontent,"");this.showheader?this.columnsheader&&this.columnsheader.css("display","block"):this.columnsheader.css("display","none");this.gridcontent=this.gridcontent||a('<div style="width: 100%; overflow: hidden; position: absolute;"></div>');this.gridcontent.remove();d=this.columnsheight;d=this._preparecolumngroups();
912this.showfilterrow&&this.filterable?(this.columnsheader.height(d+this.filterrowheight),this.showeverpresentrow&&"bottom"!==this.everpresentrowposition&&this.columnsheader.height(d+this.filterrowheight+this.everpresentrowheight)):this.showeverpresentrow&&"bottom"!==this.everpresentrowposition?this.columnsheader.height(d+this.everpresentrowheight):this.columnsheader.height(d);this.content.append(this.columnsheader);this.content.append(this.gridcontent);this._arrange();this._initgroupsheader&&this._initgroupsheader();
913this.selectionarea=this.selectionarea||a("<div style='z-index: 99; visibility: hidden; position: absolute;'></div>");this.selectionarea.addClass(this.toThemeProperty("jqx-grid-selectionarea"));this.selectionarea.addClass(this.toThemeProperty("jqx-fill-state-pressed"));this.content.append(this.selectionarea);this.tableheight=null;this.rendergridcontent(!1,f);0<this.groups.length&&this.groupable&&(d=this.vScrollBar[0].style.visibility,this.suspendgroupevents=!0,this.collapseallgroups&&(this.groupsexpandedbydefault?
914this.expandallgroups(!1):(this.collapseallgroups(!1),this._updatescrollbarsafterrowsprerender())),this.vScrollBar[0].style.visibility!=d&&(this._updatecolumnwidths(),this._updatecellwidths()),this.suspendgroupevents=!1);this.pageable&&this.updatepagerdetails&&(this.updatepagerdetails(),this.autoheight&&this._updatepageviews(),this.autorowheight&&(this.autoheight||this._updatepageviews(),this._renderrows(this.virtualsizeinfo)));this.showaggregates&&this._updateaggregates&&this._updateaggregates();
915this._addoverlayelement();
915"deferred"==this.scrollmode&&this._addscrollelement();this.showfilterrow&&this.filterable&&this.filterrow&&(void 0==h||1==h)&&this._updatelistfilters(!f);(this.filterable&&"simple"===this.filtermode||"default"===this.filtermode&&this.showfilterbar)&&this._renderfilter();this.rendered&&this.rendered("full");this.__isRendered=!0}},_addoverlayelement:function(){var d=a.jqx.utilities.getBrowser();if("msie"==d.browser&&9>parseInt(d.version)||this.isTouchDevice())if(this._overlayElement&&
916this._overlayElement.remove(),this._overlayElement=a("<div class='jqxgrid-overlay' style='visibility: hidden; position: absolute; width: 100%; height: 100%;'></div>"),this._overlayElement.css("background","white"),this._overlayElement.css("z-index",180),this._overlayElement.css("opacity",.001),this.isTouchDevice())if("hidden"!==this.vScrollBar.css("visibility")||"hidden"!==this.hScrollBar.css("visibility")){d=0;"checkbox"==this.selectionmode&&(d+=30);(this.groupable||this.rowdetails)&&this._overlayElement.css("left",
91730*(this.groups.length+(this.rowdetails?1:0)));var e=this._overlayElement.css("left");this._overlayElement.css("left",e+d);if(this.cardview){this.content.prepend(this._overlayElement);var f=this;this.host.on("mouseup",function(){f._overlayElement.css("visibility","visible")});this._overlayElement[0].onmouseup=function(g){f._overlayElement.css("visibility","hidden");g.stopPropagation()}}}else this._overlayElement&&this._overlayElement.remove();else this.content.prepend(this._overlayElement);this._updateTouchScrolling()},
918_addscrollelement:function(){this._scrollelement&&this._scrollelement.remove();this._scrollelementoverlay&&this._scrollelementoverlay.remove();this._scrollelementoverlay=a("<div style='visibility: hidden; position: absolute; width: 100%; height: 100%;'></div>");this._scrollelementoverlay.css("background","black");this._scrollelementoverlay.css("z-index",1800);this._scrollelementoverlay.css("opacity",.1);this._scrollelement=a("<span style='visibility: hidden; top: 50%; right: 10px; position: absolute;'></span>");
919this._scrollelement.css("z-index",1900);this._scrollelement.addClass(this.toThemeProperty("jqx-button"));this._scrollelement.addClass(this.toThemeProperty("jqx-fill-state-normal"));this._scrollelement.addClass(this.toThemeProperty("jqx-rc-all"));this._scrollelement.addClass(this.toThemeProperty("jqx-shadow"));this.content.prepend(this._scrollelement);this.content.prepend(this._scrollelementoverlay)},_postrender:function(d){if(("filter"==d||"sort"==d||"group"==d)&&this.rowdetails&&this.detailsVisibility&&
9200<this.detailsVisibility.length){this._detailsUpdate=!0;for(var e=0;e<this.details.length;e++)this.details[e]&&(this.details[e].rowdetailshidden=!0);if(!this._loading)for(e=0;e<this.detailsVisibility.length;e++)!1===this.detailsVisibility[e]?this.showrowdetails(e):!0===this.detailsVisibility[e]&&this.hiderowdetail
920s(e);this._detailsUpdate=!1;this.rendergridcontent(!0);this._updatecolumnwidths();this._updatecellwidths();this._renderrows(this.virtualsizeinfo)}if(this.groupable&&0<this.groups.length)if("filter"==
921d||"sort"==d)for(e=0;e<this.dataview.loadedgroups.length;e++){d=this.dataview.loadedgroups[e];var f=0,g;for(g in this.groupsVisibility)g==d.group&&this.groupsVisibility[g]&&(this._setgroupstate(d,!0,!1),f++);0<f&&(d=this.vScrollBar[0].style.visibility,this.rendergridcontent(!0,!1),d!=this.vScrollBar[0].style.visibility||this._hiddencolumns)&&(this._updatecolumnwidths(),this._updatecellwidths(),this._renderrows(this.virtualsizeinfo))}else"group"==d&&(this.groupsVisibility=[])},rendergridcontent:function(d,
922e){if(this.updating())return!1;if(void 0==d||null==d)d=!1;this._requiresupdate=d;var f=this.prerenderrequired;this.prerenderrequired&&this._arrange();d=this.that;if(null==e||void 0==e)e=!0;this.tableheight=null;d.virtualsizeinfo=d.virtualsizeinfo||d._calculatevirtualheight();d.pageable&&!d.autoheight&&d.dataview.totalrows<d.pagesize&&(d._requiresupdate=!0);e?d._rendercolumnheaders():(this._rendersortcolumn&&this._rendersortcolumn(),this._renderfiltercolumn&&this._renderfiltercolumn());d._renderrows(d.virtualsizeinfo);
923this.gridcontent&&(0!=this.gridcontent[0].scrollTop&&(this.gridcontent[0].scrollTop=0),0!=this.gridcontent[0].scrollLeft&&(this.gridcontent[0].scrollLeft=0));f&&(e=this.tableheight,this._arrange(),e!=this.tableheight&&this.autoheight&&d._renderrows(d.virtualsizeinfo));this.rtl&&this._renderhorizontalscroll();this.autosavestate&&null!=this.initializedcall&&this.savestate&&this.savestate();if(this.adaptive&&this.element.offsetWidth<=this.adaptivewidth){var g=0,h=d.element.offsetWidth-2;a.each(this.columns.records,
924function(k,l){g+=this.width;if("adaptive"===this.columntype)return!0;g>=h&&(this.adaptivehidden=!0)});this._updatecolumnwidths();this._updatecellwidths();this._renderrows(this.virtualsizeinfo)}else this.adaptive&&(a.each(this.columns.records,function(k,l){if("adaptive"===this.columntype)return!0;this.adaptivehidden=!1}),this._updatecolumnwidths(),this._updatecellwidths(),this._renderrows(this.virtualsizeinfo));return!0},_updatecolumnwidths:function(){var d=this.host.width(),e=d,f="";if(void 0!=this.columns&&
925void 0!=this.columns.records){var g=this.that,h=this.rowdetails&&this.showrowdetailscolumn?(1+this.groups.length)*this.groupindentwidth:this.groups.length*this.groupindentwidth,k=0;if(this.adaptive&&this.element.offsetWidth<=this.adaptivewidth){var l=1;a.each(this.columns.records,function(B,y){this.adaptivehidden&&l++});var m=0<this.vScrollBar[0].offsetWidth?this.vScrollBar[0].offsetWidth+4:0;"hidden"==this.vScrollBar.css("visibility")&&(m=0);k=(this.element.offsetWidth-32-m)/(this.columns.records.length-
926l)}a.each(this.columns.records,function(B,y){if(!(this.hidden&&this.hideable||this.adaptivehidden))if(-1!=this.width.toString().indexOf("%")||void 0!=this._percentagewidth){B="hidden"==g.vScrollBar[0].style.visibility?0:g.scrollbarsize+5;if(g.scrollbarautoshow||0==g.scrollbarsize)B=0;var A=e;y=parseFloat(this.width)*A/100;B+=h;void 0!=this._percentagewidth&&(y=parseFloat(this._percentagewidth)*(A-B)/100);y<this.minwidth&&"auto"!=this.minwidth&&(y=this.minwidth);y>this.maxwidth&&"auto"!=this.maxwidth&&
927(y=this.maxwidth);d-=y}else"auto"==this.width||this._width?f+=this.text:d-=this.width});m=this._gettableheight();if(!this.autoheight&&this.virtualsizeinfo&&this.virtualsizeinfo.virtualheight>m)if(this.groupable&&0<this.groups.length)if(this.dataview&&this.dataview.loadedrootgroups&&!this.groupsexpandedbydefault){var n=this.dataview.loadedrootgroups.length*this.rowsheight;if(this.pageable)for(var r=0;r<this.dataview.rows.length;r++)this.dataview.rows[r].group&&0===this.dataview.rows[r].level&&(n+=
928this.rowsheight);n>m?(d-=this.scrollbarsize+5,e-=this.scrollbarsize+5):"visible"==this.vScrollBar.css("visibility")&&(d-=this.scrollbarsize+5,e-=this.scrollbarsize+5)}else d-=this.scrollbarsize+5,e-=this.scrollbarsize+5;else"hidden"!=this.vScrollBar.css("visibility")&&0<this.scrollbarsize&&(d-=this.scrollbarsize+5,e-=this.scrollbarsize+5);
928h=this.rowdetails&&this.showrowdetailscolumn?(1+this.groups.length)*this.groupindentwidth:this.groups.length*this.groupindentwidth;e-=h;if(this.columnsheader&&(m=
929this.columnsheader.find("#columntable"+this.element.id),0!=m.length)){var t=0,u=this,x=0;a.each(this.columns.records,function(B,y){y=a(this.element);this.hidden||this.adaptivehidden||"none"!==this.element.style.display||(this.element.style.display="block");this.adaptivehidden&&(this.element.style.display="none");var A=!1,aa=this.width;if(-1!=this.width.toString().indexOf("%")||void 0!=this._percentagewidth)aa=void 0!=this._percentagewidth?parseFloat(this._percentagewidth)*e/100:parseFloat(this.width)*
930e/100,A=!0;0<k&&"adaptive"!==this.columntype?(y.width(k),this.adaptivewidth=k):"auto"==this.width||this._width||A?A?(aa<this.minwidth&&"auto"!=this.minwidth&&(this.width=aa=this.minwidth),aa>this.maxwidth&&"auto"!=this.maxwidth&&(this.width=aa=this.maxwidth),parseInt(y[0].style.width)!=aa&&(y.width(aa),this.width=aa)):(A=Math.floor(this.text.length/f.length*d),x+=A,3>d-x&&d!=x&&.01<d-x?1===d-x?A++:A+=2:B==g.columns.records.length-1&&x<d&&(A+=d-x),isNaN(A)&&(A=this.minwidth),isNaN(A)&&(A=this.minwidth),
931Infinity==A&&(A=0),0>A&&(B=a("<span>"+u.escape_HTML(this.text)+"</span>"),a(document.body).append(B),A=10+B.width(),B.remove()),A<this.minwidth&&(A=this.minwidth),A>this.maxwidth&&(A=this.maxwidth),this._width="auto",this.width=A,y.width(this.width)):parseInt(y[0].style.width)!=this.width&&y.width(this.width);parseInt(y[0].style.left)!=t&&y.css("left",t);this.hidden&&this.hideable||this.adaptivehidden||(t=0<k&&"adaptive"!==this.columntype?t+k:t+this.width);this._requirewidthupdate=!0});this.columnsheader.width(2+
932t);m.width(this.columnsheader.width());this.columnsheader[0].style.visibility=0==t?"hidden":"inherit";this._resizecolumngroups();this.showfilterrow&&this.filterrow&&(this.filterrow.width(this.columnsheader.width()),this._updatefilterrowui());this.showeverpresentrow&&("bottom"!==this.everpresentrowposition?this.addnewrowtop.width(this.columnsheader.width()):this.addnewrowbottom.width(this.columnsheader.width()),this._updateaddnewrowui());this.autowidth&&this._arrange()}}},_rendercolumnheaders:function(){var d=
933this.that;this.cardview?(0<d.cardviewcolumns.length&&a.each(this.columns.records,function(V,ba){if("string"!==typeof d.cardviewcolumns[0]){V=!1;for(ba=0;ba<d.cardviewcolumns.length;ba++)d.cardviewcolumns[ba].datafield===this.datafield&&(this.__width=this.width,this.width=d.cardviewcolumns[ba].width||"",V=!0);V||(this.__hidden=this.hidden,this.hidden=!0)}else d.cardviewcolumns[V]?(this.__width=this.width,this.width=d.cardviewcolumns[V]):this.hideable&&(this.__hidden=this.hidden,this.hidden=!0)}),this._cardviewmode=
934!0):this._cardviewmode&&(a.each(this.columns.records,function(V,ba){void 0!==this.__width&&(this.width=this.__width,delete this.__width);void 0!==this.__hidden&&(this.hidden=this.__hidden,delete this.__hidden)}),this._cardviewmode=!1);if(this.prerenderrequired){this._columnsbydatafield=[];this.columnsheader.find("#columntable"+this.element.id).remove();var e=a('<div id="columntable'+this.element.id+'" style="height: 100%; position: relative;"></div>');e[0].cells=[];var f=0,g=0,h="",k=this.host.width(),
935l=k,m=[],n=[],r=this.rowdetails&&this.showrowdetailscolumn?(1+this.groups.length)*this.groupindentwidth:this.groups.length*this.groupindentwidth;a.each(this.columns.records,function(V,ba){this.hidden&&this.hideable||this.adaptivehidden||("auto"==this.width||this._width?h+=this.text:this.width<this.minwidth&&"auto"!=this.minwidth?k-=this.minwidth:this.width>this.maxwidth&&"auto"!=this.maxwidth?k-=this.maxwidth:-1!=this.width.toString().indexOf("%")?(V="hidden"==d.vScrollBar[0].style.visibility?0:d.scrollbarsize+
9365,V+=r,ba=parseFloat(this.width)*(l-V)/100,ba<this.minwidth&&"auto"!=this.minwidth&&(ba=this.minwidth),ba>this.maxwidth&&"auto"!=this.maxwidth&&(ba=this.maxwidth),k-=ba):("string"==typeof this.width&&(this.width=parseInt(this.width)),k-=this.width));this.pinned||this.grouped||this.checkboxcolumn?(d._haspinned&&(this.pinned=!0),m[m.length]=this):n[n.length]=this});if(this.rtl){var t=0;m.reverse();for(u=this.columns.records.length-1;u>=this.columns.records.length-m.length;u--)this.columns.replace(u,
937m[t++]);for(t=0;t<n.length;t++)this.columns.replace(t,n[t])}else{for(var u=0;u<m.length;u++)this.columns.replace(u,m[u]);for(t=0;t<n.length;t++)this.columns.replace(m.length+t,n[t])}var x=this.headerZIndex,B=d.groupable?d.groups.length:0;
937this.rowdetails&&this.showrowdetailscolumn&&B++;var y=d.columnsheader.height();this.showfilterrow&&(y=this.columngroups?y-this.filterrowheight:this.columnsheight);this.showeverpresentrow&&"bottom"!==this.everpresentrowposition&&(y=this.columngroups?y-this.everpresentrowheight:
938this.columnsheight);t=this._gettableheight();if(this.virtualsizeinfo&&this.virtualsizeinfo.virtualheight>t&&!this.scrollbarautoshow)if(this.groupable&&0<this.groups.length)if(this.dataview&&this.dataview.loadedrootgroups&&!this.groupsexpandedbydefault){u=0;if(!this.pageable)u=this.dataview.loadedrootgroups.length*this.rowsheight;else if(this.pageable)for(var A=0;A<this.dataview.rows.length;A++)this.dataview.rows[A].group&&0===this.dataview.rows[A].level&&(u+=this.rowsheight);u>t&&(k-=this.scrollbarsize+
9395,l-=this.scrollbarsize+5)}else k-=this.scrollbarsize+5,l-=this.scrollbarsize+5;else!this.autoheight&&0<this.scrollbarsize&&(k-=this.scrollbarsize+5,l-=this.scrollbarsize+5);l-=r;var aa=function(V,ba){V=d.columngroupslevel*d.columnsheight;return V-=ba.level*d.columnsheight},ha=document.createDocumentFragment(),z=0;a.each(this.columns.records,function(V,ba){this.height=d.columnsheight;d.columngroups&&d.columngroups.length&&(y=this.height=aa(this.datafield,this));ba=d.toTP("jqx-grid-column-header")+
940" "+d.toTP("jqx-widget-header");d.rtl&&(ba+=" "+d.toTP("jqx-grid-column-header-rtl"));var v=d.rtl?150+x+1:150+x-1,K=d.rtl?x++:x--,C=a('<div role="columnheader" style="z-index: '+K+';position: absolute; height: 100%;" class="'+ba+'"><div style="height: 100%; width: 100%;"></div></div>');d.columngroups&&(C[0].style.height=y+"px",C[0].style.bottom="0px",this.pinned&&(C[0].style.zIndex=v));this.uielement=C;""!=this.classname&&this.classname&&C.addClass(this.classname);ba=this.width;v=!1;null===this.width&&
941(this.width="auto");if(-1!=this.width.toString().indexOf("%")||void 0!=this._percentagewidth)ba=void 0!=this._percentagewidth?parseFloat(this._percentagewidth)*l/100:parseFloat(this.width)*l/100,v=!0;if("auto"==this.width||this._width||v)if(v){ba<this.minwidth&&"auto"!=this.minwidth&&(ba=this.minwidth);ba>this.maxwidth&&"auto"!=this.maxwidth&&(ba=this.maxwidth);if(void 0==this._percentagewidth||-1!=this.width.toString().indexOf("%"))this._percentagewidth=this.width;C.width(ba);this.width=ba}else this.hidden||
942this.adaptivehidden||(ba=Math.floor(this.text.length/h.length*k),z+=ba,3>k-z&&k!=z&&.01<k-z?1===k-z?ba++:ba+=2:V==d.columns.records.length-1&&z<k&&(ba+=k-z),isNaN(ba)&&(ba=this.minwidth),0>ba&&(v=a("<span>"+this.text+"</span>"),a(document.body).append(v),ba=10+v.width(),v.remove()),ba<this.minwidth&&(ba=this.minwidth),ba>this.maxwidth&&(ba=this.maxwidth),this._width="auto",ba=this.width=ba,C.width(this.width));else ba<this.minwidth&&"auto"!=this.minwidth&&(this.width=ba=this.minwidth),ba>this.maxwidth&&
943"auto"!=this.maxwidth&&(this.width=ba=this.maxwidth),C[0].style.width=parseInt(ba)+"px";(this.hidden&&this.hideable||this.adaptivehidden)&&C.css("display","none");var da=a(C.children()[0]);v=d.rtl?d.toTP("jqx-grid-column-menubutton")+" "+d.toTP("jqx-grid-column-menubutton-rtl"):d.toTP("jqx-grid-column-menubutton");v+=" "+d.toTP("jqx-icon-arrow-down");v=a('<div style="height: '+y+'px; display: none; left: 100%; top: 0%; position: absolute;"><div class="'+v+'" style="width: 100%; height:100%;"></div></div>');
944d.enableanimations||v.css("margin-left",-16);d.rtl&&v.css("left","0px");this.columnsmenu=v[0];e[0].cells[V]=C[0];v[0].style.width=parseInt(d.columnsmenuwidth)+"px";K=d.columnsmenu;var ja=!1,ea=!1,ra=d.groupable&&0<B&&f<B||d.rowdetails&&f<B;d.rtl&&(ra=d.groupable&&0<B&&f<B||d.rowdetails&&f<B,ra&=V>d.columns.records.length-1-B);if(ra)f++,K&=0,this.editable=this.sortable=!1,ea=!0;else{var za=null!=this.renderer?this.renderer(this.text,this.align,y):d._rendercolumnheader(this.text,this.align,y,d);null==
945za&&(za=d._rendercolumnheader(this.text,this.align,y,d));null!=this.renderer&&(za=a(za));K&=1;ja=!0}d.WinJS?MSApp.execUnsafeLocalFunction(function(){da.append(a(za))}):this.renderer?da.append(a(za)):za&&(da[0].innerHTML=za);if(null!=za){var na=a('<div class="iconscontainer" style="height: '+y+'px; margin-left: -32px; display: block; position: absolute; left: 100%; top: 0%; width: 32px;"><div class="filtericon '+d.toTP("jqx-widget-header")+'" style="height: '+y+'px; float: right; display: none; width: 16px;"><div class="'+
946d.toTP("jqx-grid-column-filterbutton")+'" style="width: 100%; height:100%;"></div></div><div class="sortasc '+d.toTP("jqx-widget-header")+'" style="height: '+y+'px; float: right; display: none; width: 16px;"><div class="'+d.toTP("jqx-grid-column-sortascbutton")+" "+d.toTP("jqx-icon-arrow-up")+'" style="width: 100%; height:100%;"></div></div><div class="sortdesc '+d.toTP("jqx-widget-header")+'" style="height: '+y+'px; float: right; display: none; width: 16px;"><div class="'+d.toTP("jqx-grid-column-sortdescbutton")+
947" "+d.toTP("jqx-icon-arrow-down")+'" style="width: 100%; height:100%;"></div></div><div class="sorticon '+d.toTP("jqx-widget-header")+'" style="height: '+y+'px; float: right; visibility: hidden; width: 16px;"><div class="'+d.toTP("jqx-grid-column-sorticon")+" "+d.toTP("jqx-icon-arrow-down")+'" style="width: 100%; height:100%;"></div></div></div>');v.addClass(d.toTP("jqx-widget-header"));da.append(na);V=na.children();this.sorticon=V[3];this.sortasc=V[1];this.sortdesc=V[2];this.filtericon=V[0];this.iconscontainer=
948na;d.rtl&&(na.css("margin-left","0px"),na.css("left","0px"),a(this.sorticon).css("float","left"),a(this.sortasc).css("float","left"),a(this.filtericon).css("float","left"),a(this.sortdesc).css("float","left"));
948!d.autoshowfiltericon&&this.filterable&&a(this.filtericon).css("display","block")}this.element=C[0];K&&(d._handlecolumnsmenu(d,da,C,v,this),this.menu||v.hide());ha.appendChild(C[0]);if(d.groupable&&ja)if(C[0].id=d.dataview.generatekey(),d._handlecolumnstogroupsdragdrop)d._handlecolumnstogroupsdragdrop(this,
949C);else throw Error("jqxGrid: Missing reference to jqxgrid.grouping.js.");d.columnsreorder&&this.draggable&&d._handlecolumnsdragreorder&&d._handlecolumnsdragreorder(this,C);var qa=this;qa._applyStyle();d.addHandler(C,"mouseenter",function(Pa){qa.hovered=!0;qa._applyStyle()});d.addHandler(C,"mouseleave",function(Pa){qa.hovered=!1;qa._applyStyle()});var Ba=function(Pa,Ca,xa){if(Pa.selectable){var Fa=d.getrows();void 0===Pa.selected&&(Pa.selected=!1);Ca.shiftKey&&void 0!==d._clickedcolumn||(d._clickedcolumn=
950Pa);if(Ca.shiftKey&&d._clickedcolumn&&void 0===xa){var Na=d.columns.records.indexOf(d._clickedcolumn);xa=d.columns.records.indexOf(Pa);Pa=Math.min(Na,xa);xa=Math.max(Na,xa);d.clearselection();for(Na=Pa;Na<=xa;Na++)Ba(d.columns.records[Na],Ca,!0);d._renderrows(this.virtualsizeinfo)}else{xa?Pa.selected=!0:(Ca.ctrlKey||d.clearselection(),Pa.selected=!Pa.selected);for(Na=0;Na<Fa.length;Na++)d._applycellselection(Fa[Na].boundindex,Pa.displayfield,Pa.selected,!1,!1);Pa.selected?Pa.element.setAttribute("selected",
951""):Pa.element.removeAttribute("selected");Pa._applyStyle();void 0===xa&&(d.virtualsizeinfo=d._calculatevirtualheight(),d._renderrows(d.virtualsizeinfo))}}};d.addHandler(C,"click",function(Pa){if(qa.checkboxcolumn)return!0;if(0<d.sorttogglestates&&d._togglesort&&!d._loading){if(d.suspendClick)return!0;d._togglesort(qa)}Ba(qa,Pa);Pa.preventDefault();d._raiseEvent(7,{column:qa.getcolumnproperties(),datafield:qa.datafield,originalEvent:Pa})});qa.toggleSelection=Ba;if(qa.resizable&&d.columnsresize&&!ea){var Ua=
952!1;V="mousemove";d.isTouchDevice()&&!0!==d.touchmode&&(Ua=!0,V=a.jqx.mobile.getTouchEventName("touchstart"));d.addHandler(C,V,function(Pa){var Ca=parseInt(Pa.pageX),xa=parseInt(C.coord().left);d.hasTransform&&(xa=a.jqx.utilities.getOffset(C).left);if(d.resizing)return!0;if(d._handlecolumnsresize){if(Ua)return Ca=d.getTouches(Pa)[0].pageX,Ca>=xa+qa.width-40?(d.resizablecolumn={columnelement:C,column:qa},C.css("cursor","col-resize")):(C.css("cursor",""),d.resizablecolumn=null),!0;Pa=qa.width;d.rtl&&
953(Pa=0);if(Ca>=xa+Pa-5){if(Ca<=xa+Pa+5)return d.resizablecolumn={columnelement:C,column:qa},C.css("cursor","col-resize"),!1;C.css("cursor","")}else C.css("cursor",""),Ca<xa+Pa-5&&(qa._animating||qa._menuvisible||C.mouseenter());d.resizablecolumn=null}})}C.css("left",g);this.hidden&&this.hideable||this.adaptivehidden||(g+=ba);qa.rendered&&qa.rendered(a(da[0].firstChild),qa.align,y)&&null!=na&&na.hide();if(qa.checkboxcolumn){na&&na.hide();if(!d.host.jqxCheckBox)throw Error("jqxGrid: Missing reference to jqxcheckbox.js");
954da.html('<div style="cursor: pointer; margin-left: 3px; top: 50%; margin-top: -9px; position: relative;"></div>');var Ja=da.find("div:first");Ja.jqxCheckBox({_canFocus:!1,disabled:d.disabled,disabledContainer:!0,theme:d.theme,enableContainerClick:!1,animationShowDelay:0,animationHideDelay:0});Ja.addClass(d.toThemeProperty("jqx-checkbox"));qa.checkboxelement=Ja;na=Ja.data().jqxCheckBox.instance;d._checkboxcolumn=qa;na.updated=function(Pa,Ca,xa){d._checkboxcolumnupdating=!0;d.disabled&&(Ja.jqxCheckBox({disabled:d.disabled}),
955Ca=xa);Ca?d.selectallrows():d.unselectallrows();d._checkboxcolumnupdating=!1}}});0<g?this.columnsheader.width(2+g):this.columnsheader.width(g);e[0].appendChild(ha);this.columnsrow=e;d.columnsheader.append(e);this.showfilterrow&&this._updatefilterrow&&(this.columngroups?e.height(this.columngroupslevel*this.columnsheight):e.height(this.columnsheight),this.filterrow||(t=a("<div style='position: relative !important; '></div>"),t[0].id="filterrow."+this.element.id,t.height(this.filterrowheight),this.filterrow=
956t),this.filterrow.width(2+g),this.columnsheader.append(this.filterrow),this._updatefilterrow());this.showeverpresentrow&&"bottom"!==this.everpresentrowposition?(this.columngroups?e.height(this.columngroupslevel*this.columnsheight):e.height(this.columnsheight),this.addnewrowtop||(t=a("<div style='position: relative !important; z-index:"+this.headerZIndex+";'></div>
956"),t[0].id="addnewrowtop."+this.element.id,t.height(this.everpresentrowheight),this.addnewrowtop=t),this.addnewrowtop.width(2+g),"topAboveFilterRow"==
957this.everpresentrowposition?this.filterrow?this.addnewrowtop.insertBefore(this.filterrow):this.columnsheader.append(this.addnewrowtop):this.columnsheader.append(this.addnewrowtop),this._updateaddnewrow()):this.showeverpresentrow&&"bottom"===this.everpresentrowposition&&(this.addnewrowbottom||(t=a("<div style='position: relative !important; z-index:"+this.headerZIndex+";'></div>"),t[0].id="addnewrowbottom."+this.element.id,t.height(this.everpresentrowheight),this.addnewrowbottom=t),this.addnewrowbottom.width(2+
958g),this.addnewrow.append(this.addnewrowbottom),this._updateaddnewrow());e[0].style.visibility=0==g?"hidden":"inherit";e.width(g);this._handlecolumnsdragdrop&&this._handlecolumnsdragdrop();this._handlecolumnsreorder&&this._handlecolumnsreorder();this._rendersortcolumn&&this._rendersortcolumn();this._renderfiltercolumn&&this._renderfiltercolumn();this._handlecolumnsresize&&this._handlecolumnsresize();this.columngroups&&this._rendercolumngroups();this._updatecheckboxselection&&this._updatecheckboxselection()}else this._rendersortcolumn&&
959this._rendersortcolumn(),this._renderfiltercolumn&&this._renderfiltercolumn(),this.showfilterrow&&this.filterrow&&(this.filterrow.width(this.columnsheader.width()),this._updatefilterrowui()),this.showeverpresentrow&&("bottom"!==this.everpresentrowposition?this.addnewrowtop.width(this.columnsheader.width()):this.addnewrowbottom.width(this.columnsheader.width()),this._updateaddnewrowui())},_rendercolumngroups:function(){if(this.columngroups){for(var d=0,e=0;e<this.columns.records.length;e++)this.columns.records[e].pinned&&
960d++;d=this.headerZIndex-d+this.columns.records.length;e=this.that;var f=e.toTP("jqx-grid-column-header")+" "+e.toTP("jqx-grid-columngroup-header")+" "+e.toTP("jqx-widget-header");e.rtl&&(f+=" "+e.toTP("jqx-grid-columngroup-header-rtl"));var g=this.columnsheader.find("#columntable"+this.element.id);g.find("jqx-grid-columngroup-header").remove();for(var h=0;h<this.columngroupslevel-1;h++)for(e=0;e<this.columngroups.length;e++){var k=this.columngroups[e],l=k.level;if(l===h){l*=this.columnsheight;var m=
96199999;if(k.groups){var n=function(B){for(var y=0,A=0;A<B.groups.length;A++){var aa=B.groups[A];aa.groups?y+=n(aa):aa.hidden||(y+=aa.width,m=Math.min(parseFloat(aa.element.style.left),m))}return y};k.width=n(k);k.left=m;var r=this.columnsheight,t=d--;t=a('<div role="columnheader" style="z-index: '+t+';position: absolute;" class="'+f+'"></div>');var u=a(this._rendercolumnheader(k.text,k.align,this.columnsheight,this));if(k.renderer){u=a("<div style='height: 100%; width: 100%;'></div>");var x=k.renderer(k.text,
962k.align,r);u.html(x)}t.append(u);t[0].style.left=m+"px";0===m&&(t[0].style.borderLeftColor="transparent");this.showcolumnheaderlines||(t[0].style.borderRightColor="transparent",t[0].style.borderBottomColor="transparent",t[0].style.boxShadow="none");t[0].style.top=l+"px";t[0].style.height=r+"px";t[0].style.width=-1+k.width+"px";g.append(t);k.element=t;k.rendered&&k.rendered(u,k.align,r)}}}}},_resizecolumngroups:function(){if(this.columngroups)for(var d=0;d<this.columngroups.length;d++){var e=this.columngroups[d],
963f=e.level*this.columnsheight,g=99999;if(e.groups){var h=function(m){for(var n=0,r=0;r<m.groups.length;r++){var t=m.groups[r];t.groups?n+=h(t):t.hidden||(n+=t.width,g=Math.min(parseFloat(t.element.style.left),g))}return n};e.width=h(e);e.left=g;var k=this.columnsheight,l=e.element;l[0].style.left=g+"px";l[0].style.top=f+"px";l[0].style.height=k+"px";l[0].style.width=-1+e.width+"px"}}},_handlecolumnsmenu:function(d,e,f,g,h){d.dragmousedown=null;g[0].id=d.dataview.generatekey();e.append(g);f[0].columnsmenu=
964g[0];h.element=f[0];var k=this.columnsmenuwidth+1,l=function(){if(!h.menu)return!1;if(!d.resizing){if(h._menuvisible&&d._hasOpenedMenu)return!1;h._animating=!0;if(d.menuitemsarray&&0<d.menuitemsarray.length)if(d.enableanimations)g.css("display","block"),g.stop(),h.iconscontainer.stop(),d.rtl?(g.css("margin-left",-k),g.animate({"margin-left":"0px"},"fast",function(){g.css("display","block");h._animating=!1;h._menuvisible=!0})):(g.css("margin-left","0px"),g.animate({"margin-left":-k},"fast",function(){g.css("display",
965"block");h._animating=!1;h._menuvisible=!0})),t=d.rtl?k:-(32+k),h.iconscontainer.animate({"margin-left":t},"fast");else{g.css("display","block");var t=d.rtl?16:-48;h.iconscontainer.css("margin-left",t+"px");h._animating=!1;h._menuvisible=!0}}};e="mouseenter";d.isTouchDevice()&&(e="touchstart");d.addHandler(f,e,function(t){t=parseInt(t.pageX);var u=d.columnsresize&&h.resizable?3:0,x=parseInt(f.coord().left);d.hasTransform&&(x=a.jqx.utilities.getOffset(f).left);var B=h.width;d.rtl&&(B=0);if(0!=u&&t>=
966x+B-u&&t<=x+B+u)return!1;t=d.vScrollInstance.isScrolling();h.menu&&d.autoshowcolumnsmenubutton&&!t&&!d.disabled&&l()});d.autoshowcolumnsmenubutton||(g.css("display","block"),h.iconscontainer.css("margin-left",(d.rtl?16:-48)+"px"),d.rtl?g.css({"margin-left":"0px"}):g.css({"margin-left":-k}));d.addHandler(f,"mouseleave",function(t){d.menuitemsarray&&0<d.menuitemsarray.length&&h.menu&&(t=a.data(document.body,"contextmenu"+d.element.i
966d),void 0!=t&&g[0].id==t.columnsmenu.id||!d.autoshowcolumnsmenubutton||
967(d.enableanimations?(d.rtl?g.css("margin-left","0px"):g.css("margin-left",-k),g.stop(),h.iconscontainer.stop(),d.rtl?g.animate({"margin-left":-k},"fast",function(){g.css("display","none");h._menuvisible=!1}):g.animate({"margin-left":0},"fast",function(){g.css("display","none");h._menuvisible=!1}),t=d.rtl?0:-32,h.iconscontainer.animate({"margin-left":t},"fast")):(g.css("display","none"),t=d.rtl?0:-32,h.iconscontainer.css("margin-left",t+"px"),h._menuvisible=!1)))});var m=!0,n="";e=a(h.filtericon);
968d.addHandler(g,"mousedown",function(t){d.gridmenu||d._initmenu();m=!a.data(d.gridmenu[0],"contextMenuOpened"+d.gridmenu[0].id);n=a.data(document.body,"contextmenu"+d.element.id);null!=n&&(n=n.column.datafield)});d.addHandler(e,"mousedown",function(t){d.gridmenu||d._initmenu();m=!a.data(d.gridmenu[0],"contextMenuOpened"+d.gridmenu[0].id);n=a.data(document.body,"contextmenu"+d.element.id);null!=n&&(n=n.column.datafield)});var r=function(){if(!h.menu)return!1;d.gridmenu||d._initmenu();if(d.disabled)return!1;
969for(var t=0;t<d.columns.records.length;t++)d.columns.records[t].datafield!=h.datafield&&(d.columns.records[t]._menuvisible=!1);t=g.coord(!0);var u=g.height();if(!m&&(m=!0,n==h.datafield))return d._closemenu(),!1;var x=d.host.coord(!0);d.hasTransform&&(x=a.jqx.utilities.getOffset(d.host),t=a.jqx.utilities.getOffset(g));x.left+d.host.width()>parseInt(t.left)+d.gridmenu.width()?d.gridmenu.jqxMenu("open",t.left,t.top+u):d.gridmenu.jqxMenu("open",g.width()+t.left-d.gridmenu.width(),t.top+u);100>d.gridmenu.width()&&
970d._arrangemenu();if(d.adaptive&&d.element.offsetWidth<d.adaptivewidth){d.gridmenu.jqxMenu("close");d.gridmenu.jqxMenu("open",x.left,t.top+u);for(t=u=0;t<d.columns.records.length;t++)x=d.columns.records[t],x.hidden||x.adaptivehidden||"adaptive"===x.columntype||(u+=x.adaptivewidth);d.gridmenu.width(u);d.gridmenu.height(d.content.height())}(!d.filterable||d.filterable&&d.showfilterrow)&&setTimeout(function(){d.gridmenu.focus();for(var z=d.gridmenu.find(".jqx-item"),V=0;V<z.length;V++)z[V].active&&(z[V].active=
971!1);V=z[0];0<=z[0].className.indexOf("disabled")&&(V=z[1]);a(z).removeClass("jqx-fill-state-focus");a(V).addClass("jqx-fill-state-focus");V.active=!0},225);d._hasOpenedMenu=!0;u=d._getmenuitembyindex(0);x=d._getmenuitembyindex(1);var B=d._getmenuitembyindex(2),y=d._getmenuitembyindex(3),A=d._getmenuitembyindex(4);t=d._getmenuitembyindex(5);if(null!=u&&null!=x&&null!=B){var aa=h.sortable&&d.sortable;d.gridmenu.jqxMenu("disable",u.id,!aa);d.gridmenu.jqxMenu("disable",x.id,!aa);d.gridmenu.jqxMenu("disable",
972B.id,!aa);if(void 0!=h.displayfield){var ha=d.getsortinformation();ha=ha&&ha.sortcolumns&&ha.sortcolumns.find(function(z){return z.dataField===h.displayfield});d.sortcolumn==h.displayfield||ha?(ha=d.getsortinformation(),aa&&(ha.sortdirection.ascending?d.gridmenu.jqxMenu("disable",u.id,!0):d.gridmenu.jqxMenu("disable",x.id,!0))):d.gridmenu.jqxMenu("disable",B.id,!0)}}null!=y&&null!=A&&(d.groupable&&h.groupable?d.groups&&-1!=d.groups.indexOf(h.datafield)?(d.gridmenu.jqxMenu("disable",y.id,!0),d.gridmenu.jqxMenu("disable",
973A.id,!1)):(d.gridmenu.jqxMenu("disable",y.id,!1),d.gridmenu.jqxMenu("disable",A.id,!0)):(d.gridmenu.jqxMenu("disable",A.id,!0),d.gridmenu.jqxMenu("disable",y.id,!0)));null!=t&&(d.menuOwner=h,d._updatefilterpanel(d,t,h),u=0,d.sortable&&d._togglesort&&d.showsortmenuitems&&(u+=3),d.groupable&&d.addgroup&&d.showgroupmenuitems&&(u+=2),x=36*u+6,x=d._measureMenuElement(),x=u*x+20,a.jqx.browser.msie&&8>a.jqx.browser.version&&(x+=20,a(t).height(220)),d.isTouchDevice()&&(x+=10),d.filterable&&d.showfiltermenuitems&&
974(h.filterable?(d.gridmenu.height(x+230),a(t).css("display","block")):(d.gridmenu.height(x),a(t).css("display","none"))));d.columnmenuopening&&!1===d.columnmenuopening(d.gridmenu,h.displayfield,d.gridmenu.height())&&setTimeout(function(){d._closemenu()});a.data(document.body,"contextmenu"+d.element.id,{column:h,columnsmenu:g[0]})};d.addHandler(e,"click",function(t){if(!h.menu)return!1;d.showfilterrow||("block"!=g[0].style.display&&f.trigger("mouseenter"),setTimeout(function(){"block"!=g[0].style.display&&
975f.trigger("mouseenter");r()},200));return!1});d.addHandler(g,"click",function(t){if(!h.menu)return!1;r();return!1});d.isTouchDevice()&&d.addHandler(g,a.jqx.mobile.getTouchEventName("touchstart"),function(t){if(!h.menu)return!1;d._hasOpenedMenu?d._closemenu():r();return!1})},_removecolumnhandlers:function(d){var e=this.that,f=a(d.element);0<f.length&&(e.removeHandler(f,"mouseenter"),e.removeHandler(f,"mouseleave"),d=a(d.filtericon),e.removeHandler(d,"mousedown"),e.removeHandler(d,"click"),e.removeHandler(f,
976"click"),e.removeHandler(f,"mousemove"),e.columnsreorder&&(e.removeHandler(f,"mousedown.drag"),e.removeHandler(f,"mousemove.drag")),e.removeHandler(f,"dragstart"),f[0].columnsmenu&&(f=a(f[0].columnsmenu),e.removeHandler(f,"click"),e.removeHandler(f,"mousedown"),e.removeHandler(f,a.jqx.mobile.getTouchEventName("touchstart"))))},_rendercolumnheader:function(d,e,f,g){return this.enableellipsis?"left"==e?'<div style="padding-bottom: 2px; overflow: hidden; text-overflow: ellipsis; text-align: '+e+"; margin-left: 4px; margin-right: 2px; line-height: "+
977f+'px;"><span style="text-overflow: ellipsis; cursor: default;">'+d+"</span></div>":'<div style="padding-bottom: 2px; overflow: hidden; text-overflow: ellipsis; text-align: '+e+"; margin-left: 2px; margin-right: 4px; line-height: "+f+'px;"><span style="text-overflow: ellipsis; cursor: default;">'+d+"</span></div>":"center"==e||"middle"==e?'<div style="padding-bottom: 2px; text-align: center; line-height: '+f+'px;"><a href="#">'+d+"</a></div>":'<a style="line-height: '+f+"px; float: "+e+';" href="#">'+
978d+"</a>"},_renderrows:function(d,e,f){var g=this.that;(this.pageable||this.groupable)&&(this.autoheight||this.autorowheight)&&null!=this.table&&null!=this.table[0].rows&&this.table[0].rows.length<this.dataview.rows.length&&(g.prerenderrequired=!0);this.pageable||!this.autoheight&&!this.autorowheight||!this.virtualmode&&!this.unboundmode||(f=this.source.totalrecords,isNaN(f)||null==this.table||null==this.table[0].rows||this.table[0].rows.length==f||(g.prerenderrequired=!0));(this.autoheight||this.autorowheight)&&
979!g.prerenderrequired&&this.table&&this.table[0].rows&&(this.table[0].rows.length<this.dataview.records.length&&(this.pageable&&this.table[0].rows.length<this.dataview.pagesize?g.prerenderrequired=!0:this.pageable||(g.prerenderrequired=!0)),this.table[0].rows.length<this.dataview.cachedrecords.length&&(this.pageable&&this.table[0].rows.length<this.dataview.pagesize?g.prerenderrequired=!0:this.pageable||(g.prerenderrequired=!0)));g._prerenderrows(d);g._requiresupdate&&(g._requiresupdate=!1,g._updatepageviews());
980var h=function(){g._loading||(g.WinJS?MSApp.execUnsafeLocalFunction(function(){g._rendervisualrows()}):g._rendervisualrows(),g.virtualmode&&g.showaggregates&&g._updateaggregates&&g.refreshaggregates())};d=a.jqx.browser.msie&&10>a.jqx.browser.version;if(this.virtualmode)f=function(){if(g.rendergridrows){var m=g._startboundindex;void 0==m&&(m=0);var n=m+1+g.dataview.pagesize;if(null!=m&&null!=n){var r=g.source._source?!0:!1;if((r?g.source._source.recordstartindex:g.source.recordstartindex)!=m||1==e){if(r){if(n>=
981g.source._source.totalrecords&&(n=g.source._source.totalrecords,m=n-g.dataview.pagesize-1,0>m&&(m=0),g.source._source.recordendindex==n&&g.source._source.recordstartindex==m))return;g.source._source.recordstartindex=m;g.source._source.recordendindex=n}else g.source.recordstartindex=m,g.source.recordendindex=n;g.updatebounddata("cells")}}}},this.loadondemand&&(h(),f(),this.loadondemand=!1),f=void 0==this._browser?this._isIE10():this._browser,this.editable&&this.editcell&&!this.vScrollInstance.isScrolling()&&
982!this.hScrollInstance.isScrolling()?h():this.autoheight?h():f||d||navigator&&-1!=navigator.userAgent.indexOf("Safari")?(null!=this._scrolltimer&&clearTimeout(this._scrolltimer),this._scrolltimer=setTimeout(function(){h()},5)):h();else{if("deferred"==this.scrollmode&&(this.hScrollInstance.isScrolling()||this.vScrollInstance.isScrolling())){null!=this._scrolltimer&&clearInterval(this._scrolltimer);var k=this._getfirstvisualrow();
982null!=k&&(d=function(m){if(null==k)return"";m="<table>";var n=g.deferreddatafields;
983null==n&&0<g.columns.records.length&&(n=[],n.push(g.columns.records[0].displayfield));for(var r=0;r<n.length;r++){var t=g._getcolumnbydatafield(n[r]);if(t){var u=g._getcellvalue(t,k);""!=t.cellsformat&&a.jqx.dataFormat&&(a.jqx.dataFormat.isDate(u)?u=a.jqx.dataFormat.formatdate(u,t.cellsformat,g.gridlocalization):a.jqx.dataFormat.isNumber(u)&&(u=a.jqx.dataFormat.formatnumber(u,t.cellsformat,g.gridlocalization)));m+="<tr><td>"+u+"</td></tr>"}}return m+"</table>"},d=this.scrollfeedback?this.scrollfeedback(k.bounddata):
984d(k.bounddata),d!=this._scrollelementcontent&&(this._scrollelementcontent=this._scrollelement[0].innerHTML=d));this._scrollelement.css("visibility","visible");this._scrollelementoverlay.css("visibility","visible");this._scrollelement.css("margin-top",-this._scrollelement.height()/2);this._scrolltimer=setInterval(function(){g.hScrollInstance.isScrolling()||g.vScrollInstance.isScrolling()||(h(),g._scrollelement.css("visibility","hidden"),g._scrollelementoverlay.css("visibility","hidden"),clearInterval(g._scrolltimer),
985k&&g.ensurerowvisible(k.visibleindex))},100);return}navigator&&-1==navigator.userAgent.indexOf("Chrome")&&-1!=navigator.userAgent.indexOf("Safari")&&(this._updatedelay=1);void 0!=this.touchDevice&&1==this.touchDevice&&(this._updatedelay=5);if((f=void 0==this._browser?this._isIE10():this._browser)||d)this._updatedelay=5;if(f&&this.hScrollInstance.isScrolling()){h();return}a.jqx.browser.mozilla&&0==this._updatedelay&&(this.vScrollInstance.isScrolling()||this.hScrollInstance.isScrolling())&&(this._updatedelay=
9860);this.isTouchDevice()&&(this._updatedelay=0);null!=this.updatedelay&&(this._updatedelay=this.updatedelay);0==this._updatedelay?h():(d=this._jqxgridrendertimer,null!=d&&clearTimeout(d),this.vScrollInstance.isScrolling()||this.hScrollInstance.isScrolling()?(this._updatedelay?d=setTimeout(function(){h()},this._updatedelay):(d=null,h()),this._jqxgridrendertimer=d):(this._jqxgridrendertimer=d,h()))}if(g.autorowheight&&!g.autoheight&&0<this._pageviews.length){f=this._gettableheight();d=this._pageviews[0].height;
987if(d>f)if(this.pageable&&this.gotopage&&(d=this._pageviews[0].height,0>d&&(d=this._pageviews[0].height)),"visible"!=this.vScrollBar.css("visibility")&&this.vScrollBar.css("visibility","visible"),(d<=f||this.autoheight)&&this.vScrollBar.css("visibility","hidden"),0<d-f){if("deferred"!=this.scrollmode){f=d-f;var l=this.vScrollInstance.max;this.vScrollBar.jqxScrollBar({max:f});Math.round(f)!=Math.round(l)&&this.vScrollBar.jqxScrollBar("value")>f&&this.vScrollBar.jqxScrollBar({value:0})}}else this.vScrollBar.jqxScrollBar({value:0,
988max:d});else this._loading||this.vScrollBar.css("visibility","hidden"),this.vScrollBar.jqxScrollBar({value:0});this._arrange();this.virtualsizeinfo&&(this.virtualsizeinfo.virtualheight=d)}},scrolling:function(){var d=this.vScrollInstance.isScrolling(),e=this.hScrollInstance.isScrolling();return{vertical:d,horizontal:e}},_renderhorizontalscroll:function(){var d=this.hScrollInstance,e=d.value;"hidden"===this.hScrollBar.css("visibility")&&(e=d.value=0);var f=parseInt(e);if(null!=this.table){var g=this.table[0].rows.length,
989h=this.columnsrow,k=this.groupable&&0<this.groups.length?this.groups.length:0,l=this.columns.records.length-k,m=this.columns.records,n=0==this.dataview.rows.length;this.rtl&&"hidden"!=this.hScrollBar.css("visibility")&&(f=d.max-f);if(n&&!this._haspinned){for(d=0;d<g;d++){n=this.table[0].rows[d];for(var r=0;r<k+l;r++){var t=n.cells[r];if(void 0!=t){var u=m[r];u.pinned&&(t.style.marginLeft=f+"px",0==d&&(t=h[0].cells[r],t.style.marginLeft=f+"px"))}}}this.table[0].style.marginLeft=-f+"px";h[0].style.marginLeft=
990-f+"px"}else if(this._haspinned||void 0==this._haspinned){for(d=0;d<g;d++)for(n=this.table[0].rows[d],r=0;r<k+l;r++)if(t=n.cells[r],void 0!=t&&(u=m[r],u.pinned&&(0!=f||""!=t.style.marginLeft))){var x=u=null,B=null;this.showeverpresentrow&&this.addnewrowtop&&this.addnewrowtop[0].cells&&(B=this.addnewrowtop[0].cells[r]);this.showfilterrow&&this.filterrow&&this.filterrow[0].cells&&(x=this.filterrow[0].cells[r]);this.showaggregates&&this.statusbar[0].cells&&(u=this.statusbar[0].cells[r]);this.rtl?(t.style.marginLeft=
991-parseInt(e)+"px",0==d&&(t=h[0].cells[r],t.style.marginLeft=-parseInt(e)+"px",u&&(u.style.marginLeft=-parseInt(e)+"px"),x&&(x.style.marginLeft=-parseInt(e)+"px"),B&&(B.style.marginLeft=-parseInt(e)+"px"))):(t.style.marginLeft=f+"px",0==d&&(t=h[0].cells[r],t.style.marginLeft=f+"px",u&&(u.style.marginLeft=f+"px"),x&&(x.style.marginLeft=f+"px"),B&&(B.style.marginLeft=f+"px")))}this.table[0].style.marginLeft=-f+"px";h[0].style.marginLeft=-f+"px"}else 0==this._haspinned&&(this.table[0].style.marginLeft=
992-f+"px",h[0].style.marginLeft=-f+"px");this.showaggregates&&this.statusbar[0].cells&&(e=0,this.rtl&&"hidden"
992!=this.vScrollBar.css("visibility")&&"hidden"!=this.hScrollBar.css("visibility")&&(e=2+parseInt(this.hScrollBar.css("left"))),this.statusbar[0].style.marginLeft=-f+e+"px");this.showfilterrow&&this.filterrow&&this.filterrow[0].cells&&(this.filterrow[0].style.marginLeft=-f+"px");this.showeverpresentrow&&this.addnewrowtop&&this.addnewrowtop[0].cells&&(this.addnewrowtop[0].style.marginLeft=-f+"px")}},
993_updaterowdetailsvisibility:function(){if(this.rowdetails)for(var d=0;d<this._rowdetailselementscache.length;d++)a(this._rowdetailselementscache[d]).css("display","none")},_getvisualcolumnsindexes:function(d,e,f,g,h,k,l){var m=this.vScrollInstance.isScrolling()||this.hScrollInstance.isScrolling()||this._keydown;if((this.rowdetails||this.rtl||this.editcell&&m||this.width&&0<=this.width.toString().indexOf("%")&&!m&&!this.editcell||this.exporting)&&!l)return{start:0,end:f+g};l=0;m=-1;var n=f+g,r=!1;
994if(this.autorowheight)return{start:0,end:f+g};if(!h)for(h=0;h<f+g;h++)if(r||this.columns.records[h].pinned&&k&&(r=!0),this.columns.records[h].hidden||this.columns.records[h].adaptivehidden||(l+=this.columns.records[h].width),l>=d&&-1==m&&(m=h),l>e+d){n=h;break}n++;n>f+g&&(n=f+g);if(-1==m||r)m=0;return{start:m,end:n}},_getvirtualcolumnsindexes:function(d,e,f,g,h){var k=this.vScrollInstance.isScrolling()||this.hScrollInstance.isScrolling()||this._keydown;if(this.enableoptimization&&(this.rowdetails||
995this.rtl||this.editcell&&k||this.width&&0<=this.width.toString().indexOf("%")&&!k&&!this.editcell||this.exporting)||this.rtl||this.editcell||this.exporting)return{start:0,end:f+g};k=0;var l=-1,m=f+g;if(this.autorowheight)return{start:0,end:f+g};if(!h)for(h=0;h<f+g;h++)if(this.columns.records[h].hidden||this.columns.records[h].adaptivehidden||(k+=this.columns.records[h].width),k>=d&&-1==l&&(l=h),k>e+d){m=h;break}m++;m>f+g&&(m=f+g);-1==l&&(l=0);return{start:l,end:m}},_getfirstvisualrow:function(){var d=
996parseInt(this.vScrollInstance.value);0==this._pagescache.length&&(this.dataview.updateview(),this._loadrows());"visible"!=this.vScrollBar[0].style.visibility&&(d=0);if(!this.pageable){var e=this._findvisiblerow(d,this._pageviews);if(-1==e)return null;e!=this.dataview.pagenum?(this.dataview.pagenum=e,this.dataview.updateview(),this._loadrows()):this._pagescache[this.dataview.pagenum]||this._loadrows()}d=this._findvisiblerow(d,this._pagescache[this.dataview.pagenum]);if((e=this._pagescache[this.dataview.pagenum])&&
997e[0])return e[d]},_rendervisualrows:function(){if(this.virtualsizeinfo){var d=this.vScrollInstance,e=this.hScrollInstance,f=e.value,g=parseInt(d.value),h=parseInt(f),k=this._gettableheight(),l=void 0!=this._hostwidth?this._hostwidth:this.host.width();"visible"==this.hScrollBar[0].style.visibility&&(k+=29);"deferred"==this.scrollmode&&0!=this._newmax&&g>this._newmax&&null!=this._newmax&&(g=this._newmax);var m=d.isScrolling()||e.isScrolling()||this._keydown,n=this.groupable&&0<this.groups.length;this.visiblerows=
998[];this.hittestinfo=[];this.editcell&&void 0==this.editrow&&this._hidecelleditor(!1);void 0!=this.editrow&&this._hideeditors();this.virtualmode&&!this.pageable&&(this._pagescache=[]);0==this._pagescache.length&&(this.dataview.updateview(),this._loadrows());"hidden"==this.vScrollBar[0].style.visibility&&(g=0);this.pageable||(e=this._findvisiblerow(g,this._pageviews),-1==e&&(this._clearvisualrows(),this._renderemptyrow(),this._updaterowdetailsvisibility()),e!=this.dataview.pagenum?(this.dataview.pagenum=
999e,this.dataview.updateview(),this._loadrows()):this._pagescache[this.dataview.pagenum]||this._loadrows());var r=this.groupable&&0<this.groups.length?this.groups.length:0;if(this.columns.records){var t=this.columns.records.length-r;e=this._findvisiblerow(g,this._pagescache[this.dataview.pagenum]);var u=this._pagescache[this.dataview.pagenum],x=e;0>x&&(x=0);var B=0,y=0,A=0,aa=0,ha=this.virtualsizeinfo.visiblerecords,z=this.groupable?this.groups.length:0,V=this.toTP("jqx-grid-cell")+" "+this.toTP("jqx-item");
1000this.rtl&&(V+=" "+this.toTP("jqx-grid-cell-rtl"));(this.autoheight||this.autorowheight)&&this.pageable&&(!this.groupable||this.groupable&&0===this.groups.length)&&(ha=this.dataview.pagesize);
1000n&&(V=" "+this.toTP("jqx-grid-group-cell"));this.isTouchDevice()&&(V+=" "+this.toTP("jqx-touch"));this.autorowheight&&(V+=" jqx-grid-cell-wrap");var ba=this.rowsheight;this.cardview&&(ba=this.cardheight);var v=this._rendercell;f=this._getvisualcolumnsindexes(h,l,r,t,n,!0);e=f.start;f=f.end;var K=this._getvirtualcolumnsindexes(h,
1001l,r,t,n),C=K.start,da=K.end;(this.autoheight||this.pageable)&&this.autorowheight&&this._pageviews[0]&&(this._oldpageviewheight=this._pageviews[0].height);this.autorowheight&&(x=0);if(0<=x){this._updaterowdetailsvisibility();this._startboundindex=null!=u?u[x].bounddata.boundindex:0;this._startvisibleindex=null!=u?u[x].bounddata.visibleindex:0;var ja=this.table[0].rows;if(10<this.columns.records.length&&this.enablecolumnsvirtualization)for(var ea=function(Na){return Na&&Na.parentNode&&"#document-fragment"!=
1002Na.parentNode.nodeName?!0:!1},ra=0;ra<ja.length;ra++){K=ja[ra];K.className="";for(var za=0;za<C;za++){var na=za;if(!this.columns.records[na].pinned&&null!=this.columns.records[na].datafield){var qa=K.cells[na];ea(qa)&&qa.parentNode.removeChild(qa);var Ba=this.columns.records[na].element;this.columns.records[na]._rendered=!1;ea(Ba)&&this.columnsrow[0].removeChild(Ba);this.filterrow&&ea(this.filterrow[0].cells[na])&&this.columns.records[na].filterable&&this.filterrow[0].cells[na].parentNode.removeChild(this.filterrow[0].cells[na])}}for(za=
1003da;za<this.columns.records.length;za++)na=za,this.columns.records[na].pinned||null==this.columns.records[na].datafield||(qa=K.cells[na],ea(qa)&&qa.parentNode.removeChild(qa),Ba=this.columns.records[na].element,this.columns.records[na]._rendered=!1,ea(Ba)&&this.columnsrow[0].removeChild(Ba),this.filterrow&&ea(this.filterrow[0].cells[na])&&this.columns.records[na].filterable&&this.filterrow[0].cells[na].parentNode.removeChild(this.filterrow[0].cells[na]));for(za=C;za<da;za++)na=za,qa=K.cells[na],ea(qa)||
1004K.appendChild(qa),Ba=this.columns.records[na].element,this.columns.records[na]._rendered=!0,Ba.selectable&&(qa.removeAttribute("selected"),Ba.selected&&qa.setAttribute("selected","")),ea(Ba)||this.columnsrow[0].appendChild(Ba),this.filterrow&&this.showfilterrow&&!ea(this.filterrow[0].cells[na])&&this.columns.records[na].filterable&&this.filterrow[0].firstChild.appendChild(this.filterrow[0].cells[na])}for(ra=0;ra<ha&&y<ha;ra+=1){da=void 0!=u?u[x+ra]:null;this.virtualmode&&ra>=this.source.totalrecords&&
1005(da=null);if(null==da){x=-ra;if(this._pagescache[this.dataview.pagenum+1])u=this._pagescache[this.dataview.pagenum+1],this.dataview.pagenum++;else{K=this._pageviews.length;do if(this.dataview.pagenum<this._pageviews.length-1)this.dataview.pagenum++,u=void 0,0<this._pageviews[this.dataview.pagenum].height&&(this.dataview.updateview(),this._loadrows(),u=this._pagescache[this.dataview.pagenum]);else{u=void 0;break}while(void 0==u&&this.dataview.pagenum<K)}void 0!=u&&(da=u[x+ra])}if(null!=da){if(da.hidden)continue;
1006this._endboundindex=this._startboundindex+ra;this._endvisibleindex=this._startvisibleindex+ra;if(0==ra){var Ua=Math.abs(g-da.top);this.table[0].style.top=-Ua+"px";var Ja=this.table;a.jqx.browser.chrome&&(this._chromeTimer&&clearTimeout(this._chromeTimer),this._chromeTimer=setTimeout(function(){Ja[0].style.top=-Ua+.01+"px"},50));aa=-Ua}K=this.table[0].rows[y];if(!K)continue;parseInt(K.style.height)!=da.height&&(K.style.height=parseInt(da.height)+"px");A+=da.height;ja=this.rowdetails&&da.rowdetails;
1007ea=!da.rowdetailshidden;ja&&ea&&(K.style.height=parseInt(da.height-da.rowdetailsheight)+"px",ha++);C=this._isrowselected(!0,da);for(za=e;za<f;za++)na=za,this._rendervisualcell(v,V,C,ja,ea,n,z,K,da,na,y,m);void 0!=da.group&&this._rendergroup&&this._rendergroup(z,K,da,r,t,y,l);if(this.autorowheight&&(this.autoheight||this.pageable)){ba=this.rowsheight;for(za=e;za<f;za++)this.editable&&this.editcell&&this.editcell.column==this.columns.records[za].datafield&&this.editcell.row==this.getboundindex(da)&&
1008this.editcell.editor?ba=Math.max(ba,this.editcell.editor.height()):K.cells[za].firstChild&&(ba=Math.max(ba,8+parseInt(K.cells[za].firstChild.offsetHeight)));K.style.height=parseInt(ba)+"px";this.heights[this._startboundindex+ra]=ba;
1008ja&&ea&&(ba+=da.rowdetailsheight);da.height=ba}if(this.cardview){K.innerHTML="";ja='<div class="jqx-grid-card-row"';ea="";ja+='style="grid-template-columns: ';Ba=100/this.cardsize+"%";for(var Pa=0;Pa<this.cardsize;Pa++)if(void 0!=u&&(da=u[x+ra*this.cardsize+Pa]),da){ja+=
1009Ba+" ";var Ca='<div id="'+da.bounddata.uid+'" class="jqx-grid-card-cell">';Ca+="<table>";for(za=e;za<f;za++)if(na=za,qa=null,C=this.columns.records[na],!C.hidden||void 0!==C.__hidden){var xa=this._getcellvalue(C,da);""!=C.cellsformat&&a.jqx.dataFormat&&(a.jqx.dataFormat.isDate(xa)?xa=a.jqx.dataFormat.formatdate(xa,C.cellsformat,this.gridlocalization):a.jqx.dataFormat.isNumber(xa)&&(xa=a.jqx.dataFormat.formatnumber(xa,C.cellsformat,this.gridlocalization)));if(null!=C.cellsrenderer){var Fa=C.cellsrenderer(this.getboundindex(da),
1010C.datafield,xa,null,C.getcolumnproperties(),da.bounddata);void 0!=Fa&&(xa=Fa)}qa=K.cells[na];Fa=this.editable&&C.editable?'<span row="'+da.bounddata.uid+'"  class="jqx-icon-edit"></span>':"";Ca+='<tr class="jqx-grid-card-table-row">';Ca+='<td class="jqx-grid-card-cell-label"><div>'+C.text+"</div></td>";Ca+='<td class="jqx-grid-card-cell-value"><div>'+xa+"</div></td>";Ca+="</tr>"}Ca+="</table>";Ca+=Fa;Ca+="</div>";ea+=Ca}ja+=';">'+ea+"</div>";K.innerHTML+=ja;y++;continue}this.visiblerows[this.visiblerows.length]=
1011da;this.hittestinfo[this.hittestinfo.length]={row:da,visualrow:K,details:!1};
1011ja&&ea&&(y++,K=this.table[0].rows[y],this._renderrowdetails(V,K,da,r,t,y),this.visiblerows[this.visiblerows.length]=da,this.hittestinfo[this.hittestinfo.length]={row:da,visualrow:K,details:!0});if(!this.autorowheight&&A+aa>=k)break}else this._clearvisualrow(h,n,y,r,t),A+B+aa<=k&&(B+=ba);y++}this._horizontalvalue=h;0<B&&"visible"==this.vScrollBar[0].style.visibility&&(parseInt(this.table.css("top")),h=this._pageviews[this._pageviews.length-
10121],g=d.max,k=h.top+h.height-k,"visible"==this.hScrollBar.css("visibility")&&(k+=this.scrollbarsize+22),g!=k&&!this.autorowheight&&0<=k&&("deferred"!=this.scrollmode?(d.max=k,d.setPosition(d.max)):this._newmax!=k&&(this._newmax=k,this._rendervisualrows())))}if((this.autoheight||this.pageable)&&this.autorowheight){this._pagescache=[];for(ra=k=d=0;ra<this.visiblerows.length;ra++)for(g=this.visiblerows[ra],g.top=d,d+=g.height,k+=g.height,ja=this.rowdetails&&g.rowdetails,ea=!g.rowdetailshidden,K=this.table[0].rows[ra],
1013ja&&ea&&ra++,za=e;za<f;za++)C=this.columns.records[za],C.hidden||C.adaptivehidden||C.cellsrenderer||(qa=K.cells[za],h=0,qa.firstChild?(h=(g.height-parseInt(qa.firstChild.offsetHeight)-8)/2,ja&&ea&&(h=(g.height-g.rowdetailsheight-a(qa.firstChild).height()-8)/2)):h=(g.height-parseInt(a(qa).height())-8)/2,0<=h&&(h=parseInt(h)+4,!qa.firstChild||-1!=qa.firstChild.className.indexOf("jqx-grid-groups-row")||"checkbox"==C.columntype||"button"==C.columntype||this.editable&&this.editcell&&this.editcell.column==
1014C.datafield&&this.editcell.row==this.getboundindex(g)||(qa.firstChild.style.marginTop=h+"px")));this._pageviews[0]&&(this._pageviews[0].height=k);this._arrange()}this._renderemptyrow();this.toCompile&&0<this.toCompile.length&&a.each(this.toCompile,function(Na,I){if(this.compiled)return!0;Na=this.cell;if(!Na)return!0;a.jqx.angularCompile&&a.jqx.angularCompile(Na,"<div>"+this.value+"</div>");this.compiled=!0})}}},_hideemptyrow:function(){if(this.showemptyrow&&this.table&&this.table[0].rows){var d=this.table[0].rows[0];
1015if(d)for(var e=!1,f=0;f<d.cells.length;f++){var g=a(d.cells[f]);"none"==g.css("display")||e||g.width()!=this.host.width()&&g.text()!=this.gridlocalization.emptydatastring||(g[0].checkbox=null,g[0].button=null,e=!0,g[0].innerHTML="")}}},_renderemptyrow:function(){if(!this._loading&&0==this.dataview.records.length&&this.showemptyrow){var d=!1,e=this.toTP("jqx-grid-cell");if(this.table&&0<this.table.length&&this.table[0].rows&&0<this.table[0].rows.length){var f=this.table[0].rows[0];this.table[0].style.top=
1016"0px";for(var g=0;g<f.cells.length;g++){var h=a(f.cells[g]);if("none"!=h.css("display")&&!d){h[0].checkbox=null;h[0].button=null;h[0].className=e;d=!0;h[0].innerHTML="";var k=a("<span style='white-space: nowrap; float: left; margin-left: 50%; position: relative;'></span>");k.text(this.gridlocalization.emptydatastring);h.append(k);var l=0;this.oldhscroll||(l=parseInt(this.table[0].style.marginLeft),this.rtl&&(h.css("z-index",999),h.css("overflow","visible")));k.css("left",-l-k.width()/2);k.css("top",
1017this._gettableheight()/2-k.height()/2);a.jqx.browser.msie&&8>a.jqx.browser.version&&(k.css("margin-left","0px"),k.css("left",this.host.width()/2-k.width()/2));k=Math.abs(parseInt(this.table[0].style.top));isNaN(k)&&(k=0);a(f).height(this._gettableheight()+k);h.css("margin-left","0px");h.width(this.host.width());this.table.width()<this.host.width()&&this.table.width(this.host.width())}h.addClass(this.toThemeProperty("jqx-grid-empty-cell"))}}}},_clearvisualrows:function(){var d=this.virtualsizeinfo.visiblerecords,
1018e=parseInt(this.hScrollInstance.value),f=this.groupable&&0<this.groups.length;if(this.columns.records)for(var g=0;g<d;g++)this._clearvisualrow(e,f,g,0,this.columns.records.length)},_iscellselected:function(d,e,f){var g=!1,h=0;this.virtualmode&&this.pageable&&this.groupable&&0<this.groups.length&&(h=this.dataview.pagesize*this.dataview.pagenum);if(0<this.groups.length&&this.pageable&&this.groupable){d=this.getrowboundindexbyid(e.bounddata.uid);if(-1!=d){for(var k in this.selectedcells)k==d+"_"+f&&
1019(g=!0);return g}return!1}if(d&&null!=e.bounddata)if("singlerow"!=this.selectionmode)if(0<this.dataview.filters.length)if(this.virtualmode||void 0==e.bounddata.dataindex)for(k in this.selectedcells)k==
1019h+e.bounddata.boundindex+"_"+f&&(g=!0);else for(k in this.selectedcells)k==h+e.bounddata.dataindex+"_"+f&&(g=!0);else for(k in this.selectedcells){if(k==h+e.bounddata.boundindex+"_"+f){g=!0;break}}else if(0<this.dataview.filters.length)if(!this.virtualmode&&void 0!=e.bounddata.dataindex)for(k in this.selectedcells){if(k==
1020h+e.bounddata.dataindex+"_"+f){g=!0;break}}else for(k in this.selectedcells){if(k==h+e.bounddata.boundindex+"_"+f){g=!0;break}}else for(k in this.selectedcells)if(k==h+e.bounddata.boundindex==this.selectedrowindex){g=!0;break}return g},_isrowselected:function(d,e){var f=!1,g=0;this.virtualmode&&this.pageable&&this.groupable&&0<this.groups.length&&(g=this.dataview.pagesize*this.dataview.pagenum);if(this.groupable&&0<this.groups.length&&this.pageable){d=this.getrowboundindexbyid(e.bounddata.uid);if(void 0==
1021d||-1==d)return!1;-1!=this.selectedrowindexes.indexOf(d)&&(f=!0);f||=d==this.selectedrowindex&&-1!=this.selectedrowindex;return f}d&&null!=e.bounddata&&("singlerow"!=this.selectionmode?0<this.dataview.filters.length?this.virtualmode||void 0==e.bounddata.dataindex?-1!=this.selectedrowindexes.indexOf(g+e.bounddata.boundindex)&&(f=!0):-1!=this.selectedrowindexes.indexOf(g+e.bounddata.dataindex)&&(f=!0):-1!=this.selectedrowindexes.indexOf(g+e.bounddata.boundindex)&&(f=!0):0<this.dataview.filters.length?
1022this.virtualmode||void 0==e.bounddata.dataindex?-1!=this.selectedrowindexes.indexOf(g+e.bounddata.boundindex)&&(f=!0):-1!=this.selectedrowindexes.indexOf(g+e.bounddata.dataindex)&&(f=!0):g+e.bounddata.boundindex==this.selectedrowindex&&(f=!0));return f},_rendervisualcell:function(d,e,f,g,h,k,l,m,n,r,t,u){var x=this.columns.records[r];if(x.hidden||x.adaptivehidden)t=m.cells[r],t.innerHTML="";else{var B=this._getcellvalue(x,n);t=m.cells[r];-1!=this.selectionmode.indexOf("cell")&&(f=0<this.dataview.filters.length?
1023this.selectedcells[n.bounddata.dataindex+"_"+x.datafield]?!0:!1:this.selectedcells[n.boundindex+"_"+x.datafield]?!0:!1,this.editcell&&this.editcell.row===n.boundindex&&this.editcell.column===x.datafield&&"checkbox"!==x.columntype&&(f=!1),this.virtualmode||this.groupable&&0<this.groups.length&&this.pageable)&&(f=this._iscellselected(!0,n,x.datafield));if(""!=x.cellclassname&&x.cellclassname)if("string"==typeof x.cellclassname)e+=" "+x.cellclassname;else{this._columnClassNameCache||(this._columnClassNameCache=
1024[]);var y=this.getboundindex(n);if(void 0!==this._columnClassNameCache[y+"_"+x.datafield+"_"+B]&&this.enableoptimization){var A=this._columnClassNameCache[y+"_"+x.datafield+"_"+B];A&&(e+=" "+A)}else(A=x.cellclassname(y,x.datafield,B,n.bounddata))&&(e+=" "+A),this._columnClassNameCache[y+"_"+x.datafield+"_"+B]=A}y=this.showsortcolumnbackground&&this.sortcolumn&&x.displayfield==this.sortcolumn;if("many"===this.sortmode&&this.showsortcolumnbackground){A=this.getsortcolumns();for(var aa=0;aa<A.length;aa++)x.displayfield===
1025A[aa].dataField&&(y=!0)}y&&(e+=" "+this.toTP("jqx-grid-cell-sort"));x.filter&&this.showfiltercolumnbackground&&(e+=" "+this.toTP("jqx-grid-cell-filter"));n.bounddata.totalsrow&&(e+=" "+this.toTP("jqx-grid-cell-pinned"));if(x.pinned&&this.showpinnedcolumnbackground||x.grouped)k?n.bounddata.totalsrow||(e+=" "+this.toTP("jqx-grid-cell-pinned")):e+=" "+this.toTP("jqx-grid-cell-pinned");this.altrows&&void 0==n.group&&(A=n.visibleindex,A>=this.altstart&&0==(this.altstart+A)%(1+this.altstep)&&(e=y?e+(" "+
1026this.toTP("jqx-grid-cell-sort-alt")):e+(" "+this.toTP("jqx-grid-cell-alt")),x.filter&&this.showfiltercolumnbackground&&(e+=" "+this.toTP("jqx-grid-cell-filter-alt")),x.pinned&&this.showpinnedcolumnbackground&&(e+=" "+this.toTP("jqx-grid-cell-pinned-alt"))));if(r<=l){if(k||this.rowdetails||this.pageable&&this.virtualmode)y=a(t),A=this.columns.records[r].width,t.style.width!=parseInt(A)+"px"&&y.width(A)}else(k||this.rowdetails)&&this._hiddencolumns&&(y=a(t),A=this.columns.records[r].width,parseInt(t.style.width)!=
1027A&&y.width(A));
1027if(this.rowdetails&&g&&(h&&!k?e+=" "+this.toTP("jqx-grid-details-cell"):k&&(e+=" "+this.toTP("jqx-grid-group-details-cell")),this.showrowdetailscolumn))if(!this.rtl){if(void 0==n.group&&r==l&&!n.bounddata.totalsrow){d=this.toThemeProperty("jqx-icon-arrow-down");h?e+=" "+this.toTP("jqx-grid-group-expand"):(e+=" "+this.toTP("jqx-grid-group-collapse"),d=this.toThemeProperty("jqx-icon-arrow-right"));e+=" "+d;t.title="";t.innerHTML="";t.className!=e&&(t.className=e);return}}else if(void 0==
1028n.group&&r==m.cells.length-l-1){d=this.toThemeProperty("jqx-icon-arrow-down");h?e+=" "+this.toTP("jqx-grid-group-expand-rtl"):(e+=" "+this.toTP("jqx-grid-group-collapse-rtl"),d=this.toThemeProperty("jqx-icon-arrow-left"));e+=" "+d;t.title="";t.innerHTML="";t.className!=e&&(t.className=e);return}f&&r>=l&&(e+=" "+this.toTP("jqx-grid-cell-selected"),e+=" "+this.toTP("jqx-fill-state-pressed"));t.className!=e&&(t.className=e);x._applyCellStyle(t);void 0!=n.group?(t.title="",t.innerHTML=""):d(this,x,n,
1029B,t,u)}},_rendercell:function(d,e,f,g,h,k){var l=g+"_"+e.visibleindex;if("number"==e.columntype||null!=e.cellsrenderer)l=f.uniqueid+"_"+e.visibleindex;"number"==e.columntype&&(g=f.visibleindex);"adaptive"===e.columntype&&(g="...");e._applyCellStyle(h);h.style.borderBottomColor=d.showrowlines?"":"transparent";d.showcolumnheaderlines?(e.element.style.borderRightColor="",e.element.style.boxShadow=""):(e.element.style.borderRightColor="transparent",e.element.style.boxShadow="none");h.style.borderRightColor=
1030d.showcolumnlines?"":"transparent";if(d.editcell&&void 0==d.editrow)if("selectedrow"==d.editmode&&e.editable&&d.editable){if(d.editcell.row==d.getboundindex(f)&&d._showcelleditor){d.hScrollInstance.isScrolling()||d.vScrollInstance.isScrolling()?d._showcelleditor(d.editcell.row,e,h,!1,!1):d._showcelleditor(d.editcell.row,e,h,d.editcell.init);h.className+=" "+d.toTP("jqx-grid-cell-edit");return}}else if(d.editcell.row==d.getboundindex(f)&&d.editcell.column==e.datafield&&(d.editcell.element=h,d.editcell.editing&&
1031d._showcelleditor)){d.hScrollInstance.isScrolling()||d.vScrollInstance.isScrolling()?d._showcelleditor(d.editcell.row,e,d.editcell.element,d.editcell.init,!1):d._showcelleditor(d.editcell.row,e,d.editcell.element,d.editcell.init);h.className+=" "+d.toTP("jqx-grid-cell-edit");return}var m=d._defaultcellsrenderer(g,e),n=d._cellscache[l];if(n){if("checkbox"==e.columntype){if(d.host.jqxCheckBox){""===g&&(g=null);l=0==h.innerHTML.toString().length;!h.checkbox||d.groupable||l?d._rendercheckboxcell(d,h,
1032e,f,g):(h.checkboxrow=d.getboundindex(f),""==g&&(g=!1),"1"==g&&(g=!0),"0"==g&&(g=!1),1==g&&(g=!0),0==g&&(g=!1),"true"==g&&(g=!0),"false"==g&&(g=!1),null!=g||e.threestatecheckbox||(g=!1),e.checkboxcolumn&&(g=!1,0<d.dataview.filters.length&&!d.virtualmode&&void 0!=f.bounddata.dataindex?-1!=d.selectedrowindexes.indexOf(f.bounddata.dataindex)&&(g=!0):-1!=d.selectedrowindexes.indexOf(f.bounddata.boundindex)&&(g=!0)),d.disabled||(h.checkboxinstance?h.checkboxinstance._setState(g):h.checkbox.jqxCheckBox("_setState",
1033g)));null!=e.cellsrenderer&&(d=e.cellsrenderer(d.getboundindex(f),e.datafield,g,m,e.getcolumnproperties(),f.bounddata),void 0!=d&&(h.innerHTML=d));return}}else if("button"==e.columntype){if(d.host.jqxButton){""==g&&(g=!1);null!=e.cellsrenderer&&(g=e.cellsrenderer(d.getboundindex(f),e.datafield,g,m,e.getcolumnproperties(),f.bounddata));""==h.innerHTML&&(h.buttonrow=d.getboundindex(f),h.button=null,d._renderbuttoncell(d,h,e,f,g));h.button&&!d.groupable?(h.buttonrow=d.getboundindex(f),h.button.val(g)):
1034d._renderbuttoncell(d,h,e,f,g);return}}else if(("progressbar"==e.columntype||"rating"===e.columntype)&&d.host.jqxButton){""==g&&(g=!1);null!=e.cellsrenderer&&(g=e.cellsrenderer(d.getboundindex(f),e.datafield,g,m,e.getcolumnproperties(),f.bounddata));""==h.innerHTML&&(h.progressrow=d.getboundindex(f),h.progress=null,d._renderprogresscell(d,h,e,f,g));h.progress&&!d.groupable?(h.progressrow=d.getboundindex(f),h.progress.val(g)):d._renderprogresscell(d,h,e,f,g);return}if(e.createwidget)if(""==h.innerHTML&&
1035(h.widgetrow=d.getboundindex(f),h.widget=null,e.widget=null,d._renderwidgetcell(d,h,e,f,g)),h.widget&&!d.groupable)if(h.widgetrow=d.getboundindex(f),e.initwidget)e.initwidget(d.getboundindex(f),e.datafield,g,h.firstChild);
1035else throw Error("jqxGrid: 'initwidget' column function is not implemented. Please, implement 'initwidget'");else d._renderwidgetcell(d,h,e,f,g);else{var r=n.element;null!=e.cellsrenderer||h.childNodes&&0==h.childNodes.length||d.groupable||d.rowdetails?h.innerHTML!=r&&(h.innerHTML=
1036r):0<=h.innerHTML.indexOf("editor")?h.innerHTML=r:k?(g=r.indexOf(">"),m=r.indexOf("</"),m=r.substring(g+1,m),g=h.childNodes[0],0<=m.indexOf(">")?h.innerHTML=r:g.childNodes[0]?m!=g.childNodes[0].nodeValue&&(0<=m.indexOf("&")?h.innerHTML=r:g.childNodes[0].nodeValue=m):(r=document.createTextNode(m),g.appendChild(r))):h.innerHTML!=r&&(h.innerHTML=r);d.enabletooltips&&e.enabletooltips&&(h.title=n.title)}}else if("checkbox"==e.columntype)d._rendercheckboxcell(d,h,e,f,g),d._cellscache[l]={element:"",title:g},
1037d.enabletooltips&&e.enabletooltips&&(h.title=""+g);else if("button"==e.columntype)null!=e.cellsrenderer&&(g=e.cellsrenderer(d.getboundindex(f),e.datafield,g,m,e.getcolumnproperties(),f.bounddata)),d._renderbuttoncell(d,h,e,f,g),d._cellscache[l]={element:"",title:g},d.enabletooltips&&e.enabletooltips&&(h.title=""+g);else if("progressbar"==e.columntype||"rating"===e.columntype)null!=e.cellsrenderer&&(g=e.cellsrenderer(d.getboundindex(f),e.datafield,g,m,e.getcolumnproperties(),f.bounddata)),d._renderprogresscell(d,
1038h,e,f,g),d._cellscache[l]={element:"",title:g},d.enabletooltips&&e.enabletooltips&&(h.title=""+g);else if("number"==e.columntype&&(g=f.visibleindex),e.createwidget)null!=e.cellsrenderer&&(g=e.cellsrenderer(d.getboundindex(f),e.datafield,g,m,e.getcolumnproperties(),f.bounddata)),d._renderwidgetcell(d,h,e,f,g),d._cellscache[l]={element:"",title:g},d.enabletooltips&&e.enabletooltips&&(h.title=g);else{if(null!=e.cellsrenderer){if(d._columnCellsRenderCache||(d._columnCellsRenderCache=[]),n=d.getboundindex(f),
1039void 0!==d._columnCellsRenderCache[n+"_"+e.datafield+"_"+g]&&d.enableoptimization?r=d._columnCellsRenderCache[n+"_"+e.datafield+"_"+g]:(r=e.cellsrenderer(d.getboundindex(f),e.datafield,g,m,e.getcolumnproperties(),f.bounddata),d._columnCellsRenderCache[n+"_"+e.datafield+"_"+g]=r),r&&(0<=r.indexOf("<jqx-")||0<=r.indexOf(" ng-"))){d.toCompile&&d.toCompile.push({cell:h,value:r,row:d.getboundindex(f)});return}}else r=m;null==r&&(r=m);n=g;d.enabletooltips&&e.enabletooltips&&(""!=e.cellsformat&&a.jqx.dataFormat&&
1040(a.jqx.dataFormat.isDate(g)?n=a.jqx.dataFormat.formatdate(n,e.cellsformat,d.gridlocalization):a.jqx.dataFormat.isNumber(g)&&(n=a.jqx.dataFormat.formatnumber(n,e.cellsformat,d.gridlocalization))),h.title=n);d.WinJS?a(h).html(r):(f=h.innerHTML,0<=f.indexOf("editor")||null!=e.cellsrenderer||d.groupable||d.virtualmode?h.innerHTML=r:0<f.length?(g=r.indexOf(">"),m=r.indexOf("</"),m=r.substring(g+1,m),g=h.childNodes[0],0<=m.indexOf(">")?h.innerHTML=r:g.childNodes[0]?m!=g.childNodes[0].nodeValue&&(0<=m.indexOf("&")||
10410<=f.indexOf("span")?h.innerHTML=r:g.childNodes[0].nodeValue=m):(r=document.createTextNode(m),g.appendChild(r))):f!=r&&(h.innerHTML=r));d._cellscache[l]={element:h.innerHTML,title:n};return!0}},_isIE10:function(){if(void 0==this._browser){var d=a.jqx.utilities.getBrowser();"msie"==d.browser&&9<parseInt(d.version)?this._browser=!0:(this._browser=!1,"msie"==d.browser&&(d="Browser CodeName: "+navigator.appCodeName,d+="Browser Name: "+navigator.appName,d+="Browser Version: "+navigator.appVersion,d+="Platform: "+
1042navigator.platform,d+="User-agent header: "+navigator.userAgent,-1!=d.indexOf("Zune 4.7")&&(this._browser=!0)))}return this._browser},_renderinlinecell:function(d,e,f,g,h){a(e);e.innerHTML='<div style="position: absolute;"></div>'},_rendercheckboxcell:function(d,e,f,g,h){if(d.host.jqxCheckBox){var k=a(e);""===h&&(h=f.threestatecheckbox?null:!1);null!==h||f.threestatecheckbox||(h=!1);"1"==h&&(h=!0);"0"==h&&(h=!1);1==h&&(h=!0);0==h&&(h=!1);"true"==h&&(h=!0);"false"==h&&(h=!1);if(f.checkboxcolumn){h=
1043!1;var l=this.getboundindex(g);-1!=this.selectedrowindexes.indexOf(l)&&(h=!0)}0==k.find(".jqx-checkbox").length?(e.innerHTML='<div style="position: absolute; top: 50%; left: 50%; margin-top: -9px; margin-left: -12px;"></div>',a(e.firstChild).jqxCheckBox({disabled:d.disabled,_canFocus:!1,hasInput
1043:!1,hasThreeStates:f.threestatecheckbox,enableContainerClick:!1,animationShowDelay:0,animationHideDelay:0,locked:!0,theme:d.theme,checked:h}),this.enabletooltips&&f.enabletooltips&&(e.title=""+h),this.editable&&
1044f.editable&&a(e.firstChild).jqxCheckBox({locked:!1}),f.checkboxcolumn&&a(e.firstChild).jqxCheckBox({locked:!1}),e.checkbox=a(e.firstChild),e.checkboxinstance=e.checkbox.data().jqxCheckBox.instance,e.checkboxrow=this.getboundindex(g),a.data(e.firstChild,"jqxCheckBox").instance.updated=function(m,n,r){if(d.disabled){n=r;m=d.table[0].rows.length;for(var t=d._getcolumnindex(f.datafield),u=0;u<m;u++){var x=d.table[0].rows[u].cells[t].firstChild;x&&a(x).jqxCheckBox({disabled:d.disabled})}}if(f.editable&&
1045!d.disabled){if(m=d.table[0].rows.length,t=d._getcolumnindex(f.datafield),void 0==d.editrow)if(f.cellbeginedit&&0==f.cellbeginedit(e.checkboxrow,f.datafield,f.columntype,!n))d.setcellvalue(e.checkboxrow,f.datafield,!n,!0);else{f.cellvaluechanging&&(u=f.cellvaluechanging(e.checkboxrow,f.datafield,f.columntype,r,n),void 0!=u&&(n=u));if("selectedrow"!==d.editmode)for(u=0;u<m;u++)(x=d.table[0].rows[u].cells[t].firstChild)&&a(x).jqxCheckBox("destroy");d.editcell&&0==d.editcell.validated?d.setcellvalue(e.checkboxrow,
1046f.datafield,!n,!0):"selectedrow"!==d.editmode||null==d.editcell?(m=d.getrowdata(e.checkboxrow),d._raiseEvent(17,{rowindex:e.checkboxrow,row:m,datafield:f.datafield,value:r,columntype:f.columntype}),d.pushToHistory=!0,d.setcellvalue(e.checkboxrow,f.datafield,n,!0),d.pushToHistory=!1,d._raiseEvent(18,{rowindex:e.checkboxrow,row:m,datafield:f.datafield,oldvalue:r,value:n,columntype:f.columntype})):(d.pushToHistory=!0,d.setcellvalue(e.checkboxrow,f.datafield,n,!1,!1),d.pushToHistory=!1);f.cellendedit&&
1047f.cellendedit(e.checkboxrow,f.datafield,f.columntype,n)}}else f.checkboxcolumn&&(d.editcell&&d.endcelledit(d.editcell.row,d.editcell.column,!1,!0),d.disabled||(n?d.selectrow(e.checkboxrow):d.unselectrow(e.checkboxrow),d.autosavestate&&d.savestate&&d.savestate()))}):(e.checkboxrow=this.getboundindex(g),a(e.firstChild).jqxCheckBox("_setState",h,!(this.editable&&f.editable)&&!f.checkboxcolumn))}},_renderwidgetcell:function(d,e,f,g,h){0==a(e).find(".jqx-grid-widget").length?(e.innerHTML='<div class="jqx-grid-widget" style="opacity: 0.99; position: absolute; width: 100%; height:100%; top: 0%; left: 0%; padding: 0px;"></div>',
1048f.createwidget(g,f.datafield,h,e.firstChild),a(e.firstChild).attr("hideFocus","true"),a(e.firstChild).children().addClass("jqx-grid-widget"),e.widget=a(e.firstChild),e.widgetrow=d.getboundindex(g),f.widget=a(e.firstChild)):(f.initwidget(d.getboundindex(g),f.datafield,h,e.firstChild),e.widgetrow=d.getboundindex(g),a(e.firstChild).val(h))},_renderprogresscell:function(d,e,f,g,h){var k=a(e);if("rating"===f.columntype){d._linkadded||(g=document.createElement("link"),g.rel="stylesheet",g.href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css",
1049document.head.appendChild(g),d._linkadded=!0);f.ratingmax||(f.ratingmax=5);d="";for(g=0;g<f.ratingmax;g++)d=h>=g+1?d+'<span style="color: rgba(255, 165, 0, 1);" class="fa fa-star checked"></span>':d+'<span style="color: rgba(255, 165, 0, .3);" class="fa fa-star"></span>';f=f.cellsalign;"right"===f&&(f="flex-end");e.innerHTML='<div style="display: flex; width: 100%; height: 100%; justify-content: '+f+'; padding: 5px; box-sizing: border-box; font-size: 16px; align-items: center;">'+d+"</div>"}else""==
1050h&&(h=!1),0==k.find(".jqx-progress").length?(e.innerHTML='<progress class="jqx-progress" max="100" style="opacity: 0.99; position: absolute; top: 10%; left: 10%; width:80%; height:80%; padding: 0px;"/>',a(e.firstChild).val(h),e.progress=a(e.firstChild),e.progressrow=d.getboundindex(g)):(e.progressrow=d.getboundindex(g),a(e.firstChild).val(h))},_renderbuttoncell:function(d,e,f,g,h){if(d.host.jqxButton){var k=a(e);""==h&&(h=!1);0==k.find(".jqx-button").length?(e.innerHTML='<input type="button" style="opacity: 0.99; position: absolute; top: 0%; left: 0%; padding: 0px; margin-top: 2px; margin-left: 2px;"/>',
1051a(e.firstChild).val(h),a(e.firstChild).attr("hideFocus","true"),a(e.firstChild).jqxButton({disabled:d.disabled,theme:d.theme,height:d.rowsheight-4,width:f.width-4}),e.button=a(e.firstChild),e.buttonrow=d.getboundindex(g),this.isTouchDevice()?(g=a.jqx.mobile.getTouchEventName("touchend"),d.addHandler(a(e.firstChild),g,function(l){f.buttonclick&&f.buttonclick(e.buttonrow,l)})):d.addHandler(a(e.firstChild),"click",function(l){f.buttonclick&&f.buttonclick(e.buttonrow,l)})):(e.buttonrow=d.getboundindex(g),
1052a(e.firstChild).val(h))}},_clearvisualrow:function(d,e,f,g,h){var k=this.toTP("jqx-grid-cell");e&&(k=" "+this.toTP("jqx-grid-group-cell"));k+=" "+this.toTP("jqx-grid-cleared-cell");e=this.table[0].rows;for(var l=0;l<g+h;l++)if(e[f]){var m=e[f].cells[l];m.className!=k&&(m.className=k);var n=this.columns.records[l];this._horizontalvalue==d||n.pinned||1!=this.oldhscroll||(m.style.marginLeft=-d+"px");var r=n.width;n.adaptivewidth&&(r=n.adaptivewidth);r<n.minwidth&&(r=n.minwidth);r>n.maxwidth&&(r=n.maxwidth);
1053parseInt(m.style.width)!=r&&("auto"!=r?a(m)[0].style.width=r+"px":a(m)[0].style.width=r);""!=m.title&&(m.title="");""!=m.innerHTML&&(m.innerHTML="")}
1053e[f]&&(d=this.rowsheight,this.cardview&&(d=this.cardheight),parseInt(e[f].style.height)!=d&&(e[f].style.height=parseInt(d)+"px"))},_findgroupstate:function(d){d=this._findgroup(d);return null==d?!1:d.expanded},_findgroup:function(d){return this.expandedgroups[d]?this.expandedgroups[d]:null},_clearcaches:function(){this._columnsbydatafield=[];this._pagescache=
1054[];this._pageviews=[];this._cellscache=[];this._columnClassNameCache=[];this._columnCellsRenderCache=[];this.heights=[];this.hiddens=[];this.hiddenboundrows=[];this.heightboundrows=[];this.detailboundrows=[];this.details=[];this.expandedgroups=[];this._rowdetailscache=[];this._rowdetailselementscache=[];a.jqx.dataFormat&&a.jqx.dataFormat.cleardatescache();this.tableheight=null},_getColumnText:function(d){void 0==this._columnsbydatafield&&(this._columnsbydatafield=[]);if(this._columnsbydatafield[d])return this._columnsbydatafield[d];
1055var e=d,f=null;a.each(this.columns.records,function(){if(this.datafield==d||this.displayfield==d)return e=this.text,f=this,!1});this._columnsbydatafield[d]={label:e,column:f};return this._columnsbydatafield[d]},_getcolumnbydatafield:function(d){void 0==this.__columnsbydatafield&&(this.__columnsbydatafield=[]);if(this.__columnsbydatafield[d])return this.__columnsbydatafield[d];var e=null;a.each(this.columns.records,function(){if(this.datafield==d||this.displayfield==d)return e=this,!1});this.__columnsbydatafield[d]=
1056e;return this.__columnsbydatafield[d]},isscrollingvertically:function(){return this.vScrollBar.jqxScrollBar("isScrolling")}
1056,_renderrowdetails:function(d,e,f,g,h,k){if(void 0!=e){var l=a(e);k=this.rowdetails&&this.showrowdetailscolumn?(1+this.groups.length)*this.groupindentwidth:this.groups.length*this.groupindentwidth;if(this.groupable&&0<this.groups.length)for(var m=0;m<=h;m++){var n=a(e.cells[m]);n[0].innerHTML="";n[0].className="jqx-grid-details-cell"}n=a(e.cells[0]);if("none"==n[0].style.display){n=
1057e.cells[0];for(m=2;void 0!=n&&"none"==n.style.display&&10>m;)n=e.cells[0+m-1],m++;n=a(n)}if(this.rtl)for(;g<h;g++)e.cells[g].innerHTML="",e.cells[g].className="jqx-grid-details-cell";n.css("width","100%");l.height(f.rowdetailsheight);n[0].className=d;d=this.getboundindex(f);h=d+"_";this._rowdetailscache[h]?(e=this._rowdetailscache[h].html,this.initrowdetails?this._rowdetailscache[h].element&&(e=this._rowdetailscache[h].element,n=n.coord(),g=this.gridcontent.coord(),f=parseInt(n.top)-parseInt(g.top),
1058n=parseInt(n.left)-parseInt(g.left),this.rtl&&(n=0),a(e).css("top",f),a(e).css("left",n),a(e).css("display","block"),a(e).width(this.host.width()-k),this.layoutrowdetails&&this.layoutrowdetails(d,e,this.element,this.getrowdata(d))):n[0].innerHTML=e):(n[0].innerHTML="",this.enablerowdetailsindent||(k=0),g='<div class="jqx-enableselect" role="rowgroup" style="border: none; overflow: hidden; width: 100%; height: 100%; margin-left: '+k+'px;">'+f.rowdetails+"</div>",this.rtl&&(g='<div class="jqx-enableselect" role="rowgroup" style="border: none; overflow: hidden; width: 100%; height: 100%; margin-left: 0px; margin-right: '+
1059k+'px;">'+f.rowdetails+"</div>"),this._rowdetailscache[h]={id:e.id,html:g},this.initrowdetails?(e=a(g)[0],a(this.gridcontent).prepend(a(e)),a(e).css("position","absolute"),a(e).width(this.host.width()-k),a(e).height(n.height()),n.coord(),a(e).css("z-index",1799),this.isTouchDevice()&&a(e).css("z-index",1999),a(e).addClass(this.toThemeProperty("jqx-widget-content")),n=n.coord(),g=this.gridcontent.coord(),f=parseInt(n.top)-parseInt(g.top),n=parseInt(n.left)-parseInt(g.left),a(e).css("top",f),a(e).css("left",
1060n),this.content[0].scrollTop=0,this.content[0].scrollLeft=0,k=a(a(e).children()[0]),""!=k[0].id&&(k[0].id+=d),this.initrowdetails(d,e,this.element,this.getrowdata(d)),this._rowdetailscache[h].element=e,this._rowdetailselementscache[d]=e):n[0].innerHTML=g)}},_defaultcellsrenderer:function(d,e){""!=e.cellsformat&&a.jqx.dataFormat&&(a.jqx.dataFormat.isDate(d)?d=a.jqx.dataFormat.formatdate(d,e.cellsformat,this.gridlocalization):a.jqx.dataFormat.isNumber(d)&&(d=a.jqx.dataFormat.formatnumber(d,e.cellsformat,
1061this.gridlocalization)));var f="8px";31!=this.rowsheight&&(f=this.rowsheight/2-this._cellheight/2,0>f&&(f=4),f+="px");if(this.enableellipsis){if("center"==e.cellsalign||"middle"==e.cellsalign)return'<div class="jqx-grid-cell-middle-align" style="margin-top: '+f+';">'+d+"</div>";if("left"==e.cellsalign)return'<div class="jqx-grid-cell-left-align" style="margin-top: '+f+';">'+d+"</div>";if("right"==e.cellsalign)return'<div class="jqx-grid-cell-right-align" style="margin-top: '+f+';">'+d+"</div>"}return"center"==
1062e.cellsalign||"middle"==e.cellsalign?'<div style="text-align: center; margin-top: '+f+';">'+d+"</div>":'<span style="margin-left: 4px; margin-right: 2px; margin-top: '+f+"; float: "+e.cellsalign+';">'+d+"</span>"},getcelltext:function(d,e){if(null==d||null==e)return null;d=this.getcellvalue(d,e);(e=this.getcolumn(e))&&""!=e.cellsformat&&a.jqx.dataFormat&&(a.jqx.dataFormat.isDate(d)?d=a.jqx.dataFormat.formatdate(d,e.cellsformat,this.gridlocalization):a.jqx.dataFormat.isNumber(d)&&(d=a.jqx.dataFormat.formatnumber(d,
1063e.cellsformat,this.gridlocalization)));return d},getcelltextbyid:function(d,e){if(null==d||null==e)return null;d=this.getcellvaluebyid(d,e);(e=this.getcolumn(e))&&""!=e.cellsformat&&a.jqx.dataFormat&&(a.jqx.dataFormat.isDate(d)?d=a.jqx.dataFormat.formatdate(d,e.cellsformat,this.gridlocalization):a.jqx.dataFormat.isNumber(d)&&(d=a.jqx.dataFormat.formatnumber(d,e.cellsformat,this.gridlocalization)));return d},_getcellvalue:function(d,e){var f=e.bounddata[d.datafield];null!=d.displayfield&&(f=e.bounddata[d.displayfield]);
1064null==f&&(f="");return f},getcell:function(d,e){if(null==d||null==e)return null;var f=parseInt(d),g=d,h="";isNaN(f)||(g=this.getrowdata(f));null!=g&&(h=g[e]);return this._getcellresult(h,d,e)},getrenderedcell:function(d,e){if(null==d||null==e)return null;var f=parseInt(d),g=d,h="";isNaN(f)||(g=this.getrenderedrowdata(f));null!=g&&(h=g[e]);return this._getcellresult(h,d,e)},_getcellresult:function(d,e,f){var g=this.getcolumn(f);
1064if(null==g||void 0==g)return null;var h=g.getcolumnproperties();g=h.hidden;
1065var k=h.width,l=h.pinned,m=h.cellsalign;h=h.cellsformat;var n=this.getrowheight(e);return 0==n?null:{value:d,row:e,column:f,datafield:f,width:k,height:n,hidden:g,pinned:l,align:m,format:h}},setcellvaluebyid:function(d,e,f,g,h){d=this.getrowboundindexbyid(d);return this.setcellvalue(d,e,f,g,h)},getcellvaluebyid:function(d,e){d=this.getrowboundindexbyid(d);return this.getcellvalue(d,e)},setcellvalue:function(d,e,f,g,h){if(null==d||null==e)return!1;var k=parseInt(d);this._columnClassNameCache=[];var l=
1066d;isNaN(k)||(l=this.getrowdata(k));var m=!1;this.filterable&&this._initfilterpanel&&this.dataview.filters.length&&(m=!0);this.virtualmode&&(this._pagescache=[]);this.sortcache&&(this.sortcache={});var n="",r="";if(null!=l&&l[e]!==f){if(null===l[e]&&""===f)return;var t=this._getcolumnbydatafield(e),u="string";this.source||(this.source=new a.jqx.dataAdapter({}));var x=this.source.datafields||(this.source._source?this.source._source.datafields:null);if(x){var B="";a.each(x,function(){if(this.name==t.displayfield)return this.type&&
1067(B=this.type),!1});B&&(u=B);r=l[t.displayfield]}n=l[e];this.pushToHistory&&(this._undoRedoIndex=-1,this._undoRedo.push({action:"setcellvalue",data:{oldvalue:n,value:f,datafield:e,row:d}}));if(!t.nullable||null!=f&&""!==f&&t.nullable&&void 0===f.label)if(a.jqx.dataFormat.isNumber(n)||"number"==u||"float"==u||"int"==u||"decimal"==u&&"date"!=u?(this.gridlocalization&&","==this.gridlocalization.decimalseparator&&f&&f.indexOf&&0<=f.indexOf(",")&&(f=f.replace(",",".")),f=new Number(f),f=parseFloat(f),isNaN(f)&&
1068(f=0)):!a.jqx.dataFormat.isDate(n)&&"date"!=u||""==f||(x=new Date(f),"Invalid Date"!=x&&null!=x?f=x:"Invalid Date"==x&&(f=x=a.jqx.dataFormat.parsedate(f,t.cellsformat))),l[e]===f){this._updating||0==g||this._renderrows(this.virtualsizeinfo);return}x=this.source&&this.source._source.localdata&&"observableArray"===this.source._source.localdata.name;l[e]=f;if(x){var y=this.source._source.localdata;y._updating||(y._updating=!0,y[d][e]=f,y._updating=!1)}u=this.getrenderedrowdata(k,!0);if(!u)return;u[e]=
1069f;null!=f&&null!=f.label&&(t=this._getcolumnbydatafield(e),l[t.displayfield]=f.label,u[t.displayfield]=f.label,l[e]=f.value,u[e]=f.value,x&&!y._updating&&(y._updating=!0,y[d][e]=f.value,y[d][t.displayfield]=f.label,y._updating=!1));m&&void 0!=l.dataindex&&(this.dataview.cachedrecords[l.dataindex][e]=f,null!=f&&void 0!=f.label&&(this.dataview.cachedrecords[l.dataindex][e]=f.value,this.dataview.cachedrecords[l.dataindex][t.displayfield]=f.label))}else return this._updating||0==g||this._renderrows(this.virtualsizeinfo),
1070!1;if(this.source&&this.source._knockoutdatasource&&!this._updateFromAdapter&&this.autokoupdates&&this.source._source._localdata){y=k;m&&void 0!=l.dataindex&&(y=l.dataindex);y=this.source._source._localdata()[y];this.source.suspendKO=!0;if(y[e]&&y[e].subscribe)if(null!=f&&null!=f.label)y[t.displayfield](f.label),y[e](f.value);else y[e](f);else{x=this.source._source.datafields;var A=null;x&&a.each(x,function(){if(this.name==e)return A=this.map,!1});if(null==A)null!=f&&null!=f.label?(y[e]=f.value,y[t.displayfield]=
1071f.label):y[e]=f;else if(x=A.split(this.source.mapChar),0<x.length){u=y;for(var aa=0;aa<x.length-1;aa++)u=u[x[aa]];u[x[x.length-1]]=f}this.source._source._localdata.replace(y,a.extend({},y))}this.source.suspendKO=!1}if(this.sortcolumn&&this.dataview.sortby&&!this._updating)if(y=this.getsortinformation(),this.sortcolumn==e&&"many"!==this.sortmode)this.dataview.clearsortdata(),this.dataview.sortby(y.sortcolumn,y.sortdirection.ascending);else{if("many"===this.sortmode)for(y=this.getsortcolumns(),this.dataview.clearsortdata(),
1072this.sortby(null),x=0;x<y.length;x++)this.sortby(y[x].dataField,y[x].ascending)}else this._updating||this.dataview.sortby&&this.dataview.sortcache[e]&&(this.dataview.sortcache[e]=null);this._cellscache=[];this._pagescache=[];if(this.source.updaterow&&(void 0==h||1==h)){h=!1;var ha=this.that;y=function(V){0==V&&(ha.setcellvalue(d,e,n,!0,!1),n!=r&&ha.setcellvalue(d,ha.getcolumn(e).displayfield,r,!0,!1))};try{var z=this.getrowid(k);h=this.source.updaterow(z,l,y);void 0==h&&(h=!0)}catch(V){h=!1;ha.setcellvalue(d,
1073e,n,!0,!1);n!=r&&ha.setcellvalue(d,ha.getcolumn(e).displayfield,r,!0,!1);return}}k=this.vScrollInstance.value;this._updating&&1!=g&&(g=!1);if(1==g||void 0==g)if(ha=this.that,g=function(){ha.pageable&&ha.updatepagerdetails&&(ha.updatepagerdetails(),(ha.autoheight||ha.autorowheight)&&ha._updatepageviews())},l=this.groupable&&0<this.groups.length,m&&!l){if(this.autoheight||this.autorowheight)this.prerenderrequired=!0;this.dataview.refresh();this.rendergridcontent(!0,!1);g();this._renderrows(this.virtualsizeinfo)}else if(this.sortcolumn&&
1074!l){if(this.autoheight||this.autorowheight)this.prerenderrequired=!0;this.dataview.reloaddata();this.rendergridcontent(!0,!1);g();this._renderrows(this.virtualsizeinfo)}else if(this.groupable&&0<this.groups.length){if(this.autoheight||this.autorowheight)this.prerenderrequired=!0;this.pageable?-1!=this.groups.indexOf(e)?(this._pagescache=[],this._cellscache=[],this.dataview.refresh(),this._render(!0,!0,!1,!1)):(this._pagescache=[],this._cellscache=[],this.dataview.updateview(),this._renderrows(this.virtualsizeinfo)):
1075(this._pagescache=[],this._cellscache=[],this.dataview.updateview(),this._renderrows(this.virtualsizeinfo))}else this.dataview.updateview(),this._renderrows(this.virtualsizeinfo);this.vScrollInstance.setPosition(k);this.showaggregates&&this._updatecolumnsaggregates&&this._updatecolumnsaggregates();this.showfilterrow&&this.filterable&&this.filterrow&&(m=this.getcolumn(e).filtertype,"list"!=m&&"checkedlist"!=m||this._updatelistfilters(!0));this._raiseEvent(19,{rowindex:d,datafield:e,newvalue:f,value:f,
1076oldvalue:n});return!0},getcellvalue:function(d,e){if(null==d||null==e)return null;var f=parseInt(d);isNaN(f)||(d=this.getrowdata(f));return null!=d?d[e]:null},getrows:function(){var d=this.dataview.records.length;if(this.virtualmode){for(var e=[],f=0;f<this.dataview.records.length;f++)(d=this.dataview.records[f])&&e.push(d);void 0===this.dataview.records.length&&a.each(this.dataview.records,function(){this&&e.push(this)});f=0;this.pageable&&(f=this.dataview.pagenum*this.dataview.pagesize);return e.length>
1077this.source._source.totalrecords-f?e.slice(0,this.source._source.totalrecords-f):e}if(this.dataview.sortdata){e=[];for(f=0;f<d;f++){var g={};g=a.extend({},this.dataview.sortdata[f].value);e[f]=g}return e}return this.dataview.records},getrowboundindexbyid:function(d){var e=this.dataview.recordsbyid["id"+d];if(e&&e.boundindex)return this.getboundindex(e);e=this.getboundrows();for(var f=0;f<e.length;f++)if(e[f]&&e[f].uid==d)return f;return-1},getrowdatabyid:function(d){var e=this.dataview.recordsbyid["id"+
1078d];if(e)return e;d=this.getrowboundindexbyid(d);return this.getboundrows()[d]},getrowdata:function(d){void 0==d&&(d=0);return this.virtualmode?this.dataview.records[d]:this.getboundrows()[d]},getrenderedrowdata:function(d,e){void 0==d&&(d=0);if(this.virtualmode){var f=this.getrowvisibleindex(d);return f=this.dataview.loadedrecords[f]}f=this.getrowvisibleindex(d);return 0<=f?(this.groupable&&0<this.groups.length?f=this.dataview.loadedrecords[f]:(f=this.dataview.loadedrecords[f],!this.pageable||void 0!=
1079e&&0!=e||(f=this.dataview.loadedrecords[this.dataview.pagesize*this.dataview.pagenum+d])),f):null},getboundrows:function(){return this.dataview.cachedrecords},getrowdisplayindex:function(d){for(var e=this.getdisplayrows(),f=0;f<e.length;
1079f++)if(e[f])if(void 0!==e[f].dataindex){if(e[f].dataindex==d)return e[f].visibleindex}else if(e[f].boundindex==d)return e[f].visibleindex;return-1},getboundindex:function(d){var e=d.boundindex;this.groupable&&0<this.groups.length&&this.pageable&&d.bounddata&&(e=this.getrowboundindexbyid(d.bounddata.uid));
10800<this.dataview.filters.length&&(d.bounddata?void 0!==d.bounddata.dataindex&&(e=d.bounddata.dataindex):void 0!==d.dataindex&&(e=d.dataindex));return e},getrowboundindex:function(d){return(d=this.getdisplayrows()[d])?void 0!==d.dataindex?d.dataindex:d.boundindex:-1},getdisplayrows:function(){return this.dataview.loadedrecords},getloadedrows:function(){return this.getdisplayrows()},getvisiblerowdata:function(d){var e=this.getvisiblerows();return e?e[d]:null},getloadedrowdata:function(d){var e=this.getloadedrows();
1081return e?e[d]:null},getvisiblerows:function(){if(this.virtualmode)return this.dataview.loadedrecords;if(this.pageable){for(var d=[],e=0;e<this.dataview.pagesize;e++){var f=this.dataview.loadedrecords[e+this.dataview.pagesize*this.dataview.pagenum];if(void 0==f)break;d.push(f)}return d}if(void 0!=this._startboundindex&&void 0!=this._endboundindex){d=[];for(e=this._startvisibleindex;e<=this._endvisibleindex;e++){f=this.dataview.loadedrecords[e];if(void 0==f)break;d.push(f)}return d}return this.dataview.loadedrecords},
1082getrowid:function(d){void 0==d&&(d=0);if(this.virtualmode){var e=this.getrowvisibleindex(d);if(e=this.dataview.loadedrecords[e])return e.uid}else if(e=0<this.dataview.filters.length,0<=d&&d<this.dataview.bounditems.length&&!e&&(e=this.getrowvisibleindex(d),e=this.dataview.loadedrecords[e])||0<this.dataview.filters.length&&(e=this.getboundrows()[d])&&null!=e.uid)return e.uid;return null},_updateGridData:function(d){var e=!1;this.filterable&&this._initfilterpanel&&this.dataview.filters.length&&(e=!0);
1083e?(this.dataview.refresh(),"updaterow"==d?(this._render(!0,!0,!1,!1,!1),this.invalidate()):this.render()):this.sortcolumn||this.groupable&&0<this.groups.length?(this.dataview.reloaddata(),this.render()):("updaterow"===d&&(this.dataview.refresh(),this.virtualmode||this._render(!0,!0,!1,!1,!1)),this._cellscache=[],this._pagescache=[],this._renderrows(this.virtualsizeinfo));this.showfilterrow&&this.filterable&&this.filterrow&&this._updatelistfilters(!0)},updaterow:function(d,e,f){if(void 0!=d&&void 0!=
1084e){var g=this.that,h=!1;g._datachanged=!0;this._columnClassNameCache=[];if(this.pushToHistory){var k=this.getrowdatabyid(d);this._undoRedoIndex=-1;
1084this._undoRedo.push({action:"updaterow",data:{id:d,rowdata:e,oldrowdata:k}})}var l=function(m,n,r){if(m._loading)throw Error("jqxGrid: "+m.loadingerrormessage);var t=!1;a.isArray(n)?(a.each(n,function(y,A){t=m.dataview.updaterow(this,r[y],!1)}),m._cellscache=[],m._pagescache=[],m.dataview.refresh()):t=m.dataview.updaterow(n,r);var u=m.vScrollInstance.value;
1085void 0!=f&&1!=f||void 0!=m._updating&&0!=m._updating||m._updateGridData("updaterow");m.showaggregates&&m._updatecolumnsaggregates&&m._updatecolumnsaggregates();if(m.source&&m.source._knockoutdatasource&&!m._updateFromAdapter&&m.autokoupdates&&m.source._source._localdata){var x=m.dataview.recordsbyid["id"+n],B=m.dataview.records.indexOf(x);B=m.source._source._localdata()[B];m.source.suspendKO=!0;m.source._source._localdata.replace(B,a.extend({},x));m.source.suspendKO=!1}m.source&&m.source._source.localdata&&
1086"observableArray"===m.source._source.localdata.name&&!m.source._source.localdata._updating&&(m.source._source.localdata._updating=!0,n=m.getrowboundindexbyid(n),m.source._source.localdata.set(n,r),m.source._source.localdata._updating=!1);m.vScrollInstance.setPosition(u);return t};if(this.source.updaterow){k=function(m){1==m||void 0==m?l(g,d,e):h=!1};try{h=this.source.updaterow(d,e,k),void 0==h&&(h=!0)}catch(m){h=!1}}else h=l(g,d,e);return h}return!1},deleterow:function(d,e){if(void 0!=d){this._datachanged=
1087!0;var f=!1,g=this.that,h=this.getrowboundindexbyid(d),k=[];if(void 0!=h&&(0<=this.selectedrowindexes.indexOf(h)&&this.selectedrowindexes.splice(this.selectedrowindexes.indexOf(h),1),this.selectedrowindex==h&&(this.selectedrowindex=-1),!this.virtualmode)){if(0<=g.selectionmode.indexOf("row"))a.each(this.selectedrowindexes,function(){var t=g.getrowid(this);k.push(t)}),this.selectedrowindexes=[],this.selectedrowindex=-1;else if(0<=g.selectionmode.indexOf("cell"))for(var l in g.selectedcells){var m=
1088g.selectedcells[l],n=g.getrowid(m.rowindex);m.rowid=n}this._rendervisualrows()}var r=function(t,u){if(t._loading)throw Error("jqxGrid: "+t.loadingerrormessage);var x=!1,B=t.vScrollInstance.value;a.isArray(u)?(a.each(u,function(){x=t.dataview.deleterow(this,!1)}),t._cellscache=[],t._pagescache=[],t.dataview.refresh()):x=t.dataview.deleterow(u);if(!t.virtualmode)if(0<=t.selectionmode.indexOf("row"))a.each(k,function(){var ha=t.getrowboundindexbyid(this);-1!=ha&&t.selectrow(ha,!1)});else{u=[];for(var y in t.selectedcells){var A=
1089t.selectedcells[y],aa=t.getrowboundindexbyid(A.rowid);-1!=aa&&(A.rowindex=aa,u[aa+"_"+A.datafield]=A)}t.selectedcells=u}void 0!=t._updating&&0!=t._updating||void 0!=e&&1!=e||setTimeout(function(){t._render(!0,!0,!1,!1);"visible"!=t.vScrollBar.css("visibility")&&(t._arrange(),t._updatecolumnwidths(),t._updatecellwidths(),t._renderrows(t.virtualsizeinfo))});t.source&&t.source._knockoutdatasource&&!t._updateFromAdapter&&t.autokoupdates&&t.source._source._localdata&&(t.source.suspendKO=!0,t.source._source._localdata.pop(),
1090t.source.suspendKO=!1);t.source&&t.source._source.localdata&&"observableArray"===t.source._source.localdata.name&&!t.source._source.localdata._updating&&(t.source._source.localdata._updating=!0,t.source._source.localdata.splice(h,1),t.source._source.localdata._updating=!1);t.dataview.sortby&&"many"!==t.sortmode&&(y=t.getsortinformation(),y.sortcolumn&&(t.dataview.clearsortdata(),t.dataview.sortby(y.sortcolumn,y.sortdirection?y.sortdirection.ascending:null)));t.vScrollInstance.setPosition(B);return x};
1091if(this.source.deleterow){l=function(t){1!=t&&void 0!=t||r(g,d)};try{this.source.deleterow(d,l),void 0==f&&(f=!0)}catch(t){f=!1}}else f=r(g,d);return f}return!1},addrow:function(d,e,f){if(void 0!=e){this._datachanged=!0;void 0==f&&(f="last");var g=!1,h=this.that;if(null==d){var k=this.dataview.filters&&0<this.dataview.filters.length?this.dataview.cachedrecords.length:this.dataview.totalrecords;if(a.isArray(e)){var l=[];a.each(e,function(r,t){r=h.dataview.getid(h.dataview.source.id,e[r],k+r);l.push(r)});
1092d=l}else for(d=this.dataview.getid(this.dataview.source.id,e,k);null!=this.dataview.recordsbyid["id"+d];)d++}
1092var m=function(r,t,u,x){if(r._loading)throw Error("jqxGrid: "+r.loadingerrormessage);var B=r.vScrollInstance.value,y=!1;a.isArray(u)?(a.each(u,function(aa,ha){void 0!=this.dataindex&&delete this.dataindex;ha=null;null!=t&&null!=t[aa]&&(ha=t[aa]);y=r.dataview.addrow(ha,this,x,!1)}),r._cellscache=[],r._pagescache=[],r.dataview.refresh()):(void 0!=u&&void 0!=u.dataindex&&delete u.dataindex,y=
1093r.dataview.addrow(t,u,x));if(void 0==r._updating||0==r._updating)r._render(!0,!0,!1,!1),r.invalidate();r.source&&r.source._knockoutdatasource&&!r._updateFromAdapter&&r.autokoupdates&&r.source._source._localdata&&(r.source.suspendKO=!0,r.source._source._localdata.push(u),r.source.suspendKO=!1);if(r.source&&r.source._source.localdata&&"observableArray"===r.source._source.localdata.name&&!r.source._source.localdata._updating){r.source._source.localdata._updating=!0;var A=r.getrowboundindexbyid(t);r.source._source.localdata.set(A,
1094u);r.source._source.localdata._updating=!1}"deferred"!=r.scrollmode?r.vScrollInstance.setPosition(B):r.vScrollInstance.setPosition(0);return y};if(this.source&&this.source.addrow){var n=function(r,t){if(1==r||void 0==r)void 0!=t&&(d=t),m(h,d,e,f)};try{g=this.source.addrow(d,e,f,n),void 0==g&&(g=!0)}catch(r){g=!1}if(0==g)return!1}else m(this,d,e,f);return g}return!1},_findvisiblerow:function(d,e){void 0==d&&(d=parseInt(this.vScrollInstance.value));var f=0;if(void 0==e||null==e)e=this.rows.records;
1095for(var g=e.length;f<=g;){var h=parseInt((f+g)/2),k=e[h];if(void 0==k)break;if(k.top>d&&k.top+k.height>d)g=h-1;else if(k.top<d&&k.top+k.height<d)f=h+1;else return h}return-1},_updatecellwidths:function(){var d=this.virtualsizeinfo;if(d){var e=this.that;if(void 0!=e.gridcontent){void 0==e.table&&(e.table=e.gridcontent.find("#contenttable"+e.element.id));var f=e.groupable&&0<e.groups.length,g=0;d=d.visiblerecords;e.pageable&&(e.autoheight||e.autorowheight)&&(d=e.dataview.pagesize,e.groupable&&(e.dataview.updateview(),
1096d=e.dataview.rows.length));e.groupable||e.pageable||!e.autoheight&&!e.autorowheight||(d=e.dataview.totalrecords);e.rowdetails&&(d+=e.dataview.pagesize);if(e.columns.records){for(var h=e.columns.records.length,k=e.table[0].rows,l=0;l<d;l++){var m=k[l];if(!m)break;m=m.cells;for(var n=0,r=0;r<h;r++){var t=e.columns.records[r],u=t.width;t.adaptivewidth&&(u=t.adaptivewidth);var x=m[r];parseInt(x.style.left)!=n&&(x.style.left=n+"px");parseInt(x.style.width)!=u&&(x.style.width=u+"px");t.hidden&&t.hideable||
1097t.adaptivehidden?x.style.display="none":(n+=parseFloat(u),e.adaptive&&(x.style.display=""))}0==g&&(e.table.width(parseFloat(n)+2),g=n)}e.showaggregates&&e._updateaggregates&&e._updateaggregates();e.showfilterrow&&e.filterable&&e._updatefilterrowui&&e._updatefilterrowui();e.showeverpresentrow&&e._updateaddnewrowui();e._updatescrollbarsafterrowsprerender();f&&e._renderrows(e.virtualsizeinfo)}}}},_updatescrollbarsafterrowsprerender:function(){var d=this.that,e=d.hScrollBar[0].style.visibility,f=0,g=
1098d.vScrollBar[0].style.visibility;"visible"==g&&(f=d.scrollbarsize+3);0==d.scrollbarsize&&(f=0);d.scrollbarautoshow&&(f=0);var h=d.element.style.width;h=0<=h.toString().indexOf("%")?d.host.width():parseInt(h);parseInt(d.table[0].style.width)-2>h-f?("visible"!=e&&(d.autowidth||(d.hScrollBar[0].style.visibility="visible"),d._arrange()),"visible"==g?"deferred"==d.scrollmode||d.virtualmode?d._updatevscrollbarmax():d.virtualsizeinfo&&(g=d.virtualsizeinfo.virtualheight-d._gettableheight(),!isNaN(g)&&0<g&&
1099("hidden"!=e?d.vScrollBar.jqxScrollBar("max",g+d.scrollbarsize+4):d.vScrollBar.jqxScrollBar("max",g))):f=-2,d.hScrollBar.jqxScrollBar("max",f+d.table.width()-d.host.width())):"hidden"!=e&&(d.hScrollBar.css("visibility","hidden"),d._arrange());d._renderhorizontalscroll()},_hascolumnstyle:function(){if(void 0!==this._hascolumnstyles)return this._hascolumnstyles;this._hascolumnstyles=!1;for(var d=0;d<this.columns.records.length;d++){var e=this.columns.records[d];if(e.style.headerBackgroundColor||e.style.headerColor||
1100e.style.headerBackgroundHoveredColor||e.style.headerHoveredColor||e.style.headerBackgroundSelectedColor||e.style.headerSelectedColor||e.style.backgroundColor||e.style.color||e.style.backgroundHoveredColor||e.style.hoveredColor||e.style.backgroundSelectedColor||e.style.selectedColor)return this._hascolumnstyles=!0}return!1},_prerenderrows:function(d){var e=this.that;if(1==e.prerenderrequired&&(e.prerenderrequired=!1,e.editable&&e._destroyeditors&&e._destroyeditors(),void 0!=e.gridcontent)){e.gridcontent.find("#contenttable"+
1101e.element.id).remove();null!=e.table&&(e.table.remove(),e.table=null);e.table=a('<div id="contenttable'+e.element.id+'" style="overflow: hidden; position: relative;"></div>');e.gridcontent.addClass(e.toTP("jqx-grid-content"));e.gridcontent.addClass(e.toTP("jqx-widget-content"));e.gridcontent.append(e.table);var f=e.groupable&&0<e.groups.length,g=0;e.table[0].rows=[];var h=e.toTP("jqx-grid-cell");f&&(h=" "+e.toTP("jqx-grid-group-cell"));d=d.visiblerecords;e.pageable&&(e.autoheight||e.autorowheight)&&
1102(d=e.dataview.pagesize,e.groupable&&(e.dataview.updateview(),d=e.dataview.rows.length,d<e.dataview.pagesize&&(d=e.dataview.pagesize)));e.pageable||!e.autoheight&&!e.autorowheight||(d=e.dataview.totalrecords);e.groupable&&0<e.groups.length&&(e.autoheight||e.autorowheight)&&!e.pageable&&(d=e.dataview.rows.length);e.rowdetails&&(d=e.autoheight||e.autorowheight?d+e.dataview.pagesize:d+d);if(e.columns.records){f=e.columns.records.length;a.jqx.browser.msie&&8<a.jqx.browser.version&&e.table.css("opacity",
1103"0.99");-1!=navigator.userAgent.indexOf("Safari")&&e.table.css("opacity","0.99");var k=a.jqx.browser.msie&&8>a.jqx.browser.version;k&&e.host.attr("hideFocus","true");var l=e.tableZIndex;d*f>l&&(l=d*f);e.isTouchDevice();var m="";e._hiddencolumns=!1;for(var n=5+e.columns.records.length,r=0;r<d;r++){var t='<div role="row" style="position: relative; height:'+e.rowsheight+'px;" id="row'+r+e.element.id+'">';k&&(t='<div role="row" style="position: relative; z-index: '+l+"; height:"+e.rowsheight+'px;" id="row'+
1104r+e.element.id+'">',l--);for(var u=0,x=0;x<f;x++){var B=e.columns.records[x],y=B.width;y<B.minwidth&&(y=B.minwidth);y>B.maxwidth&&(y=B.maxwidth);if(e.rtl){var A='<div columnindex="'+x+'" role="gridcell" style="left: '+u+"px; z-index: "+(l-f+2*x)+"; width:"+y+"px;";l--}
1104else A='<div columnindex="'+x+'" role="gridcell" style="left: '+u+"px; z-index: "+l--+"; width:"+y+"px;";B.hidden&&B.hideable||B.adaptivehidden?(A+="display: none;",e._hiddencolumns=!0,l++):u+=y;0===r&&0===x&&(A+='" tabindex="'+n+'"');
1105A+='" class="'+h+'">';B=this._defaultcellsrenderer("",B);A+=B;A+="</div>";t+=A}0==g&&(e.table.width(parseInt(u)+2),g=u);t+="</div>";m+=t}e.WinJS?MSApp.execUnsafeLocalFunction(function(){e.table.html(m)}):e.table[0].innerHTML=m;e.table[0].rows=[];g=e.table.children();for(r=0;r<d;r++)for(k=g[r],e.table[0].rows.push(k),k.cells=[],n=a(k).children(),x=0;x<f;x++)k.cells.push(n[x]);if(0==d){u=0;e.showemptyrow&&(t=a('<div style="position: relative;" id="row0'+e.element.id+'"></div>'),e.table.append(t),t.height(e.rowsheight),
1106e.table[0].rows[0]=t[0],e.table[0].rows[0].cells=[]);for(x=0;x<f;x++)B=e.columns.records[x],y=B.width,e.showemptyrow&&(A=a('<div style="position: absolute; height: 100%; left: '+u+"px; z-index: "+l--+"; width:"+y+'px;" class="'+h+'"></div>'),A.height(e.rowsheight),t.append(A),e.table[0].rows[0].cells[x]=A[0]),y<B.minwidth&&(y=B.minwidth),y>B.maxwidth&&(y=B.maxwidth),B.hidden&&B.hideable||B.adaptivehidden||(u+=y);e.table.width(parseInt(u)+2);g=u}e._updatescrollbarsafterrowsprerender();e.rendered&&
1107e.rendered("rows");e.toCompile=[];e._addoverlayelement()}}},_groupsheader:function(){return this.groupable&&this.showgroupsheader},_arrange:function(){var d=null,e=null;this.tableheight=null;var f=this.that,g=!1,h=!1;null!=f.width&&-1!=f.width.toString().indexOf("px")?d=f.width:void 0==f.width||isNaN(f.width)||(d=f.width);null!=f.width&&-1!=f.width.toString().indexOf("%")&&(d=f.width,g=!0);f.scrollbarautoshow&&(f.vScrollBar[0].style.display="none",f.hScrollBar[0].style.display="none",f.vScrollBar[0].style.zIndex=
1108f.tableZIndex+f.headerZIndex,f.hScrollBar[0].style.zIndex=f.tableZIndex+f.headerZIndex);if(f.autowidth){for(var k=d=0;k<f.columns.records.length;k++){var l=f.columns.records[k].width;"auto"==l&&(l=f._measureElementWidth(f.columns.records[k].text));d+=l}"hidden"!=f.vScrollBar.css("visibility")&&(d+=f.scrollbarsize+4);f.width=d}null!=f.height&&-1!=f.height.toString().indexOf("px")?e=f.height:void 0==f.height||isNaN(f.height)||(e=f.height);null!=f.height&&-1!=f.height.toString().indexOf("%")&&(e=f.height,
1109h=!0);k=function(){var u=0,x=f.showheader?null!=f.columnsheader?f.columnsheader.height()+2:0:0;u+=x;f.pageable&&(u+=f.pagerheight);f._groupsheader()&&(u+=f.groupsheaderheight);f.showtoolbar&&(u+=f.toolbarheight);f.showfilterbar&&(u+=f.toolbarheight);f.showstatusbar&&(u+=f.statusbarheight);f.showeverpresentrow&&"bottom"===f.everpresentrowposition&&(u+=f.everpresentrowheight);"visible"==f.hScrollBar[0].style.visibility&&(u+=15);return u};f.autoheight&&f.virtualsizeinfo?f.pageable&&f.gotopage?(e=0+(f._pageviews[0]?
1110f._pageviews[0].height:0),e+=k(),f.showemptyrow&&0==f.dataview.totalrecords&&(e+=f.rowsheight)):(e=f.host.height()-f._gettableheight(),0<f._pageviews.length?(e=e+f._pageviews[f._pageviews.length-1].height+f._pageviews[f._pageviews.length-1].top,f.vScrollBar[0].style.visibility="hidden"):(e=k(),f.showemptyrow&&(e+=f.rowsheight))):f.autoheight&&(e=f.dataview.totalrecords*f.rowsheight,f.pageable&&f.gotopage&&(e=f.pagesize*f.rowsheight),f._loading&&(e=250,f.dataloadelement.height(e)),e+=k(),1E4<e&&(e=
11111E4));null!=d?(d=parseInt(d),g?f.element.style.width=f.width:f.element.style.width!=parseInt(f.width)+"px"&&(f.element.style.width=parseInt(f.width)+"px"),g&&(d=f.host.width(),2>=d&&(d=600,f.host.width(d)),f._oldWidth||(f._oldWidth=d))):f.host.width(250);null!=e?(this.autoheight&&(e+=2),h||(e=parseInt(e)),h?f.element.style.height=f.height:f.element.style.height!=parseInt(e)+"px"&&(f.element.style.height=parseInt(e)+"px"),h&&!f.autoheight&&(e=f.host.height(),0==e&&(e=400,f.host.height(e)),f._oldHeight||
1112(f._oldHeight=e))):f.host.height(250);f.autoheight&&(f.tableheight=null,f._gettableheight());g=0;f.showtoolbar?(f.toolbar.width(d),f.toolbar.height(f.toolbarheight-1),f.toolbar.css("top",0),g+=f.toolbarheight,e-=parseInt(f.toolbarheight)):f.toolbar[0].style.height="0px";f.showfilterbar?(f.filterbar.width(d),f.filterbar.height(f.toolbarheight-1),f.filterbar.css("top",g),g+=f.toolbarheight,e-=parseInt(f.toolbarheight)):f.filterbar[0].style.height="0px";
1112f.showstatusbar?(f.showaggregates?f.statusbar.width(f.table?
1113Math.max(d,f.table.width()):d):f.statusbar.width(d),f.statusbar.height(f.statusbarheight)):f.statusbar[0].style.height="0px";f.showeverpresentrow&&"bottom"===f.everpresentrowposition?(f.addnewrow.width(d),f.addnewrow.height(f.everpresentrowheight)):f.addnewrow[0].style.height="0px";f._groupsheader()?(f.groupsheader.width(d),f.groupsheader.height(f.groupsheaderheight),f.groupsheader.css("top",g),h=f.groupsheader.height()+1,g+=h,e>h&&(e-=parseInt(h))):(f.groupsheader[0].style.width!=d+"px"&&(f.groupsheader[0].style.width=
1114parseInt(d)+"px"),f.groupsheader[0].style.height="0px",f.groupsheader[0].style.top!=g+"px"&&f.groupsheader.css("top",g),h=f.showgroupsheader&&f.groupable?f.groupsheaderheight:0,f.content[0].style.top!=g+h+"px"&&f.content.css("top",g+f.groupsheaderheight));var m=f.scrollbarsize;isNaN(m)&&(m=parseInt(m),m=isNaN(m)?"17px":m+"px");m=parseInt(m);l=2;h=0;"visible"==f.vScrollBar[0].style.visibility&&(h=m+4);"visible"==f.hScrollBar[0].style.visibility&&(l=m+4+2);0==m&&(l=h=0);k=0;f.pageable&&(k=f.pagerheight,
1115l+=f.pagerheight);f.showstatusbar&&(l+=f.statusbarheight,k+=f.statusbarheight);f.showeverpresentrow&&"bottom"===f.everpresentrowposition&&(l+=f.everpresentrowheight,k+=f.everpresentrowheight);f.hScrollBar[0].style.height!=m+"px"&&(f.hScrollBar[0].style.height=parseInt(m)+"px");f.hScrollBar[0].style.top==g+e-4-m-k+"px"&&"0px"==f.hScrollBar[0].style.left||f.hScrollBar.css({top:g+e-4-m-k+"px",left:"0px"});var n=f.hScrollBar[0].style.width,r=!1,t=!1;0==h?n!=d-2+"px"&&(f.hScrollBar.width(d-2),r=!0):n!=
1116d-m-4+"px"&&(f.hScrollBar.width(d-m-4+"px"),r=!0);f.autoheight||(f.vScrollBar[0].style.width!=m+"px"&&(f.vScrollBar.width(m),t=!0),f.vScrollBar[0].style.height!=parseInt(e)-l+"px"&&(f.vScrollBar.height(parseInt(e)-l+"px"),t=!0),f.vScrollBar[0].style.left==parseInt(d)-parseInt(m)-4+"px"&&f.vScrollBar[0].style.top==g+"px"||f.vScrollBar.css({left:parseInt(d)-parseInt(m)-4+"px",top:g}));f.rtl&&(f.vScrollBar.css({left:"0px",top:g}),"hidden"!=f.vScrollBar.css("visibility")&&f.hScrollBar.css({left:m+2}));
1117n=f.vScrollInstance;n.disabled=f.disabled;f.autoheight||t&&n.refresh();t=f.hScrollInstance;t.disabled=f.disabled;r&&t.refresh();f.autowidth&&(f.hScrollBar[0].style.visibility="hidden");f.statusbarheight=parseInt(f.statusbarheight);f.toolbarheight=parseInt(f.toolbarheight);r=function(u){if("visible"==u.vScrollBar[0].style.visibility&&"visible"==u.hScrollBar[0].style.visibility){u.bottomRight[0].style.visibility="visible";u.bottomRight.css({left:1+parseInt(u.vScrollBar.css("left")),top:parseInt(u.hScrollBar.css("top"))});
1118u.rtl&&u.bottomRight.css("left","0px");u.bottomRight.width(parseInt(m)+3);u.bottomRight.height(parseInt(m)+4);var x=u.showeverpresentrow&&"bottom"==u.everpresentrowposition?u.everpresentrowheight:0;0<x&&!u.showaggregates&&(u.bottomRight.css("z-index",99),u.bottomRight.height(parseInt(m)+4+x),u.bottomRight.css({top:parseInt(u.hScrollBar.css("top"))-x}));u.showaggregates&&(u.bottomRight.css("z-index",99),u.bottomRight.height(parseInt(m)+4+u.statusbarheight+x),u.bottomRight.css({top:parseInt(u.hScrollBar.css("top"))-
1119u.statusbarheight-x}))}else u.bottomRight[0].style.visibility="hidden"};r(this);f.content[0].style.width!=d-h+"px"&&f.content.width(d-h);f.content[0].style.height!=e-l+3+"px"&&f.content.height(e-l+3);f.scrollbarautoshow&&(f.content[0].style.width!=d+"px"&&f.content.width(d),f.content[0].style.height!=e+"px"&&f.content.height(e));f.content[0].style.top!=g+"px"&&f.content.css("top",g);f.rtl&&(f.content.css("left",h),f.scrollbarautoshow&&f.content.css("left","0px"),f.table&&(l=f.table.width(),l<d-h&&
1120f.content.css("left",d-l)));f.showstatusbar&&(f.statusbar.css("top",g+e-f.statusbarheight-(f.pageable?f.pagerheight:0)),f.showaggregates&&("visible"==f.hScrollBar.css("visibility")&&(f.hScrollBar.css({top:g+e-4-m-k+f.statusbarheight+"px"}),f.statusbar.css("top",1+g+e-m-5-f.statusbarheight-(f.pageable?f.pagerheight:0))),r(this)),f.rtl&&("visible"!=f.hScrollBar.css("visibility")?f.statusbar.css("left",f.content.css("left")):f.statusbar.css("left","0px")));f.showeverpresentrow&&"bottom"===f.everpresentrowposition&&
1121(f.addnewrow.css("top",g+e-(f.showstatusbar?f.statusbarheight:0)-(f.pageable?f.pagerheight:0)-f.everpresentrowheight),f.rtl&&("visible"!=f.hScrollBar.css("visibility")?f.addnewrow.css("left",f.content.css("left")):f.addnewrow.css("left","0px")));f.pageable?(f.pager.width(d),f.pager.height(f.pagerheight),f.pager.css("top",g+e-f.pagerheight-1)):f.pager[0].style.height="0px";null!=f.table&&(g=-2,"visible"==f.vScrollBar[0].style.visibility&&(g=f.scrollbarsize+3),"visible"==f.hScrollBar[0].style.visibility&&
1122(g=g+f.table.width()-f.host.width(),0<=g&&f.hScrollBar.jqxScrollBar("max",g),"visible"==f.hScrollBar[0].style.visibility&&0==g&&(f.hScrollBar[0].style.visibility="hidden",f._arrange())));d!=parseInt(f.dataloadelement[0].style.width)&&(f.dataloadelement[0].style.width=f.element.style.width);e!=parseInt(f.dataloadelement[0].style.height)&&(f.dataloadelement[0].style.height=f.element.style.height);this.pagergotoinput&&(this.pagergotoinput.offset().top!==this.pagergoto.offset().top?(this.pagergotoinput.css("visibility",
1123"hidden"),this.pagergoto.css("visibility","hidden")):(this.pagergotoinput.css("visibility","inherit"),this.pagergoto.css("visibility","inherit")));f._hostwidth=d},destroy:function(){delete a.jqx.dataFormat.datescache;delete this.gridlocalization;delete this._undoRedo;a.jqx.utilities.resize(this.host,null,!0);(""!=document.referrer||window.frameElement)&&null!=window.top&&window.top!=window.self&&this.removeHandler(a(window.top.document),"mouseup.grid"+this.element.id);if(this.table&&this.table[0]){for(var d=
1124this.table[0].rows.length,e=0;e<d;e++){for(var f=this.table[0].rows[e],g=f.cells.length,h=0;h<g;h++)a(f.cells[h]).remove(),f.cells[h]=null,delete f.cells[h];f.cells=null;f.cells&&delete f.cells;a(this.table[0].rows[e]).remove();this.table[0].rows[e]=null}try{delete this.table[0].rows}catch(k){}this.table.remove();delete this.table}if(this.columns&&this.columns.records){for(e=0;e<this.columns.records.length;e++)d=this.columns.records[e],d.addnewrowwidget&&d.destroyeverpresentrowwidget&&d.destroyeverpresentrowwidget(d.addnewrowwidget),
1125d.destroywidget&&d.destroywidget&&d.destroywidget(d.widget),this._removecolumnhandlers(this.columns.records[e]),d.element&&(a(d.element).remove(),a(d.sortasc).remove(),a(d.sortdesc).remove(),a(d.filtericon).remove(),a(d.menu).remove(),d.element=null,d.uielement=null,d.sortasc=null,d.sortdesc=null,d.filtericon=null,d.menu=null,delete d.element,delete d.uielement,delete d.sortasc,delete d.sortdesc,delete d.filtericon,delete d.menu,delete this.columnsrow[0].cells[e]);try{delete this.columnsrow[0].cells}catch(k){}delete this.columnsrow}a.removeData(document.body,
1126"contextmenu"+this.element.id);this.host.jqxDropDownList&&this._destroyfilterpanel&&this._destroyfilterpanel();this.editable&&this._destroyeditors&&this._destroyeditors();this.filterable&&this._destroyedfilters&&this.showfilterrow&&this._destroyedfilters();this.host.jqxMenu&&this.gridmenu&&(this.removeHandler(a(document),"click.menu"+this.element.id),this.removeHandler(this.gridmenu,"keydown"),this.removeHandler(this.gridmenu,"closed"),this.removeHandler(this.gridmenu,"itemclick"),this.gridmenu.jqxMenu("destroy"),
1127this.gridmenu=null);this.pagershowrowscombo&&(this.pagershowrowscombo.jqxDropDownList("destroy"),this.pagershowrowscombo=null);this.pagerrightbutton&&(this.removeHandler(this.pagerrightbutton,"mousedown"),this.removeHandler(this.pagerrightbutton,"mouseup"),this.removeHandler(this.pagerrightbutton,"click"),this.pagerrightbutton.jqxButton("destroy"),this.pagerrightbutton=null);this.pagerleftbutton&&(this.removeHandler(this.pagerleftbutton,"mousedown"),this.removeHandler(this.pagerleftbutton,"mouseup"),
1128this.removeHandler(this.pagerleftbutton,"click"),this.pagerleftbutton.jqxButton("destroy"),this.removeHandler(a(document),"mouseup.pagerbuttons"+this.element.id),this.pagerleftbutton=null);this.removeHandler(a(document),"selectstart."+this.element.id);this.removeHandler(a(document),"mousedown.resize"+this.element.id);this.removeHandler(a(document),"mouseup.resize"+this.element.id);this.removeHandler(a(document),"mousemove.resize"+this.element.id);this.isTouchDevice()&&(e=a.jqx.mobile.getTouchEventName("touchmove")+
1129".resize"+this.element.id,d=a.jqx.mobile.getTouchEventName("touchstart")+".resize"+this.element.id,f=a.jqx.mobile.getTouchEventName("touchend")+".resize"+this.element.id,this.removeHandler(a(document),e),this.removeHandler(a(document),d),this.removeHandler(a(document),f));this.removeHandler(a(document),"mousedown.reorder"+this.element.id);
1129this.removeHandler(a(document),"mouseup.reorder"+this.element.id);this.removeHandler(a(document),"mousemove.reorder"+this.element.id);this.isTouchDevice()&&(e=a.jqx.mobile.getTouchEventName("touchmove")+
1130".reorder"+this.element.id,d=a.jqx.mobile.getTouchEventName("touchstart")+".reorder"+this.element.id,f=a.jqx.mobile.getTouchEventName("touchend")+".reorder"+this.element.id,this.removeHandler(a(document),e),this.removeHandler(a(document),d),this.removeHandler(a(document),f));this.removeHandler(a(window),"resize."+this.element.id);this.resizeline&&this.resizeline.remove();this.resizestartline&&this.resizestartline.remove();this.groupable&&(e="mousemove.grouping"+this.element.id,d="mousedown.grouping"+
1131this.element.id,f="mouseup.grouping"+this.element.id,this.removeHandler(a(document),e),this.removeHandler(a(document),d),this.removeHandler(a(document),f));this.columnsreorder&&(e="mousemove.reorder"+this.element.id,d="mousedown.reorder"+this.element.id,f="mouseup.reorder"+this.element.id,this.removeHandler(a(document),e),this.removeHandler(a(document),d),this.removeHandler(a(document),f),delete this.columnsbounds);this.content&&(this.removeHandler(this.content,"mousedown"),this.removeHandler(this.content,
1132"scroll"));this._removeHandlers();this.hScrollInstance.destroy();this.vScrollInstance.destroy();this.hScrollBar.remove();this.vScrollBar.remove();this._clearcaches();delete this.hScrollInstance;delete this.vScrollInstance;delete this.visiblerows;delete this.hittestinfo;delete this.rows;delete this.columns;delete this.columnsbydatafield;delete this.pagescache;delete this.pageviews;delete this.cellscache;delete this.heights;delete this.hiddens;delete this.hiddenboundrows;delete this.heightboundrows;
1133delete this.detailboundrows;delete this.details;delete this.expandedgroups;delete this._rowdetailscache;delete this._rowdetailselementscache;delete this.columnsmenu;this.columnsheader&&(this.columnsheader.remove(),delete this.columnsheader);this.selectionarea&&(this.selectionarea.remove(),delete this.selectionarea);if(this.menuitemsarray&&this.menuitemsarray.length)for(d=this.menuitemsarray.length,e=0;e<d;e++)a(this.menuitemsarray[e]).remove();delete this.menuitemsarray;this.dataview._clearcaches();
1134this.content.removeClass();this.content.remove();this.content=null;delete this.content;this.hScrollBar=this.vScrollBar=null;delete this.hScrollBar;delete this.hScrollBar;this.gridcontent&&(this.gridcontent.remove(),delete this.gridcontent);this.gridmenu&&(this.gridmenu=null,delete this.gridmenu);delete this._mousemovefunc;delete this._mousewheelfunc;this.dataview.destroy();delete this.dataview;this.bottomRight.remove();delete this.bottomRight;this.wrapper.remove();delete this.wrapper;this.pagerdiv&&
1135(this.pagerdiv.remove(),delete this.pagerdiv);this.pagerpageinput&&(this.pagerpageinput.remove(),delete this.pagerpageinput);this.pagergoto&&(this.pagergoto.remove(),delete this.pagergoto);this.pagershowrows&&(this.pagershowrows.remove(),delete this.pagershowrows);this.pagerfirstbutton&&(this.pagerfirstbutton.remove(),delete this.pagerfirstbutton);this.pagerlastbutton&&(this.pagerlastbutton.remove(),delete this.pagerlastbutton);this.pagerbuttons&&(this.pagerbuttons.remove(),delete this.pagerbuttons);
1136this.pagerdetails&&(this.pagerdetails.remove(),delete this.pagerdetails);this.pagergotoinput&&(this.pagergotoinput.remove(),delete this.pagergotoinput);this.pager.remove();delete this.pager;this.groupsheader.remove();delete this.groupsheader;this.dataloadelement.remove();delete this.dataloadelement;this.toolbar.remove();delete this.toolbar;this.statusbar.remove();delete this.statusbar;this.host.removeData();this.host.removeClass();this.host.remove();this.host=null;delete this.host;delete this.element;
1137delete this.set;delete this.get;delete this.that;delete this.call},_initializeColumns:function(){var d=this.source?this.source.datafields:null;null==d&&this.source&&this.source._source&&(d=this.source._source.datafields);var e=d?0<d.length:!1;if(this.autogeneratecolumns){var f=[];if(d)a.each(d,function(){f.push({datafield:this.name,text:this.text||this.name,cellsformat:this.format||""})});else if(0<this.source.records.length){d=this.source.records[0];for(var g in d)"uid"!=g&&(d={width:100,datafield:g,
1138text:g},f.push(d))}this.columns=f}if(this.columns&&this.columns.records)for(g=0;g<this.columns.records.length;g++)this._removecolumnhandlers(this.columns.records[g]);var h=this.that,k=new a.jqx.collection(this.element),l=0;this._haspinned=!1;this._columns?this.columns=this._columns:this._columns=this.columns;this.groupable&&a.each(this.groups,function(n){n=new b(h,this);n.visibleindex=l++;n.width=h.groupindentwidth;k.add(n);n.grouped=!0;n.filterable=!1;n.sortable=!1;n.editable=!1;n.resizable=!1;n.draggable=
1139!1});
1139this.rowdetails&&this.showrowdetailscolumn&&(d=new b(h,this),d.visibleindex=l++,d.width=h.groupindentwidth,d.pinned=!0,d.editable=!1,d.filterable=!1,d.draggable=!1,d.groupable=!1,d.resizable=!1,k.add(d),h._haspinned=!0);"checkbox"==this.selectionmode&&(d=new b(h,null),d.visibleindex=l++,d.width=h.groupindentwidth,d.checkboxcolumn=!0,d.editable=!1,d.columntype="checkbox",d.groupable=!1,d.draggable=!1,d.filterable=!1,d.resizable=!1,d.datafield="_checkboxcolumn",k.add(d));var m=[];a.each(this.columns,
1140function(n){if(void 0!=h.columns[n]){var r=new b(h,this);r.visibleindex=l++;void 0!=this.dataField&&(this.datafield=this.dataField);this.pinned&&(h._haspinned=!0);!h.showeverpresentrow||"addButtonColumn"!==this.datafield&&"resetButtonColumn"!==this.datafield&&"updateButtonColumn"!==this.datafield&&"deleteButtonColumn"!==this.datafield||(r.editable=!1,r.groupable=!1,r.draggable=!1,r.filterable=!1,r.resizable=!1,r.menu=!1);if(null==this.datafield)h.source&&h.source._source&&"array"==h.source._source.datatype&&
1141(e||(h.source._source.datafields||(h.source._source.datafields=[]),h.source._source.datafields.push({name:n.toString()})),this.datafield=n.toString(),this.displayfield=n.toString(),r.datafield=this.datafield,r.displayfield=this.displayfield);else{if(m[this.datafield])throw Error("jqxGrid: Invalid column 'datafield' setting. jqxGrid's columns should be initialized with unique data fields.");m[this.datafield]=!0}k.add(r)}});this.adaptive&&(d=new b(h,null),d.visibleindex=l++,d.width=h.groupindentwidth,
1142d.editable=!1,d.columntype="adaptive",d.cellsalign="center",d.groupable=!1,d.draggable=!1,d.menu=!1,d.sortable=!1,d.filterable=!1,d.resizable=!1,d.datafield="_adaptivecolumn",k.add(d));this.rtl&&k.records.reverse();this.columns=k},_initializeRows:function(){var d=new a.jqx.collection(this.element);this.rows&&this.rows.clear();this.rows=d},_raiseEvent:function(d,e){void 0==e&&(e={owner:null});if(!1!==this._trigger){var f=this.events[d];this._camelCase||(f=f.toLowerCase());if((2==d||15==d)&&this.showeverpresentrow&&
1143(0<=this.everpresentrowactions.indexOf("delete")||0<=this.everpresentrowactions.indexOf("update"))){if(this.updateeverpresentrow)var g=this;setTimeout(function(){g.updateeverpresentrow()},50)}e.owner=this;f=new a.Event(f);f.owner=this;f.args=e;d=this.host.trigger(f);e=f.args;return d}},wheel:function(d,e){if(e.autoheight&&"visible"!=e.hScrollBar.css("visibility"))return d.returnValue=!0;var f=0;d||(d=window.event);d.originalEvent&&d.originalEvent.wheelDelta&&(d.wheelDelta=d.originalEvent.wheelDelta);
1144d.wheelDelta?f=d.wheelDelta/120:d.detail&&(f=-d.detail/3);if(f){if(e=e._handleDelta(f))d.preventDefault&&d.preventDefault(),null!=d.originalEvent&&(d.originalEvent.mouseHandled=!0),void 0!=d.stopPropagation&&d.stopPropagation();return e?(e=!1,d.returnValue=e):!1}d.preventDefault&&d.preventDefault();d.returnValue=!1},_handleDelta:function(d){if("hidden"!=this.vScrollBar.css("visibility")){var e=this.vScrollInstance.value;0>d?this.scrollDown():this.scrollUp();d=this.vScrollInstance.value;if(e!=d)return!0}else if("hidden"!=
1145this.hScrollBar.css("visibility")&&(e=this.hScrollInstance.value,0<d?this.hScrollInstance.value>2*this.horizontalscrollbarstep?this.hScrollInstance.setPosition(this.hScrollInstance.value-2*this.horizontalscrollbarstep):this.hScrollInstance.setPosition(0):this.hScrollInstance.value<this.hScrollInstance.max?this.hScrollInstance.setPosition(this.hScrollInstance.value+2*this.horizontalscrollbarstep):this.hScrollInstance.setPosition(this.hScrollInstance.max),d=this.hScrollInstance.value,e!=d))return this._activeFilterElement&&
1146this._activeFilterElement.jqxDropDownList("close"),!0;return!1},scrollDown:function(){if("hidden"!=this.vScrollBar.css("visibility")){var d=this.vScrollInstance;d.value+this.rowsheight<=d.max?d.setPosition(parseInt(d.value)+this.rowsheight):d.setPosition(d.max)}},scrollUp:function(){if("hidden"!=this.vScrollBar.css("visibility")){var d=this.vScrollInstance;d.value-this.rowsheight>=d.min?d.setPosition(parseInt(d.value)-this.rowsheight):d.setPosition(d.min)}},_removeHandlers:function(){var d=this.that;
1147d.removeHandler(a(window),"orientationchange.jqxgrid"+d.element.i
1147d);d.removeHandler(a(window),"orientationchanged.jqxgrid"+d.element.id);d.removeHandler(d.vScrollBar,"valueChanged");d.removeHandler(d.hScrollBar,"valueChanged");d.vScrollInstance.valueChanged=null;d.hScrollInstance.valueChanged=null;var e="mousedown.jqxgrid";d.isTouchDevice()&&(e=a.jqx.mobile.getTouchEventName("touchend"));d.removeHandler(d.host,"dblclick.jqxgrid");d.removeHandler(d.host,e);d.removeHandler(d.content,"mousemove",d._mousemovefunc);
1148d.removeHandler(d.host,"mouseleave.jqxgrid");d.removeHandler(d.content,"mouseenter");d.removeHandler(d.content,"mouseleave");d.removeHandler(d.content,"mousedown");d.removeHandler(d.content,"scroll");d.removeHandler(d.content,"selectstart."+d.element.id);d.removeHandler(d.host,"dragstart."+d.element.id);d.removeHandler(d.host,"keydown.edit"+d.element.id);d.removeHandler(a(document),"keydown.edit"+d.element.id);d.removeHandler(a(document),"keyup.edit"+d.element.id);d._mousemovedocumentfunc&&d.removeHandler(a(document),
1149"mousemove.selection"+d.element.id,d._mousemovedocumentfunc);d.removeHandler(a(document),"mouseup.selection"+d.element.id);d._mousewheelfunc&&d.removeHandler(d.host,"mousewheel",d._mousewheelfunc);d.editable&&d.removeHandler(a(document),"mousedown.gridedit"+d.element.id);d.host.off&&(d.content.off("mousemove"),d.host.off("mousewheel"))},_addHandlers:function(){var d=this.that,e=d.isTouchDevice();e||d.addHandler(d.host,"dragstart."+d.element.id,function(g){return!1});d.scrollbarautoshow&&(d.addHandler(d.host,
1150"mouseenter.gridscroll"+d.element.id,function(g){d.vScrollBar.fadeIn("fast");d.hScrollBar.fadeIn("fast")}),d.addHandler(d.host,"mouseleave.gridscroll"+d.element.id,function(g){d.vScrollInstance.isScrolling()||d.hScrollInstance.isScrolling()||(d.vScrollBar.fadeOut("fast"),d.hScrollBar.fadeOut("fast"))}));d.editable&&d.addHandler(a(document),"mousedown.gridedit"+d.element.id,function(g){if(d.editable&&d.begincelledit&&d.editcell&&!d.vScrollInstance.isScrolling()&&!d.vScrollInstance.isScrolling()){var h=
1151d.host.coord(),k=d.host.width(),l=d.host.height(),m=!1,n=!1;if(g.pageY<h.top||g.pageY>h.top+l)n=m=!0;if(g.pageX<h.left||g.pageX>h.left+k)m=!0;if(m){if(d.editcell&&d.editcell.editor)switch(d.editcell.columntype){case "datetimeinput":if(d.editcell.editor.jqxDateTimeInput&&d.editcell.editor.jqxDateTimeInput("container")&&"block"==d.editcell.editor.jqxDateTimeInput("container")[0].style.display)if(h=d.editcell.editor.jqxDateTimeInput("container").coord().top,k=d.editcell.editor.jqxDateTimeInput("container").coord().top+
1152d.editcell.editor.jqxDateTimeInput("container").height(),n&&(g.pageY<h||g.pageY>k))d.editcell.editor.jqxDateTimeInput("close");else return;break;case "combobox":if(d.editcell.editor.jqxComboBox&&d.editcell.editor.jqxComboBox("container")&&"block"==d.editcell.editor.jqxComboBox("container")[0].style.display)if(h=d.editcell.editor.jqxComboBox("container").coord().top,k=d.editcell.editor.jqxComboBox("container").coord().top+d.editcell.editor.jqxComboBox("container").height(),n&&(g.pageY<h||g.pageY>k))d.editcell.editor.jqxComboBox("close");
1153else return;break;case "dropdownlist":if(d.editcell.editor.jqxDropDownList&&d.editcell.editor.jqxDropDownList("container")&&"block"==d.editcell.editor.jqxDropDownList("container")[0].style.display)if(h=d.editcell.editor.jqxDropDownList("container").coord().top,k=d.editcell.editor.jqxDropDownList("container").coord().top+d.editcell.editor.jqxDropDownList("container").height(),n&&(g.pageY<h||g.pageY>k))d.editcell.editor.jqxDropDownList("close");else return;break;case "template":case "custom":for(h=
1154["jqxDropDownList","jqxComboBox","jqxDropDownButton","jqxDateTimeInput"],k=0;k<h.length;k++){l=h[k];m=d.editcell.editor.data();if(m[l]&&m[l].instance.container&&"block"==m[l].instance.container[0].style.display){l=m[l].instance;m=l.container.coord().top;var r=l.container.coord().top+l.container.height();n&&(g.pageY<m||g.pageY>r)?(l.close(),l=!0):l=!1}else l=void 0;if(0==l)return}}d.endcelledit(d.editcell.row,d.editcell.column,!1,!0);d._oldselectedcell=null}}});d.vScrollInstance.valueChanged=function(g){d.virtualsizeinfo&&
1155(d._closemenu(),d._renderrows(d.virtualsizeinfo),d.currentScrollValue=g.currentValue,d.pageable||d.groupable||!d.dataview.virtualmode||(d.loadondemandupdate&&clearTimeout(d.loadondemandupdate),d.loadondemandupdate=setTimeout(function(){d.loadondemand=!0;d._renderrows(d.virtualsizeinfo)}
1155,100)),e&&(d._lastScroll=new Date))};d.hScrollInstance.valueChanged=function(g){if(d.virtualsizeinfo){d._closemenu();var h=function(){d._renderhorizontalscroll();d._renderrows(d.virtualsizeinfo);d.editcell&&!d.editrow&&
1156d._showcelleditor&&d.editcell.editing&&(d.hScrollInstance.isScrolling()||d._showcelleditor(d.editcell.row,d.getcolumn(d.editcell.column),d.editcell.element,d.editcell.init))};e?h():(void 0==d._browser&&d._isIE10(),navigator&&-1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")?(d._hScrollTimer&&clearTimeout(d._hScrollTimer),d._hScrollTimer=setTimeout(function(){h()},1)):a.jqx.browser.msie?(d._hScrollTimer&&clearTimeout(d._hScrollTimer),d._hScrollTimer=setTimeout(function(){h()},
1157.01)):h());e&&(d._lastScroll=new Date)}};d._mousewheelfunc=d._mousewheelfunc||function(g){if(!d.editcell&&d.enablemousewheel)return d.wheel(g,d),!1};d.removeHandler(d.host,"mousewheel",d._mousewheelfunc);d.addHandler(d.host,"mousewheel",d._mousewheelfunc);var f="mousedown.jqxgrid";e&&(f=a.jqx.mobile.getTouchEventName("touchend"));d.addHandler(d.host,f,function(g){if(d.isTouchDevice()&&(d._newScroll=ne
1157w Date,500>d._newScroll-d._lastScroll||a(g.target).ischildof(d.vScrollBar)||a(g.target).ischildof(d.hScrollBar)))return!1;
1158d._mousedown=new Date;var h=d._handlemousedown(g,d);d.isNestedGrid&&(d.resizablecolumn||d.columnsreorder||g.stopPropagation());d._lastmousedown=new Date;return h});e||(d.addHandler(d.host,"dblclick.jqxgrid",function(g){d.editable&&d.begincelledit&&"dblclick"==d.editmode?d._handledblclick(g,d):a.jqx.browser.msie&&9>a.jqx.browser.version&&d._handlemousedown(g,d);d.mousecaptured=!1;d._lastmousedown=new Date;return!0}),d._mousemovefunc=function(g){if(d._handlemousemove)return d._handlemousemove(g,d)},
1159d.addHandler(d.content,"mousemove",d._mousemovefunc),d._handlemousemoveselection&&(d._mousemovedocumentfunc=function(g){if(d._handlemousemoveselection)return d._handlemousemoveselection(g,d)},d.addHandler(a(document),"mousemove.selection"+d.element.id,d._mousemovedocumentfunc)),d.addHandler(a(document),"mouseup.selection"+d.element.id,function(g){if(d._handlemouseupselection){if(g.shiftKey&&a(g.target).ischildof(d.host)){var h=d.editable;d.editable=!1;d._lastmousedown=new Date(2E3,1,1);d._handlemousedown(g,
1160d);d.mousecaptured=!0;d.editable=h}d._handlemouseupselection(g,d)}}));try{""==document.referrer&&!window.frameElement||null==window.top||window.top==window.self||(f=null,window.parent&&document.referrer&&(f=document.referrer),f&&-1!=f.indexOf(document.location.host)&&d.addHandler(a(window.top.document),"mouseup.grid"+d.element.id,function(g){if(d._handlemouseupselection)try{d._handlemouseupselection(g,d)}catch(h){}}))}catch(g){}d.focused=!1;e||(d.addHandler(d.content,"mouseenter",function(g){d.focused=
1161!0;d.wrapper&&(d.wrapper.attr("tabindex",1),d.content.attr("tabindex",2));d._overlayElement&&(d.vScrollInstance.isScrolling()||d.hScrollInstance.isScrolling()?d._overlayElement[0].style.visibility="visible":d._overlayElement[0].style.visibility="hidden")}),d.addHandler(d.content,"mouseleave",function(g){d._handlemousemove&&d.enablehover&&d._clearhoverstyle();d._overlayElement&&(d._overlayElement[0].style.visibility="hidden");d.focused=!1}),(d.groupable||d.columnsreorder)&&d.addHandler(a(document),
1162"selectstart."+d.element.id,function(g){if(!0===d.__drag)return!1}),d.addHandler(d.content,"selectstart."+d.element.id,function(g){if(d.enablebrowserselection||d.showfilterrow&&a(g.target).ischildof(d.filterrow)||d.showeverpresentrow&&(a(g.target).ischildof(d.addnewrow)||d.addnewrowtop&&a(g.target).ischildof(d.addnewrowtop))||g.target.className&&0<=g.target.className.indexOf("jqx-grid-widget"))return!0;if(!d.editcell)return!1;g.stopPropagation&&g.stopPropagation()}),d.addHandler(a(document),"keyup.edit"+
1163d.element.id,function(g){d._keydown=!1}),d.addHandler(a(document),"keydown.edit"+d.element.id,function(g){if(d.adaptiveview)return!0;d._keydown=!d.editcell;var h=g.charCode?g.charCode:g.keyCode?g.keyCode:0;20===h&&(d._capsLock=d._capsLock?!1:!0);if(d.handlekeyboardnavigation&&(d.focused||g.target===d.element||a(g.target).ischildof(d.host))&&1==d.handlekeyboardnavigation(g))return!1;d.editable&&d.editcell&&(13==h||27==h||9==h||32==h)&&d._handleeditkeydown&&(k=d._handleeditkeydown(g,d));27==h&&(d.mousecaptured=
1164!1,"visible"==d.selectionarea.css("visibility")&&d.selectionarea.css("visibility","hidden"));if(a.jqx.browser.msie&&12>a.jqx.browser.version&&d.focused&&!d.isNestedGrid){if(13==h&&0==k)return k;var k=!0;!d.editcell&&d.editable&&"programmatic"!=d.editmode&&d._handleeditkeydown&&(k=d._handleeditkeydown(g,d));if(k&&d.keyboardnavigation&&d._handlekeydown)return k=d._handlekeydown(g,d),k||(g.preventDefault&&g.preventDefault(),void 0!=g.stopPropagation&&g.stopPropagation()),k}return!0}),d.addHandler(d.host,
1165"keyup.edit"+d.element.id,function(g){if(d.adaptiveview)return!0;if(9===g.keyCode&&!a(document.activeElement).ischildof(d.filterrow)&&!a(document.activeElement).ischildof(d.pager))switch(d.selectionmode){case "singlecell":case "multiplecells":case "multiplecellsextended":case "multiplecellsadvanced":d.getselectedcell();break;default:d.getselectedrowindex()}}
1165),d.addHandler(d.host,"keydown.edit"+d.element.id,function(g){var h=!0;if(d.adaptiveview)return!0;if(d.handlekeyboardnavigation&&1==d.handlekeyboardnavigation(g))return!1;
1166d.editable&&"programmatic"!=d.editmode&&d._handleeditkeydown&&(h=d._handleeditkeydown(g,d),d.isNestedGrid&&g.stopPropagation());if(!d.editcell&&g.altKey&&!a(document.activeElement).ischildof(d.filterrow)&&!a(document.activeElement).ischildof(d.pager))if(40===g.keyCode){var k=d.getselectedcell();k&&d.openmenu(k.column)}else 38===g.keyCode&&d._closemenu();a.jqx.browser.msie&&8>a.jqx.browser.version?d.isNestedGrid&&h&&d.keyboardnavigation&&d._handlekeydown&&(h=d._handlekeydown(g,d),g.stopPropagation()):
1167h&&d.keyboardnavigation&&d._handlekeydown&&(h=d._handlekeydown(g,d),d.isNestedGrid&&g.stopPropagation());h||(g.preventDefault&&g.preventDefault(),void 0!=g.stopPropagation&&g.stopPropagation());h&&d.selectedcells&&0<d.selectedcells.length&&9===g.keyCode&&g.shiftKey&&d.table&&d.table[0].rows&&0<d.table[0].rows.length&&(a(document.activeElement).ischildof(d.filterrow)||a(document.activeElement).ischildof(d.pager)||d.table[0].rows[0].cells[0].focus());return h}))},_hittestrow:function(d,e){if(null!=
1168this.vScrollInstance&&null!=this.hScrollInstance){void 0==e&&0==e;var f=this.hScrollInstance;d=this.vScrollInstance.value;"visible"!=this.vScrollBar.css("visibility")&&(d=0);f=f.value;"visible"!=this.hScrollBar.css("visibility")&&(f=0);"deferred"==this.scrollmode&&null!=this._newmax&&d>this._newmax&&(d=this._newmax);var g=parseInt(d)+e;parseInt(f);if(null!=this.visiblerows&&0!=this.visiblerows.length){d=!1;f=this._findvisiblerow(g,this.visiblerows);if(0<=f){var h=this.visiblerows[f];g=!h.rowdetailshidden;
1169if(this.rowdetails&&h.rowdetails){var k=this.visiblerows[f-1];k==h&&(h=k,f--);g&&(g=a(this.hittestinfo[f].visualrow).position().top+parseInt(this.table.css("top")),k=a(this.hittestinfo[f].visualrow).height(),e>=g&&e<=g+k||(f++,h=this.visiblerows[f],d=!0))}}return{index:f,row:h,details:d}}}},getcellatposition:function(d,e){var f=this.that,g=this.showheader?this.columnsheader.height()+2:0,h=this._groupsheader()?this.groupsheader.height():0;h=h+(this.showtoolbar?this.toolbarheight:0)+(this.showfilterbar?
1170this.toolbarheight:0);var k=this.host.coord();this.hasTransform&&(k=a.jqx.utilities.getOffset(this.host));var l=d-k.left;d=e-g-k.top-h;g=this._hittestrow(l,d);e=g.row;g=this.table[0].rows[g.index];if(this.dataview&&0==this.dataview.records.length){e=this.table[0].rows;for(h=k=0;h<e.length;h++){if(d>=k&&d<k+this.rowsheight){g=e[h];break}k+=this.rowsheight}e={boundindex:h}}if(null==g)return!0;k=this.hScrollInstance.value;var m=0;for(h=0;h<g.cells.length;h++){var n=parseInt(a(this.columnsrow[0].cells[h]).css("left"));
1171d=n-k;f.columns.records[h].pinned&&(d=n);if(!f.columns.records[h].hidden&&!f.columns.records[h].adaptivehidden&&d+a(this.columnsrow[0].cells[h]).width()>=l&&l>=d){m=h;break}}return null!=e?(f=this._getcolumnat(m),{row:this.getboundindex(e),column:f.datafield,value:this.getcellvalue(this.getboundindex(e),f.datafield)}):null},_handlecardedit:function(d){var e=d.target.getAttribute("row"),f=document.createElement("div");d=this.getrowdatabyid(e);var g='<div class="jqx-grid-card-cell"><table>';for(var h=
11720;h<this.columns.records.length;h++){var k=this.columns.records[h];if(!k.hidden||void 0!==k.__hidden){var l=d[k.datafield];""!=k.cellsformat&&a.jqx.dataFormat&&(a.jqx.dataFormat.isDate(l)?l=a.jqx.dataFormat.formatdate(l,k.cellsformat,this.gridlocalization):a.jqx.dataFormat.isNumber(l)&&(l=a.jqx.dataFormat.formatnumber(l,k.cellsformat,this.gridlocalization)));g+='<tr class="jqx-grid-card-table-row">';g+='<td class="jqx-grid-card-cell-label"><div>'+k.text+"</div></td>";g+='<td class="jqx-grid-card-cell-value"><div><input datafield="'+
1173k.datafield+'" class="jqx-widget jqx-input" value="'+l+'"/></div></td>';g+="</tr>"}}f.innerHTML="<div>"+this.gridlocalization.udpaterowstring+" "+e+'</div><div style="overflow: hidden;">'+(g+'</table></div><div class="jqx-card-edit-buttons"><input style="margin-right: 5px;" type="button" dataid="Save" value="Save" /><input dataid="Cancel" type="button" value="Cancel" /></td></div></div></div>');d=f.querySelector('[dataid="Save"]');g=f.querySelector('[dataid="Cancel"]');a(d).jqxButton({template:"primary",
1174width:"40%",theme:this.theme});a(g).jqxButton({width:"40%",theme:this.theme});var m=this;d.onclick=function(){for(var n=a(f).find("[datafield]"),r={},t=0;t<n.length;t++){for(var u=n[t].getAttribute("datafield"),x=n[t].value,B=0;B<m.dataview.source.datafields.length;B++){var y=m.dataview.source.datafields[B];if(y.name===u){if("bool"===y.type||"boolean"===y.type)x=!0;var A=m._getcolumnbydatafield(y.name);y=y.type;var aa="date"===y||"time"===y;if("number"===y||"float"===y||"int"===y||"integer"===y||
1175"string"===y&&(-1!=A.cellsformat.indexOf("p")||-1!=A.cellsformat.indexOf("c")||-1!=A.cellsformat.indexOf("n")||-1!=A.cellsformat.indexOf("f"))){if(""===x&&A.nullable)return"";x.indexOf&&-1<x.indexOf(m.gridlocalization.currencysymbol)&&(x=x.replace(m.gridlocalization.currencysymbol,""));var ha=x;ha=parseFloat(ha);if(isNaN(ha)){ha=m.gridlocalization.thousandsseparator;var z=x;if(""!=ha){for(x=z.indexOf(ha);-1!=x;
1175)z=z.replace(ha,""),x=z.indexOf(ha);x=z}x=x.replace(m.gridlocalization.decimalseparator,
1176".");-1<x.indexOf(m.gridlocalization.percentsymbol)&&(x=x.replace(m.gridlocalization.percentsymbol,""));ha="";for(z=0;z<x.length;z++){var V=x.substring(z,z+1);"-"===V&&(ha+="-");"."===V&&(ha+=".");null!=V.match(/^[0-9]+$/)&&(ha+=V)}x=ha;x=x.replace(/ /g,"");x=new Number(x);isNaN(x)&&(x="")}else x=ha}if(aa||"string"===y&&(-1!=A.cellsformat.indexOf("H")||-1!=A.cellsformat.indexOf("m")||-1!=A.cellsformat.indexOf("M")||-1!=A.cellsformat.indexOf("y")||-1!=A.cellsformat.indexOf("h")||-1!=A.cellsformat.indexOf("d"))){if(""===
1177x&&A.nullable)return"";A=x;a.jqx.dataFormat&&(x=a.jqx.dataFormat.tryparsedate(A,m.gridlocalization));if("Invalid Date"==x||null==x)x=""}}}r[u]=x}m.updaterow(e,r);a(f).jqxWindow("close")};g.onclick=function(){a(f).jqxWindow("close")};document.body.appendChild(f);a(f).jqxWindow({position:{left:this.host.offset().left,top:this.host.offset().top},modalOpacity:.01,width:this.element.offsetWidth,height:this.element.offsetHeight,isModal:!0,autoOpen:!1,resizable:!1,draggable:!1});a(f).jqxWindow("open");this.cardwindow&&
1178a(this.cardwindow).remove();this.cardwindow=f},_handlemousedown:function(d,e){if(null==d.target||e.disabled||a(d.target).ischildof(this.columnsheader)||a(d.target).ischildof(this.hScrollBar)||a(d.target).ischildof(this.vScrollBar)||d.target===e.bottomRight[0])return!0;e.cardview&&d.target&&0<=d.target.className.indexOf("jqx-icon-edit")&&e._handlecardedit(d);var f;d.which?f=3==d.which:d.button&&(f=2==d.button);var g;d.which?g=2==d.which:d.button&&(g=1==d.button);if(g||this.adaptiveview&&(a(d.target).ischildof(a(this.adaptiveview))||
1179d.target==this.adaptiveview)||this.showstatusbar&&(a(d.target).ischildof(this.statusbar)||d.target==this.statusbar[0])||this.showtoolbar&&(a(d.target).ischildof(this.toolbar)||d.target==this.toolbar[0])||this.showfilterbar&&(a(d.target).ischildof(this.filterbar)||d.target==this.filterbar[0])||this.pageable&&(a(d.target).ischildof(this.pager)||d.target==this.pager[0])||!this.columnsheader||!this.editcell&&this.pageable&&a(d.target).ischildof(this.pager))return!0;g=this.showheader?this.columnsheader.height()+
11802:0;var h=this._groupsheader()?this.groupsheader.height():0;h=h+(this.showtoolbar?this.toolbarheight:0)+(this.showfilterbar?this.toolbarheight:0);var k=this.host.coord();if(this.hasTransform){k=a.jqx.utilities.getOffset(this.host);var l=this._getBodyOffset();k.left-=l.left;k.top-=l.top}var m=parseInt(d.pageX);l=parseInt(d.pageY);if(this.isTouchDevice()){var n=e.getTouches(d)[0];m=parseInt(n.pageX);l=parseInt(n.pageY);1==e.touchmode&&void 0!=n._pageX&&(m=parseInt(n._pageX),l=parseInt(n._pageY))}n=
1181m-k.left;l=l-g-k.top-h;if(this.pageable&&!this.autoheight&&this.gotopage&&(g=this.pager.coord().top-k.top-h-g,l>g))return;if((k=this._hittestrow(n,l))&&!k.details){g=k.row;l=k.index;var r=d.target.className,t=this.table[0].rows[l];if(null==t)return e.editable&&e.begincelledit&&e.editcell&&e.endcelledit(e.editcell.row,e.editcell.column,!1,!0),!0;e.mousecaptured=!0;e.mousecaptureposition={left:d.pageX,top:d.pageY-h,clickedrow:t};h=this.hScrollInstance;var u=h.value;this.rtl&&"hidden"!=this.hScrollBar.css("visibility")&&
1182(u=h.max-h.value);var x=-1,B=this.groupable?this.groups.length:0;this.rtl&&("hidden"!=this.vScrollBar[0].style.visibility&&(u-=this.scrollbarsize+4),"hidden"==this.hScrollBar[0].style.visibility&&(u=-parseInt(this.content.css("left"))));for(var y=0;y<t.cells.length;y++)if(h=parseInt(a(this.columnsrow[0].cells[y]).css("left")),m=h-u,e.columns.records[y].pinned&&!e.rtl&&(m=h),h=this._getcolumnat(y),null==h||!h.hidden)if(null==h||!h.adaptivehidden)if(h=m+a(this.columnsrow[0].cells[y]).width(),h>=n&&
1183n>=m){x=y;e.mousecaptureposition.clickedcell=y;break}if(this.rtl&&this._haspinned)for(y=t.cells.length-1;0<=y&&e.columns.records[y].pinned;y--)if(m=h=a(this.columnsrow[0].cells[y]).coord().left-this.host.coord().left,h=this._getcolumnat(y),null==h||!h.hidden)if(null==h||!h.adaptivehidden)if(h=m+a(this.columnsrow[0].cells[y]).width(),h>=n&&n>=m){x=y;e.mousecaptureposition.clickedcell=y;break}if(null!=g&&0<=x){this._raiseEvent(1,{rowindex:this.getboundindex(g),visibleindex:g.visibleindex,row:g,group:g.group,
1184rightclick:f,originalEvent:d});h=this._getcolumnat(x);n=this.getcellvalue(this.getboundindex(g),h.datafield);this.editable&&this.editcell&&(this._currentEditableColumn=x,h.datafield==this.editcell.column&&this.getboundindex(g)==this.editcell.row&&(this.mousecaptured=!1));if("adaptive"===h.columntype){var A=document.createElement("div"),aa=document.createElement("div");f=document.createElement("a");h=document.createElement("a");k=document.createElement("div");var ha=this.getrowdata(this.getboundindex(g));
1185f.href="#";h.href="#";A.style.zIndex=99999;A.style.position="absolute";A.style.left="0px";A.style.top="0px";A.style.width="100%";A.style.height="100%";A.className="jqx-adaptive-view jqx-widget-content";k.style.position="relative";k.style.top="100%";k.style.textAlign="center";k.style.marginTop="-40px";aa.style.position="absolute";aa.style.left="0px";aa.style.top="0px";aa.style.width="100%";aa.style.height="100%";this.theme&&(A.className="jqx-widget-content jqx-widget-content-"+this.theme);g=document.createElement("span");
1186g.className="jqx-icon-close";this.theme&&(g.className="jqx-icon-close jqx-widget-close-"+this.theme);g.style.zIndex=99;g.style.position="absolute";g.style.right="10px";g.style.top="10px";g.style.width="16px";g.style.height="16px";A.appendChild(aa);A.appendChild(g);f.innerHTML=this.gridlocalization.okstring;h.innerHTML=this.gridlocalization.cancelstring;f.addEventListener("mousedown",function(z){for(var V={},ba=e.adaptiveview.querySelectorAll("input"),v=0;v<ba.length;v++){var K=e.escape_HTML(ba[v].value),
1187C=ba[v].getAttribute("data-column");V[C]=K}e.updaterow(ha.uid,V);A.parentNode.removeChild(A);e.adaptiveview=null;z.stopPropagation();return!1});h.addEventListener("mousedown",function(){A.parentNode.removeChild(A);e.adaptiveview=null;d.stopPropagation();return!1});this.editable&&(k.appendChild(f),k.appendChild(h),A.appendChild(k));f="<table class='jqx-adaptive-table'><tr>";for(y=l=0;y<this.columns.records.length;y++)h=this.columns.records[y],"adaptive"!==h.columntype&&(0<y&&0===l%2&&(f+="</tr><tr>"),
1188k=ha[h.displayfield],""!=h.cellsformat&&a.jqx.dataFormat&&(a.jqx.dataFormat.isDate(k)?k=a.jqx.dataFormat.formatdate(k,h.
1188cellsformat,this.gridlocalization):a.jqx.dataFormat.isNumber(k)&&(k=a.jqx.dataFormat.formatnumber(k,h.cellsformat,this.gridlocalization))),n=this.filterable?'<div datafield="'+h.datafield+'" class="'+e.toTP("jqx-grid-column-filterbutton")+'" style="position: relative; top: 4px; display: inline-block; width: 16px; height:16px;"></div>':"",f=this.editable?h.editable?f+("<td>"+n+this.escape_HTML(h.text)+
1189": <input data-column='"+h.displayfield+"' value='"+k+"'/></td>"):f+("<td>"+n+this.escape_HTML(h.text)+": <input data-column='"+h.displayfield+"' readonly value='"+k+"'/></td>"):f+("<td>"+n+this.escape_HTML(h.text)+": "+k+"</td>"),l++);aa.innerHTML=f+"</tr></table>";g.addEventListener("mousedown",function(z){A.parentNode.removeChild(A);e.adaptiveview=null});this.wrapper[0].appendChild(A);this.adaptiveview=A;a(this.adaptiveview).find(".jqx-grid-column-filterbutton").on("click",function(){var z=this.getAttribute("datafield"),
1190V=this.offsetTop;e.openmenu(z);setTimeout(function(){e.gridmenu.css("top",30+V);e.gridmenu.css("left",25);e.gridmenu.css("z-index",99999);e.gridmenu.parent().css("z-index",99999)},300)});return}this._raiseEvent(8,{rowindex:this.getboundindex(g),column:h?h.getcolumnproperties():null,row:g,visibleindex:g.visibleindex,datafield:h?h.datafield:null,columnindex:x,value:n,rightclick:f,originalEvent:d});if(h.createwidget)return!0;if(this.isTouchDevice())if("checkbox"==h.columntype&&this.editable&&this._overlayElement){if(!this.editcell)return this._overlayElement.css("visibility",
1191"hidden"),this.editcell=this.getcell(l,h.datafield),!0}else if("button"==h.columntype&&this._overlayElement)return h.buttonclick&&h.buttonclick(t.cells[x].buttonrow,d),!0;l=!1;if(null!=this._lastmousedown&&300>this._mousedown-this._lastmousedown&&this._clickedrowindex==this.getboundindex(g)&&(this._raiseEvent(22,{rowindex:this.getboundindex(g),row:g,visibleindex:g.visibleindex,group:g.group,rightclick:f,originalEvent:d}),this._clickedcolumn==h.datafield&&this._raiseEvent(23,{rowindex:this.getboundindex(g),
1192row:g,visibleindex:g.visibleindex,column:h?h.getcolumnproperties():null,datafield:h?h.datafield:null,columnindex:x,value:n,rightclick:f,originalEvent:d}),l=!0,this._clickedrowindex=-1,this._clickedcolumn=null,d.isPropagationStopped&&d.isPropagationStopped()))return!1;if(f)return!0;l||(this._clickedrowindex=this.getboundindex(g),this._clickedcolumn=h.datafield);f=a.jqx.utilities.getBrowser();"msie"==f.browser&&7>=parseInt(f.version)&&(0==x&&this.rowdetails&&(r="jqx-grid-group-collapse"),0<B&&x<=B&&
1193(r="jqx-grid-group-collapse"));if(-1!=r.indexOf("jqx-grid-group-expand")||-1!=r.indexOf("jqx-grid-group-collapse"))this.rtl?0<B&&x>t.cells.length-B-1&&this._togglegroupstate?this._togglegroupstate(g.bounddata,!0):x==t.cells.length-1-B&&this.rowdetails&&this.showrowdetailscolumn&&(this._togglerowdetails(g.bounddata,!0),this.gridcontent[0].scrollTop=0,this.gridcontent[0].scrollLeft=0):0<B&&x<B&&this._togglegroupstate?this._togglegroupstate(g.bounddata,!0):x==B&&this.rowdetails&&this.showrowdetailscolumn&&
1194(this._togglerowdetails(g.bounddata,!0),this.gridcontent[0].scrollTop=0,this.gridcontent[0].scrollLeft=0);else if(-1!=g.boundindex){n=this.selectedrowindexes.slice(0);f=!1;if("none"!=e.selectionmode&&"checkbox"!=e.selectionmode&&this._selectrowwithmouse){"multiplecellsadvanced"!=e.selectionmode&&"multiplecellsextended"!=e.selectionmode&&"multiplerowsextended"!=e.selectionmode&&"multiplerowsadvanced"!=e.selectionmode||d.ctrlKey||d.shiftKey||d.metaKey||(e.selectedrowindexes=[],e.selectedcells=[]);aa=
1195!1;l=this.getboundindex(g);if(e._oldselectedrow===l||"none"===e.selectionmode)aa=!0;if(-1==e.selectionmode.indexOf("cell")){if("singlerow"!=e.selectionmode||e.selectedrowindex!=l&&"singlerow"==e.selectionmode)this._applyrowselection(l,!0,!1,null,h.datafield),this._selectrowwithmouse(e,k,n,h.datafield,d.ctrlKey||d.metaKey,d.shiftKey)}else null!=h.datafield&&(this._selectrowwithmouse(e,k,n,h.datafield,d.ctrlKey||d.metaKey,d.shiftKey),d.shiftKey||this._applycellselection(l,h.datafield,!0,!1));e._oldselectedcell&&
1196e._oldselectedcell.datafield==e.selectedcell.datafield&&e._oldselectedcell.rowindex==e.selectedcell.rowindex&&(f=!0);e._oldselectedcell=e.selectedcell;e._oldselectedrow=l}e.autosavestate&&e.savestate&&e.savestate();if(e.editable&&e.begincelledit&&"programmatic"!=e.editmode){if(d.isPropagationStopped&&d.isPropagationStopped())return!1;
1196"selectedrow"==e.editmode?aa&&!e.editcell?"checkbox"!==h.columntype&&(this._currentEditableColumn=x,e.beginrowedit(this.getboundindex(g))):e.editcell&&!aa&&"none"!=e.selectionmode&&
1197e.endrowedit(e.editcell.row):(l=this.getboundindex(g),aa="click"==e.editmode||f&&"selectedcell"==e.editmode,-1==e.selectionmode.indexOf("cell")&&"dblclick"!=e.editmode&&(aa=!0),aa&&void 0!=g.boundindex&&h.editable&&(e.begincelledit(this.getboundindex(g),h.datafield,h.defaulteditorvalue,!1),-1!=e.selectionmode.indexOf("cell")&&e._applycellselection(l,h.datafield,!1,!1)),-1!=e.selectionmode.indexOf("cell")&&"selectedcell"==e.editmode&&!f&&e.editcell&&e.endcelledit(e.editcell.row,e.editcell.column,!1,
1198!0),"dblclick"!=e.editmode||f||!e.editcell||e.editcell.row==l&&h.datafield==e.editcell.column||e.endcelledit(e.editcell.row,e.editcell.column,!1,!0))}}}return!0}},_columnPropertyChanged:function(d,e,f,g){},_rowPropertyChanged:function(d,e,f,g){},_serializeObject:function(d){if(null==d)return"";var e="";a.each(d,function(f){0<f&&(e+=", ");e+="[";f=0;for(var g in this)0<f&&(e+=", "),e+="{"+g+":"+this[g]+"}",f++;e+="]"});return e},isbindingcompleted:function(){return!this._loading},propertiesChangedHandler:function(d,
1199e,f){f.width&&f.height&&2==Object.keys(f).length&&(d._updatesize(!0,!0),d._resizeWindow(),d.virtualmode&&!d._loading?d.vScrollInstance.setPosition(0):setTimeout(function(){d._renderrows(d.virtualsizeinfo)},100))},propertyChangedHandler:function(d,e,f,g){if(void 0!=this.isInitialized&&0!=this.isInitialized&&!(d.batchUpdate&&d.batchUpdate.width&&d.batchUpdate.height&&2==Object.keys(d.batchUpdate).length))switch(e=e.toLowerCase(),e){case "cardview":case "cardviewsize":case "cardviewcolumns":case "cardheight":d.rowsheight=
120032;d.__rowsheight=d.rowsheight;d.virtualsizeinfo=null;d.cardview&&(d.__rowsheight=d.rowsheight,d.rowsheight=d.cardheight);d.render();break;case "editable":case "showcolumnheaderlines":case "showcolumnlines":case "showrowlines":d.refresh();break;case "everpresentrowactionsmode":f!=g&&(d._removeaddnewrow(),d.render());break;case "everpresentrowactions":d._updateaddnewrowui();break;case "showeverpresentrow":case "everpresentrowposition":case "everpresentrowheight":f!=g&&(d._removeaddnewrow(),d.render());
1201break;case "rtl":d.content.css("left","");d.columns=d._columns;d._filterrowcache=[];d.vScrollBar.jqxScrollBar({rtl:g});d.hScrollBar.jqxScrollBar({rtl:g});d._initpager&&d._initpager();d._initgroupsheader&&d._initgroupsheader();d.render();break;case "enablebrowserselection":d.showfilterrow||(d.showstatusbar||d.showtoolbar||d.host.addClass("jqx-disableselect"),d.content.addClass("jqx-disableselect"));d.enablebrowserselection&&(d.content.removeClass("jqx-disableselect"),d.host.removeClass("jqx-disableselect"));
1202break;case "columnsheight":(32!=d.columnsheight||d.columngroups)&&d._measureElement("column");d._render(!0,!0,!0,!1,!1);break;case "rowsheight":g!=f&&(31!=d.rowsheight&&d._measureElement("cell"),d.virtualsizeinfo=null,d.rendergridcontent(!0,!1),d.refresh());break;case "scrollMode":d.vScrollInstance.thumbStep=d.rowsheight;break;case "showdefaultloadelement":d._builddataloadelement();break;case "showfiltermenuitems":case "showsortmenuitems":case "showgroupmenuitems":case "filtermode":d._initmenu();
1203break;case "touchmode":f!=g&&(d._removeHandlers(),d.touchDevice=null,d.vScrollBar.jqxScrollBar({touchMode:g}),d.hScrollBar.jqxScrollBar({touchMode:g}),d._updateTouchScrolling(),d._arrange(),d._updatecolumnwidths(),d._updatecellwidths(),d._addHandlers());break;case "autoshowcolumnsmenubutton":f!=g&&d._rendercolumnheaders();break;case "rendergridrows":f!=g&&d.updatebounddata();break;case "editmode":f!=g&&(d._removeHandlers(),d._addHandlers());break;case "source":d.updatebounddata();d.virtualmode&&!d._loading&&
1204(d.loadondemand=!0,d._renderrows(d.virtualsizeinfo));break;case "horizontalscrollbarstep":case "verticalscrollbarstep":case "horizontalscrollbarlargestep":case "verticalscrollbarlargestep":this.vScrollBar.jqxScrollBar({step:this.verticalscrollbarstep,largestep:this.verticalscrollbarlargestep});this.hScrollBar.jqxScrollBar({step:this.horizontalscrollbarstep,largestep:this.horizontalscrollbarlargestep});break;case "closeablegroups":d._initgroupsheader&&d._initgroupsheader();break;case "showgroupsheader":f!=
1205g&&(d._arrange(),d._initgroupsheader&&d._initgroupsheader(),d._renderrows(d.virtualsizeinfo));break;case "theme":g!=f&&(a.jqx.utilities.setTheme(f,g,d.host),d.gridmenu&&d.gridmenu.jqxMenu({theme:g}),d.pageable&&d._updatepagertheme(),d.filterable&&d._updatefilterrowui(!0),d.showeverpresentrow&&d._updateaddnewrowu
1205i(!0),d._applyThemeSettings());break;case "showtoolbar":case "showfilterbar":case "toolbarheight":f!=g&&(d._arrange(),d.refresh());break;case "showstatusbar":f!=g&&(d.statusbar&&(g?d.statusbar.show():
1206d.statusbar.hide()),d._arrange(),d.refresh());break;case "statusbarheight":f!=g&&(d._arrange(),d.refresh());break;case "filterable":case "showfilterrow":f!=g&&d.render();break;case "autoshowfiltericon":case "showfiltercolumnbackground":case "showpinnedcolumnbackground":case "showsortcolumnbackground":f!=g&&d.rendergridcontent();break;case "showrowdetailscolumn":f!=g&&d.render();break;case "scrollbarsize":f!=g&&(a.jqx.utilities.scrollBarSize=g,d._arrange());break;case "width":case "height":f!=g&&(d._updatesize(!0,
1207!0),d._resizeWindow(),d.virtualmode&&!d._loading?d.vScrollInstance.setPosition(0):setTimeout(function(){d._renderrows(d.virtualsizeinfo)},100));break;case "altrows":case "altstart":case "altstep":f!=g&&d._renderrows(d.virtualsizeinfo);break;case "groupsheaderheight":f!=g&&(d._arrange(),d._initgroupsheader&&d._initgroupsheader());break;case "pagerheight":f!=g&&d._initpager();break;case "selectedrowindex":d.selectrow(g);break;case "selectionmode":f!=g&&("none"==g&&(d.selectedrowindexes=[],d.selectedcells=
1208[],d.selectedrowindex=-1),d._renderrows(d.virtualsizeinfo),"checkbox"==g&&d._render(!1,!1,!0,!1,!1));break;case "showheader":g?d.columnsheader.css("display","block"):d.columnsheader.css("display","none");break;case "virtualmode":f!=g&&(d.dataview.virtualmode=d.virtualmode,d.dataview.refresh(!1),d._render(!1,!1,!1));break;case "columnsmenu":f!=g&&d.render();break;case "columngroups":d._render(!0,!0,!0,!1,!1);break;case "columns":d.columns&&d.columns.length>d.headerZIndex&&(d.headerZIndex=d.columns.length+
1209100);if(d._serializeObject(d._cachedcolumns)!==d._serializeObject(g)){var h=!1;d.filterable&&f&&f.records&&a.each(f.records,function(){this.filter&&(h=!0);d.dataview.removefilter(this.displayfield,this.filter)});d._columns=null;d._filterrowcache=[];d.render();h&&d.applyfilters();d._cachedcolumns=d.columns;d.removesort&&d.removesort()}else d[e]=f;break;case "autoheight":f!=g&&d._render(!1,!1,!0);break;case "pagermode":case "pagerbuttonscount":f!=g&&d._initpager&&(d.pagershowrowscombo&&(d.pagershowrowscombo.jqxDropDownList("destroy"),
1210d.pagershowrowscombo=null),d.pagerrightbutton&&(d.removeHandler(d.pagerrightbutton,"mousedown"),d.removeHandler(d.pagerrightbutton,"mouseup"),d.removeHandler(d.pagerrightbutton,"click"),d.pagerrightbutton.jqxButton("destroy"),d.pagerrightbutton=null),d.pagerleftbutton&&(d.removeHandler(d.pagerleftbutton,"mousedown"),d.removeHandler(d.pagerleftbutton,"mouseup"),d.removeHandler(d.pagerleftbutton,"click"),d.pagerleftbutton.jqxButton("destroy"),d.removeHandler(a(document),"mouseup.pagerbuttons"+d.element.id),
1211d.pagerleftbutton=null),d.pagerdiv.remove(),d._initpager());break;case "pagesizeoptions":case "pageable":case "pagesize":if(f!=g){if(d._loading)throw Error("jqxGrid: "+d.loadingerrormessage);if(d.host.jqxDropDownList&&d.host.jqxListBox){if(d._initpager){if("pageable"!=e&&"pagermode"!=e&&"string"==typeof g)throw f="The expected value type is: Int.","pagesize"!=e&&(f="The expected value type is: Array of Int values."),Error("Invalid Value for: "+e+". "+f);d.dataview.pageable=d.pageable;d.dataview.pagenum=
12120;d.dataview.pagesize=d._getpagesize();d.virtualmode&&d.updatebounddata();d.dataview.refresh(!0);d._initpager();"pagesizeoptions"==e&&null!=g&&0<g.length&&(d.pagesize=parseInt(g[0]),d.dataview.pagesize=parseInt(g[0]),d.prerenderrequired=!0,d._requiresupdate=!0,d.dataview.pagenum=-1,d.gotopage(0))}d._render(!1,!1,!1)}else d._testmodules()}break;case "groups":d._serializeObject(f)!==d._serializeObject(g)&&(d.dataview.groups=g,d._refreshdataview(),d._render(!0,!0,!0,!1));break;case "groupable":f!=g&&
1213(d.dataview.groupable=d.groupable,d.dataview.pagenum=0,d.dataview.refresh(!1),d._render(!1,!1,!0));break;case "renderstatusbar":null!=g&&d.renderstatusbar(d.statusbar);break;case "rendertoolbar":null!=g&&d.rendertoolbar(d.toolbar);break;case "disabled":g?d.host.addClass(d.toThemeProperty("jqx-fill-state-disabled")):d.host.removeClass(d.toThemeProperty("jqx-fill-state-disabled")),a.jqx.aria(d,"aria-disabled",d.disabled),d.pageable&&(d.pagerrightbutton&&(d.pagerrightbutton.jqxButton({disabled:g}),d.pagerleftbutton.jqxButton({disabled:g}),
1214d.pagershowrowscombo.jqxDropDownList({disabled:g}),d.pagergotoinput.attr("disabled",g)),d.pagerfirstbutton&&(d.pagerfirstbutton.jqxButton({disabled:g}),d.pagerlastbutton.jqxButton({disabled:g}))),d.vScrollBar.jqxScrollBar({disabled:g}),d.hScrollBar.jqxScrollBar({disabled:g}),d.filterable&&d.showfilterrow&&d._updatefilterrowui(!0),d.showeverpresentrow&&d._updateaddnewrowu
1214i(!0)}}});a.jqx.collection=function(d){this.records=[];this.owner=d;this.updating=!1;this.beginupdate=function(){this.updating=!0};
1215this.resumeupdate=function(){this.updating=!1};this._raiseEvent=function(e){};this.clear=function(){this.records=[]};this.replace=function(e,f){this.records[e]=f;this.updating||this._raiseEvent({type:"replace",element:f})};this.isempty=function(e){return void 0==this.records[e]?!0:!1};this.initialize=function(e){1>e&&(e=1);this.records[e-1]=-1};this.length=function(){return this.records.length};this.indexOf=function(e){return this.records.indexOf(e)};this.add=function(e){if(null==e)return!1;this.records[this.records.length]=
1216e;this.updating||this._raiseEvent({type:"add",element:e});return!0};this.insertAt=function(e,f){return null==e||void 0==e||null==f?!1:0<=e?e<this.records.length?(this.records.splice(e,0,f),this.updating||this._raiseEvent({type:"insert",index:e,element:f}),!0):this.add(f):!1};this.remove=function(e){if(null==e||void 0==e)return!1;var f=this.records.indexOf(e);return-1!=f?(this.records.splice(f,1),this.updating||this._raiseEvent({type:"remove",element:e}),!0):!1};this.removeAt=function(e){if(null==
1217e||void 0==e||0>e)return!1;if(e<this.records.length){var f=this.records[e];this.records.splice(e,1);this.updating||this._raiseEvent({type:"removeAt",index:e,element:f});return!0}return!1};return this};a.jqx.dataview=function(){this.self=this;this.aggregates=!1;this.grid=null;this.uniqueId="id";this.records=[];this.rows=[];this.columns=[];this.groups=[];this.filters=[];this.update=this.updated=null;this.suspend=!1;this.totalrecords=this.totalrows=this.pagenum=this.pagesize=0;this.groupable=!0;this.loadedrecords=
1218[];this.loadedrootgroups=[];this.loadedgroups=[];this.loadedgroupsByKey=[];this.virtualmode=!0;this._cachegrouppages=[];this.source=null;this.changedrecords=[];this.rowschangecallback=null;this.that=this;this.destroy=function(){delete this.self;delete this.grid;delete this.uniqueId;delete this.records;delete this.rows;delete this.columns;delete this.groups;delete this.filters;delete this.updated;delete this.update;delete this.suspend;delete this.pagesize;delete this.pagenum;delete this.totalrows;
1219delete this.totalrecords;delete this.groupable;delete this.loadedrecords;delete this.loadedrootgroups;delete this.loadedgroups;delete this.loadedgroupsByKey;delete this.virtualmode;delete this._cachegrouppages;delete this.source;delete this.changedrecords;delete this.rowschangecallback;delete this.that};this.suspendupdate=function(){this.suspend=!0};this.isupdating=function(){return this.suspend};this.resumeupdate=function(d){this.suspend=!1;void 0==d&&(d=!0);this.refresh(d)};this.getrecords=function(){return this.records};
1220this.clearrecords=function(){this.recordids=[]};this.databind=function(d,e){e=d._source?!0:!1;var f=null;this.grid&&(this.aggregates=this.grid.showgroupaggregates);e?(f=d,d=d._source):f=new a.jqx.dataAdapter(d,{autoBind:!1});var g=function(A){A.totalrecords=f.totalrecords;if(A.virtualmode){var aa={startindex:A.pagenum*A.pagesize,endindex:A.pagenum*A.pagesize+A.pagesize};void 0!=d.recordstartindex&&(aa.startindex=parseInt(d.recordstartindex));void 0!=d.recordendindex?aa.endindex=parseInt(d.recordendindex):
1221A.grid.pageable||(aa.endindex=aa.startindex+100,A.grid.autoheight&&(aa.endindex=aa.startindex+A.totalrecords));d.recordendindex||(A.grid.pageable?aa={startindex:A.pagenum*A.pagesize,endindex:A.pagenum*A.pagesize+A.pagesize}:(aa.endindex=aa.startindex+100,A.grid.autoheight&&(aa.endindex=aa.startindex+A.totalrecords)));aa.data=f.records;if(A.grid.rendergridrows&&0<A.totalrecords){var ha=0;d.records=A.grid.rendergridrows(aa);d.records.length&&(ha=d.records.length);if(d.records&&!d.records[aa.startindex]){var z=
1222[],V=aa.startindex;a.each(d.records,function(){z[V]=this;V++;ha++});d.records=z}0==ha&&d.records&&a.each(d.records,function(){ha++});if(0<ha&&ha<aa.endindex-aa.startindex&&!A.grid.groupable)for(var ba=d.records[0],v=0;v<aa.endindex-aa.startindex-ha;v++){var K={},C;for(C in ba)K[C]="";d.records.push&&d.records.push(K)}}d.records&&0!=A.totalrecords||(d.records=[]);A.originaldata=d.records;A.records=d.records;A.cachedrecords=d.records}else A.originaldata=f.originaldata,A.records=f.records,A.recordids=
1223f.recordids,A.cachedrecords=f.cachedrecords};f.recordids=[];f.records=[];f.cachedrecords=[];f.originaldata=[];f._options.virtualmode=this.virtualmode;f._options.totalrecords=this.totalrecords;f._options.originaldata=this.originaldata;f._options.recordids=this.recordids;f._options.cachedrecords=[];f._options.pagenum=this.pagenum;f._options.pageable=this.pageable;void 0!=d.type&&(f._options.type=d.type);void 0!=d.formatdata&&(f._options.formatData=d.formatdata);void 0!=d.contenttype&&(f._options.contentType=
1224d.contenttype);void 0!=d.async&&(f._options.async=d.async);void 0!=d.updaterow&&(f._options.updaterow=d.updaterow);void 0!=d.addrow&&(f._options.addrow=d.addrow);void 0!=d.deleterow&&(f._options.deleterow=d.deleterow);0==this.pagesize&&(this.pagesize=10);f._options.pagesize=this.pagesize;this.source=d;var h=this.that;switch(d.datatype){default:null==d.localdata&&(d.localdata=[]);
1224null!=d.localdata&&(f.unbindBindingUpdate(h.grid.element.id),(!h.grid.autobind&&h.grid.isInitialized||h.grid.autobind)&&
1225f.dataBind(),e=function(A){if(void 0!=A&&""!=A){if(f._changedrecords[0]){var aa=[];a.each(f._changedrecords,function(z){var V=this.index,ba=this.record;h.grid._updateFromAdapter=!0;switch(A){case "update":V=h.grid.getrowid(V);z==f._changedrecords.length-1?h.grid.updaterow(V,ba):h.grid.updaterow(V,ba,!1);h.grid._updateFromAdapter=!1;break;case "add":h.grid.addrow(null,ba);h.grid._updateFromAdapter=!1;break;case "remove":V=h.grid.getrowid(V),aa.push(V)}});0<aa.length&&(h.grid.deleterow(aa,!1),h.grid._updateFromAdapter=
1226!1)}if("update"==A)return}var ha=h.totalrecords;g(h,A);null===d.localdata.notifier&&"observableArray"==d.localdata.name&&(d.localdata.notifier=function(z){if(!h._updating){h._updating=!0;var V=h.grid.getrowid(z.index);switch(z.type){case "add":var ba=a.extend({},z.object[z.index]);V=f.getid(d.id,ba,z.index);0===z.index?h.grid.addrow(V,ba,"first"):h.grid.addrow(V,ba);break;case "delete":h.grid.deleterow(V);break;case "update":z.path&&1<z.path.split(".").length?(ba=z.path.split("."),h.grid.setcellvalue(z.index,
1227ba[ba.length-1],z.newValue)):(ba=a.extend({},z.object[z.index]),h.grid.updaterow(V,ba))}h._updating=!1}});"updateData"==A?(h.refresh(),h.grid._updateGridData()):(d.recordstartindex&&h.virtualmode?h.updateview(d.recordstartindex,d.recordstartindex+h.pagesize):h.refresh(),h.update(ha!=h.totalrecords))},e(),f.bindBindingUpdate(h.grid.element.id,e));break;case "json":case "jsonp":case "xml":case "xhtml":case "script":case "text":case "csv":case "tab":if(null!=d.localdata)f.unbindBindingUpdate(h.grid.element.id),
1228(!h.grid.autobind&&h.grid.isInitialized||h.grid.autobind)&&f.dataBind(),e=function(A){var aa=h.totalrecords;g(h);"updateData"==A?(h.refresh(),h.grid._updateGridData()):(d.recordstartindex&&h.virtualmode?h.updateview(d.recordstartindex,d.recordstartindex+h.pagesize):h.refresh(),h.update(aa!=h.totalrecords))},e(),f.bindBindingUpdate(h.grid.element.id,e);else{var k=[],l=0;e={};for(var m=0;m<h.filters.length;m++){var n=h.filters[m].datafield,r=h.filters[m].filter;if(r.getfilters){var t=r.getfilters();
1229e[n+"operator"]=r.operator;for(r=0;r<t.length;r++){t[r].datafield=n;var u=t[r].value;if("datefilter"==t[r].type)if(t[r].value&&t[r].value.toLocaleString){var x=h.grid.getcolumn(t[r].datafield);x&&x.cellsformat?(x=h.grid.source.formatDate(t[r].value,x.cellsformat,h.grid.gridlocalization),e["filtervalue"+l]=x?x:t[r].value.toLocaleString()):e["filtervalue"+l]=u.toString()}else e["filtervalue"+l]=u.toString();else e["filtervalue"+l]=u.toString(),t[r].data&&(e["filterid"+l]=t[r].data.toString()),t[r].id&&
1230(e["filterid"+l]=t[r].id.toString());e["filtercondition"+l]=t[r].condition;e["filteroperator"+l]=t[r].operator;e["filterdatafield"+l]=n;x={label:u.toString()};t[r].data&&(x.value=t[r].data.toString());x.value=t[r].id?t[r].id.toString():u.toString();x.condition=t[r].condition;x.operator=0==t[r].operator?"and":"or";x.field=n;x.type=t[r].type;u=!1;if(0<k.length)for(var B=0;B<k.length;B++){var y=k[B];if(y.field==n){y.filters.push(x);u=!0;break}}u||(k.push({field:n,filters:[]}),k[k.length-1].filters.push(x));
1231l++}}}e.filterGroups=k;e.filterscount=l;e.groupscount=h.groups.length;for(m=0;m<h.groups.length;m++)e["group"+m]=h.groups[m];void 0==d.recordstartindex&&(d.recordstartindex=0);if(void 0==d.recordendindex||0==d.recordendindex)h.grid.height&&-1==h.grid.height.toString().indexOf("%")?(d.recordendindex=parseInt(h.grid.height)/h.grid.rowsheight,d.recordendindex+=2):d.recordendindex=a(window).height()/h.grid.rowsheight,d.recordendindex=parseInt(d.recordendindex),h.pageable&&(d.recordendindex=h.pagesize);
1232h.pageable&&(d.recordstartindex=h.pagenum*h.pagesize,d.recordendindex=(h.pagenum+1)*h.pagesize);a.extend(e,{sortdatafield:h.sortfield,sortorder:h.sortfielddirection,pagenum:h.pagenum,pagesize:h.grid.pagesize,recordstartindex:d.recordstartindex,recordendindex:d.recordendindex});(k=f._options.data)?a.extend(f._options.data,e):(d.data&&a.extend(e,d.data),f._options.data=e);e=function(){var A=function(){var aa=h.totalrecords;g(h);d.recordstartindex&&h.virtualmode?h.updateview(d.recordstartindex,d.recordstartindex+
1233h.pagesize):h.refresh();h.update(aa!=h.totalrecords)};if(a.jqx.browser.msie&&9>a.jqx.browser.version)try{A()}catch(aa){}else A()};
1233f.unbindDownloadComplete(h.grid.element.id);f.bindDownloadComplete(h.grid.element.id,e);!h.grid.autobind&&h.grid.isInitialized||h.grid.autobind?f.dataBind():h.grid.isInitialized||h.grid.autobind||e();f._options.data=k}}};this.getid=function(d,e,f){return 0<a(d,e).length?a(d,e).text():d&&0<d.toString().length&&(d=a(e).attr(d),null!=d&&0<d.toString().length)?d:f};this.getvaluebytype=
1234function(d,e){var f=d;"date"==e.type?(e=new Date(d),d="NaN"==e.toString()||"Invalid Date"==e.toString()?a.jqx.dataFormat?a.jqx.dataFormat.tryparsedate(d):e:e,null==d&&(d=f)):"float"==e.type?(d=parseFloat(d),isNaN(d)&&(d=f)):"int"==e.type?(d=parseInt(d),isNaN(d)&&(d=f)):"bool"==e.type&&(null!=d&&("false"==d.toLowerCase()?d=!1:"true"==d.toLowerCase()&&(d=!0)),d=1==d?!0:0==d?!1:"");return d};this.setpaging=function(d){void 0!=d.pageSize&&(this.pagesize=d.pageSize);void 0!=d.pageNum&&(this.pagenum=Math.min(d.pageNum,
1235Math.ceil(this.totalrows/this.pagesize)));this.refresh()};this.getpagingdetails=function(){return{pageSize:this.pagesize,pageNum:this.pagenum,totalrows:this.totalrows}};this._clearcaches=function(){this.sortcache={};this.sortdata=null;this.changedrecords=[];this.records=[];this.rows=[];this.cacheddata=[];this.originaldata=[];this.bounditems=[];this.loadedrecords=[];this.loadedrootgroups=[];this.loadedgroups=[];this.loadedgroupsByKey=[];this._cachegrouppages=[];this.recordsbyid=[];this.cachedrecords=
1236[];this.recordids=[]};this.addfilter=function(d,e){for(var f=-1,g=0;g<this.filters.length;g++)if(this.filters[g].datafield==d){f=g;break}-1==f?this.filters[this.filters.length]={filter:e,datafield:d}:this.filters[f]={filter:e,datafield:d}};this.removefilter=function(d){for(var e=0;e<this.filters.length;e++)if(this.filters[e].datafield==d){this.filters.splice(e,1);break}};this.getItemFromIndex=function(d){return this.records[d]};this.updaterow=function(d,e,f){if(!(this.filters&&0<this.filters.length&&
1237!this.virtualmode||void 0==e)&&void 0!=d){e.uid=d;e[this.source.id]||(e[this.source.id]=e.uid);var g=this.recordsbyid["id"+d],h=this.records.indexOf(g);if(-1==h)return!1;this.records[h]=e;this.cachedrecords&&(this.cachedrecords[h]=e);1!=f&&void 0!=f||this.refresh();this.changedrecords[e.uid]={Type:"Update",OldData:g,Data:e};return!0}if(this.filters&&0<this.filters.length){var k=this.cachedrecords;g=null;h=-1;for(var l=0;l<k.length;l++)if(k[l].uid==d){g=k[l];h=l;break}if(g){d=this.that;for(var m in e)d.cachedrecords[h][m]=
1238e[m];1!=f&&void 0!=f||this.refresh();return!0}}return!1};this.addrow=function(d,e,f,g){if(void 0!=e){a.isEmptyObject(e)&&this.source&&this.source.datafields&&a.each(this.source.datafields,function(){var h="";"number"==this.type&&(h=null);"date"==this.type&&(h=null);if("bool"==this.type||"boolean"==this.type)h=!1;e[this.name]=h});if(!d||this.recordsbyid["id"+d])for(e.uid=this.getid(this.source.id,e,this.totalrecords),d=this.recordsbyid["id"+e.uid];null!=d;)d=Math.floor(1E4*Math.random()).toString(),
1239e.uid=d,d=this.recordsbyid["id"+d];else e.uid=d;e[this.source.id]||void 0==this.source.id||(e[this.source.id]=e.uid);e.boundindex=this.records.length;"last"==f?this.records.push(e):"number"===typeof f&&isFinite(f)?this.records.splice(f,0,e):this.records.splice(0,0,e);this.filters&&0<this.filters.length&&("last"==f?this.cachedrecords.push(e):"number"===typeof f&&isFinite(f)?this.cachedrecords.splice(f,0,e):this.cachedrecords.splice(0,0,e));this.totalrecords++;this.virtualmode&&(this.source.totalrecords=
1240this.totalrecords);1!=g&&void 0!=g||this.refresh();this.changedrecords[e.uid]={Type:"New",Data:e};return!0}return!1};this.deleterow=function(d,e){if(void 0!=d){var f=this.filters&&0<this.filters.length;if(this.recordsbyid["id"+d]&&!f){f=this.recordsbyid["id"+d];var g=this.records.indexOf(f);if(this.grid&&this.grid.sortable&&"many"==this.grid.sortmode)for(var h=0;h<this.records.length;h++)if(this.records[h].boundindex===f.boundindex){g=h;break}this.changedrecords[d]={Type:"Delete",Data:this.records[g]};
1241this.records.splice(g,1);this.totalrecords--;this.virtualmode&&(this.source.totalrecords=this.totalrecords);1!=e&&void 0!=e||this.refresh();return!0}if(this.filters&&0<this.filters.length){var k=this.cachedrecords;f=null;g=-1;for(h=0;h<k.length;h++)if(k[h].uid==d){f=k[h];g=h;break}if(f){this.cachedrecords.splice(g,1);if(1==e||void 0==e)this.totalrecords=0,this.records=this.cachedrecords,this.refresh();return!0}}}return!1};this.reload=function(d,e,f,g,h,k,l){var m=this.that;h=[];var n=e.length,r=0;
1242this.columns=[];this.bounditems=[];this.loadedrecords=[];this.loadedrootgroups=[];this.loadedgroups=[];this.loadedgroupsByKey=[];this._cachegrouppages=[];this.recordsbyid={};0==this.totalrecords&&(Object.size=function(u){var x=0,B;for(B in u)u.hasOwnProperty(B)&&x++;return x}
1242,this.totalrecords=Object.size(d),a.each(this.records,function(u){var x=0;a.each(this,function(B,y){m.columns[x++]=B});return!1}));if(this.virtualmode){if(this.pageable){this.updateview();return}k=0;if(this.groupable)l=this.totalrecords;
1243else{this.updateview();return}}else k=0,l=this.totalrecords;if(this.groupable&&0<this.groups.length&&this.loadgrouprecords){var t=k;t=this.loadgrouprecords(0,k,l,f,0,g,e,n,h)}else r=this.loadflatrecords(k,l,f,0,g,e,n,h);0<n&&e.splice(0,n-0);this.totalrows=0<this.groups.length&&this.groupable?t:r;return h};this.loadflatrecords=function(d,e,f,g,h,k,l,m){var n=this.that,r=f=d;e=Math.min(e,this.totalrecords);for(var t=null!=this.sortdata,u=t?this.sortdata:this.records;d<e;d++){var x={};if(t)x=a.extend({},
1244u[d].value),B=x[n.uniqueId],x.boundindex=u[d].index,void 0==x.uid&&(x.uid=n.getid(n.source.id,x,x.boundindex)),n.recordsbyid["id"+x.uid]=u[d].value,n.loadedrecords[f]=x,x.uniqueid=n.generatekey(),n.bounditems[x.boundindex]=x;else{x=Object(u[d]);var B=x[n.uniqueId];x.boundindex=f;n.loadedrecords[f]=x;void 0==x.uid&&(x.uid=n.getid(n.source.id,x,f));n.recordsbyid["id"+x.uid]=u[d];x.uniqueid=n.generatekey();n.bounditems[this.bounditems.length]=x}if(g>=l||B!=k[g][n.uniqueId]||h&&h[B])m[m.length]=g;k[g]=
1245x;g++;x.visibleindex=r;r++;f++}if(n.grid.summaryrows){var y=f;a.each(n.grid.summaryrows,function(){var A=a.extend({},this);A.boundindex=e++;n.loadedrecords[y]=A;A.uniqueid=n.generatekey();n.bounditems[n.bounditems.length]=A;k[g]=A;g++;A.visibleindex=r;r++;y++})}return r};this.updateview=function(d,e){var f=this.that,g=this.pagesize*this.pagenum,h=0,k=[],l=this.filters,m=this.updated,n=k.length;if(this.pageable){if(this.virtualmode)if(!this.groupable||0==this.groups.length)this.loadflatrecords(this.pagesize*
1246this.pagenum,this.pagesize*(1+this.pagenum),l,h,m,k,n,[]),this.totalrows=k.length;else if(this.groupable&&0<this.groups.length&&this.loadgrouprecords){if(void 0!=this._cachegrouppages[this.pagenum+"_"+this.pagesize]){this.rows=this._cachegrouppages[this.pagenum+"_"+this.pagesize];this.totalrows=this.rows.length;return}f=this.pagesize*(1+this.pagenum);f>this.totalrecords&&(f=this.totalrecords);this.loadgrouprecords(0,this.pagesize*this.pagenum,f,l,h,m,k,n,[]);this._cachegrouppages[this.pagenum+"_"+
1247this.pagesize]=this.rows;this.totalrows=this.rows.length;return}}else if(this.virtualmode&&(!this.groupable||0==this.groups.length)){var r=this.pagesize;0==r&&(r=Math.min(100,this.totalrecords));null!=d&&null!=e?this.loadflatrecords(d,e,l,h,m,k,n,[]):this.loadflatrecords(this.pagesize*this.pagenum,this.pagesize*(1+this.pagenum),l,h,m,k,n,[]);this.totalrows=this.loadedrecords.length;this.rows=k;if(k.length>=r)return}if(this.groupable&&this.pageable&&0<this.groups.length&&this._updategroupsinpage)k=
1248this._updategroupsinpage(f,l,g,h,n,this.pagesize*this.pagenum,this.pagesize*(1+this.pagenum));else for(l=this.pagesize*this.pagenum;l<this.pagesize*(1+this.pagenum);l++)if(m=l<this.loadedrecords.length?this.loadedrecords[l]:null,null!=m){if(!this.pagesize||g>=this.pagesize*this.pagenum&&g<=this.pagesize*(this.pagenum+1))k[h]=m,h++;g++}if((0==k.length||k.length<this.pagesize)&&!this.pageable&&this.virtualmode)for(g=h=k.length,l=this.pagesize*this.pagenum;l<this.pagesize*(1+this.pagenum)-g;l++)m={},
1249m.boundindex=l+g,m.visibleindex=l+g,m.uniqueid=f.generatekey(),m.empty=!0,f.bounditems[l+g]=m,k[h]=m,h++;this.rows=k};this.generatekey=function(){var d=function(){return 16*(1+Math.random())|0};return""+d()+d()+"-"+d()+"-"+d()+"-"+d()+"-"+d()+d()+d()};this.reloaddata=function(){this.reload(this.records,this.rows,this.filter,this.updated,!0)};this.refresh=function(d){if(!this.suspend){void 0==d&&(d=!0);var e=this.rows.length,f=this.totalrows;if(0<this.filters.length&&!this.virtualmode){var g=this.cachedrecords.length,
1250h=[];this.totalrecords=0;var k=this.cachedrecords;this._dataIndexToBoundIndex=[];var l=this.filters.length;if(null!=this.source&&void 0!=this.source.filter&&void 0!=this.source.localdata){var m=this.source.filter(this.filters,k,g);void 0==m&&(m=[]);for(var n=0;n<g;n++){var r=k[n],t=0<=m.indexOf(r);t?(h[h.length]=a.extend({dataindex:n},r),this._dataIndexToBoundIndex[n]={boundindex:h.length-1}):this._dataIndexToBoundIndex[n]=null}this.records=h}else if(null==this.source.filter||void 0==this.source.filter){for(n=
12510;n<g;n++){r=k[n];
1251t=void 0;for(var u=0;u<l;u++){m=this.filters[u].filter;var x=r[this.filters[u].datafield],B=m&&m.evaluate?m.evaluate(x):!0;this.grid.filter&&(x=this.grid.filter(x,r,this.filters[u].datafield,m,B),void 0!==x&&(B=x));t=void 0==t?B:"or"==m.operator?t||B:t&&B}t?(h[h.length]=a.extend({dataindex:n},r),this._dataIndexToBoundIndex[n]={boundindex:h.length-1}):this._dataIndexToBoundIndex[n]=null}this.records=h}if(this.sortdata)if(this.grid&&"many"!==this.grid.sortmode){if(g=this.sortfield,
1252this.sortcache[g]){this.sortdata=null;e=this.sortcache[g].direction;this.sortcache[g]=null;this.sortby(this.sortfield,e);return}}else{e=this.grid.getsortcolumns();for(f=0;f<e.length;f++)d=e[f],g=d.dataField,this.grid.sortby(g,d.ascending,null);return}}else if(0==this.filters.length&&!this.virtualmode&&this.cachedrecords&&(this.totalrecords=0,this.records=k=this.cachedrecords,this.sortdata))if(this.grid&&"many"!==this.grid.sortmode){if(g=this.sortfield,this.sortcache[g]){this.sortdata=null;e=this.sortcache[g].direction;
1253this.sortcache[g]=null;this.sortby(this.sortfield,e);return}}else{e=this.grid.getsortcolumns();for(f=0;f<e.length;f++)d=e[f],g=d.dataField,this.grid.sortby(g,d.ascending,null);return}d=this.reload(this.records,this.rows,this.filter,this.updated,d);this.updated=null;null!=this.rowschangecallback&&(g=this.rows,f!=this.totalrows&&this.rowschangecallback({type:"PagingChanged",data:this.getpagingdetails()}),e!=g.length&&this.rowschangecallback({type:"RowsCountChanged",data:{previous:e,current:g.length}}),
1254(0<d.length||e!=g.length)&&this.rowschangecallback({type:"RowsChanged",data:{previous:e,current:g.length,diff:d}}))}};return this}})(jqxBaseFramework);
1255(function(a){a.extend(a.jqx._jqxGrid.prototype,{selectallrows:function(){this._trigger=!1;var b=this.virtualmode?this.dataview.totalrecords:this.dataview.loadedrecords.length;this.selectedrowindexes=[];this.selectedcells=[];for(var c=this.dataview.loadedrecords,d=0;d<b;d++){var e=c[d];if(e){e=this.getboundindex(e);void 0!=e&&(this.selectedrowindexes[d]=e);for(var f=0;f<this.columns.records.length;f++)this.selectedcells[e+"_"+this.columns.records[f].datafield]=!0}else this.selectedrowindexes[d]=d}"checkbox"!=
1256this.selectionmode||this._checkboxcolumnupdating||this._checkboxcolumn&&this._checkboxcolumn.checkboxelement.jqxCheckBox({checked:!0});this._renderrows(this.virtualsizeinfo);this._trigger=!0;"checkbox"==this.selectionmode&&this._raiseEvent(2,{rowindex:this.selectedrowindexes})},unselectallrows:function(){this._trigger=!1;this.selectedrowindexes=[];this.selectedcells=[];"checkbox"!=this.selectionmode||this._checkboxcolumnupdating||this._checkboxcolumn&&this._checkboxcolumn.checkboxelement.jqxCheckBox({checked:!1});
1257this._renderrows(this.virtualsizeinfo);this._trigger=!0;"checkbox"==this.selectionmode&&this._raiseEvent(2,{rowindex:this.selectedrowindexes})}
1257,selectrow:function(b,c){"none"!==this.selectionmode&&(this._applyrowselection(b,!0,c),!1!==c&&this._updatecheckboxselection())},_updatecheckboxselection:function(){if("checkbox"==this.selectionmode){var b=this.getrows();if(b&&this._checkboxcolumn)if(0===b.length)this._checkboxcolumn.checkboxelement.jqxCheckBox({checked:!1});else{b=b.length;this.groupable&&
1258(b=this.dataview.loadedrecords.length);this.virtualmode&&(b=this.source._source.totalrecords);var c=this.selectedrowindexes.length;c===b?this._checkboxcolumn.checkboxelement.jqxCheckBox({checked:!0}):0===c?this._checkboxcolumn.checkboxelement.jqxCheckBox({checked:!1}):this._checkboxcolumn.checkboxelement.jqxCheckBox({checked:null})}}},unselectrow:function(b,c){this._applyrowselection(b,!1,c);!1!==c&&this._updatecheckboxselection()},selectcell:function(b,c){this._applycellselection(b,c,!0)},unselectcell:function(b,
1259c){this._applycellselection(b,c,!1)},clearselection:function(b,c){this._trigger=!1;this.selectedrowindex=-1;this._oldselectedcell=null;if(!1!==c)for(c=0;c<this.selectedrowindexes.length;c++)this._raiseEvent(3,{rowindex:this.selectedrowindexes[c]});this.selectedrowindexes=[];this.selectedcells=[];this.selectedcell=null;"checkbox"!=this.selectionmode||this._checkboxcolumnupdating||this._checkboxcolumn.checkboxelement.jqxCheckBox({checked:!1});for(c=0;c<this.columns.records.length;c++)this.columns.records[c].selected=
1260!1,this.columns.records[c]._applyStyle();!1===b?this._trigger=!0:(this._renderrows(this.virtualsizeinfo),this._trigger=!0,"checkbox"==this.selectionmode&&this._raiseEvent(3,{rowindex:this.selectedrowindexes}))},getselectedrowindex:function(){if(-1==this.selectedrowindex||void 0==this.selectedrowindex)for(;0<this.selectedrowindexes.length;)return this.selectedrowindexes[0];return this.selectedrowindex},getselectedrowindexes:function(){return this.selectedrowindexes},getselectedcell:function(){if(!this.selectedcell)return null;
1261var b=this.selectedcell;b.row=this.selectedcell.rowindex;b.column=this.selectedcell.datafield;b.value=this.getcellvalue(b.row,b.column);return b},getselectedcells:function(){var b=[],c;for(c in this.selectedcells)b[b.length]=this.selectedcells[c];return b},getselection:function(){return{cells:this.getselectedcells(),rows:this.getselectedrowindexes()}},_getcellsforcopypaste:function(){var b=[];if(-1==this.selectionmode.indexOf("cell"))for(var c=this.selectedrowindexes,d=0;d<c.length;d++)for(var e=
1262c[d],f=0;f<this.columns.records.length;f++)"_checkboxcolumn"!==this.columns.records[f].datafield&&b.push({rowindex:e,datafield:this.columns.records[f].datafield});return b},deleteselection:function(){var b=this.getselectedcells();-1==this.selectionmode.indexOf("cell")&&(b=this._getcellsforcopypaste());if(null!=b&&0<b.length){for(var c=0;c<b.length;c++){var d=b[c],e=this.getcolumn(d.datafield),f=this.getcellvalue(d.rowindex,d.datafield);if(e&&""!==f){var g=null;"checkbox"==e.columntype&&(e.threestatecheckbox||
1263(g=!1));this._raiseEvent(17,{rowindex:d.rowindex,datafield:d.datafield,value:f});c==b.length-1?this.setcellvalue(d.rowindex,d.datafield,g,!0):this.setcellvalue(d.rowindex,d.datafield,g,!1);e.displayfield!=e.datafield&&this.setcellvalue(d.rowindex,e.displayfield,g,!0);this._raiseEvent(18,{rowindex:d.rowindex,datafield:d.datafield,oldvalue:f,value:g})}}this.dataview.updateview();this._renderrows(this.virtualsizeinfo)}},copyselection:function(){var b="",c=this;this.clipboardselection={};this.logicalclipboardselection=
1264{};this._clipboardselection=[];var d=c.getselectedcells();-1==this.selectionmode.indexOf("cell")&&(d=this._getcellsforcopypaste());var e=[];if(null!=d&&0<d.length){for(var f=999999999999999,g=-1,h=0;h<d.length;h++){var k=d[h],l=c.getcolumn(k.datafield);if(null!=l&&l.clipboard&&(!l.hidden||this.copytoclipboardhiddencolumns)){-1==e.indexOf(l.text)&&e.push(l.text);var m=c.getcelltext(k.rowindex,l.displayfield),n=this.getrowdisplayindex(k.rowindex);this.clipboardselection[n]||(this.clipboardselection[n]=
1265{});this.clipboardselection[n][l.displayfield]=m;this.logicalclipboardselection[n]||(this.logicalclipboardselection[n]={});this.logicalclipboardselection[n][l.displayfield]=m;l.displayfield!=l.datafield&&(this.logicalclipboardselection[n][l.datafield]=c.getcellvalue(k.rowindex,l.datafield));f=Math.min(f,n);g=Math.max(g,n)}}d=[];for(h=f;h<=g;h++)this.logicalclipboardselection[h]&&(k=a.extend({},this.logicalclipboardselection[h]),d.push(k));this.logicalclipboardselection=d;if(this.copytoclipboardwithheaders){for(d=
12660;d<e.length;d++)0<d&&(b+="\t"),b+=e[d];b+="\r\n"}for(h=f;h<=g;h++){var r=0;this._clipboardselection[this._clipboardselection.length]=[];void 0!=this.clipboardselection[h]&&(a.each(this.clipboardselection[h],function(t,u){0<r&&(b+="\t");t=u;null==u&&(t="");c._clipboardselection[c._clipboardselection.length-1][r]=t;r++;b+=t}),h<g&&(b+="\r\n"))}}return this.clipboardselectedtext=b},pasteselection:function(){var b=this.getselectedcells();this._oldselectedcell=null;-1==this.selectionmode.indexOf("cell")&&
1267(b=this._getcellsforcopypaste());if(null!=b&&0<b.length){var c=this.getrowdisplayindex(b[0].rowindex),d=this._getcolumnindex(b[0].datafield);this.selectedrowindexes=[];this.selectedcells=[];var e=0,f=[],g=[];this.copytoclipboardwithheaders&&this._clipboardselection.splice(0,1);this._clipboardselection||(this._clipboardselection=[]);for(var h=0;h<this._clipboardselection.length;h++){e+=this._clipboardselection[h].length;f[h]=[];for(var k=0;k<this._clipboardselection[h].length;k++){var l=this._clipboardselection[h][k];
1268f[h].push(l)}}if(e<b.length){c=[];for(h=0;h<b.length;h++)e=b[h],c[e.rowindex]||(c[e.rowindex]=[]),c[e.rowindex].push(e);var m=d=0;for(h=0;h<c.length;h++)if(c[h]){for(k=0;k<c[h].length;k++){e=c[h][k];b=e.rowindex;var n=this.getcolumn(e.datafield);if("_checkboxcolumn"!==n.datafield&&!n.hidden){l="";f[d]&&void 0==f[d][m]&&(m=0);l=""+f[d][m];m++;if(n.cellsformat&&(-1!=n.cellsformat.indexOf("p")||-1!=n.cellsformat.indexOf("c")||-1!=n.cellsformat.indexOf("n")||-1!=n.cellsformat.indexOf("f"))){l.indexOf&&
1269-1<l.indexOf(this.gridlocalization.currencysymbol)&&(l=l.replace(this.gridlocalization.currencysymbol,""));var r=function(B,y,A){var aa=B;if(y==A)return B;for(B=aa.indexOf(y);-1!=B;)aa=aa.replace(y,A),B=aa.indexOf(y);return aa};l=r(l,this.gridlocalization.thousandsseparator,"");l=l.replace(this.gridlocalization.decimalseparator,".");-1<l.indexOf(this.gridlocalization.percentsymbol)&&(l=l.replace(this.gridlocalization.percentsymbol,""));r="";for(var t=0;t<l.length;t++){var u=l.substring(t,t+1);"-"===
1270u&&(r+="-");"."===u&&(r+=".");null!=u.match(/^[0-9]+$/)&&(r+=u)}l=r;l=l.replace(/ /g,"");l=new Number(l);isNaN(l)&&(l="")}this._raiseEvent(17,{rowindex:b,datafield:e.datafield,value:l});var x=this.getrowdata(b);g.push({oldvalue:x[e.datafield],value:l,datafield:e.datafield,row:b});this.pushToHistory=!0;this.setcellvalue(b,n.displayfield,l,!1);this.pushToHistory=!1;n.displayfield!=n.datafield&&this.logicalclipboardselection&&this.logicalclipboardselection[b]&&(r=this.logicalclipboardselection[b][n.datafield],
1271void 0!=r&&this.setcellvalue(b,n.datafield,r,!1));this._raiseEvent(18,{rowindex:b,datafield:e.datafield,oldvalue:this.getcellvalue(e.rowindex,e.datafield),value:l});this._applycellselection(b,e.datafield,!0,!1)}}d++;m=0;f[d]||(d=0)}}else{if(!this._clipboardselection)return;for(x=0;x<this._clipboardselection.length;x++)for(f=0;f<this._clipboardselection[x].length;f++)if((n=this.getcolumnat(d+f))&&"_checkboxcolumn"!==n.datafield&&!n.hidden&&(b=this.getrowboundindex(c+x),e=this.getcell(b,n.datafield),
1272l=null,l=this._clipboardselection[x][f],null!=l)){if(n.cellsformat&&(-1!=n.cellsformat.indexOf("p")||-1!=n.cellsformat.indexOf("c")||-1!=n.cellsformat.indexOf("n")||-1!=n.cellsformat.indexOf("f"))){-1<l.indexOf(this.gridlocalization.currencysymbol)&&(l=l.replace(this.gridlocalization.currencysymbol,""));r=function(B,y,A){var aa=B;if(y==A)return B;for(B=aa.indexOf(y);-1!=B;)aa=aa.replace(y,A),B=aa.indexOf(y);return aa};l=r(l,this.gridlocalization.thousandsseparator,"");l=l.replace(this.gridlocalization.decimalseparator,
1273".");-1<l.indexOf(this.gridlocalization.percentsymbol)&&(l=l.replace(this.gridlocalization.percentsymbol,""));r="";for(t=0;t<l.length;t++)u=l.substring(t,t+1),"-"===u&&(r+="-"),"."===u&&(r+="."),null!=u.match(/^[0-9]+$/)&&(r+=u);l=r;l=l.replace(/ /g,"");l=new Number(l);isNaN(l)&&(l="")}this._raiseEvent(17,{rowindex:b,datafield:e.datafield,value:l});h=this.getrowdata(b);g.push({oldvalue:h[e.datafield],value:l,datafield:e.datafield,row:b});this.pushToHistory=!0;this.setcellvalue(b,n.displayfield,l,
1274!1);this.pushToHistory=!1;n.displayfield!=n.datafield&&this.logicalclipboardselection&&(r=this.logicalclipboardselection[x][n.datafield],void 0!=r&&this.setcellvalue(b,n.datafield,r,!1));this._raiseEvent(18,{rowindex:b,datafield:e.datafield,oldvalue:this.getcellvalue(e.rowindex,e.datafield),value:l});this._applycellselection(b,e.datafield,!0,!1)}}"checkbox"==this.selectionmode&&this._updatecheckboxselection();this.dataview.updateview();this._renderrows(this.virtualsizeinfo)}this._undoRedo.push({action:"paste",
1275data:g});
1275this._undoRedoIndex=-1;this.clipboardend&&this.clipboardend("paste")},_applyrowselection:function(b,c,d,e,f){if(null==b)return!1;f=this.selectedrowindex;"singlerow"==this.selectionmode&&(c?this._raiseEvent(2,{rowindex:b,row:this.getrowdata(b)}):this._raiseEvent(3,{rowindex:b,row:this.getrowdata(b)}),this._raiseEvent(3,{rowindex:f}),this.selectedrowindexes=[],this.selectedcells=[]);1==e&&(this.selectedrowindexes=[]);0<this.dataview.filters.length&&((e=this.getrowdata(b))&&void 0!==e.dataindex?
1276b=e.dataindex:e&&void 0===e.dataindex&&void 0!=e.uid&&(b=this.getrowboundindexbyid(e.uid)));e=this.selectedrowindexes.indexOf(b);if(c)this.selectedrowindex=b,-1==e?(this.selectedrowindexes.push(b),"singlerow"!=this.selectionmode&&this._raiseEvent(2,{rowindex:b,row:this.getrowdata(b)})):"multiplerows"==this.selectionmode&&(this.selectedrowindexes.splice(e,1),this._raiseEvent(3,{rowindex:this.selectedrowindex,row:this.getrowdata(b)}),this.selectedrowindex=0<this.selectedrowindexes.length?this.selectedrowindexes[this.selectedrowindexes.length-
12771]:-1);else if(0<=e||"singlerow"==this.selectionmode||"multiplerowsextended"==this.selectionmode||"multiplerowsadvanced"==this.selectionmode)c=this.selectedrowindexes[e],this.selectedrowindexes.splice(e,1),this._raiseEvent(3,{rowindex:c,row:this.getrowdata(b)}),this.selectedrowindex=-1;(void 0==d||d)&&this._rendervisualrows();return!0},_applycellselection:function(b,c,d,e,f){if(null==b||null==c)return!1;this._autofill&&(this._autofill.remove(),a(document).off("pointermove.autofill"),a(document).off("pointerup.autofill"),
1278this._autofill=null);if("singlecell"==this.selectionmode){var g=this.selectedcell;null!=g&&this._raiseEvent(16,{rowindex:g.rowindex,datafield:g.datafield});this.selectedcells=[]}if("multiplecellsextended"==this.selectionmode||"multiplecellsadvanced"==this.selectionmode)g=this.selectedcell,null!=g&&this._raiseEvent(16,{rowindex:g.rowindex,datafield:g.datafield});g=b+"_"+c;if(0<this.dataview.filters.length){var h=this.getrowdata(b);h&&void 0!==h.dataindex?(b=h.dataindex,g=b+"_"+c):h&&void 0===h.dataindex&&
1279h.uid&&(b=this.getrowboundindexbyid(h.uid),g=b+"_"+c)}b={rowindex:b,datafield:c};if(d)if(d=this.selectedcell,this.selectedcell=b,!this.selectedcells[g])this.selectedcells[g]=b,this.selectedcells.length++,g=!0,d&&d.datafield===b.datafield&&b.rowindex===d.rowindex&&(g=!1),g&&!1!==f&&this._raiseEvent(15,b);else{if("multiplecells"==this.selectionmode||"multiplecellsextended"==this.selectionmode||"multiplecellsadvanced"==this.selectionmode)delete this.selectedcells[g],0<this.selectedcells.length&&this.selectedcells.length--,
1280!1!==f&&this._raiseEvent(16,b)}else delete this.selectedcells[g],0<this.selectedcells.length&&this.selectedcells.length--,!1!==f&&this._raiseEvent(16,b);(void 0==e||e)&&this._rendervisualrows();return!0},_getcellindex:function(b){var c=-1;a.each(this.selectedcells,function(){c++;if(this[b])return!1});return c},_clearhoverstyle:function(){if(void 0!=this.hoveredrow&&-1!=this.hoveredrow&&!this.vScrollInstance.isScrolling()&&!this.hScrollInstance.isScrolling()){var b=this.table.find(".jqx-grid-cell-hover");
12810<b.length&&(b.removeClass(this.toTP("jqx-grid-cell-hover")),b.removeClass(this.toTP("jqx-fill-state-hover")));for(var c=0;c<b.length;c++){var d=b[c].getAttribute("columnindex");d&&(d=this.columns.records[parseInt(d)])&&d._applyCellStyle(b[c])}this.hoveredrow=-1}},_clearselectstyle:function(){for(var b=this.table[0].rows.length,c=this.table[0].rows,d=this.toTP("jqx-grid-cell-selected"),e=this.toTP("jqx-fill-state-pressed"),f=this.toTP("jqx-grid-cell-hover"),g=this.toTP("jqx-fill-state-hover"),h=0;h<
1282b;h++){var k=c[h],l=k.cells.length;k=k.cells;for(var m=0;m<l;m++){var n=k[m],r=a(n);-1!=n.className.indexOf("jqx-grid-cell-selected")&&(r.removeClass(d),r.removeClass(e));-1!=n.className.indexOf("jqx-grid-cell-hover")&&(r.removeClass(f),r.removeClass(g));(r=n.getAttribute("columnindex"))&&(r=this.columns.records[parseInt(r)])&&r._applyCellStyle(n)}}},_selectpath:function(b,c){var d=this._lastClickedCell?Math.min(this._lastClickedCell.row,b):0,e=this._lastClickedCell?Math.max(this._lastClickedCell.row,
1283b):0;if(d<=e){b=this._getcolumnindex(this._lastClickedCell.column||this._lastClickedCell.datafield);var f=this._getcolumnindex(c);c=Math.min(b,f);f=Math.max(b,f);this.selectedcells=[];for(var g=this.dataview.loadedrecords;d<=e;d++)for(var h=c;h<=f;h++)b=g[d],this._applycellselection(this.getboundindex(b),this._getcolumnat(h).datafield,!0,
1283!1),this.getboundindex(b),this._getcolumnat(h);this._rendervisualrows()}},_selectrowpath:function(b){if("multiplerowsextended"==this.selectionmode){var c=this._lastClickedCell?
1284Math.min(this._lastClickedCell.row,b):0;b=this._lastClickedCell?Math.max(this._lastClickedCell.row,b):0;if(c<=b){for(this.selectedrowindexes=[];c<=b;c++){var d=this.getrowboundindex(c);this._applyrowselection(d,!0,!1)}this._rendervisualrows()}}},_selectrowwithmouse:function(b,c,d,e,f,g){var h=c.row;if(void 0!=h&&(c=c.index,void 0!=this.hittestinfo[c])){for(var k=0;k<this.columns.records.length;k++){var l=this.columns.records[k];l.selected=!1;l.element&&l.element.removeAttribute("selected");l._applyStyle()}k=
1285this.hittestinfo[c].visualrow;if(!this.hittestinfo[c].details&&!h.group){if("multiplerows"==this.selectionmode||"multiplecells"==this.selectionmode||"checkbox"==this.selectionmode||-1!=this.selectionmode.indexOf("multiple")&&(1==g||1==f)){l=this.getboundindex(h);if(0<this.dataview.filters.length){var m=this.getrowdata(l);m&&(l=m.dataindex,void 0==l&&(l=this.getboundindex(h)))}l=-1!=d.indexOf(l);d=this.getboundindex(h)+"_"+e;if(-1!=this.selectionmode.indexOf("cell"))f=void 0!=this.selectedcells[d],
1286void 0!=this.selectedcells[d]&&f?this._selectcellwithstyle(b,!1,c,e,k):this._selectcellwithstyle(b,!0,c,e,k),g&&void 0==this._lastClickedCell&&(b=this.getselectedcells())&&0<b.length&&(this._lastClickedCell={row:b[0].rowindex,column:b[0].datafield}),g&&this._lastClickedCell&&(this._selectpath(h.visibleindex,e),this.mousecaptured=!1,"visible"==this.selectionarea.css("visibility")&&this.selectionarea.css("visibility","hidden"));else if(l?f?this._applyrowselection(this.getboundindex(h),!1):this._selectrowwithstyle(b,
1287k,!1,e):this._selectrowwithstyle(b,k,!0,e),g&&void 0==this._lastClickedCell&&(b=this.getselectedrowindexes())&&0<b.length&&(this._lastClickedCell={row:b[0],column:e}),g&&this._lastClickedCell){this.selectedrowindexes=[];b=this._lastClickedCell?Math.max(this._lastClickedCell.row,h.visibleindex):0;f=this.dataview.loadedrecords;for(c=this._lastClickedCell?Math.min(this._lastClickedCell.row,h.visibleindex):0;c<=b;c++)(h=f[c])&&this._applyrowselection(this.getboundindex(h),!0,!1,!1);this._rendervisualrows()}}else this._clearselectstyle(),
1288this._selectrowwithstyle(b,k,!0,e),-1!=this.selectionmode.indexOf("cell")&&this._selectcellwithstyle(b,!0,c,e,k);g||(this._lastClickedCell={row:h.visibleindex,column:e})}}},_selectcellwithstyle:function(b,c,d,e,f){b=a(f.cells[b._getcolumnindex(e)]);b.removeClass(this.toTP("jqx-grid-cell-hover"));b.removeClass(this.toTP("jqx-fill-state-hover"));c?(b.addClass(this.toTP("jqx-grid-cell-selected")),b.addClass(this.toTP("jqx-fill-state-pressed"))):(b.removeClass(this.toTP("jqx-grid-cell-selected")),b.removeClass(this.toTP("jqx-fill-state-pressed")));
1289this.getcolumn(e)._applyCellStyle(b)},_selectrowwithstyle:function(b,c,d,e){var f=c.cells.length,g=0;
1289b.rowdetails&&b.showrowdetailscolumn?this.rtl?f=f-1-this.groups.length:g=1+this.groups.length:this.groupable&&(this.rtl?f-=this.groups.length:g=this.groups.length);for(;g<f;g++){var h=c.cells[g];d?(a(h).removeClass(this.toTP("jqx-grid-cell-hover")),a(h).removeClass(this.toTP("jqx-fill-state-hover")),-1==b.selectionmode.indexOf("cell")&&(a(h).addClass(this.toTP("jqx-grid-cell-selected")),a(h).addClass(this.toTP("jqx-fill-state-pressed")))):
1290(a(h).removeClass(this.toTP("jqx-grid-cell-hover")),a(h).removeClass(this.toTP("jqx-grid-cell-selected")),a(h).removeClass(this.toTP("jqx-fill-state-hover")),a(h).removeClass(this.toTP("jqx-fill-state-pressed")));(e=h.getAttribute("columnindex"))&&(e=this.columns.records[parseInt(e)])&&e._applyCellStyle(h)}},_handlemousemoveselection:function(b,c,d){if(c.hScrollInstance.isScrolling()||c.vScrollInstance.isScrolling())return!1;if(("multiplerowsextended"==c.selectionmode||"multiplecellsextended"==c.selectionmode||
1291"multiplecellsadvanced"==c.selectionmode)&&c.mousecaptured){if(c.multipleselectionbegins&&!1===c.multipleselectionbegins(b))return!0;var e=this.showheader?this.columnsheader.height()+2:0,f=this._groupsheader()?this.groupsheader.height():0,g=this.showtoolbar?this.toolbar.height():0;f=f+g+(this.showfilterbar?this.toolbarheight:0);g=this.host.coord();if(this.hasTransform){g=a.jqx.utilities.getOffset(this.host);var h=this._getBodyOffset();g.left-=h.left;g.top-=h.top}"0px"===this.host.css("border-top-width")&&
1292(f-=2);var k=b.pageX;h=b.pageY-f;b._pageX&&(k=b._pageX,h=b._pageY-f);if(3<Math.abs(this.mousecaptureposition.left-k)||3<Math.abs(this.mousecaptureposition.top-h)||c.autofill){parseInt(this.columnsheader.coord().top);this.hasTransform&&a.jqx.utilities.getOffset(this.columnsheader);k<g.left&&(k=g.left);k>g.left+this.host.width()&&(k=g.left+this.host.width());e=g.top+e;h<e&&(h=e+5);var l=parseInt(Math.min(c.mousecaptureposition.left,k));e=-5+parseInt(Math.min(c.mousecaptureposition.top,h));var m=parseFloat(Math.abs(c.mousecaptureposition.left-
1293k)),n=parseInt(Math.abs(c.mousecaptureposition.top-h));l-=g.left;e-=g.top;this.selectionarea.css("visibility","visible");if("multiplecellsadvanced"==c.selectionmode){k=l;var r=k+m,t=c.hScrollInstance;h=t.value;this.rtl&&"hidden"!=this.hScrollBar.css("visibility")&&(h=t.max-t.value);var u=c.table[0].rows[0],x=0,B=t=c.mousecaptureposition.clickedcell;x=!1;var y=0,A=u.cells.length;c.mousecaptureposition.left<=b.pageX&&(y=t);for(var aa=!1;y<A;y++){var ha=parseFloat(a(this.columnsrow[0].cells[y]).css("left")),
1294z=ha-h;if(c.columns.records[y].pinned&&!c.columns.records[y].hidden)if(y==t&&(aa=!0),ha+=a(this.columnsrow[0].cells[y]).width(),c.mousecaptureposition.left>b.pageX){if(ha>=k&&k>=z){B=y;x=!0;break}}else{if(ha>=r&&r>=z){B=y;x=!0;break}}else{if(aa){x=!0;B--;break}ha=this._getcolumnat(y);if(!(null!=ha&&ha.hidden||c.groupable&&0<c.groups.length&&y<c.groups.length))if(ha=z+a(this.columnsrow[0].cells[y]).width(),c.mousecaptureposition.left>b.pageX){if(ha>=k&&k>=z){B=y;x=!0;break}}else if(ha>=r&&r>=z){B=
1295y;x=!0;break}}}if(!x)if(c.mousecaptureposition.left>b.pageX)a.each(this.columns.records,function(v,K){if(c.groupable&&0<c.groups.length&&v<c.groups.length)return!0;if(!this.pinned&&!this.hidden)return B=v,!1});else if(!c.groupable||c.groupable&&0< !c.groups.length)B=u.cells.length-1;y=t;t=Math.min(t,B);B=Math.max(y,B);e=e+5+f;c.table[0].rows.indexOf(c.mousecaptureposition.clickedrow);r=0;k=b=-1;for(y=u=0;y<c.table[0].rows.length;y++){A=a(c.table[0].rows[y]);0==y&&(u=A.coord().top);z=A.height();ha=
1296u-g.top;if(-1==b&&ha+z>=e){x=!1;for(var V=0;V<c.groups.length;V++){var ba=A[0].cells[V].className;if(-1!=ba.indexOf("jqx-grid-group-collapse")||-1!=ba.indexOf("jqx-grid-group-expand")){x=!0;break}}if(x)continue;b=y}u+=z;if(c.groupable&&0<c.groups.length){x=!1;for(V=0;V<c.groups.length;V++)if(ba=A[0].cells[V].className,-1!=ba.indexOf("jqx-grid-group-collapse")||-1!=ba.indexOf("jqx-grid-group-expand")){x=!0;break}if(x)continue;x=0;for(V=c.groups.length;V<A[0].cells.length;V++)""==a(A[0].cells[V]).html()&&
1297x++;if(x==A[0].cells.length-c.groups.length)continue}-1!=b&&(r+=z);if(ha+z>e+n){k=y;break}}if(-1!=b&&(e=a(c.table[0].rows[b]).coord().top-g.top-f-2,f=0,this.filterable&&this.showfilterrow&&(f=this.filterrowheight),0>parseFloat(c.table[0].style.top)&&e<this.rowsheight+f&&(e-=parseFloat(c.table[0].style.top),r+=parseFloat(c.table[0].style.top)),n=r,g=a(this.columnsrow[0].cells[t]),f=a(this.columnsrow[0].cells[B]),l=parseFloat(g.css("left")),m=parseFloat(f.css("left"))-parseFloat(l)+f.width()-2,l-=h,
1298aa&&(l+=h),c.editcell&&c.editable&&c.endcelledit&&(t!=B||b!=k))){if(0==c.editcell.validated)return;c.endcelledit(c.editcell.row,c.editcell.column,!0,!0)}}this.selectionarea.width(m);this.selectionarea.css("left",l);null!==d&&(this.selectionarea.css("top",e),this.selectionarea.height(n))}}},_handlemouseupselection:function(b,c,d){if(this.selectionarea){if("visible"!=this.selectionarea[0].style.visibility){c._handlemousemoveselection(b,c);if(!1!==d)if(c.__firstcell){if(d=c.getselectedcell())c.__firstcell.index=
1299c.columns.records.indexOf(c.getcolumn(d.datafield)),c.__firstcell.row=d.row,c.__firstcell.rowindex=d.rowindex,c._handleAutofill(b,c)}else c.__firstcell=c.getselectedcell(),c.__firstcell&&(c.__firstcell.index=c.columns.records.indexOf(c.getcolumn(c.__firstcell.datafield)),c._handleAutofill(b,c));c.mousecaptured=!1;c.selectionarea[0].style.visibility="hidden";return!0}if(c.mousecaptured&&("multiplerowsextended"==c.selectionmode||"multiplerowsadvanced"==c.selectionmode||"multiplecellsextended"==c.selectionmode||
1300"multiplecellsadvanced"==c.selectionmode)){c.mousecaptured=!1;if("visible"==this.selectionarea.css("visibility")){this.selectionarea.css("visibility","hidden");var e=this.showheader?this.columnsheader.height()+2:0,f=this._groupsheader()?this.groupsheader.height():0;"0px"===this.host.css("border-top-width")&&(f-=2);var g=this.showtoolbar?this.toolbar.height():0;f=f+g+(this.showfilterbar?this.toolbarheight:0);var h=this.selectionarea.coord(),k=this.host.coord();this.hasTransform&&(k=a.jqx.utilities.getOffset(this.host),
1301h=a.jqx.utilities.getOffset(this.selectionarea));"0px"===this.host.css("border-top-width")&&(f-=2);g=h.left-k.left;var l=e=h.top-e-k.top-f;f=g+this.selectionarea.width();k=[];h=[];if("multiplerowsextended"==c.selectionmode){for(;e<l+this.selectionarea.height();){var m=this._hittestrow(g,e),n=m.row,r=m.index;-1==r||h[r]||(h[r]=!0,k[k.length]=m);e+=20}l=0;a.each(k,function(){var ha=this.row;"none"!=c.selectionmode&&c._selectrowwithmouse&&(b.ctrlKey||b.metaKey?c._applyrowselection(c.getboundindex(ha),
1302!0,!1,!1):0==l?c._applyrowselection(c.getboundindex(ha),!0,!1,!0):c._applyrowselection(c.getboundindex(ha),!0,!1,!1),l++)})}else{k=m=null;"multiplecellsadvanced"==c.selectionmode&&(e+=2);var t=c.hScrollInstance,u=t.value;this.rtl&&("hidden"!=this.hScrollBar.css("visibility")&&(u=t.max-t.value),"hidden"!=this.vScrollBar[0].style.visibility&&(u-=this.scrollbarsize+4));t=c.table[0].rows[0];var x=c.selectionarea.height();!b.ctrlKey&&!b.metaKey&&0<x&&(c.selectedcells=[]);parseInt(this.vScrollInstance.value);
1303m=parseInt(this.hScrollInstance.value);this._gettableheight();n=void 0!=this._hostwidth?this._hostwidth:this.host.width();r=this.groupable&&0<this.groups.length?this.groups.length:0;n=this._getvisualcolumnsindexes(m,n,r,this.columns.records.length-r,this.groupable&&0<this.groups.length,!0,!0);var B=n.start,y=n.end;for(this.__firstcell=null;e<l+x;){if(m=c._hittestrow(g,e))if(n=m.row,r=m.index,-1!=r&&!h[r])if(h[r]=!0,this.enableoptimization)for(A=B;A<y;A++){if(m=parseFloat(c.columnsrow[0].cells[A].style.left)-
1304u,aa=m+c.columns.records[A].width,g>=m&&g<=aa||f>=m&&f<=aa||m>=g&&m<=f)c._applycellselection(c.getboundindex(n),c._getcolumnat(A).datafield,!0,!1),m={x:g,y:e,rowindex:r,row:c.getboundindex(n),index:A,datafield:c._getcolumnat(A).datafield},c.__lastcell=m,k||(k=m,c.__firstcell=k)}else for(var A=0;A<t.cells.length;A++){m=parseFloat(a(c.columnsrow[0].cells[A]).css("left"))-u;var aa=m+a(c.columnsrow[0].cells[A]).width();if(g>=m&&g<=aa||f>=m&&f<=aa||m>=g&&m<=f)c._applycellselection(c.getboundindex(n),c._getcolumnat(A).datafield,
1305!0,!1),m={x:g,y:e,rowindex:r,row:c.getboundindex(n),index:A,datafield:c._getcolumnat(A).datafield},c.__lastcell=m,k||(k=m,c.__firstcell=k)}e+=5}}c.autosavestate&&c.savestate&&c.savestate()}c._renderrows(c.virtualsizeinfo);!1!==d&&c._handleAutofill(b,c)}}},_handleAutofill:function(b,c){if(this.autofill){var d=this;this.showheader&&this.columnsheader.height();this._groupsheader()&&this.groupsheader.height();this.host.css("border-top-width");this.showtoolbar&&this.toolbar.height();var e=this.selectionarea.coord(),
1306f=this.host.coord();this.hasTransform&&(f=a.jqx.utilities.getOffset(this.host),e=a.jqx.utilities.getOffset(this.selectionarea));this.host.css("border-top-width");f=e.left-f.left+this.selectionarea.width();var g=d.__firstcell;this.rtl&&this.hScrollBar.css("visibility");var h=c.selectionarea.height(),k=parseInt(b.pageX),l=parseInt(b.pageY);d=c;d._autofill&&d._autofill.remove();g&&!d.getcolumn(g.datafield).autofill||!d.autofill||(d._autofill=document.createElement("div"),d._autofill.style.width="6px",
1307d._autofill.style.height="6px",d._autofill.style.position="absolute",d._autofill.style.top=e.top-d.host.offset().top+h+1+"px",d._autofill.style.left=f+2+"px",d._autofill.style.cursor="crosshair",d._autofill.style.paddingLeft="0px",d._autofill.style.paddingTop="0px",d._autofill.style.paddingRight="0px",d._autofill.style.paddingBottom="0px",d._autofill.style.borderTopLeftRadius="0px",d._autofill.style.borderTopRightRadius="0px",d._autofill.style.borderBottomLeftRadius="0px",d._autofill.style.borderBottomRightRadius=
1308"0px",d._autofill.style.background="transparent",a(d._autofill).addClass(d.toThemeProperty("jqx-widget")),a(d._autofill).addClass(d.toThemeProperty("jqx-button")),a(d._autofill).addClass(d.toThemeProperty("primary")),a(d._autofill).addClass(d.toThemeProperty("jqx-fill-state-pressed")),d._autofill.onpointerdown=function(m){d._handlemouseupselection(m,d,!1);m=m.originalEvent?m.originalEvent:m;d._autofillDragStart=!0;d.mousecaptured=!0;var n=d.showheader?d.columnsheader.height()+2:0,r=d._groupsheader()?
1309d.groupsheader.height():0;r=r+(d.showtoolbar?d.toolbarheight:0)+(d.showfilterbar?d.toolbarheight:0);var t=d.host.coord(),u=k-t.left,x=l-n-t.top-r;if(d.pageable&&!d.autoheight&&d.gotopage&&(n=d.pager.coord().top-t.top-r-n,x>n))return;(u=d._hittestrow(u,x))&&!u.details&&(u=d.table[0].rows[g.rowindex],x=a(c.columnsrow[0].cells[g.index]).coord().left,n=a(u).coord().top+1,d.mousecaptured=!0,d.mousecaptureposition={x,y:n,left:m.pageX,top:m.pageY,clickedrow:u},d.copyselection(),m.stopPropagation(),m.preventDefault())},
1310a(document).off("pointermove.autofill"),a(document).off("pointerup.autofill"),a(document).on("pointermove.autofill",function(m){d._autofillDragStart&&(m=m.originalEvent?m.originalEvent:m,d.mou
1310secaptureposition.position?"y"===d.mousecaptureposition.position?(m._pageX=d.mousecaptureposition.x,m._pageY=m.pageY,d.mousecaptureposition.top=d.mousecaptureposition.y,d._handlemousemoveselection(m,d)):(m._pageX=m.pageX,m._pageY=d.mousecaptureposition.y,d.mousecaptureposition.clickedcell=g.index,d.mousecaptureposition.left=
1311d.mousecaptureposition.x,d._handlemousemoveselection(m,d,null)):5<=Math.abs(d.mousecaptureposition.left-m.pageX)?d.mousecaptureposition.position="x":Math.abs(d.mousecaptureposition.top-m.pageY)&&(d.mousecaptureposition.position="y"))}),a(document).on("pointerup.autofill",function(m){m=m.originalEvent?m.originalEvent:m;d._autofillDragStart?(d._handlemouseupselection(m,d),d._autofillDragStart=!1,d.mousecaptureposition=null,d.mousecaptured=!1,d.pasteselection(),d._handlemouseupselection(m,d)):(d._autofill&&
1312d._autofill.remove(),d.clearselection())}),d.wrapper[0].appendChild(d._autofill))}},selectprevcell:function(b,c){c=this._getcolumnindex(c);c=this._getprevvisiblecolumn(c);null!=c&&(this.clearselection(),this.selectcell(b,c.datafield))},selectnextcell:function(b,c){c=this._getcolumnindex(c);c=this._getnextvisiblecolumn(c);null!=c&&(this.clearselection(),this.selectcell(b,c.datafield))},_getfirstvisiblecolumn:function(){for(var b=this.columns.records.length,c=0;c<b;c++){var d=this.columns.records[c];
1313if(!d.hidden&&null!=d.datafield)return d}return null},_getlastvisiblecolumn:function(){for(var b=this.columns.records.length-1;0<=b;b--){var c=this.columns.records[b];if(!c.hidden&&null!=c.datafield)return c}return null},_handlekeydown:function(b,c){if(c.disabled)return!1;var d=b.charCode?b.charCode:b.keyCode?b.keyCode:0;if(32===d&&(b.metaKey||b.ctrlKey)&&"multiplecellsadvanced"==c.selectionmode){var e=this.getselectedcell();if(b.shiftKey){this.clearselection();this.selectallrows();if(30>this.columns.records.length)for(e=
13140;e<this.columns.records.length;e++){var f=this.columns.records[e];f.selectable&&f.toggleSelection(f,b,!0)}this._renderrows(this.virtualsizeinfo);return}e&&(f=this.getcolumn(e.datafield),f.selectable&&(this.clearselection(),f.toggleSelection(f,b,!0),this._renderrows(this.virtualsizeinfo)))}if(c.editcell&&"multiplecellsadvanced"!=c.selectionmode)return!0;if(c.editcell&&"multiplecellsadvanced"==c.selectionmode)if(33<=d&&40>=d){if(b.altKey||void 0!=c._cancelkeydown&&0!=c._cancelkeydown)return c._cancelkeydown=
1315!1,!0;if("selectedrow"!==c.editmode){if(c.endcelledit(c.editcell.row,c.editcell.column,!1,!0),c._cancelkeydown=!1,c.editcell&&!c.editcell.validated)return c._rendervisualrows(),c.endcelledit(c.editcell.row,c.editcell.column,!1,!0),!1}else return!0}else return!0;if("none"==c.selectionmode||c.showfilterrow&&c.filterable&&this.filterrow&&a(b.target).ischildof(c.filterrow)||c.showeverpresentrow&&(c.addnewrowtop&&a(b.target).ischildof(c.addnewrowtop)||c.addnewrowbottom&&a(b.target).ischildof(c.addnewrowbottom))||
1316b.target.className&&0<=b.target.className.indexOf("jqx-grid-widget")||c.pageable&&a(b.target).ischildof(this.pager)||this.showtoolbar&&a(b.target).ischildof(this.toolbar)||this.showfilterbar&&a(b.target).ischildof(this.filterbar)||this.showstatusbar&&a(b.target).ischildof(this.statusbar))return!0;var g=!1;if(b.altKey)return!0;if((b.ctrlKey||b.metaKey)&&this.clipboard){f=String.fromCharCode(d).toLowerCase();if("z"===f&&this._undoRedo){-1===this._undoRedoIndex&&(this._undoRedoIndex=this._undoRedo.length-
13171);var h=this._undoRedo[this._undoRedoIndex];if(h)if("setcellvalue"===h.action)this.setcellvalue(h.data.row,h.data.datafield,h.data.oldvalue),this.clearselection(),this.selectcell(h.data.row,h.data.datafield),this.ensurecellvisible(h.data.row,h.data.datafield);else if("paste"===h.action){this.clearselection();if(h.data)for(e=0;e<h.data.length;e++){var k=h.data[e];this.setcellvalue(k.row,k.datafield,k.oldvalue);this._applycellselection(k.row,k.datafield,!0,!1);0===e&&this.ensurecellvisible(k.row,k.datafield)}this._rendervisualrows()}0<
1318this._undoRedoIndex&&this._undoRedoIndex--}if("y"===f&&this._undoRedo){-1===this._undoRedoIndex&&(this._undoRedoIndex=this._undoRedo.length-1);
1318if(h=this._undoRedo[this._undoRedoIndex])if("setcellvalue"===h.action)this.setcellvalue(h.data.row,h.data.datafield,h.data.value),this.clearselection(),this.selectcell(h.data.row,h.data.datafield),this.ensurecellvisible(h.data.row,h.data.datafield);else if("paste"===h.action){this.clearselection();for(e=0;e<h.data.length;e++)k=h.data[e],this.setcellvalue(k.row,
1319k.datafield,k.value),this._applycellselection(k.row,k.datafield,!0,!1),0===e&&this.ensurecellvisible(k.row,k.datafield);this._rendervisualrows()}this._undoRedoIndex<this._undoRedo.length-1&&this._undoRedoIndex++}"d"===f&&(this.copyselection(),this._clipboardselection=[this._clipboardselection[0]],this.pasteselection(),b.preventDefault(),b.stopPropagation());if(this.clipboardbegin&&(e=null,"c"==f?e=this.clipboardbegin("copy",this.copyselection()):"x"==f?e=this.clipboardbegin("cut",this.copyselection()):
1320"v"==f&&(e=this.clipboardbegin("paste")),!1===e))return!1;if("c"==f||"x"==f){e=this.copyselection();"c"==f&&this.clipboardend&&this.clipboardend("copy");"x"==f&&this.clipboardend&&this.clipboardend("cut");if(window.clipboardData)window.clipboardData.setData("Text",e);else{var l=a('<textarea style="position: absolute; left: -1000px; top: -1000px;"/>');l.val(e);a("body").append(l);l.select();setTimeout(function(){document.designMode="off";l.select();l.remove();c.focus()},100)}if("c"==f&&a.jqx.browser.msie)return!1;
1321if("c"==f)return!0}else if("v"==f){if(document.activeElement&&"INPUT"===document.activeElement.nodeName)return!0;var m=a('<textarea style="position: absolute; left: -1000px; top: -1000px;"/>');a("body").append(m);m.select();var n=this;setTimeout(function(){n._clipboardselection=[];var V=m.val();0==V.length&&window.clipboardData&&(m.val(window.clipboardData.getData("Text")),V=m.val());V=V.split("\n");for(var ba=0;ba<V.length;ba++)if(0<V[ba].split("\t").length){var v=V[ba].split("\t");(1!=v.length||
1322ba!=V.length-1||""!=v[0])&&0<v.length&&n._clipboardselection.push(v)}n.pasteselection();m.remove();n.focus()},100);return!0}if("x"==f)return this.deleteselection(),this.host.focus(),!1}f=Math.round(c._gettableheight());var r=Math.round(f/c.rowsheight),t=c.getdatainformation();switch(c.selectionmode){case "singlecell":case "multiplecells":case "multiplecellsextended":case "multiplecellsadvanced":e=c.getselectedcell();null===e&&c.selectcell(0,c.columns.records[0].displayfield);if(null!=e){f=this.getrowvisibleindex(e.rowindex);
1323var u=e.datafield,x=c._getcolumnindex(u),B=function(V,ba,v,K){var C=function(da,ja){var ea=c.dataview.loadedrecords[da];if(c.groupable&&0<c.groups.length){var ra=da;"up"==K&&ra++;"down"==K&&ra--;ea=c.getdisplayrows()[ra];for(var za=1,na=!0;na&&300>za;){na=!1;"down"==K?ea=c.getdisplayrows()[ra+za]:"up"==K&&(ea=c.getdisplayrows()[ra-za]);if(!ea)break;ea&&ea.group&&(na=!0);ea&&ea.totalsrow&&(na=!0);for(var qa=ea.parentItem;qa;){var Ba;if(Ba=qa)Ba=qa.group?c.expandedgroups[qa.uniqueid]?c.expandedgroups[qa.uniqueid].expanded:
1324void 0:!1,Ba=!Ba;Ba&&(na=!0);qa=qa.parentItem}if(!na)break;za++}300==za&&(ea=null);if(c.pageable&&(ra=!1,ea)){for(za=0;za<c.dataview.rows.length;za++)c.dataview.rows[za].boundindex==ea.boundindex&&(ra=!0);ra||(ea=null)}}else if(c.pageable&&(ra=!1,ea)){for(za=0;za<c.dataview.rows.length;za++)c.dataview.rows[za].boundindex==ea.boundindex&&(ra=!0);ra||(c.pagerpageinput&&9===b.keyCode&&ea.boundindex>c.dataview.rows[c.dataview.rows.length-1].boundindex&&(c.pagerpageinput.focus(),b.preventDefault()),c.ensurerowvisible(ea))}return void 0==
1325ea||null==ja||ea.totalsrow?!1:((v||void 0==v)&&c.clearselection(),ea=c.getboundindex(ea),c.selectcell(ea,ja),c._oldselectedcell=c.selectedcell,g=!0,c.groupable?c.ensurecellvisible(ea,ja):c.ensurecellvisible(da,ja),!0)};C(V,ba)||c.groupable||(c.ensurecellvisible(V,ba),C(V,ba),c.virtualmode&&c.host.focus());c.groupable&&0<c.groups.length||(b.shiftKey&&9!=b.keyCode?"multiplecellsextended"!=c.selectionmode&&"multiplecellsadvanced"!=c.selectionmode||!c._lastClickedCell||(c._selectpath(V,ba),V=c.getboundindex(c.dataview.loadedrecords[V]),
1326c.selectedcell={rowindex:V,datafield:ba}):b.shiftKey||(c._lastClickedCell={row:V,column:ba}))},y=b.shiftKey&&"singlecell"!=c.selectionmode&&"multiplecells"!=c.selectionmode;e=function(){c.pageable?B(c.dataview.pagenum*c.dataview.pagesize,u,!y):B(0,u,!y)};h=function(){var V=t.rowscount-1;c.pageable&&(V=c.dataview.pagenum*c.dataview.pagesize+c.dataview.rows.length-1);B(V,u,!y)};var A=9==d&&!b.shiftKey,aa=9==d&&b.shiftKey;c.rtl&&(k=A,A=aa,aa=k);if(A||aa)y=!1;if((A||aa)&&document.activeElement&&document.activeElement.className&&
13270<=document.activeElement.className.indexOf("jqx-grid-cell-add-new-row"))return!0;
1327if((k=b.ctrlKey||b.metaKey)&&37==d)r=c._getfirstvisiblecolumn(x),null!=r&&B(f,r.datafield);else if(k&&39==d)r=c._getlastvisiblecolumn(x),null!=r&&B(f,r.datafield);else if(39==d||A)r=c._getnextvisiblecolumn(x),null!=r?B(f,r.datafield,!y):A?(r=c._getfirstvisiblecolumn(),d=40,u=r.displayfield):g=!0;else if(37==d||aa)r=c._getprevvisiblecolumn(x),null!=r?B(f,r.datafield,!y):aa?(r=c._getlastvisiblecolumn(),d=38,u=r.displayfield):
1328g=!0;else if(36==d)e();else if(35==d)h();else if(33==d)if(0<=f-r){var ha=f-r;B(ha,u,!y);c.pageable&&c.virtualmode&&(c.gotoprevpage(),setTimeout(function(){B(ha,u,!y)},25))}else e();else 34==d&&(t.rowscount>f+r?(ha=f+r,B(ha,u,!y),c.pageable&&c.virtualmode&&(c.gotonextpage(),setTimeout(function(){B(ha,u,!y)},25))):h());38==d&&(k?e():0<f?B(f-1,u,!y,"up"):g=!1);40==d&&(k?h():t.rowscount>f+1||c.groupable&&0<c.groups.length?B(f+1,u,!y,"down"):g=!0)}break;case "singlerow":case "multiplerows":case "multiplerowsextended":case "multiplerowsadvanced":f=
1329c.getselectedrowindex();if(null==f||-1==f)return!0;f=this.getrowvisibleindex(f);var z=function(V,ba,v){var K=function(C){var da=c.dataview.loadedrecords[C];if(c.groupable&&0<c.groups.length){"up"==v&&C++;"down"==v&&C--;da=c.getdisplayrows()[C];for(var ja=1,ea=!0;ea&&300>ja;){ea=!1;"down"==v?da=c.getdisplayrows()[C+ja]:"up"==v&&(da=c.getdisplayrows()[C-ja]);if(!da)break;da&&da.group&&(ea=!0);da&&da.totalsrow&&(ea=!0);for(var ra=da.parentItem;ra;){var za;if(za=ra)za=ra.group?c.expandedgroups[ra.uniqueid]?
1330c.expandedgroups[ra.uniqueid].expanded:void 0:!1,za=!za;za&&(ea=!0);ra=ra.parentItem}if(!ea)break;ja++}300==ja&&(da=null);if(c.pageable&&(ja=!1,da)){for(ea=0;ea<c.dataview.rows.length;ea++)c.dataview.rows[ea].boundindex==da.boundindex&&(ja=!0);ja||(da=null)}}return void 0!=da?(da=c.getboundindex(da),ja=c.selectedrowindex,(ba||void 0==ba)&&c.clearselection(),c.selectedrowindex=ja,c.selectrow(da,!1),(c.groupable?c.ensurerowvisible(da):c.ensurerowvisible(C))&&!c.autoheight&&!c.groupable||c._rendervisualrows(),
1331g=!0):!1};K(V)||c.groupable||(c.ensurerowvisible(V),K(V,ba),c.virtualmode&&setTimeout(function(){K(V,ba)},25),c.virtualmode&&c.host.focus());c.groupable&&0<c.groups.length||(b.shiftKey&&9!=d?"multiplerowsextended"==c.selectionmode&&c._lastClickedCell&&(c._selectrowpath(V),c.selectedrowindex=c.getrowboundindex(V)):b.shiftKey||(c._lastClickedCell={row:V},c.selectedrowindex=c.getrowboundindex(V)))};y=b.shiftKey&&"singlerow"!=c.selectionmode&&"multiplerows"!=c.selectionmode;e=function(){c.pageable?z(c.dataview.pagenum*
1332c.dataview.pagesize,!y):z(0,!y)};h=function(){var V=t.rowscount-1;c.pageable&&(V=c.dataview.pagenum*c.dataview.pagesize+c.dataview.rows.length-1);z(V,!y)};k=b.ctrlKey||b.metaKey;36==d||k&&38==d?e():35==d||k&&40==d?h():33==d?0<=f-r?(ha=f-r,z(ha,!y,"up"),c.pageable&&c.virtualmode&&(c.gotoprevpage(),setTimeout(function(){z(ha,!y)},25))):e():34==d?t.rowscount>f+r?(ha=f+r,z(ha,!y,"down"),c.pageable&&c.virtualmode&&(c.gotonextpage(),setTimeout(function(){z(ha,!y)},25))):h():38==d?0<f?z(f-1,!y,"up"):g=!0:
133340==d&&(t.rowscount>f+1||c.groupable&&0<c.groups.length?z(f+1,!y,"down"):g=!0)}return g?(c.autosavestate&&c.savestate&&c.savestate(),!1):!0},_handlemousemove:function(b,c){if(!c.vScrollInstance.isScrolling()&&!c.hScrollInstance.isScrolling()){if(c.enablehover||"multiplerows"==c.selectionmode){var d=this.showheader?this.columnsheader.height()+2:0;var e=this._groupsheader()?this.groupsheader.height():0;e=e+(this.showtoolbar?this.toolbarheight:0)+(this.showfilterbar?this.toolbarheight:0);var f=this.host.coord();
1334if(this.hasTransform){f=a.jqx.utilities.getOffset(this.host);var g=this._getBodyOffset();f.left-=g.left;f.top-=g.top}g=b.pageX-f.left;d=b.pageY-d-f.top-e}if("multiplerowsextended"!=c.selectionmode&&"multiplecellsextended"!=c.selectionmode&&"multiplecellsadvanced"!=c.selectionmode||1!=c.mousecaptured)if(c.enablehover){if(!(c.disabled||this.vScrollInstance.isScrolling()||this.hScrollInstance.isScrolling())&&(d=this._hittestrow(g,d))){var h=d.row;d=d.index;if(-1==this.hoveredrow||-1==d||this.hoveredrow!=
1335d||-1!=this.selectionmode.indexOf("cell")||"checkbox"==this.selectionmode)if(this._clearhoverstyle(),-1!=d&&void 0!=h&&(e=this.hittestinfo[d].visualrow,!(null==e||this.hittestinfo[d].details||b.clientX>a(e).width()+a(e).coord().left))){var k=0;f=e.cells.length;
1335c.rowdetails&&c.showrowdetailscolumn?this.rtl?f=f-1-this.groups.length:k=1+this.groups.length:this.groupable&&(this.rtl?f-=this.groups.length:k=this.groups.length);if(0!=e.cells.length&&(c=e.cells[k].className,!(h.group||0<=this.selectionmode.indexOf("row")&&
1336-1!=c.indexOf("jqx-grid-cell-selected"))))if(this.hoveredrow=d,-1!=this.selectionmode.indexOf("cell")||"checkbox"==this.selectionmode){c=-1;var l=this.hScrollInstance;h=l.value;for(this.rtl&&"hidden"!=this.hScrollBar.css("visibility")&&(h=l.max-l.value);k<f;k++)if(l=parseInt(this.columnsrow[0].cells[k].style.left)-h,this.columns.records[k].pinned&&!this.rtl&&(l=parseInt(this.columnsrow[0].cells[k].style.left)),l+this.columns.records[k].width>=g&&g>=l){c=k;break}if(-1!=c){g=e.cells[c];this.cellhover&&
1337this.cellhover(g,b.pageX,b.pageY);if(-1==g.className.indexOf("jqx-grid-cell-selected")&&this.editcell&&(h=this._getcolumnat(c))&&this.editcell.row==d&&this.editcell.column==h.datafield)return;a(g).addClass(this.toTP("jqx-grid-cell-hover"));a(g).addClass(this.toTP("jqx-fill-state-hover"));h=this._getcolumnat(c);h._applyCellStyle(g)}}else for(;k<f;k++)g=e.cells[k],a(g).addClass(this.toTP("jqx-grid-cell-hover")),a(g).addClass(this.toTP("jqx-fill-state-hover")),this.cellhover&&this.cellhover(g,b.pageX,
1338b.pageY),h=this._getcolumnat(k),h._applyCellStyle(g)}}}else return!0}}})})(jqxBaseFramework);
1339(function(a){a.jqx.dataview.grouping=function(){this.loadgrouprecords=function(b,c,d,e,f,g,h,k,l){var m=b;m=[];for(var n=0;n<this.groups.length;n++)m[n]=this.generatekey();e=[];var r=0,t=[],u=c,x=c,B=this.groups.length;this.loadedrecords=[];this.bounditems=[];this.loadedrecords=[];this.loadedrootgroups=[];this.loadedgroups=[];this.loadedgroupsByKey=[];this.sortedgroups=[];var y=null!=this.sortdata,A=y?this.sortdata:this.records;if(this.pageable){var aa=[],ha=0;A[c]||(a.each(A,function(ra,za){aa[c+
1340ra++]=this}),A=aa)}if(this.virtualmode){aa=[];for(u=ha=0;u<d-c;u++)A[u]?aa[c+ha++]=A[u]:A[c+ha]&&(aa[c+ha]=A[c+ha],ha++);u=0;A=aa}for(ha=c;ha<d;ha++){var z={};z=y?a.extend({},A[ha].value):a.extend({},A[ha]);var V=z[this.uniqueId];if(f>=k||V!=h[f][this.uniqueId]||g&&g[V])l[l.length]=f;V=[];var ba=0;for(n=0;n<B;n++){var v=this.groups[n];v=z[v];null==v&&(v="");V[ba++]={value:v,hash:m[n]}}if(V.length!=B)break;v=null;n="";ba=-1;for(var K=0;K<V.length;K++){ba++;var C=V[K].value;n=n+"_"+V[K].hash+"_"+C;
1341if(void 0!=t[n]&&null!=t[n])v=t[n];else{if(null==v)v={group:C,subItems:[],subGroups:[],level:0},e[r++]=v,v.uniqueid=this.generatekey(),this.loadedgroupsByKey[C]=v;else{var da={group:C,subItems:[],subGroups:[],parentItem:v,level:v.level+1};this.loadedgroupsByKey[v.uniqueid+"_"+C]=da;da.uniqueid=this.generatekey();v=v.subGroups[v.subGroups.length++]=da}t[n]=v}}null!=v?(void 0==z.uid&&(z.uid=this.getid(this.source.id,z,u)),y?(z.boundindex=A[ha].index,this.recordsbyid["id"+z.uid]=A[ha].value):(z.boundindex=
1342u,this.recordsbyid["id"+z.uid]=A[ha]),this.bounditems[z.boundindex]=z,this.sortedgroups[u]=z,z.uniqueid=this.generatekey(),z.parentItem=v,z.level=v.level+1,v.subItems[v.subItems.length++]=z):(void 0==z.uid&&(z.uid=this.getid(this.source.id,z,u)),y?(z.boundindex=A[ha].index,this.recordsbyid["id"+z.uid]=A[ha].value):(z.boundindex=u,this.recordsbyid["id"+z.uid]=A[ha]),this.sortedgroups[u]=z,this.bounditems[z.boundindex]=z,z.uniqueid=this.generatekey());f++;u++;x++}var ja=function(ra,za,na){for(var qa=
13430;qa<za.subItems.length;qa++)za.subItems[qa].visibleindex=b+na,ra.rows[na]=za.subItems[qa],ra.loadedrecords[na]=za.subItems[qa],na++;return na},ea=function(ra,za,na){var qa=1,Ba=ra.grid.columns.records?ra.grid.columns.records:ra.grid.columns;if(1==ra.aggregates)for(var Ua=0;Ua<Ba.length;Ua++)Ba[Ua].aggregates&&(qa=Math.max(qa,Ba[Ua].aggregates.length));for(var Ja in za.subGroups)Ua=za.subGroups[Ja],Ua.subGroups&&(ra.loadedgroups[ra.loadedgroups.length]=Ua,Ua.visibleindex=b+na,ra.rows[na]=Ua,ra.loadedrecords[na]=
1344Ua,na++,0<Ua.subGroups.length?na=ea(ra,Ua,na):0<Ua.subItems.length&&(na=ja(ra,Ua,na)));0<za.subItems.length&&(na=ja(ra,za,na));(function(Pa){if(1==ra.aggregates)for(var Ca=function(Fa){var Na=Pa,I={},Ta=function(ab){for(var Oa=0;Oa<Ba.length;Oa++)if(Ba[Oa].aggregates)for(var Ga=ra.grid.getcolumnaggregateddata(Ba[Oa].datafield,Ba[Oa].aggregates,!0,ab),la=0;la<Ba[Oa].aggregates.length;la++)if(Ba[Oa].aggregates[Fa]){var ta=Ba[Oa],va=Ba[Oa].aggregates[Fa],p=va;p=ra.grid._getaggregatename(p);var E=p+":"+
1345Ga[va];I[ta.datafield]=Ga[va]?E:p+":"+Ga[p]}};if(null!=Na)if(I.level=Na.level,I.visibleindex=b+na,I.uniqueid=ra.generatekey(),ra.rows[na]=I,ra.loadedrecords[na++]=I,I.totalsrow=!0,0<Pa.subItems.length){Na=Pa.subItems[Pa.subItems.length-1];I.parentItem=Na.parentItem;I.parentItem.subItems&&(I.parentItem.subItems[I.parentItem.subItems.length]=I);var Sa=[],db=function(){for(var ab=0;ab<Pa.subItems.length;
1345ab++)Pa.subItems[ab].totalsrow||(Sa[Sa.length]=Pa.subItems[ab])};db(Pa);Ta(Sa)}else 0<Pa.subGroups.length&&
1346(Na=Pa.subGroups[Pa.subGroups.length-1],I.level=Na.level,I.parentItem=Pa,Pa.subGroups[Pa.subGroups.length]=I,Sa=[],db=function(ab){if(!ab.totalsrow){for(var Oa=0;Oa<ab.subItems.length;Oa++)ab.subItems[Oa].totalsrow||(Sa[Sa.length]=ab.subItems[Oa]);for(Oa=0;Oa<ab.subGroups.length;Oa++)db(ab.subGroups[Oa])}},db(Pa),Ta(Sa))},xa=0;xa<qa;xa++)Ca(xa)})(za);return na};d=e.length;this.loadedgroups=[];this.rows=[];for(u=m=0;u<d;u++)v=e[u],this.loadedrootgroups[u]=v,this.loadedgroups[this.loadedgroups.length]=
1347v,v.visibleindex=b+m,this.rows[m]=v,this.loadedrecords[m]=v,m++,m=ea(this,v,m);return m};this._updategroupsinpage=function(b,c,d,e,f,g,h){var k=[];if(this.groupable&&0<this.groups.length){c=0;f=[];for(var l=[],m=0;m<b.groups.length;m++)l[m]=b.generatekey();var n=0,r=[],t=0;h>this.totalrecords&&(h=this.totalrecords);for(;g<h;g++){var u=a.extend({},b.sortedgroups[g]);if(!b.pagesize||d>=b.pagesize*b.pagenum&&d<b.pagesize*(b.pagenum+1)){var x=[],B=0;for(m=0;m<b.groups.length;m++){var y=b.groups[m];y=
1348u[y];null==y&&(y="");x[B++]={value:y,hash:l[m]}}if(x.length!=b.groups.length)break;m=null;B="";y=-1;for(var A=0;A<x.length;A++){y++;var aa=x[A].value;B=B+"_"+x[A].hash+"_"+aa;if(void 0!=f[B]&&null!=f[B])m=f[B];else{if(null==m)m={group:aa,subItems:[],subGroups:[],level:0},r[t++]=m,aa=b.loadedgroupsByKey[aa],void 0!=aa&&(m.visibleindex=aa.visibleindex,m.uniqueid=aa.uniqueid);else{var ha={group:aa,subItems:[],subGroups:[],parentItem:m,level:m.level+1};aa=b.loadedgroupsByKey[m.uniqueid+"_"+aa];ha.visibleindex=
1349aa.visibleindex;ha.uniqueid=aa.uniqueid;m=m.subGroups[m.subGroups.length++]=ha}f[B]=m}}null!=m&&(u.parentItem=m,u.level=m.level+1,m.subItems[m.subItems.length++]=u);e++}n++;d++}var z=function(v,K,C){for(v=0;v<K.subItems.length;v++)k[C]=a.extend({},K.subItems[v]),C++;return C},V=function(v){for(var K in v.subGroups){var C=v.subGroups[K];if(C.subGroups&&(0<C.subGroups.length&&V(C)||0<C.subItems.length))return!0}return 0<v.subItems.length?!0:!1},ba=function(v,K,C){var da=1,ja=v.grid.columns.records?
1350v.grid.columns.records:v.grid.columns;if(1==v.aggregates)for(var ea=0;ea<ja.length;ea++)ja[ea].aggregates&&(da=Math.max(da,ja[ea].aggregates.length));for(var ra in K.subGroups)ea=K.subGroups[ra],ea.subGroups&&V(ea)&&(k[C]=ea,C++,
13500<ea.subGroups.length?C=ba(v,ea,C):0<ea.subItems.length&&(C=z(v,ea,C)));0<K.subItems.length&&(C=z(v,K,C));(function(za){if(1==v.aggregates)for(var na=function(Ba){var Ua=za,Ja={},Pa=function(Fa){for(var Na=0;Na<ja.length;Na++)if(ja[Na].aggregates)for(var I=v.grid.getcolumnaggregateddata(ja[Na].datafield,
1351ja[Na].aggregates,!0,Fa),Ta=0;Ta<ja[Na].aggregates.length;Ta++)if(ja[Na].aggregates[Ba]){var Sa=ja[Na],db=ja[Na].aggregates[Ba],ab=db;ab=v.grid._getaggregatename(ab);Ja[Sa.datafield]=ab+":"+I[db]}};if(null!=Ua)if(Ja.level=Ua.level,Ja.visibleindex=C,Ja.uniqueid=v.generatekey(),k[C]=Ja,v.loadedrecords[C++]=Ja,Ja.totalsrow=!0,0<za.subItems.length){Ua=za.subItems[za.subItems.length-1];Ja.parentItem=Ua.parentItem;Ja.parentItem.subItems&&(Ja.parentItem.subItems[Ja.parentItem.subItems.length]=Ja);var Ca=
1352[],xa=function(){for(var Fa=0;Fa<za.subItems.length;Fa++)za.subItems[Fa].totalsrow||(Ca[Ca.length]=za.subItems[Fa])};xa(za);Pa(Ca)}else 0<za.subGroups.length&&(Ua=za.subGroups[za.subGroups.length-1],Ja.level=Ua.level,Ja.parentItem=za,za.subGroups[za.subGroups.length]=Ja,Ca=[],xa=function(Fa){if(!Fa.totalsrow){for(var Na=0;Na<Fa.subItems.length;Na++)Fa.subItems[Na].totalsrow||(Ca[Ca.length]=Fa.subItems[Na]);for(Na=0;Na<Fa.subGroups.length;Na++)xa(Fa.subGroups[Na])}},xa(za),Pa(Ca))},qa=0;qa<da;qa++)na(qa)})(K);
1353return C};for(n=0;n<r.length;n++)y=r[n],V(y)&&(k[c]=y,c++,c=ba(this,y,c))}return k}};a.extend(a.jqx._jqxGrid.prototype,{_initgroupsheader:function(){this.groupsheader.css("visibility","hidden");if(this._groupsheader()){this.groupsheader.css("visibility","inherit");var b=this,c=this.gridlocalization.groupsheaderstring;this.groupsheaderdiv=this.groupsheaderdiv||a('<div style="width: 100%; position: relative;"></div>');this.groupsheaderdiv.height(this.groupsheaderheight);this.groupsheaderdiv.css("top",
13540);this.groupsheader.append(this.groupsheaderdiv);this.groupheadersbounds=[];var d=this.groups.length;this.groupsheaderdiv.children().remove();this.groupsheaderdiv[0].innerHTML="";var e=[];0<d?a.each(this.groups,function(f){var g=this,h=b._getColumnText(this).label;h=b._rendergroupcolumn(h,g);h.addClass(b.toThemeProperty("jqx-grid-group-column"));b.groupsheaderdiv.append(h);if(b.closeablegroups){var k=a(h.find(".jqx-icon-close"));b.isTouchDevice()&&!0!==b.touchmode?b.addHandler(k,"touchstart",function(){b.removegroupat(f);
1355return!1}):b.addHandler(k,"click",function(){b.removegroupat(f);return!1})}b.sortable&&b.addHandler(h,"click",function(){var l=b.getcolumn(g);null!=l&&b._togglesort(l);return!1});e[e.length]=h;b._handlegroupstocolumnsdragdrop(this,h);f<d-1&&(h=h.height(),k=a('<div style="float: left; position: relative;"></div>'),b.rtl&&k.css("float","right"),k.width(b.groupindentwidth/3),k.height(1),k.css("top",h/2),k.addClass(b.toThemeProperty("jqx-grid-group-column-line")),b.groupsheaderdiv.append(k))}):(c=a('<div style="position: relative;">'+
1356c+"</div>"),this.groupsheaderdiv.append(c),this.rtl&&c.addClass(this.toThemeProperty("jqx-rtl")));this._groupheaders=e;this._updategroupheadersbounds()}},_updategroupheadersbounds:function(){var b=this,c=this.groupsheaderdiv.children().outerHeight();c=(this.groupsheader.height()-c)/2;this.groupsheaderdiv.css("top",c);this.rtl?(this.groupsheaderdiv.css("left",""),this.groupsheaderdiv.css("right",c)):(this.groupsheaderdiv.css("left",c),this.groupsheaderdiv.css("right",""));this.rtl&&this._groupheaders.reverse();
1357a.each(this._groupheaders,function(d){var e=this.coord();b.groupheadersbounds[d]={left:e.left,top:e.top,width:this.outerWidth(),height:this.outerHeight(),index:d}})},addgroup:function(b){b&&(this.groups!==this.dataview.groups&&(this.dataview.groups=this.groups),this.groups[this.groups.length]=b,this.refreshgroups(),this._raiseEvent(12,{type:"Add",index:this.groups[this.groups.length],groups:this.groups}))},insertgroup:function(b,c){void 0!=b&&null!=b&&0<=b&&b<=this.groups.length&&c&&(this.groups!==
1358this.dataview.groups&&(this.dataview.groups=this.groups),this.groups.splice(b,0,c.toString()),this.refreshgroups(),this._raiseEvent(12,{type:"Insert",index:b,groups:this.groups}))},refreshgroups:function(){this._refreshdataview();this._render(!0,!0,!0,!1);this._postrender("group")}
1358,_insertaftergroup:function(b,c){b=this._getGroupIndexByDataField(b);this.insertgroup(b+1,c)},_insertbeforegroup:function(b,c){b=this._getGroupIndexByDataField(b);this.insertgroup(b,c)},removegroupat:function(b){return 0<=
1359b&&null!=b&&void 0!=b?(this.groups!==this.dataview.groups&&(this.dataview.groups=this.groups),this.groups.splice(b,1),this.refreshgroups(),this.virtualmode&&this.updatebounddata(),this._raiseEvent(12,{type:"Remove",index:b,groups:this.groups}),!0):!1},cleargroups:function(){this.groups=[];this.dataview.groups=this.groups;this.refreshgroups();this._raiseEvent(12,{type:"Clear",index:-1,groups:this.groups});return!0},removegroup:function(b){if(null==b)return!1;b=this.groups.indexOf(b.toString());return this.removegroupat(b)},
1360getrootgroupscount:function(){return this.dataview.loadedrootgroups.length},collapsegroup:function(b){if(0<=b&&-1===b.toString().indexOf("."))return this._setrootgroupstate(b,!1);var c=b.toString().split("."),d=null;this.groupsVisibility||(this.groupsVisibility=[]);for(var e=0;e<c.length;e++)if(b=parseInt(c[e]),0==e)d=this.dataview.loadedrootgroups[b],this.groupsVisibility[d.group]=null;else if(b=d.subGroups[b])d=b,e==c.length-1&&(this._setgroupstate(d,!1,!0),this.groupsVisibility[d.group]=null)},
1361expandgroup:function(b){if(0<=b&&-1===b.toString().indexOf("."))return this._setrootgroupstate(b,!0);for(var c=b.toString().split("."),d=null,e=0;e<c.length;e++)if(b=parseInt(c[e]),0==e)d=this.dataview.loadedrootgroups[b],this._setrootgroupstate(b,!0),this.groupsVisibility||(this.groupsVisibility=[]),this.groupsVisibility[d.group]=d;else if(b=d.subGroups[b])d=b,this._setgroupstate(d,!0,!0),this.groupsVisibility||(this.groupsVisibility=[]),this.groupsVisibility[d.group]=d},collapseallgroups:function(b){this._setbatchgroupstate(!1,
1362b)},expandallgroups:function(b){this._setbatchgroupstate(!0,b)},isgroupexpanded:function(b){b=this.dataview.loadedrootgroups[b];return null==b?null:this.expandedgroups[b.uniqueid].expanded},jsonParser:function(){function b(r,t,u){var x=!1,B=!!t,y=[],A=[r],aa=[r],ha=[u?"~":"[Circular]"],z=r,V=1,ba,v;B&&(v="object"===typeof t?function(K,C){return""!==K&&0>l.call(t,K)?void 0:C}:t);return function(K,C){B&&(C=v.call(this,K,C));x?(z!==this&&(ba=V-l.call(A,this)-1,V-=ba,A.splice(V,A.length),y.splice(V-1,
1363y.length),z=this),"object"===typeof C&&C?(0>l.call(A,C)&&A.push(z=C),V=A.length,ba=l.call(aa,C),0>ba?(ba=aa.push(C)-1,u?(y.push((""+K).replace(g,e)),ha[ba]="~"+y.join("~")):ha[ba]=ha[0]):C=ha[ba]):"string"===typeof C&&u&&(C=C.replace(e,f).replace("~",e))):x=!0;return C}}function c(r){return function(t,u){var x="string"===typeof u;if(x&&"~"===u.charAt(0))return new m(u.slice(1));""===t&&(u=d(u,u,{}));x&&(u=u.replace(k,"$1~").replace(f,e));return r?r.call(this,t,u):u}}function d(r,t,u){if(t instanceof
1364Array)for(var x=0,B=t.length;x<B;x++)t[x]=d(r,t[x],u);else if(t instanceof m)if(t.length)if(u.hasOwnProperty(t))t=u[t];else{x=t.split("~");B=0;for(var y=x.length;B<y;r=r[x[B++].replace(h,"~")]);t=u[t]=r}else t=r;else if(t instanceof Object)for(x in t)t.hasOwnProperty(x)&&(t[x]=d(r,t[x],u));return t}var e="\\x"+("0"+(126).toString(16)).slice(-2),f="\\"+e,g=new RegExp(e,"g"),h=new RegExp(f,"g"),k=new RegExp("(?:^|([^\\\\]))"+f),l=[].indexOf||function(r){for(var t=this.length;t--&&this[t]!==r;);return t},
1365m=String,n={stringify:function(r,t,u,x){return n.parser.stringify(r,b(r,t,!x),u)},parse:function(r,t){return n.parser.parse(r,c(t))},parser:JSON};return n},getgroup:function(b){b=this.dataview.loadedrootgroups[b];if(null==b)return null;var c=this.expandedgroups[b.uniqueid].expanded,d=b.group,e=b.level,f=[];this._getsubgroups(f,b);var g=this;c={group:d,level:e,expanded:c,subgroups:f};if(b.subItems){var h=[];a.each(b.subItems,function(){h[h.length]=g.getrowdata(this.boundindex)});0<h.length&&(c.subrows=
1366h)}b=this.jsonParser().stringify(b);b=b.replace(/subItems/ig,"subrows");b=b.replace(/subGroups/ig,"subgroups");return c=this.jsonParser().parse(b)},getrootgroups:function(){for(var b=this.dataview.loadedrootgroups.length,c=[],d=0;d<b;d++)c[d]=this.getgroup(d);return c},_getsubgroups:function(b,c){var d=this,e;for(e in c.subGroups){var f=c.subGroups[e];b[b.length]={group:f.group,level:f.level,expanded:d.expandedgroups[f.uniqueid].expanded};if(f.subItems){var g=[];a.each(f.subItems,function(){g[g.length]=
1367d.getrowdata(this.boundindex)});b[b.length-1].subrows=g}f.subGroups&&d._getsubgroups([],f)}return b},_setbatchgroupstate:function(b,c){for(var d in this.dataview.loadedrootgroups)this._setrootgroupstate(d,b,!1,!0);if(0==c)return this._requiresupdate=!0,this._renderrows(this.virtualsizeinfo),!0;b=this.vScrollBar[0].style.visibility;this.rendergridcontent(!0,!1);if(b!=this.vScrollBar[0].style.visibility||this._hiddencolumns)this._updatecolumnwidths(),this._updatecellwidths(),this._renderrows(this.virtualsizeinfo);
1368return!0},_setrootgroupstate:function(b,c,d,e){if(void 0==b||null==b||0>b||!this.groupable||0==this.groups.length)return!1;d=void 0!=d?d:!0;if(0<=b&&b<this.dataview.loadedrootgroups.length){var f=this.dataview.loadedrootgroups[b];if(this.pageable){f=[];for(var g=0;g<this.dataview.rows.length;g++)null!=this.dataview.rows[g].group&&0===this.dataview.rows[g].level&&f.pu
1368sh(this.dataview.rows[g]);f=f[b];if(!f)return}return this._setgroupstate(f,c,d,e)}return!1},_togglegroupstate:function(b,c){if(null==
1369b||void 0==b)return!1;var d=this.vScrollInstance.value,e=this.expandedgroups[b.uniqueid];e=void 0==e?!1:e.expanded;e=!e;this.groupsVisibility||(this.groupsVisibility=[]);this.groupsVisibility[b.group]=e?b:null;b=this._setgroupstate(b,e,c);this._newmax=null;0!==d&&"hidden"!==this.vScrollBar.css("visibility")&&(d<=this.vScrollInstance.max?this.vScrollInstance.setPosition(d):this.vScrollInstance.setPosition(this.vScrollInstance.max));return b},_setgroupstate:function(b,c,d,e){if(null==b||void 0==b)return!1;
1370var f=!1;this.editable&&this.editcell&&this.endcelledit(this.editcell.row,this.editcell.column,!1,!1);var g=this.expandedgroups[b.uniqueid];void 0==g&&(g={expanded:!1},f=!0);g.expanded!=c&&(f=!0);if(f){this.expandedgroups[b.uniqueid]={expanded:c,group:b};this._setsubgroupsvisibility(this,b,!c,e);d&&(d=this.vScrollBar[0].style.visibility,this.rendergridcontent(!0,!1),d!=this.vScrollBar[0].style.visibility||this._hiddencolumns)&&(this._updatecolumnwidths(),this._updatecellwidths(),this._renderrows(this.virtualsizeinfo));
1371if(void 0==this.suspendgroupevents||0==this.suspendgroupevents)c?this._raiseEvent(4,{group:b.group,parentgroup:b.parentItem?b.parentItem.group:null,level:b.level,visibleindex:b.visibleindex}):this._raiseEvent(5,{group:b.group,parentgroup:b.parentItem?b.parentItem.group:null,level:b.level,visibleindex:b.visibleindex});return!0}return!1},_setgroupitemsvisibility:function(b,c,d){for(var e=0;e<c.subItems.length;e++)b._setrowvisibility(c.subItems[e].visibleindex,d,!1)},_setsubgroupsvisibility:function(b,
1372c,d,e){if(null!=c.parentItem){if(this.hiddens[c.parentItem.visibleindex])return}else if(null==c.parentItem&&this.hiddens[c.visibleindex])return;for(var f in c.subGroups){var g=c.subGroups[f];d||b._setrowvisibility(g.visibleindex,d,!1);var h=!d;e?this.expandedgroups[g.uniqueid]={expanded:h,group:g}:h=void 0==b.expandedgroups[g.uniqueid]?!1:b.expandedgroups[g.uniqueid].expanded;g.subGroups&&(0<g.subGroups.length?b._setsubgroupsvisibility(b,g,!h||d,e):0<g.subItems.length&&b._setgroupitemsvisibility(b,
1373g,!h||d));d&&b._setrowvisibility(g.visibleindex,d,!1)}c.subItems&&0<c.subItems.length&&b._setgroupitemsvisibility(b,c,d)},_handlecolumnsdragdrop:function(){var b=this,c=-1,d=!1;if(b.groupable){var e="mousemove.grouping"+this.element.id,f="mouseup.grouping"+this.element.id,g=!1;this.isTouchDevice()&&!0!==this.touchmode&&(g=!0,e=a.jqx.mobile.getTouchEventName("touchmove")+".grouping"+this.element.id,a.jqx.mobile.getTouchEventName("touchstart"),f=a.jqx.mobile.getTouchEventName("touchend")+".grouping"+
1374this.element.id);this.removeHandler(a(document),e);this.addHandler(a(document),e,function(h){if(!b.showgroupsheader)return!0;if(null!=b.dragcolumn){var k=parseInt(h.pageX),l=parseInt(h.pageY);g&&(l=b.getTouches(h)[0],k=parseInt(l.pageX),l=parseInt(l.pageY));var m=b.host.coord(),n=parseInt(m.left);m=parseInt(m.top);if(void 0==b.dragmousedownoffset||null==b.dragmousedownoffset)b.dragmousedownoffset={left:0,top:0};var r=parseInt(k)-parseInt(b.dragmousedownoffset.left),t=parseInt(l)-parseInt(b.dragmousedownoffset.top);
1375b.dragcolumn.css({left:r+"px",top:t+"px"});d=!1;k>=n&&k<=n+b.host.width()&&l>=m&&l<=m+b.host.height()&&(d=!0);c=-1;d?(b.dragcolumnicon.removeClass(b.toThemeProperty("jqx-grid-dragcancel-icon")),b.dragcolumnicon.addClass(b.toThemeProperty("jqx-grid-drag-icon")),n=b.groupsheader.coord(),m=n.top+b.groupsheader.height(),r=(r=a.data(b.dragcolumn[0],"datarecord"))?b.groups.indexOf(r.toString()):-1,r=-1==r||1<b.groups.length&&-1<r,null!=b.dropline&&(l>=n.top&&l<=m?r&&(c=b._handlegroupdroplines(k)):b.dropline.fadeOut("slow"))):
1376(null!=b.dropline&&b.dropline.fadeOut("slow"),b.dragcolumnicon.removeClass(b.toThemeProperty("jqx-grid-drag-icon")),b.dragcolumnicon.addClass(b.toThemeProperty("jqx-grid-dragcancel-icon")));if(g)return h.preventDefault(),h.stopPropagation(),!1}},{passive:!1});this.removeHandler(a(document),f);this.addHandler(a(document),f,function(h){if(!b.showgroupsheader)return!0;b.__drag=!1;a(document.body).removeClass("jqx-disableselect");parseInt(h.pageX);var k=parseInt(h.pageY);g&&(h=b.getTouches(h)[0],parseInt(h.pageX),
1377k=parseInt(h.pageY));h=b.host.coord();parseInt(h.left);var l=parseInt(h.top),m=b.groupsheader.height();b.showtoolbar&&(l+=b.toolbarheight);b.dragstarted=!1;b.dragmousedown=null;null!=b.dragcolumn&&(h=a.data(b.dragcolumn[0],"datarecord"),b.dragcolumn.remove(),b.dragcolumn=null,null!=h&&(b.getcolumn(h).groupable&&d&&(-1!=c?(k=c.index,l=b.groups[k],m=b._getGroupIndexByDataField(h),m!=k&&(void 0!=m&&0<=m&&b.groups.splice(m,1),"before"==c.position?b.rtl?b._insertaftergroup(l,h):b._insertbeforegroup(l,
1378h):b.rtl?b._insertbeforegroup(l,h):b._insertaftergroup(l,h))):0==b.groups.length?k>l&&k<=l+m&&b.addgroup(h):k>l+m&&(m=b._getGroupIndexByDataField(h),b.removegroupat(m))),null!=b.dropline&&(b.dropline.remove(),b.dropline=null)))})}},_getGroupIndexByDataField:function(b){for(var c=0;c<this.groups.length;c++)if(this.groups[c]==b)return c;return-1},_isColumnInGroups:function(b){for(var c=0;c<this.groups.length;c++)if(this.groups[c]==b)return!0;return!1},_handlegroupdroplines:function(b){var c=this,d=
1379-1;a.each(c.groupheadersbounds,function(e){if(b<=this.left+this.width/2){var f=this.left-3;0<e&&(f=this.left-1-c.groupindentwidth/6);c.dropline.css("left",f);c.dropline.css("top",this.top);c.dropline.height(this.height);c.dropline.fadeIn("slow");d={index:e,position:"before"};c.rtl&&(d={index:c.groupheadersbounds.length-1-e,position:"before"});return!1}b>=this.left+this.width/2&&(c.dropline.css("left",1+this.left+this.width),c.dropline.css("top",this.top),c.dropline.height(this.height),c.dropline.fadeIn("slow"),
1380d={index:e,position:"after"},c.rtl&&(d={index:c.groupheadersbounds.length-1-e,position:"after"}))});return d},_handlegroupstocolumnsdragdrop:function(b,c){this.dragmousedownoffset=this.dragmousedown=null;this.dragstarted=!1;this.dragcolumn=null;var d=this,e,f="mousedown",g="mousemove",h=!1;this.isTouchDevice()&&!0!==this.touchmode&&(h=!0,f=a.jqx.mobile.getTouchEventName("touchstart"),g=a.jqx.mobile.getTouchEventName("touchmove"));this.addHandler(c,"dragstart",function(k){return!1});this.addHandler(c,
1381f,function(k){if(!d.showgroupsheader)return!0;var l=k.pageX,m=k.pageY;d.__drag=!0;d.dragmousedown={left:l,top:m};h&&(m=d.getTouches(k)[0],l=m.pageX,m=m.pageY,d.dragmousedown={left:l,top:m},k.preventDefault&&k.preventDefault());k=a(k.target).coord();d.dragmousedownoffset={left:parseInt(l)-parseInt(k.left),top:parseInt(m-k.top)}});this.addHandler(c,g,function(k){if(!d.showgroupsheader)return!0;
1381if(d.dragmousedown){e={left:k.pageX,top:k.pageY};if(h){var l=d.getTouches(k)[0];e={left:l.pageX,top:l.pageY}}!d.dragstarted&&
1382null==d.dragcolumn&&(l=Math.abs(e.top-d.dragmousedown.top),3<Math.abs(e.left-d.dragmousedown.left)||3<l)&&(d._createdragcolumn(c,e,!0),a(document.body).addClass("jqx-disableselect"),a.data(d.dragcolumn[0],"datarecord",b),k.preventDefault&&k.preventDefault())}},{passive:!1})},_createdragcolumn:function(b,c,d){this.dragcolumn=a("<div></div>");var e=b.clone();this.dragcolumn.css("z-index",999999);e.css("border-width","1px");e.css("opacity","0.4");var f=a(e.find("."+this.toThemeProperty("jqx-grid-column-menubutton")));
13830<f.length&&f.css("display","none");f=a(e.find(".jqx-icon-close"));0<f.length&&f.css("display","none");this.dragcolumnicon=a('<div style="z-index: 9999; position: absolute; left: 100%; top: 50%; margin-left: -18px; margin-top: -7px;"></div>');this.dragcolumnicon.addClass(this.toThemeProperty("jqx-grid-drag-icon"));this.dragcolumn.css("float","left");this.dragcolumn.css("position","absolute");this.host.coord();e.width(b.width()+16);this.dragcolumn.append(e);this.dragcolumn.height(b.height());this.dragcolumn.width(e.width());
1384this.dragcolumn.append(this.dragcolumnicon);a(document.body).append(this.dragcolumn);e.css("margin-left",0);e.css("left",0);e.css("top",0);this.dragcolumn.css("left",c.left+this.dragmousedown.left);this.dragcolumn.css("top",c.top+this.dragmousedown.top);void 0!=d&&d&&(this.dropline=a('<div style="display: none; position: absolute;"></div>'),this.dropline.width(2),this.dropline.addClass(this.toThemeProperty("jqx-grid-group-drag-line")),a(document.body).append(this.dropline))},iscolumngroupable:function(b){return this._getcolumnproperty(b,
1385"groupable")},_handlecolumnstogroupsdragdrop:function(b,c){this.dragmousedownoffset=this.dragmousedown=null;this.dragstarted=!1;this.dragcolumn=null;var d=this,e=!1;this.isTouchDevice()&&!0!==this.touchmode&&(e=!0);var f="mousedown.drag";var g="mousemove.drag";e?(f=a.jqx.mobile.getTouchEventName("touchstart")+".drag",g=a.jqx.mobile.getTouchEventName("touchmove")+".drag"):this.addHandler(c,"dragstart",function(h){return!1});this.addHandler(c,f,function(h){if(!d.showgroupsheader)return!0;d.__drag=!0;
1386if(d._isColumnInGroups(b.displayfield))return c.css("cursor"),!0;if(0==b.groupable)return!0;var k=h.pageX,l=h.pageY;e&&(l=d.getTouches(h)[0],k=l.pageX,l=l.pageY);d.dragmousedown={left:k,top:l};e&&h.preventDefault&&h.preventDefault();h=a(h.target).coord();d.dragmousedownoffset={left:parseInt(k)-parseInt(h.left),top:parseInt(l-h.top)}});this.addHandler(c,g,function(h){if(!d.showgroupsheader)return!0;if(d._isColumnInGroups(b.displayfield))return c.css("cursor"),!0;if(d.dragmousedown){var k=h.pageX,l=
1387h.pageY;e&&(l=d.getTouches(h)[0],k=l.pageX,l=l.pageY);g={left:k,top:l};!d.dragstarted&&null==d.dragcolumn&&(k=Math.abs(g.top-d.dragmousedown.top),3<Math.abs(g.left-d.dragmousedown.left)||3<k)&&(d._createdragcolumn(c,g,!0),a.data(d.dragcolumn[0],"datarecord",b.displayfield),h.preventDefault&&h.preventDefault())}})},_rendergroupcolumn:function(b,c){var d=a('<div style="float: left; position: relative;"></div>');this.rtl&&d.css("float","right");null!=this.groupcolumnrenderer&&(d[0].innerHTML=this.groupcolumnrenderer(b),
1388d.addClass(this.toThemeProperty("jqx-grid-group-column")),d.addClass(this.toThemeProperty("jqx-fill-state-normal")));if(this.closeablegroups){""==d[0].innerHTML&&(d[0].innerHTML='<a style="float: left;" href="#">'+b+"</a>");this.rtl&&(d[0].innerHTML='<a style="float: right;" href="#">'+b+"</a>");b=this.rtl?"left":"right";var e='<div style="float: '+b+'; min-height: 16px; min-width: 18px;"><div style="position: absolute; left: 100%; top: 50%; margin-left: -18px; margin-top: -8px; float: none; width: 16px; height: 16px;" class="'+
1389this.toThemeProperty("jqx-icon-close")+'"></div></div>';a.jqx.browser.msie&&8>a.jqx.browser.version&&(e='<div style="float: left; min-height: 16px; min-width: 18px;"><div style="position: absolute; left: 100%; top: 50%; margin-left: -18px; margin-top: -8px; float: none; width: 16px; height: 16px;" class="'+this.toThemeProperty("jqx-icon-close")+'"></div></div>');this.rtl&&(e='<div style="float: '+b+'; min-height: 16px; min-width: 18px;"><div style="position: absolute; left: 0px; top: 50%; margin-top: -8px; float: none; width: 16px; height: 16px;" class="'+
1390this.toThemeProperty("jqx-icon-close")+'"></div></div>',a.jqx.browser.msie&&8>a.jqx.browser.version&&(e='<div style="float: left; min-height: 16px; min-width: 18px;"><div style="position: absolute; left: 0px; top: 50%; margin-top: -8px; float: none; width: 16px; height: 16px;" class="'+this.toThemeProperty("jqx-icon-close")+'"></div></div>'));d[0].innerHTML+=e}else""==d[0].innerHTML&&(d[0].innerHTML='<a href="#">'+b+"</a>");this.sortable&&(b=a('<div style="float: right; min-height: 16px; min-width: 18px;"><div style="position: absolute; left: 100%; top: 50%; margin-left: -16px; margin-top: -8px; float: none; width: 16px; height: 16px;" class="'+
1391this.toThemeProperty("jqx-grid-column-sortascbutton")+'"></div></div>'),e=a('<div style="float: right; min-height: 16px; min-width: 18px;"><div style="position: absolute; left: 100%; top: 50%; margin-left: -16px; margin-top: -8px; float: none; width: 16px; height: 16px;" class="'+this.toThemeProperty("jqx-grid-column-sortdescbutton")+'"></div></div>'),this.closeablegroups&&(b=a('<div style="float: right; min-height: 16px; min-width: 18px;"><div style="position: absolute; left: 100%; top: 50%; margin-left: -32px; margin-top: -8px; float: none; width: 16px; height: 16px;" class="'+
1392this.toThemeProperty("jqx-grid-column-sortascbutton")+'"></div></div>'),e=a('<div style="float: right; min-height: 16px; min-width: 18px;"><div style="position: absolute; left: 100%; top: 50%; margin-left: -32px; margin-top: -8px; float: none; width: 16px; height: 16px;" class="'+this.toThemeProperty("jqx-grid-column-sortdescbutton")+'"></div></div>')),this.rtl&&(b=a('<div style="float: right; min-height: 16px; min-width: 18px;"><div style="position: absolute; left: 0px; top: 50%; margin-left: 0px; margin-top: -8px; float: none; width: 16px; height: 16px;" class="'+
1393this.toThemeProperty("jqx-grid-column-sortascbutton")+'"></div></div>'),e=a('<div style="float: right; min-height: 16px; min-width: 18px;"><div style="position: absolute; left: 0px; top: 50%; margin-left: 0px; margin-top: -8px; float: none; width: 16px; height: 16px;" class="'+this.toThemeProperty("jqx-grid-column-sortdescbutton")+'"></div></div>'),this.closeablegroups&&(b=a('<div style="float: right; min-height: 16px; min-width: 18px;"><div style="position: absolute; left: 0px; top: 50%; margin-left: 16px; margin-top: -8px; float: none; width: 16px; height: 16px;" class="'+
1394this.toThemeProperty("jqx-grid-column-sortascbutton")+'"></div></div>'),e=a('<div style="float: right; min-height: 16px; min-width: 18px;"><div style="position: absolute; left: 0px; top: 50%; margin-left: 16px; margin-top: -8px; float: none; width: 16px; height: 16px;" class="'+this.toThemeProperty("jqx-grid-column-sortdescbutton")+'"></div></div>'))),b.css("display","none"),e.css("display","none"),a.jqx.browser.msie&&8>a.jqx.browser.version&&(b.css("float","left"),e.css("float","left")),d.append(b),
1395d.append(e),a.data(document.body,"groupsortelements"+c,{sortasc:b,sortdesc:e}));d.addClass(this.toThemeProperty("jqx-fill-state-normal"));d.addClass(this.toThemeProperty("jqx-grid-group-column"));return d},_rendergroup:function(b,c,d,e,f,g,h){e=c.cells[d.level];this.rtl&&(e=c.cells[c.cells.length-1-d.level]);var k=this._findgroupstate(d.uniqueid);if(0<d.bounddata.subGroups.length||0<d.bounddata.subItems.length)f=this.rtl?"-rtl":"",g=this.toThemeProperty("jqx-icon-arrow-right"),f&&(g=this.toThemeProperty("jqx-icon-arrow-left")),
1396e.className=k?e.className+(" "+this.toThemeProperty("jqx-grid-group-expand"+f)+" "+this.toThemeProperty("jqx-icon-arrow-down")):e.className+(" "+this.toThemeProperty("jqx-grid-group-collapse"+f)+" "+g);f=this._getColumnText(this.groups[d.level]).label;e=this.groupindentwidth;
1396var l=this.rowdetails&&this.showrowdetailscolumn?(1+b)*e:b*e,m=h-l;g=d.level+1;this.rtl&&(g=0);b=c.cells[g];for(l=2;void 0!=b&&"none"==b.style.display&&l<c.cells.length-1;)b=c.cells[g+l-1],l++;g=a(b);if(b){b.style.width=parseInt(m)+
1397"px";-1!=b.className.indexOf("jqx-grid-cell-filter")&&g.removeClass(this.toThemeProperty("jqx-grid-cell-filter"));-1!=b.className.indexOf("jqx-grid-cell-sort")&&g.removeClass(this.toThemeProperty("jqx-grid-cell-sort"));-1!=b.className.indexOf("jqx-grid-cell-pinned")&&g.removeClass(this.toThemeProperty("jqx-grid-cell-pinned"));if(null!=this.groupsrenderer)if(m={group:d.group,level:d.level,parent:d.bounddata.parentItem,subGroups:d.bounddata.subGroups,subItems:d.bounddata.subItems,groupcolumn:this._getColumnText(this.groups[d.level]).column},
1398k=this.groupsrenderer(f+": "+d.group,d.group,k,m))b.innerHTML=k,c.classList.add("jqx-grid-groups-custom-row"),this.theme&&c.classList.add("jqx-grid-groups-custom-row-"+this.theme);else{k=0<d.bounddata.subItems.length?d.bounddata.subItems.length:d.bounddata.subGroups.length;if(this.showgroupaggregates)for(m=0<d.bounddata.subItems.length?d.bounddata.subItems:d.bounddata.subGroups,l=k=0;l<m.length;l++)m[l].totalsrow||k++;b.innerHTML='<div class="'+this.toThemeProperty("jqx-grid-groups-row")+'" style="position: absolute;"><span>'+
1399f+': </span><span class="'+this.toThemeProperty("jqx-grid-groups-row-details")+'">'+d.group+" ("+k+")</span></div>"}else{var n=this._getcolumnbydatafield(this.groups[d.level]),r=d.group;if(null!=n){n.cellsformat&&a.jqx.dataFormat&&(a.jqx.dataFormat.isDate(r)?r=a.jqx.dataFormat.formatdate(r,n.cellsformat,this.gridlocalization):a.jqx.dataFormat.isNumber(r)&&(r=a.jqx.dataFormat.formatnumber(r,n.cellsformat,this.gridlocalization)));k=0<d.bounddata.subItems.length?d.bounddata.subItems.length:d.bounddata.subGroups.length;
1400if(this.showgroupaggregates)for(m=0<d.bounddata.subItems.length?d.bounddata.subItems:d.bounddata.subGroups,l=k=0;l<m.length;l++)m[l].totalsrow||k++;b.innerHTML='<div class="'+this.toThemeProperty("jqx-grid-groups-row")+'" style="position: absolute;"><span>'+f+': </span><span class="'+this.toThemeProperty("jqx-grid-groups-row-details")+'">'+r+" ("+k+")</span></div>"}else throw Error("jqxGrid: Unable to find '"+this.groups[d.level]+"' group in the Grid's columns collection.");}this.rtl&&(n||=this._getcolumnbydatafield(this.groups[d.level]),
1401f="hidden"==this.hScrollBar.css("visibility")?0:this.hScrollInstance.max-this.hScrollInstance.value,k="hidden"==this.vScrollBar.css("visibility")?0:this.scrollbarsize+6,l=this.rowdetails&&this.showrowdetailscolumn?(2+d.level)*e:(1+d.level)*e,b.style.width=h+parseInt(f)-l-k+"px",g.addClass(this.toThemeProperty("jqx-rtl")),e=a(c.cells[c.cells.length-1]).css("z-index"),g.css("z-index",e),e=g.find("div"),m=e.width(),e.css("left","100%"),c=null!=this.columns.records[c.cells.length-2-d.level]?this.columns.records[c.cells.length-
14022-d.level].pinned:!1,this.table.width()<h&&(h=this.table.width(),"hidden"!=this.vScrollBar.css("visibility")&&(h+=this.vScrollBar.outerWidth())),n.pinned||c?(this.rowdetails&&this.showrowdetailscolumn&&(h+=30),e.css("margin-left",-m),b.style.width=h+f-l-k+"px"):(f="hidden"==this.hScrollBar.css("visibility")?0:this.hScrollInstance.max,b.style.width=h+f-l-k+"px",m=e.width(),e.css("margin-left",-m)))}}})})(jqxBaseFramework);
1403(function(a){a.extend(a.jqx._jqxGrid.prototype,{autoresizecolumns:function(b,c){"cells"!=b&&"all"!=b&&"column"!=b&&(b="all");var d=this.that,e=this.getrows();this.pageable&&(e=this.dataview.rows,this.groupable&&(e=this.dataview.records));c=void 0==c?0:parseInt(c);var f=e.length;if(void 0==f&&void 0!=e){var g=[];a.each(e,function(ha){g.push(this)});e=g;f=e.length}var h=a("<span></span>");h.addClass(this.toThemeProperty("jqx-widget"));h.addClass(this.toThemeProperty("jqx-grid-cell"));a(document.body).append(h);
1404var k=[],l=[],m=[],n=[],r=d.host.width();
1404"hidden"!=d.vScrollBar[0].style.visibility&&(r-=this.scrollbarsize+5);0>r&&(r=0);for(var t=0;t<f;t++){var u=e[t];for(r=0;r<this.columns.records.length;r++){var x=this.columns.records[r];if(!(x.hidden||0<this.groups.length&&r<=this.groups.length-1)){void 0==l[x.displayfield]&&(l[x.displayfield]=0);void 0==m[x.displayfield]&&(m[x.displayfield]="");var B=u[x.displayfield];""!=x.cellsformat?a.jqx.dataFormat&&(a.jqx.dataFormat.isDate(B)?B=a.jqx.dataFormat.formatdate(B,
1405x.cellsformat,this.gridlocalization):a.jqx.dataFormat.isNumber(B)&&(B=a.jqx.dataFormat.formatnumber(B,x.cellsformat,this.gridlocalization))):x.cellsrenderer&&(k=d._defaultcellsrenderer(B,x),k=x.cellsrenderer(t,x.datafield,B,k,x.getcolumnproperties(),u),void 0!=k&&(B=a(k).text()));if((void 0==b||"cells"==b||"all"==b)&&null!=B){k=B.toString().length;var y=B.toString();y=y.replace(/[^A-Z]/g,"").length;k>l[x.displayfield]&&(l[x.displayfield]=k,m[x.displayfield]=B,n[x.displayfield]=y);if(0<k&&k>=y){var A=
140620*y+15*(k-y),aa=20*n[x.displayfield]+15*(l[x.displayfield]-n[x.displayfield]);A>aa&&0<A&&0<aa&&(l[x.displayfield]=k,m[x.displayfield]=B,n[x.displayfield]=y)}}if("column"==b||"all"==b)x.text.toString().length>l[x.displayfield]&&(m[x.displayfield]=x.text,l[x.displayfield]=x.text.length,y=x.text.toString(),y=y.replace(/[^A-Z]/g,"").length,n[x.displayfield]=y),B=x.text,k=B.toString().length,y=B.toString(),y=y.replace(/[^A-Z]/g,"").length,0<k&&k>=y&&(A=20*y+15*(k-y),aa=20*n[x.displayfield]+15*(l[x.displayfield]-
1407n[x.displayfield]),A>aa&&0<A&&0<aa&&(l[x.displayfield]=k,m[x.displayfield]=B,n[x.displayfield]=y))}}}if(this.columns.records){for(r=0;r<this.columns.records.length;r++)if(x=this.columns.records[r],x.displayfield&&(void 0==m[x.displayfield]&&(m[x.displayfield]=x.text),0<=h[0].className.indexOf("jqx-grid-column-header")&&h.removeClass(this.toThemeProperty("jqx-grid-column-header")),m[x.displayfield]==x.text&&h.addClass(this.toThemeProperty("jqx-grid-column-header")),h[0].innerHTML=this.escape_HTML(m[x.displayfield].toString()),
1408b=h.outerWidth()+10,0<h.children().length&&(b=h.children().outerWidth()+10),a.jqx.browser.msie&&8>a.jqx.browser.version&&(b+=10),this.filterable&&this.showfilterrow&&(b+=5),b+=c,b+=20,b>x.maxwidth&&(b=x.maxwidth),void 0!=x._width&&(x.__width=x._width),x._width=null,"auto"==x.maxwidth||b<=x.maxwidth))d=x.width,b<x.minwidth&&(b=x.minwidth),x.width=b,void 0!=x._percentagewidth&&(x._percentagewidth=null),this._raiseEvent(14,{columntext:x.text,column:x.getcolumnproperties(),datafield:x.datafield,displayfield:x.displayfield,
1409oldwidth:d,newwidth:b});h.remove();this._updatecolumnwidths();this._updatecellwidths();this._renderrows(this.virtualsizeinfo);for(r=0;r<this.columns.records.length;r++)x=this.columns.records[r],void 0!=x.__width&&(x._width=x.__width)}},autoresizecolumn:function(b,c,d){"cells"!=c&&"all"!=c&&"column"!=c&&(c="all");if(void 0==b)return!1;var e=this.getrows();this.pageable&&(e=this.dataview.rows,this.groupable&&(e=this.dataview.records));var f=this.getcolumn(b);if(void 0==f)return!1;d=void 0==d?0:parseInt(d);
1410var g=e.length,h=a("<span></span>");h.addClass(this.toThemeProperty("jqx-widget"));h.addClass(this.toThemeProperty("jqx-grid-cell"));a(document.body).append(h);var k=0,l="",m=0;this.that.host.width();if(void 0==c||"cells"==c||"all"==c)for(var n=0;n<g;n++){var r=e[n][f.displayfield];if(""!=f.cellsformat)a.jqx.dataFormat&&(a.jqx.dataFormat.isDate(r)?r=a.jqx.dataFormat.formatdate(r,f.cellsformat,this.gridlocalization):a.jqx.dataFormat.isNumber(r)&&(r=a.jqx.dataFormat.formatnumber(r,f.cellsformat,this.gridlocalization)));
1411else if(f.cellsrenderer){var t=f.cellsrenderer(n,f,r);void 0!=t&&(r=a(t).text())}if(null!=r){t=r.toString().length;var u=r.toString();u=u.replace(/[^A-Z]/g,"").length;t>k&&(k=t,l=r,m=u);if(0<t&&t>=u){var x=20*u+15*(t-u),B=20*m+15*(k-m);x>B&&0<x&&0<B&&(k=t,l=r,m=u)}}}if("column"==c||"all"==c)f.text.toString().length>k&&(l=f.text),r=f.text.toString(),t=r.toString().length,u=r.toString(),u=u.replace(/[^A-Z]/g,"").length,0<t&&t>=u&&(x=20*u+15*(t-u),B=20*m+15*(k-m),x>B&&0<x&&0<B&&(l=r));void 0==l&&(l=
1412f.text);h[0].innerHTML=this.escape_HTML(l);l==f.text&&h.addClass(this.toThemeProperty("jqx-grid-column-header"));c=h.outerWidth()+10;a.jqx.browser.msie&&8>a.jqx.browser.version&&(c+=5);this.filterable&&this.showfilterrow&&(c+=5);c+=d;h.remove();c>f.maxwidth&&(c=f.maxwidth);if("auto"==f.maxwidth||c<=f.maxwidth)d=f.width,c<f.minwidth&&(c=f.minwidth),f.width=c,void 0!=f._width&&(f.__width=f._width),f._width=null,void 0!=f._percentagewidth&&(f._percentagewidth=null),this._updatecolumnwidths(),this._updatecellwidths(),
1413this._raiseEvent(14,{columntext:f.text,column:f.getcolumnproperties(),datafield:b,displayfield:f.displayfield,oldwidth:d,newwidth:c}),this._renderrows(this.virtualsizeinfo),void 0!=f._width&&(f._width=f.__width)},_handlecolumnsresize:function(){var b=this.that;if(this.columnsresize){var c=!1;b.isTouchDevice()&&!0!==b.touchmode&&(c=!0);
1413var d="mousemove.resize"+this.element.id,e="mousedown.resize"+this.element.id,f="mouseup.resize"+this.element.id;c&&(d=a.jqx.mobile.getTouchEventName("touchmove")+".resize"+
1414this.element.id,e=a.jqx.mobile.getTouchEventName("touchstart")+".resize"+this.element.id,f=a.jqx.mobile.getTouchEventName("touchend")+".resize"+this.element.id);this.removeHandler(a(document),d);this.addHandler(a(document),d,function(h){if(null!=a.data(document.body,"contextmenu"+b.element.id)&&b.autoshowcolumnsmenubutton)return!0;if(null!=b.resizablecolumn&&!b.disabled&&b.resizing&&null!=b.resizeline){var k=b.host.coord(),l=parseInt(b.resizestartline.coord().left),m=l-b._startcolumnwidth,n=b.resizablecolumn.column.minwidth;
1415n="auto"==n?0:parseInt(n);var r=b.resizablecolumn.column.maxwidth;r="auto"==r?0:parseInt(r);var t=h.pageX;c&&(t=b.getTouches(h)[0].pageX);m+=n;n=0<r?l+r:0;l=0==r?!0:b._startcolumnwidth+t-l<r?!0:!1;b.rtl&&(l=!0);if(l)if(!b.rtl){if(t>=k.left&&t>=m&&(0!=n&&h.pageX<n?b.resizeline.css("left",t):0==n&&b.resizeline.css("left",t),c))return!1}else if(t>=k.left&&t<=k.left+b.host.width()&&(b.resizeline.css("left",t),c))return!1}if(!c&&null!=b.resizablecolumn)return!1});this.removeHandler(a(document),e);this.addHandler(a(document),
1416e,function(h){if(null!=a.data(document.body,"contextmenu"+b.element.id)&&b.autoshowcolumnsmenubutton)return!0;if(null!=b.resizablecolumn&&!b.disabled){var k=b.resizablecolumn.columnelement;if(k.coord().top+k.height()+5<h.pageY)b.resizablecolumn=null;else if(k.coord().top-5>h.pageY)b.resizablecolumn=null;else{b._startcolumnwidth=b.resizablecolumn.column.width;b.resizablecolumn.column._width=null;a(document.body).addClass("jqx-disableselect");a(document.body).addClass("jqx-position-reset");b.host.addClass("jqx-disableselect");
1417b.content.addClass("jqx-disableselect");b._mouseDownResize=new Date;b.resizing=!0;if(b._lastmouseDownResize&&b.columnsautoresize&&300>b._lastmouseDownResize-b._mouseDownResize&&-500<b._lastmouseDownResize-b._mouseDownResize&&(k=b.resizablecolumn.column,k.resizable)){var l=b.hScrollBar[0].style.visibility;b._resizecolumn=null;b.resizeline.hide();b.resizestartline.hide();b.resizebackground.remove();b.resizablecolumn=null;b.columndragstarted=!1;b.dragmousedown=null;b.__drag=!1;b.autoresizecolumn(k.displayfield,
1418"all");l!=b.hScrollBar[0].style.visibility&&b.hScrollInstance.setPosition(0);b.rtl&&b._arrange();b.autosavestate&&b.savestate&&b.savestate();h.stopPropagation();b.suspendClick=!0;setTimeout(function(){b.suspendClick=!1},100);return!1}b._lastmouseDownResize=new Date;b._resizecolumn=b.resizablecolumn.column;b.resizeline=b.resizeline||a('<div style="position: absolute;"></div>');b.resizestartline=b.resizestartline||a('<div style="position: absolute;"></div>');b.resizebackground=b.resizebackground||a('<div style="position: absolute; left: 0; top: 0; background: #000;"></div>');
1419b.resizebackground.css("opacity",.01);b.resizebackground.css("cursor","col-resize");b.resizeline.css("cursor","col-resize");b.resizestartline.css("cursor","col-resize");b.resizeline.addClass(b.toThemeProperty("jqx-grid-column-resizeline"));b.resizestartline.addClass(b.toThemeProperty("jqx-grid-column-resizestartline"));a(document.body).append(b.resizeline);a(document.body).append(b.resizestartline);a(document.body).append(b.resizebackground);var m=b.resizablecolumn.columnelement.coord();b.resizebackground.css("left",
1420b.host.coord().left);b.resizebackground.css("top",b.host.coord().top);b.resizebackground.width(b.host.width());b.resizebackground.height(b.host.height());b.resizebackground.css("z-index",9999);h=function(n){b.rtl?n.css("left",parseInt(m.left)):n.css("left",parseInt(m.left)+b._startcolumnwidth);var r=b._groupsheader()?b.groupsheader.height():0;r=r+(b.showtoolbar?b.toolbarheight:0)+(b.showstatusbar?b.statusbarheight:0);var t=0;b.pageable&&(t=b.pagerheight);var u="visible"==b.hScrollBar.css("visibility")?
142117:0;n.css("top",parseInt(m.top));n.css("z-index",99999);b.columngroups?n.height(b.host.height()+b.resizablecolumn.columnelement.height()-t-r-u-b.columngroupslevel*b.columnsheight):n.height(b.host.height()-t-r-u);b.enableanimations?n.show("fast"):n.show()};h(b.resizeline);h(b.resizestartline);b.dragmousedown=null}}});var g=function(){a(document.body).removeClass("jqx-disableselect");a(document.body).removeClass("jqx-position-reset");if(b.showfilterrow||b.showstatusbar||b.showtoolbar||b.enablebrowserselection)b.host.removeClass("jqx-disableselect"),
1422b.content.removeClass("jqx-disableselect");if(b.resizing)if(b._mouseUpResize=new Date,200>b._mouseUpResize-b._mouseDownResize)b.resizing=!1,null!=b._resizecolumn&&null!=b.resizeline&&"block"==b.resizeline.css("display")&&(b._resizecolumn=null,b.resizeline.hide(),b.resizestartline.hide(),b.resizebackground.remove());else if(b.resizing=!1,!b.disabled){var h=b.host.width();
1422"hidden"!=b.vScrollBar[0].style.visibility&&(h-=20);0>h&&(h=0);if(null!=b._resizecolumn&&null!=b.resizeline&&"block"==b.resizeline.css("display")){var k=
1423parseInt(b.resizeline.css("left")),l=parseInt(b.resizestartline.css("left")),m=b._startcolumnwidth+k-l;b.rtl&&(m=b._startcolumnwidth-k+l);k=b._resizecolumn.width;b._closemenu();m<b._resizecolumn.minwidth&&(m=b._resizecolumn.minwidth);b._resizecolumn.width=m;void 0!=b._resizecolumn._percentagewidth&&(b._resizecolumn._percentagewidth=m/h*100);for(h=0;h<b._columns.length;h++)if(b._columns[h].datafield===b._resizecolumn.datafield){b._columns[h].width=b._resizecolumn.width;b._columns[h].width<b._resizecolumn.minwidth&&
1424(b._columns[h].width=b._resizecolumn.minwidth);break}h=b.hScrollBar[0].style.visibility;b._updatecolumnwidths();b._updatecellwidths();b._raiseEvent(14,{columntext:b._resizecolumn.text,column:b._resizecolumn.getcolumnproperties(),datafield:b._resizecolumn.datafield,oldwidth:k,newwidth:m});b._renderrows(b.virtualsizeinfo);b.autosavestate&&b.savestate&&b.savestate();h!=b.hScrollBar[0].style.visibility&&b.hScrollInstance.setPosition(0);b.rtl&&b._arrange();b._resizecolumn=null;b.resizeline.hide();b.resizestartline.hide();
1425b.resizebackground.remove()}b.resizablecolumn=null}};try{if(""!=document.referrer||window.frameElement)d=null,null!=window.top&&window.top!=window.self&&window.parent&&document.referrer&&(d=document.referrer),d&&-1!=d.indexOf(document.location.host)&&(d=function(h){g()},window.top.document.addEventListener?window.top.document.addEventListener("mouseup",d,!1):window.top.document.attachEvent&&window.top.document.attachEvent("onmouseup",d))}catch(h){}this.removeHandler(a(document),f);this.addHandler(a(document),
1426f,function(h){if(null!=a.data(document.body,"contextmenu"+b.element.id)&&b.autoshowcolumnsmenubutton)return!0;g()})}}})})(jqxBaseFramework);
1427(function(a){a.jqx.dataview.sort=function(){this.sortby=function(b,c,d){var e=Object.prototype.toString;if(null==c&&(this.sortdata=null,"many"!==this.grid.sortmode?this.sortcache={}:this.sortcache[b]&&delete this.sortcache[b],this.grid._pagescache=[],this.grid._cellscache=[],"many"!==this.grid.sortmode)){this.refresh();return}"many"===this.grid.sortmode&&(this.grid._pagescache=[],this.grid._cellscache=[]);null!=c&&(c="a"==c||"asc"==c||"ascending"==c||1==c?!0:!1);var f=b;this.sortfield=b;this.sortfielddirection=
1428c?"asc":"desc";null==c&&(this.sortfielddirection=null);void 0==this.sortcache&&(this.sortcache={});this.sortdata=[];var g=[],h=!1;"constructor"==f&&(f="");if(!this.virtualmode&&null!=this.sortcache[f]&&"many"!==this.grid.sortmode){var k=this.sortcache[f];g=k._sortdata;k.direction==c?g.reverse():(!k.direction&&c&&g.reverse(),h=!0);g.length<this.totalrecords&&(this.sortcache={},h=!1,g=[])}Object.prototype.toString="function"==typeof b?b:function(){return this[b]};var l=this.records,m="";this.source.datafields&&
1429a.each(this.source.datafields,function(){if(this.name==b)return this.type&&(m=this.t
1429ype),!1});if(0==g.length)if(l.length)for(var n=l.length,r=0;r<n;r++)k=l[r],null!=k&&g.push({sortkey:k.toString(),value:k,index:r});else{r=!1;for(n in l){k=l[n];if(void 0==k){r=!0;break}g.push({sortkey:k.toString(),value:k,index:n})}r&&a.each(l,function(x,B){g.push({sortkey:B.toString(),value:B,index:x})})}if(!h)if(null==d){this._sortcolumntype=m;var t=this;g.sort(function(x,B){return t._compare(x,B,m)})}else g.sort(d);
1430c||g.reverse();Object.prototype.toString=e;this.sortdata=g;null!==c&&(this.sortcache[f]={_sortdata:g,direction:c,dataType:this._sortcolumntype,dataField:f});if("many"===this.grid.sortmode){c=[];d=[];e=[];for(var u in this.sortcache)"data"!==u&&(k=this.sortcache[u],c.push(k.dataField),d.push(k.direction?"asc":"desc"),e.push(k.dataType));if(0<c.length)l=this.multiSort(l,c,d,e),g=[],l&&a.each(l,function(x,B){g.push({sortkey:f,value:B,index:B.boundindex})}),this.sortdata=g;else{this.sortcache={};this.sortdata=
1431null;this.refresh();return}}this.reload(this.records,this.rows,this.filters,this.updated,!0)};this.multiSort=function(b,c,d,e,f){if(0===b.length)return[];for(var g=[],h=0;h<b.length;h++){var k=a.extend({},b[h]);g.push(k)}h=!1;g&&g.constructor&&"ObservableArray"===g.constructor.name&&(h=!0);if((!(g&&g instanceof Array&&0!==g.length&&c)||c instanceof Array&&0===c.length)&&!h)throw Error("sort: Missing or Invalid arguments!");"string"===typeof c&&(c=[c]);var l=[],m=[];void 0===d&&(d=[]);b=function(n,
1432r){switch(r||typeof n){default:var t=(new Intl.Collator).compare;break;case "date":case "time":case "datetime":case "number":case "int":case "float":t=function(u,x){return u-x};break;case "boolean":t=function(u,x){return u===x?0:!1===u?-1:1};break;case "object":n instanceof Date&&(t=function(u,x){return u.getTime()-x.getTime()})}return t};for(h=0;h<c.length;h++)l[h]=void 0===d[h]||"asc"===d[h]||"ascending"===d[h]?1:-1,m[h]=b(g[0][c[h]],e[h]);if(f)f(g,c,d,m);else return g.sort(function(n,r){for(var t=
14330;t<c.length;t++){var u=m[t](n[c[t]],r[c[t]]);if(0===u){if(c[t+1])continue;else if(void 0!==n._index)return(n._index-r._index)*l[t];return 0}return u*l[t]}if(0===c.length)return n.boundIndex<r.boundIndex?-1:n.boundIndex>
1433r.boundIndex?1:0}),g};this.clearsortdata=function(){this.sortcache={};this.sortdata=null};this._compare=function(b,c,d){b=b.sortkey;c=c.sortkey;void 0===b&&(b=null);void 0===c&&(c=null);if(null===b&&null===c)return 0;if(null===b&&null!==c)return-1;if(null!==b&&null===c)return 1;if(a.jqx.dataFormat)if(d&&
1434""!=d)switch(d){case "string":case "text":b=String(b).toLowerCase(),c=String(c).toLowerCase()}else{if(a.jqx.dataFormat.isNumber(b)&&a.jqx.dataFormat.isNumber(c)||a.jqx.dataFormat.isDate(b)&&a.jqx.dataFormat.isDate(c))return b<c?-1:b>c?1:0;a.jqx.dataFormat.isNumber(b)||a.jqx.dataFormat.isNumber(c)||(b=String(b).toLowerCase(),c=String(c).toLowerCase())}return b<c?-1:b>c?1:0};this._equals=function(b,c){return 0===this._compare(b,c)}};a.extend(a.jqx._jqxGrid.prototype,{_rendersortcolumn:function(){var b=
1435this.that,c=this.getsortcolumn();if("many"===this.sortmode){this.__columnsbydatafield=[];var d=this.getsortcolumns();a.each(this.columns.records,function(h,k){a(this.sortasc).hide();a(this.sortdesc).hide();a(this.sorticon).css("visibility","hidden");this.element.removeAttribute("sort")});if(0<d.length)for(var e=0;e<d.length;e++){var f=d[e],g=this._getcolumnbydatafield(f.dataField);g.element.setAttribute("sort",!0);b.isMaterialized()||b.isModern()?(a(g.sorticon).show(),a(g.sorticon).css("visibility",
1436"inherit"),a(g.sorticon).removeClass("ascending"),a(g.sorticon).removeClass("descending"),f.ascending?a(g.sorticon).addClass("ascending"):a(g.sorticon).addClass("descending")):f.ascending?(a(g.sortasc).show(),a(g.sortdesc).hide()):!1===f.ascending&&(a(g.sortasc).hide(),a(g.sortdesc).show())}}else this.sortdirection&&(d=function(h,k){(h=b.getcolumn(h))&&(k.ascending?a.jqx.aria(h.element,"aria-sort","ascending"):k.descending?a.jqx.aria(h.element,"aria-sort","descending"):a.jqx.aria(h.element,"aria-sort",
1437"none"))},this._oldsortinfo&&this._oldsortinfo.column&&d(this._oldsortinfo.column,{ascending:!1,descending:!1}),d(c,this.sortdirection)),this._oldsortinfo={column:c,direction:this.sortdirection},this.sortdirection&&a.each(this.columns.records,function(h,k){h=a.data(document.body,"groupsortelements"+this.displayfield);null==c||this.displayfield!=c?(a(this.sortasc).hide(),a(this.sortdesc).hide(),a(this.sorticon).css("visibility","hidden"),a(this.sorticon).removeClass("ascending"),a(this.sorticon).removeClass("descending"),
1438this.element.removeAttribute("sort"),null!=h&&(h.sortasc.hide(),h.sortdesc.hide())):(b.isMaterialized()||b.isModern()?(a(this.sortasc).hide(),a(this.sortdesc).hide(),a(this.sorticon).show(),a(this.sorticon).css("visibility","inherit"),null!=h&&(h.sortasc.hide(),h.sortdesc.show()),a(this.sorticon).removeClass("ascending"),a(this.sorticon).removeClass("descending"),b.sortdirection.ascending?a(this.sorticon).addClass("ascending"):a(this.sorticon).addClass("descending")):b.sortdirection.ascending?(a(this.sortasc).show(),
1439a(this.sortdesc).hide(),null!=h&&(h.sortasc.show(),h.sortdesc.hide())):(a(this.sortasc).hide(),a(this.sortdesc).show(),null!=h&&(h.sortasc.hide(),h.sortdesc.show())),this.element.setAttribute("sort",!0))})},getsortcolumns:function(){var b=[];for(d in this.dataview.sortcache)"data"!==d&&b.push({dataField:d,ascending:this.dataview.sortcache[d].direction});if(0===b.length)for(var c in this.sortcolumns){var d=this.sortcolumns[c];null!==d&&b.push({dataField:c,ascending:d})}return b},getsortcolumn:function(){return void 0!=
1440this.sortcolumn?this.sortcolumn:null},removesort:function(){this.sortby(null);if("many"===this.sortmode)for(var b in this.sortcolumns)this.sortby(b,null)},sortby:function(b,c,d,e,f){if(this._loading&&!1!==f)throw Error("jqxGrid: "+this.loadingerrormessage);null==b&&(c=null,b=this.sortcolumn);if(void 0!=b){f=this.that;void 0==d&&f.source&&null!=f.source.sortcomparer&&(d=f.source.sortcomparer);void 0===c&&(c=!0);var g="a"==c||"asc"==c||"ascending"==c||1==c?!0:!1;f.sortdirection=null!=c?{ascending:g,
1441descending:!g}:{ascending:!1,descending:!1};f.sortcolumn=null!=c?b:null;f.sortcolumns||(f.sortcolumns=[]);f.sortcolumns[b]=c;if(f.source&&(f.source.sort||f.virtualmode)){if(f.dataview.sortfield=b,f.dataview.sortfielddirection=null==c?"":g?"asc":"desc",f.source.sort&&!this._loading){f.source.sort(b,c,f.sortcolumns);f._raiseEvent(6,{sortinformation:f.getsortinformation()});return}}else f.dataview.sortby(b,c,d);!1!==e&&(f.groupable&&0<f.groups.length?(f._render(!0,!1,!1),f._updategroupheadersbounds&&
1442f.showgroupsheader&&f._updategroupheadersbounds()):(f.pageable&&f.dataview.updateview(),f._updaterowsproperties(),f.rendergridcontent(!0)),f._postrender("sort"),f._raiseEvent(6,{sortinformation:f.getsortinformation()}))}},_togglesort:function(b){var c=this.that;if(!this.disabled)if("many"===this.sortmode){if(b.sortable&&c.sortable){for(var d=c.gets
1442ortcolumns(),e=0;e<d.length;e++){var f=d[e];if(b.displayfield===f.dataField){d=f.ascending;d=1<c.sorttogglestates?1==d?!1:null:!d;c.sortby(b.displayfield,
1443d,null);return}}c.sortby(b.displayfield,!0,null)}}else b.sortable&&c.sortable&&(d=c.getsortinformation(),null!=d.sortcolumn&&d.sortcolumn==b.displayfield?(d=d.sortdirection.ascending,d=1<c.sorttogglestates?1==d?!1:null:!d):d=!0,c.sortby(b.displayfield,d,null))}})})(jqxBaseFramework);
1444(function(a){a.jqx.jqxWidget("jqxToolBar","",{});a.extend(a.jqx._jqxToolBar.prototype,{defineInstance:function(){var b={width:"100%",minWidth:null,maxWidth:null,height:35,tools:"",initTools:null,minimizeWidth:200,disabled:!1,rtl:!1,events:["open","close"]};if(this===a.jqx._jqxToolBar.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(){if("none"===this.host.css("display")||!1===document.body.contains(this.element))this._initiallyHidden=!0;this._toolToWidgetMapping={button:"jqxButton",
1445toggleButton:"jqxToggleButton",dropdownlist:"jqxDropDownList",combobox:"jqxComboBox",input:"jqxInput"};this._toolChanges=[];this.render()},render:function(){var b=!0;this.element.innerHTML="";0<this.element.className.length&&this._removeClass(this.element,this.toThemeProperty("jqx-widget jqx-fill-state-normal jqx-rc-all jqx-toolbar jqx-fill-state-disabled"));this._setSize();this._destroyTools(!1);this._toolWidgets&&(b=!1,a(this._minimizeButton).remove(),a(this._minimizePopup).remove());this._appendMinimizeButton();
1446this._addClasses();this._initiallyHidden||this._createTools();!0===this.disabled&&(this.element.className+=" "+this.toThemeProperty("jqx-fill-state-disabled"),this._disableTools(!0));this._initiallyHidden||this._minimize();this._removeHandlers();this._addHandlers();!1===b&&0<this._toolChanges.length&&this._restoreChanges()},refresh:function(b){!0!==b&&this.render()},getTools:function(){return this._toolWidgets},destroy:function(){this._removeHandlers();this._destroyTools();this.host.remove()},_destroyTools:function(b){!1!==
1447b&&(b=!0);if(this._toolWidgets)for(var c=this._toolWidgets.length-1;0<=c;c--)this._destroyTool(c,b,!0)},_destroyTool:function(b,c,d){b=parseInt(b,10);var e=this._toolWidgets[b];if(e){var f=e.type,g=e.tool,h=e.menuTool;if("custom"!==f){if(g[this._toolToWidgetMapping[f]]("destroy"),h)h[this._toolToWidgetMapping[f]]("destroy")}else g.remove(),h&&h.remove();e.menuSeparator&&a(e.menuSeparator).remove();this._toolWidgets.splice(b,1);this._checkType(f)&&this._refreshButtonGroups();!0!==d&&this._minimize();
1448!1!==c&&this._toolChanges.push({action:"destroyTool",index:b})}},destroyTool:function(b){this._destroyTool(b,!0)},addTool:function(b,c,d,e){var f="first"===c?0:this._toolWidgets.length;if(this._toolWidgets[f-1]){var g=this._toolWidgets[f-1].tool;var h=this._toolWidgets[f-1].separatorAfterWidget?"|":this._toolWidgets[f-1].type}if(!0===d)var k="|";else this._toolWidgets[f+1]&&(k=this._toolWidgets[f+1].type);f=this._initializeTool(f,b,g,h,k,e,!1);"first"===c?this._toolWidgets.splice(0,0,f):this._toolWidgets.push(f);
1449this._removeHandlers();this._addHandlers();this._checkType(b)&&this._refreshButtonGroups();"first"!==c&&0<this._minimizedTools?this._minimizeTool(!0):this._minimize();this._toolChanges.push({action:"addTool",type:b,position:c,separator:d,initCallback:e})},_disableTools:function(b){for(var c=0;c<this._toolWidgets.length;c++)this.disableTool(c,b)},disableTool:function(b,c){b=parseInt(b,10);var d=this._toolWidgets[b];if(d){var e=d.type;"custom"!==e&&(d.tool[this._toolToWidgetMapping[e]]({disabled:c}),
1450d.menuTool[this._toolToWidgetMapping[e]]({disabled:c}));this._toolChanges.push({action:"disableTool",index:b,disable:c})}},propertyChangedHandler:function(b,c,d,e){if("initTools"!==c&&e!==d)switch(c){case "theme":""!==d&&(b._removeClass(b.element,b.toThemeProperty("jqx-widget-"+d+" jqx-fill-state-normal-"+d+" jqx-rc-all-"+d+" jqx-toolbar-"+d)),b._removeClass(b._minimizePopup,"jqx-popup-"+d+" jqx-fill-state-normal-"+d+" jqx-rc-b-"+d+" jqx-toolbar-minimized-popup-"+d));b._addClasses();b._minimizePopup.className+=
1451" "+b.toThemeProperty("jqx-popup jqx-fill-state-normal jqx-rc-b jqx-toolbar-minimized-popup");for(var f=0;f<b._toolWidgets.length;f++)c=b._toolWidgets[f],"custom"!==c.type&&(c.menuTool&&(c.menuSeparator&&(""!==d&&b._removeClass(c.menuSeparator,"jqx-fill-state-pressed-"+d+" jqx-toolbar-minimized-popup-separator-"+d),c.menuSeparator.className+=" jqx-fill-state-pressed-"+e+" jqx-toolbar-minimized-popup-separator-"+e),c.menuTool[b._toolToWidgetMapping[b._toolWidgets[f].type]]({theme:e})),c.tool[b._toolToWidgetMapping[b._toolWidgets[f].type]]({theme:e}));
1452a.jqx.utilities.setTheme(d,e,b.host);break;case "width":b.element.style.width=b._toPx(e);b._minimize();break;case "minWidth":b.element.style.minWidth=b._toPx(e);b._minimize();break;case "maxWidth":b.element.style.maxWidth=b._toPx(e);b._minimize();break;case "height":c=!1;b.element.style.height=b._toPx(e);if("string"===typeof e&&-1!==e.indexOf("%")){if("string"===typeof d&&-1!==d.indexOf("%")){b.host.trigger("resize");break}c=!0}else f=parseInt(e,10),f-=b._getComputedStyle(b.element,"paddingTop")+
1453b._getComputedStyle(b.element,"paddingBottom")+b._getComputedStyle(b.element,"borderTopWidth")+b._getComputedStyle(b.element,"borderBottomWidth");for(e=0;e<b._toolWidgets.length;e++){d=b._toolWidgets[e];var g=d.type;if("button"===g||"toggleButton"===g||"repeatButton"===g||"linkButton"===g)d.tool[0].style.height=c?"100%":b._toPx(f),d.menuTool&&(d.menuTool[0].style.height=c?"100%":b._toPx(f));else if("dropdownlist"===g||"combobox"===g||"input"===g)if(d.tool[b._toolToWidgetMapping[g]]({height:c?"100%":
1454f-2}),d.menuTool)d.menuTool[b._toolToWidgetMapping[g]]({height:c?"100%":f-2})}break;case "tools":b._removeHandlers();b._destroyTools();b._createTools();b._addHandlers();b._minimize();break;case "minimizeWidth":!0===b._isOpen?(f=b._getComputedStyle(b._minimizePopup,"left")-(e-d),b._minimizePopup.style.width=b._toPx(e),b._minimizePopup.style.left=b._toPx(f)):b._minimizePopup.style.width=b._toPx(e);break;case "rtl":b.render();break;case "disabled":!0===e?(b.element.className+=" "+b.toThemeProperty("jqx-fill-state-disabled"),
1455b._disableTools(!0)):(b._removeClass(b.element,b.toThemeProperty("jqx-fill-state-disabled")),b._disableTools(!1))}},_raiseEvent:function(b,c){void 0===c&&(c={owner:null});b=this.events[b];c.owner=this;b=new a.Event(b);b.owner=this;b.args=c;b.preventDefault&&b.preventDefault();return this.host.trigger(b)}
1455,_addClasses:function(){var b="jqx-widget jqx-fill-state-normal jqx-rc-all jqx-toolbar";!0===this.rtl&&(b+=" jqx-toolbar-rtl");this.element.className+=" "+this.toThemeProperty(b)},_checkType:function(b){return"button"===
1456b||"toggleButton"===b||"repeatButton"===b||"linkButton"===b?!0:!1},_refreshButtonGroups:function(){function b(n,r,t,u,x,B){var y=n.tool[0];n=n.menuTool[0];var A={add:"",remove:""};A[r]+=" jqx-toolbar-tool-inner-button";A[t]+=" jqx-rc-all";A[u]+=" jqx-rc-l";A[x]+=" jqx-rc-r";""!==A.add&&(y.className+=" "+c.toThemeProperty(a.trim(A.add)),n&&(n.className+=" "+c.toThemeProperty(a.trim(A.add))));""!==A.remove&&(c._removeClass(y,c.toThemeProperty(a.trim(A.remove))),n&&c._removeClass(n,c.toThemeProperty(a.trim(A.remove))));
1457y.style.borderLeftWidth=B+"px";n&&(n.style.borderLeftWidth=B+"px")}for(var c=this,d=0;d<c._toolWidgets.length;d++){var e=c._toolWidgets[d];if(c._checkType(e.type)){var f,g,h=e.tool,k=e.menuTool;0<d&&(f=c._toolWidgets[d-1].separatorAfterWidget?"|":c._toolWidgets[d-1]);e.separatorAfterWidget?g="|":d<c._toolWidgets.length-1&&(g=c._toolWidgets[d+1]);var l=f&&c._checkType(f.type),m=!1===e.separatorAfterWidget&&g&&c._checkType(g.type);l||m?!l&&m?b(e,"remove","remove","add","remove",1):l&&m?b(e,"add","remove",
1458"remove","remove",0):l&&!m&&b(e,"remove","remove","remove","add",0):b(e,"remove","add","remove","remove",1);l=c.rtl?"rtl":"ltr";m?(c._removeClass(h[0],c.toThemeProperty("jqx-toolbar-tool-separator-"+l)),c._removeClass(h[0],c.toThemeProperty("jqx-toolbar-tool-no-separator-"+l)),k&&(c._removeClass(k[0],c.toThemeProperty("jqx-toolbar-tool-separator-"+l)),c._removeClass(k[0],c.toThemeProperty("jqx-toolbar-tool-no-separator-"+l)))):e.separatorAfterWidget?(c._removeClass(h[0],c.toThemeProperty("jqx-toolbar-tool-no-separator-"+
1459l)),h[0].className+=" "+c.toThemeProperty("jqx-toolbar-tool-separator-"+l),k&&(c._removeClass(k[0],c.toThemeProperty("jqx-toolbar-tool-no-separator-"+l)),k[0].className+=" "+c.toThemeProperty("jqx-toolbar-tool-separator-"+l))):(c._removeClass(h[0],c.toThemeProperty("jqx-toolbar-tool-separator-"+l)),h[0].className+=" "+c.toThemeProperty("jqx-toolbar-tool-no-separator-"+l),k&&(c._removeClass(k[0],c.toThemeProperty("jqx-toolbar-tool-separator-"+l)),k[0].className+=" "+c.toThemeProperty("jqx-toolbar-tool-no-separator-"+
1460l)))}}},_addHandlers:function(){var b=this,c=b.element.id;a.jqx.utilities.resize(b.host,function(){b._initiallyHidden?(b._createTools(),b._minimize(),b._initiallyHidden=!1):(!0===b._isOpen&&(b._minimizePopup.style.display="none",b._isOpen=!1,b._raiseEvent("1")),b._minimize())});b.addHandler(document,"click.jqxToolbar"+c,function(){!0===b._isOpen&&b._openMinimizePopup()});b.addHandler(b._minimizeButton,"click.jqxToolbar"+c,function(d){d.stopPropagation();b._openMinimizePopup()});b.addHandler(a(".jqx-popup"),
1461"click.jqxToolbar"+c,function(d){-1===d.target.className.indexOf("jqx-window-content")&&d.stopPropagation()})},_removeHandlers:function(){var b=this.element.id;this.removeHandler(document,"click.jqxToolbar"+b);this.removeHandler(this._minimizeButton,"click.jqxToolbar"+b);this.removeHandler(a(".jqx-popup"),"click.jqxToolbar"+b)},_setSize:function(){var b=this.element.style;b.width=this._toPx(this.width);b.height=this._toPx(this.height);this.minWidth&&(b.minWidth=this._toPx(this.minWidth));this.maxWidth&&
1462(b.maxWidth=this._toPx(this.maxWidth))},_createTools:function(){var b=this.tools.split(" "),c=a.trim(this.tools.replace(/\|/g,""));c=c.replace(/\s+/g," ");c=c.split(" ");this._toolWidgets=[];for(var d=0,e=0;e<c.length;e++){c[e]!==b[e+d]&&d++;var f=e+d;if(this._toolWidgets[e-1])var g=this._toolWidgets[e-1].tool;var h=b[f];if(""===h)return!0;f=this._initializeTool(e,h,g,b[f-1],b[f+1],this.initTools,!0);this._toolWidgets.push(f)}this._minimizePopup.style.display="none";this._minimizePopup.style.visibility=
1463"visible"},_initializeTool:function(b,c,d,e,f,g,h){var k=this._initializeWidget(c,l,k,d);var l=k.tool;k=k.menuTool;d=l[0];var m="jqx-toolbar-tool",n=k[0],r,t=!0;!0===this.rtl&&(m+=" jqx-toolbar-tool-rtl");if(this.initTools){var u=!0===h?this.initTools(c,b,l,!1):g(c,l,!1);if(!u||!1!==u.minimizable&&!1!==u.menuTool)!0===h?this.initTools(c,b,k,!0):g(c,k,!0),k&&(r="jqx-toolbar-tool-minimized");else{if("custom"!==c)k[this._toolToWidgetMapping[c]]("destroy");else k.remove();!1===u.minimizable&&(t=!1);k=
1464!1}}b=!1;k&&(n.style.display="none");g=this.rtl?"rtl":"ltr";h=["button","toggleButton","repeatButton","linkButton"];u={button:"jqxButton",toggleButton:"jqxToggleButton",repeatButton:"jqxRepeatButton",linkButton:"jqxRepeatButton"};
1464if("|"===f){if(b=!0,m+=" jqx-toolbar-tool-separator-"+g,k&&(r+=" jqx-toolbar-tool-separator-"+g),k){var x=document.createElement("div");x.className=this.toThemeProperty("jqx-fill-state-pressed jqx-toolbar-minimized-popup-separator");this._minimizePopup.appendChild(x)}}else if(-1===
1465h.indexOf(c)||-1!==h.indexOf(c)&&-1===h.indexOf(f))m+=" jqx-toolbar-tool-no-separator-"+g,k&&(r+=" jqx-toolbar-tool-no-separator-"+g);if(-1===h.indexOf(e)&&-1!==h.indexOf(c)&&-1!==h.indexOf(f))if(!1===this.rtl){if(l[u[c]]({roundedCorners:"left"}),k)k[u[c]]({roundedCorners:"left"})}else l[u[c]]({roundedCorners:"left"}),d.style.borderLeftWidth="0px",k&&(k[u[c]]({roundedCorners:"left"}),n.style.borderLeftWidth="0px");else if(-1!==h.indexOf(e)&&-1!==h.indexOf(c)&&-1!==h.indexOf(f))m+=" jqx-toolbar-tool-inner-button",
1466d.style.borderLeftWidth="0px",k&&(r+=" jqx-toolbar-tool-inner-button",n.style.borderLeftWidth="0px");else if(-1!==h.indexOf(e)&&-1!==h.indexOf(c)&&-1===h.indexOf(f))if(!1===this.rtl)l[u[c]]({roundedCorners:"right"}),d.style.borderLeftWidth="0px",k&&(k[u[c]]({roundedCorners:"right"}),n.style.borderLeftWidth="0px");else if(l[u[c]]({roundedCorners:"left"}),k)k[u[c]]({roundedCorners:"left"});d.className+=" "+this.toThemeProperty(m);k&&(n.className+=" "+this.toThemeProperty(r));return{type:c,tool:l,separatorAfterWidget:b,
1467minimizable:t,minimized:!1,menuTool:k,menuSeparator:x}},_initializeWidget:function(b,c,d,e){var f=this._toolToWidgetMapping[b],g=!1;if("string"===typeof this.height&&-1!==this.height.indexOf("%"))g=!0;else{var h=window.getComputedStyle?window.getComputedStyle(this.element):this.element.currentStyle;h=this.element.offsetHeight-(parseInt(h.paddingTop,10)+parseInt(h.paddingBottom,10)+parseInt(h.borderTopWidth,10)+parseInt(h.borderBottomWidth,10))}if("custom"!==b&&void 0===this.host[f])throw b=this._toolToWidgetMapping[b].toLowerCase(),
1468Error("jqxToolBar: Missing reference to "+b+".js");switch(b){case "button":case "toggleButton":c=document.createElement("button");d=document.createElement("button");var k={theme:this.theme,height:g?"100%":h,disabled:this.disabled,rtl:this.rtl};break;case "dropdownlist":case "combobox":c=document.createElement("div");d=document.createElement("div");k={theme:this.theme,autoDropDownHeight:!0,height:g?"100%":h-2,disabled:this.disabled,rtl:this.rtl};break;case "input":c=document.createElement("input");
1469c.setAttribute("type","text");d=document.createElement("input");d.setAttribute("type","text");k={theme:this.theme,height:g?"100%":h-2,disabled:this.disabled,rtl:this.rtl};break;case "custom":c=document.createElement("div"),d=document.createElement("div")}g=this.host.children();h=a(this._minimizePopup).children();e||1===g.length&&0===h.length?(this.element.appendChild(c),this._minimizePopup.appendChild(d)):(this.element.insertBefore(c,g[1]),this._minimizePopup.insertBefore(d,h[0]));c=a(c);d=a(d);"custom"!==
1470b&&(c[f](k),d[f](k));return{tool:c,menuTool:d}},_appendMinimizeButton:function(){this._minimizedTools=0;var b=document.createElement("div"),c="jqx-menu-minimized-button jqx-toolbar-minimized-button",d=document.createElement("div"),e="jqx-popup jqx-fill-state-normal jqx-rc-b jqx-toolbar-minimized-popup";d.setAttribute("id",this.element.id+"Popup");!0===this.rtl&&(c+=" jqx-toolbar-minimized-button-rtl",e+=" jqx-toolbar-minimized-popup-rtl");b.className=this.toThemeProperty(c);d.className=this.toThemeProperty(e);
1471this.element.appendChild(b);document.body.appendChild(d);this._isOpen=!1;d.style.width=this._toPx(this.minimizeWidth);this._minimizeButton=b;this._minimizePopup=d},_openMinimizePopup:function(){var b=this;if(!1===b._isOpen){var c=b.host.offset(),d=c.left;!1===b.rtl&&(d+=b.element.offsetWidth-parseInt(b.minimizeWidth,10)-(b._getComputedStyle(b._minimizePopup,"paddingLeft")+b._getComputedStyle(b._minimizePopup,"paddingRight")+b._getComputedStyle(b._minimizePopup,"borderLeftWidth")+b._getComputedStyle(b._minimizePopup,
1472"borderRightWidth")));c=c.top+b.element.offsetHeight-1;b._minimizePopup.style.left=d+"px";b._minimizePopup.style.top=c+"px";a(b._minimizePopup).slideDown("fast",function(){b._isOpen=!0;b._raiseEvent("0")})}else a(b._minimizePopup).slideUp("fast"),b._isOpen=!1,b._raiseEvent("1")},_minimize:function(){var b=0;0<this._minimizedTools&&(b=this._minimizeButton.offsetWidth+this._getComputedStyle(this._minimizeButton,"marginLeft"));b=this.element.offsetWidth-this._getComputedStyle(this.element,"paddingLeft")-
1473this._getComputedStyle(this.element,"paddingRight")-b-10;if(!(0>b)){for(var c=0,d,e=0;e<this._toolWidgets.length;e++){var f=this._toolWidgets[e].tool;!1===this._toolWidgets[e].minimized?(f=f[0].offsetWidth+this._getComputedStyle(f[0],"marginLeft")+this._getComputedStyle(f[0],"marginRight"),c+=f):void 0===d&&(f=f[0].cloneNode(!0),f.style.visibility="hidden",f.style.display="block",f.style.position="absolute",document.body.appendChild(f),d=f.offsetWidth+this._getComputedStyle(f,"marginLeft")+this._getComputedStyle(f,
1474"marginRight"),a(f).remove())}c>b?(this._minimizeTool(!0),this._minimize()):void 0!==d&&c+d<b&&(this._minimizeTool(!1),this._minimize())}},_minimizeTool:function(b){if(!0===b)for(var c=this._toolWidgets.length-1;0<=c;
1474c--){if(b=this._toolWidgets[c],!1!==b.minimizable&&!1===b.minimized){var d=this._getToolValue(b.tool,b.type);b.tool[0].style.display="none";b.menuTool&&(b.menuTool[0].style.display="block",this._setToolValue(d,b.menuTool,b.type));b.menuSeparator&&(b.menuSeparator.style.display="block");
1475this._toolWidgets[c].minimized=!0;this._minimizedTools++;1===this._minimizedTools&&(this._minimizeButton.style.display="block");break}}else for(c=0;c<this._toolWidgets.length;c++)if(b=this._toolWidgets[c],!0===b.minimized){b.menuTool&&(d=this._getToolValue(b.menuTool,b.type),b.menuTool[0].style.display="none");b.menuSeparator&&(b.menuSeparator.style.display="none");b.tool.show();b.menuTool&&this._setToolValue(d,b.tool,b.type);this._toolWidgets[c].minimized=!1;this._minimizedTools--;0===this._minimizedTools&&
1476(this._minimizeButton.style.display="none");break}},_getToolValue:function(b,c){switch(c){case "button":case "custom":var d=void 0;break;case "toggleButton":c=-1!==b[0].className.indexOf("jqx-fill-state-pressed");d={text:b[0].innerHTML,toggled:c};break;case "dropdownlist":case "combobox":c=this._toolToWidgetMapping[c];d=b[c]("checkboxes")?b[c]("val"):b[c]("getSelectedIndex");break;case "input":d=b.val()}return d},escape_HTML:function(b){return b.replace(/[&<>"]/g,function(c){return{"&":"&","<":"<",
1477">":">",'"':'"'}[c]||c})},_setToolValue:function(b,c,d){if(void 0!==b)switch(d){case "toggleButton":c[0].innerHTML=this.escape_HTML(b.text);-1!==c[0].className.indexOf("jqx-fill-state-pressed")!==b.toggled&&c.jqxToggleButton("toggle");break;case "dropdownlist":case "combobox":d=this._toolToWidgetMapping[d];if(c[d]("checkboxes")){if(c[d]("uncheckAll"),""!==b){b=b.split(",");for(var e=0;e<b.length;e++)c[d]("checkItem",b[e])}}else c[d]("selectIndex",b);break;case "input":c.val(b)}},_restoreChanges:function(){var b=
1478this;a.each(b._toolChanges,function(c,d){"addTool"===d.action?b.addTool(d.type,d.position,d.separator,d.initCallback):"destroyTool"===d.action?b._destroyTool(d.index):"disableTool"===d.action&&b.disableTool(d.index,d.disable)})},_removeClass:function(b,c){a(b).removeClass(c)},_toPx:function(b){return"number"===typeof b?b+"px":b},_getComputedStyle:function(b,c){if(window.getComputedStyle)var d=window.getComputedStyle(b);else b.currentStyle&&(d=b.currentStyle);return"string"===typeof d[c]&&-1===d[c].indexOf("px")?
14790:parseInt(d[c],10)}})})(jqxBaseFramework);
1480(function(a){a.jqx.jqxWidget("jqxTooltip","",{});a.extend(a.jqx._jqxTooltip.prototype,{defineInstance:function(){var b={width:"auto",height:"auto",position:"default",enableBrowserBoundsDetection:!0,content:"",left:0,top:0,absolutePositionX:0,absolutePositionY:0,trigger:"hover",showDelay:100,autoHide:!0,autoHideDelay:3E3,closeOnClick:!0,disabled:!1,animationShowDelay:200,animationHideDelay:"fast",showArrow:!0,name:"",opacity:.9,rtl:!1,_isOpen:!1,selector:null,opening:null,value:null,_eventsMap:{mousedown:a.jqx.mobile.getTouchEventName("touchstart"),
1481mouseup:a.jqx.mobile.getTouchEventName("touchend")},events:["open","close","opening","closing"]};if(this===a.jqx._jqxTooltip.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(){this._isTouchDevice=a.jqx.mobile.isTouchDevice();var b=a.data(document.body,"_tooltipIDArray"+this.name);b?this.IDArray=b:(this.IDArray=[],a.data(document.body,"_tooltipIDArray"+this.name,this.IDArray));b="jqxtooltip"+this._generatekey();this.IDArray.push({tooltipID:b,tooltipHost:this.host});var c=document.createElement("div");
1482c.setAttribute("id",b);c.innerHTML='<div id="'+b+'Main"><div id="'+b+'Text"></div></div><div id="'+b+'Arrow"></div>';a.jqx.browser.msie&&(c.className=this.toThemeProperty("jqx-noshadow"));document.body.appendChild(c);this._tooltip=c;this._tooltipHelper=a(c);this._tooltipHelper.initAnimate&&this._tooltipHelper.initAnimate();c.style.visibility="hidden";c.style.display="none";c.style.opacity=0;c.style.zIndex=99999;this._arrow=c=document.getElementById(b+"Arrow");!1===this.showArrow&&(c.style.visibility=
1483"hidden",c.style.display="none");this._main=document.getElementById(b+"Main");this._text=document.getElementById(b+"Text");this._setTheme();this._setSize();this._setContent();!1===this.disabled&&(this._trigger(),!0===this.closeOnClick&&this._clickHide())},open:function(){arguments&&arguments.length&&2===arguments.length&&(this.position="absolute",this.left=arguments[0],this.top=arguments[1],this.absolutePositionX=arguments[0],this.absolutePositionY=arguments[1]);if(!1===this.disabled&&"removed"!==
1484this._id())if("mouse"===this.position||"mouseenter"===this.position){var b=this.position;this.position="default";this._raiseEvent("2");this._setPosition();this._animateShow();this.position=b}else this._raiseEvent("2"),this._setPosition(),this._animateShow()},close:function(b){var c=this,d=a.jqx.browser.msie&&9>a.jqx.browser.version;"object"===typeof b&&a.isEmptyObject(b)&&(b=this.animationHideDelay);var e=parseFloat(c._tooltip.style.opacity),f=function(){clearTimeout(c.autoHideTimeout);c._raiseEvent("3");
1485c._tooltipHelper.animate({opacity:0},b,function(){c._tooltip.style.visibility="hidden";c._tooltip.style.display="none";c._raiseEvent("1");c._isOpen=!1})};!1===this._isOpen&&0!==e?f():!0===this._isOpen&&(!d&&e===this.opacity||d)&&f()},destroy:function(){var b=this.IDArray.length;this._removeHandlers();this._tooltipHelper.remove();for(var c=0;c<b;c++)if(this.IDArray[c].tooltipHost===this.host){this.IDArray.splice(c,1);break}this.host.removeData("jqxTooltip")},refresh:function(b){if(!0!==b){var c=this;
1486this.rtl&&(c._text.className+=" "+c.toThemeProperty("jqx-rtl"),c._text.style.direction="rtl");b=parseFloat(c._tooltip.style.opacity);"removed"!==this._id()&&(!0===this.disabled&&!0===this._isOpen&&b===this.opacity&&(clearTimeout(this.autoHideTimeout),this._tooltipHelper.animate({opacity:0}
1486,this.animationHideDelay,function(){c._tooltip.style.visibility="hidden";c._tooltip.style.display="none";c._isOpen=!1})),this._setTheme(),this._setContent(),this._setSize(),"mouse"!==this.position&&"mouseenter"!==
1487this.position&&this._setPosition(),this._removeHandlers(),!1===this.disabled&&(this._trigger(),!0===this.closeOnClick&&this._clickHide()))}},propertyChangedHandler:function(b,c,d,e){"content"===c&&(this.changeContentFlag=!0);b.refresh()},_raiseEvent:function(b,c){b=new a.Event(this.events[b]);b.owner=this;b.args=c;try{var d=this.host.trigger(b)}catch(e){}return d},_generatekey:function(){return(65536*(1+Math.random())|0).toString(16).substring(1)+(65536*(1+Math.random())|0).toString(16).substring(1)},
1488_id:function(){for(var b,c=this.IDArray.length,d=0;d<c;d++)if(this.IDArray[d].tooltipHost===this.host){b=this.IDArray[d].tooltipID;b="#"+b;break}void 0===b&&(b="removed");return b},_setPosition:function(b){var c=this,d=c._tooltip;if(!1===this._isOpen&&0===parseFloat(d.style.opacity)||!0===this.changeContentFlag)if(b||"mouse"!==this.position&&"mouseenter"!==this.position){d.style.display="block";this.changeContentFlag=!1;this.documentTop=document.documentElement.scrollTop;this.documentLeft=document.documentElement.scrollLeft;
1489this.windowWidth=window.innerWidth;this.windowHeight=window.innerHeight;this.hostWidth=c.element.offsetWidth;this.hostHeight=c.element.offsetHeight;this.tooltipWidth=d.offsetWidth;this.tooltipHeight=d.offsetHeight;this.hostOffset=this.host.offset();this.tooltipOffset=c._tooltipHelper.offset();this.defaultOffset=30;this.offsetHorizontal=parseInt(this.left,10);this.offsetVertical=parseInt(this.top,10);d=c._arrow;var e=a(d),f=c._main,g=a(f),h=f.offsetWidth,k=f.offsetHeight;this.arrowSize=5;this.tooltipMainOffset=
1490g.offset();this.tooltipArrowOffset={};switch(this.position){case "top":this.tooltipOffset.left=this.hostOffset.left+this.hostWidth/2-this.tooltipWidth/2+this.offsetHorizontal;this.tooltipOffset.top=this.hostOffset.top-this.tooltipHeight-this.arrowSize+this.offsetVertical;this._detectBrowserBounds();this.tooltipMainOffset=g.offset();c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-l-r"));d.className+=" "+c.toThemeProperty("jqx-tooltip-arrow-t-b");d.style.borderWidth=this.arrowSize+"px "+this.arrowSize+
1491"px 0px";this.tooltipArrowOffset.left=this.tooltipMainOffset.left+(h/2-this.arrowSize);this.tooltipArrowOffset.top=this.tooltipMainOffset.top+k;e.offset({top:this.tooltipArrowOffset.top,left:this.tooltipArrowOffset.left});break;case "bottom":this.tooltipOffset.left=this.hostOffset.left+this.hostWidth/2-this.tooltipWidth/2+this.offsetHorizontal;this.tooltipOffset.top=this.hostOffset.top+this.hostHeight+this.arrowSize+this.offsetVertical;this._detectBrowserBounds();this.tooltipMainOffset=g.offset();
1492c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-l-r"));d.className+=" "+c.toThemeProperty("jqx-tooltip-arrow-t-b");d.style.borderWidth="0 "+this.arrowSize+"px "+this.arrowSize+"px";this.tooltipArrowOffset.left=this.tooltipMainOffset.left+(h/2-this.arrowSize);this.tooltipArrowOffset.top=this.tooltipMainOffset.top-this.arrowSize;e.offset({top:this.tooltipArrowOffset.top,left:this.tooltipArrowOffset.left});break;case "left":f=window.getComputedStyle?window.getComputedStyle(f):f.currentStyle;this.tooltipOffset.left=
1493this.hostOffset.left-this.tooltipWidth-this.arrowSize+this.offsetHorizontal-(parseInt(f.borderLeftWidth,10)+parseInt(f.borderRightWidth,10));this.tooltipOffset.top=this.hostOffset.top+this.hostHeight/2-this.tooltipHeight/2+this.offsetVertical;this._detectBrowserBounds();c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-t-b"));d.className+=" "+c.toThemeProperty("jqx-tooltip-arrow-l-r");d.style.borderWidth=this.arrowSize+"px 0px "+this.arrowSize+"px "+this.arrowSize+"px";this.tooltipMainOffset=
1494g.offset();this.tooltipArrowOffset.left=this.tooltipMainOffset.left+h;this.tooltipArrowOffset.top=this.tooltipMainOffset.top+k/2-this.arrowSize;e.offset({top:this.tooltipArrowOffset.top,left:this.tooltipArrowOffset.left});break;case "right":this.tooltipOffset.left=this.hostOffset.left+this.hostWidth+this.arrowSize+this.offsetHorizontal;this.tooltipOffset.top=this.hostOffset.top+this.hostHeight/2-this.tooltipHeight/2+this.offsetVertical;this.tooltipOffset.top=parseInt(this.tooltipOffset.top,10);this._detectBrowserBounds();
1495this.tooltipMainOffset=g.offset();c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-t-b"));d.className+=" "+c.toThemeProperty("jqx-tooltip-arrow-l-r");d.style.borderWidth=this.arrowSize+"px "+this.arrowSize+"px "+this.arrowSize+"px 0px";this.tooltipArrowOffset.left=this.tooltipMainOffset.left-this.arrowSize;this.tooltipArrowOffset.top=this.tooltipMainOffset.top+f.offsetHeight/2-this.arrowSize;
1495e.offset({top:this.tooltipArrowOffset.top,left:this.tooltipArrowOffset.left});break;case "top-left":this.tooltipOffset.left=
1496this.hostOffset.left+this.defaultOffset-this.tooltipWidth+this.offsetHorizontal;this.tooltipOffset.top=this.hostOffset.top-this.tooltipHeight-this.arrowSize+this.offsetVertical;this._detectBrowserBounds();this.tooltipMainOffset=g.offset();c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-l-r"));d.className+=" "+c.toThemeProperty("jqx-tooltip-arrow-t-b");d.style.borderWidth=this.arrowSize+"px "+this.arrowSize+"px  0px";this.tooltipArrowOffset.left=this.tooltipMainOffset.left+h-6*this.arrowSize;
1497this.tooltipArrowOffset.top=this.tooltipMainOffset.top+k;e.offset({top:this.tooltipArrowOffset.top,left:this.tooltipArrowOffset.left});break;case "bottom-left":this.tooltipOffset.left=this.hostOffset.left+this.defaultOffset-this.tooltipWidth+this.offsetHorizontal;this.tooltipOffset.top=this.hostOffset.top+this.hostHeight+this.arrowSize+this.offsetVertical;this._detectBrowserBounds();this.tooltipMainOffset=g.offset();c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-l-r"));d.className+=" "+c.toThemeProperty("jqx-tooltip-arrow-t-b");
1498d.style.borderWidth="0 "+this.arrowSize+"px "+this.arrowSize+"px";this.tooltipArrowOffset.left=this.tooltipMainOffset.left+h-6*this.arrowSize;this.tooltipArrowOffset.top=this.tooltipMainOffset.top-this.arrowSize;e.offset({top:this.tooltipArrowOffset.top,left:this.tooltipArrowOffset.left});break;case "top-right":this.tooltipOffset.left=this.hostOffset.left+this.hostWidth-this.defaultOffset+this.offsetHorizontal;this.tooltipOffset.top=this.hostOffset.top-this.tooltipHeight-this.arrowSize+this.offsetVertical;
1499this._detectBrowserBounds();this.tooltipMainOffset=g.offset();c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-l-r"));d.className+=" "+c.toThemeProperty("jqx-tooltip-arrow-t-b");d.style.borderWidth=this.arrowSize+"px "+this.arrowSize+"px  0px";this.tooltipArrowOffset.left=this.tooltipMainOffset.left+4*this.arrowSize;this.tooltipArrowOffset.top=this.tooltipMainOffset.top+k;e.offset({top:this.tooltipArrowOffset.top,left:this.tooltipArrowOffset.left});break;case "bottom-right":this.tooltipOffset.left=
1500this.hostOffset.left+this.hostWidth-this.defaultOffset+this.offsetHorizontal;this.tooltipOffset.top=this.hostOffset.top+this.hostHeight+this.arrowSize+this.offsetVertical;this._detectBrowserBounds();this.tooltipMainOffset=g.offset();c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-l-r"));d.className+=" "+c.toThemeProperty("jqx-tooltip-arrow-t-b");d.style.borderWidth="0 "+this.arrowSize+"px "+this.arrowSize+"px";this.tooltipArrowOffset.left=this.tooltipMainOffset.left+4*this.arrowSize;this.tooltipArrowOffset.top=
1501this.tooltipMainOffset.top-this.arrowSize;e.offset({top:this.tooltipArrowOffset.top,left:this.tooltipArrowOffset.left});break;case "absolute":c._tooltipHelper.offset({top:this.absolutePositionY,left:this.absolutePositionX});d.style.borderWidth="0px";break;case "mouse":if(!1===this._isTouchDevice)switch(this.trigger){case "hover":this.mouseHoverTimeout&&clearTimeout(this.mouseHoverTimeout);this.mouseHoverTimeout=setTimeout(function(){c.tooltipOffset.left=b.pageX+10;c.tooltipOffset.top=b.pageY+10;c._detectBrowserBounds()},
1502this.showDelay);break;case "click":this.tooltipOffset.left=b.pageX+10,this.tooltipOffset.top=b.pageY+10,this._detectBrowserBounds()}else{e=b.pageX;g=b.pageY;if(b.originalEvent){var l;b.originalEvent.touches&&b.originalEvent.touches.length?l=b.originalEvent.touches[0]:b.originalEvent.changedTouches&&b.originalEvent.changedTouches.length&&(l=b.originalEvent.changedTouches[0]);void 0!==l&&(e=l.pageX,g=l.pageY)}this.tooltipOffset.left=e+10;this.tooltipOffset.top=g+10;this._detectBrowserBounds()}d.style.borderWidth=
1503"0px";break;case "mouseenter":l=b.pageY;var m=b.pageX;l<this.hostOffset.top+10&&l>this.hostOffset.top-10?(this.tooltipOffset.left=m-this.tooltipWidth/2,this.tooltipOffset.top=this.hostOffset.top-this.tooltipHeight-this.arrowSize,this._detectBrowserBounds(),this.tooltipMainOffset=g.offset(),c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-l-r")),d.className+=" "+c.toThemeProperty("jqx-tooltip-arrow-t-b"),d.style.borderWidth=this.arrowSize+"px "+this.arrowSize+"px  0px",this.tooltipArrowOffset.left=
1504this.tooltipMainOffset.left+(h/2-this.arrowSize),this.tooltipArrowOffset.top=this.tooltipMainOffset.top+k,e.offset({top:this.tooltipArrowOffset.top,left
1504:this.tooltipArrowOffset.left})):l<this.hostOffset.top+this.hostHeight+10&&l>this.hostOffset.top+this.hostHeight-10?(this.tooltipOffset.left=m-this.tooltipWidth/2,this.tooltipOffset.top=this.hostOffset.top+this.hostHeight+this.arrowSize,this._detectBrowserBounds(),this.tooltipMainOffset=g.offset(),c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-l-r")),
1505d.className+=" "+c.toThemeProperty("jqx-tooltip-arrow-t-b"),d.style.borderWidth="0 "+this.arrowSize+"px "+this.arrowSize+"px",this.tooltipArrowOffset.left=this.tooltipMainOffset.left+(h/2-this.arrowSize),this.tooltipArrowOffset.top=this.tooltipMainOffset.top-this.arrowSize,e.offset({top:this.tooltipArrowOffset.top,left:this.tooltipArrowOffset.left})):m<this.hostOffset.left+10&&m>this.hostOffset.left-10?(f=window.getComputedStyle?window.getComputedStyle(f):f.currentStyle,this.tooltipOffset.left=this.hostOffset.left-
1506this.tooltipWidth-this.arrowSize-(parseInt(f.borderLeftWidth,10)+parseInt(f.borderRightWidth,10)),this.tooltipOffset.top=l-this.tooltipHeight/2,this._detectBrowserBounds(),this.tooltipMainOffset=g.offset(),c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-t-b")),d.className+=" "+c.toThemeProperty("jqx-tooltip-arrow-l-r"),d.style.borderWidth=this.arrowSize+"px 0px "+this.arrowSize+"px "+this.arrowSize+"px",this.tooltipMainOffset=g.offset(),this.tooltipArrowOffset.left=this.tooltipMainOffset.left+
1507h,this.tooltipArrowOffset.top=this.tooltipMainOffset.top+k/2-this.arrowSize,e.offset({top:this.tooltipArrowOffset.top,left:this.tooltipArrowOffset.left})):m<this.hostOffset.left+this.hostWidth+10&&m>this.hostOffset.left+this.hostWidth-10&&(this.tooltipOffset.left=this.hostOffset.left+this.hostWidth+this.arrowSize,this.tooltipOffset.top=l-this.tooltipHeight/2,this._detectBrowserBounds(),this.tooltipMainOffset=g.offset(),c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-t-b")),d.className+=" "+
1508c.toThemeProperty("jqx-tooltip-arrow-l-r"),d.style.borderWidth=this.arrowSize+"px "+this.arrowSize+"px "+this.arrowSize+"px 0px",this.tooltipMainOffset=g.offset(),this.tooltipArrowOffset.left=this.tooltipMainOffset.left-this.arrowSize,this.tooltipArrowOffset.top=this.tooltipMainOffset.top+k/2-this.arrowSize,e.offset({top:this.tooltipArrowOffset.top,left:this.tooltipArrowOffset.left}));break;case "default":this.tooltipOffset.left=this.hostOffset.left+this.hostWidth-this.defaultOffset,this.tooltipOffset.top=
1509this.hostOffset.top+this.hostHeight+this.arrowSize,this._detectBrowserBounds(),this.tooltipMainOffset=g.offset(),c._removeClass(d,c.toThemeProperty("jqx-tooltip-arrow-l-r")),d.className+=" "+c.toThemeProperty("jqx-tooltip-arrow-t-b"),d.style.borderWidth="0 "+this.arrowSize+"px "+this.arrowSize+"px",this.tooltipArrowOffset.left=this.tooltipMainOffset.left+4*this.arrowSize,this.tooltipArrowOffset.top=this.tooltipMainOffset.top-this.arrowSize,e.offset({top:this.tooltipArrowOffset.top,left:this.tooltipArrowOffset.left})}}},
1510_setContent:function(){this._text.innerHTML=this.content},opened:function(){return this._isOpen&&"block"==this.host.css("display")&&"visible"==this.host.css("visibility")},_animateShow:function(){this._closeAll();clearTimeout(this.autoHideTimeout);var b=parseFloat(this._tooltip.style.opacity);if(!1===this._isOpen&&0===b){var c=this;c._tooltip.style.visibility="visible";c._tooltip.style.display="block";c._tooltip.style.opacity=0;this.opening&&!1===this.opening(this)||c._tooltipHelper.animate({opacity:this.opacity},
1511this.animationShowDelay,function(){c._raiseEvent("0");c._isOpen=!0;c.openedTooltip=c;a.data(document.body,"_openedTooltip"+c.name,c);c.autoHideTimeout&&clearTimeout(c.autoHideTimeout);0<c.autoHideDelay&&!0===c.autoHide&&(c.autoHideTimeout=setTimeout(function(){c._autoHide()},c.autoHideDelay))})}},_trigger:function(){if("removed"!==this._id()){var b=this,c=this.host;this.selector&&(c=a("#"+this.selector));if(!1===this._isTouchDevice)switch(this.trigger){case "hover":"mouse"===this.position?(this.addHandler(c,
1512"mousemove.tooltip",function(d){1===b._enterFlag&&(b._raiseEvent("2"),b._setPosition(d),clearTimeout(b.hoverShowTimeout),b.hoverShowTimeout=setTimeout(function(){b._animateShow();b._enterFlag=0},b.showDelay))}),this.addHandler(c,"mouseenter.tooltip",function(){0!==b._leaveFlag&&(b._enterFlag=1)}),this.addHandler(c,"mouseleave.tooltip",function(d){b._leaveFlag=1;clearTimeout(b.hoverShowTimeout);var e=b._tooltipHelper.offset(),f=b._tooltip.offsetWidth,g=b._tooltip.offsetHeight;(parseInt(d.pageX,10)<
1513parseInt(e.left,10)||parseInt(d.pageX,10)>parseInt(e.left,10)+f)&&b.close();(parseInt(d.pageY,10)<parseInt(e.top,10)||parseInt(d.pageY,10)>parseInt(e.top,10)+g)&&b.close()}),this.addHandler(b._tooltipHelper,"mouseleave.tooltip",function(d){b._checkBoundariesAuto(d);0!==b._clickFlag&&0!==b._autoFlag?b._leaveFlag=0:(b._leaveFlag=1,b.close())})):(this.addHandler(c,"mouseenter.tooltip",function(d){clearTimeout(b.hoverShowTimeout);b.hoverShowTimeout=setTimeout(function(){b._raiseEvent("2");b._setPosition(d);
1514b._animateShow()},b.showDelay)}),this.addHandler(c,"mouseleave.tooltip",function(d){b._leaveFlag=1;clearTimeout(b.hoverShowTimeout);if(b.autoHide){var e=d.pageX;d=d.pageY;var f=b._tooltipHelper.offset(),g=f.left;f=f.top;var h=b._tooltip.offsetWidth,k=b._tooltip.offsetHeight;(parseInt(e,10)<parseInt(g,10)||parseInt(e,10)>parseInt(g,10)+h||parseInt(d,10)<parseInt(f,10)||parseInt(d,10)>parseInt(f,10)+k)&&b.close()}}),this.addHandler(b._tooltipHelper,"mouseleave.tooltip",function(d){b._checkBoundariesAuto(d);
15150!==b._clickFlag&&0!==b._autoFlag?b._leaveFlag=0:(b._leaveFlag=1,b.autoHide&&b.close())}));break;case "click":this.addHandler(c,"click.tooltip",function(d){"mouseenter"
1515===b.position&&(b.position="mouse");b._raiseEvent("2");b._setPosition(d);b._animateShow()})}else"none"!==this.trigger&&this.addHandler(c,"touchstart.tooltip",function(d){"mouseenter"===b.position&&(b.position="mouse");b._raiseEvent("2");b._setPosition(d);b._animateShow()})}},_autoHide:function(){var b=this,c=parseFloat(b._tooltip.style.opacity);
1516!0===this.autoHide&&!0===this._isOpen&&c>=this.opacity&&(b._raiseEvent("3"),b._tooltipHelper.animate({opacity:0},b.animationHideDelay,function(){b._tooltip.style.visibility="hidden";b._tooltip.style.display="none";b._raiseEvent("1");b._isOpen=!1}))},_clickHide:function(){var b=this;this.addHandler(b._tooltipHelper,"click.tooltip",function(c){b._checkBoundariesClick(c);b.close()})},_setSize:function(){this._tooltip.style.width=this._toPx(this.width);this._tooltip.style.height=this._toPx(this.height)},
1517resize:function(){this._setSize()},_setTheme:function(){-1===this._tooltip.className.indexOf("jqx-tooltip")&&(this._tooltip.className+=" "+this.toThemeProperty("jqx-tooltip jqx-popup"),this._main.className+=" "+this.toThemeProperty("jqx-widget jqx-fill-state-normal jqx-tooltip-main"),this._text.className+=" "+this.toThemeProperty("jqx-widget jqx-fill-state-normal jqx-tooltip-text"),this._arrow&&(this._arrow.className+=" "+this.toThemeProperty("jqx-widget jqx-fill-state-normal jqx-tooltip-arrow")))},
1518_initialPosition:function(){var b=this.position;this.position="default";this._setPosition();this.position=b},_detectBrowserBounds:function(){var b=this._tooltipHelper;this.enableBrowserBoundsDetection?this.tooltipOffset.top<this.documentTop&&0>this.tooltipOffset.left?b.offset({top:this.documentTop,left:this.documentLeft}):this.tooltipOffset.top<this.documentTop&&this.tooltipOffset.left+this.tooltipWidth>this.windowWidth+this.documentLeft?b.offset({top:this.documentTop,left:this.windowWidth+this.documentLeft-
1519this.tooltipWidth}):this.tooltipOffset.top<this.documentTop?b.offset({top:this.documentTop,left:this.tooltipOffset.left}):this.tooltipOffset.top+this.tooltipHeight>this.windowHeight+this.documentTop&&0>this.tooltipOffset.left?b.offset({top:this.windowHeight+this.documentTop-this.tooltipHeight,left:this.documentLeft}):this.tooltipOffset.top+this.tooltipHeight>this.windowHeight+this.documentTop&&this.tooltipOffset.left+this.tooltipWidth>this.windowWidth+this.documentLeft?b.offset({top:this.windowHeight+
1520this.documentTop-this.tooltipHeight,left:this.windowWidth+this.documentLeft-this.tooltipWidth}):this.tooltipOffset.top+this.tooltipHeight>this.windowHeight+this.documentTop?b.offset({top:this.windowHeight+this.documentTop-this.tooltipHeight,left:this.tooltipOffset.left}):0>this.tooltipOffset.left?b.offset({top:this.tooltipOffset.top,left:this.documentLeft}):this.tooltipOffset.left+this.tooltipWidth>this.windowWidth+this.documentLeft?b.offset({top:this.tooltipOffset.top,left:this.windowWidth+this.documentLeft-
1521this.tooltipWidth}):b.offset({top:this.tooltipOffset.top,left:this.tooltipOffset.left}):b.offset({top:this.tooltipOffset.top,left:this.tooltipOffset.left})},_checkBoundaries:function(b){return b.pageX>=this.hostOffset.left&&b.pageX<=this.hostOffset.left+this.hostWidth&&b.pageY>=this.hostOffset.top&&b.pageY<=this.hostOffset.top+this.hostHeight?!0:!1},_checkBoundariesClick:function(b){this._checkBoundaries(b)?this._clickFlag=1:this._clickFlag=0},_checkBoundariesAuto:function(b){this._checkBoundaries(b)?
1522this._autoFlag=1:this._autoFlag=0},_removeHandlers:function(){this.removeHandler(this.host,"mouseenter.tooltip");this.removeHandler(this.host,"mousemove.tooltip");this.removeHandler(this.host,"mouseleave.tooltip");this.removeHandler(this.host,"click.tooltip");this.removeHandler(this.host,"touchstart.tooltip");this.removeHandler(this._tooltipHelper,"click.tooltip");this.removeHandler(this._tooltipHelper,"mouseleave.tooltip")},_closeAll:function(){for(var b=0;b<this.IDArray.length;b++){var c=document.getElementById(this.IDArray[b].tooltipID);
1523c!==this._tooltip&&(c.style.opacity=0,c.style.visibility="hidden",c.style.display="none",this._isOpen=!1)}},_toPx:function(b){return"number"===typeof b?b+"px":b},_removeClass:function(b,c){a(b).removeClass(c)}})})(jqxBaseFramework);
1524(function(a){a.jqx.jqxWidget("jqxCheckBox","",{});a.extend(a.jqx._jqxCheckBox.prototype,{defineInstance:function(){var b={animationShowDelay:300,animationHideDelay:300,width:null,height:null,boxSize:"16px",checked:!1,hasThreeStates:!1,disabled:!1,enableContainerClick:!0,locked:!1,groupName:"",ke
1524yboardCheck:!0,enableHover:!0,hasInput:!0,rtl:!1,updated:null,disabledContainer:!1,changeType:null,_canFocus:!0,aria:{"aria-checked":{name:"checked",type:"boolean"},"aria-disabled":{name:"disabled",type:"boolean"}},
1525events:["checked","unchecked","indeterminate","change"]};if(this===a.jqx._jqxCheckBox.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(b){this._createFromInput("CheckBox");this.render()},_createFromInput:function(b){if("input"==this.element.nodeName.toLowerCase()){this.field=this.element;this.field.className&&(this._className=this.field.className);var c={title:this.field.title};this.field.value&&(c.value=this.field.value);this.field.checked&&(c.checked=!0);c.id=this.field.id.length?
1526this.field.id.replace(/[^\w]/g,"_")+"_"+b:a.jqx.utilities.createId()+"_"+b;var d=this.element.nextSibling,e=!1;!d||"#text"!=d.nodeName&&"span"!=d.nodeName||(e=!0);var f=0;b=a("<div></div>",c);e&&(b.append(d),d=a("<span>"+a(d).text()+"</span>"),d.appendTo(a(document.body)),f+=d.width(),d.remove());b[0].style.cssText=this.field.style.cssText;this.width||(this.width=a(this.field).width()+f+10);this.height||(this.height=a(this.field).outerHeight()+10);a(this.field).hide().after(b);f=this.host.data();
1527this.host=b;this.host.data(f);this.element=b[0];this.element.id=this.field.id;this.field.id=c.id;this._className&&(this.host.addClass(this._className),a(this.field).removeClass(this._className));this.field.tabIndex&&(c=this.field.tabIndex,this.field.tabIndex=-1,this.element.tabIndex=c)}},_addInput:function(){if(this.hasInput){this.input&&this.input.remove();var b=this.host.attr("name");this.input=a("<input type='hidden'/>");this.host.append(this.input);b&&this.input.attr("name",b);this.input.val(this.checked);
1528this.host.attr("role","checkbox");a.jqx.aria(this)}},render:function(){this.init=!0;var b=this;this.setSize();this.propertyChangeMap.width=function(f,g,h,k){b.setSize()};this.propertyChangeMap.height=function(f,g,h,k){b.setSize()};this._removeHandlers();this.width||this.host.css("overflow-x","visible");this.height||this.host.css("overflow-y","visible");this.checkbox&&(this.checkbox.remove(),this.checkbox=null);this.checkMark&&(this.checkMark.remove(),this.checkMark=null);this.box&&(this.box.remove(),
1529this.box=null);this.clear&&(this.clear.remove(),this.clear=null);null==this.boxSize&&(this.boxSize=16);var c=parseInt(this.boxSize)+"px",d=Math.floor((parseInt(this.boxSize)-16)/2),e=d;d+="px";e+="px";16!=parseInt(this.boxSize)?this.checkbox=a('<div><div style="width: '+c+"; height: "+c+';"><span style="position: relative; left: '+d+"; top: "+e+'; width: 16px; height: 16px;"></span></div></div>'):this.checkbox=a('<div><div style="width: '+c+"; height: "+c+';"><span style="width: '+c+"; height: "+
1530c+';"></span></div></div>');this.host.prepend(this.checkbox);this.disabledContainer||(this.host.attr("tabIndex")||this.host.attr("tabIndex",0),this.clear=a('<div style="clear: both;"></div>'),this.host.append(this.clear));this.checkMark=a(this.checkbox[0].firstChild.firstChild);this.box=this.checkbox;this.box.addClass(this.toThemeProperty("jqx-checkbox-default")+" "+this.toThemeProperty("jqx-fill-state-normal")+" "+this.toThemeProperty("jqx-rc-all"));this.disabled&&this.disable();this.disabledContainer||
1531(this.host.addClass(this.toThemeProperty("jqx-widget")),this.host.addClass(this.toThemeProperty("jqx-checkbox")));this.locked&&!this.disabledContainer&&this.host.css("cursor","auto");c=this.element.getAttribute("checked");if("checked"==c||"true"==c||1==c)this.checked=!0;this._addInput();this._render();this._addHandlers();this.init=!1;this._centerBox();this.isMaterialized()&&(a(this.checkbox).addClass("ripple"),a.jqx.ripple(a(this.checkbox),this.host,"checkbox"))},_centerBox:function(){if(this.height&&
1532-1==this.height.toString().indexOf("%")&&this.box){var b=parseInt(this.height);this.host.css("line-height",b+"px");b=b-parseInt(this.boxSize)-1;this.box.css("margin-top",parseInt(b/2))}},refresh:function(b){b||(this.setSize(),this._render())},resize:function(b,c){this.width=b;this.height=c;this.refresh()},setSize:function(){null!=this.width&&-1!=this.width.toString().indexOf("px")?this.host.width(this.width):void 0==this.width||isNaN(this.width)?null!=this.width&&-1!=this.width.toString().indexOf("%")&&
1533(this.element.style.width=this.width):this.host.width(this.width);null!=this.height&&-1!=this.height.toString().indexOf("px")?this.host.height(this.height):void 0==this.height||isNaN(this.height)?null!=this.height&&-1!=this.height.toString().indexOf("%")&&(this.element.style.height=this.height):this.host.height(this.height);this._centerBox()},_addHandlers:function(){var b=this,c="mousedown";a.jqx.mobile.isTouchDevice()&&(c=a.jqx.mobile.getTouchEventName("touchend"));this.addHandler(this.box,c,function(d){if(!b.disabled&&
1534!b.enableContainerClick&&!b.locked)return b.changeType="mouse",b.toggle(
1534),b.updated&&(d.owner=b,b.updated(d,b.checked,b.oldChecked)),d.preventDefault&&d.preventDefault(),!1});this.disabledContainer||(this.addHandler(this.host,"keydown",function(d){if(!b.disabled&&!b.locked&&b.keyboardCheck&&32==d.keyCode){if(!b._canFocus)return!0;b.changeType="keyboard";b.toggle();b.updated&&(d.owner=b,b.updated(d,b.checked,b.oldChecked));d.preventDefault&&d.preventDefault();return!1}}),this.addHandler(this.host,
1535c,function(d){if(!b.disabled&&b.enableContainerClick&&!b.locked)return b.clickTime=new Date,b.changeType="mouse",b.toggle(),d.preventDefault&&d.preventDefault(),b._canFocus&&b.focus(),!1}),this.addHandler(this.host,"selectstart",function(d){if(!b.disabled&&b.enableContainerClick)return d.preventDefault&&d.preventDefault(),!1}),this.addHandler(this.host,"mouseup",function(d){!b.disabled&&b.enableContainerClick&&d.preventDefault&&d.preventDefault()}),this.addHandler(this.host,"focus",function(d){if(!b.disabled&&
1536!b.locked){if(!b._canFocus)return!0;b.enableHover&&b.box.addClass(b.toThemeProperty("jqx-checkbox-hover"));b.box.addClass(b.toThemeProperty("jqx-fill-state-focus"));d.preventDefault&&d.preventDefault();a(b.checkbox).removeClass("active");(!b.clickTime||b.clickTime&&300<new Date-b.clickTime)&&a(b.checkbox).addClass("active");b.hovered=!0;return!1}}),this.addHandler(this.host,"blur",function(d){a(b.checkbox).removeClass("active");if(!b.disabled&&!b.locked){if(!b._canFocus)return!0;b.enableHover&&b.box.removeClass(b.toThemeProperty("jqx-checkbox-hover"));
1537b.box.removeClass(b.toThemeProperty("jqx-fill-state-focus"));d.preventDefault&&d.preventDefault();return b.hovered=!1}}),this.addHandler(this.host,"mouseenter",function(d){b.locked&&b.host.css("cursor","arrow");if(b.enableHover&&!b.disabled&&b.enableContainerClick&&!b.locked)return b.box.addClass(b.toThemeProperty("jqx-checkbox-hover")),b.box.addClass(b.toThemeProperty("jqx-fill-state-hover")),d.preventDefault&&d.preventDefault(),b.hovered=!0,!1}),this.addHandler(this.host,"mouseleave",function(d){if(b.enableHover&&
1538!b.disabled&&b.enableContainerClick&&!b.locked)return b.box.removeClass(b.toThemeProperty("jqx-checkbox-hover")),b.box.removeClass(b.toThemeProperty("jqx-fill-state-hover")),d.preventDefault&&d.preventDefault(),b.hovered=!1}),this.addHandler(this.box,"mouseenter",function(){b.locked||b.disabled||b.enableContainerClick||(b.box.addClass(b.toThemeProperty("jqx-checkbox-hover")),b.box.addClass(b.toThemeProperty("jqx-fill-state-hover")))}),this.addHandler(this.box,"mouseleave",function(){b.disabled||b.enableContainerClick||
1539(b.box.removeClass(b.toThemeProperty("jqx-checkbox-hover")),b.box.removeClass(b.toThemeProperty("jqx-fill-state-hover")))}))},focus:function(){try{this.host.focus()}catch(b){}},_removeHandlers:function(){var b="mousedown";a.jqx.mobile.isTouchDevice()&&(b="touchend");this.box&&(this.removeHandler(this.box,b),this.removeHandler(this.box,"mouseenter"),this.removeHandler(this.box,"mouseleave"));this.removeHandler(this.host,b);this.removeHandler(this.host,"mouseup");this.removeHandler(this.host,"selectstart");
1540this.removeHandler(this.host,"mouseenter");this.removeHandler(this.host,"mouseleave");this.removeHandler(this.host,"keydown");this.removeHandler(this.host,"blur");this.removeHandler(this.host,"focus")},_render:function(){this.disabled?this.disable():this.enableContainerClick?this.host.css("cursor","pointer"):this.init||this.host.css("cursor","auto");this.rtl&&(this.box.addClass(this.toThemeProperty("jqx-checkbox-rtl")),this.host.addClass(this.toThemeProperty("jqx-rtl")));this.updateStates();this.host.attr("checked",
1541this.checked)},_setState:function(b,c){this.checked!=b&&(this.checked=b,this.checkMark[0].className=this.checked?this.toThemeProperty("jqx-checkbox-check-checked"):null==this.checked?this.toThemeProperty("jqx-checkbox-check-indeterminate"):"");if(!1===c||!0===c)this.locked=c;b?this.element.setAttribute("checked",!0):this.element.removeAttribute("checked")},val:function(b){if(0==arguments.length||null!=b&&"object"==typeof b)return this.checked;"string"==typeof b?("true"==b&&this.check(),"false"==b&&
1542this.uncheck(),""==b&&this.indeterminate()):(1==b&&this.check(),0==b&&this.uncheck(),null==b&&this.indeterminate());return this.checked},check:function(){this.checked=!0;var b=this;this.checkMark.removeClass();this.element.setAttribute("checked",!0);a.jqx.browser.msie||0==this.animationShowDelay?this.checkMark.addClass(this.toThemeProperty("jqx-checkbox-check-checked")):(this.checkMark.addClass(this.toThemeProperty("jqx-checkbox-check-checked")),this.checkMark.css("opacity",0),this.checkMark.stop().animate({opacity:1},
1543this.animationShowDelay,function(){}));if(null!=this.groupName&&0<this.groupName.length){var c=a.find(this.toThemeProperty(".jqx-checkbox",!0));a.each(c,function(){a(this).jqxCheckBox("groupName")==b.groupName&&this!=b.element&&a(this).jqxCheckBox("uncheck")})}c=this.changeType;this._raiseEvent("0",{checked:!0});this.changeType=c;this._raiseEvent("3",{checked:!0});void 0!=this.input&&(this.input.val(this.checked),a.jqx.aria(this,"aria-checked",this.checked),this.host.attr("checked",this.checked))},
1544uncheck:function(){this.checked=!1;var b=this;this.element.removeAttribute("checked");a.jqx.browser.msie||0==this.animationHideDelay?""!=b.checkMark[0].className&&(b.checkMark[0].className=""):(this.checkMark.css("opacity",1),this.checkMark.stop().animate({opacity:0}
1544,this.animationHideDelay,function(){""!=b.checkMark[0].className&&(b.checkMark[0].className="")}));var c=this.changeType;this._raiseEvent("1");this.changeType=c;this._raiseEvent("3",{checked:!1});void 0!=this.input&&(this.input.val(this.checked),
1545a.jqx.aria(this,"aria-checked",this.checked),this.host.attr("checked",this.checked))},indeterminate:function(){this.checked=null;this.checkMark.removeClass();a.jqx.browser.msie||0==this.animationShowDelay?this.checkMark.addClass(this.toThemeProperty("jqx-checkbox-check-indeterminate")):(this.checkMark.addClass(this.toThemeProperty("jqx-checkbox-check-indeterminate")),this.checkMark.css("opacity",0),this.checkMark.stop().animate({opacity:1},this.animationShowDelay,function(){}));this._raiseEvent("2");
1546this._raiseEvent("3",{checked:null});void 0!=this.input&&(this.input.val(this.checked),a.jqx.aria(this,"aria-checked","undefined"),this.host.attr("checked","undefined"))},toggle:function(){this.disabled||this.locked||(null!=this.groupName&&0<this.groupName.length?1!=this.checked&&(this.checked=!0,this.updateStates()):(this.oldChecked=this.checked,this.checked=1==this.checked?this.hasThreeStates?null:!1:null!=this.checked,this.updateStates(),void 0!=this.input&&this.input.val(this.checked)))},updateStates:function(){this.checked?
1547this.check():0==this.checked?this.uncheck():null==this.checked&&this.indeterminate()},disable:function(){this.disabled=!0;1==this.checked?this.checkMark.addClass(this.toThemeProperty("jqx-checkbox-check-disabled")):null==this.checked&&this.checkMark.addClass(this.toThemeProperty("jqx-checkbox-check-indeterminate-disabled"));this.box.addClass(this.toThemeProperty("jqx-checkbox-disabled-box"));this.host.addClass(this.toThemeProperty("jqx-checkbox-disabled"));this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled"));
1548this.box.addClass(this.toThemeProperty("jqx-checkbox-disabled"));a.jqx.aria(this,"aria-disabled",this.disabled)},enable:function(){1==this.checked?this.checkMark.removeClass(this.toThemeProperty("jqx-checkbox-check-disabled")):null==this.checked&&this.checkMark.removeClass(this.toThemeProperty("jqx-checkbox-check-indeterminate-disabled"));this.box.removeClass(this.toThemeProperty("jqx-checkbox-disabled-box"));this.host.removeClass(this.toThemeProperty("jqx-checkbox-disabled"));this.host.removeClass(this.toThemeProperty("jqx-fill-state-disabled"));
1549this.box.removeClass(this.toThemeProperty("jqx-checkbox-disabled"));this.disabled=!1;a.jqx.aria(this,"aria-disabled",this.disabled)},destroy:function(){this.host.remove()},_raiseEvent:function(b,c){if(!this.init){b=new a.Event(this.events[b]);b.owner=this;c||={};c.type=this.changeType;this.changeType=null;b.args=c;try{var d=this.host.trigger(b)}catch(e){}return d}},propertiesChangedHandler:function(b,c,d){d.width&&d.height&&2==Object.keys(d).length&&b.setSize()},propertyChangedHandler:function(b,
1550c,d,e){if(void 0!=this.isInitialized&&0!=this.isInitialized&&!(b.batchUpdate&&b.batchUpdate.width&&b.batchUpdate.height&&2==Object.keys(b.batchUpdate).length)){"enableContainerClick"!=c||b.disabled||b.locked||(e?b.host.css("cursor","pointer"):b.host.css("cursor","auto"));"rtl"==c&&(e?(b.box.addClass(b.toThemeProperty("jqx-checkbox-rtl")),b.host.addClass(b.toThemeProperty("jqx-rtl"))):(b.box.removeClass(b.toThemeProperty("jqx-checkbox-rtl")),b.host.removeClass(b.toThemeProperty("jqx-rtl"))));"boxSize"==
1551c&&b.render();"theme"==c&&a.jqx.utilities.setTheme(d,e,b.host);if("checked"==c&&e!=d)switch(e){case !0:b.check();break;case !1:b.uncheck();break;case null:b.indeterminate()}"disabled"==c&&e!=d&&(e?b.disable():b.enable())}}})})(jqxBaseFramework);
1552(function(a){a.jqx.jqxWidget("jqxRibbon","",{});a.extend(a.jqx._jqxRibbon.prototype,{defineInstance:function(){var b={width:null,height:"auto",mode:"default",position:"top",selectedIndex:-1,selectionMode:"click",popupCloseMode:"click",animationType:"fade",animationDelay:400,scrollPosition:"both",disabled:!1,rtl:!1,scrollStep:10,scrollDelay:30,reorder:!1,initContent:null,_roundedCorners:!0,_removeByDrag:!1,_suppressReorder:!0,events:["select","unselect","change","_removeByDrag","reorder"]}
1552;if(this===
1553a.jqx._jqxRibbon.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(){if("none"===this.host.css("display")||!1===document.body.contains(this.element))this._initiallyHidden=!0;this._browser=a.jqx.browser;"popup"!==this.mode&&-1===this.selectedIndex&&(this.selectedIndex=0);this._originalHTML=this.element.innerHTML;this._render(!0)},render:function(){this._render()},refresh:function(b){!0!==b&&this._render()},destroy:function(){this._removeHandlers();this.host.remove()},selectAt:function(b){this._selectAt(b)},
1554clearSelection:function(){-1!==this.selectedIndex&&this._clearSelection()},disableAt:function(b){this._items[b]._disabled=!0;a(this._items[b]).addClass(this.toThemeProperty("jqx-fill-state-disabled"));b===this.selectedIndex&&this._clearSelection()},enableAt:function(b){this._items[b]._disabled=!1;a(this._items[b]).removeClass(this.toThemeProperty("jqx-fill-state-disabled"))},hideAt:function(b){this._items[b].style.display="none";this._checkScrollButtons();b===this.selectedIndex?this._clearSelection():
1555this._updatePositions()},showAt:function(b){this._items[b].style.display="horizontal"===this._orientation?"inline-block":"inherit";this._checkScrollButtons();this._updatePositions()},val:function(b){if(b)this._selectAt(b);else return this.selectedIndex},addAt:function(b,c){var d="jqx-ribbon-item jqx-ribbon-item-"+this.position,e="jqx-widget-content jqx-ribbon-content-section jqx-ribbon-content-section-"+this.position;this._removeHandlers();var f=document.createElement("li");f.innerHTML=c.title;var g=
1556document.createElement("div");if("string"===typeof c.content)g.innerHTML=c.content;else if(void 0!==c.content.length)try{if(void 0!==window.$&&c.content instanceof window.$)a(g).append(c.content);else if(a.isArray(c.content))for(var h=0;h<c.content.length;h++)c.content[h].appendTo(g);else for(;0<c.content.length;)g.appendChild(c.content[0])}catch(k){}else g.appendChild(c.content);switch(this.position){case "top":d+=" jqx-rc-t";e+=" jqx-rc-b";break;case "bottom":d+=" jqx-rc-b";e+=" jqx-rc-t";break;
1557case "left":d+=" jqx-rc-l";e+=" jqx-rc-r";break;case "right":d+=" jqx-rc-r",e+=" jqx-rc-l"}"popup"===this.mode&&(e+=" jqx-ribbon-content-section-popup jqx-ribbon-content-section-"+this._orientation+"-popup");!0===this.rtl&&(d+=" jqx-ribbon-item-rtl");f.className=this.toThemeProperty(d);g.className=this.toThemeProperty(e);this._items.length-1>=b?(this._headerElement.insertBefore(f,this._items[b]),this._contentElement.insertBefore(g,this._contentSections[b])):(this._headerElement.appendChild(f),this._contentElement.appendChild(g));
1558this._updateItems();this._addHandlers();this._checkScrollButtons();b<=this.selectedIndex&&this.selectedIndex<this._items.length-1&&this.selectedIndex++;this._updatePositions();0>this.selectedIndex||(this._suppressSelectionEvents=!0,this._selectAt(this.selectedIndex,this.selectedIndex,!0))},removeAt:function(b){b===this.selectedIndex&&this._clearSelection();a(this._items[b]).remove();a(this._contentSections[b]).remove();this._updateItems(!0);this._updatePositions();this._checkScrollButtons()},updateAt:function(b,
1559c){var d=this._items[b];d.innerHTML=c.newTitle;this._contentSections[b].innerHTML=c.newContent;d._isInitialized=!1;this.initContent&&b===this.selectedIndex&&(this.initContent(b),d._isInitialized=!0);this._updatePositions()},setPopupLayout:function(b,c,d,e){var f=this._contentSections[b];"popup"===this.mode&&(f.getAttribute("data-width")||(f.style.width&&f.setAttribute("data-width",f.style.width),f.style.height&&f.setAttribute("data-height",f.style.height)),d&&(f.style.width=this._toPx(d)),e&&(f.style.height=
1560this._toPx(e)),f._layout=c,this._positionContent(b))},propertiesChangedHandler:function(b,c,d){d&&d.width&&d.height&&2===Object.keys(d).length&&(b.element.style.width=b._toPx(b.width),b.element.style.height=b._toPx(b.height),b._updateSize())},propertyChangedHandler:function(b,c,d,e){if(!(b.batchUpdate&&b.batchUpdate.width&&b.batchUpdate.height&&2===Object.keys(b.batchUpdate).length)&&e!==d)switch(c){case "width":case "height":b.element.style[c]=b._toPx(e);b._updateSize();break;case "position":b._render();
1561break;case "mode":b._contentElement.style.width="auto";b._removeHandlers(null,d);b._render();break;case "selectedIndex":b._selectAt(e,d);break;case "selectionMode":b._removeHandlers(d);b._addHandlers();break;case "scrollPosition":c=b._scrollButtonNear;var f=b._scrollButtonFar;a(c).removeClass(b.toThemeProperty("jqx-ribbon-scrollbutton-"+d+" jqx-rc-tr jqx-rc-bl jqx-rc-tl"));a(f).removeClass(b.toThemeProperty("jqx-ribbon-scrollbutton-"+d+" jqx-rc-tr jqx-rc-bl jqx-rc-br"));c.className+=" "+b.toThemeProperty("jqx-ribbon-scrollbutton-"+
1562e);f.className+=" "+b.toThemeProperty("jqx-ribbon-scrollbutton-"+e);b._scrollButtonRc(c,f);b._checkScrollButtons();b._updatePositions();break;case "disabled":!0===e?(b._removeHandlers(),b.element.className+=" "+b.toThemeProperty("jqx-fill-state-disabled")):(b.host.removeClass(b.toThemeProperty("jqx-fill-state-disabled")),b._addHandlers());break;case "theme":a.jqx.utilities.setTheme(d,e,b.host);break;case "rtl":if(!0===e)for(b._headerElement.className+=" "+b.toThemeProperty("jqx-ribbon-header-rtl"),
1563d=0;d<b._items.length;d++)b._items[d].className+=" "+b.toThemeProperty("jqx-ribbon-item-rtl");else for(b._header.removeClass(b.toThemeProperty("jqx-ribbon-header-rtl")),d=0;d<b._items.length;d++)a(b._items[d]).removeClass(b.toThemeProperty("jqx-ribbon-item-rtl"));b._positionSelectionToken(b.selectedIndex)}}
1563,_raiseEvent:function(b,c){b=new a.Event(this.events[b]);b.owner=this;b.args=c;try{var d=this.host.trigger(b)}catch(e){}return d},_render:function(b){var c=this;!0!==b&&c._removeHandlers();c._selectionTokenOffsetY=
15640;switch(c._browser.browser){case "mozilla":c._browserWidthRtlFlag=0;c._browserScrollRtlFlag=1;c._selectionTokenOffsetX=1;break;case "msie":c._browserWidthRtlFlag=0;c._browserScrollRtlFlag=-1;"8.0"===c._browser.version?c._selectionTokenOffsetX=1:"7.0"===c._browser.version?(c._selectionTokenOffsetX=0,"popup"!==c.mode||"bottom"!==c.position&&"right"!==c.position||(c._selectionTokenOffsetY=2)):c._selectionTokenOffsetX=0;break;default:c._browserWidthRtlFlag=1,c._browserScrollRtlFlag=1,c._selectionTokenOffsetX=
15650}if(!0===b){var d=c.host.children();c._headerElement=d[0];c._header=a(d[0]);c._contentElement=d[1];c._content=a(d[1]);c._checkStructure(d);c._refreshBarPosition()}c._headerElement.style["float"]="none";c._contentElement.style.padding="0px";c.element.style.width=c._toPx(c.width);c.element.style.height=c._toPx(c.height);"bottom"!==c.position&&"right"!==c.position||c.element.insertBefore(c._contentElement,c._headerElement);c._orientation="top"===c.position||"bottom"===c.position?"horizontal":"vertical";
1566"right"===c.position?c._headerElement.style["float"]="right":"left"===c.position&&(c._headerElement.style["float"]="left");c._contentSections=c._content.children();a.each(c._contentSections,function(){this.getAttribute("data-width")&&(this.style.width=this.getAttribute("data-width"),this.style.height=this.getAttribute("data-height"),this.removeAttribute("data-width"),this.removeAttribute("data-height"))});!0===b&&(c._selectionToken=document.createElement("div"),c._selectionToken.className=c.toThemeProperty("jqx-widget-content jqx-ribbon-selection-token jqx-ribbon-selection-token-"+
1567c.position),c.element.appendChild(c._selectionToken));c._updateItems();!0!==c._initiallyHidden&&c._addClasses();!0===b&&(c._appendScrollButtons(),c._checkScrollButtons());c._allowSelection=!0;-1!==c.selectedIndex&&(c._items[c.selectedIndex].className+=" "+c.toThemeProperty("jqx-widget-content jqx-ribbon-item-selected"),c._positionSelectionToken(c.selectedIndex),c._contentSections[c.selectedIndex].style.display="block",c.initContent&&(c.initContent(c.selectedIndex),c._items[c.selectedIndex]._isInitialized=
1568!0));c.disabled?c.element.className+=" "+c.toThemeProperty("jqx-fill-state-disabled"):c._addHandlers();a.jqx.utilities.resize(c.host,function(){c._initiallyHidden&&(c._initiallyHidden=!1,c._addClasses(),-1!==c.selectedIndex&&(c._items[c.selectedIndex].className+=" "+c.toThemeProperty("jqx-widget-content jqx-ribbon-item-selected")));c._updateSize(!0)});"popup"===c.mode&&""!==c.theme&&setTimeout(function(){c._positionPopup();c._positionSelectionToken(c.selectedIndex)},30)},_updateSize:function(b){if("7.0"===
1569this._browser.version&&"msie"===this._browser.browser)if("horizontal"===this._orientation)this._header.css("width",this.host.width()-parseInt(this._header.css("padding-left"),10)-parseInt(this._header.css("padding-right"),10)-parseInt(this._header.css("border-left-width"),10)-parseInt(this._header.css("border-right-width"),10)),this._contentSections.width(this._content.width()-parseInt(this._contentSections.css("border-left-width"),10)-parseInt(this._contentSections.css("border-right-width"),10)-
1570parseInt(this._contentSections.css("padding-left"),10)-parseInt(this._contentSections.css("padding-right"),10)),"default"===this.mode&&"string"===typeof this.height&&-1!==this.height.indexOf("%")&&this._contentSections.height(this._content.height()-this._header.height()-parseInt(this._contentSections.css("border-bottom-width"),10)-parseInt(this._contentSections.css("border-top-width"),10)-1);else if(this._header.css("height",this.host.height()-parseInt(this._header.css("padding-top"),10)-parseInt(this._header.css("padding-bottom"),
157110)-parseInt(this._header.css("border-top-width"),10)-parseInt(this._header.css("border-bottom-width"),10)),this._contentSections.height(this._content.height()-parseInt(this._contentSections.css("border-top-width"),10)-parseInt(this._contentSections.css("border-bottom-width"),10)-parseInt(this._contentSections.css("padding-top"),10)-parseInt(this._contentSections.css("padding-bottom"),10)),"default"===this.mode&&"string"===typeof this.width&&-1!==this.height.indexOf("%")){var c="left"===this.position?
1572parseInt(this._contentSections.css("border-left-width"),10)+parseInt(this._contentSections.css("border-right-width"),10)+1:0;this._contentSections.width(this._content.width()-this._header.width()-c)}this._checkScrollButtons(!0);this._updatePositions(void 0,b);"popup"===this.mode&&this._positionPopup();this._refreshBarPosition()},_stopAnimation:function(){if(!this._allowSelection){this.selectedIndex=this._animatingIndex;var b=a(this._contentSections[this._animatingIndex]);this._initAnimate(b);b.animate("finish");
1573this._clearSelection(!0,this._animatingIndex);this._allowSelection=!0}
1573},_refreshBarPosition:function(){var b=this;if(!this.bar){var c=a("<span></span>");a(this.host).append(c);c.addClass(this.toThemeProperty("jqx-tabs-bar"));this.bar=c}setTimeout(function(){var d=parseInt(a(b._headerElement).css("left"),10)-b._headerElement.scrollLeft,e=parseInt(a(b._headerElement).css("top"),10)-b._headerElement.scrollTop,f=void 0!==b._animatingIndex?b._animatingIndex:b.selectedIndex;b._items[f]&&b.bar&&("top"===
1574b.position||"bottom"===b.position?(b.bar.css("left",b._items[f].offsetLeft+d),"top"===b.position?b.bar.css("top",b._items[f].offsetTop+e+b._items[f].offsetHeight):b.bar.css("top",e),b.bar.width(a(b._items[f]).outerWidth()-2),b.bar.removeClass(b.toThemeProperty("vertical"))):("left"===b.position?b.bar.css("left",b._items[f].offsetLeft+d+b._items[f].offsetWidth):b.bar.css("left",b._items[f].offsetLeft+d),b.bar.css("top",e+b._items[f].offsetTop),b.bar.height(a(b._items[f]).outerHeight()-2),b.bar.addClass(b.toThemeProperty("vertical"))))})},
1575_selectAt:function(b,c,d){var e=this;void 0===c&&(c=e.selectedIndex);if(b!==c||!0===d)if(e._stopAnimation(),e._refreshBarPosition(),e._allowSelection){e._animatingIndex=b;-1!==e.selectedIndex&&e._clearSelection(!0,c);e._allowSelection=!1;e._selecting=b;"click"===e.selectionMode&&a(e._items[b]).removeClass(e.toThemeProperty("jqx-fill-state-hover jqx-ribbon-item-hover"));if("popup"===e.mode&&e._roundedCorners){e._header.removeClass(e.toThemeProperty("jqx-rc-all"));switch(e.position){case "top":var f=
1576"jqx-rc-t";var g="jqx-rc-b";break;case "bottom":f="jqx-rc-b";g="jqx-rc-t";break;case "left":f="jqx-rc-l";g="jqx-rc-r";break;case "right":f="jqx-rc-r",g="jqx-rc-l"}e._headerElement.className+=" "+e.toThemeProperty(f);for(d=0;d<e._items.length;d++)e._items[d].className+=" "+e.toThemeProperty(f),e._contentSections[d].className+=" "+e.toThemeProperty(g)}e._items[b].className+=" "+e.toThemeProperty("jqx-widget-content jqx-ribbon-item-selected");e._selectionToken.style.display="block";e._updatePositions(b);
1577switch(e.animationType){case "fade":f=a(e._contentSections[b]);e._initAnimate(f);"none"===f.css("display")?f.fadeIn({duration:e.animationDelay,complete:function(){e._animationComplete(b,c)}}):f.fadeOut({duration:e.animationDelay,complete:function(){e._animationComplete(b,c)}});break;case "slide":f=a(e._contentSections[b]);g=e.position;"top"===g?g="up":"bottom"===g&&(g="down");e.slideAnimation=e._slide(f,{mode:"show",direction:g,duration:e.animationDelay},b,c);break;case "none":e._contentSections[b].style.display=
1578"block",e._animationComplete(b,c)}}},_clearSelection:function(b,c){var d=this;
1578"popup"===d.mode&&d._roundedCorners&&(d._headerElement.className+=" "+d.toThemeProperty("jqx-rc-all"));d._selecting=-1;void 0===c&&(c=d.selectedIndex);a(d._items[c]).removeClass(d.toThemeProperty("jqx-widget-content jqx-ribbon-item-selected"));d._selectionToken.style.display="none";if(!0!==b&&"none"!==d.animationType)if(b=a(d._contentSections[c]),"fade"===d.animationType)d._initAnimate(b),b.fadeOut({duration:d.animationDelay,
1579complete:function(){d._clearSelectionComplete(c)}});else{if("slide"===d.animationType){var e=d.position;"top"===e?e="up":"bottom"===e&&(e="down");d._stopAnimation();c=d.selectedIndex;d.slideAnimation=d._slide(b,{mode:"hide",direction:e,duration:d.animationDelay},c);d.selectedIndex=-1}}else-1!==c&&(d._contentSections[c].style.display="none",d._clearSelectionComplete(c,b))},_addHandlers:function(){function b(y){y=l._closest(y.target,"li");var A=y._index;l._items[A]._disabled||(A!==l.selectedIndex?l._selectAt(A):
1580"popup"===l.mode&&"none"!==l.popupCloseMode&&(y.className+=" "+l.toThemeProperty("jqx-fill-state-hover jqx-ribbon-item-hover"),l._clearSelection()))}function c(y){if(!0===l.reorder&&!0===n){var A=l._closest(y.target,"li")._index;y=l._items[r].innerHTML;for(var aa=l._contentSections[r].childNodes,ha=[];0<aa.length;)ha.push(a(aa[0]).detach());l._suppressSelectionEvents=!0;l._oldReorderIndex=r;l.removeAt(r);l.clearSelection();l.addAt(A,{title:y,content:ha});l.selectAt(A);setTimeout(function(){a(l._items[A]).trigger("mousedown")},
15810)}else y=l._closest(y.target,"li"),u(y._index)&&(y.className+=" "+l.toThemeProperty("jqx-fill-state-hover jqx-ribbon-item-hover"))}function d(y){y=l._closest(y.target,"li");u(y._index)&&a(y).removeClass(l.toThemeProperty("jqx-fill-state-hover jqx-ribbon-item-hover"))}function e(y){"#document"!==y.target.nodeName&&(y=l._closest(y.target,"li"),!0!==l.reorder&&!0!==l._removeByDrag||y._index!==l.selectedIndex||(n=!0,r=y._index,y.style.cursor="move"))}function f(){"mouseLeave"===l.popupCloseMode&&"popup"===
1582l.mode&&l._clearSelection()}function g(y){y=l._closest(y.target,"li")._index;l._items[y]._disabled||y===l.selectedIndex||l._selectAt(y)}function h(y){y=l._closest(y.target,"li")._index;l._items[y]._disabled||"popup"===l.mode&&"none"!==l.popupCloseMode&&l._clearSelection()}function k(){"mouseLeave"===l.popupCloseMode&&"popup"===l.mode&&l._clearSelection()}var l=this,m=l.element.id,n=!1,r,t=function(y){if("click"===l.popupCloseMode&&"popup"===l.mode&&-1!==l.selectedIndex&&"svg"!==y.target.tagName){var A=
1583l._closest(y.target,void 0,"jqx-ribbon");if(void 0!==A&&A.getAttribute("id")!==m)l._clearSelection();else if(void 0===y.target.className||-1!==y.target.className.indexOf("jqx-ribbon-content-popup"))l._clearSelection();else if(!a(y.target).ischildof(l.host)){var aa=!1,ha=[],z=function(V){V.parentElement&&(ha.push(V.parentElement),z(V.parentElement))};z(y.target);a.each(ha,function(){if(void 0!==this.className&&this.className.indexOf){if(-1!==this.className.indexOf("jqx-ribbon"))return aa=!0,!1;if(-1!==
1584this.className.indexOf("jqx-ribbon"))return m===this.id&&(aa=!0),!1}});aa||l._clearSelection()}}};if("click"===l.selectionMode){for(var u=function(y){return(l._selecting!==y&&!1===l._allowSelection||(-1===l._selecting||l.selectedIndex!==y)&&!0===l._allowSelection)&&!l._items[y]._disabled},x=0;x<l._items.length;x++){var B=l._items[x];l.addHandler(B,"click.ribbon"+m,b);l.addHandler(B,"mouseenter.ribbon"+m,c);l.addHandler(B,"mouseleave.ribbon"+m,d);l.addHandler(B,"mousedown.ribbon"+m,e)}if("popup"===
1585l.mode){l.addHandler(l.host,"mouseleave.ribbon"+m,function(){"mouseLeave"===l.popupCloseMode&&"popup"===l.mode&&l._clearSelection()});for(x=0;x<l._contentSections.length;x++)l.addHandler(l._contentSections[x],"mouseleave.ribbon"+m,f);l.addHandler(a(document),"mousedown.ribbon"+m,function(y){t(y)})}if(!0===l._removeByDrag)for(x=0;x<l._items.length;x++)l._items[x].className+=" "+l.toThemeProperty("jqx-ribbon-item-docking-layout");l.addHandler(document,"mouseup.ribbon"+m,function(){n=!1;for(var y=0;y<
1586l._items.length;y++)l._items[y].style.cursor=""});l.addHandler(l._header,"mouseleave.ribbon"+m,function(y){!0===l._removeByDrag&&!0===n&&(l._raiseEvent("3",{draggedIndex:r,x:y.pageX,y:y.pageY}),1<l._items.length&&l.removeAt(r),n=!1,y.target.style.cursor="")}
1586)}else if("hover"===l.selectionMode){for(x=0;x<l._items.length;x++)B=l._items[x],l.addHandler(B,"mouseenter.ribbon"+m,g),"popup"===l.mode&&l.addHandler(B,"click.ribbon"+m,h);if("popup"===l.mode){l.addHandler(l.host,"mouseleave.ribbon"+m,function(){"mouseLeave"===
1587l.popupCloseMode&&"popup"===l.mode&&l._clearSelection()});for(x=0;x<l._contentSections.length;x++)l.addHandler(l._contentSections,"mouseleave.ribbon"+m,k);l.addHandler(a(document),"mousedown.ribbon"+m,function(y){t(y)})}}a.jqx.mobile.isTouchDevice()?(x="touchstart",B="touchend"):(x="mousedown",B="mouseup");l.addHandler(l._scrollButtonNear,x+".ribbon"+m,function(){l._timeoutNear="horizontal"===l._orientation?setInterval(function(){l._headerElement.scrollLeft-=l.scrollStep*(l.rtl&&"msie"===l._browser.browser?
1588-1:1);l._updatePositions()},l.scrollDelay):setInterval(function(){l._headerElement.scrollTop-=l.scrollStep;l._updatePositions()},l.scrollDelay);return!1});l.addHandler(l._scrollButtonFar,x+".ribbon"+m,function(){l._timeoutFar="horizontal"===l._orientation?setInterval(function(){l._headerElement.scrollLeft+=l.scrollStep*(l.rtl&&"msie"===l._browser.browser?-1:1);l._updatePositions()},l.scrollDelay):setInterval(function(){l._headerElement.scrollTop+=l.scrollStep;l._updatePositions()},l.scrollDelay);
1589return!1});l.addHandler(a(document),B+".ribbon"+m,function(){clearInterval(l._timeoutNear);clearInterval(l._timeoutFar)})},_removeHandlers:function(b,c){var d=this.element.id;b||(b=this.selectionMode);c||(c=this.mode);for(var e=0;e<this._items.length;e++){var f=this._items[e];this.removeHandler(f,"mouseenter.ribbon"+d);"click"===b&&(this.removeHandler(f,"click.ribbon"+d),this.removeHandler(f,"mouseleave.ribbon"+d),this.removeHandler(f,"mousedown.ribbon"+d))}"click"===b?(this.removeHandler(document,
1590"mouseup.ribbon"+d),this.removeHandler(this._header,"mouseleave.ribbon"+d)):"hover"===b&&"popup"===c&&this.removeHandler(this.host,"mouseleave.ribbon"+d);a.jqx.mobile.isTouchDevice()?(b="touchstart",c="touchend"):(b="mousedown",c="mouseup");this.removeHandler(this._scrollButtonNear,b+".ribbon"+d);this.removeHandler(this._scrollButtonFar,b+".ribbon"+d);this.removeHandler(a(document),c+".ribbon"+d)},_checkStructure:function(b){if(2!==b.length)throw Error("jqxRibbon: Invalid HTML structure. You need to add a ul and a div to the widget container.");
1591b=this._header.children().length;var c=this._content.children().length;if(b!==c)throw Error("jqxRibbon: Invalid HTML structure. For each list item you must have a corresponding div element.");},_addClasses:function(){var b="jqx-widget-content jqx-ribbon-content-section jqx-ribbon-content-section-"+this.position,c="jqx-widget-content jqx-ribbon-content jqx-ribbon-content-"+this._orientation,d="jqx-widget-header jqx-disableselect jqx-ribbon-header jqx-ribbon-header-"+this._orientation,e="jqx-ribbon-item jqx-ribbon-item-"+
1592this.position;this._content.removeClass();this._header.removeClass(this.toThemeProperty("jqx-rc-all jqx-widget-header jqx-disableselect jqx-rc-t jqx-rc-b jqx-rc-l jqx-rc-r jqx-rc-all jqx-ribbon-header-"+this._orientation+"-popup jqx-ribbon-header-bottom jqx-ribbon-header-auto jqx-ribbon-header-right jqx-ribbon-header-rtl"));this.host.removeClass();if(this._roundedCorners)switch(this.position){case "top":d+=" jqx-rc-t";e+=" jqx-rc-t";b+=" jqx-rc-b";break;case "bottom":d+=" jqx-rc-b";e+=" jqx-rc-b";
1593b+=" jqx-rc-t";break;case "left":d+=" jqx-rc-l";e+=" jqx-rc-l";b+=" jqx-rc-r";break;case "right":d+=" jqx-rc-r",e+=" jqx-rc-r",b+=" jqx-rc-l"}else switch(this.position){case "top":e+=" jqx-rc-t";break;case "bottom":e+=" jqx-rc-b";break;case "left":e+=" jqx-rc-l";break;case "right":e+=" jqx-rc-r"}!0===this.rtl&&(d+=" jqx-ribbon-header-rtl",e+=" jqx-ribbon-item-rtl");this.element.className+=" "+this.toThemeProperty("jqx-widget jqx-ribbon");this._headerElement.className+=" "+this.toThemeProperty(d);
1594this._contentElement.className+=" "+this.toThemeProperty(c);for(c=0;c<this._items.length;c++){d=a(this._contentSections[c]);var f=a(this._items[c]);d.removeClass();f.removeClass(this.toThemeProperty("jqx-fill-state-disabled jqx-ribbon-item-rtl jqx-widget-content jqx-ribbon-item-selected jqx-rc-t jqx-rc-b jqx-rc-l jqx-rc-r jqx-ribbon-item-docking-layout jqx-ribbon-item jqx-ribbon-item-"+this.position));"popup"===this.mode&&(b+=" jqx-ribbon-content-section-popup jqx-ribbon-content-popup-"+this.position+
1595" jqx-ribbon-content-section-"+this._orientation+"-popup");this._contentSections[c].className+=" "+this.toThemeProperty(b);this._items[c].className+=" "+this.toThemeProperty(e)}if("popup"===this.mode)-1===this.selectedIndex&&this._roundedCorners&&(this.element.className+=" "+this.toThemeProperty("jqx-rc-all"),this._headerElement.className+=" "+this.toThemeProperty("jqx-rc-all")),this.element.className+=" "+this.toThemeProperty("jqx-ribbon-popup"),this._headerElement.className+=" "+this.toThemeProperty("jqx-ribbon-header-"+
1596this._orientation+"-popup"),this._contentElement.className+=" "+this.toThemeProperty("jqx-ribbon-content-popup"),this._positionPopup();else{if("horizontal"===this._orientation)if("auto"!==this.height){var g=this._headerElement.offsetHeight;"top"===this.position?this._contentElement.style.paddingTop=this._toPx(g):this._headerElement.className+=" "+this.toThemeProperty("jqx-ribbon-header-bottom")}else this._headerElement.className+=" "+this.toThemeProperty("jqx-ribbon-header-auto");else if("vertical"===
1597this._orientation)if("auto"!==this.width){var h=this._headerElement.offsetWidth;"left"===this.position?this._contentElement.style.paddingLeft=this._toPx(h):(this._headerElement.className+=" "+this.toThemeProperty("jqx-ribbon-header-right"),this._contentElement.style.paddingRight=this._toPx(h))}else this.element.className+=" "+this.toThemeProperty("jqx-ribbon-auto"),this._headerElement.className+=" "+this.toThemeProperty("jqx-ribbon-header-auto"),this._contentElement.className+=" "+this.toThemeProperty("jqx-ribbon-content-auto-width");
1598this.host.addClass("jqx-tabs-header-position-"+this.position)}a(this._headerElement).addClass(this.toThemeProperty("jqx-ribbon-header-"+this.position));"7.0"===this._browser.version&&"msie"===this._browser.browser&&("horizontal"===this._orientation?(this._header.css("width",this.host.width()-parseInt(this._header.css("padding-left"),10)-parseInt(this._header.css("padding-right"),10)-parseInt(this._header.css("border-left-width"),10)-parseInt(this._header.css("border-right-width"),10)),this._items.height(this._items.height()-
1599parseInt(this._items.css("padding-top"),10)-parseInt(this._items.css("padding-bottom"),10)-parseInt(this._items.css("border-top-width"),10)-parseInt(this._items.css("border-bottom-width"),10)),this._contentSections.width(this._contentSections.width()-parseInt(this._contentSections.css("border-left-width"),10)-parseInt(this._contentSections.css("border-right-width"),10)-parseInt(this._contentSections.css("padding-left"),10)-parseInt(this._contentSections.css("padding-right"),10)),"default"===this.mode&&
1600"auto"!==this.height&&("top"===this.position?this._contentSections.css("padding-top",g):this._contentSections.css("padding-bottom",g),this._content.css("height",this.host.height()+2),this._contentSections.css("height",this._content.height()-parseInt(this._contentSections.css("border-bottom-width"),10)-parseInt(this._contentSections.css("border-top-width"),10)-1))):("left"===this.position?(this._contentElement.className+=" "+this.toThemeProperty("jqx-ribbon-content-left"),b=parseInt(this._contentSections.css("border-left-width"),
160110)+parseInt(this._contentSections.css("border-right-width"),10)+1):(this._contentElement.className+=" "+this.toThemeProperty("jqx-ribbon-content-right"),b=0),this._header.css("height",this.host.height()-parseInt(this._header.css("padding-top"),10)-parseInt(this._header.css("padding-bottom"),10)-parseInt(this._header.css("border-top-width"),10)-parseInt(this._header.css("border-bottom-width"),10)),this._items.width(this._items.width()-parseInt(this._items.css("padding-left"),10)-parseInt(this._items.css("padding-right"),
160210)-parseInt(this._items.css("border-left-width"),10)-parseInt(this._items.css("border-right-width"),10)),this._contentSections.height(this._contentSections.height()-parseInt(this._contentSections.css("border-top-width"),10)-parseInt(this._contentSections.css("border-bottom-width"),10)-parseInt(this._contentSections.css("padding-top"),10)-parseInt(this._contentSections.css("padding-bottom"),10)),"default"===this.mode&&"auto"!==this.width&&("left"===this.position?this._contentSections.css("padding-left",
1603h):this._contentSections.css("padding-right",h),this._contentSections.width(this._content.width()-this._header.width()-b))));"bottom"===this.position&&this._content.css("padding-bottom",g)},_positionPopup:function(){var b="7.0"===this._browser.version&&"msie"===this._browser.browser;switch(this.position){case "top":this._contentElement.style.top=this._toPx(this._headerElement.offsetHeight);break;case "bottom":this._contentElement.style.bottom=b?this._toPx(this._height(this._headerElement)):this._toPx(this._headerElement.offsetHeight);
1604break;
1604case "left":this._contentElement.style.left=this._toPx(this._headerElement.offsetWidth);break;case "right":this._contentElement.style.right=this._header.outerWidth()+"px"}},_appendScrollButtons:function(){function b(g,h,k){g.className=c.toThemeProperty("jqx-ribbon-scrollbutton jqx-ribbon-scrollbutton-"+c.position+" jqx-ribbon-scrollbutton-"+c.scrollPosition+" jqx-widget-header "+h);g.innerHTML='<div class="'+c.toThemeProperty("jqx-ribbon-scrollbutton-inner "+k)+'"></div>';"horizontal"===c._orientation?
1605g.style.height=c._toPx(c._height(c._headerElement)):g.style.width=c._toPx(c._width(c._headerElement));c.element.appendChild(g)}var c=this,d="horizontal"===c._orientation?["left","right"]:["up","down"],e=document.createElement("div");b(e,"jqx-ribbon-scrollbutton-lt","jqx-icon-arrow-"+d[0]);var f=document.createElement("div");b(f,"jqx-ribbon-scrollbutton-rb","jqx-icon-arrow-"+d[1]);c._scrollButtonRc(e,f);c._scrollButtonNear=e;c._scrollButtonFar=f;if(c.roundedCorners)switch(c.position){case "top":case "bottom":e.style.marginLeft=
1606"-1px";f.style.marginRight="-1px";break;case "right":case "left":e.style.marginTop="-1px",f.style.marginBottom="-1px"}},_scrollButtonRc:function(b,c){if(this.roundedCorners)switch(this.position){case "top":"far"!==this.scrollPosition&&(b.className+=" "+this.toThemeProperty("jqx-rc-tl"));"near"!==this.scrollPosition&&(c.className+=" "+this.toThemeProperty("jqx-rc-tr"));break;case "bottom":"far"!==this.scrollPosition&&(b.className+=" "+this.toThemeProperty("jqx-rc-bl"));"near"!==this.scrollPosition&&
1607(c.className+=" "+this.toThemeProperty("jqx-rc-br"));break;case "left":"far"!==this.scrollPosition&&(b.className+=" "+this.toThemeProperty("jqx-rc-tl"));"near"!==this.scrollPosition&&(c.className+=" "+this.toThemeProperty("jqx-rc-bl"));break;case "right":"far"!==this.scrollPosition&&(b.className+=" "+this.toThemeProperty("jqx-rc-tr")),"near"!==this.scrollPosition&&(c.className+=" "+this.toThemeProperty("jqx-rc-br"))}},_updateItems:function(b){function c(){d._items[e]._index===d.selectedIndex&&(d.selectedIndex=
1608e)}var d=this;d._items=d._header.children();d._contentSections=d._content.children();for(var e=0;e<d._items.length;e++){var f=d._items[e];f.setAttribute("unselectable","on");
1608void 0===f._index&&(f._disabled=!1,f._isInitialized=!1,d._contentSections[e]._layout="default");!0===b&&c();f._index=e;!0!==b&&c();d._contentSections[e]&&(d._contentSections[e]._index=e)}},_positionContent:function(b){var c=this,d=c._contentSections[b];if("horizontal"===c._orientation){var e=c.element.offsetWidth;var f=c.host.offset().left;
1609var g=c._items[b].offsetWidth;b=a(c._items[b]).offset().left;var h=d.offsetWidth||parseInt(d.style.width,10);var k="left"}else e=c.element.offsetHeight,f=c.host.offset().top,g=c._items[b].offsetHeight,b=a(c._items[b]).offset().top,h=d.offsetHeight||parseInt(d.style.height,10),k="top";var l=function(m){0>m?m=0:m+h>e&&(m=e-h);d.style[k]=c._toPx(m)};switch(d._layout){case "near":l(b-f);break;case "far":l(b-f-(h-g));break;case "center":l(b-f-(h-g)/2);break;default:if("right"===c.position)for(f=0;f<c._contentSections.length;f++)c._contentSections[f].style.right=
1610"1px";else d.style[k]=""}},_checkScrollButtons:function(b){var c=this,d=0;a.each(c._items,function(){var h=a(this);"none"!==h.css("display")&&(d+="horizontal"===c._orientation?h.outerWidth(!0):h.outerHeight(!0))});var e="horizontal"===c._orientation?["margin-left","margin-right"]:["margin-top","margin-bottom"],f="horizontal"===c._orientation?c._width(c._headerElement):c._height(c._headerElement);c._itemMargins||(c._itemMargins=[],c._itemMargins.push(a(c._items[0]).css(e[0])),c._itemMargins.push(a(c._items[c._items.length-
16111]).css(e[1])));if(d>f){c._scrollButtonNear.style.display="block";c._scrollButtonFar.style.display="block";f=c.rtl?c._itemMargins[0]:17;var g=c.rtl?c._itemMargins[0]:17;switch(c.scrollPosition){case "near":g=0;f=34;break;case "far":g=34,f=17}c._items[0]&&(c._items[0].style[e[0]]=c._toPx(f));c._items[c._items.length-1]&&(c._items[c._items.length-1].style[e[1]]=c._toPx(g))}else c._items[0]&&(c._items[0].style[e[0]]=c._toPx(c._itemMargins[0])),c._items[c._items.length-1]&&(c._items[c._items.length-1].style[e[1]]=
1612c._toPx(c._itemMargins[1])),c._scrollButtonNear.style.display="none",c._scrollButtonFar.style.display="none";!0===b&&("horizontal"===c._orientation?(b=c._toPx(c._height(c._headerElement)),c._scrollButtonNear.style.height=b,c._scrollButtonFar.style.height=b):(b=c._toPx(c._width(c._headerElement)),c._scrollButtonNear.style.width=b,c._scrollButtonFar.style.width=b))},_positionSelectionToken:function(b){if(-1!==b){var c=a(this._items[b]);if(0!==c.length)if("horizontal"===this._orientation){if(!0===this.rtl){b=
16131===this._browserWidthRtlFlag?this._headerElement.scrollWidth-this._headerElement.clientWidth:0;var d=this._browserScrollRtlFlag}else b=0,d=1;d=c[0].offsetLeft+b-this._headerElement.scrollLeft*d-this._selectionTokenOffsetX+2;var e=this._headerElement.offsetHeight-1;c=this._width(c[0])+parseInt(c.css("padding-left"),10)+parseInt(c.css("padding-right"),10);"top"===this.position?(b=e-this._selectionTokenOffsetY,e=""):(b="",e-=this._selectionTokenOffsetY);this._selectionToken.style.top=this._toPx(b);
1614this._selectionToken.style.bottom=this._toPx(e);this._selectionToken.style.left=this._toPx(d);this._selectionToken.style.width=this._toPx(c)}else b=c[0].offsetTop-this._headerElement.scrollTop-this._selectionTokenOffsetX+2,e=this._headerElement.offsetWidth-1,c=this._height(c[0])+parseInt(c.css("padding-top"),10)+parseInt(c.css("padding-bottom"),10),"left"===this.position?(d=e-this._selectionTokenOffsetY,e=""):(d="",e-=this._selectionTokenOffsetY),this._selectionToken.style.top=this._toPx(b),this._selectionToken.style.left=
1615this._toPx(d),this._selectionToken.style.right=this._toPx(e),this._selectionToken.style.height=this._toPx(c)}},_updatePositions:function(b,c){isNaN(b)&&(b=!0===c&&null!==this._selecting&&0<=this._selecting?this._selecting:this.selectedIndex);-1!==b&&(this._positionSelectionToken(b),"popup"===this.mode&&"default"!==this._contentSections[b]._layout&&this._positionContent(b),"popup"!==this.mode||"left"!==this.position&&"right"!==this.position||(this._contentElement.style.width="auto",this._contentSections[b].style.width&&
16160<=this._contentSections[b].style.width.indexOf("%")?this._contentElement.style.width=this._toPx(this._width(this._contentSections[b])-this._width(this._headerElement)):this._contentElement.style.width=this._toPx(this._width(this._contentSections[b]))),this._refreshBarPosition())},_animationComplete:function(b,c){c=-1!==c?c:null;this._contentElement.style.pointerEvents="auto";this.selectedIndex=b;!0!==this._suppressSelectionEvents?(this._raiseEvent("0",{selectedIndex:b}),this._raiseEvent("2",{unselectedIndex:c,
1617selectedIndex:b})):(!0!==this._suppressReorder&&void 0!==this._oldReorderIndex&&b!==this._oldReorderIndex&&this._raiseEvent("4",{newIndex:b,oldIndex:this._oldReorderIndex}),this._suppressReorder=this._suppressSelectionEvents=!1);this.initContent&&!1===this._items[b]._isInitialized&&(this.initContent(b),this._items[b]._isInitialized=!0);this._allowSelection=!0;this._selecting=null;this._refreshBarPosition()},_clearSelectionComplete:function(b,c){this._selecting=null;void 0===b&&(b=this.selectedIndex);
1618-1!==b&&(this._contentElement.style.pointerEvents="none",!0!==this._suppressSelectionEvents&&this._raiseEvent("1",{unselectedIndex:b}));!0!==c&&(this.selectedIndex=-1)},_slide:function(b,c,d,e){var f=this;f.activeAnimations||(f.activeAnimations=[]);if(0<f.activeAnimations.length)for(var g=0;g<f.activeAnimations.length;g++)f.activeAnimations[g].clearQueue(),f.activeAnimations[g].finish();else b.clearQueue(),b.animate("finish");var h={save:function(u,x){for(var B=0;B<x.length;B++)null!==x[B]&&0<u.length&&
1619u.data("ui-effects-"+x[B],u[0].style[x[B]])},restore:function(u,x){var B;for(B=0;B<x.length;B++)if(null!==x[B]){var y=u.data("ui-effects-"+x[B]);void 0===y&&(y="");u.css(x[B],y)}},createWrapper:function(u){if(u.parent().is(".ui-effects-wrapper"))return u.parent();var x={width:u.outerWidth(!0),height:u.outerHeight(!0),"float":u.css("float")},B=a("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),y={width:u.width(),height:u.height()},
1620A=document.activeElement;try{A.id}catch(aa){A=document.body}u.wrap(B);(u[0]===A||a.contains(u[0],A))&&a(A).focus();B=u.parent();"static"===u.css("position")?(B.css({position:"relative"}),u.css({position:"relative"})):(a.extend(x,{position:u.css("position"),zIndex:u.css("z-index")}),a.each(["top","left","bottom","right"],function(aa,ha){x[ha]=u.css(ha);isNaN(parseInt(x[ha],10))&&(x[ha]="auto")}),u.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"}));u.css(y);return B.css(x).show()},
1621removeWrapper:function(u){var x=document.activeElement;u.parent().is(".ui-effects-wrapper")&&(u.parent().replaceWith(u),(u[0]===x||a.contains(u[0],x))&&a(x).focus());return u}}
1621,k="position top bottom left right width height".split(" "),l=c.mode;g="show"===l;var m=c.direction||"left",n="up"===m||"down"===m?"top":"left";m="up"===m||"left"===m;var r={};h.save(b,k);b.show();var t=c.distance||b["top"===n?"outerHeight":"outerWidth"](!0);h.createWrapper(b).css({overflow:"hidden"});g&&b.css(n,m?isNaN(t)?
1622"-"+t:-t:t);r[n]=(g?m?"+=":"-=":m?"-=":"+=")+t;f.activeAnimations.push(b);b.animate(r,{duration:c.duration,easing:c.easing,complete:function(){f.activeAnimations.pop(b);"show"===l?f._animationComplete(d,e):"hide"===l&&(b.hide(),f._clearSelectionComplete(d));h.restore(b,k);h.removeWrapper(b)}});return function(){b.clearQueue();b.stop(!0,!0)}},_toPx:function(b){return"number"===typeof b?b+"px":b},_width:function(b){var c=a(b),d=c.css("border-left-width"),e=c.css("border-right-width"),f=parseInt(c.css("padding-left"),
162310),g=parseInt(c.css("padding-right"),10);if(c="none"===c.css("display")?!0:!1)b.style.display="block";d=-1===d.indexOf("px")?1:parseInt(d,10);e=-1===e.indexOf("px")?1:parseInt(e,10);d=b.offsetWidth-(d+e+f+g);c&&(b.style.display="none");return Math.max(0,d)},_height:function(b){var c=a(b),d=c.css("border-top-width"),e=c.css("border-bottom-width"),f=parseInt(c.css("padding-top"),10);c=parseInt(c.css("padding-bottom"),10);d=-1===d.indexOf("px")?1:parseInt(d,10);e=-1===e.indexOf("px")?1:parseInt(e,10);
1624return Math.max(0,b.offsetHeight-(d+e+f+c))},_closest:function(b,c,d){if(c){if(b.nodeName.toLowerCase()===c)return b;for(var e=b.parentNode;null!==e&&"#document"!==e.nodeName;){if(e.nodeName.toLowerCase()===c)return e;e=e.parentNode}}if(d){if(-1<(" "+b.className+" ").replace(/[\n\t]/g," ").indexOf(" "+d+" "))return b;for(b=b.parentNode;null!==b&&"#document"!==b.nodeName;){if(-1<(" "+b.className+" ").replace(/[\n\t]/g," ").indexOf(" "+d+" "))return b;b=b.parentNode}}},_initAnimate:function(b){b.initAnimate&&
1625!b.animate&&b.initAnimate()}})})(jqxBaseFramework);
1626(function(a){a.jqx.jqxWidget("jqxRadioButton","",{});a.extend(a.jqx._jqxRadioButton.prototype,{defineInstance:function(){var b={animationShowDelay:300,animationHideDelay:300,width:null,height:null,boxSize:"16px",checked:!1,hasThreeStates:!1,disabled:!1,enableContainerClick:!0,locked:!1,groupName:"",rtl:!1,changeType:null,_canFocus:!0,aria:{"aria-checked":{name:"checked",type:"boolean"},"aria-disabled":{name:"disabled",type:"boolean"}},events:["checked","unchecked","indeterminate","change"]};if(this===
1627a.jqx._jqxRadioButton.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(b){this._createFromInput("RadioButton");this.render()},_createFromInput:function(b){if("input"==this.element.nodeName.toLowerCase()){this.field=this.element;this.field.className&&(this._className=this.field.className);var c={title:this.field.title};this.field.value&&(c.value=this.field.value);this.field.checked&&(c.checked=!0);c.id=this.field.id.length?this.field.id.replace(/[^\w]/g,"_")+"_"+b:a.jqx.utilities.createId()+
1628"_"+b;var d=this.element.nextSibling,e=!1;!d||"#text"!=d.nodeName&&"span"!=d.nodeName||(e=!0);var f=0;b=a("<div></div>",c);e&&(b.append(d),d=a("<span>"+a(d).text()+"</span>"),d.appendTo(a(document.body)),f+=d.width(),d.remove());b[0].style.cssText=this.field.style.cssText;this.width||(this.width=a(this.field).width()+f+10);this.height||(this.height=a(this.field).outerHeight()+10);a(this.field).hide().after(b);f=this.host.data();this.host=b;this.host.data(f);this.element=b[0];this.element.id=this.field.id;
1629this.field.id=c.id;this._className&&(this.host.addClass(this._className),a(this.field).removeClass(this._className));this.field.tabIndex&&(c=this.field.tabIndex,this.field.tabIndex=-1,this.element.tabIndex=c)}},render:function(){this.setSize();var b=this;this.propertyChangeMap.width=function(g,h,k,l){b.setSize()};this.propertyChangeMap.height=function(g,h,k,l){b.setSize()};this.radiobutton&&this.radiobutton.remove();this.width||this.host.css("overflow-x","visible");this.height||this.host.css("overflow-y",
1630"visible");null==this.boxSize&&(this.boxSize=16);var c=parseInt(this.boxSize)+"px",d=Math.floor((parseInt(this.boxSize)-16)/2),e=d;d+="px";e+="px";var f=parseInt(this.boxSize)/2+"px";this.radiobutton="16px"!=this.boxSize?a('<div><div style="width: '+c+"; height: "+c+';"><span style="position: relative; left: '+d+"; top: "+e+'; width: 16px; height: 16px;"></span></div></div>'):a('<div><div style="width: '+c+"; height: "+c+';"><span style="width: '+f+"; height: "+f+';"></span></div></div>');this.host.attr("role",
1631"radio");this.host.prepend(this.radiobutton);this.disabledContainer||(this.host.attr("tabIndex")||this.host.attr("tabIndex",0),this.clear=a('<div style="clear: both;"></div>'),this.host.append(this.clear));this.checkMark=a(this.radiobutton[0].firstChild.firstChild);this.box=this.radiobutton;this._supportsRC=!0;a.jqx.browser.msie&&9>a.jqx.browser.version&&(this._supportsRC=!1);this.box.addClass(this.toThemeProperty("jqx-fill-state-normal"));this.box.addClass(this.toThemeProperty("jqx-radiobutton-default"));
1632this.host.addClass(this.toThemeProperty("jqx-widget"));this.disabled&&this.disable();this.host.addClass(this.toThemeProperty("jqx-radiobutton"));this.locked&&this.host.css("cursor","auto");c=this.element.getAttribute("checked");if("checked"==c||"true"==c||1==c)this.checked=!0;this._addInput();this._render();this._addHandlers();a.jqx.aria(this);this._centerBox();this.isMaterialized()&&(a(this.radiobutton).addClass("ripple"),a.jqx.ripple(a(this.radiobutton),this.host,"radiobutton"))},_centerBox:function(){if(this.height&&
1633-1==this.height.toString().indexOf("%")&&this.box){var b=parseInt(this.height);this.host.css("line-height",b+"px");b=b-parseInt(this.boxSize)-1;this.box.css("margin-top",parseInt(b/2))}},_addInput:function(){var b=this.host.attr("name");this.input=a("<input type='hidden'/>");this.host.append(this.input);b&&this.input.attr("name",b)},refresh:function(b){b||(this.setSize(),this._render())},resize:function(b,c){this.width=b;this.height=c;this.setSize()},setSize:function(){null!=this.width&&-1!=this.width.toString().indexOf("px")?
1634this.host.width(this.width):void 0==this.width||isNaN(this.width)?null!=this.width&&-1!=this.width.toString().indexOf("%")&&(this.element.style.width=this.width):this.host.width(this.width);null!=this.height&&-1!=this.height.toString().indexOf("px")?this.host.height(this.height):void 0==this.height||isNaN(this.height)?null!=this.height&&-1!=this.height.toString().indexOf("%")&&(this.element.style.height=this.height):this.host.height(this.height);this._centerBox()},_addHandlers:function(){var b=this;
1635this.addHandler(this.box,"click",function(c){if(!b.disabled&&!b.enableContainerClick)return b.changeType="mouse",b.toggle("click"),c.preventDefault(),!1});this.addHandler(this.host,"keydown",function(c){if(!b.disabled&&!b.locked&&32==c.keyCode){if(!b._canFocus)return!0;b.changeType="keyboard";b.toggle("click");c.preventDefault();return!1}});this.addHandler(this.host,"mousedown",function(c){if(!b.disabled&&b.enableContainerClick)return b.clickTime=new Date,b.changeType="mouse",b.toggle("click"),b._canFocus&&
1636b.focus(),c.preventDefault(),!1});this.addHandler(this.host,"selectstart",function(c){!b.disabled&&b.enableContainerClick&&c.preventDefault()});this.addHandler(this.host,"mouseup",function(c){!b.disabled&&b.enableContainerClick&&c.preventDefault()});this.addHandler(this.host,"focus",function(c){if(!b.disabled&&b.enableContainerClick&&!b.locked)return a(b.radiobutton).removeClass("active"),(!b.clickTime||b.clickTime&&300<new Date-b.clickTime)&&a(b.radiobutton).addClass("active"),b.box.addClass(b.toThemeProperty("jqx-radiobutton-hover")),
1637b.box.addClass(b.toThemeProperty("jqx-fill-state-focus")),c.preventDefault(),!1});this.addHandler(this.host,"blur",function(c){a(b.radiobutton).removeClass("active");if(!b.disabled&&b.enableContainerClick&&!b.locked)return b.box.removeClass(b.toThemeProperty("jqx-radiobutton-hover")),b.box.removeClass(b.toThemeProperty("jqx-fill-state-focus")),c.preventDefault(),!1});this.addHandler(this.host,"mouseenter",function(c){if(!b.disabled&&b.enableContainerClick&&!b.locked)return b.box.addClass(b.toThemeProperty("jqx-radiobutton-hover")),
1638b.box.addClass(b.toThemeProperty("jqx-fill-state-hover")),c.preventDefault(),!1});this.addHandler(this.host,"mouseleave",function(c){if(!b.disabled&&b.enableContainerClick&&!b.locked)return b.box.removeClass(b.toThemeProperty("jqx-radiobutton-hover")),b.box.removeClass(b.toThemeProperty("jqx-fill-state-hover")),c.preventDefault(),!1});this.addHandler(this.box,"mouseenter",function(){b.disabled||b.enableContainerClick||(b.box.addClass(b.toThemeProperty("jqx-radiobutton-hover")),b.box.addClass(b.toThemeProperty("jqx-fill-state-hover")))});
1639this.addHandler(this.box,"mouseleave",function(){b.disabled||b.enableContainerClick||(b.box.removeClass(b.toThemeProperty("jqx-radiobutton-hover")),b.box.removeClass(b.toThemeProperty("jqx-fill-state-hover")))})},focus:function(){try{this.host.focus()}catch(b){}},_removeHandlers:function(){this.removeHandler(this.box,"click");this.removeHandler(this.box,"mouseenter");this.removeHandler(this.box,"mouseleave");this.removeHandler(this.host,"click");this.removeHandler(this.host,"mouseup");this.removeHandler(this.host,
1640"mousedown");this.removeHandler(this.host,"selectstart");this.removeHandler(this.host,"mouseenter");this.removeHandler(this.host,"mouseleave");this.removeHandler(this.host,"keydown");this.removeHandler(this.host,"focus");this.removeHandler(this.host,"blur")},_render:function(){null==this.boxSize&&(this.boxSize=13);this.box.width(this.boxSize);this.box.height(this.boxSize);this.disabled?this.disable():this.enableContainerClick?this.host.css("cursor","pointer"):this.host.css("cursor","auto");this.rtl&&
1641(this.box.addClass(this.toThemeProperty("jqx-radiobutton-rtl")),this.host.addClass(this.toThemeProperty("jqx-rtl")));this.updateStates()},val:function(b){if(0==arguments.length||"object"==typeof b)return this.checked;"string"==typeof b?("true"==b&&this.check("api"),"false"==b&&this.uncheck("api"),""==b&&this.indeterminate("api")):(1==b&&this.check("api"),0==b&&this.uncheck("api"),null==b&&this.indeterminate("api"));return this.checked},check:function(b){this.checked=!0;var c=this;this.checkMark.removeClass();
1642this.checkMark.addClass(this.toThemeProperty("jqx-fill-state-pressed"));a.jqx.browser.msie?(this.disabled&&this.checkMark.addClass(this.toThemeProperty("jqx-radiobutton-check-disabled")),this.checkMark.addClass(this.toThemeProperty("jqx-radiobutton-check-checked"))):(this.disabled&&this.checkMark.addClass(this.toThemeProperty("jqx-radiobutton-check-disabled")),this.checkMark.addClass(this.toThemeProperty("jqx-radiobutton-check-checked")),this.checkMark.css("opacity",0),this.checkMark.stop().animate({opacity:1},
1643this.animationShowDelay,function(){}));var d=a.find(".jqx-radiobutton");null==this.groupName&&(this.groupName="");a.each(d,function(){a(this).jqxRadioButton("groupName")==c.groupName&&this!=c.element&&a(this).jqxRadioButton("uncheck","api")});d=this.changeType;this._raiseEvent("0");this.changeType=d;this._raiseEvent("3",{type:b,checked:!0});0==this.checkMark.height()?(b=parseInt(this.boxSize)/2,this.checkMark.height(b),this.checkMark.width(b)):"13px"!=this.boxSize&&(b=parseInt(this.boxSize)/2,this.checkMark.height(b),
1644this.checkMark.width(b),this.checkMark.css("margin-left",1+b/4),this.checkMark.css("margin-top",1+b/4));this.input.val(this.checked);a.jqx.aria(this,"aria-checked",this.checked);this.host.attr("checked",this.checked)},uncheck:function(b){var c=this.checked;this.checked=!1;var d=this;a.jqx.browser.msie?d.checkMark.removeClass():(this.checkMark.css("opacity",1),this.checkMark.stop().animate({opacity:0}
1644,this.animationHideDelay,function(){d.checkMark.removeClass()}));c&&(c=this.changeType,this._raiseEvent("1"),
1645this.changeType=c,this._raiseEvent("3",{type:b,checked:!1}));this.input.val(this.checked);a.jqx.aria(this,"aria-checked",this.checked);this.host.attr("checked",this.checked)},indeterminate:function(b){var c=this.checked;this.checked=null;this.checkMark.removeClass();a.jqx.browser.msie?this.checkMark.addClass(this.toThemeProperty("jqx-radiobutton-check-indeterminate")):(this.checkMark.addClass(this.toThemeProperty("jqx-radiobutton-check-indeterminate")),this.checkMark.css("opacity",0),this.checkMark.stop().animate({opacity:1},
1646this.animationShowDelay,function(){}));null!=c&&(c=this.changeType,this._raiseEvent("2"),this.changeType=c,this._raiseEvent("3",{type:b,checked:null}));this.input.val(this.checked);a.jqx.aria(this,"aria-checked","undefined");this.host.attr("checked","undefined")},toggle:function(b){if(!this.disabled&&!this.locked){var c=this.checked;this.checked=1==this.checked?this.hasTreeStates?null:!0:!0;c!=this.checked&&this.updateStates(b);this.input.val(this.checked)}},updateStates:function(b){this.checked?
1647this.check(b):0==this.checked?this.uncheck(b):null==this.checked&&this.indeterminate(b)},disable:function(){this.disabled=!0;1==this.checked?this.checkMark.addClass(this.toThemeProperty("jqx-radiobutton-check-disabled")):null==this.checked&&this.checkMark.addClass(this.toThemeProperty("jqx-radiobutton-check-indeterminate-disabled"));this.box.addClass(this.toThemeProperty("jqx-radiobutton-disabled"));this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled"));a.jqx.aria(this,"aria-disabled",
1648this.disabled)},enable:function(){this.host.removeClass(this.toThemeProperty("jqx-fill-state-disabled"));1==this.checked?this.checkMark.removeClass(this.toThemeProperty("jqx-radiobutton-check-disabled")):null==this.checked&&this.checkMark.removeClass(this.toThemeProperty("jqx-radiobutton-check-indeterminate-disabled"));this.box.removeClass(this.toThemeProperty("jqx-radiobutton-disabled"));this.disabled=!1;a.jqx.aria(this,"aria-disabled",this.disabled)},destroy:function(){this._removeHandlers();this.host.remove()},
1649_raiseEvent:function(b,c){b=new a.Event(this.events[b]);b.owner=this;c||={};c.type=this.changeType;this.changeType=null;b.args=c;try{var d=this.host.trigger(b)}catch(e){}return d},propertiesChangedHandler:function(b,c,d){d.width&&d.height&&2==Object.keys(d).length&&b.setSize()},propertyChangedHandler:function(b,c,d,e){if(void 0!=this.isInitialized&&0!=this.isInitialized&&!(b.batchUpdate&&b.batchUpdate.width&&b.batchUpdate.height&&2==Object.keys(b.batchUpdate).length)){c!=this.enableContainerClick||
1650this.disabled||this.locked||(e?this.host.css("cursor","pointer"):this.host.css("cursor","auto"));"rtl"==c&&(e?(b.box.addClass(b.toThemeProperty("jqx-radiobutton-rtl")),b.host.addClass(b.toThemeProperty("jqx-rtl"))):(b.box.removeClass(b.toThemeProperty("jqx-radiobutton-rtl")),b.host.removeClass(b.toThemeProperty("jqx-rtl"))));"boxSize"==c&&b.render();if("checked"==c)switch(e){case !0:this.check("api");break;case !1:this.uncheck("api");break;case null:this.indeterminate()}"theme"==c&&a.jqx.utilities.setTheme(d,
1651e,this.host);"disabled"==c&&(e?this.disable():this.enable())}}})})(jqxBaseFramework);
1652(function(a){a.jqx.jqxWidget("jqxSplitter","",{});a.extend(a.jqx._jqxSplitter.prototype,{defineInstance:function(){var b={width:300,height:300,panels:[],orientation:"vertical",disabled:!1,splitBarSize:5,touchSplitBarSize:15,panel1:null,panel2:null,_eventsMap:{mousedown:a.jqx.mobile.getTouchEventName("touchstart"),mouseup:a.jqx.mobile.getTouchEventName("touchend"),mousemove:a.jqx.mobile.getTouchEventName("touchmove"),mouseenter:"mouseenter",mouseleave:"mou
1652seleave"},_isTouchDevice:!1,_isNested:!1,resizable:!0,
1653touchMode:"auto",showSplitBar:!0,initContent:null,_events:["resize","expanded","collapsed","resizeStart","layout"]};if(this===a.jqx._jqxSplitter.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(){this.render()},_initOverlay:function(b){this.overlay||"undefined"==b?(this.overlay.remove(),this.overlay=null):1==b&&(this.overlay=a("<div style='z-index: 100; background: #fff;'></div>"),this.overlay.css("opacity",.01),this.overlay.css("position","absolute"),this.overlay.appendTo(a(document.body)),
1654this.host.coord(),this.overlay.css("left","0px"),this.overlay.css("top","0px"),this.overlay.width(a(window).width()),this.overlay.height(a(window).height()),this.overlay.addClass("jqx-disableselect"),"horizontal"==this.orientation?this.overlay.css("cursor","row-resize"):this.overlay.css("cursor","col-resize"))},_startDrag:function(b){return b.target==this.splitBarButton[0]||this.disabled||this.panels[0].collapsed||this.panels[1].collapsed||!this.resizable?!0:null==this.overlay?(this._dragging=!0,
1655this._initOverlay(!0),this._dragStart=a.jqx.position(b),!1):!0},_drag:function(b){if(this.panels[0].collapsed||this.panels[1].collapsed||this.disabled||!this._dragging)return!0;var c="horizontal"==this.orientation?"top":"left",d="vertical"==this.orientation?"width":"height";this._position=a.jqx.position(b);if(this.overlay&&!this._splitBarClone&&3<=Math.abs(this._position[c]-this._dragStart[c]))b=this.splitBar.coord(),this._cloneStart={left:b.left,top:b.top},this._splitBarClone=this._createSplitBarClone(),
1656this._raiseEvent(3,{panels:this.panels});else{if(this._splitBarClone){var e=this.host[d](),f=e/100;d=this._splitBarClone[d]()+2;var g=parseInt(this.host.coord()[c]);var h=this._position[c]-this._dragStart[c]+this._cloneStart[c]-g;0>h&&(h=0);h>e+0-d&&(h=e+0-d);g=this.panels[0].min;var k=this.panels[1].min;-1!=k.toString().indexOf("%")&&(k=parseFloat(k)*f);-1!=g.toString().indexOf("%")&&(g=parseFloat(g)*f);this._splitBarClone.removeClass(this.toThemeProperty("jqx-splitter-splitbar-invalid"));h<g&&(this._splitBarClone.addClass(this.toThemeProperty("jqx-splitter-splitbar-invalid")),
1657h=g);h>e+0-d-k&&(this._splitBarClone.addClass(this.toThemeProperty("jqx-splitter-splitbar-invalid")),h=e+0-d-k);this._splitBarClone.css(c,h);b.preventDefault&&b.preventDefault();b.stopPropagation&&b.stopPropagation();return!1}return!0}},resize:function(b,c){this.width=b;this.height=c;this._arrange()},_resize:function(){var b="horizontal"==this.orientation?"height":"width",c=this._splitBarClone.css("horizontal"==this.orientation?"top":"left");b=this.host[b]();var d=1/(b/100);-1!=this.panels[0].size.toString().indexOf("%")?
1658(this.panels[0].size=parseFloat(c)*d+"%",this.panels[1].size=100-parseFloat(c)*d+"%"):(this.panels[0].size=parseFloat(c),this.panels[1].size=b-parseFloat(c));this._layoutPanels();this._raiseEvent(0,{panels:this.panels})},_stopDrag:function(){this._dragging&&this._initOverlay();this._dragging=!1;if(this._splitBarClone){if(this.panels[0].collapsed||this.panels[1].collapsed||this.disabled)return!0;this._resize();this._splitBarClone.remove();this._splitBarClone=null}},_createSplitBarClone:function(){var b=
1659this.splitBar.clone();b.fadeTo(0,.7);b.css("z-index",99999);"vertical"==this.orientation?b.css("cursor","col-resize"):b.css("cursor","row-resize");this.host.append(b);return b},_eventName:function(b){return this._isTouchDevice?this._eventsMap[b]:b},_addHandlers:function(){var b=this;a.jqx.utilities.resize(this.host,function(){b._layoutPanels()});this.addHandler(this.splitBar,"dragstart."+this.element.id,function(d){return!1});this.splitBarButton&&(this.addHandler(this.splitBarButton,"click."+this.element.id,
1660function(){b.panels[0].collapsible?b.panels[0].collapsed?b.expand():b.collapse():b.panels[1].collapsible&&(b.panels[1].collapsed?b.expand():b.collapse())}),this.addHandler(this.splitBarButton,this._eventName("mouseenter"),function(){b.splitBarButton.addClass(b.toThemeProperty("jqx-splitter-collapse-button-hover"));b.splitBarButton.addClass(b.toThemeProperty("jqx-fill-state-hover"))}),this.addHandler(this.splitBarButton,this._eventName("mouseleave"),function(){b.splitBarButton.removeClass(b.toThemeProperty("jqx-splitter-collapse-button-hover"));
1661b.splitBarButton.removeClass(b.toThemeProperty("jqx-fill-state-hover"))}));this.addHandler(a(document),this._eventName("mousemove")+"."+this.element.i
1661d,function(d){return b._drag(d)});this.addHandler(a(document),this._eventName("mouseup")+"."+this.element.id,function(){return b._stopDrag()});this.addHandler(this.splitBar,this._eventName("mousedown"),function(d){return b._startDrag(d)});this.addHandler(this.splitBar,this._eventName("mouseenter"),function(){b.resizable&&!b.disabled&&(b.splitBar.addClass(b.toThemeProperty("jqx-splitter-splitbar-hover")),
1662b.splitBar.addClass(b.toThemeProperty("jqx-fill-state-hover")))});this.addHandler(this.splitBar,this._eventName("mouseleave"),function(){b.resizable&&!b.disabled&&(b.splitBar.removeClass(b.toThemeProperty("jqx-splitter-splitbar-hover")),b.splitBar.removeClass(b.toThemeProperty("jqx-fill-state-hover")))});if((""!=document.referrer||window.frameElement)&&null!=window.top&&window.top!=window.self){var c=null;window.parent&&document.referrer&&(c=document.referrer);c&&-1!=c.indexOf(document.location.host)&&
1663(c=function(d){b._stopDrag()},window.top.document.addEventListener?window.top.document.addEventListener("mouseup",c,!1):window.top.document.attachEvent&&window.top.document.attachEvent("onmouseup",c))}},_removeHandlers:function(){this.removeHandler(a(window),"resize."+this.element.id);this.splitBarButton&&(this.removeHandler(this.splitBarButton,"click."+this.element.id),this.removeHandler(this.splitBarButton,this._eventName("mouseenter")),this.removeHandler(this.splitBarButton,this._eventName("mouseleave")));
1664this.removeHandler(a(document),this._eventName("mousemove")+"."+this.element.id);this.removeHandler(a(document),this._eventName("mouseup")+"."+this.element.id);this.splitBar&&(this.removeHandler(this.splitBar,"dragstart."+this.element.id),this.removeHandler(this.splitBar,this._eventName("mousedown")),this.removeHandler(this.splitBar,this._eventName("mouseenter")),this.removeHandler(this.splitBar,this._eventName("mouseleave")))},render:function(){this.splitBar&&this.splitBar.remove();var b=this.host.children();
1665if(2!=b.length)throw"Invalid HTML Structure! jqxSplitter requires 1 container DIV tag and 2 nested DIV tags.";if(2==b.length){var c=b[0].className.split(" ");b=b[1].className.split(" ");if(-1!=c.indexOf("jqx-reset")&&-1!=c.indexOf("jqx-splitter")&&-1!=c.indexOf("jqx-widget"))throw"Invalid HTML Structure! Nested jqxSplitter cannot be initialized from a Splitter Panel. You need to add a new DIV tag inside the Splitter Panel and initialize the nested jqxSplitter from it!";if(-1!=b.indexOf("jqx-reset")&&
1666-1!=b.indexOf("jqx-splitter")&&-1!=b.indexOf("jqx-widget"))throw"Invalid HTML Structure! Nested jqxSplitter cannot be initialized from a Splitter Panel. You need to add a new DIV tag inside the Splitter Panel and initialize the nested jqxSplitter from it!";}if(0<this.host.parent().length&&-1!=this.host.parent()[0].className.indexOf("jqx-splitter")){if(-1!=this.element.className.indexOf("jqx-splitter-panel"))throw"Invalid HTML Structure! Nested jqxSplitter cannot be initialized from a Splitter Panel. You need to add a new DIV tag inside the Splitter Panel and initialize the nested jqxSplitter from it!";
1667this._isNested=!0;300==this.width&&(this.width="100%");300==this.height&&(this.height="100%");"100%"==this.width&&"100%"==this.height&&(this.host.addClass("jqx-splitter-nested"),-1!=this.host.parent()[0].className.indexOf("jqx-splitter-panel")&&this.host.parent().addClass("jqx-splitter-panel-nested"))}this._hasBorder=0==this.host.hasClass("jqx-hideborder")||""!=this.element.style.borderTopWidth;this._removeHandlers();this._isTouchDevice=a.jqx.mobile.isTouchDevice();this._validate();this.panel1.css("left",
1668"0px");this.panel1.css("top","0px");this.panel2.css("left","0px");this.panel2.css("top","0px");this.splitBar=a("<div><div></div></div>");this.resizable||this.splitBar.css("cursor","default");this.splitBarButton=this.splitBar.find("div:last");this._setTheme();this.splitBar.insertAfter(this.panel1);this._arrange();0==this.panels[0].collapsible&&0==this.panels[1].collapsible&&this.splitBarButton.hide();this._addHandlers();this.initContent&&this.initContent();this.disabled&&this.disable()},_hiddenParent:function(){return a.jqx.isHidden(this.host)},
1669_setTheme:function(){this.panel1.addClass(this.toThemeProperty("jqx-widget-content"));this.panel2.addClass(this.toThemeProperty("jqx-widget-content"));this.panel1.addClass(this.toThemeProperty("jqx-splitter-panel"));this.panel2.addClass(this.toThemeProperty("jqx-splitter-panel"));this.panel1.addClass(this.toThemeProperty("jqx-reset"));this.panel2.addClass(this.toThemeProperty("jqx-reset"));this.host.addClass(this.toThemeProperty("jqx-reset"));this.host.addClass(this.toThemeProperty("jqx-splitter"));
1670this.host.addClass(this.toThemeProperty("jqx-widget"));this.host.addClass(this.toThemeProperty("jqx-widget-content"));this.splitBar.addClass(this.toThemeProperty("jqx-splitter-splitbar-"+this.orientation));this.splitBar.addClass(this.toThemeProperty("jqx-fill-state-normal"));this.splitBarButton.addClass(this.toThemeProperty("jqx-splitter-collapse-button-"+this.orientation));this.splitBarButton.addClass(this.toThemeProperty("jqx-fill-state-pressed"))},_validate:function(){var b=this.host.children();
1671if(2!=b.length)throw"Invalid HTML Structure! jqxSplitter requires two nested DIV tags!";this.panels&&!this.panels[1]?this.panels[0]?this.panels[1]={}:this.panels=[{size:"50%"},{size:"50%"}]:void 0==this.panels&&(this.panels=[{size:"50%"},{size:"50%"}]);b=this.host.children();this.panel1=this.panels[0].element=a(b[0]);this.panel2=this.panels[1].element=a(b[1]);this.panel1[0].style.minWidth="";this.panel1[0].style.maxWidth="";this.panel2[0].style.minWidth="";this.panel2[0].style.maxWidth="";a.each(this.panels,
1672function(){void 0==this.min&&(this.min=0);void 0==this.size&&(this.size=0);0>this.size&&(this.size=0);0>this.min&&(this.min=0);void 0==this.collapsible&&(this.collapsible=!0);void 0==this.collapsed&&(this.collapsed=!1);0!=this.size&&(-1!=this.size.toString().indexOf("px")&&(this.size=parseInt(this.size)),-1==this.size.toString().indexOf("%")?parseInt(this.min)>parseInt(this.size)&&(this.min=this.size):-1!=this.min.toString().indexOf("%")&&parseInt(this.min)>parseInt(this.size)&&(this.min=this.size))})},
1673_arrange:function(){if(null!=this.width){var b=this.width;"string"!=typeof b&&(b=parseInt(this.width)+"px");this.host.css("width",b)}null!=this.height&&(b=this.height,"string"!=typeof b&&(b=parseInt(this.height)+"px"),this.host.css("height",b));this._splitBarSize=this._isTouchDevice?this.touchSplitBarSize:this.splitBarSize;this.showSplitBar||(this._splitBarSize=0,this.splitBar.hide());b="horizontal"==this.orientation?"width":"height";this.splitBar.css(b,"100%");this.panel1.css(b,"100%");this.panel2.css(b,
1674"100%");"horizontal"==this.orientation?this.splitBar.height(this._splitBarSize):this.splitBar.width(this._splitBarSize);"vertical"===this.orientation?(this.splitBarButton.width(this._splitBarSize),this.splitBarButton.height(45)):(this.splitBarButton.height(this._splitBarSize),this.splitBarButton.width(45));this.splitBarButton.css("position","relative");"vertical"===this.orientation?(this.splitBarButton.css("top","50%"),this.splitBarButton.css("left","0"),this.splitBarButton.css("margin-top","-23px"),
1675this.splitBarButton.css("margin-left","-0px")):(this.splitBarButton.css("left","50%"),this.splitBarButton.css("top","0"),this.splitBarButton.css("margin-left","-23px"),this.splitBarButton.css("margin-top","-0px"));this._layoutPanels()},collapse:function(){if(!this.disabled){var b=-1;this.panels[0].collapsed=this.panels[1].collapsed=!1;this.panels[0].element[0].style.visibility="inherit";this.panels[1].element[0].style.visibility="inherit";this.panels[0].collapsible?b=0:this.panels[1].collapsible&&
1676(b=1);-1!=b&&(this.panels[b].collapsed=!0,this.panels[b].element[0].style.visibility="hidden",this.splitBar.addClass(this.toThemeProperty("jqx-splitter-splitbar-collapsed")),this._layoutPanels(),this._raiseEvent(2,{index:b,panels:this.panels}),this._raiseEvent(0,{panels:this.panels}))}},expand:function(){if(!this.disabled){var b=-1;this.panels[0].collapsed=this.panels[1].collapsed=!1;this.panels[0].element[0].style.visibility="inherit";this.panels[1].element[0].style.visibility="inherit";this.panels[0].collapsible?
1677b=0:this.panels[1].collapsible&&(b=1);-1!=b&&(this.panels[b].collapsed=!1,this.panels[b].element[0].style.visibility="inherit",this.splitBar.removeClass(this.toThemeProperty("jqx-splitter-splitbar-collapsed")),this._layoutPanels(),this._raiseEvent(1,{index:b,panels:this.panels}),this._raiseEvent(0,{panels:this.panels}))}},disable:function(){this.disabled=!0;this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled"));this.splitBar.addClass(this.toThemeProperty("jqx-splitter-splitbar-collapsed"));
1678this.splitBarButton.addClass(this.toThemeProperty("jqx-splitter-splitbar-collapsed"))},enable:function(){this.disabled=!1;this.host.removeClass(this.toThemeProperty("jqx-fill-state-disabled"));this.splitBar.removeClass(this.toThemeProperty("jqx-splitter-splitbar-collapsed"));this.splitBarButton.removeClass(this.toThemeProperty("jqx-splitter-splitbar-collapsed"))},refresh:function(b){1!=b&&this._arrange()},propertyChangedHandler:function(b,c,d,e){"panels"===c||"orientation"===c||"showSplitBar"===c?
1679b.render():("touchMode"===c&&(b._isTouchDevice=e),"disabled"===c?e?b.disable():b.enable():"theme"===c?a.jqx.utilities.setTheme(d,e,b.host):b.refresh())},_layoutPanels:function(){var b="horizontal"==this.orientation?"height":"width",c="horizontal"==this.orientation?"top":"left",d,e,f=parseInt(this._splitBarSize)+2;this.showSplitBar||(f=0);var g=this.host[b](),h=g/100,k=1/h,l=k*f,m=this.panel1,n=this.panel2,r=this.panels[0].size;this.panels[0].collapsed&&(d=!0);this.panels[1].collapsed&&(e=!0);var t=
1680this.panels[0].min;var u=this.panels[1].min;-1!=u.toString().indexOf("%")&&(u=parseFloat(u)*h);-1!=t.toString().indexOf("%")&&(t=parseFloat(t)*h);this._isNested&&this._isTouchDevice&&("horizontal"==this.orientation?(m.width(this.host.width()),n.width(this.host.width())):(m.height(this.host.height()),n.height(this.host.height())));if(d)t=Math.max(u,g-f),m[b](0),n[b](t);else if(e)t=Math.max(t,g-f),n[b](0),m[b](t);else if(-1!=r.toString().indexOf("%"))d=100-parseFloat(r),m.css(b,parseFloat(r)+"%"),n.css(b,
1681d-l+"%"),d=n[b](),d<u&&(u=(d-u)*k,r=parseFloat(r)+parseFloat(u),d=100-parseFloat(r),m.css(b,parseFloat(r)+"%"),n.css(b,d-l+"%")),m[b]()<t&&m.css(b,parseFloat(t*k)+"%");else{d=g-r-f;if(m[0].style[b]!=r+"px")m[b](r);if(n[0].style[b]!=d+"px")n[b](d);d<u&&(r+=d-u,n[b](u),m[b](r));if(r<t)m[b](t)}b=this.panel1[b]();this.splitBar[0].style[c]!=b+"px"&&("vertical"==this.orientation?(this.splitBar[0].style.borderLeftColor="",this.splitBar[0].style.borderRightColor="",this.splitBarButton[0].style.width=parseInt(this._splitBarSize)+
1682"px",this.splitBarButton[0].style.left="0px"):(this.splitBar[0].style.borderTopColor="",this.splitBar[0].style.borderBottomColor="",this.splitBarButton[0].style.height=parseInt(this._splitBarSize)+"px",this.splitBarButton[0].style.top="0px"),this._hasBorder&&(g-f==b?"vertical"==this.orientation?(this.splitBar[0].style.borderRightColor="transparent",this.splitBarButton[0].style.width=parseInt(this._splitBarSize+1)+"px"):(this.splitBar[0].style.borderBottomColor="transparent",this.splitBarButton[0].style.height=
1683parseInt(this._splitBarSize+1)+"px"):0==b&&("vertical"==this.orientation?(this.splitBar[0].style.borderLeftColor="transparent",this.splitBarButton[0].style.width=parseInt(this._splitBarSize+1)+"px",this.splitBarButton[0].style.left="-1px"):(this.splitBar[0].style.borderTopColor="transparent",this.splitBarButton[0].style.height=parseInt(this._splitBarSize+1)+"px",this.splitBarButton[0].style.top="-1px"))),this.splitBar[0].style[c]=b+"px");this.panel2[0].style[c]!=b+f+"px"&&(this.panel2[0].style[c]=
1684b+f+"px");this._raiseEvent(4,{panels:this.panels})},destroy:function(){this._removeHandlers();a.jqx.utilities.resize(this.host,null,!0);this.host.remove()}
1684,_raiseEvent:function(b,c){b=new a.Event(this._events[b]);b.owner=this;b.args=c;c=[{},{}];c[0].size="vertical"==this.orientation?this.panel1[0].offsetWidth:this.panel1[0].offsetHeight;c[1].size="vertical"==this.orientation?this.panel2[0].offsetWidth:this.panel2[0].offsetHeight;c[0].min=this.panels[0].min;c[1].min=this.panels[1].min;c[0].collapsible=
1685this.panels[0].collapsible;c[1].collapsible=this.panels[1].collapsible;c[0].collapsed=this.panels[0].collapsed;c[1].collapsed=this.panels[1].collapsed;b.args.panels=c;return this.host.trigger(b)}})})(jqxBaseFramework);
1686(function(a){a.jqx.jqxWidget("jqxTabs","",{});a.extend(a.jqx._jqxTabs.prototype,{defineInstance:function(){var b={scrollAnimationDuration:200,enabledHover:!0,disabled:!1,collapsible:!1,animationType:"none",enableScrollAnimation:!0,contentTransitionDuration:450,toggleMode:"click",selectedItem:0,height:"auto",width:"auto",position:"top",selectionTracker:!1,scrollable:!0,scrollPosition:"right",scrollStep:70,autoHeight:!0,headerHeight:null,showCloseButtons:!1,canCloseAllTabs:!0,closeButtonSize:16,arrowButtonSize:16,
1687keyboardNavigation:!0,reorder:!1,selectionTrackerAnimationDuration:300,_isTouchDevice:!1,roundedCorners:!0,_headerExpandingBalance:0,_dragStarted:!1,_tabCaptured:!1,_lastUnorderedListPosition:0,_selectedItem:0,_titleList:[],_contentList:[],_contentWrapper:null,_unorderedList:null,_scrollTimeout:null,isCollapsed:!1,touchMode:!1,initTabContent:null,enableDropAnimation:!1,_currentEvent:null,_needScroll:!0,_isAnimated:{},_events:"created selected add removed enabled disabled selecting unselecting unselected dragStart dragEnd locked unlocked collapsed expanded tabclick".split(" "),
1688_initTabContentList:[],_invalidArgumentExceptions:{invalidScrollAnimationDuration:"The scroll animation duration is not valid!",invalidWidth:"Width you've entered is invalid!",invalidHeight:"Height you've entered is invalid!",invalidAnimationType:"You've entered invalid animation type!",invali
1688dcontentTransitionDuration:"You've entered invalid value for contentTransitionDuration!",invalidToggleMode:"You've entered invalid value for toggleMode!",invalidPosition:"You've entered invalid position!",invalidScrollPosition:"You've entered invalid scroll position!",
1689invalidScrollStep:"You've entered invalid scroll step!",invalidStructure:"Invalid structure!",invalidArrowSize:"Invalid scroll button size!",invalidCloseSize:"Invalid close button size!"},aria:{"aria-disabled":{name:"disabled",type:"boolean"}},rtl:!1};if(this===a.jqx._jqxTabs.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(){this._IE8=a.jqx.browser.msie&&9>a.jqx.browser.version;a.jqx.aria(this);this.element.className+=" "+this.toThemeProperty("jqx-tabs jqx-widget jqx-widget-content");
1690this.element.setAttribute("role","tablist");for(var b=this.host.children(),c=0;c<b.length;c++){var d=b[c];"ul"===d.nodeName.toLowerCase()?this._unorderedList=d:"div"===d.nodeName.toLowerCase()&&this._contentList.push(d)}this._unorderedListHelper=a(this._unorderedList);this._unorderedListHelper.initAnimate&&this._unorderedListHelper.initAnimate();this._closeButtonList=[];this._selectedItem=this.selectedItem;this._isTouchDevice=a.jqx.mobile.isTouchDevice();this._needScroll=this.scrollable;this.selectionTracker&&
1691(this.selectionTracker=this._seletionTrackerBrowserCheck());this._isTouchDevice&&(this.keyboardNavigation=this.reorder=!1);this._titleList=this._unorderedListHelper.children();for(b=this._titleList.length;b;)b--,this._titleList[b].setAttribute("role","tab"),this._titleList[b].getAttribute("id")||this._titleList[b].setAttribute("id",this.element.id+"Tab"+b),this._contentList[b].setAttribute("role","tabpanel");this._validateProperties();this._refresh();this._moveSelectionTrack(this._selectedItem,0);
1692this.disabled&&this.disable();this.element.tabIndex=0;this._raiseEvent(0);this._enableWindowResize()},_hiddenParent:function(){if("none"===this.host.css("display"))return!0;var b=!1;a.each(this.host.parents(),function(){if("none"===a(this).css("display"))return b=!0,!1});return b},_enableWindowResize:function(){var b=this,c=a.jqx.isHidden(b.host);a.jqx.utilities.resize(this.host,function(){c?(b._uiRefresh(!0),c=!1):b.refresh();b._refreshBarPosition()})},resize:function(b,c){this.width=b;this.height=
1693c;a.jqx.isHidden(this.host)?this._uiRefresh(!0):this.refresh()},refresh:function(b){!0===b&&void 0!==b||this._setSize()},_seletionTrackerBrowserCheck:function(){var b="Browser CodeName: "+navigator.appCodeName;b+="Browser Name: "+navigator.appName;b+="Browser Version: "+navigator.appVersion;b+="Platform: "+navigator.platform;b+="User-agent header: "+navigator.userAgent;return-1!==b.indexOf("IEMobile")||-1!==b.indexOf("Windows Phone OS")||a.jqx.browser.msie&&7>=a.jqx.browser.version?!1:!0},render:function(){this._refresh()},
1694_uiRefresh:function(b){this._unorderedListLeftBackup=this._unorderedListHelper.css("left");b&&this._render();this._addStyles();this._performLayout();this._prepareTabs();this._removeEventHandlers();this._addEventHandlers();"auto"===this._unorderedListLeftBackup&&(this._unorderedListLeftBackup=this._getArrowsDisplacement());this._unorderedList.style.left=this._toPx(this._unorderedListLeftBackup);this.rtl&&this.scrollable&&this._rightArrow&&"hidden"!==a(this._rightArrow).css("visibility")&&(b=2*this.arrowButtonSize,
1695b=this._width(this.element)-parseInt(this._width(this._unorderedList)+b+parseInt(this._unorderedListHelper.css("margin-left"),10),10),this._unorderedList.style.left=b+"px");var c=this;setTimeout(function(){c._performLayout()},100)},_refresh:function(){a.jqx.isHidden(this.host)||(this._uiRefresh(!0),this.host.addClass("jqx-tabs-header-position-"+this.position))},_addStyles:function(){this._unorderedList.className+=" "+this.toThemeProperty("jqx-tabs-title-container");this._unorderedList.style.outline=
1696"none";this._unorderedList.style.whiteSpace="nowrap";this._unorderedList.style.marginTop="0px";this._unorderedList.style.marginBottom="0px";this._unorderedList.style.padding="0px";this._unorderedList.style.background="transparent";this._unorderedList.style.border="none";this._unorderedList.style.borderStyle="none";this._unorderedList.style.textIndent="0px";for(var b=this.length();b;){b--;var c=this._titleList[b],d="jqx-tabs-title jqx-item";c.style.padding="";"bottom"===this.position&&(d+=" jqx-tabs-title-bottom");
1697c.disabled&&(d+=" jqx-tabs-title-disable jqx-fill-state-disabled");switch(this.position){case "top":d+=" jqx-rc-t";this._removeClass(this._contentList[b],this.toThemeProperty("jqx-rc-t"));this._contentList[b].className+=" "+this.toThemeProperty("jqx-rc-b");break;case "bottom":d+=" jqx-rc-b",this._removeClass(this._contentList[b],this.toThemeProperty("jqx-rc-b")),this._contentList[b].className+=" "+this.toThemeProperty("jqx-rc-t")}c.className="jqx-reset jqx-disableselect "+this.toThemeProperty(d)}if(this.selectionTracker)switch(this.position){case "top":this._removeClass(this._selectionTracker,
1698this.toThemeProperty("jqx-rc-b"));this._selectionTracker.className+=" "+this.toThemeProperty("jqx-rc-t");break;case "bottom":this._removeClass(this._selectionTracker,this.toThemeProperty("jqx-rc-t")),this._selectionTracker.className+=" "+this.toThemeProperty("jqx-rc-b")}},_raiseEvent:function(b,c){var d=new a.Event(this._events[b]);d.owner=this;d.args=c;if(6===b||7===b)d.cancel=!1,this._currentEvent=d;c="";try{if(c=this.host.trigger(d),1===b){var e=this;if(this.selectionTracker||"none"!==this.animationType)setTimeout(function(){!e._initTabContentList[e.selectedItem]&&
1699e.initTabContent&&(e.initTabContent(e.selectedItem),e._initTabContentList[e.selectedItem]=!0);var h=new a.Event("loadContent");h.owner=this;0<e._contentList.length&&e._contentList[e.selectedItem]&&a(e._contentList[e.selectedItem]).trigger(h)},50+e.selectionTrackerAnimationDuration);else{var f=new a.Event("loadContent");!e._initTabContentList[e.selectedItem]&&e.initTabContent&&(e.initTabContent(e.selectedItem),e._initTabContentList[e.selectedItem]=!0);f.owner=this;var g=new a.Event("resize");this.host.trigger(g)}}}catch(h){h&&
1700console&&console.log(h)}return c},_getArrowsDisplacement:function(){if(!this._needScroll)return 0;var b=this.arrowButtonSize,c=this.arrowButtonSize;return"left"===this.scrollPosition?b+c:"both"===this.scrollPosition?b:0},_scrollRight:function(b){this._stop(this._unorderedListHelper);this._unlockAnimation("unorderedList");var c=parseInt(this._width(this._unorderedList)+parseInt(this._unorderedListHelper.css("margin-left"),10),10),d=this._width(this.element),e=parseInt(this._unorderedListHelper.css("left"),
170110),f=this._getArrowsDisplacement();if(this.scrollable){var g=this._leftArrow.offsetWidth;var h=this._rightArrow.offsetWidth}else h=g=0;b=this.enableScrollAnimation?b:0;if(!(this._width(this._headerWrapper)>parseInt(this._unorderedListHelper.css("margin-left"),10)+this._width(this._unorderedList)))if(Math.abs(e)+this.scrollStep<Math.abs(d-c)+g+h+f){f=e-this.scrollStep;var k=e-this.scrollStep+parseInt(a(this._titleList[this._selectedItem]).position().left,10)}else f=d-c-(2*this.arrowButtonSize-f),
1702f<parseInt(this._unorderedListHelper.css("left"),10)-4&&f>parseInt(this._unorderedListHelper.css("left"),10)+4&&(k=d-c-g-h+parseInt(a(this._titleList[this._selectedItem]).position().left,10));this._performScrollAnimation(f,k,b)},_scrollLeft:function(b){this._stop(this._unorderedListHelper);this._unlockAnimation("unorderedList");var c=parseInt(this._unorderedListHelper.css("left"),10),d=this._getArrowsDisplacement();b=this.enableScrollAnimation?b:0;if(!(this._width(this._headerWrapper)>=this._width(this._unorderedList)))if(c+
1703this.scrollStep<d){d=c+this.scrollStep;var e=c+this.scrollStep+parseInt(a(this._titleList[this._selectedItem]).position().left,10)}
1703else d<parseInt(this._unorderedListHelper.css("left"),10)-4&&d>parseInt(this._unorderedListHelper.css("left"),10)+4&&(e=parseInt(a(this._titleList[this._selectedItem]).position().left,10));this._performScrollAnimation(d,e,b)},_performScrollAnimation:function(b,c,d){var e=this;void 0!==c&&this._moveSelectionTrack(this._selectedItem,0,c);this._lockAnimation("unorderedList");
1704e._refreshBarPosition();this._unorderedListHelper.animate({left:b},d,function(){e._moveSelectionTrack(e.selectedItem,0);e._unlockAnimation("unorderedList");e._refreshBarPosition()})},_addKeyboardHandlers:function(){var b=this;this.keyboardNavigation&&this.addHandler(this.host,"keydown",function(c){if(!b._activeAnimation()){var d=b.selectionTracker,e=b.getContentAt(b._selectedItem);if(a(c.target).ischildof(e)||a(document.activeElement).ischildof(a(e)))return!0;switch(c.keyCode){case 37:return b.rtl?
1705b.next():b.previous(),!1;case 39:return b.rtl?b.previous():b.next(),!1;case 36:return b.first(),!1;case 35:return b.last(),!1;case 27:b._tabCaptured&&(b._cancelClick=!0,b._uncapture(null,b.selectedItem),b._tabCaptured=!1)}b.selectionTracker=d}return!0})},_addScrollHandlers:function(){var b=this;this.addHandler(this._leftArrow,"mousedown",function(){b._startScrollRepeat(!0,b.scrollAnimationDuration)});this.addHandler(this._rightArrow,"mousedown",function(){b._startScrollRepeat(!1,b.scrollAnimationDuration)});
1706this.addHandler(this._rightArrow,"mouseleave",function(){clearTimeout(b._scrollTimeout)});this.addHandler(this._leftArrow,"mouseleave",function(){clearTimeout(b._scrollTimeout)});this.addHandler(a(document),"mouseup.tab"+this.element.id,this._mouseUpScrollDocumentHandler,this);this.addHandler(a(document),"mouseleave.tab"+this.element.id,this._mouseLeaveScrollDocumentHandler,this)},_mouseLeaveScrollDocumentHandler:function(b){b=b.data;b._scrollTimeout&&clearTimeout(b._scrollTimeout)},_mouseUpScrollDocumentHandler:function(b){clearTimeout(b.data._scrollTimeout)},
1707_mouseUpDragDocumentHandler:function(b){var c=b.data;c._tabCaptured&&c._dragStarted&&c._uncapture(b);c._tabCaptured=!1},_addReorderHandlers:function(){this.addHandler(a(document),"mousemove.tab"+this.element.id,this._moveElement,this);this.addHandler(a(document),"mouseup.tab"+this.element.id,this._mouseUpDragDocumentHandler,this)},_addEventHandlers:function(){for(var b=this.length();b;)b--,this._addEventListenerAt(b);this.keyboardNavigation&&this._addKeyboardHandlers();this.scrollable&&this._addScrollHandlers();
1708this.reorder&&!this._isTouchDevice&&this._addReorderHandlers();var c=this;try{if((""!==document.referrer||window.frameElement)&&null!==window.top&&window.top!==window.self){b=function(){c._tabCaptured&&(c._cancelClick=!0,c._uncapture(null,c.selectedItem),c._tabCaptured=!1)};var d=null;window.parent&&document.referrer&&(d=document.referrer);d&&-1!==d.indexOf(document.location.host)&&window.top.document&&this.addHandler(a(window.top.document),"mouseup.tabs"+this.element.id,b)}}catch(e){}},focus:function(){try{this.host.focus();
1709var b=this;setTimeout(function(){b.host.focus()},25)}catch(c){}},_getFocusedItem:function(b){for(var c=this.length();c;){c--;var d=this._titleList[c],e=this._outerWidth(d,!0),f=parseInt(a(d).offset().left,10);if(f<=b&&f+e>=b&&d!==this._capturedElement&&!this._titleList[c].locked&&!0!==this._titleList[c].disabled)return c}return-1},_uncapture:function(b){var c=this.selectionTracker;this._unorderedListLeftBackup=this._unorderedListHelper.css("left");this._tabCaptured=this._dragStarted=!1;var d=this._indexOf(this._capturedElement);
1710if(this._capturedElement){switch(this.position){case "top":this._capturedElement.style.bottom="0px";break;case "bottom":this._capturedElement.style.top="0px"}var e;b&&(e=this._getFocusedItem(b.clientX));-1!==e&&b?(this._raiseEvent(10,{item:d,dropIndex:e}),this._reorderItems(e,d)):this._capturedElement.style.left="0px";for(var f=0;f<this._titleList.length;f++)this._titleList[f].style.position="static";this._reorderHeaderElements();this._unorderedList.style.position="relative";this._unorderedList.style.top=
1711"0px";this._prepareTabs();-1!==e&&b?this._moveSelectionTrack(this._selectedItem,0):(this._selectedItem=d,this._moveSelectionTrack(d,0));this._addSelectStyle(this._selectedItem,!0);document.selection&&document.selection.clear();this._unorderedList.style.left=this._toPx(this._unorderedListLeftBackup);this.selectionTracker=c}},_reorderItems:function(b,c){var d=this._titleList[this.selectedItem],e=this._titleList[c];"undefined"===typeof this._capturedElement&&(this._capturedElement=e);a(e).remove();c<
1712b?this._titleList[b+1]?this._unorderedList.insertBefore(e,this._titleList[b+1]):this._unorderedList.appendChild(e):this._unorderedList.insertBefore(e,this._titleList[b]);this._reorderElementArrays(b,c);this._getSelectedItem(d);this._removeEventHandlers();this._addEventHandlers()},_reorderElementArrays:function(b,c){var d=this._contentList[c];if(c<b)for(;c<=b;c++)this._titleList[c]=this._titleList[c+1],this._contentList[c]=this._contentList[c+1];else for(;c>=b;c--)this._titleList[c]=this._titleList[c-
17131],this._contentList[c]=this._contentList[c-1];this._contentList[b]=d;this._titleList[b]=this._capturedElement},getSelectedItem:function(){return this.selectedItem},_getSelectedItem:function(b){for(var c=this.length();c;)if(c--,this._titleList[c]===b){this._selectedItem=this.selectedItem=c;break}},_moveElement:function(b){var c=b.data;if(c._tabCaptured)if(document.selection&&document.selection.clear(),c._dragStarted)c._performDrag(b),clearTimeout(c._scrollTimeout);else{var d=-parseInt(c._unorderedListHelper.css("left"),
171410);if(b.clientX+d>c._startX+3||b.clientX+d<c._startX-3)c._prepareTabForDragging(),c._dragStarted=!0}},_performDrag:function(b){var c=this.getZoomFactor(),d=-parseInt(this._unorderedListHelper.css("left"),10);this._capturedElement.style.left=this._toPx(d+b.clientX/c-this._startX/c);this._lastX=b.clientX/c;this._moveSelectionTrack(this.selectedItem,0)},getZoomFactor:function(){var b=1;document.body.getBoundingClientRect&&(b=document.body.getBoundingClientRect(),b=Math.round((b.right-b.left)/document.body.offsetWidth*
1715100)/100);return b},_prepareTabForDragging:function(){this._capturedElement.style.position="relative";this._capturedElement.style.left="0px";this._capturedElement.style.top="0px";this._capturedElement.style.zIndex=300;this.selectedItem=this._indexOf(this._capturedElement);switch(this.position){case "top":this._capturedElement.style.bottom=this._toPx(a(this._capturedElement).css("top"));break;case "bottom":this._capturedElement.style.top=this._toPx(a(this._capturedElement).css("top"))}this._raiseEvent(9,
1716{item:this._indexOf(this._capturedElement)})},_dragScroll:function(b){var c=parseInt(this._unorderedListHelper.css("left"),10),d=this,e=a(d._headerWrapper);b.clientX<=e.offset().left?(this._scrollLeft(this.scrollAnimationDuration),this._capturedElement.style.left=parseInt(a(this._capturedElement).css("left"),10)+this._lastUnorderedListPosition-c):b.clientX>e.offset().left+d._width(this._headerWrapper)?(this._scrollRight(this.scrollAnimationDuration),this._capturedElement.style.left=parseInt(a(this._capturedElement).css("left"),
171710)+this._lastUnorderedListPosition-c):(d._stop(d._unorderedListHelper),this._unlockAnimation("unorderedList"),clearTimeout(this._scrollTimeout));this._scrollTimeout=setTimeout(function(){d._dragScroll(b)},this.scrollAnimationDuration);this._lastUnorderedListPosition=c},_captureElement:function(b,c){this._tabCaptured||this._titleList[c].locked||!0===this._titleList[c].disabled||this._activeAnimation()||(this._startX=-parseInt(this._unorderedListHelper.css("left"),10)+b.clientX,this._startY=b.clientY,
1718this._lastX=b.clientX,this._lastY=b.clientY,this._tabCaptured=!0,this._capturedElement=this._titleList[c])},_titleInteractionTrigger:function(b){0<this._headerExpandingBalance&&this._removeOppositeBorder();this._selectedItem!==b?(this.select(this._titleList[b],"toggle"),this._titleList[b].collapsed=!1,this.collapsible||("auto"!==this.height?this._contentWrapper.style.visibility="visible":this._contentWrapper.style.display="block")):this.collapsible&&(this.isCollapsed?this.expand():this.collapse())},
1719collapse:function(){var b=this._selectedItem;this.isCollapsed=!0;"auto"!==this.height?this._contentWrapper.style.visibility="hidden":this._contentWrapper.style.display="none";this._raiseEvent(13,{item:b});"top"===this.position?(this._headerWrapper.className+=" "+this.toThemeProperty("jqx-tabs-header-collapsed"),this.element.className+=" "+this.toThemeProperty("jqx-tabs-collapsed")):(this._headerWrapper.className+=" "+this.toThemeProperty("jqx-tabs-header-collapsed-bottom"),this.element.className+=
1720" "+this.toThemeProperty("jqx-tabs-collapsed-bottom"))},expand:function(){var b=this._selectedItem;this.isCollapsed=!1;this._select(b,this.contentTransitionDuration,null,!1,!0);"auto"!==this.height?this._contentWrapper.style.visibility="visible":this._contentWrapper.style.display="block";this._raiseEvent(14,{item:b});"top"===this.position?(this._removeClass(this._headerWrapper,this.toThemeProperty("jqx-tabs-header-collapsed")),this._removeClass(this.element,this.toThemeProperty("jqx-tabs-collapsed"))):
1721(this._removeClass(this._headerWrapper,this.toThemeProperty("jqx-tabs-header-collapsed-bottom")),this._removeClass(this.element,this.toThemeProperty("jqx-tabs-collapsed-bottom")))},_addSelectHandler:function(b){var c=this;this.addHandler(this._titleList[b],"selectstart",function(){return!1});this.addHandler(this._titleList[b],this.toggleMode,function(d){return function(){c._raiseEvent("15",{item:d});c._tabCaptured||c._cancelClick||c._titleInteractionTrigger(d);return!0}}(b))},_addDragDropHandlers:function(b){var c=
1722this;this.addHandler(this._titleList[b],"mousedown",function(d){c._captureElement(d,b)});this.addHandler(this._titleList[b],"mouseup",function(d){c._tabCaptured&&c._dragStarted?(c._cancelClick=!0,c._uncapture(d,b)):c._cancelClick=!1;return c._tabCaptured=!1})},_removeHoverStates:function(){var b=this;a.each(this._titleList,function(){b._removeClass(this,b.toThemeProperty("jqx-tabs-title-hover-top jqx-tabs-title-hover-bottom"))})},_addHoverHandlers:function(b){var c=this,d=this._titleList[b];this.addHandler(d,
1723"mouseenter mouseleave",function(e){if(b!==c._selectedItem){var f="jqx-fill-state-hover";f="top"===c.position?f+" jqx-tabs-title-hover-top":f+" jqx-tabs-title-hover-bottom";
1723"mouseenter"===e.type?d.className+=" "+c.toThemeProperty(f):c._removeClass(d,c.toThemeProperty(f));c.showCloseButtons&&(f=c._closeButtonList[b],"mouseenter"===e.type?f.className+=" "+c.toThemeProperty("jqx-tabs-close-button-hover",!0):c._removeClass(f,c.toThemeProperty("jqx-tabs-close-button-hover",!0)))}})},_addEventListenerAt:function(b){var c=
1724this;this._titleList[b].disabled||(this.reorder&&!this._isTouchDevice&&this._addDragDropHandlers(b),this._addSelectHandler(b),this.enabledHover&&this._addHoverHandlers(b),b=c._closeButtonList[b],this.removeHandler(b,"click"),this.addHandler(b,"click",function(){var d=a(this).parents("li").index();c.removeAt(d);return!1}))},_removeEventHandlers:function(){for(var b=this.length();b;)b--,this._removeEventListenerAt(b);this.scrollable&&(this.removeHandler(this._leftArrow,"mousedown"),this.removeHandler(this._rightArrow,
1725"mousedown"));this.removeHandler(a(document),"mousemove.tab"+this.element.id,this._moveElement);this.removeHandler(a(document),"mouseup.tab"+this.element.id,this._mouseUpScrollDocumentHandler);this.removeHandler(a(document),"mouseup.tab"+this.element.id,this._mouseUpDragDocumentHandler);this.removeHandler(this.host,"keydown")},_removeEventListenerAt:function(b){this.removeHandler(this._titleList[b],this.toggleMode);this.removeHandler(this._titleList[b],"mouseenter");this.removeHandler(this._titleList[b],
1726"mouseleave");this.removeHandler(this._titleList[b],"mousedown");this.removeHandler(this._titleList[b],"mouseup");this.removeHandler(this._closeButtonList[b],"click")},_moveSelectionTrack:function(b,c,d){var e=this;if(-1!==b&&0!==this._titleList.length&&!(b>=this._titleList.length)){var f=this._titleList[b],g=a(f);e._refreshBarPosition();if(this.selectionTracker&&this._selectionTracker){e._stop(e._selectionTrackerHelper);this._unlockAnimation("selectionTracker");void 0===d&&(d=parseInt(g.position().left,
172710),isNaN(parseInt(this._unorderedListHelper.css("left"),10))||(d+=parseInt(this._unorderedListHelper.css("left"),10)),isNaN(parseInt(this._unorderedListHelper.css("margin-left"),10))||(d+=parseInt(this._unorderedListHelper.css("margin-left"),10)),isNaN(parseInt(g.css("margin-left"),10))||(d+=parseInt(g.css("margin-left"),10)),isNaN(parseInt(g.css("margin-right"),10)));var h=0;"top"===this.position&&(this._height(e._headerWrapper),this.autoHeight||(h+=parseInt(g.css("margin-top"),10)));this._lockAnimation("selectionTracker");
1728h=parseInt(g.css("padding-left"),10)+parseInt(g.css("padding-right"),10);var k="top"===this.position?0:1,l=parseInt(a(this._headerWrapper).css("padding-top"),10),m=parseInt(g.css("padding-top"),10)+parseInt(g.css("padding-bottom"),10);this._selectionTracker.style.visibility="visible";this._moveSelectionTrackerContainer.style.visibility="visible";g=parseInt(g.css("margin-top"),10);isNaN(g)&&(g=0);e._refreshBarPosition();e._selectionTrackerHelper.animate({top:l+g-k,left:d+"px",height:parseInt(this._height(f)+
1729m,10),width:e._width(f)+h},c,function(){e._unlockAnimation("selectionTracker");e._selectionTracker.style.visibility="hidden";e._addSelectStyle(b,!0);e._moveSelectionTrackerContainer.style.visibility="hidden"})}}},destroy:function(){a.jqx.utilities.resize(this.host,null,!0);(""!=document.referrer||window.frameElement)&&null!=window.top&&window.top!=window.self&&this.removeHandler(a(window.top.document),"mouseup.tabs"+this.element.id);this.host.remove()},_switchTabs:function(b,c){if(b!==c&&!this._activeAnimation()&&
1730!this._tabCaptured){this._raiseEvent(7,{item:c});this._raiseEvent(6,{item:b});if(this._currentEvent&&this._currentEvent.cancel){this._currentEvent=null;return}this._unselect(c,null,!0);this._select(b,this.contentTransitionDuration,null,!0);return!0}return!1},_activeAnimation:function(){for(var b in this._isAnimated)if(this._isAnimated.hasOwnProperty(b)&&this._isAnimated[b])return!0;return!1},_indexOf:function(b){for(var c=this.length();c;)if(c--,this._titleList[c]===b||this._contentList[c]===b)return c;
1731return-1},_validateProperties:function(){try{if(0>this.scrollAnimationDuration||isNaN(this.scrollAnimationDuration))throw Error(this._invalidArgumentExceptions.invalidScrollAnimationDuration);if(0>parseInt(this.width,10)&&"auto"!==this.width)throw Error(this._invalidArgumentExceptions.invalidWidth);if(0>parseInt(this.height,10)&&"auto"!==this.height)throw Error(this._invalidArgumentExceptions.invalidHeight);if("none"!==this.animationType&&"fade"!==this.animationType)throw Error(this._invalidArgumentExceptions.invalidAnimationType);
1732if(0>this.contentTransitionDuration||isNaN(this.contentTransitionDuration))throw Error(this._invalidArgumentExceptions.invalidcontentTransitionDuration);if("click"!==this.toggleMode&&"dblclick"!==this.toggleMode&&"mouseenter"!==this.toggleMode&&"none"!==this.toggleMode)throw Error(this._invalidArgumentExceptions.invalidToggleMode);if("top"!==this.position&&"bottom"!==this.position)throw Error(this._invalidArgumentExceptions.invalidPosition);if("left"!==this.scrollPosition&&"right"!==this.scrollPosition&&
1733"both"!==this.scrollPosition)throw Error(this._invalidArgumentExceptions.invalidScrollPosition);if(0>this.scrollStep||isNaN(this.scrollStep))throw Error(this._invalidArgumentExceptions.invalidScrollStep);if(this._titleList.length!==this._contentList.length||0===this._titleList.length)throw Error(this._invalidArgumentExceptions.invalidStructure);if(0>this.arrowButtonSize||isNaN(this.arrowButtonSize))throw Error(this._invalidArgumentExceptions.invalidArrowSize);if(0>this.closeButtonSize||isNaN(this.closeButtonSize))throw Error(this._invalidArgumentExceptions.invalidCloseSize);
1734}catch(b){try{console.log(b)}catch(c){}}},_startScrollRepeat:function(b,c){var d=this;b?this._scrollLeft(c):this._scrollRight(c);this._scrollTimeout&&clearTimeout(this._scrollTimeout);this._scrollTimeout=setTimeout(function(){d._startScrollRepeat(b,d.scrollAnimationDuration)},c)},_performLayout:function(){for(var b=this.length();b;)if(b--,"top"===this.position||"bottom"===this.position)this._titleList[b].style["float"]=this.rtl?"right":"left";this._fitToSize();this._performHeaderLayout();this._fitToSize()},
1735updatetabsheader:function(){this._performHeaderLayout()},_setSize:function(){this._fitToSize();this._positionArrows(this._totalItemsWidth);this._unorderedList.style.width=this._totalItemsWidth>this.element.offsetWidth?this._toPx(this._totalItemsWidth):this.element.offsetWidth-2+"px";this._fitToSize()},_addArrows:function(){this._leftArrow&&this._rightArrow&&(a(this._leftArrow).remove(),a(this._rightArrow).remove());this._leftArrow=document.createElement("div");this._leftArrow.innerHTML='<span style="display: block; width: 16px; height: 16px;" class="'+
1736this.toThemeProperty("jqx-tabs-arrow-left")+'"></span>';this._leftArrow.className=this.toThemeProperty("jqx-tabs-arrow-background jqx-widget-header");this._leftArrow.style.zIndex=30;this._leftArrow.style.display="none";this._leftArrow.style.width=this._toPx(this.arrowButtonSize);this._leftArrow.style.height="100%";this._rightArrow=document.createElement("div");this._rightArrow.innerHTML='<span style="display: block; width: 16px; height: 16px;" class="'+this.toThemeProperty("jqx-tabs-arrow-right")+
1737'"></span>';this._rightArrow.className=this.toThemeProperty("jqx-tabs-arrow-background jqx-widget-header");this._rightArrow.style.zIndex=30;this._rightArrow.style.display="none";this._rightArrow.style.width=this._toPx(this.arrowButtonSize);this._rightArrow.style.height="100%";this._headerWrapper.appendChild(this._leftArrow);this._headerWrapper.appendChild(this._rightArrow)},_tabsWithVisibleCloseButtons:function(){if(!this.showCloseButtons)return 0;var b=this.length();a.each(this._titleList,function(){var c=
1738this.attr("hasclosebutton");void 0===c||null===c||"false"!==c&&!1!==c||b--});return b},_calculateTitlesSize:function(){function b(l,m){l&&(l.style.display=m?"block":"none")}var c=0,d=0,e=this.length();this.rtl&&a.jqx.browser.msie&&8>a.jqx.browser.version&&(this._measureItem=document.createElement("span"),this._measureItem.style.position="relative",this._measureItem.style.visibility="hidden",document.body.appendChild(this._measureItem));for(;e;){e--;var f=this._titleList[e],g=this._closeButtonList[e];
1739this._measureItem&&(this._measureItem.innerHTML=f.innerHTML,this._measureItem.html(this._titleList[e].html()),f.style.width=this._toPx(this._width(this._measureItem)));f.style.position="static";b(g,!1);d+=this._outerWidth(f,!0);var h=this._outerHeight(f,!0);
1739c<h&&(c=h);0===this._height(f)&&(h=f.cloneNode(!0),document.body.appendChild(h),c=this._outerHeight(h,!0),document.body.removeChild(h));h=f.getAttribute("hasCloseButton");if(void 0!==h&&null!==h){var k=!1;this.hiddenCloseButtons&&1===this.hiddenCloseButtons[e]&&
1740(b(g,!1),k=!0);k||("true"===h||!0===h?(d+=this.closeButtonSize,b(g,!0)):"false"!==h&&!1!==h||b(g,!1))}else this.showCloseButtons&&(this.canCloseAllTabs||1<this._tabsWithVisibleCloseButtons())&&(k=!1,this.hiddenCloseButtons&&1===this.hiddenCloseButtons[e]&&(b(g,!1),k=!0),k||(d+=this.closeButtonSize,b(g,!0)));f.style.height=this._toPx(this._height(f))}this._measureItem&&a(this._measureItem).remove();return{height:c,width:10+d}},_reorderHeaderElements:function(){this.selectionTracker&&(this._moveSelectionTrackerContainer.style.position=
1741"absolute",this._moveSelectionTrackerContainer.style.height="100%",this._moveSelectionTrackerContainer.style.top="0px",this._moveSelectionTrackerContainer.style.left="0px",this._moveSelectionTrackerContainer.style.width="100%");this._headerWrapper.style.position="relative";this._headerWrapper.style.left="0px";this._headerWrapper.style.top="0px";if(this.scrollable){this._rightArrow.style.width=this._toPx(this.arrowButtonSize);this._rightArrow.style.position="absolute";this._rightArrow.style.top="0px";
1742this._leftArrow.style.width=this._toPx(this.arrowButtonSize);this._leftArrow.style.position="absolute";this._leftArrow.style.top="0px";var b=this.theme&&-1!==this.theme.indexOf("ui-")?3:0;0<b&&(this._rightArrow.className+=" "+this.toThemeProperty("jqx-rc-r"),this._leftArrow.className+=" "+this.toThemeProperty("jqx-rc-l"));var c=this.scrollPosition;this.rtl&&("left"===c&&(c="right"),"right"===c&&(c="left"));switch(c){case "both":this._rightArrow.style.right="0px";this._leftArrow.style.left="0px";break;
1743case "left":this._rightArrow.style.left=this._toPx(this.arrowButtonSize);this._leftArrow.style.left="0px";break;case "right":this._rightArrow.style.right=this._toPx(-b),this._leftArrow.style.right=this._toPx(parseInt(this.arrowButtonSize,10)-b)}}},_positionArrows:function(b){b>=this._headerWrapper.offsetWidth&&this.scrollable?(this._needScroll=!0,0===this._unorderedListHelper.position().left&&(this._unorderedListLeftBackup=this._getArrowsDisplacement()+"px"),this._leftArrow.style.display="block",
1744this._rightArrow.style.display="block"):(this._needScroll=!1,this._leftArrow.style.display="none",this._rightArrow.style.display="none",this._unorderedList.style.left="0px")},_performHeaderLayout:function(){this._removeSelectStyle();var b=this._calculateTitlesSize(),c=b.height;b=b.width;this._headerWrapper.style.height=this._toPx(c);this._unorderedList.style.height=this._toPx(c);null!==this.headerHeight&&"auto"!==this.headerHeight&&(this._headerWrapper.style.height=this._toPx(this.headerHeight),this._unorderedList.style.height=
1745this._toPx(this.headerHeight));c=this._width(this.element);this._unorderedList.style.width=b>c?this._toPx(b):this._toPx(c);a.jqx.browser.msie&&8>a.jqx.browser.version&&(this._unorderedList.style.position="relative",this._unorderedList.style.overflow="hidden");this._reorderHeaderElements();this._totalItemsWidth=b+=parseInt(this._unorderedListHelper.css("margin-left"),10);this._positionArrows(b);this._unorderedList.style.position="relative";this._unorderedList.style.top="0px";this._verticalAlignElements();
1746this._moveSelectionTrack(this._selectedItem,0);this._addSelectStyle(this.selectedItem)},_verticalAlignElements:function(){for(var b=this.length();b;){b--;var c=this._titleList[b],d=a(c),e=d.children()[0],f=this._closeButtonList[b];parseInt(d.css("padding-top"),10);if(this.autoHeight){var g=parseInt(d.css("padding-top"),10),h=parseInt(d.css("padding-bottom"),10),k=d.css("border-top-width");d=d.css("border-bottom-width");k=-1===k.indexOf("px")?1:parseInt(k,10);d=-1===d.indexOf("px")?1:parseInt(d,10);
1747c.style.height=this._toPx(this._outerHeight(this._unorderedList,!0)-(g+h+k+d))}else"top"===this.position?(g=this._height(this._unorderedList)-parseInt(this._outerHeight(c,!0),10),parseInt(d.css("margin-top"),10)!==g&&0!==g&&(c.style.marginTop=this._toPx(g))):c.style.height=this._toPx(this._height(c));e.style.height="100%";c=this._height(c);f&&(d=c/2-this._height(f)/2,f.style.marginTop=this._toPx(1+d));f=c/2-this._height(e)/2;e.style.marginTop=this._toPx(f)}this.scrollable&&(b=(parseInt(this._headerWrapper.offsetHeight,
174810)-this.arrowButtonSize)/2,a(this._rightArrow).children()[0].style.marginTop=this._toPx(b),this._rightArrow.style.height="100%",a(this._leftArrow).children()[0].style.marginTop=this._toPx(b),this._leftArrow.style.height="100%")},_getImageUrl:function(b){b=b.css("background-image");
1748b=b.replace('url("',"");b=b.replace('")',"");b=b.replace("url(","");return b=b.replace(")","")},_fitToSize:function(){var b=!1,c=!1;null!==this.width&&-1!==this.width.toString().indexOf("%")&&(b=!0);null!==this.height&&
1749-1!==this.height.toString().indexOf("%")&&(c=!0);b?(this.element.style.width=this.width,this._contentWrapper.style.width="100%"):(this.element.style.width=this._toPx(this.width),"auto"!==this.width&&(this._contentWrapper.style.width="100%"));c?(this.element.style.height=this.height,this._contentWrapper.style.width="100%",this._contentWrapper.style.height="auto",b=this.element.offsetHeight-this._headerWrapper.offsetHeight-2,this._contentWrapper.style.height=b+"px"):"auto"!==this.height?(this.element.style.height=
1750this._toPx(this.height),b=this._height(this.element)-this._headerWrapper.offsetHeight,this._contentWrapper.style.height=this._toPx(b)):this._contentWrapper.style.height="auto"},_maxHeightTab:function(){for(var b=this.length(),c=-1;b;)b--,-1<this._outerHeight(this._titleList[b],!0)&&(c=b);return c},_addSelectionTracker:function(){this._moveSelectionTrackerContainer&&a(this._moveSelectionTrackerContainer).remove();this._moveSelectionTrackerContainer=document.createElement("div");this._moveSelectionTrackerContainer.className=
1751this.toThemeProperty("jqx-tabs-selection-tracker-container");this._selectionTracker=document.createElement("div");this._selectionTracker.className=this.toThemeProperty("jqx-tabs-selection-tracker-"+this.position);this._selectionTracker.style.color="inherit";this._selectionTracker.style.position="absolute";this._selectionTracker.style.zIndex=10;this._selectionTracker.style.left="0px";this._selectionTracker.style.top="0px";this._selectionTracker.style.display="inline-block";this._moveSelectionTrackerContainer.appendChild(this._selectionTracker);
1752this._headerWrapper.appendChild(this._moveSelectionTrackerContainer);this._selectionTrackerHelper=a(this._selectionTracker);this._selectionTrackerHelper.initAnimate&&this._selectionTrackerHelper.initAnimate()},_addContentWrapper:function(){var b=null===this._contentWrapper;b&&(this._contentWrapper=document.createElement("div"),this._contentWrapper.className=this.toThemeProperty("jqx-tabs-content jqx-widget-content"),this._contentWrapper.style["float"]="none");for(var c=this.length();c;)c--,this._contentList[c].className+=
1753" "+this.toThemeProperty("jqx-tabs-content-element");if(b)for("top"===this.position?this.element.appendChild(this._contentWrapper):this.element.insertBefore(this._contentWrapper,this.element.firstChild),b=0;b<this._contentList.length;b++)this._contentWrapper.appendChild(this._contentList[b]);this.roundedCorners&&(this._contentWrapper.className="top"===this.position?this._contentWrapper.className+(" "+this.toThemeProperty("jqx-rc-b")):this._contentWrapper.className+(" "+this.toThemeProperty("jqx-rc-t")),
1754this.element.className+=" "+this.toThemeProperty("jqx-rc-all"))},_addHeaderWrappers:function(){var b=this.length();void 0!==this._headerWrapper&&(a(this._headerWrapper).remove(),this.bar&&(this.bar=null));this._headerWrapper=document.createElement("div");this._headerWrapper.style.outline="none";"top"===this.position?this.element.insertBefore(this._headerWrapper,this.element.firstChild):this.element.appendChild(this._headerWrapper);this._headerWrapper.appendChild(this._unorderedList);var c="jqx-tabs-headerWrapper jqx-tabs-header jqx-widget-header";
1755"bottom"===this.position&&(c+=" jqx-tabs-header-bottom");this.roundedCorners&&(c="top"===this.position?c+" jqx-rc-t":c+" jqx-rc-b");for(this._headerWrapper.className=this.toThemeProperty(c);b;)if(b--,c=this._titleList[b],null===c.querySelector(".jqx-tabs-titleWrapper")){var d=document.createElement("div");d.className="jqx-tabs-titleWrapper";d.style.outline="none";d.style.position="relative";d.style.zIndex=15;var e=a(c).children();d.appendChild(e[0]);d.appendChild(e[1]);c.appendChild(d)}},_render:function(){this._addCloseButtons();
1756this._addHeaderWrappers();this._addContentWrapper();this.selectionTracker&&this._addSelectionTracker();this._addArrows()},_addCloseButton:function(b,c){var d=document.createElement("div"),e=this._titleList[b];d.className="jqx-tabs-titleContentWrapper jqx-disableselect";var f="left";this.rtl&&(f="right");0<a(e).find(".jqx-tabs-close-button").length&&a(e).find(".jqx-tabs-close-button").remove();d.style["float"]=f;d.innerHTML=e.innerHTML;e.innerHTML="";var g=document.createElement("div");g.className=
1757this.toThemeProperty("jqx-tabs-close-button");g.style.height=this._toPx(this.closeButtonSize);g.style.width=this._toPx(this.closeButtonSize);g.style["float"]=f;g.style.fontSize="1px";e.appendChild(d);e.appendChild(g);!0===c?this._closeButtonList[b]=g:this._closeButtonList.splice(b,0,g);this.showCloseButtons?this.hiddenCloseButtons&&1===this.hiddenCloseButtons[b]&&(g.style.display="none"):g.style.display="none"},_addCloseButtons:function(){for(var b=this.length();b;)b--,this._addCloseButton(b,!0)},
1758_prepareTabs:function(){var b=this.length(),c=this.selectionTracker;for(this.selectionTracker=!1;b;)b--,this._selectedItem!==b&&this._unselect(b,null,!1);this._select(this._selectedItem,0,null,!1);this.selectionTracker=c;!this.initTabContent||this._initTabContentList[this.selectedItem]||this._hiddenParent()||(this.initTabContent(this.selectedItem),this._initTabContentList[this.selectedItem]=!0)},_isValidIndex:function(b){return 0<=b&&b<this.length()},_removeSelectStyle:function(){for(var b=this.length();b;){b--;
1759var c=this._titleList[b];this.showCloseButtons&&this._removeClass(this._closeButtonList[b],this.toThemeProperty("jqx-tabs-close-button-selected"));var d="jqx-fill-state-pressed";d="top"===this.position?d+" jqx-tabs-title-selected-top":d+" jqx-tabs-title-selected-bottom";this._removeClass(c,this.toThemeProperty(d))}},_addSelectStyle:function(b,c){this._removeSelectStyle();if(!this.selectionTracker||void 0!==c&&c)if(c=this._titleList[b],0<=b&&void 0!==c){var d=null;this.showCloseButtons&&(d=this._closeButtonList[b],
1760this.hiddenCloseButtons&&1===this.hiddenCloseButtons[b]&&(d=null));b="jqx-fill-state-hover";var e=" jqx-fill-state-pressed";"top"===this.position?(b+=" jqx-tabs-title-hover-top",e+=" jqx-tabs-title-selected-top"):(b+=" jqx-tabs-title-hover-bottom",e+=" jqx-tabs-title-selected-bottom");this._removeClass(c,this.toThemeProperty(b));c.className+=this.toThemeProperty(e);null!==d&&(d.className+=" "+this.toThemeProperty("jqx-tabs-close-button-selected"))}},_addItemTo:function(b,c,d){if(c<b.length){for(var e,
1761f,g=c;g+1<b.length;g++)void 0===e?(e=b[g+1],b[g+1]=b[g]):(f=b[g+1],b[g+1]=e,e=f);void 0===e&&(e=b[c]);b[c]=d;b.push(e)}else b.push(d)},_refreshBarPosition:function(){var b=this;if(!this.bar){var c=a("<span></span>");a(this._headerWrapper).append(c);c.addClass(this.toThemeProperty("jqx-tabs-bar"));this.bar=c}setTimeout(function(){if(!(0>b._selectedItem)){var d=parseInt(b._unorderedListHelper.css("left"),10),e=parseInt(b._unorderedListHelper.css("margin-left"));d?b.bar.css("left",e+b._titleList[b._selectedItem].offsetLeft+
1762d):b.bar.css("left",e+b._titleList[b._selectedItem].offsetLeft);b.bar.width(a(b._titleList[b._selectedItem]).outerWidth()-2)}})},_select:function(b,c,d,e,f){if(!this._tabCaptured){this.host.attr("hideFocus","true");var g=this;void 0===f?this._addSelectStyle(b):this._addSelectStyle(b,f);var h=a(g._titleList[b]),k=g._titleList[b].getAttribute("id"),l=a(g._contentList[b]);if(this.isCollapsed&&this.collapsible)l[0].style.display="none",this._selectCallback(b,d,e);else switch(g._refreshBarPosition(),this.animationType){case "none":if(g.selectionTracker)setTimeout(function(){l[0].style.display=
1763"block";a.jqx.aria(h,"aria-selected",!0);a.jqx.aria(l,"aria-hidden",!1);a.jqx.aria(g,"aria-activedescendant",k)},this.selectionTrackerAnimationDuration);else{for(c=0;c<this._contentList.length;c++)b!==c&&"block"===a(g._contentList[c]).css("display")&&(g._contentList[c].style.display="none",a.jqx.aria(a(g._titleList[c]),"aria-selected",!1),a.jqx.aria(a(g._contentList[c]),"aria-hidden",!0));l[0].style.display="block";a.jqx.aria(h,"aria-selected",!0);a.jqx.aria(l,"aria-hidden",!1);a.jqx.aria(this,"aria-activedescendant",
1764k)}this._selectCallback(b,d,e);break;
1764case "fade":this._lockAnimation("contentListSelect"),g._selectCallback(b,d,e),l.initAnimate&&void 0===l.fadeIn&&l.initAnimate(),l.fadeIn({duration:1E3,complete:function(){g._unlockAnimation("contentListSelect");a.jqx.aria(h,"aria-selected",!0);a.jqx.aria(l,"aria-hidden",!1);a.jqx.aria(g,"aria-activedescendant",k)}})}}},_selectCallback:function(b,c,d){this.selectedItem=this._selectedItem=b;c&&c();d&&this._raiseEvent(1,{item:b})},_unselect:function(b,c,d){if(0<=
1765b&&!this._tabCaptured){var e=this._contentList[b],f=a(e),g=this._titleList[b],h=a(g);f.initAnimate&&void 0===f.animate&&f.initAnimate();this._stop(f);"fade"===this.animationType?(e.style.display="none",a.jqx.aria(h,"aria-selected",!1),a.jqx.aria(f,"aria-hidden",!0)):this.selectionTracker?setTimeout(function(){e.style.display="none";a.jqx.aria(h,"aria-selected",!1);a.jqx.aria(f,"aria-hidden",!0)},this.selectionTrackerAnimationDuration):(e.style.display="none",a.jqx.aria(h,"aria-selected",!1),a.jqx.aria(f,
1766"aria-hidden",!0));this._unselectCallback(b,c,d);this.selectionTracker||this._removeClass(g,this.toThemeProperty("jqx-tabs-title-selected jqx-fill-state-pressed"))}},_unselectCallback:function(b,c,d){d&&this._raiseEvent(8,{item:b});c&&c()},disable:function(){for(var b=this.length();b;)b--,this.disableAt(b)},enable:function(){for(var b=this.length();b;)b--,this.enableAt(b)},getEnabledTabsCount:function(){var b=0;a.each(this._titleList,function(){this.disabled||b++});return b},getDisabledTabsCount:function(){var b=
17670;a.each(this._titleList,function(){this.disabled&&b++});return b},removeAt:function(b){if(this._isValidIndex(b)&&(this.canCloseAllTabs||1<this.length())){this._removeHoverStates();this._initTabContentList[b]=!1;var c=this,d=c._outerWidth(this._titleList[b],!0),e=this.getTitleAt(b);this._unorderedList.style.width=c._toPx(c._width(this._unorderedList)-d);a(this._titleList[b]).remove();a(this._contentList[b]).remove();this._titleList.splice(b,1);this._contentList.splice(b,1);c._closeButtonList.splice(b,
17681);this._addStyles();this._performHeaderLayout();this._removeEventHandlers();this._addEventHandlers();this._raiseEvent(3,{item:b,title:e});this._isAnimated={};0<this.selectedItem?(this._selectedItem=-1,this.selectedItem>=b?(b=this._getPreviousIndex(this.selectedItem),this.select(b)):this.select(c.selectedItem)):(this._selectedItem=-1,b=this._getNextIndex(this.selectedItem),this.select(b));parseInt(this._unorderedListHelper.css("left"),10)>this._getArrowsDisplacement()&&(this._unorderedList.style.left=
1769c._toPx(this._getArrowsDisplacement()));c._width(this._unorderedList)<=c._width(this._headerWrapper)&&(b=this.enableScrollAnimation?this.scrollAnimationDuration:0,this._lockAnimation("unorderedList"),this._unorderedListHelper.animate({left:0},b,function(){c._unlockAnimation("unorderedList")}))}},removeFirst:function(){this.removeAt(0)},removeLast:function(){this.removeAt(this.length()-1)},disableAt:function(b){var c=this._titleList[b];c.disabled&&void 0!==c.disabled||(this.selectedItem===b&&(this.next()||
1770this.previous()),c.disabled=!0,this.removeHandler(c,this.toggleMode),this.enabledHover&&a(c).off("mouseenter").off("mouseleave"),this._removeEventListenerAt(b),c.className+=" "+this.toThemeProperty("jqx-tabs-title-disable jqx-fill-state-disabled"),this._raiseEvent(5,{item:b}))},enableAt:function(b){var c=this._titleList[b];c.disabled&&(c.disabled=!1,this._addEventListenerAt(b),this._removeClass(c,this.toThemeProperty("jqx-tabs-title-disable jqx-fill-state-disabled")),this._raiseEvent(4,{item:b}))},
1771addAt:function(b,c,d){if(0<=b&&b<=this.length()){this._removeHoverStates();var e=document.createElement("li");e.innerHTML=c;e.className=this.toThemeProperty("jqx-tabs-title jqx-item");c=document.createElement("div");c.innerHTML=d;c.className=this.toThemeProperty("jqx-tabs-content-element");"bottom"===this.position&&(e.className+=" "+this.toThemeProperty("jqx-tabs-title-bottom"));0===this._titleList.length?this._unorderedList.appendChild(e):b<this.length()&&0<=b?this._unorderedList.insertBefore(e,
1772this._titleList[b]):this._unorderedList.appendChild(e);this._contentWrapper.appendChild(c);this._addItemTo(this._titleList,b,e);this._addItemTo(this._contentList,b,c);this._addCloseButton(b);this._selectedItem>b&&this._selectedItem++;this._switchTabs(b,this._selectedItem);this._selectedItem=b;this._uiRefresh(!1);this._raiseEvent(2,{item:b});this._moveSelectionTrack(this._selectedItem,0)}},addFirst:function(b,c){this.addAt(0,b,c)},addLast:function(b,c){this.addAt(this.length(),b,c)},val:function(b){if(0===
1773arguments.length||"object"===typeof b)return this._selectedItem;this.select(b);return this._selectedItem},select:function(b){"object"===typeof b&&(b=this._indexOf(b));var c=0<=b&&b<this._titleList.length?this._titleList[b].getAttribute("canselect"):!0;(void 0===c||null===c||"true"===c||!0===c)&&b!==this._selectedItem&&this._isValidIndex(b)&&(this._activeAnimation()||this._titleList[b].disabled||this._switchTabs(b,this._selectedItem)&&this.ensureVisible(b))},previous:function(b){var c=this._selectedItem;
1774for(void 0===b||isNaN(b)||(c=b);0<c&&c<this._titleList.length;)if(c--,!this._titleList[c].disabled)return this.select(c),!0;return!1},_getPreviousIndex:function(b){if(void 0===b||isNaN(b))return 0;for(var c=b;0<b&&b<=this._titleList.length;)if(b--,!this._titleList[b].disabled)return b;return c},_getNextIndex:function(b){if(void 0===b||isNaN(b))return 0;for(var c=b;0<=b&&b<this._titleList.length;){if(!this._titleList[b].disabled)return b;b++}return c},next:function(b){var c=this._selectedItem;for(void 0===
1775b||isNaN(b)||(c=b);0<=c&&c<this._titleList.length-1;)if(c++,!this._titleList[c].disabled)return this.select(c),!0;return!1},first:function(){this._titleList[0].disabled?this.next(0):this.select(0)},last:function(){var b=this._titleList.length-1;this._titleList[b].disabled?this.previous(b):this.select(b)},length:function(){return this._titleList.length},lockAt:function(b){!this._isValidIndex(b)||this._titleList[b].locked&&void 0!==this._titleList[b].locked||(this._titleList[b].locked=!0,this._raiseEvent(11,
1776{item:b}))},unlockAt:function(b){this._isValidIndex(b)&&this._titleList[b].locked&&(this._titleList[b].locked=!1,this._raiseEvent(12,{item:b}))},lockAll:function(){for(var b=this.length();b;)b--,this.lockAt(b)}
1776,unlockAll:function(){for(var b=this.length();b;)b--,this.unlockAt(b)},showCloseButtonAt:function(b){this._isValidIndex(b)&&(this.showCloseButtons||(this.showCloseButtons=!0,this.updatetabsheader()),this._closeButtonList[b].style.display="block",this.hiddenCloseButtons||(this.hiddenCloseButtons=
1777[]),this.hiddenCloseButtons[b]=0)},hideCloseButtonAt:function(b){this._isValidIndex(b)&&(this._closeButtonList[b].style.display="none",this.hiddenCloseButtons||(this.hiddenCloseButtons=[]),this.hiddenCloseButtons[b]=1)},hideAllCloseButtons:function(){for(var b=this.length();b;)b--,this.hideCloseButtonAt(b)},showAllCloseButtons:function(){for(var b=this.length();b;)b--,this.showCloseButtonAt(b)},getTitleAt:function(b){return this._titleList[b]?a(this._titleList[b]).text():null},getContentAt:function(b){return this._contentList[b]?
1778this._contentList[b]:null},setTitleAt:function(b,c){this._titleList[b]&&(a(this._titleList[b]).text(c),this.showCloseButtons&&(this._addCloseButton(b),this._removeEventHandlers(),this._addEventHandlers()),this.render(),this.refresh())},setContentAt:function(b,c){this._contentList[b]&&a(this._contentList[b]).html(c)},ensureVisible:function(b){var c=this;if(void 0===b||-1===b||null===b)b=this.selectedItem;if(!this._isValidIndex(b))return!1;var d=this._titleList[b],e=parseInt(a(d).position().left,10)+
1779parseInt(this._unorderedListHelper.css("margin-left"),10),f=parseInt(this._unorderedListHelper.css("left"),10),g=this._outerWidth(this._headerWrapper,!0);d=this._outerWidth(d,!0);f-=this._getArrowsDisplacement();var h=g-this._getArrowsDisplacement()-f;if(e<-f)e=-e+this._getArrowsDisplacement(),g=this._getArrowsDisplacement();else if(e+d>h-this._getArrowsDisplacement())e=-e+g-d-(this.scrollable?2*this.arrowButtonSize-this._getArrowsDisplacement():0),g=g-d-this._getArrowsDisplacement();else return this._moveSelectionTrack(b,
1780this.selectionTrackerAnimationDuration),!0;this._lockAnimation("unorderedList");this._unorderedListHelper.animate({left:e},this.scrollAnimationDuration,function(){c._unlockAnimation("unorderedList");c._moveSelectionTrack(c._selectedItem,0);return!0});this._moveSelectionTrack(b,this.selectionTrackerAnimationDuration,g);return!0},isVisibleAt:function(b){if(void 0===b||-1===b||null===b)b=this.selectedItem;if(!this._isValidIndex(b))return!1;var c=this._titleList[b];b=parseInt(a(c).position().left,10)+
1781parseInt(this._unorderedListHelper.css("margin-left"),10);var d=parseInt(this._unorderedListHelper.css("left"),10),e=this._outerWidth(this._headerWrapper,!0);c=this._outerWidth(c,!0);d-=this._getArrowsDisplacement();e=e-this._getArrowsDisplacement()-d;return b<-d||b+c>e?!1:!0},isDisabled:function(b){return this._titleList[b].disabled},_lockAnimation:function(b){this._isAnimated&&(this._isAnimated[b]=!0)},_unlockAnimation:function(b){this._isAnimated&&(this._isAnimated[b]=!1)},propertiesChangedHandler:function(b,
1782c,d){d&&d.width&&d.height&&2===Object.keys(d).length&&b._setSize()},propertyChangedHandler:function(b,c,d,e){if(!(b.batchUpdate&&b.batchUpdate.width&&b.batchUpdate.height&&2===Object.keys(b.batchUpdate).length)){this._validateProperties();switch(c){case "touchMode":e&&(b.enabledHover=!1,b.keyboardNavigation=!1);break;case "width":case "height":b._setSize();return;case "disabled":e?this.disable():this.enable();return;case "showCloseButtons":e?this.showAllCloseButtons():this.hideAllCloseButtons();this._performHeaderLayout();
1783return;case "selectedItem":this._isValidIndex(e)&&this.select(e);return;case "scrollStep":case "contentTransitionDuration":case "scrollAnimationDuration":case "enableScrollAnimation":return;case "selectionTracker":e?(this._refresh(),this.select(this._selectedItem)):this._selectionTracker&&this._selectionTrackerHelper.remove();return;case "scrollable":e?(this._refresh(),this.select(this._selectedItem)):(a(this._leftArrow).remove(),a(this._rightArrow).remove(),this._performHeaderLayout());return;case "autoHeight":this._performHeaderLayout();
1784return;case "theme":a.jqx.utilities.setTheme(d,e,this.host);return}this._unorderedList.style.left="0px";this._refresh();this.select(this._selectedItem);this._addSelectStyle(this._selectedItem,!0)}},_toPx:function(b){return"number"===typeof b?b+"px":b},_removeClass:function(b,c){a(b).removeClass(c)},_width:function(b){var c=a(b),d=c.css("border-left-width"),e=c.
1784css("border-right-width"),f=parseInt(c.css("padding-left"),10);c=parseInt(c.css("padding-right"),10);d=-1===d.indexOf("px")?1:parseInt(d,10);
1785e=-1===e.indexOf("px")?1:parseInt(e,10);return b.offsetWidth-(d+e+f+c)},_outerWidth:function(b,c){var d=b.offsetWidth;c&&(c=a(b),b=parseInt(c.css("margin-left"),10),c=parseInt(c.css("margin-right"),10),d+=b+c);return d},_height:function(b){var c=a(b),d=c.css("border-top-width"),e=c.css("border-bottom-width"),f=parseInt(c.css("padding-top"),10);c=parseInt(c.css("padding-bottom"),10);d=-1===d.indexOf("px")?1:parseInt(d,10);e=-1===e.indexOf("px")?1:parseInt(e,10);return b.offsetHeight-(d+e+f+c)},_outerHeight:function(b,
1786c){var d=b.offsetHeight;c&&(c=a(b),b=parseInt(c.css("margin-top"),10),c=parseInt(c.css("margin-bottom"),10),d+=b+c);return d},_stop:function(b){b.stop?b.stop():b.animate("stop",!0)}})})(jqxBaseFramework);
1787(function(a){function b(c){c=a(c);return"none"!==c.css("display")&&"hidden"!==c.css("visibility")}a.jqx.jqxWidget("jqxWindow","",{});a.extend(a.jqx._jqxWindow.prototype,{defineInstance:function(){var c={height:"auto",width:200,minHeight:50,maxHeight:1200,minWidth:50,maxWidth:1200,showCloseButton:!0,disabled:!1,autoOpen:!0,keyboardCloseKey:"esc",title:"",content:"",draggable:!0,resizable:!0,animationType:"fade",closeAnimationDuration:250,showAnimationDuration:250,isModal:!1,position:"center",closeButtonSize:16,
1788closeButtonAction:"hide",modalOpacity:.3,dragArea:null,okButton:null,cancelButton:null,dialogResult:{OK:!1,Cancel:!1,None:!0},collapsed:!1,showCollapseButton:!1,collapseAnimationDuration:150,collapseButtonSize:16,rtl:!1,keyboardNavigation:!0,headerHeight:null,_events:"created closed moving moved open collapse expand open close resize".split(" "),initContent:null,enableResize:!0,restricter:null,autoFocus:!0,closing:null,_invalidArgumentExceptions:{invalidHeight:"Invalid height!",invalidWidth:"Invalid width!",
1789invalidMinHeight:"Invalid minHeight!",invalidMaxHeight:"Invalid maxHeight!",invalidMinWidth:"Invalid minWidth!",invalidMaxWidth:"Invalid maxWidth",invalidKeyCode:"Invalid keyCode!",invalidAnimationType:"Invalid animationType!",invali
1789dCloseAnimationDuration:"Invalid closeAnimationDuration!",invalidShowAnimationDuration:"Invalid showAnimationDuration!",invalidPosition:"Invalid position!",invalidCloseButtonSize:"Invalid closeButtonSize!",invalidCollapseButtonSize:"Invalid collapseButtonSize!",invalidCloseButtonAction:"Invalid cluseButtonAction!",
1790invalidModalOpacity:"Invalid modalOpacity!",invalidDragArea:"Invalid dragArea!",invalidDialogResult:"Invalid dialogResult!",invalidIsModal:"You can have just one modal window!"},_enableResizeCollapseBackup:null,_enableResizeBackup:void 0,_heightBeforeCollapse:null,_minHeightBeforeCollapse:null,_mouseDown:!1,_isDragging:!1,_rightContentWrapper:null,_leftContentWrapper:null,_headerContentWrapper:null,_closeButton:null,_collapseButton:null,_title:null,_content:null,_mousePosition:{},_windowPosition:{},
1791_modalBackground:null,_SCROLL_WIDTH:21,_visible:!0,modalBackgroundZIndex:1299,modalZIndex:1800,zIndex:1E3,_touchEvents:{mousedown:a.jqx.mobile.getTouchEventName("touchstart"),mouseup:a.jqx.mobile.getTouchEventName("touchend"),mousemove:a.jqx.mobile.getTouchEventName("touchmove"),mouseenter:"mouseenter",mouseleave:"mou
1791seleave",click:a.jqx.mobile.getTouchEventName("touchstart")}};if(this===a.jqx._jqxWindow.prototype)return c;a.extend(!0,this,c);return c},createInstance:function(){this.host.initAnimate&&
1792this.host.initAnimate();this.host.attr("role","dialog");this.host.removeAttr("data-bind");this.host.appendTo(document.body);var c=this;(function(e){for(var f=0;f<e.length;f++){var g=e[f];c[g]&&0<=c[g].toString().indexOf("px")&&(c[g]=parseInt(c[g],10))}})("minWidth minHeight maxWidth maxHeight width height".split(" "));var d=function(){var e=parseInt(a(c.restricter).css("padding-top"),10),f=parseInt(a(c.restricter).css("padding-left"),10),g=parseInt(a(c.restricter).css("padding-bottom"),10),h=parseInt(a(c.restricter).css("padding-right"),
179310),k=a(c.restricter).coord();c.dragArea={left:f+k.left,top:e+k.top,width:1+h+a(c.restricter).width(),height:1+g+a(c.restricter).height()}};this.restricter&&d();this.restricter&&(this.addHandler(a(window),"resize."+this.element.id,function(){d()}),this.addHandler(a(window),"orientationchanged."+this.element.id,function(){d()}),this.addHandler(a(window),"orientationchange."+this.element.id,function(){d()}));this._isTouchDevice=a.jqx.mobile.isTouchDevice();this._validateProperties();this._createStructure();
1794this._refresh();this.autoOpen||(this.element.style.display="none");a.jqx.browser.msie&&this.host.addClass(this.toThemeProperty("jqx-noshadow"));this.isModal||this._fixWindowZIndex();this._setStartupSettings();this._positionWindow();this._raiseEvent(0);this.autoOpen&&(this._performLayout(),this.isModal&&this._fixWindowZIndex("modal-show"),this.initContent&&(this.initContent(),this._contentInitialized=!0),this._raiseEvent(7),this._raiseEvent(9))},refresh:function(){this._performLayout()},_setStartupSettings:function(){this.disabled&&
1795this.disable();this.collapsed&&(this.collapsed=!1,this.collapse(0));this.autoOpen||(this.hide(null,.001,!0),this._visible=!1);null!==this.title&&""!==this.title&&this.setTitle(this.title);null!==this.content&&""!==this.content&&this.setContent(this.content);this.title=this._headerContentWrapper.html();this.content=this._content.html()},_fixWindowZIndex:function(c){var d=a.data(document.body,"jqxwindows-list")||[],e=this.zIndex;if(this.isModal)d&&(d=this._removeFromArray(this.host,d),a.data(document.body,
1796"jqxwindows-list",d)),(d=a.data(document.body,"jqxwindows-modallist"))?"modal-show"==c?d.push(this.host):(c=d.indexOf(this.host),-1!=c&&d.splice(c,1)):"modal-show"==c?(d=[],d.push(this.host),a.data(document.body,"jqxwindows-modallist",d)):(a.data(document.body,"jqxwindows-modallist",[]),d=[]),e=this.modalZIndex,a.each(d,function(){if(this.data()&&this.data().jqxWindow){var g=this.data().jqxWindow.instance;g._modalBackground.style.zIndex=e;g.element.style.zIndex=e+1;e+=2}}),a.data(document.body,"jqxwindow-modal",
1797this.host);else{0>this._indexOf(this.host,d)&&d.push(this.host);a.data(document.body,"jqxwindows-list",d);if(1<d.length)if(c=d[d.length-2],"auto"==c.css("z-index"))e=this.zIndex+d.length+1;else{var f=this.zIndex;e=parseInt(c.css("z-index"),10)+1;e<f&&(e=f)}this.element.style.zIndex=e;this._sortByStyle("z-index",d)}},_validateProperties:function(){try{this._validateSize();this._validateAnimationProperties();this._validateInteractionProperties();this._validateModalProperties();if(!this.position)throw Error(this._invalidArgumentExceptions.invalidPosition);
1798if(isNaN(this.closeButtonSize)||0>parseInt(this.closeButtonSize,10))throw Error(this._invalidArgumentExceptions.invalidCloseButtonSize);if(isNaN(this.collapseButtonSize)||0>parseInt(this.collapseButtonSize,10))throw Error(this._invalidArgumentExceptions.invalidCollapseButtonSize);}catch(c){throw Error(c);}},_validateModalProperties:function(){if(0>this.modalOpacity||1<this.modalOpacity)throw Error(this._invalidArgumentExceptions.invalidModalOpacity);if(this.isModal&&!this._singleModalCheck())throw Error(this._invalidArgumentExceptions.invalidIsModal);
1799},_validateSize:function(){this._validateSizeLimits();if("auto"!==this.height&&isNaN(parseInt(this.height,10)))throw Error(this._invalidArgumentExceptions.invalidHeight);if("auto"!==this.width&&isNaN(parseInt(this.width,10)))throw Error(this._invalidArgumentExceptions.invalidWidth);"auto"!==this.height&&this.height<this.minHeight&&(this.height=this.minHeight);this.width<this.minWidth&&(this.width=this.minWidth);"auto"!==this.height&&this.height>this.maxHeight&&(this.height=this.maxHeight);this.width>
1800this.maxWidth&&(this.width=this.maxWidth);null!==this.dragArea&&this.dragArea&&(null!==this.dragArea.height&&this.host.height()>this.dragArea.height||parseInt(this.height,10))},_validateSizeLimits:function(){null==this.maxHeight&&(this.maxHeight=9999);null==this.minWidth&&(this.minWidth=0);null==this.maxWidth&&(this.maxWidth=9999);null==this.minHeight&&(this.minHeight=0);if(isNaN(parseInt(this.minHeight,10)))throw Error(this._invalidArgumentExceptions.invalidMinHeight);if(isNaN(parseInt(this.maxHeight,
180110)))throw Error(this._invalidArgumentExceptions.invalidMaxHeight);if(isNaN(parseInt(this.minWidth,10)))throw Error(this._invalidArgumentExceptions.invalidMinWidth);if(isNaN(parseInt(this.maxWidth,10)))throw Error(this._invalidArgumentExceptions.invalidMaxWidth);if(this.minHeight&&this.maxHeight&&parseInt(this.minHeight,10)>parseInt(this.maxHeight,10)&&this.maxHeight!=Number.MAX_VALUE)throw Error(this._invalidArgumentExceptions.invalidMinHeight);if(this.minWidth&&this.maxWidth&&parseInt(this.minWidth,
180210)>parseInt(this.maxWidth,10)&&this.maxWidth!=Number.MAX_VALUE)throw Error(this._invalidArgumentExceptions.invalidMinWidth);}
1802,_validateAnimationProperties:function(){if("fade"!==this.animationType&&"slide"!==this.animationType&&"combined"!==this.animationType&&"none"!==this.animationType)throw Error(this._invalidArgumentExceptions.invalidAnimationType);if(isNaN(parseInt(this.closeAnimationDuration,10))||0>this.closeAnimationDuration)throw Error(this._invalidArgumentExceptions.invalidCloseAnimationDuration);
1803if(isNaN(parseInt(this.showAnimationDuration,10))||0>this.showAnimationDuration)throw Error(this._invalidArgumentExceptions.invalidShowAnimationDuration);},_validateInteractionProperties:function(){if(0>parseInt(this.keyCode,10)||130<parseInt(this.keyCode,10)&&"esc"!==this.keyCode)throw Error(this._invalidArgumentExceptions.invalidKeyCode);if(null!==this.dragArea&&("undefined"===typeof this.dragArea.width||"undefined"===typeof this.dragArea.height||"undefined"===typeof this.dragArea.left||"undefined"===
1804typeof this.dragArea.top))throw Error(this._invalidArgumentExceptions.invalidDragArea);if(!this.dialogResult||!this.dialogResult.OK&&!this.dialogResult.Cancel&&!this.dialogResult.None)throw Error(this._invalidArgumentExceptions.invalidDialogResult);if("hide"!==this.closeButtonAction&&"close"!==this.closeButtonAction)throw Error(this._invalidArgumentExceptions.invalidCloseButtonAction);},_singleModalCheck:function(){for(var c=a.data(document.body,"jqxwindows-list")||[],d=c.length;d;)if(--d,0<a(c[d].attr("id")).length&&
1805a(c[d].attr("id")).jqxWindow("isModal"))return!1;return!0},_createStructure:function(){var c=this.host.children();if(1===c.length)this._content=c[0],this._header=document.createElement("div"),this._header.innerHTML=this.host.attr("caption"),this.element.insertBefore(this._header,this._content),this.host.attr("caption",""),this._header=a(this._header),this._content=a(this._content);else if(2===c.length)this._header=a(c[0]),this._content=a(c[1]);else throw Error("Invalid structure!");},_refresh:function(){this._render();
1806this._addStyles();this._performLayout();this._removeEventHandlers();this._addEventHandlers();this._initializeResize()},_render:function(){this._addHeaderWrapper();this._addCloseButton();this._addCollapseButton();this._removeModal();this._makeModal()},_addHeaderWrapper:function(){this._headerContentWrapper||(this._header[0].innerHTML='<div style="float:left;">'+this._header[0].innerHTML+"</div>",this._headerContentWrapper=a(this._header.children()[0]),null!==this.headerHeight&&this._header.height(this.headerHeight))},
1807_addCloseButton:function(){this._closeButton||(this._closeButtonWrapper=document.createElement("div"),this._closeButtonWrapper.className=this.toThemeProperty("jqx-window-close-button-background"),this._closeButton=document.createElement("div"),this._closeButton.className=this.toThemeProperty("jqx-window-close-button jqx-icon-close"),this._closeButton.style.width="100%",this._closeButton.style.height="100%",this._closeButtonWrapper.appendChild(this._closeButton),this._header[0].appendChild(this._closeButtonWrapper),
1808this._closeButtonWrapper=a(this._closeButtonWrapper),this._closeButton=a(this._closeButton))},_addCollapseButton:function(){this._collapseButton||(this._collapseButtonWrapper=document.createElement("div"),this._collapseButtonWrapper.className=this.toThemeProperty("jqx-window-collapse-button-background"),this._collapseButton=document.createElement("div"),this._collapseButton.className=this.toThemeProperty("jqx-window-collapse-button jqx-icon-arrow-up"),this._collapseButton.style.width="100%",this._collapseButton.style.height=
1809"100%",this._collapseButtonWrapper.appendChild(this._collapseButton),this._header[0].appendChild(this._collapseButtonWrapper),this._collapseButtonWrapper=a(this._collapseButtonWrapper),this._collapseButton=a(this._collapseButton))},_removeModal:function(){this.isModal||"object"!==typeof this._modalBackground||null===this._modalBackground||(a("."+this.toThemeProperty("jqx-window-modal")).remove(),this._modalBackground=null)},focus:function(){try{this.host.focus();var c=this;setTimeout(function(){c.host.focus()},
181010)}catch(d){}}
1810,_makeModal:function(){if(this.isModal&&!this._modalBackground){var c=a.data(document.body,"jqxwindows-list");c&&(this._removeFromArray(this.host,c),a.data(document.body,"jqxwindows-list",c));this._modalBackground=document.createElement("div");this._modalBackground.className=this.toThemeProperty("jqx-window-modal");this._setModalBackgroundStyles();document.body.appendChild(this._modalBackground);this.addHandler(this._modalBackground,this._getEvent("click"),function(){return!1});var d=
1811this;this.addHandler(this._modalBackground,"mouseup",function(e){d._stopResizing(d);e.preventDefault()});this.addHandler(this._modalBackground,"mousedown",function(e){var f=d._getTabbables();0<f.length&&(f[0].focus(),setTimeout(function(){f[0].focus()},100));e.preventDefault();return!1});this.addHandler(a(document),"keydown.window"+this.element.id,function(e){if(9===e.keyCode){var f=a.data(document.body,"jqxwindows-modallist");if(!(1<f.length&&f[f.length-1][0]!=d.element)){f=d._getTabbables();var g=
1812null,h=null;if(0!==d.element.offsetWidth&&0!==d.element.offsetHeight&&(0<f.length&&(g=f[0],h=f[f.length-1]),e.target!=d.element&&null!=g)){if(!d.element.contains(e.target)||e.target===h&&!e.shiftKey)return g.focus(),!1;if(e.target===g&&e.shiftKey)return h.focus(),!1}}}})}},_addStyles:function(){this.host.addClass(this.toThemeProperty("jqx-rc-all"));this.host.addClass(this.toThemeProperty("jqx-window"));this.host.addClass(this.toThemeProperty("jqx-popup"));a.jqx.browser.msie&&this.host.addClass(this.toThemeProperty("jqx-noshadow"));
1813this.host.addClass(this.toThemeProperty("jqx-widget"));this.host.addClass(this.toThemeProperty("jqx-widget-content"));this._header.addClass(this.toThemeProperty("jqx-window-header"));this._content.addClass(this.toThemeProperty("jqx-window-content"));this._header.addClass(this.toThemeProperty("jqx-widget-header"));this._content.addClass(this.toThemeProperty("jqx-widget-content"));this._header.addClass(this.toThemeProperty("jqx-disableselect"));this._header.addClass(this.toThemeProperty("jqx-rc-t"));
1814this._content.addClass(this.toThemeProperty("jqx-rc-b"));this.host.attr("tabindex")||(this.element.tabIndex=0,this._header[0].tabIndex=0,this._content[0].tabIndex=0);this.element.setAttribute("hideFocus","true");this.element.style.outline="none"},_performHeaderLayout:function(){this._handleHeaderButtons();this._header[0].style.position="relative";this.rtl?(this._headerContentWrapper[0].style.direction="rtl",this._headerContentWrapper[0].style["float"]="right"):(this._headerContentWrapper[0].style.direction=
1815"ltr",this._headerContentWrapper[0].style["float"]="left");this._performHeaderCloseButtonLayout();this._performHeaderCollapseButtonLayout();this._centerElement(this._headerContentWrapper,this._header,"y","margin");this.headerHeight&&(this._centerElement(this._closeButtonWrapper,this._header,"y","margin"),this._centerElement(this._collapseButtonWrapper,this._header,"y","margin"))},_handleHeaderButtons:function(){if(this._closeButtonWrapper){if(this.showCloseButton){this._closeButtonWrapper[0].style.visibility=
1816"visible";var c=this._toPx(this.closeButtonSize);this._closeButtonWrapper[0].style.width=c;this._closeButtonWrapper[0].style.height=c}else this._closeButtonWrapper[0].style.visibility="hidden";this.showCollapseButton?(this._collapseButtonWrapper[0].style.visibility="visible",c=this._toPx(this.collapseButtonSize),this._collapseButtonWrapper[0].style.width=c,this._collapseButtonWrapper[0].style.height=c):this._collapseButtonWrapper[0].style.visibility="hidden"}},_performHeaderCloseButtonLayout:function(){if(this._closeButtonWrapper){var c=
1817parseInt(this._header.css("padding-right"),10);isNaN(c)||(this._closeButtonWrapper.width(this._closeButton.width()),this.rtl?(this._closeButtonWrapper[0].style.marginRight="0px",this._closeButtonWrapper[0].style.marginLeft=this._toPx(c)):(this._closeButtonWrapper[0].style.marginRight=this._toPx(c),this._closeButtonWrapper[0].style.marginLeft="0px"));this._closeButtonWrapper[0].style.position="absolute";this.rtl?(this._closeButtonWrapper[0].style.right="",this._closeButtonWrapper[0].style.left="0px"):
1818(this._closeButtonWrapper[0].style.right="0px",this._closeButtonWrapper[0].style.left="")}},_performHeaderCollapseButtonLayout:function(){if(this._closeButtonWrapper){var c=parseInt(this._header.css("padding-right"),10);if(!isNaN(c)){var d=this._toPx(this.collapseButtonSize);this._collapseButtonWrapper[0].style.width=d;this._collapseButtonWrapper[0].style.height=d;this.rtl?(this._collapseButtonWrapper[0].style.marginRight="0px",this._collapseButtonWrapper[0].style.marginLeft=this._toPx(c)):(this._collapseButtonWrapper[0].style.marginRight=
1819this._toPx(c),this._collapseButtonWrapper[0].style.marginLeft="0px")}this._collapseButtonWrapper[0].style.position="absolute";c=this._toPx(this.showCloseButton?this._closeButton.outerWidth(!0):0);this.rtl?(this._collapseButtonWrapper[0].style.right="",this._collapseButtonWrapper[0].style.left=c):(this._collapseButtonWrapper[0].style.right=c,this._collapseButtonWrapper[0].style.left="");this._centerElement(this._collapseButton,a(this._collapseButton[0].parentElement),"y")}}
1819,_performWidgetLayout:function(){"auto"!==
1820this.width&&(this.width&&0<=this.width.toString().indexOf("%")?this.element.style.width=this.width:this.element.style.width=this._toPx(this.width));this.collapsed||("auto"!==this.height?this.height&&0<=this.height.toString().indexOf("%")?this.element.style.height=this.height:this.element.style.height=this._toPx(this.height):this.element.style.height=this.host.height()+"px",this.element.style.minHeight=this._toPx(this.minHeight));this._setChildrenLayout();var c=this._validateMinSize();this.element.style.maxHeight=
1821this._toPx(this.maxHeight);this.element.style.minWidth=this._toPx(this.minWidth);this.element.style.maxWidth=this._toPx(this.maxWidth);c||this._setChildrenLayout()},_setChildrenLayout:function(){this._header.width(this.host.width()-(this._header.outerWidth(!0)-this._header.width()));this._content.width(this.host.width()-(this._content.outerWidth(!0)-this._content.width()));this._content.height(this.host.height()-this._header.outerHeight(!0)-(this._content.outerHeight(!0)-this._content.height()))},
1822_validateMinSize:function(){var c=!0;this.minHeight<this._header.height()&&(this.minHeight=this._header.height(),c=!1);var d=a(this._header.children()[0]).outerWidth(),e=this._header.children()[1]?a(this._header.children()[1]).outerWidth():0;100>this.minWidth&&(this.minWidth=Math.min(d+e,100),c=!1);return c},_centerElement:function(c,d,e,f){"number"===typeof d.left&&"number"===typeof d.top&&"number"===typeof d.height&&"number"===typeof d.width?this._centerElementInArea(c,d,e):this._centerElementInParent(c,
1823d,e,f)},_centerElementInParent:function(c,d,e,f){var g="none"===c.css("display");e=e.toLowerCase();if(f){var h=f+"Top";f+="Left"}else h="top",f="left";if(0<=e.indexOf("y")){g&&(c[0].style.display="block");var k=c.outerHeight(!0);g&&(c[0].style.display="none");var l=d.height();c[0].style[h]=Math.max(0,l-k)/2+"px"}0<=e.indexOf("x")&&(g&&(c[0].style.display="block"),e=c.outerWidth(!0),g&&(c[0].style.display="none"),d=d.width(),c[0].style[f]=Math.max(0,d-e)/2+"px")},_centerElementInArea:function(c,d,
1824e){e=e.toLowerCase();if(0<=e.indexOf("y")){var f=c.outerHeight(!0);c[0].style.top=(d.height-f)/2+d.top+"px"}0<=e.indexOf("x")&&(e=c.outerWidth(!0),c[0].style.left=(d.width-e)/2+d.left+"px")},_removeEventHandlers:function(){this.removeHandler(this._header,this._getEvent("mousedown"));this.removeHandler(this._header,this._getEvent("mousemove"));this.removeHandler(this._header,"focus");this.removeHandler(a(document),this._getEvent("mousemove")+"."+this.host.attr("id"));this.removeHandler(a(document),
1825this._getEvent("mouseup")+"."+this.host.attr("id"));this.removeHandler(this.host,"keydown");this.removeHandler(this._closeButton,this._getEvent("click"));this.removeHandler(this._closeButton,this._getEvent("mouseenter"));this.removeHandler(this._closeButton,this._getEvent("mouseleave"));this.removeHandler(this._collapseButton,this._getEvent("click"));this.removeHandler(this._collapseButton,this._getEvent("mouseenter"));this.removeHandler(this._collapseButton,this._getEvent("mouseleave"));this.removeHandler(this.host,
1826this._getEvent("mousedown"));this.okButton&&this.removeHandler(a(this.okButton),this._getEvent("click"),this._setDialogResultHandler);this.cancelButton&&this.removeHandler(a(this.cancelButton),this._getEvent("click"),this._setDialogResultHandler);this.removeHandler(this._header,this._getEvent("mouseenter"));this.removeHandler(this._header,this._getEvent("mouseleave"));this.removeHandler(this.host,"resizing",this._windowResizeHandler)},_removeFromArray:function(c,d){return 0<=this._indexOf(c,d)?d.splice(this._indexOf(c,
1827d),1):d},_sortByStyle:function(c,d){for(var e=0;e<d.length;e++)for(var f=d.length-1;f>e;f--){var g=d[f],h=d[f-1];parseInt(g.css(c),10)<parseInt(h.css(c),10)&&(d[f]=h,d[f-1]=g)}},_initializeResize:function(){this.resizable&&this.initResize({target:this.host,alsoResize:this._content,maxWidth:this.maxWidth,minWidth:this.minWidth,maxHeight:this.maxHeight,minHeight:this.minHeight,indicatorSize:10,resizeParent:this.dragArea})},_removeResize:function(){this.removeResize()},_getEvent:function(c){return this._isTouchDevice?
1828this._touchEvents[c]:c},_addEventHandlers:function(){this._addDragDropHandlers();this._addCloseHandlers();this._addCollapseHandlers();this._addFocusHandlers();this._documentResizeHandlers();this._closeButtonHover();this._collapseButtonHover();this._addDialogButtonsHandlers();this._addHeaderHoverEffect();this._addResizeHandlers();var c=this;this.addHandler(this._header,this._getEvent("mousemove"),function(){c._addHeaderCursorHandlers(c)})},_addResizeHandlers:function(){var c=this;c.addHandler(c.host,
1829"resizing",c._windowResizeHandler,{self:c});
1829this.addHandler(a(window),"orientationchanged."+this.element.id,function(){c._performLayout()});this.addHandler(a(window),"orientationchange."+this.element.id,function(){c._performLayout()})},_windowResizeHandler:function(c){var d=c.data.self;d._header.width(d.host.width()-(d._header.outerWidth(!0)-d._header.width()));if(d.width&&0<=d.width.toString().indexOf("%")){var e=a(document.body).width()/100;d.width=1/e*c.args.width+"%"}else d.width=c.args.width;
1830d.height&&0<=d.height.toString().indexOf("%")?(e=a(document.body).height()/100,d.height=1/e*c.args.height+"%"):d.height=c.args.height},_addHeaderHoverEffect:function(){var c=this;this.addHandler(this._header,this._getEvent("mouseenter"),function(){a(this).addClass(c.toThemeProperty("jqx-window-header-hover"))});this.addHandler(this._header,this._getEvent("mouseleave"),function(){a(this).removeClass(c.toThemeProperty("jqx-window-header-hover"))})},_addDialogButtonsHandlers:function(){this.okButton&&
1831this.addHandler(a(this.okButton),this._getEvent("click"),this._setDialogResultHandler,{self:this,result:"ok"});this.cancelButton&&this.addHandler(a(this.cancelButton),this._getEvent("click"),this._setDialogResultHandler,{self:this,result:"cancel"})},_documentResizeHandlers:function(){var c=this;this.isModal&&this.addHandler(a(window),"resize.window"+this.element.id,function(){if("object"===typeof c._modalBackground&&null!==c._modalBackground){c.isOpen()&&(c._modalBackground.style.display="none");
1832if(c.restricter)c._modalBackground.style.left=c._toPx(c.dragArea.left),c._modalBackground.style.top=c._toPx(c.dragArea.top),c._modalBackground.style.width=c._toPx(c.dragArea.width),c._modalBackground.style.height=c._toPx(c.dragArea.height);else{var d=c._getDocumentSize();c._modalBackground.style.width=d.width+"px";c._modalBackground.style.height=d.height+"px"}c.isOpen()&&(c._modalBackground.style.display="block")}})},_setDialogResultHandler:function(c){var d=c.data.self;d._setDialogResult(c.data.result);
1833d.closeWindow()},_setDialogResult:function(c){this.dialogResult.OK=!1;this.dialogResult.None=!1;this.dialogResult.Cancel=!1;c=c.toLowerCase();switch(c){case "ok":this.dialogResult.OK=!0;break;case "cancel":this.dialogResult.Cancel=!0;break;default:this.dialogResult.None=!0}},_getDocumentSize:function(){var c=a.jqx.browser.msie&&9>a.jqx.browser.version,d=c?4:0,e=d;document.body.scrollHeight>document.body.clientHeight&&c&&(d=this._SCROLL_WIDTH);document.body.scrollWidth>document.body.clientWidth&&c&&
1834(e=this._SCROLL_WIDTH);return{width:a(document).width()-d,height:a(document).height()-e}},_closeButtonHover:function(){var c=this;this.addHandler(this._closeButton,this._getEvent("mouseenter"),function(){c._closeButton.addClass(c.toThemeProperty("jqx-window-close-button-hover"))});this.addHandler(this._closeButton,this._getEvent("mouseleave"),function(){c._closeButton.removeClass(c.toThemeProperty("jqx-window-close-button-hover"))})},_collapseButtonHover:function(){var c=this;this.addHandler(this._collapseButton,
1835this._getEvent("mouseenter"),function(){c._collapseButton.addClass(c.toThemeProperty("jqx-window-collapse-button-hover"))});this.addHandler(this._collapseButton,this._getEvent("mouseleave"),function(){c._collapseButton.removeClass(c.toThemeProperty("jqx-window-collapse-button-hover"))})},_setModalBackgroundStyles:function(){if(this.isModal){var c=this._getDocumentSize();a.jqx.browser.msie&&9>a.jqx.browser.version?this._modalBackground.style.filter="alpha(opacity="+100*this.modalOpacity+")":this._modalBackground.style.opacity=
1836this.modalOpacity;this._modalBackground.style.position="absolute";this._modalBackground.style.top="0px";this._modalBackground.style.left="0px";this._modalBackground.style.width=c.width;this._modalBackground.style.height=c.height;this._modalBackground.style.zIndex=this.modalBackgroundZIndex;this.autoOpen||(this._modalBackground.style.display="none")}},_addFocusHandlers:function(){var c=this;this.addHandler(this.host,this._getEvent("mousedown"),function(){c.isModal||c.bringToFront()})},_indexOf:function(c,
1837d){for(var e=0;e<d.length;e++)if(d[e][0]===c[0])return e;return-1},_addCloseHandlers:function(){var c=this;this.addHandler(this._closeButton,this._getEvent("click"),function(d){return c._closeWindow(d)});"none"!==this.keyboardCloseKey&&"number"!==typeof this.keyboardCloseKey&&"esc"===this.keyboardCloseKey.toLowerCase()&&(this.keyboardCloseKey=27);this.addHandler(this.host,"keydown",function(d){d.keyCode===c.keyboardCloseKey&&null!=c.keyboardCloseKey&&"none"!=c.keyboardCloseKey?c._closeWindow(d):c._handleKeys(d)},
1838{self:this});this.addHandler(this.host,"keyup",function(){if(c.keyboardNavigation&&c._moved){var d=c.host.coord(),e=d.left;d=d.top;c._raiseEvent(3,e,d,e,d);c._moved=!1}})},_handleKeys:function(c){if(this.keyboardNavigation&&this._headerFocused&&!a(document.activeElement).ischildof(this._content)){var d=c.ctrlKey,e=c.keyCode,f=this.host.coord(),g=f.left;f=f.top;var h=this._getDraggingArea(),k=this.host.width(),l=this.host.height(),m=!0;switch(e){case 37:d?this.resizable&&this.resize(k-10,l):this.draggable&&
18390<=g-10&&this.move(g-10,f);m=!1;break;case 38:d?this.resizable&&this.resize(k,l-10):this.draggable&&0<=f-10&&this.move(g,f-10);m=!1;break;case 39:d?this.resizable&&this.resize(k+10,l):this.draggable&&g+k+10<=h.width&&this.move(g+10,f);m=!1;break;case 40:d?this.resizable&&this.resize(k,l+10):this.draggable&&f+l+10<=h.height&&this.move(g,f+10),m=!1}m||(c.preventDefault&&c.preventDefault(),c.stopPropagation&&c.stopPropagation());return m}},_addCollapseHandlers:function(){var c=this;this.addHandler(this._collapseButton,
1840this._getEvent("click"),function(){c.collapsed?c.expand():c.collapse()})},_closeWindow:function(){this.closeWindow();return!1},_addHeaderCursorHandlers:function(c){c.resizeArea&&c.resizable&&!c.collapsed?c._header[0].style.cursor=c._resizeWrapper.style.cursor:c.draggable?c._header[0].style.cursor="move":(c._header[0].style.cursor="default",c._resizeWrapper&&(c._resizeWrapper.style.cursor="default"))},_addDragDropHandlers:function(){if(this.draggable){var c=this;this.addHandler(this.host,"focus",function(){c._headerFocused=
1841!0});this.addHandler(this.host,"blur",function(){c._headerFocused=!1});this.addHandler(this._header,"focus",function(){c._headerFocused=!0;return!1});this.addHandler(this._header,this._getEvent("mousedown"),function(e,f,g){f&&(e.pageX=f);g&&(e.pageY=g);c._headerMouseDownHandler(c,e);return!0});this.addHandler(this._header,"dragstart",function(e){e.preventDefault&&e.preventDefault();return!1});this.addHandler(this._header,this._getEvent("mousemove"),function(e){return c._headerMouseMoveHandler(c,e)});
1842this.addHandler(a(document),this._getEvent("mousemove")+"."+this.host.attr("id"),function(e){return c._dragHandler(c,e)});this.addHandler(a(document),this._getEvent("mouseup")+"."+this.host.attr("id"),function(e){return c._dropHandler(c,e)});try{if(""!==document.referrer||window.frameElement){var d=null;null!=window.top&&window.top!=window.self&&window.parent&&document.referrer&&(d=document.referrer);d&&-1!=d.indexOf(document.location.host)&&(d=function(e){c._dropHandler(c,e)},window.top.document.addEventListener?
1843window.top.document.addEventListener("mouseup",d,!1):window.top.document.attachEvent&&window.top.document.attachEvent("onmouseup",d))}}catch(e){}}},_headerMouseDownHandler:function(c,d){c.isModal||c.bringToFront();null==c._resizeDirection&&(d=a.jqx.position(d),c._mousePosition.x=d.left,c._mousePosition.y=d.top,c._mouseDown=!0,c._isDragging=!1)},_headerMouseMoveHandler:function(c,d){if(c._mouseDown&&!c._isDragging){a.jqx.mobile.getTouches(d);var e=a.jqx.position(d);var f=e.left;e=e.top;if(f+3<c._mousePosition.x||
1844f-3>c._mousePosition.x||e+3<c._mousePosition.y||e-3>c._mousePosition.y)c._isDragging=!0,c._mousePosition={x:f,y:e},c._windowPosition={x:c.host.coord().left,y:c.host.coord().top},a(document.body).addClass(c.toThemeProperty("jqx-disableselect"));return c._isTouchDevice?(d.preventDefault(),!0):!1}return c._isDragging?c._isTouchDevice?(d.preventDefault(),!0):!1:!0},_dropHandler:function(c,d){var e=!0;if(c._isDragging&&!c.isResizing&&!c._resizeDirection){e=parseInt(c.host.css("left"),10);var f=parseInt(c.host.css("top"),
184510),g=c._isTouchDevice?0:d.pageX,h=c._isTouchDevice?0:d.pageY;c.enableResize=c._enableResizeBackup;c._enableResizeBackup="undefined";c._raiseEvent(3,e,f,g,h);e=!1;"undefined"!=d.preventDefault&&d.preventDefault();null!=d.originalEvent&&(d.originalEvent.mouseHandled=!0);"undefined"!=d.stopPropagation&&d.stopPropagation()}c._isDragging=!1;c._mouseDown=!1;a(document.body).removeClass(c.toThemeProperty("jqx-disableselect"));return e},_dragHandler:function(c,d){if(c._isDragging&&!c.isResizing&&!c._resizeDirection){var e=
1846c._isTouchDevice?d.originalEvent.which:d.which;"undefined"===typeof c._enableResizeBackup&&(c._enableResizeBackup=c.enableResize);c.enableResize=!1;if(0===e&&a.jqx.browser.msie&&8>a.jqx.browser.version)return c._dropHandler(c,d);e=a.jqx.position(d);c.move(c._windowPosition.x+(e.left-c._mousePosition.x),c._windowPosition.y+(e.top-c._mousePosition.y),d);d.preventDefault();return!1}return!0},_validateCoordinates:function(c,d,e,f){var g=this._getDraggingArea();c=c<g.left?g.left:c;d=d<g.top?g.top:d;var h=
1847this.host.outerWidth(!0),k=this.host.outerHeight(!0);c+h>
1847=g.width+g.left-2*f&&(c=g.width+g.left-h-f);d+k>=g.height+g.top-e&&(d=g.height+g.top-k-e);return{x:c,y:d}},_performLayout:function(){this._performHeaderLayout();this._performWidgetLayout()},_parseDragAreaAttributes:function(){null!==this.dragArea&&(this.dragArea.height=parseInt(this.dragArea.height,10),this.dragArea.width=parseInt(this.dragArea.width,10),this.dragArea.top=parseInt(this.dragArea.top,10),this.dragArea.left=parseInt(this.dragArea.left,
184810))},_positionWindow:function(){this._parseDragAreaAttributes();if(this.position instanceof Array&&2===this.position.length&&"number"===typeof this.position[0]&&"number"===typeof this.position[1])this.element.style.left=this._toPx(this.position[0]),this.element.style.top=this._toPx(this.position[1]);else if(this.position instanceof Object)if(this.position.left)this.host.offset(this.position);else if(void 0!==this.position.x&&void 0!==this.position.y)this.element.style.left=this._toPx(this.position.x),
1849this.element.style.top=this._toPx(this.position.y);else{if(this.position.center){this._centerElement(this.host,this.position.center,"xy");var c=this.position.center.coord(),d=parseInt(this.host.css("left"),10),e=parseInt(this.host.css("top"),10);this.element.style.left=this._toPx(d+c.left);this.element.style.top=this._toPx(e+c.top)}}else this._positionFromLiteral()},_getDraggingArea:function(){var c={};c.left=this.dragArea&&this.dragArea.left?this.dragArea.left:0;c.top=this.dragArea&&this.dragArea.top?
1850this.dragArea.top:0;c.width=this.dragArea&&this.dragArea.width?this.dragArea.width:this._getDocumentSize().width;c.height=this.dragArea&&this.dragArea.height?this.dragArea.height:this._getDocumentSize().height;return c},_positionFromLiteral:function(){this.position instanceof Array||(this.position=this.position.split(","));for(var c=this.position.length,d=this._getDraggingArea();c;)switch(--c,this.position[c]=this.position[c].replace(/ /g,""),this.position[c]){case "top":this.element.style.top=this._toPx(d.top);
1851break;case "left":this.element.style.left=this._toPx(d.left);break;case "bottom":this.element.style.top=this._toPx(d.height-this.host.height()+d.top);break;case "right":this.element.style.left=this._toPx(d.left+d.width-this.host.width());break;default:this.dragArea||(d=a(window)),this._centerElement(this.host,d,"xy")}},_raiseEvent:function(c,d,e,f,g){var h=this._events[c],k=a.Event(h),l={};if(2===c||3===c)l.x=d,l.y=e,l.pageX=f,l.pageY=g;if("closed"===h||"close"===h)l.dialogResult=this.dialogResult;
1852k.args=l;return this.host.trigger(k)},destroy:function(){this.removeHandler(a(window),"resize.window"+this.element.id);this._removeEventHandlers();this._destroy()},_destroy:function(){this.isModal&&(null!==this._modalBackground&&a(this._modalBackground).remove(),this.host.jqxWindow({isModal:!1}));this.restricter&&(this.removeHandler(a(window),"resize."+this.element.id),this.removeHandler(a(window),"orientationchanged."+this.element.id),this.removeHandler(a(window),"orientationchange."+this.element.id));
1853this.host.remove();null!==this._modalBackground&&a(this._modalBackground).remove()},_toClose:function(c,d){return c&&d[0]===this.element||d[0]!==this.element&&"object"===typeof d[0]},propertyChangedHandler:function(c,d,e,f){this._validateProperties();switch(d){case "rtl":this._performLayout();break;case "dragArea":this._positionWindow();break;case "collapseButtonSize":this._performLayout();break;case "closeButtonSize":this._performLayout();break;case "isModal":this._refresh();this._fixWindowZIndex();
1854if(!1===f){c=a.data(document.body,"jqxwindows-modallist");var g=[];for(d=0;d<c.length;d++)c[d][0]!==this.element&&g.push(c[d])}a.data(document.body,"jqxwindows-modallist",g);break;case "keyboardCloseKey":this._removeEventHandlers();this._addEventHandlers();break;case "disabled":f?this.disable():(this.disabled=!0,this.enable());break;case "showCloseButton":case "showCollapseButton":this._performLayout();break;case "height":this._performLayout();break;case "width":this._performLayout();break;case "title":this.setTitle(f);
1855this.title=f;break;case "content":this.setContent(f);break;case "draggable":this._removeEventHandlers();this._addEventHandlers();this._removeResize();this._initializeResize();break;case "resizable":(this.enableResize=f)?this._initializeResize():this._removeResize();break;case "position":this._positionWindow();break;
1855case "modalOpacity":this._setModalBackgroundStyles();break;case "okButton":f?this._addDialogButtonsHandlers():this.removeHandler(this.okButton);break;case "cancelButton":f?this._addDialogButtonsHandlers():
1856this.removeHandler(this.cancelButton);break;case "collapsed":f?e||(this.collapsed=!1,this.collapse(0)):e&&(this.collapsed=!0,this.expand(0));break;case "theme":a.jqx.utilities.setTheme(e,f,this.host);break;case "maxWidth":case "maxHeight":case "minWidth":case "minHeight":c._performLayout(),c._removeResize(),c._initializeResize()}},collapse:function(c){if(!this.collapsed&&!0!==this._animationInProgress&&"none"!=this.host.css("display")){var d=this,e=this._header.outerHeight(!0),f=parseInt(this._header.css("border-bottom-width"),
185710),g=parseInt(this._header.css("margin-bottom"),10);c=isNaN(parseInt(c,10))?this.collapseAnimationDuration:c;isNaN(f)||(e-=2*f);isNaN(g)||(e+=g);this._heightBeforeCollapse=this.host.height();this._minHeightBeforeCollapse=this.host.css("min-height");this.element.style.minHeight=this._toPx(e);d._animationInProgress=!0;this.host.animate({height:e},{duration:c,complete:function(){d._animationInProgress=!1;d.collapsed=!0;d._collapseButton.addClass(d.toThemeProperty("jqx-window-collapse-button-collapsed"));
1858d._collapseButton.addClass(d.toThemeProperty("jqx-icon-arrow-down"));d._content[0].style.display="none";d._raiseEvent(5);d._raiseEvent(9);a.jqx.aria(d,"aria-expanded",!1)}})}},expand:function(c){if(this.collapsed&&!0!==this._animationInProgress){var d=this;c=isNaN(parseInt(c,10))?this.collapseAnimationDuration:c;d._animationInProgress=!0;this.host.animate({height:this._heightBeforeCollapse},{duration:c,complete:function(){d._animationInProgress=!1;d.collapsed=!1;d.element.style.minHeight=d._toPx(d._minHeightBeforeCollapse);
1859d._collapseButton.removeClass(d.toThemeProperty("jqx-window-collapse-button-collapsed"));d._collapseButton.removeClass(d.toThemeProperty("jqx-icon-arrow-down"));d._content[0].style.display="block";d._raiseEvent(6);d._performWidgetLayout();d._raiseEvent(9);a.jqx.aria(d,"aria-expanded",!0)}})}},closeAll:function(c){c=!0;for(var d=a.data(document.body,"jqxwindows-list"),e=d.length,f=a.data(document.body,"jqxwindow-modal")||[];e;)--e,this._toClose(c,d[e])&&(d[e].jqxWindow("closeWindow","close"),d.splice(e,
18601));this._toClose(c,f)&&(f.jqxWindow("closeWindow","close"),a.data(document.body,"jqxwindow-modal",[]));a.data(document.body,"jqxwindows-list",d)},setTitle:function(c){if("string"===typeof c)this._headerContentWrapper.html(c);else if("object"===typeof c)try{this._headerContentWrapper[0].innerHTML="",c instanceof HTMLElement?this._headerContentWrapper[0].appendChild(c):c.appendTo&&c.appendTo(this._headerContentWrapper)}catch(d){throw Error(d);}this.title=c;this._performLayout()},setContent:function(c){this._contentInitialized=
1861!1;for(var d=this._content,e=!1;!e;)d[0].style.width="auto",d[0].style.height="auto",d.hasClass("jqx-window")?e=!0:d=a(d[0].parentNode);if(a.isArray(c))for(d=0;d<c.length;d++)c[d].appendTo(this._content);else if("string"===typeof c)a(this._content[0]).html(c);else if("object"===typeof c)try{this._content[0].innerHTML="",c instanceof HTMLElement?this._content[0].appendChild(c):c.appendTo&&c.appendTo(this._content)}catch(f){throw Error(f);}this.content=c;this._performLayout()},disable:function(){this.disabled=
1862!0;this._removeEventHandlers();this._header.addClass(this.toThemeProperty("jqx-window-header-disabled"));this._closeButton.addClass(this.toThemeProperty("jqx-window-close-button-disabled"));this._collapseButton.addClass(this.toThemeProperty("jqx-window-collapse-button-disabled"));this._content.addClass(this.toThemeProperty("jqx-window-content-disabled"));this.host.addClass(this.toThemeProperty("jqx-window-disabled"));this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled"));this._removeResize()},
1863enable:function(){this.disabled&&(this._addEventHandlers(),this._header.removeClass(this.toThemeProperty("jqx-window-header-disabled")),this._content.removeClass(this.toThemeProperty("jqx-window-content-disabled")),this._closeButton.removeClass(this.toThemeProperty("jqx-window-close-button-disabled")),this._collapseButton.removeClass(this.toThemeProperty("jqx-window-collapse-button-disabled")),this.host.removeClass(this.toThemeProperty("jqx-window-disabled")),this.host.removeClass(this.toThemeProperty("jqx-fill-state-disabled")),
1864this.disabled=!1,this._initializeResize())},isOpen:function(){return this._visible},closeWindow:function(c){var d=this;c="undefined"===typeof c?this.closeButtonAction:c;this.hide(function(){"close"===c&&d._destroy()})},bringToFront:function(){var c=a.data(document.body,"jqxwindows-list");if(this.isModal)a.data(document.body,"jqxwindows-modallist"),this._fixWindowZIndex("modal-hide"),this._fixWindowZIndex("modal-show");else{for(var d=parseInt(c[c.length-1].css("z-index"),10),e=this._indexOf(this.host,
1865c),f=c.length-1;f>e;--f){var g=parseInt(c[f].css("z-index"),10)-1;c[f][0].style.zIndex=g}this.element.style.zIndex=d;this._sortByStyle("z-index",c)}},hide:function(c,d,e){var f=this;if(!this.closing||!1!==this.closing()){d=d||this.closeAnimationDuration;switch(this.animationType){case "none":this.element.style.display="none";break;case "fade":f._animationInProgress=!0;this.host.fadeOut({duration:d,callback:function(){f._animationInProgress=!1;c instanceof Function&&c()}});break;case "slide":f._animationInProgress=
1866!0;this.host.slideUp({duration:d,callback:function(){f._animationInProgress=!1;c instanceof Function&&c()}});break;case "combined":f._animationInProgress=!0,this.host.animate({opacity:0,width:"0px",height:"0px"},{duration:d,complete:function(){f._animationInProgress=!1;f.element.style.display="none";c instanceof Function&&c()}})}this._visible=!1;
1866this.isModal&&(a(this._modalBackground).hide(),this._fixWindowZIndex("modal-hide"));!0!==e&&(this._raiseEvent(1),this._raiseEvent(8))}},open:function(c,d){this.show(c,
1867d)},close:function(c,d,e){this.hide(c,d,e)},show:function(c,d){var e=this;this._setDialogResult("none");d=d||this.showAnimationDuration;switch(this.animationType){case "none":this.element.style.display="block";break;case "fade":e._animationInProgress=!0;this.host.fadeIn({duration:d,complete:function(){e._animationInProgress=!1;c instanceof Function&&c()}});break;case "slide":e._animationInProgress=!0;this.host.slideDown({duration:d,callback:function(){e._animationInProgress=!1;c instanceof Function&&
1868c()}});break;case "combined":this.element.style.display="block";var f=e.host.width(),g=e.host.height();this.element.style.minWidth="0px";this.element.style.minHeight="0px";this.element.style.opacity=0;this.element.style.width="0px";this.element.style.height="0px";e._animationInProgress=!0;this.host.animate({opacity:1,width:f+"px",height:g+"px"},{duration:d,complete:function(){e._animationInProgress=!1;e._performLayout();c instanceof Function&&c()}})}this.isModal&&(a(this._modalBackground).show(),
1869this._fixWindowZIndex("modal-show"));var h=this;this._visible||(150<d&&"none"!=this.animationType?setTimeout(function(){!h._contentInitialized&&h.initContent&&(h.initContent(),h._contentInitialized=!0);h._raiseEvent(7);h._raiseEvent(9)},d-150):(!h._contentInitialized&&h.initContent&&(h.initContent(),h._contentInitialized=!0),this._raiseEvent(7),h._raiseEvent(9)));this._visible=!0;"combined"!==e.animationType&&this._performLayout();this.autoFocus&&(h._isTouchDevice||h._content[0].focus(),setTimeout(function(){h._isTouchDevice||
1870h._content[0].focus()},100))},_getTabbables:function(){var c=a.jqx.browser.msie&&9>a.jqx.browser.version?this._content.find("*"):this._content[0].querySelectorAll("*");var d=[];a.each(c,function(){var e=this.getAttribute("tabindex"),f=null===e;if(e=f||0<=e)f=!f,e=this.nodeName.toLowerCase(),"area"===e?(f=this.parentNode,e=f.name,this.href&&e&&"map"===f.nodeName.toLowerCase()?(f=a("img[usemap=#"+e+"]")[0],e=!!f&&b(f)):e=!1):e=(/input|select|textarea|button|object/.test(e)?!this.disabled:"a"==e?this.href||
1871f:f)&&b(this);e&&(d[d.length]=this)});return d},move:function(c,d,e,f){var g=0,h=0;c=parseInt(c,10);d=parseInt(d,10);a.jqx.browser.msie&&(a(window).width()>a(document).width()&&!this.dragArea&&(h=this._SCROLL_WIDTH),a(window).height()<a(document).height()&&document.documentElement.clientWidth>document.documentElement.scrollWidth&&!this.dragArea&&(g=this._SCROLL_WIDTH));g=this._validateCoordinates(c,d,h,g);if(parseInt(this.host.css("left"),10)!==g.x||parseInt(this.host.css("top"),10)!==g.y){if(e){e=
1872a.jqx.position(e);var k=e.left;var l=e.top}void 0===k&&(k=c);void 0===l&&(l=d);!1!==f&&this._raiseEvent(2,g.x,g.y,k,l)}this.element.style.left=g.x+"px";this.element.style.top=g.y+"px";this._moved=!0},_toPx:function(c){return"number"===typeof c?c+"px":c}})})(jqxBaseFramework);
1873(function(a){var b=function(c){return{resizeConfig:function(){this.resizeTarget=null;this.resizeIndicatorSize=5;this.resizeTargetChildren=null;this.resizeArea=this.isResizing=!1;this.minWidth=1;this.maxWidth=100;this.minHeight=1;this.maxHeight=100;this.resizeParent=null;this.enableResize=!0;this._resizeEvents=["resizing","resized","resize"];this._resizeMouseDown=!1;this._resizeCurrentMode=null;this._mouseResizePosition={};this._resizeMethods=null;this._SCROLL_WIDTH=21},_resizeExceptions:{invalidTarget:"Invalid target!",
1874invalidMinHeight:"Invalid minimal height!",invalidMaxHeight:"Invalid maximum height!",invalidMinWidth:"Invalid minimum width!",invalidMaxWidth:"Invalid maximum width!",invalidIndicatorSize:"Invalid indicator size!",invalidSize:"Invalid size!"},removeResize:function(){if(this.resizeTarget){var d=c(this.resizeTarget.children(".jqx-resize"));d.detach();var e=d.children();this._removeResizeEventListeners();for(var f=0;f<e.length;f+=1)c(e[f]).detach(),this.resizeTarget.append(e[f]);d.remove()}this._resizeDirection=
1875null},initResize:function(d){this.resizeConfig();this.resizeTarget=c(d.target);this.resizeIndicatorSize=d.indicatorSize||10;this.maxWidth=d.maxWidth||100;this.minWidth=d.minWidth||1;this.maxHeight=d.maxHeight||100;this.minHeight=d.minHeight||1;this.resizeParent=d.resizeParent;this._parseResizeParentProperties();
1875this._validateResizeProperties();this._validateResizeTargetDimensions();this._getChildren(this.resizeTarget.maxWidth,this.resizeTarget.minWidth,this.resizeTarget.maxHeight,this.resizeTarget.minHeight,
1876d.alsoResize);this._refreshResize();this._cursorBackup=this.resizeTarget.css("cursor");"auto"===this._cursorBackup&&(this._cursorBackup="default")},_validateResizeTargetDimensions:function(){this.resizeTarget.maxWidth=this.maxWidth;this.resizeTarget.minWidth=3*this.resizeIndicatorSize>this.minWidth?3*this.resizeIndicatorSize:this.minWidth;this.resizeTarget.maxHeight=this.maxHeight;this.resizeTarget.minHeight=3*this.resizeIndicatorSize>this.minHeight?3*this.resizeIndicatorSize:this.minHeight},_parseResizeParentProperties:function(){this.resizeParent&&
1877(this.resizeParent.left=parseInt(this.resizeParent.left,10),this.resizeParent.top=parseInt(this.resizeParent.top,10),this.resizeParent.width=parseInt(this.resizeParent.width,10),this.resizeParent.height=parseInt(this.resizeParent.height,10))},_getChildren:function(d,e,f,g,h){this.resizeTargetChildren=c(h);this.resizeTargetChildren=this.resizeTargetChildren.toArray();for(d=this.resizeTargetChildren.length;d;)--d,this.resizeTargetChildren[d]=c(this.resizeTargetChildren[d])},_refreshResize:function(){this._renderResize();
1878this._performResizeLayout();this._removeResizeEventListeners();this._addResizeEventHandlers()},_renderResize:function(){if(!(void 0!==this._resizeWrapper&&0<c(this._resizeWrapper).parents().length)){var d=document.createElement("div");d.className="jqx-resize jqx-rc-all";d.style.zIndex=8E3;d.appendChild(this._header[0]);d.appendChild(this._content[0]);this.resizeTarget[0].appendChild(d);this._resizeWrapper=d}},_performResizeLayout:function(){this._resizeWrapper.style.height=this.resizeTarget.height()+
1879"px";this._resizeWrapper.style.width=this.resizeTarget.width()+"px"},_removeResizeEventListeners:function(){var d=this.resizeTarget.attr("id");this.removeHandler(this._resizeWrapper,"mousemove.resize"+d);this.removeHandler(this._resizeWrapper,"mousedown.resize"+d);this.removeHandler(c(document),"mousemove.resize"+d);this.removeHandler(c(document),"mouseup.resize"+d)},_addResizeEventHandlers:function(){var d=this.resizeTarget.attr("id"),e=this;e._isTouchDevice?(this.addHandler(this._resizeWrapper,
1880"touchmove.resize."+d,function(f){e._resizeCursorChangeHandler(e,f)}),this.addHandler(this._resizeWrapper,"touchstart.resize."+d,function(f){e._resizeCursorChangeHandler(e,f);e._resizeMouseDownHandler(e,f)}),this.addHandler(c(document),"touchmove.resize."+d,function(f){return e._resizeHandler(e,f)}),this.addHandler(c(document),"touchend.resize."+d,function(f){e._stopResizing(e,f)})):(this.addHandler(this._resizeWrapper,"mousemove.resize."+d,function(f){e._resizeCursorChangeHandler(e,f)}),this.addHandler(this._resizeWrapper,
1881"mousedown.resize."+d,function(f){e._resizeMouseDownHandler(e,f)}),this.addHandler(c(document),"mousemove.resize."+d,function(f){return e._resizeHandler(e,f)}),this.addHandler(c(document),"mouseup.resize."+d,function(f){e._stopResizing(e,f)}));try{if(""!==document.referrer||window.frameElement)d=function(f){e._stopResizing(e,f)},window.top.document.addEventListener?window.top.document.addEventListener("mouseup",d,!1):window.top.document.attachEvent&&window.top.document.attachEvent("onmouseup",d)}catch(f){}},
1882_stopResizing:function(d){d.enableResize&&(d.isResizing&&d._raiseResizeEvent(1),d._resizeMouseDown=!1,d.isResizing=!1,d._resizeDirection=null,d.resizeTarget&&d.resizeTarget.removeClass("jqx-disableselect"));"undefined"==d._cursorBackup&&(d._cursorBackup="default");d._resizeWrapper&&(d._resizeWrapper.style.cursor=d._cursorBackup)},_resizeHandler:function(d,e){if(d.enableResize&&!d.collapsed){if(d.isResizing&&d._resizeDirection){0===e.which&&c.jqx.browser.msie&&9>c.jqx.browser.version&&d._stopResizing(e);
1883if(d._isTouchDevice)return e=c.jqx.position(e),d._performResize(e.left,e.top),!1;d._performResize(e.pageX,e.pageY);return!1}return d._isTouchDevice?(e=c.jqx.position(e),d._resizeCaptureCursor(e.left,e.top)):d._resizeCaptureCursor(e.pageX,e.pageY)}},_resizeCaptureCursor:function(d,e){if(this._resizeMouseDown&&!this.isResizing&&this._resizeDirection&&(this._isTouchDevice||d+3<this._mouseResizePosition.x||d-3>this._mouseResizePosition.x||e+3<this._mouseResizePosition.y||e-3>this._mouseResizePosition.y))return this._changeCursor(d-
1884parseInt(this.resizeTarget.css("left"),10),e-parseInt(this.resizeTarget.css("top"),10)),this._mouseResizePosition={x:d,y:e},this._prepareResizeMethods(this._resizeDirection),this._resizeBackupData(),this.isResizing=!0,this.resizeTarget.addClass("jqx-disableselect"),!1},_resizeBackupData:function(){this.resizeTarget.lastWidth=this.resizeTarget.width();this.resizeTarget.lastHeight=this.resizeTarget.height();this.resizeTarget.x=parseInt(this.resizeTarget.css("left"),10);this.resizeTarget.y=parseInt(this.resizeTarget.css("top"),
188510);this._resizeBackupChildrenSize()},_resizeBackupChildrenSize:function(){for(var d=this.resizeTargetChildren.length,e;d;)--d,e=this.resizeTargetChildren[d],this.resizeTargetChildren[d].lastWidth=e.width(),this.resizeTargetChildren[d].lastHeight=e.height()},_performResize:function(d,e){d-=this._mouseResizePosition.x;e-=this._mouseResizePosition.y;this._resizeDirection&&this._resize(this.resizeTarget,d,e)},_resizeCursorChangeHandler:function(d,e){!d.enableResize||d.collapsed||d.isResizing||(d._isTouchDevice?
1886(e=c.jqx.position(e),d._changeCursor(e.left-parseInt(d.resizeTarget.css("left"),10),e.top-parseInt(d.resizeTarget.css("top"),10))):d._changeCursor(e.pageX-parseInt(d.resizeTarget.css("left"),10),e.pageY-parseInt(d.resizeTarget.css("top"),10)))},_resizeMouseDownHandler:function(d,e){if(d.enableResize&&null!==d._resizeDirection){d._resizeMouseDown=!0;if(d._isTouchDevice){var f=c.jqx.position(e);d._mouseResizePosition.x=f.left;
1886d._mouseResizePosition.y=f.top}else d._mouseResizePosition.x=e.pageX,d._mouseResizePosition.y=
1887e.pageY;e.preventDefault()}},_validateResizeProperties:function(){try{if(!this.resizeTarget||1!==this.resizeTarget.length)throw Error(this._resizeExceptions.invalidTarget);if(0>this.minHeight||isNaN(parseInt(this.minHeight,10)))throw Error(this._resizeExceptions.invalidMinHeight);if(0>=this.maxHeight||isNaN(parseInt(this.maxHeight,10)))throw Error(this._resizeExceptions.invalidMaxHeight);if(0>this.minWidth||isNaN(parseInt(this.minWidth,10)))throw Error(this._resizeExceptions.invalidMinWidth);if(0>
1888this.maxWidth||isNaN(parseInt(this.maxWidth,10)))throw Error(this._resizeExceptions.invalidMaxWidth);if(0>this.resizeIndicatorSize||isNaN(parseInt(this.resizeIndicatorSize,10)))throw Error(this._resizeExceptions.invalidIndicatorSize);if(this.minHeight>this.maxHeight||this.minWidth>this.maxWidth)throw Error(this._resizeExceptions.invalidSize);}catch(d){throw Error(d);}},_changeCursor:function(d,e){this.isResizing||this._resizeMouseDown||(this.resizeArea=!0,d<=this.resizeIndicatorSize&&0<=d&&e<=this.resizeIndicatorSize&&
18890<e?(this._resizeWrapper.style.cursor="nw-resize",this._resizeDirection="topleft"):e<=this.resizeIndicatorSize&&0<e&&d>=this.resizeTarget.width()-this.resizeIndicatorSize?(this._resizeWrapper.style.cursor="ne-resize",this._resizeDirection="topright"):e>=this.resizeTarget.height()-this.resizeIndicatorSize&&e<this.resizeTarget.height()&&d<=this.resizeIndicatorSize&&0<=d?(this._resizeWrapper.style.cursor="sw-resize",this._resizeDirection="bottomleft"):e>=this.resizeTarget.height()-this.resizeIndicatorSize&&
1890e<this.resizeTarget.height()&&d>=this.resizeTarget.width()-this.resizeIndicatorSize&&d<this.resizeTarget.width()?(this._resizeWrapper.style.cursor="se-resize",this._resizeDirection="bottomright"):d<=this.resizeIndicatorSize&&0<=d?(this._resizeWrapper.style.cursor="e-resize",this._resizeDirection="left"):e<=this.resizeIndicatorSize&&0<e?(this._resizeWrapper.style.cursor="n-resize",this._resizeDirection="top"):e>=this.resizeTarget.height()-this.resizeIndicatorSize&&e<this.resizeTarget.height()?(this._resizeWrapper.style.cursor=
1891"n-resize",this._resizeDirection="bottom"):d>=this.resizeTarget.width()-this.resizeIndicatorSize&&d<this.resizeTarget.width()?(this._resizeWrapper.style.cursor="e-resize",this._resizeDirection="right"):(this._resizeWrapper.style.cursor=this._cursorBackup,this._resizeDirection=null,this.resizeArea=!1))},_prepareResizeMethods:function(d){this._resizeMethods=[];0<=d.indexOf("left")&&this._resizeMethods.push(this._resizeLeft);0<=d.indexOf("top")&&this._resizeMethods.push(this._resizeTop);0<=d.indexOf("right")&&
1892this._resizeMethods.push(this._resizeRight);0<=d.indexOf("bottom")&&this._resizeMethods.push(this._resizeBottom)},_validateResize:function(d,e,f,g,h){return"horizontal"===f||"both"===f?this._validateWidth(d,g,h):"vertical"===f||"both"===f?this._validateHeight(e,g,h):{result:!1,fix:0}},_getParent:function(){return null!==this.resizeParent&&"undefined"!==this.resizeParent&&this.resizeParent.height&&this.resizeParent.width&&this.resizeParent.top&&this.resizeParent.left?this.resizeParent:{left:0,top:0,
1893width:c(document).width(),height:c(document).height()}},_validateHeight:function(d,e,f){var g=0,h=this._getParent();c(window).width()>c(document).width()&&c.jqx.browser.msie&&h.height===c(document).height()&&(g=this._SCROLL_WIDTH);return"bottom"===f&&d+e.position().top+g+2>h.height+h.top?{fix:h.height-e.position().top-g-2+h.top,result:!1}:"top"===f&&e.lastHeight-d+e.y<h.top?{fix:d+(e.lastHeight-d+e.y)-h.top,result:!1}:d<e.minHeight?{fix:e.minHeight,result:!1}:d>e.maxHeight?{fix:e.maxHeight,result:!1}:
1894{result:!0,fix:d}},_validateWidth:function(d,e,f){var g=0,h=this._getParent();c(window).height()<c(document).height()&&c.jqx.browser.msie&&document.documentElement.clientWidth>=document.documentElement.scrollWidth&&h.width===c(document).width()&&(g=this._SCROLL_WIDTH);return"right"===f&&d+e.position().left+g+2>h.width+h.left?{fix:h.width-e.position().left-g-2+h.left,result:!1}:"left"===f&&e.lastWidth-d+e.x<h.left?{fix:d+(e.lastWidth-d+e.x)-h.left,result:!1}:d<e.minWidth?{fix:e.minWidth,result:!1}:
1895d>e.maxWidth?{fix:e.maxWidth,result:!1}:{result:!0,fix:d}},_resize:function(d,e,f){for(var g=this._resizeMethods.length,h=0;h<g;h++)if(this._resizeMethods[h]instanceof Function)this._resizeMethods[h]({element:d,x:e,y:f,self:this});this._performResizeLayout()},resize:function(d,e){if(this.resizable){d-=this.host.width();e-=this.host.height();var f="right";0!==e&&(f="bottom");this._resizeDirection=f;this._prepareResizeMethods(this._resizeDirection);this._resizeBackupData();this.isResizing=!0;this._resize(this.resizeTarget,
1896d,e);this.isResizing=!1;0<d&&0<e&&(this._resizeDirection="right",this._prepareResizeMethods(this._resizeDirection),this._resizeBackupData(),this.isResizing=!0,this._resize(this.resizeTarget,d,e),this.isResizing=!1)}},_setResizeChildrenSize:function(d,e){for(var f=this.resizeTargetChildren.length;f;)if(f--,"width"===e){var g=this.resizeTargetChildren[f].lastWidth-(this.resizeTarget.lastWidth-d);g<this.resizeTarget.maxWidth&&0<g&&this.resizeTargetChildren[f].width(g)}else g=this.resizeTargetChildren[f].lastHeight-
1897(this.resizeTarget.lastHeight-d),g<this.resizeTarget.maxHeight&&0<g&&this.resizeTargetChildren[f].height(g)},_resizeRight:function(d){var e=d.element.lastWidth+d.x,f=d.self._validateResize(e,0,"horizontal",d.element,"right");f.result||(e=f.fix);d.element.width()!==e&&(d.self._setResizeChildrenSize(e,"width"),d.element.width(e),0<=d.self.width.toString().indexOf("%")&&(f=c(document.body).width()/100,d.element[0].style.width=1/f*e+"%",d.self._setChildrenLayout()
1897),d.self._raiseResizeEvent(0));return e},
1898_resizeLeft:function(d){var e=d.element.lastWidth-d.x,f=d.self._validateResize(e,0,"horizontal",d.element,"left"),g=d.element.x+d.x;if(f.result)return d.element.width()!==e&&(d.self._setResizeChildrenSize(e,"width"),d.element.width(e),0<=d.self.width.toString().indexOf("%")&&(f=c(document.body).width()/100,d.element[0].style.width=1/f*e+"%",d.self._setChildrenLayout()),d.element[0].style.left=d.self._toPx(g),d.self._raiseResizeEvent(0)),e},_resizeBottom:function(d){var e=d.element.lastHeight+d.y,
1899f=d.self._validateResize(0,e,"vertical",d.element,"bottom");f.result||(e=f.fix);d.element.height()!==e&&(d.self._setResizeChildrenSize(e,"height"),d.element.height(e),0<=d.self.height.toString().indexOf("%")&&(f=c(document.body).height()/100,d.element[0].style.height=1/f*e+"%",d.self._setChildrenLayout()),d.self._raiseResizeEvent(0));return e},_resizeTop:function(d){var e=d.element.lastHeight-d.y,f=d.self._validateResize(0,e,"vertical",d.element,"top"),g=d.element.y+d.y;if(f.result)return d.element.height()!==
1900e&&(d.self._setResizeChildrenSize(e,"height"),d.element.height(e),0<=d.self.height.toString().indexOf("%")&&(f=c(document.body).height()/100,d.element[0].style.height=1/f*e+"%",d.self._setChildrenLayout()),d.element[0].style.top=d.self._toPx(g),d.self._raiseResizeEvent(0)),e},_raiseResizeEvent:function(d){var e=this._resizeEvents[d],f=c.Event(e),g={};g.width=parseInt(this.resizeTarget[0].style.width,10);g.height=parseInt(this.resizeTarget[0].style.height,10);f.args=g;0===d&&(e=this._resizeEvents[2],
1901d=c.Event(e),d.args=g,this.resizeTarget.trigger(d));return this.resizeTarget.trigger(f)}}}(jqxBaseFramework);a.extend(a.jqx._jqxWindow.prototype,b)})(jqxBaseFramework);
1902(function(a){a.jqx.jqxWidget("jqxInput","",{});a.extend(a.jqx._jqxInput.prototype,{defineInstance:function(){var b={disabled:!1,filter:this._filter,sort:this._sort,highlight:this._highlight,dropDownWidth:null,renderer:this._renderer,opened:!1,$popup:document.createElement("ul"),source:[],roundedCorners:!0,searchMode:"default",placeHolder:"",width:null,height:null,value:"",rtl:!1,hint:!0,displayMember:"",valueMember:"",events:["select","open","close","change"],popupZIndex:1E3,items:8,minLength:1,maxLength:null};
1903if(this===a.jqx._jqxInput.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(){if("none"===this.host.css("display")||!1===document.body.contains(this.element))this._initiallyHidden=!0;
1903this._popupHelper=a(this.$popup);this.render()},render:function(){var b=this;this.input=this.element;if(b.isMaterialized()&&this.input instanceof HTMLInputElement){var c=this.host.children();a.each(c,function(l){var m="jqx-input-group-addon";a(this).removeClass(b.toThemeProperty("jqx-rc-all"));
19040===l&&(m+=" jqx-rc-l");l===c.length-1&&(m+=" jqx-rc-r");this!==b.element&&(m+=" jqx-fill-state-normal");this.className+=" "+b.toThemeProperty(m)});var d=a("<div></div>");d.addClass(b.toThemeProperty("jqx-input-group"));this.host.after(d);var e=this.element,f=this.host.data();d.append(e);var g=a("<label></label");this.hint&&(g[0].innerHTML=this.placeHolder);g.addClass(b.toThemeProperty("jqx-input-label"));d.append(g);var h=a("<span></span>");d.append(h);h.addClass(b.toThemeProperty("jqx-input-bar"));
1905d[0].id=this.element.id;this.element.removeAttribute("id");d[0].style.cssText=this.element.style.cssText;b.input=b.element;this.input instanceof HTMLInputElement||(this.input=this.host.find("input"),0<this.input.length&&(this.input=this.input[0]),a(this.input).addClass(this.toThemeProperty("jqx-input-widget")));this.label=g;this.bar=h;this.element.style.cssText="";this.host=d;this.element=d[0];this.host.data(f);b=this;b.template&&(b.bar.addClass(b.toThemeProperty("jqx-"+b.template)),b.label.addClass(b.toThemeProperty("jqx-"+
1906b.template)));0<c.length&&(b._hasAddons=!0)}else if("textarea"===this.element.nodeName.toLowerCase())this.element.style.overflow="auto";else if("div"===this.element.nodeName.toLowerCase()){this.baseHost=this.element;e=b.element.getElementsByTagName("input");var k=!1;a.each(e,function(){var l=this.type;if(null==l||"text"===l||"textarea"===l)return e=a(this),k=!0,!1});if(!k)throw Error("jqxInput: Missing Text Input in the Input Group");0<e.length&&(this.baseHost=a(this.element),b.baseElement=b.element,
1907f=this.host.data(),this.host=e,this.element=e[0],b.input=e[0],this.host.data(f),b.baseElement.className+=" "+b.toThemeProperty("jqx-widget jqx-rc-all jqx-input-group"),c=this.baseHost.children(),a.each(c,function(l){var m="jqx-input-group-addon";a(this).removeClass(b.toThemeProperty("jqx-rc-all"));0===l&&(m+=" jqx-rc-l");l===c.length-1&&(m+=" jqx-rc-r");this!==b.element&&(m+=" jqx-fill-state-normal");this.className+=" "+b.toThemeProperty(m)}))}this.addHandlers();this.rtl&&(b.element.className+=" "+
1908b.toThemeProperty("jqx-rtl"));b.element.setAttribute("role","textbox");a.jqx.aria(this,"aria-autocomplete","both");a.jqx.aria(this,"aria-disabled",this.disabled);a.jqx.aria(this,"aria-readonly",!1);a.jqx.aria(this,"aria-multiline",!1);this.source&&this.source.length&&a.jqx.aria(this,"aria-haspopup",!0);""!==this.value&&(this.input.value=this.value);this._oldsource=this.source;this._updateSource()},_updateSource:function(){var b=this,c=function(f){if(void 0===f)return null;if("string"===typeof f||
1909f instanceof String)return{label:f,value:f};if("string"!==typeof f&&!1===f instanceof String){var g="",h="";""!==b.displayMember&&void 0!==b.displayMember&&f[b.displayMember]&&(g=f[b.displayMember]);""!==b.valueMember&&void 0!==b.valueMember&&(h=f[b.valueMember]);""===g&&(g=f.label);""===h&&(h=f.value);return{label:g,value:h}}return f},d=function(f){for(var g=[],h=0;h<f.length;h++)g[h]=c(f[h]);return g};if(this.source&&this.source._source){this.adapter=this.source;if(null!=this.adapter._source.localdata)this.adapter.unbindBindingUpdate(this.element.id),
1910this.adapter.bindBindingUpdate(this.element.id,function(){b.source=d(b.adapter.records)});else{var e={};this.adapter._options.data?a.extend(b.adapter._options.data,e):(this.source._source.data&&a.extend(e,this.source._source.data),this.adapter._options.data=e);this.adapter.unbindDownloadComplete(this.element.id);this.adapter.bindDownloadComplete(this.element.id,function(){b.source=d(b.adapter.records)})}this.source.dataBind()}else a.isFunction(this.source)||(this.source=d(this.source))},_refreshClasses:function(b){b=
1911b?"addClass":"removeClass";var c="jqx-widget-content jqx-input-widget jqx-input jqx-widget",d="jqx-popup jqx-input-popup jqx-menu jqx-menu-vertical jqx-menu-dropdown jqx-widget jqx-widget-content";a.jqx.browser.msie&&(d+=" jqx-noshadow");this.roundedCorners&&(c+=" jqx-rc-all",d+=" jqx-rc-all");this.disabled?c+=" jqx-fill-state-disabled":this.host.removeClass(this.toThemeProperty("jqx-fill-state-disabled"));this.host[b](this.toThemeProperty(c));this._popupHelper[b](this.toThemeProperty(d))},selectAll:function(){var b=
1912this.host;!1===b[0]instanceof HTMLInputElement&&(b=a(this.input));setTimeout(function(){if("selectionStart"in b[0])b[0].focus(),b[0].setSelectionRange(0,b[0].value.length);else{var c=b[0].createTextRange();c.collapse(!0);c.moveEnd("character",b[0].value.length);c.moveStart("character",0);c.select()}},10)},selectLast:function(){var b=this.host;!1===b[0]instanceof HTMLInputElement&&(b=a(this.input));this.selectStart(b[0].value.length)},selectFirst:function(){this.selectStart(0)},selectStart:function(b){var c=
1913this.host;!1===c[0]instanceof HTMLInputElement&&(c=a(this.input));setTimeout(function(){if("selectionStart"in c[0])c[0].focus(),c[0].setSelectionRange(b,b);else{var d=c[0].createTextRange();d.collapse(!0);d.moveEnd("character",b);d.moveStart("character",b);d.select()}},10)},focus:function(){try{var b=this;b.element.focus();setTimeout(function(){b.element.focus()},25)}catch(c){}},resize:function(b,c){this.width=b;this.height=c;this.refresh()},refresh:function(){this._refreshClasses(!1);this._refreshClasses(!0);
1914if(this.baseHost){null!=this.width&&-1!=this.width.toString().indexOf("px")?this.baseElement.style.width=parseInt(this.width)+"px":void 0==this.width||isNaN(this.width)||(this.baseElement.style.width=this.width+"px");null!=this.height&&-1!=this.height.toString().indexOf("px")?this.baseElement.style.height=parseInt(this.height)+"px":void 0==this.height||isNaN(this.height)||(this.baseElement.style.height=this.height+"px");var b=this,c=a.jqx.browser.msie&&9>a.jqx.browser.version,d=0;a.each(this.baseHost.children(),
1915function(){this.style.height="100%";this!==b.element&&(d+=a(this).outerWidth())});b._addonsWidth=d;if(c){var e=Math.max(0,b.baseElement.offsetHeight-2);b.element.style.width=Math.max(0,b.baseElement.offsetWidth-d-1)+"px";b.element.style.minHeight=e+"px";b.element.style.lineHeight=e+"px"}else b.element.style.width="calc(100% - "+d+"px)";a.jqx.utilities.resize(b.baseHost,function(){if(c&&"string"===typeof b.width&&-1!==b.width.indexOf("%")&&!b._initiallyHidden)b.element.style.width=b.baseElement.offsetWidth-
1916b._addonsWidth-1+"px";else if(b._initiallyHidden){b._addonsWidth=b._getAddonsWidth();if(c){b.element.style.width=b.baseElement.offsetWidth-b._addonsWidth-1+"px";var f=b.baseElement.offsetHeight-2;b.element.style.minHeight=f+"px";b.element.style.lineHeight=f+"px"}else b.element.style.width="calc(100% - "+b._addonsWidth+"px)";b._initiallyHidden=!1}})}else null!=this.width&&-1!=this.width.toString().indexOf("px")?this.element.style.width=parseInt(this.width)+"px":void 0==this.width||isNaN(this.width)?
1917this.element.style.width=this.width:this.element.style.width=this.width+"px",null!=this.height&&-1!=this.height.toString().indexOf("px")?this.element.style.height=parseInt(this.height)+"px":void 0==this.height||isNaN(this.height)?this.element.style.height=this.height:this.element.style.height=this.height+"px",this._hasAddons&&(this._addonsWidth=35,this.input.style.width="calc(100% - "+this._addonsWidth+"px)");this.disabled?this.element.setAttribute("disabled",!0):this.element.removeAttribute("disabled");
1918this.maxLength&&(this.element.setAttribute("maxlength",this.maxLength),this.input&&this.input.setAttribute("maxlength",this.maxLength));this.element.getAttribute("placeholder")||this._refreshPlaceHolder()},_refreshPlaceHolder:function(){this.isMaterialized()&&this.hint||("placeholder"in this.input&&!(a.jqx.browser.msie&&9>a.jqx.browser.version)?this.input.setAttribute("placeHolder",this.placeHolder):""===this.input.value&&(this.input.value=this.placeHolder));this.hint&&(""!==this.input.value?this.element.setAttribute("hint",
1919!0):this.element.removeAttribute("hint"),this.label&&(this.label.innerHTML=this.placeHolder))},destroy:function(){this.removeHandlers();this.baseHost?this.baseHost.remove():this.host.remove();this.$popup&&this._popupHelper.remove()}
1919,propertiesChangedHandler:function(b,c,d){d.width&&d.height&&2===Object.keys(d).length&&b.refresh()},propertyChangedHandler:function(b,c,d,e){if("width"===c&&e!==d)b.baseHost?(b.baseElement.style.width=b._toPx(e),a.jqx.browser.msie&&9>a.jqx.browser.version&&(b.element.style.width=
1920b.baseElement.offsetWidth-b._addonsWidth-1+"px")):b.element.style.width=b._toPx(e);else if("placeHolder"===c)"placeholder"in b.element&&!(a.jqx.browser.msie&&9>a.jqx.browser.version)||b.input.value!==d||(b.input.value=""),b._refreshPlaceHolder();else if(!(b.batchUpdate&&b.batchUpdate.width&&b.batchUpdate.height&&2===Object.keys(b.batchUpdate).length))if("theme"===c&&a.jqx.utilities.setTheme(d,e,b.host),"opened"===c)e?b.open():b.close();else{"source"===c&&(b._oldsource=e,b._updateSource());if("displayMember"===
1921c||"valueMember"===c)b.source=b._oldsource,b._updateSource();"disabled"===c&&a.jqx.aria(b,"aria-disabled",b.disabled);"value"===c&&(b.input.value=e,b._refreshPlaceHolder());b.refresh()}},select:function(b,c,d){c=this._find("jqx-fill-state-pressed",this._popupHelper);b=c.getAttribute("data-value");c=c.getAttribute("data-name");this.input.value=this.renderer(c,this.input.value);this.selectedItem={label:c,value:b};this.element.setAttribute("data-value",b);this.element.setAttribute("data-label",c);this._raiseEvent("0",
1922{item:{label:c,value:b},label:c,value:b});this._raiseEvent("3",{type:d,item:{label:c,value:b},label:c,value:b});this.value=c;return this.close()},val:function(b){if(0===arguments.length||null!=b&&"object"===typeof b&&!b.label&&!b.value)return""!==this.displayMember&&""!==this.valueMember&&this.selectedItem?""===this.input.value?"":this.selectedItem:this.input.value;if(b&&b.label)return this.selectedItem={label:b.label,value:b.value},this.element.setAttribute("data-value",b.value),this.element.setAttribute("data-label",
1923b.label),this.value=b,this.input.value=b.label,this.input&&(this.input.value=b.label),this.input.value;this.value=b;this.input.value=b;this.element.setAttribute("data-value",b);this.element.setAttribute("data-label",b);b&&b.label?this._raiseEvent("3",{type:null,item:{label:b.label,value:b.value},label:b.label,value:b.value}):this._raiseEvent("3",{type:null,item:{label:b,value:b},label:b,value:b});this._refreshPlaceHolder();return this.input.value},_raiseEvent:function(b,c){void 0===c&&(c={owner:null});
1924b=this.events[b];c.owner=this;b=new a.Event(b);b.owner=this;b.args=c;b.preventDefault&&b.preventDefault();return this.host.trigger(b)},_renderer:function(b){return b},open:function(){if(!a.jqx.isHidden(this.host)){var b=a.extend({},this.host.coord(!0),{height:this.element.offsetHeight});if(this.$popup.parentNode!==document.body){var c=this.element.id+"_popup";this.$popup.id=c;a.jqx.aria(this,"aria-owns",c);document.body.appendChild(this.$popup)}this.$popup.style.position="absolute";this.$popup.style.zIndex=
1925this.popupZIndex;this.$popup.style.top=this._toPx(b.top+b.height);this.$popup.style.left=this._toPx(b.left);this.$popup.style.display="block";var d=0;b=this._popupHelper.children();a.each(b,function(){d+=a(this).outerHeight()+1});this.$popup.style.height=this._toPx(d);this.opened=!0;this._raiseEvent("1",{popup:this.$popup});a.jqx.aria(this,"aria-expanded",!0);return this}},close:function(){if(this.opened)return this.$popup.style.display="none",this.opened=!1,this._raiseEvent("2",{popup:this.$popup}),
1926a.jqx.aria(this,"aria-expanded",!1),this._refreshPlaceHolder(),this},suggest:function(){var b;this.query=this.input.value;return!this.query||this.query.length<this.minLength?this.opened?this.close():this:(b=a.isFunction(this.source)?this.source(this.query,a.proxy(this.load,this)):this.source)?this.load(b):this},load:function(b){for(var c=[],d=0;d<b.length;d++){var e=b[d];this.filter(e)&&c.push(e)}c=this.sort(c);return c.length?this._render(c.slice(0,this.items)).open():this.opened?this.close():this},
1927_filter:function(b){var c=this.query,d=b;null!=b.label?d=b.label:this.displayMember&&(d=b[this.displayMember]);switch(this.searchMode){case "none":break;default:return a.jqx.string.containsIgnoreCase(d,c);case "contains":return a.jqx.string.contains(d,c);case "equals":return a.jqx.string.equals(d,c);case "equalsignorecase":return a.jqx.string.equalsIgnoreCase(d,c);case "startswith":return a.jqx.string.startsWith(d,c);case "startswithignorecase":return a.jqx.string.startsWithIgnoreCase(d,c);case "endswith":return a.jqx.string.endsWith(d,
1928c);case "endswithignorecase":return a.jqx.string.endsWithIgnoreCase(d,c)}},_sort:function(b){for(var c=[],d=[],e=[],f=0;f<b.length;f++){var g=b[f],h=g;g.label?h=g.label:this.displayMember&&(h=g[this.displayMember]);0===h.toString().toLowerCase().indexOf(this.query.toString().toLowerCase())?c.push(g):0<=h.toString().indexOf(this.query)?d.push(g):0<=h.toString().toLowerCase().indexOf(this.query.toString().toLowerCase())&&e.push(g)}return c.concat(d,e)},_highlight:function(b){var c=this.query;c=c.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,
1929"\\$&");return b.replace(new RegExp("("+c+")","ig"),function(d,e){return"<b>"+e+"</b>"})},escape_HTML:function(b){return b?b.replace?b.replace(/[&<>"]/g,function(c){return{"&":"&","<":"<",">":">",'"':'"'}[c]||c}):b:""},_render:function(b){var c=this,d=c._popupHelper.children();if(0<d.length)for(var e=0;e<d.length;e++)a(d[e]).remove();var f=function(g,h){var k=g,l=document.createElement("li"),m=document.createElement("a");m.setAttribute("href","#");l.appendChild(m);if(void 0!==g.value&&null!==g.value){var n=
1930void 0!==g.label&&null!==g.label?g.label:g.value;var r=c.escape_HTML(g.value)}else void 0!==g.label&&null!==g.label?r=n=g.label:void 0!==c.displayMember&&""!==c.displayMember?(n=g[c.displayMember],r=g[c.valueMember]):r=n=g;l.setAttribute("data-value",r);l.setAttribute("data-name",n);g.label?k=g.label:c.displayMember&&(k=g[c.displayMember]);m.innerHTML=c.highlight(k);g="";c.rtl&&(g=" jqx-rtl");0===h&&(g+=" jqx-fill-state-pressed");l.className=c.toThemeProperty("jqx-item jqx-menu-item jqx-rc-all"+g);
1931c.$popup.appendChild(l);c.addHandler(l,"mouseenter",function(t){c.mouseenter(t)})};(function(g){for(var h=0;h<g.length;h++)f(g[h],h)})(b);this.$popup.style.width=this.dropDownWidth?c._toPx(c.dropDownWidth):c._toPx(c.element.offsetWidth-6);return this},next:function(){var b=this._find("jqx-fill-state-pressed",this._popupHelper),c=b.nextSibling;a(b).removeClass(this.toThemeProperty("jqx-fill-state-pressed"));c||(c=this.$popup.firstChild);c.className+=" "+this.toThemeProperty("jqx-fill-state-pressed")},
1932prev:function(){var b=this._find("jqx-fill-state-pressed",this._popupHelper),c=b.previousSibling;a(b).removeClass(this.toThemeProperty("jqx-fill-state-pressed"));c||(c=this.$popup.lastChild);c.className+=" "+this.toThemeProperty("jqx-fill-state-pressed")}
1932,addHandlers:function(){var b=this,c=".jqxInput"+b.element.id;b.addHandler(b.host,"focus"+c,function(){b.onFocus()});b.addHandler(b.host,"blur"+c,function(){b.onBlur()});b.addHandler(b.host,"change"+c,function(d){if(b.opened&&!d.args)d.stopPropagation(),
1933d.preventDefault(),d.stopImmediatePropagation();else if(!d.args){d.stopPropagation();d.preventDefault();d.stopImmediatePropagation();var e=b.val();e&&e.label?(d=e.label,e=e.val):d=e;b._raiseEvent("3",{type:"keyboard",item:{label:d,value:e},label:d,value:e});b.value=d;b._refreshPlaceHolder()}});b.addHandler(b.host,"keypress"+c,function(d){b.keypress(d)});b.addHandler(b.host,"keyup"+c,function(d){b.keyup(d)});b.addHandler(b.host,"keydown"+c,function(d){b.keydown(d)});b.addHandler(b.$popup,"click"+c,
1934function(d){b.click(d)})},removeHandlers:function(){var b=".jqxInput"+this.element.id;this.removeHandler(this.host,"change"+b);this.removeHandler(this.host,"focus"+b);this.removeHandler(this.host,"blur"+b);this.removeHandler(this.host,"keypress"+b);this.removeHandler(this.host,"keyup"+b);this.removeHandler(this.host,"keydown"+b);this.removeHandler(this.$popup,"click"+b)},move:function(b){if(this.opened){switch(b.keyCode){case 9:case 13:case 27:b.preventDefault();break;case 38:b.shiftKey||(b.preventDefault(),
1935this.prev());break;case 40:b.shiftKey||(b.preventDefault(),this.next())}b.stopPropagation()}},keydown:function(b){this.suppressKeyPressRepeat=-1!==[40,38,9,13,27].indexOf(b.keyCode);this.move(b)},keypress:function(b){this.suppressKeyPressRepeat||this.move(b)},keyup:function(b){switch(b.keyCode){case 40:case 38:case 16:case 17:case 18:break;case 9:case 13:if(!this.opened)return;this.select(b,this,"keyboard");break;case 27:if(!this.opened)return;this.close();break;default:var c=this;this.timer&&clearTimeout(this.timer);
1936this.timer=setTimeout(function(){c.suggest()},300)}b.stopPropagation();b.preventDefault()},clear:function(){this.val("")},onBlur:function(){var b=this;setTimeout(function(){b.close()},150);b.host.removeClass(b.toThemeProperty("jqx-fill-state-focus"));b._refreshPlaceHolder()},onFocus:function(){this.element.className+=" "+this.toThemeProperty("jqx-fill-state-focus");this._refreshPlaceHolder()},click:function(b){b.stopPropagation();b.preventDefault();this.select(b,this,"mouse")},mouseenter:function(b){a(this._find("jqx-fill-state-pressed",
1937this._popupHelper)).removeClass(this.toThemeProperty("jqx-fill-state-pressed"));b.currentTarget.className+=" "+this.toThemeProperty("jqx-fill-state-pressed")},_toPx:function(b){return"number"===typeof b?b+"px":b},_find:function(b,c){c=c.children();for(var d=0;d<c.length;d++){var e=c[d];if(-1!==e.className.indexOf(b))return e}},_getAddonsWidth:function(){for(var b=this.baseHost.children(),c=0,d=0;d<b.length;d++)b[d]!==this.element&&(c+=a(b[d]).outerWidth());return c}})})(jqxBaseFramework);
1938(function(a){a.jqx.jqxWidget("jqxNumberInput","",{});a.extend(a.jqx._jqxNumberInput.prototype,{defineInstance:function(){var b={value:0,decimal:0,min:-99999999,max:99999999,width:200,validationMessage:"Invalid value",height:25,textAlign:"right",readOnly:!1,promptChar:"_",decimalDigits:2,decimalSeparator:".",groupSeparator:",",groupSize:3,symbol:"",symbolPosition:"left",digits:8,negative:!1,negativeSymbol:"-",disabled:!1,inputMode:"advanced",spinButtons:!1,spinButtonsWidth:18,spinButtonsStep:1,autoValidate:!0,
1939spinMode:"advanced",enableMouseWheel:!0,touchMode:"auto",allowNull:!0,placeHolder:"",changeType:null,template:"",rtl:!1,hint:!0,events:"valueChanged textchanged mousedown mouseup keydown keyup keypress change".split(" "),aria:{"aria-valuenow":{name:"decimal",type:"number"},"aria-valuemin":{name:"min",type:"number"},"aria-valuemax":{name:"max",type:"number"},"aria-disabled":{name:"disabled",type:"boolean"}},invalidArgumentExceptions:["invalid argument exception"]};if(this===a.jqx._jqxNumberInput.prototype)return b;
1940a.extend(!0,this,b);return b},createInstance:function(b){""===this.promptChar&&(this.promptChar=" ");b=this.host.attr("value");void 0!=b&&(this.decimal=b);0===this.decimal&&(null!=this.value?this.decimal=this.value:null===this.value&&0!==this.decimal&&(this.value=this.decimal));this._createFromInput("jqxNumberInput");this.render()},_updateHint:function(){var b=this;b.hint&&b.isMaterialized()&&setTimeout(function(){0===b.numberInput[0].value.length?(b.element.removeAttribute("hint"),b.label&&b.label[0]&&
1941(b.label[0].innerHTML=b.placeHolder)):b.element.setAttribute("hint",!0)})},_createFromInput:function(b){if("input"==this.element.nodeName.toLowerCase()){this.field=this.element;this.field.className&&(this._className=this.field.className);var c={title:this.field.title};this.field.value&&(this.decimal=parseFloat(this.field.value));if(this.field.getAttribute("min")){var d=this.field.getAttribute("min");this.min=parseFloat(d)}this.field.getAttribute("step")&&(d=this.field.getAttribute("step"),this.spinButtonsStep=
1942parseFloat(d));this.field.getAttribute("max")&&(d=this.field.getAttribute("max"),this.max=parseFloat(d));c.id=this.field.id.length?this.field.id.replace(/[^\w]/g,"_")+"_"+b:a.jqx.utilities.createId()+"_"+b;b=a("<div></div>",c);b[0].style.cssText=this.field.style.cssText;this.width||(this.width=a(this.field).width());this.height||(this.height=a(this.field).outerHeight());a(this.field).hide().after(b);d=this.host.data();this.host=b;this.host.data(d);this.element=b[0];
1942this.element.id=this.field.id;this.field.id=
1943c.id;this._className&&(this.host.addClass(this._className),a(this.field).removeClass(this._className));this.field.tabIndex&&(c=this.field.tabIndex,this.field.tabIndex=-1,this.element.tabIndex=c)}},_doTouchHandling:function(){var b=this.savedValue;this.parsing||(this.parsing=!0);if(this.parsing){this.numberInput.val()&&0==this.numberInput.val().indexOf("-")?this.setvalue("negative",!0):this.setvalue("negative",!1);for(var c=this.numberInput.val(),d=0;d<c.length-1;d++){var e=c.substring(d,d+1);if(isNaN(parseFloat(e))&&
1944-1===this.symbol.toString().indexOf(e)&&"%"!=e&&"$"!=e&&"."!=e&&","!=e&&"-"!=e){this.numberInput[0].value=b;this.parsing=!1;return}}this.ValueString=this.GetValueString(this.numberInput.val(),this.decimalSeparator,""!=this.decimalSeparator);this._parseDecimalInSimpleMode();this.decimal=this.ValueString;this.getvalue("negative")&&(this.decimal="-"+this.ValueString);this.parsing=!1}},render:function(){this.host.attr({role:"spinbutton"});this.host.attr("data-role","input");a.jqx.aria(this);a.jqx.aria(this,
1945"aria-multiline",!1);var b=this;(this.officeMode||this.theme&&-1!=this.theme.indexOf("office"))&&18==this.spinButtonsWidth&&(this.spinButtonsWidth=15);if(a.jqx.mobile.isTouchDevice()||!0===this.touchMode)this.inputMode="textbox",this.spinMode="simple";""==this.decimalSeparator&&(this.decimalSeparator=" ");this.host.addClass(this.toThemeProperty("jqx-input"));this.host.addClass(this.toThemeProperty("jqx-rc-all"));this.host.addClass(this.toThemeProperty("jqx-widget"));this.host.addClass(this.toThemeProperty("jqx-widget-content"));
1946this.host.addClass(this.toThemeProperty("jqx-numberinput"));this.spinButtons?this._spinButtons():(this.numberInput=a("<input style='border:none;' autocomplete='off' type='textarea'/>").appendTo(this.host),this.numberInput.addClass(this.toThemeProperty("jqx-input-content")),this.numberInput.addClass(this.toThemeProperty("jqx-widget-content")));this.isMaterialized()||this.numberInput.attr("placeholder",this.placeHolder);var c=this.host.attr("name");c&&this.numberInput.attr("name",c);this.host.attr("tabindex")&&
1947(this.numberInput.attr("tabindex",this.host.attr("tabindex")),this.host.removeAttr("tabindex"));if(a.jqx.mobile.isTouchDevice()||!0===this.touchMode||"textbox"==this.inputMode)b=this,b.savedValue="",this.addHandler(this.numberInput,"focus",function(){b.savedValue=b.numberInput[0].value}),this.addHandler(this.numberInput,"change",function(){b._doTouchHandling()});a.data(this.host[0],"jqxNumberInput").jqxNumberInput=this;b=this;0<this.host.parents("form").length&&this.addHandler(this.host.parents("form"),
1948"reset",function(){setTimeout(function(){b.setDecimal(0)},10)});this.propertyChangeMap.disabled=function(f,g,h,k){k?(f.numberInput.addClass(d.toThemeProperty("jqx-input-disabled")),f.numberInput.attr("disabled",!0)):(f.host.removeClass(d.toThemeProperty("jqx-input-disabled")),f.numberInput.attr("disabled",!1));f.spinButtons&&f.host.jqxRepeatButton&&(f.upbutton.jqxRepeatButton({disabled:k}),f.downbutton.jqxRepeatButton({disabled:k}))};this.disabled&&(this.numberInput.addClass(this.toThemeProperty("jqx-input-disabled")),
1949this.numberInput.attr("disabled",!0),this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled")));this.selectedText="";this.decimalSeparatorPosition=-1;var d=this;this.oldValue=this._value();this.items=[];c=this.value;var e=this.decimal;this._initializeLiterals();this._render();this.setDecimal(null!==c?e:null);b=this;setTimeout(function(){},100);this._addHandlers();a.jqx.utilities.resize(this.host,function(){b._render()})},refresh:function(b){b||this._render()},wheel:function(b,c){if(c.enableMouseWheel){c.changeType=
1950"mouse";var d=0;b||(b=window.event);b.originalEvent&&b.originalEvent.wheelDelta&&(b.wheelDelta=b.originalEvent.wheelDelta);b.wheelDelta?d=b.wheelDelta/120:b.detail&&(d=-b.detail/3);if(d)return c=c._handleDelta(d),b.preventDefault&&b.preventDefault(),null!=b.originalEvent&&(b.originalEvent.mouseHandled=!0),void 0!=b.stopPropagation&&b.stopPropagation(),c?(c=!1,b.returnValue=c):!1;b.preventDefault&&b.preventDefault();b.returnValue=!1}},_handleDelta:function(b){0>b?this.spinDown():this.spinUp();return!0},
1951_addHandlers:function(){var b=this;this.addHandler(this.numberInput,"paste",function(d){var e=b._selection();d.preventDefault();if(d.originalEvent.clipboardData)var f=(d.originalEvent||d).clipboardData.getData("text/plain");else window.clipboardData&&(f=window.clipboardData.getData("Text"));this.selectedText=f;a.data(document.body,"jqxSelection",this.selectedText);"simple"!=b.inputMode?b._pasteSelectedText():b.val(f);setTimeout(function(){b._setSelectionStart(e.start)})});this.addHandler(this.numberInput,
1952"mousedown",function(d){return b._raiseEvent(2,d)});this._mousewheelfunc=this._mousewheelfunc||function(d){if(!b.editcell)return b.wheel(d,b),!1};this.removeHandler(this.host,"mousewheel",this._mousewheelfunc);this.addHandler(this.host,"mousewheel",this._mousewheelfunc);var c="";this.addHandler(this.numberInput,"focus",function(d){a.data(b.numberInput,"selectionstart",b._selection().start);b.host.addClass(b.toThemeProperty("jqx-fill-state-focus"));b.spincontainer&&b.spincontainer.addClass(b.toThemeProperty("jqx-numberinput-focus"));
1953c=b.numberInput.val();b._savedValue=b.decimal});this.addHandler(this.numberInput,"blur",function(d){"simple"==b.inputMode&&b._exitSimpleInputMode(d,b,!1,c);if(b.autoValidate){var e=parseFloat(b.decimal);
1953b.getvalue("negative")&&0<b.decimal&&(e=-parseFloat(b.decimal));e>b.max&&(b._disableSetSelection=!0,b.setDecimal(b.max),b._disableSetSelection=!1);e<b.min&&(b._disableSetSelection=!0,b.setDecimal(b.min),b._disableSetSelection=!1)}b.host.removeClass(b.toThemeProperty("jqx-fill-state-focus"));b.spincontainer&&
1954b.spincontainer.removeClass(b.toThemeProperty("jqx-numberinput-focus"));b.numberInput.val()!=c&&(b._raiseEvent(7,d),a.jqx.aria(b,"aria-valuenow",b.decimal),b.element.value=b.decimal);return!0});this.addHandler(this.numberInput,"mouseup",function(d){return b._raiseEvent(3,d)});this.addHandler(this.numberInput,"keydown",function(d){b.changeType="keyboard";return b._raiseEvent(4,d)});this.addHandler(this.numberInput,"keyup",function(d){return b._raiseEvent(5,d)});this.addHandler(this.numberInput,"keypress",
1955function(d){return b._raiseEvent(6,d)})},focus:function(){try{this.numberInput.focus()}catch(b){}},_removeHandlers:function(){this.removeHandler(this.numberInput,"mousedown");a.jqx.mobile.isOperaMiniMobileBrowser()&&this.removeHandler(a(document),"click."+this.element.id,this._exitSimpleInputMode,this);this.removeHandler(this.numberInput,"paste");this.removeHandler(this.numberInput,"focus");this.removeHandler(this.numberInput,"blur");this.removeHandler(this.numberInput,"mouseup");this.removeHandler(this.numberInput,
1956"keydown");this.removeHandler(this.numberInput,"keyup");this.removeHandler(this.numberInput,"keypress")},_spinButtons:function(){if(this.host.jqxRepeatButton){this.numberInput?this.numberInput.css("float","left"):(this.numberInput=a("<input autocomplete='off' style='border: none; position: relative; float: left;' type='textarea'/>"),this.numberInput.appendTo(this.host),this.numberInput.addClass(this.toThemeProperty("jqx-input-content")),this.numberInput.addClass(this.toThemeProperty("jqx-widget-content")));
1957this.spincontainer&&(this.upbutton&&this.upbutton.jqxRepeatButton("destroy"),this.downbutton&&this.downbutton.jqxRepeatButton("destroy"),this.spincontainer.remove());this.spincontainer=a('<div style="float: right; height: 100%; overflow: hidden; position: relative;"></div>');this.rtl&&(this.spincontainer.css("float","right"),this.numberInput.css("float","right"),this.spincontainer.css("left","-1px"));this.host.append(this.spincontainer);this.upbutton=a('<div style="overflow: hidden; padding: 0px; margin-left: -1px; position: relative;"><div></div></div>');
1958this.spincontainer.append(this.upbutton);this.upbutton.jqxRepeatButton({overrideTheme:!0,disabled:this.disabled,roundedCorners:"top-right"});this.downbutton=a('<div style="overflow: hidden; padding: 0px; margin-left: -1px; position: relative;"><div></div></div>');this.spincontainer.append(this.downbutton);this.downbutton.jqxRepeatButton({overrideTheme:!0,disabled:this.disabled,roundedCorners:"bottom-right"});this.template&&(this.upbutton.addClass(this.toThemeProperty("jqx-"+this.template)),this.downbutton.addClass(this.toThemeProperty("jqx-"+
1959this.template)));var b=this;this.downbutton.addClass(this.toThemeProperty("jqx-fill-state-normal jqx-action-button"));this.upbutton.addClass(this.toThemeProperty("jqx-fill-state-normal jqx-action-button"));this.upbutton.addClass(this.toThemeProperty("jqx-rc-tr"));this.downbutton.addClass(this.toThemeProperty("jqx-rc-br"));this.addHandler(this.downbutton,"mouseup",function(e){b.disabled||(b.downbutton.removeClass(b.toThemeProperty("jqx-fill-state-pressed")),b._downArrow.removeClass(b.toThemeProperty("jqx-icon-arrow-down-selected")))});
1960this.addHandler(this.upbutton,"mouseup",function(e){b.disabled||(b.upbutton.removeClass(b.toThemeProperty("jqx-fill-state-pressed")),b._upArrow.removeClass(b.toThemeProperty("jqx-icon-arrow-up-selected")))});this.removeHandler(a(document),"mouseup."+this.element.id);this.addHandler(a(document),"mouseup."+this.element.id,function(e){b.upbutton.removeClass(b.toThemeProperty("jqx-fill-state-pressed"));b._upArrow.removeClass(b.toThemeProperty("jqx-icon-arrow-up-selected"));b.downbutton.removeClass(b.toThemeProperty("jqx-fill-state-pressed"));
1961b._downArrow.removeClass(b.toThemeProperty("jqx-icon-arrow-down-selected"))});this.addHandler(this.downbutton,"mousedown",function(e){if(!b.disabled)return a.jqx.browser.msie&&9>a.jqx.browser.version&&(b._inputSelection=b._selection()),b.downbutton.addClass(b.toThemeProperty("jqx-fill-state-pressed")),b._downArrow.addClass(b.toThemeProperty("jqx-icon-arrow-down-selected")),e.preventDefault(),e.stopPropagation(),!1});this.addHandler(this.upbutton,"mousedown",function(e){if(!b.disabled)return a.jqx.browser.msie&&
19629>a.jqx.browser.version&&(b._inputSelection=b._selection()),b.upbutton.addClass(b.toThemeProperty("jqx-fill-state-pressed")),b._upArrow.addClass(b.toThemeProperty("jqx-icon-arrow-up-selected")),e.preventDefault(),e.stopPropagation(),!1});this.addHandler(this.upbutton,"mouseenter",function(e){b.upbutton.addClass(b.toThemeProperty("jqx-fill-state-hover"));b._upArrow.addClass(b.toThemeProperty("jqx-icon-arrow-up-hover"))});this.addHandler(this.upbutton,"mouseleave",function(e){b.upbutton.removeClass(b.toThemeProperty("jqx-fill-state-hover"));
1963b._upArrow.removeClass(b.toThemeProperty("jqx-icon-arrow-up-hover"))});this.addHandler(this.downbutton,"mouseenter",function(e){b.downbutton.addClass(b.toThemeProperty("jqx-fill-state-hover"));b._downArrow.addClass(b.toThemeProperty("jqx-icon-arrow-down-hover"))});this.addHandler(this.downbutton,"mouseleave",function(e){b.downbutton.removeClass(b.toThemeProperty("jqx-fill-state-hover"));b._downArrow.removeClass(b.toThemeProperty("jqx-icon-arrow-down-hover"))});this.upbutton.css("border-width","0px");
1964this.downbutton.css("border-width","0px");this.disabled?(this.upbutton[0].disabled=!0,this.downbutton[0].disabled=!0):(this.upbutton[0].disabled=!1,this.downbutton[0].disabled=!1);this.spincontainer.addClass(this.toThemeProperty("jqx-input"));this.spincontainer.addClass(this.toThemeProperty("jqx-rc-r"));this.spincontainer.css("border-width","0px");this.rtl?this.spincontainer.css("border-right-width","1px"):this.spincontainer.css("border-left-width","1px");this._upArrow=this.upbutton.find("div");this._downArrow=
1965this.downbutton.find("div");this._upArrow.addClass(this.toThemeProperty("jqx-icon-arrow-up"));this._downArrow.addClass(this.toThemeProperty("jqx-icon-arrow-down"));this._upArrow.addClass(this.toThemeProperty("jqx-input-icon"));this._downArrow.addClass(this.toThemeProperty("jqx-input-icon"));b=this;this._upArrow.hover(function(){b.disabled||b._upArrow.addClass(b.toThemeProperty("jqx-icon-arrow-up-hover"))},function(){b._upArrow.removeClass(b.toThemeProperty("jqx-icon-arrow-up-hover"))});this._downArrow.hover(function(){b.disabled||
1966b._downArrow.addClass(b.toThemeProperty("jqx-icon-arrow-down-hover"))},function(){b._downArrow.removeClass(b.toThemeProperty("jqx-icon-arrow-down-hover"))});var c=a.jqx.mobile.isTouchDevice(),d="click";c&&(d=a.jqx.mobile.getTouchEventName("touchstart"));c&&(this.addHandler(this.downbutton,"click",function(e){b.spinDown()}),this.addHandler(this.upbutton,"click",function(e){b.spinUp()}));this.addHandler(this.downbutton,d,function(e){c?(e.preventDefault(),e.stopPropagation()):(0==b._selection().start&&
1967b._setSelectionStart(b.numberInput.val().length),a.jqx.browser.msie&&9>a.jqx.browser.version&&b._setSelectionStart(b._inputSelection.start));b.spinDown();return!1});this.addHandler(this.upbutton,d,function(e){c?(e.preventDefault(),e.stopPropagation()):(0==b._selection().start&&b._setSelectionStart(b.numberInput.val().length),a.jqx.browser.msie&&9>a.jqx.browser.version&&b._setSelectionStart(b._inputSelection.start));b.spinUp();return!1})}else throw Error("jqxNumberInput: Missing reference to jqxbuttons.js.");
1968},spinDown:function(){var b=this.decimal;if("none"!=this.spinMode)if(null==this.decimal)this.setDecimal(0);else{var c=this.getvalue("negative"),d=c?-1:0;(a.jqx.mobile.isTouchDevice()||"textbox"==this.inputMode)&&this._doTouchHandling();if(!this.disabled){var e=this._selection(),f=this.decimal,g=this.getDecimal();if(g<this.min)this.setDecimal(this.min),this._setSelectionStart(e.start),this.spinDown();else if(g>this.max)this.setDecimal(this.max),this._setSelectionStart(e.start),this.spinDown();else{0>
1969this.spinButtonsStep&&(this.spinButtonsStep=1);var h=parseInt(this.decimal)-this.spinButtonsStep;h=h.toString().length;var k=d+h<=this.digits;if("advanced"!=this.spinMode){if(g-this.spinButtonsStep>=this.min&&k){h=1;for(k=0;k<this.decimalDigits;k++)h*=10;g=h*g-h*this.spinButtonsStep;g=this._parseDecimalValueToEditorValue(g/h);this.setDecimal(g)}}else{c=this._getspindecimal();this._getSeparatorPosition();g=parseFloat(c.decimal);0>this.spinButtonsStep&&(this.spinButtonsStep=1);h=parseInt(g)-this.spinButtonsStep;
1970h=h.toString().length;k=d+h<=this.digits;h=1;var l=c.decimal.indexOf(".");if(-1!=l){var m=c.decimal.length-l-1;h=1;for(k=0;k<m;k++)h*=10;g-=new Number(this.spinButtonsStep/h);g=g.toFixed(m);l=g.toString().indexOf(".");-1==l&&(g=g.toString()+".");m=g.toString()+c.afterdecimal;m=new Number(m);m=m.toFixed(this.decimalDigits);m>=this.min&&(m=this._parseDecimalValueToEditorValue(m),this.setDecimal(m))}else g-this.spinButtonsStep>=this.min&&k&&(g=h*g-h*this.spinButtonsStep,m=(g/h).toString()+c.afterdecimal,
1971m>=this.min&&(m=this._parseDecimalValueToEditorValue(m),this.setDecimal(m)))}void 0==m||"simple"!=this.inputMode?(c=this.getvalue("negative"),0==d&&c?this._setSelectionStart(e.start+1):this._setSelectionStart(e.start),this.savedValue=this.numberInput[0].value):(m=this.decimal.toString(),c=this.getvalue("negative"),0==d&&c?this._setSelectionStart(e.start+1):void 0==m||void 0!=f&&f.toString().length!=m.length?c?this._setSelectionStart(e.start+1):this._setSelectionStart(e.start-1):this._setSelectionStart(e.start));
1972b!=this.decimal&&(a.jqx.mobile.isTouchDevice()&&this._raiseEvent(0,{}),this._raiseEvent(7,{}));a.jqx.aria(this,"aria-valuenow",this.decimal)}}}},_getspindecimal:function(){var b=this._selection(),c="";this._getSeparatorPosition();var d=this._getVisibleItems(),e=this._getHiddenPrefixCount(),f=this.numberInput.val();this.numberInput.val().length==b.start&&0==b.length&&(this._setSelection(b.start,b.start+1),b=this._selection());var g="advanced"!=this.inputMode;b=b.start;0===b&&b++;1===b&&"left"===this.symbolPosition&&
1973""!==this.symbol&&(b+=this.symbol.length);for(var h=0;h<b;h++)if(g){var k=f.substring(h,h+1),l=!isNaN(parseInt(k));l&&(c+=k);k==this.decimalSeparator&&(c+=k)}
1973else d[h].canEdit&&d[h].character!=this.promptChar?c+=d[h].character:d[h].canEdit||-1==this.decimalSeparatorPosition||d[h]!=d[this.decimalSeparatorPosition-e]||(0==c.length&&(c="0"),c+=d[h].character);var m="";for(h=b;h<d.length;h++)g?(k=f.substring(h,h+1),(l=!isNaN(parseInt(k)))&&(m+=k),k==this.decimalSeparator&&(m+=k)):d[h].canEdit&&d[h].character!=
1974this.promptChar?m+=d[h].character:d[h].canEdit||-1==this.decimalSeparatorPosition||d[h]!=d[this.decimalSeparatorPosition-e]||(m+=d[h].character);return{decimal:this.getvalue("negative")?"-"+this._parseDecimalValue(c).toString():this._parseDecimalValue(c).toString(),afterdecimal:this._parseDecimalValue(m)}},_parseDecimalValue:function(b){if("."!=this.decimalSeparator){var c=b.toString().indexOf(this.decimalSeparator);if(0<=c)return b.toString().substring(0,c)+"."+b.toString().substring(c+1)}return b},
1975_parseDecimalValueToEditorValue:function(b){if("."!=this.decimalSeparator){var c=b.toString().indexOf(".");if(0<=c)return b.toString().substring(0,c)+this.decimalSeparator+b.toString().substring(c+1)}return b},spinUp:function(){var b=this.decimal;if("none"!=this.spinMode)if(null==this.decimal)this.setDecimal(0);else{(a.jqx.mobile.isTouchDevice()||"textbox"==this.inputMode)&&this._doTouchHandling();var c=this.getvalue("negative"),d=c?-1:0;if(!this.disabled){var e=this._selection(),f=this.decimal,g=
1976this.getDecimal();if(g<this.min)this.setDecimal(this.min),this._setSelectionStart(e.start),this.spinUp();else if(g>this.max)this.setDecimal(this.max),this._setSelectionStart(e.start),this.spinUp();else{0>this.spinButtonsStep&&(this.spinButtonsStep=1);var h=parseInt(this.decimal)+this.spinButtonsStep;h=h.toString().length;var k=d+h<=this.digits;if("advanced"!=this.spinMode){if(g+this.spinButtonsStep<=this.max&&k){h=1;for(c=0;c<this.decimalDigits;c++)h*=10;g=h*g+h*this.spinButtonsStep;g=this._parseDecimalValueToEditorValue(g/
1977h);this.setDecimal(g)}}else{var l=this._getspindecimal();this._getSeparatorPosition();g=parseFloat(l.decimal);0>this.spinButtonsStep&&(this.spinButtonsStep=1);h=parseInt(g)+this.spinButtonsStep;h=h.toString().length;k=d+h<=this.digits;h=1;var m=l.decimal.indexOf(".");if(-1!=m){var n=l.decimal.length-m-1;h=1;for(c=0;c<n;c++)h*=10;g+=new Number(this.spinButtonsStep/h);g=g.toFixed(n);m=g.toString().indexOf(".");-1==m&&(g=g.toString()+".");n=g.toString()+l.afterdecimal;n=new Number(n);n=n.toFixed(this.decimalDigits);
1978g=(new Number(n)).toFixed(this.decimalDigits);g<=this.max?(n=this._parseDecimalValueToEditorValue(n),this.setDecimal(n)):n=void 0}else g+this.spinButtonsStep<=this.max&&k&&(g=h*g+h*this.spinButtonsStep,n=(g/h).toString()+l.afterdecimal,g=(new Number(n)).toFixed(this.decimalDigits),g<=this.max?(n=this._parseDecimalValueToEditorValue(n),c&&-1==n.indexOf("-")&&"-0"!=l.decimal&&(n="-"+n),this.setDecimal(n)):n=void 0)}void 0==n||"simple"!=this.inputMode?(this._setSelectionStart(e.start),this.savedValue=
1979this.numberInput[0].value):(n=this.decimal.toString(),c=this.getvalue("negative"),-1!=d||c?void 0==n||void 0!=f&&f.toString().length!=n.length?c?this._setSelectionStart(e.start):this._setSelectionStart(1+e.start):this._setSelectionStart(e.start):this._setSelectionStart(-1+e.start));b!=this.decimal&&(a.jqx.mobile.isTouchDevice()&&this._raiseEvent(0,{}),this._raiseEvent(7,{}));a.jqx.aria(this,"aria-valuenow",this.decimal)}}}},_exitSimpleInputMode:function(b,c,d,e){void 0==c&&(c=b.data);if(null!=c){if(void 0==
1980d){if(null!=b.target&&null!=c.element&&(void 0!=b.target.id&&0<b.target.id.toString().length&&0<c.host.find("#"+b.target.id).length||b.target==c.element))return;e=c.host.offset();d=e.left;e=e.top;var f=c.host.width(),g=c.host.height();b=a(b.target).offset();if(b.left>=d&&b.left<=d+f&&b.top>=e&&b.top<=e+g)return}a.jqx.mobile.isOperaMiniBrowser()&&c.numberInput.attr("readonly",!0);if(!c.disabled&&!c.readOnly&&null!=a.data(c.numberInput,"simpleInputMode"))return a.data(c.numberInput,"simpleInputMode",
1981null),this._parseDecimalInSimpleMode(),!1}},_getDecimalInSimpleMode:function(){var b=this.decimal;if("."!=this.decimalSeparator){var c=b.toString().indexOf(this.decimalSeparator);0<c&&(b=b.toString().substring(0,c)+"."+b.toString().substring(c+1))}return b},_parseDecimalInSimpleMode:function(b){var c=this.getvalue("negative"),d=this.ValueString;void 0==d&&(d=this.GetValueString(this.numberInput.val(),this.decimalSeparator,""!=this.decimalSeparator));if("."!=this.decimalSeparator){var e=d.toString().indexOf(".");
19820<e&&(d=d.toString().substring(0,e)+this.decimalSeparator+d.toString().substring(e+1))}c=c?"-":"";"left"==this.symbolPosition&&(c+=this.symbol);d=d.toString();0<=d.indexOf("-")&&(d=d.substring(d.indexOf("-")+1));c+=d;"right"==this.symbolPosition&&(c+=this.symbol);0!=b&&this.numberInput.val(c)},_enterSimpleInputMode:function(b,c){void 0==c&&(c=b.data);b=this._selection();if(null!=c){var d=c.getvalue("negative"),e=c.decimal;d&&0<e&&(e=-e);c.numberInput.val(e);a.data(c.numberInput,"simpleInputMode",
1983!0);a.jqx.mobile.isOperaMiniBrowser()&&c.numberInput.attr("readonly",!1);this._parseDecimalInSimpleMode();this._setSelectionStart(b.start)}},setvalue:function(b,c){void 0!==this[b]&&("decimal"==b?this._setDecimal(c):(this[b]=c,this.propertyChangedH
1983andler(this,b,c,c)))},getvalue:function(b){return"decimal"==b&&void 0!=this.negative&&1==this.negative?this.decimal.toString().indexOf(",")?-Math.abs(this.decimal.toString().replace(/,/,".")):-Math.abs(this[b]):b in this?this[b]:null},_getString:function(){for(var b=
1984"",c=0;c<this.items.length;c++)b+=this.items[c].character;return b},_literal:function(b,c,d,e){return{character:b,regex:c,canEdit:d,isSeparator:e}},_initializeLiterals:function(){if("textbox"!=this.inputMode){for(var b=0,c=this.negativeSymbol.length,d=0;d<c;d++){var e=this.negativeSymbol.substring(d,d+1),f="",g=!1;e=this.negative?this._literal(e,f,g,!1):this._literal("",f,g,!1);this.items[b]=e;b++}c=this.symbol.length;if("left"==this.symbolPosition)for(d=0;d<c;d++)e=this.symbol.substring(d,d+1),f=
1985"",g=!1,e=this._literal(e,f,g,!1),this.items[b]=e,b++;var h=this.digits%this.groupSize;0==h&&(h=this.groupSize);for(d=0;d<this.digits;d++)e=this.promptChar,f="\\d",g=!0,e=this._literal(e,f,g,!1),this.items[b]=e,b++,d<this.digits-1&&void 0!=this.groupSeparator&&0<this.groupSeparator.length?(h--,0==h&&(h=this.groupSize,e=this._literal(this.groupSeparator,"",!1,!1),this.items[b]=e,b++)):d==this.digits-1&&(e.character=0);this.decimalSeparatorPosition=-1;if(void 0!=this.decimalDigits&&0<this.decimalDigits)for(e=
1986this.decimalSeparator,0==e.length&&(e="."),e=this._literal(e,"",!1,!0),this.items[b]=e,this.decimalSeparatorPosition=b,b++,d=0;d<this.decimalDigits;d++)f="\\d",h=this._literal(0,f,!0,!1),this.items[b]=h,b++;if("right"==this.symbolPosition)for(d=0;d<c;d++)e=this.symbol.substring(d,d+1),f="",g=!1,e=this._literal(e,f,g),this.items[b]=e,b++}},_match:function(b,c){return(new RegExp(c,"i")).test(b)},_raiseEvent:function(b,c){var d=this.events[b],e={owner:this};if("none"==this.host.css("display"))return!0;
1987var f=c.charCode?c.charCode:c.keyCode?c.keyCode:0,g=!0,h=this.readOnly;if((3==b||2==b)&&!this.disabled)if("simple"!=this.inputMode&&"textbox"!=this.inputMode)this._handleMouse(c);else return!0;if(0==b){var k=this.getvalue("decimal");this.max<k||this.min>k?this.host.addClass(this.toThemeProperty("jqx-input-invalid")):(this.host.removeClass(this.toThemeProperty("jqx-input-invalid")),this.host.addClass(this.toThemeProperty("jqx-input")),this.host.addClass(this.toThemeProperty("jqx-rc-all")))}k=new a.Event(d);
1988k.owner=this;e.value=this.getvalue("decimal");e.text=this.numberInput.val();k.args=e;7==b&&(e.type=this.changeType,this.changeType=null);void 0!=d&&4!=b&&5!=b&&6!=b&&(g=this.host.trigger(k));if("textbox"==this.inputMode)return g;if("simple"!=this.inputMode)if(4==b){if(h||this.disabled)return!1;g=this._handleKeyDown(c,f)}else if(5==b){if(h||this.disabled)g=!1}else{if(6==b){if(h||this.disabled)return!1;g=this._handleKeyPress(c,f)}}else if(4==b||5==b||6==b){if(a.jqx.mobile.isTouchDevice()||!0===this.touchMode)return!0;
1989if(h||this.disabled)return!1;d=String.fromCharCode(f);parseInt(d);d=!0;c.ctrlKey||c.shiftKey||c.metaKey||65<=f&&90>=f&&(d=!1);if(6==b&&void 0!=a.jqx.browser.opera&&8==f)return!1;if(d){4==b&&(d=this._handleSimpleKeyDown(c,f));107==f&&(g=this.getvalue("negative"))&&(this.setvalue("negative",!1),this.decimal=this.ValueString,this._parseDecimalInSimpleMode(),this._setSelectionStart(l.start+1),this._raiseEvent(0,this.value),this._raiseEvent(1,this.numberInput.val()));if(189==f||45==f||109==f||173==f){var l=
1990this._selection();4==b&&(g=this.getvalue("negative"),0==g?this.setvalue("negative",!0):this.setvalue("negative",!1),this.decimal=this.ValueString,this._parseDecimalInSimpleMode(),g?this._setSelectionStart(l.start-1):this._setSelectionStart(l.start+1),d=!1,this._raiseEvent(0,this.value),this._raiseEvent(1,this.numberInput.val()))}e=e.ctrlKey||e.metaKey;if(!a.jqx.browser.msie&&(e&&99==f||e&&67==f||e&&122==f||e&&90==f||e&&118==f||e&&86==f||c.shiftKey&&45==f))return(a.jqx.browser.webkit||a.jqx.browser.chrome)&&
1991this._handleSimpleKeyDown(c,f),67==f?!0:!1;if(e&&97==f||e&&65==f)return!0;if(6==b&&d)return this._isSpecialKey(f)}return d}return g},GetSelectionInValue:function(b,c,d,e){for(var f=0,g=0;g<c.length&&!(g>=b);g++){var h=c.substring(g,g+1);(!isNaN(parseInt(h))||e&&c.substring(g,g+1)==d)&&f++}return f},GetSelectionLengthInValue:function(b,c,d,e){for(var f=0,g=0;g<d.length&&!(g>=b+c);g++){var h=d.substring(g,g+1);h=!isNaN(parseInt(h));(0<c&&g>=b&&h||g>=b&&d[g].toString()==e)&&f++}return f},GetInsertTypeByPositionInValue:function(b,
1992c,d,e){var f="before";d=this.GetValueString(d,c,e);c=this.GetDigitsToSeparator(0,d,c);b>c&&(f="after");return f},RemoveRange:function(b,c,d,e,f,g){var h=this.digits,k=c,l=0;this._selection();e=this.decimalSeparator;var m=""!=e;if(0==k&&this.ValueString.length<this.decimalPossibleChars-1)return l;var n=this.GetSeparatorPositionInText(e,d);f||(n=this.GetSeparatorPositionInText(e,d));0>n&&!m&&1<d.length&&(n=d.length);-1==n&&(n=d.length);2>c&&1==g&&this.ValueString.length-this.decimalDigits-(m?1:0)==
1993h&&b+c<n&&k++;c="";for(g=0;g<d.length;g++)g<b||g>=b+k?c+=d.substring(g,g+1):(h=d.substring(g,g+1),h==e?c+=e:(h=d.substring(g,g+1),this.symbol&&""!=this.symbol&&0<=this.symbol.indexOf(h)||(g>n?c+="0":(h=d.substring(g,g+1),isNaN(parseInt(h))||l++))));0==c.length&&(c="0");f?this.numberInput.val(c):this.ValueString=c;d=c.substring(0,1);d==e&&isNaN(parseInt(d))&&(c="0"+c);this.decimal=this.ValueString=this.GetValueString(c,e,m);this._parseDecimalInSimpleMode();this._setSelectionStart(b);return l},InsertDigit:function(b,
1994c){"number"!=typeof this.digits&&(this.digits=parseInt(this.digits));"number"!=typeof this.decimalDigits&&(this.decimalDigits=parseInt(this.decimalDigits));var d=1+this.digits,e=this._selection(),f=this.getvalue("negative"),g=!1;0==e.start&&""!=this.symbol&&"left"==this.symbolPosition&&(this._setSelectionStart(e.start+1),e=this._selection(),g=!0);if(f&&g||f&&!g&&0==e.start)this._setSelectionStart(e.start+1),e=this._selection();var h=this.numberInput.val().substring(e.start,e.start+1),k=this.numberInput.val();
1995g=this.decimalSeparator;var l=""!=g&&0<this.decimalDigits;if(h==this.symbol&&"right"==this.symbolPosition)if(0==this.decimalDigits){if(this.ValueString=this.GetValueString(k,g,l),this.ValueString.length>=d)return}else return;this.ValueString=this.GetValueString(k,g,l);""==this.ValueString&&(this.ValueString=(new Number(0)).toFixed(this.decimalDigits));h=this.ValueString;0<this.decimalDigits&&c>=h.length&&(c=h.length-1);var m="";c<h.length&&(m=h.substring(c,c+1));var n=!1;"after"==this.GetInsertTypeByPositionInValue(c,
1996g,k,l)&&(n=!0);m!=g&&this.ValueString.length-this.decimalDigits-(l?1:0)>=d-1&&(n=!0);"0"===m&&1===this.ValueString.length&&0===this.decimalDigits&&(n=!0);k=l?1:0;if(!(!n&&this.ValueString&&this.ValueString.length>
1996=this.digits+this.decimalDigits+k)){if(n&&m!=g){d=h.substring(0,c);if(d.length==h.length&&this.ValueString.length>=this.digits+this.decimalDigits+k)return;k="";c+1<h.length&&(k=h.substring(c+1));this.ValueString=d+b+k}else d=h.substring(0,c),k=h.substring(c),c=d+b+k,"0"==h.substring(0,1)&&
1997h.substring(1,2)==g&&(c=b+h.substring(1),m==g&&(this._setSelectionStart(e.start-1),e=this._selection())),this.ValueString=c;this.decimal=f?-this.ValueString:this.ValueString;this._parseDecimalInSimpleMode();this._setSelectionStart(e.start+1);this.value=this.decimal;this._raiseEvent(0,this.value);this._raiseEvent(1,this.numberInput.val())}},GetStringToSeparator:function(b,c,d){var e=this.GetSeparatorPositionInText(c,b);b=b.subString(0,e);return this.GetValueString(b,c,d)},GetSeparatorPositionInText:function(b,
1998c){for(var d=-1,e=0;e<c.length;e++)if(c.substring(e,e+1)==b){d=e;break}return d},GetValueString:function(b,c,d){d="";for(var e=0;e<b.length;e++){var f=b.substring(e,e+1);isNaN(parseInt(f))||(d+=f);f==c&&(d+=c)}return d},Backspace:function(){var b=this._selection(),c=this._selection(),d=this.numberInput.val();if(0!=b.start||0!=b.length)this.isBackSpace=!0,d=d.substring[b.start,b.start+1],isNaN(parseInt(d)),0<b.start&&0==b.length&&(this._setSelectionStart(b.start-1),this._selection()),this.Delete(),
1999this._setSelectionStart(c.start-1),this.isBackSpace=!1},Delete:function(b){var c=this._selection(),d=this.numberInput.val();0===c.start&&"-"==d.substring(0,1)&&(this.setvalue("negative",!1),c=this._selection(),d=this.numberInput.val());b=c.start;var e=c.length;e=Math.max(e,1);this.ValueString=this.GetValueString(d,this.decimalSeparator,""!=this.decimalSeparator);b>this.ValueString.indexOf(this.decimalSeparator)&&0<this.decimalDigits&&b++;d=0;this.symbol&&("left"==this.symbolPosition&&d--,this.negative&&
2000d--);this.RemoveRange(c.start+d,e,this.ValueString,".",!1);c=this.ValueString.substring(0,1);isNaN(parseInt(c))&&(this.ValueString="0"+this.ValueString);this.decimal=this.ValueString;this._parseDecimalInSimpleMode();this._setSelectionStart(b);this.value=this.decimal;this._raiseEvent(0,this.value);this._raiseEvent(1,this.numberInput.val())},insertsimple:function(b){var c=this._selection(),d=this.numberInput.val();if(!(c.start==d.length&&null!=this.decimal&&0<this.decimalDigits)){var e=this.decimalSeparator;
2001this.ValueString=this.GetValueString(d,e,""!=e);var f=this.GetSelectionInValue(c.start,d,e,""!=e);d=this.GetSelectionLengthInValue(c.start,c.length,d,e);this.GetDigitsToSeparator(0,this.ValueString,e);0<this.decimalDigits&&f>=this.ValueString.length&&f--;""==this.ValueString?(this.ValueString=(new Number(0)).toFixed(this.decimalDigits),this.ValueString=this.ValueString.replace(".",e),this.RemoveRange(c.start,d,this.ValueString,e,!1,!0),this.InsertDigit(b,0,c)):(this.RemoveRange(c.start,d,this.ValueString,
2002e,!1,!0),this.InsertDigit(b,f,c))}},GetDigitsToSeparator:function(b,c,d){void 0==d&&(d=".");if(0>c.indexOf(d))return c.length;for(var e=0;e<c.length;e++)if(c.substring(e,e+1)==d){b=e;break}return b},_handleSimpleKeyDown:function(b,c){var d=this._selection(),e=b.ctrlKey||b.metaKey;if((8==c||46==c)&&e)return this.setDecimal(null),!1;0<=d.start&&d.start<this.items.length&&(e=String.fromCharCode(c));27===c&&(this.setDecimal(this._savedValue),e=this.GetSeparatorPositionInText(this.decimalSeparator,this.numberInput.val()),
2003-1!=e&&this._setSelectionStart(e),b.preventDefault());if(this.rtl&&37==c)return b=(c=b.shiftKey)?1:0,c?this._setSelection(d.start+1-b,d.start+d.length+1):this._setSelection(d.start+1-b,d.start+1),!1;if(this.rtl&&39==c)return(c=b.shiftKey)?this._setSelection(d.start-1,d.length+(c?1:0)+d.start-1):this._setSelection(d.start-1,d.start-1),!1;if(8==c)return this.Backspace(),!1;if(190==c||110==c)return e=this.GetSeparatorPositionInText(this.decimalSeparator,this.numberInput.val()),-1!=e&&this._setSelectionStart(e+
20041),!1;if(188==c&&","===this.groupSeparator){b=this.numberInput.val();for(c=d.start;c<b.length;c++)if(b[c]==this.groupSeparator){this._setSelectionStart(1+c);break}return!1}if((e=b.ctrlKey||b.metaKey)&&99==c||e&&67==c){d=this._selection();b="";e=this.numberInput.val();if(0<d.start||0<d.length)for(c=d.start;c<d.end;c++)b+=e.substring(c,c+1);a.data(document.body,"jqxSelection",b);if(a.jqx.browser.msie)window.clipboardData.setData("Text",b);else{var f=this,g=a('<textarea style="position: absolute; left: -1000px; top: -1000px;"/>');
2005g.val(b);a("body").append(g);g.select();setTimeout(function(){document.designMode="off";g.select();g.remove();f.focus()},100)}this.savedText=b;return!0}if(e&&122==c||e&&90==c)return!1;if(e&&118==c||e&&86==c||b.shiftKey&&45==c)return a.jqx.browser.msie&&!this.savedText&&(this.savedText=window.clipboardData.getData("Text")),null!=this.savedText&&0<this.savedText.length?this.val(this.savedText):this.val(a.data(document.body,"jqxSelection")),!1;e=String.fromCharCode(c);d=parseInt(e);96<=c&&105>=c&&(d=
2006c-96,c-=48);if(!isNaN(d))return f=this,this.insertsimple(d),!1;if(46==c)return this.Delete(),!1;if(38==c)return this.spinUp(),!1;if(40==c)return this.spinDown(),!1;d=this._isSpecialKey(c);return a.jqx.browser.mozilla?d:!0},_getEditRange:function(){for(var b=0,c=0,d=0;d<this.items.length;d++)if(this.items[d].canEdit){b=d;break}for(d=this.items.length-1;0<=d;d--)if(this.items[d].canEdit){c=d;break}return{start:b,end:c}},_getVisibleItems:function(){for(var b=[],c=0,d=0;d<this.items.length;d++)0<this.items[d].character.toString().length&&
2007(b[c]=this.items[d],c++);return b},_hasEmptyVisibleItems:function(){for(var b=this._getVisibleItems(),c=0;c<b.length;c++)if(b[c].canEdit&&b[c].character==this.promptChar)return!0;return!1},_getFirstVisibleNonEmptyIndex:function(){for(var b=this._getVisibleItems(),c=0;c<b.length;c++)if(b[c].canEdit&&b[c].character!=this.promptChar)return c}
2007,_handleMouse:function(b,c){b=this._selection();1>=b.length&&(c=this._getFirstVisibleNonEmptyIndex(),b.start<c&&this._setSelectionStart(c))},_insertKey:function(b){this.numberInput[0].focus();
2008var c=String.fromCharCode(b);b=parseInt(c);if(!isNaN(b)){var d=0;for(b=0;b<this.items.length;b++)0==this.items[b].character.length&&d++;var e=this._selection(),f=this;if(0<=e.start&&e.start<=this.items.length){var g=!1;b=this._getFirstVisibleNonEmptyIndex();e.start<b&&0==e.length&&(!isNaN(c)||" "==c)&&(this._setSelectionStart(b),e=this._selection());this._getFirstEditableItemIndex();var h=this._getLastEditableItemIndex();null===this.value&&(h=0);var k=this._getVisibleItems();a.each(k,function(l,m){if(!(e.start>
2009l&&l!=k.length-1)){var n=k[l];l>h&&(n=k[h]);if(!isNaN(c)&&" "!=c&&""!=c&&n&&n.canEdit&&(m=f._getSeparatorPosition(),f._match(c,n.regex))){if(!g&&0<e.length){for(var r=e.start+d;r<e.end+d;r++)f.items[r].canEdit&&(f.items[r].character=r>m?"0":f.promptChar);f._getString();g=!0}m=f._getSeparatorPosition();r=f._hasEmptyVisibleItems();null==f.decimal&&(e.start=m-1,0>e.start&&(e.start=0),e.end=e.start);if(e.start<=m&&r){n=l;-1==f.decimalSeparatorPosition&&e.start==m&&(n=l+1);null==f.decimal&&(n=e.start);
2010r="";for(var t=0;t<n;t++)k[t].canEdit&&k[t].character!=f.promptChar&&(r+=k[t].character);r+=c;l=1>f.decimal?1:0;e.start==m&&-1!=f.decimalSeparatorPosition&&(r+=f.decimalSeparator,l=0);for(t=n+l;t<k.length;t++)k[t].character==f.decimalSeparator&&k[t].isSeparator?r+=k[t].character:k[t].canEdit&&k[t].character!=f.promptChar&&(r+=k[t].character);"."!=f.decimalSeparator&&(r=f._parseDecimalValue(r));r=parseFloat(r).toString();r=new Number(r);r=r.toFixed(f.decimalDigits);"."!=f.decimalSeparator&&(r=f._parseDecimalValueToEditorValue(r));
2011f.setvalue("decimal",r);f._getString();e.end<m?f._setSelectionStart(e.end+l):f._setSelectionStart(e.end);1<=e.length&&f._setSelectionStart(e.end);e.length==f.numberInput.val().length&&(l=f._moveCaretToDecimalSeparator(),f._setSelectionStart(l-(0<=f.decimalSeparatorPosition?1:0)))}else if(e.start<m||e.start>m){if(f.numberInput.val().length==e.start&&-1!=f.decimalSeparatorPosition||f.numberInput.val().length==e.start&&-1==f.decimalSeparatorPosition&&!r)return!1;r="";var u=!1;for(t=0;t<l;t++)k[t].canEdit&&
2012k[t].character!=f.promptChar&&(r+=k[t].character),k[t].character==f.decimalSeparator&&k[t].isSeparator&&(r+=k[t].character,u=!0);r+=c;u||e.start!=m-1||(r+=f.decimalSeparator,u=!0);for(t=l+1;t<k.length;t++)!u&&k[t].character==f.decimalSeparator&&k[t].isSeparator?r+=k[t].character:k[t].canEdit&&k[t].character!=f.promptChar&&(r+=k[t].character);f.setvalue("decimal",r);m=f._getString();if(0>f.decimalSeparatorPosition&&n==k[h])return f._setSelectionStart(l),!1;n=m.indexOf(f.symbol);r=f.getvalue("negative")?
20131:0;n<=r&&(n=m.length);e.start<n?f._setSelectionStart(l+1):f._setSelectionStart(l);e.length==f.numberInput.val().length&&(l=f._moveCaretToDecimalSeparator(),f._setSelectionStart(l-1))}return!1}}})}}},_handleKeyPress:function(b,c){var d=this._selection();if((b=b.ctrlKey||b.metaKey)&&97==c||b&&65==c)return!0;if(8==c)return 0<d.start&&this._setSelectionStart(d.start),!1;if(46==c)return d.start<this.items.length&&this._setSelectionStart(d.start),!1;a.jqx.browser.mozilla||45!=c&&173!=c&&109!=c&&189!=c||
2014(0==this.getvalue("negative")?this.setvalue("negative",!0):this.setvalue("negative",!1));a.jqx.browser.msie&&this._insertKey(c);return this._isSpecialKey(c)},_deleteSelectedText:function(){var b=this._selection(),c="",d=this._getSeparatorPosition(),e=this._getVisibleItems(),f=this._getHiddenPrefixCount();this.numberInput.val().length==b.start&&0==b.length&&(this._setSelection(b.start,b.start+1),b=this._selection());for(var g=0;g<b.start;g++)e[g].canEdit&&e[g].character!=this.promptChar?c+=e[g].character:
2015e[g].canEdit||-1==this.decimalSeparatorPosition||e[g]!=e[this.decimalSeparatorPosition-f]||(0==c.length&&(c="0"),c+=e[g].character);for(g=b.start;g<b.end;g++)g>d&&-1!=this.decimalSeparatorPosition?e[g].canEdit&&e[g].character!=this.promptChar&&(c+="0"):e[g].canEdit||-1==this.decimalSeparatorPosition||e[g]!=e[this.decimalSeparatorPosition-f]||(0==c.length&&(c="0"),c+=e[g].character);for(g=b.end;g<e.length;g++)e[g].canEdit&&e[g].character!=this.promptChar?c+=e[g].character:e[g].canEdit||-1==this.decimalSeparatorPosition||
2016e[g]!=e[this.decimalSeparatorPosition-f]||(0==c.length&&(c="0"),c+=e[g].character);this.setvalue("decimal",c);return 0<b.length},_restoreInitialState:function(){var b=parseInt(this.decimalDigits);0<b&&(b+=2);for(var c=this.items.length-1;c>this.items.length-1-b&&this.items[c];c--)this.items[c].canEdit&&this.items[c].character==this.promptChar&&(this.items[c].character=0)},clear:function(){this.setDecimal(0)}
2016,clearDecimal:function(){if("textbox"==this.inputMode)this.numberInput.val();else{for(var b=
20170;b<this.items.length;b++)this.items[b].canEdit&&(this.items[b].character=this.promptChar);this._restoreInitialState()}},_saveSelectedText:function(){var b=this._selection(),c="",d=this._getVisibleItems();if(0<b.start||0<b.length)for(var e=b.start;e<b.end;e++)d[e].canEdit&&d[e].character!=this.promptChar?c+=d[e].character:d[e].isSeparator&&(c+=d[e].character);a.jqx.browser.msie&&window.clipboardData.setData("Text",c);return c},_pasteSelectedText:function(){this._selection();this.selectedText=a.data(document.body,
2018"jqxSelection");if(window.clipboardData){var b=window.clipboardData.getData("Text");if(b!=this.selectedText&&0<b.length&&(this.selectedText=window.clipboardData.getData("Text"),null==this.selectedText||void 0==this.selectedText))return}this._getVisibleItems();if(null!=this.selectedText)for(b=0;b<this.selectedText.length;b++){var c=parseInt(this.selectedText[b]);isNaN(c)||this._insertKey(48+c)}},_getHiddenPrefixCount:function(){var b=0;this.negative||b++;if("left"==this.symbolPosition)for(var c=0;c<
2019this.symbol.length;c++)""==this.symbol.substring(c,c+1)&&b++;return b},_getEditableItem:function(){for(var b=this._selection(),c=0;c<this.items.length;c++)if(c<b.start&&this.items[c].canEdit&&this.items[c].character!=this.promptChar)return this.items[c];return null},_getEditableItems:function(){for(var b=[],c=0,d=0;d<this.items.length;d++)this.items[d].canEdit&&(b[c]=this.items[d],c++);return b},_getValidSelectionStart:function(b){for(b=this.items.length-1;0<=b;b--)if(this.items[b].canEdit&&this.items[b].character!=
2020this.promptChar)return b;return-1},_getEditableItemIndex:function(b){b=this._selection();for(var c=this._getHiddenPrefixCount(),d=this._getVisibleItems(),e=b.start,f=-1,g=0;g<e;g++)g<d.length&&d[g].canEdit&&(f=g+c);if(-1==f&&0<b.length)for(e=b.end,g=0;g<e;g++)if(g<d.length&&d[g].canEdit){f=g+c;break}return f},_getEditableItemByIndex:function(b){for(var c=0;c<this.items.length;c++)if(c>b&&this.items[c].canEdit&&this.items[c].character!=this.promptChar)return c;return-1},_getFirstEditableItemIndex:function(){for(var b=
2021this._getVisibleItems(),c=0;c<b.length;c++)if(b[c].character!=this.promptChar&&b[c].canEdit&&"0"!=b[c].character)return c;return-1},_getLastEditableItemIndex:function(){for(var b=this._getVisibleItems(),c=b.length-1;0<=c;c--)if(b[c].character!=this.promptChar&&b[c].canEdit)return c;return-1},_moveCaretToDecimalSeparator:function(){for(var b=this.items.length-1;0<=b;b--)if(this.items[b].character==this.decimalSeparator&&this.items[b].isSeparator)return this.negative?this._setSelectionStart(b+1):this._setSelectionStart(b),
2022b;return this.numberInput.val().length},_handleBackspace:function(){var b=this._selection(),c=this._getHiddenPrefixCount(),d=this._getEditableItemIndex()-c,e=this._getFirstVisibleNonEmptyIndex();c=!1;this.negative&&(c=!0,e>=d+1||0==b.start)&&(this.setvalue("negative",!1),0==b.length&&(this._setSelectionStart(b.start-1),b=this._selection()));if(0<=d){if(0==b.length&&-1!=d&&this._setSelection(d,d+1),(d=b.start>this._getSeparatorPosition()+1&&0<this.decimalSeparatorPosition)&&(b=this._selection()),this._deleteSelectedText(),
20231>b.length||d?this._setSelectionStart(b.start):1<=b.length&&this._setSelectionStart(b.end),b.length==this.numberInput.val().length||c)b=this._moveCaretToDecimalSeparator(),this._setSelectionStart(b-1)}else this._setSelectionStart(b.start)},_handleKeyDown:function(b,c){var d=this._selection(),e=b.ctrlKey||b.metaKey;if((8==c||46==c)&&e)return this.setDecimal(null),!1;if(this.rtl&&37==c)return b=(c=b.shiftKey)?1:0,c?this._setSelection(d.start+1-b,d.start+d.length+1):this._setSelection(d.start+1-b,d.start+
20241),!1;if(this.rtl&&39==c)return(c=b.shiftKey)?this._setSelection(d.start-1,d.length+(c?1:0)+d.start-1):this._setSelection(d.start-1,d.start-1),!1;if(e&&97==c||e&&65==c)return!0;if(e&&120==c||e&&88==c)return this.selectedText=this._saveSelectedText(b),a.data(document.body,"jqxSelection",this.selectedText),this._handleBackspace(),!1;if(e&&99==c||e&&67==c)return this.selectedText=this._saveSelectedText(b),a.data(document.body,"jqxSelection",this.selectedText),!1;if(e&&122==c||e&&90==c)return!1;if(e&&
2025118==c||e&&86==c||b.shiftKey&&45==c)return this._pasteSelectedText(),!1;0<=d.start&&d.start<this.items.length&&String.fromCharCode(c);if(8==c)return this._handleBackspace(),!1;if(190==c||110==c||188===c&&","===this.decimalSeparator)return this._moveCaretToDecimalSeparator(),!1;if(188==c&&","===this.groupSeparator){c=this.numberInput.val();for(d=d.start;d<c.length;d++)if(c[d]==this.groupSeparator){this._setSelectionStart(1+d);break}return!1}if(null==a.jqx.browser.msie&&(e=String.fromCharCode(c),e=
2026parseInt(e),96<=c&&105>=c&&(e=c-96,c-=48),!isNaN(e)))return this._insertKey(c),!1;if(46==c){c=this._getVisibleItems();if(d.start<c.length){b=0==c[d.start].canEdit?2:1;if(0==d.start&&this.negative&&(this.setvalue("negative",!1),0==d.length&&this._setSelectionStart(0),d=this._selection(),0==d.length))return!1;0==d.length&&this._setSelection(d.start+b,d.start+b+d.length);this._handleBackspace();1>new Number(this.decimal)||d.start>this._getSeparatorPosition()?this._setSelectionStart(d.end+b):d.start+
20271<this.decimalSeparatorPosition&&this._setSelectionStart(d.end+b)}return!1}if(38==c)return this.spinUp(),!1;if(40==c)return this.spinDown(),!1;27===c&&(this.setDecimal(this._savedValue),this._setSelectionStart(d.end),b.preventDefault());d=this._isSpecialKey(c);
2027!a.jqx.browser.mozilla||45!=c&&173!=c&&109!=c&&189!=c||(0==this.getvalue("negative")?this.setvalue("negative",!0):this.setvalue("negative",!1));return a.jqx.browser.mozilla?d:!0},_isSpecialKey:function(b){return 8!=b&&9!=b&&13!=b&&35!=b&&36!=
2028b&&37!=b&&39!=b&&27!=b&&46!=b?!1:!0},_selection:function(){try{if("selectionStart"in this.numberInput[0]){var b=this.numberInput[0],c=b.selectionEnd-b.selectionStart;return{start:b.selectionStart,end:b.selectionEnd,length:c,text:b.value}}var d=document.selection.createRange();if(null==d)return{start:0,end:b.value.length,length:0};var e=this.numberInput[0].createTextRange(),f=e.duplicate();e.moveToBookmark(d.getBookmark());f.setEndPoint("EndToStart",e);c=d.text.length;return{start:f.text.length,end:f.text.length+
2029d.text.length,length:c,text:d.text}}catch(g){return{start:0,end:0,length:0}}},selectAll:function(){var b=this.numberInput;setTimeout(function(){if("selectionStart"in b[0])b[0].focus(),b[0].setSelectionRange(0,b[0].value.length);else{var c=b[0].createTextRange();c.collapse(!0);c.moveEnd("character",b[0].value.length);c.moveStart("character",0);c.select()}},10)},_setSelection:function(b,c){if(1!=this._disableSetSelection&&!a.jqx.mobile.isTouchDevice()&&1!=this.touchMode)try{if("selectionStart"in this.numberInput[0])this.numberInput[0].focus(),
2030this.numberInput[0].setSelectionRange(b,c);else{var d=this.numberInput[0].createTextRange();d.collapse(!0);d.moveEnd("character",c);d.moveStart("character",b);d.select()}}catch(e){}},_setSelectionStart:function(b){this._setSelection(b,b);a.data(this.numberInput,"selectionstart",b)},resize:function(b,c){this.width=b;this.height=c;this._render(!1)},_render:function(b){var c=parseInt(this.host.css("border-left-width")),d=parseInt(this.host.css("border-left-width")),e=parseInt(this.host.css("border-left-width")),
2031f=parseInt(this.host.css("border-left-width"));this.numberInput.css("padding-top","0px");this.numberInput.css("padding-bottom","0px");var g=window.getComputedStyle(this.element),h=2*parseInt(g.borderLeftWidth);if("border-box"===g.boxSizing||isNaN(h))h=0;null!=this.width&&-1!=this.width.toString().indexOf("px")?this.element.style.width=parseInt(this.width)-h+"px":void 0==this.width||isNaN(this.width)||(this.element.style.width=parseInt(this.width)-h+"px");null!=this.height&&-1!=this.height.toString().indexOf("px")?
2032this.element.style.height=parseInt(this.height)-h+"px":void 0==this.height||isNaN(this.height)||(this.element.style.height=parseInt(this.height)-h+"px");g=this.host.width();h=this.host.height();this.numberInput.css({"border-left-width":0,"border-right-width":0,"border-bottom-width":0,"border-top-width":0});isNaN(e)&&(e=1);isNaN(d);isNaN(f);isNaN(c);this.numberInput.css("text-align",this.textAlign);c=this.numberInput.css("font-size");""==c&&(c=13);this.numberInput.css("height",parseInt(c)+4+"px");
2033this.numberInput.css("width",g-2);e=h-2*e-parseInt(c)-2;isNaN(e)&&(e=0);0>e&&(e=0);this.spinButtons&&this.spincontainer&&(g-=parseInt(this.spinButtonsWidth-2),a.jqx.mobile.isTouchDevice()||!0===this.touchMode?(this.spincontainer.width(2*this.spinButtonsWidth),g-=this.spinButtonsWidth,this.upbutton.height("100%"),this.downbutton.height("100%"),this.downbutton.css("float","left"),this.upbutton.css("float","right"),this.upbutton.width(this.spinButtonsWidth),this.downbutton.width(1+this.spinButtonsWidth)):
2034(this.spincontainer.width(this.spinButtonsWidth),this.upbutton.width(this.spinButtonsWidth+2),this.downbutton.width(this.spinButtonsWidth+2),this.upbutton.height("50%"),this.downbutton.height("50%"),this.spincontainer.width(this.spinButtonsWidth)),this._upArrow.height("100%"),this._downArrow.height("100%"),this.numberInput.css("width",g-6),this.numberInput.css("margin-right","2px"));c=e/2;a.jqx.browser.msie&&8>a.jqx.browser.version&&(c=e/4);this.numberInput.css("padding-left","0px");this.numberInput.css("padding-right",
2035"0px");this.numberInput.css("padding-top",Math.round(c)+"px");this.numberInput.css("padding-bottom",Math.round(c)+"px");if(void 0==b||1==b)this.numberInput.val(this._getString()),"advanced"!=this.inputMode&&this._parseDecimalInSimpleMode();this._addBarAndLabel(this.numberInput);this._updateHint()},_addBarAndLabel:function(b){if(null===this.bar&&null===this.label){var c=a("<label></label");this.hint&&(c[0].innerHTML=this.placeHolder);c.addClass(this.toThemeProperty("jqx-input-label"));b.after(c);this.label=
2036c;c=a("<span></span>");b.after(c);c.addClass(this.toThemeProperty("jqx-input-bar"));this.spinButtons?c.css("top",this.host.height()):c.css("top","0px");this.bar=c;this.template&&(this.bar.addClass(this.toThemeProperty("jqx-"+this.template)),this.label.addClass(this.toThemeProperty("jqx-"+this.template)))}},destroy:function(){this._removeHandlers();this.host.remove()}
2036,inputValue:function(b){if(void 0===b)return this._value();this.propertyChangedHandler(this,"value",this._value,b);this._refreshValue();
2037return this},val:function(b){if(void 0!==b&&"object"!=typeof b||null===b)if(null===b)this.setDecimal(null);else if(0>b)this.setDecimal(b);else{b=b.toString();-1<b.indexOf(this.symbol)&&(b=b.replace(this.symbol,""));b=b.replace(this.decimalSeparator,".");var c=this.groupSeparator,d=b;if(""!=c){for(b=d.indexOf(c);-1!=b;)d=d.replace(c,""),b=d.indexOf(c);b=d}c="";for(d=0;d<b.length;d++){var e=b.substring(d,d+1);"-"===e&&(c+="-");"."===e&&(c+=".");null!=e.match(/^[0-9]+$/)&&(c+=e)}b=c.replace(/ /g,"");
2038b=b.replace(".",this.decimalSeparator);this._setDecimal(b)}else return this.getDecimal()},getDecimal:function(){if(null==this.decimal)return null;"simple"==this.inputMode&&(this._parseDecimalInSimpleMode(!1),this.decimal=this._getDecimalInSimpleMode(this.decimal));return""==this.decimal?0:this.getvalue("negative")&&0<this.decimal?-parseFloat(this.decimal):parseFloat(this.decimal)},setDecimal:function(b){var c=b;if("."!=this.decimalSeparator)if(null===b)this._setDecimal(b);else{var d=b;if("number"!=
2039typeof b){b=b.toString();var e=b.indexOf(".");if(-1!=e){var f=b.substring(0,e);b=b.substring(e+1);d=f+"."+b;-1!=f.indexOf("-")&&(f=f.substring(1));b="advanced"!=this.inputMode?f+"."+b:f+this.decimalSeparator+b}else e=b.indexOf(this.decimalSeparator),-1!=e&&(f=b.substring(0,e),b=b.substring(e+1),d=f+"."+b,-1!=f.indexOf("-")&&(f=f.substring(1)),b="advanced"!=this.inputMode?f+"."+b:f+this.decimalSeparator+b)}0>d?this.setvalue("negative",!0):this.setvalue("negative",!1);null===b?this._setDecimal(b):this._setDecimal(Math.abs(b))}else 0>
2040b?this.setvalue("negative",!0):this.setvalue("negative",!1),null===b?this._setDecimal(b):this._setDecimal(Math.abs(b));null==c&&this.numberInput.val("");this._updateHint()},_setDecimal:function(b){this.allowNull||null!=b||(b=this.decimal=0);if(null==b)this.value=this.decimal=null,this.clearDecimal(),this._refreshValue(),this.value=this.decimal=null,this.ValueString="";else{-1!=b.toString().indexOf("e")&&(b=(new Number(b)).toFixed(this.decimalDigits).toString());this.clearDecimal();var c=b.toString(),
2041d="",e="",f=!0;0==c.length&&(c="0");for(var g=0;g<c.length;g++){if("number"==typeof b){if("."==c.substring(g,g+1)){f=!1;continue}}else if(c.substring(g,g+1)==this.decimalSeparator){f=!1;continue}f?d+=c.substring(g,g+1):e+=c.substring(g,g+1)}0<d.length&&(d=parseFloat(d).toString());g=this.digits;g<d.length&&(d=d.substr(0,g));c=0;f=this._getSeparatorPosition();g=this._getHiddenPrefixCount();for(g=f+=g;0<=g;g--)g<this.items.length&&this.items[g].canEdit&&c<d.length&&(this.items[g].character=d.substring(d.length-
2042c-1,d.length-c),c++);c=0;for(g=f;g<this.items.length;g++)this.items[g].canEdit&&c<e.length&&(this.items[g].character=e.substring(c,c+1),c++);this._refreshValue();"."==this.decimalSeparator?this.ValueString=(new Number(b)).toFixed(this.decimalDigits):(d=b.toString().indexOf(this.decimalSeparator),0<d?(b=b.toString().substring(0,d)+"."+b.toString().substring(d+1),this.ValueString=(new Number(b)).toFixed(this.decimalDigits)):this.ValueString=(new Number(b)).toFixed(this.decimalDigits));"advanced"!=this.inputMode&&
2043(this._parseDecimalInSimpleMode(),this._raiseEvent(1,this.ValueString));"textbox"==this.inputMode&&(this.decimal=this.ValueString,this.getvalue("negative")&&(this.decimal="-"+this.ValueString));b=this.val();b<this.min||b>this.max?this.host.addClass("jqx-input-invalid"):this.host.removeClass("jqx-input-invalid");this._updateHint()}},_getSeparatorPosition:function(){var b=this._getHiddenPrefixCount();return 0<this.decimalSeparatorPosition?this.decimalSeparatorPosition-b:this.items.length-b},_setTheme:function(){this.host.removeClass();
2044this.host.addClass(this.toThemeProperty("jqx-input"));this.host.addClass(this.toThemeProperty("jqx-rc-all"));this.host.addClass(this.toThemeProperty("jqx-widget"));this.host.addClass(this.toThemeProperty("jqx-widget-content"));this.host.addClass(this.toThemeProperty("jqx-numberinput"));this.spinButtons&&(this.downbutton.removeClass(),this.upbutton.removeClass(),this.downbutton.addClass(this.toThemeProperty("jqx-scrollbar-button-state-normal")),this.upbutton.addClass(this.toThemeProperty("jqx-scrollbar-button-state-normal")),
2045this._upArrow.removeClass(),this._downArrow.removeClass(),this._upArrow.addClass(this.toThemeProperty("jqx-icon-arrow-up")),this._downArrow.addClass(this.toThemeProperty("jqx-icon-arrow-down")));this.numberInput.removeClass();this.numberInput.addClass(this.toThemeProperty("jqx-input-content"))}
2045,propertiesChangedHandler:function(b,c,d){d&&d.width&&d.height&&2==Object.keys(d).length&&b._render()},propertyChangedHandler:function(b,c,d,e){if(!(b.batchUpdate&&b.batchUpdate.width&&b.batchUpdate.height&&
20462==Object.keys(b.batchUpdate).length)){"template"==c&&(b.upbutton.removeClass(b.toThemeProperty("jqx-"+b.template)),b.downbutton.removeClass(b.toThemeProperty("jqx-"+b.template)),b.upbutton.addClass(b.toThemeProperty("jqx-"+b.template)),b.downbutton.addClass(b.toThemeProperty("jqx-"+b.template)));if(("digits"==c||"groupSize"==c||"decimalDigits"==c)&&0>e)throw new Exception(this.invalidArgumentExceptions[0]);"placeHolder"==c&&(b.isMaterialized()?b.hint&&(b.label[0].innerHTML=b.placeHolder):b.numberInput.attr("placeholder",
2047b.placeHolder));"theme"===c&&a.jqx.utilities.setTheme(d,e,b.host);"digits"==c&&e!=d&&(b.digits=parseInt(e));if("min"==c||"max"==c)a.jqx.aria(b,"aria-value"+c,e.toString()),b._refreshValue();"decimalDigits"==c&&e!=d&&(b.decimalDigits=parseInt(e));if("decimalSeparator"==c||"digits"==c||"symbol"==c||"symbolPosition"==c||"groupSize"==c||"groupSeparator"==c||"decimalDigits"==c||"negativeSymbol"==c){var f=b.decimal;"decimalSeparator"==c&&""==e&&(e=" ");d!=e&&(b._selection(),b.items=[],b._initializeLiterals(),
2048b.value=b._getString(),b._refreshValue(),b._setDecimal(f))}"rtl"==c&&(b.rtl?(b.spincontainer&&(b.spincontainer.css("float","right"),b.spincontainer.css("border-right-width","1px")),b.numberInput.css("float","right")):(b.spincontainer&&(b.spincontainer.css("float","right"),b.spincontainer.css("border-right-width","1px")),b.numberInput.css("float","left")));"spinButtons"==c&&(b.spincontainer?(e?b.spincontainer.css("display","block"):b.spincontainer.css("display","none"),b._render()):b._spinButtons());
2049"touchMode"===c&&(b.inputMode="textbox",b.spinMode="simple",b.render());"negative"==c&&"advanced"==b.inputMode&&(d=b._selection(),e?(b.items[0].character=b.negativeSymbol[0],f=1):(b.items[0].character="",f=-1),b._refreshValue(),b.isInitialized&&b._setSelection(d.start+f,d.end+f));"decimal"==c&&(b.value=e,b.setDecimal(e));"value"===c&&(b.value=e,b.setDecimal(e),b._raiseEvent(1,e));"textAlign"==c&&(b.textAlign=e,b._render());"disabled"==c&&(b.numberInput.attr("disabled",e),b.disabled?b.host.addClass(b.toThemeProperty("jqx-fill-state-disabled")):
2050b.host.removeClass(b.toThemeProperty("jqx-fill-state-disabled")),a.jqx.aria(b,"aria-disabled",e.toString()));"readOnly"==c&&(b.readOnly=e);if("promptChar"==c){for(d=0;d<b.items.length;d++)b.items[d].character==b.promptChar&&(b.items[d].character=e);b.promptChar=e}"width"==c?(b.width=e,b._render()):"height"==c&&(b.height=e,b._render())}},_value:function(){return this.value},_refreshValue:function(){if("textbox"!==this.inputMode){var b=this.value=this._getString();for(var c="",d=0;d<this.items.length;d++){var e=
2051this.items[d];e.canEdit&&e.character!=this.promptChar&&(c+=e.character);d==this.decimalSeparatorPosition&&(c+=".")}this.decimal=c;c=!1;this.oldValue!==b&&(this.oldValue=b,this._raiseEvent(0,b),c=!0);"simple"!=this.inputMode&&(this.numberInput.val(b),c&&this._raiseEvent(1,b));null==b&&this.numberInput.val("")}}})})(jqxBaseFramework);
2052(function(a){a.jqx.jqxWidget("jqxPasswordInput","",{});a.extend(a.jqx._jqxPasswordInput.prototype,{defineInstance:function(){var b={width:null,height:null,disabled:!1,rtl:!1,placeHolder:null,showStrength:!1,showStrengthPosition:"right",maxLength:null,minLength:null,showPasswordIcon:!0,strengthTypeRenderer:null,passwordStrength:null,changeType:null,hint:!0,localization:{passwordStrengthString:"Password strength",tooShort:"Too short",weak:"Weak",fair:"Fair",good:"Good",strong:"Strong",showPasswordString:"Show Password"},
2053strengthColors:{tooShort:"rgb(170, 0, 51)",weak:"rgb(170, 0, 51)",fair:"rgb(255, 204, 51)",good:"rgb(45, 152, 243)",strong:"rgb(118, 194, 97)"}};if(this===a.jqx._jqxPasswordInput.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(){this._inDOM=document.body.contains(this.element);this.render()},render:function(){var b=this,c=a.jqx.browser.version;this._browserCheck="msie"!=a.jqx.browser.browser||"7.0"!=c&&"8.0"!=c;
2053this.widgetID=b.element.id;if("password"!=this.element.getAttribute("type"))throw"Invalid input type. Please set the type attribute of the input element to password.";
2054this.input=this.element;if(b.isMaterialized()){c=a("<div></div>");c.addClass(b.toThemeProperty("jqx-input-group"));this.host.after(c);var d=this.element,e=this.host.data();c.append(d);d=a("<label></label");this.hint&&(d[0].innerHTML=this.placeHolder);d.addClass(b.toThemeProperty("jqx-input-label"));c.append(d);var f=a("<span></span>");c.append(f);f.addClass(b.toThemeProperty("jqx-input-bar"));c[0].id=this.element.id;this.element.removeAttribute("id");c[0].style.cssText=this.element.style.cssText;
2055b.input=b.element;this.element.style.cssText="";this.bar=f;this.label=d;this.host=c;this.element=c[0];this.host.data(e);b=this;b.template&&(b.bar.addClass(b.toThemeProperty("jqx-"+b.template)),b.label.addClass(b.toThemeProperty("jqx-"+b.template)))}b._hidden=!0;b._setTheme();b._setAttributes();b._showPassword();b._showStrength();a.jqx.utilities.resize(this.host,function(){if(!b._inDOM){var g=b.element.parentNode;b.element.nextSibling?g.insertBefore(b.icon,b.element.nextSibling):g.appendChild(b.icon);
2056b._inDOM=!0}else if(b.element===document.activeElement||b.isMaterialized())b._positionIcon(),b.showStrength&&b.host.jqxTooltip("close")})},refresh:function(b){b||(this.removeHandler(this.host,"change.passwordinput"+this.widgetID),this.removeHandler(this.host,"focus.passwordinput"+this.widgetID),this.removeHandler(this.host,"blur.passwordinput"+this.widgetID),this.removeHandler(this.host,"click.passwordinput"+this.widgetID),this.removeHandler(this.host,"keyup.passwordinput"+this.widgetID),this.removeHandler(this.icon,
2057"mousedown.passwordinput"+this.widgetID),this.removeHandler(a(document),"mouseup.passwordinput"+this.widgetID),this.removeHandler(a(document),"mousedown.passwordinput"+this.widgetID),this._setAttributes(),this._setTheme(),this._showPassword(),this._showStrength())},val:function(b){var c=this.input.value,d="placeholder"in this.input;if(a.isEmptyObject(b)&&""!==b)return d||c!==this.placeHolder||(c=""),c;if(!d||b!==c){if(!d){if(""===b){c!==this.placeHolder&&(this.input.value=this.placeHolder,this.input.setAttribute("type",
2058"text"));return}this.input.setAttribute("type","password")}this.input.value=b;d&&this.isMaterialized()&&this._refreshPlaceHolder();!0===this.showStrength&&this._evaluateStrength()}},propertyChangedHandler:function(b,c,d,e){"theme"===c?a.jqx.utilities.setTheme(d,e,b.host):"disabled"==c?b.disabled?(b.element.setAttribute("disabled","disabled"),b.element.className+=" "+b.toThemeProperty("jqx-fill-state-disabled")):(b.host.removeAttr("disabled"),b.host.removeClass(b.toThemeProperty("jqx-fill-state-disabled"))):
2059"placeHolder"==c?this._browserCheck&&("placeholder"in this.element?b.element.setAttribute("placeholder",b.placeHolder):""===b.input.value?(b.input.setAttribute("type","text"),b.input.value=e):b.input.value==d&&(b.input.value=e)):this.refresh()},resize:function(b,c){this.width=b;this.height=c;null!=this.width&&-1!=this.width.toString().indexOf("px")?this.element.style.width=this.width:void 0==this.width||isNaN(this.width)||(this.element.style.width=this.width+"px");null!=this.height&&-1!=this.height.toString().indexOf("px")?
2060this.element.style.height=this.height:void 0==this.height||isNaN(this.height)||(this.element.style.height=this.height+"px")},_setAttributes:function(){var b=this,c=b.element;null!=this.width&&-1!=this.width.toString().indexOf("px")?this.element.style.width=this.width:void 0==this.width||isNaN(this.width)||(this.element.style.width=this.width+"px");null!=this.height&&-1!=this.height.toString().indexOf("px")?this.element.style.height=this.height:void 0==this.height||isNaN(this.height)||(this.element.style.height=
2061this.height+"px");null!=this.height&&-1!=this.height.toString().indexOf("%")&&(this.element.style.height=this.height);null!=this.width&&-1!=this.width.toString().indexOf("%")&&(this.element.style.width=this.width);b.maxLength&&c.setAttribute("maxlength",b.maxLength);b.minLength&&c.setAttribute("minLength",b.minLength);b.placeHolder&&b._browserCheck&&("placeholder"in b.element?c.setAttribute("placeholder",b.placeHolder):""===c.value&&(c.setAttribute("type","text"),c.value=b.placeHolder));b.disabled?
2062(c.setAttribute("disabled","disabled"),c.className+=" "+this.toThemeProperty("jqx-fill-state-disabled")):(c.removeAttribute("disabled"),b.host.removeClass(b.toThemeProperty("jqx-fill-state-disabled")));var d=!1;b.addHandler(c,"change.passwordinput"+b.widgetID,function(e){d||(e.preventDefault(),e.stopPropagation(),d=!0,b._raiseEvent(),d=!1);b._refreshPlaceHolder()});b.addHandler(c,"click.passwordinput"+b.widgetID,function(){b.showPasswordIcon&&b.icon&&(b.icon.style.display="inline",b._positionIcon())});
2063b.interval=null;b.addHandler(c,"keydown.passwordinput"+b.widgetID,function(){b.changeType="keyboard";if(b.showPasswordIcon&&b.icon){b.interval&&clearInterval(b.interval);var e=0;b.interval=setInterval(function(){"none"!=b.icon.style.display?(b._positionIcon(),e++,5<e&&clearInterval(b.interval)):clearInterval(b.interval)},100)}});b.addHandler(c,"focus.passwordinput"+b.widgetID,function(){b._focused=!0;c.className+=" "+b.toThemeProperty("jqx-fill-state-focus");!b.placeHolder||!b._browserCheck||"placeholder"in
2064b.element||c.value!=b.placeHolder||(c.value="",b._hidden&&c.setAttribute("type","password"));0<b.val().length&&b.showStrength&&b.host.jqxTooltip("content")&&b.host.jqxTooltip("open");b.showPasswordIcon&&b.icon&&(b.icon.style.display="inline",b._positionIcon())});b.addHandler(c,"blur.passwordinput"+b.widgetID,function(){b._focused=!1;b.host.removeClass(b.toThemeProperty("jqx-fill-state-focus"));!b.placeHolder||!b._browserCheck||"placeholder"in b.input||""!==c.value||(b.input.value=b.placeHolder,b.input.setAttribute("type",
2065"text"));b.showPasswordIcon&&b._browserCheck&&(!1===b.rtl?b.host.removeClass(b.toThemeProperty("jqx-passwordinput-password-icon-ltr")):b.host.removeClass(b.toThemeProperty("jqx-passwordinput-password-icon-rtl")));b.showStrength&&b.host.jqxTooltip("close");b.showPasswordIcon&&b.icon&&(b.icon.style.display="none")})},_refreshPlaceHolder:function(){this.isMaterialized()||("placeholder"in this.input&&!(a.jqx.browser.msie&&9>a.jqx.browser.version)?this.input.setAttribute("placeHolder",this.placeHolder):
2066""===this.input.value&&(this.input.value=this.placeHolder));""!==this.input.value?this.element.setAttribute("hint",!0):this.element.removeAttribute("hint");this.label&&(this.label.innerHTML=this.placeHolder)},destroy:function(){this.host.jqxTooltip&&this.host.jqxTooltip("destroy");this.host.remove()},_setTheme:function(){var b="jqx-widget jqx-widget-content jqx-input jqx-input-widget jqx-rc-all";this.rtl?(b+=" jqx-rtl",this.element.style.direction="rtl"):(this.host.removeClass(this.toThemeProperty("jqx-rtl")),
2067this.element.style.direction="ltr");this.element.className+=" "+this.toThemeProperty(b)},_showPassword:function(){if(this.showPasswordIcon&&this._browserCheck){var b=this,c=document.createElement("span"),d=".passwordinput"+b.widgetID;c.setAttribute("tabindex",-1);c.setAttribute("hasfocus",!1);c.setAttribute("title",b.localization.showPasswordString);c.style.position="absolute";c.style.display="none";c.className=b.toThemeProperty("jqx-passwordinput-password-icon");var e=b.element.parentNode;e&&(b.element.nextSibling?
2068e.insertBefore(c,b.element.nextSibling):e.appendChild(c));b.icon=c;b._positionIcon();var f=function(){b.element.setAttribute("type","password");b.input&&b.input.setAttribute("type","password");b._hidden=!0},g=function(){!1===b._hidden?f():b._hidden&&(b.element.setAttribute("type","text"),b.input&&b.input.setAttribute("type","text"),b._hidden=!1)};a.jqx.mobile.isTouchDevice()?b.addHandler(b.icon,"mousedown"+d,function(){g();return!1}):(b.addHandler(b.icon,"mousedown"+d,function(){g();return!1}),b.addHandler(a(document),
2069"mouseup"+d,function(){f();return!1}),b.addHandler(a(document),"mousedown"+d,function(){b._focused&&f()}))}},_positionIcon:function(){var b=this.host.offset(),c=this.element.offsetWidth,d=this.element.offsetHeight,e=a(this.icon);this.rtl?e.offset({top:parseInt(b.top+d/2-5,10),left:b.left+2}):e.offset({top:parseInt(b.top+d/2-5,10),left:b.left+c-18})},_showStrength:function(){if(this.showStrength)if(this.host.jqxTooltip){var b=this.widgetID+"Strength",c=b+"Value";b+="Indicator";if(this.strengthTypeRenderer){var d=
2070this.input.value;"placeholder"in this.input||!this._browserCheck||d!=this.placeHolder||(d="");this._countCharacters();d=this.strengthTypeRenderer(d,{letters:this.letters,numbers:this.numbers,specialKeys:this.specials},this.localization.tooShort)}else d='<div style="width: 220px;"><div><span style="font-weight: bold;">
2070'+this.localization.passwordStrengthString+': </span><span id="'+c+'"></span></div><div id="'+b+'"></div></div>';this.host.jqxTooltip({theme:this.theme,position:this.showStrengthPosition,
2071content:d,trigger:"none",autoHide:!1,rtl:this.rtl});this.strengthTypeRenderer||(b=document.getElementById(b),document.getElementById(c).innerHTML=this.localization.tooShort,b.className+=" jqx-passwordinput-password-strength-inicator",b.style.backgroundColor=this.strengthColors.tooShort,b.style["float"]=!1===this.rtl?"left":"right");this._checkStrength()}else throw Error("jqxPasswordInput: Missing reference to jqxtooltip.js");},_checkStrength:function(){var b=this;b.addHandler(b.host,"keyup.passwordinput"+
2072b.widgetID,function(){b._evaluateStrength()})},_raiseEvent:function(){var b=new a.Event("change");b.args={type:this.changeType};this.changeType=null;b.owner=this;return this.host.trigger(b)},_evaluateStrength:function(){var b=this.input.value,c=b.length;this._countCharacters();0<c&&this.showStrength&&(this.host.jqxTooltip("opened")||this.host.jqxTooltip("open"));var d=this.letters+this.numbers+2*this.specials+this.letters*this.numbers/2+c;var e=8>c?this.localization.tooShort:20>d?this.localization.weak:
207330>d?this.localization.fair:40>d?this.localization.good:this.localization.strong;if(this.strengthTypeRenderer){var f=this.strengthTypeRenderer(b,{letters:this.letters,numbers:this.numbers,specialKeys:this.specials},e);this.host.jqxTooltip({content:f})}else{this.passwordStrength&&(f=this.passwordStrength(b,{letters:this.letters,numbers:this.numbers,specialKeys:this.specials},e),a.each(this.localization,function(){if(f==this)return e=f,!1}));document.getElementById(this.widgetID+"StrengthValue").innerHTML=
2074e;b=document.getElementById(this.widgetID+"StrengthIndicator");switch(e){case this.localization.tooShort:var g="20%";var h=this.strengthColors.tooShort;break;case this.localization.weak:g="40%";h=this.strengthColors.weak;break;case this.localization.fair:g="60%";h=this.strengthColors.fair;break;case this.localization.good:g="80%";h=this.strengthColors.good;break;case this.localization.strong:g="100%",h=this.strengthColors.strong}b.style.width=g;b.style.backgroundColor=h}},_countCharacters:function(){this.specials=
2075this.numbers=this.letters=0;for(var b=this.input.value,c=b.length,d=0;d<c;d++){var e=b.charAt(d),f=b.charCodeAt(d);64<f&&91>f||96<f&&123>f||127<f&&155>f||159<f&&166>f?this.letters+=1:!1===isNaN(e)?this.numbers+=1:-1!="<>@!#$%^&*()_+[]{}?:;|'\"\\,./~`-=".indexOf(e)&&(this.specials+=1)}},_toPx:function(b){return"number"===typeof b?b+"px":b}})})(jqxBaseFramework);
2076(function(a){a.jqx.jqxWidget("jqxProgressBar","",{});a.extend(a.jqx._jqxProgressBar.prototype,{defineInstance:function(){var b={colorRanges:[],value:0,oldValue:null,max:100,min:0,orientation:"horizontal",layout:"normal",width:null,height:null,showText:!1,animationDuration:300,disabled:!1,rtl:!1,renderText:null,template:"",aria:{"aria-valuenow":{name:"value",type:"number"},"aria-disabled":{name:"disabled",type:"boolean"}},events:["valueChanged","invalidValue","complete","change"]};if(this===a.jqx._jqxProgressBar.prototype)return b;
2077a.extend(!0,this,b);return b},createInstance:function(b){var c=this;this.host.addClass(this.toThemeProperty("jqx-progressbar"));this.host.addClass(this.toThemeProperty("jqx-widget"));this.host.addClass(this.toThemeProperty("jqx-widget-content"));this.host.addClass(this.toThemeProperty("jqx-rc-all"));a.jqx.aria(this);if(null==this.width||-1==this.width.toString().indexOf("px"))void 0==this.width||isNaN(this.width);this.host.width(this.width);if(null==this.height||-1==this.height.toString().indexOf("px"))void 0==
2078this.height||isNaN(this.height);this.host.height(this.height);this.valueDiv=a("<div></div>").appendTo(this.element);this._addRanges();this.valueDiv.addClass(this.toThemeProperty("jqx-fill-state-pressed"));this.template&&this.valueDiv.addClass(this.toThemeProperty("jqx-"+this.template));this.feedbackElementHost=a("<div style='left: 0px; top: 0px; width: 100%; height: 100%; position: absolute;'></div>").appendTo(this.host);
2078this.feedbackElement=a("<span class='text'></span>").appendTo(this.feedbackElementHost);
2079this.feedbackElement.addClass(this.toThemeProperty("jqx-progressbar-text"));this.oldValue=this._value();this.refresh();a.jqx.utilities.resize(this.host,function(){c.refresh()})},_addRanges:function(){if(0!=this.colorRanges.length)for(var b="vertical"==this.orientation,c=this.colorRanges,d=c.length,e=0;e<d;e++)this._createColorElements(c[e].stop,c[e].color,b,d-e,e)},_refreshColorElements:function(){for(var b=this.host.outerWidth(),c=this.host.outerHeight(),d="vertical"==this.orientation,e=0;e<this.colorRanges.length;e++){var f=
2080this.colorRanges[e].element;if(!f){this.host.find(".jqx-progressbar-range").remove();this._addRanges();break}var g=this.colorRanges[e].stop;g>Math.min(this.max,this.value)&&(g=Math.min(this.max,this.value));g=100*(g-this.min)/(this.max-this.min);g=d?c*g/100:b*g/100;g+="px";d?(f.css("height",g),"reverse"==this.layout?f.css("bottom",0):f.css("top",0)):(f.css("width",g),(this.rtl||"reverse"==this.layout)&&f.css("right","0px"))}},_createColorElements:function(b,c,d,e,f){b>Math.min(this.max,this.value)&&
2081(b=Math.min(this.max,this.value));b=100*b/this.max;this.host.width();this.host.height();b=d?this.host.outerHeight()*b/100:this.host.outerWidth()*b/100;b+="px";var g=a(this.valueDiv).parent()[0];g.style.position="relative";d?(d=a("<div/>"),d.attr("class","jqx-progressbar-range"),d.css("width","100%"),d.css("height",b),d.css("background-color",c),d.css("position","absolute"),d.css("z-index",e),"reverse"==this.layout?d.css("bottom",0):d.css("top",0)):(d=a("<div/>"),d.attr("class","jqx-progressbar-range"),
2082d.css("width",b),d.css("height","100%"),d.css("background-color",c),d.css("position","absolute"),d.css("z-index",e),d.css("top","0px"),this.rtl&&d.css("right","0px"));d.appendTo(g);this.colorRanges[f].element=d},resize:function(b,c){this.width=b;this.height=c;this.refresh()},destroy:function(){this.host.removeClass();this.valueDiv.removeClass();this.valueDiv.remove();this.feedbackElement.remove()},_raiseevent:function(b,c,d){if(void 0!=this.isInitialized&&1==this.isInitialized)return b=new a.Event(this.events[b]),
2083b.previousValue=c,b.currentValue=d,b.owner=this,this.host.trigger(b)},actualValue:function(b){if(void 0===b)return this._value();a.jqx.aria(this,"aria-valuenow",b);a.jqx.setvalueraiseevent(this,"value",b);return this._value()},val:function(b){return 0==arguments.length||"object"==typeof b?this.actualValue():this.actualValue(b)},propertiesChangedHandler:function(b,c,d){d&&d.width&&d.height&&2==Object.keys(d).length&&(b.host.width(d.width),b.host.height(d.height),b.refresh())},propertyChangedHandler:function(b,
2084c,d,e){!this.isInitialized||d==e||b.batchUpdate&&b.batchUpdate.width&&b.batchUpdate.height&&2==Object.keys(b.batchUpdate).length||("colorRanges"==c&&(b.host.find(".jqx-progressbar-range").remove(),b._addRanges()),"min"==c&&b.value<e?b.value=e:"max"==c&&b.value>e&&(b.value=e),"value"===c&&void 0!=this.value&&(this.value=e,this.oldValue=d,a.jqx.aria(b,"aria-valuenow",e),(e<this.min||e>this.max)&&this._raiseevent(1,d,e),this.refresh()),"theme"==c&&a.jqx.utilities.setTheme(d,e,b.host),"renderText"==c||
2085"orientation"==c||"layout"==c||"showText"==c||"min"==c||"max"==c?this.refresh():"width"==c&&void 0!=this.width?void 0==this.width||isNaN(this.width)||(this.host.width(this.width),this.refresh()):"height"!=c||void 0==this.height||void 0==this.height||isNaN(this.height)||(this.host.height(this.height),this.refresh()),"disabled"==c&&this.refresh())},_value:function(){var b=this.value;"number"!==typeof b&&(b=parseInt(b),b=isNaN(b)?0:b);return Math.min(this.max,Math.max(this.min,b))},_percentage:function(){return 100*
2086(this._value()-this.min)/(this.max-this.min)},_textwidth:function(b){b=a("<span>"+b+"</span>");a(this.host).append(b);var c=b.width();b.remove();return c},_textheight:function(b){b=a("<span>"+b+"</span>");a(this.host).append(b);var c=b.height();b.remove();return c},_initialRender:!0,refresh:function(b){if(!0!==b){var c=this.actualValue(),d=this._percentage();if(this.disabled)this.host.addClass(this.toThemeProperty("jqx-progressbar-disabled")),this.host.addClass(this.toThemeProperty("jqx-fill-state-disabled"));
2087else if(this.host.removeClass(this.toThemeProperty("jqx-progressbar-disabled")),this.host.removeClass(this.toThemeProperty("jqx-fill-state-disabled")),a(this.element.children[0]).show(),!isNaN(c)&&!isNaN(d)){this.oldValue!==c&&(this._raiseevent(0,this.oldValue,c),this._raiseevent(3,this.oldValue,c),this.oldValue=c);var e=this.oldValue,f=this.host.outerHeight(),g=this.host.outerWidth();null!=this.width&&(g=parseInt(this.width));null!=this.height&&(f=parseInt(this.height));this._refreshColorElements();
2088b=parseInt(this.host.outerWidth())/2;parseInt(this.host.outerHeight());isNaN(d)&&(d=0);this.valueDiv.removeClass(this.toThemeProperty("jqx-progressbar-value-vertical jqx-progressbar-value"));"horizontal"==this.orientation?(this.valueDiv.width(0),this.valueDiv[0].style.height="100%",this.valueDiv.addClass(this.toThemeProperty("jqx-progressbar-value"))):(this.valueDiv[0].style.width="100%",this.valueDiv.height(0),this.valueDiv.addClass(this.toThemeProperty("jqx-progressbar-value-vertical")));var h=
2089this;try{var k=this.element.children[0];a(k)[0].style.position="relative";if("horizontal"==this.orientation){a(k).toggle(c>=this.min);g=this.host.outerWidth()*d/100;f=0;if("reverse"==this.layout||this.rtl)this._initialRender&&(a(k)[0].style.left=this.host.width()+"px",a(k)[0].style.width=0),f=this.host.outerWidth()-g;a(k).stop();a(k).animate({width:g,left:f+"px"}
2089,this.animationDuration,function(){h._value()===h.max&&h._raiseevent(2,e,h.max)})}else a(k).toggle(c>=this.min),f=this.host.height()*d/100,
2090g=0,"reverse"==this.layout&&(this._initialRender&&(a(k)[0].style.top=this.host.height()+"px",a(k)[0].style.height=0),g=this.host.height()-f),a(k).stop(),a(k).animate({height:f,top:g+"px"},this.animationDuration,function(){var l=h._percentage();isNaN(l)&&(l=0);l.toFixed(0)==h.min&&(a(k).hide(),h._value()===h.max&&h._raiseevent(2,e,h.max))})}catch(l){}this._initialRender=!1;this.feedbackElement.html(d.toFixed(0)+"%").toggle(1==this.showText);this.renderText&&this.feedbackElement.html(this.renderText(d.toFixed(0)+
2091"%",d));this.feedbackElement.css("position","absolute");this.feedbackElement.css("top","50%");this.feedbackElement.css("left","0");0<this.colorRanges.length&&this.feedbackElement.css("z-index",this.colorRanges.length+1);d=this.feedbackElement.height();f=this.feedbackElement.width();b=Math.floor(b-parseInt(f)/2);this.feedbackElement.css({left:b,"margin-top":-parseInt(d)/2+"px"})}}}})})(jqxBaseFramework);
2092(function(a){a.jqx.jqxWidget("jqxValidator","",{});a.extend(a.jqx._jqxValidator.prototype,{defineInstance:function(){var b={rules:null,scroll:!0,focus:!0,scrollDuration:300,scrollCallback:null,position:"right",arrow:!0,animation:"fade",animationDuration:150,closeOnClick:!0,onError:null,onSuccess:null,ownerElement:null,_events:["validationError","validationSuccess"],hintPositionOffset:5,_inputHint:[],rtl:!1,hintType:"tooltip"};if(this===a.jqx._jqxValidator.prototype)return b;a.extend(!0,this,b);return b},
2093createInstance:function(){"label"==this.hintType&&150==this.animationDuration&&(this.animationDuration=0);this._configureInputs();this._removeEventListeners();this._addEventListeners()},destroy:function(){this._removeEventListeners();this.hide()},validate:function(b){var c=!0,d,e=Infinity,f=[];this.updatePosition();for(var g=this,h=0,k=0;k<this.rules.length;k+=1)"function"===typeof this.rules[k].rule&&h++;this.positions=[];for(k=0;k<this.rules.length;k+=1)if(a(this.rules[k].input),"function"===typeof this.rules[k].rule?
2094this._validateRule(this.rules[k],function(t,u){d=t;0==d&&(c=!1,a(u.input),l=a(u.input),f.push(l),t=l.offset())&&(n=t.top,e>n&&(e=n,r=l));h--;0==h&&"function"===typeof b&&(g._handleValidation(c,e,r,f),b&&b(c))}):d=this._validateRule(this.rules[k]),0==d){c=!1;var l=a(this.rules[k].input);f.push(l);var m=l.offset();if(m){var n=m.top;if(e>n){e=n;var r=l}}}if(0==h)return this._handleValidation(c,e,r,f),c},validateInput:function(b){b=this._getRulesForInput(b);for(var c=!0,d=0;d<b.length;d+=1)this._validateRule(b[d])||
2095(c=!1);return c},hideHint:function(b){b=this._getRulesForInput(b);for(var c=0;c<b.length;c+=1)this._hideHintByRule(b[c])},hide:function(){for(var b=0;b<this.rules.length;b+=1)this._hideHintByRule(this.rules[b])},updatePosition:function(){this.positions=[];for(var b=0;b<this.rules.length;b+=1){var c=this.rules[b];c.hint&&this._hintLayout(c.hint,a(c.input),c.position,c)}},_getRulesForInput:function(b){for(var c=[],d=0;d<this.rules.length;d+=1)this.rules[d].input===b&&c.push(this.rules[d]);return c},
2096_validateRule:function(b,c){var d=a(b.input),e=!0,f=this,g=function(l){l?(f._hideHintByRule(b),c&&c(!0,b)):(l=f.animation,f.animation=null,b.hint&&f._hideHintByRule(b),"none"==a(d).css("display")?f._hideHintByRule(b):0==a(d).parents().length?f._hideHintByRule(b):(k=b.hintRender.apply(f,[b.message,d]),f._hintLayout(k,d,b.position,b),f._showHint(k),b.hint=k,f._removeLowPriorityHints(b),c&&c(!1,b),f.animation=l))},h=!1;"function"===typeof b.rule&&(h=b.rule.call(this,d,g),1==h&&c&&c(!0,b));if("function"===
2097typeof b.rule&&0==h){if("function"===typeof b.hintRender&&!b.hint&&!this._higherPriorityActive(b)&&d.is(":visible")){var k=b.hintRender.apply(this,[b.message,d]);this._removeLowPriorityHints(b);this._hintLayout(k,d,b.position,b);this._showHint(k);b.hint=k}e=!1;c&&c(!1,b)}else this._hideHintByRule(b);return e},_hideHintByRule:function(b){var c=a(b.input),d=this,e,f=function(){if("label"==d.hintType){if("top"==d.position||"left"==d.position){if(c.prev().hasClass(".jqx-validator-error-label"))return}else if(c.next().hasClass(".jqx-validator-error-label"))return;
2098"input"!=c[0].nodeName.toLowerCase()?0<c.find("input").length?(0<c.find(".jqx-input").length?c.find(".jqx-input").removeClass(d.toThemeProperty("jqx-validator-error-element")):0<c.find(".jqx-text-area").length?c.find(".jqx-text-area").removeClass(d.toThemeProperty("jqx-validator-error-element")):c.is(".jqx-checkbox")&&c.find(".jqx-checkbox-default").removeClass(d.toThemeProperty("jqx-validator-error-element")),c.is(".jqx-radiobutton")?c.find(".jqx-radiobutton-default").removeClass(d.toThemeProperty("jqx-validator-error-element")):
2099c.removeClass(d.toThemeProperty("jqx-validator-error-element"))):c.removeClass(d.toThemeProperty("jqx-validator-error-element")):c.removeClass(d.toThemeProperty("jqx-validator-error-element"))}};if(b){if(e=b.hint)this.positions&&this.positions[Math.round(e.offset().top)+"_"+Math.round(e.offset().left)]&&(this.positions[Math.round(e.offset().top)+"_"+Math.round(e.offset().left)]=null),"fade"===this.animation?e.fadeOut(this.animationDuration,function(){e.remove();f()}):(e.remove(),f());b.hint=null}},
2100_handleValidation:function(b,c,d,e){if(b){if(this._raiseEvent(1),"function"===typeof this.onSuccess)this.onSuccess()}else if(this._scrollHandler(c),this.focus&&d.focus(),this._raiseEvent(0,{invalidInputs:e}),"function"===typeof this.onError)this.onError(e)},_scrollHandler:function(b){if(this.scroll){var c=this;a("html,body").animate({scrollTop:b},this.scrollDuration,function(){"function"===typeof c.scrollCallback&&c.scrollCallback.call(c)})}},_higherPriorityActive:function(b){for(var c=!1,d,e=this.rules.length-
21011;0<=e;--e){d=this.rules[e];if(c&&d.input===b.input&&d.hint)return!0;d===b&&(c=!0)}return!1},_removeLowPriorityHints:function(b){for(var c=!1,d,e=0;e<this.rules.length;e+=1)d=this.rules[e],c&&d.input===b.input&&this._hideHintByRule(d),d===b&&(c=!0)},_getHintRuleByInput:function(b){for(var c,d=0;d<this.rules.length;d+=1)if(c=this.rules[d],a(c.input)[0]===b[0]&&c.hint)return c;return null},_removeEventListeners:function(){for(var b,c,d=0;d<this.rules.length;d+=1){b=this.rules[d];c=b.action.split(",");
2102b=a(b.input);for(var e=0;e<c.length;e+=1)this.removeHandler(b,a.trim(c[e])+".jqx-validator")}},_addEventListeners:function(){if(0<this.host.parents(".jqx-window").length){var b=this,c=function(){b.updatePosition()};var d=this.host.parents(".jqx-window");this.addHandler(d,"closed",function(){b.hide()});this.addHandler(d,"moved",c);this.addHandler(d,"moving",c);this.addHandler(d,"resized",c);this.addHandler(d,"resizing",c);this.addHandler(a(document.parentWindow),"scroll",function(){b.scroll&&c()})}for(var e=
21030;e<this.rules.length;e+=1){d=this.rules[e];var f=a(d.input);this._addListenerTo(f,d)}},_addListenerTo:function(b,c){var d=this,e=c.action.split(","),f=!1;this._isjQWidget(b)&&(f=!0);for(var g=0;g<e.length;g+=1){var h=a.trim(e[g]);!f||"blur"!=h&&"focus"!=h||b&&"input"!=b[0].nodeName.toLowerCase()&&(b=b.find("input"));
2103this.addHandler(b,h+".jqx-validator",function(k){d._validateRule(c)})}},_configureInputs:function(){this.rules=this.rules||[];for(var b=0;b<this.rules.length;b+=1)this._handleInput(b)},
2104_handleInput:function(b){b=this.rules[b];b.position||(b.position=this.position);b.message||(b.message="Validation Failed!");b.action||(b.action="blur");b.hintRender||(b.hintRender=this._hintRender);b.rule?this._handleRule(b):b.rule=null},_handleRule:function(b){var c=b.rule,d,e=!1;if("string"===typeof c){if(0<=c.indexOf("=")){c=c.split("=");var f=c[1].split(",");c=c[0]}(d=this["_"+c])?b.rule=function(g,h){return d.apply(this,[g].concat(f))}:e=!0}else"function"!==typeof c?e=!0:b.rule=c;if(e)throw Error("Wrong parameter!");
2105},_required:function(b){switch(this._getType(b)){case "jqx-input-inner":if(0<b.find("input").length)return""!==a.trim(b.find("input").val());break;case "textarea":case "password":case "jqx-input":case "jqx-text-area":case "text":var c=a.data(b[0]);return c.jqxMaskedInput?(c=b.jqxMaskedInput("promptChar"),(b=b.jqxMaskedInput("value"))&&0>b.indexOf(c)):c.jqxNumberInput?""!==b.jqxNumberInput("inputValue"):c.jqxDateTimeInput?!0:""!==a.trim(b.val());case "checkbox":return b.is(":checked");case "radio":return b.is(":checked");
2106case "jqx-check-box":case "jqx-radio-button":return b[0].val();case "jqxCheckBox":case "jqxcheckbox":case "jqxradiobutton":case "jqxRadioButton":b=b.find("input").val();if(!0===b||1===b||"true"===b)return!0;break;case "div":if(b.is(".jqx-checkbox"))return b.jqxCheckBox("checked");if(b.is(".jqx-radiobutton"))return b.jqxRadioButton("checked")}return!1},_notNumber:function(b){return this._validateText(b,function(c){return""==c?!0:!/\d/.test(c)})},_startWithLetter:function(b){return this._validateText(b,
2107function(c){return""==c?!0:!/\d/.test(c.substring(0,1))})},_number:function(b){return this._validateText(b,function(c){if(""==c)return!0;c=new Number(c);return!isNaN(c)&&isFinite(c)})},_phone:function(b){return this._validateText(b,function(c){return""==c?!0:/^\(\d{3}\)(\d){3}-(\d){4}$/.test(c)})},_length:function(b,c,d){return this._minLength(b,c)&&this._maxLength(b,d)},_maxLength:function(b,c){c=parseInt(c,10);return this._validateText(b,function(d){return d.length<=c})},_minLength:function(b,c){c=
2108parseInt(c,10);return this._validateText(b,function(d){return d.length>=c})},_email:function(b){return this._validateText(b,function(c){return""==c?!0:/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(c)})},_zipCode:function(b){return this._validateText(b,function(c){return""==c?!0:/^(^\d{5}$)|(^\d{5}-\d{4}$)|(\d{3}-\d{2}-\d{4})$/.test(c)})},_ssn:function(b){return this._validateText(b,function(c){return""==
2109c?!0:/\d{3}-\d{2}-\d{4}/.test(c)})},_validateText:function(b,c){return this._isTextInput(b)?(b=this._isjQWidget(b)?0<b.find("input").length?b.find("input").val():b.val():b.val(),c(b)):!1},_isjQWidget:function(b){var c=a.data(b[0]);return c.jqxMaskedInput||c.jqxNumberInput||c.jqxDateTimeInput||0<=b[0].tagName.toLowerCase().indexOf("jqx")||0<=b[0].tagName.toLowerCase().indexOf("jqx-input")||0<=b[0].tagName.toLowerCase().indexOf("jqx-password-input")||0<=b[0].tagName.toLowerCase().indexOf("jqx-complex-input")||
21100<=b[0].tagName.toLowerCase().indexOf("jqx-formatted-input")||0<=b[0].tagName.toLowerCase().indexOf("jqx-masked-input")||0<=b[0].tagName.toLowerCase().indexOf("jqx-date-time-input")||0<=b[0].tagName.toLowerCase().indexOf("jqx-number-input")||0<=b[0].tagName.toLowerCase().indexOf("jqx-check-box")||0<=b[0].tagName.toLowerCase().indexOf("jqx-radio-button")||0<=b[0].tagName.toLowerCase().indexOf("jqxcheckbox")||0<=b[0].tagName.toLowerCase().indexOf("angular")?!0:!1},_isTextInput:function(b){var c=this._getType(b);
2111return"text"===c||"textarea"===c||"password"===c||"jqx-input-inner"===c||b.is(".jqx-input")||b.is(".jqx-text-area")},_getType:function(b){if(b[0]){var c=b[0].tagName.toLowerCase();return"textarea"===c?"textarea":b.is(".jqx-input")?"jqx-input":b.is(".jqx-text-area")?"jqx-text-area":0<b.find(".jqx-input").length?"jqx-input-inner":"input"===c?b=a(b).attr("type")?a(b).attr("type").toLowerCase():"text":"jqx-password-input"===c?"password":"jqx-check-box"===c?"jqx-check-box":"jqx-radio-button"===c?"jqx-radio-button":
2112c}},_hintRender:function(b,c){if("label"==this.hintType){var d=a('<label class="'+this.toThemeProperty("jqx-validator-error-label")+'"></label>');d.html(b);var e=!1;0<c.parent().find(".jqx-input-label").length&&!c.hasClass("jqx-dropdownlist")&&!c.hasClass("jqx-combobox")&&!c.hasClass("jqx-datetimeinput")&&(d=c.parent().find(".jqx-input-label"),c.data().jqxWidget.hint&&(d.html(b),d.addClass(this.toThemeProperty("jqx-validator-error-label")),c.data().jqxWidget.host.attr("hint",!0)),this.hasHint=e=!0);
2113var f=this;this.closeOnClick&&d.click(function(){f.hideHint(c.selector)});e||("left"==this.position||"top"==this.position?d.insertBefore(a(c)):d.insertAfter(a(c)));return d}d=a('<div class="'+this.toThemeProperty("jqx-validator-hint")+' jqx-rc-all"></div>');var g=this;d.html(b);this.closeOnClick&&d.click(function(){g.hideHint(c.selector)});null==this.ownerElement?d.appendTo(document.body):this.ownerElement.innerHTML?d.appendTo(a(this.ownerElement)):d.appendTo(this.ownerElement);return d},_hintLayout:function(b,
2114c,d,e){if(this._hintRender===e.hintRender)if(e=this._getPosition(c,d,b,e),"label"==this.hintType){e="2px";if("left"==this.position||"top"==this.position)e="-2px";"input"!=c[0].nodeName.toLowerCase()&&"textarea"!=c[0].nodeName.toLowerCase()?(0<c.find(".jqx-text-area").length&&c.find(".jqx-text-area").addClass(this.toThemeProperty("jqx-validator-error-element")),0<c.find("input").length&&(0<c.find(".jqx-input").length?c.find(".jqx-input").addClass(this.toThemeProperty("jqx-validator-error-element")):
21150<c.find(".jqx-text-area").length?c.find(".jqx-text-area").addClass(this.toThemeProperty("jqx-validator-error-element")):c.is(".jqx-checkbox")&&c.find(".jqx-checkbox-default").addClass(this.toThemeProperty("jqx-validator-error-element")),c.is(".jqx-radiobutton")?c.find(".jqx-radiobutton-default").addClass(this.toThemeProperty("jqx-validator-error-element")):c.addClass(this.toThemeProperty("jqx-validator-error-element")))):c.addClass(this.toThemeProperty("jqx-validator-error-element"));var f=a("<span></span>");
2116f.addClass(this.toThemeProperty("jqx-validator-hint"));f.html(b.text());f.appendTo(a(document.body));var g=f.outerWidth();f.remove();this.hasHint||(b.css({position:"relative",left:a(c).css("margin-left"),width:a(c).width(),top:e}),"center"==d&&(b.css("width",g),b.css("left","0px"),b.css("margin-left","auto"),b.css("margin-right","auto")))}else b.css({position:"absolute",left:e.left,top:e.top}),this.arrow&&this._addArrow(c,b,d,e)},_showHint:function(b){b&&"fade"===this.animation&&(b.fadeOut(0),b.fadeIn(this.animationDuration))},
2117_getPosition:function(b,c,d,e){var f=b.offset(),g=b.outerWidth(),h=b.outerHeight();this.rtl&&0<=c.indexOf("left")&&(c="right");this.rtl&&0<=c.indexOf("right")&&(c="left");null!=this.ownerElement&&(f={left:0,top:0},f.top=parseInt(f.top)+b.position().top,f.left=parseInt(f.left)+b.position().left);
2117e&&e.hintPositionRelativeElement&&(e=a(e.hintPositionRelativeElement),f=e.offset(),g=e.width(),h=e.height());e=0<=c.indexOf("top")?f.top-h:0<=c.indexOf("bottom")?f.top+d.outerHeight()+this.hintPositionOffset+
21185:f.top;d=0<=c.indexOf("center")?f.left+this.hintPositionOffset+(g-d.outerWidth())/2:0<=c.indexOf("left")?f.left-d.outerWidth()-this.hintPositionOffset:0<=c.indexOf("right")?f.left+g+this.hintPositionOffset:f.left+this.hintPositionOffset;0<=c.indexOf(":")&&(c=c.split(":")[1].split(","),d+=parseInt(c[0],10),e+=parseInt(c[1],10));this.positions||(this.positions=[]);this.positions[Math.round(e)+"_"+Math.round(d)]&&this.positions[Math.round(e)+"_"+Math.round(d)].top==e&&(e+=b.outerHeight());this.positions[Math.round(e)+
2119"_"+Math.round(d)]={left:d,top:e};return{left:d,top:e}},_addArrow:function(b,c,d,e){b=a('<div class="'+this.toThemeProperty("jqx-validator-hint-arrow")+'"></div>');var f;this.rtl&&0<=d.indexOf("left")&&(d="right");this.rtl&&0<=d.indexOf("right")&&(d="left");c.children(".jqx-validator-hint-arrow").remove();c.append(b);var g=b.outerHeight();e=b.outerWidth();var h=c.outerHeight();c=c.outerWidth();this._addImage(b);g=0<=d.indexOf("top")?h-g:0<=d.indexOf("bottom")?-g:(h-g)/2-g/2;0<=d.indexOf("center")?
2120f=(c-e)/2:0<=d.indexOf("left")?f=c-e/2-1:0<=d.indexOf("right")&&(f=-e/2);if(0<=d.indexOf("topright")||0<=d.indexOf("bottomright"))f=0;if(0<=d.indexOf("topleft")||0<=d.indexOf("bottomleft"))f=c-e;b.css({position:"absolute",left:f,top:g})},_addImage:function(b){var c=b.css("background-image");c=c.replace('url("',"");c=c.replace('")',"");c=c.replace("url(","");c=c.replace(")","");b.css("background-image","none");b.append('<img src="'+c+'" alt="Arrow" style="position: relative; top: 0px; left: 0px; width: '+
2121b.width()+"px; height: "+b.height()+'px;" />')},_raiseEvent:function(b,c){b=a.Event(this._events[b]);b.args=c;return this.host.trigger(b)},propertyChangedHandler:function(b,c,d,e){"rules"===c&&(this._configureInputs(),this._removeEventListeners(),this._addEventListeners())}})})(jqxBaseFramework);
2122(function(a){a.jqx.jqxWidget("jqxListBox","",{});a.extend(a.jqx._jqxListBox.prototype,{defineInstance:function(){var b={disabled:!1,checkboxSize:16,checkboxes:!1,width:null,height:null,items:[],multiple:!1,selectedIndex:-1,selectedIndexes:[],source:null,scrollBarSize:a.jqx.utilities.scrollBarSize,enableHover:!0,enableSelection:!0,visualItems:[],groups:[],equalItemsWidth:!0,itemHeight:-1,visibleItems:[],emptyGroupText:"Group",hasThreeStates:!1,autoHeight:!1,autoItemsHeight:!1,roundedcorners:!0,touchMode:"auto",
2123displayMember:"",groupMember:"",valueMember:"",searchMember:"",searchMode:"startswithignorecase",incrementalSearch:!0,incrementalSearchDelay:1E3,incrementalSearchKeyDownDelay:300,allowDrag:!1,allowDrop:!0,dropAction:"default",touchModeStyle:"auto",keyboardNavigation:!0,enableMouseWheel:!0,multipleextended:!1,selectedValues:[],emptyString:"",rtl:!1,rendered:null,renderer:null,dragStart:null,dragEnd:null,focusable:!0,ready:null,_checkForHiddenParent:!0,autoBind:!0,_renderOnDemand:!1,filterable:!1,filterHeight:27,
2124filterPlaceHolder:"Looking for",filterDelay:100,filterChange:null,aria:{"aria-disabled":{name:"disabled",type:"boolean"}},events:"select unselect change checkChange dragStart dragEnd bindingComplete itemAdd itemRemove itemUpdate".split(" ")};if(this===a.jqx._jqxListBox.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(b){15!=a.jqx.utilities.scrollBarSize&&(this.scrollBarSize=a.jqx.utilities.scrollBarSize);null==this.width&&(this.width=200);null==this.height&&(this.height=200);
2125this.isMaterialized()&&(b=window.getComputedStyle(this.element).getPropertyValue("--jqx-list-item-height"))&&-1===this.itemHeight&&(this.itemHeight=parseInt(b));this.renderListBox();var c=this;a.jqx.utilities.resize(this.host,function(){c._updateSize()},!1,this._checkForHiddenParent)},resize:function(b,c){this.width=b;this.height=c;this._updateSize()},render:function(){this.renderListBox();this.refresh()},renderListBox:function(){var b=this,c=b.element.nodeName.toLowerCase();if("select"==c||"ul"==
2126c||"ol"==c){b.field=b.element;b.field.className&&(b._className=b.field.className);c={title:b.field.title};c.id=b.field.id.length?b.field.id.replace(/[^\w]/g,"_")+"_jqxListBox":a.jqx.utilities.createId()+"_jqxListBox";var d=a("<div></div>",c);b.width||(b.width=a(b.field).width());b.height||(b.height=a(b.field).outerHeight());b.element.style.cssText=b.field.style.cssText;a(b.field).hide().after(d);var e=b.host.data();b.host=d;b.host.data(e);b.element=d[0];
2126b.element.id=b.field.id;b.field.id=c.id;b._className&&
2127(b.host.addClass(b._className),a(b.field).removeClass(b._className));b.field.tabIndex&&(c=b.field.tabIndex,b.field.tabIndex=-1,b.element.tabIndex=c)}else if(0<b.host.find("li").length||0<b.host.find("option").length)c=a.jqx.parseSourceTag(b.element),b.source=c.items;b.element.innerHTML="";c=b.element.className;c+=" "+b.toThemeProperty("jqx-listbox");c+=" "+b.toThemeProperty("jqx-reset");c+=" "+b.toThemeProperty("jqx-rc-all");c+=" "+b.toThemeProperty("jqx-widget");c+=" "+b.toThemeProperty("jqx-widget-content");
2128b.element.className=c;d=window.getComputedStyle(this.element);c=2*parseInt(d.borderLeftWidth);d=d.boxSizing;0===this.element.offsetWidth&&(c=2);if("border-box"===d||isNaN(c))c=0;null!=b.width&&-1!=b.width.toString().indexOf("%")&&(b.host.width(b.width),0<c&&this.host.css("box-sizing","border-box"));null!=b.height&&-1!=b.height.toString().indexOf("%")&&(b.host.height(b.height),0==b.host.height()&&b.host.height(200));null!=b.width&&-1!=b.width.toString().indexOf("px")?b.element.style.width=parseInt(b.width)-
2129c+"px":void 0==b.width||isNaN(b.width)||(b.element.style.width=parseInt(b.width)-c+"px");null!=b.height&&-1!=b.height.toString().indexOf("px")?b.element.style.height=parseInt(b.height)-c+"px":void 0==b.height||isNaN(b.height)||(b.element.style.height=parseInt(b.height)-c+"px");b.multiple||b.multipleextended||b.checkboxes?a.jqx.aria(b,"aria-multiselectable",!0):a.jqx.aria(b,"aria-multiselectable",!1);c="<div style='-webkit-appearance: none; background: transparent; outline: none; width:100%; height: 100%; align:left; border: 0px; padding: 0px; margin: 0px; left: 0px; top: 0px; valign:top; position: relative;'><div style='-webkit-appearance: none; border: none; background: transparent; outline: none; width:100%; height: 100%; padding: 0px; margin: 0px; align:left; left: 0px; top: 0px; valign:top; position: relative;'><div id='filter"+
2130b.element.id+"' style='display: none; visibility: inherit; align:left; valign:top; left: 0px; top: 0px; position: absolute;'><input style='position: absolute;'/></div><div id='listBoxContent' style='-webkit-appearance: none; border: none; background: transparent; outline: none; border: none; padding: 0px; overflow: hidden; margin: 0px; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div><div id='verticalScrollBar"+b.element.id+"' style='visibility: inherit; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div><div id='horizontalScrollBar"+
2131b.element.id+"' style='visibility: inherit; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div><div id='bottomRight' style='align:left; valign:top; left: 0px; top: 0px; border: none; position: absolute;'/></div></div>";b.host.attr("role","listbox");b.element.innerHTML=c;b._checkForHiddenParent&&(b._addInput(),b.host.attr("tabIndex")||b.host.attr("tabIndex",1));b.filter=a(b.element.firstChild.firstChild.firstChild);b.filterInput=a(b.filter[0].firstChild);b.filterInput.attr("placeholder",
2132b.filterPlaceHolder);b.filterInput.addClass(b.toThemeProperty("jqx-widget jqx-listbox-filter-input jqx-input jqx-rc-all"));b.addHandler(b.filterInput,"keyup.textchange",function(f){13==f.keyCode?b._search(f):0<b.filterDelay&&(b._filterTimer&&clearTimeout(b._filterTimer),b._filterTimer=setTimeout(function(){b._search(f)},b.filterDelay));f.stopPropagation()});c=a(b.element.firstChild.firstChild.firstChild.nextSibling.nextSibling);if(!b.host.jqxButton)throw Error("jqxListBox: Missing reference to jqxbuttons.js.");
2133if(c.jqxScrollBar)d=parseInt(b.host.height())/2,0==d&&(d=10),b.vScrollBar=c.jqxScrollBar({_initialLayout:!0,vertical:!0,rtl:b.rtl,theme:b.theme,touchMode:b.touchMode,largestep:d}),c=a(b.element.firstChild.firstChild.firstChild.nextSibling.nextSibling.nextSibling),b.hScrollBar=c.jqxScrollBar({_initialLayout:!0,vertical:!1,rtl:b.rtl,touchMode:b.touchMode,theme:b.theme}),b.content=a(b.element.firstChild.firstChild.firstChild.nextSibling),b.content[0].id="listBoxContent"+b.element.id,b.bottomRight=a(b.element.firstChild.firstChild.firstChild.nextSibling.nextSibling.nextSibling.nextSibling).addClass(b.toThemeProperty("jqx-listbox-bottomright")).addClass(b.toThemeProperty("jqx-scrollbar-state-normal")),
2134b.bottomRight[0].id="bottomRight"+b.element.id,b.vScrollInstance=a.data(b.vScrollBar[0],"jqxScrollBar").instance,b.hScrollInstance=a.data(b.hScrollBar[0],"jqxScrollBar").instance,!b.isTouchDevice()||a.jqx.browser.msie&&9>a.jqx.browser.version||(c=a("<div class='overlay' unselectable='on' style='z-index: 99; -webkit-appearance: none; border: none; background: black; opacity: 0.01; outline: none; border: none; padding: 0px; overflow: hidden; margin: 0px; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div>"),
2135b.content.parent().append(c),b.overlayContent=b.host.find(".overlay"),b.filterable&&b.overlayContent.css("top","30px")),b._updateTouchScrolling(),b.host.addClass("jqx-disableselect"),b.host.jqxDragDrop&&window.jqxListBoxDragDrop();else throw Error("jqxListBox: Missing reference to jqxscrollbar.js.");},_highlight:function(b,c){c=c.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");return b.replace(new RegExp("("+c+")","ig"),function(d,e){return"<b>"+e+"</b>"})},_addInput:function(){var b=this.host.attr("name");
2136b&&this.host.attr("name","");this.input=a("<input type='hidden'/>");this.host.append(this.input);this.input.attr("name",b)},_updateTouchScrolling:function(){var b=this;if(this.isTouchDevice()){b.enableHover=!1;var c=this.overlayContent?this.overlayContent:this.content;this.removeHandler(a(c),a.jqx.mobile.getTouchEventName("touchstart")+".touchScroll");this.removeHandler(a(c),a.jqx.mobile.getTouchEventName("touchmove")+".touchScroll");this.removeHandler(a(c),a.jqx.mobile.getTouchEventName("touchend")+
2137".touchScroll");this.removeHandler(a(c),"touchcancel.touchScroll");a.jqx.mobile.touchScroll(c,b.vScrollInstance.max,function(d,e){null!=e&&"hidden"!=b.vScrollBar.css("visibility")&&(b.vScrollInstance.setPosition(e),b._lastScroll=new Date);null!=d&&"hidden"!=b.hScrollBar.css("visibility")&&(b.hScrollInstance.setPosition(d),b._lastScroll=new Date)},this.element.id,this.hScrollBar,this.vScrollBar);"visible"!=b.vScrollBar.css("visibility")&&"visible"!=b.hScrollBar.css("visibility")?a.jqx.mobile.setTouchScroll(!1,
2138this.element.id):a.jqx.mobile.setTouchScroll(!0,this.element.id);this._arrange()}},isTouchDevice:function(){var b=a.jqx.mobile.isTouchDevice();if(1==this.touchMode){if(this.touchDevice)return!0;if(a.jqx.browser.msie&&9>a.jqx.browser.version)return!1;b=this.touchDevice=!0;a.jqx.mobile.setMobileSimulator(this.element)}else 0==this.touchMode&&(b=!1);b&&0!=this.touchModeStyle&&(this.scrollBarSize=a.jqx.utilities.touchScrollBarSize);b&&this.host.addClass(this.toThemeProperty("jqx-touch"));return b},beginUpdate:function(){this.updatingListBox=
2139!0},endUpdate:function(){this.updatingListBox=!1;this.allowDrag&&this._enableDragDrop||this.virtualSize&&this.virtualSize.height<10+this.host.height()?this._addItems(!0):this._addItems(!1);this._renderItems();this.allowDrag&&this._enableDragDrop&&this._enableDragDrop()},beginUpdateLayout:function(){this.updating=!0},resumeUpdateLayout:function(){this.updating=!1;this.vScrollInstance.value=0;this._render(!1)},propertiesChangedHandler:function(b,c,d){d.width&&d.height&&2==Object.keys(d).length&&(b._cachedItemHtml=
2140[],b.refresh())},propertyChangedHandler:function(b,c,d,e){if(void 0!=this.isInitialized&&0!=this.isInitialized&&d!=e&&!(b.batchUpdate&&b.batchUpdate.width&&b.batchUpdate.height&&2==Object.keys(b.batchUpdate).length)){if("_renderOnDemand"==c&&(b._render(!1,!0),-1!=b.selectedIndex)){var f=b.selectedIndex;b.selectedIndex=-1;b._stopEvents=!0;b.selectIndex(f,!1,!0);-1==b.selectedIndex&&(b.selectedIndex=f);b._stopEvents=!1}"filterable"==c&&b.refresh();"filterHeight"==c&&b._arrange();"filterPlaceHolder"==
2141c&&b.filterInput.attr("placeholder",e);"renderer"==c&&(b._cachedItemHtml=[],b.refresh());"itemHeight"!=c&&"checkboxSize"!==c||b.refresh();if("source"==c||"checkboxes"==c)null==e&&d&&d.unbindBindingUpdate&&(d.unbindBindingUpdate(b.element.id),d.unbindDownloadComplete(b.element.id)),b.clearSelection(),b.refresh();"scrollBarSize"!=c&&"equalItemsWidth"!=c||e==d||b._updatescrollbars();"disabled"==c&&(b._renderItems(),b.vScrollBar.jqxScrollBar({disabled:e}),b.hScrollBar.jqxScrollBar({disabled:e}));if("touchMode"==
2142c||"rtl"==c)b._removeHandlers(),b.vScrollBar.jqxScrollBar({touchMode:e}),b.hScrollBar.jqxScrollBar({touchMode:e}),"touchMode"!=c||a.jqx.browser.msie&&9>a.jqx.browser.version||(f=a("<div class='overlay' unselectable='on' style='z-index: 99; -webkit-appearance: none; border: none; background: black; opacity: 0.01; outline: none; border: none; padding: 0px; overflow: hidden; margin: 0px; align:left; valign:top; left: 0px; top: 0px; position: absolute;'></div>"),b.content.parent().append(f),b.overlayContent=
2143b.host.find(".overlay")),b.filterable&&b.filterInput&&("rtl"==c&&e?b.filterInput.addClass(b.toThemeProperty("jqx-rtl")):"rtl"!=c||e||b.filterInput.removeClass(b.toThemeProperty("jqx-rtl")),b._arrange()),b._updateTouchScrolling(),b._addHandlers(),b._render(!1);this.updating||("width"==c||"height"==c)&&b._updateSize();"theme"==c&&d!=e&&(b.hScrollBar.jqxScrollBar({theme:b.theme}),b.vScrollBar.jqxScrollBar({theme:b.theme}),b.host.removeClass(),b.host.addClass(b.toThemeProperty("jqx-listbox")),b.host.addClass(b.toThemeProperty("jqx-widget")),
2144b.host.addClass(b.toThemeProperty("jqx-widget-content")),b.host.addClass(b.toThemeProperty("jqx-reset")),b.host.addClass(b.toThemeProperty("jqx-rc-all")),b.refresh());"selectedIndex"==c&&(b.clearSelection(),b.selectIndex(e,!0));if("displayMember"==c||"valueMember"==c)d!=e&&(f=b.selectedIndex,b.refresh(),b.selectedIndex=f,b.selectedIndexes[f]=f),b._renderItems();"autoHeight"==c&&(d!=e?b._render(!1):(b._updatescrollbars(),b._renderItems())
2144);b._checkForHiddenParent&&a.jqx.isHidden(b.host)&&a.jqx.utilities.resize(this.host,
2145function(){b._updateSize()},!1,b._checkForHiddenParent)}},loadFromSelect:function(b){if(null!=b&&(b=a("#"+b),0<b.length)){b=a.jqx.parseSourceTag(b[0]);var c=b.index;this.source=b.items;this.fromSelect=!0;this.clearSelection();this.selectedIndex=c;this.selectedIndexes[this.selectedIndex]=this.selectedIndex;this.refresh()}},invalidate:function(){this._cachedItemHtml=[];this._renderItems();this.virtualSize=null;this._updateSize()},refresh:function(b){var c=this;if(void 0!=this.vScrollBar){this.itemHeight=
2146parseInt(this.itemHeight);this._cachedItemHtml=[];this.visibleItems=[];var d=function(e){1==e&&-1!=c.selectedIndex&&(e=c.selectedIndex,c.selectedIndex=-1,c._stopEvents=!0,c.selectIndex(e,!1,!0),-1==c.selectedIndex&&(c.selectedIndex=e),c._stopEvents=!1)};null!=this.itemswrapper&&(this.itemswrapper.remove(),this.itemswrapper=null);if(a.jqx.dataAdapter&&null!=this.source&&this.source._source)this.databind(this.source,b),d(b);else{if(this.autoBind||!this.autoBind&&!b)this.field&&this.loadSelectTag(),
2147this.items=this.loadItems(this.source);this._render(!1,1==b);d(b);this._raiseEvent("6")}}},loadSelectTag:function(){var b=a.jqx.parseSourceTag(this.field);this.source=b.items;-1==this.selectedIndex&&(this.selectedIndex=b.index)},_render:function(b,c){if(this._renderOnDemand)this.visibleItems=[],this.renderedVisibleItems=[],this._renderItems();else{this._addItems();this._renderItems();this.vScrollInstance.setPosition(0);this._cachedItemHtml=[];(void 0==b||b)&&void 0!=this.items&&null!=this.items&&
21480<=this.selectedIndex&&this.selectedIndex<this.items.length&&this.selectIndex(this.selectedIndex,!0,!0,!0);if(this.allowDrag&&this._enableDragDrop&&(this._enableDragDrop(),this.isTouchDevice())){this._removeHandlers();this.overlayContent&&(this.overlayContent.remove(),this.overlayContent=null);this._updateTouchScrolling();this._addHandlers();return}this._updateTouchScrolling();this.rendered&&this.rendered();this.ready&&this.ready()}},_hitTest:function(b,c){this.filterable&&(c-=this.filterHeight,0>
2149c&&(c=0));b=parseInt(this.vScrollInstance.value);var d=this._searchFirstVisibleIndex(c+b,this.renderedVisibleItems);if(void 0!=this.renderedVisibleItems[d]&&this.renderedVisibleItems[d].isGroup||0<this.renderedVisibleItems.length&&(d=this.renderedVisibleItems[this.renderedVisibleItems.length-1],d.height+d.top<c+b))return null;d=this._searchFirstVisibleIndex(c+b);return this.visibleItems[d]},_searchFirstVisibleIndex:function(b,c){void 0==b&&(b=parseInt(this.vScrollInstance.value));var d=0;if(void 0==
2150c||null==c)c=this.visibleItems;for(var e=c.length;d<=e;){var f=parseInt((d+e)/2),g=c[f];if(void 0==g)break;if(g.initialTop>b&&g.initialTop+g.height>b)e=f-1;else if(g.initialTop<b&&g.initialTop+g.height<=b)d=f+1;else return f}return 0},_renderItems:function(){if(void 0==this.items||0==this.items.length)this.visibleItems=[];else if(1!=this.updatingListBox){var b=this.isTouchDevice(),c=this.vScrollInstance,d=this.hScrollInstance,e=parseInt(c.value),f=parseInt(d.value);this.rtl&&"hidden"!=this.hScrollBar[0].style.visibility&&
2151(f=d.max-f);this.host.width();var g=parseInt(this.content[0].style.width);d=g+parseInt(d.max);parseInt(this.vScrollBar[0].style.width);"visible"!=this.hScrollBar[0].style.visibility&&(d=g);this._getVirtualItemsCount();var h=[],k=0,l=parseInt(this.element.style.height)+2;-1!=this.element.style.height.indexOf("%")&&(l=this.host.outerHeight());isNaN(l)&&(l=0);var m=0,n=0,r=0;if(0==c.value||0==this.visibleItems.length)for(var t=0;t<this.items.length;t++)if(c=this.items[t],c.visible){c.top=-e;c.initialTop=
2152-e;!c.isGroup&&c.visible&&(this.visibleItems[n++]=c,c.visibleIndex=n-1);this.renderedVisibleItems[r++]=c;c.left=-f;var u=c.top+c.height;0<=u&&c.top-c.height<=l&&(h[k++]={index:t,item:c});e-=c.height;e--}t=0<e?this._searchFirstVisibleIndex(this.vScrollInstance.value,this.renderedVisibleItems):0;k=n=0;e=this.vScrollInstance.value;for(r=0;n<100+l;){c=this.renderedVisibleItems[t];if(void 0==c)break;c.visible&&(c.left=-f,u=c.top+c.height-e,0<=u&&c.initialTop-e-c.height<=2*l&&(h[k++]={index:t,item:c}));
2153t++;c.visible&&(n+=c.initialTop-e+c.height-n);r++;if(r>this.items.length-1)break}if(!this._renderOnDemand){f=this.toThemeProperty("jqx-listitem-state-normal")+" "+this.toThemeProperty("jqx-item");k=this.toThemeProperty("jqx-listitem-state-group");u=this.toThemeProperty("jqx-listitem-state-disabled")+" "+this.toThemeProperty("jqx-fill-state-disabled");this.checkboxes&&(f+=" checkboxes");var x=0,B=this;for(t=0;t<this.visualItems.length;t++){var y=this.visualItems[t];n=function(){var aa=y[0].firstChild;
2154B.checkboxes&&(aa=y[0].lastChild);null!=aa&&(aa.style.visibility="hidden",aa.className="");B.checkboxes&&(y[0].firstChild.style.visibility="hidden")};if(t<h.length)if(c=h[t].item,c.initialTop-e>=l)n();else{if(n=a(y[0].firstChild),this.checkboxes&&(n=a(y[0].lastChild)),0!=n.length&&null!=n[0]){n[0].className="";n[0].style.display="block";n[0].style.visibility="inherit";r="";r=!c.isGroup&&0<=!this.selectedIndexes[c.index]?f:k;if(c.disabled||this.disabled)r+=" "+u;this.roundedcorners&&(r+=" "+this.toThemeProperty("jqx-rc-all"));
2155b&&(r+=" "+this.toThemeProperty("jqx-listitem-state-normal-touch"));n[0].className=r;if(this.renderer)c.key||(c.key=this.generatekey()),this._cachedItemHtml||(this._cachedItemHtml=[]),this._cachedItemHtml[c.key]?n[0].innerHTML!=this._cachedItemHtml[c.key]&&(n[0].innerHTML=this._cachedItemHtml[c.key]):(r=this.renderer(c.index,c.label,c.value),n[0].innerHTML=r,this._cachedItemHtml[c.key]=n[0].innerHTML);else if(-1!==this.itemHeight&&(r=2+2*parseInt(n.css("padding-top")),n[0].style.lineHeight=c.height-
2156r+"px",n.css("vertical-align","middle")),null!=c.html&&0<c.html.toString().length)n[0].innerHTML=c.html;else if(null!=c.label||null!=c.value)null!=c.label?(n[0].innerHTML!==c.label&&(n[0].innerHTML=c.label),""==a.trim(c.label)&&(n[0].innerHTML=this.emptyString,""==this.emptyString&&(n[0].style.height=c.height-8+"px")),this.incrementalSearch||c.disabled||void 0==this.searchString||""==this.searchString||(n[0].innerHTML=this._highlight(c.label.toString(),this.searchString))):null===c.label?(n[0].innerHTML=
2157this.emptyString,""==this.emptyString&&(n[0].style.height=c.height-8+"px")):n[0].innerHTML!==c.value?n[0].innerHTML=c.value:""==c.label&&(n[0].innerHTML=" ");else if(""==c.label||null==c.label)n[0].innerHTML="",n[0].style.height=c.height-8+"px";y[0].style.left=c.left+"px";y[0].style.top=c.initialTop-e+"px";c.element=n[0];this.isMaterialized()&&!this.renderer&&this._checkForHiddenParent&&(a(c.element).addClass("ripple"),a.jqx.ripple(a(c.element)));c.title&&(n[0].title=c.title);this.equalItemsWidth&&
2158!c.isGroup?(0==m&&(m=parseInt(d),r=parseInt(n.outerWidth())-parseInt(n.width()),m-=r,r=1,r=null!=r?parseInt(r):0,"border-box"===this.host.css("box-sizing")&&(m-=2),this.checkboxes&&"hidden"==this.hScrollBar[0].style.visibility&&(m-=this.checkboxSize+13)),g>this.virtualSize.width?(n[0].style.width=m+"px",c.width=m):(n[0].style.width=-4+this.virtualSize.width+"px",c.width=this.virtualSize.width-4)):n.width()<this.host.width()&&n.width(this.host.width()-2);this.rtl&&(n[0].style.textAlign="right");this.autoItemsHeight&&
2159(n[0].style.whiteSpace="pre-line",n.width(m),c.width=m);x=0;if(this.checkboxes&&!c.isGroup){0==x&&(x=(c.height-this.checkboxSize-3)/2,x=parseInt(x),x++);r=a(y.children()[0]);r[0].item=c;if(this.rtl)"0px"!=n[0].style.left&&(n[0].style.left="0px");else{var A=this.checkboxSize+9;n[0].style.left!=A+"px"&&(n[0].style.left=A+"px")}this.rtl&&r.css("left",8+c.width+"px");r[0].style.top=x+"px";r[0].style.display="block";r[0].style.visibility="inherit";A=(x=c.checked)?" "+this.toThemeProperty("jqx-checkbox-check-checked"):
2160"";r[0].setAttribute("checked",c.checked);r[0].firstChild&&r[0].firstChild.firstChild&&r[0].firstChild.firstChild.firstChild&&r[0].firstChild.firstChild&&(x?r[0].firstChild.firstChild.firstChild.className=A:!1===x?r[0].firstChild.firstChild.firstChild.className="":null===x&&(r[0].firstChild.firstChild.firstChild.className=this.toThemeProperty("jqx-checkbox-check-indeterminate")));a.jqx.ariaEnabled&&(x?y[0].setAttribute("aria-selected",!0):y[0].removeAttribute("aria-selected"))}else this.checkboxes&&
2161(r=a(y.children()[0]),r.css({display:"none",visibility:"inherit"}));!c.disabled&&(!this.filterable&&0<=this.selectedIndexes[c.visibleIndex]||c.selected&&this.filterable)?(n.addClass(this.toThemeProperty("jqx-listitem-state-selected")),n.addClass(this.toThemeProperty("jqx-fill-state-pressed")),a.jqx.ariaEnabled&&(y[0].setAttribute("aria-selected",!0),this._activeElement=y[0])):this.checkboxes||a.jqx.ariaEnabled&&y[0].removeAttribute("aria-selected")}}else n()}}}},escape_HTML:function(b){return b.replace(/[&<>"]/g,
2162function(c){return{"&":"&","<":"<",">":">",'"':'"'}[c]||c})},generatekey:function(){var b=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return b()+b()+"-"+b()+"-"+b()+"-"+b()+"-"+b()+b()+b()},_calculateVirtualSize:function(b){if(!this._renderOnDemand){var c=0,d=2,e=document.createElement("span");this.equalItemsWidth&&a(e).css("float","left");e.style.whiteSpace="pre";var f=0,g=void 0===b?this.host.outerHeight():b+2;document.body.appendChild(e);var h=this.items.length,k=this.host.width();
2163this.autoItemsHeight&&(k-=10,"hidden"!=this.vScrollBar.css("visibility")&&(k-=20));if(this.autoItemsHeight||this.renderer||1<=this.groups.length||0<h&&null!=this.items[0].html&&""!=this.items[0].html)for(b=0;b<h;b++){var l=this.items[b];if((!l.isGroup||""!=l.label||""!=l.html)&&l.visible){var m="";m=l.isGroup?m+this.toThemeProperty("jqx-listitem-state-group jqx-rc-all"):m+this.toThemeProperty("jqx-widget jqx-listitem-state-normal jqx-rc-all");m+=" "+this.toThemeProperty("jqx-fill-state-normal");this.isTouchDevice()&&
2164(m+=" "+this.toThemeProperty("jqx-touch"));e.className=m;this.autoItemsHeight&&(e.style.whiteSpace="pre-line",m=this.checkboxSize+9,m=this.checkboxes?-m:0,e.style.width=m+k+"px");if(this.renderer){var n=this.renderer(l.index,l.label,l.value);e.innerHTML=n}else if(null!=l.html&&0<l.html.toString().length)e.innerHTML=l.html;else if(null!=l.label||null!=l.value)null!=l.label?(e.innerHTML=l.label,""==l.label&&(e.innerHTML="Empty")):e.innerHTML=this.escape_HTML(l.value);m=e.offsetHeight;n=e.offsetWidth;
2165-1<this.itemHeight&&(m=this.itemHeight);l.height=m;l.width=n;m++;d+=m;c=Math.max(c,n);d<=g&&f++}}else{var r=d=0;c="";var t=n=0,u=-1;for(b=0;b<h;b++)if(l=this.items[b],(!l.isGroup||""!=l.label||""!=l.html)&&l.visible){u++;m="";if(0==u){m+=this.toThemeProperty("jqx-listitem-state-normal jqx-rc-all");m+=" "+this.toThemeProperty("jqx-fill-state-normal");m+=" "+this.toThemeProperty("jqx-widget");m+=" "+this.toThemeProperty("jqx-listbox");m+=" "+this.toThemeProperty("jqx-widget-content");this.isTouchDevice()&&
2166(m+=" "+this.toThemeProperty("jqx-touch"),m+=" "+this.toThemeProperty("jqx-listitem-state-normal-touch"));e.className=m;this.autoItemsHeight&&(e.style.whiteSpace="pre-line",m=this.checkboxSize+9,m=this.checkboxes?-m:0,e.style.width=m+k+"px");if(null==l.html||""==l.label||null==l.label)e.innerHTML="Item";else if(null!=l.html&&0<l.html.toString().length)e.innerHTML=l.html;else if(null!=l.label||null!=l.value)null!=l.label?null!=l.label.toString().match(RegExp("\\w"))||null!=l.label.toString().match(RegExp("\\d"))?
2167e.innerHTML=l.label:e.innerHTML="Item":e.innerHTML=l.value;m=1+e.offsetHeight;-1<this.itemHeight&&(m=this.itemHeight);r=m}void 0!=n&&(t=n);null!=l.html&&0<l.html.toString().length?(n=Math.max(n,l.html.toString().length),t!=n&&(c=l.html)):null!=l.label?(n=Math.max(n,l.label.length),t!=n&&(c=l.label)):null!=l.value&&(n=Math.max(n,l.value.length),t!=n&&(c=l.value));l.height=r;d+=r;d++;d<=g&&f++}e.innerHTML=c;c=e.offsetWidth}d+=2;10>f&&(f=10);this.filterable&&(d+=this.filterHeight);d-=4;e.parentNode.removeChild(e);
2168return{width:c,height:d,itemsPerPage:f}}},_getVirtualItemsCount:function(){if(0==this.virtualItemsCount){var b=parseInt(this.host.height())/5;b>this.items.length&&(b=this.items.length);return b}return this.virtualItemsCount},_addItems:function(b){if(!this._renderOnDemand){var c=this;if(1!=c.updatingListBox)if(void 0==c.items||0==c.items.length)c.virtualSize={width:0,height:0,itemsPerPage:0},c._updatescrollbars(),c.renderedVisibleItems=[],c.itemswrapper&&c.itemswrapper.children().remove();else{var d=
2169c.host.height();if(0==b){var e=c._calculateVirtualSize(d),f=2*e.itemsPerPage;c.autoHeight&&(f=c.items.length);c.virtualItemsCount=Math.min(f,c.items.length);c.virtualSize=e;c._updatescrollbars()}else{b=0;c.visibleItems=[];c.renderedVisibleItems=[];c._removeHandlers();c.allowDrag&&c._enableDragDrop&&(c.itemswrapper=null);null==c.itemswrapper&&(c.content[0].innerHTML="",c.itemswrapper=a('<div style="outline: 0 none; overflow:hidden; width:100%; position: relative;"></div>'),c.itemswrapper[0].style.height=
21702*d+"px",c.content[0].appendChild(c.itemswrapper[0]));e=c._calculateVirtualSize(d);f=2*e.itemsPerPage;c.autoHeight&&(f=c.items.length);c.virtualItemsCount=Math.min(f,c.items.length);c=this;c.virtualSize=e;e=Math.max(c.host.width(),17+e.width);c.itemswrapper[0].style.width=e+"px";var g="",h=a.jqx.browser.msie&&9>a.jqx.browser.version?' unselectable="on"':"";for(e=0;e<c.virtualItemsCount;e++){f=c.items[e];var k="listitem"+e+c.element.id;g=""!=c.theme?g+("<div"+h+" role='option' id='"+k+"' class='jqx-listitem-element jqx-listitem-element-"+
2171c.theme+"'>"):g+("<div"+h+" role='option' id='"+k+"' class='jqx-listitem-element'>");c.checkboxes&&(k=this.checkboxSize+8,g+='<div style="background-color: transparent; padding: 0; margin: 0; overflow:hidden; position: absolute; float: left; width: '+k+"px; height:  "+k+'px;" class="'+c.toThemeProperty("jqx-checkbox")+' chkbox">',k='<div class="'+c.toThemeProperty("jqx-checkbox-default")+" "+c.toThemeProperty("jqx-fill-state-normal")+" "+c.toThemeProperty("jqx-rc-all")+'"><div style="cursor: pointer; width:  '+
2172this.checkboxSize+"px; height:  "+this.checkboxSize+'px;">',f=f.checked?" "+c.toThemeProperty("jqx-checkbox-check-checked"):"",k+='<span style="width: '+this.checkboxSize+"px; height:  "+this.checkboxSize+'px;" class="checkBoxCheck'+f+'"></span>',k+="</div></div>",g+=k,g+="</div>");g+="<span"+h+" style='white-space: pre; -ms-touch-action: none;'></span></div>"}this.WinJS?c.itemswrapper.html(g):c.itemswrapper[0].innerHTML=g;g=c.itemswrapper.children();for(e=0;e<c.virtualItemsCount;e++)f=c.items[e],
2173h=a(g[e]),c.allowDrag&&c._enableDragDrop&&h.addClass("draggable"),c.checkboxes&&(a(
2173h.children()[0]),h.css("float","left"),a(h[0].firstChild).css("float","left")),h[0].style.height=f.height+"px",h[0].style.top=b+"px",b+=f.height+1,c.visualItems[e]=h;c._addHandlers();c._updatescrollbars();c.autoItemsHeight&&(e=c._calculateVirtualSize(d),f=2*e.itemsPerPage,c.autoHeight&&(f=c.items.length),c.virtualItemsCount=Math.min(f,c.items.length),c=this,c.virtualSize=e,c._updatescrollbars());a.jqx.browser.msie&&
21748>a.jqx.browser.version&&(c.host.attr("hideFocus",!0),c.host.find("div").attr("hideFocus",!0))}}}},_updatescrollbars:function(){if(this.virtualSize){var b=this.virtualSize.height,c=this.virtualSize.width,d=this.vScrollInstance,e=this.hScrollInstance;this._arrange(!1);var f=!1,g=this.host.outerWidth(),h=this.host.outerHeight(),k=0;c>g&&(k=this.hScrollBar.outerHeight()+2);if(b+k>h){var l=d.max;d.max=2+parseInt(b)+k-parseInt(h-2);"inherit"!=this.vScrollBar[0].style.visibility&&(this.vScrollBar[0].style.visibility=
2175"inherit",f=!0);l!=d.max&&d._arrange()}else"hidden"!=this.vScrollBar[0].style.visibility&&(this.vScrollBar[0].style.visibility="hidden",f=!0,d.setPosition(0));k=0;"hidden"!=this.vScrollBar[0].style.visibility&&(k=this.scrollBarSize+6);l=this.checkboxes?this.checkboxSize+6:0;if(this.autoItemsHeight)this.hScrollBar[0].style.visibility="hidden";else if(c>=g-k-l){var m=e.max;e.max="inherit"==this.vScrollBar[0].style.visibility?l+k+parseInt(c)-this.host.width()+2:l+parseInt(c)-this.host.width()+4;"inherit"!=
2176this.hScrollBar[0].style.visibility&&(this.hScrollBar[0].style.visibility="inherit",f=!0);m!=e.max&&e._arrange();"inherit"==this.vScrollBar[0].style.visibility&&(d.max=2+parseInt(b)+this.hScrollBar.outerHeight()+2-parseInt(this.host.height()))}
2176else"hidden"!=this.hScrollBar[0].style.visibility&&(this.hScrollBar[0].style.visibility="hidden",f=!0);e.setPosition(0);f&&this._arrange();this.itemswrapper&&(this.itemswrapper[0].style.width=Math.max(0,Math.max(g-2,17+c))+"px",this.itemswrapper[0].style.height=
2177Math.max(0,2*h)+"px");this.isTouchDevice()&&("visible"!=this.vScrollBar.css("visibility")&&"visible"!=this.hScrollBar.css("visibility")?a.jqx.mobile.setTouchScroll(!1,this.element.id):a.jqx.mobile.setTouchScroll(!0,this.element.id))}},clear:function(){this.source=null;this.visibleItems=[];this.renderedVisibleItems=[];this.itemsByValue=[];this.clearSelection();this.refresh()},clearSelection:function(b){for(var c=0;c<this.selectedIndexes.length;c++)this.selectedIndexes[c]&&-1!=this.selectedIndexes[c]&&
2178this._raiseEvent("1",{index:c,type:"api",item:this.getVisibleItem(c),originalEvent:null}),this.selectedIndexes[c]=-1;this.selectedIndex=-1;this.selectedValue=null;this.selectedValues=[];0!=b&&this._renderItems()},unselectIndex:function(b,c){if(!isNaN(b)){this.selectedIndexes[b]=-1;for(var d=!1,e=0;e<this.selectedIndexes.length;e++){var f=this.selectedIndexes[e];-1!=f&&void 0!=f&&(d=!0)}d||(this.selectedValue=null,this.selectedIndex=-1,(d=this.getVisibleItem(b))&&this.selectedValues[d.value]&&(this.selectedValues[d.value]=
2179null));if(void 0==c||1==c)this._renderItems(),this._raiseEvent("1",{index:b,type:"api",item:this.getVisibleItem(b),originalEvent:null});this._updateInputSelection();this._raiseEvent("2",{index:b,type:"api",item:this.getItem(b)})}},getInfo:function(){var b=this.getItems(),c=this.getVisibleItems(),d=this.vScrollInstance.value;this.filterable&&(d-=this.filterHeight);for(var e=[],f=0;f<c.length;f++){var g=c[f];if(g){var h=g.initialTop,k=!0;if(0>h+g.height-d||h-d>=this.host.height())k=!1;k&&e.push(g)}}return{items:b,
2180visibleItems:c,viewItems:e}},getItem:function(b){if(-1==b||isNaN(b)||"string"===typeof b)return-1===b?null:this.getItemByValue(b);var c=null;a.each(this.items,function(){if(this.index==b)return c=this,!1});return c},getVisibleItem:function(b){return-1==b||isNaN(b)||"string"===typeof b?-1===b?null:this.getItemByValue(b):this.visibleItems[b]},getVisibleItems:function(){return this.visibleItems},checkIndex:function(b,c,d){if(this.checkboxes&&!(isNaN(b)||0>b||b>=this.visibleItems.length||null!=this.visibleItems[b]&&
2181this.visibleItems[b].disabled||this.disabled)){var e=this.getItem(b);if(0<this.groups.length||this.filterable)e=this.getVisibleItem(b);null!=e&&(a(e.checkBoxElement),e.checked=!0,void 0!=c&&1!=c||this._updateCheckedItems());void 0!=d&&1!=d||this._raiseEvent(3,{label:e.label,value:e.value,checked:!0,item:e})}},getCheckedItems:function(){if(!this.checkboxes)return null;var b=[];if(void 0!=this.items)return a.each(this.items,function(){this.checked&&(b[b.length]=this)}),b},checkAll:function(b){if(this.checkboxes&&
2182!this.disabled){var c=this;a.each(this.items,function(){var d=this.checked;this.checked=!0;!1!==b&&!0!==d&&c._raiseEvent(3,{label:this.label,value:this.value,checked:!0,item:this})});this._updateCheckedItems()}},uncheckAll:function(b){if(this.checkboxes&&!this.disabled){var c=this;a.each(this.items,function(){var d=this.checked;this.checked=!1;!1!==b&&!1!==d&&(this.checked=!1,c._raiseEvent(3,{label:this.label,value:this.value,checked:!1,item:this}))});this._updateCheckedItems()}},uncheckIndex:function(b,
2183c,d){if(this.checkboxes&&!(isNaN(b)||0>b||b>=this.visibleItems.length||null!=this.visibleItems[b]&&this.visibleItems[b].disabled||this.disabled)){var e=this.getItem(b);if(0<this.groups.length||this.filterable)e=this.getVisibleItem(b);null!=e&&(a(e.checkBoxElement),e.checked=!1,void 0!=c&&1!=c||this._updateCheckedItems());void 0!=d&&1!=d||this._raiseEvent(3,{label:e.label,value:e.value,checked:!1,item:e})}},indeterminateIndex:function(b,c,d){if(this.checkboxes&&!(isNaN(b)||0>b||b>=this.visibleItems.length||
2184null!=this.visibleItems[b]&&this.visibleItems[b].disabled||this.disabled)){var e=this.getItem(b);if(0<this.groups.length||this.filterable)e=this.getVisibleItem(b);null!=e&&(a(e.checkBoxElement),e.checked=null,void 0!=c&&1!=c||this._updateCheckedItems());void 0!=d&&1!=d||this._raiseEvent(3,{checked:null})}},getSelectedIndex:function(){return this.selectedIndex},getSelectedItems:function(){var b=this.getVisibleItems(),c=this.selectedIndexes,d=[],e;for(e in c)-1!=c[e]&&(d[d.length]=b[e]);return d},getSelectedItem:function(){var b=
2185this.getSelectedItems();return b&&0<b.length?b[0]:null},_updateCheckedItems:function(){var b=this.selectedIndex;this.clearSelection(!1);this.getCheckedItems();this.selectedIndex=b;this._renderItems();b=a.data(this.element,"hoveredItem");null!=b&&(a(b).addClass(this.toThemeProperty("jqx-listitem-state-hover")),a(b).addClass(this.toThemeProperty("jqx-fill-state-hover")));this._updateInputSelection()},getItemByValue:function(b){if(null!=this.visibleItems){b&&b.value&&(b=b.value);if(this.itemsByValue)return this.itemsByValue[a.trim(b).split(" ").join("?")];
2186for(var c=this.visibleItems,d=0;d<c.length;d++)if(c[d].value==b)return c[d]}},checkItem:function(b){return null!=b?(b=this._getItemByParam(b),this.checkIndex(b.visibleIndex,!0)):!1},uncheckItem:function(b){return null!=b?(b=this._getItemByParam(b),this.uncheckIndex(b.visibleIndex,!0)):!1},indeterminateItem:function(b){return null!=b?(b=this._getItemByParam(b),this.indeterminateIndex(b.visibleIndex,!0)):!1},val:function(b){if(this.input){a:{for(c in b)if(b.hasOwnProperty(c)){var c=!1;break a}c="number"==
2187typeof b||"date"==typeof b||"boolean"==typeof b||"string"==typeof b?!1:!0}if(c||0==arguments.length)return this.input.val();c=this.getItemByValue(b);null!=c&&this.selectItem(c);if(this.input)return this.input.val()}},selectItem:function(b){if(null!=b){if(void 0==b.index){var c=this.getItemByValue(b);c&&(b=c)}return this.selectIndex(b.visibleIndex,!0)}this.clearSelection();return!1},unselectItem:function(b){if(null!=b){if(void 0==b.index){var c=this.getItemByValue(b);c&&(b=c)}return this.unselectIndex(b.visibleIndex,
2188!0)}return!1},selectIndex:function(b,c,d,e,f,g){if(!isNaN(b)){var h=this.selectedIndex;this.filterable&&(this.selectedIndex=-1);if(!(-1>b||b>=this.visibleItems.length||null!=this.visibleItems[b]&&this.visibleItems[b].disabled||this.disabled))if(this.multiple||this.multipleextended||this.selectedIndex!=b||e||this.checkboxes)if(this.checkboxes){this._updateCheckedItems();var k=h;this.selectedIndex!=b||this.multiple||(k=-1);void 0==f&&(f="none");h=this.getItem(b);var l=this.getItem(k);this.visibleItems&&
2189this.items&&this.visibleItems.length!=this.items.length&&(h=this.getVisibleItem(b),l=this.getVisibleItem(k));this._raiseEvent("1",{index:k,type:f,item:l,originalEvent:g});this.selectedIndex=b;this.selectedIndexes[k]=-1;this.selectedIndexes[b]=b;h&&(this.selectedValue=h.value,this.selectedValues[h.value]=h.value);this._raiseEvent("0",{index:b,type:f,item:h,originalEvent:g});this._renderItems()}else{this.focused=!0;var m=!1;this.selectedIndex!=b&&(m=!0);k=h;this.selectedIndex!=b||this.multiple||(k=
2190-1);void 0==f&&(f="none");h=this.getItem(b);l=this.getItem(k);this.visibleItems&&this.items&&this.visibleItems.length!=this.items.length&&(h=this.getVisibleItem(b),l=this.getVisibleItem(k));if(void 0!=e&&e)this._raiseEvent("1",{index:k,type:f,item:l,originalEvent:g}),this.selectedIndex=b,this.selectedIndexes[k]=-1,this.selectedIndexes[b]=b,h&&(this.selectedValue=h.value,this.selectedValues[h.value]=h.value),this._raiseEvent("0",{index:b,type:f,item:h,originalEvent:g});else{var n=this;e=function(t,
2191u,x,B,y,A){n._raiseEvent("1",{index:u,type:x,item:B,originalEvent:A});n.selectedIndex=t;n.selectedIndexes=[];n.selectedIndexes[t]=t;n.selectedValues=[];y&&(n.selectedValues[y.value]=y.value);n._raiseEvent("0",{index:t,type:x,item:y,originalEvent:A})};var r=function(t,u,x,B,y,A){void 0==n.selectedIndexes[t]||-1==n.selectedIndexes[t]?(n.selectedIndexes[t]=t,n.selectedIndex=t,y&&(n.selectedValues[y.value]=y.value,
2191n._raiseEvent("0",{index:t,type:x,item:y,originalEvent:A}))):(u=n.selectedIndexes[t],(B=
2192n.getVisibleItem(u))&&(n.selectedValues[B.value]=null),n.selectedIndexes[t]=-1,n.selectedIndex=-1,n._raiseEvent("1",{index:u,type:x,item:B,originalEvent:A}))};if(this.multipleextended)if(!this._shiftKey&&!this._ctrlKey)"keyboard"!=f&&"mouse"!=f?(r(b,k,f,l,h,g),n._clickedIndex=b):(this.clearSelection(!1),n._clickedIndex=b,e(b,k,f,l,h,g));else if(this._ctrlKey)"keyboard"==f&&(this.clearSelection(!1),n._clickedIndex=b),r(b,k,f,l,h,g);else{if(this._shiftKey){void 0==n._clickedIndex&&(n._clickedIndex=
2193k);e=Math.min(n._clickedIndex,b);k=Math.max(n._clickedIndex,b);for(this.clearSelection(!1);e<=k;e++)n.selectedIndexes[e]=e,n.selectedValues[n.getVisibleItem(e).value]=n.getVisibleItem(e).value,n._raiseEvent("0",{index:e,type:f,item:this.getVisibleItem(e),originalEvent:g});n.selectedIndex="keyboard"!=f?n._clickedIndex:b}}else this.multiple?r(b,k,f,l,h,g):(h&&(this.selectedValue=h.value),e(b,k,f,l,h,g))}void 0!=d&&1!=d||this._renderItems();void 0!=c&&null!=c&&1==c&&this.ensureVisible(b);this._raiseEvent("2",
2194{index:b,item:h,oldItem:l,type:f,originalEvent:g});this._updateInputSelection();return m}else this.visibleItems&&this.items&&this.visibleItems.length!=this.items.length&&(h=this.getVisibleItem(b))&&(this.selectedValue=h.value,this.selectedValues[h.value]=h.value)}},_updateInputSelection:function(){this._syncSelection();var b=[];if(this.input&&(-1==this.selectedIndex?this.input.val(""):this.items&&void 0!=this.items[this.selectedIndex]&&(this.input.val(this.items[this.selectedIndex].value),b.push(this.items[this.selectedIndex].value)),
2195this.multiple||this.multipleextended||this.checkboxes)){var c=this.checkboxes?this.getCheckedItems():this.getSelectedItems(),d="";if(c){for(var e=0;e<c.length;e++)void 0!=c[e]&&(d=e==c.length-1?d+c[e].value:d+(c[e].value+","),b.push(c[e].value));this.input.val(d)}}this.field&&this.input&&("select"==this.field.nodeName.toLowerCase()?a.each(this.field,function(f,g){a(this).removeAttr("selected");(this.selected=0<=b.indexOf(this.value))&&a(this).attr("selected",!0)}):a.each(this.items,function(f,g){a(this.originalItem.originalItem).removeAttr("data-selected");
2196(this.selected=0<=b.indexOf(this.value))&&a(this.originalItem.originalItem).attr("data-selected",!0)}))},isIndexInView:function(b){if(isNaN(b)||!this.items||0>b||b>=this.items.length)return!1;var c=this.vScrollInstance.value,d=0;this.filterable&&(d=this.filterHeight);var e=this.visibleItems[b];if(void 0==e)return!0;b=e.initialTop;e=e.height;return b-c<d||b-c+d+e>=this.host.outerHeight()?!1:!0},_itemsInPage:function(){var b=0,c=this;this.items&&a.each(this.items,function(){if(this.initialTop+this.height>=
2197c.content.height())return!1;b++});return b},_firstItemIndex:function(){return null!=this.visibleItems?this.visibleItems[0]?this.visibleItems[0].isGroup?this._nextItemIndex(0):0:0:-1},_lastItemIndex:function(){return null!=this.visibleItems?this.visibleItems[this.visibleItems.length-1]?this.visibleItems[this.visibleItems.length-1].isGroup?this._prevItemIndex(this.visibleItems.length-1):this.visibleItems.length-1:this.visibleItems.length-1:-1},_nextItemIndex:function(b){for(b+=1;b<this.visibleItems.length;b++)if(this.visibleItems[b]&&
2198!this.visibleItems[b].disabled&&!this.visibleItems[b].isGroup)return b;return-1},_prevItemIndex:function(b){for(--b;0<=b;b--)if(this.visibleItems[b]&&!this.visibleItems[b].disabled&&!this.visibleItems[b].isGroup)return b;return-1},clearFilter:function(){this.filterInput.val("");this._updateItemsVisibility("")},_search:function(b){var c=this.filterInput.val();if(9!=b.keyCode&&"none"!=this.searchMode&&null!=this.searchMode&&"undefined"!=this.searchMode&&16!=b.keyCode&&17!=b.keyCode&&20!=b.keyCode){if(37==
2199b.keyCode||39==b.keyCode)return!1;b.altKey||18==b.keyCode||33<=b.keyCode&&40>=b.keyCode||(b.ctrlKey||b.metaKey||this.ctrlKey)&&88!=b.keyCode&&86!=b.keyCode||c!==this.searchString&&this._updateItemsVisibility(c)}},_updateItemsVisibility:function(b){var c=this.getItems();if(void 0==c)return{index:-1,matchItem:[]};var d=this,e=0;a.each(c,function(g){if(!this.isGroup){g=this.searchLabel?this.searchLabel:this.label?this.label:this.value?this.value:this.title?this.title:"jqxItem";g=g.toString();var h=!1;
2200switch(d.searchMode){case "containsignorecase":h=a.jqx.string.containsIgnoreCase(g,b);break;case "contains":h=a.jqx.string.contains(g,b);break;case "equals":h=a.jqx.string.equals(g,b);break;case "equalsignorecase":h=a.jqx.string.equalsIgnoreCase(g,b);break;case "startswith":h=a.jqx.string.startsWith(g,b);break;case "startswithignorecase":h=a.jqx.string.startsWithIgnoreCase(g,b);break;case "endswith":h=a.jqx.string.endsWith(g,b);break;case "endswithignorecase":h=a.jqx.string.endsWithIgnoreCase(g,b)}h||
2201(this.visible=!1);h&&(e++,this.visible=!0);""==b&&(this.visible=!0)}});d.renderedVisibleItems=[];d.visibleItems=[];d.vScrollInstance.setPosition(0,!0);d._addItems(!1);d._renderItems();for(c=0;c<d.items.length;c++)d.selectedIndexes[c]=-1;d.selectedIndex=-1;for(var f in d.selectedValues)b=d.selectedValues[f],(c=d.getItemByValue(b))&&c.visible&&(d.selectedIndex=c.visibleIndex,d.selectedIndexes[c.visibleIndex]=c.visibleIndex);d._syncSelection();d.filterChange&&d.filterChange(b)},_getMatches:function(b,
2202c){if(void 0==b||0==b.length)return-1;void 0==c&&(c=0);var d=this.getItems(),e=this,f=-1;a.each(d,function(g){if(!this.isGroup){g=this.searchLabel?this.searchLabel.toString():this.label?this.label.toString():this.value?this.value.toString():this.title?this.title.toString():"jqxItem";var h=!1;switch(e.searchMode){case "containsignorecase":h=a.jqx.string.containsIgnoreCase(g,b);break;case "contains":h=a.jqx.string.contains(g,b);break;case "equals":h=a.jqx.string.equals(g,b);break;case "equalsignorecase":h=
2203a.jqx.string.equalsIgnoreCase(g,b);break;case "startswith":h=a.jqx.string.startsWith(g,b);break;case "startswithignorecase":h=a.jqx.string.startsWithIgnoreCase(g,b);break;case "endswith":h=a.jqx.string.endsWith(g,b);break;case "endswithignorecase":h=a.jqx.string.endsWithIgnoreCase(g,b)}if(h&&this.visibleIndex>=c)return f=this.visibleIndex,!1}});return f},findItems:function(b){var c=this.getItems(),d=this,e=0,f=[];a.each(c,function(g){if(!this.isGroup){g=this.label?this.label:this.value?this.value:
2204this.title?this.title:"jqxItem";var h=!1;switch(d.searchMode){case "containsignorecase":h=a.jqx.string.containsIgnoreCase(g,b);break;case "contains":h=a.jqx.string.contains(g,b);break;case "equals":h=a.jqx.string.equals(g,b);break;case "equalsignorecase":h=a.jqx.string.equalsIgnoreCase(g,b);break;case "startswith":h=a.jqx.string.startsWith(g,b);break;case "startswithignorecase":h=a.jqx.string.startsWithIgnoreCase(g,b);break;case "endswith":h=a.jqx.string.endsWith(g,b);break;case "endswithignorecase":h=
2205a.jqx.string.endsWithIgnoreCase(g,b)}h&&(f[e++]=this)}});return f},_syncSelection:function(){if(this.filterable){if(this.items)for(var b=0;b<this.items.length;b++){var c=this.items[b];c.selected=!1}for(b=0;b<this.visibleItems.length;b++)c=this.visibleItems[b],this.selectedIndexes&&this.selectedIndexes[b]==c.visibleIndex&&(c.selected=!0);this.itemswrapper&&this._renderItems()}},_handleKeyDown:function(b){var c=b.keyCode,d=this,e=d.selectedIndex,f=d.selectedIndex;if(this.keyboardNavigation&&this.enableSelection&&
2206!(this.filterInput&&b.target==this.filterInput[0]||b.target instanceof HTMLInputElement&&a(b.target).ischildof(this.host))){var g=function(){(d.multiple||d.checkboxes)&&d.clearSelection(!1)};
2206b.altKey&&(c=-1);if(32==c&&this.checkboxes){var h=this.getItem(e);null!=h&&(d._updateItemCheck(h,e),b.preventDefault());d._searchString="";d.selectIndex(h.visibleIndex,!1,!0,!0,"keyboard",b);d._renderItems()}else{if(d.incrementalSearch){var k=-1;d._searchString||(d._searchString="");(8==c||46==c)&&1<=d._searchString.length&&
2207(d._searchString=d._searchString.substr(0,d._searchString.length-1));h=String.fromCharCode(c);b.key&&(h=b.key);var l=!isNaN(parseInt(h)),m=!1;if(65<=c&&97>=c||l||8==c||32==c||46==c){b.shiftKey||(h=h.toLocaleLowerCase());l=1+d.selectedIndex;8!=c&&32!=c&&46!=c&&(0<d._searchString.length&&d._searchString.substr(0,1)==h&&(l=1+d.selectedIndex),d._searchString+=h);32==c&&(d._searchString+=" ");k=h=this._getMatches(d._searchString,l);if(k==d._lastMatchIndex||-1==k)k=h=this._getMatches(d._searchString,0);
2208d._lastMatchIndex=k;0<=k&&(d._toSelectTimer&&clearTimeout(d._toSelectTimer),d._toSelectTimer=setTimeout(function(){g();d.selectIndex(k,!1,!1,!1,"keyboard",b);d.isIndexInView(k)?d._renderItems():d.ensureVisible(k)},d.incrementalSearchKeyDownDelay));m=!0}void 0!=d._searchTimer&&clearTimeout(d._searchTimer);if(27==c||13==c)d._searchString="";d._searchTimer=setTimeout(function(){d._searchString="";d._renderItems()},d.incrementalSearchDelay);if(0<=k)return;if(m)return!1}33==c&&(h=d._itemsInPage(),0<=d.selectedIndex-
2209h?(g(),d.selectIndex(f-h,!1,!1,!1,"keyboard",b)):(g(),d.selectIndex(d._firstItemIndex(),!1,!1,!1,"keyboard",b)),d._searchString="");32==c&&this.checkboxes&&(h=this.getItem(e),null!=h&&(d._updateItemCheck(h,e),b.preventDefault()),d._searchString="");36==c&&(g(),d.selectIndex(d._firstItemIndex(),!1,!1,!1,"keyboard",b),d._searchString="");35==c&&(g(),d.selectIndex(d._lastItemIndex(),!1,!1,!1,"keyboard",b),d._searchString="");34==c&&(h=d._itemsInPage(),d.selectedIndex+h<d.visibleItems.length?(g(),d.selectIndex(f+
2210h,!1,!1,!1,"keyboard",b)):(g(),d.selectIndex(d._lastItemIndex(),!1,!1,!1,"keyboard",b)),d._searchString="");if(38==c)if(d._searchString="",0<d.selectedIndex)if(e=d._prevItemIndex(d.selectedIndex),e!=d.selectedIndex&&-1!=e)g(),d.selectIndex(e,!1,!1,!1,"keyboard",b);else return!0;else return!1;else if(40==c)if(d._searchString="",d.selectedIndex+1<d.visibleItems.length)if(e=d._nextItemIndex(d.selectedIndex),e!=d.selectedIndex&&-1!=e)g(),d.selectIndex(e,!1,!1,!1,"keyboard",b);else return!0;else return!1;
2211return 35==c||36==c||38==c||40==c||34==c||33==c?(d.isIndexInView(d.selectedIndex)?d._renderItems():d.ensureVisible(d.selectedIndex),!1):!0}}},_updateItemCheck:function(b,c){if(!this.disabled)switch(b.checked=1==b.checked?b.hasThreeStates&&this.hasThreeStates?null:!1:null!=b.checked,b.checked){case !0:this.checkIndex(c);break;case !1:this.uncheckIndex(c);break;default:this.indeterminateIndex(c)}},wheel:function(b,c){if(c.autoHeight||!c.enableMouseWheel)return b.returnValue=!0;if(c.disabled)return!0;
2212var d=0;b||(b=window.event);b.originalEvent&&b.originalEvent.wheelDelta&&(b.wheelDelta=b.originalEvent.wheelDelta);b.wheelDelta?d=b.wheelDelta/120:b.detail&&(d=-b.detail/3);if(d){if(c=c._handleDelta(d))b.preventDefault&&b.preventDefault(),null!=b.originalEvent&&(b.originalEvent.mouseHandled=!0),void 0!=b.stopPropagation&&b.stopPropagation();return c?(c=!1,b.returnValue=c):!1}b.preventDefault&&b.preventDefault();b.returnValue=!1},_handleDelta:function(b){var c=this.vScrollInstance.value;0>b?this.scrollDown():
2213this.scrollUp();return c!=this.vScrollInstance.value?!0:!1},focus:function(){try{this.focused=!0;this.host.focus();var b=this;setTimeout(function(){b.host.focus()},25)}catch(c){}},_removeHandlers:function(){this.removeHandler(a(document),"keydown.listbox"+this.element.id);this.removeHandler(a(document),"keyup.listbox"+this.element.id);this.removeHandler(this.vScrollBar,"valueChanged");this.removeHandler(this.hScrollBar,"valueChanged");this._mousewheelfunc?this.removeHandler(this.host,"mousewheel",
2214this._mousewheelfunc):this.removeHandler(this.host,"mousewheel");this.removeHandler(this.host,"keydown");this.removeHandler(this.content,"mouseleave");this.removeHandler(this.content,"focus");this.removeHandler(this.content,"blur");this.removeHandler(this.host,"focus");this.removeHandler(this.host,"blur");this.removeHandler(this.content,"mouseenter");this.removeHandler(this.content,"mouseup");this.removeHandler(this.content,"mousedown");this.removeHandler(this.content,"touchend");this._mousemovefunc?
2215this.removeHandler(this.content,"mousemove",this._mousemovefunc):this.removeHandler(this.content,"mousemove");this.removeHandler(this.content,"selectstart");this.overlayContent&&this.removeHandler(this.overlayContent,a.jqx.mobile.getTouchEventName("touchend"))},_updateSize:function(){this.virtualSize||(this._oldheight=null,this.virtualSize=this._calculateVirtualSize());this._arrange();if(this.host.height()!=this._oldheight||this.host.width()!=this._oldwidth){this.host.width();if(this.autoItemsHeight)this._render(!1);
2216else if(this.items)if(0<this.items.length&&this.virtualItemsCount*this.items[0].height<this._oldheight-2)this._render(!1);else{var b=this.vScrollInstance.value;this._updatescrollbars();this._renderItems();b<this.vScrollInstance.max?this.vScrollInstance.setPosition(b):this.vScrollInstance.setPosition(this.vScrollInstance.max)}this._oldwidth=this.host.width();this._oldheight=this.host.height()}},_addHandlers:function(){var b=this;this.focused=!1;var c=this.isTouchDevice();this.addHandler(this.vScrollBar,
2217"valueChanged",function(h){a.jqx.browser.msie&&9<a.jqx.browser.version?setTimeout(function(){b._renderItems()},1):b._renderItems()});this.addHandler(this.hScrollBar,"valueChanged",function(){b._renderItems()});this._mousewheelfunc&&this.removeHandler(this.host,"mousewheel",this._mousewheelfunc);this._mousewheelfunc=function(h){b.wheel(h,b)};this.addHandler(this.host,"mousewheel",this._mousewheelfunc);
2217this.addHandler(a(document),"keydown.listbox"+this.element.id,function(h){b._ctrlKey=h.ctrlKey||h.metaKey;
2218b._shiftKey=h.shiftKey});this.addHandler(a(document),"keyup.listbox"+this.element.id,function(h){b._ctrlKey=h.ctrlKey||h.metaKey;b._shiftKey=h.shiftKey});this.addHandler(this.host,"keydown",function(h){return b._handleKeyDown(h)});this.addHandler(this.content,"mouseleave",function(h){b.focused=!1;h=a.data(b.element,"hoveredItem");null!=h&&(a(h).removeClass(b.toThemeProperty("jqx-listitem-state-hover")),a(h).removeClass(b.toThemeProperty("jqx-fill-state-hover")),a.data(b.element,"hoveredItem",null))});
2219this.addHandler(this.content,"focus",function(h){b.disabled||(b.host.addClass(b.toThemeProperty("jqx-fill-state-focus")),b.focused=!0)});this.addHandler(this.content,"blur",function(h){b.focused=!1;b.host.removeClass(b.toThemeProperty("jqx-fill-state-focus"))});this.addHandler(this.host,"focus",function(h){b.disabled||(b.host.addClass(b.toThemeProperty("jqx-fill-state-focus")),b.focused=!0)});this.addHandler(this.host,"blur",function(h){a.jqx.browser.msie&&9>a.jqx.browser.version&&b.focused||(b.host.removeClass(b.toThemeProperty("jqx-fill-state-focus")),
2220b.focused=!1)});this.addHandler(this.content,"mouseenter",function(h){b.focused=!0});var d=a.jqx.utilities.hasTransform(this.host),e=b.isTouchDevice()&&!0!==this.touchMode,f=e?"touchend":"mousedown";if(this.overlayContent)this.addHandler(this.overlayContent,a.jqx.mobile.getTouchEventName("touchend"),function(h){if(!b.enableSelection||e&&(b._newScroll=ne
2220w Date,500>b._newScroll-b._lastScroll))return!0;var k=a.jqx.mobile.getTouches(h)[0];if(void 0!=k){var l=b.host.offset(),m=parseInt(k.pageX),n=parseInt(k.pageY);
22211==b.touchMode&&void 0!=k._pageX&&(m=parseInt(k._pageX),n=parseInt(k._pageY));m-=l.left;n-=l.top;var r=b._hitTest(m,n);if(null!=r&&!r.isGroup){b._newScroll=new Date;if(500>b._newScroll-b._lastScroll)return!1;if(b.checkboxes)b._updateItemCheck(r,r.visibleIndex);else if(-1!=r.html.indexOf("href"))setTimeout(function(){b.selectIndex(r.visibleIndex,!1,!0,!1,"mouse",h);b.content.trigger("click");return!1},100);else return b.selectIndex(r.visibleIndex,!1,!0,!1,"mouse",h),h.preventDefault&&h.preventDefault(),
2222b.content.trigger("click"),!1}}});else{var g=!1;this.addHandler(this.content,f,function(h){if(!b.enableSelection)return!0;g=!0;if(e&&(b._newScroll=new Date,500>b._newScroll-b._lastScroll))return!1;b.focused=!0;!b.isTouchDevice()&&b.focusable&&b.host.focus();if(h.target.id!="listBoxContent"+b.element.id&&b.itemswrapper[0]!=h.target){var k=h.target,l=a(k).offset(),m=b.host.offset();if(d){var n=a.jqx.mobile.getLeftPos(k);k=a.jqx.mobile.getTopPos(k);l.left=n;l.top=k;n=a.jqx.mobile.getLeftPos(b.element);
2223k=a.jqx.mobile.getTopPos(b.element);m.left=n;m.top=k}n=parseInt(l.top)-parseInt(m.top);var r=parseInt(l.left)-parseInt(m.left),t=b._hitTest(r,n);if(null!=t&&!t.isGroup){var u=function(x,B){b._shiftKey||(b._clickedIndex=x.visibleIndex);b.checkboxes?(r=20+B.pageX-l.left,b.rtl?("hidden"!=b.hScrollBar.css("visibility")||b.host.width(),r<=b.host.width()-20&&(b.allowDrag?setTimeout(function(){b._dragItem||g||(b._updateItemCheck(x,x.visibleIndex),b.selectIndex(x.visibleIndex,!1,!0,!1,"mouse",B))},200):(b._updateItemCheck(x,
2224x.visibleIndex),b.selectIndex(x.visibleIndex,!1,!0,!1,"mouse",B)))):20<=r+b.hScrollInstance.value&&(b.allowDrag?setTimeout(function(){b._dragItem||g||(b._updateItemCheck(x,x.visibleIndex),b.selectIndex(x.visibleIndex,!1,!0,!1,"mouse",B))},200):(b._updateItemCheck(x,x.visibleIndex),b.selectIndex(x.visibleIndex,!1,!0,!1,"mouse",B)))):b.selectIndex(x.visibleIndex,!1,!0,!1,"mouse",B)};t.disabled||(-1!=t.html.indexOf("href")?setTimeout(function(){u(t,h)},100):u(t,h))}}return!0})}this.addHandler(this.content,
2225"mouseup",function(h){b.vScrollInstance.handlemouseup(b,h);g=!1});a.jqx.browser.msie&&this.addHandler(this.content,"selectstart",function(h){return!1});c=this.isTouchDevice();this.enableHover&&!c&&(this._mousemovefunc=function(h){if(c||!b.enableHover||null==h.target||b.disabled)return!0;b.focused=!0;if(!b.vScrollInstance.isScrolling()&&h.target.id!="listBoxContent"+b.element.id&&b.itemswrapper[0]!=h.target){var k=h.target;h=a(k).offset();var l=b.host.offset();if(d){var m=a.jqx.mobile.getLeftPos(k);
2226k=a.jqx.mobile.getTopPos(k);h.left=m;h.top=k;m=a.jqx.mobile.getLeftPos(b.element);k=a.jqx.mobile.getTopPos(b.element);l.left=m;l.top=k}m=parseInt(h.top)-parseInt(l.top);h=parseInt(h.left)-parseInt(l.left);h=b._hitTest(h,m);null==h||h.isGroup||h.disabled||(l=a.data(b.element,"hoveredItem"),null!=l&&(a(l).removeClass(b.toThemeProperty("jqx-listitem-state-hover")),a(l).removeClass(b.toThemeProperty("jqx-fill-state-hover"))),a.data(b.element,"hoveredItem",h.element),h=a(h.element),h.addClass(b.toThemeProperty("jqx-listitem-state-hover")),
2227h.addClass(b.toThemeProperty("jqx-fill-state-hover")))}},this.addHandler(this.content,"mousemove",this._mousemovefunc))},_arrange:function(b){void 0==b&&(b=!0);var c=this,d=null,e=null,f=c.filterable?c.filterHeight:0,g=window.getComputedStyle(this.element),h=2*parseInt(g.borderLeftWidth);g=g.boxSizing;0===this.element.offsetWidth&&(h=2);if("border-box"===g||isNaN(h))h=0;g=function(n){n=c.host.height()-h;0==n&&(n=200,c.host.height(n));return n};null!=c.width&&-1!=c.width.toString().indexOf("px")?d=
2228c.width:void 0==c.width||isNaN(c.width)||(d=c.width);null!=c.height&&-1!=c.height.toString().indexOf("px")?e=c.height:void 0==c.height||isNaN(c.height)||(e=c.height);null!=c.width&&-1!=c.width.toString().indexOf("%")&&(c.host.css("width",c.width),d=c.host.width());null!=c.height&&-1!=c.height.toString().indexOf("%")&&(c.host.css("height",c.height),e=g(e));null!=d&&(d=parseInt(d)-h,parseInt(c.element.style.width)!=parseInt(c.width)&&(c.element.style.width=parseInt(d)+"px"));c.autoHeight?c.virtualSize&&
2229("hidden"!=c.hScrollBar.css("visibility")?(c.host.height(c.virtualSize.height+parseInt(c.scrollBarSize)+3),c.height=c.virtualSize.height+parseInt(c.scrollBarSize)+3,e=c.height):(c.host.height(c.virtualSize.height),e=c.height=c.virtualSize.height)):null!=e&&(e=parseInt(e),parseInt(c.element.style.height)!=parseInt(c.height)&&(c.host.height(c.height),g(e)));var k=c.scrollBarSize;isNaN(k)&&(k=parseInt(k),k=isNaN(k)?"17px":k+"px");k=parseInt(k);g=2;var l=1;if(c.vScrollBar&&("hidden"!=c.vScrollBar[0].style.visibility?
2230l=k+4:(l=0,c.vScrollInstance.setPosition(0)),0==k&&(g=l=0),c.hScrollBar)){"hidden"
2230!=c.hScrollBar[0].style.visibility?g=k+4:(c.hScrollInstance.setPosition(0),g=0);c.autoItemsHeight&&(c.hScrollBar[0].style.visibility="hidden",g=0);null==e&&(e=0);var m=parseInt(e)-4-k;0>m&&(m=0);parseInt(c.hScrollBar[0].style.height)!=k&&(0>parseInt(k)&&(k=0),c.hScrollBar[0].style.height=parseInt(k)+"px");c.hScrollBar[0].style.top!=m+"px"&&(c.hScrollBar[0].style.top=m+"px",c.hScrollBar[0].style.left="0px");m=d-k-4;0>
2231m&&(m=0);m+="px";c.hScrollBar[0].style.width!=m&&(c.hScrollBar[0].style.width=m);1>=l&&2<=d&&(c.hScrollBar[0].style.width=parseInt(d-2)+"px");k!=parseInt(c.vScrollBar[0].style.width)&&(c.vScrollBar[0].style.width=parseInt(k)+"px");parseInt(e)-g!=parseInt(c.vScrollBar[0].style.height)&&(m=parseInt(e)-g,0>m&&(m=0),c.vScrollBar[0].style.height=m+"px");null==d&&(d=0);m=parseInt(d)-parseInt(k)-4+"px";"border-box"===this.host.css("box-sizing")&&(m=parseInt(m)-2+"px");m!=c.vScrollBar[0].style.left&&(0<=
2232parseInt(m)&&(c.vScrollBar[0].style.left=m),c.vScrollBar[0].style.top="0px");m=c.vScrollInstance;m.disabled=c.disabled;b&&m._arrange();m=c.hScrollInstance;m.disabled=c.disabled;b&&m._arrange();"hidden"!=c.vScrollBar[0].style.visibility&&"hidden"!=c.hScrollBar[0].style.visibility?(c.bottomRight[0].style.visibility="inherit",c.bottomRight[0].style.left=1+parseInt(c.vScrollBar[0].style.left)+"px",c.bottomRight[0].style.top=1+parseInt(c.hScrollBar[0].style.top)+"px",c.rtl&&c.bottomRight.css({left:0}),
2233c.bottomRight[0].style.width=parseInt(k)+3+"px",c.bottomRight[0].style.height=parseInt(k)+3+"px"):c.bottomRight[0].style.visibility="hidden";parseInt(c.content[0].style.width)!=parseInt(d)-l&&(b=parseInt(d)-l,0>b&&(b=0),c.content[0].style.width=b+"px");c.rtl&&(c.vScrollBar.css({left:"0px",top:"0px"}),c.hScrollBar.css({left:c.vScrollBar.width()+2+"px"}),"hidden"!=c.vScrollBar[0].style.visibility?c.content.css("margin-left",4+c.vScrollBar.width()):(c.content.css("margin-left",0),c.hScrollBar.css({left:"0px"})),
2234c.filterable&&c.filterInput&&c.filterInput.css({left:c.vScrollBar.width()+6+"px"}));parseInt(c.content[0].style.height)!=parseInt(e)-g&&(b=parseInt(e)-g,0>b&&(b=0),c.content[0].style.height=b+"px",c.content[0].style.top="0px");0<f&&(c.content[0].style.top=f+"px",c.content[0].style.height=parseInt(c.content[0].style.height)-f+"px");c.filterable?(c.filterInput[0].style.height=f-6+"px",c.filterInput[0].style.top="3px",c.rtl||(c.filterInput[0].style.left=parseInt(c.content.css("left"))+3+"px"),c.filterInput[0].style.width=
2235parseInt(c.content.css("width"))-7+"px",c.filter[0].style.display="block"):c.filter[0].style.display="none";c.overlayContent&&(c.overlayContent.width(parseInt(d)-l),c.overlayContent.height(parseInt(e)-g))}},ensureVisible:function(b,c){if(isNaN(b)){var d=this.getItemByValue(b);d&&(b=d.index)}if(!this.isIndexInView(b)){if(0>b)return;if(this.autoHeight)b=a.data(this.vScrollBar[0],"jqxScrollBar").instance,b.setPosition(0);else for(var e=0;e<this.visibleItems.length;e++)if(d=this.visibleItems[e],d.visibleIndex==
2236b&&!d.isGroup){b=a.data(this.vScrollBar[0],"jqxScrollBar").instance;var f=b.value,g=this.filterable?this.filterHeight+2:0,h="hidden"===this.hScrollBar.css("visibility")?0:this.scrollBarSize+4;d.initialTop<f?(b.setPosition(d.initialTop),0==e&&b.setPosition(0)):d.initialTop+d.height>f+this.host.height()-g&&(g=this.host.height(),this.filterable?b.setPosition(this.filterHeight+2+d.initialTop+d.height+2-g+h):(b.setPosition(d.initialTop+d.height+2-g+h),e===this.visibleItems.length-1&&b.setPosition(b.max)),
2237c&&(f=b.value,c=d.initialTop,this.filterable&&(c=this.filterHeight+2+d.initialTop),f+g<b.max&&b.setPosition(c)));break}}else if(c)for(e=0;e<this.visibleItems.length;e++)d=this.visibleItems[e],d.visibleIndex!=b||d.isGroup||(f=this.vScrollInstance.value,c=d.initialTop,this.filterable&&(c=this.filterHeight+2+d.initialTop),f+this.host.height()<this.vScrollInstance.max&&this.vScrollInstance.setPosition(c));this._renderItems()},scrollTo:function(b,c){"hidden"!=this.vScrollBar.css("visibility")&&this.vScrollInstance.setPosition(c);
2238"hidden"!=this.hScrollBar.css("visibility")&&this.hScrollInstance.setPosition(b)},scrollDown:function(){if("hidden"==this.vScrollBar.css("visibility"))return!1;var b=this.vScrollInstance;b.value+b.largestep<=b.max?b.setPosition(b.value+b.largestep):b.setPosition(b.max);return!0},scrollUp:function(){if("hidden"==this.vScrollBar.css("visibility"))return!1;var b=this.vScrollInstance;return b.value-b.largestep>=b.min?(b.setPosition(b.value-b.largestep),!0):b.value!=b.min?(b.setPosition(b.min),!0):!1},
2239databind:function(b,c){this.records=[];var d=b._source?!0:!1,e=new a.jqx.dataAdapter(b,{autoBind:!1});d&&(e=b,b=b._source);var f=function(h,k){var l=function(u){var x=null;if("string"===typeof u)var B=u,y=u;else void 0!=h.displayMember&&""!=h.displayMember&&(y=u[h.valueMember],B=u[h.displayMember]);var A="";h.groupMember?A=u[h.groupMember]:u&&void 0!=u.group&&(A=u.group);h.searchMember?x=u[h.searchMember]:u&&void 0!=u.searchLabel&&(x=u.searchLabel);h.valueMember||h.displayMember||"string"==a.type(u)&&
2240(B=y=u.toString());u&&void 0!=u.label&&(B=u.label);u&&void 0!=u.value&&(y=u.value);var aa=!1;u&&void 0!=u.checked&&(aa=u.checked);var ha="";u&&void 0!=u.html&&(ha=u.html);var z=!0;u&&void 0!=u.visible&&(z=u.visible);var V=!1;u&&void 0!=u.disabled&&(V=u.disabled);var ba=!1;u&&void 0!=u.hasThreeStates&&(ba=u.hasThreeStates);var v={};v.label=B;v.value=y;v.searchLabel=x;v.html=ha;v.visible=z;v.originalItem=u;v.group=A;v.groupHtml="";v.disabled=V;v.checked=aa;v.hasThreeStates=ba;return v};if(void 0!=k&&
2241e._changedrecords[0])a.each(e._changedrecords,function(){var u=this.index,x=this.record;if("remove"!=k)var B=l(x);switch(k){case "update":h.updateAt(B,u);break;case "add":h.insertAt(B,u);break;case "remove":h.removeAt(u)}});else{h.records=e.records;for(var m=h.records.length,n=[],r=0;r<m;r++){var t=l(h.records[r]);t.index=r;n[r]=t}
2241h.items=h.loadItems(n,!0);h._render();h._raiseEvent("6")}};void 0!=b.type&&(e._options.type=b.type);void 0!=b.formatdata&&(e._options.formatData=b.formatdata);void 0!=b.contenttype&&
2242(e._options.contentType=b.contenttype);void 0!=b.async&&(e._options.async=b.async);var g=this;switch(b.datatype){default:if(null!=b.localdata||a.isArray(b))e.unbindBindingUpdate(this.element.id),(this.autoBind||!this.autoBind&&!c)&&e.dataBind(),f(this),e.bindBindingUpdate(this.element.id,function(h){f(g,h)});break;case "json":case "jsonp":case "xml":case "xhtml":case "script":case "text":case "csv":case "tab":null!=b.localdata?(e.unbindBindingUpdate(this.element.id),(this.autoBind||!this.autoBind&&
2243!c)&&e.dataBind(),f(this),e.bindBindingUpdate(this.element.id,function(){f(g)})):(d={},e._options.data?a.extend(e._options.data,d):(b.data&&a.extend(d,b.data),e._options.data=d),e.unbindDownloadComplete(g.element.id),e.bindDownloadComplete(g.element.id,function(){f(g)}),(this.autoBind||!this.autoBind&&!c)&&e.dataBind())}},loadItems:function(b,c){if(null==b)this.groups=[],this.items=[],this.visualItems=[];else{var d=this,e=0,f=0,g=0;this.groups=[];this.items=[];this.visualItems=[];var h=[];this.itemsByValue=
2244[];a.map(b,function(u){if(void 0==u)return null;var x=new a.jqx._jqxListBox.item,B=u.group,y=u.groupHtml,A=u.title,aa=null;d.searchMember?aa=u[d.searchMember]:u&&void 0!=u.searchLabel&&(aa=u.searchLabel);if(null==A||void 0==A)A="";if(null==B||void 0==B)B="";d.groupMember&&(B=u[d.groupMember]);if(null==y||void 0==y)y="";d.groups[B]||(d.groups[B]={items:[],index:-1,caption:B,captionHtml:y},e++,d.groups[e+"jqxGroup"]=d.groups[B],f++,d.groups.length=f);y=d.groups[B];y.index++;y.items[y.index]=x;"string"===
2245typeof u?(x.label=u,x.value=u,1<arguments.length&&arguments[1]&&"string"==a.type(arguments[1])&&(x.label=u,x.value=arguments[1])):null==u.label&&null==u.value&&null==u.html&&null==u.group&&null==u.groupHtml?(x.label=u.toString(),x.value=u.toString()):(x.label=u.label,x.value=u.value,void 0===x.label&&(x.label=u.value),void 0===x.value&&(x.value=u.label));"string"!=typeof u&&(void 0===u.label&&""!=d.displayMember&&(x.label=void 0!=u[d.displayMember]?u[d.displayMember]:""),void 0===u.value&&""!=d.valueMember&&
2246(x.value=u[d.valueMember]));x.hasThreeStates=void 0!=u.hasThreeStates?u.hasThreeStates:!0;x.originalItem=u;c&&(x.originalItem=u.originalItem);(x.title=A)&&void 0===x.value&&void 0===x.label&&(x.value=x.label=A);x.html=u.html||"";x.group=B;x.checked=u.checked||!1;x.groupHtml=u.groupHtml||"";x.disabled=u.disabled||!1;x.visible=void 0!=u.visible?u.visible:!0;x.searchLabel=aa;x.index=g;h[g]=x;g++;return x});var k=[],l=0;if(void 0==this.fromSelect||0==this.fromSelect)for(var m=0;m<f;m++){e=m+1;b=this.groups[e+
2247"jqxGroup"];if(void 0==b||null==b)break;if(0==m&&""==b.caption&&""==b.captionHtml&&1>=f){for(m=0;m<b.items.length;m++){var n=b.items[m].value;if(void 0==b.items[m].value||null==b.items[m].value)n=m;this.itemsByValue[a.trim(n).split(" ").join("?")]=b.items[m]}return b.items}n=new a.jqx._jqxListBox.item;n.isGroup=!0;n.label=b.caption;""==b.caption&&""==b.captionHtml&&(b.caption=this.emptyGroupText,n.label=b.caption);n.html=b.captionHtml;k[l]=n;l++;for(var r=0;r<b.items.length;r++){k[l]=b.items[r];n=
2248b.items[r].value;if(""==b.items[r].value||null==b.items[r].value)n=l;d.itemsByValue[a.trim(n).split(" ").join("?")]=b.items[r];l++}}else{l=0;var t=[];a.each(h,function(){if(!t[this.group]&&""!=this.group){var u=new a.jqx._jqxListBox.item;u.isGroup=!0;u.label=this.group;k[l]=u;l++;t[this.group]=!0}k[l]=this;u=this.value;if(""==this.value||null==this.value)u=l-1;d.itemsByValue[a.trim(u).split(" ").join("?")]=this;l++})}return k}},_mapItem:function(b){var c=new a.jqx._jqxListBox.item;this.displayMember&&
2249(void 0==b.label&&(b.label=b[this.displayMember]),void 0==b.value&&(b.value=b[this.valueMember]));"string"===typeof b?(c.label=b,c.value=b):"number"===typeof b?(c.label=b.toString(),c.value=b.toString()):(c.label=void 0!==b.label?b.label:b.value,c.value=void 0!==b.value?b.value:b.label);void 0==c.label&&void 0==c.value&&void 0==c.html&&(c.label=c.value=b);c.html=b.html||"";c.group=b.group||"";c.checked=b.checked||!1;c.title=b.title||"";c.groupHtml=b.groupHtml||"";c.disabled=b.disabled||!1;c.visible=
2250b.visible||!0;return c},addItem:function(b){return this.insertAt(b,this.items?this.items.length:0)},_getItemByParam:function(b){if(null!=b&&void 0==b.index){var c=this.getItemByValue(b);c&&(b=c)}return b}
2250,insertItem:function(b,c){b=this._getItemByParam(b);return this.insertAt(b,c)},updateItem:function(b,c){return(c=this._getItemByParam(c))&&void 0!=c.index?this.updateAt(b,c.index):!1},updateAt:function(b,c){null!=b&&(b=this._mapItem(b),this.itemsByValue[a.trim(b.value).split(" ").join("?")]=this.items[c],
2251this.items[c].value=b.value,this.items[c].label=b.label,this.items[c].html=b.html,this.items[c].disabled=b.disabled,this._raiseEvent("9",{item:this.items[c]}));this._cachedItemHtml=[];this._renderItems();this.rendered&&this.rendered()},insertAt:function(b,c){if(null==b)return!1;this._cachedItemHtml=[];if(void 0==this.items||0==this.items.length){this.source=[];this.refresh();b=this._mapItem(b);b.index=0;this.items[this.items.length]=b;this._addItems(!0);this._renderItems();this.rendered&&this.rendered();
2252this.allowDrag&&this._enableDragDrop&&this._enableDragDrop();var d=b.value;if(""==b.value||null==b.value)d=c;this.itemsByValue[a.trim(d).split(" ").join("?")]=b;return!1}b=this._mapItem(b);if(-1==c||void 0==c||null==c||c>=this.items.length)b.index=this.items.length,this.items[this.items.length]=b;else{d=[];for(var e=0,f=!1,g=0,h=0;h<this.items.length;h++)0==this.items[h].isGroup&&g>=c&&!f&&(d[e++]=b,b.index=c,g++,f=!0),d[e]=this.items[h],this.items[h].isGroup||(d[e].index=g,g++),e++;this.items=d}d=
2253b.value;if(""==b.value||null==b.value)d=c;this.itemsByValue[a.trim(d).split(" ").join("?")]=b;this.visibleItems=[];this.renderedVisibleItems=[];c=a.data(this.vScrollBar[0],"jqxScrollBar").instance;d=c.value;c.setPosition(0);this.allowDrag&&this._enableDragDrop||this.virtualSize&&this.virtualSize.height<10+this.host.height()?this._addItems(!0):this._addItems(!1);this._renderItems();this.allowDrag&&this._enableDragDrop&&this._enableDragDrop();c.setPosition(d);this._raiseEvent("7",{item:b});this.rendered&&
2254this.rendered();return!0},removeAt:function(b){if(0>b||b>this.items.length-1||void 0==b)return!1;var c=this.items[b].height,d=this.items[b].value;if(""==d||null==d)d=b;this.itemsByValue[a.trim(d).split(" ").join("?")]=null;var e=this.items[b];if(1<this.groups.length){var f=[];for(d=0;d<this.items.length;d++)this.items[d].isGroup||f.push({item:this.items[d],key:d});if(f[b])this.items.splice(f[b].key,1);else return!1}else this.items.splice(b,1);b=[];var g=f=0;for(d=0;d<this.items.length;d++)b[f]=this.items[d],
2255this.items[d].isGroup||(b[f].index=g,g++),f++;this.items=b;a.data(this.vScrollBar[0],"jqxScrollBar");d=a.data(this.vScrollBar[0],"jqxScrollBar").instance;b=d.value;d.setPosition(0);this.visibleItems=[];this.renderedVisibleItems=[];0<this.items.length?(this.virtualSize&&(this.virtualSize.height-=c,c=2*this.virtualSize.itemsPerPage,this.autoHeight&&(c=this.items.length),this.virtualItemsCount=Math.min(c,this.items.length)),this._updatescrollbars()):this._addItems();this._renderItems();this.allowDrag&&
2256this._enableDragDrop&&this._enableDragDrop();"hidden"!=this.vScrollBar.css("visibility")?d.setPosition(b):d.setPosition(0);this.itemsByValue=[];for(c=0;c<this.items.length;c++){d=this.items[c].value;if(""==this.items[c].value||null==this.items[c].value)d=c;this.itemsByValue[a.trim(d).split(" ").join("?")]=this.items[c]}this._raiseEvent("8",{item:e});0===this.items.length&&(this.selectedIndex=-1,this.selectedValue=null,this._updateInputSelection());this.rendered&&this.rendered();return!0},removeItem:function(b,
2257c){b=this._getItemByParam(b);var d=-1;if(b&&void 0!=b.index&&!0!==c){for(c=0;c<this.items.length;c++)if(this.items[c].label==b.label&&this.items[c].value==b.value){d=c;break}if(-1!=d)return this.removeAt(d)}if(-1==d)return this.removeAt(b.index)},getItems:function(){return this.items},disableItem:function(b){b=this._getItemByParam(b);this.disableAt(b.index)},enableItem:function(b){b=this._getItemByParam(b);this.enableAt(b.index)},disableAt:function(b){if(!this.items||0>b||b>this.items.length-1)return!1;
2258this.items[b].disabled=!0;this._renderItems();return!0},enableAt:function(b){if(!this.items||0>b||b>this.items.length-1)return!1;this.items[b].disabled=!1;this._renderItems();return!0},destroy:function(){this.source&&this.source.unbindBindingUpdate&&this.source.unbindBindingUpdate(this.element.i
2258d);this._removeHandlers();this.vScrollBar.jqxScrollBar("destroy");this.hScrollBar.jqxScrollBar("destroy");this.vScrollBar.remove();this.hScrollBar.remove();this.content.remove();a.jqx.utilities.resize(this.host,
2259null,!0);var b=a.data(this.element,"jqxListBox");delete this.hScrollInstance;delete this.vScrollInstance;delete this.vScrollBar;delete this.hScrollBar;delete this.content;delete this.bottomRight;delete this.itemswrapper;delete this.visualItems;delete this.visibleItems;delete this.items;delete this.groups;delete this.renderedVisibleItems;delete this._mousewheelfunc;delete this._mousemovefunc;delete this._cachedItemHtml;delete this.itemsByValue;delete this._activeElement;delete this.source;delete this.events;
2260this.input&&(this.input.remove(),delete this.input);b&&delete b.instance;this.host.removeData();this.host.removeClass();this.host.remove();this.element=null;delete this.element;this.host=null;delete this.set;delete this.get;delete this.call;delete this.host},_raiseEvent:function(b,c){if(1==this._stopEvents)return!0;void 0==c&&(c={owner:null});b=this.events[b];c.owner=this;this._updateInputSelection();b=new a.Event(b);b.owner=this;b.args=c;if(null!=this.host)var d=this.host.trigger(b);return d}})})(jqxBaseFramework);
2261(function(a){a.jqx.parseSourceTag=function(b){var c=[],d=a(b).find("option"),e=a(b).find("optgroup"),f=!1;0===d.length&&(d=a(b).find("li"),0<d.length&&(f=!0));if(0===d.length){var g=[];d=a(b).find("tr");var h=a(b).find("th"),k=0;0===h.length&&0<d.length&&(h=a(d[0]).find("td"),k=1);var l=[],m=[];g=[];for(b=0;b<d.length;b++){var n=d[b],r={};b===k+1&&(m=[]);for(var t=0;t<h.length;t++){var u=a.trim(a(h[t]).text()),x=a(n).find("td:eq("+t+")");r[u]=a.trim(x.text());b===k&&(l.push({text:u,dataField:u}),
2262m.push({name:u}));if(b===k+1){x=typeof r[u];var B="";"string"===x&&("true"===r[u]||"false"===r[u]?x="bool":isNaN(parseFloat(r[u]))||-1!==r[u].indexOf("-")||-1!==r[u].indexOf("/")?0<=r[u].indexOf("$")||0<=r[u].indexOf("%")?(x="number",0<=r[u].indexOf("$")&&(B="c"),0<=r[u].indexOf("%")&&(B="p"),r[u]=r[u].replace("%","").replace("$","")):"Invalid Date"!==(new Date(r[u])).toString()&&(x="date",B="d"):(x="number",B=0<=r[u].indexOf(".")?"f":"n"));l[t].cellsformat=B;"number"===x&&(l[t].cellsalign="right",
2263l[t].align="right");m.push({name:u,type:x})}}1<=b&&(g[g.length]=r)}return{source:new a.jqx.dataAdapter({localdata:g,datatype:"array",datafields:m}),columns:l}}var y=null;y=-1;var A=[];a.each(d,function(ha){var z=0<e.find(this).length;null==this.text||null!=this.label&&""!=this.label||(this.label=this.text);!0===f&&(this.label=a(this).text().trim(),this.checked=this.selected=a(this).attr("data-selected"),this.value=a(this).attr("data-value")||ha,this.disabled=a(this).attr("disabled"));var V={style:this.style.cssText,
2264selected:this.selected,html:this.innerHTML.trim(),classes:this.className,disabled:this.disabled,value:this.value,label:this.label,title:this.title,originalItem:this};a.jqx.browser.msie&&8>a.jqx.browser.version&&!f&&""==V.value&&null!=this.text&&0<this.text.length&&(V.value=this.text);z&&(z=e.find(this).parent()[0].label,V.group=z,A[z]||(A[z]=[],A.length++),A[z].push(V));this.selected&&(y=ha);V.checked=this.selected;void 0!==V.label&&c.push(V)});if(0<A.length){var aa=[];for(g in A)if("indexOf"!==g){for(b=
22650;b<e.length&&g!==e[b].label&&!e[b].text;b++);a.each(A[g],function(ha,z){void 0!==this.label&&aa.push(this)})}}return aa&&0<aa.length?{items:aa,index:y}:{items:c,index:y}};a.jqx._jqxListBox.item=function(){return{group:"",groupHtml:"",selected:!1,isGroup:!1,highlighted:!1,value:null,label:"",html:null,visible:!0,disabled:!1,element:null,width:null,height:null,initialTop:null,top:null,left:null,title:"",index:-1,checkBoxElement:null,originalItem:null,checked:!1,visibleIndex:-1}}})(jqxBaseFramework);
2266(function(a){a.jqx.jqxWidget("jqxDropDownList","",{});a.extend(a.jqx._jqxDropDownList.prototype,{defineInstance:function(){var b={disabled:!1,width:null,height:null,items:[],selectedIndex:-1,source:null,scrollBarSize:15,arrowSize:17,enableHover:!0,enableSelection:!0,autoItemsHeight:!1,visualItems:[],groups:[],equalItemsWidth:!0,itemHeight:-1,visibleItems:[],emptyGroupText:"Group",checkboxes:!1,openDelay:250,closeDelay:300,dropDownContainer:"default",animationType:"default",autoOpen:!1,dropDownWidth:"auto",
2267dropDownHeight:"200px",autoDropDownHeight:!1,keyboardSelection:!0,enableBrowserBoundsDetection:!1,dropDown
2267HorizontalAlignment:"left",dropDownVerticalAlignment:"bottom",displayMember:"",valueMember:"",groupMember:"",searchMember:"",searchMode:"startswithignorecase",incrementalSearch:!0,incrementalSearchDelay:700,renderer:null,placeHolder:"",promptText:"Please Choose:",emptyString:"",rtl:!1,selectionRenderer:null,listBox:null,popupZIndex:3001,renderMode:"default",touchMode:"auto",_checkForHiddenParent:!0,
2268autoBind:!0,ready:null,focusable:!0,filterable:!1,filterHeight:27,filterPlaceHolder:"Looking for",filterDelay:100,hint:!0,template:"default",aria:{"aria-disabled":{name:"disabled",type:"boolean"}},events:"open close select unselect change checkChange bindingComplete itemAdd itemRemove itemUpdate".split(" ")};if(this===a.jqx._jqxDropDownList.prototype)return b;a.extend(!0,this,b);return b},createInstance:function(b){if(this.isMaterialized()){var c=window.getComputedStyle(this.element);b=c.getPropertyValue("--jqx-dropdown-animation");
2269c=c.getPropertyValue("--jqx-list-item-height");b&&"default"==this.animationType&&(this.animationType=b.trim());c&&-1===this.itemHeight&&(this.itemHeight=parseInt(c))}this.render()},render:function(){var b=this;b.width||(b.width=200);b.height||(b.height=25);b.host.addClass(b.toThemeProperty("jqx-dropdownlist"));var c=b.element.nodeName.toLowerCase();if("select"==c||"ul"==c||"ol"==c){b.field=b.element;b.field.className&&(b._className=b.field.className);c={title:b.field.title};c.id=b.field.id.length?
2270b.field.id.replace(/[^\w]/g,"_")+"_jqxDropDownList":a.jqx.utilities.createId()+"_jqxDropDownList";var d=a("<div></div>",c);b.width||(b.width=a(b.field).width());b.height||(b.height=a(b.field).outerHeight());d[0].style.cssText=b.field.style.cssText;a(b.field).hide().after(d);var e=b.host.data();b.host=d;b.host.data(e);b.element=d[0];b.element.id=b.field.id;b.field.id=c.id;b._className&&(b.host.addClass(b._className),a(b.field).removeClass(b._className));b.field.tabIndex&&(c=b.field.tabIndex,b.field.tabIndex=
2271-1,b.element.tabIndex=c);c=a.jqx.parseSourceTag(b.field);b.source=c.items;-1==b.selectedIndex&&(b.selectedIndex=c.index)}else if(0<b.host.find("li").length||0<b.host.find("option").length)c=a.jqx.parseSourceTag(b.element),b.source=c.items;b.element.innerHTML="";b.isanimating=!1;b.id=b.element.id||a.jqx.utilities.createId();b.host.attr("role","combobox");a.jqx.aria(b,"aria-autocomplete","both");a.jqx.aria(b,"aria-readonly",!1);if(null==a.jqx._jqxListBox||void 0==a.jqx._jqxListBox)throw Error("jqxDropDownList: Missing reference to jqxlistbox.js.");
2272b.host.attr("tabindex")||b.host.attr("tabindex",0);b.touch=a.jqx.mobile.isTouchDevice();b.comboStructure="<div style='background-color: transparent; -webkit-appearance: none; outline: none; width:100%; height: 100%; padding: 0px; margin: 0px; border: 0px; position: relative;'><div id='dropdownlistWrapper' style='overflow: hidden; outline: none; background-color: transparent; border: none; float: left; width:100%; height: 100%; position: relative;'><div id='dropdownlistContent' unselectable='on' style='outline: none; background-color: transparent; border: none; float: left; position: relative;'></div><div id='dropdownlistArrow' unselectable='on' style='background-color: transparent; border: none; float: right; position: relative;'><div unselectable='on'></div></div></div></div>";
2273b.element.innerHTML="<div style='background-color: transparent; -webkit-appearance: none; outline: none; width:100%; height: 100%; padding: 0px; margin: 0px; border: 0px; position: relative;'><div id='dropdownlistWrapper' style='overflow: hidden; outline: none; background-color: transparent; border: none; float: left; width:100%; height: 100%; position: relative;'><div id='dropdownlistContent' unselectable='on' style='outline: none; background-color: transparent; border: none; float: left; position: relative;'></div><div id='dropdownlistArrow' unselectable='on' style='background-color: transparent; border: none; float: right; position: relative;'><div unselectable='on'></div></div></div></div>";
2274b.dropdownlistWrapper=a(b.element.firstChild.firstChild);b.dropdownlistArrow=a(b.dropdownlistWrapper[0].firstChild.nextSibling);b.arrow=a(b.dropdownlistArrow[0].firstChild);b.dropdownlistContent=a(b.dropdownlistWrapper[0].firstChild);b.dropdownlistContent.addClass(b.toThemeProperty("jqx-dropdownlist-content jqx-disableselect"));b.rtl&&b.dropdownlistContent.addClass(b.toThemeProperty("jqx-rtl jqx-dropdownlist-content-rtl"));b.addHandler(b.dropdownlistWrapper,"selectstart",function(){return!1});b.dropdownlistWrapper[0].id=
2275"dropdownlistWrapper"+b.element.id;b.dropdownlistArrow[0].id="dropdownlistArrow"+b.element.id;b.dropdownlistContent[0].id="dropdownlistContent"+b.element.id;b._addInput();c=a("<label></label");this.hint&&(c[0].innerHTML=this.placeHolder);c.addClass(b.toThemeProperty("jqx-input-label"));b.dropdownlistWrapper.append(c);b.label=c;c=a("<span></span>");b.dropdownlistWrapper.append(c);c.addClass(b.toThemeProperty("jqx-input-bar"));b.bar=c;b.bar.css("top",this.host.height());this.template&&(this.bar.addClass(this.toThemeProperty("jqx-"+
2276this.template)),this.label.addClass(this.toThemeProperty("jqx-"+this.template)));"Please Choose:"!=b.promptText&&(b.placeHolder=b.promptText);c=b.toThemeProperty("jqx-widget")+" "+b.toThemeProperty("jqx-dropdownlist-state-normal")+" "+b.toThemeProperty("jqx-rc-all")+" "+b.toThemeProperty("jqx-fill-state-normal");b.element.className+=" "+c;b._firstDiv=a(b.element.firstChild);try{var f="listBox"+b.id,g=a(a.find("#"+f));0<g.length&&g.remove();a.jqx.aria(b,"aria-owns",f);a.jqx.aria(b,"aria-haspopup",
2277!0);var h=a("<div style='overflow: hidden; background-color: transparent; border: none; position: absolute;' id='listBox"+b.id+"'><div id='innerListBox"+b.id+"'></div></div>");h.hide();h.addClass(b.toThemeProperty("jqx-listbox-container"));"element"==b.dropDownContainer?h.appendTo(b.host):h.appendTo(document.body);b.container=h;b.listBoxContainer=a(a.find("#innerListBox"+b.id));var k=b.width;"auto"!=b.dropDownWidth&&(k=b.dropDownWidth);null==k&&(k=b.host.width(),0==k&&(k=b.dropDownWidth));null==b.dropDownHeight&&
2278(b.dropDownHeight=200);b.container.width(parseInt(k)+25);b.container.height(parseInt(b.dropDownHeight)+25);b._ready=!1;b.addHandler(b.listBoxContainer,"bindingComplete",function(l){b.listBox||(b.listBox=a.data(b.listBoxContainer[0],"jqxListBox").instance);b.selectedIndex!=b.listBoxContainer.jqxListBox("selectedIndex")&&(b.listBox=a.data(b.listBoxContainer[0],"jqxListBox").instance,b.listBoxContainer.jqxListBox({selectedIndex:b.selectedIndex}));b.renderSelection("mouse");b._ready||(b.ready&&b.ready(),
2279b._ready=!0);b._raiseEvent("6")});b.addHandler(b.listBoxContainer,"itemAdd",function(l){b._raiseEvent("7",l.args)});b.addHandler(b.listBoxContainer,"itemRemove",function(l){b._raiseEvent("8",l.args)});b.addHandler(b.listBoxContainer,"itemUpdate",function(l){b._raiseEvent("9",l.args)});b.listBoxContainer.jqxListBox({filterHeight:b.filterHeight,filterPlaceHolder:b.filterPlaceHolder,filterDelay:b.filterDelay,autoItemsHeight:b.autoItemsHeight,filterable:b.filterable,allowDrop:!1,allowDrag:!1,autoBind:b.autoBind,
2280_checkForHiddenParent:!1,focusable:b.focusable,touchMode:b.touchMode,checkboxes:b.checkboxes,rtl:b.rtl,_renderOnDemand:!0,emptyString:b.emptyString,itemHeight:b.itemHeight,width:k,searchMode:b.searchMode,incrementalSearch:b.incrementalSearch,incrementalSearchDelay:b.incrementalSearchDelay,groupMember:b.groupMember,searchMember:b.searchMember,displayMember:b.displayMember,valueMember:b.valueMember,height:b.dropDownHeight,autoHeight:b.autoDropDownHeight,scrollBarSize:b.scrollBarSize,selectedIndex:b.selectedIndex,
2281source:b.source,theme:b.theme,rendered:function(){b.selectedIndex!=b.listBoxContainer.jqxListBox("selectedIndex")&&(b.listBox=a.data(b.listBoxContainer[0],"jqxListBox").instance,b.listBoxContainer.jqxListBox({selectedIndex:b.selectedIndex}));b.renderSelection("mouse")},renderer:b.renderer,filterChange:function(l){b.autoDropDownHeight&&b.container.height(b.listBoxContainer.height()+25)}});"element"===b.dropDownContainer?b.listBoxContainer.css({position:"absolute",top:0,left:0}):b.listBoxContainer.css({position:"absolute",
2282zIndex:b.popupZIndex,top:0,left:0});b.template&&b.listBoxContainer.addClass(b.toThemeProperty("jqx-"+b.template+"-item"));b.listBox=a.data(b.listBoxContainer[0],"jqxListBox").instance;b.listBox.enableSelection=b.enableSelection;b.listBox.enableHover=b.enableHover;b.listBox.equalItemsWidth=b.equalItemsWidth;b.listBox.selectIndex(b.selectedIndex);b.listBox._arrange();b.listBoxContainer.addClass(b.toThemeProperty("jqx-popup"));a.jqx.browser.msie&&b.listBoxContainer.addClass(b.toThemeProperty("jqx-noshadow"));
2283b.addHandler(b.listBoxContainer,"unselect",function(l){b._raiseEvent("3",{index:l.args.index,type:l.args.type,item:l.args.item})});b.addHandler(b.listBoxContainer,"change",function(l){l.args&&("keyboard"!=l.args.type?b._raiseEvent("4",{index:l.args.index,type:l.args.type,item:l.args.item}):"keyboard"==l.args.type&&(b.isOpened()||b._raiseEvent("4",{index:b.selectedIndex,type:"keyboard",item:b.getItem(b.selectedIndex)})))});"none"==b.animationType?b.container.css("display","none"):b.container.hide()}catch(l){console&&
2284console.log(l)}b.propertyChangeMap.disabled=function(l,m,n,r){r?(l.host.addClass(b.toThemeProperty("jqx-dropdownlist-state-disabled")),l.host.addClass(b.toThemeProperty("jqx-fill-state-disabled")),l.dropdownlistContent.addClass(b.toThemeProperty("jqx-dropdownlist-content-disabled"))):(l.host.removeClass(b.toThemeProperty("jqx-dropdownlist-state-disabled")),l.host.removeClass(b.toThemeProperty("jqx-fill-state-disabled")),l.dropdownlistContent.removeClass(b.toThemeProperty("jqx-dropdownlist-content-disabled")));
2285a.jqx.aria(l,"aria-disabled",l.disabled)};b.disabled&&(b.host.addClass(b.toThemeProperty("jqx-dropdownlist-state-disabled")),b.host.addClass(b.toThemeProperty("jqx-fill-state-disabled")),b.dropdownlistContent.addClass(b.toThemeProperty("jqx-dropdownlist-content-disabled")));"top"==b.dropDownVerticalAlignment?b.arrow.addClass(b.toThemeProperty("jqx-icon-arrow-up")):b.arrow.addClass(b.toThemeProperty("jqx-icon-arrow-down"));b.arrow.addClass(b.toThemeProperty("jqx-icon"));"simple"===b.renderMode&&(b.arrow.remove(),
2286b.host.removeClass(b.toThemeProperty("jqx-fill-state-normal")),b.host.removeClass(b.toThemeProperty("jqx-rc-all")));b.template&&b.host.addClass(b.toThemeProperty("jqx-"+b.template));b._updateHandlers();b._setSize();b._arrange();b.listBox&&b.renderSelection();a.jqx.browser.msie&&8>a.jqx.browser.version&&0<b.host.parents(".jqx-window").length&&(f=b.host.parents(".jqx-window").css("z-index"),h.css("z-index",f+10),b.listBoxContainer.css("z-index",f+10))},resize:function(b,c){this.width=b;this.height=
2287c;this._setSize();this._arrange()},val:function(b){if(!this.dropdownlistContent)return"";var c;if(c=this.input){a:{for(var d in b)if(b.hasOwnProperty(d)){c=!1;break a}c="number"==typeof b||"date"==typeof b||"boolean"==typeof b||"string"==typeof b?!1:!0}c=c||0==arguments.length}if(c)return this.input.val();c=this.getItemByValue(b);null!=c&&this.selectItem(c);if(this.input)return this.input.val()},focus:function(){try{var b=this,c=function(){b.host&&(b.host.focus(),b._firstDiv&&b._firstDiv.focus())};
2288c();setTimeout(function(){c()},10)}catch(d){}},_addInput:function(){var b=this.host.attr("name");this.input=a("<input type='hidden'/>");this.host.append(this.input);b&&this.input.attr("name",b)},getItems:function(){return this.listBox?this.listBox.items:[]},getVisibleItems:function(){return this.listBox.getVisibleItems()},_setSize:function(){var b=window.getComputedStyle(this.element),c=2*p
2288arseInt(b.borderLeftWidth);b=b.boxSizing;0===this.element.offsetWidth&&(c=2);if("border-box"===b||isNaN(c))c=
22890;null!=this.width&&-1!=this.width.toString().indexOf("px")?this.element.style.width=parseInt(this.width)-c+"px":void 0==this.width||isNaN(this.width)||(this.element.style.width=parseInt(this.width)-c+"px");null!=this.height&&-1!=this.height.toString().indexOf("px")?this.element.style.height=parseInt(this.height)-c+"px":void 0==this.height||isNaN(this.height)||(this.element.style.height=parseInt(this.height)-c+"px");b=!1;null!=this.width&&-1!=this.width.toString().indexOf("%")&&(b=!0,this.element.style.width=
2290this.width,0<c&&(this.host.css("box-sizing","border-box"),this.listBoxContainer.css("box-sizing","border-box")));null!=this.height&&-1!=this.height.toString().indexOf("%")&&(b=!0,this.element.style.height=this.height);var d=this;b&&(c=this.host.width()+2,"auto"!=this.dropDownWidth&&(c=this.dropDownWidth),this.listBoxContainer.jqxListBox({width:c}),this.container.width(parseInt(c)+25));a.jqx.utilities.resize(this.host,function(){d._arrange();if("auto"==d.dropDownWidth){var e=d.host.width()+2;d.listBoxContainer.jqxListBox({width:e});
2291d.container.width(parseInt(e)+25)}},!1,this._checkForHiddenParent)},isOpened:function(){var b=a.data(document.body,"openedJQXListBox"+this.id);return null!=b&&b==this.listBoxContainer?!0:!1},_updateHandlers:function(){var b=this;this.removeHandlers();this.touch||(this.addHandler(this.host,"mouseenter",function(){!b.disabled&&b.enableHover&&"simple"!==b.renderMode&&(b.host.addClass(b.toThemeProperty("jqx-dropdownlist-state-hover")),"top"==b.dropDownVerticalAlignment?b.arrow.addClass(b.toThemeProperty("jqx-icon-arrow-up-hover")):
2292b.arrow.addClass(b.toThemeProperty("jqx-icon-arrow-down-hover")),b.host.addClass(b.toThemeProperty("jqx-fill-state-hover")))}),this.addHandler(this.host,"mouseleave",function(){!b.disabled&&b.enableHover&&"simple"!==b.renderMode&&(b.host.removeClass(b.toThemeProperty("jqx-dropdownlist-state-hover")),b.host.removeClass(b.toThemeProperty("jqx-fill-state-hover")),b.arrow.removeClass(b.toThemeProperty("jqx-icon-arrow-down-hover")),b.arrow.removeClass(b.toThemeProperty("jqx-icon-arrow-up-hover")))}));
2293this.host.parents()&&this.addHandler(this.host.parents(),"scroll.dropdownlist"+this.element.id,function(d){b.isOpened()&&b.close()});var c="mousedown";this.touch&&(c=a.jqx.mobile.getTouchEventName("touchstart"));this.addHandler(this.dropdownlistWrapper,c,function(d){if(!b.disabled){var e="block"==b.container.css("display");if(!b.isanimating){if(e)return b.hideListBox(),!1;b.showListBox();b.focusable?b.focus():d.preventDefault&&d.preventDefault()}}});b.autoOpen&&(this.addHandler(this.host,"mouseenter",
2294function(){!b.isOpened()&&b.autoOpen&&(b.open(),b.host.focus())}),a(document).on("mousemove."+b.id,function(d){if(b.isOpened()&&b.autoOpen){var e=b.host.coord(),f=e.top;e=e.left;var g=b.container.coord(),h=g.left;g=g.top;var k=!0;d.pageY>=f&&d.pageY<=f+b.host.height()&&d.pageX>=e&&d.pageX<e+b.host.width()&&(k=!1);d.pageY>=g&&d.pageY<=g+b.container.height()&&d.pageX>=h&&d.pageX<h+b.container.width()&&(k=!1);k&&b.close()}}));this.touch?this.addHandler(a(document),a.jqx.mobile.getTouchEventName("touchstart")+
2295"."+this.id,b.closeOpenedListBox,{me:this,listbox:this.listBox,id:this.id}):this.addHandler(a(document),"mousedown."+this.id,b.closeOpenedListBox,{me:this,listbox:this.listBox,id:this.id});this.addHandler(this.host,"keydown",function(d){var e="block"==b.container.css("display");if("none"==b.host.css("display"))return!0;if(("13"==d.keyCode||"9"==d.keyCode)&&!b.isanimating)return e&&(b.renderSelection(),"13"==d.keyCode&&b.focusable&&b._firstDiv.focus(),b.hideListBox(),b.keyboardSelection||b._raiseEvent("2",
2296{index:b.selectedIndex,type:"keyboard",item:b.getItem(b.selectedIndex)}),"13"==d.keyCode&&b._raiseEvent("4",{index:b.selectedIndex,type:"keyboard",item:b.getItem(b.selectedIndex)})),e&&"9"!=d.keyCode?!1:!0;if(115==d.keyCode)return b.isanimating||(b.isOpened()?b.isOpened()&&b.hideListBox():b.showListBox()),!1;if(d.altKey&&"block"==b.host.css("display"))if(38==d.keyCode){if(b.isOpened())return b.hideListBox(),!0}else if(40==d.keyCode&&!b.isOpened())return b.showListBox(),!0;if("27"==d.keyCode&&!b.ishiding)return b.isOpened()&&
2297(b.hideListBox(),void 0!=b.tempSelectedIndex&&b.selectIndex(b.tempSelectedIndex)),!0;if(!b.disabled)return b._kbnavigated=b.listBox._handleKeyDown(d),b._kbnavigated});this.addHandler(this.listBoxContainer,"checkChange",function(d){b.renderSelection();b._updateInputSelection();b._raiseEvent(5,{label:d.args.label,value:d.args.value,checked:d.args.checked,item:d.args.item})});this.addHandler(this.listBoxContainer,"select",function(d){!b.disabled&&d.args&&("keyboard"!=d.args.type||b.isOpened()||b.renderSelection(),
2298"keyboard"!=d.args.type||b.keyboardSelection)&&(b.renderSelection(),b._raiseEvent("2",{index:d.args.index,type:d.args.type,item:d.args.item,originalEvent:d.args.originalEvent}),"mouse"!=d.args.type||b.checkboxes||(b.hideListBox(),b._firstDiv&&b.focusable&&b._firstDiv.focus()))});this.listBox&&this.listBox.content&&this.addHandler(this.listBox.content,"click",function(d){if(!b.disabled){if(b.listBox.itemswrapper&&d.target===b.listBox.itemswrapper[0])return!0;b.renderSelection("mouse");b.touch||b.ishiding||
2299b.checkboxes||(b.hideListBox(),b._firstDiv&&b.focusable&&b._firstDiv.focus());b.keyboardSelection||(!1===b._kbnavigated&&(b.tempSelectedIndex!=b.selectedIndex&&b._raiseEvent("4",{index:b.selectedIndex,type:"mouse",item:b.getItem(b.selectedIndex)}),b._kbnavigated=!0),void 0==b._oldSelectedInd&&(b._oldSelectedIndx=b.selectedIndex),b.selectedIndex!=b._oldSelectedIndx&&(b._raiseEvent("2",{index:b.selectedIndex,type:"keyboard",item:b.getItem(b.selectedIndex)}),b._oldSelectedIndx=b.selectedIndex))}});this.addHandler(this.host,
2300"focus",function(d){"simple"!==b.renderMode&&(b.host.addClass(b.toThemeProperty("jqx-dropdownlist-state-focus")),b.host.addClass(b.toThemeProperty("jqx-fill-state-focus")));b.bar.addClass("focused");b.label.addClass("focused")});this.addHandler(this.host,"blur",function(){"simple"!==b.renderMode&&(b.host.removeClass(b.toThemeProperty("jqx-dropdownlist-state-focus")),b.host.removeClass(b.toThemeProperty("jqx-fill-state-focus")));b.bar.removeClass("focused");b.label.removeClass("focused")});this.addHandler(this._firstDiv,
2301"focus",function(d){"simple"!==b.renderMode&&(b.host.addClass(b.toThemeProperty("jqx-dropdownlist-state-focus")),b.host.addClass(b.toThemeProperty("jqx-fill-state-focus")));b.bar.addClass("focused");b.label.addClass("focused")});this.addHandler(this._firstDiv,"blur",function(){"simple"!==b.renderMode&&(b.host.removeClass(b.toThemeProperty("jqx-dropdownlist-state-focus")),b.host.removeClass(b.toThemeProperty("jqx-fill-state-focus")));b.bar.removeClass("focused");b.label.removeClass("focused")})},removeHandlers:function(){var b=
2302"mousedown";this.touch&&(b=a.jqx.mobile.getTouchEventName("touchstart"));this.removeHandler(this.dropdownlistWrapper,b);this.listBox&&this.listBox.content&&this.removeHandler(this.listBox.content,"click");this.removeHandler(this.host,"loadContent");this.removeHandler(this.listBoxContainer,"checkChange");this.removeHandler(this.host,"keydown");this.removeHandler(this.host,"focus");this.removeHandler(this.host,"blur");this.removeHandler(this._firstDiv,"focus");this.removeHandler(this._firstDiv,"blur");
2303this.removeHandler(this.host,"mouseenter");this.removeHandler(this.host,"mouseleave");this.removeHandler(a(document),"mousemove."+this.id)},getItem:function(b){return this.listBox.getItem(b)},getItemByValue:function(b){return this.listBox.getItemByValue(b)},selectItem:function(b){void 0!=this.listBox&&(this.listBox.selectItem(b),this.selectedIndex=this.listBox.selectedIndex,this.renderSelection("mouse"))},unselectItem:function(b){void 0!=this.listBox&&(this.listBox.unselectItem(b),this.renderSelection("mouse"))},
2304checkItem:function(b){void 0!=this.listBox&&this.listBox.checkItem(b)},uncheckItem:function(b){void 0!=this.listBox&&this.listBox.uncheckItem(b)},indeterminateItem:function(b){void 0!=this.listBox&&this.listBox.indeterminateItem(b)},renderSelection:function(){if(null!=this.listBox){this.height&&-1!=this.height.toString().indexOf("%")&&this._arrange();var b=this.listBox.visibleItems[this.listBox.selectedIndex];if(this.filterable&&-1==this.listBox.selectedIndex)for(var c in this.listBox.selectedValues){var d=
2305this.listBox.getItemByValue(this.listBox.selectedValues[c]);d&&(b=d)}this.checkboxes&&(c=this.getCheckedItems(),b=null!=c&&0<c.length?c[0]:null);this.hint&&(this.label&&(this.label[0].innerHTML=this.placeHolder),null!=b?this.element.setAttribute("hint",!0):this.element.removeAttribute("hint"));this.bar.css("top",this.host.height());if(null==b){c=a('<span unselectable="on" style="color: inherit; border: none; background-color: transparent;"></span>');c.appendTo(a(document.body));c.addClass(this.toThemeProperty("jqx-widget"));
2306c.addClass(this.toThemeProperty("jqx-listitem-state-normal"));c.addClass(this.toThemeProperty("jqx-item"));a.jqx.utilities.html(c,this.placeHolder);this.isMaterialized()&&!this.element.getAttribute("default-placeholder")&&this.hint&&(c[0].innerHTML="",this.label&&(this.label[0].innerHTML=this.placeHolder));d=this.dropdownlistContent.css("padding-top");var e=this.dropdownlistContent.css("padding-bottom");c.css("padding-top",d);c.css("padding-bottom",e);d=c.outerHeight();c.remove();c.removeClass();
2307a.jqx.utilities.html(this.dropdownlistContent,c);e=this.host.height();null!=this.height&&void 0!=this.height&&-1===this.height.toString().indexOf("%")&&(e=parseInt(this.height));b=parseInt((parseInt(e)-parseInt(d))/2);"border-box"===this.host.css("box-sizing")&&(b=parseInt((parseInt(e-2)-parseInt(d))/2));0<b&&(this.dropdownlistContent.css("margin-top",b+"px"),this.dropdownlistContent.css("margin-bottom",b+"px"));this.selectionRenderer&&(a.jqx.utilities.html(this.dropdownlistContent,this.selectionRenderer(c,
2308-1,"","")),this.dropdownlistContent.css("margin-top","0px"),this.dropdownlistContent.css("margin-bottom","0px"));this._updateInputSelection();this.selectedIndex=this.listBox.selectedIndex;"auto"===this.width&&this._arrange();this.focusable&&this.isOpened()&&this.focus()}else{this.selectedIndex=this.listBox.selectedIndex;c=a(document.createElement("span"));c[0].setAttribute("unselectable","on");try{c[0].style.color="inherit"}catch(k){}c[0].style.borderWidth="0px";c[0].style.backgroundColor="transparent";
2309c.appendTo(a(document.body));c.addClass(this.toThemeProperty("jqx-widget jqx-listitem-state-normal jqx-item"));var f=!1;try{if(void 0!=b.html&&null!=b.html&&0<b.html.toString().length)a.jqx.utilities.html(c,b.html);else if(void 0!=b.label&&null!=b.label&&0<b.label.toString().length)a.jqx.utilities.html(c,b.label);else if(null===b.label||""===b.label)f=!0,a.jqx.utilities.html(c,"");else if(void 0!=b.value&&null!=b.value&&0<b.value.toString().length)a.jqx.utilities.html(c,b.value);else if(void 0!=b.title&&
2310null!=b.title&&0<b.title.toString().length)a.jqx.utilities.html(c,b.title);else if(""==b.label||null==b.label)f=!0,a.jqx.utilities.html(c,"")}catch(k){}d=this.dropdownlistContent[0].style.paddingTop;e=this.dropdownlistContent[0].style.paddingBottom;""===d&&(d="0px");""===e&&(e="0px");c[0].style.paddingTop=d;c[0].style.paddingBottom=e;d=c.outerHeight();0===d&&(d=16);""!=b.label&&null!=b.label||!f||a.jqx.utilities.html(c,"");f=this.width&&0>=this.width.toString().indexOf("%");c.remove();c.removeClass();
2311if(this.selectionRenderer)a.jqx.utilities.html(this.dropdownlistContent,this.selectionRenderer(c,b.index,b.label,b.value));else if(this.checkboxes){b=this.getCheckedItems();for(var g="",h=0;h<b.length;h++)g=h==b.length-1?g+b[h].label:g+(b[h].label+",");c.text(g);f&&c.css("max-width",this.host.width()-30);c.css("overflow","hidden");c.css("display","block");this.rtl||f&&c.css("width",this.host.width()-30);c.css("text-overflow","ellipsis");c.css("padding-bottom",1+parseInt(e));this.dropdownlistContent.html(c)}else b=
2312this.host.width()-this.arrowSize-1,this.width&&"auto"!==this.width&&(f&&(this.rtl||c.css("max-width",b+"px")),c[0].style.overflow="hidden",c[0].style.display="block",c[0].style.paddingTop=1+parseInt(e)+"px",!this.rtl&&f&&(0>b&&(b=0),c[0].style.width=b+"px"),c[0].style.textOverflow="ellipsis"),this.dropdownlistContent[0].innerHTML=c[0].innerHTML;this.focusable&&this.isOpened()&&this.focus();e=this.host.height();null!=this.height&&void 0!=this.height&&-1===this.height.toString().indexOf("%")&&(e=parseInt(this.height));
2313b=parseInt((parseInt(e)-parseInt(d))/2);"border-box"===this.host.css("box-sizing")&&(b=parseInt((parseInt(e-2)-parseInt(d))/2));0<=b&&(this.dropdownlistContent[0].style.marginTop=b+"px",this.dropdownlistContent[0].style.marginBottom=b+"px");this.selectionRenderer&&(this.dropdownlistContent[0].style.marginTop="0px",this.dropdownlistContent[0].style.marginBottom="0px");this.dropdownlistContent&&this.input&&this._updateInputSelection();this.listBox&&this.listBox._activeElement&&a.jqx.aria(this,"aria-activedescendant",
2314this.listBox._activeElement.id);"auto"===this.width&&this._arrange()}}},_updateInputSelection:function(){if(this.input){var b=[];if(-1==this.selectedIndex)this.input.val("");else{var c=this.getSelectedItem();null!=c?(this.input.val(c.value),b.push(c.value)):this.input.val(this.dropdownlistContent.text())}if(this.checkboxes){c=this.getCheckedItems();var d="";if(null!=c)for(var e=0;e<c.length;e++){var f=c[e].value;void 0!=f&&(d=e==c.length-1?d+f:d+(f+","),b.push(f))}this.input.val(d)}}this.field&&this.input&&
2315("select"==this.field.nodeName.toLowerCase()?a.each(this.field,function(g,h){a(this).removeAttr("selected");(this.selected=0<=b.indexOf(this.value))&&a(this).attr("selected",!0)}):a.each(this.items,function(g,h){a(this.originalItem.originalItem).removeAttr("data-selected");(this.selected=0<=b.indexOf(this.value))&&a(this.originalItem.originalItem).attr("data-selected",!0)}))},setContent:function(b){a.jqx.utilities.html(this.dropdownlistContent,b);this._updateInputSelection()},dataBind:function(){this.listBoxContainer.jqxListBox({source:this.source});
2316this.renderSelection("mouse");null==this.source&&this.clearSelection()},clear:function(){this.listBoxContainer.jqxListBox({source:null});this.clearSelection()},clearSelection:function(b){this.selectedIndex=-1;this._updateInputSelection();this.listBox.clearSelection();this.renderSelection();this.selectionRenderer||this.hint||this.isMaterialized()||a.jqx.utilities.html(this.dropdownlistContent,this.placeHolder)},unselectIndex:function(b,c){isNaN(b)||(this.listBox.unselectIndex(b,c),this.renderSelection())},
2317selectIndex:function(b,c,d,e){this.listBox.selectIndex(b,c,d,e,"api")},getSelectedIndex:function(){return this.selectedIndex},getSelectedItem:function(){return this.listBox.getVisibleItem(this.selectedIndex)},getCheckedItems:function(){return this.listBox.getCheckedItems()},checkIndex:function(b){this.listBox.checkIndex(b)},uncheckIndex:function(b){this.listBox.uncheckIndex(b)},indeterminateIndex:function(b){this.listBox.indeterminateIndex(b)},checkAll:function(){this.listBox.checkAll();this.renderSelection("mouse")},
2318uncheckAll:function(){this.listBox.uncheckAll();this.renderSelection("mouse")},addItem:function(b){return this.listBox.addItem(b)},insertAt:function(b,c){return null==b?!1:this.listBox.insertAt(b,c)},removeAt:function(b){b=this.listBox.removeAt(b);this.renderSelection("mouse");return b},removeItem:function(b){b=this.listBox.removeItem(b);this.renderSelection("mouse");return b}
2318,updateItem:function(b,c){b=this.listBox.updateItem(b,c);this.renderSelection("mouse");return b},updateAt:function(b,c){b=
2319this.listBox.updateAt(b,c);this.renderSelection("mouse");return b},ensureVisible:function(b){return this.listBox.ensureVisible(b)},disableAt:function(b){return this.listBox.disableAt(b)},enableAt:function(b){return this.listBox.enableAt(b)},disableItem:function(b){return this.listBox.disableItem(b)},enableItem:function(b){return this.listBox.enableItem(b)},_findPos:function(b){for(;b&&("hidden"==b.type||1!=b.nodeType||a.expr.filters.hidden(b));)b=b.nextSibling;b=a(b).coord(!0);return[b.left,b.top]},
2320testOffset:function(b,c,d){var e=b.outerWidth();b=b.outerHeight();var f=a(window).width()+a(window).scrollLeft(),g=a(window).height()+a(window).scrollTop();c.left+e>f&&e>this.host.width()&&(f=this.host.coord().left,e-=this.host.width(),c.left=f-e+2);0>c.left&&(c.left=parseInt(this.host.coord().left)+"px");c.top-=Math.min(c.top,c.top+b>g&&g>b?Math.abs(b+d+22):0);return c},open:function(){this.showListBox()},close:function(){this.hideListBox()},_getBodyOffset:function(){var b=0,c=0;"0px"!=a("body").css("border-top-width")&&
2321(b=parseInt(a("body").css("border-top-width")),isNaN(b)&&(b=0));"0px"!=a("body").css("border-left-width")&&(c=parseInt(a("body").css("border-left-width")),isNaN(c)&&(c=0));return{left:c,top:b}},showListBox:function(){a.jqx.aria(this,"aria-expanded",!0);this.listBox._renderOnDemand&&this.listBoxContainer.jqxListBox({_renderOnDemand:!1});if("auto"==this.dropDownWidth&&null!=this.width&&this.width.indexOf&&(-1!=this.width.indexOf("%")||-1!=this.width.indexOf("auto"))&&this.listBox.host.width()!=this.host.width()){var b=
2322this.element.offsetWidth;this.listBoxContainer.jqxListBox({width:b});this.container.width(parseInt(b)+25)}"auto"==this.dropDownWidth&&"0px"===this.host.css("border-left-width")&&(b=this.element.offsetWidth,this.listBoxContainer.jqxListBox({width:b+1}),this.container.width(parseInt(b)+25));var c=this,d=this.listBoxContainer,e=this.listBox;a(window).scrollTop();a(window).scrollLeft();var f=parseInt(this._findPos(this.host[0])[1])+parseInt(this.host.outerHeight())-1+"px",g=parseInt(Math.round(this.host.coord(!0).left));
2323b=g+"px";"element"===this.dropDownContainer&&(f=parseInt(this.host.outerHeight())-1+"px",b=0);if(null!=this.listBox){this.ishiding=!1;this.keyboardSelection||(this.listBox.selectIndex(this.selectedIndex),this.listBox.ensureVisible(this.selectedIndex));this.tempSelectedIndex=this.selectedIndex;this.autoDropDownHeight&&this.container.height(this.listBoxContainer.height()+25);d.stop();"simple"!==this.renderMode&&(this.host.addClass(this.toThemeProperty("jqx-dropdownlist-state-selected")),this.host.addClass(this.toThemeProperty("jqx-fill-state-pressed")),
2324"top"==this.dropDownVerticalAlignment?this.arrow.addClass(this.toThemeProperty("jqx-icon-arrow-up-selected")):this.arrow.addClass(this.toThemeProperty("jqx-icon-arrow-down-selected")));this.container.css("left",b);this.container.css("top",f);e._arrange();b=!1;if("right"==this.dropDownHorizontalAlignment||this.rtl){var h=this.container.outerWidth(),k=-2+Math.abs(h-this.host.width());h>this.host.width()?this.container.css("left",25+parseInt(Math.round(g))-k+"px"):this.container.css("left",25+parseInt(Math.round(g))+
2325k+"px")}"top"==this.dropDownVerticalAlignment&&(g=d.height(),b=!0,d.css("top",23),d.addClass(this.toThemeProperty("jqx-popup-up")),h=parseInt(this.host.outerHeight()),g=parseInt(f)-Math.abs(g+h+23),this.container.css("top",g));this.enableBrowserBoundsDetection&&(f=this.testOffset(d,{left:parseInt(this.container.css("left")),top:parseInt(f)},parseInt(this.host.outerHeight())),parseInt(this.container.css("top"))!=f.top?(b=!0,d.css("top",23),d.addClass(this.toThemeProperty("jqx-popup-up"))):d.css("top",
23260),this.container.css("top",f.top),parseInt(this.container.css("left"))!=f.left&&this.container.css("left",f.left));"none"==this.animationType||"transform"===this.animationType?(this.container.css("display","block"),a.data(document.body,"openedJQXListBoxParent",c),a.data(document.body,"openedJQXListBox"+this.id,d),d.css("margin-top",0),d.css("opacity",1),e._renderItems(),c._raiseEvent("0",e)):(this.container.css("display","block"),c.isanimating=!0,"fade"==this.animationType?(d.css("margin-top",0),
2327d.css("opacity",0),d.animate({opacity:1},this.openDelay,function(){a.data(document.body,"openedJQXListBoxParent",c);a.data(document.body,"openedJQXListBox"+c.id,d);c.ishiding=!1;c.isanimating=!1;e._renderItems();c._raiseEvent("0",e)})):(d.css("opacity",1),f=d.outerHeight(),b?d.css("margin-top",f):d.css("margin-top",-f),d.animate({"margin-top":0},this.openDelay,function(){a.data(document.body,"openedJQXListBoxParent",c);a.data(document.body,"openedJQXListBox"+c.id,d);c.ishiding=!1;c.isanimating=!1;
2328e._renderItems();c._raiseEvent("0",e)})));b?(this.host.addClass(this.toThemeProperty("jqx-rc-t-expanded")),d.addClass(this.toThemeProperty("jqx-rc-b-expanded"))):(this.host.addClass(this.toThemeProperty("jqx-rc-b-expanded")),d.addClass(this.toThemeProperty("jqx-rc-t-expanded")));"simple"!==this.renderMode&&(d.addClass(this.toThemeProperty("jqx-fill-state-focus")),this.host.addClass(this.toThemeProperty("jqx-dropdownlist-state-focus")),this.host.addClass(this.toThemeProperty("jqx-fill-state-focus")));
2329this.element.setAttribute("opened",!0);d.addClass(this.toThemeProperty("jqx-popup-show"))}},hideListBox:function(){a.jqx.aria(this,"aria-expanded",!1);var b=this.listBoxContainer,c=this.listBox,d=this.container,e=this;this.element.removeAttribute("opened");b.removeClass("jqx-popup-show");a.data(document.body,"openedJQXListBox"+this.id,null);if("none"==this.animationType)this.container.css("display","none");else if("transform"===this.animationType)setTimeout(function(){d.css("display","none")},this.closeDelay);
2330else if(!e.ishiding){b.stop();var f=b.outerHeight();b.css("margin-top",0);e.isanimating=!0;var g=-f;parseInt(this.container.coord().top)<parseInt(this.host.coord().top)&&(g=f);"fade"==this.animationType?(b.css({opacity:1}),b.animate({opacity:0}
2330,this.closeDelay,function(){d.css("display","none");e.isanimating=!1;e.ishiding=!1})):b.animate({"margin-top":g},this.closeDelay,function(){d.css("display","none");e.isanimating=!1;e.ishiding=!1})}this.ishiding=!0;this.host.removeClass(this.toThemeProperty("jqx-dropdownlist-state-selected"));
2331this.host.removeClass(this.toThemeProperty("jqx-fill-state-pressed"));this.arrow.removeClass(this.toThemeProperty("jqx-icon-arrow-down-selected"));this.arrow.removeClass(this.toThemeProperty("jqx-icon-arrow-up-selected"));this.host.removeClass(this.toThemeProperty("jqx-rc-b-expanded"));b.removeClass(this.toThemeProperty("jqx-rc-t-expanded"));this.host.removeClass(this.toThemeProperty("jqx-rc-t-expanded"));b.removeClass(this.toThemeProperty("jqx-rc-b-expanded"));b.removeClass(this.toThemeProperty("jqx-fill-state-focus"));
2332this.host.removeClass(this.toThemeProperty("jqx-dropdownlist-state-focus"));this.host.removeClass(this.toThemeProperty("jqx-fill-state-focus"));this._raiseEvent("1",c)},closeOpenedListBox:function(b){var c=b.data.me,d=a(b.target),e=b.data.listbox;if(null==e||a(b.target).ischildof(b.data.me.host)||!c.isOpened()||a(b.target).ischildof(c.listBoxContainer))return!0;var f=!1;a.each(d.parents(),function(){if("undefined"!=this.className&&this.className.indexOf){if(-1!=this.className.indexOf("jqx-listbox"))return f=
2333!0,!1;if(-1!=this.className.indexOf("jqx-dropdownlist"))return c.element.id==this.id&&(f=!0),!1}});null!=e&&!f&&c.isOpened()&&c.hideListBox();return!0},clearFilter:function(){this.listBox.clearFilter()},loadFromSelect:function(b){this.listBox.loadFromSelect(b)},refresh:function(b){!0!==b&&(this._setSize(),this._arrange(),this.listBox&&this.renderSelection())},_arrange:function(){var b=parseInt(this.host.width()),c=parseInt(this.host.height()),d=this.arrowSize,e=b-d-6;0<e&&"auto"!==this.width?this.dropdownlistContent[0].style.width=
2334e+"px":0>=e&&(this.dropdownlistContent[0].style.width="0px");"auto"===this.width&&(this.dropdownlistContent.css("width","auto"),b=2+this.dropdownlistContent.width()+d+6,47>b&&(b=47),this.host.width(b));this.dropdownlistContent[0].style.height=c+"px";this.dropdownlistContent[0].style.left="0px";this.dropdownlistContent[0].style.top="0px";this.dropdownlistArrow[0].style.width=d+"px";this.width&&0<=this.width.toString().indexOf("%")&&(this.dropdownlistArrow[0].style.width=100*d/b+"%",this.dropdownlistContent[0].style.width=
2335100*e/b+"%");this.dropdownlistArrow[0].style.height=c+"px";this.rtl&&(this.dropdownlistArrow.css("float","left"),this.dropdownlistContent.css("float","right"))},destroy:function(){a.jqx.utilities.resize(this.host,null,!0);this.removeHandler(this.listBoxContainer,"select");this.removeHandler(this.listBoxContainer,"unselect");this.removeHandler(this.listBoxContainer,"change");this.removeHandler(this.dropdownlistWrapper,"selectstart");this.removeHandler(this.dropdownlistWrapper,"mousedown");this.removeHandler(this.host,
2336"keydown");this.removeHandler(this.listBoxContainer,"select");this.removeHandler(this.listBox.content,"click");this.removeHandler(this.listBoxContainer,"bindingComplete");this.host.parents()&&this.removeHandler(this.host.parents(),"scroll.dropdownlist"+this.element.id);this.removeHandlers();this.listBoxContainer.jqxListBox("destroy");this.listBoxContainer.remove();this.host.removeClass();this.removeHandler(a(document),"mousedown."+this.id,this.closeOpenedListBox);this.touch&&this.removeHandler(a(document),
2337a.jqx.mobile.getTouchEventName("touchstart")+"."+this.id);this.dropdownlistArrow.remove();delete this.dropdownlistArrow;delete this.dropdownlistWrapper;delete this.listBoxContainer;delete this.input;delete this.arrow;delete this.dropdownlistContent;delete this.listBox;delete this._firstDiv;this.container.remove();delete this.container;var b=a.data(this.element,"jqxDropDownList");b&&delete b.instance;this.host.removeData();this.host.remove();delete this.comboStructure;delete this.host;delete this.element},
2338_raiseEvent:function(b,c){void 0==c&&(c={owner:null});var d=this.events[b];c.owner=this;d=new a.Event(d);d.owner=this;if(2==b||3==b||4==b||5==b||6==b||7==b||8==b||9==b)d.args=c;return this.host.trigger(d)}
2338,propertiesChangedHandler:function(b,c,d){d.width&&d.height&&2==Object.keys(d).length&&(b._setSize(),"width"==c&&"auto"==b.dropDownWidth&&(c=b.host.width(),b.listBoxContainer.jqxListBox({width:c}),b.container.width(parseInt(c)+25)),b._arrange(),b.close())},propertyChangedHandler:function(b,c,d,e){if(void 0!=
2339b.isInitialized&&0!=b.isInitialized&&!(b.batchUpdate&&b.batchUpdate.width&&b.batchUpdate.height&&2==Object.keys(b.batchUpdate).length)){"template"==c&&(b.listBoxContainer.removeClass(b.toThemeProperty("jqx-"+d+"-item")),b.listBoxContainer.addClass(b.toThemeProperty("jqx-"+b.template+"-item")),b.host.removeClass(b.toThemeProperty("jqx-"+d)),b.host.addClass(b.toThemeProperty("jqx-"+b.template)));"dropDownVerticalAlignment"==c&&(b.close(),b.arrow.removeClass(b.toThemeProperty("jqx-icon-arrow-up")),b.arrow.removeClass(b.toThemeProperty("jqx-icon-arrow-down")),
2340"top"==b.dropDownVerticalAlignment?b.arrow.addClass(b.toThemeProperty("jqx-icon-arrow-up")):b.arrow.addClass(b.toThemeProperty("jqx-icon-arrow-down")),b.listBoxContainer.css("top",0),b.listBoxContainer.removeClass(this.toThemeProperty("jqx-popup-up")));"autoItemsHeight"==c&&b.listBoxContainer.jqxListBox({autoItemsHeight:e});"filterable"==c&&b.listBoxContainer.jqxListBox({filterable:e});"filterHeight"==c&&b.listBoxContainer.jqxListBox({filterHeight:e});"filterPlaceHolder"==c&&b.listBoxContainer.jqxListBox({filterPlaceHolder:e});
2341"filterDelay"==c&&b.listBoxContainer.jqxListBox({filterDelay:e});"enableSelection"==c&&b.listBoxContainer.jqxListBox({enableSelection:e});"enableHover"==c&&b.listBoxContainer.jqxListBox({enableHover:e});"autoOpen"==c&&b._updateHandlers();"emptyString"==c&&(b.listBox.emptyString=b.emptyString);"itemHeight"==c&&b.listBoxContainer.jqxListBox({itemHeight:e});"renderer"==c&&b.listBoxContainer.jqxListBox({renderer:e});"rtl"==c&&(e?(b.dropdownlistArrow.css("float","left"),b.dropdownlistContent.css("float",
2342"right")):(b.dropdownlistArrow.css("float","right"),b.dropdownlistContent.css("float","left")),b.listBoxContainer.jqxListBox({rtl:b.rtl}));"source"==c&&(b.listBoxContainer.jqxListBox({source:b.source}),b.listBox.selectedIndex=-1,b.listBox.selectIndex(this.selectedIndex),b.renderSelection(),null==e&&b.clear());if("displayMember"==c||"valueMember"==c)b.listBoxContainer.jqxListBox({displayMember:b.displayMember,valueMember:b.valueMember}),b.renderSelection();"placeHolder"==c&&b.renderSelection();"theme"==
2343c&&null!=e&&(b.listBoxContainer.jqxListBox({theme:e}),b.listBoxContainer.addClass(b.toThemeProperty("jqx-popup")),a.jqx.utilities.setTheme(d,e,b.host));"autoDropDownHeight"==c&&(b.listBoxContainer.jqxListBox({autoHeight:b.autoDropDownHeight}),b.autoDropDownHeight?b.container.height(b.listBoxContainer.height()+25):(b.listBoxContainer.jqxListBox({height:b.dropDownHeight}),b.container.height(parseInt(b.dropDownHeight)+25)),b.listBox._arrange(),b.listBox._updatescrollbars());"searchMode"==c&&b.listBoxContainer.jqxListBox({searchMode:b.searchMode});
2344"incrementalSearch"==c&&b.listBoxContainer.jqxListBox({incrementalSearch:b.incrementalSearch});"incrementalSearchDelay"==c&&b.listBoxContainer.jqxListBox({incrementalSearchDelay:b.incrementalSearchDelay});"dropDownHeight"!=c||b.autoDropDownHeight||(b.listBoxContainer.jqxListBox({height:b.dropDownHeight}),b.container.height(parseInt(b.dropDownHeight)+25));if("dropDownWidth"==c||"scrollBarSize"==c){var f=b.width;"auto"!=b.dropDownWidth&&(f=b.dropDownWidth);b.listBoxContainer.jqxListBox({width:f,scrollBarSize:b.scrollBarSize});
2345b.container.width(parseInt(f)+25)}"width"!=c&&"height"!=c||e==d||(this.refresh(),"width"==c&&"auto"==b.dropDownWidth&&(f=2+b.host.width(),b.listBoxContainer.jqxListBox({width:f}),b.container.width(parseInt(f)+25)),b.close());"checkboxes"==c&&b.listBoxContainer.jqxListBox({checkboxes:b.checkboxes});"selectedIndex"==c&&null!=b.listBox&&(b.listBox.selectIndex(parseInt(e)),b.renderSelection())}}})})(jqxBaseFramework);
2346(function(a,b){"function"===typeof define&&define.amd?define([],b):"undefined"!==typeof exports?b():(b(),a.FileSaver={})})(this,function(){function a(h,k){"undefined"===typeof k?k={autoBom:!1}:"object"!==typeof k&&(console.warn("Deprecated: Expected third argument to be a object"),k={autoBom:!k});return k.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(h.type)?new Blob([String.fromCharCode(65279),h],{type:h.type}):h}function b(h,k,l){var m=new XMLHttpRequest;
2347m.open("GET",h);m.responseType="blob";m.onload=function(){g(m.response,k,l)};m.onerror=function(){console.error("could not download file")};m.send()}function c(h){var k=new XMLHttpRequest;k.open("HEAD",h,!1);try{k.send()}catch(l){}return 200<=k.status&&299>=k.status}function d(h){try{h.dispatchEvent(new MouseEvent("click"))}catch(l){var k=document.createEvent("MouseEvents");
2347k.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null);h.dispatchEvent(k)}}var e="object"===typeof window&&window.window===
2348window?window:"object"===typeof self&&self.self===self?self:"object"===typeof global&&global.global===global?global:void 0,f=/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),g=e.saveAs||("object"!==typeof window||window!==e?function(){}:"download"in HTMLAnchorElement.prototype&&!f?function(h,k,l){var m=e.URL||e.webkitURL,n=document.createElement("a");k=k||h.name||"download";n.download=k;n.rel="noopener";"string"===typeof h?(n.href=
2349h,n.origin!==location.origin?c(n.href)?b(h,k,l):d(n,n.target="_blank"):d(n)):(n.href=m.createObjectURL(h),setTimeout(function(){m.revokeObjectURL(n.href)},4E4),setTimeout(function(){d(n)},0))}:"msSaveOrOpenBlob"in navigator?function(h,k,l){k=k||h.name||"download";if("string"===typeof h)if(c(h))b(h,k,l);else{var m=document.createElement("a");m.href=h;m.target="_blank";setTimeout(function(){d(m)})}else navigator.msSaveOrOpenBlob(a(h,l),k)}:function(h,k,l,m){if(m=m||open("","_blank"))m.document.title=
2350m.document.body.innerText="downloading...";if("string"===typeof h)return b(h,k,l);k="application/octet-stream"===h.type;l=/constructor/i.test(e.HTMLElement)||e.safari;var n=/CriOS\/[\d]+/.test(navigator.userAgent);if((n||k&&l||f)&&"undefined"!==typeof FileReader){var r=new FileReader;r.onloadend=function(){var x=r.result;x=n?x:x.replace(/^data:[^;]*;/,"data:attachment/file;");m?m.location.href=x:location=x;m=null};r.readAsDataURL(h)}else{var t=e.URL||e.webkitURL,u=t.createObjectURL(h);m?m.location=
2351u:location.href=u;m=null;setTimeout(function(){t.revokeObjectURL(u)},4E4)}});e.saveAs=g.saveAs=g;"undefined"!==typeof module&&(module.exports=g)});"use strict";let CBStatIconField=function(a){jsGrid.Field.call(this,a)};CBStatIconField.prototype=new jsGrid.Field({css:"jsg-icon",align:"center",itemTemplate:genTemplate("statIcon")});jsGrid.fields.staticon=CBStatIconField;var CBResIconField=function(a){jsGrid.Field.call(this,a)};
2352CBResIconField.prototype=new jsGrid.Field({css:"jsg-icon",align:"center",itemTemplate:genTemplate("resIcon")});jsGrid.fields.resicon=CBResIconField;var CBFlagWField=function(a){jsGrid.Field.call(this,a)};CBFlagWField.prototype=new jsGrid.Field({css:"jsg-flag",align:"center",itemTemplate:genFlagTemplate("flgw")});jsGrid.fields.flgw=CBFlagWField;var CBFlagBField=function(a){jsGrid.Field.call(this,a)};CBFlagBField.prototype=new jsGrid.Field({css:"jsg-flag",align:"center",itemTemplate:genFlagTemplate("flgb")});
2353jsGrid.fields.flgb=CBFlagBField;function genTemplate(a){return function(b,c){return b?(b=glApp.config.getExternalCommonPath()+"Media/Ribbons/Reader/Status/"+b+"16.png",String.formatEx('<span data-{0}="'+c.id+'"><img src="'+b+'"height="16"></span>',a)):String.formatEx('<span data-{0}="'+c.id+'"></span>',a)}}
2354function genFlagTemplate(a){return function(b,c){return b?(b=new Nation(b),b=glApp.mediaPathFlags+String.f("Flags16/{0}.png",b.getStrFlag()),String.formatEx('<span data-{0}="'+c.id+'"><img src="'+b+'"height="16"></span>',a)):String.formatEx('<span data-{0}="'+c.id+'"></span>',a)}}
2355(function(a){"object"===typeof exports&&"undefined"!==typeof module?module.exports=a():"function"===typeof define&&define.amd?define([],a):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).localforage=a()})(function(){return function e(b,c,d){function f(k,l){if(!c[k]){if(!b[k]){var m="function"==typeof require&&require;if(!l&&m)return m(k,!0);if(g)return g(k,!0);l=Error("Cannot find module '"+k+"'");throw l.code="MODULE_NOT_FOUND",l;}l=c[k]=
2356{exports:{}};b[k][0].call(l.exports,function(n){var r=b[k][1][n];return f(r?r:n)},l,l.exports,e,b,c,d)}return c[k].exports}for(var g="function"==typeof require&&require,h=0;h<d.length;h++)f(d[h]);return f}({1:[function(b,c,d){(function(e){function f(){n=!0;for(var t,u,x=r.length;x;){u=r;r=[];for(t=-1;++t<x;)u[t]();x=r.length}n=!1}var g=e.MutationObserver||e.WebKitMutationObserver;if(g){var h=0;g=new g(f);var k=e.document.createTextNode("");g.observe(k,{characterData:!0}
2356);var l=function(){k.data=h=
2357++h%2}}else if(e.setImmediate||"undefined"===typeof e.MessageChannel)l="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){f();t.onreadystatechange=null;t.parentNode.removeChild(t);t=null};e.document.documentElement.appendChild(t)}:function(){setTimeout(f,0)};else{var m=new e.MessageChannel;m.port1.onmessage=f;l=function(){m.port2.postMessage(0)}}var n,r=[];c.exports=function(t){1!==r.push(t)||
2358n||l()}}).call(this,"undefined"!==typeof global?global:"undefined"!==typeof self?self:"undefined"!==typeof window?window:{})},{}],2:[function(b,c,d){function e(){}function f(B){if("function"!==typeof B)throw new TypeError("resolver must be a function");this.state=x;this.queue=[];this.outcome=void 0;B!==e&&l(this,B)}function g(B,y,A){this.promise=B;"function"===typeof y&&(this.onFulfilled=y,this.callFulfilled=this.otherCallFulfilled);"function"===typeof A&&(this.onRejected=A,this.callRejected=this.otherCallRejected)}
2359function h(B,y,A){n(function(){try{var aa=y(A)}catch(ha){return r.reject(B,ha)}aa===B?r.reject(B,new TypeError("Cannot resolve promise with itself")):r.resolve(B,aa)})}function k(B){var y=B&&B.then;if(B&&("object"===typeof B||"function"===typeof B)&&"function"===typeof y)return function(){y.apply(B,arguments)}}function l(B,y){function A(V){ha||(ha=!0,r.reject(B,V))}function aa(V){ha||(ha=!0,r.resolve(B,V))}var ha=!1,z=m(function(){y(aa,A)});"error"===z.status&&A(z.value)}function m(B,y){var A={};
2360try{A.value=B(y),A.status="success"}catch(aa){A.status="error",A.value=aa}return A}var n=b(1),r={},t=["REJECTED"],u=["FULFILLED"],x=["PENDING"];c.exports=f;f.prototype["catch"]=function(B){return this.then(null,B)};f.prototype.then=function(B,y){if("function"!==typeof B&&this.state===u||"function"!==typeof y&&this.state===t)return this;var A=new this.constructor(e);this.state!==x?h(A,this.state===u?B:y,this.outcome):this.queue.push(new g(A,B,y));return A};g.prototype.callFulfilled=function(B){r.resolve(this.promise,
2361B)};g.prototype.otherCallFulfilled=function(B){h(this.promise,this.onFulfilled,B)};g.prototype.callRejected=function(B){r.reject(this.promise,B)};g.prototype.otherCallRejected=function(B){h(this.promise,this.onRejected,B)};r.resolve=function(B,y){var A=m(k,y);if("error"===A.status)return r.reject(B,A.value);if(A=A.value)l(B,A);else{B.state=u;B.outcome=y;A=-1;for(var aa=B.queue.length;++A<aa;)B.queue[A].callFulfilled(y)}return B};r.reject=function(B,y){B.state=t;B.outcome=y;for(var A=-1,aa=B.queue.length;++A<
2362aa;)B.queue[A].callRejected(y);return B};f.resolve=function(B){return B instanceof this?B:r.resolve(new this(e),B)};f.reject=function(B){var y=new this(e);return r.reject(y,B)};f.all=function(B){function y(K,C){A.resolve(K).then(function(da){z[C]=da;++V!==aa||ha||(ha=!0,r.resolve(v,z))},function(da){ha||(ha=!0,r.reject(v,da))})}var A=this;if("[object Array]"!==Object.prototype.toString.call(B))return this.reject(new TypeError("must be an array"));var aa=B.length,ha=!1;if(!aa)return this.resolve([]);
2363for(var z=Array(aa),V=0,ba=-1,v=new this(e);++ba<aa;)y(B[ba],ba);return v};f.race=function(B){function y(ba){A.resolve(ba).then(function(v){ha||(ha=!0,r.resolve(V,v))},function(v){ha||(ha=!0,r.reject(V,v))})}var A=this;if("[object Array]"!==Object.prototype.toString.call(B))return this.reject(new TypeError("must be an array"));var aa=B.length,ha=!1;if(!aa)return this.resolve([]);for(var z=-1,V=new this(e);
2363++z<aa;)y(B[z]);return V}},{1:1}],3:[function(b,c,d){c="undefined"!==typeof global?global:"undefined"!==
2364typeof self?self:"undefined"!==typeof window?window:{};"function"!==typeof c.Promise&&(c.Promise=b(2))},{2:2}],4:[function(b,c,d){function e(la,ta){la=la||[];ta=ta||{};try{return new Blob(la,ta)}catch(E){if("TypeError"!==E.name)throw E;for(var va=new ("undefined"!==typeof BlobBuilder?BlobBuilder:"undefined"!==typeof MSBlobBuilder?MSBlobBuilder:"undefined"!==typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),p=0;p<la.length;p+=1)va.append(la[p]);return va.getBlob(ta.type)}}function f(la,ta){ta&&
2365la.then(function(va){ta(null,va)},function(va){ta(va)})}function g(la,ta,va){"function"===typeof ta&&la.then(ta);if("function"===typeof va)la["catch"](va)}function h(la){"string"!==typeof la&&(console.warn(la+" used as a key, but it is not a string."),la=String(la));return la}function k(){if(arguments.length&&"function"===typeof arguments[arguments.length-1])return arguments[arguments.length-1]}function l(la){return(new qa(function(ta){var va=la.transaction("local-forage-detect-blob-support","readwrite"),
2366p=e([""]);va.objectStore("local-forage-detect-blob-support").put(p,"key");va.onabort=function(E){E.preventDefault();E.stopPropagation();ta(!1)};va.oncomplete=function(){var E=navigator.userAgent.match(/Chrome\/(\d+)/),L=navigator.userAgent.match(/Edge\//);ta(L||!E||43<=parseInt(E[1],10))}}))["catch"](function(){return!1})}function m(la){return"boolean"===typeof Ba?qa.resolve(Ba):l(la).then(function(ta){return Ba=ta})}function n(la){la=Ua[la.name];var ta={};ta.promise=new qa(function(va,p){ta.resolve=
2367va;ta.reject=p});la.deferredOperations.push(ta);la.dbReady=la.dbReady?la.dbReady.then(function(){return ta.promise}):ta.promise}function r(la){if(la=Ua[la.name].deferredOperations.pop())return la.resolve(),la.promise}function t(la,ta){if(la=Ua[la.name].deferredOperations.pop())return la.reject(ta),la.promise}function u(la,ta){return new qa(function(va,p){Ua[la.name]=Ua[la.name]||z();if(la.db)if(ta)n(la),la.db.close();else return va(la.db);var E=[la.name];ta&&E.push(la.version);var L=na.open.apply(na,
2368E);ta&&(L.onupgradeneeded=function(ca){var fa=L.result;try{fa.createObjectStore(la.storeName),1>=ca.oldVersion&&fa.createObjectStore("local-forage-detect-blob-support")}catch(ia){if("ConstraintError"===ia.name)console.warn('The database "'+la.name+'" has been upgraded from version '+ca.oldVersion+" to version "+ca.newVersion+', but the storage "'+la.storeName+'" already exists.');else throw ia;}});L.onerror=function(ca){ca.preventDefault();p(L.error)};L.onsuccess=function(){va(L.result);r(la)}})}
2369function x(la,ta){if(!la.db)return!0;var va=!la.db.objectStoreNames.contains(la.storeName),p=la.version>la.db.version;la.version<la.db.version&&(la.version!==ta&&console.warn('The database "'+la.name+"\" can't be downgraded from version "+la.db.version+" to version "+la.version+"."),la.version=la.db.version);return p||va?(va&&(ta=la.db.version+1,ta>la.version&&(la.version=ta)),!0):!1}function B(la){return new qa(function(ta,va){var p=new FileReader;p.onerror=va;p.onloadend=function(E){E=btoa(E.target.result||
2370"");ta({__local_forage_encoded_blob:!0,data:E,type:la.type})};p.readAsBinaryString(la)})}function y(la){for(var ta=atob(la.data),va=ta.length,p=new ArrayBuffer(va),E=new Uint8Array(p),L=0;L<va;L++)E[L]=ta.charCodeAt(L);return e([p],{type:la.type})}function A(la){var ta=this,va=ta._initReady().then(function(){var p=Ua[ta._dbInfo.name];if(p&&p.dbReady)return p.dbReady});g(va,la,la);return va}function aa(la){n(la);for(var ta=Ua[la.name],va=ta.forages,p=0;p<va.length;p++){var E=va[p];E._dbInfo.db&&(E._dbInfo.db.close(),
2371E._dbInfo.db=null)}la.db=null;return u(la,!1).then(function(L){la.db=L;return x(la)?u(la,!0):L}).then(function(L){la.db=ta.db=L;for(var ca=0;ca<va.length;ca++)va[ca]._dbInfo.db=L})["catch"](function(L){t(la,L);throw L;})}function ha(la,ta,va,p){void 0===p&&(p=1);try{var E=la.db.transaction(la.storeName,ta);va(null,E)}catch(L){if(0<p&&(!la.db||"InvalidStateError"===L.name||"NotFoundError"===L.name))return qa.resolve().then(function(){if(!la.db||"NotFoundError"===L.name&&!la.db.objectStoreNames.contains(la.storeName)&&
2372la.version<=la.db.version)return la.db&&(la.version=la.db.version+1),u(la,!0)}).then(function(){return aa(la).then(function(){ha(la,ta,va,p-1)})})["catch"](va);va(L)}}function z(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function V(la){var ta=.75*la.length,va=la.length,p=0;"="===la[la.length-1]&&(ta--,"="===la[la.length-2]&&ta--);var E=new ArrayBuffer(ta),L=new Uint8Array(E);for(ta=0;ta<va;ta+=4){var ca="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
2372+/".indexOf(la[ta]);
2373var fa="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(la[ta+1]);var ia="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(la[ta+2]);var ma="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(la[ta+3]);L[p++]=ca<<2|fa>>4;L[p++]=(fa&15)<<4|ia>>2;L[p++]=(ia&3)<<6|ma&63}return E}function ba(la){la=new Uint8Array(la);var ta="",va;for(va=0;va<la.length;va+=3)ta+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[la[va]>>
23742],ta+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(la[va]&3)<<4|la[va+1]>>4],ta+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(la[va+1]&15)<<2|la[va+2]>>6],ta+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[la[va+2]&63];2===la.length%3?ta=ta.substring(0,ta.length-1)+"=":1===la.length%3&&(ta=ta.substring(0,ta.length-2)+"==");return ta}function v(la,ta,va,p){la.executeSql("CREATE TABLE IF NOT EXISTS "+ta.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",
2375[],va,p)}function K(la,ta,va,p,E,L){la.executeSql(va,p,E,function(ca,fa){fa.code===fa.SYNTAX_ERR?ca.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[ta.storeName],function(ia,ma){ma.rows.length?L(ia,fa):v(ia,ta,function(){ia.executeSql(va,p,E,L)},L)},L):L(ca,fa)},L)}function C(la,ta,va,p){var E=this;la=h(la);var L=new qa(function(ca,fa){E.ready().then(function(){void 0===ta&&(ta=null);var ia=ta,ma=E._dbInfo;ma.serializer.serialize(ta,function(ua,wa){wa?fa(wa):ma.db.transaction(function(Da){K(Da,
2376ma,"INSERT OR REPLACE INTO "+ma.storeName+" (key, value) VALUES (?, ?)",[la,ua],function(){ca(ia)},function(Ea,Aa){fa(Aa)})},function(Da){Da.code===Da.QUOTA_ERR&&(0<p?ca(C.apply(E,[la,ia,va,p-1])):fa(Da))})})})["catch"](fa)});f(L,va);return L}function da(la){return new qa(function(ta,va){la.transaction(function(p){p.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(E,L){E=[];for(var ca=0;ca<L.rows.length;ca++)E.push(L.rows.item(ca).name);
2377ta({db:la,storeNames:E})},function(E,L){va(L)})},function(p){va(p)})})}function ja(la,ta){var va=la.name+"/";la.storeName!==ta.storeName&&(va+=la.storeName+"/");return va}function ea(la,ta){la[ta]=function(){var va=arguments;return la.ready().then(function(){return la[ta].apply(la,va)})}}function ra(){for(var la=1;la<arguments.length;la++){var ta=arguments[la];if(ta)for(var va in ta)ta.hasOwnProperty(va)&&(I(ta[va])?arguments[0][va]=ta[va].slice():arguments[0][va]=ta[va])}return arguments[0]}var za=
2378"function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(la){return typeof la}:function(la){return la&&"function"===typeof Symbol&&la.constructor===Symbol&&la!==Symbol.prototype?"symbol":typeof la},na=function(){if("undefined"!==typeof indexedDB)return indexedDB;if("undefined"!==typeof webkitIndexedDB)return webkitIndexedDB;if("undefined"!==typeof mozIndexedDB)return mozIndexedDB;if("undefined"!==typeof OIndexedDB)return OIndexedDB;if("undefined"!==typeof msIndexedDB)return msIndexedDB}();
2379"undefined"===typeof Promise&&b(3);var qa=Promise,Ba=void 0,Ua={},Ja=Object.prototype.toString;b={_driver:"asyncStorage",_initStorage:function(la){function ta(){return qa.resolve()}var va=this,p={db:null};if(la)for(var E in la)p[E]=la[E];var L=Ua[p.name];L||(L=z(),Ua[p.name]=L);L.forages.push(va);va._initReady||(va._initReady=va.ready,va.ready=A);la=[];for(E=0;E<L.forages.length;E++){var ca=L.forages[E];ca!==va&&la.push(ca._initReady()["catch"](ta))}var fa=L.forages.slice(0);return qa.all(la).then(function(){p.db=
2380L.db;return u(p,!1)}).then(function(ia){p.db=ia;return x(p,va._defaultConfig.version)?u(p,!0):ia}).then(function(ia){p.db=L.db=ia;va._dbInfo=p;for(ia=0;ia<fa.length;ia++){var ma=fa[ia];ma!==va&&(ma._dbInfo.db=p.db,ma._dbInfo.version=p.version)}})},_support:function(){try{if(!na)return!1;var la="undefined"!==typeof openDatabase&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),ta="function"===typeof fetch&&-1!==fetch.toString().indexOf("[native code");
2381return(!la||ta)&&"undefined"!==typeof indexedDB&&"undefined"!==typeof IDBKeyRange}catch(va){return!1}}(),iterate:function(la,ta){var va=this,p=new qa(function(E,L){va.ready().then(function(){ha(va._dbInfo,"readonly",function(ca,fa){if(ca)return L(ca);try{var ia=fa.objectStore(va._dbInfo.storeName).openCursor(),ma=1;ia.onsuccess=function(){var ua=ia.result;if(ua){var wa=ua.value;wa&&wa.__local_forage_encoded_blob&&(wa=y(wa));wa=la(wa,ua.key,ma++);if(void 0!==wa)E(wa);else ua["continue"]()}else E()};
2382ia.onerror=function(){L(ia.error)}}catch(ua){L(ua)}})})["catch"](L)});f(p,ta);return p},getItem:function(la,ta){var va=this;la=h(la);var p=new qa(function(E,L){va.ready().then(function(){ha(va._dbInfo,"readonly",function(ca,fa){if(ca)return L(ca);try{var ia=fa.objectStore(va._dbInfo.storeName).get(la);ia.onsuccess=function(){var ma=ia.result;void 0===ma&&(ma=null);ma&&ma.__local_forage_encoded_blob&&(ma=y(ma));E(ma)};ia.onerror=function(){L(ia.error)}}catch(ma){L(ma)}})})["catch"](L)});f(p,ta);return p},
2383setItem:function(la,ta,va){var p=this;la=h(la);var E=new qa(function(L,ca){var fa;p.ready().then(function(){fa=p._dbInfo;return"[object Blob]"===Ja.call(ta)?m(fa.db).then(function(ia){return ia?ta:B(ta)}):ta}).then(function(ia){ha(p._dbInfo,"readwrite",function(ma,ua){if(ma)return ca(ma);try{var wa=ua.objectStore(p._dbInfo.storeName);null===ia&&(ia=void 0);var Da=wa.put(ia,la);ua.oncomplete=function(){void 0===ia&&(ia=null);L(ia)};ua.onabort=ua.onerror=function(){ca(Da.error?Da.error:Da.transaction.error)}}catch(Ea){ca(Ea)}})})["catch"](ca)});
2384f(E,va);return E},removeItem:function(la,ta){var va=this;la=h(la);var p=new qa(function(E,L){va.ready().then(function(){ha(va._dbInfo,"readwrite",function(ca,fa){if(ca)return L(ca);try{var ia=fa.objectStore(va._dbInfo.storeName)["delete"](la);fa.oncomplete=function(){E()};fa.onerror=function(){L(ia.error)};fa.onabort=function(){L(ia.error?ia.error:ia.transaction.error)}}catch(ma){L(ma)}})})["catch"](L)});f(p,ta);return p},clear:function(la){var ta=this,va=new qa(function(p,E){ta.ready().then(function(){ha(ta._dbInfo,
2385"readwrite",function(L,ca){if(L)return E(L);try{var fa=ca.objectStore(ta._dbInfo.storeName).clear();ca.oncomplete=function(){p()};ca.onabort=ca.onerror=function(){E(fa.error?fa.error:fa.transaction.error)}}catch(ia){E(ia)}})})["catch"](E)});f(va,la);return va},length:function(la){var ta=this,va=new qa(function(p,E){ta.ready().then(function(){ha(ta._dbInfo,"readonly",function(L,ca){if(L)return E(L);try{var fa=ca.objectStore(ta._dbInfo.storeName).count();fa.onsuccess=function(){p(fa.result)};fa.onerror=
2386function(){E(fa.error)}}catch(ia){E(ia)}})})["catch"](E)});f(va,la);return va},key:function(la,ta){var va=this,p=new qa(function(E,L){if(0>la)E(null);else va.ready().then(function(){ha(va._dbInfo,"readonly",function(ca,fa){if(ca)return L(ca);try{var ia=!1,ma=fa.objectStore(va._dbInfo.storeName).openCursor();ma.onsuccess=function(){var ua=ma.result;ua?0===la?E(ua.key):ia?E(ua.key):(ia=!0,ua.advance(la)):E(null)};ma.onerror=function(){L(ma.error)}}catch(ua){L(ua)}})})["catch"](L)});f(p,ta);return p},
2387keys:function(la){var ta=this,va=new qa(function(p,E){ta.ready().then(function(){ha(ta._dbInfo,"readonly",function(L,ca){if(L)return E(L);try{var fa=ca.objectStore(ta._dbInfo.storeName).openCursor(),ia=[];fa.onsuccess=function(){var ma=fa.result;ma?(ia.push(ma.key),ma["continue"]()):p(ia)};fa.onerror=function(){E(fa.error)}}catch(ma){E(ma)}})})["catch"](E)});f(va,la);return va},dropInstance:function(la,ta){ta=k.apply(this,arguments);var va=this.config();la="function"!==typeof la&&la||{};la.name||
2388(la.name=la.name||va.name,la.storeName=la.storeName||va.storeName);la.name?(va=la.name===va.name&&this._dbInfo.db?qa.resolve(this._dbInfo.db):u(la,!1).then(function(p){var E=Ua[la.name],L=E.forages;E.db=p;for(E=0;E<L.length;E++)L[E]._dbInfo.db=p;return p}),va=la.storeName?va.then(function(p){if(p.objectStoreNames.contains(la.storeName)){var E=p.version+1;n(la);var L=Ua[la.name],ca=L.forages;p.close();for(p=0;p<ca.length;p++){var fa=ca[p];fa._dbInfo.db=null;fa._dbInfo.version=E}return(new qa(function(ia,
2389ma){var ua=na.open(la.name,E);ua.onerror=function(wa){ua.result.close();ma(wa)};ua.onupgradeneeded=function(){ua.result.deleteObjectStore(la.storeName)};ua.onsuccess=function(){var wa=ua.result;wa.close();ia(wa)}})).then(function(ia){L.db=ia;for(var ma=0;ma<ca.length;ma++){var ua=ca[ma];ua._dbInfo.db=ia;r(ua._dbInfo)}})["catch"](function(ia){(t(la,ia)||qa.resolve())["catch"](function(){});throw ia;})}}
2389):va.then(function(p){n(la);var E=Ua[la.name],L=E.forages;p.close();for(p=0;p<L.length;p++)L[p]._dbInfo.db=
2390null;return(new qa(function(ca,fa){var ia=na.deleteDatabase(la.name);ia.onerror=ia.onblocked=function(ma){var ua=ia.result;ua&&ua.close();fa(ma)};ia.onsuccess=function(){var ma=ia.result;ma&&ma.close();ca(ma)}})).then(function(ca){E.db=ca;for(ca=0;ca<L.length;ca++)r(L[ca]._dbInfo)})["catch"](function(ca){(t(la,ca)||qa.resolve())["catch"](function(){});throw ca;})})):va=qa.reject("Invalid arguments");f(va,ta);return va}};var Pa=/^~~local_forage_type~([^~]+)~/,Ca=Object.prototype.toString,xa={serialize:function(la,
2391ta){var va="";la&&(va=Ca.call(la));if(la&&("[object ArrayBuffer]"===va||la.buffer&&"[object ArrayBuffer]"===Ca.call(la.buffer))){var p="__lfsc__:";if(la instanceof ArrayBuffer){var E=la;p+="arbf"}else E=la.buffer,"[object Int8Array]"===va?p+="si08":"[object Uint8Array]"===va?p+="ui08":"[object Uint8ClampedArray]"===va?p+="uic8":"[object Int16Array]"===va?p+="si16":"[object Uint16Array]"===va?p+="ur16":"[object Int32Array]"===va?p+="si32":"[object Uint32Array]"===va?p+="ui32":"[object Float32Array]"===
2392va?p+="fl32":"[object Float64Array]"===va?p+="fl64":ta(Error("Failed to get type for BinaryArray"));ta(p+ba(E))}else if("[object Blob]"===va)va=new FileReader,va.onload=function(){var L="~~local_forage_type~"+la.type+"~"+ba(this.result);ta("__lfsc__:blob"+L)},va.readAsArrayBuffer(la);else try{ta(JSON.stringify(la))}catch(L){console.error("Couldn't convert value into a JSON string: ",la),ta(null,L)}},deserialize:function(la){if("__lfsc__:"!==la.substring(0,9))return JSON.parse(la);var ta=la.substring(13);
2393la=la.substring(9,13);if("blob"===la&&Pa.test(ta)){var va=ta.match(Pa);var p=va[1];ta=ta.substring(va[0].length)}ta=V(ta);switch(la){case "arbf":return ta;case "blob":return e([ta],{type:p});case "si08":return new Int8Array(ta);case "ui08":return new Uint8Array(ta);case "uic8":return new Uint8ClampedArray(ta);case "si16":return new Int16Array(ta);case "ur16":return new Uint16Array(ta);case "si32":return new Int32Array(ta);case "ui32":return new Uint32Array(ta);case "fl32":return new Float32Array(ta);
2394case "fl64":return new Float64Array(ta);default:throw Error("Unkown type: "+la);}},stringToBuffer:V,bufferToString:ba};d={_driver:"webSQLStorage",_initStorage:function(la){var ta=this,va={db:null};if(la)for(var p in la)va[p]="string"!==typeof la[p]?la[p].toString():la[p];la=new qa(function(E,L){try{va.db=openDatabase(va.name,String(va.version),va.description,va.size)}catch(ca){return L(ca)}va.db.transaction(function(ca){v(ca,va,function(){ta._dbInfo=va;E()},function(fa,ia){L(ia)})},L)});va.serializer=
2395xa;return la},_support:"function"===typeof openDatabase,iterate:function(la,ta){var va=this,p=new qa(function(E,L){va.ready().then(function(){var ca=va._dbInfo;ca.db.transaction(function(fa){K(fa,ca,"SELECT * FROM "+ca.storeName,[],function(ia,ma){ia=ma.rows;ma=ia.length;for(var ua=0;ua<ma;ua++){var wa=ia.item(ua),Da=wa.value;Da&&=ca.serializer.deserialize(Da);Da=la(Da,wa.key,ua+1);if(void 0!==Da){E(Da);return}}E()},function(ia,ma){L(ma)})})})["catch"](L)});f(p,ta);return p},getItem:function(la,ta){var va=
2396this;la=h(la);var p=new qa(function(E,L){va.ready().then(function(){var ca=va._dbInfo;ca.db.transaction(function(fa){K(fa,ca,"SELECT * FROM "+ca.storeName+" WHERE key = ? LIMIT 1",[la],function(ia,ma){(ia=ma.rows.length?ma.rows.item(0).value:null)&&(ia=ca.serializer.deserialize(ia));E(ia)},function(ia,ma){L(ma)})})})["catch"](L)});f(p,ta);return p},setItem:function(la,ta,va){return C.apply(this,[la,ta,va,1])},removeItem:function(la,ta){var va=this;la=h(la);var p=new qa(function(E,L){va.ready().then(function(){var ca=
2397va._dbInfo;ca.db.transaction(function(fa){K(fa,ca,"DELETE FROM "+ca.storeName+" WHERE key = ?",[la],function(){E()},function(ia,ma){L(ma)})})})["catch"](L)});f(p,ta);return p},clear:function(la){var ta=this,va=new qa(function(p,E){ta.ready().then(function(){var L=ta._dbInfo;L.db.transaction(function(ca){K(ca,L,"DELETE FROM "+L.storeName,[],function(){p()},function(fa,ia){E(ia)})})})["catch"](E)});f(va,la);return va},length:function(la){var ta=this,va=new qa(function(p,E){ta.ready().then(function(){var L=
2398ta._dbInfo;
2398L.db.transaction(function(ca){K(ca,L,"SELECT COUNT(key) as c FROM "+L.storeName,[],function(fa,ia){fa=ia.rows.item(0).c;p(fa)},function(fa,ia){E(ia)})})})["catch"](E)});f(va,la);return va},key:function(la,ta){var va=this,p=new qa(function(E,L){va.ready().then(function(){var ca=va._dbInfo;ca.db.transaction(function(fa){K(fa,ca,"SELECT key FROM "+ca.storeName+" WHERE id = ? LIMIT 1",[la+1],function(ia,ma){ia=ma.rows.length?ma.rows.item(0).key:null;E(ia)},function(ia,ma){L(ma)})})})["catch"](L)});
2399f(p,ta);return p},keys:function(la){var ta=this,va=new qa(function(p,E){ta.ready().then(function(){var L=ta._dbInfo;L.db.transaction(function(ca){K(ca,L,"SELECT key FROM "+L.storeName,[],function(fa,ia){fa=[];for(var ma=0;ma<ia.rows.length;ma++)fa.push(ia.rows.item(ma).key);p(fa)},function(fa,ia){E(ia)})})})["catch"](E)});f(va,la);return va},dropInstance:function(la,ta){ta=k.apply(this,arguments);var va=this.config();la="function"!==typeof la&&la||{};la.name||(la.name=la.name||va.name,la.storeName=
2400la.storeName||va.storeName);var p=this;var E=la.name?(new qa(function(L){var ca=la.name===va.name?p._dbInfo.db:openDatabase(la.name,"","",0);la.storeName?L({db:ca,storeNames:[la.storeName]}):L(da(ca))})).then(function(L){return new qa(function(ca,fa){L.db.transaction(function(ia){function ma(Ea){return new qa(function(Aa,Ka){ia.executeSql("DROP TABLE IF EXISTS "+Ea,[],function(){Aa()},function(Ra,cb){Ka(cb)})})}for(var ua=[],wa=0,Da=L.storeNames.length;wa<Da;wa++)ua.push(ma(L.storeNames[wa]));qa.all(ua).then(function(){ca()})["catch"](function(Ea){fa(Ea)})},
2401function(ia){fa(ia)})})}):qa.reject("Invalid arguments");f(E,ta);return E}};try{var Fa="undefined"!==typeof localStorage&&"setItem"in localStorage&&!!localStorage.setItem}catch(la){Fa=!1}var Na=function(la,ta){for(var va=la.length,p=0;p<va;){var E=la[p],L=ta;if(E===L||"number"===typeof E&&"number"===typeof L&&isNaN(E)&&isNaN(L))return!0;p++}return!1},I=Array.isArray||function(la){return"[object Array]"===Object.prototype.toString.call(la)},Ta={},Sa={},db={INDEXEDDB:b,WEBSQL:d,LOCALSTORAGE:{_driver:"localStorageWrapper",
2402_initStorage:function(la){var ta={};if(la)for(var va in la)ta[va]=la[va];ta.keyPrefix=ja(la,this._defaultConfig);try{localStorage.setItem("_localforage_support_test",!0);localStorage.removeItem("_localforage_support_test");var p=!1}catch(E){p=!0}if(p&&!(0<localStorage.length))return qa.reject();this._dbInfo=ta;ta.serializer=xa;return qa.resolve()},_support:Fa,iterate:function(la,ta){var va=this,p=va.ready().then(function(){for(var E=va._dbInfo,L=E.keyPrefix,ca=L.length,fa=localStorage.length,ia=1,
2403ma=0;ma<fa;ma++){var ua=localStorage.key(ma);if(0===ua.indexOf(L)){var wa=localStorage.getItem(ua);wa&&=E.serializer.deserialize(wa);wa=la(wa,ua.substring(ca),ia++);if(void 0!==wa)return wa}}});f(p,ta);return p},getItem:function(la,ta){var va=this;la=h(la);var p=va.ready().then(function(){var E=va._dbInfo,L=localStorage.getItem(E.keyPrefix+la);L&&=E.serializer.deserialize(L);return L});f(p,ta);return p},setItem:function(la,ta,va){var p=this;la=h(la);var E=p.ready().then(function(){void 0===ta&&(ta=
2404null);var L=ta;return new qa(function(ca,fa){var ia=p._dbInfo;ia.serializer.serialize(ta,function(ma,ua){if(ua)fa(ua);else try{localStorage.setItem(ia.keyPrefix+la,ma),ca(L)}catch(wa){"QuotaExceededError"!==wa.name&&"NS_ERROR_DOM_QUOTA_REACHED"!==wa.name||fa(wa),fa(wa)}})})});f(E,va);return E},removeItem:function(la,ta){var va=this;la=h(la);var p=va.ready().then(function(){localStorage.removeItem(va._dbInfo.keyPrefix+la)});f(p,ta);return p},clear:function(la){var ta=this,va=ta.ready().then(function(){for(var p=
2405ta._dbInfo.keyPrefix,E=localStorage.length-1;0<=E;E--){var L=localStorage.key(E);0===L.indexOf(p)&&localStorage.removeItem(L)}});f(va,la);return va},length:function(la){var ta=this.keys().then(function(va){return va.length});f(ta,la);return ta},key:function(la,ta){var va=this,p=va.ready().then(function(){var E=va._dbInfo;try{var L=localStorage.key(la)}catch(ca){L=null}L&&=L.substring(E.keyPrefix.length);return L});f(p,ta);return p},keys:function(la){var ta=this,va=ta.ready().then(function(){for(var p=
2406ta._dbInfo,E=localStorage.length,L=[],ca=0;ca<E;ca++){var fa=localStorage.key(ca);0===fa.indexOf(p.keyPrefix)&&L.push(fa.substring(p.keyPrefix.length))}return L});f(va,la);return va},dropInstance:function(la,ta){ta=k.apply(this,arguments);la="function"!==typeof la&&la||{};if(!la.name){var va=this.config();la.name=la.name||va.name;la.storeName=la.storeName||va.storeName}var p=this;va=la.name?(new qa(function(E){la.storeName?E(ja(la,p._defaultConfig)):E(la.name+"/")})).then(function(E){for(var L=localStorage.length-
24071;0<=L;L--){var ca=localStorage.key(L);0===ca.indexOf(E)&&localStorage.removeItem(ca)}}):qa.reject("Invalid arguments");f(va,ta);return va}}};Fa=[db.INDEXEDDB._driver,db.WEBSQL._driver,db.LOCALSTORAGE._driver];var ab=["dropInstance"],Oa="clear getItem iterate key keys length removeItem setItem".split(" ").concat(ab),Ga={description:"",driver:Fa.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};Fa=new (function(){function la(ta){if(!(this instanceof la))throw new TypeError("Cannot call a class as a function");
2408for(var va in db)if(db.hasOwnProperty(va)){var p=db[va],E=p._driver;this[va]=E;Ta[E]||this.defineDriver(p)}this._defaultConfig=ra({},Ga);this._config=ra({},this._defaultConfig,ta);this._initDriver=this._driverSet=null;this._ready=!1;this._dbInfo=null;this._wrapLibraryMethodsWithReady();this.setDriver(this._config.driver)["catch"](function(){})}la.prototype.config=function(ta){if("object"===("undefined"===typeof ta?"undefined":za(ta))){if(this._ready)return Error("Can't call config() after localforage has been used.");
2409for(var va in ta){"storeName"===va&&(ta[va]=ta[va].replace(/\W/g,"_"));if("version"===va&&"number"!==typeof ta[va])return Error("Database version must be a number.");this._config[va]=ta[va]}return"driver"in ta&&ta.driver?this.setDriver(this._config.driver):!0}return"string"===typeof ta?this._config[ta]:this._config};la.prototype.defineDriver=function(ta,va,p){var E=new qa(function(L,ca){try{var fa=ta._driver,ia=Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");
2410if(ta._driver){for(var ma=Oa.concat("_initStorage"),ua=0,wa=ma.length;ua<wa;ua++){var Da=ma[ua];if((!Na(ab,Da)||ta[Da])&&"function"!==typeof ta[Da]){ca(ia);return}}(function(){for(var Ea=function(cb){return function(){var ib=qa.reject(Error("Method "+cb+" is not implemented by the current driver"));f(ib,arguments[arguments.length-1]);return ib}},Aa=0,Ka=ab.length;Aa<Ka;Aa++){var Ra=ab[Aa];ta[Ra]||(ta[Ra]=Ea(Ra))}})();ia=function(Ea){Ta[fa]&&console.info("Redefining LocalForage driver: "+fa);Ta[fa]=
2411ta;Sa[fa]=Ea;L()};"_support"in ta?ta._support&&"function"===typeof ta._support?ta._support().then(ia,ca):ia(!!ta._support):ia(!0)}else ca(ia)}catch(Ea){ca(Ea)}});g(E,va,p);return E};la.prototype.driver=function(){return this._driver||null};la.prototype.getDriver=function(ta,va,p){ta=Ta[ta]?qa.resolve(Ta[ta]):qa.reject(Error("Driver not found."));g(ta,va,p);return ta};la.prototype.getSerializer=function(ta){var va=qa.resolve(xa);g(va,ta);return va};la.prototype.ready=function(ta){var va=this,p=va._driverSet.then(function(){null===
2412va._ready&&(va._ready=va._initDriver());return va._ready});g(p,ta,ta);return p};la.prototype.setDriver=function(ta,va,p){function E(){fa._config.driver=fa.driver()}function L(ma){fa._extend(ma);E();fa._ready=fa._initStorage(fa._config);return fa._ready}function ca(ma){return function(){function ua(){for(;wa<ma.length;){var Da=ma[wa];wa++;fa._dbInfo=null;fa._ready=null;return fa.getDriver(Da).then(L)["catch"](ua)}E();fa._driverSet=qa.reject(Error("No available storage method found."));return fa._driverSet}
2413var wa=0;return ua()}}var fa=this;I(ta)||(ta=[ta]);var ia=this._getSupportedDrivers(ta);this._driverSet=(null!==this._driverSet?this._driverSet["catch"](function(){return qa.resolve()}):qa.resolve()).then(function(){var ma=ia[0];fa._dbInfo=null;fa._ready=null;return fa.getDriver(ma).then(function(ua){fa._driver=ua._driver;E();fa._wrapLibraryMethodsWithReady();fa._initDriver=ca(ia)})})["catch"](function(){E();fa._driverSet=qa.reject(Error("No available storage method found."));return fa._driverSet});
2414g(this._driverSet,va,p);return this._driverSet};la.prototype.supports=function(ta){return!!Sa[ta]};la.prototype._extend=function(ta){ra(this,ta)};la.prototype._getSupportedDrivers=function(ta){for(var va=[],p=0,E=ta.length;p<E;p++){var L=ta[p];this.supports(L)&&va.push(L)}return va};la.prototype._wrapLibraryMethodsWithReady=function(){for(var ta=0,va=Oa.length;ta<va;ta++)ea(this,Oa[ta])};la.prototype.createInstance=function(ta){return new la(ta)};return la}());c.exports=Fa},{3:3}]},{},[4])(4)});
2415(function(a,b){"object"===typeof exports&&"object"===typeof module?module.exports=b():"function"===typeof define&&define.amd?define([],b):"object"===typeof exports?exports.signalR=b():a.signalR=b()})(window,function(){return function(a){function b(d){if(c[d])return c[d].exports;var e=c[d]={i:d,l:!1,exports:{}};a[d].call(e.exports,e,e.exports,b);e.l=!0;return e.exports}var c={};b.m=a;b.c=c;b.d=function(d,e,f){b.o(d,e)||Object.defineProperty(d,e,{enumerable:!0,get:f})};b.r=function(d){"undefined"!==
2416typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(d,Symbol.toStringTag,{value:"Module"});Object.defineProperty(d,"__esModule",{value:!0})};b.t=function(d,e){e&1&&(d=b(d));if(e&8||e&4&&"object"===typeof d&&d&&d.__esModule)return d;var f=Object.create(null);b.r(f);Object.defineProperty(f,"default",{enumerable:!0,value:d});if(e&2&&"string"!=typeof d)for(var g in d)b.d(f,g,function(h){return d[h]}.bind(null,g));return f};b.n=function(d){var e=d&&d.__esModule?function(){return d["default"]}:function(){return d};
2417b.d(e,"a",e);return e};b.o=function(d,e){return Object.prototype.hasOwnProperty.call(d,e)};b.p="";return b(b.s=0)}([function(a,b,c){c.r(b);a=c(1);c.n(a);var d=c(3);c.d(b,"AbortError",function(){return d.AbortError});c.d(b,"HttpError",function(){return d.HttpError});c.d(b,"TimeoutError",function(){return d.TimeoutError});c.d(b,"HttpClient",function(){return d.HttpClient});c.d(b,"HttpResponse",function(){return d.HttpResponse});c.d(b,"DefaultHttpClient",function(){return d.DefaultHttpClient});c.d(b,
2418"HubConnection",function(){return d.HubConnection});c.d(b,"HubConnectionState",function(){return d.HubConnectionState});c.d(b,"HubConnectionBuilder",function(){return d.HubConnectionBuilder});c.d(b,"MessageType",function(){return d.MessageType});c.d(b,"LogLevel",function(){return d.LogLevel});c.d(b,"HttpTransportType",function(){return d.HttpTransportType});c.d(b,"TransferFormat",function(){return d.TransferFormat});c.d(b,"NullLogger",function(){return d.NullLogger});c.d(b,"JsonHubProtocol",function(){return d.JsonHubProtocol});
2419c.d(b,"Subject",function(){return d.Subject});c.d(b,"VERSION",function(){return d.VERSION});Uint8Array.prototype.indexOf||Object.defineProperty(Uint8Array.prototype,"indexOf",{value:Array.prototype.indexOf,writable:!0});Uint8Array.prototype.slice||Object.defineProperty(Uint8Array.prototype,"slice",{value:function(e,f){return new Uint8Array(Array.prototype.slice.call(this,e,f))},writable:!0});Uint8Array.prototype.forEach||Object.defineProperty(Uint8Array.prototype,"forEach",{value:Array.prototype.forEach,
2420writable:!0})},function(a,b,c){(function(d){(function(e,f){a.exports=f()})(this,function(){function e(){return function(){return process.nextTick(k)}}function f(){var Oa=0,Ga=new Ba(k),la=document.createTextNode("");Ga.observe(la,{characterData:!0}
2420);return function(){la.data=Oa=++Oa%2}}function g(){var Oa=new MessageChannel;Oa.port1.onmessage=k;return function(){return Oa.port2.postMessage(0)}}function h(){var Oa=setTimeout;return function(){return Oa(k,1)}}function k(){for(var Oa=0;Oa<ra;Oa+=2)(0,Ja[Oa])(Ja[Oa+
24211]),Ja[Oa]=void 0,Ja[Oa+1]=void 0;ra=0}function l(){try{var Oa=Error("Cannot find module 'vertx'");Oa.code="MODULE_NOT_FOUND";throw Oa;}catch(Ga){return h()}}function m(Oa,Ga){var la=this,ta=new this.constructor(r);void 0===ta[Ca]&&da(ta);var va=la._state;if(va){var p=arguments[va-1];na(function(){return K(va,ta,p,la._result)})}else V(la,ta,Oa,Ga);return ta}function n(Oa){if(Oa&&"object"===typeof Oa&&Oa.constructor===this)return Oa;var Ga=new this(r);A(Ga,Oa);return Ga}function r(){}function t(Oa){try{return Oa.then}catch(Ga){return I.error=
2422Ga,I}}function u(Oa,Ga,la,ta){try{Oa.call(Ga,la,ta)}catch(va){return va}}function x(Oa,Ga,la){na(function(ta){var va=!1,p=u(la,Ga,function(E){va||(va=!0,Ga!==E?A(ta,E):ha(ta,E))},function(E){va||(va=!0,z(ta,E))},"Settle: "+(ta._label||" unknown promise"));!va&&p&&(va=!0,z(ta,p))},Oa)}function B(Oa,Ga){Ga._state===Fa?ha(Oa,Ga._result):Ga._state===Na?z(Oa,Ga._result):V(Ga,void 0,function(la){return A(Oa,la)},function(la){return z(Oa,la)})}function y(Oa,Ga,la){Ga.constructor===Oa.constructor&&la===m&&
2423Ga.constructor.resolve===n?B(Oa,Ga):la===I?(z(Oa,I.error),I.error=null):void 0===la?ha(Oa,Ga):"function"===typeof la?x(Oa,Ga,la):ha(Oa,Ga)}function A(Oa,Ga){if(Oa===Ga)z(Oa,new TypeError("You cannot resolve a promise with itself"));else{var la=typeof Ga;null===Ga||"object"!==la&&"function"!==la?ha(Oa,Ga):y(Oa,Ga,t(Ga))}}function aa(Oa){Oa._onerror&&Oa._onerror(Oa._result);ba(Oa)}function ha(Oa,Ga){Oa._state===xa&&(Oa._result=Ga,Oa._state=Fa,0!==Oa._subscribers.length&&na(ba,Oa))}function z(Oa,Ga){Oa._state===
2424xa&&(Oa._state=Na,Oa._result=Ga,na(aa,Oa))}function V(Oa,Ga,la,ta){var va=Oa._subscribers,p=va.length;Oa._onerror=null;va[p]=Ga;va[p+Fa]=la;va[p+Na]=ta;0===p&&Oa._state&&na(ba,Oa)}function ba(Oa){var Ga=Oa._subscribers,la=Oa._state;if(0!==Ga.length){for(var ta,va,p=Oa._result,E=0;E<Ga.length;E+=3)ta=Ga[E],va=Ga[E+la],ta?K(la,ta,va,p):va(p);Oa._subscribers.length=0}}function v(){this.error=null}function K(Oa,Ga,la,ta){var va="function"===typeof la,p=void 0,E=void 0,L=void 0,ca=void 0;if(va){try{p=
2425la(ta)}catch(fa){Ta.error=fa,p=Ta}p===Ta?(ca=!0,E=p.error,p.error=null):L=!0;if(Ga===p){z(Ga,new TypeError("A promises callback cannot return that same promise."));return}}else p=ta,L=!0;Ga._state===xa&&(va&&L?A(Ga,p):ca?z(Ga,E):Oa===Fa?ha(Ga,p):Oa===Na&&z(Ga,p))}function C(Oa,Ga){try{Ga(function(la){A(Oa,la)},function(la){z(Oa,la)})}catch(la){z(Oa,la)}}function da(Oa){Oa[Ca]=Sa++;Oa._state=void 0;Oa._result=void 0;Oa._subscribers=[]}var ja=void 0,ea=ja=Array.isArray?Array.isArray:function(Oa){return"[object Array]"===
2426Object.prototype.toString.call(Oa)},ra=0,za=void 0,na=function(Oa,Ga){Ja[ra]=Oa;Ja[ra+1]=Ga;ra+=2;2===ra&&(za?za(k):Pa())},qa=(ja="undefined"!==typeof window?window:void 0)||{},Ba=qa.MutationObserver||qa.WebKitMutationObserver;qa="undefined"===typeof self&&"undefined"!==typeof process&&"[object process]"==={}.toString.call(process);var Ua="undefined"!==typeof Uint8ClampedArray&&"undefined"!==typeof importScripts&&"undefined"!==typeof MessageChannel,Ja=Array(1E3),Pa=void 0;Pa=qa?e():Ba?f():Ua?g():
2427void 0===ja?l():h();var Ca=Math.random().toString(36).substring(16),xa=void 0,Fa=1,Na=2,I=new v,Ta=new v,Sa=0,db=function(){function Oa(Ga,la){this._instanceConstructor=Ga;this.promise=new Ga(r);this.promise[Ca]||da(this.promise);ea(la)?(this._remaining=this.length=la.length,this._result=Array(this.length),0===this.length?ha(this.promise,this._result):(this.length=this.length||0,this._enumerate(la),0===this._remaining&&ha(this.promise,this._result))):z(this.promise,Error("Array Methods must be provided an Array"))}
2428Oa.prototype._enumerate=function(Ga){for(var la=0;this._state===xa&&la<Ga.length;la++)this._eachEntry(Ga[la],la)};Oa.prototype._eachEntry=function(Ga,la){var ta=this._instanceConstructor,va=ta.resolve;va===n?(va=t(Ga),va===m&&Ga._state!==xa?this._settledAt(Ga._state,la,Ga._result):"function"!==typeof va?(this._remaining--,this._result[la]=Ga):ta===ab?(ta=new ta(r),y(ta,Ga,va),this._willSettleAt(ta,la)):this._willSettleAt(ne
2428w ta(function(p){return p(Ga)}),la)):this._willSettleAt(va(Ga),la)};Oa.prototype._settledAt=
2429function(Ga,la,ta){var va=this.promise;va._state===xa&&(this._remaining--,Ga===Na?z(va,ta):this._result[la]=ta);0===this._remaining&&ha(va,this._result)};Oa.prototype._willSettleAt=function(Ga,la){var ta=this;V(Ga,void 0,function(va){return ta._settledAt(Fa,la,va)},function(va){return ta._settledAt(Na,la,va)})};return Oa}(),ab=function(){function Oa(Ga){this[Ca]=Sa++;this._result=this._state=void 0;this._subscribers=[];if(r!==Ga){if("function"!==typeof Ga)throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");
2430if(this instanceof Oa)C(this,Ga);else throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");}}Oa.prototype.catch=function(Ga){return this.then(null,Ga)};Oa.prototype.finally=function(Ga){var la=this.constructor;return this.then(function(ta){return la.resolve(Ga()).then(function(){return ta})},function(ta){return la.resolve(Ga()).then(function(){throw ta;})})};return Oa}();ab.prototype.then=m;ab.all=function(Oa){return(new db(this,
2431Oa)).promise};ab.race=function(Oa){var Ga=this;return ea(Oa)?new Ga(function(la,ta){for(var va=Oa.length,p=0;p<va;p++)Ga.resolve(Oa[p]).then(la,ta)}):new Ga(function(la,ta){return ta(new TypeError("You must pass an array to race."))})};ab.resolve=n;ab.reject=function(Oa){var Ga=new this(r);z(Ga,Oa);return Ga};ab._setScheduler=function(Oa){za=Oa};ab._setAsap=function(Oa){na=Oa};ab._asap=na;ab.polyfill=function(){var Oa=void 0;if("undefined"!==typeof d)Oa=d;else if("undefined"!==typeof self)Oa=self;
2432else try{Oa=Function("return this")()}catch(ta){throw Error("polyfill failed because global object is unavailable in this environment");}var Ga=Oa.Promise;if(Ga){var la=null;try{la=Object.prototype.toString.call(Ga.resolve())}catch(ta){}if("[object Promise]"===la&&!Ga.cast)return}Oa.Promise=ab};ab.Promise=ab;ab.polyfill();return ab})}).call(this,c(2))},function(a,b){b=function(){return this}();try{b=b||(new Function("return this"))()}catch(c){"object"===typeof window&&(b=window)}a.exports=b},function(a,
2433b,c){c.r(b);var d=c(4);c.d(b,"AbortError",function(){return d.AbortError});c.d(b,"HttpError",function(){return d.HttpError});c.d(b,"TimeoutError",function(){return d.TimeoutError});var e=c(5);c.d(b,"HttpClient",function(){return e.HttpClient});c.d(b,"HttpResponse",function(){return e.HttpResponse});var f=c(6);c.d(b,"DefaultHttpClient",function(){return f.DefaultHttpClient});var g=c(12);c.d(b,"HubConnection",function(){return g.HubConnection});c.d(b,"HubConnectionState",function(){return g.HubConnectionState});
2434var h=c(17);c.d(b,"HubConnectionBuilder",function(){return h.HubConnectionBuilder});var k=c(15);c.d(b,"MessageType",function(){return k.MessageType});var l=c(8);c.d(b,"LogLevel",function(){return l.LogLevel});var m=c(20);c.d(b,"HttpTransportType",function(){return m.HttpTransportType});c.d(b,"TransferFormat",function(){return m.TransferFormat});var n=c(10);c.d(b,"NullLogger",function(){return n.NullLogger});var r=c(25);c.d(b,"JsonHubProtocol",function(){return r.JsonHubProtocol});var t=c(16);c.d(b,
2435"Subject",function(){return t.Subject});var u=c(9);c.d(b,"VERSION",function(){return u.VERSION})},function(a,b,c){c.r(b);c.d(b,"HttpError",function(){return e});c.d(b,"TimeoutError",function(){return f});c.d(b,"AbortError",function(){return g});var d=function(){var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(k,l){k.__proto__=l}||function(k,l){for(var m in l)l.hasOwnProperty(m)&&(k[m]=l[m])};return function(k,l){function m(){this.constructor=k}h(k,l);k.prototype=null===l?Object.create(l):
2436(m.prototype=l.prototype,new m)}}(),e=function(h){function k(l,m){var n=this.constructor.prototype;l=h.call(this,l)||this;l.statusCode=m;l.__proto__=n;return l}d(k,h);return k}(Error),f=function(h){function k(l){var m=this.constructor;void 0===l&&(l="A timeout occurred.");m=m.prototype;l=h.call(this,l)||this;l.__proto__=m;return l}d(k,h);return k}(Error),g=function(h){function k(l){var m=this.constructor;void 0===l&&(l="An abort occurred.");m=m.prototype;l=h.call(this,l)||this;l.__proto__=m;return l}
2437d(k,h);return k}(Error)},function(a,b,c){c.r(b);c.d(b,"HttpResponse",function(){return e});c.d(b,"HttpClient",function(){return f});var d=Object.assign||function(g){for(var h,k=1,l=arguments.length;k<l;k++){h=arguments[k];for(var m in h)Object.prototype.hasOwnProperty.call(h,m)&&(g[m]=h[m])}return g},e=function(){return function(g,h,k){this.statusCode=g;this.statusText=h;this.content=k}}(),f=function(){function g(){}g.prototype.get=function(h,k){return this.send(d({},k,{method:"GET",url:h}))};g.prototype.post=
2438function(h,k){return this.send(d({},k,{method:"POST",url:h}))};g.prototype.delete=function(h,k){return this.send(d({},k,{method:"DELETE",url:h}))};g.prototype.getCookieString=function(h){return""};return g}()},function(a,b,c){c.r(b);c.d(b,"DefaultHttpClient",function(){return k});var d=c(4),e=c(7);a=c(5);var f=c(9),g=c(11),h=function(){var l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,n){m.__proto__=n}||function(m,n){for(var r in n)n.hasOwnProperty(r)&&(m[r]=n[r])};return function(m,
2439n){function r(){this.constructor=m}l(m,n);m.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),k=function(l){function m(n){var r=l.call(this)||this;if("undefined"!==typeof fetch||f.Platform.isNode)r.httpClient=new e.FetchHttpClient(n);else if("undefined"!==typeof XMLHttpRequest)r.httpClient=new g.XhrHttpClient(n);else throw Error("No usable HttpClient found.");return r}h(m,l);m.prototype.send=function(n){return n.abortSignal&&n.abortSignal.aborted?Promise.reject(new d.AbortError):
2440n.method?n.url?this.httpClient.send(n):Promise.reject(Error("No url defined.")):Promise.reject(Error("No method defined."))};m.prototype.getCookieString=function(n){return this.httpClient.getCookieString(n)};return m}(a.HttpClient)},function(a,b,c){function d(t,u){switch(u){case "arraybuffer":t=t.arrayBuffer();break;case "text":t=t.text();break;case "blob":case "document":case "json":throw Error(u+" is not supported.");default:t=t.text()}return t}c.r(b);c.d(b,"FetchHttpClient",function(){return r});
2441var e=c(4),f=c(5),g=c(8),h=c(9),k=function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,x){u.__proto__=x}||function(u,x){for(var B in x)x.hasOwnProperty(B)&&(u[B]=x[B])};return function(u,x){function B(){this.constructor=u}t(u,x);u.prototype=null===x?Object.create(x):(B.prototype=x.prototype,new B)}}(),l=Object.assign||function(t){for(var u,x=1,B=arguments.length;x<B;x++){u=arguments[x];for(var y in u)Object.prototype.hasOwnProperty.call(u,y)&&(t[y]=u[y])}return t},m=
2442function(t,u,x,B){return new (x||=Promise)(function(y,A){function aa(V){try{z(B.next(V))}catch(ba){A(ba)}}function ha(V){try{z(B["throw"](V))}catch(ba){A(ba)}}function z(V){V.done?y(V.value):(new x(function(ba){ba(V.value)})).then(aa,ha)}z((B=B.apply(t,u||[])).next())})},n=function(t,u){function x(V){return function(ba){return B([V,ba])}}function B(V){if(A)throw new TypeError("Generator is already executing.");for(;y;)try{if(A=1,aa&&(ha=V[0]&2?aa["return"]:V[0]?aa["throw"]||((ha=aa["return"])&&ha.call(aa),
24430):aa.next)&&!(ha=ha.call(aa,V[1])).done)return ha;if(aa=0,ha)V=[V[0]&2,ha.value];switch(V[0]){case 0:case 1:ha=V;break;case 4:return y.label++,{value:V[1],done:!1};case 5:y.label++;aa=V[1];V=[0];continue;case 7:V=y.ops.pop();y.trys.pop();continue;default:if(!(ha=y.trys,ha=0<ha.length&&ha[ha.length-1])&&(6===V[0]||2===V[0])){y=0;continue}if(3===V[0]&&(!ha||V[1]>ha[0]&&V[1]<ha[3]))y.label=V[1];else if(6===V[0]&&y.label<ha[1])y.label=ha[1],ha=V;else if(ha&&y.label<ha[2])y.label=ha[2],y.ops.push(V);
2444else{ha[2]&&y.ops.pop();y.trys.pop();continue}}V=u.call(t,y)}catch(ba){V=[6,ba],aa=0}finally{A=ha=0}if(V[0]&5)throw V[1];return{value:V[0]?V[1]:void 0,done:!0}}var y={label:0,sent:function(){if(ha[0]&1)throw ha[1];return ha[1]},trys:[],ops:[]},A,aa,ha,z;return z={next:x(0),throw:x(1),return:x(2)},"function"===typeof Symbol&&(z[Symbol.iterator]=function(){return this}),z},r=function(t){function u(x){var B=t.call(this)||this;B.logger=x;"undefined"===typeof fetch?(x=require,B.jar=new (x("tough-cookie").CookieJar),
2445B.fetchType=x("node-fetch"),B.fetchType=x("fetch-cookie")(B.fetchType,B.jar),B.abortControllerType=x("abort-controller")):(B.fetchType=fetch.bind(self),B.abortControllerType=AbortController);return B}k(u,t);u.prototype.send=function(x){return m(this,void 0,void 0,function(){var B,y,A,aa,ha,z,V,ba,v=this;return n(this,function(K){switch(K.label){case 0:if(x.abortSignal&&x.abortSignal.aborted)throw new e.AbortError;if(!x.method)throw Error("No method defined.");if(!x.url)throw Error("No url defined.");
2446B=new this.abortControllerType;x.abortSignal&&(x.abortSignal.onabort=function(){B.abort();y=new e.AbortError});A=null;x.timeout&&(aa=x.timeout,A=setTimeout(function(){B.abort();v.logger.log(g.LogLevel.Warning,"Timeout from HTTP request.");y=new e.TimeoutError},aa));K.label=1;case 1:return K.trys.push([1,3,4,5]),[4,this.fetchType(x.url,{body:x.content,cache:"no-cache",credentials:!0===x.withCredentials?"include":"same-origin",headers:l({"Content-Type":"text/plain;charset=UTF-8","X-Requested-With":"XMLHttpRequest"},
2447x.headers),method:x.method,mode:"cors",redirect:"manual",signal:B.signal})];case 2:return ha=K.sent(),[3,5];case 3:z=K.sent();if(y)throw y;this.logger.log(g.LogLevel.Warning,"Error from HTTP request. "+z+".");throw z;case 4:return A&&clearTimeout(A),x.abortSignal&&(x.abortSignal.onabort=null),[7];case 5:if(!ha.ok)throw new e.HttpError(ha.statusText,ha.status);V=d(ha,x.responseType);return[4,V];case 6:return ba=K.sent(),[2,new f.HttpResponse(ha.status,ha.statusText,ba)]}})})};u.prototype.getCookieString=
2448function(x){var B="";h.Platform.isNode&&this.jar&&this.jar.getCookies(x,function(y,A){return B=A.join("; ")});return B};return u}(f.HttpClient)},function(a,b,c){c.r(b);c.d(b,"LogLevel",function(){return d});var d;(function(e){e[e.Trace=0]="Trace";e[e.Debug=1]="Debug";e[e.Information=2]="Information";e[e.Warning=3]="Warning";e[e.Error=4]="Error";e[e.Critical=5]="Critical";e[e.None=6]="None"})(d||={})},function(a,b,c){function d(z,V){var ba="";f(z)?(ba="Binary data of length "+z.byteLength,V&&(ba+=
2449". Content: '"+e(z)+"'")):"string"===typeof z&&(ba="String data of length "+z.length,V&&(ba+=". Content: '"+z+"'"));return ba}function e(z){var V="";(new Uint8Array(z)).forEach(function(ba){V+="0x"+(16>ba?"0":"")+ba.toString(16)+" "});return V.substr(0,V.length-1)}function f(z){return z&&"undefined"!==typeof ArrayBuffer&&(z instanceof ArrayBuffer||z.constructor&&"ArrayBuffer"===z.constructor.name)}function g(z,V,ba,v,K,C,da,ja,ea){return u(this,void 0,void 0,function(){var ra,za,na,qa,Ba,Ua,Ja,Pa;
2450return x(this,function(Ca){switch(Ca.label){case 0:return za={},K?[4,K()]:[3,2];case 1:(na=Ca.sent())&&(za=(ra={},ra.Authorization="Bearer "+na,ra)),Ca.label=2;case 2:return qa=k(),Ba=qa[0],Ua=qa[1],za[Ba]=Ua,z.log(n.LogLevel.Trace,"("+V+" transport) sending data. "+d(C,da)+"."),Ja=f(C)?"arraybuffer":"text",[4,ba.post(v,{content:C,headers:t({},za,ea),responseType:Ja,withCredentials:ja})];case 3:return Pa=Ca.sent(),z.log(n.LogLevel.Trace,"("+V+" transport) request complete. Response status: "+Pa.statusCode+
2451"."),[2]}})})}function h(z){return void 0===z?new ha(n.LogLevel.Information):null===z?r.NullLogger.instance:z.log?z:new ha(z)}function k(){var z="X-SignalR-User-Agent";A.isNode&&(z="User-Agent");var V=B,ba=m();var v=A.isNode?"NodeJS":"Browser";var K=A.isNode?process.versions.node:void 0;return[z,l(V,ba,v,K)]}function l(z,V,ba,v){var K="Microsoft SignalR/",C=z.split(".");K+=C[0]+"."+C[1];K+=" ("+z+"; ";K=(V&&""!==V?K+(V+"; "):K+"Unknown OS; ")+(""+ba);K=v?K+("; "+v):K+"; Unknown Runtime Version";return K+
2452")"}function m(){if(A.isNode)switch(process.platform){case "win32":return"Windows NT";case "darwin":return"macOS";case "linux":return"Linux";default:return process.platform}else return""}c.r(b);c.d(b,"VERSION",function(){return B});c.d(b,"Arg",function(){return y});c.d(b,"Platform",function(){return A});c.d(b,"getDataDetail",function(){return d});c.d(b,"formatArrayBuffer",function(){return e});c.d(b,"isArrayBuffer",function(){return f});
2452c.d(b,"sendMessage",function(){return g});c.d(b,"createLogger",
2453function(){return h});c.d(b,"SubjectSubscription",function(){return aa});c.d(b,"ConsoleLogger",function(){return ha});c.d(b,"getUserAgentHeader",function(){return k});c.d(b,"constructUserAgent",function(){return l});var n=c(8),r=c(10),t=Object.assign||function(z){for(var V,ba=1,v=arguments.length;ba<v;ba++){V=arguments[ba];for(var K in V)Object.prototype.hasOwnProperty.call(V,K)&&(z[K]=V[K])}return z},u=function(z,V,ba,v){return new (ba||=Promise)(function(K,C){function da(ra){try{ea(v.next(ra))}catch(za){C(za)}}
2454function ja(ra){try{ea(v["throw"](ra))}catch(za){C(za)}}function ea(ra){ra.done?K(ra.value):(new ba(function(za){za(ra.value)})).then(da,ja)}ea((v=v.apply(z,V||[])).next())})},x=function(z,V){function ba(ra){return function(za){return v([ra,za])}}function v(ra){if(C)throw new TypeError("Generator is already executing.");for(;K;)try{if(C=1,da&&(ja=ra[0]&2?da["return"]:ra[0]?da["throw"]||((ja=da["return"])&&ja.call(da),0):da.next)&&!(ja=ja.call(da,ra[1])).done)return ja;if(da=0,ja)ra=[ra[0]&2,ja.value];
2455switch(ra[0]){case 0:case 1:ja=ra;break;case 4:return K.label++,{value:ra[1],done:!1};case 5:K.label++;da=ra[1];ra=[0];continue;case 7:ra=K.ops.pop();K.trys.pop();continue;default:if(!(ja=K.trys,ja=0<ja.length&&ja[ja.length-1])&&(6===ra[0]||2===ra[0])){K=0;continue}if(3===ra[0]&&(!ja||ra[1]>ja[0]&&ra[1]<ja[3]))K.label=ra[1];else if(6===ra[0]&&K.label<ja[1])K.label=ja[1],ja=ra;else if(ja&&K.label<ja[2])K.label=ja[2],K.ops.push(ra);else{ja[2]&&K.ops.pop();K.trys.pop();continue}}ra=V.call(z,K)}catch(za){ra=
2456[6,za],da=0}finally{C=ja=0}if(ra[0]&5)throw ra[1];return{value:ra[0]?ra[1]:void 0,done:!0}}var K={label:0,sent:function(){if(ja[0]&1)throw ja[1];return ja[1]},trys:[],ops:[]},C,da,ja,ea;return ea={next:ba(0),throw:ba(1),return:ba(2)},"function"===typeof Symbol&&(ea[Symbol.iterator]=function(){return this}),ea},B="5.0.7",y=function(){function z(){}z.isRequired=function(V,ba){if(null===V||void 0===V)throw Error("The '"+ba+"' argument is required.");};z.isNotEmpty=function(V,ba){if(!V||V.match(/^\s*$/))throw Error("The '"+
2457ba+"' argument should not be empty.");};z.isIn=function(V,ba,v){if(!(V in ba))throw Error("Unknown "+v+" value: "+V+".");};return z}(),A=function(){function z(){}Object.defineProperty(z,"isBrowser",{get:function(){return"object"===typeof window},enumerable:!0,configurable:!0});Object.defineProperty(z,"isWebWorker",{get:function(){return"object"===typeof self&&"importScripts"in self},enumerable:!0,configurable:!0});Object.defineProperty(z,"isNode",{get:function(){return!this.isBrowser&&!this.isWebWorker},
2458enumerable:!0,configurable:!0});return z}(),aa=function(){function z(V,ba){this.subject=V;this.observer=ba}z.prototype.dispose=function(){var V=this.subject.observers.indexOf(this.observer);-1<V&&this.subject.observers.splice(V,1);0===this.subject.observers.length&&this.subject.cancelCallback&&this.subject.cancelCallback().catch(function(ba){})};return z}(),ha=function(){function z(V){this.minimumLogLevel=V;this.outputConsole=console}z.prototype.log=function(V,ba){if(V>=this.minimumLogLevel)switch(V){case n.LogLevel.Critical:case n.LogLevel.Error:this.outputConsole.error("["+
2459(new Date).toISOString()+"] "+n.LogLevel[V]+": "+ba);break;case n.LogLevel.Warning:this.outputConsole.warn("["+(new Date).toISOString()+"] "+n.LogLevel[V]+": "+ba);break;case n.LogLevel.Information:this.outputConsole.info("["+(new Date).toISOString()+"] "+n.LogLevel[V]+": "+ba);break;default:this.outputConsole.log("["+(new Date).toISOString()+"] "+n.LogLevel[V]+": "+ba)}};return z}()},function(a,b,c){c.r(b);c.d(b,"NullLogger",function(){return d});var d=function(){function e(){}e.prototype.log=function(f,
2460g){};e.instance=new e;return e}()},function(a,b,c){c.r(b);c.d(b,"XhrHttpClient",function(){return h});var d=c(4),e=c(5),f=c(8),g=function(){var k=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,m){l.__proto__=m}||function(l,m){for(var n in m)m.hasOwnProperty(n)&&(l[n]=m[n])};return function(l,m){function n(){this.constructor=l}k(l,m);l.prototype=null===m?Object.create(m):(n.prototype=m.prototype,new n)}}(),h=function(k){function l(m){var n=k.call(this)||this;n.logger=m;return n}
2461g(l,k);l.prototype.send=function(m){var n=this;return m.abortSignal&&m.abortSignal.aborted?Promise.reject(new d.AbortError):m.method?m.url?new Promise(function(r,t){var u=new XMLHttpRequest;u.open(m.method,m.url,!0);u.withCredentials=void 0===m.withCredentials?!0:m.withCredentials;u.setRequestHeader("X-Requested-With","XMLHttpRequest");u.setRequestHeader("Content-Type","text/plain;charset=UTF-8");var x=m.headers;
2461x&&Object.keys(x).forEach(function(B){u.setRequestHeader(B,x[B])});m.responseType&&(u.responseType=
2462m.responseType);m.abortSignal&&(m.abortSignal.onabort=function(){u.abort();t(new d.AbortError)});m.timeout&&(u.timeout=m.timeout);u.onload=function(){m.abortSignal&&(m.abortSignal.onabort=null);200<=u.status&&300>u.status?r(new e.HttpResponse(u.status,u.statusText,u.response||u.responseText)):t(new d.HttpError(u.statusText,u.status))};u.onerror=function(){n.logger.log(f.LogLevel.Warning,"Error from HTTP request. "+u.status+": "+u.statusText+".");t(new d.HttpError(u.statusText,u.status))};u.ontimeout=
2463function(){n.logger.log(f.LogLevel.Warning,"Timeout from HTTP request.");t(new d.TimeoutError)};u.send(m.content||"")}):Promise.reject(Error("No url defined.")):Promise.reject(Error("No method defined."))};return l}(e.HttpClient)},function(a,b,c){c.r(b);c.d(b,"HubConnectionState",function(){return m});c.d(b,"HubConnection",function(){return n});var d=c(13),e=c(15),f=c(8),g=c(16),h=c(9),k=function(r,t,u,x){return new (u||=Promise)(function(B,y){function A(z){try{ha(x.next(z))}catch(V){y(V)}}function aa(z){try{ha(x["throw"](z))}catch(V){y(V)}}
2464function ha(z){z.done?B(z.value):(new u(function(V){V(z.value)})).then(A,aa)}ha((x=x.apply(r,t||[])).next())})},l=function(r,t){function u(z){return function(V){return x([z,V])}}function x(z){if(y)throw new TypeError("Generator is already executing.");for(;B;)try{if(y=1,A&&(aa=z[0]&2?A["return"]:z[0]?A["throw"]||((aa=A["return"])&&aa.call(A),0):A.next)&&!(aa=aa.call(A,z[1])).done)return aa;if(A=0,aa)z=[z[0]&2,aa.value];switch(z[0]){case 0:case 1:aa=z;break;case 4:return B.label++,{value:z[1],done:!1};
2465case 5:B.label++;A=z[1];z=[0];continue;case 7:z=B.ops.pop();B.trys.pop();continue;default:if(!(aa=B.trys,aa=0<aa.length&&aa[aa.length-1])&&(6===z[0]||2===z[0])){B=0;continue}if(3===z[0]&&(!aa||z[1]>aa[0]&&z[1]<aa[3]))B.label=z[1];else if(6===z[0]&&B.label<aa[1])B.label=aa[1],aa=z;else if(aa&&B.label<aa[2])B.label=aa[2],B.ops.push(z);else{aa[2]&&B.ops.pop();B.trys.pop();continue}}z=t.call(r,B)}catch(V){z=[6,V],A=0}finally{y=aa=0}if(z[0]&5)throw z[1];return{value:z[0]?z[1]:void 0,done:!0}}var B={label:0,
2466sent:function(){if(aa[0]&1)throw aa[1];return aa[1]},trys:[],ops:[]},y,A,aa,ha;return ha={next:u(0),throw:u(1),return:u(2)},"function"===typeof Symbol&&(ha[Symbol.iterator]=function(){return this}),ha},m;(function(r){r.Disconnected="Disconnected";r.Connecting="Connecting";r.Connected="Connected";r.Disconnecting="Disconnecting";r.Reconnecting="Reconnecting"})(m||={});var n=function(){function r(t,u,x,B){var y=this;this.nextKeepAlive=0;h.Arg.isRequired(t,"connection");h.Arg.isRequired(u,"logger");h.Arg.isRequired(x,
2467"protocol");this.serverTimeoutInMilliseconds=3E4;this.keepAliveIntervalInMilliseconds=15E3;this.logger=u;this.protocol=x;this.connection=t;this.reconnectPolicy=B;this.handshakeProtocol=new d.HandshakeProtocol;this.connection.onreceive=function(A){return y.processIncomingData(A)};this.connection.onclose=function(A){return y.connectionClosed(A)};this.callbacks={};this.methods={};this.closedCallbacks=[];this.reconnectingCallbacks=[];this.reconnectedCallbacks=[];this.invocationId=0;this.receivedHandshakeResponse=
2468!1;this.connectionState=m.Disconnected;this.connectionStarted=!1;this.cachedPingMessage=this.protocol.writeMessage({type:e.MessageType.Ping})}r.create=function(t,u,x,B){return new r(t,u,x,B)};Object.defineProperty(r.prototype,"state",{get:function(){return this.connectionState},enumerable:!0,configurable:!0});Object.defineProperty(r.prototype,"connectionId",{get:function(){return this.connection?this.connection.connectionId||null:null},enumerable:!0,configurable:!0});Object.defineProperty(r.prototype,
2469"baseUrl",{get:function(){return this.connection.baseUrl||""},set:function(t){if(this.connectionState!==m.Disconnected&&this.connectionState!==m.Reconnecting)throw Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");if(!t)throw Error("The HubConnection url must be a valid url.");this.connection.baseUrl=t},enumerable:!0,configurable:!0});r.prototype.start=function(){return this.startPromise=this.startWithStateTransitions()};r.prototype.startWithStateTransitions=
2470function(){return k(this,void 0,void 0,function(){var t;return l(this,function(u){switch(u.label){case 0:if(this.connectionState!==m.Disconnected)return[2,Promise.reject(Error("Cannot start a HubConnection that is not in the 'Disconnected' state."))];this.connectionState=m.Connecting;
2470this.logger.log(f.LogLevel.Debug,"Starting HubConnection.");u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.startInternal()];case 2:return u.sent(),this.connectionState=m.Connected,this.connectionStarted=!0,this.logger.log(f.LogLevel.Debug,
2471"HubConnection connected successfully."),[3,4];case 3:return t=u.sent(),this.connectionState=m.Disconnected,this.logger.log(f.LogLevel.Debug,"HubConnection failed to start successfully because of error '"+t+"'."),[2,Promise.reject(t)];case 4:return[2]}})})};r.prototype.startInternal=function(){return k(this,void 0,void 0,function(){var t,u,x,B=this;return l(this,function(y){switch(y.label){case 0:return this.stopDuringStartError=void 0,this.receivedHandshakeResponse=!1,t=new Promise(function(A,aa){B.handshakeResolver=
2472A;B.handshakeRejecter=aa}),[4,this.connection.start(this.protocol.transferFormat)];case 1:y.sent(),y.label=2;case 2:return y.trys.push([2,5,,7]),u={protocol:this.protocol.name,version:this.protocol.version},this.logger.log(f.LogLevel.Debug,"Sending handshake request."),[4,this.sendMessage(this.handshakeProtocol.writeHandshakeRequest(u))];case 3:return y.sent(),this.logger.log(f.LogLevel.Information,"Using HubProtocol '"+this.protocol.name+"'."),this.cleanupTimeout(),this.resetTimeoutPeriod(),this.resetKeepAliveInterval(),
2473[4,t];case 4:y.sent();if(this.stopDuringStartError)throw this.stopDuringStartError;return[3,7];case 5:return x=y.sent(),this.logger.log(f.LogLevel.Debug,"Hub handshake failed with error '"+x+"' during start(). Stopping HubConnection."),this.cleanupTimeout(),this.cleanupPingTimer(),[4,this.connection.stop(x)];case 6:throw y.sent(),x;case 7:return[2]}})})};r.prototype.stop=function(){return k(this,void 0,void 0,function(){var t;return l(this,function(u){switch(u.label){case 0:return t=this.startPromise,
2474this.stopPromise=this.stopInternal(),[4,this.stopPromise];case 1:u.sent(),u.label=2;case 2:return u.trys.push([2,4,,5]),[4,t];case 3:return u.sent(),[3,5];case 4:return u.sent(),[3,5];case 5:return[2]}})})};r.prototype.stopInternal=function(t){if(this.connectionState===m.Disconnected)return this.logger.log(f.LogLevel.Debug,"Call to HubConnection.stop("+t+") ignored because it is already in the disconnected state."),Promise.resolve();if(this.connectionState===m.Disconnecting)return this.logger.log(f.LogLevel.Debug,
2475"Call to HttpConnection.stop("+t+") ignored because the connection is already in the disconnecting state."),this.stopPromise;this.connectionState=m.Disconnecting;this.logger.log(f.LogLevel.Debug,"Stopping HubConnection.");if(this.reconnectDelayHandle)return this.logger.log(f.LogLevel.Debug,"Connection stopped during reconnect delay. Done reconnecting."),clearTimeout(this.reconnectDelayHandle),this.reconnectDelayHandle=void 0,this.completeClose(),Promise.resolve();this.cleanupTimeout();this.cleanupPingTimer();
2476this.stopDuringStartError=t||Error("The connection was stopped before the hub handshake could complete.");return this.connection.stop(t)};r.prototype.stream=function(t){for(var u=this,x=[],B=1;B<arguments.length;B++)x[B-1]=arguments[B];B=this.replaceStreamingParams(x);var y=B[0],A=this.createStreamInvocation(t,x,B[1]),aa=new g.Subject;aa.cancelCallback=function(){var z=u.createCancelInvocation(A.invocationId);delete u.callbacks[A.invocationId];return ha.then(function(){return u.sendWithProtocol(z)})};
2477this.callbacks[A.invocationId]=function(z,V){V?aa.error(V):z&&(z.type===e.MessageType.Completion?z.error?aa.error(Error(z.error)):aa.complete():aa.next(z.item))};var ha=this.sendWithProtocol(A).catch(function(z){aa.error(z);delete u.callbacks[A.invocationId]});this.launchStreams(y,ha);return aa};r.prototype.sendMessage=function(t){this.resetKeepAliveInterval();return this.connection.send(t)};r.prototype.sendWithProtocol=function(t){return this.sendMessage(this.protocol.writeMessage(t))};r.prototype.send=
2478function(t){for(var u=[],x=1;x<arguments.length;x++)u[x-1]=arguments[x];var B=this.replaceStreamingParams(u);x=B[0];u=this.sendWithProtocol(this.createInvocation(t,u,!0,B[1]));this.launchStreams(x,u);return u};r.prototype.invoke=function(t){for(var u=this,x=[],B=1;B<arguments.length;B++)x[B-1]=arguments[B];B=this.replaceStreamingParams(x);var y=B[0],A=this.createInvocation(t,x,!1,B[1]);return new Promise(function(aa,ha){u.callbacks[A.invocationId]=function(V,ba){ba?ha(ba):V&&(V.type===e.MessageType.Completion?
2479V.error?ha(Error(V.error)):aa(V.result):ha(Error("Unexpected message type: "+V.type)))};var z=u.sendWithProtocol(A).catch(function(V){ha(V);delete u.callbacks[A.invocationId]});u.launchStreams(y,z)})};r.prototype.on=function(t,u){t&&u&&(t=t.toLowerCase(),this.methods[t]||(this.methods[t]=[]),-1===this.methods[t].indexOf(u)&&this.methods[t].push(u))};r.prototype.off=function(t,u){if(t){t=t.toLowerCase();var x=this.methods[t];x&&(u?(u=x.indexOf(u),-1!==u&&(x.splice(u,1),0===x.length&&delete this.methods[t])):
2480delete this.methods[t])}};r.prototype.onclose=function(t){t&&this.closedCallbacks.push(t)};r.prototype.onreconnecting=function(t){t&&this.reconnectingCallbacks.push(t)};r.prototype.onreconnected=function(t){t&&this.reconnectedCallbacks.push(t)};r.prototype.processIncomingData=function(t){this.cleanupTimeout();this.receivedHandshakeResponse||(t=this.processHandshakeResponse(t),this.receivedHandshakeResponse=!0);if(t){var u=0;for(t=this.protocol.parseMessages(t,this.logger);
2480u<t.length;u++){var x=t[u];
2481switch(x.type){case e.MessageType.Invocation:this.invokeClientMethod(x);break;case e.MessageType.StreamItem:case e.MessageType.Completion:var B=this.callbacks[x.invocationId];B&&(x.type===e.MessageType.Completion&&delete this.callbacks[x.invocationId],B(x));break;case e.MessageType.Ping:break;case e.MessageType.Close:this.logger.log(f.LogLevel.Information,"Close message received from server.");B=x.error?Error("Server returned an error on close: "+x.error):void 0;!0===x.allowReconnect?this.connection.stop(B):
2482this.stopPromise=this.stopInternal(B);break;default:this.logger.log(f.LogLevel.Warning,"Invalid message type: "+x.type+".")}}}this.resetTimeoutPeriod()};r.prototype.processHandshakeResponse=function(t){try{var u=this.handshakeProtocol.parseHandshakeResponse(t);var x=u[0];var B=u[1]}catch(y){throw t="Error parsing handshake response: "+y,this.logger.log(f.LogLevel.Error,t),t=Error(t),this.handshakeRejecter(t),t;}if(B.error)throw t="Server returned handshake error: "+B.error,this.logger.log(f.LogLevel.Error,
2483t),t=Error(t),this.handshakeRejecter(t),t;this.logger.log(f.LogLevel.Debug,"Server handshake complete.");this.handshakeResolver();return x};r.prototype.resetKeepAliveInterval=function(){this.connection.features.inherentKeepAlive||(this.nextKeepAlive=(new Date).getTime()+this.keepAliveIntervalInMilliseconds,this.cleanupPingTimer())};r.prototype.resetTimeoutPeriod=function(){var t=this;if(!this.connection.features||!this.connection.features.inherentKeepAlive)if(this.timeoutHandle=setTimeout(function(){return t.serverTimeout()},
2484this.serverTimeoutInMilliseconds),void 0===this.pingServerHandle){var u=this.nextKeepAlive-(new Date).getTime();0>u&&(u=0);this.pingServerHandle=setTimeout(function(){return k(t,void 0,void 0,function(){return l(this,function(x){switch(x.label){case 0:if(this.connectionState!==m.Connected)return[3,4];x.label=1;case 1:return x.trys.push([1,3,,4]),[4,this.sendMessage(this.cachedPingMessage)];case 2:return x.sent(),[3,4];case 3:return x.sent(),this.cleanupPingTimer(),[3,4];case 4:return[2]}})})},u)}};
2485r.prototype.serverTimeout=function(){this.connection.stop(Error("Server timeout elapsed without receiving a message from the server."))};r.prototype.invokeClientMethod=function(t){var u=this,x=this.methods[t.target.toLowerCase()];if(x){try{x.forEach(function(B){return B.apply(u,t.arguments)})}catch(B){this.logger.log(f.LogLevel.Error,"A callback for the method "+t.target.toLowerCase()+" threw error '"+B+"'.")}t.invocationId&&(this.logger.log(f.LogLevel.Error,"Server requested a response, which is not supported in this version of the client."),
2486this.stopPromise=this.stopInternal(Error("Server requested a response, which is not supported in this version of the client.")))}else this.logger.log(f.LogLevel.Warning,"No client method with the name '"+t.target+"' found.")};r.prototype.connectionClosed=function(t){this.logger.log(f.LogLevel.Debug,"HubConnection.connectionClosed("+t+") called while in state "+this.connectionState+".");this.stopDuringStartError=this.stopDuringStartError||t||Error("The underlying connection was closed before the hub handshake could complete.");
2487this.handshakeResolver&&this.handshakeResolver();this.cancelCallbacksWithError(t||Error("Invocation canceled due to the underlying connection being closed."));this.cleanupTimeout();this.cleanupPingTimer();this.connectionState===m.Disconnecting?this.completeClose(t):this.connectionState===m.Connected&&this.reconnectPolicy?this.reconnect(t):this.connectionState===m.Connected&&this.completeClose(t)};r.prototype.completeClose=function(t){var u=this;if(this.connectionStarted){this.connectionState=m.Disconnected;
2488this.connectionStarted=!1;try{this.closedCallbacks.forEach(function(x){return x.apply(u,[t])})}catch(x){this.logger.log(f.LogLevel.Error,"An onclose callback called with error '"+t+"' threw error '"+x+"'.")}}};r.prototype.reconnect=function(t){return k(this,void 0,void 0,function(){var u,x,B,y,A,aa=this;return l(this,function(ha){switch(ha.label){case 0:u=Date.now();x=0;
2488B=void 0!==t?t:Error("Attempting to reconnect due to a unknown error.");y=this.getNextRetryDelay(x++,0,B);if(null===y)return this.logger.log(f.LogLevel.Debug,
2489"Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt."),this.completeClose(t),[2];this.connectionState=m.Reconnecting;t?this.logger.log(f.LogLevel.Information,"Connection reconnecting because of error '"+t+"'."):this.logger.log(f.LogLevel.Information,"Connection reconnecting.");if(this.onreconnecting){try{this.reconnectingCallbacks.forEach(function(z){return z.apply(aa,[t])})}catch(z){this.logger.log(f.LogLevel.Error,"An onreconnecting callback called with error '"+
2490t+"' threw error '"+z+"'.")}if(this.connectionState!==m.Reconnecting)return this.logger.log(f.LogLevel.Debug,"Connection left the reconnecting state in onreconnecting callback. Done reconnecting."),[2]}ha.label=1;case 1:if(null===y)return[3,7];this.logger.log(f.LogLevel.Information,"Reconnect attempt number "+x+" will start in "+y+" ms.");return[4,new Promise(function(z){aa.reconnectDelayHandle=setTimeout(z,y)})];case 2:ha.sent();this.reconnectDelayHandle=void 0;if(this.connectionState!==m.Reconnecting)return this.logger.log(f.LogLevel.Debug,
2491"Connection left the reconnecting state during reconnect delay. Done reconnecting."),[2];ha.label=3;case 3:return ha.trys.push([3,5,,6]),[4,this.startInternal()];case 4:ha.sent();this.connectionState=m.Connected;this.logger.log(f.LogLevel.Information,"HubConnection reconnected successfully.");if(this.onreconnected)try{this.reconnectedCallbacks.forEach(function(z){return z.apply(aa,[aa.connection.connectionId])})}catch(z){this.logger.log(f.LogLevel.Error,"An onreconnected callback called with connectionId '"+
2492this.connection.connectionId+"; threw error '"+z+"'.")}return[2];case 5:A=ha.sent();this.logger.log(f.LogLevel.Information,"Reconnect attempt failed because of error '"+A+"'.");if(this.connectionState!==m.Reconnecting)return this.logger.log(f.LogLevel.Debug,"Connection moved to the '"+this.connectionState+"' from the reconnecting state during reconnect attempt. Done reconnecting."),this.connectionState===m.Disconnecting&&this.completeClose(),[2];B=A instanceof Error?A:Error(A.toString());y=this.getNextRetryDelay(x++,
2493Date.now()-u,B);return[3,6];case 6:return[3,1];case 7:return this.logger.log(f.LogLevel.Information,"Reconnect retries have been exhausted after "+(Date.now()-u)+" ms and "+x+" failed attempts. Connection disconnecting."),this.completeClose(),[2]}})})};r.prototype.getNextRetryDelay=function(t,u,x){try{return this.reconnectPolicy.nextRetryDelayInMilliseconds({elapsedMilliseconds:u,previousRetryCount:t,retryReason:x})}catch(B){return this.logger.log(f.LogLevel.Error,"IRetryPolicy.nextRetryDelayInMilliseconds("+
2494t+", "+u+") threw error '"+B+"'."),null}};r.prototype.cancelCallbacksWithError=function(t){var u=this.callbacks;this.callbacks={};Object.keys(u).forEach(function(x){(0,u[x])(null,t)})};r.prototype.cleanupPingTimer=function(){this.pingServerHandle&&(clearTimeout(this.pingServerHandle),this.pingServerHandle=void 0)};r.prototype.cleanupTimeout=function(){this.timeoutHandle&&clearTimeout(this.timeoutHandle)};r.prototype.createInvocation=function(t,u,x,B){if(x)return 0!==B.length?{arguments:u,streamIds:B,
2495target:t,type:e.MessageType.Invocation}:{arguments:u,target:t,type:e.MessageType.Invocation};x=this.invocationId;this.invocationId++;return 0!==B.length?{arguments:u,invocationId:x.toString(),streamIds:B,target:t,type:e.MessageType.Invocation}:{arguments:u,invocationId:x.toString(),target:t,type:e.MessageType.Invocation}};r.prototype.launchStreams=function(t,u){var x=this;if(0!==t.length){u||=Promise.resolve();var B=function(A){t[A].subscribe({complete:function(){u=u.then(function(){return x.sendWithProtocol(x.createCompletionMessage(A))})},
2496error:function(aa){var ha=aa instanceof Error?aa.message:aa&&aa.toString?aa.toString():"Unknown error";u=u.then(function(){return x.sendWithProtocol(x.createCompletionMessage(A,ha))})},next:function(aa){u=u.then(function(){return x.sendWithProtocol(x.createStreamItemMessage(A,aa))})}})},y;for(y in t)B(y)}};r.prototype.replaceStreamingParams=function(t){for(var u=[],x=[],B=0;B<t.length;B++){var y=t[B];if(this.isObservable(y)){var A=this.invocationId;this.invocationId++;u[A]=y;x.push(A.toString());
2497t.splice(B,1)}}return[u,x]};r.prototype.isObservable=function(t){return t&&t.subscribe&&"function"===typeof t.subscribe};r.prototype.createStreamInvocation=function(t,u,x){var B=this.invocationId;this.invocationId++;return 0!==x.length?{arguments:u,invocationId:B.toString(),streamIds:x,target:t,type:e.MessageType.StreamInvocation}:{arguments:u,invocationId:B.toString(),target:t,type:e.MessageType.StreamInvocation}};r.prototype.createCancelInvocation=function(t){return{invocationId:t,type:e.MessageType.CancelInvocation}};
2498r.prototype.createStreamItemMessage=function(t,u){return{invocationId:t,item:u,type:e.MessageType.StreamItem}};r.prototype.createCompletionMessage=function(t,u,x){return u?{error:u,invocationId:t,type:e.MessageType.Completion}:{invocationId:t,result:x,type:e.MessageType.Completion}};return r}()},function(a,b,c){c.r(b);c.d(b,"HandshakeProtocol",function(){return f});var d=c(14),e=c(9),f=function(){function g(){}g.prototype.writeHandshakeRequest=function(h){return d.TextMessageFormat.write(JSON.stringify(h))};
2499g.prototype.parseHandshakeResponse=function(h){if(Object(e.isArrayBuffer)(h)||"undefined"!==typeof Buffer&&h instanceof Buffer){h=new Uint8Array(h);var k=h.indexOf(d.TextMessageFormat.RecordSeparatorCode);if(-1===k)throw Error("Message is incomplete.");var l=k+1;k=String.fromCharCode.apply(null,h.slice(0,l));h=h.byteLength>l?h.slice(l).buffer:null}else{k=h.indexOf(d.TextMessageFormat.RecordSeparator);if(-1===k)throw Error("Message is incomplete.");l=k+1;k=h.substring(0,l);h=h.length>l?h.substring(l):
2500null}k=d.TextMessageFormat.parse(k);k=JSON.parse(k[0]);if(k.type)throw Error("Expected a handshake response from the server.");return[h,k]};return g}()},function(a,b,c){c.r(b);c.d(b,"TextMessageFormat",function(){return d});var d=function(){function e(){}e.write=function(f){return""+f+e.RecordSeparator};e.parse=function(f){if(f[f.length-1]!==e.RecordSeparator)throw Error("Message is incomplete.");f=f.split(e.RecordSeparator);f.pop();return f};e.RecordSeparatorCode=30;e.RecordSeparator=String.fromCharCode(e.RecordSeparatorCode);
2501return e}()},function(a,b,c){c.r(b);c.d(b,"MessageType",function(){return d});var d;(function(e){e[e.Invocation=1]="Invocation";e[e.StreamItem=2]="StreamItem";e[e.Completion=3]="Completion";e[e.StreamInvocation=4]="StreamInvocation";e[e.CancelInvocation=5]="CancelInvocation";e[e.Ping=6]="Ping";e[e.Close=7]="Close"})(d||={})},function(a,b,c){c.r(b);c.d(b,"Subject",function(){return e});var d=c(9),e=function(){function f(){this.observers=[]}f.prototype.next=function(g){for(var h=0,k=this.observers;h<
2502k.length;h++)k[h].next(g)};f.prototype.error=function(g){for(var h=0,k=this.observers;h<k.length;h++){var l=k[h];l.error&&l.error(g)}};f.prototype.complete=function(){for(var g=0,h=this.observers;g<h.length;g++){var k=h[g];k.complete&&k.complete()}};f.prototype.subscribe=function(g){this.observers.push(g);return new d.SubjectSubscription(this,g)};return f}()},function(a,b,c){c.r(b);c.d(b,"HubConnectionBuilder",function(){return n});var d=c(18),e=c(19),f=c(12);a=c(8);var g=c(25),h=c(10),k=c(9),l=Object.assign||
2503function(r){for(var t,u=1,x=arguments.length;u<x;u++){t=arguments[u];for(var B in t)Object.prototype.hasOwnProperty.call(t,B)&&(r[B]=t[B])}return r},m={trace:a.LogLevel.Trace,debug:a.LogLevel.Debug,info:a.LogLevel.Information,information:a.LogLevel.Information,warn:a.LogLevel.Warning,warning:a.LogLevel.Warning,error:a.LogLevel.Error,critical:a.LogLevel.Critical,none:a.LogLevel.None},n=function(){function r(){}r.prototype.configureLogging=function(t){k.Arg.isRequired(t,"logging");if(void 0!==t.log)this.logger=
2504t;else if("string"===typeof t){var u=m[t.toLowerCase()];if("undefined"===typeof u)throw Error("Unknown log level: "+t);this.logger=new k.ConsoleLogger(u)}else this.logger=new k.ConsoleLogger(t);return this};r.prototype.withUrl=function(t,u){k.Arg.isRequired(t,"url");k.Arg.isNotEmpty(t,"url");this.url=t;this.httpConnectionOptions="object"===typeof u?l({},this.httpConnectionOptions,u):l({},this.httpConnectionOptions,{transport:u});return this};r.prototype.withHubProtocol=function(t){k.Arg.isRequired(t,
2505"protocol");this.protocol=t;return this};r.prototype.withAutomaticReconnect=function(t){if(this.reconnectPolicy)throw Error("A reconnectPolicy has already been set.");t?Array.isArray(t)?this.reconnectPolicy=new d.DefaultReconnectPolicy(t):this.reconnectPolicy=t:this.reconnectPolicy=new d.DefaultReconnectPolicy;return this};r.prototype.build=function(){var t=this.httpConnectionOptions||{};void 0===t.logger&&(t.logger=this.logger);if(!this.url)throw Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");
2506t=new e.HttpConnection(this.url,t);return f.HubConnection.create(t,this.logger||h.NullLogger.instance,this.protocol||new g.JsonHubProtocol,this.reconnectPolicy)};return r}()},function(a,b,c){c.r(b);c.d(b,"DefaultReconnectPolicy",function(){return e});var d=[0,2E3,1E4,3E4,null],e=function(){function f(g){this.retryDelays=void 0!==g?g.concat([null]):d}f.prototype.nextRetryDelayInMilliseconds=function(g){return this.retryDelays[g.previousRetryCount]};return f}()},function(a,b,c){c.r(b);c.d(b,"HttpConnection",
2507function(){return t});c.d(b,"TransportSendQueue",function(){return u});
2507var d=c(6),e=c(8),f=c(20),g=c(21),h=c(23),k=c(9),l=c(24),m=Object.assign||function(B){for(var y,A=1,aa=arguments.length;A<aa;A++){y=arguments[A];for(var ha in y)Object.prototype.hasOwnProperty.call(y,ha)&&(B[ha]=y[ha])}return B},n=function(B,y,A,aa){return new (A||=Promise)(function(ha,z){function V(K){try{v(aa.next(K))}catch(C){z(C)}}function ba(K){try{v(aa["throw"](K))}catch(C){z(C)}}function v(K){K.done?ha(K.value):(new A(function(C){C(K.value)})).then(V,
2508ba)}v((aa=aa.apply(B,y||[])).next())})},r=function(B,y){function A(K){return function(C){return aa([K,C])}}function aa(K){if(z)throw new TypeError("Generator is already executing.");for(;ha;)try{if(z=1,V&&(ba=K[0]&2?V["return"]:K[0]?V["throw"]||((ba=V["return"])&&ba.call(V),0):V.next)&&!(ba=ba.call(V,K[1])).done)return ba;if(V=0,ba)K=[K[0]&2,ba.value];switch(K[0]){case 0:case 1:ba=K;break;case 4:return ha.label++,{value:K[1],done:!1};case 5:ha.label++;V=K[1];K=[0];continue;case 7:K=ha.ops.pop();ha.trys.pop();
2509continue;default:if(!(ba=ha.trys,ba=0<ba.length&&ba[ba.length-1])&&(6===K[0]||2===K[0])){ha=0;continue}if(3===K[0]&&(!ba||K[1]>ba[0]&&K[1]<ba[3]))ha.label=K[1];else if(6===K[0]&&ha.label<ba[1])ha.label=ba[1],ba=K;else if(ba&&ha.label<ba[2])ha.label=ba[2],ha.ops.push(K);else{ba[2]&&ha.ops.pop();ha.trys.pop();continue}}K=y.call(B,ha)}catch(C){K=[6,C],V=0}finally{z=ba=0}if(K[0]&5)throw K[1];return{value:K[0]?K[1]:void 0,done:!0}}var ha={label:0,sent:function(){if(ba[0]&1)throw ba[1];return ba[1]},trys:[],
2510ops:[]},z,V,ba,v;return v={next:A(0),throw:A(1),return:A(2)},"function"===typeof Symbol&&(v[Symbol.iterator]=function(){return this}),v},t=function(){function B(y,A){void 0===A&&(A={});this.stopPromiseResolver=function(){};this.features={};this.negotiateVersion=1;k.Arg.isRequired(y,"url");this.logger=Object(k.createLogger)(A.logger);this.baseUrl=this.resolveUrl(y);A=A||{};A.logMessageContent=void 0===A.logMessageContent?!1:A.logMessageContent;if("boolean"===typeof A.withCredentials||void 0===A.withCredentials)A.withCredentials=
2511void 0===A.withCredentials?!0:A.withCredentials;else throw Error("withCredentials option was not a 'boolean' or 'undefined' value");var aa=y=null;k.Platform.isNode&&(aa=require,y=aa("ws"),aa=aa("eventsource"));k.Platform.isNode||"undefined"===typeof WebSocket||A.WebSocket?k.Platform.isNode&&!A.WebSocket&&y&&(A.WebSocket=y):A.WebSocket=WebSocket;k.Platform.isNode||"undefined"===typeof EventSource||A.EventSource?k.Platform.isNode&&!A.EventSource&&"undefined"!==typeof aa&&(A.EventSource=aa):A.EventSource=
2512EventSource;this.httpClient=A.httpClient||new d.DefaultHttpClient(this.logger);this.connectionState="Disconnected";this.connectionStarted=!1;this.options=A;this.onclose=this.onreceive=null}B.prototype.start=function(y){return n(this,void 0,void 0,function(){var A;return r(this,function(aa){switch(aa.label){case 0:y=y||f.TransferFormat.Binary;k.Arg.isIn(y,f.TransferFormat,"transferFormat");this.logger.log(e.LogLevel.Debug,"Starting connection with transfer format '"+f.TransferFormat[y]+"'.");if("Disconnected"!==
2513this.connectionState)return[2,Promise.reject(Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."))];this.connectionState="Connecting";this.startInternalPromise=this.startInternal(y);return[4,this.startInternalPromise];case 1:aa.sent();if("Disconnecting"!==this.connectionState)return[3,3];A="Failed to start the HttpConnection before stop() was called.";this.logger.log(e.LogLevel.Error,A);return[4,this.stopPromise];case 2:return aa.sent(),[2,Promise.reject(Error(A))];case 3:if("Connected"!==
2514this.connectionState)return A="HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!",this.logger.log(e.LogLevel.Error,A),[2,Promise.reject(Error(A))];aa.label=4;case 4:return this.connectionStarted=!0,[2]}})})};B.prototype.send=function(y){if("Connected"!==this.connectionState)return Promise.reject(Error("Cannot send data if the connection is not in the 'Connected' State."));this.sendQueue||(this.sendQueue=new u(this.transport));return this.sendQueue.send(y)};
2515B.prototype.stop=function(y){return n(this,void 0,void 0,function(){var A=this;return r(this,function(aa){switch(aa.label){case 0:if("Disconnected"===this.connectionState)return this.logger.log(e.LogLevel.Debug,"Call to HttpConnection.stop("+y+") ignored because the connection is already in the disconnected state."),[2,Promise.resolve()];if("Disconnecting"===this.connectionState)return this.logger.log(e.LogLevel.Debug,"Call to HttpConnection.stop("+y+") ignored because the connection is already in the disconnecting state."),
2516[2,this.stopPromise];this.connectionState="Disconnecting";this.stopPromise=new Promise(function(ha){A.stopPromiseResolver=ha});return[4,this.stopInternal(y)];case 1:return aa.sent(),[4,this.stopPromise];case 2:return aa.sent(),[2]}})})};B.prototype.stopInternal=function(y){return n(this,void 0,void 0,function(){var A;return r(this,function(aa){switch(aa.label){case 0:this.stopError=y,aa.label=1;case 1:return aa.trys.push([1,3,,4]),[4,this.startInternalPromise];case 2:return aa.sent(),[3,4];case 3:return aa.sent(),
2517[3,4];case 4:if(!this.transport)return[3,9];aa.label=5;case 5:return aa.trys.push([5,7,,8]),[4,this.transport.stop()];case 6:return aa.sent(),[3,8];case 7:return A=aa.sent(),this.logger.log(e.LogLevel.Error,"HttpConnection.transport.stop() threw error '"+A+"'."),this.stopConnection(),[3,8];case 8:return this.transport=void 0,[3,10];case 9:this.logger.log(e.LogLevel.Debug,"HttpConnection.transport is undefined in HttpConnection.stop() because start() failed."),aa.label=10;case 10:return[2]}})})};B.prototype.startInternal=
2518function(y){return n(this,void 0,void 0,function(){var A,aa,ha,z,V,ba;return r(this,function(v){switch(v.label){case 0:A=this.baseUrl,this.accessTokenFactory=this.options.accessTokenFactory,v.label=1;case 1:v.trys.push([1,12,,13]);if(!this.options.skipNegotiation)return[3,5];if(this.options.transport!==f.HttpTransportType.WebSockets)return[3,3];
2518this.transport=this.constructTransport(f.HttpTransportType.WebSockets);return[4,this.startTransport(A,y)];case 2:return v.sent(),[3,4];case 3:throw Error("Negotiation can only be skipped when using the WebSocket transport directly.");
2519case 4:return[3,11];case 5:aa=null,ha=0,z=function(){var K;return r(this,function(C){switch(C.label){case 0:return[4,V.getNegotiationResponse(A)];case 1:aa=C.sent();if("Disconnecting"===V.connectionState||"Disconnected"===V.connectionState)throw Error("The connection was stopped during negotiation.");if(aa.error)throw Error(aa.error);if(aa.ProtocolVersion)throw Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");
2520aa.url&&(A=aa.url);aa.accessToken&&(K=aa.accessToken,V.accessTokenFactory=function(){return K});ha++;return[2]}})},V=this,v.label=6;case 6:return[5,z()];case 7:v.sent(),v.label=8;case 8:if(aa.url&&100>ha)return[3,6];v.label=9;case 9:if(100===ha&&aa.url)throw Error("Negotiate redirection limit exceeded.");return[4,this.createTransport(A,this.options.transport,aa,y)];case 10:v.sent(),v.label=11;case 11:return this.transport instanceof g.LongPollingTransport&&(this.features.inherentKeepAlive=!0),"Connecting"===
2521this.connectionState&&(this.logger.log(e.LogLevel.Debug,"The HttpConnection connected successfully."),this.connectionState="Connected"),[3,13];case 12:return ba=v.sent(),this.logger.log(e.LogLevel.Error,"Failed to start the connection: "+ba),this.connectionState="Disconnected",this.transport=void 0,this.stopPromiseResolver(),[2,Promise.reject(ba)];case 13:return[2]}})})};B.prototype.getNegotiationResponse=function(y){return n(this,void 0,void 0,function(){var A,aa,ha,z,V,ba,v,K,C;return r(this,function(da){switch(da.label){case 0:return A=
2522{},this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:(aa=da.sent())&&(A.Authorization="Bearer "+aa),da.label=2;case 2:ha=Object(k.getUserAgentHeader)(),z=ha[0],V=ha[1],A[z]=V,ba=this.resolveNegotiateUrl(y),this.logger.log(e.LogLevel.Debug,"Sending negotiation request: "+ba+"."),da.label=3;case 3:return da.trys.push([3,5,,6]),[4,this.httpClient.post(ba,{content:"",headers:m({},A,this.options.headers),withCredentials:this.options.withCredentials})];case 4:v=da.sent();if(200!==v.statusCode)return[2,
2523Promise.reject(Error("Unexpected status code returned from negotiate '"+v.statusCode+"'"))];K=JSON.parse(v.content);if(!K.negotiateVersion||1>K.negotiateVersion)K.connectionToken=K.connectionId;return[2,K];case 5:return C=da.sent(),this.logger.log(e.LogLevel.Error,"Failed to complete negotiation with the server: "+C),[2,Promise.reject(C)];case 6:return[2]}})})};B.prototype.createConnectUrl=function(y,A){return A?y+(-1===y.indexOf("?")?"?":"&")+("id="+A):y};B.prototype.createTransport=function(y,A,
2524aa,ha){return n(this,void 0,void 0,function(){var z,V,ba,v,K,C,da,ja,ea,ra;return r(this,function(za){switch(za.label){case 0:z=this.createConnectUrl(y,aa.connectionToken);if(!this.isITransport(A))return[3,2];this.logger.log(e.LogLevel.Debug,"Connection was provided an instance of ITransport, using that directly.");this.transport=A;return[4,this.startTransport(z,ha)];case 1:return za.sent(),this.connectionId=aa.connectionId,[2];case 2:V=[],ba=aa.availableTransports||[],v=aa,K=0,C=ba,za.label=3;case 3:if(!(K<
2525C.length))return[3,13];da=C[K];ja=this.resolveTransportOrError(da,A,ha);if(!(ja instanceof Error))return[3,4];V.push(da.transport+" failed: "+ja);return[3,12];case 4:if(!this.isITransport(ja))return[3,12];this.transport=ja;if(v)return[3,9];za.label=5;case 5:return za.trys.push([5,7,,8]),[4,this.getNegotiationResponse(y)];case 6:return v=za.sent(),[3,8];case 7:return ea=za.sent(),[2,Promise.reject(ea)];case 8:z=this.createConnectUrl(y,v.connectionToken),za.label=9;case 9:return za.trys.push([9,11,
2526,12]),[4,this.startTransport(z,ha)];case 10:return za.sent(),this.connectionId=v.connectionId,[2];case 11:return ra=za.sent(),this.logger.log(e.LogLevel.Error,"Failed to start the transport '"+da.transport+"': "+ra),v=void 0,V.push(da.transport+" failed: "+ra),"Connecting"!==this.connectionState?(this.logger.log(e.LogLevel.Debug,"Failed to select transport before stop() was called."),[2,Promise.reject(Error("Failed to select transport before stop() was called."))]):[3,12];case 12:return K++,[3,3];
2527case 13:return 0<V.length?[2,Promise.reject(Error("Unable to connect to the server with any of the available transports. "+V.join(" ")))]:[2,Promise.reject(Error("None of the transports supported by the client are supported by the server."))]}})})};
2527B.prototype.constructTransport=function(y){switch(y){case f.HttpTransportType.WebSockets:if(!this.options.WebSocket)throw Error("'WebSocket' is not supported in your environment.");return new l.WebSocketTransport(this.httpClient,this.accessTokenFactory,
2528this.logger,this.options.logMessageContent||!1,this.options.WebSocket,this.options.headers||{});case f.HttpTransportType.ServerSentEvents:if(!this.options.EventSource)throw Error("'EventSource' is not supported in your environment.");return new h.ServerSentEventsTransport(this.httpClient,this.accessTokenFactory,this.logger,this.options.logMessageContent||!1,this.options.EventSource,this.options.withCredentials,this.options.headers||{});case f.HttpTransportType.LongPolling:return new g.LongPollingTransport(this.httpClient,
2529this.accessTokenFactory,this.logger,this.options.logMessageContent||!1,this.options.withCredentials,this.options.headers||{});default:throw Error("Unknown transport: "+y+".");}};B.prototype.startTransport=function(y,A){var aa=this;this.transport.onreceive=this.onreceive;this.transport.onclose=function(ha){return aa.stopConnection(ha)};return this.transport.connect(y,A)};B.prototype.resolveTransportOrError=function(y,A,aa){var ha=f.HttpTransportType[y.transport];if(null===ha||void 0===ha)return this.logger.log(e.LogLevel.Debug,
2530"Skipping transport '"+y.transport+"' because it is not supported by this client."),Error("Skipping transport '"+y.transport+"' because it is not supported by this client.");if(A&&0===(ha&A))return this.logger.log(e.LogLevel.Debug,"Skipping transport '"+f.HttpTransportType[ha]+"' because it was disabled by the client."),Error("'"+f.HttpTransportType[ha]+"' is disabled by the client.");if(0<=y.transferFormats.map(function(z){return f.TransferFormat[z]}).indexOf(aa)){if(ha===f.HttpTransportType.WebSockets&&
2531!this.options.WebSocket||ha===f.HttpTransportType.ServerSentEvents&&!this.options.EventSource)return this.logger.log(e.LogLevel.Debug,"Skipping transport '"+f.HttpTransportType[ha]+"' because it is not supported in your environment.'"),Error("'"+f.HttpTransportType[ha]+"' is not supported in your environment.");this.logger.log(e.LogLevel.Debug,"Selecting transport '"+f.HttpTransportType[ha]+"'.");try{return this.constructTransport(ha)}catch(z){return z}}else return this.logger.log(e.LogLevel.Debug,
2532"Skipping transport '"+f.HttpTransportType[ha]+"' because it does not support the requested transfer format '"+f.TransferFormat[aa]+"'."),Error("'"+f.HttpTransportType[ha]+"' does not support "+f.TransferFormat[aa]+".")};B.prototype.isITransport=function(y){return y&&"object"===typeof y&&"connect"in y};B.prototype.stopConnection=function(y){var A=this;this.logger.log(e.LogLevel.Debug,"HttpConnection.stopConnection("+y+") called while in state "+this.connectionState+".");this.transport=void 0;y=this.stopError||
2533y;this.stopError=void 0;if("Disconnected"===this.connectionState)this.logger.log(e.LogLevel.Debug,"Call to HttpConnection.stopConnection("+y+") was ignored because the connection is already in the disconnected state.");else{if("Connecting"===this.connectionState)throw this.logger.log(e.LogLevel.Warning,"Call to HttpConnection.stopConnection("+y+") was ignored because the connection is still in the connecting state."),Error("HttpConnection.stopConnection("+y+") was called while the connection is still in the connecting state.");
2534"Disconnecting"===this.connectionState&&this.stopPromiseResolver();y?this.logger.log(e.LogLevel.Error,"Connection disconnected with error '"+y+"'."):this.logger.log(e.LogLevel.Information,"Connection disconnected.");this.sendQueue&&(this.sendQueue.stop().catch(function(aa){A.logger.log(e.LogLevel.Error,"TransportSendQueue.stop() threw error '"+aa+"'.")}),this.sendQueue=void 0);this.connectionId=void 0;this.connectionState="Disconnected";if(this.connectionStarted){this.connectionStarted=!1;try{if(this.onclose)this.onclose(y)}catch(aa){this.logger.log(e.LogLevel.Error,
2535"HttpConnection.onclose("+y+") threw error '"+aa+"'.")}}}};B.prototype.resolveUrl=function(y){if(0===y.lastIndexOf("https://",0)||0===y.lastIndexOf("http://",0))return y;if(!k.Platform.isBrowser||!window.document)throw Error("Cannot resolve '"+y+"'.");var A=window.document.createElement("a");A.href=y;this.logger.log(e.LogLevel.Information,"Normalizing '"+y+"' to '"+A.href+"'.");return A.href};B.prototype.resolveNegotiateUrl=function(y){var A=y.indexOf("?"),aa=y.substring(0,-1===A?y.length:A);"/"!==
2536aa[aa.length-1]&&(aa+="/");aa=aa+"negotiate"+(-1===A?"":y.substring(A));-1===aa.indexOf("negotiateVersion")&&(aa=aa+(-1===A?"?":"&")+("negotiateVersion="+this.negotiateVersion));return aa};return B}(),u=function(){function B(y){this.transport=y;this.buffer=[];this.executing=!0;this.sendBufferedData=new x;this.transportResult=new x;this.sendLoopPromise=this.sendLoop()}B.prototype.send=function(y){this.bufferData(y);this.transportResult||(this.transportResult=new x);return this.transportResult.promise};
2537B.prototype.stop=function(){this.executing=!1;this.sendBufferedData.resolve();return this.sendLoopPromise};B.prototype.bufferData=function(y){if(this.buffer.length&&typeof this.buffer[0]!==typeof y)throw Error("Expected data to be of type "+typeof this.buffer+" but was of type "+typeof y);this.buffer.push(y);this.sendBufferedData.resolve()};B.prototype.sendLoop=function(){return n(this,void 0,void 0,function(){var y,A,aa;return r(this,function(ha){switch(ha.label){case 0:return[4,this.sendBufferedData.promise];
2538case 1:ha.sent();if(!this.executing)return this.transportResult&&this.transportResult.reject("Connection stopped."),[3,6];this.sendBufferedData=new x;y=this.transportResult;this.transportResult=void 0;A="string"===typeof this.buffer[0]?this.buffer.join(""):B.concatBuffers(this.buffer);this.buffer.length=0;ha.label=2;case 2:return ha.trys.push([2,4,,5]),[4,this.transport.send(A)];case 3:return ha.sent(),y.resolve(),[3,5];case 4:return aa=ha.sent(),y.reject(aa),[3,5];case 5:return[3,0];case 6:return[2]}})})};
2539B.concatBuffers=function(y){var A=y.map(function(V){return V.byteLength}).reduce(function(V,ba){return V+ba});
2539A=new Uint8Array(A);for(var aa=0,ha=0;ha<y.length;ha++){var z=y[ha];A.set(new Uint8Array(z),aa);aa+=z.byteLength}return A.buffer};return B}(),x=function(){function B(){var y=this;this.promise=new Promise(function(A,aa){var ha;return ha=[A,aa],y.resolver=ha[0],y.rejecter=ha[1],ha})}B.prototype.resolve=function(){this.resolver()};B.prototype.reject=function(y){this.rejecter(y)};return B}()},
2540function(a,b,c){c.r(b);c.d(b,"HttpTransportType",function(){return d});c.d(b,"TransferFormat",function(){return e});var d;(function(f){f[f.None=0]="None";f[f.WebSockets=1]="WebSockets";f[f.ServerSentEvents=2]="ServerSentEvents";f[f.LongPolling=4]="LongPolling"})(d||={});var e;(function(f){f[f.Text=1]="Text";f[f.Binary=2]="Binary"})(e||={})},function(a,b,c){c.r(b);c.d(b,"LongPollingTransport",function(){return n});var d=c(22),e=c(4),f=c(8),g=c(20),h=c(9),k=Object.assign||function(r){for(var t,u=1,
2541x=arguments.length;u<x;u++){t=arguments[u];for(var B in t)Object.prototype.hasOwnProperty.call(t,B)&&(r[B]=t[B])}return r},l=function(r,t,u,x){return new (u||=Promise)(function(B,y){function A(z){try{ha(x.next(z))}catch(V){y(V)}}function aa(z){try{ha(x["throw"](z))}catch(V){y(V)}}function ha(z){z.done?B(z.value):(new u(function(V){V(z.value)})).then(A,aa)}ha((x=x.apply(r,t||[])).next())})},m=function(r,t){function u(z){return function(V){return x([z,V])}}function x(z){if(y)throw new TypeError("Generator is already executing.");
2542for(;B;)try{if(y=1,A&&(aa=z[0]&2?A["return"]:z[0]?A["throw"]||((aa=A["return"])&&aa.call(A),0):A.next)&&!(aa=aa.call(A,z[1])).done)return aa;if(A=0,aa)z=[z[0]&2,aa.value];switch(z[0]){case 0:case 1:aa=z;break;case 4:return B.label++,{value:z[1],done:!1};case 5:B.label++;A=z[1];z=[0];continue;case 7:z=B.ops.pop();B.trys.pop();continue;default:if(!(aa=B.trys,aa=0<aa.length&&aa[aa.length-1])&&(6===z[0]||2===z[0])){B=0;continue}if(3===z[0]&&(!aa||z[1]>aa[0]&&z[1]<aa[3]))B.label=z[1];else if(6===z[0]&&
2543B.label<aa[1])B.label=aa[1],aa=z;else if(aa&&B.label<aa[2])B.label=aa[2],B.ops.push(z);else{aa[2]&&B.ops.pop();B.trys.pop();continue}}z=t.call(r,B)}catch(V){z=[6,V],A=0}finally{y=aa=0}if(z[0]&5)throw z[1];return{value:z[0]?z[1]:void 0,done:!0}}var B={label:0,sent:function(){if(aa[0]&1)throw aa[1];return aa[1]},trys:[],ops:[]},y,A,aa,ha;return ha={next:u(0),throw:u(1),return:u(2)},"function"===typeof Symbol&&(ha[Symbol.iterator]=function(){return this}),ha},n=function(){function r(t,u,x,B,y,A){this.httpClient=
2544t;this.accessTokenFactory=u;this.logger=x;this.pollAbort=new d.AbortController;this.logMessageContent=B;this.withCredentials=y;this.headers=A;this.running=!1;this.onclose=this.onreceive=null}Object.defineProperty(r.prototype,"pollAborted",{get:function(){return this.pollAbort.aborted},enumerable:!0,configurable:!0});r.prototype.connect=function(t,u){return l(this,void 0,void 0,function(){var x,B,y,A,aa,ha,z,V,ba;return m(this,function(v){switch(v.label){case 0:h.Arg.isRequired(t,"url");h.Arg.isRequired(u,
2545"transferFormat");h.Arg.isIn(u,g.TransferFormat,"transferFormat");this.url=t;this.logger.log(f.LogLevel.Trace,"(LongPolling transport) Connecting.");if(u===g.TransferFormat.Binary&&"undefined"!==typeof XMLHttpRequest&&"string"!==typeof(new XMLHttpRequest).responseType)throw Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");B=Object(h.getUserAgentHeader)();y=B[0];A=B[1];aa=k((x={},x[y]=A,x),this.headers);ha={abortSignal:this.pollAbort.signal,headers:aa,
2546timeout:1E5,withCredentials:this.withCredentials};u===g.TransferFormat.Binary&&(ha.responseType="arraybuffer");return[4,this.getAccessToken()];case 1:return z=v.sent(),this.updateHeaderToken(ha,z),V=t+"&_="+Date.now(),this.logger.log(f.LogLevel.Trace,"(LongPolling transport) polling: "+V+"."),[4,this.httpClient.get(V,ha)];case 2:return ba=v.sent(),200!==ba.statusCode?(this.logger.log(f.LogLevel.Error,"(LongPolling transport) Unexpected response code: "+ba.statusCode+"."),this.closeError=new e.HttpError(ba.statusText||
2547"",ba.statusCode),this.running=!1):this.running=!0,this.receiving=this.poll(this.url,ha),[2]}})})};r.prototype.getAccessToken=function(){return l(this,void 0,void 0,function(){return m(this,function(t){switch(t.label){case 0:return this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:return[2,t.sent()];case 2:return[2,null]}})})};r.prototype.updateHeaderToken=function(t,u){t.headers||(t.headers={});u?t.headers.Authorization="Bearer "+u:t.headers.Authorization&&delete t.headers.Authorization};
2548r.prototype.poll=function(t,u){return l(this,void 0,void 0,function(){var x,B,y,A;return m(this,function(aa){switch(aa.label){case 0:aa.trys.push([0,,8,9]),aa.label=1;case 1:return this.running?[4,this.getAccessToken()]:[3,7];case 2:x=aa.sent(),this.updateHeaderToken(u,x),aa.label=3;case 3:return aa.trys.push([3,5,,6]),B=t+"&_="+Date.now(),this.logger.log(f.
2548LogLevel.Trace,"(LongPolling transport) polling: "+B+"."),[4,this.httpClient.get(B,u)];case 4:y=aa.sent();if(204===y.statusCode)this.logger.log(f.LogLevel.Information,
2549"(LongPolling transport) Poll terminated by server."),this.running=!1;else if(200!==y.statusCode)this.logger.log(f.LogLevel.Error,"(LongPolling transport) Unexpected response code: "+y.statusCode+"."),this.closeError=new e.HttpError(y.statusText||"",y.statusCode),this.running=!1;else if(y.content){if(this.logger.log(f.LogLevel.Trace,"(LongPolling transport) data received. "+Object(h.getDataDetail)(y.content,this.logMessageContent)+"."),this.onreceive)this.onreceive(y.content)}else this.logger.log(f.LogLevel.Trace,
2550"(LongPolling transport) Poll timed out, reissuing.");return[3,6];case 5:return A=aa.sent(),this.running?A instanceof e.TimeoutError?this.logger.log(f.LogLevel.Trace,"(LongPolling transport) Poll timed out, reissuing."):(this.closeError=A,this.running=!1):this.logger.log(f.LogLevel.Trace,"(LongPolling transport) Poll errored after shutdown: "+A.message),[3,6];case 6:return[3,1];case 7:return[3,9];case 8:return this.logger.log(f.LogLevel.Trace,"(LongPolling transport) Polling complete."),this.pollAborted||
2551this.raiseOnClose(),[7];case 9:return[2]}})})};r.prototype.send=function(t){return l(this,void 0,void 0,function(){return m(this,function(u){return this.running?[2,Object(h.sendMessage)(this.logger,"LongPolling",this.httpClient,this.url,this.accessTokenFactory,t,this.logMessageContent,this.withCredentials,this.headers)]:[2,Promise.reject(Error("Cannot send until the transport is connected"))]})})};r.prototype.stop=function(){return l(this,void 0,void 0,function(){var t,u,x,B,y,A;return m(this,function(aa){switch(aa.label){case 0:this.logger.log(f.LogLevel.Trace,
2552"(LongPolling transport) Stopping polling."),this.running=!1,this.pollAbort.abort(),aa.label=1;case 1:return aa.trys.push([1,,5,6]),[4,this.receiving];case 2:return aa.sent(),this.logger.log(f.LogLevel.Trace,"(LongPolling transport) sending DELETE request to "+this.url+"."),t={},u=Object(h.getUserAgentHeader)(),x=u[0],B=u[1],t[x]=B,y={headers:k({},t,this.headers),withCredentials:this.withCredentials},[4,this.getAccessToken()];case 3:return A=aa.sent(),this.updateHeaderToken(y,A),[4,this.httpClient.delete(this.url,
2553y)];case 4:return aa.sent(),this.logger.log(f.LogLevel.Trace,"(LongPolling transport) DELETE request sent."),[3,6];case 5:return this.logger.log(f.LogLevel.Trace,"(LongPolling transport) Stop finished."),this.raiseOnClose(),[7];case 6:return[2]}})})};r.prototype.raiseOnClose=function(){if(this.onclose){var t="(LongPolling transport) Firing onclose event.";this.closeError&&(t+=" Error: "+this.closeError);this.logger.log(f.LogLevel.Trace,t);this.onclose(this.closeError)}};return r}()},function(a,b,
2554c){c.r(b);c.d(b,"AbortController",function(){return d});var d=function(){function e(){this.isAborted=!1;this.onabort=null}e.prototype.abort=function(){if(!this.isAborted&&(this.isAborted=!0,this.onabort))this.onabort()};Object.defineProperty(e.prototype,"signal",{get:function(){return this},enumerable:!0,configurable:!0});Object.defineProperty(e.prototype,"aborted",{get:function(){return this.isAborted},enumerable:!0,configurable:!0});return e}()},function(a,b,c){c.r(b);c.d(b,"ServerSentEventsTransport",
2555function(){return l});var d=c(8),e=c(20),f=c(9),g=Object.assign||function(m){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var u in n)Object.prototype.hasOwnProperty.call(n,u)&&(m[u]=n[u])}return m},h=function(m,n,r,t){return new (r||=Promise)(function(u,x){function B(aa){try{A(t.next(aa))}catch(ha){x(ha)}}function y(aa){try{A(t["throw"](aa))}catch(ha){x(ha)}}function A(aa){aa.done?u(aa.value):(new r(function(ha){ha(aa.value)})).then(B,y)}A((t=t.apply(m,n||[])).next())})},k=function(m,
2556n){function r(aa){return function(ha){return t([aa,ha])}}function t(aa){if(x)throw new TypeError("Generator is already executing.");for(;u;)try{if(x=1,B&&(y=aa[0]&2?B["return"]:aa[0]?B["throw"]||((y=B["return"])&&y.call(B),0):B.next)&&!(y=y.call(B,aa[1])).done)return y;if(B=0,y)aa=[aa[0]&2,y.value];switch(aa[0]){case 0:case 1:y=aa;break;case 4:return u.label++,{value:aa[1],done:!1};case 5:u.label++;B=aa[1];aa=[0];continue;case 7:aa=u.ops.pop();u.trys.pop();continue;default:if(!(y=u.trys,y=0<y.length&&
2557y[y.length-1])&&(6===aa[0]||2===aa[0])){u=0;continue}if(3===aa[0]&&(!y||aa[1]>y[0]&&aa[1]<y[3]))u.label=aa[1];else if(6===aa[0]&&u.label<y[1])u.label=y[1],y=aa;
2557else if(y&&u.label<y[2])u.label=y[2],u.ops.push(aa);else{y[2]&&u.ops.pop();u.trys.pop();continue}}aa=n.call(m,u)}catch(ha){aa=[6,ha],B=0}finally{x=y=0}if(aa[0]&5)throw aa[1];return{value:aa[0]?aa[1]:void 0,done:!0}}var u={label:0,sent:function(){if(y[0]&1)throw y[1];return y[1]},trys:[],ops:[]},x,B,y,A;return A={next:r(0),throw:r(1),return:r(2)},
2558"function"===typeof Symbol&&(A[Symbol.iterator]=function(){return this}),A},l=function(){function m(n,r,t,u,x,B,y){this.httpClient=n;this.accessTokenFactory=r;this.logger=t;this.logMessageContent=u;this.withCredentials=B;this.eventSourceConstructor=x;this.headers=y;this.onclose=this.onreceive=null}m.prototype.connect=function(n,r){return h(this,void 0,void 0,function(){var t,u=this;return k(this,function(x){switch(x.label){case 0:return f.Arg.isRequired(n,"url"),f.Arg.isRequired(r,"transferFormat"),
2559f.Arg.isIn(r,e.TransferFormat,"transferFormat"),this.logger.log(d.LogLevel.Trace,"(SSE transport) Connecting."),this.url=n,this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:(t=x.sent())&&(n+=(0>n.indexOf("?")?"?":"&")+("access_token="+encodeURIComponent(t))),x.label=2;case 2:return[2,new Promise(function(B,y){var A=!1;if(r!==e.TransferFormat.Text)y(Error("The Server-Sent Events transport only supports the 'Text' transfer format"));else{if(f.Platform.isBrowser||f.Platform.isWebWorker)var aa=
2560new u.eventSourceConstructor(n,{withCredentials:u.withCredentials});else{var ha=u.httpClient.getCookieString(n),z={};z.Cookie=ha;ha=Object(f.getUserAgentHeader)();z[ha[0]]=ha[1];aa=new u.eventSourceConstructor(n,{withCredentials:u.withCredentials,headers:g({},z,u.headers)})}try{aa.onmessage=function(V){if(u.onreceive)try{u.logger.log(d.LogLevel.Trace,"(SSE transport) data received. "+Object(f.getDataDetail)(V.data,u.logMessageContent)+"."),u.onreceive(V.data)}catch(ba){u.close(ba)}},aa.onerror=function(V){V=
2561Error(V.data||"Error occurred");A?u.close(V):y(V)},aa.onopen=function(){u.logger.log(d.LogLevel.Information,"SSE connected to "+u.url);u.eventSource=aa;A=!0;B()}}catch(V){y(V)}}})]}})})};m.prototype.send=function(n){return h(this,void 0,void 0,function(){return k(this,function(r){return this.eventSource?[2,Object(f.sendMessage)(this.logger,"SSE",this.httpClient,this.url,this.accessTokenFactory,n,this.logMessageContent,this.withCredentials,this.headers)]:[2,Promise.reject(Error("Cannot send until the transport is connected"))]})})};
2562m.prototype.stop=function(){this.close();return Promise.resolve()};m.prototype.close=function(n){if(this.eventSource&&(this.eventSource.close(),this.eventSource=void 0,this.onclose))this.onclose(n)};return m}()},function(a,b,c){c.r(b);c.d(b,"WebSocketTransport",function(){return l});var d=c(8),e=c(20),f=c(9),g=Object.assign||function(m){for(var n,r=1,t=arguments.length;r<t;r++){n=arguments[r];for(var u in n)Object.prototype.hasOwnProperty.call(n,u)&&(m[u]=n[u])}return m},h=function(m,n,r,t){return new (r||=
2563Promise)(function(u,x){function B(aa){try{A(t.next(aa))}catch(ha){x(ha)}}function y(aa){try{A(t["throw"](aa))}catch(ha){x(ha)}}function A(aa){aa.done?u(aa.value):(new r(function(ha){ha(aa.value)})).then(B,y)}A((t=t.apply(m,n||[])).next())})},k=function(m,n){function r(aa){return function(ha){return t([aa,ha])}}function t(aa){if(x)throw new TypeError("Generator is already executing.");for(;u;)try{if(x=1,B&&(y=aa[0]&2?B["return"]:aa[0]?B["throw"]||((y=B["return"])&&y.call(B),0):B.next)&&!(y=y.call(B,
2564aa[1])).done)return y;if(B=0,y)aa=[aa[0]&2,y.value];switch(aa[0]){case 0:case 1:y=aa;break;case 4:return u.label++,{value:aa[1],done:!1};case 5:u.label++;B=aa[1];aa=[0];continue;case 7:aa=u.ops.pop();u.trys.pop();continue;default:if(!(y=u.trys,y=0<y.length&&y[y.length-1])&&(6===aa[0]||2===aa[0])){u=0;continue}if(3===aa[0]&&(!y||aa[1]>y[0]&&aa[1]<y[3]))u.label=aa[1];else if(6===aa[0]&&u.label<y[1])u.label=y[1],y=aa;
2564else if(y&&u.label<y[2])u.label=y[2],u.ops.push(aa);else{y[2]&&u.ops.pop();u.trys.pop();
2565continue}}aa=n.call(m,u)}catch(ha){aa=[6,ha],B=0}finally{x=y=0}if(aa[0]&5)throw aa[1];return{value:aa[0]?aa[1]:void 0,done:!0}}var u={label:0,sent:function(){if(y[0]&1)throw y[1];return y[1]},trys:[],ops:[]},x,B,y,A;return A={next:r(0),throw:r(1),return:r(2)},"function"===typeof Symbol&&(A[Symbol.iterator]=function(){return this}),A},l=function(){function m(n,r,t,u,x,B){this.logger=t;this.accessTokenFactory=r;this.logMessageContent=u;this.webSocketConstructor=x;this.httpClient=n;this.onclose=this.onreceive=
2566null;this.headers=B}m.prototype.connect=function(n,r){return h(this,void 0,void 0,function(){var t,u=this;return k(this,function(x){switch(x.label){case 0:return f.Arg.isRequired(n,"url"),f.Arg.isRequired(r,"transferFormat"),f.Arg.isIn(r,e.TransferFormat,"transferFormat"),this.logger.log(d.LogLevel.Trace,"(WebSockets transport) Connecting."),this.accessTokenFactory?[4,this.accessTokenFactory()]:[3,2];case 1:(t=x.sent())&&(n+=(0>n.indexOf("?")?"?":"&")+("access_token="+encodeURIComponent(t))),x.label=
25672;case 2:return[2,new Promise(function(B,y){n=n.replace(/^http/,"ws");var A=u.httpClient.getCookieString(n),aa=!1;if(f.Platform.isNode){var ha={},z=Object(f.getUserAgentHeader)();ha[z[0]]=z[1];A&&(ha.Cookie=""+A);var V=new u.webSocketConstructor(n,void 0,{headers:g({},ha,u.headers)})}V||=new u.webSocketConstructor(n);r===e.TransferFormat.Binary&&(V.binaryType="arraybuffer");V.onopen=function(ba){u.logger.log(d.LogLevel.Information,"WebSocket connected to "+n+".");u.webSocket=V;aa=!0;B()};V.onerror=
2568function(ba){y("undefined"!==typeof ErrorEvent&&ba instanceof ErrorEvent?ba.error:Error("There was an error with the transport."))};V.onmessage=function(ba){u.logger.log(d.LogLevel.Trace,"(WebSockets transport) data received. "+Object(f.getDataDetail)(ba.data,u.logMessageContent)+".");if(u.onreceive)try{u.onreceive(ba.data)}catch(v){u.close(v)}};
2568V.onclose=function(ba){aa?u.close(ba):y("undefined"!==typeof ErrorEvent&&ba instanceof ErrorEvent?ba.error:Error("There was an error with the transport."))}})]}})})};
2569m.prototype.send=function(n){return this.webSocket&&this.webSocket.readyState===this.webSocketConstructor.OPEN?(this.logger.log(d.LogLevel.Trace,"(WebSockets transport) sending data. "+Object(f.getDataDetail)(n,this.logMessageContent)+"."),this.webSocket.send(n),Promise.resolve()):Promise.reject("WebSocket is not in the OPEN state")};m.prototype.stop=function(){this.webSocket&&this.close(void 0);return Promise.resolve()};m.prototype.close=function(n){this.webSocket&&(this.webSocket.onclose=function(){},
2570this.webSocket.onmessage=function(){},this.webSocket.onerror=function(){},this.webSocket.close(),this.webSocket=void 0);this.logger.log(d.LogLevel.Trace,"(WebSockets transport) socket closed.");if(this.onclose)if(!this.isCloseEvent(n)||!1!==n.wasClean&&1E3===n.code)if(n instanceof Error)this.onclose(n);else this.onclose();else this.onclose(Error("WebSocket closed with status code: "+n.code+" ("+n.reason+")."))};m.prototype.isCloseEvent=function(n){return n&&"boolean"===typeof n.wasClean&&"number"===
2571typeof n.code};return m}()},function(a,b,c){c.r(b);c.d(b,"JsonHubProtocol",function(){return k});var d=c(15),e=c(8),f=c(20),g=c(10),h=c(14),k=function(){function l(){this.name="json";this.version=1;this.transferFormat=f.TransferFormat.Text}l.prototype.parseMessages=function(m,n){if("string"!==typeof m)throw Error("Invalid input for JSON hub protocol. Expected a string.");if(!m)return[];null===n&&(n=g.NullLogger.instance);var r=[],t=0;for(m=h.TextMessageFormat.parse(m);t<m.length;t++){var u=JSON.parse(m[t]);
2572if("number"!==typeof u.type)throw Error("Invalid payload.");switch(u.type){case d.MessageType.Invocation:this.isInvocationMessage(u);break;case d.MessageType.StreamItem:this.isStreamItemMessage(u);break;case d.MessageType.Completion:this.isCompletionMessage(u);break;case d.MessageType.Ping:break;case d.MessageType.Close:break;default:n.log(e.LogLevel.Information,"Unknown message type '"+u.type+"' ignored.");continue}r.push(u)}return r};l.prototype.writeMessage=function(m){return h.TextMessageFormat.write(JSON.stringify(m))};
2573l.prototype.isInvocationMessage=function(m){this.assertNotEmptyString(m.target,"Invalid payload for Invocation message.");void 0!==m.invocationId&&this.assertNotEmptyString(m.invocationId,"Invalid payload for Invocation message.")};l.prototype.isStreamItemMessage=function(m){this.assertNotEmptyString(m.invocationId,"Invalid payload for StreamItem message.");if(void 0===m.item)throw Error("Invalid payload for StreamItem message.");};l.prototype.isCompletionMessage=function(m){if(m.result&&m.error)throw Error("Invalid payload for Completion message.");
2574!m.result&&m.error&&this.assertNotEmptyString(m.error,"Invalid payload for Completion message.");this.assertNotEmptyString(m.invocationId,"Invalid payload for Completion message.")};l.prototype.assertNotEmptyString=function(m,n){if("string"!==typeof m||""===m)throw Error(n);};return l}()}])});
2575(function(a,b){"object"===typeof exports&&"undefined"!==typeof module?module.exports=b():"function"===typeof define&&define.amd?define(b):(a="undefined"!==typeof globalThis?globalThis:a||self,a.Swiper=b())})(this,function(){function a(p){return null!==p&&"object"===typeof p&&"constructor"in p&&p.constructor===Object}function b(p={},E={}
2575){Object.keys(E).forEach(L=>{"undefined"===typeof p[L]?p[L]=E[L]:a(E[L])&&a(p[L])&&0<Object.keys(E[L]).length&&b(p[L],E[L])})}function c(){const p="undefined"!==typeof document?
2576document:{};b(p,xa);return p}function d(){const p="undefined"!==typeof window?window:{};b(p,Fa);return p}function e(p){const E=p.__proto__;Object.defineProperty(p,"__proto__",{get(){return E},set(L){E.__proto__=L}})}function f(p=[]){const E=[];p.forEach(L=>{Array.isArray(L)?E.push(...f(L)):E.push(L)});return E}function g(p,E){return Array.prototype.filter.call(p,E)}function h(p,E){var L=d(),ca=c(),fa=[];if(!E&&p instanceof Na)return p;if(!p)return new Na(fa);if("string"===typeof p)if(L=p.trim(),0<=
2577L.indexOf("<")&&0<=L.indexOf(">")){E="div";0===L.indexOf("<li")&&(E="ul");0===L.indexOf("<tr")&&(E="tbody");if(0===L.indexOf("<td")||0===L.indexOf("<th"))E="tr";0===L.indexOf("<tbody")&&(E="table");0===L.indexOf("<option")&&(E="select");ca=ca.createElement(E);ca.innerHTML=L;for(E=0;E<ca.childNodes.length;E+=1)fa.push(ca.childNodes[E])}else if(L=p.trim(),"string"!==typeof L)fa=[L];else for(fa=[],ca=(E||ca).querySelectorAll(L),E=0;E<ca.length;E+=1)fa.push(ca[E]);else if(p.nodeType||p===L||p===ca)fa.push(p);
2578else if(Array.isArray(p)){if(p instanceof Na)return p;fa=p}ca=fa;fa=[];for(E=0;E<ca.length;E+=1)-1===fa.indexOf(ca[E])&&fa.push(ca[E]);return new Na(fa)}function k(p){Object.keys(p).forEach(E=>{try{p[E]=null}catch(L){}try{delete p[E]}catch(L){}})}function l(p,E=0){return setTimeout(p,E)}function m(){return Date.now()}function n(p){const E=d();let L;E.getComputedStyle&&(L=E.getComputedStyle(p,null));!L&&p.currentStyle&&(L=p.currentStyle);L||(L=p.style);return L}function r(p,E="x"){const L=d();let ca,
2579fa;p=n(p);L.WebKitCSSMatrix?(fa=p.transform||p.webkitTransform,6<fa.split(",").length&&(fa=fa.split(", ").map(ia=>ia.replace(",",".")).join(", ")),p=new L.WebKitCSSMatrix("none"===fa?"":fa)):(p=p.MozTransform||p.OTransform||p.MsTransform||p.msTransform||p.transform||p.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),ca=p.toString().split(","));"x"===E&&(fa=L.WebKitCSSMatrix?p.m41:16===ca.length?parseFloat(ca[12]):parseFloat(ca[4]));"y"===E&&(fa=L.WebKitCSSMatrix?p.m42:16===
2580ca.length?parseFloat(ca[13]):parseFloat(ca[5]));return fa||0}function t(p){return"object"===typeof p&&null!==p&&p.constructor&&"Object"===Object.prototype.toString.call(p).slice(8,-1)}function u(...p){const E=Object(p[0]),L=["__proto__","constructor","prototype"];for(let fa=1;fa<p.length;fa+=1){const ia=p[fa];var ca;if(ca=void 0!==ia&&null!==ia)ca="undefined"!==typeof window&&"undefined"!==typeof window.HTMLElement?ia instanceof HTMLElement:ia&&(1===ia.nodeType||11===ia.nodeType),ca=!ca;if(ca){ca=
2581Object.keys(Object(ia)).filter(ma=>0>L.indexOf(ma));for(let ma=0,ua=ca.length;ma<ua;ma+=1){const wa=ca[ma],Da=Object.getOwnPropertyDescriptor(ia,wa);void 0!==Da&&Da.enumerable&&(t(E[wa])&&t(ia[wa])?ia[wa].__swiper__?E[wa]=ia[wa]:u(E[wa],ia[wa]):!t(E[wa])&&t(ia[wa])?(E[wa]={},ia[wa].__swiper__?E[wa]=ia[wa]:u(E[wa],ia[wa])):E[wa]=ia[wa])}}}return E}function x({swiper:p,targetPosition:E,side:L}){const ca=d(),fa=-p.translate;let ia=null,ma;const ua=p.params.speed;p.wrapperEl.style.scrollSnapType="none";
2582ca.cancelAnimationFrame(p.cssModeFrameID);const wa=E>fa?"next":"prev",Da=()=>{ma=(new Date).getTime();null===ia&&(ia=ma);let Ea=fa+(.5-Math.cos(Math.max(Math.min((ma-ia)/ua,1),0)*Math.PI)/2)*(E-fa);if("next"===wa&&Ea>=E||"prev"===wa&&Ea<=E)Ea=E;p.wrapperEl.scrollTo({[L]:Ea});"next"===wa&&Ea>=E||"prev"===wa&&Ea<=E?(p.wrapperEl.style.overflow="hidden",p.wrapperEl.style.scrollSnapType="",setTimeout(()=>{p.wrapperEl.style.overflow="";p.wrapperEl.scrollTo({[L]:Ea})}),ca.cancelAnimationFrame(p.cssModeFrameID)):
2583p.cssModeFrameID=ca.requestAnimationFrame(Da)};Da()}function B(){const p=d(),E=c();return{smoothScroll:E.documentElement&&"scrollBehavior"in E.documentElement.style,touch:!!("ontouchstart"in p||p.DocumentTouch&&E instanceof p.DocumentTouch),passiveListener:function(){let L=!1;try{const ca=Object.defineProperty({},"passive",{get(){L=!0}});p.addEventListener("testPassiveListener",null,ca)}catch(ca){}return L}(),gestures:"ongesturestart"in p}}function y(){Ta||=B();return Ta}function A({userAgent:p}=
2584{}){const E=y();var L=d();const ca=L.navigator.platform;p=p||L.navigator.userAgent;const fa={ios:!1,android:!1},ia=L.screen.width;L=L.screen.height;const ma=p.match(/(Android);?[\s\/]+([\d.]+)?/);let ua=p.match(/(iPad).*OS\s([\d_]+)/);const wa=p.match(/(iPod)(.*OS\s([\d_]+))?/),Da=!ua&&p.match(/(iPhone\sOS|iOS)\s([\d_]+)/),Ea="Win32"===ca,Aa="1024x1366 1366x1024 834x1194 1194x834 834x1112 1112x834 768x1024 1024x768 820x1180 1180x820 810x1080 1080x810".split(" ");!ua&&"MacIntel"===ca&&E.touch&&0<=
2585Aa.indexOf(`${ia}x${L}`)&&((ua=p.match(/(Version)\/([\d.]+)/))||(ua=[0,1,"13_0_0"]));ma&&!Ea&&(fa.os="android",fa.android=!0);if(ua||Da||wa)fa.os="ios",fa.ios=!0;return fa}function aa(p={}){Sa||=A(p);return Sa}function ha(){const p=d(),E=p.navigator.userAgent.toLowerCase();return{isSafari:0<=E.indexOf("safari")&&0>E.indexOf("chrome")&&0>
2585E.indexOf("android"),isWebView:/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(p.navigator.userAgent)}}function z({swiper:p,runCallbacks:E,direction:L,step:ca}){const {activeIndex:fa,
2586previousIndex:ia}=p;L||=fa>ia?"next":fa<ia?"prev":"reset";p.emit(`transition${ca}`);E&&fa!==ia&&("reset"===L?p.emit(`slideResetTransition${ca}`):(p.emit(`slideChangeTransition${ca}`),"next"===L?p.emit(`slideNextTransition${ca}`):p.emit(`slidePrevTransition${ca}`)))}function V(p,E=this){function L(ca){if(!ca||ca===c()||ca===d())return null;ca.assignedSlot&&(ca=ca.assignedSlot);return ca.closest(p)||L(ca.getRootNode().host)}return L(E)}function ba(p){var E=c();const L=d(),ca=this.touchEventsData,{params:fa,
2587touches:ia,enabled:ma}=this;if(ma&&(!this.animating||!fa.preventInteractionOnTransition)){!this.animating&&fa.cssMode&&fa.loop&&this.loopFix();var ua=p;ua.originalEvent&&(ua=ua.originalEvent);var wa=h(ua.target);if("wrapper"!==fa.touchEventsTarget||wa.closest(this.wrapperEl).length)if(ca.isTouchEvent="touchstart"===ua.type,!(!ca.isTouchEvent&&"which"in ua&&3===ua.which||!ca.isTouchEvent&&"button"in ua&&0<ua.button||ca.isTouched&&ca.isMoved)){fa.noSwipingClass&&""!==fa.noSwipingClass&&ua.target&&ua.target.shadowRoot&&
2588p.path&&p.path[0]&&(wa=h(p.path[0]));var Da=fa.noSwipingSelector?fa.noSwipingSelector:`.${fa.noSwipingClass}`,Ea=!(!ua.target||!ua.target.shadowRoot);if(fa.noSwiping&&(Ea?V(Da,ua.target):wa.closest(Da)[0]))this.allowClick=!0;else if(!fa.swipeHandler||wa.closest(fa.swipeHandler)[0]){ia.currentX="touchstart"===ua.type?ua.targetTouches[0].pageX:ua.pageX;ia.currentY="touchstart"===ua.type?ua.targetTouches[0].pageY:ua.pageY;Da=ia.currentX;Ea=ia.currentY;var Aa=fa.edgeSwipeDetection||fa.iOSEdgeSwipeDetection,
2589Ka=fa.edgeSwipeThreshold||fa.iOSEdgeSwipeThreshold;if(Aa&&(Da<=Ka||Da>=L.innerWidth-Ka))if("prevent"===Aa)p.preventDefault();else return;Object.assign(ca,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0});ia.startX=Da;ia.startY=Ea;ca.touchStartTime=m();this.allowClick=!0;this.updateSize();this.swipeDirection=void 0;0<fa.threshold&&(ca.allowThresholdMove=!1);"touchstart"!==ua.type&&(p=!0,wa.is(ca.focusableElements)&&(p=!1),E.activeElement&&h(E.activeElement).is(ca.focusableElements)&&
2590E.activeElement!==wa[0]&&E.activeElement.blur(),E=p&&this.allowTouchMove&&fa.touchStartPreventDefault,!fa.touchStartForcePreventDefault&&!E||wa[0].isContentEditable||ua.preventDefault());this.emit("touchStart",ua)}}}}function v(p){var E=c();const L=this.touchEventsData,{params:ca,touches:fa,rtlTranslate:ia,enabled:ma}=this;if(ma)if(p.originalEvent&&(p=p.originalEvent),!L.isTouched)L.startMoving&&L.isScrolling&&this.emit("touchMoveOpposite",p);else if(!L.isTouchEvent||"touchmove"===p.type){var ua=
2591"touchmove"===p.type&&p.targetTouches&&(p.targetTouches[0]||p.changedTouches[0]),wa="touchmove"===p.type?ua.pageX:p.pageX;ua="touchmove"===p.type?ua.pageY:p.pageY;if(p.preventedByNestedSwiper)fa.startX=wa,fa.startY=ua;else if(this.allowTouchMove){if(L.isTouchEvent&&ca.touchReleaseOnEdges&&!ca.loop)if(this.isVertical()){if(ua<fa.startY&&this.translate<=this.maxTranslate()||ua>fa.startY&&this.translate>=this.minTranslate()){L.isTouched=!1;L.isMoved=!1;return}}else if(wa<fa.startX&&this.translate<=this.maxTranslate()||
2592wa>fa.startX&&this.translate>=this.minTranslate())return;if(L.isTouchEvent&&E.activeElement&&p.target===E.activeElement&&h(p.target).is(L.focusableElements))L.isMoved=!0,this.allowClick=!1;else if(L.allowTouchCallbacks&&this.emit("touchMove",p),!(p.targetTouches&&1<p.targetTouches.length||(fa.currentX=wa,fa.currentY=ua,E=fa.currentX-fa.startX,wa=fa.currentY-fa.startY,this.params.threshold&&Math.sqrt(E**2+wa**2)<this.params.threshold)))if("undefined"===typeof L.isScrolling&&(this.isHorizontal()&&fa.currentY===
2593fa.startY||this.isVertical()&&fa.currentX===fa.startX?L.isScrolling=!1:25<=E*E+wa*wa&&(ua=180*Math.atan2(Math.abs(wa),Math.abs(E))/Math.PI,L.isScrolling=this.isHorizontal()?ua>ca.touchAngle:90-ua>ca.touchAngle)),L.isScrolling&&this.emit("touchMoveOpposite",p),"undefined"!==typeof L.startMoving||fa.currentX===fa.startX&&fa.currentY===fa.startY||(L.startMoving=!0),L.isScrolling)L.isTouched=!1;else if(L.startMoving){this.allowClick=!1;!ca.cssMode&&p.cancelable&&p.preventDefault();ca.touchMoveStopPropagation&&
2594!ca.nested&&p.stopPropagation();L.isMoved||(ca.loop&&!ca.cssMode&&this.loopFix(),L.startTranslate=this.getTranslate(),this.setTransition(0),this.animating&&this.$wrapperEl.trigger("webkitTransitionEnd transitionend"),L.allowMomentumBounce
2594=!1,!ca.grabCursor||!0!==this.allowSlideNext&&!0!==this.allowSlidePrev||this.setGrabCursor(!0),this.emit("sliderFirstMove",p));this.emit("sliderMove",p);L.isMoved=!0;E=this.isHorizontal()?E:wa;fa.diff=E;E*=ca.touchRatio;ia&&(E=-E);this.swipeDirection=0<E?"prev":"next";
2595L.currentTranslate=E+L.startTranslate;wa=!0;ua=ca.resistanceRatio;ca.touchReleaseOnEdges&&(ua=0);0<E&&L.currentTranslate>this.minTranslate()?(wa=!1,ca.resistance&&(L.currentTranslate=this.minTranslate()-1+(-this.minTranslate()+L.startTranslate+E)**ua)):0>E&&L.currentTranslate<this.maxTranslate()&&(wa=!1,ca.resistance&&(L.currentTranslate=this.maxTranslate()+1-(this.maxTranslate()-L.startTranslate-E)**ua));wa&&(p.preventedByNestedSwiper=!0);!this.allowSlideNext&&"next"===this.swipeDirection&&L.currentTranslate<
2596L.startTranslate&&(L.currentTranslate=L.startTranslate);!this.allowSlidePrev&&"prev"===this.swipeDirection&&L.currentTranslate>L.startTranslate&&(L.currentTranslate=L.startTranslate);this.allowSlidePrev||this.allowSlideNext||(L.currentTranslate=L.startTranslate);
2596if(0<ca.threshold)if(Math.abs(E)>ca.threshold||L.allowThresholdMove){if(!L.allowThresholdMove){L.allowThresholdMove=!0;fa.startX=fa.currentX;fa.startY=fa.currentY;L.currentTranslate=L.startTranslate;fa.diff=this.isHorizontal()?fa.currentX-
2597fa.startX:fa.currentY-fa.startY;return}}else{L.currentTranslate=L.startTranslate;return}if(ca.followFinger&&!ca.cssMode){if(ca.freeMode&&ca.freeMode.enabled&&this.freeMode||ca.watchSlidesProgress)this.updateActiveIndex(),this.updateSlidesClasses();if(this.params.freeMode&&ca.freeMode.enabled&&this.freeMode)this.freeMode.onTouchMove();this.updateProgress(L.currentTranslate);this.setTranslate(L.currentTranslate)}}}else this.allowClick=!1,L.isTouched&&(Object.assign(fa,{startX:wa,startY:ua,currentX:wa,
2598currentY:ua}),L.touchStartTime=m())}}function K(p){const E=this;var L=E.touchEventsData;const {params:ca,touches:fa,rtlTranslate:ia,slidesGrid:ma,enabled:ua}=E;if(ua)if(p.originalEvent&&(p=p.originalEvent),L.allowTouchCallbacks&&E.emit("touchEnd",p),L.allowTouchCallbacks=!1,L.isTouched){ca.grabCursor&&L.isMoved&&L.isTouched&&(!0===E.allowSlideNext||!0===E.allowSlidePrev)&&E.setGrabCursor(!1);var wa=m(),Da=wa-L.touchStartTime;if(E.allowClick){var Ea=p.path||p.composedPath&&p.composedPath();E.updateClickedSlide(Ea&&
2599Ea[0]||p.target);E.emit("tap click",p);300>Da&&300>wa-L.lastClickTime&&E.emit("doubleTap doubleClick",p)}L.lastClickTime=m();l(()=>{E.destroyed||(E.allowClick=!0)});if(L.isTouched&&L.isMoved&&E.swipeDirection&&0!==fa.diff&&L.currentTranslate!==L.startTranslate){if(L.isTouched=!1,L.isMoved=!1,L.startMoving=!1,wa=ca.followFinger?ia?E.translate:-E.translate:-L.currentTranslate,!ca.cssMode)if(E.params.freeMode&&ca.freeMode.enabled)E.freeMode.onTouchEnd({currentPos:wa});else{L=0;Ea=E.slidesSizesGrid[0];
2600for(let Aa=0;Aa<ma.length;Aa+=Aa<ca.slidesPerGroupSkip?1:ca.slidesPerGroup){const Ka=Aa<ca.slidesPerGroupSkip-1?1:ca.slidesPerGroup;"undefined"!==typeof ma[Aa+Ka]?wa>=ma[Aa]&&wa<ma[Aa+Ka]&&(L=Aa,Ea=ma[Aa+Ka]-ma[Aa]):wa>=ma[Aa]&&(L=Aa,Ea=ma[ma.length-1]-ma[ma.length-2])}wa=(wa-ma[L])/Ea;Ea=L<ca.slidesPerGroupSkip-1?1:ca.slidesPerGroup;Da>ca.longSwipesMs?ca.longSwipes?("next"===E.swipeDirection&&(wa>=ca.longSwipesRatio?E.slideTo(L+Ea):E.slideTo(L)),"prev"===E.swipeDirection&&(wa>1-ca.longSwipesRatio?
2601E.slideTo(L+Ea):E.slideTo(L))):E.slideTo(E.activeIndex):ca.shortSwipes?!E.navigation||p.target!==E.navigation.nextEl&&p.target!==E.navigation.prevEl?("next"===E.swipeDirection&&E.slideTo(L+Ea),"prev"===E.swipeDirection&&E.slideTo(L)):p.target===E.navigation.nextEl?E.slideTo(L+Ea):E.slideTo(L):E.slideTo(E.activeIndex)}}else L.isTouched=!1,L.isMoved=!1,L.startMoving=!1}else L.isMoved&&ca.grabCursor&&E.setGrabCursor(!1),L.isMoved=!1,L.startMoving=!1}function C(){const {params:p,el:E}=this;if(!E||0!==
2602E.offsetWidth){p.breakpoints&&this.setBreakpoint();var {allowSlideNext:L,allowSlidePrev:ca,snapGrid:fa}=this;this.allowSlidePrev=this.allowSlideNext=!0;this.updateSize();this.updateSlides();this.updateSlidesClasses();("auto"===p.slidesPerView||1<p.slidesPerView)&&this.isEnd&&!this.isBeginning&&!this.params.centeredSlides?this.slideTo(this.slides.length-1,0,!1,!0):this.slideTo(this.activeIndex,0,!1,!0);this.autoplay&&this.autoplay.running&&this.autoplay.paused&&this.autoplay.run();this.allowSlidePrev=
2603ca;this.allowSlideNext=L;this.params.watchOverflow&&fa!==this.snapGrid&&this.checkOverflow()}}function da(p){this.enabled&&!this.allowClick&&(this.params.preventClicks&&p.preventDefault(),this.params.preventClicksPropagation&&this.animating&&(p.stopPropagation(),p.stopImmediatePropagation()))}function ja(){const {wrapperEl:p,rtlTranslate:E,enabled:L}=this;if(L){this.previousTranslate=this.translate;this.isHorizontal()?this.translate=-p.scrollLeft:this.translate=-p.scrollTop;-0===this.translate&&(this.translate=
26040);this.updateActiveIndex();this.updateSlidesClasses();var ca=this.maxTranslate()-this.minTranslate();(0===ca?0:(this.translate-this.minTranslate())/ca)!==this.progress&&this.updateProgress(E?-this.translate:this.translate);this.emit("setTranslate",this.translate,!1)}}function ea(){}function ra(p,E){const L=[];p.forEach(ca=>
2604{"object"===typeof ca?Object.keys(ca).forEach(fa=>{ca[fa]&&L.push(E+fa)}):"string"===typeof ca&&L.push(E+ca)});return L}function za(p,E){return function(L={}){const ca=Object.keys(L)[0],
2605fa=L[ca];"object"===typeof fa&&null!==fa&&(0<=["navigation","pagination","scrollbar"].indexOf(ca)&&!0===p[ca]&&(p[ca]={auto:!0}),ca in p&&"enabled"in fa&&(!0===p[ca]&&(p[ca]={enabled:!0}),"object"!==typeof p[ca]||"enabled"in p[ca]||(p[ca].enabled=!0),p[ca]||(p[ca]={enabled:!1})));u(E,L)}}function na(p,E,L,ca){const fa=c();p.params.createElements&&Object.keys(ca).forEach(ia=>{if(!L[ia]&&!0===L.auto){let ma=p.$el.children(`.${ca[ia]}`)[0];ma||(ma=fa.createElement("div"),ma.className=ca[ia],p.$el.append(ma));
2606L[ia]=ma;E[ia]=ma}});return L}function qa(p=""){return`.${p.trim().replace(/([\.:!\/])/g,"\\$1").replace(/ /g,".")}`}function Ba(p){const {$wrapperEl:E,params:L}=this;L.loop&&this.loopDestroy();if("object"===typeof p&&"length"in p)for(let ca=0;ca<p.length;ca+=1)p[ca]&&E.append(p[ca]);else E.append(p);L.loop&&this.loopCreate();L.observer||this.update()}function Ua(p){const {params:E,$wrapperEl:L,activeIndex:ca}=this;E.loop&&this.loopDestroy();var fa=ca+1;if("object"===typeof p&&"length"in p){for(fa=
26070;fa<p.length;fa+=1)p[fa]&&L.prepend(p[fa]);fa=ca+p.length}else L.prepend(p);E.loop&&this.loopCreate();E.observer||this.update();this.slideTo(fa,0,!1)}function Ja(p,E){const {$wrapperEl:L,params:ca,activeIndex:fa}=this;let ia=fa;ca.loop&&(ia-=this.loopedSlides,this.loopDestroy(),this.slides=L.children(`.${ca.slideClass}`));var ma=this.slides.length;if(0>=p)this.prependSlide(E);else if(p>=ma)this.appendSlide(E);else{var ua=ia>p?ia+1:ia,wa=[];for(--ma;ma>=p;--ma){const Da=this.slides.eq(ma);Da.remove();
2608wa.unshift(Da)}if("object"===typeof E&&"length"in E){for(ua=0;ua<E.length;ua+=1)E[ua]&&L.append(E[ua]);ua=ia>p?ia+E.length:ia}else L.append(E);for(p=0;p<wa.length;p+=1)L.append(wa[p]);ca.loop&&this.loopCreate();ca.observer||this.update();ca.loop?this.slideTo(ua+this.loopedSlides,0,!1):this.slideTo(ua,0,!1)}}function Pa(p){const {params:E,$wrapperEl:L,activeIndex:ca}=this;var fa=ca;E.loop&&(fa-=this.loopedSlides,this.loopDestroy(),this.slides=L.children(`.${E.slideClass}`));let ia;if("object"===typeof p&&
2609"length"in p)for(let ma=0;ma<p.length;ma+=1)ia=p[ma],this.slides[ia]&&this.slides.eq(ia).remove(),ia<fa&&--fa;else ia=p,this.slides[ia]&&this.slides.eq(ia).remove(),ia<fa&&--fa;fa=Math.max(fa,0);E.loop&&this.loopCreate();E.observer||this.update();E.loop?this.slideTo(fa+this.loopedSlides,0,!1):this.slideTo(fa,0,!1)}function Ca(){const p=[];for(let E=0;E<this.slides.length;E+=1)p.push(E);this.removeSlide(p)}const xa={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},
2610querySelector(){return null},querySelectorAll(){return[]},getElementById(){return null},createEvent(){return{initEvent(){}}},createElement(){return{children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName(){return[]}}},createElementNS(){return{}},importNode(){return null},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}},Fa={document:xa,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",
2611search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle(){return{getPropertyValue(){return""}}},Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia(){return{}},requestAnimationFrame(p){return"undefined"===typeof setTimeout?(p(),null):setTimeout(p,0)},cancelAnimationFrame(p){"undefined"!==typeof setTimeout&&clearTimeout(p)}};class Na extends Array{constructor(p){super(...(p||
2612[]));e(this)}}h.fn=Na.prototype;const I={addClass:function(...p){const E=f(p.map(L=>L.split(" ")));this.forEach(L=>{L.classList.add(...E)});return this},removeClass:function(...p){const E=f(p.map(L=>L.split(" ")));this.forEach(L=>{L.classList.remove(...E)});return this},hasClass:function(...p){const E=f(p.map(L=>L.split(" ")));return 0<g(this,L=>0<E.filter(ca=>L.classList.contains(ca)).length).length},toggleClass:function(...p){const E=f(p.map(L=>L.split(" ")));this.forEach(L=>
2612{E.forEach(ca=>{L.classList.toggle(ca)})})},
2613attr:function(p,E){if(1===arguments.length&&"string"===typeof p){if(this[0])return this[0].getAttribute(p)}else{for(let L=0;L<this.length;L+=1)if(2===arguments.length)this[L].setAttribute(p,E);else for(const ca in p)this[L][ca]=p[ca],this[L].setAttribute(ca,p[ca]);return this}},removeAttr:function(p){for(let E=0;E<this.length;E+=1)this[E].removeAttribute(p);return this},transform:function(p){for(let E=0;E<this.length;E+=1)this[E].style.transform=p;return this},transition:function(p){for(let E=0;E<
2614this.length;E+=1)this[E].style.transitionDuration="string"!==typeof p?`${p}ms`:p;return this},on:function(...p){function E(Da){var Ea=Da.target;if(Ea){var Aa=Da.target.dom7EventData||[];0>Aa.indexOf(Da)&&Aa.unshift(Da);if(h(Ea).is(fa))ia.apply(Ea,Aa);else for(Da=h(Ea).parents(),Ea=0;Ea<Da.length;Ea+=1)h(Da[Ea]).is(fa)&&ia.apply(Da[Ea],Aa)}}function L(Da){const Ea=Da&&Da.target?Da.target.dom7EventData||[]:[];0>Ea.indexOf(Da)&&Ea.unshift(Da);ia.apply(this,Ea)}let [ca,fa,ia,ma]=p;"function"===typeof p[1]&&
2615([ca,ia,ma]=p,fa=void 0);ma||=!1;p=ca.split(" ");let ua;for(let Da=0;Da<this.length;Da+=1){const Ea=this[Da];if(fa)for(ua=0;ua<p.length;ua+=1){var wa=p[ua];Ea.dom7LiveListeners||(Ea.dom7LiveListeners={});Ea.dom7LiveListeners[wa]||(Ea.dom7LiveListeners[wa]=[]);Ea.dom7LiveListeners[wa].push({listener:ia,proxyListener:E});Ea.addEventListener(wa,E,ma)}else for(ua=0;ua<p.length;ua+=1)wa=p[ua],Ea.dom7Listeners||(Ea.dom7Listeners={}),Ea.dom7Listeners[wa]||(Ea.dom7Listeners[wa]=[]),Ea.dom7Listeners[wa].push({listener:ia,
2616proxyListener:L}),Ea.addEventListener(wa,L,ma)}return this},off:function(...p){let [E,L,ca,fa]=p;"function"===typeof p[1]&&([E,ca,fa]=p,L=void 0);fa||=!1;p=E.split(" ");for(let ia=0;ia<p.length;ia+=1){const ma=p[ia];for(let ua=0;ua<this.length;ua+=1){const wa=this[ua];let Da;!L&&wa.dom7Listeners?Da=wa.dom7Listeners[ma]:L&&wa.dom7LiveListeners&&(Da=wa.dom7LiveListeners[ma]);if(Da&&Da.length)for(let Ea=Da.length-1;0<=Ea;--Ea){const Aa=Da[Ea];ca&&Aa.listener===ca?(wa.removeEventListener(ma,Aa.proxyListener,
2617fa),Da.splice(Ea,1)):ca&&Aa.listener&&Aa.listener.dom7proxy&&Aa.listener.dom7proxy===ca?(wa.removeEventListener(ma,Aa.proxyListener,fa),Da.splice(Ea,1)):ca||(wa.removeEventListener(ma,Aa.proxyListener,fa),Da.splice(Ea,1))}}}return this},trigger:function(...p){const E=d(),L=p[0].split(" "),ca=p[1];for(let fa=0;fa<L.length;fa+=1){const ia=L[fa];for(let ma=0;ma<this.length;ma+=1){const ua=this[ma];if(E.CustomEvent){const wa=new E.CustomEvent(ia,{detail:ca,bubbles:!0,cancelable:!0});ua.dom7EventData=
2618p.filter((Da,Ea)=>0<Ea);ua.dispatchEvent(wa);ua.dom7EventData=[];delete ua.dom7EventData}}}return this},transitionEnd:function(p){function E(ca){ca.target===this&&(p.call(this,ca),L.off("transitionend",E))}const L=this;if(p)L.on("transitionend",E);return this},outerWidth:function(p){return 0<this.length?p?(p=this.styles(),this[0].offsetWidth+parseFloat(p.getPropertyValue("margin-right"))+parseFloat(p.getPropertyValue("margin-left"))):this[0].offsetWidth:null},outerHeight:function(p){return 0<this.length?
2619p?(p=this.styles(),this[0].offsetHeight+parseFloat(p.getPropertyValue("margin-top"))+parseFloat(p.getPropertyValue("margin-bottom"))):this[0].offsetHeight:null},styles:function(){const p=d();return this[0]?p.getComputedStyle(this[0],null):{}},offset:function(){if(0<this.length){const E=d();var p=c();const L=this[0],ca=L.getBoundingClientRect();p=p.body;return{top:ca.top+(L===E?E.scrollY:L.scrollTop)-(L.clientTop||p.clientTop||0),left:ca.left+(L===E?E.scrollX:L.scrollLeft)-(L.clientLeft||p.clientLeft||
26200)}}return null},css:function(p,E){var L=d();if(1===arguments.length)if("string"===typeof p){if(this[0])return L.getComputedStyle(this[0],null).getPropertyValue(p)}else{for(L=0;L<this.length;L+=1)for(const ca in p)this[L].style[ca]=p[ca];return this}if(2===arguments.length&&"string"===typeof p)for(L=0;L<this.length;L+=1)this[L].style[p]=E;return this},each:function(p){if(!p)return this;this.forEach((E,L)=>{p.apply(E,[E,L])});return this},html:function(p){if("undefined"===typeof p)return this[0]?this[0].innerHTML:
2621null;for(let E=0;E<this.length;E+=1)this[E].innerHTML=p;return this},text:function(p){if("undefined"===typeof p)return this[0]?this[0].textContent.trim():null;for(let E=0;E<this.length;E+=1)this[E].textContent=p;return this},is:function(p){var E=d();const L=c(),ca=this[0];if(!ca||"undefined"===typeof p)return!1;
2621if("string"===typeof p){if(ca.matches)return ca.matches(p);if(ca.webkitMatchesSelector)return ca.webkitMatchesSelector(p);if(ca.msMatchesSelector)return ca.msMatchesSelector(p);p=h(p);for(E=
26220;E<p.length;E+=1)if(p[E]===ca)return!0;return!1}if(p===L)return ca===L;if(p===E)return ca===E;if(p.nodeType||p instanceof Na)for(p=p.nodeType?[p]:p,E=0;E<p.length;E+=1)if(p[E]===ca)return!0;return!1},index:function(){let p=this[0],E;if(p){for(E=0;null!==(p=p.previousSibling);)1===p.nodeType&&(E+=1);return E}},eq:function(p){if("undefined"===typeof p)return this;const E=this.length;return p>E-1?h([]):0>p?(p=E+p,0>p?h([]):h([this[p]])):h([this[p]])},append:function(...p){let E;const L=c();for(let fa=
26230;fa<p.length;fa+=1){E=p[fa];for(let ia=0;ia<this.length;ia+=1)if("string"===typeof E){var ca=L.createElement("div");for(ca.innerHTML=E;ca.firstChild;)this[ia].appendChild(ca.firstChild)}else if(E instanceof Na)for(ca=0;ca<E.length;ca+=1)this[ia].appendChild(E[ca]);else this[ia].appendChild(E)}return this},prepend:function(p){const E=c();let L,ca;for(L=0;L<this.length;L+=1)if("string"===typeof p){const fa=E.createElement("div");fa.innerHTML=p;for(ca=fa.childNodes.length-1;0<=ca;--ca)this[L].insertBefore(fa.childNodes[ca],
2624this[L].childNodes[0])}else if(p instanceof Na)for(ca=0;ca<p.length;ca+=1)this[L].insertBefore(p[ca],this[L].childNodes[0]);else this[L].insertBefore(p,this[L].childNodes[0]);return this},next:function(p){if(0<this.length){if(p)return this[0].nextElementSibling&&h(this[0].nextElementSibling).is(p)?h([this[0].nextElementSibling]):h([]);if(this[0].nextElementSibling)return h([this[0].nextElementSibling])}return h([])},nextAll:function(p){const E=[];var L=this[0];if(!L)return h([]);for(;L.nextElementSibling;)L=
2625L.nextElementSibling,p?h(L).is(p)&&E.push(L):E.push(L);return h(E)},prev:function(p){if(0<this.length){const E=this[0];if(p)return E.previousElementSibling&&h(E.previousElementSibling).is(p)?h([E.previousElementSibling]):h([]);if(E.previousElementSibling)return h([E.previousElementSibling])}return h([])},prevAll:function(p){const E=[];var L=this[0];if(!L)return h([]);for(;L.previousElementSibling;)L=L.previousElementSibling,p?h(L).is(p)&&E.push(L):E.push(L);return h(E)},parent:function(p){const E=
2626[];for(let L=0;L<this.length;L+=1)null!==this[L].parentNode&&(p?h(this[L].parentNode).is(p)&&E.push(this[L].parentNode):E.push(this[L].parentNode));return h(E)},parents:function(p){const E=[];for(let L=0;L<this.length;L+=1){let ca=this[L].parentNode;for(;ca;)p?h(ca).is(p)&&E.push(ca):E.push(ca),ca=ca.parentNode}return h(E)},closest:function(p){let E=this;if("undefined"===typeof p)return h([]);E.is(p)||(E=E.parents(p).eq(0));return E},find:function(p){const E=[];for(let L=0;L<this.length;L+=1){const ca=
2627this[L].querySelectorAll(p);for(let fa=0;fa<ca.length;fa+=1)E.push(ca[fa])}return h(E)},children:function(p){const E=[];for(let L=0;L<this.length;L+=1){const ca=this[L].children;for(let fa=0;fa<ca.length;fa+=1)p&&!h(ca[fa]).is(p)||E.push(ca[fa])}return h(E)},filter:function(p){p=g(this,p);return h(p)},remove:function(){for(let p=0;p<this.length;p+=1)this[p].parentNode&&this[p].parentNode.removeChild(this[p]);return this}};Object.keys(I).forEach(p=>{Object.defineProperty(h.fn,p,{value:I[p],writable:!0})});
2628let Ta,Sa,db,ab=!1;const Oa=(p,E)=>{var L=c();const {params:ca,touchEvents:fa,el:ia,wrapperEl:ma,device:ua,support:wa}=p,Da=!!ca.nested,Ea="on"===E?"addEventListener":"removeEventListener";if(wa.touch){if(L="touchstart"===fa.start&&wa.passiveListener&&ca.passiveListeners?{passive:!0,capture:!1}:!1,ia[Ea](fa.start,p.onTouchStart,L),ia[Ea](fa.move,p.onTouchMove,wa.passiveListener?{passive:!1,capture:Da}:Da),ia[Ea](fa.end,p.onTouchEnd,L),fa.cancel)ia[Ea](fa.cancel,p.onTouchEnd,L)}else ia[Ea](fa.start,
2629p.onTouchStart,!1),L[Ea](fa.move,p.onTouchMove,Da),L[Ea](fa.end,p.onTouchEnd,!1);if(ca.preventClicks||ca.preventClicksPropagation)ia[Ea]("click",p.onClick,!0);if(ca.cssMode)ma[Ea]("scroll",p.onScroll);if(ca.updateOnWindowResize)p[E](ua.ios||ua.android?"resize orientationchange observerUpdate":"resize observerUpdate",C,!0);else p[E]("observerUpdate",C,!0)};var Ga={init:!0,direction:"horizontal",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,
2630nested:!1,createElements:!1,enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",
2630spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,
2631slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:0,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,
2632slideToClickedSlide:!1,preloadImages:!0,updateOnImagesReady:!0,loop:!1,loopAdditionalSlides:0,loopedSlides:null,loopFillGroupWithBlank:!1,loopPreventsSlide:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-invisible-blank",slideActiveClass:"swiper-slide-active",slideDuplicateActiveClass:"swiper-slide-duplicate-active",
2633slideVisibleClass:"swiper-slide-visible",slideDuplicateClass:"swiper-slide-duplicate",slideNextClass:"swiper-slide-next",slideDuplicateNextClass:"swiper-slide-duplicate-next",slidePrevClass:"swiper-slide-prev",slideDuplicatePrevClass:"swiper-slide-duplicate-prev",wrapperClass:"swiper-wrapper",runCallbacksOnInit:!0,_emitClasses:!1};const la={eventsEmitter:{on(p,E,L){const ca=this;if("function"!==typeof E)return ca;const fa=L?"unshift":"push";p.split(" ").forEach(ia=>{ca.eventsListeners[ia]||(ca.eventsListeners[ia]=
2634[]);ca.eventsListeners[ia][fa](E)});return ca},once(p,E,L){function ca(...ia){fa.off(p,ca);ca.__emitterProxy&&delete ca.__emitterProxy;E.apply(fa,ia)}const fa=this;if("function"!==typeof E)return fa;ca.__emitterProxy=E;return fa.on(p,ca,L)},onAny(p,E){if("function"!==typeof p)return this;E=E?"unshift":"push";if(0>this.eventsAnyListeners.indexOf(p))this.eventsAnyListeners[E](p);return this},offAny(p){if(!this.eventsAnyListeners)return this;p=this.eventsAnyListeners.indexOf(p);0<=p&&this.eventsAnyListeners.splice(p,
26351);return this},off(p,E){const L=this;if(!L.eventsListeners)return L;p.split(" ").forEach(ca=>{"undefined"===typeof E?L.eventsListeners[ca]=[]:L.eventsListeners[ca]&&L.eventsListeners[ca].forEach((fa,ia)=>{(fa===E||fa.__emitterProxy&&fa.__emitterProxy===E)&&L.eventsListeners[ca].splice(ia,1)})});return L},emit(...p){const E=this;if(!E.eventsListeners)return E;let L,ca,fa;"string"===typeof p[0]||Array.isArray(p[0])?(L=p[0],ca=p.slice(1,p.length),fa=E):(L=p[0].events,ca=p[0].data,fa=p[0].context||E);
2636ca.unshift(fa);(Array.isArray(L)?L:L.split(" ")).forEach(ia=>{E.eventsAnyListeners&&E.eventsAnyListeners.length&&E.eventsAnyListeners.forEach(ma=>{ma.apply(fa,[ia,...ca])});E.eventsListeners&&E.eventsListeners[ia]&&E.eventsListeners[ia].forEach(ma=>{ma.apply(fa,ca)})});return E}},update:{updateSize:function(){let p,E;const L=this.$el;p="undefined"!==typeof this.params.width&&null!==this.params.width?this.params.width:L[0].clientWidth;E="undefined"!==typeof this.params.height&&null!==this.params.height?
2637this.params.height:L[0].clientHeight;0===p&&this.isHorizontal()||0===E&&this.isVertical()||(p=p-parseInt(L.css("padding-left")||0,10)-parseInt(L.css("padding-right")||0,10),E=E-parseInt(L.css("padding-top")||0,10)-parseInt(L.css("padding-bottom")||0,10),Number.isNaN(p)&&(p=0),Number.isNaN(E)&&(E=0),Object.assign(this,{width:p,height:E,size:this.isHorizontal()?p:E}))},updateSlides:function(){function p(Xa){return L.isHorizontal()?Xa:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right",
2638"margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[Xa]}function E(Xa,wb){return parseFloat(Xa.getPropertyValue(p(wb))||0)}const L=this,ca=L.params,{$wrapperEl:fa,size:ia,rtlTranslate:ma,wrongRTL:ua}=L;var wa=L.virtual&&ca.virtual.enabled;const Da=wa?L.virtual.slides.length:L.slides.length,Ea=fa.children(`.${L.params.slideClass}`);wa=wa?L.virtual.slides.length:Ea.length;let Aa=[];const Ka=[],Ra=[];let cb=
2639ca.slidesOffsetBefore;"function"===typeof cb&&(cb=ca.slidesOffsetBefore.call(L));let ib=ca.slidesOffsetAfter;"function"===typeof ib&&(ib=ca.slidesOffsetAfter.call(L));const fb=L.snapGrid.length,bb=L.slidesGrid.length;let eb=ca.spaceBetween;var kb=-cb,rb=0,$a=0;if("undefined"!==typeof ia){"string"===typeof eb&&0<=eb.indexOf("%")&&(eb=parseFloat(eb.replace("%",""))/100*ia);L.virtualSize=-eb;ma?Ea.css({marginLeft:"",marginBottom:"",marginTop:""}):Ea.css({marginRight:"",marginBottom:"",marginTop:""});
2640ca.centeredSlides&&ca.cssMode&&(L.wrapperEl.style.setProperty("--swiper-centered-offset-before",""),L.wrapperEl.style.setProperty("--swiper-centered-offset-after",""));var nb=ca.grid&&1<ca.grid.rows&&L.grid;nb&&L.grid.initSlides(wa);var vb="auto"===ca.slidesPerView&&ca.breakpoints&&0<Object.keys(ca.breakpoints).filter(Xa=>"undefined"!==typeof ca.breakpoints[Xa].slidesPerView).length;for(let Xa=0;Xa<wa;Xa+=1){var jb=0;const wb=Ea.eq(Xa);nb&&L.grid.updateSlide(Xa,wb,wa,p);if("none"!==wb.css("display")){if("auto"===
2641ca.slidesPerView){vb&&(Ea[Xa].style[p("width")]="");var Ya=getComputedStyle(wb[0]);const Bb=wb[0].style.transform,ob=wb[0].style.webkitTransform;Bb&&(wb[0].style.transform="none");ob&&(wb[0].style.webkitTransform="none");if(ca.roundLengths)jb=L.isHorizontal()?wb.outerWidth(!0):wb.outerHeight(!0);else{jb=E(Ya,"width");const Ab=E(Ya,"padding-left"),Cb=E(Ya,"padding-right"),Eb=E(Ya,"margin-left"),Nb=E(Ya,"margin-right");if((Ya=Ya.getPropertyValue("box-sizing"))&&"border-box"===Ya)jb=jb+Eb+Nb;else{const {clientWidth:ic,
2642offsetWidth:mc}=wb[0];jb=jb+Ab+Cb+Eb+Nb+(mc-ic)}}Bb&&(wb[0].style.transform=Bb);ob&&(wb[0].style.webkitTransform=ob);ca.roundLengths&&(jb=Math.floor(jb))}else jb=(ia-(ca.slidesPerView-1)*eb)/ca.slidesPerView,ca.roundLengths&&(jb=Math.floor(jb)),Ea[Xa]&&(Ea[Xa].style[p("width")]=`${jb}px`);Ea[Xa]&&(Ea[Xa].swiperSlideSize=jb);Ra.push(jb);ca.centeredSlides?(kb=kb+jb/2+rb/2+eb,0===rb&&0!==Xa&&(kb=kb-ia/2-eb),0===Xa&&(kb=kb-ia/2-eb),.001>Math.abs(kb)&&(kb=0),ca.roundLengths&&(kb=Math.floor(kb)),0===$a%
2643ca.slidesPerGroup&&Aa.push(kb),Ka.push(kb)):(ca.roundLengths&&(kb=Math.floor(kb)),0===($a-Math.min(L.params.slidesPerGroupSkip,$a))%L.params.slidesPerGroup&&Aa.push(kb),Ka.push(kb),kb=kb+jb+eb);L.virtualSize+=jb+eb;rb=jb;$a+=1}}L.virtualSize=Math.max(L.virtualSize,ia)+ib;ma&&ua&&("slide"===ca.effect||"coverflow"===ca.effect)&&fa.css({width:`${L.virtualSize+ca.spaceBetween}px`});ca.setWrapperSize&&fa.css({[p("width")]:`${L.virtualSize+ca.spaceBetween}px`});nb&&L.grid.updateWrapperSize(jb,Aa,p);if(!ca.centeredSlides){kb=
2644[];for(rb=0;rb<Aa.length;rb+=1)$a=Aa[rb],ca.roundLengths&&($a=Math.floor($a)),Aa[rb]<=L.virtualSize-ia&&kb.push($a);Aa=kb;1<Math.floor(L.virtualSize-ia)-Math.floor(Aa[Aa.length-1])&&Aa.push(L.virtualSize-ia)}0===Aa.length&&(Aa=[0]);0!==ca.spaceBetween&&(kb=L.isHorizontal()&&ma?"marginLeft":p("marginRight"),Ea.filter((Xa,wb)=>ca.cssMode?wb===Ea.length-1?!1:!0:!0).css({[kb]:`${eb}px`}));if(ca.centeredSlides&&ca.centeredSlidesBounds){let Xa=0;Ra.forEach(Bb=>{Xa+=Bb+(ca.spaceBetween?ca.spaceBetween:0)});
2645Xa-=ca.spaceBetween;const wb=Xa-ia;Aa=Aa.map(Bb=>0>Bb?-cb:Bb>wb?wb+ib:Bb)}if(ca.centerInsufficientSlides){let Xa=0;Ra.forEach(wb=>{Xa+=wb+(ca.spaceBetween?ca.spaceBetween:0)});Xa-=ca.spaceBetween;if(Xa<ia){const wb=(ia-Xa)/2;Aa.forEach((Bb,ob)=>{Aa[ob]=Bb-wb});Ka.forEach((Bb,ob)=>{Ka[ob]=Bb+wb})}}Object.assign(L,{slides:Ea,snapGrid:Aa,slidesGrid:Ka,slidesSizesGrid:Ra});if(ca.centeredSlides&&ca.cssMode&&!ca.centeredSlidesBounds){L.wrapperEl.style.setProperty("--swiper-centered-offset-before",`${-Aa[0]}px`);
2646L.wrapperEl.style.setProperty("--swiper-centered-offset-after",`${L.size/2-Ra[Ra.length-1]/2}px`);const Xa=-L.snapGrid[0],wb=-L.slidesGrid[0];L.snapGrid=L.snapGrid.map(Bb=>Bb+Xa);L.slidesGrid=L.slidesGrid.map(Bb=>Bb+wb)}wa!==Da&&L.emit("slidesLengthChange");Aa.length!==fb&&(L.params.watchOverflow&&L.checkOverflow(),L.emit("snapGridLengthChange"));Ka.length!==bb&&L.emit("slidesGridLengthChange");ca.watchSlidesProgress&&L.updateSlidesOffset()}},updateAutoHeight:function(p){const E=this,L=[],ca=E.virtual&&
2647E.params.virtual.enabled;let fa=0;"number"===typeof p?E.setTransition(p):!0===p&&E.setTransition(E.params.speed);var ia=ma=>ca?E.slides.filter(ua=>parseInt(ua.getAttribute("data-swiper-slide-index"),10)===ma)[0]:E.slides.eq(ma)[0];if("auto"!==E.params.slidesPerView&&1<E.params.slidesPerView)if(E.params.centeredSlides)E.visibleSlides.each(ma=>{L.push(ma)});else for(p=0;p<Math.ceil(E.params.slidesPerView);p+=1){const ma=E.activeIndex+p;if(ma>E.slides.length&&!ca)break;L.push(ia(ma))}else L.push(ia(E.activeIndex));
2648for(p=0;p<L.length;p+=1)"undefined"!==typeof L[p]&&(ia=L[p].offsetHeight,fa=ia>fa?ia:fa);(fa||0===fa)&&E.$wrapperEl.css("height",`${fa}px`)},updateSlidesOffset:function(){const p=this.slides;for(let E=0;E<p.length;E+=1)p[E].swiperSlideOffset=this.isHorizontal()?p[E].offsetLeft:p[E].offsetTop},updateSlidesProgress:function(p=this&&this.translate||0){const E=this.params,{slides:L,rtlTranslate:ca,snapGrid:fa}=this;if(0!==L.length){"undefined"===typeof L[0].swiperSlideOffset&&this.updateSlidesOffset();
2649var ia=-p;ca&&(ia=p);L.removeClass(E.slideVisibleClass);this.visibleSlidesIndexes=[];this.visibleSlides=[];for(p=0;p<L.length;p+=1){const ua=L[p];var ma=ua.swiperSlideOffset;E.cssMode&&E.centeredSlides&&(ma-=L[0].swiperSlideOffset);const wa=(ia+(E.centeredSlides?this.minTranslate():0)-ma)/(ua.swiperSlideSize+E.spaceBetween),Da=(ia-fa[0]+(E.centeredSlides?this.minTranslate():0)-ma)/(ua.swiperSlideSize+E.spaceBetween);ma=-(ia-ma);const Ea=ma+this.slidesSizesGrid[p];if(0<=ma&&ma<this.size-1||1<Ea&&Ea<=
2650this.size||0>=ma&&Ea>=this.size)this.visibleSlides.push(ua),this.visibleSlidesIndexes.push(p),L.eq(p).addClass(E.slideVisibleClass);ua.progress=ca?-wa:wa;ua.originalProgress=ca?-Da:Da}this.visibleSlides=h(this.visibleSlides)}},updateProgress:function(p){"undefined"===typeof p&&(p=this.rtlTranslate?-1:1,p=this&&this.translate&&this.translate*p||0);const E=this.params,L=this.maxTranslate()-this.minTranslate();let {progress:ca,isBeginning:fa,isEnd:ia}=this;const ma=fa,ua=ia;0===L?(ca=0,ia=fa=!0):(ca=
2651(p-this.minTranslate())/L,fa=0>=ca,ia=1<=ca);Object.assign(this,{progress:ca,isBeginning:fa,isEnd:ia});(E.watchSlidesProgress||E.centeredSlides&&E.autoHeight)&&this.updateSlidesProgress(p);
2651fa&&!ma&&this.emit("reachBeginning toEdge");ia&&!ua&&this.emit("reachEnd toEdge");(ma&&!fa||ua&&!ia)&&this.emit("fromEdge");this.emit("progress",ca)},updateSlidesClasses:function(){const {slides:p,params:E,$wrapperEl:L,activeIndex:ca,realIndex:fa}=this;var ia=this.virtual&&E.virtual.enabled;p.removeClass(`${E.slideActiveClass} ${E.slideNextClass} ${E.slidePrevClass} ${E.slideDuplicateActiveClass} ${E.slideDuplicateNextClass} ${E.slideDuplicatePrevClass}`);
2652var ma=ia?this.$wrapperEl.find(`.${E.slideClass}[data-swiper-slide-index="${ca}"]`):p.eq(ca);ma.addClass(E.slideActiveClass);E.loop&&(ma.hasClass(E.slideDuplicateClass)?L.children(`.${E.slideClass}:not(.${E.slideDuplicateClass})[data-swiper-slide-index="${fa}"]`).addClass(E.slideDuplicateActiveClass):L.children(`.${E.slideClass}.${E.slideDuplicateClass}[data-swiper-slide-index="${fa}"]`).addClass(E.slideDuplicateActiveClass));ia=ma.nextAll(`.${E.slideClass}`).eq(0).addClass(E.slideNextClass);E.loop&&
26530===ia.length&&(ia=p.eq(0),ia.addClass(E.slideNextClass));ma=ma.prevAll(`.${E.slideClass}`).eq(0).addClass(E.slidePrevClass);E.loop&&0===ma.length&&(ma=p.eq(-1),ma.addClass(E.slidePrevClass));E.loop&&(ia.hasClass(E.slideDuplicateClass)?L.children(`.${E.slideClass}:not(.${E.slideDuplicateClass})[data-swiper-slide-index="${ia.attr("data-swiper-slide-index")}"]`).addClass(E.slideDuplicateNextClass):L.children(`.${E.slideClass}.${E.slideDuplicateClass}[data-swiper-slide-index="${ia.attr("data-swiper-slide-index")}"]`).addClass(E.slideDuplicateNextClass),
2654ma.hasClass(E.slideDuplicateClass)?L.children(`.${E.slideClass}:not(.${E.slideDuplicateClass})[data-swiper-slide-index="${ma.attr("data-swiper-slide-index")}"]`).addClass(E.slideDuplicatePrevClass):L.children(`.${E.slideClass}.${E.slideDuplicateClass}[data-swiper-slide-index="${ma.attr("data-swiper-slide-index")}"]`).addClass(E.slideDuplicatePrevClass));this.emitSlidesClasses()},updateActiveIndex:function(p){var E=this.rtlTranslate?this.translate:-this.translate;const {slidesGrid:L,snapGrid:ca,params:fa,
2655activeIndex:ia,realIndex:ma,snapIndex:ua}=this;if("undefined"===typeof p){for(var wa=0;wa<L.length;wa+=1)"undefined"!==typeof L[wa+1]?E>=L[wa]&&E<L[wa+1]-(L[wa+1]-L[wa])/2?p=wa:E>=L[wa]&&E<L[wa+1]&&(p=wa+1):E>=L[wa]&&(p=wa);fa.normalizeSlideIndex&&(0>p||"undefined"===typeof p)&&(p=0)}0<=ca.indexOf(E)?E=ca.indexOf(E):(E=Math.min(fa.slidesPerGroupSkip,p),E+=Math.floor((p-E)/fa.slidesPerGroup));E>=ca.length&&(E=ca.length-1);p===ia?E!==ua&&(this.snapIndex=E,this.emit("snapIndexChange")):(wa=parseInt(this.slides.eq(p).attr("data-swiper-slide-index")||
2656p,10),Object.assign(this,{snapIndex:E,realIndex:wa,previousIndex:ia,activeIndex:p}),this.emit("activeIndexChange"),this.emit("snapIndexChange"),ma!==wa&&this.emit("realIndexChange"),(this.initialized||this.params.runCallbacksOnInit)&&this.emit("slideChange"))},updateClickedSlide:function(p){const E=this.params;p=h(p).closest(`.${E.slideClass}`)[0];let L=!1,ca;if(p)for(let fa=0;fa<this.slides.length;fa+=1)if(this.slides[fa]===p){L=!0;ca=fa;break}p&&L?(this.clickedSlide=p,this.clickedIndex=this.virtual&&
2657this.params.virtual.enabled?parseInt(h(p).attr("data-swiper-slide-index"),10):ca,E.slideToClickedSlide&&void 0!==this.clickedIndex&&this.clickedIndex!==this.activeIndex&&this.slideToClickedSlide()):this.clickedIndex=this.clickedSlide=void 0}},translate:{getTranslate:function(p=this.isHorizontal()?"x":"y"){const {params:E,rtlTranslate:L,translate:ca,$wrapperEl:fa}=this;if(E.virtualTranslate)return L?-ca:ca;if(E.cssMode)return ca;p=r(fa[0],p);L&&(p=-p);return p||0},setTranslate:function(p,E){const {rtlTranslate:L,
2658params:ca,$wrapperEl:fa,wrapperEl:ia,progress:ma}=this;var ua=0;let wa=0;this.isHorizontal()?ua=L?-p:p:wa=p;ca.roundLengths&&(ua=Math.floor(ua),wa=Math.floor(wa));ca.cssMode?ia[this.isHorizontal()?"scrollLeft":"scrollTop"]=this.isHorizontal()?-ua:-wa:ca.virtualTranslate||fa.transform(`translate3d(${ua}px, ${wa}px, ${0}px)`);this.previousTranslate=this.translate;this.translate=this.isHorizontal()?ua:wa;ua=this.maxTranslate()-this.minTranslate();(0===ua?0:(p-this.minTranslate())/ua)!==ma&&this.updateProgress(p);
2659this.emit("setTranslate",this.translate,E)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(p=0,E=this.params.speed,L=!0,ca=!0,fa){const ia=this,{params:ma,wrapperEl:ua}=ia;if(ia.animating&&ma.preventInteractionOnTransition)return!1;const wa=ia.minTranslate(),Da=ia.maxTranslate();p=ca&&p>wa?wa:ca&&p<Da?Da:p;ia.updateProgress(p);if(ma.cssMode){fa=ia.isHorizontal();if(0===E)ua[fa?"scrollLeft":"scrollTop"]=-p;
2660else{if(!ia.support.smoothScroll)return x({swiper:ia,targetPosition:-p,side:fa?"left":"top"}),!0;ua.scrollTo({[fa?"left":"top"]:-p,behavior:"smooth"})}return!0}0===E?(ia.setTransition(0),ia.setTranslate(p),L&&(ia.emit("beforeTransitionStart",E,fa),ia.emit("transitionEnd"))):(ia.setTransition(E),ia.setTranslate(p),L&&(ia.emit("beforeTransitionStart",E,fa),ia.emit("transitionStart")),ia.animating||(ia.animating=!0,ia.onTranslateToWrapperTransitionEnd||(ia.onTranslateToWrapperTransitionEnd=function(Ea){ia&&
2661!ia.destroyed&&Ea.target===this&&(ia.$wrapperEl[0].removeEventListener("transitionend",ia.onTranslateToWrapperTransitionEnd),ia.$wrapperEl[0].removeEventListener("webkitTransitionEnd",ia.onTranslateToWrapperTransitionEnd),ia.onTranslateToWrapperTransitionEnd=null,delete ia.onTranslateToWrapperTransitionEnd,L&&ia.emit("transitionEnd"))}),ia.$wrapperEl[0].addEventListener("transitionend",ia.onTranslateToWrapperTransitionEnd),ia.$wrapperEl[0].addEventListener("webkitTransitionEnd",ia.onTranslateToWrapperTransitionEnd)));
2662return!0}},transition:{setTransition:function(p,E){this.params.cssMode||this.$wrapperEl.transition(p);this.emit("setTransition",p,E)},transitionStart:function(p=!0,E){const {params:L}=this;L.cssMode||(L.autoHeight&&this.updateAutoHeight(),z({swiper:this,runCallbacks:p,direction:E,step:"Start"}))},transitionEnd:function(p=!0,E){const {params:L}=this;this.animating=!1;L.cssMode||(this.setTransition(0),z({swiper:this,runCallbacks:p,direction:E,step:"End"}))}},slide:{slideTo:function(p=0,E=this.params.speed,
2663L=!0,ca,fa){if("number"!==typeof p&&"string"!==typeof p)throw Error(`The 'index' argument cannot have type other than 'number' or 'string'. [${typeof p}] given.`);if("string"===typeof p){var ia=parseInt(p,10);if(!isFinite(ia))throw Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${p}] given.`);p=ia}const ma=this;0>p&&(p=0);const {params:ua,snapGrid:wa,slidesGrid:Da,previousIndex:Ea,activeIndex:Aa,rtlTranslate:Ka,wrapperEl:Ra,enabled:cb}=ma;if(ma.animating&&ua.preventInteractionOnTransition||
2664!cb&&!ca&&!fa)return!1;fa=Math.min(ma.params.slidesPerGroupSkip,p);fa+=Math.floor((p-fa)/ma.params.slidesPerGroup);fa>=wa.length&&(fa=wa.length-1);(Aa||ua.initialSlide||0)===(Ea||0)&&L&&ma.emit("beforeSlideChangeStart");fa=-wa[fa];ma.updateProgress(fa);if(ua.normalizeSlideIndex)for(ia=0;ia<Da.length;ia+=1){const fb=-Math.floor(100*fa),bb=Math.floor(100*Da[ia]),eb=Math.floor(100*Da[ia+1]);"undefined"!==typeof Da[ia+1]?fb>=bb&&fb<eb-(eb-bb)/2?p=ia:fb>=bb&&fb<eb&&(p=ia+1):fb>=bb&&(p=ia)}if(ma.initialized&&
2665p!==Aa&&(!ma.allowSlideNext&&fa<ma.translate&&fa<ma.minTranslate()||!ma.allowSlidePrev&&fa>ma.translate&&fa>ma.maxTranslate()&&(Aa||0)!==p))return!1;let ib;ib=p>Aa?"next":p<Aa?"prev":"reset";if(Ka&&-fa===ma.translate||!Ka&&fa===ma.translate)return ma.updateActiveIndex(p),ua.autoHeight&&ma.updateAutoHeight(),ma.updateSlidesClasses(),"slide"!==ua.effect&&ma.setTranslate(fa),"reset"!==ib&&(ma.transitionStart(L,ib),ma.transitionEnd(L,ib)),!1;if(ua.cssMode){ca=ma.isHorizontal();p=Ka?fa:-fa;if(0===E){if(E=
2666ma.virtual&&ma.params.virtual.enabled)ma.wrapperEl.style.scrollSnapType="none",ma._immediateVirtual=!0;Ra[ca?"scrollLeft":"scrollTop"]=p;E&&requestAnimationFrame(()=>{ma.wrapperEl.style.scrollSnapType="";ma._swiperImmediateVirtual=!1})}else{if(!ma.support.smoothScroll)return x({swiper:ma,targetPosition:p,side:ca?"left":"top"}),!0;Ra.scrollTo({[ca?"left":"top"]:p,behavior:"smooth"})}return!0}ma.setTransition(E);ma.setTranslate(fa);ma.updateActiveIndex(p);ma.updateSlidesClasses();ma.emit("beforeTransitionStart",
2667E,ca);ma.transitionStart(L,ib);0===E?ma.transitionEnd(L,ib):ma.animating||(ma.animating=!0,ma.onSlideToWrapperTransitionEnd||(ma.onSlideToWrapperTransitionEnd=function(fb){ma&&!ma.destroyed&&fb.target===this&&(ma.$wrapperEl[0].removeEventListener("transitionend",ma.onSlideToWrapperTransitionEnd),ma.$wrapperEl[0].removeEventListener("webkitTransitionEnd",ma.onSlideToWrapperTransitionEnd),ma.onSlideToWrapperTransitionEnd=null,delete ma.onSlideToWrapperTransitionEnd,ma.transitionEnd(L,ib))}),ma.$wrapperEl[0].addEventListener("transitionend",
2668ma.onSlideToWrapperTransitionEnd),ma.$wrapperEl[0].addEventListener("webkitTransitionEnd",ma.onSlideToWrapperTransitionEnd));return!0},slideToLoop:function(p=0,E=this.params.speed,L=!0,ca){this.params.loop&&(p+=this.loopedSlides);return this.slideTo(p,E,L,ca)},slideNext:function(p=this.params.speed,E=!0,L){const {animating:ca,enabled:fa,params:ia}=this;if(!fa)return this;var ma=ia.slidesPerGroup;"auto"===ia.slidesPerView&&1===ia.slidesPerGroup&&ia.slidesPerGroupAuto&&(ma=Math.max(this.slidesPerViewDynamic("current",
2669!0),1));ma=this.activeIndex<ia.slidesPerGroupSkip?1:ma;if(ia.loop){if(ca&&ia.loopPreventsSlide)return!1;this.loopFix();this._clientLeft=this.$wrapperEl[0].clientLeft}return ia.rewind&&this.isEnd?this.slideTo(0,p,E,L):this.slideTo(this.activeIndex+ma,p,E,L)},slidePrev:function(p=this.params.speed,E=!0,L){function ca(Ra){return 0>Ra?-Math.floor(Math.abs(Ra)):Math.floor(Ra)}const {params:fa,animating:ia,snapGrid:ma,slidesGrid:ua,rtlTranslate:wa,enabled:Da}=this;if(!Da)return this;if(fa.loop){if(ia&&
2670fa.loopPreventsSlide)return!1;this.loopFix();this._clientLeft=this.$wrapperEl[0].clientLeft}const Ea=ca(wa?this.translate:-this.translate);var Aa=ma.map(Ra=>ca(Ra));Aa=ma[Aa.indexOf(Ea)-1];if("undefined"===typeof Aa&&fa.cssMode){let Ra;ma.forEach((cb,ib)=>{Ea>=cb&&(Ra=ib)});"undefined"!==typeof Ra&&(Aa=ma[0<Ra?Ra-1:Ra])}let Ka=0;"undefined"!==typeof Aa&&(Ka=ua.indexOf(Aa),0>Ka&&(Ka=this.activeIndex-1),"auto"===fa.slidesPerView&&1===fa.slidesPerGroup&&fa.slidesPerGroupAuto&&(Ka=Ka-this.slidesPerViewDynamic("previous",
2671!0)+1,Ka=Math.max(Ka,0)));
2671return fa.rewind&&this.isBeginning?this.slideTo(this.slides.length-1,p,E,L):this.slideTo(Ka,p,E,L)},slideReset:function(p=this.params.speed,E=!0,L){return this.slideTo(this.activeIndex,p,E,L)},slideToClosest:function(p=this.params.speed,E=!0,L,ca=.5){let fa=this.activeIndex;var ia=Math.min(this.params.slidesPerGroupSkip,fa);ia+=Math.floor((fa-ia)/this.params.slidesPerGroup);const ma=this.rtlTranslate?this.translate:-this.translate;if(ma>=this.snapGrid[ia]){var ua=this.snapGrid[ia];
2672ma-ua>(this.snapGrid[ia+1]-ua)*ca&&(fa+=this.params.slidesPerGroup)}else ua=this.snapGrid[ia-1],ma-ua<=(this.snapGrid[ia]-ua)*ca&&(fa-=this.params.slidesPerGroup);fa=Math.max(fa,0);fa=Math.min(fa,this.slidesGrid.length-1);return this.slideTo(fa,p,E,L)},slideToClickedSlide:function(){const p=this,{params:E,$wrapperEl:L}=p,ca="auto"===E.slidesPerView?p.slidesPerViewDynamic():E.slidesPerView;let fa=p.clickedIndex,ia;E.loop?p.animating||(ia=parseInt(h(p.clickedSlide).attr("data-swiper-slide-index"),10),
2673E.centeredSlides?fa<p.loopedSlides-ca/2||fa>p.slides.length-p.loopedSlides+ca/2?(p.loopFix(),fa=L.children(`.${E.slideClass}[data-swiper-slide-index="${ia}"]:not(.${E.slideDuplicateClass})`).eq(0).index(),l(()=>{p.slideTo(fa)})):p.slideTo(fa):fa>p.slides.length-ca?(p.loopFix(),fa=L.children(`.${E.slideClass}[data-swiper-slide-index="${ia}"]:not(.${E.slideDuplicateClass})`).eq(0).index(),l(()=>{p.slideTo(fa)})):p.slideTo(fa)):p.slideTo(fa)}},loop:{loopCreate:function(){const p=this;var E=c();const {params:L,
2674$wrapperEl:ca}=p,fa=0<ca.children().length?h(ca.children()[0].parentNode):ca;fa.children(`.${L.slideClass}.${L.slideDuplicateClass}`).remove();let ia=fa.children(`.${L.slideClass}`);if(L.loopFillGroupWithBlank){const wa=L.slidesPerGroup-ia.length%L.slidesPerGroup;if(wa!==L.slidesPerGroup){for(let Da=0;Da<wa;Da+=1){const Ea=h(E.createElement("div")).addClass(`${L.slideClass} ${L.slideBlankClass}`);fa.append(Ea)}ia=fa.children(`.${L.slideClass}`)}}"auto"!==L.slidesPerView||L.loopedSlides||(L.loopedSlides=
2675ia.length);p.loopedSlides=Math.ceil(parseFloat(L.loopedSlides||L.slidesPerView,10));p.loopedSlides+=L.loopAdditionalSlides;p.loopedSlides>ia.length&&(p.loopedSlides=ia.length);const ma=[],ua=[];ia.each((wa,Da)=>{const Ea=h(wa);Da<p.loopedSlides&&ua.push(wa);Da<ia.length&&Da>=ia.length-p.loopedSlides&&ma.push(wa);Ea.attr("data-swiper-slide-index",Da)});for(E=0;E<ua.length;E+=1)fa.append(h(ua[E].cloneNode(!0)).addClass(L.slideDuplicateClass));for(E=ma.length-1;0<=E;--E)fa.prepend(h(ma[E].cloneNode(!0)).addClass(L.slideDuplicateClass))},
2676loopFix:function(){this.emit("beforeLoopFix");const {activeIndex:p,slides:E,loopedSlides:L,allowSlidePrev:ca,allowSlideNext:fa,snapGrid:ia,rtlTranslate:ma}=this;let ua;this.allowSlideNext=this.allowSlidePrev=!0;const wa=-ia[p]-this.getTranslate();p<L?(ua=E.length-3*L+p,this.slideTo(ua+L,0,!1,!0)&&0!==wa&&this.setTranslate((ma?-this.translate:this.translate)-wa)):p>=E.length-L&&(ua=-E.length+p+L,this.slideTo(ua+L,0,!1,!0)&&0!==wa&&this.setTranslate((ma?-this.translate:this.translate)-wa));this.allowSlidePrev=
2677ca;this.allowSlideNext=fa;this.emit("loopFix")},loopDestroy:function(){const {$wrapperEl:p,params:E,slides:L}=this;p.children(`.${E.slideClass}.${E.slideDuplicateClass},.${E.slideClass}.${E.slideBlankClass}`).remove();L.removeAttr("data-swiper-slide-index")}},grabCursor:{setGrabCursor:function(p){if(!(this.support.touch||!this.params.simulateTouch||this.params.watchOverflow&&this.isLocked||this.params.cssMode)){var E="container"===this.params.touchEventsTarget?this.el:this.wrapperEl;E.style.cursor=
2678"move";E.style.cursor=p?"-webkit-grabbing":"-webkit-grab";E.style.cursor=p?"-moz-grabbin":"-moz-grab";E.style.cursor=p?"grabbing":"grab"}},unsetGrabCursor:function(){this.support.touch||this.params.watchOverflow&&this.isLocked||this.params.cssMode||(this["container"===this.params.touchEventsTarget?"el":"wrapperEl"].style.cursor="")}},events:{attachEvents:function(){const p=c(),{params:E,support:L}=this;this.onTouchStart=ba.bind(this);this.onTouchMove=v.bind(this);this.onTouchEnd=K.bind(this);E.cssMode&&
2679(this.onScroll=ja.bind(this));this.onClick=da.bind(this);L.touch&&!ab&&(p.addEventListener("touchstart",ea),ab=!0);Oa(this,"on")},detachEvents:function(){Oa(this,"off")}},breakpoints:{setBreakpoint:function(){const {activeIndex:p,initialized:E,loopedSlides:L=0,params:ca,$el:fa}=this;var ia=ca.breakpoints;
2679if(ia&&(!ia||0!==Object.keys(ia).length)){var ma=this.getBreakpoint(ia,this.params.breakpointsBase,this.el);if(ma&&this.currentBreakpoint!==ma){ia=(ma in ia?ia[ma]:void 0)||this.originalParams;var ua=
2680this.grid&&ca.grid&&1<ca.grid.rows,wa=this.grid&&ia.grid&&1<ia.grid.rows,Da=ca.enabled;ua&&!wa?(fa.removeClass(`${ca.containerModifierClass}grid ${ca.containerModifierClass}grid-column`),this.emitContainerClasses()):!ua&&wa&&(fa.addClass(`${ca.containerModifierClass}grid`),(ia.grid.fill&&"column"===ia.grid.fill||!ia.grid.fill&&"column"===ca.grid.fill)&&fa.addClass(`${ca.containerModifierClass}grid-column`),this.emitContainerClasses());wa=ia.direction&&ia.direction!==ca.direction;ua=ca.loop&&(ia.slidesPerView!==
2681ca.slidesPerView||wa);wa&&E&&this.changeDirection();u(this.params,ia);wa=this.params.enabled;Object.assign(this,{allowTouchMove:this.params.allowTouchMove,allowSlideNext:this.params.allowSlideNext,allowSlidePrev:this.params.allowSlidePrev});Da&&!wa?this.disable():!Da&&wa&&this.enable();this.currentBreakpoint=ma;this.emit("_beforeBreakpoint",ia);ua&&E&&(this.loopDestroy(),this.loopCreate(),this.updateSlides(),this.slideTo(p-L+this.loopedSlides,0,!1));this.emit("breakpoint",ia)}}},getBreakpoint:function(p,
2682E="window",L){if(p&&("container"!==E||L)){var ca=!1,fa=d(),ia="window"===E?fa.innerHeight:L.clientHeight;p=Object.keys(p).map(ma=>{if("string"===typeof ma&&0===ma.indexOf("@")){const ua=parseFloat(ma.substr(1));return{value:ia*ua,point:ma}}return{value:ma,point:ma}});p.sort((ma,ua)=>
2682parseInt(ma.value,10)-parseInt(ua.value,10));for(let ma=0;ma<p.length;ma+=1){const {point:ua,value:wa}=p[ma];"window"===E?fa.matchMedia(`(min-width: ${wa}px)`).matches&&(ca=ua):wa<=L.clientWidth&&(ca=ua)}return ca||"max"}}},
2683checkOverflow:{checkOverflow:function(){const {isLocked:p,params:E}=this,{slidesOffsetBefore:L}=E;if(L){const ca=this.slides.length-1;this.isLocked=this.size>this.slidesGrid[ca]+this.slidesSizesGrid[ca]+2*L}else this.isLocked=1===this.snapGrid.length;!0===E.allowSlideNext&&(this.allowSlideNext=!this.isLocked);!0===E.allowSlidePrev&&(this.allowSlidePrev=!this.isLocked);p&&p!==this.isLocked&&(this.isEnd=!1);p!==this.isLocked&&this.emit(this.isLocked?"lock":"unlock")}},classes:{addClasses:function(){const {classNames:p,
2684params:E,rtl:L,$el:ca,device:fa,support:ia}=this,ma=ra(["initialized",E.direction,{"pointer-events":!ia.touch},{"free-mode":this.params.freeMode&&E.freeMode.enabled},{autoheight:E.autoHeight},{rtl:L},{grid:E.grid&&1<E.grid.rows},{"grid-column":E.grid&&1<E.grid.rows&&"column"===E.grid.fill},{android:fa.android},{ios:fa.ios},{"css-mode":E.cssMode},{centered:E.cssMode&&E.centeredSlides}],E.containerModifierClass);p.push(...ma);ca.addClass([...p].join(" "));this.emitContainerClasses()},removeClasses:function(){const {$el:p,
2685classNames:E}=this;p.removeClass(E.join(" "));this.emitContainerClasses()}},images:{loadImage:function(p,E,L,ca,fa,ia){function ma(){ia&&ia()}const ua=d();h(p).parent("picture")[0]||p.complete&&fa?ma():E?(p=new ua.Image,p.onload=ma,p.onerror=ma,ca&&(p.sizes=ca),L&&(p.srcset=L),E&&(p.src=E)):ma()},preloadImages:function(){function p(){"undefined"!==typeof E&&null!==E&&E&&!E.destroyed&&(void 0!==E.imagesLoaded&&(E.imagesLoaded+=1),E.imagesLoaded===E.imagesToLoad.length&&(E.params.updateOnImagesReady&&
2686E.update(),E.emit("imagesReady")))}const E=this;E.imagesToLoad=E.$el.find("img");for(let L=0;L<E.imagesToLoad.length;L+=1){const ca=E.imagesToLoad[L];E.loadImage(ca,ca.currentSrc||ca.getAttribute("src"),ca.srcset||ca.getAttribute("srcset"),ca.sizes||ca.getAttribute("sizes"),!0,p)}}}},ta={};class va{constructor(...p){let E,L;1===p.length&&p[0].constructor&&"Object"===Object.prototype.toString.call(p[0]).slice(8,-1)?L=p[0]:[E,L]=p;L||={};L=u({},L);E&&!L.el&&(L.el=E);if(L.el&&1<h(L.el).length){const ia=
2687[];h(L.el).each(ma=>{ma=u({},L,{el:ma});ia.push(new va(ma))});return ia}const ca=this;ca.__swiper__=!0;ca.support=y();ca.device=aa({userAgent:L.userAgent});db||=ha();ca.browser=db;ca.eventsListeners={};ca.eventsAnyListeners=[];ca.modules=[...ca.__modules__];L.modules&&Array.isArray(L.modules)&&ca.modules.push(...L.modules);const fa={};ca.modules.forEach(ia=>{ia({swiper:ca,extendParams:za(L,fa),on:ca.on.bind(ca),once:ca.once.bind(ca),off:ca.off.bind(ca),emit:ca.emit.bind(ca)})});p=u({},Ga,fa);ca.params=
2688u({},p,ta,L);ca.originalParams=u({},ca.params);ca.passedParams=u({},L);
2688ca.params&&ca.params.on&&Object.keys(ca.params.on).forEach(ia=>{ca.on(ia,ca.params.on[ia])});if(ca.params&&ca.params.onAny)ca.onAny(ca.params.onAny);ca.$=h;Object.assign(ca,{enabled:ca.params.enabled,el:E,classNames:[],slides:h(),slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal(){return"horizontal"===ca.params.direction},isVertical(){return"vertical"===ca.params.direction},activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,
2689translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,allowSlideNext:ca.params.allowSlideNext,allowSlidePrev:ca.params.allowSlidePrev,touchEvents:function(){const ia=["touchstart","touchmove","touchend","touchcancel"],ma=["pointerdown","pointermove","pointerup"];ca.touchEventsTouch={start:ia[0],move:ia[1],end:ia[2],cancel:ia[3]};ca.touchEventsDesktop={start:ma[0],move:ma[1],end:ma[2]};return ca.support.touch||!ca.params.simulateTouch?ca.touchEventsTouch:ca.touchEventsDesktop}(),touchEventsData:{isTouched:void 0,
2690isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:ca.params.focusableElements,lastClickTime:m(),clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,isTouchEvent:void 0,startMoving:void 0},allowClick:!0,allowTouchMove:ca.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0});ca.emit("_swiper");ca.params.init&&ca.init();
2691return ca}enable(){this.enabled||(this.enabled=!0,this.params.grabCursor&&this.setGrabCursor(),this.emit("enable"))}disable(){this.enabled&&(this.enabled=!1,this.params.grabCursor&&this.unsetGrabCursor(),this.emit("disable"))}setProgress(p,E){p=Math.min(Math.max(p,0),1);const L=this.minTranslate(),ca=this.maxTranslate();this.translateTo((ca-L)*p+L,"undefined"===typeof E?0:E);this.updateActiveIndex();this.updateSlidesClasses()}emitContainerClasses(){const p=this;if(p.params._emitClasses&&p.el){var E=
2692p.el.className.split(" ").filter(L=>0===L.indexOf("swiper")||0===L.indexOf(p.params.containerModifierClass));p.emit("_containerClasses",E.join(" "))}}getSlideClasses(p){const E=this;return p.className.split(" ").filter(L=>0===L.indexOf("swiper-slide")||0===L.indexOf(E.params.slideClass)).join(" ")}emitSlidesClasses(){const p=this;if(p.params._emitClasses&&p.el){var E=[];p.slides.each(L=>{const ca=p.getSlideClasses(L);E.push({slideEl:L,classNames:ca});p.emit("_slideClass",L,ca)});p.emit("_slideClasses",
2693E)}}slidesPerViewDynamic(p="current",E=!1){const {params:L,slides:ca,slidesGrid:fa,slidesSizesGrid:ia,size:ma,activeIndex:ua}=this;let wa=1;if(L.centeredSlides){E=ca[ua].swiperSlideSize;var Da;for(p=ua+1;p<ca.length;p+=1)ca[p]&&!Da&&(E+=ca[p].swiperSlideSize,wa+=1,E>ma&&(Da=!0));for(p=ua-1;0<=p;--p)ca[p]&&!Da&&(E+=ca[p].swiperSlideSize,wa+=1,E>ma&&(Da=!0))}else if("current"===p)for(Da=ua+1;Da<ca.length;Da+=1){if(E?fa[Da]+ia[Da]-fa[ua]<ma:fa[Da]-fa[ua]<ma)wa+=1}else for(Da=ua-1;0<=Da;--Da)fa[ua]-fa[Da]<
2694ma&&(wa+=1);return wa}update(){function p(){const ia=Math.min(Math.max(E.rtlTranslate?-1*E.translate:E.translate,E.maxTranslate()),E.minTranslate());E.setTranslate(ia);E.updateActiveIndex();E.updateSlidesClasses()}const E=this;if(E&&!E.destroyed){var {snapGrid:L,params:ca}=E;ca.breakpoints&&E.setBreakpoint();E.updateSize();E.updateSlides();E.updateProgress();E.updateSlidesClasses();var fa;E.params.freeMode&&E.params.freeMode.enabled?(p(),E.params.autoHeight&&E.updateAutoHeight()):(fa=("auto"===E.params.slidesPerView||
26951<E.params.slidesPerView)&&E.isEnd&&!E.params.centeredSlides?E.slideTo(E.slides.length-1,0,!1,!0):E.slideTo(E.activeIndex,0,!1,!0))||p();ca.watchOverflow&&L!==E.snapGrid&&E.checkOverflow();E.emit("update")}}changeDirection(p,E=!0){const L=this.params.direction;p||="horizontal"===L?"vertical":"horizontal";if(p===L||"horizontal"!==p&&"vertical"!==p)return this;this.$el.removeClass(`${this.params.containerModifierClass}${L}`).addClass(`${this.params.containerModifierClass}${p}`);this.emitContainerClasses();
2696this.params.direction=p;this.slides.each(ca=>{"vertical"===p?ca.style.width="":ca.style.height=""});
2696this.emit("changeDirection");E&&this.update();return this}mount(p){const E=this;if(E.mounted)return!0;const L=h(p||E.params.el);p=L[0];if(!p)return!1;p.swiper=E;const ca=()=>`.${(E.params.wrapperClass||"").trim().split(" ").join(".")}`;let fa=(()=>{if(p&&p.shadowRoot&&p.shadowRoot.querySelector){const ia=h(p.shadowRoot.querySelector(ca()));ia.children=ma=>L.children(ma);return ia}return L.children(ca())})();
2697if(0===fa.length&&E.params.createElements){const ia=c().createElement("div");fa=h(ia);ia.className=E.params.wrapperClass;L.append(ia);L.children(`.${E.params.slideClass}`).each(ma=>{fa.append(ma)})}Object.assign(E,{$el:L,el:p,$wrapperEl:fa,wrapperEl:fa[0],mounted:!0,rtl:"rtl"===p.dir.toLowerCase()||"rtl"===L.css("direction"),rtlTranslate:"horizontal"===E.params.direction&&("rtl"===p.dir.toLowerCase()||"rtl"===L.css("direction")),wrongRTL:"-webkit-box"===fa.css("display")});return!0}init(p){if(this.initialized||
2698!1===this.mount(p))return this;this.emit("beforeInit");this.params.breakpoints&&this.setBreakpoint();this.addClasses();this.params.loop&&this.loopCreate();this.updateSize();this.updateSlides();this.params.watchOverflow&&this.checkOverflow();this.params.grabCursor&&this.enabled&&this.setGrabCursor();this.params.preloadImages&&this.preloadImages();this.params.loop?this.slideTo(this.params.initialSlide+this.loopedSlides,0,this.params.runCallbacksOnInit,!1,!0):this.slideTo(this.params.initialSlide,0,
2699this.params.runCallbacksOnInit,!1,!0);this.attachEvents();this.initialized=!0;this.emit("init");this.emit("afterInit");return this}destroy(p=!0,E=!0){const L=this,{params:ca,$el:fa,$wrapperEl:ia,slides:ma}=L;if("undefined"===typeof L.params||L.destroyed)return null;L.emit("beforeDestroy");L.initialized=!1;L.detachEvents();ca.loop&&L.loopDestroy();E&&(L.removeClasses(),fa.removeAttr("style"),ia.removeAttr("style"),ma&&ma.length&&ma.removeClass([ca.slideVisibleClass,ca.slideActiveClass,ca.slideNextClass,
2700ca.slidePrevClass].join(" ")).removeAttr("style").removeAttr("data-swiper-slide-index"));L.emit("destroy");Object.keys(L.eventsListeners).forEach(ua=>{L.off(ua)});!1!==p&&(L.$el[0].swiper=null,k(L));L.destroyed=!0;return null}static extendDefaults(p){u(ta,p)}static get extendedDefaults(){return ta}static get defaults(){return Ga}static installModule(p){va.prototype.__modules__||(va.prototype.__modules__=[]);const E=va.prototype.__modules__;"function"===typeof p&&0>E.indexOf(p)&&E.push(p)}static use(p){if(Array.isArray(p))return p.forEach(E=>
2701va.installModule(E)),va;va.installModule(p);return va}}Object.keys(la).forEach(p=>{Object.keys(la[p]).forEach(E=>{va.prototype[E]=la[p][E]})});va.use([function({swiper:p,on:E,emit:L}){const ca=d();let fa=null;const ia=()=>{p&&!p.destroyed&&p.initialized&&(L("beforeResize"),L("resize"))},ma=()=>{p&&!p.destroyed&&p.initialized&&(fa=new ResizeObserver(wa=>{const {width:Da,height:Ea}=p;let Aa=Da,Ka=Ea;wa.forEach(({contentBoxSize:Ra,contentRect:cb,target:ib})=>{ib&&ib!==p.el||(Aa=cb?cb.width:(Ra[0]||Ra).inlineSize,
2702Ka=cb?cb.height:(Ra[0]||Ra).blockSize)});Aa===Da&&Ka===Ea||ia()}),fa.observe(p.el))},ua=()=>{p&&!p.destroyed&&p.initialized&&L("orientationchange")};E("init",()=>{p.params.resizeObserver&&"undefined"!==typeof ca.ResizeObserver?ma():(ca.addEventListener("resize",ia),ca.addEventListener("orientationchange",ua))});E("destroy",()=>{fa&&fa.unobserve&&p.el&&(fa.unobserve(p.el),fa=null);ca.removeEventListener("resize",ia);ca.removeEventListener("orientationchange",ua)})},function({swiper:p,extendParams:E,
2703on:L,emit:ca}){const fa=[],ia=d(),ma=(ua,wa={})=>{const Da=new (ia.MutationObserver||ia.WebkitMutationObserver)(Ea=>{if(1===Ea.length)ca("observerUpdate",Ea[0]);else{var Aa=function(){ca("observerUpdate",Ea[0])};ia.requestAnimationFrame?ia.requestAnimationFrame(Aa):ia.setTimeout(Aa,0)}});Da.observe(ua,{attributes:"undefined"===typeof wa.attributes?!0:wa.attributes,childList:"undefined"===typeof wa.childList?!0:wa.childList,characterData:"undefined"===typeof wa.characterData?!0:wa.characterData});
2704fa.push(Da)};E({observer:!1,observeParents:!1,observeSlideChildren:!1});L("init",()=>{if(p.params.observer){if(p.params.observeParents){const ua=p.$el.parents();for(let wa=0;wa<ua.length;wa+=1)ma(ua[wa])}ma(p.$el[0],{childList:p.params.observeSlideChildren});ma(p.$wrapperEl[0],{attributes:!1})}});L("destroy",()=>{fa.forEach(ua=>{ua.disconnect()});fa.splice(0,fa.length)})}]);va.use([function({swiper:p,extendParams:E,on:L}){function ca(ma,ua){const wa=p.params.virtual;if(wa.cache&&p.virtual.cache[ua])return p.virtual.cache[ua];
2705ma=wa.renderSlide?h(wa.renderSlide.call(p,ma,ua)):h(`<div class="${p.params.slideClass}" data-swiper-slide-index="${ua}">${ma}</div>`);ma.attr("data-swiper-slide-index")||ma.attr("data-swiper-slide-index",ua);wa.cache&&(p.virtual.cache[ua]=ma);return ma}function fa(ma){function ua(){p.updateSlides();p.updateProgress();p.updateSlidesClasses();p.lazy&&p.params.lazy.enabled&&p.lazy.load()}const {slidesPerView:wa,slidesPerGroup:Da,centeredSlides:Ea}=p.params,{addSlidesBefore:Aa,addSlidesAfter:Ka}=p.params.virtual,
2706{from:Ra,to:cb,slides:ib,slidesGrid:fb,offset:bb}=p.virtual;p.params.cssMode||p.updateActiveIndex();var eb=p.activeIndex||0;let kb;kb=p.rtlTranslate?"right":p.isHorizontal()?"left":"top";if(Ea){var rb=Math.floor(wa/2)+Da+Ka;var $a=Math.floor(wa/2)+Da+Aa}else rb=wa+(Da-1)+Ka,$a=Da+Aa;const nb=Math.max((eb||0)-$a,0),vb=Math.min((eb||0)+rb,ib.length-1);eb=(p.slidesGrid[nb]||0)-(p.slidesGrid[0]||0);Object.assign(p.virtual,{from:nb,to:vb,offset:eb,slidesGrid:p.slidesGrid});if(Ra!==nb||cb!==vb||ma)if(p.params.virtual.renderExternal)p.params.virtual.renderExternal.call(p,
2707{offset:eb,from:nb,to:vb,slides:function(){const Ya=[];for(let Xa=nb;Xa<=vb;Xa+=1)Ya.push(ib[Xa]);return Ya}()}),p.params.virtual.renderExternalUpdate&&ua();else{rb=[];$a=[];if(ma)p.$wrapperEl.find(`.${p.params.slideClass}`).remove();else for(var jb=Ra;jb<=cb;jb+=1)(jb<nb||jb>vb)&&p.$wrapperEl.find(`.${p.params.slideClass}[data-swiper-slide-index="${jb}"]`).remove();for(jb=0;jb<ib.length;jb+=1)jb>=nb&&jb<=vb&&("undefined"===typeof cb||ma?$a.push(jb):(jb>cb&&$a.push(jb),jb<Ra&&rb.push(jb)));$a.forEach(Ya=>
2708{p.$wrapperEl.append(ca(ib[Ya],Ya))});rb.sort((Ya,Xa)=>
2708Xa-Ya).forEach(Ya=>{p.$wrapperEl.prepend(ca(ib[Ya],Ya))});p.$wrapperEl.children(".swiper-slide").css(kb,`${eb}px`);ua()}else p.slidesGrid!==fb&&eb!==bb&&p.slides.css(kb,`${eb}px`),p.updateProgress()}E({virtual:{enabled:!1,slides:[],cache:!0,renderSlide:null,renderExternal:null,renderExternalUpdate:!0,addSlidesBefore:0,addSlidesAfter:0}});let ia;p.virtual={cache:{},from:void 0,to:void 0,slides:[],offset:0,slidesGrid:[]};L("beforeInit",()=>{p.params.virtual.enabled&&
2709(p.virtual.slides=p.params.virtual.slides,p.classNames.push(`${p.params.containerModifierClass}virtual`),p.params.watchSlidesProgress=!0,p.originalParams.watchSlidesProgress=!0,p.params.initialSlide||fa())});L("setTranslate",()=>{p.params.virtual.enabled&&(p.params.cssMode&&!p._immediateVirtual?(clearTimeout(ia),ia=setTimeout(()=>{fa()},100)):fa())});L("init update resize",()=>{p.params.virtual.enabled&&p.params.cssMode&&p.wrapperEl.style.setProperty("--swiper-virtual-size",`${p.virtualSize}px`)});
2710Object.assign(p.virtual,{appendSlide:function(ma){if("object"===typeof ma&&"length"in ma)for(let ua=0;ua<ma.length;ua+=1)ma[ua]&&p.virtual.slides.push(ma[ua]);else p.virtual.slides.push(ma);fa(!0)},prependSlide:function(ma){const ua=p.activeIndex;var wa=ua+1;let Da=1;if(Array.isArray(ma)){for(wa=0;wa<ma.length;wa+=1)ma[wa]&&p.virtual.slides.unshift(ma[wa]);wa=ua+ma.length;Da=ma.length}else p.virtual.slides.unshift(ma);if(p.params.virtual.cache){const Ea=p.virtual.cache,Aa={};Object.keys(Ea).forEach(Ka=>
2711{const Ra=Ea[Ka],cb=Ra.attr("data-swiper-slide-index");cb&&Ra.attr("data-swiper-slide-index",parseInt(cb,10)+Da);Aa[parseInt(Ka,10)+Da]=Ra});p.virtual.cache=Aa}fa(!0);p.slideTo(wa,0)},removeSlide:function(ma){if("undefined"!==typeof ma&&null!==ma){var ua=p.activeIndex;if(Array.isArray(ma))for(let wa=ma.length-1;0<=wa;--wa)p.virtual.slides.splice(ma[wa],1),p.params.virtual.cache&&delete p.virtual.cache[ma[wa]],ma[wa]<ua&&--ua,ua=Math.max(ua,0);else p.virtual.slides.splice(ma,1),p.params.virtual.cache&&
2712delete p.virtual.cache[ma],ma<ua&&--ua,ua=Math.max(ua,0);fa(!0);p.slideTo(ua,0)}},removeAllSlides:function(){p.virtual.slides=[];p.params.virtual.cache&&(p.virtual.cache={});fa(!0);p.slideTo(0,0)},update:fa})},function({swiper:p,extendParams:E,on:L,emit:ca}){function fa(Da){if(p.enabled){var {rtlTranslate:Ea}=p;Da.originalEvent&&(Da=Da.originalEvent);var Aa=Da.keyCode||Da.charCode,Ka=p.params.keyboard.pageUpDown,Ra=Ka&&33===Aa;Ka=Ka&&34===Aa;var cb=37===Aa,ib=39===Aa,fb=38===Aa,bb=40===Aa;if(!p.allowSlideNext&&
2713(p.isHorizontal()&&ib||p.isVertical()&&bb||Ka)||!p.allowSlidePrev&&(p.isHorizontal()&&cb||p.isVertical()&&fb||Ra))return!1;if(!(Da.shiftKey||Da.altKey||Da.ctrlKey||Da.metaKey||ua.activeElement&&ua.activeElement.nodeName&&("input"===ua.activeElement.nodeName.toLowerCase()||"textarea"===ua.activeElement.nodeName.toLowerCase()))){if(p.params.keyboard.onlyInViewport&&(Ra||Ka||cb||ib||fb||bb)){let nb=!1;if(0<p.$el.parents(`.${p.params.slideClass}`).length&&0===p.$el.parents(`.${p.params.slideActiveClass}`).length)return;
2714var eb=p.$el,kb=eb[0].clientWidth,rb=eb[0].clientHeight;eb=wa.innerWidth;const vb=wa.innerHeight;var $a=p.$el.offset();Ea&&($a.left-=p.$el[0].scrollLeft);kb=[[$a.left,$a.top],[$a.left+kb,$a.top],[$a.left,$a.top+rb],[$a.left+kb,$a.top+rb]];for(rb=0;rb<kb.length;rb+=1)$a=kb[rb],0<=$a[0]&&$a[0]<=eb&&0<=$a[1]&&$a[1]<=vb&&(0!==$a[0]||0!==$a[1])&&(nb=!0);if(!nb)return}if(p.isHorizontal()){if(Ra||Ka||cb||ib)Da.preventDefault?Da.preventDefault():Da.returnValue=!1;((Ka||ib)&&!Ea||(Ra||cb)&&Ea)&&p.slideNext();
2715((Ra||cb)&&!Ea||(Ka||ib)&&Ea)&&p.slidePrev()}else{if(Ra||Ka||fb||bb)Da.preventDefault?Da.preventDefault():Da.returnValue=!1;(Ka||bb)&&p.slideNext();(Ra||fb)&&p.slidePrev()}ca("keyPress",Aa)}}}function ia(){p.keyboard.enabled||(h(ua).on("keydown",fa),p.keyboard.enabled=!0)}function ma(){p.keyboard.enabled&&(h(ua).off("keydown",fa),p.keyboard.enabled=!1)}const ua=c(),wa=d();p.keyboard={enabled:!1};E({keyboard:{enabled:!1,onlyInViewport:!0,pageUpDown:!0}});L("init",()=>{p.params.keyboard.enabled&&ia()});
2716L("destroy",()=>{p.keyboard.enabled&&ma()});Object.assign(p.keyboard,{enable:ia,disable:ma})},function({swiper:p,extendParams:E,on:L,emit:ca}){function fa(eb){let kb=0,rb=0,$a,nb;"detail"in eb&&(rb=eb.detail);"wheelDelta"in eb&&(rb=-eb.wheelDelta/120);
2716"wheelDeltaY"in eb&&(rb=-eb.wheelDeltaY/120);"wheelDeltaX"in eb&&(kb=-eb.wheelDeltaX/120);"axis"in eb&&eb.axis===eb.HORIZONTAL_AXIS&&(kb=rb,rb=0);$a=10*kb;nb=10*rb;"deltaY"in eb&&(nb=eb.deltaY);"deltaX"in eb&&($a=eb.deltaX);eb.shiftKey&&!$a&&($a=nb,
2717nb=0);($a||nb)&&eb.deltaMode&&(1===eb.deltaMode?($a*=40,nb*=40):($a*=800,nb*=800));$a&&!kb&&(kb=1>$a?-1:1);nb&&!rb&&(rb=1>nb?-1:1);return{spinX:kb,spinY:rb,pixelX:$a,pixelY:nb}}function ia(){p.enabled&&(p.mouseEntered=!0)}function ma(){p.enabled&&(p.mouseEntered=!1)}function ua(eb){if(p.params.mousewheel.thresholdDelta&&eb.delta<p.params.mousewheel.thresholdDelta||p.params.mousewheel.thresholdTime&&m()-ib<p.params.mousewheel.thresholdTime)return!1;if(6<=eb.delta&&60>m()-ib)return!0;0>eb.direction?
2718p.isEnd&&!p.params.loop||p.animating||(p.slideNext(),ca("scroll",eb.raw)):p.isBeginning&&!p.params.loop||p.animating||(p.slidePrev(),ca("scroll",eb.raw));ib=(new Ra.Date).getTime();return!1}function wa(eb){const kb=p.params.mousewheel;if(0>eb.direction){if(p.isEnd&&!p.params.loop&&kb.releaseOnEdges)return!0}else if(p.isBeginning&&!p.params.loop&&kb.releaseOnEdges)return!0;return!1}function Da(eb){let kb=eb;var rb=!0;if(p.enabled){var $a=p.params.mousewheel;p.params.cssMode&&kb.preventDefault();var nb=
2719p.$el;"container"!==p.params.mousewheel.eventsTarget&&(nb=h(p.params.mousewheel.eventsTarget));if(!p.mouseEntered&&!nb[0].contains(kb.target)&&!$a.releaseOnEdges)return!0;kb.originalEvent&&(kb=kb.originalEvent);nb=0;nb=p.rtlTranslate?-1:1;rb=fa(kb);if($a.forceToAxis)if(p.isHorizontal())if(Math.abs(rb.pixelX)>Math.abs(rb.pixelY))nb*=-rb.pixelX;else return!0;else if(Math.abs(rb.pixelY)>Math.abs(rb.pixelX))nb=-rb.pixelY;else return!0;else nb=Math.abs(rb.pixelX)>Math.abs(rb.pixelY)?-rb.pixelX*nb:-rb.pixelY;
2720if(0===nb)return!0;$a.invert&&(nb=-nb);rb=p.getTranslate()+nb*$a.sensitivity;rb>=p.minTranslate()&&(rb=p.minTranslate());rb<=p.maxTranslate()&&(rb=p.maxTranslate());(rb=p.params.loop?!0:!(rb===p.minTranslate()||rb===p.maxTranslate()))&&p.params.nested&&kb.stopPropagation();if(p.params.freeMode&&p.params.freeMode.enabled){const jb={time:m(),delta:Math.abs(nb),direction:Math.sign(nb)};eb=fb&&jb.time<fb.time+500&&jb.delta<=fb.delta&&jb.direction===fb.direction;if(!eb){fb=void 0;p.params.loop&&p.loopFix();
2721$a=p.getTranslate()+nb*$a.sensitivity;rb=p.isBeginning;var vb=p.isEnd;$a>=p.minTranslate()&&($a=p.minTranslate());$a<=p.maxTranslate()&&($a=p.maxTranslate());p.setTransition(0);p.setTranslate($a);p.updateProgress();p.updateActiveIndex();p.updateSlidesClasses();(!rb&&p.isBeginning||!vb&&p.isEnd)&&p.updateSlidesClasses();if(p.params.freeMode.sticky){clearTimeout(cb);cb=void 0;15<=bb.length&&bb.shift();rb=bb.length?bb[bb.length-1]:void 0;vb=bb[0];bb.push(jb);if(rb&&(jb.delta>rb.delta||jb.direction!==
2722rb.direction))bb.splice(0);else if(15<=bb.length&&500>jb.time-vb.time&&1<=vb.delta-jb.delta&&6>=jb.delta){const Ya=0<nb?.8:.2;fb=jb;bb.splice(0);cb=l(()=>{p.slideToClosest(p.params.speed,!0,void 0,Ya)},0)}cb||=l(()=>{fb=jb;bb.splice(0);p.slideToClosest(p.params.speed,!0,void 0,.5)},500)}eb||ca("scroll",kb);p.params.autoplay&&p.params.autoplayDisableOnInteraction&&p.autoplay.stop();if($a===p.minTranslate()||$a===p.maxTranslate())return!0}}else if(nb={time:m(),delta:Math.abs(nb),direction:Math.sign(nb),
2723raw:eb},2<=bb.length&&bb.shift(),$a=bb.length?bb[bb.length-1]:void 0,bb.push(nb),$a?(nb.direction!==$a.direction||nb.delta>$a.delta||nb.time>$a.time+150)&&ua(nb):ua(nb),wa(nb))return!0;kb.preventDefault?kb.preventDefault():kb.returnValue=!1;return!1}}function Ea(eb){let kb=p.$el;"container"!==p.params.mousewheel.eventsTarget&&(kb=h(p.params.mousewheel.eventsTarget));kb[eb]("mouseenter",ia);kb[eb]("mouseleave",ma);kb[eb]("wheel",Da)}function Aa(){if(p.params.cssMode)return p.wrapperEl.removeEventListener("wheel",
2724Da),!0;if(p.mousewheel.enabled)return!1;Ea("on");return p.mousewheel.enabled=!0}function Ka(){if(p.params.cssMode)return p.wrapperEl.addEventListener(event,Da),!0;if(!p.mousewheel.enabled)return!1;Ea("off");p.mousewheel.enabled=!1;return!0}const Ra=d();E({mousewheel:{enabled:!1,releaseOnEdges:!1,invert:!1,forceToAxis:!1,sensitivity:1,eventsTarget:"container",thresholdDelta:null,thresholdTime:null}});p.mousewheel={enabled:!1};let cb,ib=m(),fb;const bb=[];L("init",()=>{!p.params.mousewheel.enabled&&
2725p.params.cssMode&&Ka();p.params.mousewheel.enabled&&Aa()});L("destroy",()=>{p.params.cssMode&&Aa();p.mousewheel.enabled&&Ka()});Object.assign(p.mousewheel,{enable:Aa,disable:Ka})},function({swiper:p,extendParams:E,on:L,emit:ca}){function fa(Aa){let Ka;Aa&&(Ka=h(Aa),p.params.uniqueNavElements&&"string"===typeof Aa&&1<Ka.length&&1===p.$el.find(Aa).length&&(Ka=p.$el.find(Aa)));return Ka}function ia(Aa,Ka){const Ra=p.params.navigation;if(Aa&&0<Aa.length&&(Aa[Ka?"addClass":"removeClass"](Ra.disabledClass),
2726Aa[0]&&"BUTTON"===Aa[0].tagName&&(Aa[0].disabled=Ka),p.params.watchOverflow&&p.enabled))Aa[p.isLocked?"addClass":"removeClass"](Ra.lockClass)}function ma(){if(!p.params.loop){var {$nextEl:Aa,$prevEl:Ka}=p.navigation;
2726ia(Ka,p.isBeginning&&!p.params.rewind);ia(Aa,p.isEnd&&!p.params.rewind)}}function ua(Aa){Aa.preventDefault();(!p.isBeginning||p.params.loop||p.params.rewind)&&p.slidePrev()}function wa(Aa){Aa.preventDefault();(!p.isEnd||p.params.loop||p.params.rewind)&&p.slideNext()}function Da(){const Aa=
2727p.params.navigation;p.params.navigation=na(p,p.originalParams.navigation,p.params.navigation,{nextEl:"swiper-button-next",prevEl:"swiper-button-prev"});if(Aa.nextEl||Aa.prevEl){var Ka=fa(Aa.nextEl),Ra=fa(Aa.prevEl);if(Ka&&0<Ka.length)Ka.on("click",wa);if(Ra&&0<Ra.length)Ra.on("click",ua);Object.assign(p.navigation,{$nextEl:Ka,nextEl:Ka&&Ka[0],$prevEl:Ra,prevEl:Ra&&Ra[0]});p.enabled||(Ka&&Ka.addClass(Aa.lockClass),Ra&&Ra.addClass(Aa.lockClass))}}function Ea(){const {$nextEl:Aa,$prevEl:Ka}=p.navigation;
2728Aa&&Aa.length&&(Aa.off("click",wa),Aa.removeClass(p.params.navigation.disabledClass));Ka&&Ka.length&&(Ka.off("click",ua),Ka.removeClass(p.params.navigation.disabledClass))}E({navigation:{nextEl:null,prevEl:null,hideOnClick:!1,disabledClass:"swiper-button-disabled",hiddenClass:"swiper-button-hidden",lockClass:"swiper-button-lock"}});p.navigation={nextEl:null,$nextEl:null,prevEl:null,$prevEl:null};L("init",()=>{Da();ma()});L("toEdge fromEdge lock unlock",()=>{ma()});L("destroy",()=>{Ea()});L("enable disable",
2729()=>{const {$nextEl:Aa,$prevEl:Ka}=p.navigation;if(Aa)Aa[p.enabled?"removeClass":"addClass"](p.params.navigation.lockClass);if(Ka)Ka[p.enabled?"removeClass":"addClass"](p.params.navigation.lockClass)});L("click",(Aa,Ka)=>{const {$nextEl:Ra,$prevEl:cb}=p.navigation;Aa=Ka.target;if(!(!p.params.navigation.hideOnClick||h(Aa).is(cb)||h(Aa).is(Ra)||p.pagination&&p.params.pagination&&p.params.pagination.clickable&&(p.pagination.el===Aa||p.pagination.el.contains(Aa)))){var ib;Ra?ib=Ra.hasClass(p.params.navigation.hiddenClass):
2730cb&&(ib=cb.hasClass(p.params.navigation.hiddenClass));!0===ib?ca("navigationShow"):ca("navigationHide");Ra&&Ra.toggleClass(p.params.navigation.hiddenClass);cb&&cb.toggleClass(p.params.navigation.hiddenClass)}});Object.assign(p.navigation,{update:ma,init:Da,destroy:Ea})},function({swiper:p,extendParams:E,on:L,emit:ca}){function fa(){return!p.params.pagination.el||!p.pagination.el||!p.pagination.$el||0===p.pagination.$el.length}function ia(Ka,Ra){const {bulletActiveClass:cb}=p.params.pagination;Ka[Ra]().addClass(`${cb}-${Ra}`)[Ra]().addClass(`${cb}-${Ra}-${Ra}`)}
2731function ma(){var Ka=p.rtl;const Ra=p.params.pagination;if(!fa()){var cb=p.virtual&&p.params.virtual.enabled?p.virtual.slides.length:p.slides.length,ib=p.pagination.$el,fb=p.params.loop?Math.ceil((cb-2*p.loopedSlides)/p.params.slidesPerGroup):p.snapGrid.length;if(p.params.loop){var bb=Math.ceil((p.activeIndex-p.loopedSlides)/p.params.slidesPerGroup);bb>cb-1-2*p.loopedSlides&&(bb-=cb-2*p.loopedSlides);bb>fb-1&&(bb-=fb);0>bb&&"bullets"!==p.params.paginationType&&(bb=fb+bb)}else bb="undefined"!==typeof p.snapIndex?
2732p.snapIndex:p.activeIndex||0;if("bullets"===Ra.type&&p.pagination.bullets&&0<p.pagination.bullets.length){cb=p.pagination.bullets;let $a,nb;if(Ra.dynamicBullets){Ea=cb.eq(0)[p.isHorizontal()?"outerWidth":"outerHeight"](!0);ib.css(p.isHorizontal()?"width":"height",`${Ea*(Ra.dynamicMainBullets+4)}px`);1<Ra.dynamicMainBullets&&void 0!==p.previousIndex&&(Aa+=bb-(p.previousIndex-p.loopedSlides||0),Aa>Ra.dynamicMainBullets-1?Aa=Ra.dynamicMainBullets-1:0>Aa&&(Aa=0));$a=Math.max(bb-Aa,0);nb=$a+(Math.min(cb.length,
2733Ra.dynamicMainBullets)-1);var eb=(nb+$a)/2}cb.removeClass(" -next -next-next -prev -prev-prev -main".split(" ").map(vb=>`${Ra.bulletActiveClass}${vb}`).join(" "));if(1<ib.length)cb.each(vb=>{vb=h(vb);const jb=vb.index();jb===bb&&vb.addClass(Ra.bulletActiveClass);Ra.dynamicBullets&&(jb>=$a&&jb<=nb&&vb.addClass(`${Ra.bulletActiveClass}-main`),jb===$a&&ia(vb,"prev"),jb===nb&&ia(vb,"next"))});else{var kb=cb.eq(bb),rb=kb.index();kb.addClass(Ra.bulletActiveClass);if(Ra.dynamicBullets){kb=cb.eq($a);const vb=
2734cb.eq(nb);for(let jb=$a;jb<=nb;jb+=1)cb.eq(jb).addClass(`${Ra.bulletActiveClass}-main`);if(p.params.loop)if(rb>=cb.length){for(rb=Ra.dynamicMainBullets;0<=rb;--rb)cb.eq(cb.length-rb).addClass(`${Ra.bulletActiveClass}-main`);cb.eq(cb.length-Ra.dynamicMainBullets-1).addClass(`${Ra.bulletActiveClass}-prev`)}else ia(kb,"prev"),ia(vb,"next");else ia(kb,"prev"),ia(vb,"next")}}Ra.dynamicBullets&&(eb=(Ea*Math.min(cb.length,Ra.dynamicMainBullets+4)-Ea)/2-eb*Ea,Ka=Ka?"right":"left",cb.css(p.isHorizontal()?
2735Ka:"top",`${eb}px`))}"fraction"===Ra.type&&(ib.find(qa(Ra.currentClass)).text(Ra.formatFractionCurrent(bb+1)),ib.find(qa(Ra.totalClass)).text(Ra.formatFractionTotal(fb)));"progressbar"===Ra.type&&(Ka=Ra.progressbarOpposite?p.isHorizontal()?"vertical":"horizontal":p.isHorizontal()?"horizontal":"vertical",cb=(bb+1)/fb,rb=eb=1,"horizontal"===Ka?eb=cb:rb=cb,ib.find(qa(Ra.progressbarFillClass)).transform(`translate3d(0,
27350,0) scaleX(${eb}) scaleY(${rb})`).transition(p.params.speed));"custom"===Ra.type&&
2736Ra.renderCustom?(ib.html(Ra.renderCustom(p,bb+1,fb)),ca("paginationRender",ib[0])):ca("paginationUpdate",ib[0]);if(p.params.watchOverflow&&p.enabled)ib[p.isLocked?"addClass":"removeClass"](Ra.lockClass)}}function ua(){const Ka=p.params.pagination;if(!fa()){var Ra=p.virtual&&p.params.virtual.enabled?p.virtual.slides.length:p.slides.length,cb=p.pagination.$el,ib="";if("bullets"===Ka.type){let fb=p.params.loop?Math.ceil((Ra-2*p.loopedSlides)/p.params.slidesPerGroup):p.snapGrid.length;p.params.freeMode&&
2737p.params.freeMode.enabled&&!p.params.loop&&fb>Ra&&(fb=Ra);for(Ra=0;Ra<fb;Ra+=1)ib=Ka.renderBullet?ib+Ka.renderBullet.call(p,Ra,Ka.bulletClass):ib+`<${Ka.bulletElement} class="${Ka.bulletClass}"></${Ka.bulletElement}>`;cb.html(ib);p.pagination.bullets=cb.find(qa(Ka.bulletClass))}"fraction"===Ka.type&&(ib=Ka.renderFraction?Ka.renderFraction.call(p,Ka.currentClass,Ka.totalClass):`<span class="${Ka.currentClass}"></span>`+" / "+`<span class="${Ka.totalClass}"></span>`,cb.html(ib));"progressbar"===Ka.type&&
2738(ib=Ka.renderProgressbar?Ka.renderProgressbar.call(p,Ka.progressbarFillClass):`<span class="${Ka.progressbarFillClass}"></span>`,cb.html(ib));"custom"!==Ka.type&&ca("paginationRender",p.pagination.$el[0])}}function wa(){p.params.pagination=na(p,p.originalParams.pagination,p.params.pagination,{el:"swiper-pagination"});const Ka=p.params.pagination;if(Ka.el){var Ra=h(Ka.el);if(0!==Ra.length){p.params.uniqueNavElements&&"string"===typeof Ka.el&&1<Ra.length&&(Ra=p.$el.find(Ka.el),1<Ra.length&&(Ra=Ra.filter(cb=>
2739h(cb).parents(".swiper")[0]!==p.el?!1:!0)));"bullets"===Ka.type&&Ka.clickable&&Ra.addClass(Ka.clickableClass);Ra.addClass(Ka.modifierClass+Ka.type);Ra.addClass(Ka.modifierClass+p.params.direction);"bullets"===Ka.type&&Ka.dynamicBullets&&(Ra.addClass(`${Ka.modifierClass}${Ka.type}-dynamic`),Aa=0,1>Ka.dynamicMainBullets&&(Ka.dynamicMainBullets=1));"progressbar"===Ka.type&&Ka.progressbarOpposite&&Ra.addClass(Ka.progressbarOppositeClass);if(Ka.clickable)Ra.on("click",qa(Ka.bulletClass),function(cb){cb.preventDefault();
2740cb=h(this).index()*p.params.slidesPerGroup;p.params.loop&&(cb+=p.loopedSlides);p.slideTo(cb)});Object.assign(p.pagination,{$el:Ra,el:Ra[0]});p.enabled||Ra.addClass(Ka.lockClass)}}}function Da(){const Ka=p.params.pagination;if(!fa()){var Ra=p.pagination.$el;Ra.removeClass(Ka.hiddenClass);Ra.removeClass(Ka.modifierClass+Ka.type);Ra.removeClass(Ka.modifierClass+p.params.direction);p.pagination.bullets&&p.pagination.bullets.removeClass&&p.pagination.bullets.removeClass(Ka.bulletActiveClass);Ka.clickable&&
2741Ra.off("click",qa(Ka.bulletClass))}}E({pagination:{el:null,bulletElement:"span",clickable:!1,hideOnClick:!1,renderBullet:null,renderProgressbar:null,renderFraction:null,renderCustom:null,progressbarOpposite:!1,type:"bullets",dynamicBullets:!1,dynamicMainBullets:1,formatFractionCurrent:Ka=>Ka,formatFractionTotal:Ka=>Ka,bulletClass:"swiper-pagination-bullet",bulletActiveClass:"swiper-pagination-bullet-active",modifierClass:"swiper-pagination-",currentClass:"swiper-pagination-current",totalClass:"swiper-pagination-total",
2742hiddenClass:"swiper-pagination-hidden",progressbarFillClass:"swiper-pagination-progressbar-fill",progressbarOppositeClass:"swiper-pagination-progressbar-opposite",clickableClass:"swiper-pagination-clickable",lockClass:"swiper-pagination-lock",horizontalClass:"swiper-pagination-horizontal",verticalClass:"swiper-pagination-vertical"}});p.pagination={el:null,$el:null,bullets:[]};let Ea,Aa=0;L("init",()=>{wa();ua();ma()});L("activeIndexChange",()=>{p.params.loop?ma():"undefined"===typeof p.snapIndex&&
2743ma()});L("snapIndexChange",()=>{p.params.loop||ma()});L("slidesLengthChange",()=>{p.params.loop&&(ua(),ma())});L("snapGridLengthChange",()=>{p.params.loop||(ua(),ma())});L("destroy",()=>{Da()});L("enable disable",()=>{const {$el:Ka}=p.pagination;if(Ka)Ka[p.enabled?"removeClass":"addClass"](p.params.pagination.lockClass)});L("lock unlock",()=>{ma()});L("click",(Ka,Ra)=>{Ka=Ra.target;({$el:Ra}=p.pagination);!(p.params.pagination.el&&p.params.pagination.hideOnClick&&0<Ra.length)||h(Ka).hasClass(p.params.pagination.bulletClass)||
2744p.navigation&&(p.navigation.nextEl&&Ka===p.navigation.nextEl||p.navigation.prevEl&&Ka===p.navigation.prevEl)||(!0===Ra.hasClass(p.params.pagination.hiddenClass)?ca("paginationShow"):ca("paginationHide"),Ra.toggleClass(p.params.pagination.hiddenClass))});Object.assign(p.pagination,{render:ua,update:ma,init:wa,destroy:Da})},function({swiper:p,extendParams:E,on:L,emit:ca}){function fa(){if(p.params.scrollbar.el&&p.scrollbar.el){var {scrollbar:$a,rtlTranslate:nb,progress:vb}=p,{$dragEl:jb,$el:Ya}=$a,
2745Xa=p.params.scrollbar,wb=eb,Bb=(kb-eb)*vb;nb?(Bb=-Bb,0<Bb?(wb=eb-Bb,Bb=0):-Bb+eb>kb&&(wb=kb+Bb)):0>Bb?(wb=eb+Bb,Bb=0):Bb+eb>kb&&(wb=kb-Bb);p.isHorizontal()?(jb.transform(`translate3d(${Bb}px, 0, 0)`),jb[0].style.width=`${wb}px`):(jb.transform(`translate3d(0px, ${Bb}px, 0)`),jb[0].style.height=`${wb}px`);Xa.hide&&(clearTimeout(ib),Ya[0].style.opacity=1,ib=setTimeout(()=>{Ya[0].style.opacity=0;Ya.transition(400)},1E3))}}function ia(){if(p.params.scrollbar.el&&p.scrollbar.el){var {scrollbar:$a}=p,{$dragEl:nb,
2746$el:vb}=$a;nb[0].style.width="";nb[0].style.height="";kb=p.isHorizontal()?vb[0].offsetWidth:vb[0].offsetHeight;rb=p.size/(p.virtualSize+p.params.slidesOffsetBefore-(p.params.centeredSlides?p.snapGrid[0]:0));eb="auto"===p.params.scrollbar.dragSize?kb*rb:parseInt(p.params.scrollbar.dragSize,10);p.isHorizontal()?nb[0].style.width=`${eb}px`:nb[0].style.height=`${eb}px`;vb[0].style.display=1<=rb?"none":"";p.params.scrollbar.hide&&(vb[0].style.opacity=0);if(p.params.watchOverflow&&p.enabled)$a.$el[p.isLocked?
2747"addClass":"removeClass"](p.params.scrollbar.lockClass)}}function ma($a){return p.isHorizontal()?"touchstart"===$a.type||"touchmove"===$a.type?$a.targetTouches[0].clientX:$a.clientX:"touchstart"===$a.type||"touchmove"===$a.type?$a.targetTouches[0].clientY:$a.clientY}function ua($a){const {scrollbar:nb,rtlTranslate:vb}=p,{$el:jb}=nb;$a=(ma($a)-jb.offset()[p.isHorizontal()?"left":"top"]-(null!==bb?bb:eb/2))/(kb-eb);$a=Math.max(Math.min($a,1),0);vb&&($a=1-$a);$a=p.minTranslate()+(p.maxTranslate()-p.minTranslate())*
2748$a;p.updateProgress($a);p.setTranslate($a);p.updateActiveIndex();p.updateSlidesClasses()}function wa($a){const nb=p.params.scrollbar,{scrollbar:vb,$wrapperEl:jb}=p,{$el:Ya,$dragEl:Xa}=vb;cb=!0;bb=$a.target===Xa[0]||$a.target===Xa?ma($a)-$a.target.getBoundingClientRect()[p.isHorizontal()?"left":"top"]:null;$a.preventDefault();$a.stopPropagation();jb.transition(100);Xa.transition(100);ua($a);clearTimeout(fb);Ya.transition(0);nb.hide&&Ya.css("opacity",1);p.params.cssMode&&p.$wrapperEl.css("scroll-snap-type",
2749"none");ca("scrollbarDragStart",$a)}function Da($a){const {scrollbar:nb,$wrapperEl:vb}=p,{$el:jb,$dragEl:Ya}=nb;cb&&($a.preventDefault?$a.preventDefault():$a.returnValue=!1,ua($a),vb.transition(0),jb.transition(0),Ya.transition(0),ca("scrollbarDragMove",$a))}function Ea($a){const nb=p.params.scrollbar,{scrollbar:vb,$wrapperEl:jb}=p,{$el:Ya}=vb;cb&&(cb=!1,p.params.cssMode&&(p.$wrapperEl.css("scroll-snap-type",""),jb.transition("")),nb.hide&&(clearTimeout(fb),fb=l(()=>{Ya.css("opacity",0);Ya.transition(400)},
27501E3)),ca("scrollbarDragEnd",$a),nb.snapOnRelease&&p.slideToClosest())}function Aa($a){const {scrollbar:nb,touchEventsTouch:vb,touchEventsDesktop:jb,params:Ya,support:Xa}=p,wb=nb.$el[0],Bb=Xa.passiveListener&&Ya.passiveListeners?{passive:!1,capture:!1}:!1,ob=Xa.passiveListener&&Ya.passiveListeners?{passive:!0,capture:!1}:!1;wb&&($a="on"===$a?"addEventListener":"removeEventListener",Xa.touch?(wb[$a](vb.start,wa,Bb),wb[$a](vb.move,Da,Bb),wb[$a](vb.end,Ea,ob)):(wb[$a](jb.start,wa,Bb),Ra[$a](jb.move,Da,
2751Bb),Ra[$a](jb.end,Ea,ob)))}function Ka(){const {scrollbar:$a,$el:nb}=p;p.params.scrollbar=na(p,p.originalParams.scrollbar,p.params.scrollbar,{el:"swiper-scrollbar"});const vb=p.params.scrollbar;if(vb.el){var jb=h(vb.el);p.params.uniqueNavElements&&"string"===typeof vb.el&&1<jb.length&&1===nb.find(vb.el).length&&(jb=nb.find(vb.el));var Ya=jb.find(`.${p.params.scrollbar.dragClass}`);0===Ya.length&&(Ya=h(`<div class="${p.params.scrollbar.dragClass}"></div>`),jb.append(Ya));Object.assign($a,{$el:jb,el:jb[0],
2752$dragEl:Ya,dragEl:Ya[0]});vb.draggable&&p.params.scrollbar.el&&Aa("on");if(jb)jb[p.enabled?"removeClass":"addClass"](p.params.scrollbar.lockClass)}}const Ra=c();let cb=!1,ib=null,fb=null,bb,eb,kb,rb;E({scrollbar:{el:null,dragSize:"auto",hide:!1,draggable:!1,snapOnRelease:!0,lockClass:"swiper-scrollbar-lock",dragClass:"swiper-scrollbar-drag"}});p.scrollbar={el:null,dragEl:null,$el:null,$dragEl:null};L("init",()=>{Ka();ia();fa()});L("update resize observerUpdate lock unlock",()=>{ia()});L("setTranslate",
2753()=>{fa()});L("setTransition",($a,nb)=>{p.params.scrollbar.el&&p.scrollbar.el&&p.scrollbar.$dragEl.transition(nb)});L("enable disable",()=>{const {$el:$a}=p.scrollbar;if($a)$a[p.enabled?"removeClass":"addClass"](p.params.scrollbar.lockClass)});L("destroy",()=>{p.params.scrollbar.el&&Aa("off")});Object.assign(p.scrollbar,{updateSize:ia,setTranslate:fa,init:Ka,destroy:function(){p.params.scrollbar.el&&Aa("off")}})},function({swiper:p,extendParams:E,on:L}){E({parallax:{enabled:!1}});const ca=(ma,ua)=>
2754{var {rtl:wa}=p;ma=h(ma);wa=wa?-1:1;const Da=ma.attr("data-swiper-parallax")||"0";let Ea=ma.attr("data-swiper-parallax-x"),Aa=ma.attr("data-swiper-parallax-y");const Ka=ma.attr("data-swiper-parallax-scale"),Ra=ma.attr("data-swiper-parallax-opacity");Ea||Aa?(Ea=Ea||"0",Aa=Aa||"0"):p.isHorizontal()?(Ea=Da,Aa="0"):(Aa=Da,Ea="0");Ea=0<=Ea.indexOf("%")?`${parseInt(Ea,10)*ua*wa}%`:`${Ea*ua*wa}px`;Aa=0<=Aa.indexOf("%")?`${parseInt(Aa,10)*ua}%`:`${Aa*ua}px`;"undefined"!==typeof Ra&&null!==Ra&&(ma[0].style.opacity=
2755Ra-(Ra-1)*(1-Math.abs(ua)));"undefined"===typeof Ka||null===Ka?ma.transform(`translate3d(${Ea}, ${Aa}, 0px)`):ma.transform(`translate3d(${Ea}, ${Aa}, 0px) scale(${Ka-(Ka-1)*(1-Math.abs(ua))})`)},fa=()=>{const {$el:ma,slides:ua,progress:wa,snapGrid:Da}=p;ma.children("[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]").each(Ea=>{ca(Ea,wa)});ua.each((Ea,Aa)=>{let Ka=Ea.progress;1<p.params.slidesPerGroup&&"auto"!==
2756p.params.slidesPerView&&(Ka+=Math.ceil(Aa/2)-wa*(Da.length-1));Ka=Math.min(Math.max(Ka,-1),1);h(Ea).find("[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]").each(Ra=>{ca(Ra,Ka)})})},ia=(ma=p.params.speed)=>{const {$el:ua}=p;ua.find("[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]").each(wa=>{wa=h(wa);let Da=parseInt(wa.attr("data-swiper-parallax-duration"),
275710)||ma;0===ma&&(Da=0);wa.transition(Da)})};L("beforeInit",()=>{p.params.parallax.enabled&&(p.params.watchSlidesProgress=!0,p.originalParams.watchSlidesProgress=!0)});L("init",()=>{p.params.parallax.enabled&&fa()});L("setTranslate",()=>{p.params.parallax.enabled&&fa()});L("setTransition",(ma,ua)=>{p.params.parallax.enabled&&ia(ua)})},function({swiper:p,extendParams:E,on:L,emit:ca}){function fa(ob){return 2>ob.targetTouches.length?1:Math.sqrt((ob.targetTouches[1].pageX-ob.targetTouches[0].pageX)**
27582+(ob.targetTouches[1].pageY-ob.targetTouches[0].pageY)**2)}function ia(ob){const Ab=p.support,Cb=p.params.zoom;jb=vb=!1;if(!Ab.gestures){if("touchstart"!==ob.type||"touchstart"===ob.type&&2>ob.targetTouches.length)return;vb=!0;Ya.scaleStart=fa(ob)}if(!Ya.$slideEl||!Ya.$slideEl.length)if(Ya.$slideEl=h(ob.target).closest(`.${p.params.slideClass}`),0===Ya.$slideEl.length&&(Ya.$slideEl=p.slides.eq(p.activeIndex)),Ya.$imageEl=Ya.$slideEl.find(`.${Cb.containerClass}`).eq(0).find("picture, img, svg, canvas, .swiper-zoom-target").eq(0),
2759Ya.$imageWrapEl=Ya.$imageEl.parent(`.${Cb.containerClass}`),Ya.maxRatio=Ya.$imageWrapEl.attr("data-swiper-zoom")||Cb.maxRatio,0===Ya.$imageWrapEl.length){Ya.$imageEl=void 0;return}Ya.$imageEl&&Ya.$imageEl.transition(0);$a=!0}function ma(ob){const Ab=p.support,Cb=p.params.zoom,Eb=p.zoom;if(!Ab.gestures){if("touchmove"!==ob.type||"touchmove"===ob.type&&2>ob.targetTouches.length)return;jb=!0;Ya.scaleMove=fa(ob)}Ya.$imageEl&&0!==Ya.$imageEl.length?(Eb.scale=Ab.gestures?ob.scale*rb:Ya.scaleMove/Ya.scaleStart*
2760rb,Eb.scale>Ya.maxRatio&&(Eb.scale=Ya.maxRatio-1+(Eb.scale-Ya.maxRatio+1)**.5),Eb.scale<Cb.minRatio&&(Eb.scale=Cb.minRatio+1-(Cb.minRatio-Eb.scale+1)**.5),Ya.$imageEl.transform(`translate3d(0,0,0) scale(${Eb.scale})`)):"gesturechange"===ob.type&&ia(ob)}function ua(ob){const Ab=p.device,Cb=p.params.zoom,Eb=p.zoom;if(!p.support.gestures){if(!vb||!jb||"touchend"!==ob.type||"touchend"===ob.type&&2>ob.changedTouches.length&&!Ab.android)return;jb=vb=!1}Ya.$imageEl&&0!==Ya.$imageEl.length&&(Eb.scale=Math.max(Math.min(Eb.scale,
2761Ya.maxRatio),Cb.minRatio),Ya.$imageEl.transition(p.params.speed).transform(`translate3d(0,0,0) scale(${Eb.scale})`),rb=Eb.scale,$a=!1,1===Eb.scale&&(Ya.$slideEl=void 0))}function wa(ob){var Ab=p.zoom;if(Ya.$imageEl&&0!==Ya.$imageEl.length&&(p.allowClick=!1,Xa.isTouched&&Ya.$slideEl)){Xa.isMoved||(Xa.width=Ya.$imageEl[0].offsetWidth,Xa.height=Ya.$imageEl[0].offsetHeight,Xa.startX=r(Ya.$imageWrapEl[0],"x")||0,Xa.startY=r(Ya.$imageWrapEl[0],"y")||0,Ya.slideWidth=Ya.$slideEl[0].offsetWidth,Ya.slideHeight=
2762Ya.$slideEl[0].offsetHeight,Ya.$imageWrapEl.transition(0));var Cb=Xa.width*Ab.scale;Ab=Xa.height*Ab.scale;if(!(Cb<Ya.slideWidth&&Ab<Ya.slideHeight)){Xa.minX=Math.min(Ya.slideWidth/2-Cb/2,0);Xa.maxX=-Xa.minX;Xa.minY=Math.min(Ya.slideHeight/2-Ab/2,0);Xa.maxY=-Xa.minY;Xa.touchesCurrent.x="touchmove"===ob.type?ob.targetTouches[0].pageX:ob.pageX;Xa.touchesCurrent.y="touchmove"===ob.type?ob.targetTouches[0].pageY:ob.pageY;if(!Xa.isMoved&&!$a){if(p.isHorizontal()&&(Math.floor(Xa.minX)===Math.floor(Xa.startX)&&
2763Xa.touchesCurrent.x<Xa.touchesStart.x||Math.floor(Xa.maxX)===Math.floor(Xa.startX)&&Xa.touchesCurrent.x>Xa.touchesStart.x)){Xa.isTouched=!1;return}if(!p.isHorizontal()&&(Math.floor(Xa.minY)===Math.floor(Xa.startY)&&Xa.touchesCurrent.y<Xa.touchesStart.y||Math.floor(Xa.maxY)===Math.floor(Xa.startY)&&Xa.touchesCurrent.y>Xa.touchesStart.y)){Xa.isTouched=!1;return}}ob.cancelable&&ob.preventDefault();ob.stopPropagation();Xa.isMoved=!0;Xa.currentX=Xa.touchesCurrent.x-Xa.touchesStart.x+Xa.startX;Xa.currentY=
2764Xa.touchesCurrent.y-Xa.touchesStart.y+Xa.startY;Xa.currentX<Xa.minX&&(Xa.currentX=Xa.minX+1-(Xa.minX-Xa.currentX+1)**.8);Xa.currentX>Xa.maxX&&(Xa.currentX=Xa.maxX-1+(Xa.currentX-Xa.maxX+1)**.8);Xa.currentY<Xa.minY&&(Xa.currentY=Xa.minY+1-(Xa.minY-Xa.currentY+1)**.8);Xa.currentY>Xa.maxY&&(Xa.currentY=Xa.maxY-1+(Xa.currentY-Xa.maxY+1)**.8);wb.prevPositionX||(wb.prevPositionX=Xa.touchesCurrent.x);wb.prevPositionY||(wb.prevPositionY=Xa.touchesCurrent.y);wb.prevTime||(wb.prevTime=Date.now());wb.x=(Xa.touchesCurrent.x-
2765wb.prevPositionX)/(Date.now()-wb.prevTime)/2;wb.y=(Xa.touchesCurrent.y-wb.prevPositionY)/(Date.now()-wb.prevTime)/2;2>Math.abs(Xa.touchesCurrent.x-wb.prevPositionX)&&(wb.x=0);2>Math.abs(Xa.touchesCurrent.y-wb.prevPositionY)&&(wb.y=0);wb.prevPositionX=Xa.touchesCurrent.x;wb.prevPositionY=Xa.touchesCurrent.y;wb.prevTime=Date.now();Ya.$imageWrapEl.transform(`translate3d(${Xa.currentX}px, ${Xa.currentY}px,0)`)}}}function Da(){const ob=p.zoom;Ya.$slideEl&&p.previousIndex!==p.activeIndex&&(Ya.$imageEl&&
2766Ya.$imageEl.transform("translate3d(0,0,0) scale(1)"),Ya.$imageWrapEl&&Ya.$imageWrapEl.transform("translate3d(0,0,0)"),rb=ob.scale=1,Ya.$slideEl=void 0,Ya.$imageEl=void 0,Ya.$imageWrapEl=void 0)}function Ea(ob){const Ab=p.zoom;var Cb=p.params.zoom;Ya.$slideEl||(ob&&ob.target&&(Ya.$slideEl=h(ob.target).closest(`.${p.params.slideClass}`)),Ya.$slideEl||(Ya.$slideEl=p.params.virtual&&p.params.virtual.enabled&&p.virtual?p.$wrapperEl.children(`.${p.params.slideActiveClass}`):p.slides.eq(p.activeIndex)),
2767Ya.$imageEl=Ya.$slideEl.find(`.${Cb.containerClass}`).eq(0).find("picture, img, svg, canvas, .swiper-zoom-target").eq(0),Ya.$imageWrapEl=Ya.$imageEl.parent(`.${Cb.containerClass}`));if(Ya.$imageEl&&0!==Ya.$imageEl.length&&Ya.$imageWrapEl&&0!==Ya.$imageWrapEl.length){p.params.cssMode&&(p.wrapperEl.style.overflow="hidden",p.wrapperEl.style.touchAction="none");Ya.$slideEl.addClass(`${Cb.zoomedSlideClass}`);if("undefined"===typeof Xa.touchesStart.x&&ob){var Eb="touchend"===ob.type?ob.changedTouches[0].pageX:
2768ob.pageX;var Nb="touchend"===ob.type?ob.changedTouches[0].pageY:ob.pageY}else Eb=Xa.touchesStart.x,Nb=Xa.touchesStart.y;Ab.scale=Ya.$imageWrapEl.attr("data-swiper-zoom")||Cb.maxRatio;rb=Ya.$imageWrapEl.attr("data-swiper-zoom")||Cb.maxRatio;if(ob){var ic=Ya.$slideEl[0].offsetWidth;Cb=Ya.$slideEl[0].offsetHeight;var mc=Ya.$slideEl.offset().left+kb.scrollX;ob=Ya.$slideEl.offset().top+kb.scrollY;var gc=Ya.$imageEl[0].offsetWidth;var jc=Ya.$imageEl[0].offsetHeight;gc*=Ab.scale;var hc=jc*Ab.scale;jc=Math.min(ic/
27692-gc/2,0);gc=Math.min(Cb/2-hc/2,0);hc=-jc;var pc=-gc;Eb=(mc+ic/2-Eb)*Ab.scale;Nb=(ob+Cb/2-Nb)*Ab.scale;Eb<jc&&(Eb=jc);Eb>hc&&(Eb=hc);Nb<gc&&(Nb=gc);Nb>pc&&(Nb=pc)}else Nb=Eb=0;Ya.$imageWrapEl.transition(300).transform(`translate3d(${Eb}px, ${Nb}px,0)`);
2769Ya.$imageEl.transition(300).transform(`translate3d(0,0,0) scale(${Ab.scale})`)}}function Aa(){const ob=p.zoom,Ab=p.params.zoom;Ya.$slideEl||(Ya.$slideEl=p.params.virtual&&p.params.virtual.enabled&&p.virtual?p.$wrapperEl.children(`.${p.params.slideActiveClass}`):
2770p.slides.eq(p.activeIndex),Ya.$imageEl=Ya.$slideEl.find(`.${Ab.containerClass}`).eq(0).find("picture, img, svg, canvas, .swiper-zoom-target").eq(0),Ya.$imageWrapEl=Ya.$imageEl.parent(`.${Ab.containerClass}`));Ya.$imageEl&&0!==Ya.$imageEl.length&&Ya.$imageWrapEl&&0!==Ya.$imageWrapEl.length&&(p.params.cssMode&&(p.wrapperEl.style.overflow="",p.wrapperEl.style.touchAction=""),rb=ob.scale=1,Ya.$imageWrapEl.transition(300).transform("translate3d(0,0,0)"),Ya.$imageEl.transition(300).transform("translate3d(0,0,0) scale(1)"),
2771Ya.$slideEl.removeClass(`${Ab.zoomedSlideClass}`),Ya.$slideEl=void 0)}function Ka(ob){const Ab=p.zoom;Ab.scale&&1!==Ab.scale?Aa():Ea(ob)}function Ra(){const ob=p.support;return{passiveListener:"touchstart"===p.touchEvents.start&&ob.passiveListener&&p.params.passiveListeners?{passive:!0,capture:!1}:!1,activeListenerWithCapture:ob.passiveListener?{passive:!1,capture:!0}:!0}}function cb(ob){const {passiveListener:Ab}=Ra(),Cb=`.${p.params.slideClass}`;p.$wrapperEl[ob]("gesturestart",Cb,ia,Ab);p.$wrapperEl[ob]("gesturechange",
2772Cb,ma,Ab);p.$wrapperEl[ob]("gestureend",Cb,ua,Ab)}function ib(){nb||(nb=!0,cb("on"))}function fb(){nb&&(nb=!1,cb("off"))}function bb(){var ob=p.zoom;if(!ob.enabled){ob.enabled=!0;ob=p.support;var {passiveListener:Ab,activeListenerWithCapture:Cb}=Ra(),Eb=`.${p.params.slideClass}`;if(ob.gestures)p.$wrapperEl.on(p.touchEvents.start,ib,Ab),p.$wrapperEl.on(p.touchEvents.end,fb,Ab);else if("touchstart"===p.touchEvents.start&&(p.$wrapperEl.on(p.touchEvents.start,Eb,ia,Ab),p.$wrapperEl.on(p.touchEvents.move,
2773Eb,ma,Cb),p.$wrapperEl.on(p.touchEvents.end,Eb,ua,Ab),p.touchEvents.cancel))p.$wrapperEl.on(p.touchEvents.cancel,Eb,ua,Ab);p.$wrapperEl.on(p.touchEvents.move,`.${p.params.zoom.containerClass}`,wa,Cb)}}function eb(){var ob=p.zoom;if(ob.enabled){var Ab=p.support;ob.enabled=!1;var {passiveListener:Cb,activeListenerWithCapture:Eb}=Ra();ob=`.${p.params.slideClass}`;Ab.gestures?(p.$wrapperEl.off(p.touchEvents.start,ib,Cb),p.$wrapperEl.off(p.touchEvents.end,fb,Cb)):"touchstart"===p.touchEvents.start&&(p.$wrapperEl.off(p.touchEvents.start,
2774ob,ia,Cb),p.$wrapperEl.off(p.touchEvents.move,ob,ma,Eb),p.$wrapperEl.off(p.touchEvents.end,ob,ua,Cb),p.touchEvents.cancel&&p.$wrapperEl.off(p.touchEvents.cancel,ob,ua,Cb));p.$wrapperEl.off(p.touchEvents.move,`.${p.params.zoom.containerClass}`,wa,Eb)}}const kb=d();E({zoom:{enabled:!1,maxRatio:3,minRatio:1,toggle:!0,containerClass:"swiper-zoom-container",zoomedSlideClass:"swiper-slide-zoomed"}});p.zoom={enabled:!1};let rb=1,$a=!1,nb,vb,jb;const Ya={$slideEl:void 0,slideWidth:void 0,slideHeight:void 0,
2775$imageEl:void 0,$imageWrapEl:void 0,maxRatio:3},Xa={isTouched:void 0,isMoved:void 0,currentX:void 0,currentY:void 0,minX:void 0,minY:void 0,maxX:void 0,maxY:void 0,width:void 0,height:void 0,startX:void 0,startY:void 0,touchesStart:{},touchesCurrent:{}},wb={x:void 0,y:void 0,prevPositionX:void 0,prevPositionY:void 0,prevTime:void 0};let Bb=1;Object.defineProperty(p.zoom,"scale",{get(){return Bb},set(ob){Bb!==ob&&ca("zoomChange",ob,Ya.$imageEl?Ya.$imageEl[0]:void 0,Ya.$slideEl?Ya.$slideEl[0]:void 0);
2776Bb=ob}});L("init",()=>{p.params.zoom.enabled&&bb()});L("destroy",()=>{eb()});L("touchStart",(ob,Ab)=>{p.zoom.enabled&&Ya.$imageEl&&0!==Ya.$imageEl.length&&!Xa.isTouched&&(p.device.android&&Ab.cancelable&&Ab.preventDefault(),Xa.isTouched=!0,Xa.touchesStart.x="touchstart"===Ab.type?Ab.targetTouches[0].pageX:Ab.pageX,Xa.touchesStart.y="touchstart"===Ab.type?Ab.targetTouches[0].pageY:Ab.pageY)});L("touchEnd",(ob,Ab)=>{if(p.zoom.enabled&&(ob=p.zoom,Ya.$imageEl&&0!==Ya.$imageEl.length))if(Xa.isTouched&&
2777Xa.isMoved){Xa.isTouched=!1;Xa.isMoved=!1;var Cb=300,Eb=300;Ab=Xa.currentX+wb.x*Cb;var Nb=Xa.currentY+wb.y*Eb;0!==wb.x&&(Cb=Math.abs((Ab-Xa.currentX)/wb.x));0!==wb.y&&(Eb=Math.abs((Nb-Xa.currentY)/wb.y));Cb=Math.max(Cb,Eb);Xa.currentX=Ab;Xa.currentY=Nb;Ab=Xa.height*ob.scale;Xa.minX=Math.min(Ya.slideWidth/2-Xa.width*ob.scale/2,0);Xa.maxX=-Xa.minX;Xa.minY=Math.min(Ya.slideHeight/2-Ab/2,0);Xa.maxY=-Xa.minY;Xa.currentX=Math.max(Math.min(Xa.currentX,Xa.maxX),Xa.minX);Xa.currentY=Math.max(Math.min(Xa.currentY,
2778Xa.maxY),Xa.minY);Ya.$imageWrapEl.transition(Cb).transform(`translate3d(${Xa.currentX}px, ${Xa.currentY}px,0)`)}else Xa.isTouched=!1,Xa.isMoved=!1});L("doubleTap",(ob,Ab)=>{!p.animating&&p.params.zoom.enabled&&p.zoom.enabled&&p.params.zoom.toggle&&Ka(Ab)});L("transitionEnd",()=>{p.zoom.enabled&&p.params.zoom.enabled&&Da()});L("slideChange",()=>{p.zoom.enabled&&p.params.zoom.enabled&&p.params.cssMode&&Da()});Object.assign(p.zoom,{enable:bb,disable:eb,in:Ea,out:Aa,toggle:Ka})},function({swiper:p,extendParams:E,
2779on:L,emit:ca}){function fa(Da,Ea=!0){const Aa=p.params.lazy;if("undefined"!==typeof Da&&0!==p.slides.length){var Ka=p.virtual&&p.params.virtual.enabled?p.$wrapperEl.children(`.${p.params.slideClass}[data-swiper-slide-index="${Da}"]`):p.slides.eq(Da);Da=Ka.find(`.${Aa.elementClass}:not(.${Aa.loadedClass}):not(.${Aa.loadingClass})`);!Ka.hasClass(Aa.elementClass)||Ka.hasClass(Aa.loadedClass)||Ka.hasClass(Aa.loadingClass)||Da.push(Ka[0]);0!==Da.length&&Da.each(Ra=>{const cb=h(Ra);cb.addClass(Aa.loadingClass);
2780const ib=cb.attr("data-background"),fb=cb.attr("data-src"),bb=cb.attr("data-srcset"),eb=cb.attr("data-sizes"),kb=cb.parent("picture");p.loadImage(cb[0],fb||ib,bb,eb,!1,()=>
2780{if("undefined"!==typeof p&&null!==p&&p&&(!p||p.params)&&!p.destroyed){ib?(cb.css("background-image",`url("${ib}")`),cb.removeAttr("data-background")):(bb&&(cb.attr("srcset",bb),cb.removeAttr("data-srcset")),eb&&(cb.attr("sizes",eb),cb.removeAttr("data-sizes")),kb.length&&kb.children("source").each($a=>{$a=h($a);$a.attr("data-srcset")&&
2781($a.attr("srcset",$a.attr("data-srcset")),$a.removeAttr("data-srcset"))}),fb&&(cb.attr("src",fb),cb.removeAttr("data-src")));cb.addClass(Aa.loadedClass).removeClass(Aa.loadingClass);Ka.find(`.${Aa.preloaderClass}`).remove();if(p.params.loop&&Ea){var rb=Ka.attr("data-swiper-slide-index");Ka.hasClass(p.params.slideDuplicateClass)?(rb=p.$wrapperEl.children(`[data-swiper-slide-index="${rb}"]:not(.${p.params.slideDuplicateClass})`),fa(rb.index(),!1)):(rb=p.$wrapperEl.children(`.${p.params.slideDuplicateClass}[data-swiper-slide-index="${rb}"]`),
2782fa(rb.index(),!1))}ca("lazyImageReady",Ka[0],cb[0]);p.params.autoHeight&&p.updateAutoHeight()}});ca("lazyImageLoad",Ka[0],cb[0])})}}function ia(){function Da(kb){if(ib){if(Aa.children(`.${Ka.slideClass}[data-swiper-slide-index="${kb}"]`).length)return!0}else if(Ra[kb])return!0;return!1}function Ea(kb){return ib?h(kb).attr("data-swiper-slide-index"):h(kb).index()}const {$wrapperEl:Aa,params:Ka,slides:Ra,activeIndex:cb}=p,ib=p.virtual&&Ka.virtual.enabled;var fb=Ka.lazy,bb=Ka.slidesPerView;"auto"===
2783bb&&(bb=0);wa||=!0;if(p.params.watchSlidesProgress)Aa.children(`.${Ka.slideVisibleClass}`).each(kb=>{kb=ib?h(kb).attr("data-swiper-slide-index"):h(kb).index();fa(kb)});else if(1<bb)for(var eb=cb;eb<cb+bb;eb+=1)Da(eb)&&fa(eb);else fa(cb);if(fb.loadPrevNext)if(1<bb||fb.loadPrevNextAmount&&1<fb.loadPrevNextAmount){eb=fb.loadPrevNextAmount;const kb=bb;fb=Math.min(cb+kb+Math.max(eb,kb),Ra.length);eb=Math.max(cb-Math.max(kb,eb),0);for(bb=cb+bb;bb<fb;bb+=1)Da(bb)&&fa(bb);for(bb=eb;bb<cb;bb+=1)Da(bb)&&fa(bb)}else bb=
2784Aa.children(`.${Ka.slideNextClass}`),0<bb.length&&fa(Ea(bb)),bb=Aa.children(`.${Ka.slidePrevClass}`),0<bb.length&&fa(Ea(bb))}function ma(){var Da=d();if(p&&!p.destroyed){var Ea=p.params.lazy.scrollingElement?h(p.params.lazy.scrollingElement):h(Da),Aa=Ea[0]===Da,Ka=Aa?Da.innerWidth:Ea[0].offsetWidth;Aa=Aa?Da.innerHeight:Ea[0].offsetHeight;var Ra=p.$el.offset(),{rtlTranslate:cb}=p;Da=!1;cb&&(Ra.left-=p.$el[0].scrollLeft);Ra=[[Ra.left,Ra.top],[Ra.left+p.width,Ra.top],[Ra.left,Ra.top+p.height],[Ra.left+
2785p.width,Ra.top+p.height]];for(cb=0;cb<Ra.length;cb+=1){const ib=Ra[cb];0<=ib[0]&&ib[0]<=Ka&&0<=ib[1]&&ib[1]<=Aa&&(0!==ib[0]||0!==ib[1])&&(Da=!0)}Ka="touchstart"===p.touchEvents.start&&p.support.passiveListener&&p.params.passiveListeners?{passive:!0,capture:!1}:!1;Da?(ia(),Ea.off("scroll",ma,Ka)):ua||(ua=!0,Ea.on("scroll",ma,Ka))}}E({lazy:{checkInView:!1,enabled:!1,loadPrevNext:!1,loadPrevNextAmount:1,loadOnTransitionStart:!1,scrollingElement:"",elementClass:"swiper-lazy",loadingClass:"swiper-lazy-loading",
2786loadedClass:"swiper-lazy-loaded",preloaderClass:"swiper-lazy-preloader"}});p.lazy={};let ua=!1,wa=!1;L("beforeInit",()=>{p.params.lazy.enabled&&p.params.preloadImages&&(p.params.preloadImages=!1)});L("init",()=>{p.params.lazy.enabled&&(p.params.lazy.checkInView?ma():ia())});L("scroll",()=>{p.params.freeMode&&p.params.freeMode.enabled&&!p.params.freeMode.sticky&&ia()});L("scrollbarDragMove resize _freeModeNoMomentumRelease",()=>{p.params.lazy.enabled&&(p.params.lazy.checkInView?ma():ia())});L("transitionStart",
2787()=>{p.params.lazy.enabled&&(p.params.lazy.loadOnTransitionStart||!p.params.lazy.loadOnTransitionStart&&!wa)&&(p.params.lazy.checkInView?ma():ia())});L("transitionEnd",()=>{p.params.lazy.enabled&&!p.params.lazy.loadOnTransitionStart&&(p.params.lazy.checkInView?ma():ia())});L("slideChange",()=>{const {lazy:Da,cssMode:Ea,watchSlidesProgress:Aa,touchReleaseOnEdges:Ka,resistanceRatio:Ra}=p.params;Da.enabled&&(Ea||Aa&&(Ka||0===Ra))&&ia()});Object.assign(p.lazy,{load:ia,loadInSlide:fa})},function({swiper:p,
2788extendParams:E,on:L}){function ca(ia,ma){const ua=function(){let Ea,Aa,Ka;return(Ra,cb)=>{Aa=-1;for(Ea=Ra.length;1<Ea-Aa;)Ka=Ea+Aa>>1,Ra[Ka]<=cb?Aa=Ka:Ea=Ka;return Ea}}();this.x=ia;this.y=ma;this.lastIndex=ia.length-1;let wa,Da;this.interpolate=function(Ea){if(!Ea)return 0;Da=ua(this.x,Ea);wa=Da-1;return(Ea-this.x[wa])*(this.y[Da]-this.y[wa])/(this.x[Da]-this.x[wa])+this.y[wa]};return this}function fa(){p.controller.control&&p.controller.spline&&(p.controller.spline=void 0,delete p.controller.spline)}
2789E({controller:{control:void 0,inverse:!1,by:"slide"}});p.controller={control:void 0};L("beforeInit",()=>{p.controller.control=p.params.controller.control});L("update",()=>{fa()});L("resize",()=>{fa()});L("observerUpdate",()=>{fa()});L("setTranslate",(ia,ma,ua)=>{p.controller.control&&p.controller.setTranslate(ma,ua)});L("setTransition",(ia,ma,ua)=>{p.controller.control&&p.controller.setTransition(ma,ua)});Object.assign(p.controller,{setTranslate:function(ia,ma){function ua(Aa){const Ka=p.rtlTranslate?
2790-p.translate:p.translate;"slide"===p.params.controller.by&&(p.controller.spline||(p.controller.spline=p.params.loop?new ca(p.slidesGrid,Aa.slidesGrid):new ca(p.snapGrid,Aa.snapGrid)),Da=-p.controller.spline.interpolate(-Ka));Da&&"container"!==p.params.controller.by||(wa=(Aa.maxTranslate()-Aa.minTranslate())/(p.maxTranslate()-p.minTranslate()),Da=(Ka-p.minTranslate())*wa+Aa.minTranslate());p.params.controller.inverse&&(Da=Aa.maxTranslate()-Da);Aa.updateProgress(Da);Aa.setTranslate(Da,p);Aa.updateActiveIndex();
2791Aa.updateSlidesClasses()}ia=p.controller.control;let wa,Da;const Ea=p.constructor;if(Array.isArray(ia))for(let Aa=0;Aa<ia.length;Aa+=1)ia[Aa]!==ma&&ia[Aa]instanceof Ea&&ua(ia[Aa]);else ia instanceof Ea&&ma!==ia&&ua(ia)},setTransition:function(ia,ma){function ua(Aa){Aa.setTransition(ia,p);0!==ia&&(Aa.transitionStart(),Aa.params.autoHeight&&l(()=>{Aa.updateAutoHeight()}),Aa.$wrapperEl.transitionEnd(()=>{Da&&(Aa.params.loop&&"slide"===p.params.controller.by&&Aa.loopFix(),Aa.transitionEnd())}))}const wa=
2792p.constructor,Da=p.controller.control;let Ea;if(Array.isArray(Da))for(Ea=0;Ea<Da.length;Ea+=1)Da[Ea]!==ma&&Da[Ea]instanceof wa&&ua(Da[Ea]);else Da instanceof wa&&ma!==Da&&ua(Da)}})},function({swiper:p,extendParams:E,on:L}){function ca(fb){const bb=cb;0!==bb.length&&(bb.html(""),bb.html(fb))}function fa(fb=16){return"x".repeat(fb).replace(/x/g,()=>Math.round(16*Math.random()).toString(16))}function ia(fb){fb.attr("tabIndex","0")}function ma(fb,bb){fb.attr("role",bb)}function ua(fb,bb){fb.attr("aria-roledescription",
2793bb)}function wa(fb,bb){fb.attr("aria-label",bb)}function Da(fb){if(13===fb.keyCode||32===fb.keyCode){var bb=p.params.a11y;fb=h(fb.target);p.navigation&&p.navigation.$nextEl&&fb.is(p.navigation.$nextEl)&&(p.isEnd&&!p.params.loop||p.slideNext(),p.isEnd?ca(bb.lastSlideMessage):ca(bb.nextSlideMessage));p.navigation&&p.navigation.$prevEl&&fb.is(p.navigation.$prevEl)&&(p.isBeginning&&!p.params.loop||p.slidePrev(),p.isBeg
2793inning?ca(bb.firstSlideMessage):ca(bb.prevSlideMessage));p.pagination&&fb.is(qa(p.params.pagination.bulletClass))&&
2794fb[0].click()}}function Ea(){if(!p.params.loop&&!p.params.rewind&&p.navigation){var {$nextEl:fb,$prevEl:bb}=p.navigation;bb&&0<bb.length&&(p.isBeginning?(bb.attr("aria-disabled",!0),bb.attr("tabIndex","-1")):(bb.attr("aria-disabled",!1),ia(bb)));fb&&0<fb.length&&(p.isEnd?(fb.attr("aria-disabled",!0),fb.attr("tabIndex","-1")):(fb.attr("aria-disabled",!1),ia(fb)))}}function Aa(){return p.pagination&&p.pagination.bullets&&p.pagination.bullets.length}function Ka(){const fb=p.params.a11y;Aa()&&p.pagination.bullets.each(bb=>
2795{bb=h(bb);p.params.pagination.clickable&&(ia(bb),p.params.pagination.renderBullet||(ma(bb,"button"),wa(bb,fb.paginationBulletMessage.replace(/\{\{index\}\}/,bb.index()+1))));bb.is(`.${p.params.pagination.bulletActiveClass}`)?bb.attr("aria-current","true"):bb.removeAttr("aria-current")})}function Ra(){const fb=p.params.a11y;p.$el.append(cb);var bb=p.$el;fb.containerRoleDescriptionMessage&&ua(bb,fb.containerRoleDescriptionMessage);fb.containerMessage&&wa(bb,fb.containerMessage);bb=p.$wrapperEl;const eb=
2796bb.attr("id")||`swiper-wrapper-${fa(16)}`,kb=p.params.autoplay&&p.params.autoplay.enabled?"off":"polite";bb.attr("id",eb);bb.attr("aria-live",kb);fb.itemRoleDescriptionMessage&&ua(h(p.slides),fb.itemRoleDescriptionMessage);ma(h(p.slides),fb.slideRole);const rb=p.params.loop?p.slides.filter(vb=>!vb.classList.contains(p.params.slideDuplicateClass)).length:p.slides.length;p.slides.each((vb,jb)=>{vb=h(vb);jb=p.params.loop?parseInt(vb.attr("data-swiper-slide-index"),10):jb;jb=fb.slideLabelMessage.replace(/\{\{index\}\}/,
2797jb+1).replace(/\{\{slidesLength\}\}/,rb);wa(vb,jb)});let $a,nb;p.navigation&&p.navigation.$nextEl&&($a=p.navigation.$nextEl);p.navigation&&p.navigation.$prevEl&&(nb=p.navigation.$prevEl);$a&&$a.length&&ib($a,eb,fb.nextSlideMessage);nb&&nb.length&&ib(nb,eb,fb.prevSlideMessage);if(Aa()&&p.params.pagination.clickable)p.pagination.$el.on("keydown",qa(p.params.pagination.bulletClass),Da)}E({a11y:{enabled:!0,notificationClass:"swiper-notification",prevSlideMessage:"Previous slide",nextSlideMessage:"Next slide",
2798firstSlideMessage:"This is the first slide",lastSlideMessage:"This is the last slide",paginationBulletMessage:"Go to slide {{index}}",slideLabelMessage:"{{index}} / {{slidesLength}}",containerMessage:null,containerRoleDescriptionMessage:null,itemRoleDescriptionMessage:null,slideRole:"group"}});let cb=null;const ib=(fb,bb,eb)=>{ia(fb);"BUTTON"!==fb[0].tagName&&(ma(fb,"button"),fb.on("keydown",Da));wa(fb,eb);fb.attr("aria-controls",bb)};L("beforeInit",()=>{cb=h(`<span class="${p.params.a11y.notificationClass}" aria-live="assertive" aria-atomic="true"></span>`)});
2799L("afterInit",()=>{p.params.a11y.enabled&&(Ra(),Ea())});L("toEdge",()=>{p.params.a11y.enabled&&Ea()});L("fromEdge",()=>{p.params.a11y.enabled&&Ea()});L("paginationUpdate",()=>{p.params.a11y.enabled&&Ka()});L("destroy",()=>{if(p.params.a11y.enabled){cb&&0<cb.length&&cb.remove();if(p.navigation&&p.navigation.$nextEl)var fb=p.navigation.$nextEl;if(p.navigation&&p.navigation.$prevEl)var bb=p.navigation.$prevEl;fb&&fb.off("keydown",Da);bb&&bb.off("keydown",Da);Aa()&&p.params.pagination.clickable&&p.pagination.$el.off("keydown",
2800qa(p.params.pagination.bulletClass),Da)}})},function({swiper:p,extendParams:E,on:L}){E({history:{enabled:!1,root:"",replaceState:!1,key:"slides"}});let ca=!1,fa={};const ia=Ea=>Ea.toString().replace(/\s+/g,"-").replace(/[^\w-]+/g,"").replace(/--+/g,"-").replace(/^-+/,"").replace(/-+$/,""),ma=Ea=>{var Aa=d();Ea=(Ea?new URL(Ea):Aa.location).pathname.slice(1).split("/").filter(Ka=>""!==Ka);Aa=Ea.length;return{key:Ea[Aa-2],value:Ea[Aa-1]}},ua=(Ea,Aa)=>{const Ka=d();if(ca&&p.params.history.enabled){var Ra=
2801p.params.url?new URL(p.params.url):Ka.location;Aa=p.slides.eq(Aa);Aa=ia(Aa.attr("data-history"));0<p.params.history.root.length?(Ra=p.params.history.root,"/"===Ra[Ra.length-1]&&(Ra=Ra.slice(0,Ra.length-1)),Aa=`${Ra}/${Ea}/${Aa}`):Ra.pathname.includes(Ea)||(Aa=`${Ea}/${Aa}`);(Ea=Ka.history.state)&&Ea.value===Aa||(p.params.history.replaceState?Ka.history.replaceState({value:Aa},null,Aa):Ka.history.pushState({value:Aa},null,Aa))}},wa=(Ea,Aa,Ka)=>{if(Aa)for(let cb=0,ib=p.slides.length;cb<ib;cb+=1){var Ra=
2802p.slides.eq(cb);ia(Ra.attr("data-history"))!==Aa||Ra.hasClass(p.params.slideDuplicateClass)||(Ra=Ra.index(),p.slideTo(Ra,Ea,Ka))}else p.slideTo(0,Ea,Ka)},Da=()=>{fa=ma(p.params.url);wa(p.params.speed,p.paths.value,!1)};L("init",()=>{if(p.params.history.enabled){const Ea=d();if(p.params.history)if(Ea.history&&Ea.history.pushState){if(ca=!0,fa=ma(p.params.url),fa.key||fa.value)wa(0,fa.value,p.params.runCallbacksOnInit),p.params.history.replaceState||Ea.addEventListener("popstate",Da)}else p.params.history.enabled=
2803!1,p.params.hashNavigation.enabled=!0}});L("destroy",()=>{if(p.params.history.enabled){const Ea=d();p.params.history.replaceState||Ea.removeEventListener("popstate",Da)}});L("transitionEnd _freeModeNoMomentumRelease",()=>{ca&&ua(p.params.history.key,p.activeIndex)});L("slideChange",()=>{ca&&p.params.cssMode&&ua(p.params.history.key,p.activeIndex)})},function({swiper:p,extendParams:E,emit:L,on:ca}){let fa=!1;const ia=c(),ma=d();E({hashNavigation:{enabled:!1,replaceState:!1,watchState:!1}});const ua=
2804()=>{L("hashChange");var Da=ia.location.hash.replace("#","");const Ea=p.slides.eq(p.activeIndex).attr("data-hash");Da!==Ea&&(Da=p.$wrapperEl.children(`.${p.params.slideClass}[data-hash="${Da}
2804"]`).index(),"undefined"!==typeof Da&&p.slideTo(Da))},wa=()=>{if(fa&&p.params.hashNavigation.enabled){if(p.params.hashNavigation.replaceState&&ma.history&&ma.history.replaceState)ma.history.replaceState(null,null,`#${p.slides.eq(p.activeIndex).attr("data-hash")}`||"");else{var Da=p.slides.eq(p.activeIndex);Da=
2805Da.attr("data-hash")||Da.attr("data-history");ia.location.hash=Da||""}L("hashSet")}};ca("init",()=>{if(p.params.hashNavigation.enabled&&!(!p.params.hashNavigation.enabled||p.params.history&&p.params.history.enabled)){fa=!0;var Da=ia.location.hash.replace("#","");if(Da)for(let Aa=0,Ka=p.slides.length;Aa<Ka;Aa+=1){var Ea=p.slides.eq(Aa);(Ea.attr("data-hash")||Ea.attr("data-history"))!==Da||Ea.hasClass(p.params.slideDuplicateClass)||(Ea=Ea.index(),p.slideTo(Ea,0,p.params.runCallbacksOnInit,!0))}if(p.params.hashNavigation.watchState)h(ma).on("hashchange",
2806ua)}});ca("destroy",()=>{p.params.hashNavigation.enabled&&p.params.hashNavigation.watchState&&h(ma).off("hashchange",ua)});ca("transitionEnd _freeModeNoMomentumRelease",()=>{fa&&wa()});ca("slideChange",()=>{fa&&p.params.cssMode&&wa()})},function({swiper:p,extendParams:E,emit:L,once:ca}){E({freeMode:{enabled:!1,momentum:!0,momentumRatio:1,momentumBounce:!0,momentumBounceRatio:1,momentumVelocityRatio:1,sticky:!1,minimumVelocity:.02}});Object.assign(p,{freeMode:{onTouchMove:function(){const {touchEventsData:fa,
2807touches:ia}=p;0===fa.velocities.length&&fa.velocities.push({position:ia[p.isHorizontal()?"startX":"startY"],time:fa.touchStartTime});fa.velocities.push({position:ia[p.isHorizontal()?"currentX":"currentY"],time:m()})},onTouchEnd:function({currentPos:fa}){const {params:ia,$wrapperEl:ma,rtlTranslate:ua,snapGrid:wa,touchEventsData:Da}=p,Ea=m()-Da.touchStartTime;if(fa<-p.minTranslate())p.slideTo(p.activeIndex);else if(fa>-p.maxTranslate())p.slides.length<wa.length?p.slideTo(wa.length-1):p.slideTo(p.slides.length-
28081);else{if(ia.freeMode.momentum){if(1<Da.velocities.length){fa=Da.velocities.pop();var Aa=Da.velocities.pop(),Ka=fa.time-Aa.time;p.velocity=(fa.position-Aa.position)/Ka;p.velocity/=2;Math.abs(p.velocity)<ia.freeMode.minimumVelocity&&(p.velocity=0);if(150<Ka||300<m()-fa.time)p.velocity=0}else p.velocity=0;p.velocity*=ia.freeMode.momentumVelocityRatio;Da.velocities.length=0;Ka=1E3*ia.freeMode.momentumRatio;fa=p.translate+p.velocity*Ka;ua&&(fa=-fa);Aa=!1;let fb;var Ra=20*Math.abs(p.velocity)*ia.freeMode.momentumBounceRatio,
2809cb;if(fa<p.maxTranslate())ia.freeMode.momentumBounce?(fa+p.maxTranslate()<-Ra&&(fa=p.maxTranslate()-Ra),fb=p.maxTranslate(),Aa=!0,Da.allowMomentumBounce=!0):fa=p.maxTranslate(),ia.loop&&ia.centeredSlides&&(cb=!0);else if(fa>p.minTranslate())ia.freeMode.momentumBounce?(fa-p.minTranslate()>Ra&&(fa=p.minTranslate()+Ra),fb=p.minTranslate(),Aa=!0,Da.allowMomentumBounce=!0):fa=p.minTranslate(),ia.loop&&ia.centeredSlides&&(cb=!0);else if(ia.freeMode.sticky){for(Ra=0;Ra<wa.length;Ra+=1)if(wa[Ra]>-fa){var ib=
2810Ra;break}fa=Math.abs(wa[ib]-fa)<Math.abs(wa[ib-1]-fa)||"next"===p.swipeDirection?wa[ib]:wa[ib-1];fa=-fa}cb&&ca("transitionEnd",()=>{p.loopFix()});if(0!==p.velocity)Ka=ua?Math.abs((-fa-p.translate)/p.velocity):Math.abs((fa-p.translate)/p.velocity),ia.freeMode.sticky&&(cb=Math.abs((ua?-fa:fa)-p.translate),ib=p.slidesSizesGrid[p.activeIndex],Ka=cb<ib?ia.speed:cb<2*ib?1.5*ia.speed:2.5*ia.speed);else if(ia.freeMode.sticky){p.slideToClosest();return}ia.freeMode.momentumBounce&&Aa?(p.updateProgress(fb),
2811p.setTransition(Ka),p.setTranslate(fa),p.transitionStart(!0,p.swipeDirection),p.animating=!0,ma.transitionEnd(()=>{p&&!p.destroyed&&Da.allowMomentumBounce&&(L("momentumBounce"),p.setTransition(ia.speed),setTimeout(()=>{p.setTranslate(fb);ma.transitionEnd(()=>{p&&!p.destroyed&&p.transitionEnd()})},0))})):p.velocity?(L("_freeModeNoMomentumRelease"),p.updateProgress(fa),p.setTransition(Ka),p.setTranslate(fa),p.transitionStart(!0,p.swipeDirection),p.animating||(p.animating=!0,ma.transitionEnd(()=>{p&&
2812!p.destroyed&&p.transitionEnd()}))):p.updateProgress(fa);p.updateActiveIndex();p.updateSlidesClasses()}else{if(ia.freeMode.sticky){p.slideToClosest();return}ia.freeMode&&L("_freeModeNoMomentumRelease")}if(!ia.freeMode.momentum||Ea>=ia.longSwipesMs)p.updateProgress(),p.updateActiveIndex(),p.updateSlidesClasses()}}}})},function({swiper:p,extendParams:E}){E({grid:{rows:1,fill:"column"}});let L,ca,fa;p.grid={initSlides:ia=>{const {slidesPerView:ma}=p.params,{rows:ua,fill:wa}=p.params.grid;ca=L/ua;fa=
2813Math.floor(ia/ua);L=Math.floor(ia/ua)===ia/ua?ia:Math.ceil(ia/ua)*ua;"auto"!==ma&&"row"===wa&&(L=Math.max(L,ma*ua))},updateSlide:(ia,ma,ua,wa)=>{const {slidesPerGroup:Da,spaceBetween:Ea}=p.params,{rows:Aa,fill:Ka}=p.params.grid;if("row"===Ka&&1<Da){var Ra=Math.floor(ia/(Da*Aa));const cb=ia-Aa*Da*Ra;ua=0===Ra?Da:Math.min(Math.ceil((ua-Ra*Aa*Da)/Aa),Da);ia=Math.floor(cb/ua);Ra=cb-ia*ua+Ra*Da;Ra+=ia*L/Aa;
2813ma.css({"-webkit-order":Ra,order:Ra})}else if("column"===Ka){if(Ra=Math.floor(ia/Aa),ia-=Ra*Aa,Ra>
2814fa||Ra===fa&&ia===Aa-1)ia+=1,ia>=Aa&&(ia=0)}else ia=Math.floor(ia/ca);ma.css(wa("margin-top"),0!==ia?Ea&&`${Ea}px`:"")},updateWrapperSize:(ia,ma,ua)=>{const {spaceBetween:wa,centeredSlides:Da,roundLengths:Ea}=p.params;var {rows:Aa}=p.params.grid;p.virtualSize=(ia+wa)*L;p.virtualSize=Math.ceil(p.virtualSize/Aa)-wa;p.$wrapperEl.css({[ua("width")]:`${p.virtualSize+wa}px`});if(Da){ma.splice(0,ma.length);ia=[];for(ua=0;ua<ma.length;ua+=1)Aa=ma[ua],Ea&&(Aa=Math.floor(Aa)),ma[ua]<p.virtualSize+ma[0]&&ia.push(Aa);
2815ma.push(...ia)}}}},function({swiper:p}){Object.assign(p,{appendSlide:Ba.bind(p),prependSlide:Ua.bind(p),addSlide:Ja.bind(p),removeSlide:Pa.bind(p),removeAllSlides:Ca.bind(p)})}]);return va});
2816!function(a,b,c,d){function e(sa,Ia,Qa){return setTimeout(l(sa,Qa),Ia)}function f(sa,Ia,Qa){return Array.isArray(sa)?(g(sa,Qa[Ia],Qa),!0):!1}function g(sa,Ia,Qa){var Za;if(sa)if(sa.forEach)sa.forEach(Ia,Qa);else if(sa.length!==d)for(Za=0;Za<sa.length;)Ia.call(Qa,sa[Za],Za,sa),Za++;else for(Za in sa)sa.hasOwnProperty(Za)&&Ia.call(Qa,sa[Za],Za,sa)}function h(sa,Ia,Qa){var Za="DEPRECATED METHOD: "+Ia+"\n"+Qa+" AT \n";return function(){var pb=Error("get-stack-trace");pb=pb&&pb.stack?pb.stack.replace(/^[^\(]+?[\n$]/gm,
2817"").replace(/^\s+at\s+/gm,"").replace(/^Object.<anonymous>\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace";var zb=a.console&&(a.console.warn||a.console.log);return zb&&zb.call(a.console,Za,pb),sa.apply(this,arguments)}}function k(sa,Ia,Qa){var Za=Ia.prototype;Ia=sa.prototype=Object.create(Za);Ia.constructor=sa;Ia._super=Za;Qa&&ma(Ia,Qa)}function l(sa,Ia){return function(){return sa.apply(Ia,arguments)}}function m(sa,Ia){return typeof sa==L?sa.apply(Ia?Ia[0]||d:d,Ia):sa}function n(sa,Ia,Qa){g(u(Ia),
2818function(Za){sa.addEventListener(Za,Qa,!1)})}function r(sa,Ia,Qa){g(u(Ia),function(Za){sa.removeEventListener(Za,Qa,!1)})}function t(sa,Ia){for(;sa;){if(sa==Ia)return!0;sa=sa.parentNode}return!1}function u(sa){return sa.trim().split(/\s+/g)}function x(sa,Ia,Qa){if(sa.indexOf&&!Qa)return sa.indexOf(Ia);for(var Za=0;Za<sa.length;){if(Qa&&sa[Za][Qa]==Ia||!Qa&&sa[Za]===Ia)return Za;Za++}return-1}function B(sa){return Array.prototype.slice.call(sa,0)}function y(sa,Ia,Qa){for(var Za=[],pb=[],zb=0;zb<sa.length;){var Fb=
2819Ia?sa[zb][Ia]:sa[zb];0>x(pb,Fb)&&Za.push(sa[zb]);pb[zb]=Fb;zb++}return Qa&&(Za=Ia?Za.sort(function(Kb,ac){return Kb[Ia]>ac[Ia]}):Za.sort()),Za}function A(sa,Ia){for(var Qa,Za,pb=Ia[0].toUpperCase()+Ia.slice(1),zb=0;zb<p.length;){if(Qa=p[zb],Za=Qa?Qa+pb:Ia,Za in sa)return Za;zb++}return d}function aa(sa){sa=sa.ownerDocument||sa;return sa.defaultView||sa.parentWindow||a}function ha(sa,Ia){var Qa=this;this.manager=sa;this.callback=Ia;this.element=sa.element;this.target=sa.options.inputTarget;this.domHandler=
2820function(Za){m(sa.options.enable,[sa])&&Qa.handler(Za)};this.init()}function z(sa){var Ia=sa.options.inputClass;return new (Ia?Ia:Ka?ea:Ra?za:Aa?qa:ja)(sa,V)}function V(sa,Ia,Qa){var Za=Qa.pointers.length;var pb=Qa.changedPointers.length;var zb=Ia&ib&&0===Za-pb;Za=Ia&(bb|eb)&&0===Za-pb;Qa.isFirst=!!zb;Qa.isFinal=!!Za;zb&&(sa.session={});Qa.eventType=Ia;Ia=sa.session;zb=Qa.pointers;Za=zb.length;Ia.firstInput||(Ia.firstInput=ba(Qa));
28201<Za&&!Ia.firstMultiple?Ia.firstMultiple=ba(Qa):1===Za&&(Ia.firstMultiple=
2821!1);pb=Ia.firstInput;var Fb=(Za=Ia.firstMultiple)?Za.center:pb.center;var Kb=Qa.center=v(zb);Qa.timeStamp=ia();Qa.deltaTime=Qa.timeStamp-pb.timeStamp;Qa.angle=da(Fb,Kb);Qa.distance=C(Fb,Kb);pb=Qa.center;Fb=Ia.offsetDelta||{};Kb=Ia.prevDelta||{};var ac=Ia.prevInput||{};Qa.eventType!==ib&&ac.eventType!==bb||(Kb=Ia.prevDelta={x:ac.deltaX||0,y:ac.deltaY||0},Fb=Ia.offsetDelta={x:pb.x,y:pb.y});Qa.deltaX=Kb.x+(pb.x-Fb.x);Qa.deltaY=Kb.y+(pb.y-Fb.y);Qa.offsetDirection=K(Qa.deltaX,Qa.deltaY);Kb=Qa.deltaTime;
2822pb=Qa.deltaX/Kb||0;Fb=Qa.deltaY/Kb||0;Qa.overallVelocityX=pb;Qa.overallVelocityY=Fb;Qa.overallVelocity=fa(pb)>fa(Fb)?pb:Fb;Za?(pb=Za.pointers,pb=C(zb[0],zb[1],Bb)/C(pb[0],pb[1],Bb)):pb=1;Qa.scale=pb;Za?(Za=Za.pointers,zb=da(zb[1],zb[0],Bb)+da(Za[1],Za[0],Bb)):zb=0;Qa.rotation=zb;Qa.maxPointers=Ia.prevInput?Qa.pointers.length>Ia.prevInput.maxPointers?Qa.pointers.length:Ia.prevInput.maxPointers:Qa.pointers.length;Fb=Ia.lastInterval||Qa;zb=Qa.timeStamp-Fb.timeStamp;Qa.eventType!=eb&&(zb>cb||Fb.velocity===
2823d)?(pb=Qa.deltaX-Fb.deltaX,Fb=Qa.deltaY-Fb.deltaY,Kb=pb/zb||0,ac=Fb/zb||0,zb=Kb,Za=ac,Kb=fa(Kb)>fa(ac)?Kb:ac,pb=K(pb,Fb),Ia.lastInterval=Qa):(Kb=Fb.velocity,zb=Fb.velocityX,Za=Fb.velocityY,pb=Fb.direction);Qa.velocity=Kb;Qa.velocityX=zb;Qa.velocityY=Za;Qa.direction=pb;Ia=sa.element;t(Qa.srcEvent.target,Ia)&&(Ia=Qa.srcEvent.target);Qa.target=Ia;sa.emit("hammer.input",Qa);sa.recognize(Qa);sa.session.prevInput=Qa}function ba(sa){for(var Ia=[],Qa=0;Qa<sa.pointers.length;)Ia[Qa]={clientX:ca(sa.pointers[Qa].clientX),
2824clientY:ca(sa.pointers[Qa].clientY)},Qa++;return{timeStamp:ia(),pointers:Ia,center:v(Ia),deltaX:sa.deltaX,deltaY:sa.deltaY}}function v(sa){var Ia=sa.length;if(1===Ia)return{x:ca(sa[0].clientX),y:ca(sa[0].clientY)};for(var Qa=0,Za=0,pb=0;Ia>pb;)Qa+=sa[pb].clientX,Za+=sa[pb].clientY,pb++;return{x:ca(Qa/Ia),y:ca(Za/Ia)}}function K(sa,Ia){return sa===Ia?kb:fa(sa)>=fa(Ia)?0>sa?rb:$a:0>Ia?nb:vb}function C(sa,Ia,Qa){Qa||=wb;var Za=Ia[Qa[0]]-sa[Qa[0]];sa=Ia[Qa[1]]-sa[Qa[1]];return Math.sqrt(Za*Za+sa*sa)}
2825function da(sa,Ia,Qa){Qa||=wb;return 180*Math.atan2(Ia[Qa[1]]-sa[Qa[1]],Ia[Qa[0]]-sa[Qa[0]])/Math.PI}function ja(){this.evEl=Ab;this.evWin=Cb;this.pressed=!1;ha.apply(this,arguments)}function ea(){this.evEl=ic;this.evWin=mc;ha.apply(this,arguments);this.store=this.manager.session.pointerEvents=[]}function ra(){this.evTarget=jc;this.evWin=hc;this.started=!1;ha.apply(this,arguments)}function za(){this.evTarget=Fc;this.targetIds={};ha.apply(this,arguments)}function na(sa,Ia){var Qa=B(sa.touches),Za=
2826this.targetIds;if(Ia&(ib|fb)&&1===Qa.length)return Za[Qa[0].identifier]=!0,[Qa,Qa];var pb;sa=B(sa.changedTouches);var zb=[],Fb=this.target;if(pb=Qa.filter(function(Kb){return t(Kb.target,Fb)}),Ia===ib)for(Qa=0;Qa<pb.length;)Za[pb[Qa].identifier]=!0,Qa++;for(Qa=0;Qa<sa.length;)Za[sa[Qa].identifier]&&zb.push(sa[Qa]),Ia&(bb|eb)&&delete Za[sa[Qa].identifier],Qa++;return zb.length?[y(pb.concat(zb),"identifier",!0),zb]:void 0}function qa(){ha.apply(this,arguments);var sa=l(this.handler,this);this.touch=
2827new za(this.manager,sa);this.mouse=new ja(this.manager,sa);this.primaryTouch=null;this.lastTouches=[]}function Ba(sa){sa=sa.changedPointers[0];if(sa.identifier===this.primaryTouch){var Ia={x:sa.clientX,y:sa.clientY};this.lastTouches.push(Ia);var Qa=this.lastTouches;setTimeout(function(){var Za=Qa.indexOf(Ia);-1<Za&&Qa.splice(Za,1)},Oc)}}function Ua(sa,Ia){this.manager=sa;this.set(Ia)}function Ja(sa){if(-1<sa.indexOf(Lb))return Lb;var Ia=-1<sa.indexOf(Wb),Qa=-1<sa.indexOf(Xb);return Ia&&Qa?Lb:Ia||
2828Qa?Ia?Wb:Xb:-1<sa.indexOf(rc)?rc:zc}function Pa(sa){this.options=ma({},this.defaults,sa||{});this.id=Da++;this.manager=null;sa=this.options.enable;this.options.enable=sa===d?!0:sa;this.state=wc;this.simultaneous={};this.requireFail=[]}function Ca(sa){return sa&dc?"cancel":sa&cc?"end":sa&oc?"move":sa&Vb?"start":""}function xa(sa){return sa==vb?"down":sa==nb?"up":sa==rb?"left":sa==$a?"right":""}function Fa(sa,Ia){return(Ia=Ia.manager)?Ia.get(sa):sa}function Na(){Pa.apply(this,arguments)}function I(){Na.apply(this,
2829arguments);this.pY=this.pX=null}function Ta(){Na.apply(this,arguments)}function Sa(){Pa.apply(this,arguments);this._input=this._timer=null}function db(){Na.apply(this,arguments)}function ab(){Na.apply(this,arguments)}function Oa(){Pa.apply(this,arguments);this.pCenter=this.pTime=!1;this._input=this._timer=null;this.count=0}function Ga(sa,Ia){Ia=Ia||{};var Qa=Ia.recognizers;return Ia.recognizers=Qa===d?Ga.defaults.preset:Qa,new la(sa,Ia)}function la(sa,Ia){this.options=ma({},Ga.defaults,Ia||{});this.options.inputTarget=
2830this.options.inputTarget||sa;this.handlers={};this.session={};this.recognizers=[];this.oldCssProps={};this.element=sa;this.input=z(this);this.touchAction=new Ua(this,this.options.touchAction);ta(this,!0);g(this.options.recognizers,function(Qa){var Za=this.add(new Qa[0](Qa[1]));Qa[2]&&Za.recognizeWith(Qa[2]);Qa[3]&&Za.requireFailure(Qa[3])},this)}function ta(sa,Ia){var Qa=sa.element;if(Qa.style){var Za;g(sa.options.cssProps,function(pb,zb){Za=A(Qa.style,zb);Ia?(sa.oldCssProps[Za]=Qa.style[Za],Qa.style[Za]=
2831pb):Qa.style[Za]=sa.oldCssProps[Za]||""});Ia||(sa.oldCssProps={})}}function va(sa,Ia){var Qa=b.createEvent("Event");Qa.initEvent(sa,!0,!0);Qa.gesture=Ia;Ia.target.dispatchEvent(Qa)}var p=" webkit Moz MS ms o".split(" "),E=b.createElement("div"),L="function",ca=Math.round,fa=Math.abs,ia=Date.now;var ma="function"!=typeof Object.assign?function(sa){if(sa===d||null===sa)throw new TypeError("Cannot convert undefined or null to object");for(var Ia=Object(sa),Qa=1;Qa<arguments.length;Qa++){var Za=arguments[Qa];
2832if(Za!==d&&null!==Za)for(var pb in Za)Za.hasOwnProperty(pb)&&(Ia[pb]=Za[pb])}return Ia}:Object.assign;var ua=h(function(sa,Ia,Qa){for(var Za=Object.keys(Ia),pb=0;pb<Za.length;)(!Qa||Qa&&sa[Za[pb]]===d)&&(sa[Za[pb]]=Ia[Za[pb]]),pb++;return sa},"extend","Use `assign`."),wa=h(function(sa,Ia){return ua(sa,Ia,!0)},"merge","Use `assign`."),Da=1,Ea=/mobile|tablet|ip(ad|hone|od)|android/i,Aa="ontouchstart"in a,Ka=A(a,"PointerEvent")!==d,Ra=Aa&&Ea.test(navigator.userAgent),cb=25,ib=1,fb=2,bb=4,eb=8,kb=1,rb=
28332,$a=4,nb=8,vb=16,jb=rb|$a,Ya=nb|vb,Xa=jb|Ya,wb=["x","y"],Bb=["clientX","clientY"];ha.prototype={handler:function(){},init:function(){this.evEl&&n(this.element,this.evEl,this.domHandler);this.evTarget&&n(this.target,this.evTarget,this.domHandler);this.evWin&&n(aa(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&r(this.element,this.evEl,this.domHandler);this.evTarget&&r(this.target,this.evTarget,this.domHandler);this.evWin&&r(aa(this.element),this.evWin,this.domHandler)}};var ob=
2834{mousedown:ib,mousemove:fb,mouseup:bb},Ab="mousedown",Cb="mousemove mouseup";k(ja,ha,{handler:function(sa){var Ia=ob[sa.type];Ia&ib&&0===sa.button&&(this.pressed=!0);Ia&fb&&1!==sa.which&&(Ia=bb);this.pressed&&(Ia&bb&&(this.pressed=!1),this.callback(this.manager,Ia,{pointers:[sa],changedPointers:[sa],pointerType:"mouse",srcEvent:sa}))}});var Eb={pointerdown:ib,pointermove:fb,pointerup:bb,pointercancel:eb,pointerout:eb},Nb={2:"touch",3:"pen",4:"mouse",5:"kinect"},ic="pointerdown",mc="pointermove pointerup pointercancel";
2835a.MSPointerEvent&&!a.PointerEvent&&(ic="MSPointerDown",mc="MSPointerMove MSPointerUp MSPointerCancel");k(ea,ha,{handler:function(sa){var Ia=this.store,Qa=!1,Za=sa.type.toLowerCase().replace("ms","");Za=Eb[Za];var pb=Nb[sa.pointerType]||sa.pointerType,zb="touch"==pb,Fb=x(Ia,sa.pointerId,"pointerId");Za&ib&&(0===sa.button||zb)?0>Fb&&(Ia.push(sa),Fb=Ia.length-1):Za&(bb|eb)&&(Qa=!0);0>Fb||(Ia[Fb]=sa,this.callback(this.manager,Za,{pointers:Ia,changedPointers:[sa],pointerType:pb,srcEvent:sa}),Qa&&Ia.splice(Fb,
28361))}});var gc={touchstart:ib,touchmove:fb,touchend:bb,touchcancel:eb},jc="touchstart",hc="touchstart touchmove touchend touchcancel";k(ra,ha,{handler:function(sa){var Ia=gc[sa.type];if(Ia===ib&&(this.started=!0),this.started){var Qa=B(sa.touches),Za=B(sa.changedTouches);var pb=(Ia&(bb|eb)&&(Qa=y(Qa.concat(Za),"identifier",!0)),[Qa,Za]);Ia&(bb|eb)&&0===pb[0].length-pb[1].length&&(this.started=!1);this.callback(this.manager,Ia,{pointers:pb[0],changedPointers:pb[1],pointerType:"touch",srcEvent:sa})}}});
2837var pc={touchstart:ib,touchmove:fb,touchend:bb,touchcancel:eb},Fc="touchstart touchmove touchend touchcancel";k(za,ha,{handler:function(sa){var Ia=pc[sa.type],Qa=na.call(this,sa,Ia);Qa&&this.callback(this.manager,Ia,{pointers:Qa[0],changedPointers:Qa[1],pointerType:"touch",srcEvent:sa})}});var Oc=2500;k(qa,ha,{handler:function(sa,Ia,Qa){var Za="touch"==Qa.pointerType,pb="mouse"==Qa.pointerType;if(!(pb&&Qa.sourceCapabilities&&Qa.sourceCapabilities.firesTouchEvents)){if(Za)Ia&ib?(this.primaryTouch=
2838Qa.changedPointers[0].identifier,Ba.call(this,Qa)):Ia&(bb|eb)&&Ba.call(this,Qa);else{if(Za=pb)a:{Za=Qa.srcEvent.clientX;pb=Qa.srcEvent.clientY;for(var zb=0;zb<this.lastTouches.length;zb++){var Fb=this.lastTouches[zb],Kb=Math.abs(pb-Fb.y);if(25>=Math.abs(Za-Fb.x)&&25>=Kb){Za=!0;break a}}Za=!1}if(Za)return}this.callback(sa,Ia,Qa)}},destroy:function(){this.touch.destroy();this.mouse.destroy()}});var Gc=A(E.style,"touchAction"),Sb=Gc!==d,zc="auto",rc="manipulation",Lb="none",Wb="pan-x",Xb="pan-y",nc=
2839function(){if(!Sb)return!1;var sa={},Ia=a.CSS&&a.CSS.supports;return"auto;manipulation;pan-y;pan-x;pan-x pan-y;none".split(";").forEach(function(Qa){sa[Qa]=Ia?a.CSS.supports("touch-action",Qa):!0}),sa}();Ua.prototype={set:function(sa){"compute"==sa&&(sa=this.compute());Sb&&this.manager.element.style&&nc[sa]&&(this.manager.element.style[Gc]=sa);this.actions=sa.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var sa=[];return g(this.manager.recognizers,
2840function(Ia){m(Ia.options.enable,[Ia])&&(sa=sa.concat(Ia.getTouchAction()))}),Ja(sa.join(" "))},preventDefaults:function(sa){var Ia=sa.srcEvent,Qa=sa.offsetDirection;if(this.manager.session.prevented)return void Ia.preventDefault();var Za=this.actions,pb=-1<Za.indexOf(Lb)&&!nc[Lb],zb=-1<Za.indexOf(Xb)&&!nc[Xb];Za=-1<Za.indexOf(Wb)&&!nc[Wb];if(pb){var Fb=2>sa.distance,Kb=250>
2840sa.deltaTime;if(1===sa.pointers.length&&Fb&&Kb)return}return Za&&zb?void 0:pb||zb&&Qa&jb||Za&&Qa&Ya?this.preventSrc(Ia):void 0},
2841preventSrc:function(sa){this.manager.session.prevented=!0;sa.preventDefault()}};var wc=1,Vb=2,oc=4,cc=8,$b=cc,dc=16;Pa.prototype={defaults:{},set:function(sa){return ma(this.options,sa),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(sa){if(f(sa,"recognizeWith",this))return this;var Ia=this.simultaneous;return sa=Fa(sa,this),Ia[sa.id]||(Ia[sa.id]=sa,sa.recognizeWith(this)),this},dropRecognizeWith:function(sa){return f(sa,"dropRecognizeWith",this)?this:(sa=Fa(sa,this),
2842delete this.simultaneous[sa.id],this)},requireFailure:function(sa){if(f(sa,"requireFailure",this))return this;var Ia=this.requireFail;return sa=Fa(sa,this),-1===x(Ia,sa)&&(Ia.push(sa),sa.requireFailure(this)),this},dropRequireFailure:function(sa){if(f(sa,"dropRequireFailure",this))return this;sa=Fa(sa,this);sa=x(this.requireFail,sa);return-1<sa&&this.requireFail.splice(sa,1),this},hasRequireFailures:function(){return 0<this.requireFail.length},canRecognizeWith:function(sa){return!!this.simultaneous[sa.id]},
2843emit:function(sa){function Ia(pb){Qa.manager.emit(pb,sa)}var Qa=this,Za=this.state;cc>Za&&Ia(Qa.options.event+Ca(Za));Ia(Qa.options.event);sa.additionalEvent&&Ia(sa.additionalEvent);Za>=cc&&Ia(Qa.options.event+Ca(Za))},tryEmit:function(sa){return this.canEmit()?this.emit(sa):void(this.state=32)},canEmit:function(){for(var sa=0;sa<this.requireFail.length;){if(!(this.requireFail[sa].state&(32|wc)))return!1;sa++}return!0},recognize:function(sa){sa=ma({},sa);return m(this.options.enable,[this,sa])?(this.state&
2844($b|dc|32)&&(this.state=wc),this.state=this.process(sa),void(this.state&(Vb|oc|cc|dc)&&this.tryEmit(sa))):(this.reset(),void(this.state=32))},process:function(sa){},getTouchAction:function(){},reset:function(){}};k(Na,Pa,{defaults:{pointers:1},attrTest:function(sa){var Ia=this.options.pointers;return 0===Ia||sa.pointers.length===Ia},process:function(sa){var Ia=this.state,Qa=sa.eventType,Za=Ia&(Vb|oc);sa=this.attrTest(sa);return Za&&(Qa&eb||!sa)?Ia|dc:Za||sa?Qa&bb?Ia|cc:Ia&Vb?Ia|oc:Vb:32}});k(I,Na,
2845{defaults:{event:"pan",threshold:10,pointers:1,direction:Xa},getTouchAction:function(){var sa=this.options.direction,Ia=[];return sa&jb&&Ia.push(Xb),sa&Ya&&Ia.push(Wb),Ia},directionTest:function(sa){var Ia=this.options,Qa=!0,Za=sa.distance,pb=sa.direction,zb=sa.deltaX,Fb=sa.deltaY;return pb&Ia.direction||(Ia.direction&jb?(pb=0===zb?kb:0>zb?rb:$a,Qa=zb!=this.pX,Za=Math.abs(sa.deltaX)):(pb=0===Fb?kb:0>Fb?nb:vb,Qa=Fb!=this.pY,Za=Math.abs(sa.deltaY))),sa.direction=pb,Qa&&Za>Ia.threshold&&pb&Ia.direction},
2846attrTest:function(sa){return Na.prototype.attrTest.call(this,sa)&&(this.state&Vb||!(this.state&Vb)&&this.directionTest(sa))},emit:function(sa){this.pX=sa.deltaX;this.pY=sa.deltaY;var Ia=xa(sa.direction);Ia&&(sa.additionalEvent=this.options.event+Ia);this._super.emit.call(this,sa)}});k(Ta,Na,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Lb]},attrTest:function(sa){return this._super.attrTest.call(this,sa)&&(Math.abs(sa.scale-1)>this.options.threshold||this.state&
2847Vb)},emit:function(sa){1!==sa.scale&&(sa.additionalEvent=this.options.event+(1>sa.scale?"in":"out"));this._super.emit.call(this,sa)}});k(Sa,Pa,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[zc]},process:function(sa){var Ia=this.options,Qa=sa.pointers.length===Ia.pointers,Za=sa.distance<Ia.threshold,pb=sa.deltaT
vendor: 1,581 bytes, lines 2847-2850
2847ime>Ia.time;if(this._input=sa,!Za||!Qa||sa.eventType&(bb|eb)&&!pb)this.reset();else if(sa.eventType&ib)this.reset(),this._timer=e(function(){this.state=
2848$b;this.tryEmit()},Ia.time,this);else if(sa.eventType&bb)return $b;return 32},reset:function(){clearTimeout(this._timer)},emit:function(sa){this.state===$b&&(sa&&sa.eventType&bb?this.manager.emit(this.options.event+"up",sa):(this._input.timeStamp=ia(),this.manager.emit(this.options.event,this._input)))}});k(db,Na,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Lb]},attrTest:function(sa){return this._super.attrTest.call(this,sa)&&(Math.abs(sa.rotation)>this.options.threshold||
2849this.state&Vb)}});k(ab,Na,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:jb|Ya,pointers:1},getTouchAction:function(){return I.prototype.getTouchAction.call(this)},attrTest:function(sa){var Ia,Qa=this.options.direction;return Qa&(jb|Ya)?Ia=sa.overallVelocity:Qa&jb?Ia=sa.overallVelocityX:Qa&Ya&&(Ia=sa.overallVelocityY),this._super.attrTest.call(this,sa)&&Qa&sa.offsetDirection&&sa.distance>this.options.threshold&&sa.maxPointers==this.options.pointers&&fa(Ia)>this.options.velocity&&sa.eventType&
2850bb},emit:function(sa){var Ia=xa(sa.offsetDirection);Ia&&this.manager.emit(this.options.event+Ia,sa);this.manager.emit(this.options.event,sa)}});k(Oa,Pa,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[rc]},process:function(sa){var Ia=this.options,Qa=sa.pointers.length===Ia.pointers,Za=sa.distance<Ia.threshold,pb=sa.deltaT
2850ime<Ia.time;if(this.reset(),sa.eventType&ib&&0===this.count)return this.failTimeout();if(Za&&pb&&Qa){if(sa.eventType!=
2851bb)return this.failTimeout();Qa=this.pTime?sa.timeStamp-this.pTime<Ia.interval:!0;Za=!this.pCenter||C(this.pCenter,sa.center)<Ia.posThreshold;this.pTime=sa.timeStamp;this.pCenter=sa.center;Za&&Qa?this.count+=1:this.count=1;this._input=sa;if(0===this.count%Ia.taps)return this.hasRequireFailures()?(this._timer=e(function(){this.state=$b;this.tryEmit()},Ia.interval,this),Vb):$b}return 32},failTimeout:function(){return this._timer=e(function(){this.state=32},this.options.interval,this),32},reset:function(){clearTimeout(this._timer)},
2852emit:function(){this.state==$b&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}});Ga.VERSION="2.0.8";Ga.defaults={domEvents:!1,touchAction:"compute",enable:!0,inputTarget:null,inputClass:null,preset:[[db,{enable:!1}],[Ta,{enable:!1},["rotate"]],[ab,{direction:jb}],[I,{direction:jb},["swipe"]],[Oa],[Oa,{event:"doubletap",taps:2},["tap"]],[Sa]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};
2853la.prototype={set:function(sa){return ma(this.options,sa),sa.touchAction&&this.touchAction.update(),sa.inputTarget&&(this.input.destroy(),this.input.target=sa.inputTarget,this.input.init()),this},stop:function(sa){this.session.stopped=sa?2:1},recognize:function(sa){var Ia=this.session;if(!Ia.stopped){this.touchAction.preventDefaults(sa);var Qa=this.recognizers,Za=Ia.curRecognizer;(!Za||Za&&Za.state&$b)&&(Za=Ia.curRecognizer=null);for(var pb=0;pb<Qa.length;){var zb=Qa[pb];2===Ia.stopped||Za&&zb!=Za&&
2854!zb.canRecognizeWith(Za)?zb.reset():zb.recognize(sa);!Za&&zb.state&(Vb|oc|cc)&&(Za=Ia.curRecognizer=zb);pb++}}},get:function(sa){if(sa instanceof Pa)return sa;for(var Ia=this.recognizers,Qa=0;Qa<Ia.length;Qa++)if(Ia[Qa].options.event==sa)return Ia[Qa];return null},add:function(sa){if(f(sa,"add",this))return this;var Ia=this.get(sa.options.event);return Ia&&this.remove(Ia),this.recognizers.push(sa),sa.manager=this,this.touchAction.update(),sa},remove:function(sa){if(f(sa,"remove",this))return this;
2855if(sa=this.get(sa)){var Ia=this.recognizers;sa=x(Ia,sa);-1!==sa&&(Ia.splice(sa,1),this.touchAction.update())}return this},on:function(sa,Ia){if(sa!==d&&Ia!==d){var Qa=this.handlers;return g(u(sa),function(Za){Qa[Za]=Qa[Za]||[];Qa[Za].push(Ia)}),this}},off:function(sa,Ia){if(sa!==d){var Qa=this.handlers;return g(u(sa),function(Za){Ia?Qa[Za]&&Qa[Za].splice(x(Qa[Za],Ia),1):delete Qa[Za]}),this}},emit:function(sa,Ia){this.options.domEvents&&va(sa,Ia);var Qa=this.handlers[sa]&&this.handlers[sa].slice();
2856if(Qa&&Qa.length)for(Ia.type=sa,Ia.preventDefault=function(){Ia.srcEvent.preventDefault()},sa=0;sa<Qa.length;)Qa[sa](Ia),sa++},destroy:function(){this.element&&ta(this,!1);this.handlers={};this.session={};this.input.destroy();this.element=null}};ma(Ga,{INPUT_START:ib,INPUT_MOVE:fb,INPUT_END:bb,INPUT_CANCEL:eb,STATE_POSSIBLE:wc,STATE_BEGAN:Vb,STATE_CHANGED:oc,STATE_ENDED:cc,STATE_RECOGNIZED:$b,STATE_CANCELLED:dc,STATE_FAILED:32,DIRECTION_NONE:kb,DIRECTION_LEFT:rb,DIRECTION_RIGHT:$a,DIRECTION_UP:nb,
2857DIRECTION_DOWN:vb,DIRECTION_HORIZONTAL:jb,DIRECTION_VERTICAL:Ya,DIRECTION_ALL:Xa,Manager:la,Input:ha,TouchAction:Ua,TouchInput:za,MouseInput:ja,PointerEventInput:ea,TouchMouseInput:qa,SingleTouchInput:ra,Recognizer:Pa,AttrRecognizer:Na,Tap:Oa,Pan:I,Swipe:ab,Pinch:Ta,Rotate:db,Press:Sa,on:n,off:r,each:g,merge:wa,extend:ua,assign:ma,inherit:k,bindFn:l,prefixed:A});("undefined"!=typeof a?a:"undefined"!=typeof self?self:{}).Hammer=Ga;"function"==typeof define&&define.amd?define(function(){return Ga}):
2858"undefined"!=typeof module&&module.exports?module.exports=Ga:a[c]=Ga}(window,document,"Hammer");
2859var X={signature:"GIF",version:"89a",trailer:59,extensionIntroducer:33,applicationExtensionLabel:255,graphicControlExtensionLabel:249,imageSeparator:44,signatureSize:3,versionSize:3,globalColorTableFlagMask:128,colorResolutionMask:112,sortFlagMask:8,globalColorTableSizeMask:7,applicationIdentifierSize:8,applicationAuthCodeSize:3,disposalMethodMask:28,userIn
2859putFlagMask:2,transparentColorFlagMask:1,localColorTableFlagMask:128,interlaceFlagMask:64,idSortFlagMask:32,localColorTableSizeMask:7};
2860function F(a=256){function b(e){var f=d.length;f>=e||(e=Math.max(e,f*(1048576>f?2:1.125)>>>0),0!=f&&(e=Math.max(e,256)),f=d,d=new Uint8Array(e),0<c&&d.set(f.subarray(0,c),0))}let c=0,d=new Uint8Array(a);return{get buffer(){return d.buffer},reset(){c=0},bytesView(){return d.subarray(0,c)},bytes(){return d.slice(0,c)},writeByte(e){b(c+1);d[c]=e;c++},writeBytes(e,f=0,g=e.length){b(c+g);for(let h=0;h<g;h++)d[c++]=e[h+f]},writeBytesView(e,f=0,g=e.byteLength){b(c+g);d.set(e.subarray(f,f+g),c);c+=g}}}
2861var O=12,J=5003,lt=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];
2862function at(a,b,c,d,e=F(512),f=new Uint8Array(256),g=new Int32Array(J),h=new Int32Array(J)){function k(z){m&=lt[n];0<n?m|=z<<n:m=z;for(n+=u;8<=n;)f[A++]=m&255,254<=A&&(e.writeByte(A),e.writeBytesView(f,0,A),A=0),m>>=8,n-=8;if((y>x||t)&&(t?(u=r,x=(1<<u)-1,t=!1):(++u,x=u===O?1<<u:(1<<u)-1)),z==B){for(;0<n;)f[A++]=m&255,254<=A&&(e.writeByte(A),e.writeBytesView(f,0,A),A=0),m>>=8,n-=8;0<A&&(e.writeByte(A),e.writeBytesView(f,0,A),A=0)}}a=g.length;var l=Math.max(2,d);f.fill(0);h.fill(0);g.fill(-1);let m=
28630,n=0,r=d=l+1,t=!1,u=r,x=(1<<u)-1;d=1<<d-1;let B=d+1,y=d+2,A=0;b=c[0];let aa=0;for(var ha=a;65536>ha;ha*=2)++aa;aa=8-aa;e.writeByte(l);k(d);l=c.length;for(ha=1;ha<l;ha++)a:{let z=c[ha],V=(z<<O)+b,ba=z<<aa^b;if(g[ba]===V){b=h[ba];break a}let v=0===ba?1:a-ba;for(;0<=g[ba];)if(ba-=v,0>ba&&(ba+=a),g[ba]===V){b=h[ba];break a}k(b);b=z;y<1<<O?(h[ba]=y++,g[ba]=V):(g.fill(-1),y=d+2,t=!0,k(d))}return k(b),k(B),e.writeByte(0),e.bytesView()}function D(a,b,c){return a<<8&63488|b<<2&992|c>>3}
2864function G(a,b,c,d){return a>>4|b&240|(c&240)<<4|(d&240)<<8}function j(a,b,c){return a>>4<<8|b&240|c>>4}function R(a,b,c){return a<b?b:a>c?c:a}function T(a){return a*a}function tt(a,b,c){var d=0,e=1E100;b=a[b];let f=b.cnt,g=b.ac,h=b.rc,k=b.gc,l=b.bc;for(var m=b.fw;0!=m;m=a[m].fw){let r=a[m];var n=r.cnt;let t=f*n/(f+n);t>=e||(n=0,c&&(n+=t*T(r.ac-g),n>=e)||(n+=t*T(r.rc-h),n>=e||(n+=t*T(r.gc-k),n>=e||(n+=t*T(r.bc-l),n>=e||(e=n,d=m)))))}b.err=e;b.nn=d}
2865function Q(){return{ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0}}
2866function ut(a,b){let c=Array("rgb444"===b?4096:65536),d=a.length;if("rgba4444"===b)for(b=0;b<d;++b){var e=a[b],f=e>>24&255,g=e>>16&255,h=e>>8&255;e&=255;var k=G(e,h,g,f);k=k in c?c[k]:c[k]=Q();k.rc+=e;k.gc+=h;k.bc+=g;k.ac+=f;k.cnt++}else if("rgb444"===b)for(b=0;b<d;++b)h=a[b],f=h>>16&255,g=h>>8&255,h&=255,e=j(h,g,f),e=e in c?c[e]:c[e]=Q(),e.rc+=h,e.gc+=g,e.bc+=f,e.cnt++;else for(b=0;b<d;++b)h=a[b],f=h>>16&255,g=h>>8&255,h&=255,e=D(h,g,f),e=e in c?c[e]:c[e]=Q(),e.rc+=h,e.gc+=g,e.bc+=f,e.cnt++;return c}
2867function H(a,b,c={}){let {format:d="rgb565",clearAlpha:e=!0,clearAlphaColor:f=0,clearAlphaThreshold:g=0,oneBitAlpha:h=!1}=c;if(!a||!a.buffer)throw Error("quantize() expected RGBA Uint8Array data");if(!(a instanceof Uint8Array||a instanceof Uint8ClampedArray))throw Error("quantize() expected RGBA Uint8Array data");a=new Uint32Array(a.buffer);var k=!1!==c.useSqrt;c="rgba4444"===d;a=ut(a,d);for(var l=a.length,m=l-1,n=new Uint32Array(l+1),r=0,t=0;t<l;++t){let A=a[t];if(null!=A){var u=1/A.cnt;c&&(A.ac*=
2868u);A.rc*=u;A.gc*=u;A.bc*=u;a[r++]=A}}.022>T(b)/r&&(k=!1);for(t=0;t<r-1;++t)a[t].fw=t+1,a[t+1].bk=t,k&&(a[t].cnt=Math.sqrt(a[t].cnt));k&&(a[t].cnt=Math.sqrt(a[t].cnt));var x,B;for(t=0;t<r;++t){tt(a,t,!1);k=a[t].err;for(u=++n[0];1<u&&(B=u>>1,!(a[x=n[B]].err<=k));u=B)n[u]=x;n[u]=t}b=r-b;for(t=0;t<b;){for(var y;;){r=n[1];if(y=a[r],y.tm>=y.mtm&&a[y.nn].mtm<=y.tm)break;y.mtm==m?r=n[1]=n[n[0]--]:(tt(a,r,!1),y.tm=t);k=a[r].err;for(u=1;(B=u+u)<=n[0]&&(B<n[0]&&a[n[B]].err>a[n[B+1]].err&&B++,!(k<=a[x=n[B]].err));u=
2869B)n[u]=x;n[u]=r}r=a[y.nn];k=y.cnt;l=r.cnt;u=1/(k+l);c&&(y.ac=u*(k*y.ac+l*r.ac));y.rc=u*(k*y.rc+l*r.rc);y.gc=u*(k*y.gc+l*r.gc);y.bc=u*(k*y.bc+l*r.bc);y.cnt+=r.cnt;y.mtm=++t;a[r.bk].fw=r.fw;a[r.fw].bk=r.bk;r.mtm=m}x=[];for(t=B=0;;++B){y=R(Math.round(a[t].rc),0,255);m=R(Math.round(a[t].gc),0,255);n=R(Math.round(a[t].bc),0,255);b=255;if(c){if(b=R(Math.round(a[t].ac),0,255),h)b=b<=("number"==typeof h?h:127)?0:255;e&&b<=g&&(y=m=n=f,b=0)}y=c?[y,m,n,b]:[y,m,n];if(xt(x,y)||x.push(y),0==(t=a[t].fw))break}return x}
2870function xt(a,b){for(let c=0;c<a.length;c++){let d=a[c],e=4<=d.length&&4<=b.length?d[3]===b[3]:!0;if(d[0]===b[0]&&d[1]===b[1]&&d[2]===b[2]&&e)return!0}return!1}function U(a,b){var c=0,d;for(d=0;d<a.length;d++){let e=a[d]-b[d];c+=e*e}return c}function P(a,b){return 1<b?Math.round(a/b)*b:a}
2871function et(a,{roundRGB:b=5,roundAlpha:c=10,oneBitAlpha:d=null}={}){a=new Uint32Array(a.buffer);for(let f=0;f<a.length;f++){var e=a[f];let g=e>>24&255,h=e>>16&255,k=e>>8&255;e&=255;if(g=P(g,c),d)g=g<=("number"==typeof d?d:127)?0:255;e=P(e,b);k=P(k,b);h=P(h,b);a[f]=g<<24|h<<16|k<<8|e<<0}}
2872function nt(a,b,c="rgb565"){if(!a||!a.buffer)throw Error("quantize() expected RGBA Uint8Array data");if(!(a instanceof Uint8Array||a instanceof Uint8ClampedArray))throw Error("quantize() expected RGBA Uint8Array data");
2872if(256<b.length)throw Error("applyPalette() only works with 256 colors or less");a=new Uint32Array(a.buffer);let d=a.length;var e="rgb444"===c?4096:65536;let f=new Uint8Array(d);e=Array(e);if("rgba4444"===c)for(c=0;c<d;c++){var g=a[c],h=g>>24&255,k=g>>16&255,l=g>>8&255;g&=255;var m=
2873G(g,l,k,h);h=m in e?e[m]:e[m]=gt(g,l,k,h,b);f[c]=h}else for(c="rgb444"===c?j:D,h=0;h<d;h++)g=a[h],k=g>>16&255,l=g>>8&255,g&=255,m=c(g,l,k),k=m in e?e[m]:e[m]=bt(g,l,k,b),f[h]=k;return f}function gt(a,b,c,d,e){let f=0,g=1E100;for(let h=0;h<e.length;h++){let k=e[h],l=q(k[3]-d);l>g||(l+=q(k[0]-a),l>g)||(l+=q(k[1]-b),l>g)||(l+=q(k[2]-c),!(l>g)&&(g=l,f=h))}return f}
2874function bt(a,b,c,d){let e=0,f=1E100;for(let g=0;g<d.length;g++){let h=d[g],k=q(h[0]-a);k>f||(k+=q(h[1]-b),k>f)||(k+=q(h[2]-c),!(k>f)&&(f=k,e=g))}return e}function rt(a,b,c=5){if(a.length&&b.length){var d=a.map(g=>g.slice(0,3));c*=c;var e=a[0].length;for(let g=0;g<b.length;g++){let h=b[g];h.length<e?h=[h[0],h[1],h[2],255]:h.length>e?h=h.slice(0,3):h=h.slice();var f=N(d,h.slice(0,3),U);let k=f[0];f=f[1];0<f&&f<=c&&(a[k]=h)}}}function q(a){return a*a}
2875function W(a,b,c=U){let d=Infinity,e=-1;for(let f=0;f<a.length;f++){let g=c(b,a[f]);g<d&&(d=g,e=f)}return e}function N(a,b,c=U){let d=Infinity,e=-1;for(let f=0;f<a.length;f++){let g=c(b,a[f]);g<d&&(d=g,e=f)}return[e,d]}function ot(a,b,c=U){return a[W(a,b,c)]}
2876function ct(a={}){function b(){ft(e,"GIF89a")}let {initialCapacity:c=4096,auto:d=!0}=a,e=F(c),f=new Uint8Array(256),g=new Int32Array(5003),h=new Int32Array(5003),k=!1;return{reset(){e.reset();k=!1},finish(){e.writeByte(X.trailer)},bytes(){return e.bytes()},bytesView(){return e.bytesView()},get buffer(){return e.buffer},get stream(){return e},writeHeader:b,writeFrame(l,m,n,r={}){let {transparent:t=!1,transparentIndex:u=0,delay:x=0,palette:B=null,repeat:y=0,colorDepth:A=8,dispose:aa=-1}=r,ha=!1;if(d?
2877k||(ha=!0,b(),k=!0):ha=!!r.first,m=Math.max(0,Math.floor(m)),n=Math.max(0,Math.floor(n)),ha){if(!B)throw Error("First frame must include a { palette } option");pt(e,m,n,B,A);it(e,B);0<=y&&dt(e,y)}wt(e,aa,Math.round(x/10),t,u);r=!!B&&!ha;ht(e,m,n,r?B:null);r&&it(e,B);yt(e,l,m,n,A,f,g,h)}}}function wt(a,b,c,d,e){a.writeByte(33);a.writeByte(249);a.writeByte(4);0>e&&(e=0,d=!1);var f,g;d?(f=1,g=2):(f=0,g=0);0<=b&&(g=b&7);a.writeByte(g<<2|0|f);S(a,c);a.writeByte(e||0);a.writeByte(0)}
2878function pt(a,b,c,d,e=8){d=Z(d.length)-1;e=e-1<<4|128|d;S(a,b);S(a,c);a.writeBytes([e,0,0])}function dt(a,b){a.writeByte(33);a.writeByte(255);a.writeByte(11);ft(a,"NETSCAPE2.0");a.writeByte(3);a.writeByte(1);S(a,b);a.writeByte(0)}function it(a,b){let c=1<<Z(b.length);for(let d=0;d<c;d++){let e=[0,0,0];d<b.length&&(e=b[d]);a.writeByte(e[0]);a.writeByte(e[1]);a.writeByte(e[2])}}function ht(a,b,c,d){(a.writeByte(44),S(a,0),S(a,0),S(a,b),S(a,c),d)?(b=Z(d.length)-1,a.writeByte(128|b)):a.writeByte(0)}
2879function yt(a,b,c,d,e=8,f,g,h){at(c,d,b,e,a,f,g,h)}function S(a,b){a.writeByte(b&255);a.writeByte(b>>8&255)}function ft(a,b){for(var c=0;c<b.length;c++)a.writeByte(b.charCodeAt(c))}function Z(a){return Math.max(Math.ceil(Math.log2(a)),1)}
2880var Bt=ct,__defProp=Object.defineProperty,__markAsModule=a=>__defProp(a,"__esModule",{value:!0}),__export=(a,b)=>{for(var c in b)__defProp(a,c,{get:b[c],enumerable:!0})},constants_default={signature:"GIF",version:"89a",trailer:59,extensionIntroducer:33,applicationExtensionLabel:255,graphicControlExtensionLabel:249,imageSeparator:44,signatureSize:3,versionSize:3,globalColorTableFlagMask:128,colorResolutionMask:112,sortFlagMask:8,globalColorTableSizeMask:7,applicationIdentifierSize:8,applicationAuthCodeSize:3,
2881disposalMethodMask:28,userInputFlagMask:2,transparentColorFlagMask:1,localColorTableFlagMask:128,interlaceFlagMask:64,idSortFlagMask:32,localColorTableSizeMask:7};
2882function createStream(a=256){function b(e){var f=d.length;f>=e||(e=Math.max(e,f*(1048576>f?2:1.125)>>>0),0!=f&&(e=Math.max(e,256)),f=d,d=new Uint8Array(e),0<c&&d.set(f.subarray(0,c),0))}let c=0,d=new Uint8Array(a);return{get buffer(){return d.buffer},reset(){c=0},bytesView(){return d.subarray(0,c)},bytes(){return d.slice(0,c)},writeByte(e){b(c+1);d[c]=e;c++},writeBytes(e,f=0,g=e.length){b(c+g);for(let h=0;h<g;h++)d[c++]=e[h+f]},writeBytesView(e,f=0,g=e.byteLength){b(c+g);d.set(e.subarray(f,f+g),c);
2883c+=g}}}var BITS=12,DEFAULT_HSIZE=5003,MASKS=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];
2884function lzwEncode(a,b,c,d,e=createStream(512),f=new Uint8Array(256),g=new Int32Array(DEFAULT_HSIZE),h=new Int32Array(DEFAULT_HSIZE)){function k(z){m&=MASKS[n];m=0<n?m|z<<n:z;for(n+=u;8<=n;)f[A++]=m&255,254<=A&&(e.writeByte(A),e.writeBytesView(f,0,A),A=0),m>>=8,n-=8;if(y>x||t)t?(u=r,x=(1<<u)-1,t=!1):(++u,x=u===BITS?1<<u:(1<<u)-1);if(z==B){for(;0<n;)f[A++]=m&255,254<=A&&(e.writeByte(A),e.writeBytesView(f,0,A),A=0),m>>=8,n-=8;0<A&&(e.writeByte(A),e.writeBytesView(f,0,A),A=0)}}a=g.length;var l=Math.max(2,
2885d);f.fill(0);h.fill(0);g.fill(-1);let m=0,n=0;const r=d=l+1;let t=!1,u=r,x=(1<<u)-1;d=1<<d-1;const B=d+1;let y=d+2,A=0;b=c[0];let aa=0;for(var ha=a;65536>ha;ha*=2)++aa;aa=8-aa;e.writeByte(l);k(d);l=c.length;for(ha=1;ha<l;ha++)a:{const z=c[ha],V=(z<<BITS)+b;let ba=z<<aa^b;if(g[ba]===V){b=h[ba];break a}const v=0===ba?1:a-ba;for(;0<=g[ba];)if(ba-=v,0>ba&&(ba+=a),g[ba]===V){b=h[ba];break a}k(b);b=z;y<1<<BITS?(h[ba]=y++,g[ba]=V):(g.fill(-1),y=d+2,t=!0,k(d))}k(b);k(B);e.writeByte(0);return e.bytesView()}
2886var lzwEncode_default=lzwEncode;function rgb888_to_rgb565(a,b,c){return a<<8&63488|b<<2&992|c>>3}function rgba8888_to_rgba4444(a,b,c,d){return a>>4|b&240|(c&240)<<4|(d&240)<<8}function rgb888_to_rgb444(a,b,c){return a>>4<<8|b&240|c>>4}function clamp(a,b,c){return a<b?b:a>c?c:a}function sqr(a){return a*a}
2887function find_nn(a,b,c){var d=0,e=1E100;b=a[b];const f=b.cnt,g=b.ac,h=b.rc,k=b.gc,l=b.bc;for(var m=b.fw;0!=m;m=a[m].fw){const r=a[m];var n=r.cnt;const t=f*n/(f+n);if(!(t>=e)){n=0;if(c&&(n+=t*sqr(r.ac-g),n>=e))continue;n+=t*sqr(r.rc-h);n>=e||(n+=t*sqr(r.gc-k),n>=e||(n+=t*sqr(r.bc-l),n>=e||(e=n,d=m)))}}b.err=e;b.nn=d}function create_bin(){return{ac:0,rc:0,gc:0,bc:0,cnt:0,nn:0,fw:0,bk:0,tm:0,mtm:0,err:0}}
2888function create_bin_list(a,b){const c=Array("rgb444"===b?4096:65536),d=a.length;if("rgba4444"===b)for(b=0;b<d;++b){var e=a[b],f=e>>24&255,g=e>>16&255,h=e>>8&255;e&=255;var k=rgba8888_to_rgba4444(e,h,g,f);k=k in c?c[k]:c[k]=create_bin();k.rc+=e;k.gc+=h;k.bc+=g;k.ac+=f;k.cnt++}else if("rgb444"===b)for(b=0;b<d;++b)h=a[b],f=h>>16&255,g=h>>8&255,h&=255,e=rgb888_to_rgb444(h,g,f),e=e in c?c[e]:c[e]=create_bin(),e.rc+=h,e.gc+=g,e.bc+=f,e.cnt++;else for(b=0;b<d;++b)h=a[b],f=h>>16&255,g=h>>8&255,h&=255,e=rgb888_to_rgb565(h,
2889g,f),e=e in c?c[e]:c[e]=create_bin(),e.rc+=h,e.gc+=g,e.bc+=f,e.cnt++;return c}
2890function quantize(a,b,c={}){const {format:d="rgb565",clearAlpha:e=!0,clearAlphaColor:f=0,clearAlphaThreshold:g=0,oneBitAlpha:h=!1}=c;if(!a||!a.buffer)throw Error("quantize() expected RGBA Uint8Array data");if(!(a instanceof Uint8Array||a instanceof Uint8ClampedArray))throw Error("quantize() expected RGBA Uint8Array data");a=new Uint32Array(a.buffer);var k=!1!==c.useSqrt;c="rgba4444"===d;a=create_bin_list(a,d);for(var l=a.length,m=l-1,n=new Uint32Array(l+1),r=0,t=0;t<l;++t){var u=a[t];
2890if(null!=u){var x=
28911/u.cnt;c&&(u.ac*=x);u.rc*=x;u.gc*=x;u.bc*=x;a[r++]=u}}.022>sqr(b)/r&&(k=!1);for(t=0;t<r-1;++t)a[t].fw=t+1,a[t+1].bk=t,k&&(a[t].cnt=Math.sqrt(a[t].cnt));k&&(a[t].cnt=Math.sqrt(a[t].cnt));for(t=0;t<r;++t){find_nn(a,t,!1);u=a[t].err;for(k=++n[0];1<k;k=l){l=k>>1;if(a[x=n[l]].err<=u)break;n[k]=x}n[k]=t}b=r-b;for(t=0;t<b;){for(;;){var B=n[1];r=a[B];if(r.tm>=r.mtm&&a[r.nn].mtm<=r.tm)break;r.mtm==m?B=n[1]=n[n[0]--]:(find_nn(a,B,!1),r.tm=t);u=a[B].err;for(k=1;(l=k+k)<=n[0];k=l){l<n[0]&&a[n[l]].err>a[n[l+
28921]].err&&l++;if(u<=a[x=n[l]].err)break;n[k]=x}n[k]=B}k=a[r.nn];l=r.cnt;u=k.cnt;x=1/(l+u);c&&(r.ac=x*(l*r.ac+u*k.ac));r.rc=x*(l*r.rc+u*k.rc);r.gc=x*(l*r.gc+u*k.gc);r.bc=x*(l*r.bc+u*k.bc);r.cnt+=k.cnt;r.mtm=++t;a[k.bk].fw=k.fw;a[k.fw].bk=k.bk;k.mtm=m}m=[];for(t=n=0;b=clamp(Math.round(a[t].rc),0,255),x=clamp(Math.round(a[t].gc),0,255),r=clamp(Math.round(a[t].bc),0,255),k=255,c&&(k=clamp(Math.round(a[t].ac),0,255),h&&(k=k<=("number"===typeof h?h:127)?0:255),e&&k<=g&&(b=x=r=f,k=0)),b=c?[b,x,r,k]:[b,x,
2893r],existsInPalette(m,b)||m.push(b),0!=(t=a[t].fw);++n);return m}function existsInPalette(a,b){for(let c=0;c<a.length;c++){const d=a[c];let e=4<=d.length&&4<=b.length?d[3]===b[3]:!0;if(d[0]===b[0]&&d[1]===b[1]&&d[2]===b[2]&&e)return!0}return!1}function euclideanDistanceSquared(a,b){var c=0,d;for(d=0;d<a.length;d++){const e=a[d]-b[d];c+=e*e}return c}function roundStep(a,b){return 1<b?Math.round(a/b)*b:a}
2894function prequantize(a,{roundRGB:b=5,roundAlpha:c=10,oneBitAlpha:d=null}={}){a=new Uint32Array(a.buffer);for(let f=0;f<a.length;f++){var e=a[f];let g=e>>24&255,h=e>>16&255,k=e>>8&255;e&=255;g=roundStep(g,c);d&&(g=g<=("number"===typeof d?d:127)?0:255);e=roundStep(e,b);k=roundStep(k,b);h=roundStep(h,b);a[f]=g<<24|h<<16|k<<8|e<<0}}
2895function applyPalette(a,b,c="rgb565"){if(!a||!a.buffer)throw Error("quantize() expected RGBA Uint8Array data");if(!(a instanceof Uint8Array||a instanceof Uint8ClampedArray))throw Error("quantize() expected RGBA Uint8Array data");if(256<b.length)throw Error("applyPalette() only works with 256 colors or less");a=new Uint32Array(a.buffer);const d=a.length;var e="rgb444"===c?4096:65536;const f=new Uint8Array(d);e=Array(e);if("rgba4444"===c)for(c=0;c<d;c++){var g=a[c],h=g>>24&255,k=g>>16&255,l=g>>8&255;
2896g&=255;var m=rgba8888_to_rgba4444(g,l,k,h);h=m in e?e[m]:e[m]=nearestColorIndexRGBA(g,l,k,h,b);f[c]=h}else for(c="rgb444"===c?rgb888_to_rgb444:rgb888_to_rgb565,h=0;h<d;h++)g=a[h],k=g>>16&255,l=g>>8&255,g&=255,m=c(g,l,k),k=m in e?e[m]:e[m]=nearestColorIndexRGB(g,l,k,b),f[h]=k;return f}function nearestColorIndexRGBA(a,b,c,d,e){let f=0,g=1E100;for(let h=0;h<e.length;h++){const k=e[h];let l=sqr2(k[3]-d);l>g||(l+=sqr2(k[0]-a),l>g||(l+=sqr2(k[1]-b),l>g||(l+=sqr2(k[2]-c),l>g||(g=l,f=h))))}return f}
2897function nearestColorIndexRGB(a,b,c,d){let e=0,f=1E100;for(let g=0;g<d.length;g++){const h=d[g];let k=sqr2(h[0]-a);k>f||(k+=sqr2(h[1]-b),k>f||(k+=sqr2(h[2]-c),k>f||(f=k,e=g)))}return e}
2898function snapColorsToPalette(a,b,c=5){if(a.length&&b.length){var d=a.map(g=>g.slice(0,3));c*=c;var e=a[0].length;for(let g=0;g<b.length;g++){let h=b[g];h=h.length<e?[h[0],h[1],h[2],255]:h.length>e?h.slice(0,3):h.slice();var f=nearestColorIndexWithDistance(d,h.slice(0,3),euclideanDistanceSquared);const k=f[0];f=f[1];0<f&&f<=c&&(a[k]=h)}}}function sqr2(a){return a*a}
2899function nearestColorIndex(a,b,c=euclideanDistanceSquared){let d=Infinity,e=-1;for(let f=0;f<a.length;f++){const g=c(b,a[f]);g<d&&(d=g,e=f)}return e}function nearestColorIndexWithDistance(a,b,c=euclideanDistanceSquared){let d=Infinity,e=-1;for(let f=0;f<a.length;f++){const g=c(b,a[f]);g<d&&(d=g,e=f)}return[e,d]}function nearestColor(a,b,c=euclideanDistanceSquared){return a[nearestColorIndex(a,b,c)]}
2900function GIFEncoder(a={}){function b(){writeUTFBytes(e,"GIF89a")}const {initialCapacity:c=4096,auto:d=!0}=a,e=createStream(c),f=new Uint8Array(256),g=new Int32Array(5003),h=new Int32Array(5003);let k=!1;return{reset(){e.reset();k=!1},finish(){e.writeByte(constants_default.trailer)},bytes(){return e.bytes()},bytesView(){return e.bytesView()},get buffer(){return e.buffer},get stream(){return e},writeHeader:b,writeFrame(l,m,n,r={}){const {transparent:t=!1,transparentIndex:u=0,delay:x=0,palette:B=null,
2901repeat:y=0,colorDepth:A=8,dispose:aa=-1}=r;let ha=!1;d?k||(ha=!0,b(),k=!0):ha=!!r.first;m=Math.max(0,Math.floor(m));n=Math.max(0,Math.floor(n));if(ha){if(!B)throw Error("First frame must include a { palette } option");
2901encodeLogicalScreenDescriptor(e,m,n,B,A);encodeColorTable(e,B);0<=y&&encodeNetscapeExt(e,y)}encodeGraphicControlExt(e,aa,Math.round(x/10),t,u);r=!!B&&!ha;encodeImageDescriptor(e,m,n,r?B:null);r&&encodeColorTable(e,B);encodePixels(e,l,m,n,A,f,g,h)}}}
2902function encodeGraphicControlExt(a,b,c,d,e){a.writeByte(33);a.writeByte(249);a.writeByte(4);0>e&&(e=0,d=!1);if(d){d=1;var f=2}else f=d=0;0<=b&&(f=b&7);a.writeByte(f<<2|0|d);writeUInt16(a,c);a.writeByte(e||0);a.writeByte(0)}function encodeLogicalScreenDescriptor(a,b,c,d,e=8){d=colorTableSize(d.length)-1;e=e-1<<4|128|d;writeUInt16(a,b);writeUInt16(a,c);a.writeBytes([e,0,0])}
2903function encodeNetscapeExt(a,b){a.writeByte(33);a.writeByte(255);a.writeByte(11);writeUTFBytes(a,"NETSCAPE2.0");a.writeByte(3);a.writeByte(1);writeUInt16(a,b);a.writeByte(0)}function encodeColorTable(a,b){const c=1<<colorTableSize(b.length);for(let d=0;d<c;d++){let e=[0,0,0];d<b.length&&(e=b[d]);a.writeByte(e[0]);a.writeByte(e[1]);a.writeByte(e[2])}}
2904function encodeImageDescriptor(a,b,c,d){a.writeByte(44);writeUInt16(a,0);writeUInt16(a,0);writeUInt16(a,b);writeUInt16(a,c);d?(b=colorTableSize(d.length)-1,a.writeByte(128|b)):a.writeByte(0)}function encodePixels(a,b,c,d,e=8,f,g,h){lzwEncode_default(c,d,b,e,a,f,g,h)}function writeUInt16(a,b){a.writeByte(b&255);a.writeByte(b>>8&255)}function writeUTFBytes(a,b){for(var c=0;c<b.length;c++)a.writeByte(b.charCodeAt(c))}function colorTableSize(a){return Math.max(Math.ceil(Math.log2(a)),1)}
2905function imagesToGif(a,b,c){let d=new GIFEncoder({auto:!0}),e=0,f=0;a.length&&(e=a[0].width,f=a[0].height);for(let g=c;g<a.length;g++){let h=quantize(a[g].data,256),k=applyPalette(a[g].data,h),l=b[g-c]||1E3;g||(l/=3);d.writeFrame(k,e,f,{palette:h,delay:l})}d.finish();return d.bytes()}
2906!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.QRious=b()}(this,function(){function a(z,V){var ba;return"function"==typeof Object.create?ba=Object.create(z):(d.prototype=z,ba=new d,d.prototype=null),V&&b(!0,ba,V),ba}function b(z,V,ba){for(var v,K,C=0,da=(ba=f.call(arguments,2)).length;C<da;C++)for(v in K=ba[C],K)z&&!e.call(K,v)||(V[v]=K[v])}function c(){}var d=function(){},e=Object.prototype.hasOwnProperty,f=
2907Array.prototype.slice;c.class_="Nevis";c.super_=Object;c.extend=function(z,V,ba,v){var K=this;return"string"!=typeof z&&(v=ba,ba=V,V=z,z=null),"function"!=typeof V&&(v=ba,ba=V,V=function(){return K.apply(this,arguments)}),b(!1,V,K,v),V.prototype=a(K.prototype,ba),V.prototype.constructor=V,V.class_=z||K.class_,V.super_=K,V};var g=c.extend(function(z,V,ba){this.qrious=z;this.element=V;this.element.qrious=z;this.enabled=!!ba},{draw:function(z){},getElement:function(){return this.enabled||(this.enabled=
2908!0,this.render()),this.element},getModuleSize:function(z){var V=this.qrious;return Math.max(1,Math.floor((V.size-2*(V.padding||0))/z.width))},getOffset:function(z){var V=this.qrious,ba=V.padding;if(null!=ba)return ba;ba=this.getModuleSize(z);return Math.max(0,Math.floor((V.size-ba*z.width)/2))},render:function(z){this.enabled&&(this.resize(),this.reset(),this.draw(z))},reset:function(){},resize:function(){}}),h=g.extend({draw:function(z){var V;var ba=this.qrious;var v=this.getModuleSize(z),K=this.getOffset(z),
2909C=this.element.getContext("2d");C.fillStyle=ba.foreground;C.globalAlpha=ba.foregroundAlpha;for(ba=0;ba<z.width;ba++)for(V=0;V<z.width;V++)z.buffer[V*z.width+ba]&&C.fillRect(v*ba+K,v*V+K,v,v)},reset:function(){var z=this.qrious,V=this.element.getContext("2d"),ba=z.size;V.lineWidth=1;V.clearRect(0,0,ba,ba);V.fillStyle=z.background;V.globalAlpha=z.backgroundAlpha;V.fillRect(0,0,ba,ba)},resize:function(){var z=this.element;z.width=z.height=this.qrious.size}}),k=c.extend(null,{BLOCK:[0,11,15,19,23,27,
291031,16,18,20,22,24,26,28,20,22,24,24,26,28,28,22,24,24,26,26,28,28,24,24,26,26,26,28,28,24,26,26,26,28,28]}),l=c.extend(null,{BLOCKS:[1,0,19,7,1,0,16,10,1,0,13,13,1,0,9,17,1,0,34,10,1,0,28,16,1,0,22,22,1,0,16,28,1,0,55,15,1,0,44,26,2,0,17,18,2,0,13,22,1,0,80,20,2,0,32,18,2,0,24,26,4,0,9,16,1,0,108,26,2,0,43,24,2,2,15,18,2,2,11,22,2,0,68,18,4,0,27,16,4,0,19,24,4,0,15,28,2,0,78,20,4,0,31,18,2,4,14,18,4,1,13,26,2,0,97,24,2,2,38,22,4,2,18,22,4,2,14,26,2,0,116,30,3,2,36,22,4,4,16,20,4,4,12,24,2,2,68,18,
29114,1,43,26,6,2,19,24,6,2,15,28,4,0,81,20,1,4,50,30,4,4,22,28,3,8,12,24,2,2,92,24,6,2,36,22,4,6,20,26,7,4,14,28,4,0,107,26,8,1,37,22,8,4,20,24,12,4,11,22,3,1,115,30,4,5,40,24,11,5,16,20,11,5,12,24,5,1,87,22,5,5,41,24,5,7,24,30,11,7,12,24,5,1,98,24,7,3,45,28,15,2,19,24,3,13,15,30,1,5,107,28,10,1,46,28,1,15,22,28,2,17,14,28,5,1,120,30,9,4,43,26,17,1,22,28,2,19,14,28,3,4,113,28,3,11,44,26,17,4,21,26,9,16,13,26,3,5,107,28,3,13,41,26,15,5,24,30,15,10,15,28,4,4,116,28,17,0,42,26,17,6,22,28,19,6,16,30,2,7,
2912111,28,17,0,46,28,7,16,24,30,34,0,13,24,4,5,121,30,4,14,47,28,11,14,24,3
29120,16,14,15,30,6,4,117,30,6,14,45,28,11,16,24,30,30,2,16,30,8,4,106,26,8,13,47,28,7,22,24,30,22,13,15,30,10,2,114,28,19,4,46,28,28,6,22,28,33,4,16,30,8,4,122,30,22,3,45,28,8,26,23,30,12,28,15,30,3,10,117,30,3,23,45,28,4,31,24,30,11,31,15,30,7,7,116,30,21,7,45,28,1,37,23,30,19,26,15,30,5,10,115,30,19,10,47,28,15,25,24,30,23,25,15,30,13,3,115,30,2,29,46,28,42,1,24,30,23,28,15,30,17,0,115,30,10,23,46,28,10,35,24,30,19,35,15,30,17,
29131,115,30,14,21,46,28,29,19,24,30,11,46,15,30,13,6,115,30,14,23,46,28,44,7,24,30,59,1,16,30,12,7,121,30,12,26,47,28,39,14,24,30,22,41,15,30,6,14,121,30,6,34,47,28,46,10,24,30,2,64,15,30,17,4,122,30,29,14,46,28,49,10,24,30,24,46,15,30,4,18,122,30,13,32,46,28,48,14,24,30,42,32,15,30,20,4,117,30,40,7,47,28,43,22,24,30,10,67,15,30,19,6,118,30,18,31,47,28,34,34,24,30,20,61,15,30],FINAL_FORMAT:[30660,29427,32170,30877,26159,25368,27713,26998,21522,20773,24188,23371,17913,16590,20375,19104,13663,12392,16177,
291414854,9396,8579,11994,11245,5769,5054,7399,6608,1890,597,3340,2107],LEVELS:{L:1,M:2,Q:3,H:4}}),m=c.extend(null,{EXPONENT:[1,2,4,8,16,32,64,128,29,58,116,232,205,135,19,38,76,152,45,90,180,117,234,201,143,3,6,12,24,48,96,192,157,39,78,156,37,74,148,53,106,212,181,119,238,193,159,35,70,140,5,10,20,40,80,160,93,186,105,210,185,111,222,161,95,190,97,194,153,47,94,188,101,202,137,15,30,60,120,240,253,231,211,187,107,214,177,127,254,225,223,163,91,182,113,226,217,175,67,134,17,34,68,136,13,26,52,104,208,
2915189,103,206,129,31,62,124,248,237,199,147,59,118,236,197,151,51,102,204,133,23,46,92,184,109,218,169,79,158,33,66,132,21,42,84,168,77,154,41,82,164,85,170,73,146,57,114,228,213,183,115,230,209,191,99,198,145,63,126,252,229,215,179,123,246,241,255,227,219,171,75,150,49,98,196,149,55,110,220,165,87,174,65,130,25,50,100,200,141,7,14,28,56,112,224,221,167,83,166,81,162,89,178,121,242,249,239,195,155,43,86,172,69,138,9,18,36,72,144,61,122,244,245,247,243,251,235,203,139,11,22,44,88,176,125,250,233,207,
2916131,27,54,108,216,173,71,142,0],LOG:[255,0,1,25,2,50,26,198,3,223,51,238,27,104,199,75,4,100,224,14,52,141,239,129,28,193,105,248,200,8,76,113,5,138,101,47,225,36,15,33,53,147,142,218,240,18,130,69,29,181,194,125,106,39,249,185,201,154,9,120,77,228,114,166,6,191,139,98,102,221,48,253,226,152,37,179,16,145,34,136,54,208,148,206,143,150,219,189,241,210,19,92,131,56,70,64,30,66,182,163,195,72,126,110,107,58,40,84,250,133,186,61,202,94,155,159,10,21,121,43,78,212,229,172,115,243,167,87,7,112,192,247,
2917140,128,99,13,103,74,222,237,49,197,254,24,227,165,153,119,38,184,180,124,17,68,146,217,35,32,137,46,55,63,209,91,149,188,207,205,144,135,151,178,220,252,190,97,242,86,211,171,20,42,93,158,132,60,57,83,71,109,65,162,31,45,67,216,183,123,164,118,196,23,73,236,127,12,111,246,108,161,59,82,41,157,85,170,251,96,134,177,187,204,62,90,203,89,95,176,156,169,160,81,11,245,22,235,122,117,44,215,79,174,213,233,230,231,173,232,116,214,244,234,168,80,88,175]}),n=c.extend(null,{BLOCK:[3220,1468,2713,1235,3062,
29181890,2119,1549,2344,2936,1117,2583,1330,2470,1667,2249,2028,3780,481,4011,142,3098,831,3445,592,2517,1776,2234,1951,2827,1070,2660,1345,3177]}),r=c.extend(function(z){var V,ba,v,K,C,da=z.value.length;this._badness=[];this._level=l.LEVELS[z.level];this._polynomial=[];this._value=z.value;this._version=0;for(this._stringBuffer=[];40>this._version&&(this._version++,v=4*(this._level-1)+16*(this._version-1),K=l.BLOCKS[v++],C=l.BLOCKS[v++],V=l.BLOCKS[v++],ba=l.BLOCKS[v],v=V*(K+C)+C-3+(9>=this._version),
2919!(da<=v)););this._dataBlock=V;this._eccBlock=ba;this._neccBlock1=K;this._neccBlock2=C;z=this.width=17+4*this._version;this.buffer=r._createArray(z*z);this._ecc=r._createArray(V+(V+ba)*(K+C)+C);this._mask=r._createArray((z*(z+1)+1)/2);this._insertFinders();this._insertAlignments();this.buffer[8+z*(z-8)]=1;this._insertTimingGap();this._reverseMask();this._insertTimingRowAndColumn();this._insertVersion();this._syncMask();this._convertBitStream(da);this._calculatePolynomial();this._appendEccToData();
2920this._interleaveBlocks();this._pack();this._finish()},{_addAlignment:function(z,V){var ba,v=this.buffer,K=this.width;v[z+K*V]=1;for(ba=-2;2>ba;ba++)v[z+ba+K*(V-2)]=1,v[z-2+K*(V+ba+1)]=1,v[z+2+K*(V+ba)]=1,v[z+ba+1+K*(V+2)]=1;for(ba=0;2>ba;ba++)this._setMask(z-1,V+ba),this._setMask(z+1,V-ba),this._setMask(z-ba,V-1),this._setMask(z+ba,V+1)},_appendData:function(z,V,ba,v){var K,C,da,ja=this._polynomial,ea=this._stringBuffer;for(C=0;C<v;C++)ea[ba+C]=0;for(C=0;C<V;C++){if(255!==(K=m.LOG[ea[z+C]^ea[ba]]))for(da=
29211;da<v;
2921da++)ea[ba+da-1]=ea[ba+da]^m.EXPONENT[r._modN(K+ja[v-da])];else for(da=ba;da<ba+v;da++)ea[da]=ea[da+1];ea[ba+v-1]=255===K?0:m.EXPONENT[r._modN(K+ja[0])]}},_appendEccToData:function(){var z,V=0,ba=this._dataBlock,v=this._calculateMaxLength(),K=this._eccBlock;for(z=0;z<this._neccBlock1;z++)this._appendData(V,ba,v,K),V+=ba,v+=K;for(z=0;z<this._neccBlock2;z++)this._appendData(V,ba+1,v,K),V+=ba+1,v+=K},_applyMask:function(z){var V,ba,v,K=this.buffer,C=this.width;switch(z){case 0:for(v=0;v<C;v++)for(ba=
29220;ba<C;ba++)ba+v&1||this._isMasked(ba,v)||(K[ba+v*C]^=1);break;case 1:for(v=0;v<C;v++)for(ba=0;ba<C;ba++)1&v||this._isMasked(ba,v)||(K[ba+v*C]^=1);break;case 2:for(v=0;v<C;v++)for(ba=z=0;ba<C;ba++,z++)3===z&&(z=0),z||this._isMasked(ba,v)||(K[ba+v*C]^=1);break;case 3:for(v=V=0;v<C;v++,V++)for(3===V&&(V=0),z=V,ba=0;ba<C;ba++,z++)3===z&&(z=0),z||this._isMasked(ba,v)||(K[ba+v*C]^=1);break;case 4:for(v=0;v<C;v++)for(z=0,V=v>>1&1,ba=0;ba<C;ba++,z++)3===z&&(z=0,V=!V),V||this._isMasked(ba,v)||(K[ba+v*C]^=
29231);break;case 5:for(v=V=0;v<C;v++,V++)for(3===V&&(V=0),ba=z=0;ba<C;ba++,z++)3===z&&(z=0),(ba&v&1)+!(!z|!V)||this._isMasked(ba,v)||(K[ba+v*C]^=1);break;case 6:for(v=V=0;v<C;v++,V++)for(3===V&&(V=0),ba=z=0;ba<C;ba++,z++)3===z&&(z=0),(ba&v&1)+(z&&z===V)&1||this._isMasked(ba,v)||(K[ba+v*C]^=1);break;case 7:for(v=V=0;v<C;v++,V++)for(3===V&&(V=0),ba=z=0;ba<C;ba++,z++)3===z&&(z=0),(z&&z===V)+(ba+v&1)&1||this._isMasked(ba,v)||(K[ba+v*C]^=1)}},_calculateMaxLength:function(){return this._dataBlock*(this._neccBlock1+
2924this._neccBlock2)+this._neccBlock2},_calculatePolynomial:function(){var z,V,ba=this._eccBlock,v=this._polynomial;v[0]=1;for(z=0;z<ba;z++){v[z+1]=1;for(V=z;0<V;V--)v[V]=v[V]?v[V-1]^m.EXPONENT[r._modN(m.LOG[v[V]]+z)]:v[V-1];v[0]=m.EXPONENT[r._modN(m.LOG[v[0]]+z)]}for(z=0;z<=ba;z++)v[z]=m.LOG[v[z]]},_checkBadness:function(){var z,V,ba,v=0,K=this._badness,C=this.buffer,da=this.width;for(ba=0;ba<da-1;ba++)for(V=0;V<da-1;V++)(C[V+da*ba]&&C[V+1+da*ba]&&C[V+da*(ba+1)]&&C[V+1+da*(ba+1)]||!(C[V+da*ba]||C[V+
29251+da*ba]||C[V+da*(ba+1)]||C[V+1+da*(ba+1)]))&&(v+=r.N2);var ja=0;for(ba=0;ba<da;ba++){var ea=0;for(V=z=K[0]=0;V<da;V++)z===(z=C[V+da*ba])?K[ea]++:K[++ea]=1,ja+=z?1:-1;v+=this._getBadness(ea)}0>ja&&(ja=-ja);ea=0;for(ja=ja+(ja<<2)<<1;ja>da*da;)ja-=da*da,ea++;v+=ea*r.N4;for(V=0;V<da;V++){ea=0;for(ba=z=K[0]=0;ba<da;ba++)z===(z=C[V+da*ba])?K[ea]++:K[++ea]=1;v+=this._getBadness(ea)}return v},_convertBitStream:function(z){var V,ba=this._ecc,v=this._version;for(V=0;V<z;V++)ba[V]=this._value.charCodeAt(V);
2926ba=this._stringBuffer=ba.slice();var K=this._calculateMaxLength();z>=K-2&&(z=K-2,9<v&&z--);var C=z;if(9<v){ba[C+2]=0;for(ba[C+3]=0;C--;)V=ba[C],ba[C+3]|=255&V<<4,ba[C+2]=V>>4;ba[2]|=255&z<<4;ba[1]=z>>4;ba[0]=64|z>>12}else{ba[C+1]=0;for(ba[C+2]=0;C--;)V=ba[C],ba[C+2]|=255&V<<4,ba[C+1]=V>>4;ba[1]|=255&z<<4;ba[0]=64|z>>4}for(C=z+3-(10>v);C<K;)ba[C++]=236,ba[C++]=17},_getBadness:function(z){var V,ba=0,v=this._badness;for(V=0;V<=z;V++)5<=v[V]&&(ba+=r.N1+v[V]-5);for(V=3;V<z-1;V+=2)v[V-2]===v[V+2]&&v[V+
29272]===v[V-1]&&v[V-1]===v[V+1]&&3*v[V-1]===v[V]&&(0===v[V-3]||V+3>z||3*v[V-3]>=4*v[V]||3*v[V+3]>=4*v[V])&&(ba+=r.N3);return ba},_finish:function(){this._stringBuffer=this.buffer.slice();var z,V,ba=0,v=3E4;for(V=0;8>V&&(this._applyMask(V),(z=this._checkBadness())<v&&(v=z,ba=V),7!==ba);V++)this.buffer=this._stringBuffer.slice();ba!==V&&this._applyMask(ba);v=l.FINAL_FORMAT[ba+(this._level-1<<3)];z=this.buffer;ba=this.width;for(V=0;8>V;V++,v>>=1)1&v&&(z[ba-1-V+8*ba]=1,6>V?z[8+ba*V]=1:z[8+ba*(V+1)]=1);for(V=
29280;7>V;V++,v>>=1)1&v&&(z[8+ba*(ba-7+V)]=1,V?z[6-V+8*ba]=1:z[7+8*ba]=1)},_interleaveBlocks:function(){var z,V,ba=this._dataBlock,v=this._ecc,K=this._eccBlock,C=0,da=this._calculateMaxLength(),ja=this._neccBlock1,ea=this._neccBlock2,ra=this._stringBuffer;for(z=0;z<ba;z++){for(V=0;V<ja;V++)v[C++]=ra[z+V*ba];for(V=0;V<ea;V++)v[C++]=ra[ja*ba+z+V*(ba+1)]}for(V=0;V<ea;V++)v[C++]=ra[ja*ba+z+V*(ba+1)];for(z=0;z<K;z++)for(V=0;V<ja+ea;V++)v[C++]=ra[da+z+V*K];this._stringBuffer=v},_insertAlignments:function(){var z,
2929V;var ba=this._version;var v=this.width;if(1<ba)for(ba=k.BLOCK[ba],V=v-7;;){for(z=v-7;z>ba-3&&(this._addAlignment(z,V),!(z<ba));)z-=ba;if(V<=ba+9)break;V-=ba;this._addAlignment(6,V);this._addAlignment(V,6)}},_insertFinders:function(){var z,V,ba,v=this.buffer,K=this.width;for(z=0;3>z;z++){var C=V=0;1===z&&(V=K-7);2===z&&(C=K-7);v[C+3+K*(V+3)]=1;for(ba=0;6>ba;ba++)v[C+ba+K*V]=1,v[C+K*(V+ba+1)]=1,v[C+6+K*(V+ba)]=1,v[C+ba+1+K*(V+6)]=1;for(ba=1;5>ba;ba++)this._setMask(C+ba,V+1),this._setMask(C+1,V+ba+
29301),this._setMask(C+5,V+ba),this._setMask(C+ba+1,V+5);for(ba=2;4>ba;ba++)v[C+ba+K*(V+2)]=1,v[C+2+K*(V+ba+1)]=1,v[C+4+K*(V+ba)]=1,v[C+ba+1+K*(V+4)]=1}},_insertTimingGap:function(){var z,V=this.width;for(z=0;7>z;z++)this._setMask(7,z),this._setMask(V-8,z),this._setMask(7,z+V-7);for(z=0;8>z;z++)this._setMask(z,7),this._setMask(z+V-8,7),this._setMask(z,V-8)},_insertTimingRowAndColumn:function(){var z,V=this.buffer,ba=this.width;for(z=0;z<ba-14;z++)1&z?(this._setMask(8+z,6),this._setMask(6,8+z)):(V[8+z+
29316*ba]=1,V[6+ba*(8+z)]=1)},_insertVersion:function(){var z,V,ba=this.buffer,v=this._version,K=this.width;
2931if(6<v){var C=n.BLOCK[v-7];var da=17;for(z=0;6>z;z++)for(V=0;3>V;V++,da--)1&(11<da?v>>da-12:C>>da)?(ba[5-z+K*(2-V+K-11)]=1,ba[2-V+K-11+K*(5-z)]=1):(this._setMask(5-z,2-V+K-11),this._setMask(2-V+K-11,5-z))}},_isMasked:function(z,V){z=r._getMaskBit(z,V);return 1===this._mask[z]},_pack:function(){var z,V,ba=1,v=1,K=this.width,C=K-1,da=K-1,ja=(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+
2932this._neccBlock2;for(z=0;z<ja;z++){var ea=this._stringBuffer[z];for(V=0;8>V;V++,ea<<=1){128&ea&&(this.buffer[C+K*da]=1);do v?C--:(C++,ba?0!==da?da--:(ba=!ba,6===(C-=2)&&(C--,da=9)):da!==K-1?da++:(ba=!ba,6===(C-=2)&&(C--,da-=8))),v=!v;while(this._isMasked(C,da))}}},_reverseMask:function(){var z,V=this.width;for(z=0;9>z;z++)this._setMask(z,8);for(z=0;8>z;z++)this._setMask(z+V-8,8),this._setMask(8,z);for(z=0;7>z;z++)this._setMask(8,z+V-7)},_setMask:function(z,V){z=r._getMaskBit(z,V);this._mask[z]=1},
2933_syncMask:function(){var z,V,ba=this.width;for(V=0;V<ba;V++)for(z=0;z<=V;z++)this.buffer[z+ba*V]&&this._setMask(z,V)}},{_createArray:function(z){var V,ba=[];for(V=0;V<z;V++)ba[V]=0;return ba},_getMaskBit:function(z,V){var ba;return z>V&&(ba=z,z=V,V=ba),ba=V,ba+=V*V,ba>>=1,ba+z},_modN:function(z){for(;255<=z;)z=((z-=255)>>8)+(255&z);return z},N1:3,N2:3,N3:40,N4:10}),t=r,u=g.extend({draw:function(){this.element.src=this.qrious.toDataURL()},reset:function(){this.element.src=""},resize:function(){var z=
2934this.element;z.width=z.height=this.qrious.size}});g=c.extend(function(z,V,ba,v){this.name=z;this.modifiable=!!V;this.defaultValue=ba;this._valueTransformer=v},{transform:function(z){var V=this._valueTransformer;return"function"==typeof V?V(z,this):z}});var x=c.extend(null,{abs:function(z){return null!=z?Math.abs(z):null},hasOwn:function(z,V){return Object.prototype.hasOwnProperty.call(z,V)},noop:function(){},toUpperCase:function(z){return null!=z?z.toUpperCase():null}}),B=c.extend(function(z){this.options=
2935{};z.forEach(function(V){this.options[V.name]=V},this)},{exists:function(z){return null!=this.options[z]},get:function(z,V){return B._get(this.options[z],V)},getAll:function(z){var V,ba=this.options,v={};for(V in ba)x.hasOwn(ba,V)&&(v[V]=B._get(ba[V],z));return v},init:function(z,V,ba){"function"!=typeof ba&&(ba=x.noop);var v,K;for(v in this.options)x.hasOwn(this.options,v)&&(K=this.options[v],B._set(K,K.defaultValue,V),B._createAccessor(K,V,ba));this._setAll(z,V,!0)},set:function(z,V,ba){return this._set(z,
2936V,ba)},setAll:function(z,V){return this._setAll(z,V)},_set:function(z,V,ba,v){var K=this.options[z];if(!K)throw Error("Invalid option: "+z);if(!K.modifiable&&!v)throw Error("Option cannot be modified: "+z);return B._set(K,V,ba)},_setAll:function(z,V,ba){if(!z)return!1;var v,K=!1;for(v in z)x.hasOwn(z,v)&&this._set(v,z[v],V,ba)&&(K=!0);return K}},{_createAccessor:function(z,V,ba){var v={get:function(){return B._get(z,V)}};z.modifiable&&(v.set=function(K){B._set(z,K,V)&&ba(K,z)});Object.defineProperty(V,
2937z.name,v)},_get:function(z,V){return V["_"+z.name]},_set:function(z,V,ba){var v="_"+z.name,K=ba[v];z=z.transform(null!=V?V:z.defaultValue);return ba[v]=z,z!==K}}),y=B,A=c.extend(function(){this._services={}},{getService:function(z){var V=this._services[z];if(!V)throw Error("Service is not being managed with name: "+z);return V},setService:function(z,V){if(this._services[z])throw Error("Service is already managed with name: "+z);V&&(this._services[z]=V)}}),aa=new y([new g("background",!0,"white"),
2938new g("backgroundAlpha",!0,1,x.abs),new g("element"),new g("foreground",!0,"black"),new g("foregroundAlpha",!0,1,x.abs),new g("level",!0,"L",x.toUpperCase),new g("mime",!0,"image/png"),new g("padding",!0,null,x.abs),new g("size",!0,100,x.abs),new g("value",!0,"")]),ha=new A;g=c.extend(function(z){aa.init(z,this,this.update.bind(this));z=aa.get("element",this);var V=ha.getService("element"),ba=z&&V.isCanvas(z)?z:V.createCanvas();V=z&&V.isImage(z)?z:V.createImage();this._canvasRenderer=new h(this,ba,
2939!0);this._imageRenderer=new u(this,V,V===z);this.update()},{get:function(){return aa.getAll(this)},set:function(z){aa.setAll(z,this)&&this.update()},toDataURL:function(z){return this.canvas.toDataURL(z||this.mime)},update:function(){var z=new t({level:this.level,value:this.value});this._canvasRenderer.render(z);this._imageRenderer.render(z)}},{use:function(z){ha.setService(z.getName(),z)}});Object.defineProperties(g.prototype,{canvas:{get:function(){return this._canvasRenderer.getElement()}},image:{get:function(){return this._imageRenderer.getElement()}}});
2940y=c.extend({getName:function(){}}).extend({createCanvas:function(){},createImage:function(){},getName:function(){return"element"},isCanvas:function(z){},isImage:function(z){}}).extend({createCanvas:function(){return document.createElement("canvas")},createImage:function(){return document.createElement("img")},isCanvas:function(z){return z instanceof HTMLCanvasElement},isImage:function(z){return z instanceof HTMLImageElement}});return g.use(new y),g});var UZIP={};
2941"object"==typeof module&&(module.exports=UZIP);UZIP.parse=function(a,b){var c=UZIP.bin.readUshort,d=UZIP.bin.readUint,e,f={};a=new Uint8Array(a);for(e=a.length-4;101010256!=d(a,e);)e--;e=e+4+4;var g=c(a,e);e+=2;c(a,e);e+=2;d(a,e);e+=4;e=d(a,e);for(var h=0;h<g;h++){d(a,e);e+=4;e+=4;e+=4;e+=4;d(a,e);e+=4;var k=d(a,e);e+=4;var l=d(a,e);e+=4;var m=c(a,e),n=c(a,e+2),r=c(a,e+4);e+=6;e+=8;var t=d(a,e);e+=4;e+=m+n+r;UZIP._readLocal(a,t,f,k,l,b)}return f};
2942UZIP._readLocal=function(a,b,c,d,e,f){var g=UZIP.bin.readUshort,h=UZIP.bin.readUint;h(a,b);b+=4;g(a,b);b+=2;g(a,b);b+=2;var k=g(a,b);b+=2;h(a,b);b+=4;h(a,b);b=b+4+8;h=g(a,b);b+=2;var l=g(a,b);b+=2;g=UZIP.bin.readUTF8(a,b,h);b=b+h+l;if(f)c[g]={size:e,csize:d};else if(a=new Uint8Array(a.buffer,b),0==k)c[g]=new Uint8Array(a.buffer.slice(b,b+d));else if(8==k)b=new Uint8Array(e),UZIP.inflateRaw(a,b),c[g]=b;else throw"unknown compression method: "+k;};
2943UZIP.inflateRaw=function(a,b){return UZIP.F.inflate(a,b)};UZIP.inflate=function(a,b){return UZIP.inflateRaw(new Uint8Array(a.buffer,a.byteOffset+2,a.length-6),b)};UZIP.deflate=function(a,b){null==b&&(b={level:6});var c=0,d=new Uint8Array(50+Math.floor(1.1*a.length));d[c]=120;d[c+1]=156;
2943c=UZIP.F.deflateRaw(a,d,c+2,b.level);a=UZIP.adler(a,0,a.length);d[c+0]=a>>>24&255;d[c+1]=a>>>16&255;d[c+2]=a>>>8&255;d[c+3]=a>>>0&255;return new Uint8Array(d.buffer,0,c+4)};
2944UZIP.deflateRaw=function(a,b){null==b&&(b={level:6});var c=new Uint8Array(50+Math.floor(1.1*a.length)),d=UZIP.F.deflateRaw(a,c,d,b.level);return new Uint8Array(c.buffer,0,d)};
2945UZIP.encode=function(a,b){null==b&&(b=!1);var c=0,d=UZIP.bin.writeUint,e=UZIP.bin.writeUshort,f={},g;for(g in a){var h=!UZIP._noNeed(g)&&!b,k=a[g],l=UZIP.crc.crc(k,0,k.length);f[g]={cpr:h,usize:k.length,crc:l,file:h?UZIP.deflateRaw(k):k}}for(g in f)c+=f[g].file.length+30+46+2*UZIP.bin.sizeUTF8(g);a=new Uint8Array(c+22);b=0;k=[];for(g in f)l=f[g],k.push(b),b=UZIP._writeHeader(a,b,g,l,0);c=0;h=b;for(g in f)l=f[g],k.push(b),b=UZIP._writeHeader(a,b,g,l,1,k[c++]);f=b-h;d(a,b,101010256);b=b+4+4;e(a,b,c);
2946b+=2;e(a,b,c);b+=2;d(a,b,f);d(a,b+4,h);return a.buffer};UZIP._noNeed=function(a){a=a.split(".").pop().toLowerCase();return-1!="png,jpg,jpeg,zip".indexOf(a)};
2947UZIP._writeHeader=function(a,b,c,d,e,f){var g=UZIP.bin.writeUint,h=UZIP.bin.writeUshort,k=d.file;g(a,b,0==e?67324752:33639248);b+=4;1==e&&(b+=2);h(a,b,20);b+=2;h(a,b,0);b+=2;h(a,b,d.cpr?8:0);b+=2;g(a,b,0);b+=4;g(a,b,d.crc);b+=4;g(a,b,k.length);b+=4;g(a,b,d.usize);b+=4;h(a,b,UZIP.bin.sizeUTF8(c));b+=2;h(a,b,0);b+=2;1==e&&(b=b+2+2+6,g(a,b,f),b+=4);c=UZIP.bin.writeUTF8(a,b,c);b+=c;0==e&&(a.set(k,b),b+=k.length);return b};
2948UZIP.crc={table:function(){for(var a=new Uint32Array(256),b=0;256>b;b++){for(var c=b,d=0;8>d;d++)c=c&1?3988292384^c>>>1:c>>>1;a[b]=c}return a}(),update:function(a,b,c,d){for(var e=0;e<d;e++)a=UZIP.crc.table[(a^b[c+e])&255]^a>>>8;return a},crc:function(a,b,c){return UZIP.crc.update(4294967295,a,b,c)^4294967295}};UZIP.adler=function(a,b,c){var d=1,e=0,f=b;for(b+=c;f<b;){for(c=Math.min(f+5552,b);f<c;)d+=a[f++],e+=d;d%=65521;e%=65521}return e<<16|d};
2949UZIP.bin={readUshort:function(a,b){return a[b]|a[b+1]<<8},writeUshort:function(a,b,c){a[b]=c&255;a[b+1]=c>>8&255},readUint:function(a,b){return 16777216*a[b+3]+(a[b+2]<<16|a[b+1]<<8|a[b])},writeUint:function(a,b,c){a[b]=c&255;a[b+1]=c>>8&255;a[b+2]=c>>16&255;a[b+3]=c>>24&255},readASCII:function(a,b,c){for(var d="",e=0;e<c;e++)d+=String.fromCharCode(a[b+e]);return d},writeASCII:function(a,b,c){for(var d=0;d<c.length;d++)a[b+d]=c.charCodeAt(d)},pad:function(a){return 2>a.length?"0"+a:a},readUTF8:function(a,
2950b,c){for(var d="",e,f=0;f<c;f++)d+="%"+UZIP.bin.pad(a[b+f].toString(16));try{e=decodeURIComponent(d)}catch(g){return UZIP.bin.readASCII(a,b,c)}return e},writeUTF8:function(a,b,c){for(var d=c.length,e=0,f=0;f<d;f++){var g=c.charCodeAt(f);if(0==(g&4294967168))a[b+e]=g,e++;else if(0==(g&4294965248))a[b+e]=192|g>>6,a[b+e+1]=128|g>>0&63,e+=2;else if(0==(g&4294901760))a[b+e]=224|g>>12,a[b+e+1]=128|g>>6&63,a[b+e+2]=128|g>>0&63,e+=3;else if(0==(g&4292870144))a[b+e]=240|g>>18,a[b+e+1]=128|g>>12&63,a[b+e+2]=
2951128|g>>6&63,a[b+e+3]=128|g>>0&63,e+=4;else throw"e";}return e},sizeUTF8:function(a){for(var b=a.length,c=0,d=0;d<b;d++){var e=a.charCodeAt(d);if(0==(e&4294967168))c++;else if(0==(e&4294965248))c+=2;else if(0==(e&4294901760))c+=3;else if(0==(e&4292870144))c+=4;else throw"e";}return c}};UZIP.F={};
2952UZIP.F.deflateRaw=function(a,b,c,d){var e=[[0,0,0,0,0],[4,4,8,4,0],[4,5,16,8,0],[4,6,16,16,0],[4,10,16,32,0],[8,16,32,32,0],[8,16,128,128,0],[8,32,128,256,0],[32,128,258,1024,1],[32,258,258,4096,1]][d],f=UZIP.F.U,g=UZIP.F._goodIndex,h=UZIP.F._putsE,k=0;c<<=3;var l=0,m=a.length;if(0==d){for(;k<m;){var n=Math.min(65535,m-k);h(b,c,k+n==m?1:0);c=UZIP.F._copyExact(a,k,n,b,c+8);k+=n}return c>>>3}h=f.lits;d=f.strt;var r=f.prev,t=0,u=0,x=0,B=0,y=0;2<m&&(y=UZIP.F._hash(a,0),d[y]=0);for(k=0;k<m;k++){n=y;if(k+
29531<m-2){y=UZIP.F._hash(a,k+1);var A=k+1&32767;r[A]=d[y];d[y]=A}if(l<=k){(14E3<t||26697<u)&&100<m-k&&(l<k&&(h[t]=k-l,t+=2,l=k),c=UZIP.F._writeBlock(k==m-1||l==m?1:0,h,t,B,a,x,k-x,b,c),t=u=B=0,x=k);A=0;k<m-2&&(A=UZIP.F._bestMatch(a,k,r,n,Math.min(e[2],m-k),e[3]));if(0!=A){n=A>>>16;A&=65535;var aa=g(n,f.of0);f.lhst[257+aa]++;var ha=g(A,f.df0);f.dhst[ha]++;B+=f.exb[aa]+f.dxb[ha];h[t]=n<<23|k-l;h[t+1]=A<<16|aa<<8|ha;t+=2;l=k+n}else f.lhst[a[k]]++;u++}}if(x!=k||0==a.length)l<k&&(h[t]=k-l,t+=2),c=UZIP.F._writeBlock(1,
2954h,t,B,a,x,k-x,b,c);for(;0!=(c&7);)c++;return c>>>3};UZIP.F._bestMatch=function(a,b,c,d,e,f){var g=b&32767,h=c[g],k=g-h+32768&32767;if(h==g||d!=UZIP.F._hash(a,b-k))return 0;for(var l=d=0,m=Math.min(32767,b);k<=m&&0!=--f&&h!=g;){if(0==d||a[b+d]==a[b+d-k])if(g=UZIP.F._howLong(a,b,k),g>d){d=g;l=k;if(d>=e)break;k+2<g&&(g=k+2);for(var n=0,r=0;r<g-2;r++){var t=b-k+r+32768&32767,u=t-c[t]+32768&32767;u>n&&(n=u,h=t)}}g=h;h=c[g];k+=g-h+32768&32767}return d<<16|l};
2955UZIP.F._howLong=function(a,b,c){if(a[b]!=a[b-c]||a[b+1]!=a[b+1-c]||a[b+2]!=a[b+2-c])return 0;var d=b,e=Math.min(a.length,b+258);for(b+=3;b<e&&a[b]==a[b-c];)b++;return b-d};UZIP.F._hash=function(a,b){return(a[b]<<8|a[b+1])+(a[b+2]<<4)&65535};UZIP.saved=0;
2956UZIP.F._writeBlock=function(a,b,c,d,e,f,g,h,k){var l=UZIP.F.U,m=UZIP.F._putsF,n=UZIP.F._putsE;l.lhst[256]++;var r=UZIP.F.getTrees();var t=r[0];var u=r[1];var x=r[2];var B=r[3];var y=r[4];var A=r[5];var aa=r[6];r=r[7];var ha=(0==(k+3&7)?0:8-(k+3&7))+32+(g<<3),z=d+UZIP.F.contSize(l.fltree,l.lhst)+UZIP.F.contSize(l.fdtree,l.dhst);d=d+UZIP.F.contSize(l.ltree,l.lhst)+UZIP.F.contSize(l.dtree,l.dhst);d+=14+3*A+UZIP.F.contSize(l.itree,l.ihst)+(2*l.ihst[16]+3*l.ihst[17]+7*l.ihst[18]);for(var V=0;286>V;V++)l.lhst[V]=
29570;for(V=0;30>V;V++)l.dhst[V]=0;for(V=0;19>V;V++)l.ihst[V]=0;ha=ha<z&&ha<d?0:z<d?1:2;m(h,k,a);m(h,k+1,ha);k+=3;if(0==ha){for(;0!=(k&7);)k++;k=UZIP.F._copyExact(e,f,g,h,k)}else{if(1==ha){var ba=l.fltree;var v=l.fdtree}if(2==ha){UZIP.F.makeCodes(l.ltree,t);UZIP.F.revCodes(l.ltree,t);UZIP.F.makeCodes(l.dtree,u);UZIP.F.revCodes(l.dtree,u);UZIP.F.makeCodes(l.itree,x);UZIP.F.revCodes(l.itree,x);ba=l.ltree;v=l.dtree;n(h,k,B-257);k+=5;n(h,k,y-1);k+=5;n(h,k,A-4);k+=4;for(a=0;a<A;a++)n(h,k+3*a,l.itree[(l.ordr[a]<<
29581)+1]);k=UZIP.F._codeTiny(aa,l.itree,h,k+3*A);k=UZIP.F._codeTiny(r,l.itree,h,k)}for(A=0;A<c;A+=2){a=b[A];aa=a>>>23;for(a=f+(a&8388607);f<a;)k=UZIP.F._writeLit(e[f++],ba,h,k);0!=aa&&(t=b[A+1],a=t>>16,g=t>>8&255,t&=255,k=UZIP.F._writeLit(257+g,ba,h,k),n(h,k,aa-l.of0[g]),k+=l.exb[g],k=UZIP.F._writeLit(t,v,h,k),m(h,k,a-l.df0[t]),k+=l.dxb[t],f+=aa)}k=UZIP.F._writeLit(256,ba,h,k)}return k};
2959UZIP.F._copyExact=function(a,b,c,d,e){var f=e>>>3;d[f]=c;d[f+1]=c>>>8;d[f+2]=255-d[f];d[f+3]=255-d[f+1];f+=4;d.set(new Uint8Array(a.buffer,b,c),f);return e+(c+4<<3)};
2960UZIP.F.getTrees=function(){for(var a=UZIP.F.U,b=UZIP.F._hufTree(a.lhst,a.ltree,15),c=UZIP.F._hufTree(a.dhst,a.dtree,15),d=[],e=UZIP.F._lenCodes(a.ltree,d),f=[],g=UZIP.F._lenCodes(a.dtree,f),h=0;h<d.length;h+=2)a.ihst[d[h]]++;for(h=0;h<f.length;h+=2)a.ihst[f[h]]++;h=UZIP.F._hufTree(a.ihst,a.itree,7);for(var k=19;4<k&&0==a.itree[(a.ordr[k-1]<<1)+1];)k--;return[b,c,h,e,g,k,d,f]};UZIP.F.getSecond=function(a){for(var b=[],c=0;c<a.length;c+=2)b.push(a[c+1]);return b};
2961UZIP.F.nonZero=function(a){for(var b="",c=0;c<a.length;c+=2)0!=a[c+1]&&(b+=(c>>1)+",");return b};UZIP.F.contSize=function(a,b){for(var c=0,d=0;d<b.length;d++)c+=b[d]*a[(d<<1)+1];return c};UZIP.F._codeTiny=function(a,b,c,d){for(var e=0;e<a.length;e+=2){var f=a[e],g=a[e+1];d=UZIP.F._writeLit(f,b,c,d);var h=16==f?2:17==f?3:7;15<f&&(UZIP.F._putsE(c,d,g,h),d+=h)}return d};
2962UZIP.F._lenCodes=function(a,b){for(var c=a.length;2!=c&&0==a[c-1];)c-=2;for(var d=0;d<c;d+=2){var e=a[d+1],f=d+3<c?a[d+3]:-1,g=d+5<c?a[d+5]:-1,h=0==d?-1:a[d-1];if(0==e&&f==e&&g==e){for(f=d+5;f+2<c&&a[f+2]==e;)f+=2;e=Math.min(f+1-d>>>1,138);11>e?b.push(17,e-3):b.push(18,e-11);d+=2*e-2}else if(e==h&&f==e&&g==e){for(f=d+5;f+2<c&&a[f+2]==e;)f+=2;e=Math.min(f+1-d>>>1,6);b.push(16,e-3);d+=2*e-2}else b.push(e,0)}return c>>>1};
2963UZIP.F._hufTree=function(a,b,c){var d=[],e=a.length,f=b.length,g=0;for(g=0;g<f;g+=2)b[g]=0,b[g+1]=0;for(g=0;g<e;g++)0!=a[g]&&d.push({lit:g,f:a[g]});a=d.length;e=d.slice(0);if(0==a)return 0;if(1==a)return c=d[0].lit,b[(c<<1)+1]=1,b[((0==c?1:0)<<1)+1]=1;d.sort(function(m,n){return m.f-n.f});g=d[0];f=d[1];var h=0,k=1,l=2;for(d[0]={lit:-1,f:g.f+f.f,l:g,r:f,d:0};k!=a-1;)g=h!=k&&(l==a||d[h].f<d[l].f)?d[h++]:d[l++],f=h!=k&&(l==a||d[h].f<d[l].f)?d[h++]:d[l++],d[k++]={lit:-1,f:g.f+f.f,l:g,r:f};d=UZIP.F.setDepth(d[k-
29641],0);d>c&&(UZIP.F.restrictDepth(e,c,d),d=c);for(g=0;g<a;g++)b[(e[g].lit<<1)+1]=e[g].d;return d};UZIP.F.setDepth=function(a,b){return-1!=a.lit?a.d=b:Math.max(UZIP.F.setDepth(a.l,b+1),UZIP.F.setDepth(a.r,b+1))};
2965UZIP.F.restrictDepth=function(a,b,c){var d=0,e=1<<c-b,f=0;a.sort(function(h,k){return k.d==h.d?h.f-k.f:k.d-h.d});for(d=0;d<a.length;d++)if(a[d].d>b){var g=a[d].d;a[d].d=b;f+=e-(1<<c-g)}else break;for(f>>>=c-b;0<f;)g=a[d].d,g<b?(a[d].d++,f-=1<<b-g-1):d++;for(;0<=d;d--)a[d].d==b&&0>f&&(a[d].d--,f++);0!=f&&console.log("debt left")};UZIP.F._goodIndex=function(a,b){var c=0;b[c|16]<=a&&(c|=16);b[c|8]<=a&&(c|=8);b[c|4]<=a&&(c|=4);b[c|2]<=a&&(c|=2);b[c|1]<=a&&(c|=1);return c};
2966UZIP.F._writeLit=function(a,b,c,d){UZIP.F._putsF(c,d,b[a<<1]);return d+b[(a<<1)+1]};
2967UZIP.F.inflate=function(a,b){var c=Uint8Array;
2967if(3==a[0]&&0==a[1])return b?b:new c(0);var d=UZIP.F,e=d._bitsF,f=d._bitsE,g=d._decodeTiny,h=d.makeCodes,k=d.codes2map,l=d._get17,m=d.U,n=null==b;n&&(b=new c(a.length>>>2<<3));for(var r=0,t,u,x,B=0,y=u=0,A=0,aa;0==r;)if(r=e(a,A,1),t=e(a,A+1,2),A+=3,0==t)0!=(A&7)&&(A+=8-(A&7)),A=(A>>>3)+4,t=a[A-4]|a[A-3]<<8,n&&(b=UZIP.F._check(b,y+t)),b.set(new c(a.buffer,a.byteOffset+A,t),y),A=A+t<<3,y+=t;else{n&&(b=UZIP.F._check(b,y+131072));1==t&&(x=m.flmap,aa=m.fdmap,
2968B=511,u=31);if(2==t){u=f(a,A,5)+257;t=f(a,A+5,5)+1;x=f(a,A+10,4)+4;A+=14;for(aa=0;38>aa;aa+=2)m.itree[aa]=0,m.itree[aa+1]=0;B=1;for(aa=0;aa<x;aa++){var ha=f(a,A+3*aa,3);m.itree[(m.ordr[aa]<<1)+1]=ha;ha>B&&(B=ha)}A+=3*x;h(m.itree,B);k(m.itree,B,m.imap);x=m.lmap;aa=m.dmap;A=g(m.imap,(1<<B)-1,u+t,a,A,m.ttree);ha=d._copyOut(m.ttree,0,u,m.ltree);B=(1<<ha)-1;t=d._copyOut(m.ttree,u,t,m.dtree);u=(1<<t)-1;h(m.ltree,ha);k(m.ltree,ha,x);h(m.dtree,t);k(m.dtree,t,aa)}for(;;)if(t=x[l(a,A)&B],A+=t&15,ha=t>>>4,0==
2969ha>>>8)b[y++]=ha;else if(256==ha)break;else{t=y+ha-254;264<ha&&(ha=m.ldef[ha-257],t=y+(ha>>>3)+f(a,A,ha&7),A+=ha&7);ha=aa[l(a,A)&u];A+=ha&15;ha=m.ddef[ha>>>4];var z=(ha>>>4)+e(a,A,ha&15);A+=ha&15;for(n&&(b=UZIP.F._check(b,y+131072));y<t;)b[y]=b[y++-z],b[y]=b[y++-z],b[y]=b[y++-z],b[y]=b[y++-z];y=t}}return b.length==y?b:b.slice(0,y)};UZIP.F._check=function(a,b){var c=a.length;if(b<=c)return a;b=new Uint8Array(Math.max(c<<1,b));b.set(a,0);return b};
2970UZIP.F._decodeTiny=function(a,b,c,d,e,f){for(var g=UZIP.F._bitsE,h=UZIP.F._get17,k=0;k<c;){var l=a[h(d,e)&b];e+=l&15;var m=l>>>4;if(15>=m)f[k]=m,k++;else{var n=l=0;16==m?(n=3+g(d,e,2),e+=2,l=f[k-1]):17==m?(n=3+g(d,e,3),e+=3):18==m&&(n=11+g(d,e,7),e+=7);for(m=k+n;k<m;)f[k]=l,k++}}return e};UZIP.F._copyOut=function(a,b,c,d){for(var e=0,f=0,g=d.length>>>1;f<c;){var h=a[f+b];d[f<<1]=0;d[(f<<1)+1]=h;h>e&&(e=h);f++}for(;f<g;)d[f<<1]=0,d[(f<<1)+1]=0,f++;return e};
2971UZIP.F.makeCodes=function(a,b){var c=UZIP.F.U,d=a.length,e,f;var g=c.bl_count;for(e=0;e<=b;e++)g[e]=0;for(e=1;e<d;e+=2)g[a[e]]++;c=c.next_code;e=0;g[0]=0;for(f=1;f<=b;f++)e=e+g[f-1]<<1,c[f]=e;for(b=0;b<d;b+=2)g=a[b+1],0!=g&&(a[b]=c[g],c[g]++)};UZIP.F.codes2map=function(a,b,c){for(var d=a.length,e=UZIP.F.U.rev15,f=0;f<d;f+=2)if(0!=a[f+1]){var g=a[f+1],h=f>>1<<4|g,k=b-g;g=a[f]<<k;for(k=g+(1<<k);g!=k;)c[e[g]>>>15-b]=h,g++}};
2972UZIP.F.revCodes=function(a,b){for(var c=UZIP.F.U.rev15,d=15-b,e=0;e<a.length;e+=2)a[e]=c[a[e]<<b-a[e+1]]>>>d};UZIP.F._putsE=function(a,b,c){c<<=b&7;b>>>=3;a[b]|=c;a[b+1]|=c>>>8};UZIP.F._putsF=function(a,b,c){c<<=b&7;b>>>=3;a[b]|=c;a[b+1]|=c>>>8;a[b+2]|=c>>>16};UZIP.F._bitsE=function(a,b,c){return(a[b>>>3]|a[(b>>>3)+1]<<8)>>>(b&7)&(1<<c)-1};UZIP.F._bitsF=function(a,b,c){return(a[b>>>3]|a[(b>>>3)+1]<<8|a[(b>>>3)+2]<<16)>>>(b&7)&(1<<c)-1};
2973UZIP.F._get17=function(a,b){return(a[b>>>3]|a[(b>>>3)+1]<<8|a[(b>>>3)+2]<<16)>>>(b&7)};UZIP.F._get25=function(a,b){return(a[b>>>3]|a[(b>>>3)+1]<<8|a[(b>>>3)+2]<<16|a[(b>>>3)+3]<<24)>>>(b&7)};
2974UZIP.F.U=function(){var a=Uint16Array,b=Uint32Array;return{next_code:new a(16),bl_count:new a(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new a(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,
29755,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new b(32),flmap:new a(512),fltree:[],fdmap:new a(32),fdtree:[],lmap:new a(32768),ltree:[],ttree:[],dmap:new a(32768),dtree:[],imap:new a(512),itree:[],rev15:new a(32768),lhst:new b(286),dhst:new b(30),ihst:new b(19),lits:new b(15E3),strt:new a(65536),prev:new a(32768)}}();
2976(function(){function a(e,f,g){for(;0!=f--;)e.push(0,g)}for(var b=UZIP.F.U,c=0;32768>c;c++){var d=c;d=(d&2863311530)>>>1|(d&1431655765)<<1;d=(d&3435973836)>>>2|(d&858993459)<<2;d=(d&4042322160)>>>4|(d&252645135)<<4;d=(d&4278255360)>>>8|(d&16711935)<<8;b.rev15[c]=(d>>>16|d<<16)>>>17}for(c=0;32>c;c++)b.ldef[c]=b.of0[c]<<3|b.exb[c],b.ddef[c]=b.df0[c]<<4|b.dxb[c];a(b.fltree,144,8);a(b.fltree,112,9);a(b.fltree,24,7);a(b.fltree,8,8);UZIP.F.makeCodes(b.fltree,9);UZIP.F.codes2map(b.fltree,9,b.flmap);UZIP.F.revCodes(b.fltree,
29779);a(b.fdtree,32,5);UZIP.F.makeCodes(b.fdtree,5);UZIP.F.codes2map(b.fdtree,5,b.fdmap);UZIP.F.revCodes(b.fdtree,5);a(b.itree,19,0);a(b.ltree,286,0);a(b.dtree,30,0);a(b.ttree,320,0)})();function CBDebug(){}CBDebug.assert=function(a,b){};CBDebug.call=function(a,b,c){};CBDebug.profile=function(a){};CBDebug.profileEnd=function(){};function ASSERT(){}"use strict";let ToolButtons=null;"use strict";var CB={};
2978function namespace(a){a=a.split(".");for(var b=window,c=0;c<a.length;c+=1)"undefined"===typeof b[a[c]]&&(b[a[c]]={}),b=b[a[c]]}function inherit(a,b){var c=a.prototype;a.prototype=new b;for(var d in c)c.hasOwnProperty(d)&&(a.prototype[d]=c[d]);a.superClass=b;a.prototype.superClass=b.prototype;return a}function mixin(a,b){for(var c in b)b.hasOwnProperty(c)&&(a.prototype[c]=b[c])}function mixinNonReplace(a,b){for(let c in b)b.hasOwnProperty(c)&&!a.prototype[c]&&(a.prototype[c]=b[c])}
2979function mixObject(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])}function mixObjectNonReplace(a,b){for(var c in b)b.hasOwnProperty(c)&&!a[c]&&(a[c]=b[c])}function partial(a,b){return ObjUtil.copyTo(b,a,!0)}function protect(a,b){Object.defineProperty(a,b,{writable:!1})}function property(a,b,c,d){Object.defineProperty(a,b,{get:c,set:d})}function classProperty(a,b,c,d){Object.defineProperty(a.prototype,b,{get:c,set:d})}
2980class StringTools{static trimChar(a,b){a.charAt(0)==b&&(a=a.slice(1,a.length-1));2<a.length&&a.charAt(a.length-1)==b&&(a=a.slice(0,a.length-1));return a}}
2981class Char{static IsDigit(a){return"9">=a&&"0"<=a}static IsLetter(a){return"z">=a&&"a"<=a||"Z">=a&&"A"<=a}static IsUpperCaseLetter(a){return"Z">=a&&"A"<=a}static IsLetterOrDigit(a){return Char.IsLetter(a)||Char.IsDigit(a)}
2981static IsWhiteSpace(a){return"\r"===a||"\n"===a||" "===a||"\t"===a}static getIsChar(a){return function(b){return b===a}}static getIsNotChar(a){return function(b){return b!==a}}}
2982class StringIterator{constructor(a){this.m_str=a;this.m_len=a.length;this.m_inx=-1}Current(){return this.m_str[this.m_inx]}Peek(){return this.m_inx>=this.m_len-1?0:this.m_str[this.m_inx+1]}Next(){++this.m_inx;return this.m_inx===this.m_len?0:this.m_str[this.m_inx]}CurrentString(a){return this.SubString(this.m_inx,a)}NextString(a){return this.SubString(this.m_inx+1,a)}SubString(a,b){var c=this.m_len-a;if(!b||b>c)b=c;return this.m_str.substring(a,a+b)}getPosition(){return this.m_inx}setPosition(a){this.m_inx=
2983a}skip(a){this.m_inx+=a}isEOF(){return this.m_inx===this.m_len}AcceptWhile(a,b){var c="";if(b){b=this.Current();if("undefined"===typeof b||!a(b))return c;c=b}for(b=this.Next();0!==b&&a(b)&&(c+=b,"undefined"!==typeof b);b=this.Next());return c}AcceptUntil(a,b){return this.AcceptWhile(NOT(a),b)}AcceptStr(a,b){var c=a.length;return(b?this.CurrentString(c):this.NextString(c))===a?(b||++c,this.skip(c),!0):!1}AcceptChar(a,b){if(b){if(this.Current()===a)return this.skip(1),!0}else if(this.Peek()===a)return this.skip(2),
2984!0;return!1}skipWhile(a,b){if(!b||a(this.Current()))for(b=this.Next();0!==b&&a(b);b=this.Next());}skipUntil(a){return this.skipWhile(NOT(a))}}
2985function AddStringExtensions(){String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s\s*/,"").replace(/\s\s*$/,"")});String.quote||(String.prototype.quote=function(){return'"'+this.replace(/\\/g,"\\\\").replace(RegExp('"',"g"),'\\"')+'"'});String.startsWith||(String.prototype.startsWith=function(a){return this.indexOf?0===this.indexOf(a):!1});String.capitalize||(String.capitalize=function(){return this.length?this[0].toUpperCase()+this.substring(1,this.length).toLowerCase():
2986this})}AddStringExtensions();
2987class StringBuilder{constructor(){this.ep=this.sp=null;this.l=0;this.accum="";this.MAX_LEN=2800}appendFormat(){var a=String.formatEx.apply("",arguments);this.append(a)}append(a){this.accum+=a;this.accum.length>this.MAX_LEN&&(null===this.sp?this.sp=this.ep=[]:(a=this.ep,this.ep=[],a[1]=this.ep),this.ep[0]=this.accum,this.accum="",++this.l)}toString(){if(0==this.l)return this.accum;for(;1<this.l;){for(var a=this.sp,b=[],c=b,d=0;"undefined"!=typeof a;)"undefined"==typeof c[0]?(c[0]=a[0],++d):("undefined"!=
2988typeof a[0]&&(c[0]+=a[0]),c[1]=[],c=c[1]),a=a[1];this.sp=b;this.ep=c;this.l=d}return this.sp[0]+this.accum}}
2989function InitStringFormat(){function a(d){try{for(var e="",f=c.lastIndex=0;;){var g=c.exec(d);if(!g)break;var h=g.index;if(h>f){var k=d.substring(f,h).quote();e&&(e+="+");e+=k}var l=g[1],m=parseInt(l);var n="nz(";n=isNaN(m)?n+("(_a."+l+")"):n+("(_a["+(m+1)+"])");n+=")";e&&(e+="+");e+=n;f=c.lastIndex}if(d.length>f){var r=d.substring(f).quote();e&&(e+="+");e+=r}var t="var nz = function(_v){if(_v === undefined || _v === null)return ''; return _v.toString()};return "+e+";"}catch(u){console.error("_prepFormat",
2990u)}return new Function("_a",t)}var b={},c=/{(\w+(\.\w+)*(\[\d+\])?)}/g;String.formatEx||(String.formatEx=function(d){try{var e=b[d];e||(e=a(d),b[d]=e);var f=arguments;2===arguments.length&&"object"===typeof arguments[1]&&0>d.indexOf("{0}")&&(f=arguments[1])}catch(g){console.error("formatEx",g)}return e(f)});String.f=String.formatEx;String.vformatEx||(String.vformatEx=function(d,e){return a(d)(e)})}InitStringFormat();
2991var Levenshtein={getDistance:function(a,b,c,d,e){c=c||1;d=d||1;e=e||1;if(0===a.length)return b.length;if(0===b.length)return a.length;var f=[],g;for(g=0;g<=b.length;g++)f[g]=[g];var h;for(h=0;h<=a.length;h++)f[0][h]=h;for(g=1;g<=b.length;g++)for(h=1;h<=a.length;h++)b.charAt(g-1)==a.charAt(h-1)?f[g][h]=f[g-1][h-1]:f[g][h]=Math.min(f[g-1][h-1]+c,Math.min(f[g][h-1]+d,f[g-1][h]+e));return f[b.length][a.length]}};"use strict";
2992let CBTabs=function(){var a=function(b){this.config=b||{}};a.prototype.create=function(b){this.parent=b;this.nestDiv=$("<div></div>");$(b).append(this.nestDiv);this._createHtml(this.nestDiv);$(this.nestDiv).jqxTabs({width:"100%",height:"100%",keyboardNavigation:!1,scrollable:this.config.scrollable,theme:glApp.config.jqxTheme})};a.prototype.addHandlers=function(b){if(b.onTabSelect)$(this.nestDiv).on("selected",b.onTabSelect.bind(b));if(b.onTabClick)$(this.nestDiv).on("tabclick",b.onTabClick.bind(b))};
2993a.prototype.resize=function(){};a.prototype.select=function(b){this.nestDiv.jqxTabs("select",b)};a.prototype.getTab=function(b){return $(this.nestDiv).find("#"+this.config.tabs[b].id)};a.prototype.disable=function(b){b<this.config.tabs.length&&this.nestDiv.jqxTabs("disableAt",b)};a.prototype.enable=function(b){b<this.config.tabs.length&&this.nestDiv.jqxTabs("enableAt",b)};a.prototype.show=function(b){$("#"+b+"-tab").parents("li[role='tab']").show()};a.prototype.hide=function(b){$("#"+b+"-tab").parents("li[role='tab']").hide()};
2994a.prototype.getSelectedInx=function(){return this.nestDiv.jqxTabs("val")};a.prototype.getSelectedId=function(){var b=this.nestDiv.jqxTabs("val");if(0<=b&&(b=this.nestDiv.jqxTabs("getContentAt",b)))return b.id};a.prototype._createHtml=function(b){if(this.config.tabs.length){$(b).append($("<ul></ul>"));for(var c=0;c<this.config.tabs.length;c++)this.createEl(c,b);for(let d=0;d<this.config.tabs.length;d++)c=$(String.f("<div id='{0}'></div>",this.config.tabs[d].id)),$(b).append(c)}};a.prototype.createEl=
2995function(b,c){if(this.config.tabs[b].icon){var d=this._getImgSrc(this.config.tabs[b].icon);$(c).find("ul").append(String.f("<li><div id='{2}-tab'><img style='float:left' src='{1}'/><div class='cbJqxTabHeaderText'>{0}</div></div></li>",this.config.tabs[b].title,d,this.config.tabs[b].id))}else $(c).find("ul").append(String.f("<li>{0}</li>",this.config.tabs[b].title))};a.prototype._getImgSrc=function(b){var c=glApp.config.getRibbonPath();this.config.iconPath&&(c+=this.config.iconPath+"/");c=c+b+(this.config.iconHeight||
299624);return c+".png"};return a}();"use strict";
2997class CBForm{constructor(a){this.config=a;this.inpH=26;this.buttonW=90;this.buttonH=30;this.theme="chessbase"}show(){$(this.nestDiv).css("display","block")}hide(){$(this.nestDiv).css("display","none")}isVisible(){return!$(this.nestDiv).is(":hidden")}create(a,b,c){let d=window.pageYOffset;$("#"+this.config.id).remove();this.nestDiv=$(String.f("<div id='{0}'></div>",this.config.id));this._createHtml(this.nestDiv);$(a).append(this.nestDiv);b=this.config.height||400;glApp.panelMgr.onFormOpen();$(this.nestDiv).jqxWindow({width:this.config.width||
2998400,height:b,isModal:this.config.modal,theme:this.theme,resizable:!1,autoOpen:!1,showCloseButton:!1,draggable:!this.config.fixed});$(this.nestDiv).jqxWindow({initContent:function(){"undefined"===typeof this.config.noButtons&&($("#btnCancel").jqxButton({width:this.buttonW,height:this.buttonH,theme:this.theme}),$("#btnOk").jqxButton({width:this.buttonW,height:this.buttonH,theme:this.theme}));this.config.focusField&&$("#"+this.config.focusField).jqxInput("focus");$(this.nestDiv).keyup(function(e){13==
2999e.keyCode&&$("#btnOk").click()})}.bind(this)});$(this.nestDiv).jqxWindow("cancelButton",$("#btnCancel"));$(this.nestDiv).jqxWindow("open");a&&($("html, body").scrollTop(d),c?(a=c.clientY-40,a+b>window.innerHeight&&(a=Math.max(0,window.innerHeight-b)),$(this.nestDiv).css({top:a,position:"fixed"})):$(this.nestDiv)[0].scrollIntoView());this.validator&&this.validator(this.nestDiv);$("#btnOk").click(function(e){e=!0;this.validator&&(e=$(this.nestDiv).jqxValidator("validate"));e&&(e=this._extractResults(),
3000$(this.nestDiv).jqxWindow("hide"),$(this.nestDiv).remove(),this.config.okHandler&&this.config.okHandler(e),glApp.panelMgr.onFormClose())}.bind(this));$("#btnCancel")&&$("#btnCancel").click(function(e){$(this.nestDiv).jqxWindow("hide");$(this.nestDiv).remove();this.config.cancelHandler&&this.config.cancelHandler();glApp.panelMgr.onFormClose()}.bind(this));this.config.accountButton&&($("#btnAccount").jqxButton({width:this.buttonW,height:this.buttonH,theme:this.theme}),$("#btnAccount").on("click",function(e){glApp.panelMgr.openRegisterPage()}));
3001this.config.pasteButton&&($("#btnPaste").jqxButton({width:this.buttonW,height:this.buttonH,theme:this.theme}
3001),$("#btnPaste").on("click",function(e){System.isElectron()&&"undefined"!==typeof electronBridge&&(e=electronBridge.readFromClipboard().trim(),34<=e.length&&($("#idSerial0").val(e.substr(0,5)),$("#idSerial1").val(e.substr(6,5)),$("#idSerial2").val(e.substr(12,5)),$("#idSerial3").val(e.substr(18,5)),$("#idSerial4").val(e.substr(24,5))))}));this.config.top&&$(this.nestDiv).css("top",this.config.top);
3002this.config.left&&$(this.nestDiv).css("left",this.config.left);this.config.position&&$(this.nestDiv).css("position",this.config.position)}closeDialog(){$(this.nestDiv).jqxWindow("hide");$(this.nestDiv).remove()}_extractResults(){var a={};this.config.fields.forEach(function(b){switch(b.type){case "number":case "password":case "string":case "stringmultiline":a[b.id]=$("#"+b.id).val();break;case "serial":for(var c="",d=0;5>d;d++)c+=$("#"+b.id+d).val();a[b.id]=c;break;case "checkbox":a[b.id]=$("#"+b.id).jqxCheckBox("checked");
3003break;case "select":a[b.id]=$("#"+b.id+"_jqxDropDownList").children("option:selected").val();if(c=$("#"+b.id).jqxDropDownList("getSelectedItem"))a[b.id+"-inx"]=c.index;break;case "radio":for(c=0;c<b.buttons.length;c++)$(`#${b.buttons[c].id}`).jqxRadioButton("val")&&(a[b.id]=c)}}.bind(this));return a}_getButtonConfig(){return{imgHeight:32,imgWidth:32,theme:this.theme}}_createHtml(a){var b=$("<div>"+this.config.title+"</div>");a.append(b);b=$(String.f("<div></div>"));var c=$("<table class='cbJqxFormTable'></table>");
3004b.append(c);this.config.fields.forEach(function(f){var g=$("<tr></tr>");switch(f.type){case "label":var h=$(String.f("<td align='right' class='cbJqxFormCaption'><h3 id='myLabel'>{0}</h3></td>",f.caption));g.append(h);this.label=h;break;case "separator":g.append($("<td colspan='2'><div class='cbJqxFormSeparator'/></td>"));break;case "progress":h=$(String.f("<td align='right' class='cbJqxFormCaption'>{0}</td>",f.caption));g.append(h);h=$("<td align='left'></td>");var k=$(String.f("<div id='{0}'></div>",
3005f.id));h.append(k);k.jqxProgressBar({width:300,height:this.config.checkBoxH||this.inpH,value:0,showText:!0});g.append(h);k.jqxProgressBar("animationDuration",0);k.jqxProgressBar("theme","shinyblack");k.jqxProgressBar("value",0);k.jqxProgressBar("colorRanges",[{stop:0,color:"#A00000"},{stop:100,color:"#00FF00"}]);this.progressBar=k;break;case "number":h=$(String.f("<td align='right' class='cbJqxFormCaption'>{0}</td>",f.caption));g.append(h);h=$("<td align='left'></td>");k=$(String.f("<input id='{0}'/>",
3006f.id));h.append(k);k.jqxNumberInput({width:this.config.numInpW||60,height:this.config.inpH||this.inpH,min:f.min||0,max:f.max||999999999,theme:this.theme,decimalDigits:0,digits:f.digits||2,inputMode:"simple",spinButtons:f.spin});f.val&&k.jqxNumberInput("val",f.val);g.append(h);break;case "string":h=$(String.f("<td align='right'>{0}</td>",f.caption));g.append(h);h=$("<td align='left'></td>");k=$(String.f("<input id='{0}'/>",f.id));h.append(k);k.jqxInput({width:this.config.strInpW||200,height:this.config.inpH||
3007this.inpH,maxLength:this.config.maxLength||128,theme:this.theme});f.val&&k.jqxInput("val",f.val);g.append(h);break;case "serial":h=$(String.f("<td align='right'>{0}</td>",f.caption));g.append(h);h=$("<td align='left'></td>");for(var l=0;5>l;l++)k=$(String.f("<input id='{0}' style='text-transform: uppercase;' />",f.id+l)),h.append(k),k.jqxInput({width:80,height:this.config.inpH||this.inpH,minLength:5,maxLength:5,theme:this.theme}),f.val&&34<=f.val.length&&5>l&&k.jqxInput("val",f.val.substr(6*l,5)),
3008h.append("-"),4==l&&h.append("DATA");g.append(h);break;case "stringmultiline":h=$(String.f("<td align='right'>{0}</td>",f.caption));g.append(h);h=$("<td align='center'></td>");k=$(String.f("<textarea id='{0}' rows='{1}' cols='{2}' maxlength='{3}'/>",f.id,f.rows,f.cols,f.maxLength));$(k).addClass("jqx-input jqx-widget jqx-widget-content");$(k).on("keyup",r=>r.stopPropagation());this.theme&&$(k).addClass(String.f("jqx-input-{0} jqx-widget-{0} jqx-widget-content-{0}",this.theme));h.append(k);f.val&&
3009k.text(f.val);g.append(h);break;case "password":h=$(String.f("<td align='right'>{0}</td>",f.caption));g.append(h);h=$("<td align='left'></td>");k=$(String.f("<input id='{0}' type='password' />",f.id));h.append(k);k.jqxPasswordInput({width:this.config.strInpW||200,height:this.config.inpH||this.inpH,maxLength:128,theme:this.theme,placeHolder:"Enter password"});g.append(h);break;case "checkbox":h=$(String.f("<td align='right' class='cbJqxFormCaption'>{0}</td>",f.caption));g.append(h);h=$("<td align='left'></td>");
3010k=$(String.f("<div id='{0}'></div>",f.id));h.append(k);k.jqxCheckBox({width:this.config.checkBoxW||120,height:this.config.checkBoxH||this.inpH,theme:this.theme,checked:f.checked});g.append(h);break;case "select":h=CBForm.createCaption(f.caption);g.append(h);h=$("<td>",{align:"left"});var m=$("<select>");m.attr("id",f.id);f.options.forEach(function(r){var t=$("<option>");t.val(r.value);t.text(r.text);f.val==r.value&&t.attr("selected","selected");m.append(t)});h.append(m);g.append(h);m.jqxDropDownList({width:this.config.selW||
3011200,height:this.config.selH||this.inpH});break;case "radio":h=CBForm.createCaption(f.caption);g.append(h);var n=$("<td>",{align:"left"});g.append(n);f.buttons.forEach(function(r){let t=$(`<div id="${r.id}">${r.text}</div>`);t.bind("change",function(u){});n.append(t);t.jqxRadioButton({width:100,height:25,checked:r.checked,theme:this.theme})}.bind(this))}c.append(g)}.bind(this));var d=$("<tr></tr>");c.append($("<tr><td></td></tr>"));d.append($("<td align='right'></td>"));if(this.config.pasteButton){var e=
3012$("<tr></tr>");e.append($("<td colspan='2' align='left' style='padding-top: 16px'><input type='button' id='btnPaste' value='"+lm.PASTE+"' /></td>"));c.append(e)}this.progressBar||d.append($(String.f('<td style="padding-top: 10px;" align="right"><input style="margin-right: 5px;" type="button" id="btnOk" value="OK" /><input id="btnCancel" type="button" value="{0}" /></td>',lm.CANCEL)));c.append(d);this.config.accountButton&&(c.append($("<tr><td></td></tr>")),d=$("<tr></tr>"),d.append($("<td colspan='2' align='left' style='padding-top: 16px'><input type='button' id='btnAccount' value='Register' /></td>")),
3013c.append(d));a.append(b)}_getImgSrc(a){var b=glApp.config.getRibbonPath();this.config.iconPath&&(b+=this.config.iconPath+"/");b=b+a+(this.config.iconHeight||32);return b+".png"}static inputString(a,b,c,d,e,f){(new CBForm({id:"inputString",title:a,width:300,height:180,modal:!0,okHandler:e,cancelHandler:f,fields:[{caption:b,type:"string",id:"idInput",strInpW:160,maxLength:d,val:c}]})).create()}static fnCommand(a){alert(a)}static createCaption(a){return $(String.f("<td align='right' class='cbJqxFormCaption'>{0}</td>",
3014a))}}function LOG(a){}
3015var LogException=function(a,b,c){var d=b?b.toString():"---";if("undefined"!==typeof ga&&System.V3()){System.isMobile()&&(d+=" (mob)",System.getAndroidVersion()?d+=", andr="+System.getAndroidVersion():System.getiOSVersion()&&(d+=", ios="+System.getiOSVersion()));var e="catch";window.glApp&&window.glApp.versionCode&&(d+=", ver="+window.glApp.versionCode.getStrVersion(),e+=window.glApp.versionCode.getStrVersion());var f=a+", "+d;b&&(b.lineNumber&&(f+=", line="+b.lineNumber),b.columnNumber&&(f+=", col="+
3016b.columnNumber),b.stack&&(c=b.stack));ga("send","event",e,f,c)}console.log(a+", "+d);console.log(b);System.isIPad()&&DOM.add(a+", "+d)},lm;
3017class Localization{constructor(a){this.locObjects=[].concat(a);lm=this.locObjects[0];for(a=1;a<this.locObjects.length;a++){var b=this.locObjects[a];for(c in b)b.hasOwnProperty(c)&&(lm[c]=b[c])}lm.rnd=function(){return arguments[Math.floor(Math.random()*arguments.length)]};var c=ObjUtil.clone(V5);c.arrStrPieces[Piece.W_KING]=c.arrStrPieces[Piece.B_KING]=lm.NOTATION_KING;c.arrStrPieces[Piece.W_QUEEN]=c.arrStrPieces[Piece.B_QUEEN]=lm.NOTATION_QUEEN;c.arrStrPieces[Piece.W_ROOK]=c.arrStrPieces[Piece.B_ROOK]=
3018lm.NOTATION_ROOK;c.arrStrPieces[Piece.W_BISHOP]=c.arrStrPieces[Piece.B_BISHOP]=lm.NOTATION_BISHOP;c.arrStrPieces[Piece.W_KNIGHT]=c.arrStrPieces[Piece.B_KNIGHT]=lm.NOTATION_KNIGHT;c.arrStrPieces[Piece.W_PAWN]=c.arrStrPieces[Piece.B_PAWN]="";lm.NOTA_LOCALIZATION=c}}var glLoc;function setGlobalLoc(a){glLoc=a}var Loc={};"use strict";
3019var Chess_en={LOGIN:"Log in",LOGOUT:"Log out",ACCOUNT:"My Account",BOARDS:"Boards",RECONNECT:"Reconnect",RESIGN:"Resign",CLOSE_BOARD:"Close Board",OFFER_DRAW:"Offer Draw",ACCEPT_DRAW:"Accept Draw",ACCEPTED_DRAW:"{0} accepted a draw.",OFFERS_DRAW:"{0} offers a draw.",ACCEPTS_DRAW:"{0} accepts a draw.",RESIGNS:"{0} resigns.",TESTING_CONN:"Testing Connection to Server",CONNECTING:"Connecting to server, please wait...",RECONNECTED_OK:"Reconnected OK",NAME:"Name",NATION:"Country",RANK:"Rank",WHITE:"White",
3020BLACK:"Black",ELO_WHITE:"Elo White",ELO_BLACK:"Elo Black",RESULT:"Result",TIME_CONTROL:"Time Control",TOURNAMENT:"Tournament",GAMES:"Games",CHAT:"Chat",CHAT_PARTNER_GONE:"Your chat partner is gone.",CONNECTION:"Connection",MAP:"Map",KING:"King",QUEEN:"Queen",ROOK:"Rook",BISHOP:"Bishop",KNIGHT:"Knight",PAWN:"Pawn",TYPE_CHAT_HERE:"Type Chat Here",TYPE_HERE_TO_CHAT_WITH:"Type Here To Chat With",GUEST:"Guest",CONFIRM:"Confirm",CANCEL:"Cancel",CLOCK:"Clock",TIME:"Time",GAIN_PER_MO
3020VE:"Gain per Move",CLOSE:"Close",
3021ADD:"Add",REMOVE:"Remove",NOTATION:"Notation",BOARD_FRITZ:"Fritz",BOARD_CRYSTALS:"Crystals",BOARD_USCF:"USCF",BOARD_OLDSTYLE:"OldStyle",BOARD_HABSBURG:"Habsburg",BOARD_FRITZ_AND_CHESTER:"Fritz & Chesster",PLAY_BLITZ:"Play Blitz",NEW_GAME:"New Game",TAKE_BACK:"Take Back",MAKE_MOVE:"Make Move",FLIP_BOARD:"Flip Board",COPY:"Copy",SEARCH_BOARD:"Search Board",YEAR:"Year",BOOK:"Book",LIVE_BOOK:"Live Book",MOVE:"Move",NR_GAMES:"Nr Games",SCORE:"Score",LAST_PLAYED:"Last Played",ELO_AVG:"Elo Avg.",VISITS:"Visits",
3022LOADING_STATISTICS:"Loading statistics",LETS_CHECK:"Let's Check",EVAL:"Eval",VARIATION:"Variation",DEPTH:"Depth",ENGINE:"Engine",ENTER_YOUR_SEARCH_TEXT:"Enter your search text...",RETRIEVING_GAMES:"Retrieving games",PLAYER_DETAILS:"Player details",PLAYER_INFORMATION:"Player information",FIRST_NAME:"First Name",LAST_NAME:"Last Name",YEAR_OF_BIRTH:"Year of Birth",TREND:"Trend",RATING:"Rating",SEND_FEEDBACK:"Send Feedback",YOUR_COMMENT:"Your Comment",YOUR_EMAIL_ADDRESS:"Your E-mail Address",SEND:"Send",
3023BROWSER_DOESNT_SUPPORT_3D:"Browser does not support 3d boards",BOARD3D_FRITZ:"Fritz",BOARD3D_MODERN:"Modern",BOARD3D_ROOM:"Room",BOARD3D_BALLOON:"Balloon",BOARD3D_METAL:"Metal",BOARD3D_SILVER:"Silver",BOARD3D_FUTURE:"Future",BOARD3D_MARBLE:"Marble",WELCOME:"Welcome",MATERIAL:"Material",ANALYSIS:"Analysis",ANALYSIS_ENGINE:"Engine",ENG_SEARCH_INFO_FMT:"Depth {0}/{1}, Speed = {2}kPos/s, Time = {3}s",PASTE:"Paste",PW_INVALID:"<bold>User/Password invalid, please try again</bold>",PLEASE_LOGIN:"Please log in with your ChessBase (Playchess) account:",
3024ACCOUNTNAME:"Name",PASSWORD:"Password",CREATE_ACCOUNT:"Create Account",LOGIN_GUEST:"Guest",PLEASE_LOGIN_SHORT:"Please Log In",LOADING_ENGINE:"Loading Engine...",LOADING_LIVE_GAMES:"Loading Live Games ...",INVITING_OTHER_PLAYERS:"Inviting other players to a game of {0} ({1})",OTHER_TOOLS:"More Apps",DATABASES:"Databases",OPEN_DATABASE:"Open Database",CREATE_DATABASE:"Create Database",DELETE_DATABASE:"Delete Database",DELETE:"Delete",CLEAN_UP:"Clean Up",MY_DATABASES:"My Databases",DATABASES_SHARED_WITH_ME:"Databases shared with me",
3025SELECT_DATABASE_FOR_USER:"Select Database For '{0}'",OPEN_PGN:"Open PGN",SAVE:"Save",SAVE_AND_REPLACE_GAMES:"Save and replace games",SAVE_AS_NEW:"Save As New",EDIT_GAME:"Edit Game",DATABASE_FUNCTIONS:"Open, create and delete databases",TEXT_BEFORE:"Text Before",TEXT_AFTER:"Text",START_LINE:"Start Line",PROMOTE_LINE:"Promote Line",DELETE_LINE:"Delete Line",CUT_LINE:"Cut Line",OPEN_PGN_TIP:"Open a PGN file from your computer",TEXT_BEFORE_TIP:"Add a text annotation before this move",TEXT_AFTER_TIP:"Add a text annotation after this move",
3026START_LINE_TIP:"Retract current move and start a line",PROMOTE_LINE_TIP:"Promote the currently selected line",DELETE_LINE_TIP:"Delete the selected line",CUT_LINE_TIP:"Cut off the following moves",STAY_LOGGED_IN:"Stay Logged In",FORGOT_PASSWORD:"Forgot Password",CHANGE_PASSWORD:"Change Password",OLD_PASSWORD:"Old Password",NEW_PASSWORD:"New Password",CONFIRM_PASSWORD:"Confirm Password",MENU_PLAYCHESS_TOOL:"Play & Watch",MENU_DATABASE_TOOL:"Live Database",MENU_MYGAMES_TOOL:"My Own Games",MENU_FRITZ_TOOL:"Chess Program Fritz",
3027MENU_FRITZ_CHESSTER_TOOL:"Chess For Kids",MENU_TACTICS_TOOL:"Tactics Training",LANGUAGE:"Language",LOGIN_CREATE_LINK:"Click here to create an account",LOGIN_PLEASE_LOGIN:"Please Log In",LOGIN_ACCOUNT_FREE:"Creating an account is free. The account is valid for all other ChessBase Web Tools and for play.chessbase.com.",LOGIN_WELCOME:"Welcome, {0}!",MANAGE_FRIENDS:"Manage friends",INVITE_FRIEND:"Invite a friend",PING:"Ping",NOTATION_KING:"K",NOTATION_QUEEN:"Q",NOTATION_KNIGHT:"N",NOTATION_BISHOP:"B",
3028NOTATION_ROOK:"R",NOTATION_PAWN:"P",GENERAL_INVITE:'Thank you for using the <span style="font-weight:bold">{0}</span>.',MYGAMES_INVITE:'Thank you for using <span style="font-weight:bold">ChessBase MyGames</span>, your personal chess database in the web.',MYGAMES_FUNCTIONALITY:"Please login with your ChessBase Account to create and access your cloud chess databases. You can also use the cloud databases with ChessBase 13.",ECO:"ECO",BACK:"Back",NEXT_MOVE:"Next Move",PREV_MOVE:"Previous Move",NEXT_GAME:"Next Game",
3029PREV_GAME:"Previous Game",MENU_VIDEO_TOOL:"Training Videos",MENU_OPENINGS_TOOL:"Manage Openings",REQUESTING_MOVES:"Requesting Moves",FRESH_POSITION:"Fresh Position",EMBED:"Embed",HELP:"Help",TOGGLE_3D_2D:"Toggle 2D/3D Board",BOARD3D_BLACKWHITE:"Black 
3029white",MATE:"Mate",STALEMATE:"Stalemate",SETUP_POSITION:"Setup Position",WHITE_MATES:"White mates",WHITE_CLEARLY_WINNING:"White is clearly winning",WHITE_WINNING:"White is winning",WHITE_DECISIVE:"White has a decisive advantage",WHITE_CLEARLY_BETTER:"White is clearly better",
3030WHITE_BETTER:"White is better",WHITE_SLIGHTLY:"White is slightly better",WHITE_EDGE:"White is minimally better",BLACK_MATES:"Black mates",BLACK_CLEARLY_WINNING:"Black is clearly winning",BLACK_WINNING:"Black is winning",BLACK_DECISIVE:"Black has a decisive advantage",BLACK_CLEARLY_BETTER:"Black is clearly better",BLACK_BETTER:"Black is better",BLACK_SLIGHTLY:"Black is slightly better",BLACK_EDGE:"Black is minimally better",EQUAL_POS:"The position is equal",PREMIUM_ONLY:"Premium Only",BOARD3D_CHARACTER:"Avatar",
3031CALC_TRAINING:"Assisted Calculation",TTIP_CALC_TRAINING:"Calculate variations with Fritz' assistance before you continue the game here.",CALC_INFO:"Enter moves blindly. Click in the notation to add variations anywhere. Right-click unveils current position. Click 'Assisted Calculation' to resume your game.",CALCULATING:"Calculating...",WOOD:"Wood",TRAINING_SOLUTION:"Show Solution",TRAINING_HELP:"Get Help",TRAINING_QUESTION:"Find the correct move",UNANNOTATE:"Unannotate",MORE_LINES:"More Lines",LESS_LINES:"Less Lines",
3032CALCULATE_THREAT:"Calculate Threat",START_RADIO:"Start",PAUSE_RADIO:"Pause",CURRENTLY_NO_LIVE_BROADCAST:"At the moment there\u2019s no live broadcast",CONNECTED_TO_SERVER:"Connected to server: {0}",INITIALIZING:"Initializing",INSERT_DIAGRAM:"Insert Diagram",BOARD:"Board",LIKE:"Like",LOADING_BOARD:"Loading board, just a second...",DB_NOGAMES_FOUND:"No games found for this position and search string.",YOUR_KING_ACC:"your king",YOUR_QUEEN_ACC:"your queen",YOUR_KNIGHT_ACC:"your knight",YOUR_BISHOP_ACC:"your bishop",
3033YOUR_ROOK_ACC:"your rook",YOUR_PAWN_ACC:"your pawn",MOVE_IMP:"Move",WHITES_MOVE:"White's move",BLACKS_MOVE:"Black's move",CLICK_TO_FLIP_BOARD:"click to flip board",MAXIMIZE:"Maximize",PIECES:"Pieces",SOUND_ONOFF:"Sound On/Off",GOTO_BEGIN:"Goto Begin",GOTO_END:"Goto End",LOAD_PREV:"Load Prev.",LOAD_NEXT:"Load Next",SEARCH_MATERIAL:"Search Material",JOIN_WITH_VIDEO:"Join with Video",JOIN_WITH_AUDIO:"Join with Audio",AUDIO_VIDEO_REQUIRES_SECURED_CONNECTION:"Using video and audio requires a secure connection",
3034REACHED_DAILY_LIMIT:"You reached your daily limit",PLEASE_ATTACH_VIDEO_OR_AUDIO_RECORDING_DEVICE:"Please attach video or audio recording device",REPORT:"Report",SERVER_LOGGED_YOU_OFF:"Server logged you off:",DOUBLE_LOGIN:"Double login",PLEASE_CHECK_CONNECTION:"Please check your connection",START_ANALYSIS:"Start Analysis",VARIATIONS:"Variations",ENGINE_STOPPED:"Engine Stopped",SAVE_AS_PGN:"Save as PGN",SETUP_AND_SAVE:"Setup and Save",A_QUEEN_ACC:"a queen",A_KNIGHT_ACC:"a knight",A_BISHOP_ACC:"a bishop",
3035A_ROOK_ACC:"a rook",A_PAWN_ACC:"a pawn",LOGGED_IN:"Logged in",TECHNICAL:"Technical",CALM:"Calm",NORMAL:"Normal",EXCITING:"Exciting",SHARP:"Sharp",VERY_SHARP:"Very sharp",BOARD_ON_FIRE:"Board on fire",HINTS_ONLY:"Hints only",NEXT_HINT:"Next Hint",BIG_BOARD:"Big Board",BIG_NOTATION:"Big Notation",TWO_BOARDS:"Two Boards",FOUR_BOARDS:"Four Boards",HOME:"Home",SHARE_BOARD:"Share Board (.png)",SETTINGS:"Settings",SHARE:"Share",SHARE_BOARD_USER:"Share Board (configure)",LAYOUT:"Layout",BOARDS_SAME_SIZE:"Boards Same Size",
3036LAYOUT_SETTINGS:"Layout Settings",SWIPED_LAYOUT:"Swipe notation/lists",SPLITTED_LAYOUT:"Use splitters",FONT_SIZE:"Font Size Notation",READING_MODE:"Reading mode",FLOAT_BOARD_HELP:"Drag/resize possible",DOWNLOAD:"Download",SHARE_PLAYABLE:"Share playable board",PASTE_PGN:"Paste PGN",SHARE_GIF:"Share game as GIF",SIZE:"Size",DELAY:"Delay",PLAYERS:"Include Players",TITLE:"Title",OPEN:"Open",NEW:"New",DESCRIPTION:"Description",USE_THINK_TIMES:"Use Thinking Times",GREY:"Grey",LINK_TO_THIS_GAME:"Share link to this game",
3037SELECT_GAMES:"Select games",SHOW_SELECTED_GAMES:"Load selected games",ENG_BELOW_NOTA:"Engine below notation",CORRECT_MOVE:"Correct!",TRY_AGAIN:"Please try again."};namespace("Loc.Chess.ENG");Loc.Chess.ENG=Chess_en;"use strict";
3038var Chess_de={LOGIN:"Anmelden",LOGOUT:"Abmelden",ACCOUNT:"Mein Konto",BOARDS:"Bretter",RECONNECT:"Verbinden",RESIGN:"Aufgeben",CLOSE_BOARD:"Brett schlie\u00dfen",OFFER_DRAW:"Remis bieten",ACCEPT_DRAW:"Remis akzeptieren",ACCEPTED_DRAW:"{0} hat das Remis angenommen.",OFFERS_DRAW:"{0} bietet Remis.",ACCEPTS_DRAW:"{0} nimmt Remis an.",RESIGNS:"{0} gibt auf.",TESTING_CONN:"Test Verbindung zum Server",CONNECTING:"Verbindung wird aufgebaut, einen Moment...",RECONNECTED_OK:"Verbindung wiederhergestellt",
3039NAME:"Name",NATION:"Land",RANK:"Rang",WHITE:"Weiss",BLACK:"Schwarz",ELO_WHITE:"Elo Weiss",ELO_BLACK:"Elo Schwarz",RESULT:"Ergebnis",TIME_CONTROL:"Bedenkzeit",TOURNAMENT:"Turnier",GAMES:"Partien",CHAT:"Chat",CHAT_PARTNER_GONE:"Ihr Chat Partner ist gegangen.",CONNECTION:"Verbindung",MAP:"Karte",KING:"K\u00f6nig",QUEEN:"Dame",ROOK:"Turm",BISHOP:"L\u00e4ufer",KNIGHT:"Springer",PAWN:"Bauer",TYPE_CHAT_HERE:"Chat hier eingeben",TYPE_HERE_TO_CHAT_WITH:"Hier tippen f\u00fcr Chat an",GUEST:"Gast",CONFIRM:"Best\u00e4tigen",
3040CANCEL:"Abbruch",CLOCK:"Uhr",TIME:"Zeit",GAIN_PER_MOVE:"Gain per Move",CLOSE:"Close",ADD:"Add",REMOVE:"Remove",NOTATION:"Notation",BOARD_FRITZ:"Fritz",BOARD_CRYSTALS:"Crystals",BOARD_USCF:"USCF",BOARD_OLDSTYLE:"OldStyle",BOARD_HABSBURG:"Habsburg",BOARD_FRITZ_AND_CHESTER:"Fritz & Fertig",PLAY_BLITZ:"Blitzpartie",NEW_GAME:"Neue Partie",TAKE_BACK:"Zug zur\u00fcck",MAKE_MOVE:"Zug vor",FLIP_BOARD:"Brett drehen",COPY:"Kopieren",SEARCH_BOARD:"Brett suchen",YEAR:"Jahr",BOOK:"Buch",LIVE_BOOK:"Live Buch",MOVE:"Zug",
3041NR_GAMES:"Nr Games",SCORE:"Score",LAST_PLAYED:"Zuletzt gespielt",ELO_AVG:"Elo Avg.",VISITS:"Besuche",LOADING_STATISTICS:"L\u00e4dt Statistiken",LETS_CHECK:"Let's Check",EVAL:"Eval",VARIATION:"Variation",DEPTH:"Tiefe",ENGINE:"Engine",ENTER_YOUR_SEARCH_TEXT:"Suchtext hier eingeben...",RETRIEVING_GAMES:"Lade Partien",PLAYER_DETAILS:"Spieler Details",PLAYER_INFORMATION:"Spieler Information",FIRST_NAME:"Vorname",LAST_NAME:"Nachname",YEAR_OF_BIRTH:"Geburtsjahr",TREND:"Trend",RATING:"Rating",SEND_FEEDBACK:"Feedback senden",
3042YOUR_COMMENT:"Ihr Hinweis",YOUR_EMAIL_ADDRESS:"Ihre E-Mail-Adresse",SEND:"Absenden",BROWSER_DOESNT_SUPPORT_3D:"Ihr Browser unterst\u00fctzt noch kein 3D",BOARD3D_FRITZ:"Fritz",BOARD3D_MODERN:"Modern",BOARD3D_ROOM:"Room",BOARD3D_BALLOON:"Balloon",BOARD3D_METAL:"Metal",BOARD3D_SILVER:"Silver",BOARD3D_FUTURE:"Future",BOARD3D_MARBLE:"Marble",WELCOME:"Willkommen",MATERIAL:"Material",ANALYSIS:"Analyse",ANALYSIS_ENGINE:"Engine",ENG_SEARCH_INFO_FMT:"Tiefe {0}/{1}, {2}k Pos/s, Zeit = {3}s",PASTE:"Einf\u00fcgen",
3043PW_INVALID:'Account <em>"{0}"</em> oder Passwort nicht erkannt.',PLEASE_LOGIN:"Anmelden mit ChessBase (Playchess) Konto:",ACCOUNTNAME:"Name",PASSWORD:"Passwort",CREATE_ACCOUNT:"Konto neu anlegen",LOGIN_GUEST:"Gast",PLEASE_LOGIN_SHORT:"Bitte anmelden",LOADING_ENGINE:"Lade Engine...",LOADING_LIVE_GAMES:"Lade Live Partien ...",INVITING_OTHER_PLAYERS:"Inviting other players to a game of {0} ({1})",OTHER_TOOLS:"Weitere Apps",DATABASES:"Datenbanken",OPEN_DATABASE:"Datenbank \u00f6ffnen",CREATE_DATABASE:"Neue Datenbank",
3044DELETE_DATABASE:"Datenbank l\u00f6schen",DELETE:"L\u00f6schen",CLEAN_UP:"Aufr\u00e4umen",MY_DATABASES:"Meine Datenbanken",DATABASES_SHARED_WITH_ME:"Mit mir geteilt",SELECT_DATABASE_FOR_USER:"Datenbankauswahl f\u00fcr '{0}'",OPEN_PGN:"PGN \u00f6ffnen",SAVE:"Speichern",SAVE_AND_REPLACE_GAMES:"Partien speichern und ersetzen",SAVE_AS_NEW:"Neue Version speichern",EDIT_GAME:"Kenndaten setzen",DATABASE_FUNCTIONS:"Datenbanken \u00f6ffnen, anlegen und l\u00f6schen",TEXT_BEFORE:"Text vor Zug",TEXT_AFTER:"Text",
3045START_LINE:"Variante",PROMOTE_LINE:"Aufwerten",DELETE_LINE:"L\u00f6schen",CUT_LINE:"Schneiden",OPEN_PGN_TIP:"PGN-Datei von Ihrem Computer \u00f6ffnen",TEXT_BEFORE_TIP:"Textkommentar vor diesem Zug",TEXT_AFTER_TIP:"Textkommentar nach diesem Zug",START_LINE_TIP:"Zug zur\u00fccknehmen und Variante starten",PROMOTE_LINE_TIP:"Ausgew\u00e4hlte Variante wird Hauptvariante",DELETE_LINE_TIP:"Ausgew\u00e4hlte Variante l\u00f6schen",CUT_LINE_TIP:"Nachfolgende Z\u00fcge wegschneiden",STAY_LOGGED_IN:"Angemeldet bleiben",
3046FORGOT_PASSWORD:"Passwort vergessen",CHANGE_PASSWORD:"Passwort \u00e4ndern",OLD_PASSWORD:"Altes Passwort",NEW_PASSWORD:"Neues Passwort",CONFIRM_PASSWORD:"Passwort best\u00e4tigen",MENU_PLAYCHESS_TOOL:"Spielen & Zuschauen",MENU_DATABASE_TOOL:"Live Datenbank",MENU_MYGAMES_TOOL:"Meine Partien",MENU_FRITZ_TOOL:"Schachprogramm Fritz",MENU_FRITZ_CHESSTER_TOOL:"Fritz & Fertig f\u00fcr Kinder",MENU_TACTICS_TOOL:"Taktiktraining",LANGUAGE:"Sprache",LOGIN_CREATE_LINK:"Hier klicken, um Account anzulegen",LOGIN_PLEASE_LOGIN:"Bitte anmelden",
3047LOGIN_ACCOUNT_FREE:"Ein ChessBase Account ist kostenlos und gilt f\u00fcr alle ChessBase Web Tools und f\u00fcr www.schach.de.",LOGIN_WELCOME:"Willkommen, {0}!",MANAGE_FRIENDS:"Freunde verwalten",INVITE_FRIEND:"Einen Freund einladen",PING:"Ping",NOTATION_KING:"K",NOTATION_QUEEN:"D",NOTATION_KNIGHT:"S",NOTATION_BISHOP:"L",NOTATION_ROOK:"T",NOTATION_PAWN:"",GENERAL_INVITE:'Danke f\u00fcr den Einsatz von <span style="font-weight:bold">{0}</span>.',MYGAMES_INVITE:'Danke f\u00fcr den Einsatz von <span style="font-weight:bold">ChessBase MyGames</span>, ihrer pers\u00f6nlichen Schachdatenbank im Web.',
3048MYGAMES_FUNCTIONALITY:"Mit Ihrem ChessBase Account k\u00f6nnen Sie Clouddatenbanken f\u00fcr Schachpartien anlegen und verwalten. Diese Clouddatenbanken stehen auch unter ChessBase 13 zur Verf\u00fcgung.",ECO:"ECO",BACK:"Zur\u00fcck",NEXT_MOVE:"N\u00e4chster Zug",PREV_MOVE:"Vorheriger Zug",NEXT_GAME:"N\u00e4chste Partie",PREV_GAME:"Vorherige Partie",MENU_VIDEO_TOOL:"Videotraining",MENU_OPENINGS_TOOL:"Er\u00f6ffnungen verwalten",REQUESTING_MOVES:"Z\u00fcge anfordern",FRESH_POSITION:"Frische Stellung",
3049EMBED:"Teilen",HELP:"Hilfe",TOGGLE_3D_2D:"2D/3D Brett umschalten",BOARD3D_BLACKWHITE:"Schwarzweiss",MATE:"Matt",STALEMATE:"Patt",SETUP_POSITION:"Stellung aufbauen",WHITE_MATES:"Weiss setzt Matt",WHITE_CLEARLY_WINNING:"Weiss steht v\u00f6llig auf Gewinn",WHITE_WINNING:"Weiss steht auf Gewinn",WHITE_DECISIVE:"Weiss hat gro\u00dfen Vorteil",WHITE_CLEARLY_BETTER:"Weiss steht deutlich besser",WHITE_BETTER:"Weiss steht besser",WHITE_SLIGHTLY:"Weiss steht etwas besser",WHITE_EDGE:"Weiss steht minimal besser",
3050BLACK_MATES:"Schwarz setzt Matt",BLACK_CLEARLY_WINNING:"Schwarz steht v\u00f6llig auf Gewinn",BLACK_WINNING:"Schwarz steht auf Gewinn",BLACK_DECISIVE:"Schwarz hat gro\u00dfen Vorteil",BLACK_CLEARLY_BETTER:"Schwarz steht deutlich besser",BLACK_BETTER:"Schwarz steht besser",BLACK_SLIGHTLY:"Schwarz steht etwas besser",BLACK_EDGE:"Schwarz steht minimal besser",EQUAL_POS:"Die Stellung ist ausgeglichen",PREMIUM_ONLY:"Nur bei Premium",BOARD3D_CHARACTER:"Avatar",CALC_TRAINING:"Rechentraining",TTIP_CALC_TRAINING:"Berechnen Sie beliebige (gepr\u00fcfte) Varianten bevor Sie die Partie hier fortsetzen.",
3051CALC_INFO:"F\u00fchren Sie Z\u00fcge blind aus. Klicken Sie in die Notation, um Varianten hinzuzuf\u00fcgen. Rechtsklick zeigt wahre Stellung. Klick auf 'Rechentraining' setzt die Partie fort.",CALCULATING:"Rechne...",WOOD:"Holz",TRAINING_SOLUTION:"L\u00f6sung zeigen",TRAINING_HELP:"Hilfestellung",TRAINING_QUESTION:"Finde den richtigen Zug",UNANNOTATE:"Entkommentieren",MORE_LINES:"Mehr Varianten",LESS_LINES:"Weniger Varianten",CALCULATE_THREAT:"Drohung berechnen",START_RADIO:"Start",PAUSE_RADIO:"Pause",
3052CURRENTLY_NO_LIVE_BROADCAST:"Im Augenblick l\u00e4uft keine Live\u00fcbertragung",CONNECTED_TO_SERVER:"Verbunden: {0}",INITIALIZING:"Initialisiere",INSERT_DIAGRAM:"Diagramm einf\u00fcgen",BOARD:"Brett",LOADING_BOARD:"Brett wird geladen, eine Sekunde...",LIKE:"Like",DB_NOGAMES_FOUND:"Keine Partien mit diesem Suchtext und diesem Brett.",YOUR_KING_ACC:"Deinen K\u00f6nig",YOUR_QUEEN_ACC:"Deine Dame",YOUR_ROOK_ACC:"Deinen Turm",YOUR_BISHOP_ACC:"Deinen L\u00e4ufer",YOUR_KNIGHT_ACC:"Deinen Springer",YOUR_PAWN_ACC:"Deinen Bauern",
3053MOVE_IMP:"Ziehe",WHITES_MOVE:"Wei\u00df am Zug",BLACKS_MOVE:"Schwarz am Zug",CLICK_TO_FLIP_BOARD:"Klicke hier, um das brett zu drehen",MAXIMIZE:"Maximieren",PIECES:"Figuren",SOUND_ONOFF:"Ton An/Aus",GOTO_BEGIN:"Gehe zur Anfangsstellung",GOTO_END:"Gehe zur Endstellung",LOAD_PREV:"Vorherigen Zug",LOAD_NEXT:"N\u00e4chsten Zug",SEARCH_MATERIAL:"Search Material",JOIN_WITH_VIDEO:"Join with Video",JOIN_WITH_AUDIO:"Join with Audio",AUDIO_VIDEO_REQUIRES_SECURED_CONNECTION:"Using video and audio requires a secure connection",
3054REACHED_DAILY_LIMIT:"You reached your daily limit",PLEASE_ATTACH_VIDEO_OR_AUDIO_RECORDING_DEVICE:"Please attach video or audio recording device",REPORT:"Report",SERVER_LOGGED_YOU_OFF:"Server hat Verbindung getrennt:",DOUBLE_LOGIN:"Woanders neu angemeldet",PLEASE_CHECK_CONNECTION:"Bitte Internetverbindung pr\u00fcfen.",START_ANALYSIS:"Starte Analyse",VARIATIONS:"Varianten",ENGINE_STOPPED:"Engine angehalten",SAVE_AS_PGN:"Speichere als PGN",SETUP_AND_SAVE:"Setup/Speichern",A_QUEEN_ACC:"eine Dame",A_KNIGHT_ACC:"einen Springer",
3055A_BISHOP_ACC:"einen L\u00e4ufer",A_ROOK_ACC:"einen Turm",A_PAWN_ACC:"einen Bauern",LOGGED_IN:"Angemeldet",TECHNICAL:"Technisch",CALM:"Ruhig",NORMAL:"Normal",EXCITING:"Spannungsvoll",SHARP:"Scharf",VERY_SHARP:"Sehr scharf",BOARD_ON_FIRE:"Brett brennt",HINTS_ONLY:"Nur Tipps",NEXT_HINT:"N\u00e4chster Tipp",BIG_BOARD:"Gro\u00dfes Brett",BIG_NOTATION:"Gro\u00dfe Notation",TWO_BOARDS:"Zwei Bretter",FOUR_BOARDS:"Vier Bretter",HOME:"Hauptseite",SHARE_BOARD:"Brett teilen",SETTINGS:"Einstellungen",SHARE:"Teilen",
3056SHARE_BOARD_USER:"Brett teilen - konfigurierbar",LAYOUT:"Layout",BOARDS_SAME_SIZE:"Bretter gleiche Gr\u00f6\u00dfe",LAYOUT_SETTINGS:"Layout einstellen",SWIPED_LAYOUT:"Notation/Liste wischen",SPLITTED_LAYOUT:"Geteilte Fenster",FONT_SIZE:"Schriftgr\u00f6\u00dfe Notation",READING_MODE:"Lesemodus",FLOAT_BOARD_HELP:"Verschieben/vergr\u00f6\u00dfern m\u00f6glich",DOWNLOAD:"Herunterladen",SHARE_PLAYABLE:"Brett spielbar teilen",PASTE_PGN:"PGN einf\u00fcgen",SHARE_GIF:"Partie als GIF teilen",SIZE:"Gr\u00f6\u00dfe",
3057DELAY:"Verz\u00f6gerung",PLAYERS:"Spieler einblenden",TITLE:"Titel",OPEN:"\u00d6ffnen",NEW:"Neu",DESCRIPTION:"Beschreibung",USE_THINK_TIMES:"Bedenkzeit nutzen",GREY:"Grau",LINK_TO_THIS_GAME:"Link zu dieser Partie",SELECT_GAMES:"Partien ausw\u00e4hlen",SHOW_SELECTED_GAMES:"Ausgew\u00e4hlte Partien laden",ENG_BELOW_NOTA:"Engine unter Notation",CORRECT_MOVE:"Richtig!",TRY_AGAIN:"Bitte nochmal versuchen!"};namespace("Loc.Chess.GER");Loc.Chess.GER=Chess_de;"use strict";
3058var Chess_es={LOGIN:"Conectar",LOGOUT:"Cerrar sesi\u00f3n",ACCOUNT:"Mi cuenta",BOARDS:"Tablero",RECONNECT:"Reconectar",RESIGN:"Rendirse",CLOSE_BOARD:"Cerrar tablero",OFFER_DRAW:"Ofrecer tablas",ACCEPT_DRAW:"Aceptar tablas",ACCEPTED_DRAW:"{0} acept\u00f3 tablas.",OFFERS_DRAW:"{0} ofrece tablas.",ACCEPTS_DRAW:"{0} acepta tablas.",RESIGNS:"{0} se rinde.",TESTING_CONN:"Probando la conexi\u00f3n con el servidor",CONNECTING:"Conectando con el servidor, por favor espere...",RECONNECTED_OK:"Reconectado",
3059NAME:"Nombre",NATION:"Pa\u00eds",RANK:"Rango",WHITE:"Blancas",BLACK:"Negras",ELO_WHITE:"Elo blancas",ELO_BLACK:"Elo negras",RESULT:"Resultado",TIME_CONTROL:"
3059Control de tiempo",TOURNAMENT:"Torneo",GAMES:"Partidas",CHAT:"Charla",CHAT_PARTNER_GONE:"Su interlocutor se ha ido.",CONNECTION:"Conexi\u00f3n",MAP:"Mapa",KING:"Rey",QUEEN:"Dama",ROOK:"Torre",BISHOP:"Alfil",KNIGHT:"Caballo",PAWN:"Pe\u00f3n",TYPE_CHAT_HERE:"Escriba aqu\u00ed la charla",TYPE_HERE_TO_CHAT_WITH:"Escriba aqu\u00ed con quien quiere charlar",
3060GUEST:"Invitado",CONFIRM:"Confirmar",CANCEL:"Cancelar",CLOCK:"Reloj",TIME:"Tiempo",GAIN_PER_MOVE:"Incr. por mov.",CLOSE:"Cerrar",ADD:"A\u00f1adir",REMOVE:"Quitar",NOTATION:"Notaci\u00f3n",BOARD_FRITZ:"Fritz",BOARD_CRYSTALS:"Crystals",BOARD_USCF:"USCF",BOARD_OLDSTYLE:"OldStyle",BOARD_HABSBURG:"Habsburg",BOARD_FRITZ_AND_CHESTER:"Fritz & Chesster",PLAY_BLITZ:"Jugar blitz",NEW_GAME:"Nueva partida",TAKE_BACK:"Retroceder",MAKE_MOVE:"Jugar",FLIP_BOARD:"Girar tablero",COPY:"Copiar",SEARCH_BOARD:"Buscar tablero",
3061YEAR:"A\u00f1o",BOOK:"Libro",LIVE_BOOK:"Live Book",MOVE:"Jugada",NR_GAMES:"Partidas",SCORE:"Marcador",LAST_PLAYED:"\u00daltima vez",ELO_AVG:"Elo medio",VISITS:"Visitas",LOADING_STATISTICS:"Cargando estad\u00edsticas",LETS_CHECK:"Let's Check",EVAL:"Eval.",VARIATION:"Variante",DEPTH:"Prof.",ENGINE:"M\u00f3dulo",ENTER_YOUR_SEARCH_TEXT:"Escriba el texto a buscar...",RETRIEVING_GAMES:"Obtener partidas",PLAYER_DETAILS:"Datos del jugador",PLAYER_INFORMATION:"Informaci\u00f3n del jugador",FIRST_NAME:"Nombre",
3062LAST_NAME:"Apellidos",YEAR_OF_BIRTH:"Nacido en",TREND:"Tendencia",RATING:"Elo",SEND_FEEDBACK:"Enviar comentario",YOUR_COMMENT:"Su comentario",YOUR_EMAIL_ADDRESS:"Su e-mail",SEND:"Enviado",BROWSER_DOESNT_SUPPORT_3D:"El navegador no admite tableros 3D",BOARD3D_FRITZ:"Fritz",BOARD3D_MODERN:"Moderno",BOARD3D_ROOM:"Habitaci\u00f3n",BOARD3D_BALLOON:"Globos",BOARD3D_METAL:"Metal",BOARD3D_SILVER:"Plata",BOARD3D_FUTURE:"Futuro",BOARD3D_MARBLE:"M\u00e1rmol",WELCOME:"Bienvenido",MATERIAL:"Material",ANALYSIS:"An\u00e1lisis",
3063ANALYSIS_ENGINE:"M\u00f3dulo",ENG_SEARCH_INFO_FMT:"Prof {0}/{1}, {2}kPos/s, tiempo = {3}s",PASTE:"Pegar",PW_INVALID:"Usuario/Contrase\u00f1a no v\u00e1lido. Por favor, vuelva a intentarlo",PLEASE_LOGIN:"Por favor conecte con su cuenta ChessBase (Playchess):",ACCOUNTNAME:"Nombre",PASSWORD:"Contrase\u00f1a",CREATE_ACCOUNT:"Crear cuenta",LOGIN_GUEST:"Invitado",PLEASE_LOGIN_SHORT:"Por favor, identif\u00edquese",LOADING_ENGINE:"Cargando m\u00f3dulo...",LOADING_LIVE_GAMES:"Cargando partidas en directo...",
3064INVITING_OTHER_PLAYERS:"Invitando a otros jugadores a una partida de {0} ({1})",OTHER_TOOLS:"M\u00e1s herramientas",DATABASES:"Bases de datos",OPEN_DATABASE:"Abrir base",CREATE_DATABASE:"Crear base",DELETE_DATABASE:"Borrar base",DELETE:"Borrar",CLEAN_UP:"Limpiar",MY_DATABASES:"Mis bases",DATABASES_SHARED_WITH_ME:"Bases compartidas conmigo",SELECT_DATABASE_FOR_USER:"Seleccionar base para '{0}'",OPEN_PGN:"Abrir PGN",SAVE:"Guardar",SAVE_AND_REPLACE_GAMES:"Guardar y reemplazar partidas",SAVE_AS_NEW:"Guardar como nueva",
3065EDIT_GAME:"Editar partida",DATABASE_FUNCTIONS:"Abrir, crear y y borrar bases",TEXT_BEFORE:"Texto antes",TEXT_AFTER:"Texto despu\u00e9s",START_LINE:"Iniciar l\u00ednea",PROMOTE_LINE:"Promocionar l\u00ednea",DELETE_LINE:"Borrar l\u00ednea",CUT_LINE:"Cortar l\u00ednea",OPEN_PGN_TIP:"Abrir un archivo PGN de su equipo",TEXT_BEFORE_TIP:"A\u00f1adir comentario en forma de texto antes de esta jugada",TEXT_AFTER_TIP:" A\u00f1adir comentario en forma de texto tras esta jugada",START_LINE_TIP:"Retroceder la jugada y comenzar una variante",
3066PROMOTE_LINE_TIP:"Subir de nivel la variante seleccionada",DELETE_LINE_TIP:"Borrar la variante seleccionada",CUT_LINE_TIP:"Truncar la variante",STAY_LOGGED_IN:"Seguir conectado",FORGOT_PASSWORD:"Contrase\u00f1a olvidada",CHANGE_PASSWORD:"Cambiar contrase\u00f1a",OLD_PASSWORD:"Contrase\u00f1a antigua",NEW_PASSWORD:"Contrase\u00f1a nueva",CONFIRM_PASSWORD:"Confirmar contrase\u00f1a",MENU_PLAYCHESS_TOOL:"Playchess",MENU_DATABASE_TOOL:"Live Database",MENU_MYGAMES_TOOL:"My Games Cloud",MENU_FRITZ_TOOL:"Fritz Online",
3067MENU_FRITZ_CHESSTER_TOOL:"Chess For Kids",MENU_TACTICS_TOOL:"Tactics Training",LANGUAGE:"Idioma",LOGIN_CREATE_LINK:"Haga clic aqu\u00ed para crear una cuenta",LOGIN_PLEASE_LOGIN:"Por favor identif\u00edquese",LOGIN_ACCOUNT_FREE:"La creaci\u00f3n de una cuenta es gratis. La cuenta vale para todas las dem\u00e1s herramientas web de ChessBase y para jugar en www.playchess.com.",LOGIN_WELCOME:"Bienvenido {0}",MANAGE_FRIENDS:"Gestionar amigos",INVITE_FRIEND:"Invitar a un amigo",PING:"Ping",NOTATION_KING:"R",
3068NOTATION_QUEEN:"D",NOTATION_KNIGHT:"C",NOTATION_BISHOP:"A",NOTATION_ROOK:"T",NOTATION_PAWN:"P",GENERAL_INVITE:"Gracias por usar {0}.",MYGAMES_INVITE:"Gracias por usar ChessBase MyGames, su base de datos de ajedrez personal en la web.",MYGAMES_FUNCTIONALITY:"Por favor con\u00e9ctese con su cuenta ChessBase para tener acceso a sus bases de datos en la nube. Tambi\u00e9n puede usar las bases de datos en la nube con ChessBase 13.",ECO:"ECO",BACK:"Volver",NEXT_MOVE:"Siguiente jug.",PREV_MOVE:"Anterior jug.",
3069NEXT_GAME:"Siguiente part.",PREV_GAME:"Anterior part.",MENU_VIDEO_TOOL:"V\u00eddeos de entrenamiento",MENU_OPENINGS_TOOL:"Gestionar aperturas",REQUESTING_MOVES:"Requesting Moves",FRESH_POSITION:"Fresh Position",EMBED:"Embed",HELP:"Help",TOGGLE_3D_2D:"Toggle 2D/3D Board",BOARD3D_BLACKWHITE:"Black 
3069white",MATE:"Mate",STALEMATE:"Ahogado",SETUP_POSITION:"Armar posici\u00f3n",WHITE_MATES:"Las blancas dan mate",WHITE_CLEARLY_WINNING:"Las blancas tienen clara ventaja ganadora",WHITE_WINNING:"Las blancas tienen ventaja ganadora",
3070WHITE_DECISIVE:"Las blancas tienen ventaja decisiva",WHITE_CLEARLY_BETTER:"Las blancas est\u00e1n claramente mejor",WHITE_BETTER:"Las blancas est\u00e1n mejor",WHITE_SLIGHTLY:"Las blancas est\u00e1n un poco mejor",WHITE_EDGE:"Las blancas tienen una ventaja m\u00ednima",BLACK_MATES:"Las negras dan mate",BLACK_CLEARLY_WINNING:"Las negras tienen clara ventaja ganadora",BLACK_WINNING:"Las negras tienen ventaja ganadora",BLACK_DECISIVE:"Las negras tienen ventaja decisiva",BLACK_CLEARLY_BETTER:"Las negras est\u00e1n claramente mejor",
3071BLACK_BETTER:"Las negras est\u00e1n mejor",BLACK_SLIGHTLY:"Las negras est\u00e1n un poco mejor",BLACK_EDGE:"Las negras tienen una ventaja m\u00ednima",EQUAL_POS:"La posici\u00f3n est\u00e1 igualada",PREMIUM_ONLY:"S\u00f3lo premium",BOARD3D_CHARACTER:"Avatar",CALC_TRAINING:"Entrenar c\u00e1lculo",TTIP_CALC_TRAINING:"Calcular variantes con la ayuda de Fritz antes de continuar la partida aqu\u00ed.",CALC_INFO:"Ejecute jugadas a la ciega. Haga clic en la notaci\u00f3n para a\u00f1adir variantes. Haga clic en 'Entrenar c\u00e1lculo' para reanudar la partida.",
3072CALCULATING:"Calculando...",WOOD:"Madera",TRAINING_SOLUTION:"Ver soluci\u00f3n",TRAINING_HELP:"Ayuda",TRAINING_QUESTION:"Encontrar la jugada correcta",UNANNOTATE:"Desanotar",MORE_LINES:"M\u00e1s l\u00edneas",LESS_LINES:"Menos l\u00edneas",CALCULATE_THREAT:"Calcular amenaza",START_RADIO:"Start",PAUSE_RADIO:"Pause",CURRENTLY_NO_LIVE_BROADCAST:"En ese momento, no hay una transmisi\u00f3n",CONNECTED_TO_SERVER:"Conectado al servidor: {0}",INITIALIZING:"Inicializando",INSERT_DIAGRAM:"Insertar diagrama",
3073BOARD:"Tablero",LOADING_BOARD:"Cargando tablero, solo un segundo...",LIKE:"Me gusta",KING_ACC:"Rey",QUEEN_ACC:"Reina",KNIGHT_ACC:"Caballo",BISHOP_ACC:"Alfil",ROOK_ACC:"Torre",PAWN_ACC:"Pe\u00f3n",MOVE_IMP:"Jugada",WHITES_MOVE:"Jugada de las blancas",BLACKS_MOVE:"Jugada de las negras",CLICK_TO_FLIP_BOARD:"haz clic para voltear el tablero",MAXIMIZE:"Maximizar",PIECES:"Piezas",SOUND_ONOFF:"Sonido Encendido/Apagado",GOTO_BEGIN:"Ir al principio",GOTO_END:"Ir al final",LOAD_PREV:"Cargar anterior",LOAD_NEXT:"Cargar siguiente",
3074SEARCH_MATERIAL:"Buscar material",JOIN_WITH_VIDEO:"Unirse con video",JOIN_WITH_AUDIO:"Unirse con audio",AUDIO_VIDEO_REQUIRES_SECURED_CONNECTION:"El uso de video y audio requiere una conexi\u00f3n segura",REACHED_DAILY_LIMIT:"Has alcanzado tu l\u00edmite diario",PLEASE_ATTACH_VIDEO_OR_AUDIO_RECORDING_DEVICE:"Por favor, conecta un dispositivo de grabaci\u00f3n de video o audio",REPORT:"Reportar",SERVER_LOGGED_YOU_OFF:"El servidor te desconect\u00f3:",DOUBLE_LOGIN:"Doble inicio de sesi\u00f3n",PLEASE_CHECK_CONNECTION:"Por favor, revisa tu conexi\u00f3n",
3075A_QUEEN_ACC:"una reina",A_KNIGHT_ACC:"un caballo",A_BISHOP_ACC:"un alfil",A_ROOK_ACC:"una torre",A_PAWN_ACC:"un pe\u00f3n",LOGGED_IN:"Logged in",TECHNICAL:"T\u00e9cnico",CALM:"Tranquilo",NORMAL:"Normal",EXCITING:"Emocionante",SHARP:"Afilado",VERY_SHARP:"Muy afilado",BOARD_ON_FIRE:"Tablero en llamas",HINTS_ONLY:"Solo pistas"};namespace("Loc.Chess.ESP");Loc.Chess.ESP=Chess_es;"use strict";
3076var Reader_en={PRODUCT_IS_ACTIVATED:"Product is activated",PRODUCT_KEY_CONTAINS_5_BLOCKS:"A product key should contain 5 blocks of 5 characters",DOWNLOADING_FILES:"Downloading files",PLEASE_ACTIVATE_THIS_PRODUCT:"Please activate this product",SERVER_IS_IN_MAINTENANCE:"Server in Maintenance",PRODUCT_KEY_ALREADY_USED_BEFORE:"Product key Already used",PRODUCT_KEY_IS_DISABLED:"Product key disabled",PRODUCT_KEY_IS_INVALID:"Product key invalid",PRODUCT_KEY_ALREADY_ACTIVATED:"Product key is already activated",
3077PRODUCT_KEY_NOT_VALID_FOR_THIS_PRODUCT:"Product key not valid for this product",DEACTIVATE_THIS_PRODUCT:"Deactivate this product",PRODUCT_IS_DEACTIVATED:"Product is deactivated",LAST_BLOCK_SHOULD_CONTAIN_DATA:"Last block should contain 'DATA'",YOUR_SYSTEMS_CONFIGURATION_HAS_CHANGED:"Your Systems configuration has changed",SEND_YOUR_FEEDBACK:"Send your feedback",DOWNLOAD_STARTED:"Download started",PLEASE_WAIT:"Please wait",CLICK_ENGINE_TO_ANALYSE:"You can click on the Engine button to Analyse the position",
3078AUTOPLAY:"Autoplay (Ctrl, Shift and/or Alt-key when clicking changes time)",DOWNLOAD_PGN:"Download PGN",MORE_LINES:"More Lines",LESS_LINES:"Less Lines",PRODUCT_KEY:"Product Key",MESSAGE:"Message",SUBJECT:"Subject"};namespace("Loc.Reader.ENG");Loc.Reader.ENG=Reader_en;"use strict";
3079var Reader_de={PRODUCT_IS_ACTIVATED:"Aktiviert",PRODUCT_KEY_CONTAINS_5_BLOCKS:"Der Aktivierungsschl\u00fcssel besteht aus 5 Blocken \u00e0 5 Zeichen",DOWNLOADING_FILES:"Lade Dateien herunter",PLEASE_ACTIVATE_THIS_PRODUCT:"Bitte aktivieren Sie dieses Produkt",SERVER_IS_IN_MAINTENANCE:"Zur Zeit sind Serverwartungsarbeiten im Gange, bitte versuchen Sie es sp\u00e4ter noch ein Mal",PRODUCT_KEY_ALREADY_USED_BEFORE:"Der Aktivierungsschl\u00fcssel wurde bereits verwendet",PRODUCT_KEY_IS_DISABLED:"Der Aktivierungsschl\u00fcssel wurde gesperrt",
3080PRODUCT_KEY_IS_INVALID:"Der Aktivierungsschl\u00fcssel ist ung\u00fcltig",PRODUCT_KEY_ALREADY_ACTIVATED:"Der Aktivierungsschl\u00fcssel wurde bereits aktiviert",PRODUCT_KEY_NOT_VALID_FOR_THIS_PRODUCT:"Der Aktivierungsschl\u00fcssel passt nicht f\u00fcr dieses Produkt",DEACTIVATE_THIS_PRODUCT:"Deaktiviere dieses Produkt ",PRODUCT_IS_DEACTIVATED:"Das Produkt ist deaktiviert ",LAST_BLOCK_SHOULD_CONTAIN_DATA:"Der letzte Block sollte 'DATA' beinhalten",YOUR_SYSTEMS_CONFIGURATION_HAS_CHANGED:"Ihre Systemkonfiguration hat sich ver\u00e4ndert ",
3081SEND_YOUR_FEEDBACK:"Schicken Sie uns Feedback",DOWNLOAD_STARTED:"Download startet",PLEASE_WAIT:"Bitte warten",CLICK_ENGINE_TO_ANALYSE:"Sie k\u00f6nnen auf den Engineknopf dr\u00fccken um die Brettstellung zu analysieren",AUTOPLAY:"Partie vorf\u00fchren",DOWNLOAD_PGN:"PGN Herunterladen",MORE_LINES:"Mehr Varianten",LESS_LINES:"Weniger Varianten",PRODUCT_KEY:"Aktivierungsschl\u00fcssel",MESSAGE:"Nachricht",SUBJECT:"Betreff"};namespace("Loc.Reader.GER");Loc.Reader.GER=Reader_de;"use strict";
3082var Reader_es={PRODUCT_IS_ACTIVATED:"Product is activated",PRODUCT_KEY_CONTAINS_5_BLOCKS:"A product key should contain 5 blocks of 5 characters",DOWNLOADING_FILES:"Downloading files",PLEASE_ACTIVATE_THIS_PRODUCT:"Please activate this product",SERVER_IS_IN_MAINTENANCE:"Server in Maintenance",PRODUCT_KEY_ALREADY_USED_BEFORE:"Product key Already used",PRODUCT_KEY_IS_DISABLED:"Product key disabled",PRODUCT_KEY_IS_INVALID:"Product key invalid",PRODUCT_KEY_ALREADY_ACTIVATED:"Product key is already activated",
3083PRODUCT_KEY_NOT_VALID_FOR_THIS_PRODUCT:"Product key not valid for this product",DEACTIVATE_THIS_PRODUCT:"Deactivate this product",PRODUCT_IS_DEACTIVATED:"Product is deactivated",LAST_BLOCK_SHOULD_CONTAIN_DATA:"Last block should contain 'DATA'",YOUR_SYSTEMS_CONFIGURATION_HAS_CHANGED:"Your Systems configuration has changed",SEND_YOUR_FEEDBACK:"Send your feedback",DOWNLOAD_STARTED:"Download started",PLEASE_WAIT:"Please wait",CLICK_ENGINE_TO_ANALYSE:"You can click on the Engine button to Analyse the position",
3084AUTOPLAY:"Autoplay (Ctrl, Shift and/or Alt-key when clicking changes time)",DOWNLOAD_PGN:"Download PGN",MORE_LINES:"More Lines",LESS_LINES:"Less Lines",PRODUCT_KEY:"Product Key",MESSAGE:"Message",SUBJECT:"Subject"};namespace("Loc.Reader.ESP");Loc.Reader.ESP=Reader_es;"use strict";
3085var Training_en={DIFFICULTY:"Difficulty:",POSITIONS_SOLVED:"Positions Solved:",YOUR_RATING:"Your Rating:",YOUR_RANK:"Your Rank:",NEW_RANK:"NEW RANK:",RANKING_LISTS:"Ranking Lists",NEXT_POSITION:"Next Position",TTIP_NEXT_POSITION:"Next Position - loses Elo if no solution has been entered",HINT:"Hint",TTIP_HINT:"Click For Next Hint",SOLUTION:"Solution",TTIP_SOLUTION:"Show Solution (deducts Elo)",CRITICISE_POSITION:"Criticise Position",TTIP_CRITICISE_POSITION:"Send critical feedback about this position",
3086LIKE_POSITION:"Like Position",TTIP_LIKE_POSITION:"Say that you liked this position",CAPTURE_SOMETHING:"Capture something.",GIVE_CHECK:"Give a check.",MATE_IN_ONE:"Mate in One!",STALEMATE:"Stalemate",THREATEN_MATE:"Threaten mate.",RECAPTURE_MATERIAL:"Recapture material.",DOUBLE_ATTACK:"Double Attack",DISCOVERED_ATTACK:"Discovered Attack",PINNING:"Pinning",DEFLECTION:"Deflection",DECOY:"Decoy",INTERCEPTION:"Interception",ANNIHILATION:"Annihilation",CLEARANCE:"Clearance",BLOCKADE:"Blockade",XRAY:"X-Ray Attack",
3087OVERLOADING:"Overloading",PAWN_BREAK:"Pawn Break",PASSED_PAWN:"Passed Pawn",PROMOTION:"Promotion",DEMOLITION:"Demolition",PURSUIT:"Pursuit",MATE_ATTACK:"Mate Attack",MATE_THREAT:"Mate Threat",SKEWER:"Skewer",THREAT:"Threat",PIN:"Pin",FORK:"Fork",SACRIFICE_SOMETHING:"Sacrifice something.",BACKRANK:"Weak Back Rank",ATTACK_THE_QUEEN:"Attack the queen.",ATTACK_A_ROOK:"Attack a rook.",THREATEN_PAWN_WIN:"Threaten to win a pawn.",THREATEN_TO_WIN_MATERIAL:"Threaten to win material.",OVERWORKED_PIECE:"Overworked piece",
3088EVADE_AN_ATTACK:"Evade an attack",COVER_A_PIECE:"Cover a piece",MATERIAL:"Material",OPPONENT_MOVES:"Opponent moves...",TOMOVE_AND_DRAW:"to move and draw.",TOMOVE_AND_WIN:"to move and win.",SOLVED:"Solved!",FINISH_MATE:"Mate!",FINISH_STALEMATE:"Stalemate!",CLICK_NEXT_POS:"Click 'Next Position' to continue...",CONTINUE:"Continue...",CONTINUE_ENTER_NEXT:"Continue... please enter the next move.",NO_HINTS:"No Hints available.",FIND_MATE:"Find the mate!",PLEASE_TRY_AGAIN:"Not the strongest move.",MAINTENANCE_LOGOFF:"Sorry, the server is now shutting down for maintenance, please try again in ten minutes. Your rating will be fine. Thank you!",
3089CLICK_NEXT_TO_START:"Click 'Next Position' to start",FEEDBACK_POSITION:"Send Feedback to ChessBase about this position:",SEEN_N_TIMES:"Seen {0} times before. Hints = {1}",NOT_SEEN_BEFORE:"Not seen before. Hints = {0}",N_HINTS:"Hints = {0}",LOGIN_INVITE:'Thank you for using <span style="font-weight:bold">ChessBase Training</span>. Play stronger by practising chess tactics!',LOGIN_FUNCTIONALITY:"Please login with your ChessBase Account to use 44000 tactical positions. As guest you are limited to 300 easy positions. Well suited to warm you up.",
3090FRIENDS_RANKING:"Friends Ranking",TTIP_FRIENDS_RANKING:"Compare your score with your friends",WAITING_FOR_POSITION:"Waiting for Position...",WAITING_FOR_HINT:"Waiting for Hint...",WAITING_FOR_SOLUTION:"Waiting for Solution...",LEVEL_RIDICULOUS:"Ridiculous",LEVEL_TRIVIAL:"Trivial",LEVEL_VERY_EASY:"Very easy",LEVEL_EASY:"Easy",LEVEL_NOT_EASY:"Not so easy",LEVEL_NEEDS_THINK:"Needs a think",LEVEL_MEDIUM:"Medium",LEVEL_INTERESTING:"Interesting",LEVEL_CHALLENGING:"Challenging",LEVEL_TOUGH:"Tough",LEVEL_DIFFICULT:"Difficult",
3091LEVEL_VERY_DIFFICULT:"Very difficult",LEVEL_MASTER_LEVEL:"Master level",LEVEL_NIGHTMARE:"Nightmare",CAN_ONLY_ANALYSE_SOLVED:"Can only anal
3091yse a solved position.",HTML_DESCRIPTION:"Solve tactical positions and get stronger in chess.",SOLVE_TACTICS:"Solve Tactics",PLAY_TACTICS_FIGHT:"Start A Tactics Fight!",WAITING_SEEKS:"Waiting:",SOLVE_EXPLAIN_1:"Improve your calculation skills",SOLVE_EXPLAIN_2:"Solve tactical positions fitting your playing strength.",SOLVE_EXPLAIN_3:"Get constructive hints if you are stuck. No time pressure.",
3092SOLVE_EXPLAIN_4:"Replay the solution and analyse with an engine.",FIGHT_EXPLAIN_1:"Play a match of max 24 positions against another user.",FIGHT_EXPLAIN_2:"If you solve a position first, you score a point.",FIGHT_EXPLAIN_3:"If you enter the wrong solution, your opponent scores a point. The first player to reach 12.5 points wins.",FIGHT_EXPLAIN_4:"If nobody enters a move within 60 seconds, both players get 0.5 points.",START_SOLVING:"Start Solving",START_FIGHT:"Seek Fight",CLICK_START_TO_BE_FIRST:"Click 'Seek Fight' to invite others.",
3093CANCEL_WAIT:"Cancel Invitation",REQUEST_SENT:"Invitation Sent",TTIP_START_FIGHT:"Click to find an opponent for a tactics fight of 24 positions.",END_OF_FIGHT:"End Of Fight.",YOU_WON:"You Won",NEW_ELO:"New Elo:",TIMEOUT_NEXT_POSITION:"TIMEOUT - Next position...",FIGHT_STARTED:"Fight Started",WON_VERB:"won",SOLVED_BY:" Solved by",WRONG_MOVE_BY:" Wrong move by",WAITING_FOR_OPPONENT:"Waiting for an opponent...",ABORTED:"Aborted",DRAW:"Draw",XY_RESIGNED:"resigned",XY_OFFERED_REMATCH:"offered a rematch",
3094PRESS_REMATCH_TO_ACCEPT:"Press 'Rematch' to accept the rematch offer",PLAYER_NOT_ONLINE:"Player not online",CHALLENGE_PLAYER:"Challenge Player",TTIP_CHALLENGE_FIGHT:"Enter the account name of a friend for a tactics fight",TTIP_SOLVING_TO_MAIN:"Stop Solving and return to the main screen",CLOSE_FIGHT_BOARD:"Close Fight Board",TTIP_CLOSE_FIGHT:"Close the fight board and return to normal solving",RESIGN_FIGHT:"Resign Fight",TTIP_RESIGN_FIGHT:"Click resign and stop the fight",REMATCH:"Rematch",TTIP_REMATCH:"Offer or accept a rematch",
3095REMATCH_OFFER_SENT:"Rematch Offer Sent",FIGHT_EXPLAIN_5:"If you kibitz a fight, you may also enter the solutions. A good training.",KIBITZ_FIGHT:"Kibitz Fight",TTIP_KIBITZ_FIGHT:"Kibitz a Tactics Fight",RADAR_BOARD_HINT:"Final position will show here if all hints used up:",CLICK_FOR_HINT:"Every click here will show another (and more direct) hint",CORRECT:"Correct",WRONG:"Wrong",MOVE_IMP:"Move",TO_A_LIGHT_SQUARE:"to a light square.",TO_A_DARK_SQUARE:"to a dark square.",VERTICALLY:"vertically",HORIZONTALLY:"horizontally.",
3096DIAGONALLY:"diagonally",ADVANCE_FORMAT:"Advance {0}",RETREAT_FORMAT:"Retreat {0}",CENTRALIZE:"Centralize",MOVE_KING_SIDEWAYS:"Move your king sideways.",MOVE_YOUR_FILE_PAWN:"Move your {0}-pawn.",MAKE_PAWN_DOUBLE_STEP:"Make a double step with your pawn.",MOVE_CENTER_PAWN:"Move your center pawn.",MOVE_QSIDE_PAWN:"Move your pawn on the queens side.",MOVE_KSIDE_PAWN:"Move your pawn on the kings side.",MOVE_LIGHT_BISHOP:"Move your light squared bishop.",MOVE_DARK_BISHOP:"Move your dark squared bishop.",
3097RETREAT_BISHOP:"Retreat your bishop.",ADVANCE_BISHOP:"Advance your bishop.",DEVELOP_KSIDE:"Develop your king's side.",PREPARE_CASTLING:"Prepare to castle.",DEVELOP_QSIDE:"Develop your queen's side.",DEVELOP_QN:"Develop your queen's knight.",DEVELOP_KN:"Develop your king's knight.",CENTRALIZE_KNIGHT:"Centralize your knight.",ADVANCE_KNIGHT:"Advance your knight.",RETREAT_KNIGHT:"Retreat your knight.",MOVE_KNIGHT_SIDEWAYS:"Move your knight sideways.",ROOK_TO_OPEN_FILE:"Move your rook to an open file.",
3098ADVANCE_ROOK:"Advance your rook.",RETREAT_ROOK:"Retreat your rook.",MOVE_ROOK_VERTICALLY:"Move your rook vertically.",CENTRALIZE_ROOK:"Centralize your rook.",MOVE_ROOK_HORIZONTALLY:"Move your rook horizontally.",DOUBLE_ROOKS:"Double your rooks.",PREPARE_DOUBLE_ROOKS:"Prepare to double rooks.",CASTLE_IMP:"Castle.",PIN_IMP:"Pin something.",ATTACK_A_MINOR_PIECE:"Attack a minor piece.",RETREAT_A_PIECE:"Retreat a piece.",OPP_THREATENS_MATE:"Do not get mated!",OPP_THREATENS_QUEEN:"Watch your queen!",OPP_THREATENS_ROOK:"Your rook is in danger.",
3099OPP_THREATENS_MINOR:"A minor piece is attacked.",OPP_THREATENS_PAWN:"Your pawn is hanging.",MATE_IMP:"Find the mate!",EXCHANGE_IMP:"Exchange material.",CREATE_PASSED_PAWN:"Create a passed pawn.",PROMOTE_IMP:"Promote a pawn.",OFFER_EXCHANGE_IMP:"Offer to exchange a piece.",THREATEN_IMP:"Create a threat.",WATCH_OUT:"Watch out for a threat.",RED_ARROW_THREAT:"Red arrow = threat.",GREEN_ARROW_MOVE:"Green arrow = suggested move.",ATTACK_A_PAWN:"Attack a pawn",COVER_SOMETHING:"Cover something.",BLOCK_ATTACK:"Block an attack",
3100EVADE_ATTACK_IMP:"Evade an attack.",SAC_IMP:"Sacrifice",OPEN_ATTACK_FILE:"Open an attack file.",EVADE_CHECK:"Move your king out of check.",BLOCK_CHECK:"Block the check.",DOUBLE_ATTACK_IMP:"Find a double attack.",BRILLIANT:"Brilliant",SPLENDID:"Splendid",BEAUTIFUL:"Beautiful",POWERFUL:"Powerful",COOL:"Cool",EXCELLENT:"Excellent",THIS_IS_THE_WAY:"This is the way",SUPER:"Super",STRONG:"Strong",WELL_PLAYED:"Well played",FINE:"Fine",BRAVE:"Brave",SHARP:"Sharp",HOT_MOVE:"Hot move",TRICKY:"Tricky",ADVENTUROUS:"Adventurous",
3101NICE:"Nice",GOOD:"Good",RISKY:"Risky!?",GOOD_GAMBLE:"Good Gamble",NO_FEAR:"No fear",ON_THE_EDGE:"On the edge",EVADE_EXCHANGE_IMP:"Evade an exchange.",DOUBLE_ROOKS_7TH:"Two rooks on the seventh rank are strong.",ROOK_TO_HALFOPEN_FILE:"Move your rook to a half open file.",ONLY_MOVE:"Only one legal move.",WIN_MATERIAL:"Win material."};namespace("Loc.Training.ENG");Loc.Training.ENG=Training_en;"use strict";
3102var Training_de={DIFFICULTY:"H\u00e4rte:",POSITIONS_SOLVED:"Gel\u00f6st:",YOUR_RATING:"Ihre Wertung:",YOUR_RANK:"Ihr Rang:",NEW_RANK:"NEUER RANG:",RANKING_LISTS:"Ranglisten",NEXT_POSITION:"N\u00e4chste Stellung",TTIP_NEXT_POSITION:"N\u00e4chste Stellung aufrufen - Punktabzug, falls die aktuelle nicht gel\u00f6st wurde",HINT:"Tipp",TTIP_HINT:"Zeigt den n\u00e4chsten von m\u00f6glicherweise mehreren Tipps",SOLUTION:"L\u00f6sung",TTIP_SOLUTION:"Markiert L\u00f6sung auf dem Brett (Punktabzug)",CRITICISE_POSITION:"Stellung bem\u00e4ngeln",
3103TTIP_CRITICISE_POSITION:"Kritische R\u00fcckmeldung zu dieser Stellung schicken.",LIKE_POSITION:"Gef\u00e4llt mir",TTIP_LIKE_POSITION:"Klicken, falls Ihnen diese Aufgabe gef\u00e4llt",CAPTURE_SOMETHING:"Schlage etwas.",GIVE_CHECK:"Gib ein Schach.",MATE_IN_ONE:"Matt in Eins!",STALEMATE:"Patt",THREATEN_MATE:"Drohe Matt.",RECAPTURE_MATERIAL:"Schlage zur\u00fcck.",DOUBLE_ATTACK:"Doppelangriff",DISCOVERED_ATTACK:"Abzugsangriff",PINNING:"Fesselung",DEFLECTION:"Ablenkung",DECOY:"Hinlenkung",INTERCEPTION:"Verstellung",
3104ANNIHILATION:"Vernichtung Deckungsfigur",CLEARANCE:"R\u00e4umung",BLOCKADE:"Blockade",XRAY:"R\u00f6ntgenangriff",OVERLOADING:"\u00dcberlastung",PAWN_BREAK:"Durchbruch",PASSED_PAWN:"Freibauer",PROMOTION:"Umwandlung",DEMOLITION:"Zerst\u00f6rung Verteidiger",PURSUIT:"Verfolgung",MATE_ATTACK:"Mattangriff",MATE_THREAT:"Mattdrohung",SKEWER:"Spiess",THREAT:"Drohung",PIN:"Fesselung",FORK:"Gabel",SACRIFICE_SOMETHING:"Ein Opfer...",BACKRANK:"Schwache Grundreihe",ATTACK_THE_QUEEN:"Greife die Dame an.",ATTACK_A_ROOK:"Greife einen Turm an.",
3105THREATEN_PAWN_WIN:"Drohe einen Bauerngewinn.",THREATEN_TO_WIN_MATERIAL:"Drohe Materialgewinn.",EVADE_AN_ATTACK:"Eine angegriffene Figur zieht",COVER_A_PIECE:"Decke eine Figur",OVERWORKED_PIECE:"\u00dcberlastete Figur",MATERIAL:"Material",OPPONENT_MOVES:"Einleitender Zug...",TOMOVE_AND_DRAW:"zieht und h\u00e4lt Remis.",TOMOVE_AND_WIN:"zieht und gewinnt.",SOLVED:"Gel\u00f6st!",FINISH_MATE:"Matt!",FINISH_STALEMATE:"Patt!",CLICK_NEXT_POS:"Klick auf 'N\u00e4chste Stellung' f\u00e4hrt fort...",CONTINUE:"Fortsetzung...",
3106CONTINUE_ENTER_NEXT:"Fortsetzung... bitte geben Sie den n\u00e4chsten Zug ein.",NO_HINTS:"Keine Hilfestellungen verf\u00fcgbar.",FIND_MATE:"Finde das Matt!",PLEASE_TRY_AGAIN:"Nicht der st\u00e4rkste Zug.",MAINTENANCE_LOGOFF:"Entschuldigung, der Server wird gerade zu Wartungszwecken gestoppt. Bitte probieren Sie es in f\u00fcnfzehn Minuten wieder. Danke!",CLICK_NEXT_TO_START:"Klick auf 'N\u00e4chste Stellung' startet.",FEEDBACK_POSITION:"R\u00fcckmeldung zur Stellung an ChessBase senden:",SEEN_N_TIMES:"Bereits {0} Mal gesehen. Verf\u00fcgbare Hilfen = {1}",
3107NOT_SEEN_BEFORE:"Frische Stellung. Verf\u00fcgbare Hilfen = {0}",N_HINTS:"Hilfen = {0}",LOGIN_INVITE:'Danke f\u00fcr den Einsatz von <span style="font-weight:bold">ChessBase Training</span>. Schnell st\u00e4rker werden durch Taktiktraining!',LOGIN_FUNCTIONALITY:"Bitte loggen Sie sich mit Ihrem ChessBase Account ein, um mit 44000 Taktikstellungen zu trainieren. G\u00e4ste sind auf 300 leichte Stellungen beschr\u00e4nkt. Ideal zum Aufw\u00e4rmen.",FRIENDS_RANKING:"Friends Ranking",TTIP_FRIENDS_RANKING:"Compare your score with your friends",
3108WAITING_FOR_POSITION:"Warte auf Stellung...",WAITING_FOR_HINT:"Warte auf Hilfe...",WAITING_FOR_SOLUTION:"Warte auf L\u00f6sung...",LEVEL_RIDICULOUS:"Babyleicht",LEVEL_TRIVIAL:"Trivial",LEVEL_VERY_EASY:"Sehr leicht",LEVEL_EASY:"Leicht",LEVEL_NOT_EASY:"Nicht so leicht",LEVEL_NEEDS_THINK:"Etwas schwieriger",LEVEL_MEDIUM:"Mittel",LEVEL_INTERESTING:"Interessant",LEVEL_CHALLENGING:"Fordernd",LEVEL_TOUGH:"Hart",LEVEL_DIFFICULT:"Schwer",LEVEL_VERY_DIFFICULT:"Sehr schwer",LEVEL_MASTER_LEVEL:"Meisterklasse",
3109LEVEL_NIGHTMARE:"Albtraum",CAN_ONLY_ANALYSE_SOLVED:"Analyse erst nach L\u00f6sung der Stellung m\u00f6glich.",HTML_DESCRIPTION:"L\u00f6se Taktikstellungen und spiele st\u00e4rker Schach.",SOLVE_TACTICS:"Taktik l\u00f6sen",PLAY_TACTICS_FIGHT:"Einen Taktik-Fight spielen",WAITING_SEEKS:"Wartend:",SOLVE_EXPLAIN_1:"Verbessern Sie Ihre Variantenberechnungen.",SOLVE_EXPLAIN_2:"L\u00f6sen Sie Taktikstellungen, die zu Ihrer Spielst\u00e4rke passen.",SOLVE_EXPLAIN_3:"Mit 
3109konstruktiven Tipps. Kein Zeitdruck.",
3110SOLVE_EXPLAIN_4:"Analysieren Sie die L\u00f6sung mit der eingebauten Engine.",FIGHT_EXPLAIN_1:"Treten Sie zu einem Wettkampf gegen einen anderen Spieler an.",FIGHT_EXPLAIN_2:"Wer eine (leichte) Stellung als Erster l\u00f6st, erh\u00e4lt einen Punkt.",FIGHT_EXPLAIN_3:"Bei Eingabe einer falschen L\u00f6sung erh\u00e4lt der Gegner einen Punkt. Wer zuerst 12,5 Punkte hat, gewinnt.",FIGHT_EXPLAIN_4:"Wenn binnen 60 Sekunden niemand zieht, erhalten beide Spieler einen halben Punkt.",START_SOLVING:"Stellungen l\u00f6sen",
3111START_FIGHT:"Fight starten",CLICK_START_TO_BE_FIRST:"Klicken Sie auf 'Fight starten', um andere Spieler einzuladen.",CANCEL_WAIT:"Zur\u00fcckziehen",REQUEST_SENT:"Einladung unterwegs",TTIP_START_FIGHT:"Laden Sie anderen Spieler zu einem Taktik-Fight \u00fcber 24 Stellungen ein.",END_OF_FIGHT:"Ende des Fights.",YOU_WON:"Sie gewinnen",NEW_ELO:"Neue Wertung:",TIMEOUT_NEXT_POSITION:"TIMEOUT - N\u00e4chste Stellung...",FIGHT_STARTED:"Fight gestartet",WON_VERB:"gewinnt",SOLVED_BY:" Gel\u00f6st von",WRONG_MOVE_BY:" Falscher Zug von",
3112WAITING_FOR_OPPONENT:"Wartet auf einen Gegner...",ABORTED:"Abbruch",DRAW:"Remis",XY_RESIGNED:"hat aufgegeben",XY_OFFERED_REMATCH:"bietet Revanche an",PRESS_REMATCH_TO_ACCEPT:"Dr\u00fccken Sie 'Revanche', um das Angebot anzunehmen",PLAYER_NOT_ONLINE:"Spieler nicht online",CHALLENGE_PLAYER:"Spieler herausfordern",TTIP_CHALLENGE_FIGHT:"Geben Sie einen Accountnamen ein, um zum Taktikfight herauszufordern",TTIP_SOLVING_TO_MAIN:"Beenden Sie das L\u00f6sungen von Stellungen und kehren Sie zum Hauptschirm zur\u00fcck",
3113CLOSE_FIGHT_BOARD:"Fight Brett schlie\u00dfen",TTIP_CLOSE_FIGHT:"Schlie\u00dfen Sie das Brett f\u00fcr Taktikfights und kehren Sie zum Hauptschirm zur\u00fcck",RESIGN_FIGHT:"Fight aufgeben",TTIP_RESIGN_FIGHT:"Den laufenden Fight aufgeben (kostet Elo)",REMATCH:"Revanche",TTIP_REMATCH:"Eine Revanche anbieten bzw. annehmen",REMATCH_OFFER_SENT:"Revancheangebot abgesendet",FIGHT_EXPLAIN_5:"Wenn Sie einen Fight kiebitzen, k\u00f6nnen Sie selbst die L\u00f6sungen eingeben.",KIBITZ_FIGHT:"Fight kiebitzen",
3114TTIP_KIBITZ_FIGHT:"Bei einem Taktikfight zuschauen und selbst Z\u00fcge eingeben",RADAR_BOARD_HINT:"Wenn alle Hilfen verbraucht sind, erscheint hier die Schlussstellung:",CLICK_FOR_HINT:"Jeder Klick hier liefert eine neue, deutlichere Hilfestellung",CORRECT:"Richtig",WRONG:"Falsch",MOVE_IMP:"Ziehe",TO_A_LIGHT_SQUARE:"auf ein wei\u00dfes Feld.",TO_A_DARK_SQUARE:"auf ein schwarzes Feld.",VERTICALLY:"vertikal",HORIZONTALLY:"horizontal",DIAGONALLY:"diagonal",ADVANCE_FORMAT:"Aktiviere {0}.",RETREAT_FORMAT:"Ziehe {0} zur\u00fcck.",
3115CENTRALIZE:"Zentralisiere",MOVE_KING_SIDEWAYS:"Ziehe Deinen K\u00f6nig seitlich.",MOVE_YOUR_FILE_PAWN:"Ziehe Deinen {0}-Bauern.",MAKE_PAWN_DOUBLE_STEP:"Mache einen Doppelschritt mit einem Bauern.",MOVE_CENTER_PAWN:"Ziehe einen Zentrumsbauern.",MOVE_QSIDE_PAWN:"Ziehe einen Bauern am Damenfl\u00fcgel.",MOVE_KSIDE_PAWN:"Ziehe einen Bauern am K\u00f6nigsfl\u00fcgel.",MOVE_LIGHT_BISHOP:"Ziehe Deinen wei\u00dffeldrigen L\u00e4ufer.",MOVE_DARK_BISHOP:"Ziehe Deinen schwarzfeldrigen L\u00e4ufer.",RETREAT_BISHOP:"Ziehe Deinen L\u00e4ufer zur\u00fcck.",
3116ADVANCE_BISHOP:"Ziehe Deinen L\u00e4ufer vor.",DEVELOP_KSIDE:"Entwickle Deinen K\u00f6nigsfl\u00fcgel.",PREPARE_CASTLING:"Bereite die Rochade vor.",DEVELOP_QSIDE:"Entwickle Deinen Damenfl\u00fcgel.",DEVELOP_QN:"Entwickle Deinen Damenspringer.",DEVELOP_KN:"Entwickle Deinen K\u00f6nigsspringer.",CENTRALIZE_KNIGHT:"Zentralisiere Deinen Springer.",ADVANCE_KNIGHT:"Springer vor!",RETREAT_KNIGHT:"Ziehe Deinen Springer zur\u00fcck.",MOVE_KNIGHT_SIDEWAYS:"Ziehe Deinen Springer seitlich.",ROOK_TO_OPEN_FILE:"Ziehe Deinen Turm auf eine offene Linie.",
3117ADVANCE_ROOK:"Vorsto\u00df mit dem Turm.",RETREAT_ROOK:"R\u00fcckzug mit dem Turm.",MOVE_ROOK_VERTICALLY:"Ziehe einen Turm vertikal.",CENTRALIZE_ROOK:"Zentralisiere einen Turm.",MOVE_ROOK_HORIZONTALLY:"Ziehe einen Turm horizontal.",DOUBLE_ROOKS:"Verdopple die T\u00fcrme.",PREPARE_DOUBLE_ROOKS:"Bereite die Turmverdopplung vor.",CASTLE_IMP:"Rochiere.",PIN_IMP:"Fessele etwas.",ATTACK_A_MINOR_PIECE:"Greife eine Leichtfigur an.",RETREAT_A_PIECE:"Ziehe eine Figur zur\u00fcck.",OPP_THREATENS_MATE:"Vorsicht, es droht Matt!",
3118OPP_THREATENS_QUEEN:"Deine Dame ist angegriffen.",OPP_THREATENS_ROOK:"Dein Turm ist angegriffen.",OPP_THREATENS_MINOR:"Eine Leichtfigur ist angegriffen.",OPP_THREATENS_PAWN:"Ein Bauer h\u00e4ngt.",MATE_IMP:"Setze Matt!",EXCHANGE_IMP:"Tausche ab.",CREATE_PASSED_PAWN:"Bilde einen Freibauern.",PROMOTE_IMP:"Wandle einen Bauern um.",OFFER_EXCHANGE_IMP:"Biete einen Abtausch an.",THREATEN_IMP:"Drohe etwas",WATCH_OUT:"Achtung - es gibt eine starke Drohung!",RED_ARROW_THREAT:"Roter Pfeil = Drohung.",GREEN_ARROW_MOVE:"Gr\u00fcner Pfeil = Zugvorschlag.",
3119ATTACK_A_PAWN:"Greife einen Bauern an.",COVER_SOMETHING:"Decke etwas.",BLOCK_ATTACK:"Blockiere einen Angriff.",EVADE_ATTACK_IMP:"Weiche einem Angriff aus.",SAC_IMP:"Opfere",OPEN_ATTACK_FILE:"\u00d6ffne eine Angriffslinie.",EVADE_CHECK:"Ziehe den K\u00f6nig aus dem Schach.",BLOCK_CHECK:"Verstelle das Schach.",DOUBLE_ATTACK_IMP:"Spiele einen Doppelangriff.",BRILLIANT:"Brilliant",SPLENDID:"Sehr sch\u00f6n",BEAUTIFUL:"Tschakka!",POWERFUL:"Kr\u00e4ftig",COO
3119L:"Cool",EXCELLENT:"Exzellent",THIS_IS_THE_WAY:"This is the way",
3120SUPER:"Super",STRONG:"Stark",WELL_PLAYED:"Gut gespielt",FINE:"Fein",BRAVE:"Unerschrocken",SHARP:"Scharf",HOT_MOVE:"Hei\u00dfer Zug",TRICKY:"Trickreich",ADVENTUROUS:"Unternehmungslustig",NICE:"Nett",GOOD:"Gut",RISKY:"Riskant!?",GOOD_GAMBLE:"Gut gepokert!?",NO_FEAR:"Furchtlos",ON_THE_EDGE:"Hart am Wind gespielt",EVADE_EXCHANGE_IMP:"Weiche einem Abtausch aus.",DOUBLE_ROOKS_7TH:"Zwei T\u00fcrme auf der siebten Reihe sind stark.",ROOK_TO_HALFOPEN_FILE:"Ziehe Deinen Turm auf eine halboffene Linie.",ONLY_MOVE:"Nur ein legaler Zug.",
3121WIN_MATERIAL:"Gewinne Material."};namespace("Loc.Training.GER");Loc.Training.GER=Training_de;"use strict";
3122var Training_es={DIFFICULTY:"Dificultad:",POSITIONS_SOLVED:"Posiciones resueltas:",YOUR_RATING:"Su Elo:",YOUR_RANK:"Su rango:",NEW_RANK:"Nuevo rango:",RANKING_LISTS:"Clasificaciones",NEXT_POSITION:"Siguiente posici\u00f3n",TTIP_NEXT_POSITION:"Siguiente posici\u00f3n (pierde Elo si no se ha dado una soluci\u00f3n)",HINT:"Pista",TTIP_HINT:"Haga clic para la siguiente pista",SOLUTION:"Soluci\u00f3n",TTIP_SOLUTION:"Mostrar soluci\u00f3n (resta Elo)",CRITICISE_POSITION:"Criticar posici\u00f3n",TTIP_CRITICISE_POSITION:"Mandar un comentario cr\u00edtico sobre esta posici\u00f3n",
3123LIKE_POSITION:"Me gusta",TTIP_LIKE_POSITION:"Indicar que le gust\u00f3 esta posici\u00f3n",CAPTURE_SOMETHING:"Captura algo",GIVE_CHECK:"Da jaque",MATE_IN_ONE:"\u00a1Mate en uno!",STALEMATE:"Ahogado",THREATEN_MATE:"Amenaza mate",RECAPTURE_MATERIAL:"Recapture material",DOUBLE_ATTACK:"Ataque doble",DISCOVERED_ATTACK:"Ataque a la descubierta",PINNING:"Clavada",DEFLECTION:"Desviaci\u00f3n",DECOY:"Se\u00f1uelo",INTERCEPTION:"Interceptaci\u00f3n",ANNIHILATION:"Destrucci\u00f3n",CLEARANCE:"Despeje",BLOCKADE:"Bloqueo",
3124XRAY:"Rayos X",OVERLOADING:"Sobrecarga",PAWN_BREAK:"Ruptura de pe\u00f3n",PASSED_PAWN:"Pe\u00f3n pasado",PROMOTION:"Promoci\u00f3n",DEMOLITION:"Demolici\u00f3n",PURSUIT:"Persecuci\u00f3n",MATE_ATTACK:"Ataque de mate",MATE_THREAT:"Amenaza de mate",SKEWER:"Pincho",PIN:"Pin",FORK:"Fork",SACRIFICE_SOMETHING:"Sacrifice something.",BACKRANK:"Weak Back Rank",ATTACK_THE_QUEEN:"Attack the queen",ATTACK_A_ROOK:"Attack a rook",THREATEN_PAWN_WIN:"Threaten to win a pawn",THREATEN_TO_WIN_MATERIAL:"Threaten to win material",
3125EVADE_AN_ATTACK:"Evade an attack",COVER_A_PIECE:"Cover a piece",OVERWORKED_PIECE:"Overworked piece",THREAT:"Amenaza",MATERIAL:"Material",OPPONENT_MOVES:"El rival juega...",TOMOVE_AND_DRAW:"juegan y entablan.",TOMOVE_AND_WIN:"juegan y ganan.",SOLVED:"\u00a1Resuelto!",FINISH_MATE:"\u00a1Mate!",FINISH_STALEMATE:"\u00a1Ahogado!",CLICK_NEXT_POS:"Haga clic en 'Siguiente posici\u00f3n' para continuar...",CONTINUE:"Contin\u00fae...",CONTINUE_ENTER_NEXT:"Contin\u00fae... Por favor, haga la siguiente jugada.",
3126NO_HINTS:"No hay pistas.",FIND_MATE:"\u00a1Encuentre el mate!",PLEASE_TRY_AGAIN:"No es la jugada m\u00e1s fuerte.",MAINTENANCE_LOGOFF:"Lo sentimos, pero el servidor est\u00e1 apag\u00e1ndose para realizar tareas de mantenimiento. Por favor, vuelva a intentarlo dentro de 10 minutos. \u00a1Muchas gracias!",CLICK_NEXT_TO_START:"Haga clic en 'Siguiente posici\u00f3n' para empezar",FEEDBACK_POSITION:"Comentario para ChessBase sobre esta posici\u00f3n:",SEEN_N_TIMES:"Vista {0} veces ya. Pistas = {1}",NOT_SEEN_BEFORE:"Nunca vista antes. Pistas = {0}",
3127LOGIN_INVITE:'Gracias por usar <span style="font-weight:bold">ChessBase Training</span>. \u00a1Aumente su fuerza practicando t\u00e1ctica!',LOGIN_FUNCTIONALITY:"Por favor, con\u00e9ctese con su cuenta de ChessBase para usar 44000 posiciones de t\u00e1ctica. Como invitado, est\u00e1 limitado a 300 posiciones f\u00e1ciles, adecuadas para un calentamiento.",FRIENDS_RANKING:"Elo amigos",TTIP_FRIENDS_RANKING:"Compare su puntuaci\u00f3n con la de sus amigos",N_HINTS:"Pistas = {0}",WAITING_FOR_POSITION:"Esperando posici\u00f3n...",
3128WAITING_FOR_HINT:"Esperando pista...",WAITING_FOR_SOLUTION:"Esperando soluci\u00f3n...",LEVEL_RIDICULOUS:"De risa",LEVEL_TRIVIAL:"Trivial",LEVEL_VERY_EASY:"Muy f\u00e1cil",LEVEL_EASY:"F\u00e1cil",LEVEL_NOT_EASY:"No tan f\u00e1cil",LEVEL_NEEDS_THINK:"Necesita una pensada",LEVEL_MEDIUM:"Medio",LEVEL_INTERESTING:"Interesante",LEVEL_CHALLENGING:"Desafiante",LEVEL_TOUGH:"Duro",LEVEL_DIFFICULT:"Dif\u00edcil",LEVEL_VERY_DIFFICULT:"Muy dif\u00edcil",LEVEL_MASTER_LEVEL:"Nivel magistral",LEVEL_NIGHTMARE:"Pesadilla",
3129CAN_ONLY_ANALYSE_SOLVED:"Solo se pueden analizar posiciones resueltas.",HTML_DESCRIPTION:"Resuelva problemas t\u00e1cticos y fortalezca su ajedrez.",SOLVE_TACTICS:"Problemas de t\u00e1ctica",PLAY_TACTICS_FIGHT:"\u00a1Pelea t\u00e1ctica!",WAITING_SEEKS:"Esperando:",SOLVE_EXPLAIN_1:"Mejore su capacidad de c\u00e1lculo.",SOLVE_EXPLAIN_2:"Resuelva posiciones t\u00e1cticas que se ajustan a su fuerza de juego.",SOLVE_EXPLAIN_3:"Reciba pistas constructivas si se qeuda atascado. Sin presi\u00f3n de tiempo.",
3130SOLVE_EXPLAIN_4:"Reproduzca la soluci\u00f3n y analice con un m\u
313000f3dulo.",FIGHT_EXPLAIN_1:"Juegue un duelo al mejor de 24 posiciones contra otro usuario.",FIGHT_EXPLAIN_2:"Si resuelve primero un posicion, obtiene el punto.",FIGHT_EXPLAIN_3:"Si se equivoca en la posici\u00f3n, el punto se lo lleva el rival.",FIGHT_EXPLAIN_4:"Si nadie ejecuta una jugada en 60 segundos, cambia la posici\u00f3n.",START_SOLVING:"Empezar a resolver",START_FIGHT:"Empezar a pelear",CLICK_START_TO_BE_FIRST:"Haga clic en 'Empezar a pelear' para invitar a otros.",
3131CANCEL_WAIT:"Cancelar invitaci\u00f3n",REQUEST_SENT:"Invitaci\u00f3n enviada",TTIP_START_FIGHT:"Haga clic para buscar rival para una lucha t\u00e1ctica de 24 posiciones.",END_OF_FIGHT:"Fin de la pelea.",YOU_WON:"Usted gan\u00f3",NEW_ELO:"Nuevo Elo:",TIMEOUT_NEXT_POSITION:"TIEMPO \u2013 Siguiente posici\u00f3n...",FIGHT_STARTED:"Comenz\u00f3 la pelea",WON_VERB:"ganado",SOLVED_BY:" Resuelto por",WRONG_MOVE_BY:" Error de",WAITING_FOR_OPPONENT:"A la espera de rival...",ABORTED:"Abortado",DRAW:"Tablas",
3132XY_RESIGNED:"se rindi\u00f3",XY_OFFERED_REMATCH:"ofreci\u00f3 la revancha",PRESS_REMATCH_TO_ACCEPT:"Pulse 'Revancha' para aceptar la oferta",PLAYER_NOT_ONLINE:"Jugador no conectado",CHALLENGE_PLAYER:"Retar jugador",TTIP_CHALLENGE_FIGHT:"Escriba el nombre de la cuenta de un amigo para una pelea t\u00e1ctica",TTIP_SOLVING_TO_MAIN:"Dejar de resolver y volver a la pantalla principal",CLOSE_FIGHT_BOARD:"Cerrar tablero de pelea",TTIP_CLOSE_FIGHT:"Cerrar el tablero de lucha y volver a la resoluci\u00f3n normal",
3133RESIGN_FIGHT:"Rendirse en la lucha",TTIP_RESIGN_FIGHT:"Haga clic para rendirse y terminar la lucha",REMATCH:"Revancha",TTIP_REMATCH:"Ofrecer o aceptar la revancha",REMATCH_OFFER_SENT:"Enviada oferta de revancha",FIGHT_EXPLAIN_5:"If you kibitz a fight, you may also enter the solutions. A good training.",KIBITZ_FIGHT:"Kibitz Fight",TTIP_KIBITZ_FIGHT:"Kibitz a Tactics Fight",RADAR_BOARD_HINT:"Final position will show here if all hints used up:",CLICK_FOR_HINT:"Every click here will show another (and more direct) hint",
3134CORRECT:"Correct",WRONG:"Wrong",MOVE_IMP:"Move",TO_A_LIGHT_SQUARE:"to a light square.",TO_A_DARK_SQUARE:"to a dark square.",VERTICALLY:"vertically",HORIZONTALLY:"horizontally.",DIAGONALLY:"diagonally",ADVANCE_FORMAT:"Advance {0}",RETREAT_FORMAT:"Retreat {0}",CENTRALIZE:"Centralize",MOVE_KING_SIDEWAYS:"Move your king sideways.",MOVE_YOUR_FILE_PAWN:"Move your {0}-pawn.",MAKE_PAWN_DOUBLE_STEP:"Make a double step with your pawn.",MOVE_CENTER_PAWN:"Move your center pawn.",MOVE_QSIDE_PAWN:"Move your pawn on the queens side.",
3135MOVE_KSIDE_PAWN:"Move your pawn on the kings side.",MOVE_LIGHT_BISHOP:"Move your light squared bishop.",MOVE_DARK_BISHOP:"Move your dark squared bishop.",RETREAT_BISHOP:"Retreat your bishop.",ADVANCE_BISHOP:"Advance your bishop.",DEVELOP_KSIDE:"Develop your king's side.",PREPARE_CASTLING:"Prepare to castle.",DEVELOP_QSIDE:"Develop your queen's side.",DEVELOP_QN:"Develop your queen's knight.",DEVELOP_KN:"Develop your king's knight.",CENTRALIZE_KNIGHT:"Centralize your knight.",ADVANCE_KNIGHT:"Advance your knight.",
3136RETREAT_KNIGHT:"Retreat your knight.",MOVE_KNIGHT_SIDEWAYS:"Move your knight sideways.",ROOK_TO_OPEN_FILE:"Move your rook to an open file.",ADVANCE_ROOK:"Advance your rook.",RETREAT_ROOK:"Retreat your rook.",MOVE_ROOK_VERTICALLY:"Move your rook vertically.",CENTRALIZE_ROOK:"Centralize your rook.",MOVE_ROOK_HORIZONTALLY:"Move your rook horizontally.",DOUBLE_ROOKS:"Double your rooks.",PREPARE_DOUBLE_ROOKS:"Prepare to double rooks.",CASTLE_IMP:"Castle.",PIN_IMP:"Pin something.",ATTACK_A_MINOR_PIECE:"Attack a minor piece.",
3137RETREAT_A_PIECE:"Retreat a piece.",OPP_THREATENS_MATE:"Do not get mated!",OPP_THREATENS_QUEEN:"Watch your queen!",OPP_THREATENS_ROOK:"Your rook is in danger.",OPP_THREATENS_MINOR:"A minor piece is attacked.",OPP_THREATENS_PAWN:"Your pawn is hanging.",MATE_IMP:"Find the mate!",EXCHANGE_IMP:"Exchange material.",CREATE_PASSED_PAWN:"Create a passed pawn.",PROMOTE_IMP:"Promote a pawn.",OFFER_EXCHANGE_IMP:"Offer to exchange a piece.",THREATEN_IMP:"Create a threat.",WATCH_OUT:"Watch out for a threat.",RED_ARROW_THREAT:"Red arrow = threat.",
3138GREEN_ARROW_MOVE:"Green arrow = suggested move.",ATTACK_A_PAWN:"Attack a pawn",COVER_SOMETHING:"Cover something.",BLOCK_ATTACK:"Block an attack.",EVADE_ATTACK_IMP:"Evade an attack.",SAC_IMP:"Sacrifice",OPEN_ATTACK_FILE:"Open an attack file.",EVADE_CHECK:"Move your king out of check.",BLOCK_CHECK:"Block the check.",DOUBLE_ATTACK_IMP:"Find a double attack.",BRILLIANT:"Brilliant",SPLENDID:"Splendid",BEAUTIFUL:"Beautiful",COOL:"Cool!",EXCELLENT:"Excellent",POWERFUL:"Powerful",THIS_IS_THE_WAY:"This is the way",
3139SUPER:"Super",STRONG:"Strong!",WELL_PLAYED:"Well played",FINE:"Fine!",BRAVE:"Brave",SHARP:"Sharp",HOT_MOVE:"Hot move",TRICKY:"Tricky",ADVENTUROUS:"Adventurous",NICE:"Nice",GOOD:"Good",RISKY:"Risky!?",GOOD_GAMBLE:"Good Gamble",NO_FEAR:"No fear",ON_THE_EDGE:"On the edge",EVADE_EXCHANGE_IMP:"Evade an exchange.",DOUBLE_ROOKS_7TH:"Two rooks on the seventh rank are strong.",ROOK_TO_HALFOPEN_FILE:"Move your rook to a half open file.",ONLY_MOVE:"Only one legal move.",WIN_MATERIAL:"Win material."};namespace("Loc.Training.ESP");
3140Loc.Training.ESP=Training_es;"use strict";
3141var Playchess={GONE:"Gone",PLAYING:"Playing",KIBITZING:"Kibitzing",CHAIRMAN:"Chairman",TACTICS:"Tactics",SEEKS:"Seeking",IDLE:"Idle",PAUSE:"Pause",TOURN_DIRECTOR:"Tournament Director",IN_PROGRESS:"...",ABORTED:"Aborted",FINISHED:"Finished",PLAY_BULLET:"Play Bullet",PLAY_SLOW:"Play Slow",KIBITZ_BLITZ:"Kibitz Blitz",LIVE_GAMES:"Live Games",PING_SERVER:"Ping Server",CLOSE_FINISHED:"Close Finished",RECEIVING_MOVES:"Receiving Moves",DEFAULT_URL:"www.playchess.com",APPLAUDE:"Applaude",REMATCH:"Rematch",
3142REMATCH_OK:"Rematch OK",CLAIM_WIN:"Claim Win",PING_OPPONENT:"Ping Opponent",WAITING_FOR_OPPONENT:"Waiting for Opponent",NO_CONTACT:"No Contact To Opponent...",OPPONENT_CLOSED_WINDOW:"Opponent closed game window",ABORTED_GAME:"aborted.",REMATCH_OFFER_SENT:"Rematch offer sent",OFFERS_REMATCH:"offers a rematch.",WAITING_CHESS_SERVER:"Waiting for playchess.com",PLAYERS:"Players",CHALLENGE_PLAYER:"Challenge",ONLY_STRONG_PLAYERS:"Only strong players",KIBITZERS:"Kibitzers",WATCH_GAMES:"Watch Games",REFRESH_LIST:"Refresh List",
3143OBSERVERS:"Observers",NO_CHAT_PARTNER_SELECTED:"No chat partner or kibitzed game selected, please click on a player in the list.",GUESTS_CANNOT_CHAT:"Guests cannot chat with other players, please log in.",ACCEPT:"Accept",DELET
3143E:"Delete",SEEK:"Seek",CHALLENGES:"Challenges",CONDITIONS:"Conditions",RATED:"Rated",UNRATED:"Unrated",RETRIEVING_PLAYERS:"Retrieving players...",DONE:"done",TYPE_TO:"Type to",KIBITZERS_OF:"kibitzers of",SENT_GUEST_APPLAUSE:"Sent praise to opponent.",IS_CURRENTLY_EMPTY:"is currently empty, join the main community?",
3144SEARCH_GAMES:"Search Games",EDIT_FRIENDS:"Edit Friends",EDIT_IGNORES:"Edit Ignores",TOPLIST_FRIENDS:"Toplist friends",TOPLIST_COUNTRY:"Toplist Country",TOPLIST_REGION:"Toplist Region",TOPLIST_CITY:"Toplist City",WITH_CLOCK:"With Clock",SERVER_STATISTICS:"Statistics",PLAYCHESS_STATISTICS:"Playchess statistics",PEAK_CONNECTIONS:"Peak Connections",DAILY_GAMES:"Daily Games",VISITORS:"Visitors",UP_SINCE:"Up Since",CHALLENGE_X:"Challenge",FRIENDS:"Friends",TOP_LIST:"Top List",USER:"User",CURRENTLY_NO_ACTIVE_MEDIA_BROADCASTS:"There are currently no active Media broadcasts",
3145SELECT_THE_BROADCAST:"Select the broadcast",BROADCAST:"Broadcast",LISTEN_TO_RADIO:"Listen to radio",ZOOM_IN:"Zoom in",ZOOM_OUT:"Zoom Out",SELECT_ROOM:"Select A Room",ROOM_TO_VISIT:"Room To Visit",MAIN_HALL:"Main Playing Hall",TIP_KIBITZ_BLITZ:"Follow the strongest Blitz game currently being played on playchess.com",TIP_WATCH_LIVETOURNAMENTS:"Watch real games live from grandmaster tournaments",TIP_WATCH_LIVERADIO:"Listen to live audio commentary (under construction)",TIP_SEND_FEEDBACK:"Send feedback to the developpers",
3146TIP_SHOW_STATISTICS:"Show statistics about playchess.com",TIP_PING_SERVER:"Measure the speed of your internet connection",TIP_LOGIN:"Login with your ChessBase account",TIP_RECEIVING_MOVES:"Toggle the link of this game with the server broadcast to enter your own analysis",TIP_PLAY_BLITZ:"Start a 5 min Blitz game against a player of your strength.<br/>Click the menu arrow to select other clock times.",TIP_PLAY_BULLET:"Start a 1 min Bullet game against a player of your strength",TIP_PLAY_SLOW:"Start a rapid game against a player of your strength.<br/>Click the menu arrow to select other clock times.",
3147TIP_ACCOUNT:"Check your Elo Rating and other account settings",TIP_SELECT_ROOM:"Change between your club room and the main playing hall",TIP_REMATCH:"Offer a rematch game with reversed colors",TIP_REMATCH_OK:"Accept your opponent's rematch offer",TIP_RESIGN:"Resign this game",TIP_OFFER_DRAW:"Offer a draw",TIP_ACCEPT_DRAW:"Accept your opponent's draw offer",TIP_CLAIM_WIN:"Claim a win in this game because your opponent is disconnected",TIP_PING_OPPONENT:"Test the connection speed to your opponent. This shows the sum of both your lags in milliseconds in the chat window.",
3148TIP_APPLAUDE:"Send an applause to your opponent which will be shown in the chat window. Also possible for guests.",YOU_NEED_PREMIUM_MEMBERSHIP:"You need premium membership",YOU_NEED_TO_LOG_ON_TO_USE_THIS_FUNCTION:"You need to logon to use this function",BROW
3148SE_CMS_ARCHIVE:"Browse CMS Archive",TIP_BROWSE_CMS_ARCHIV:"Browse throught the CMS archive",ROOMS:"Rooms",GO_BACK:"Go back",CHAT_AND_NOTATION:"Chat, Notation",LISTS_AND_CHALLENGES:"Lists, Challenges",LOGIN_TO_PLAY_ELO_OPPONENTS:"Log in with your ChessBase Account to play against opponents of your own strength or to chat.",
3149THANK_YOU_FOR_USING_PLAYCHESS:'Thank you for using <span style="font-weight:bold">playchess.com</span> to play and watch games.',NOT_RATED:"Not rated",BLITZ:"Blitz",BULLET:"Bullet",STATUS:"Status",MORE_BOARDS:"More",LESS_BOARDS:"Less",NEXT_BOARD:"Next",FULL_VIEW:"Notation and more...",TTIP_BACK_HOME:"Back to home screen",TTIP_MORE_BOARDS:"View more boards",TTIP_LESS_BOARDS:"View less boards",TOGGLE_GAMELIST:"Games List",TTIP_TOGGLE_GAMELIST:"Hide/Show the list of all broadcasted games",MORE_TIME_CONTROLS:"More Time Controls",
3150MORE:"More",START_GAME:"Start Game",ARBITER:"Arbiter",ABORT:"Abort",TIP_ABORT:"Abort this game",STARTING_GAME:"Starting Game, waiting..",GAME_STARTED:"Game started.",YOU_LOST_ON_TIME:"You lost on time. ",YOU_RESIGNED:"You resigned",YOU_OFFERED_DRAW:"You offered a draw",CLICK_DRAW_TO_ACCEPT:"Press 'Draw' to accept.",CLICK_REMATCH_TO_ACCEPT:"Press 'Rematch' to accept.",OPPONENT_STILL_ONLINE:"Your opponent is still online",CLAIM_ACCEPTED:"Claim accepted.",LOOKING_FOR_OPPONENT:"Inviting an opponent",
3151RECEIVERS:"Receivers",CLICK_BLITZ_TO_START:"Press a 'Blitz' button to start.",YOU_CLAIM_WIN:"You claim a win",READY_TO_START:"Ready to start a game",TIP_10MIN_BLITZ:"Starts a game with 10 min time per player",START_10MIN_BLITZ:"Start 10 Min Game",CUSTOM_SEEK:"Offer Time",LIVE_CHESS:"Live Chess",TO_OPPONENT:"To Opponent",TO_ALL:"To All",TO_KIBITZERS:"To Kibitzers",PLEASE_SELECT_RECEIVER:"Please select a receiver in the community, in the chat or play against somebody.",CONNECTED_OK:"Connected OK.",
3152INVITATIONS:"Invitations",GAME:"Game",COMMUNITY:"Community",OPPONENTS:"Opponents",OPPONENT:"Opponent",INVITE_TO_A_GAME:"Invite to a game",INVITE_NAME:"Invite: {0}",SLOW:"Slow",PLAYCHESS_SIMPLE_HELP:"Press a button to invite others to a game. Or accept an invitation from the list below.",PLAYERS_ONLINE:"Players online",SERVER_COMMUNITY:"Server Community",INFO_COMMUNITY:"This tab shows you strong players, people in your neighbourhood and server administrators.",COMMUNITY_ACTIONS:"You can follow their games, invite them or chat.",
3153RECENT_OPPONENTS:"Recent Opponents",INFO_RECENT_OPPONENTS:"This tab will show all recent opponents and your score against them.",OPPONENT_ACTIONS:"You can invite them to a game, mark them as friends or chat with them.",MANAGE_FRIENDS:"Manage your friends",INFO_FRIENDS:"This will list all your friends.",FRIEND_ACTIONS:"You can see who is online, invite them to a game or chat with them.",PLEASE_LOGIN_OR_CREATE_ACCOUNT:"To use this, please log in or create an account.",STOP_KIBITZING:"Stop 
3153Kibitzing",
3154DISTANCE:"Distance",FRIEND:"Friend",MINUTES:"Minutes",INC_SECONDS:"Seconds per Move",READY:"Ready",SHOW_THREAT:"Show Threat",TTIP_SHOW_THREAT:"Show your opponents threat",HINT:"Hint",TTIP_HINT:"Click for a hint text",BLUNDER_SHIELD:"Blunder Shield",TTIP_BLUNDER_SHIELD:"Show safe squares for a piece",SPY_MOVE:"Spy Move",TTIP_SPY_MOVE:"Hold your piece over a square and see the answering move",FIFTY_JOKER:"50/50 Joker",TTIP_FIFTY_JOKER:"Check which half of the board contains a good move",THEORY_HINT:"Theory Hint",
3155TTIP_THEORY_HINT:"Show the theory moves",BROWSER_FINE_FOR_HINTS:"Your browser is fine for help & hint calculations.",NO_HINTS_FOR_THIS_POSITION:"No hints for this position.",NO_HINTS_AVAILABLE:"No hints available.",CLICK_CHAT_TAB:"Click on the 'Chat' tab to chat with other players.",DO_NOT_CLOSE_BROWSER:"Please do NOT close or refresh your browser while playing.",YOU_ARE_IN_ROOM:"You are in the room",YOUR_CLUB:"Your Club",JOIN_TOURNAMENT:"Join Tournament",QUIT_TOURNAMENT:"Quit Tournament",YOU_ARE_REGISTERED:"You are registered",
3156CLICK_FOR_STANDINGS:"Click for standings",ARBITER_DECISION_ME:"Arbiter decision in my favour.",OFFER_TAKE_BACK:"Offer Take Back",ACCEPT_TAKE_BACK:"Accept Take Back",XY_OFFERS_TAKE_BACK:"{0} offers that you take your move back",CLICK_BUTTON_ACCEPTS:"Click Button To Accept",KIBITZ:"Kibitz",NO_GAMES_YET:"No Game Yet.",DISCO_NOT_SENT:"Not connected - move not sent.",INVITATION_FROM:"Invitation from {0}",NO_TD_PRESENT:"No Tournament Director present",TOURNAMENT:"Tournament",CLICK_JOIN:"Click 'Join Tournament'.",
3157ROUNDS:"rounds",RETURN_TO_MAIN_ROOM:"Return to the main playing hall",TOURNAMENT_FINISHED:"Tournament finished.",GAMES_REQUIRED:"{0} more games required to increase hints.",PLAY_GAMES_FOR_HINTS:"Play more games to get more hints!",STOP_ANALYSIS:"Close Analysis",BONUS_HINT:"Good move -> one bonus hint.",POSINFO_TITLE:"Piece placement, activity, complexity:",TIP_5MIN_BLITZ:"Starts a game with 5 min time per player",START_5MIN_BLITZ:"Start 5 Min Blitz"},PlaychessHelp={HELP_MAIN_SCREEN:"Main Screen",
3158HELP_PLAY_BLITZ_GAME:"Play a Blitz game - 5 minutes.",HELP_PLAY_BULLET_GAME:"Play a Bullet game - one minute.",HELP_PLAY_SLOW_GAME:"Play a slow game - 15 minutes.",HELP_LIVE_TOURNAMENTS:"Kibitz the four most interesting live games from real world tournaments currently running.",HELP_FOLLOW_BEST:"Kibitz the strongest Blitz game currently played on the server.",HELP_LOGIN_ACCOUNT:"Log in with your existing Playchess account or create a new one",HELP_HEADER_GAME:"In A Game",HELP_CLAIM_WIN:"Claim win - If your opponent seems disconnected (does not move any more), you can ask the server to award you the point.",
3159HELP_REMATCH:"Offer rematch - Suggests a revanche game with reversed colors to your opponent.",HELP_CLOSE:"Closes the board window. Warning: If you are still in a game, you will automatically resign.",HELP_MOVE_ENTRY1:"Move entry: You can use premove, single-click entry and inverted entry (click target square first).",HELP_MOVE_ENTRY2:"To cancel a premove, click the piece again or click outside the board. When you promote, release the mouse-button on the promotion piece (don't worry, the queen is huge).",
3160HELP_HEADER_KIBITZING:"While Kibitzing (click 'Live Games')",HELP_SPLITTERS:"Resizing: Drag the vertical window splitters left and right of the board area to resize the board area to your liking.",HELP_WATCH:"Use Ctrl-Click to select multiple games, then click 'Watch Game' above the game list to kibitz them.",HELP_RECEIVING:"Click 'Receiving Moves' to toggle your move feed from the server and to start you own analysis. To obtain the original games, click 'Receiving Moves' again.",HELP_ENGINE:"Start an analysis engine.",
3161HELP_DOWNLOAD_CLIENT:"Download the free native Windows software (more functionality)"};namespace("Loc.Playchess.ENG");Loc.Playchess.ENG=Playchess;namespace("Loc.PlaychessHelp.ENG");Loc.PlaychessHelp.ENG=PlaychessHelp;"use strict";
3162Playchess={GONE:"Gegangen",PLAYING:"Spielt",KIBITZING:"Kiebitzt",CHAIRMAN:"Leiter",TACTICS:"Taktik",SEEKS:"Sucht",IDLE:"Ruht",PAUSE:"Pause",TOURN_DIRECTOR:"Turnierleiter",IN_PROGRESS:"...",ABORTED:"Abbruch",FINISHED:"Beendet",P
3162LAY_BULLET:"Bullet Spielen",PLAY_SLOW:"Schnellpartie",KIBITZ_BLITZ:"Blitz kiebitzen",LIVE_GAMES:"Live Schach",PING_SERVER:"Verbindung testen",CLOSE_FINISHED:"Fertige schliessen",RECEIVING_MOVES:"Empf\u00e4ngt Z\u00fcge",DEFAULT_URL:"www.schach.de",APPLAUDE:"Applaus",REMATCH:"Revanche",
3163REMATCH_OK:"Revanche OK",CLAIM_WIN:"Sieg reklamieren",PING_OPPONENT:"Gegner Online?",WAITING_FOR_OPPONENT:"Warte auf Gegner",NO_CONTACT:"Keine Verbindung zum Gegner...",OPPONENT_CLOSED_WINDOW:"Gegner hat das Brett geschlossen",ABORTED_GAME:"hat die Partie abgebrochen.",REMATCH_OFFER_SENT:"Revancheangebot abgesendet.",OFFERS_REMATCH:"bietet Revanche an.",WAITING_CHESS_SERVER:"Warte auf playchess.com",PLAYERS:"Spieler",CHALLENGE_PLAYER:"Herausfordern",ONLY_STRONG_PLAYERS:"Nur starke Spieler",KIBITZERS:"Zuschauer",
3164WATCH_GAMES:"Zuschauen",REFRESH_LIST:"Liste aktualisieren",RETRIEVING_GAMES:"Lade Partien",OBSERVERS:"Zuschauer",NO_CHAT_PARTNER_SELECTED:"Kein Chat Partner oder keine Kiebitzpartie ausgew\u00e4hlt. Klicke in der Spielerliste.",GUESTS_CANNOT_CHAT:"G\u00e4ste k\u00f6nnen nicht mit anderen Spielern chatten. Bitte melde Dich an.",ACCEPT:"Annehmen",DELETE:"Entfernen",SEEK:"Angebot",CHALLENGES:"Herausforderungen",CONDITIONS:"Bedingungen",RATED:"Gewertet",UNRATED:"Ungewertet",RETRIEVING_PLAYERS:"Lade Spieler...",
3165DONE:"erledigt",TYPE_TO:"Nachricht an",KIBITZERS_OF:"Kiebitze von",SENT_GUEST_APPLAUSE:"Lob an Gegner gesendet.",IS_CURRENTLY_EMPTY:"ist derzeit leer, in Hauptraum wechseln?",SEARCH_GAMES:"Search Games",EDIT_FRIENDS:"Freunde",EDIT_IGNORES:"Ignorierte Spieler",TOPLIST_FRIENDS:"Rangliste Freunde",TOPLIST_COUNTRY:"Rangliste Land",TOPLIST_REGION:"Rangliste Region",TOPLIST_CITY:"Rangliste Stadt",WITH_CLOCK:"Mit Uhr",SERVER_STATISTICS:"Serverstatistik",PLAYCHESS_STATISTICS:"PlayChess Statistik",PEAK_CONNECTIONS:"Max. Verbindungen",
3166DAILY_GAMES:"T\u00e4gliche Partien",VISITORS:"Besucher",UP_SINCE:"Server l\u00e4uft seit",CHALLENGE_X:"Herausforderung",FRIENDS:"Freunde",TOP_LIST:"Rangliste",USER:"User",CURRENTLY_NO_ACTIVE_MEDIA_BROADCASTS:"Im Augenblick l\u00e4uft kein Audio.",SELECT_THE_BROADCAST:"Sendung ausw\u00e4hlen",BROADCAST:"Sendung",LISTEN_TO_RADIO:"Audiokommentar",ZOOM_IN:"Zoomen - Ein",ZOOM_OUT:"Zoomen - Aus",SELECT_ROOM:"Raum ausw\u00e4hlen",ROOM_TO_VISIT:"Spielen im Raum",MAIN_HALL:"Gro\u00dfer Spielsaal",TIP_KIBITZ_BLITZ:"Zuschauen bei der st\u00e4rksten Blitzpartie, die gerade gespielt wird.",
3167TIP_WATCH_LIVETOURNAMENTS:"Partien aus realen Gro\u00dfmeisterturniern live verfolgen.",TIP_WATCH_LIVERADIO:"Audiokommentar oder Trainingsradio h\u00f6ren (in der Entwicklung)",TIP_SEND_FEEDBACK:"Kritik/Lob an Entwickler senden",TIP_SHOW_STATISTICS:"Statistiken zu playchess.com abrufen",TIP_PING_SERVER:"Misst die Geschwindigkeit Ihrer Internetverbindung",TIP_LOGIN:"Anmeldung mit Ihrem universellen ChessBase-Account. Angemeldete Nutzer erhalten Wertungszahlen.",TIP_RECEIVING_MOVES:"Schaltet die Ankn\u00fcpfung dieser Partie an eine Live\u00fcbertragung ein oder aus. Zur eigenen Analyse ausschalten.",
3168TIP_PLAY_BLITZ:"Startet eine F\u00fcnfminuten-Blitzpartie gegen einen gleich starken Gegner.<br/>Klicken Sie auf den Men\u00fcpfeil, um andere Bedenkzeiten zu w\u00e4hlen.",TIP_PLAY_BULLET:"Startet eine 1-Minuten-Blitzpartie (Bullet)gegen einen gleich starken Gegner.",TIP_PLAY_SLOW:"Startet eine Schnellpartie gegen einen gleich starken Gegner.<br/>Klicken Sie auf den Men\u00fcpfeil, um andere Bedenkzeiten zu w\u00e4hlen.",TIP_ACCOUNT:"Zeigt Ihre Wertungszahl und anderen Einstellungen zu Ihrem Konto an.",
3169TIP_SELECT_ROOM:"Wechselt zwischen Ihrem Vereinsraum und dem gro\u00dfen Spielsaal.",TIP_REMATCH:"Bietet eine Revanchepartie mit vertauschten Farben an.",TIP_REMATCH_OK:"Nimmt das Revancheangebot Ihres Gegners an.",TIP_RESIGN:"Diese Partie aufgeben.",TIP_OFFER_DRAW:"Bietet ein Remis=Unentschieden an.",TIP_ACCEPT_DRAW:"Nimmt das Remisangebot Ihres Gegners an.",TIP_CLAIM_WIN:"Reklamiert einen Gewinner, weil Ihr Gegner nicht mehr mit dem Server verbunden ist.",TIP_PING_OPPONENT:"Testet die Geschwindigkeit der Verbindung zum Gegner. Im Chat wird die gesamte Laufzeit angezeigt, einschl. Ihrer eigenen Verbindung.",
3170TIP_APPLAUDE:"Sende einen Applaus an Deinen Gegner, der im Chat angezeigt wird. Auch bei G\u00e4sten m\u00f6glich.",YOU_NEED_PREMIUM_MEMBERSHIP:"You need premium membership",YOU_NEED_TO_LOG_ON_TO_USE_THIS_FUNCTION:"You need to logon to use this function",BROW
3170SE_CMS_ARCHIVE:"Browse CMS Archive",TIP_BROWSE_CMS_ARCHIV:"Browse throught the CMS archive",ROOMS:"Rooms",GO_BACK:"Go back",CHAT_AND_NOTATION:"Chat, Notation",LISTS_AND_CHALLENGES:"Listen, Angebote",LOGIN_TO_PLAY_ELO_OPPONENTS:"Melden Sie sich mit Ihrem ChessBase Account an, um auf Gegner Ihrer eigenen Spielst\u00e4rke zu treffen oder zu chatten.",
3171THANK_YOU_FOR_USING_PLAYCHESS:'Danke, dass Sie <span style="font-weight:bold">schach.de</span> benutzen.',NOT_RATED:"Nicht gewertet",BLITZ:"Blitz",BULLET:"Bullet",STATUS:"Status",MORE_BOARDS:"Mehr",LESS_BOARDS:"Weniger",NEXT_BOARD:"N\u00e4chste",FULL_VIEW:"Notation und mehr...",TTIP_BACK_HOME:"Zur\u00fcck zum Startschirm (Spielen)",TTIP_MORE_BOARDS:"Weitere Bretter zum Kiebitzen \u00f6ffnen",TTIP_LESS_BOARDS:"Weniger Bretter kiebitzen",TOGGLE_GAMELIST:"Partienliste",TTIP_TOGGLE_GAMELIST:"Liste aller Partien ein/aus",
3172MORE_TIME_CONTROLS:"Weitere Bedenkzeiten",MORE:"Mehr...",START_GAME:"Partie starten",ARBITER:"Reklamieren",ABORT:"Abbruch",TIP_ABORT:"Diese Partie abbrechen",STARTING_GAME:"Verbinde Gegner...",GAME_STARTED:"Gegner ist bereit.",YOU_LOST_ON_TIME:"Auf Zeit verloren.",YOU_RESIGNED:"Aufgegeben",YOU_OFFERED_DRAW:"Remis angeboten",CLICK_DRAW_TO_ACCEPT:"Klick auf 'Remis' nimmt an.",CLICK_REMATCH_TO_ACCEPT:"Klick auf 'Revanche' nimmt an.",OPPONENT_STILL_ONLINE:"Gegner ist noch online",CLAIM_ACCEPTED:"Reklamation stattgegeben.",
3173LOOKING_FOR_OPPONENT:"L\u00e4dt Gegner ein",RECEIVERS:"Empf\u00e4nger",CLICK_BLITZ_TO_START:"Druck auf 'Blitz' startet Partie.",YOU_CLAIM_WIN:"Gewinn reklamiert...",READY_TO_START:"Startbereit",START_10MIN_BLITZ:"Starte 10 Min Partie",TIP_10MIN_BLITZ:"Startet eine Partie mit 10 Minuten Bedenkzeit pro Spieler.",CUSTOM_SEEK:"Bedenkzeit anbieten",LIVE_CHESS:"Live Schach",TO_OPPONENT:"An Gegner",TO_ALL:"An Alle",TO_KIBITZERS:"To Kibitzers",PLEASE_SELECT_RECEIVER:"Bitte klicken Sie auf einen Empf\u00e4nger in der Community oder im Chat, oder spielen Sie eine Partie",
3174CONNECTED_OK:"Verbunden und bereit.",INVITATIONS:"Einladungen",GAME:"Partie",COMMUNITY:"Community",OPPONENTS:"Gegner",OPPONENT:"Gegner",INVITE_TO_A_GAME:"Einladung an alle senden",INVITE_NAME:"Einladung an: {0}",SLOW:"L\u00e4nger",PLAYCHESS_SIMPLE_HELP:"Klicken Sie auf einen Schalter oben, um andere Spieler einzuladen. Oder nehmen Sie unten eine Einladung an.",PLAYERS_ONLINE:"Spieler online",SERVER_COMMUNITY:"Server Community",INFO_COMMUNITY:"Hier finden Sie starke Spieler, Spieler in Ihrer Nachbarschaft und Administratoren.",
3175COMMUNITY_ACTIONS:"Sie k\u00f6nnnen deren Partien kiebitzen, sie als Freunde setzen or mit ihnen chatten.",RECENT_OPPONENTS:"Aktuelle Gegner",INFO_RECENT_OPPONENTS:"Hier stehen alle Ihre k\u00fcrzlichen Gegner mit Matchergebnissen.",OPPONENT_ACTIONS:"Sie k\u00f6nnen Sie zu weiteren Partien einladen, sie als Freunde setzen oder mit ihnen chatten.",MANAGE_FRIENDS:"Verwalten Sie Ihre Freunde",INFO_FRIENDS:"Hier steht eine Liste aller ihrer Freunde.",FRIEND_ACTIONS:"Sie sehen, wer gerade online ist, Einladungen senden, chatten oder Freunde entfernen.",
3176PLEASE_LOGIN_OR_CREATE_ACCOUNT:"Bitte melden Sie sich dazu an oder registrieren Sie einen neuen Account.",STOP_KIBITZING:"Kiebitzen schlie\u00dfen",DISTANCE:"Entfernung",FRIEND:"Freund",MINUTES:"Minuten",INC_SECONDS:"Sekunden pro Zug",READY:"Fertig",SHOW_THREAT:"Drohung zeigen",TTIP_SHOW_THREAT:"Zeige die gegnerische Drohung",HINT:"Hilfestellung",TTIP_HINT:"Gib eine Hilfestellung",BLUNDER_SHIELD:"Patzer Protect",TTIP_BLUNDER_SHIELD:"Verhindere Fehlz\u00fcge der angeklickten Figur",SPY_MOVE:"Antwortz\u00fcge zeigen",
3177TTIP_SPY_MOVE:"Halten Sie ihre Figur \u00fcber einem Zielfeld, um den Antwortzug zu sehen.",FIFTY_JOKER:"50/50 Joker",TTIP_FIFTY_JOKER:"Zeigt, welche H\u00e4lfte der Figuren einen guten Zug enth\u00e4lt.",THEORY_HINT:"Er\u00f6ffnungstipp",TTIP_THEORY_HINT:"Zeigt die theoretische Fortsetzung, falls vorhanden.",BROWSER_FINE_FOR_HINTS:"Sie nutzen einen modernen Browser, der Tipps berechnen kann.",NO_HINTS_FOR_THIS_POSITION:"Keine Hilfen in dieser Stellung.",NO_HINTS_AVAILABLE:"Keine Hilfen verf\u00fcgbar",
3178CLICK_CHAT_TAB:"Klicke auf den Reiter 'Chat', um mit anderen Spieler zu chatten.",DO_NOT_CLOSE_BROWSER:"Bitte schlie\u00dfen oder aktualisieren Sie w\u00e4hrend der Partie nicht den Browser.",YOU_ARE_IN_ROOM:"Sie sind im Raum",YOUR_CLUB:"Dein Club",JOIN_TOURNAMENT:"Turnier mitmachen",QUIT_TOURNAMENT:"Turnier verlassen",YOU_ARE_REGIST
3178ERED:"Du bist ins Turnier aufgenommen",CLICK_FOR_STANDINGS:"Tabellen usw.",ARBITER_DECISION_ME:"Entscheidung zu meinen Gunsten.",OFFER_TAKE_BACK:"Zugr\u00fccknahme anbieten",
3179ACCEPT_TAKE_BACK:"Zugr\u00fccknahme ausf\u00fchren",XY_OFFERS_TAKE_BACK:"{0} bietet Zugr\u00fccknahme an",CLICK_BUTTON_ACCEPTS:"Klick auf Schalter nimmt an",KIBITZ:"Kiebitzen",NO_GAMES_YET:"Noch keine Partien.",DISCO_NOT_SENT:"Keine Verbindung - Zug nicht gesendet.",INVITATION_FROM:"Einladung von {0}",NO_TD_PRESENT:"Kein Turnierleiter im Raum",TOURNAMENT:"Turnier",CLICK_JOIN:"Klicke auf 'Mitmachen'.",ROUNDS:"Runden",RETURN_TO_MAIN_ROOM:"Zur\u00fcck in den gro\u00dfen Spielsaal",TOURNAMENT_FINISHED:"Turnier beendet.",
3180GAMES_REQUIRED:"Nach {0} Partien gibt es weitere Tipps.",PLAY_GAMES_FOR_HINTS:"Spiele mehrere Partien, um zus\u00e4tzliche Tipps zu bekommen!",STOP_ANALYSIS:"Analyse schlie\u00dfen",BONUS_HINT:"Guter Zug = Bonus Tipp.",POSINFO_TITLE:"Figuren, Aktivit\u00e4t, Sch\u00e4rfe:",START_5MIN_BLITZ:"Starte 5 Min Partie",TIP_5MIN_BLITZ:"Startet eine Partie mit 5 Minuten Bedenkzeit pro Spieler."};
3181PlaychessHelp={HELP_MAIN_SCREEN:"Startschirm",HELP_PLAY_BLITZ_GAME:"Starte eine Blitzpartie mit f\u00fcnf Minuten Bedenkzeit.",HELP_PLAY_BULLET_GAME:"Starte eine Bulletpartie mit einer Minute Bedenkzeit.",HELP_PLAY_SLOW_GAME:"Langsamere Partie mit 15 Minuten Bedenkzeit.",HELP_LIVE_TOURNAMENTS:"Live\u00fcbertragung - Die vier beliebtesten Partien aus realen Turnieren ansehen.",HELP_FOLLOW_BEST:"Bei der aktuell st\u00e4rksten Blitzpartie kibitzen.",HELP_LOGIN_ACCOUNT:"Melden Sie sich an und finden Sie dann gleich starke Gegner:",
3182HELP_HEADER_GAME:"In einer Partie",HELP_CLAIM_WIN:"Gewinn reklamieren - Falls Ihr Gegner die Verbindung verloren hat und nicht mehr zieht, wird Ihnen damit der Gewinn zugesprochen.",HELP_REMATCH:"Revanche anbieten - L\u00e4dt den Gegner zu einer Revanchepartie mit vertauschten Farben ein.",HELP_CLOSE:"Schliesst das Brettfenster - Achtung: Wenn die Partie noch l&auml;uft, geben Sie gleichzeitig auf.",HELP_MOVE_ENTRY1:"Zugeingabe: Sie k\u00f6nnen Z\u00fcge vorab eingeben oder Einzelklickeingabe verwenden (aufs Zielfeld klicken).",
3183HELP_MOVE_ENTRY2:"Die Zugeingabe vorab brechen Sie ab, indem Sie die gleiche Figur noch einmal anklicken oder ausserhalb des Brettes klicken. Bei Umwandlung von Bauern halten Sie die Maustaste auf dem Zielfeld gedr\u00fcckt und f\u00fchren Sie sie auf die Umwandlungsfigur. Die Dame ist kaum zu verfehlen.",HELP_HEADER_KIBITZING:"Beim Kiebitzen (nach Klick auf 'Live Partien')",HELP_SPLITTERS:"Ziehen Sie die Fensterteilungen links und rechts der Brettfl\u00e4che, um das Brett ihrem Geschmack noch zu vergr\u00f6\u00dfern.",
3184HELP_WATCH:"Zuschauen - verwenden Sie Strg-Klick, um mehrere Partien in der Partieliste auszuw\u00e4hlen, dann klicken Sie auf 'Zuschauen', um diese Partien zu kiebitzen.",HELP_RECEIVING:"Klick auf 'Empf\u00e4ngt Z\u00fcge' schaltet beim die Zug\u00fcbermittlung vom Server ab, damit Sie in Ruhe analysieren k\u00f6nnen. Erneuter Klick schaltet sie wieder ein.",HELP_ENGINE:"Mit der Fritz Schachengine analysieren.",HELP_DOWNLOAD_CLIENT:"Kostenlose Windows-Software laden (tolle zus\u00e4tzliche Funktionen)."};
3185namespace("Loc.Playchess.GER");Loc.Playchess.GER=Playchess;namespace("Loc.PlaychessHelp.GER");Loc.PlaychessHelp.GER=PlaychessHelp;"use strict";
3186Playchess={GONE:"Se fue",PLAYING:"Jugando",KIBITZING:"Mirando",CHAIRMAN:"Director",TACTICS:"T\u00e1ctica",SEEKS:"Buscando",IDLE:"Inactivo",PAUSE:"Pausa",TOURN_DIRECTOR:"Director de torneo ",IN_PROGRESS:"Ejecut\u00e1ndose...",ABORTED:"Cancelado",FINISHED:"Terminado",PLAY_BULLET:"Jugar bala",PLAY_SLOW:"Jugar lenta",KIBITZ_BLITZ:"Mirar blitz",LIVE_GAMES:"Partidas en directo",PING_SERVER:"Ping servidor",CLOSE_FINISHED:"Cerrar terminadas",RECEIVING_MOVES:"Recibiendo jugadas",DEFAULT_URL:"www.playchess.com",
3187APPLAUDE:"Aplaudir",REMATCH:"Revancha",REMATCH_OK:"Acepto revancha",CLAIM_WIN:"Reclamar victoria",PING_OPPONENT:"Ping rival",WAITING_FOR_OPPONENT:"Esperando por rival ",NO_CONTACT:"Sin contacto con el rival...",OPPONENT_CLOSED_WINDOW:"El rival cerr\u00f3 la ventana de la partida",ABORTED_GAME:"cancelada.",REMATCH_OFFER_SENT:"Enviada la oferta de revancha",OFFERS_REMATCH:"ofrece la revancha.",WAITING_CHESS_SERVER:"Esperando por Playchess.com",PLAYERS:"Jugadores",CHALLENGE_PLAYER:"Reto",ONLY_STRONG_PLAYERS:"Solo jugadores fuertes",
3188KIBITZERS:"Espectadores",WATCH_GAMES:"Mirar partidas ",REFRESH_LIST:"Actualizar lista ",OBSERVERS:"Observadores",NO_CHAT_PARTNER_SELECTED:"No se ha seleccionado interlocutor ni partida. Por favor haga clic en un jugador del listado.",GUESTS_CANNOT_CHAT:"Los invitados no pueden charlar. Por favor, haga clic en el bot\u00f3n de conexi\u00f3n en la parte superior.",ACCEPT:"Aceptar",DELET
3188E:"Borrar",SEEK:"Buscar",CHALLENGES:"Retos",CONDITIONS:"Condiciones",RATED:"Evaluada",UNRATED:"Amistosa",RETRIEVING_PLAYERS:"Obteniendo jugadores...",
3189DONE:"hecho",TYPE_TO:"Escriba a",KIBITZERS_OF:"espectadores de",SENT_GUEST_APPLAUSE:"Enviar aplauso al rival.",IS_CURRENTLY_EMPTY:"est\u00e1 vac\u00eda \u00bfQuiere ir a la principal?",SEARCH_GAMES:"Buscar partidas",EDIT_FRIENDS:"Editar amigos",EDIT_IGNORES:"Editar ignorados",TOPLIST_FRIENDS:"Amigos",TOPLIST_COUNTRY:"Pa\u00edses",TOPLIST_REGION:"Regiones",TOPLIST_CITY:"Ciudades",WITH_CLOCK:"Con reloj",SERVER_STATISTICS:"Estad\u00edsticas servidor",PLAYCHESS_STATISTICS:"Estad\u00edsticas Playchess",
3190PEAK_CONNECTIONS:"Pico de conexiones",DAILY_GAMES:"Partidas diarias",VISITORS:"Visitantes",UP_SINCE:"Conectado desde",CHALLENGE_X:"Retar",FRIENDS:"Amigos",TOP_LIST:"Clasificaci\u00f3n",USER:"Usuario",CURRENTLY_NO_ACTIVE_MEDIA_BROADCASTS:"Ahora mismo no hay retransmisiones multimedia",SELECT_THE_BROADCAST:"Seleccione la retransmisi\u00f3n",BROADCAST:"Retransmisi\u00f3n",LISTEN_TO_RADIO:"O\u00edr la radio",ZOOM_IN:"Zoom +",ZOOM_OUT:"Zoom -",SELECT_ROOM:"Seleccionar sala",ROOM_TO_VISIT:"Sala a visitar",
3191MAIN_HALL:"Sala principal",TIP_KIBITZ_BLITZ:"Siga las partidas rel\u00e1mpago m\u00e1s fuertes que se est\u00e9n jugando en este momento en Playchess.com",TIP_WATCH_LIVETOURNAMENTS:"Mirar partidas en directo de torneos de grandes maestros",TIP_WATCH_LIVERADIO:"Seguir comentarios con audio (en desarrollo)",TIP_SEND_FEEDBACK:"Enviar comentario a los programadores",TIP_SHOW_STATISTICS:"Mostrar estad\u00edsticas de Playchess.com",TIP_PING_SERVER:"Medir la velocidad de la conexi\u00f3n a Internet",TIP_LOGIN:"Conectar con su cuenta de ChessBase",
3192TIP_RECEIVING_MOVES:"Conectar y desconectar la partida para introducir sus propios an\u00e1lisis",TIP_PLAY_BLITZ:"Iniciar una partida blitz de 5 minutos contra alguien de su misma fuerza.</br>Haga clic en la flecha para seleccionar otros controles de tiempo.",TIP_PLAY_BULLET:"Iniciar una partida bala de 1 minuto contra alguien de su misma fuerza",TIP_PLAY_SLOW:"Iniciar una partida r\u00e1pida contra alguien de su misma fuerza.</br>Haga clic en la flecha para seleccionar otros controles de tiempo.",
3193TIP_ACCOUNT:"Compruebe su Elo y otros elementos de su cuenta",TIP_SELECT_ROOM:"Cambiar entre la sala de su club y la principal",TIP_REMATCH:"Ofrecer la revancha intercambiando los bandos",TIP_REMATCH_OK:"Aceptar la oferta de revancha de su rival",TIP_RESIGN:"Abandonar la partida",TIP_OFFER_DRAW:"Ofrecer tablas",TIP_ACCEPT_DRAW:"Aceptar la oferta de tablas de su rival",TIP_CLAIM_WIN:"Reclamar la victoria porque el rival se ha desconectado del servidor",TIP_PING_OPPONENT:"Pruebe la velocidad de conexi\u00f3n de su rival. Muestra la suma de los retardos de ambos en milisegundos en el panel de charla.",
3194TIP_APPLAUDE:"Enviar un aplauso a su rival, que se mostrar\u00e1 en el panel de charla. Tambi\u00e9n pueden hacerlo los invitados.",YOU_NEED_PREMIUM_MEMBERSHIP:"Necesita una suscripci\u00f3n Premium",YOU_NEED_TO_LOG_ON_TO_USE_THIS_FUNCTION:"Necesita conectarse para usar esta funci\u00f3n",BROWSE_CMS_ARCHIVE:"Buscar archivo CMS",TIP_BROWSE_CMS_ARCHIV:"Examinar en busca del archivo CMS",ROOMS:"Salas",GO_BACK:"Volver",CHAT_AND_NOTATION:"Charla, notaci\u00f3n",LISTS_AND_CHALLENGES:"Listados, retos",LOGIN_TO_PLAY_ELO_OPPONENTS:"Conectar con su cuenta ChessBase para jugar con rivales de su fuerza o charlar.",
3195THANK_YOU_FOR_USING_PLAYCHESS:'Gracias por usar <span style="font-weight:bold">Playchess.com</span> para jugar y mirar partidas.',NOT_RATED:"Amistosa",BLITZ:"Rel\u00e1mpago",BULLET:"Bala",STATUS:"Estado",MORE_BOARDS:"M\u00e1s",LESS_BOARDS:"Menos",NEXT_BOARD:"Next",FULL_VIEW:"Notation and more...",TTIP_BACK_HOME:"Back to home screen",TTIP_MORE_BOARDS:"View more boards",TTIP_LESS_BOARDS:"View less boards",TOGGLE_GAMELIST:"Games List",TTIP_TOGGLE_GAMELIST:"Hide/Show the list of all broadcasted games",
3196MORE_TIME_CONTROLS:"M\u00e1s controles de tiempo",MORE:"M\u00e1s",START_GAME:"Iniciar partida",ARBITER:"\u00c1rbitro",ABORT:"Cancelar",TIP_ABORT:"Cancelar esta partida",STARTING_GAME:"Arrancando la partida, en espera...",GAME_STARTED:"Partida iniciada.",YOU_LOST_ON_TIME:"A usted se le ha ca\u00eddo la bandera. ",YOU_RESIGNED:"Usted se ha rendido",YOU_OFFERED_DRAW:"Usted ha ofrecido tablas",CLICK_DRAW_TO_ACCEPT:"Pulse en 'Tablas' para aceptar.",CLICK_REMATCH_TO_ACCEPT:"Pulse en 'Revancha' para aceptar.",
3197OPPONENT_STILL_ONLINE:"Su rival sigue conectado",CLAIM_ACCEPTED:"Reclamaci\u00f3n aceptada.",LOOKING_FOR_OPPONENT:"Invitando a un rival",RECEIVERS:"Receptores",CLICK_BLITZ_TO_START:"Pulse 'Blitz' para iniciar.",YOU_CLAIM_WIN:"Usted ha reclamado la victoria",READY_TO_START:"Listo para jugar una partida",TIP_10MIN_BLITZ:"Inicia una partida con 10 min por jugador",START_10MIN_BLITZ:"Iniciar una partida a 10 minutos",CUSTOM_SEEK:"Personalizar tiempo",LIVE_CHESS:"Ajedrez en directo",TO_OPPONENT:"Al rival",
3198TO_ALL:"A todos",TO_KIBITZERS:"A los espectadores",PLEASE_SELECT_RECEIVER:"Por favor seleccione un receptor en la comunidad o juegue contra alguien.",CONNECTED_OK:"Conectado OK.",INVITATIONS:"Invitaciones",GAME:"Partida",COMMUNITY:"Comunidad",OPPONENTS:"Rivales",OPPONENT:"Oponente",INVITE_TO_A_GAME:"Invitar a una partida",INVITE_NAME:"Invitar: {0}",SLOW:"Lenta",PLAYCHESS_SIMPLE_HELP:"Pulse un bot\u00f3n para invitar a otros a jugar o acepte una invitaci\u00f3n de la lista de m\u00e1s abajo.",PLAYERS_ONLINE:"Jugadores conectados",
3199SERVER_COMMUNITY:"Comunidad del servidor",INFO_COMMUNITY:"Esta pesta\u00f1
3199a le muestra los jugadores fuertes, gente pr\u00f3xima y administradores del servidor.",COMMUNITY_ACTIONS:"Puede seguir sus partidas, invitarlos a jugar o charlar.",RECENT_OPPONENTS:"Rivales recientes",INFO_RECENT_OPPONENTS:"Esta pesta\u00f1a le mostrar\u00e1 los \u00faltimos oponentes y su marcador contra ellos.",OPPONENT_ACTIONS:"Puede invitarlos a jugar, marcarlos como amigos o charlar con ellos.",MANAGE_FRIENDS:"Gesti\u00f3n de amigos",
3200INFO_FRIENDS:"Presentar\u00e1 una lista de todos sus amigos.",FRIEND_ACTIONS:"Puede ver quien est\u00e1 conectado e invitarlo a jugar o a charlar.",PLEASE_LOGIN_OR_CREATE_ACCOUNT:"Para usarlo por favor identif\u00edquese o cree una cuenta.",STOP_KIBITZING:"Dejar de mirar",DISTANCE:"Distancia",FRIEND:"Amigo",MINUTES:"Minutos",INC_SECONDS:"Segundos por mov.",READY:"Listo",SHOW_THREAT:"Show Threat",TTIP_SHOW_THREAT:"Show your opponents threat",HINT:"Hint",TTIP_HINT:"Click for a hint text",BLUNDER_SHIELD:"Blunder Shield",
3201TTIP_BLUNDER_SHIELD:"Show safe squares for a piece",SPY_MOVE:"Spy Move",TTIP_SPY_MOVE:"Hold your piece over a square and see the answering move",FIFTY_JOKER:"50/50 Joker",TTIP_FIFTY_JOKER:"Check which half of the board contains a good move",THEORY_HINT:"Theory Hint",TTIP_THEORY_HINT:"Show the theory moves",BROWSER_FINE_FOR_HINTS:"Your browser is fine for help & hint calculations.",NO_HINTS_FOR_THIS_POSITION:"No hints for this position.",NO_HINTS_AVAILABLE:"No hints available.",CLICK_CHAT_TAB:"Click on the 'Chat' tab to chat with other players.",
3202DO_NOT_CLOSE_BROWSER:"Please do NOT close or refresh your browser while playing.",YOU_ARE_IN_ROOM:"You are in the room",YOUR_CLUB:"Your Club",JOIN_TOURNAMENT:"Join Tournament",QUIT_TOURNAMENT:"Quit Tournament",YOU_ARE_REGISTERED:"You are registered",CLICK_FOR_STANDINGS:"Click for standings",ARBITER_DECISION_ME:"Arbiter decision in my favour.",OFFER_TAKE_BACK:"Offer Take Back",ACCEPT_TAKE_BACK:"Accept Take Back",XY_OFFERS_TAKE_BACK:"{0} offers that you take your move back",CLICK_BUTTON_ACCEPTS:"Click Button To Accept",
3203KIBITZ:"Kibitz",NO_GAMES_YET:"No Game Yet.",DISCO_NOT_SENT:"Not connected - move not sent.",INVITATION_FROM:"Invitation from {0}",NO_TD_PRESENT:"No Tournament Director present",TOURNAMENT:"Tournament",CLICK_JOIN:"Click 'Join Tournament'.",ROUNDS:"rounds",RETURN_TO_MAIN_ROOM:"Return to the main playing hall",TOURNAMENT_FINISHED:"Tournament finished.",GAMES_REQUIRED:"{0} more games required to increase hints.",PLAY_GAMES_FOR_HINTS:"Play more games to get more hints!",STOP_ANALYSIS:"Close Analysis",
3204BONUS_HINT:"Good move -> one bonus hint.",POSINFO_TITLE:"Piece placement, activity, complexity:"};
3205PlaychessHelp={HELP_MAIN_SCREEN:"C\u00f3mo usar la aplicaci\u00f3n web de playchess.com",HELP_PLAY_BLITZ_GAME:"Jugar blitz (5 minutos).",HELP_PLAY_BULLET_GAME:"Jugar bala (1 minuto).",HELP_PLAY_SLOW_GAME:"Jugar lenta (15 minutos).",HELP_LIVE_TOURNAMENTS:"Mirar las 4 partidas m\u00e1s interesantes de torneos presenciales que se est\u00e9n emitiendo.",HELP_FOLLOW_BEST:"Mirar la partida rel\u00e1mpago m\u00e1s fuerte en juego.",HELP_LOGIN_ACCOUNT:"Con\u00e9ctese con su cuenta de Playchess o cree una",
3206HELP_HEADER_GAME:"Durante la partida",HELP_CLAIM_WIN:"Reclamar victoria. Si su rival parece haber desconectado (no responde), pide al servidor que le adjudique el punto.",HELP_REMATCH:"Ofrecer revancha. Pide al rival que le conceda la revancha con colores cambiados.",HELP_CLOSE:"Cerrar la ventana de tablero. Atenci\u00f3n: si no ha terminado la partida, se interpreta como rendirse.",HELP_MOVE_ENTRY1:"Puede premover, jugar con un clic o jugar al rev\u00e9s (haciendo clic primero en la casilla de destino).",
3207HELP_MOVE_ENTRY2:"Para cancelar una prejugada, haga clic de nuevo sobre la pieza o fuera del tablero. Al promocionar, suelte el bot\u00f3n del rat\u00f3n sobre la pieza a convertir (\u00a1No se preocupe, la dama es enorme!)",HELP_HEADER_KIBITZING:"Mientras se miran partidas",HELP_SPLITTERS:"Arrastre los separadores verticales de los paneles a izquierda y derecha de la zona de tablero para ajustarla al tama\u00f1o deseado.",HELP_WATCH:"Ctrl-clic para seleccionar varias partidas y luego haga clic en en Mirar partidas, en la parte superior del listado, para cargarlas.",
3208HELP_RECEIVING:"Haga clic en \u2018Recibir jugadas\u2019 para conectar y desconectar el env\u00edo de movimientos desde el servidor y hacer sus propios an\u00e1lisis. 
3208Cuando vuelva a hacer clic recibir\u00e1 las partidas originales otra vez.",HELP_ENGINE:"Arrancar un m\u00f3dulo de an\u00e1lisis.",HELP_DOWNLOAD_CLIENT:"Descargue el programa gratuito para Windows con m\u00e1s funciones"};namespace("Loc.Playchess.ESP");Loc.Playchess.ESP=Playchess;namespace("Loc.PlaychessHelp.ESP");
3209Loc.PlaychessHelp.ESP=PlaychessHelp;
3210class Vk{static initInstForListeners(a){a.addListener=Vk.addListener;a.removeListener=Vk.removeListener;a.fireEvent=Vk.fireEvent;a.getListeners=Vk.getListeners;a.enableEvents=Vk.enableEvents;a.eventsEnabled=!0;a.idLstnr=0}static initForListeners(a){Vk.initInstForListeners(a.prototype)}static enableEvents(a){this.eventsEnabled=a}static getListeners(a){a="m_lstOn"+a;var b=this[a];b||(b={},this[a]=b);return b}static addListener(a,b){this.getListeners(a)[++this.idLstnr]=b;return this.idLstnr}static removeListener(a,
3211b){delete this.getListeners(a)[b]}static fireEvent(a,b){if(this.eventsEnabled){var c=this.getListeners(a),d=[],e;for(e in c)if(c.hasOwnProperty(e)){var f=c[e];try{let g=f.apply(this,b);g&&d.push(g)}catch(g){LogException("fireEv="+a,g)}}return d}}static addInstEvent(a,b,c){a[String.formatEx("addOn{0}Listener",b)]=function(d){return this.addListener(b,d)};a[String.formatEx("removeOn{0}Listener",b)]=function(d){this.removeListener(b,d)};a[String.formatEx("fireOn{0}",b)]=function(){let d=[];if(!this[String.formatEx("fireOn{0}",
3212b)].skipped){if(this[String.formatEx("fireOn{0}",b)].delayed)this[String.formatEx("fireOn{0}",b)].needFire=!0;else try{var e=arguments||[];c&&(e=c.call(this));d=this.fireEvent(b,e)}catch(f){LogException("fire-"+b,f)}return d}};a.removeAllListeners=function(){for(var d in this)this.hasOwnProperty(d)&&0==d.search("m_lstOn")&&delete this[d]};a[String.formatEx("delayfireOn{0}",b)]=function(d){d=d||100;this[String.formatEx("fireOn{0}",b)].delayed=!0;var e=this;window.setTimeout(function(){e[String.formatEx("continuefireOn{0}",
3213b)]()},d)};a[String.formatEx("continuefireOn{0}",b)]=function(){this[String.formatEx("fireOn{0}",b)].delayed=!1;this[String.formatEx("fireOn{0}",b)].skipped=!1;if(this[String.formatEx("fireOn{0}",b)].needFire)try{this[String.formatEx("fireOn{0}",b)]()}catch(d){LogException("delfire-"+b,d)}this[String.formatEx("fireOn{0}",b)].needFire=!1};a[String.formatEx("skipfireOn{0}",b)]=function(d){d=d||100;this[String.formatEx("fireOn{0}",b)].skipped=!0;window.setTimeout(()=>{this[String.formatEx("continuefireOn{0}",
3214b)]()},d)}}static addEvent(a,b,c){Vk.addInstEvent(a.prototype,b,c)}}
3215class HashTable{constructor(a,b){a&&(this.funcHash=a);b&&(this.funcEq=b);this.impl={}}funcHash(a){return ObjUtil.hashCode(a)}funcEq(a,b){return a===b}getItem(a){var b=this.funcHash(a);if(b=this.impl[b]){var c=function(d){return this.funcEq(d.key,a)}.bind(this);b=b.filter(c);if(null!=b&&0<b.length)return b[0].value}}setItem(a,b){var c=this.funcHash(a),d=this.impl[c];d||(d=[],this.impl[c]=d);c=0;for(var e=d.length;c<e;++c){var f=d[c];if(this.funcEq(f.key,a)){f.value=b;return}}d.push({key:a,value:b})}removeItem(a){var b=
3216this.funcHash(a),c=this.impl[b];if(c){var d=function(e){return!this.funcEq(e.key,a)}.bind(this);c=c.filter(d);this.impl[b]=c}}clear(){this.impl={}}}"use strict";
3217class ObjUtil{static clone(a,b){b||=new HashTable;var c=b.getItem(a);if(c)return c;a.clone?c=a.clone(b):(c=new a.constructor,b.setItem(a,c),ObjUtil.copyTo(a,c,!1,b));b.setItem(a,c);return c}static clone2(a,b){b||=new HashTable;var c=b.getItem(a);if(c)return c;c=new a.constructor;b.setItem(a,c);return ObjUtil.copyTo2(a,c,b)}static cloneNoFunc(a){a=JSON.stringify(a);return JSON.parse(a)}static copyTo(a,b,c,d){for(var e in a)if(!(c&&e in b)){var f=a[e],g=f;null!=f&&"object"===typeof f&&(g=ObjUtil.clone(f,
3218d));b[e]=g}a.toString!==b.toString&&(b.toString=a.toString);return b}static copyTo2(a,b,c){Object.setPrototypeOf(b,Object.getPrototypeOf(a));for(var d in a){var e=a[d],f=e;null!=e&&"object"===typeof e&&(f=ObjUtil.clone2(e,c));a.hasOwnProperty(d)&&(b[d]=f)}return b}static equals(a,b){if(a.equals)return a.equals(b);for(var c in a)if(!_CMP(a[c],b[c]))return!1;return!0}static isEmpty(a){return!Object.keys(a).length}static isFunction(a){return!!(a&&a.constructor&&a.call&&a.apply)}static isArray(a){return"[object Array]"===
3219Object.prototype.toString.call(a)}static hashCode(a){return a.hashCode?a.hashCode():"object"===typeof a?StringHash(a):djb2(a.toString())}}function _CMP(a,b){if(void 0===a!==(void 0===b))return!1;if(void 0===a&&void 0===b)return!0;
3219if(null===a!==(null===b))return!1;if(null===a&&null===b)return!0;var c=typeof a,d=typeof b;return"object"===c!==("object"===d)?!1:"object"===c&&"object"===d?ObjUtil.equals(a,b):a==b}
3220function djb2(a){for(var b=5381,c,d=0;d<a.length;++d)c=a.charCodeAt(d)&255,b=4294967295&(b<<5)+b+c;return b}function StringHash(a){return djb2(typeof a+a.constructor.toString())}function EnumToString(a,b){for(var c in a)if(a[c]===b)return c;return""}function StringToEnum(a,b){if(b in a)return a[b]}function StringToEnumFlags(a,b){b=b.split("|");for(var c=0,d=0,e=b.length;d<e;++d){var f=StringToEnum(a,b[d]);f&&(c|=f)}return c}
3221function minusToCamel(a){for(var b=a.indexOf("-");0<=b;b=a.indexOf("-")){var c=a.substring(0,b);a=a.substring(b+1);0<a.length&&(a=a.charAt(0).toUpperCase()+(1<a.length?a.substring(1):""));a=c+a}return a}function NOT(a){return function(){return!a.apply(this,arguments)}}function TRUE(){return function(){return!0}}function FALSE(){return function(){return!1}}function IDENTITY(a){return a}function EqualsFilter(a){return function(b,c,d){return ObjUtil.equals(b,a)}}
3222function NoArgs(a){return function(){return a()}}function emptyFunc(){}"use strict";function initArrayUtil(){}Array.prototype.find||(Array.prototype.find=function(a){if("function"!==typeof a)throw new TypeError("predicate must be a function");for(var b=Object(this),c=b.length>>>0,d,e=0;e<c;e++)if(e in b&&(d=b[e],a.call(this,d,e,b)))return d});Array.prototype.all||(Array.prototype.all=function(a){a=a||function(b){return b};return!this.some(function(b,c,d){return!a(b,c,d)})});
3223Array.prototype.findIndex||(Array.prototype.findIndex=function(a){if("function"!==typeof a)throw new TypeError("predicate must be a function");for(var b=Object(this),c=b.length>>>0,d,e=0;e<c;e++)if(e in b&&(d=b[e],a.call(this,d,e,b)))return e;return-1});
3224Array.prototype.pickRandom||(Array.prototype.pickRandom=function(a){a=a||function(k){return 1};for(var b=Object(this),c=b.length>>>0,d,e=void 0,f=0,g=0;g<c;g++)g in b&&(f+=a.call(this,b[g],g,b));var h=Math.random()*f;for(g=f=0;g<c;g++)if(g in b&&(d=b[g],f+=a.call(this,d,g,b),f>=h)){e=d;break}return e});Array.prototype.removeIf||(Array.prototype.removeIf=function(a){a=a||function(c){return!1};for(var b=0;b<this.length;)a(this[b],b,this)?this.splice(b,1):b++});
3225Array.prototype.sum||(Array.prototype.sum=function(a){a=a||function(b){return b};return this.reduce((b,c)=>b+a(c),0)});"use strict";
3226class Handlers{constructor(a){this.scope=a;this.handlers=[]}count(){return this.handlers.length}add(a){this.handlers.push(a);return this.handlers.length-1}remove(a){null!=a&&void 0!==this.handlers[a]&&delete this.handlers[a]}execute(){for(var a=0;a<this.handlers.length;a++)if(void 0!==this.handlers[a])this.handlers[a](this.scope)}empty(){for(var a=0;a<this.handlers.length;a++)if(void 0!==this.handlers[a])return!1;return!0}}"use strict";
3227class StrUtil{static encodeUTF8(a){return unescape(encodeURIComponent(a))}static decodeUTF8(a){return StrUtil.utf8ArrayToStr(a)}static test(){var a=StrUtil.encodeUTF8("Rh\u00f4ne");return StrUtil.mayBeUtf8(a)}static utf8ArrayToStr(a){var b,c,d;var e="";var f=a.length;for(b=0;b<f;
3227){var g=a[b++].charCodeAt(0);switch(g>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:e+=String.fromCharCode(g);break;case 12:case 13:b<f&&(c=a[b++].charCodeAt(0));e+=String.fromCharCode((g&31)<<6|c&63);break;
3228case 14:b<f&&(c=a[b++].charCodeAt(0)),b<f&&(d=a[b++].charCodeAt(0)),e+=String.fromCharCode((g&15)<<12|(c&63)<<6|(d&63)<<0)}}return e}static mayBeUtf8(a){for(var b=!1,c=0;c<a.length&&!b;c++){var d=a.charCodeAt(c);if(d&128)if(194<=d&&223>=d&&128<=a.charCodeAt(c+1)&&191>=a.charCodeAt(c+1))c+=2,b=!0;else if(224==d&&160<=a.charCodeAt(c+1)&&191>=a.charCodeAt(c+1)&&128<=a.charCodeAt(c+2)&&191>=a.charCodeAt(c+2)||(225<=d&&236>=d||238==d||239==d)&&128<=a.charCodeAt(c+1)&&191>=a.charCodeAt(c+1)&&128<=a.charCodeAt(c+
32292)&&191>=a.charCodeAt(c+2)||237==d&&128<=a.charCodeAt(c+1)&&159>=a.charCodeAt(c+1)&&128<=a.charCodeAt(c+2)&&191>=a.charCodeAt(c+2))c+=3,b=!0;else if(240==d&&144<=a.charCodeAt(c+1)&&191>=a.charCodeAt(c+1)&&128<=a.charCodeAt(c+2)&&191>=a.charCodeAt(c+2)&&128<=a.charCodeAt(c+3)&&191>=a.charCodeAt(c+3)||241<=d&&243>=d&&128<=a.charCodeAt(c+1)&&191>=a.charCodeAt(c+1)&&128<=a.charCodeAt(c+2)&&191>=a.charCodeAt(c+2)&&128<=a.charCodeAt(c+3)&&191>=a.charCodeAt(c+3)||244==d&&128<=a.charCodeAt(c+1)&&143>=a.charCodeAt(c+
32301)&&128<=a.charCodeAt(c+2)&&191>=a.charCodeAt(c+2)&&128<=a.charCodeAt(c+3)&&191>=a.charCodeAt(c+3))c+=4,b=!0}return b}static hasASCIIgreater127(a){for(var b=0;b<a.length;b++)if(a.charCodeAt(b)&128)return!0;return!1}static codeURLParameter(a){return StrUtil.base64.encode(a)}static decodeURLParameter(a){return StrUtil.base64.decode(a)}static base64={base64s:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",encode:function(a){if("function"===typeof btoa)return btoa(a);for(var b=this.base64s,
3231c,d,e=0,f="";a.length>=e+3;)c=(a.charCodeAt(e++)&255)<<16|(a.charCodeAt(e++)&255)<<8|a.charCodeAt(e++)&255,f+=b.charAt((c&16515072)>>18)+b.charAt((c&258048)>>12)+b.charAt((c&4032)>>6)+b.charAt(c&63);0<a.length-e&&3>a.length-e&&(d=!!(a.length-e-1),c=(a.charCodeAt(e++)&255)<<16|(d?(a.charCodeAt(e)&255)<<8:0),f+=b.charAt((c&16515072)>>18)+b.charAt((c&258048)>>12)+(d?b.charAt((c&4032)>>6):"=")+"=");return f},decode:function(a){if("function"===typeof atob)return atob(a);var b=this.base64s,c="",d;for(d=
32320;d<a.length;d+=4){var e=(b.indexOf(a.charAt(d))&255)<<18|(b.indexOf(a.charAt(d+1))&255)<<12|(b.indexOf(a.charAt(d+2))&255)<<6|b.indexOf(a.charAt(d+3))&255;c+=String.fromCharCode((e&16711680)>>16,(e&65280)>>8,e&255)}return 61===a.charCodeAt(d-2)?c.substring(0,c.length-2):61===a.charCodeAt(d-1)?c.substring(0,c.length-1):c},decodeToBinary:function(a){this.lookup=new Uint8Array(256);for(var b=0;b<this.base64s.length;b++)this.lookup[this.base64s.charCodeAt(b)]=b;b=.75*a.length;var c=a.length,d=0;"="===
3233a[a.length-1]&&(b--,"="===a[a.length-2]&&b--);var e=new ArrayBuffer(b),f=new Uint8Array(e);for(b=0;b<c;b+=4){var g=this.lookup[a.charCodeAt(b)];var h=this.lookup[a.charCodeAt(b+1)];var k=this.lookup[a.charCodeAt(b+2)];var l=this.lookup[a.charCodeAt(b+3)];f[d++]=g<<2|h>>4;f[d++]=(h&15)<<4|k>>2;f[d++]=(k&3)<<6|l&63}return e}};static getURLParam(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");a=(new RegExp("[\\?&]"+a+"=([^&#]*)")).exec(window.location.href);if(null===a)return"";a=a[1];a.length&&"/"==
3234a.charAt(a.length-1)&&(a=a.slice(0,a.length-1));return a}static hasURLParam(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");return null!==(new RegExp("[\\?&]"+a)).exec(window.location.href)}static shortenURL(a){if(a){var b=a.toLowerCase();b.replace(/</g,"(");b.replace(/>/g,")");b&&15<b.length&&(-1!=a.search("http://")&&(b=b.slice(7)),-1!=a.search("https://")&&(b=b.slice(8)),a=b.indexOf("/"),0<a&&(b=b.slice(0,a)));return b}return""}static trimQuotes(a){a=a.replace("%22",'"');a=a.replace("%27","'");
3235if('"'==a.charAt(0)||"'"==a.charAt(0))a=a.slice(1,a.length-1);return a}static escapeHtmlEntities(a){return a.replace(/[\u00A0-\u2666<>&]/g,function(b){return"&#"+b.charCodeAt(0)+";"})}static htmlEncode(a){return a.replace(/[\u00A0-\u2666<>&]/g,function(b){return"&#"+b.charCodeAt(0)+";"})}static htmlDecode(a){return a.replace(/&#(\d+);/g,function(b,c){return String.fromCharCode(c)})}static tryConvertCyrillicAscii(a){for(var b=0,c="",d=0;d<a.length;
3235d++){var e=a.charCodeAt(d);if(255<e)return a;127<e&&
3236b++;c+=String.fromCharCode(this.conv1252[e])}return b>.7*a.length?c:a}static _randomStringChars="abcdefghijklmnopqr stuvwxyz012345";static getRandomString(a){for(var b=StrUtil._randomStringChars.length,c=[],d=0;d<a;d++)c.push(StrUtil._randomStringChars.substr(Math.floor(Math.random()*b),1));return c.join("")}static conv1252=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,
323769,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,1026,1027,8218,1107,8222,8230,8224,8225,8364,8240,1033,8249,1034,1036,1035,1039,1106,8216,8217,8220,8221,8226,8211,8212,8482,1113,8250,1114,1116,1115,1119,160,1038,1118,1032,164,1168,166,167,1025,169,1028,171,172,173,174,1031,176,177,1030,1110,1169,181,182,183,1105,8470,1108,187,1112,1029,1109,1111,
32381040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103];}var decodeHtmlEntity=function(a){},encodeHtmlEntity=function(a){};
3239function JSONP(a,b,c,d){a=a||"";b=b||{};c=c||"";d=d||function(){};var e=function(k){var l=[],m;for(m in k)k.hasOwnProperty(m)&&l.push(m);return l};if("object"==typeof b){var f="";e=e(b);for(var g=0;g<e.length;g++)f+=encodeURIComponent(e[g])+"="+encodeURIComponent(b[e[g]]),g!=e.length-1&&(f+="&");a+="?"+f}else"function"==typeof b&&(d=c=b);"function"==typeof c&&(d=c,c="callback");Date.now||(Date.now=function(){return(new Date).getTime()});b=Date.now();var h="jsonp"+Math.round(b+1000001*Math.random());
3240window[h]=function(k){d(k);delete window[h]};a=-1===a.indexOf("?")?a+"?":a+"&";b=document.createElement("script");b.setAttribute("src",a+c+"="+h);document.getElementsByTagName("head")[0].appendChild(b)}function byteswap_ushort(a){var b=new ArrayBuffer(2);b=new DataView(b);b.setUInt16(0,a);a=b.GetUint8();b.SetUint8(0,b.GetUint8(1));b.SetUint8(1,a);return b.GetUint16(0)}
3241function byteswap_ulong(a){var b=new ArrayBuffer(4);b=new DataView(b);b.setUInt32(0,a);a=new ArrayBuffer(4);a=new DataView(a);for(var c=0;4>c;c++)a.setUint8(c,b.getUint8(3-c));return a.GetUint32(0)}function byteswap_uint64(a){var b=new ArrayBuffer(8);b=new DataView(b);b.setUInt64(0,a);a=new ArrayBuffer(8);a=new DataView(a);for(var c=0;8>c;c++)a.setUint8(c,b.getUint8(7-c));return a.GetUint64(0)}
3242function getInternetExplorerVersion(){return 0<=navigator.userAgent.indexOf("MSIE ")||navigator.userAgent.match(/Trident.*rv:11\./)?11:-1}function idiv(a,b){return(a-a%b)/b}function isNumber(a){return!isNaN(parseInt(a,10))}function setFlag(a,b,c){if("number"!=typeof b)throw Error("CB.setFlag: number expected for bits");void 0===a.flags&&(a.flags=0);a.flags=c?a.flags|b:a.flags&~b}function isFlag(a,b){return 0!=(a&b)}function isFlagObj(a,b){return isFlag(a.flags,b)}
3243class TimeTools{static getCBTimeOfCentiSecs(a){a=new Date(10*a);return a.getUTCHours()<<24|a.getUTCMinutes()<<16|a.getUTCSeconds()<<8|a.getUTCMilliseconds()/10}}function removeById(a,b){var c=-1;a.forEach(function(d,e){d.id===b&&(c=e)});0<=c&&a.splice(c,1)}"use strict";
3244class Timer{constructor(a){this.handler=a;this.active=!1;this.arrIndex=-1}launch(a){this.runOnce(0,a)}runOnce(a,b){if(this.inHandler)this.fnAfterHandler=function(){this.runOnce(a,b)}.bind(this);else{if("undefined"==typeof a||null==a)a=5E3;b&&(this.handler=b);this.stop();this.isPeriodic=!1;this.active=!0;this.timeout=a;this.timer=window.setTimeout(this.timeoutHandler.bind(this),this.timeout);this.tick=new Tick}}runPeriodic(a,b){b&&(this.handler=b);this.stop();this.active=this.isPeriodic=!0;this.timeout=
3245a||5E3;this.timer=window.setInterval(this.timeoutHandler.bind(this),this.timeout);this.tick=new Tick}runArray(a){this.timeouts=a;this.stop();this.arrIndex=0;this.isPeriodic=!1;this.active=!0;this.timer=window.setTimeout(this.timeoutHandler.bind(this),this.timeouts[this.arrIndex++]);this.tick=new Tick}restart(){this.active&&(this.stop(),this.active=!0,this.timer=this.isPeriodic?window.setInterval(this.timeoutHandler.bind(this),this.timeout):window.setTimeout(this.timeoutHandler.bind(this),this.timeout),
3246this.tick=new Tick)}getExpiredMS(){return this.tick?this.tick.getExpiredMS():0}stop(){this.isPeriodic?window.clearInterval(this.timer):window.clearTimeout(this.timer);this.active=!1;0<=this.arrIndex&&(this.arrIndex=-1)}start(){this.runOnce(this.timeout)}isActive(){return this.active}timeoutHandler(){this.inHandler=!0;this.handler&&this.handler();this.inHandler=!1;this.active=this.isPeriodic;this.fnAfterHandler&&(this.fnAfterHandler(),delete this.fnAfterHandler);0<this.arrIndex&&this.timeouts[this.arrIndex]&&
3247(this.active=!0,this.isPeriodic=!1,this.timer=window.setTimeout(this.timeoutHandler.bind(this),this.timeouts[this.arrIndex++]),this.tick=new Tick)}getTimeoutMs(){return this.timeout?this.timeout:0}static busyWait(a){for(a+=(new Date).getTime();new Date<a;);}static launch(a,b){b=b||100;(new Timer).runOnce(b,a)}}var hasHiResTimer=window.performance&&window.performance.now;
3248class Tick{constructor(){this.start()}start(){this.ticker=hasHiResTimer?window.performance.now():(new Date).valueOf()}getExpired(){return hasHiResTimer?Math.round(100*(window.performance.now()-this.ticker))/100:(new Date).valueOf()-this.ticker}logTime(a){var b="";a&&(b=a+": ");b+=this.getExpired()+"ms";this.start();return b}getExpiredMS(){return Math.round(this.getExpired())}}function getTick(){return hasHiResTimer?Math.round(window.performance.now()):(new Date).valueOf()}
3249function getHiResTick(){return hasHiResTimer?window.performance.now():(new Date).valueOf()}class TimeSpan{constructor(a){this.autoRestart=void 0!==a?a:!0;this.start()}start(){this.tick=(new Date).valueOf()}isElapsed(a){return this.getElapsedMilliSecs()>1E3*a?(this.autoRestart&&this.start(),!0):!1}getElapsedMilliSecs(){return(new Date).valueOf()-this.tick}}
3250class V10{exec(a,b){this.timer?.stop();this.timer=new Timer(a);this.milliSecs=b;this.timer.runOnce(b)}isActive(){return this.timer?.isActive()??!1}stop(){this.timer?.stop()}restart(){this.isActive()&&(this.timer.stop(),this.timer.runOnce(this.milliSecs||1E3))}}
3251class BlockGate{constructor(){this.blocked=!1;this.milliSecs=100}block(a,b){this.blocked&&this.fn&&(this.fn(),this.fn=null);this.blocked=a;b&&(this.milliSecs=b)}exec(a){this.blocked?(this.timer&&this.timer.stop(),this.fn=a,this.timer=new Timer(function(){this.fn&&(this.fn(),this.fn=null)}.bind(this)),this.timer.runOnce(this.milliSecs)):a()}isActive(){return this.timer&&this.timer.isActive()}stop(){this.timer&&this.timer.stop()}restart(){this.isActive()&&(this.timer.stop(),this.timer.runOnce(this.milliSecs||
32521E3))}}CB=CB||{};CB.Timer=Timer;CB.hasHiResTimer=hasHiResTimer;CB.Tick=Tick;CB.getTick=getTick;CB.getHiResTick=getHiResTick;CB.TimeSpan=TimeSpan;CB.V10=V10;window.V10=V10;window.BlockGate=BlockGate;"use strict";
3253class CBDate{constructor(a,b,c){a&&(this.year=a);b&&(this.month=b);c&&(this.day=c)}static g_regexPGN=/(?:(\d{4})|\?{4})\.(?:(\d{2})|\?{2})\.(?:(\d{2})|\?{2})/;static fromPGNString(a){return(a=CBDate.g_regexPGN.exec(a))?new CBDate(Number(a[1]),Number(a[2]),Number(a[3])):new CBDate}static today(){var a=new CBDate;a.setToday();return a}static getThisYear(){var a=new CBDate;a.setToday();return a.getYear()}toString(){return String.formatEx("{day}.{month}.{year}",this)}constructFromNum(a){this.year=a>>
32549;this.month=a>>5&15;this.day=a&31}setToday(){var a=new Date;this.year=a.getFullYear();this.month=a.getMonth()+1;this.day=a.getDate()}getNum(){return this.year<<9|this.month<<5|this.day}fromDataBuf(a){a=a.V19();this.constructFromNum(a)}V17(a){a.V13(this.year<<9|this.month<<5|this.day)}
3254toLocaleString(){var a="";this.year&&(a=this.year.toString(),this.month&&(a=this.month.toString()+"."+a,10>this.month&&(a="0"+a),this.day&&(a=this.day.toString()+"."+a,10>this.day&&(a="0"+a))));return a}toPGNString(){var a=
3255"";if(this.year){a=this.year.toString();if(this.month){var b=this.month.toString();10>this.month&&(b="0"+b);a+="."+b}else a+=".??";this.day?(b=this.day.toString(),10>this.day&&(b="0"+b),a+="."+b):a+=".??"}return a}getDay(){return this.day}setDay(a){this.day=a}getMonth(){return this.month}setMonth(a){this.month=a}getYear(){return this.year}setYear(a){this.year=a}getShortDateString(a){var b=a.getDate().toString(),c=(a.getMonth()+1).toString();a=a.getFullYear();alert("notimpl");return a+c+b}}"use strict";
3256class CBTime{constructor(a){this.time=a||0}fromJSDate(a){this.setHour(a.getHours());this.setMinute(a.getMinutes());this.setSecond(a.getSeconds())}fromHourMin(a,b){this.setHour(a);this.setMinute(b)}toJSDate(){var a=new Date;a.setTime(Date.now());a.setHours(this.getHour());a.setMinutes(this.getMinute());a.setSeconds(this.getSecond());a.setMilliseconds(0);return a}static now(){var a=new Date;a.setTime(Date.now());var b=new CBTime;b.fromJSDate(a);return b}static test(){var a=new Date;a.setTime(Date.now());
3257a.setHours(15);a.setMinutes(30);a.setSeconds(20);a.setMilliseconds(0);var b=new CBTime;b.fromJSDate(a);console.log(b.toString());var c=b.toJSDate();console.log(a.getTime()+" "+c.getTime());console.log(b.getDiffIn100ths(CBTime.now())/100);return a.getTime()===c.getTime()}toString(){var a=new Date;a.setUTCHours(this.getHour());a.setUTCMinutes(this.getMinute());a.setUTCSeconds(this.getSecond());return a.toLocaleTimeString()}toUtc(){var a=new Date;a.setHours(this.getHour());a.setMinutes(this.getMinute());
3258a.setSeconds(this.getSecond());this.setHour(a.getUTCHours());this.setMinute(a.getUTCMinutes());this.setSecond(a.getUTCSeconds());return this}getHour(){return this.time>>24}getMinute(){return this.time>>16&255}getSecond(){return this.time>>8&255}get100th(){return this.time&255}setHour(a){this.time&=16777215;this.time|=a%100<<24}setMinute(a){this.time&=4278255615;this.time|=a%60<<16}setSecond(a){this.time&=4294902015;this.time|=a%60<<8}setTimeInMinutes(a){this.time=0;var b=Math.floor(a/60);a-=60*b;
3259this.setHour(b);this.setMinute(a)}getTimeInMinutes(){return 60*this.getHour()+this.getMinute()}addMinutes(a){this.setTimeInMinutes(this.getTimeInMinutes()+a)}toLocal(){var a=new Date;a.setUTCHours(this.getHour());a.setUTCMinutes(this.getMinute());a.setUTCSeconds(this.getSecond());this.setHour(a.getHours());this.setMinute(a.getMinutes());this.setSecond(a.getSeconds())}getTimeIn100th(){return 36E4*this.getHour()+6E3*this.getMinute()+100*this.getSecond()+this.get100th()}getDiffIn100ths(a){return this.getTimeIn100th()-
3260a.getTimeIn100th()}}
3261class DateAndTime{constructor(){this.nYear=this.nMonth=this.nDay=this.nHour=this.nMinute=this.nSecond=this.nMilliSecond=this.nMicroSecond=this.utcTimeVal=0}V17(a){a.V15(this.utcTimeVal)}fromDataBuf(a){a.V18(this.utcTimeVal)}computeFields(){this.computeGregorian(this.toJulianDay())}computeGregorian(a){var b=Math.floor(a-1721118.5);a=a-1721118.5-b;var c=b-.25,d=Math.floor(c/36524.25);d-=Math.floor(d/4);this.nYear=Math.floor((d+c)/365.25);b=d+b-Math.floor(365.25*this.nYear);this.nMonth=Math.floor((5*
3262b+456)/153);this.nDay=b-Math.floor((153*this.nMonth-457)/5)+a;12<this.nMonth&&(++this.nYear,this.nMonth-=12);a*=24;this.nHour=Math.floor(a);a-=Math.floor(a);a*=60;this.nMinute=Math.floor(a);a-=Math.floor(a);a*=60;this.nSecond=Math.floor(a);a-=Math.floor(a);a*=1E3;this.nMilliSecond=Math.floor(a);a-=Math.floor(a);this.nMicroSecond=1E3*a+.5;this.normalize()}daysOfMonth(a,b){return 2==b&&this.isLeapYear(a)?29:[0,31,28,31,30,31,30,31,31,30,31,30,31][b]}normalize(){1E3<this.nMicroSecond&&(this.nMilliSecond+=
3263this.nMicroSecond/1E3,this.nMicroSecond%=1E3);1E3<this.nMilliSecond&&(this.nSecond+=this.nMilliSecond/1E3,this.nMilliSecond%=1E3);60<this.nSecond&&(this.nMinute+=this.nSecond/60,this.nSecond%=60);60<this.nMinute&&(this.nHour+=this.nMinute/60,this.nMinute%=60);24<this.nHour&&(this.nDay+=this.nHour/24,this.nHour%=24);this.nDay>this.daysOfMonth(this.nYear,this.nMonth)&&(this.nDay-=this.daysOfMonth(this.nYear,this.nMonth),12<++this.nMonth&&(++this.nYear,this.nMonth-=12))}isLeapYear(a){return 0==a%4&&
3264(0!=a%100||0==a%400)}static toJulianDay(a){return a/864E9+2299160.5}}
3265class CBGuid{constructor(){this.uint16Data3=this.uint16Data2=this.uint32Data1=0;this.uint8Data4=[0,0,0,0,0,0,0,0]}fromRandom(a){var b=0;if(void 0!==a)for(var c=0;c<a.length;
3265c++)b+=a.charCodeAt(c);this.uint32Data1=Math.floor(4294967296*Math.random()+b);this.uint16Data2=Math.floor(65536*Math.random()+b);this.uint16Data3=Math.floor(65536*Math.random()+b);for(c=0;8>c;c++)this.uint8Data4[c]=Math.floor(256*Math.random()+b)}toString(){for(var a=this.uint32Data1.toString(16)+"-"+this.uint16Data2.toString(16)+
3266"-"+this.uint16Data3.toString(16)+"-",b=0;2>b;b++)a+=this.uint8Data4[b].toString(16);a+="-";for(b=2;8>b;b++)a+=this.uint8Data4[b].toString(16);return a}V17(a){a.Vu(this.uint32Data1);a.Vv(this.uint16Data2);a.Vv(this.uint16Data3);for(var b=0;8>b;b++)a.writeUint8(this.uint8Data4[b])}fromDataBuf(a){this.uint32Data1=a.Vw();this.uint16Data2=a.Vv();this.uint16Data3=a.Vv();for(var b=0;8>b;b++)this.uint8Data4[b]=a.readUint8()}}window.CBGuid=CBGuid;"use strict";
3267const NAT={NONE:0,AFG:1,ALB:2,ALG:3,AND:4,ANG:5,ANT:6,ARG:7,ARM:8,AUS:9,AUT:10,AZE:11,BAH:12,BHN:13,BAN:14,BAR:15,BLR:16,BEL:17,BLZ:18,BER:19,BOL:20,BIH:21,BOT:22,BRA:23,IVB:24,BRN:25,BUL:26,BUR:27,CAN:28,CHI:29,CHN:30,COL:31,CRI:32,CRO:33,CUB:34,CYP:35,CZE:36,DEN:37,DJI:38,DOM:39,ECU:40,EGY:41,ENG:42,ESP:43,EST:44,ETH:45,FAI:46,FIJ:47,FIN:48,FRA:49,MKD:50,GAM:51,GEO:52,GER:53,GHA:54,GRE:55,GUA:56,GCI:57,GUY:58,HAI:59,HON:60,HKG:61,HUN:62,ISL:63,IND:64,INA:65,IRI:66,IRQ:67,ISR:68,IRL:69,ITA:70,IVO:71,
3268JAM:72,JPN:73,JCI:74,JOR:75,KAZ:76,KEN:77,KOR:78,KYR:79,KUW:80,LAT:81,LBN:82,LBY:83,LIE:84,LTU:85,LUX:86,MAC:87,MAD:88,MAS:89,MLI:90,MLT:91,MAU:92,MRI:93,MEX:94,MDA:95,MNC:96,MON:97,MAR:98,MOZ:99,MYA:100,NAM:101,NEP:102,NED:103,AHO:104,NZL:105,NCA:106,NGR:107,NOR:108,PAK:109,PLE:110,PAN:111,PNG:112,PAR:113,PER:114,PHI:115,POL:116,POR:117,PUR:118,QAT:119,ROU:120,RUS:121,ESA:122,SMR:123,SCO:124,SEN:125,SEY:126,SIN:127,SVK:128,SLO:129,RSA:130,SRI:131,SUD:132,SUR:133,SWE:134,SUI:135,SYR:136,TJK:137,TAN:138,
3269THA:139,TRI:140,TUN:141,TUR:142,TKM:143,UGA:144,UKR:145,UAE:146,USA:147,URU:148,URS:149,UZB:150,VEN:151,VIE:152,ISV:153,WLS:154,YEM:155,YUG:156,ZAM:157,ZIM:158,ZRE:159,DDR:160,CSR:161,CAM:162,CHD:163,KAP:164,KBA:165,COM:166,CON:167,NKO:168,LAO:169,LES:170,MWI:171,MDV:172,MSH:173,OMN:174,NAU:175,MIC:176,NIG:177,SAU:178,TOG:179,TON:180,VAN:181,VAT:182,TUV:183,SWA:184,SIE:185,SLU:186,PAP:187,SVI:188,SAM:189,SKI:190,SAL:191,GE2:192,ZAR:193,RWA:194,LBR:195,NET:196,TPE:197,ASU:198,AGG:199,ARN:200,BNN:201,
3270BTN:202,BRI:203,CMB:204,CAY:205,CAR:206,CIB:207,CIA:208,COA:209,CIN:210,ELG:211,ERI:212,FGB:213,FRG:214,FRP:215,GAB:216,GGB:217,GRA:218,GRL:219,FGA:220,GMA:221,GUI:222,GUB:223,IOM:224,JMY:225,MFR:226,MYF:227,MSG:228,NCF:229,NNN:230,NNA:231,NMI:232,OTM:233,PAL:234,PIG:235,RUF:236,SAO:237,SOM:238,SVN:239,HGB:240,PGB:241,TKI:242,TCI:243,WFR:244,NIR:245,ISS:246,GBR:247,SAA:248,MNE:249,SRB:250,CAT:251,BAS:252,KOS:253,NUM:254};
3271var Nation=function(){var a=[];a[NAT.NONE]="United Nations";a[NAT.AFG]="Afghanistan";a[NAT.ALB]="Albania";a[NAT.ALG]="Algeria";a[NAT.ASU]="American samoa";a[NAT.AND]="Andorra";a[NAT.ANG]="Angola";a[NAT.AGG]="Anguilla";a[NAT.ANT]="Antigua and Barbuda";a[NAT.ARG]="Argentina";a[NAT.ARM]="Armenia";a[NAT.ARN]="Aruba";a[NAT.AUS]="Australia";a[NAT.AUT]="Austria";a[NAT.AZE]="Azerbaijan";a[NAT.BAH]="Bahamas";a[NAT.BHN]="Bahrain";a[NAT.BAN]="Bangladesh";a[NAT.BAR]="Barbados";a[NAT.BAS]="Basque Country";a[NAT.BLR]=
3272"Belarus";a[NAT.BEL]="Belgium";a[NAT.BLZ]="Belize";a[NAT.BNN]="Benin";a[NAT.BER]="Bermuda";a[NAT.BTN]="Bhutan";a[NAT.BOL]="Bolivia";a[NAT.BIH]="Bosnia and Herzegovina";a[NAT.BOT]="Botswana";a[NAT.BRA]="Brazil";a[NAT.IVB]="Virgin Islands British";a[NAT.ISV]="Virgin Islands US";a[NAT.BRN]="Brunei";a[NAT.BUL]="Bulgaria";a[NAT.BUR]="Burkina faso";a[NAT.BRI]="Burundi";a[NAT.CMB]="Cambodja";a[NAT.CAM]="Cameroon";a[NAT.CAN]="Canada";a[NAT.KAP]="Cape verde";a[NAT.CAY]="Cayman Islands";a[NAT.CAR]="Central African Republic";
3273a[NAT.CAT]="Catalonia";a[NAT.CHD]="Chad";a[NAT.CIB]="Jersey";a[NAT.CHI]="Chile";a[NAT.CHN]="China";a[NAT.CIA]="Christmas";a[NAT.COA]="Cocos (Keeling)";a[NAT.COL]="Colombia";a[NAT.COM]="Comoros";a[NAT.CON]="Congo-Brazzaville";a[NAT.CIN]="Cook Islands";a[NAT.CRI]="Costa Rica";a[NAT.CRO]="Croatia";a[NAT.CUB]="Cuba";a[NAT.CYP]="Cyprus";a[NAT.CZE]="Czech Republic";a[NAT.DEN]="Denmark";
3273a[NAT.DJI]="Djibouti";a[NAT.DOM]="Dominican Republic";a[NAT.ECU]="Ecuador";a[NAT.ELG]="Equatorial Guinea";a[NAT.EGY]="Egypt";
3274a[NAT.ENG]="England";a[NAT.ERI]="Eritrea";a[NAT.ESP]="Spain";a[NAT.EST]="Estonia";a[NAT.ETH]="Ethiopia";a[NAT.FGB]="England";a[NAT.FAI]="Faroes";a[NAT.FIJ]="Fiji";a[NAT.FIN]="Finland";a[NAT.FRA]="France";a[NAT.FRG]="Guyana";a[NAT.FRP]="Tahiti(French Polinesia)";a[NAT.MKD]="Macedonia";a[NAT.GAB]="Gabon";a[NAT.GAM]="Gambia";a[NAT.GEO]="Georgia";a[NAT.GER]="Germany";a[NAT.SAA]="Germany";a[NAT.DDR]="Germany";a[NAT.GE2]="Germany";a[NAT.GHA]="Ghana";a[NAT.GGB]="Gibraltar";a[NAT.GRE]="Greece";a[NAT.GRA]=
3275"Grenada";a[NAT.GRL]="Greenland";a[NAT.FGA]="Guadeloupe";a[NAT.GMA]="Guam";a[NAT.GUA]="Guatemala";a[NAT.GUI]="Guinea";a[NAT.GUB]="Guinea-Bissau";a[NAT.GCI]="Guernsey";a[NAT.GUY]="Guyana";a[NAT.HAI]="Haiti";a[NAT.HON]="Honduras";a[NAT.HKG]="Hong Kong";a[NAT.HUN]="Hungary";a[NAT.ISL]="Iceland";a[NAT.IND]="India";a[NAT.INA]="Indonesia";a[NAT.IRI]="Iran";a[NAT.IRQ]="Iraq";a[NAT.IOM]="Isle of MAN";a[NAT.ISR]="Israel";a[NAT.IRL]="Ireland";a[NAT.ITA]="Italy";a[NAT.IVO]="Cote d'Ivoire";a[NAT.JAM]="Jamaica";
3276a[NAT.JMY]="Svalbard and Jan Mayen";a[NAT.JPN]="Japan";a[NAT.JCI]="Jersey";a[NAT.JOR]="Jordan";a[NAT.KAZ]="Kazakhstan";a[NAT.KEN]="Kenya";a[NAT.KBA]="Kiribati";a[NAT.KOR]="South Korea";a[NAT.KYR]="Kyrgyzstan";a[NAT.KUW]="Kuwait";a[NAT.LAO]="Laos";a[NAT.LAT]="Latvia";a[NAT.LBN]="Lebanon";a[NAT.LES]="Lesotho";a[NAT.LBR]="Liberia";a[NAT.LBY]="Libya";a[NAT.LIE]="Liechtenstein";a[NAT.LTU]="Lithuania";a[NAT.LUX]="Luxembourg";a[NAT.MAC]="Macao";a[NAT.MAD]="Madagascar";a[NAT.MAS]="Malaysia";a[NAT.MLI]="Mali";
3277a[NAT.MLT]="Malta";a[NAT.MWI]="Malawi";a[NAT.MFR]="Martinique";a[NAT.MAU]="Mauritania";a[NAT.MRI]="Mauritius";a[NAT.MYF]="Mayotte";a[NAT.MEX]="Mexico";a[NAT.MIC]="Micronesia";a[NAT.MDA]="Moldova";a[NAT.MNC]="Monaco";a[NAT.MON]="Mongolia";a[NAT.MSG]="Montserrat";a[NAT.MAR]="Morocco";a[NAT.MOZ]="Mozambique";a[NAT.MYA]="Myanmar(Burma)";a[NAT.NAM]="Namibia";a[NAT.NEP]="Nepal";a[NAT.NED]="Netherlands";a[NAT.AHO]="Netherlands Antilles";a[NAT.NCF]="New caledonia";a[NAT.NET]="United Nations";a[NAT.NZL]="New zealand";
3278a[NAT.NCA]="Nicaragua";a[NAT.NGR]="Nigeria";a[NAT.NNN]="Niue";a[NAT.NNA]="Norfolk";a[NAT.NMI]="Northern Mariana";a[NAT.NOR]="Norway";a[NAT.OTM]="Timor-Leste";a[NAT.PAK]="Pakistan";a[NAT.PAL]="Palau";a[NAT.PLE]="Palestine";a[NAT.PAN]="Panama";a[NAT.PNG]="Papua new GUINEA";a[NAT.PAR]="Paraguay";a[NAT.PER]="Peru";a[NAT.PHI]="Philippines";a[NAT.PIG]="Pitcairn";a[NAT.POL]="Poland";a[NAT.POR]="Portugal";a[NAT.PUR]="Puerto rico";a[NAT.QAT]="Qatar";a[NAT.RUF]="Reunion";a[NAT.ROU]="Romania";a[NAT.URS]="Russian Federation";
3279a[NAT.RUS]="FIDE";a[NAT.ZAR]="Russian Federation";a[NAT.ESA]="El Salvador";a[NAT.SMR]="San Marino";a[NAT.SAO]="Sao Tome and PRINCIPE";a[NAT.SCO]="Scotland";a[NAT.SEN]="Senegal";a[NAT.YUG]="Serbia(Yugoslavia)";a[NAT.SRB]="Serbia(Yugoslavia)";a[NAT.SEY]="Seychelles";a[NAT.SIN]="Singapore";a[NAT.SVK]="Slovakia";a[NAT.SLO]="Slovenia";a[NAT.SOM]="Somalia";a[NAT.RSA]="South africa";a[NAT.SRI]="Sri lanka";a[NAT.SUD]="Sudan";a[NAT.SUR]="Suriname";a[NAT.SVN]="Svalbard and Jan Mayen";a[NAT.SWE]="Sweden";a[NAT.SUI]=
3280"Switzerland";a[NAT.SYR]="Syria";a[NAT.HGB]="Saint Helena";a[NAT.PGB]="Saint Pierre and Miquelon";a[NAT.TJK]="Tajikistan";a[NAT.TAN]="Tanzania";a[NAT.THA]="Thailand";a[NAT.TKI]="Tokelau";a[NAT.TRI]="Trinidad and Tobago";a[NAT.TUN]="Tunisia";a[NAT.TCI]="Turks and Caicos Islands";a[NAT.TUR]="Turkey";a[NAT.TKM]="Turkmenistan";a[NAT.UGA]="Uganda";a[NAT.UKR]="Ukraine";a[NAT.UAE]="United Arab Emirates";a[NAT.USA]="United States of America";a[NAT.URU]="Uruguay";a[NAT.UZB]="Uzbekistan";a[NAT.VEN]="Venezuela";
3281a[NAT.VIE]="Viet Nam";a[NAT.WLS]="Wales";a[NAT.WFR]="Wallis and Futuna";a[NAT.YEM]="Yemen";a[NAT.ZAM]="Zambia";a[NAT.ZIM]="Zimbabwe";a[NAT.ZRE]="Congo-Kinshasa(Zaire)";a[NAT.NKO]="North korea";a[NAT.MDV]="Maldives";a[NAT.MSH]="Marshall Islands";a[NAT.OMN]="Oman";a[NAT.NAU]="Nauru";a[NAT.NIG]="Niger";a[NAT.SAU]="Saudi Arabia";a[NAT.TOG]="Togo";a[NAT.TON]="Tonga";a[NAT.VAN]="Vanuatu";a[NAT.VAT]="Vatican City";a[NAT.TUV]="Tuvalu";a[NAT.SWA]="Swaziland";a[NAT.SIE]="Sierra Leone";a[NAT.SLU]="Saint Lucia";
3282a[NAT.PAP]="Papua New Guinea";a[NAT.SVI]="St Vincent and The Grenadines";a[NAT.SAM]="Samoa";a[NAT.SKI]="St Kitts and NEVIS";a[NAT.SAL]="Solomon islands";a[NAT.RWA]="Rwanda";a[NAT.TPE]="Taiwan";a[NAT.NIR]="Northern Ireland";a[NAT.GBR]="United Kingdom(Great Britain)";a[NAT.KOS]="Kosovo";var b=[],c=function(d){this.n=d;void 0===this.n&&(this.n=NAT.NONE);if(0==b.length){d=0;for(var e in NAT)NAT.hasOwnProperty(e)&&(b[d]=e,d+=1);for(e=0;e<b.length;e++){var f=a[e];void 0===f&&(f=a[0]);d=b[e];1<d.length&&
3283(f=window.escape(f),f=" background-image: url( "+getCommonPath()+"media/flags/flags16/"+f+".png ) !important;",CBCSS.addRules(".cls-"+d,f+"background-repeat:no-repeat; background-position:center center;"))}}};c.prototype.getStrCode=function(){return b[this.n]};c.prototype.getStrFlag=function(){return a[this.n]?a[this.n]:a[NAT.NONE]};c.getFlagRaster=function(){return[16,24,32,48,64]};c.getRasteredFlagHeight=function(d){let e=c.getFlagRaster();for(let f=0;f<e.length-1;f++)if(d>e[f]&&d<e[f+1])return e[f];
3284return d};return c}();"use strict";
3285class System{static getStrOS(){this.strOS||(this.getiOSVersion()&&(this.strOS="iOS"+this.getiOSVersion()),this.getAndroidVersion()&&(this.strOS="Andr"+this.getAndroidVersion()),this.isWindows()&&(this.strOS="Win"),this.isLinux()&&(this.strOS="Ux"),this.isMac()&&(this.strOS="Mac"),this.strOS=navigator.platform);return this.strOS}
3285static getOSChar(){var a="X";this.isWindows()?a="W":this.isMac()?a="M":this.isIPhone()||this.isIPad()?a="I":this.isAndroid()?a="A":this.isLinux()&&(a="L");return a}static getStrSysInfo(){return this.getStrOS()+
3286" "+String.f("{0}/{1}/{2}, cpus={3}",window.innerWidth,window.innerHeight,window.devicePixelRatio,this.getNCpus())}static isCordova(){return"cordova"===StrUtil.getURLParam("client")||!!window.cordova}static isMobile(){return/Kindle|Silk|KFAPW|KFARWI|KFASWI|KFFOWI|KFJW|KFMEWI|KFOT|KFSAW|KFSOWI|KFTBW|KFTHW|KFTT|WFFOWI/i.test(navigator.userAgent)?!0:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|bada|Opera Mini/i.test(navigator.userAgent)}static isDesktop(){return!System.isMobile()&&1400<screen.width&&
3287900<=screen.height}static isElectron(){return-1<navigator.userAgent.toLowerCase().indexOf(" electron/")}static requestFullScreen(){var a=document.documentElement;a.requestFullscreen?a.requestFullscreen():a.webkitrequestFullscreen?a.webkitrequestFullscreen():a.mozrequestFullscreen?a.mozrequestFullscreen():a.msrequestFullscreen&&a.msrequestFullscreen()}static isFullScreen(){return document.fullscreen||document.webkitIsFullScreen||document.mozFullScreen||(screen.availHeight||screen.height-30)<=window.innerHeight}static isAtLeastTablet(){7;
3288return 1E3<=screen.width&&760<=screen.height||1E3<=screen.height}static isIPhone(){return/iPhone/i.test(navigator.userAgent)||/iPod/i.test(navigator.userAgent)}static isIPad(){return/iPad/i.test(navigator.userAgent)}static getiOSVersion(){return parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||!1}static shouldWarnIOS(){try{let a=this.getiOSVersion().toString();if(a){let b=a.split(".");
3289if(2==b.length&&"15"==b[0]&&3==parseInt(b[1]))return!0}}catch(a){console.log(a)}}static isWindows(){return/Win32/i.test(navigator.platform)}static isLinux(){return/Linux/i.test(navigator.platform)}static isMac(){return/Mac/i.test(navigator.platform)}static isTouchDevice(){void 0===this.isTouchChecked&&(this.isTouchChecked=this.isMobile()||"ontouchstart"in window||0<navigator.MaxTouchPoints||0<navigator.msMaxTouchPoints);return this.isTouchChecked}static runsInIFrame(){try{return window.self!==window.top&&
3290-1==document.referrer.search(/google/i)&&-1==document.referrer.search(/bing/i)}catch(a){return!0}}
3290static getWindowPos(){if(void 0!==window.screenLeft)return new CBPoint(window.screenLeft,window.screenTop);if(void 0!==window.screenX)return new CBPoint(window.screenX,window.screenY)}static getWindowSize(){var a=window,b=document,c=b.documentElement;b=b.getElementsByTagName("body")[0];return new CBSize(a.innerWidth||c.clientWidth||b.clientWidth,a.innerHeight||c.clientHeight||b.clientHeight)}static getTimeZone(){return String(String(new Date).split("(")[1]).split(")")[0]}static isHighResScreen(){return 1400<=
3291screen.width&&900<=screen.height}static isPortraitScreen(a){return screen.width*(a||1)<screen.height}static getLanguage(){return navigator.language}static getSystemLanguage(){return navigator.systemLanguage||window.navigator.language}static getWindowsCodePage(){if(document.inputEncoding)switch(document.inputEncoding){default:return 1252;case "ISO-8859-11":return 874;case "Windows-31J":return 932;case "ISO-8859-2":return 1250;case "ISO-8859-5":return 1251;case "ISO-8859-1":return 1252;case "ISO-8859-7":return 1253;
3292case "ISO-8859-9":return 1254;case "ISO-8859-8":return 1255;case "ISO-8859-6":return 1256;case "ISO-8859-13":return 1257}else return 1252}static getInternetExplorerVersion(){var a=-1;"Microsoft Internet Explorer"==navigator.appName&&null!=RegExp("MSIE ([0-9]{1,}[.0-9]{0,})").exec(navigator.userAgent)&&(a=parseFloat(RegExp.$1));return a}static useExtJSTouchCSS(){return this.isMobile()||this.isTouchDevice()}static isBrowserOk(){return void 0!==Function.prototype.bind&&"undefined"!==typeof console&&
3293"WebSocket"in window?11<=this.getIEVersion()?!0:this.isAndroidBrowser()&&4.2>=this.getAndroidVersion()||this.isSafariOnWindows()&&535>this.getSafariVersion()&&!this.isChrome()?!1:!0:!1}static isHTTPS(){return document.location&&document.location.protocol?"http:"!=document.location.protocol:window.location&&window.location.protocol?"http:"!=window.location.protocol:!1}static getIEVersion(){var a=window.navigator.userAgent,b=a.indexOf("MSIE ");if(0<b)return parseInt(a.substring(b+5,a.indexOf(".",b)),
329410);if(0<a.indexOf("Trident/"))return b=a.indexOf("rv:"),parseInt(a.substring(b+3,a.indexOf(".",b)),10);b=a.indexOf("Edge/");if(0<b||0<a.indexOf("Edg/"))return parseInt(a.substring(b+5,a.indexOf(".",b)),10)}static getFirefoxVersion(){var a=window.navigator.userAgent.match(/Firefox\/([0-9]+)\./);return a?parseInt(a[1]):0}static isNonCrossDomainIE(){var a=this.getIEVersion();return a?12>a:!1}static canRunWebAssembly(){return"object"===typeof WebAssembly}static isActivexEnabled(){var a=null;try{a=!!new ActiveXObject("htmlfile")}catch(b){a=
3295!1}return a}static isWebKit(){return null!=window.webkitURL}static isChrome(){return-1!=navigator.userAgent.indexOf("Chrome")}static isSafari(){return-1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")&&-1==navigator.userAgent.indexOf("CriOS")}static isFirefox(){return-1!=navigator.userAgent.indexOf("Firefox")}static isIE(){return 0<this.getIEVersion()}static isOldIE(){return 0<this.getIEVersion()&&12>this.getIEVersion()}static isNewEdge(){return-1==navigator.userAgent.indexOf("Edge")&&
3296-1!=navigator.userAgent.indexOf("Edg")}static isOpera(){return-1!=navigator.userAgent.indexOf("OPR")}static browserIsSafeForEngine(a){var b=this.getIEVersion(),c=this.getFirefoxVersion(),d=parseFloat(this.getSafariVersion());b=System.canRunWebAssembly()||this.isChrome()||11<=b||54<=c||600<d;return b=System.getNCpus()?b&&System.getNCpus()>=(a||4):b&&System.canRunWebAssembly()}static browserIsOld(){var a=this.getIEVersion(),b=this.getFirefoxVersion(),c=parseFloat(this.getSafariVersion());return!(this.isChrome()||
329711<=a||54<=b||600<c||System.canRunWebAssembly())}static isAndroidBrowser(){return 0<=navigator.userAgent.indexOf("Android")&&-1==navigator.userAgent.indexOf("Chrome")}static isAndroid(){return 0<this.getAndroidVersion()}static isSafariOnWindows(){return 0<=navigator.userAgent.indexOf("Windows")&&0<=navigator.userAgent.indexOf("Safari")}static getSafariVersion(){var a=navigator.userAgent;return 0<=a.indexOf("Safari")?parseFloat(a.slice(a.indexOf("Safari")+7)):0}
3297static copyToClipboard(a){if("string"==
3298typeof a)if(navigator.clipboard)navigator.clipboard.writeText(a);else{var b=document.createElement("textarea");b.value=a;document.body.appendChild(b);b.focus();b.select();try{document.execCommand("copy")}catch(c){}document.body.removeChild(b)}else navigator.clipboard&&navigator.clipboard.write(a)}static getAndroidVersion(){var a=navigator.userAgent;return 0<=a.indexOf("Android")?parseFloat(a.slice(a.indexOf("Android")+8)):0}static isWebGlCapable(a){if(window.WebGLRenderingContext)for(var b=document.createElement("canvas"),
3299c=["webgl","experimental-webgl","moz-webgl","webkit-3d"],d=!1,e=0;4>e;e++)try{if((d=b.getContext(c[e]))&&"function"==typeof d.getParameter)return a?{name:c[e],gl:d}:!0}catch(f){}return!1}static urlSearch(a){return-1!=document.URL.search(a)}static V3(){return this.urlSearch(/chessbase.com/i)&&!this.urlSearch(/cloudserver/i)||this.urlSearch(/playchess.com/i)||this.urlSearch(/schach.de/i)}static runsOnTestDomain(){return this.urlSearch(/wir.chessbase.com/i)||this.urlSearch(/videotraining.chessbase.com/i)||
3300this.urlSearch(/test.chessbase.com/i)||this.urlSearch(/localhost/i)}static runsOnChessBaseCom(){return this.urlSearch(/chessbase.com/i)}static runsOnChessBaseNews(){return this.urlSearch(/en.chessbase.com/i)||this.urlSearch(/de.chessbase.com/i)||this.urlSearch(/es.chessbase.com/i)||this.urlSearch(/fr.chessbase.com/i)}static runsOnLiveChessBaseCom(){return this.urlSearch(/live.chessbase.com/i)||this.urlSearch(/liv.chessbase.com/i)||this.urlSearch(/test.chessbase.com/i)}static runsOnVideosChessBaseCom(){return this.urlSearch(/videos.chessbase.com/i)||
3301this.urlSearch(/videostest.chessbase.com/i)}static runsOnLocalHost(){return this.urlSearch(/localhost/i)}static runsOnBooks(){return this.urlSearch(/books.chessbase/i)||this.urlSearch(/books2.chessbase/i)||this.urlSearch(/tutorials.chessbase/i)}static getDevicePixelRatio(){return window.devicePixelRatio}static overrideDeviceZoom(a){this.overriddenDeviceZoom=a}static pixToZoom(a){return this.overriddenDeviceZoom?a/this.overriddenDeviceZoom:window.devicePixelRatio?a/window.devicePixelRatio:a}static zoomToPix(a){return this.overriddenDeviceZoom?
3302a*this.overriddenDeviceZoom:window.devicePixelRatio?a*window.devicePixelRatio:a}static getNCpus(){return window.navigator.hardwareConcurrency?window.navigator.hardwareConcurrency:0}static getDeviceMemory(){return navigator.deviceMemory?navigator.deviceMemory:0}static getHardwareId(){return this.getDeviceMemory()+navigator.platform+this.getNCpus()+this.getSystemLanguage()+this.getTimeZone()}static browser=class{static detect(){return{browser:this.search(this.data.browser),version:this.search(navigator.userAgent)||
3303this.search(navigator.appVersion),os:this.search(this.data.os)}}static search(a){if("object"===typeof a)for(var b=0;b<a.length;b++){var c=a[b].string,d=a[b].prop;this.version_string=a[b].versionSearch||a[b].identity;if(c){if(-1!=c.indexOf(a[b].subString))return a[b].identity}else if(d)return a[b].identity}else return b=a.indexOf(this.version_string),-1==b?void 0:parseFloat(a.substr(b+this.version_string.length+1))}static data={browser:[{string:navigator.userAgent,subString:"Chrome",identity:"Chrome"},
3304{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari",versionSearch:"Version"},{prop:window.opera,identity:"Opera",versionSearch:"Version"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,
3305subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],os:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.userAgent,subString:"iPhone",identity:"iPhone/iPod"},
3306{string:navigator.userAgent,subString:"iPad",identity:"iPad"},{string:navigator.userAgent,subString:"Android",identity:"Android"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};};}CB.System=System;"use strict";
3307class Language{static ENG=0;static DEU=1;static GER=1;static FRA=2;static ESP=3;static ITA=4;static NED=5;static POR=6;static DEF=7;static SLO=8;static SWE=9;static BAS=10;static SVK=11;static POL=12;static CZE=13;static CAT=14;static TRK=15;static MGY=16;static RUS=17;static GRK=18;static ROM=19;static CHN=20;static UN=21;static NOR=22;static HEB=23;static UKR=24;static VIE=25;static ARA=26;static SER=27;static LIT=28;static BRA=29;static FAR=30;static CRO=31;static GAL=32;static HIN=33;static getStrUserLanguage(){return void 0!==navigator.languages&&
3308navigator.languages.length?navigator.languages[0]:void 0!==navigator.language?navigator.language:void 0!==navigator.userLanguage?navigator.userLanguage:"en-en"}
3308static getStrUserLanguageTwoChars(){return this.getStrUserLanguage().slice(0,2)}static getAccountPageLangSegment(){let a=this.getStrUserLanguageTwoChars();return-1==["en","de","es","fr"].findIndex(b=>b==a)?"en":a}static getUserLanguageId(){var a=Language.getStrUserLanguage();return this.getLanguageIdOfParam(a)}static getLanguageIdOfParam(a){return-1<
3309a.indexOf("de")?this.DEU:-1<a.indexOf("es")?this.ESP:-1<a.indexOf("nl")?this.NED:-1<a.indexOf("fr")?this.FRA:-1<a.indexOf("it")?this.ITA:-1<a.indexOf("sl")?this.SLO:-1<a.indexOf("sv")?this.SWE:-1<a.indexOf("ro")?this.ROM:-1<a.indexOf("zh")?this.CHN:-1<a.indexOf("ru")?this.RUS:-1<a.indexOf("no")?this.NOR:-1<a.indexOf("pl")?this.POL:-1<a.indexOf("he")?this.HEB:-1<a.indexOf("ca")?this.CAT:-1<a.indexOf("tr")?this.TRK:-1<a.indexOf("sl")?this.SLO:-1<a.indexOf("el")?this.GRK:-1<a.indexOf("uk")?this.UKR:
3310-1<a.indexOf("vi")?this.VIE:-1<a.indexOf("ar")?this.ARA:-1<a.indexOf("sr")?this.SER:-1<a.indexOf("lt")?this.LIT:-1<a.indexOf("pt-br")||-1<a.indexOf("pt")?this.BRA:-1<a.indexOf("fa")?this.FAR:-1<a.indexOf("ga")?this.GAL:-1<a.indexOf("hr")?this.CRO:-1<a.indexOf("hi")?this.HIN:-1<a.indexOf("cs")?this.CZE:this.ENG}static getParamOfLanguageId(a){switch(a){default:case Language.ENG:return"en";case Language.DEU:return"de";case Language.ESP:return"es";case Language.NED:return"nl";case Language.FRA:return"fr";
3311case Language.ITA:return"it";case Language.POR:return"pt";case Language.SLO:return"sl";case Language.SWE:return"sv";case Language.ROM:return"ro";case Language.CHN:return"zh";case Language.RUS:return"ru";case Language.NOR:return"no";case Language.POL:return"pl";case Language.HEB:return"he";case Language.CAT:return"ca";case Language.TRK:return"tr";case Language.GRK:return"el";case Language.UKR:return"uk";case Language.VIE:return"vi";case Language.ARA:return"ar";case Language.SER:return"sr";case Language.LIT:return"lt";
3312case Language.BRA:return"pt";case Language.FAR:return"fa";case Language.CRO:return"hr";case Language.GAL:return"ga";case Language.HIN:return"hi";case Language.CZE:return"cs"}}static getHelpParamOfLanguageId(a){switch(a){default:case Language.ENG:return"en";case Language.DEU:return"de";case Language.ESP:return"es";case Language.FRA:return"fr";case Language.NED:return"nl";case Language.ITA:return"it"}}
3312static getRibbonFlagName(a){switch(a){default:case Language.ENG:return"en-us"==this.getStrUserLanguage()?
3313"us":"gb";case Language.DEU:return"de-at"==this.getStrUserLanguage()?"at":"de";case Language.ESP:return"es";case Language.NED:return"nl";case Language.ROM:return"ro";case Language.CHN:switch(this.getStrUserLanguage()){default:case "zh-cn":return"cn";case "zh-tw":return"tw";case "zh-sg":return"si";case "zh-hk":return"hk"}case Language.FRA:return"fr";case Language.RUS:return"ru";case Language.NOR:return"no";case Language.ITA:return"it";case Language.POL:return"pl";case Language.UN:return"_United_Nations";
3314case Language.HEB:return"il";case Language.CAT:return"_Catalonia";case Language.TRK:return"tr";case Language.SLO:return"si";case Language.GRK:return"gr";case Language.UKR:return"ua";case Language.VIE:return"vn";case Language.ARA:return"sa";case Language.SER:return"rs";case Language.LIT:return"lt";case Language.BRA:return"br";case Language.FAR:return"ir";case Language.CRO:return"hr";case Language.GAL:return"ie";case Language.HIN:return"in";case Language.CZE:return"cz"}}static getInternalName(a){switch(a){default:case Language.ENG:return"ENG";
3315case Language.DEU:case Language.GER:return"GER";case Language.ESP:return"ESP";case Language.NED:return"NED";case Language.ROM:return"ROM";case Language.CHN:return"CHN";case Language.FRA:return"FRA";case Language.RUS:return"RUS";case Language.NOR:return"NOR";case Language.POL:return"POL";case Language.ITA:return"ITA";case Language.HEB:return"HEB";case Language.CAT:return"CAT";case Language.TRK:return"TRK";case Language.SLO:return"SLO";case Language.UN:return"UN";case Language.GRK:return"EL";case Language.UKR:return"UKR";
3316case Language.VIE:return"VIE";case Language.ARA:return"ARA";case Language.SER:return"SER";case Language.LIT:return"LIT";case Language.BRA:return"BRA";case Language.FAR:return"FAR";case Language.CRO:return"CRO";case Language.GAL:return"GAL";case Language.HIN:return"HIN";case Language.CZE:return"CZE"}}static getNativeLangName(a){switch(a){default:case Language.ENG:return"English";case Language.DEU:return"Deutsch";case Language.ESP:return"Espa\u00f1ol";case Language.NED:return"Nederlands";case Language.ROM:return"Rom\u00e2n";
3317case Language.CHN:return"\u4e2d\u6587";case Language.FRA:return"Fran\u00e7ais";case Language.RUS:return"\u0420\u0443\u0441\u0441\u043a\u0438\u0439";case Language.NOR:return"Norsk";case Language.POL:return"Polski";case Language.ITA:return"Italiano";case Language.HEB:return"\u05e2\u05d1\u05e8\u05d9\u05ea";case Language.CAT:return"Catal\u00e0";case Language.TRK:return"T\u00fcrk\u00e7e";case Language.SLO:return"Slovenski";case Language.GRK:return"\u0395\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac";case Language.UKR:return"\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430";
3318case Language.VIE:return"Ti\u1ebfng Vi\u1ec7t";case Language.ARA:return"\u0627\u0644\u0639\u0631\u0628\u064a\u0629";case Language.SER:return"Srbski";case Language.LIT:return"Lietuvi\u0173";case Language.BRA:return"Portugu\u00eas";case Language.FAR:return"\u0641\u0627\u0631\u0633\u06cc";case Language.CRO:return"Hrvatski";case Language.GAL:return"Gaeilge";case Language.HIN:return"\u0939\u093f\u0928\u094d\u0926\u0940";case Language.CZE:return"\u010ce\u0161tina"}}static getNativeLangNames(a){var b=[];
3319a.forEach(function(c){b.push(Language.getNativeLangName(c))}.bind(this));return b}static getFlagNames(a){var b=[];a.forEach(function(c){b.push(Language.getRibbonFlagName(c))}.bind(this));return b}}"use strict";
3320class GeoCoordinates{constructor(a,b){this.fLat=a;this.fLong=b;this.nNation=this.fHeight=0}isValid(){return 0!=this.fLat||0!=this.fLong}toString(){return""}fromDataBuf(a){this.fLat=a.readFloat32();this.fLong=a.readFloat32();this.nNation=a.V19()}V17(a){a.writeFloat32(this.fLat);a.writeFloat32(this.fLong);a.V13(this.nNation)}getSphericDist(a){return this.fLat==a.fLat&&this.fLong==a.fLong?0:6378*Math.acos(Math.sin(GeoCoordinates.dtr(this.fLat))*Math.sin(GeoCoordinates.dtr(a.fLat))+Math.cos(GeoCoordinates.dtr(this.fLat))*
3321Math.cos(GeoCoordinates.dtr(a.fLat))*Math.cos(GeoCoordinates.dtr(a.fLong-this.fLong)))}getAzimuthDirection(a){return-Math.atan2(Math.sin(GeoCoordinates.dtr(this.fLong-a.fLong))*M
3321ath.cos(GeoCoordinates.dtr(this.fLat)),Math.cos(GeoCoordinates.dtr(this.fLat))*Math.sin(GeoCoordinates.dtr(a.fLat))-Math.sin(GeoCoordinates.dtr(this.fLat))*Math.cos(GeoCoordinates.dtr(a.fLat))*Math.cos(GeoCoordinates.dtr(this.fLong-a.fLong)))}getNewPoint(a,b){var c=a/6378;a=Math.acos(Math.cos(c)*Math.cos(GeoCoordinates.dtr(90-
3322this.fLat))+Math.sin(GeoCoordinates.dtr(90-this.fLat))*Math.sin(c)*Math.cos(GeoCoordinates.dtr(b)));b=Math.asin(Math.sin(c)*Math.sin(GeoCoordinates.dtr(b))/Math.sin(a));a=90-GeoCoordinates.rtd(a);b=GeoCoordinates.rtd(b)+this.fLon;return new GeoCoordinates(a,b)}fromBrowser(){navigator.geolocation.getCurrentPosition(function(a){this.fLat=a.coords.latitude;this.fLong=a.coords.longitude;this.fHeight=a.coords.altitude},function(a){},{enableHighAccuracy:!1,timeout:2E4,maximumAge:"Infinite"})}static dtr(a){return Math.PI/
3323180*a}static rtd(a){return a/(Math.PI/180)}}"NOMINIFY=w,h,topLeft";"use strict";
3324class CBPoint{constructor(a,b){"object"==typeof a&&"undefined"==typeof b?void 0!=a.clientX?this.set(a.clientX,a.clientY):a.touches&&a.touches.length?this.set(a.touches[0].pageX,a.touches[0].pageY):void 0!=a.pageX&&this.set(a.pageX,a.pageY):this.set(a,b)}set(a,b){this.x=a;this.y=b}add(a){return new CBPoint(this.x+a.x,this.y+a.y)}subtract(a){return new CBPoint(this.x-a.x,this.y-a.y)}getDist(a){a=this.subtract(a);return Math.sqrt(a.x*a.x+a.y*a.y)}getVecLen(){return Math.sqrt(this.x*this.x+this.y*this.y)}toInt(){this.x=
3325Math.floor(this.x+.5);this.y=Math.floor(this.y+.5)}cloneIntPoint(){var a=new CBPoint(this.x,this.y);a.toInt();return a}toString(){return"("+this.x+","+this.y+")"}getX(){return this.x}getY(){return this.y}}class CBSize{constructor(a,b){this.w=a;this.h=b}toString(){return"w="+this.w+", h="+this.h}centerInSize(a){return new CBPoint((a.w-this.w)/2,(a.h-this.h)/2)}}
3326class CBRect{constructor(a,b,c,d){this.left=a||0;this.top=b||0;this.right=c||0;this.bottom=d||0}get w(){return this.getSize().w}set w(a){this.right=this.left+a-1}get h(){return this.getSize().h}set h(a){this.bottom=this.top+a-1}get topLeft(){return new CBPoint(this.left,this.top)}set topLeft(a){var b=this.w,c=this.h;this.left=a.x;this.top=a.y;this.w=b;this.h=c}static factory(a){let b=new CBRect;b.fromRect(a);return b}fromRect(a){this.left=a.left;this.top=a.top;this.right=a.right;this.bottom=a.bottom}fromPosSize(a,
3327b){this.left=a.x;this.top=a.y;this.right=a.x+b.w-1;this.bottom=a.y+b.h-1}fromClientRect(a){this.left=a.left;this.top=a.top;this.right=a.right;this.bottom=a.bottom}fromTwoPoints(a,b,c,d){this.left=Math.min(a,c);this.right=Math.max(a,c);this.top=Math.min(b,d);this.bottom=Math.max(b,d)}toString(){return"l="+this.left+", t="+this.top+" "+this.getSize().toString()}getPos(){return new CBPoint(this.left,this.top)}getTopLeft(){return new CBPoint(this.left,this.top)}getTopRight(){return new CBPoint(this.right,
3328this.top)}getBottomRight(){return new CBPoint(this.right,this.bottom)}getBottomLeft(){return new CBPoint(this.left,this.bottom)}getSize(){return new CBSize(this.right-this.left+1,this.bottom-this.top+1)}getUnion(a){if(!a)return new CBRect(this.left,this.top,this.right,this.bottom);let b=this.left,c=this.right,d=this.top,e=this.bottom;try{b=Math.min(Math.min(this.left,a.left),Math.min(this.right,a.right)),c=Math.max(Math.max(this.left,a.left),Math.max(this.right,a.right)),d=Math.min(Math.min(this.top,
3329a.top),Math.min(this.bottom,a.bottom)),e=Math.max(Math.max(this.top,a.top),Math.max(this.bottom,a.bottom))}catch(f){console.log("getUnion Exc")}return new CBRect(b,d,c,e)}getCutAtBoundary(a){var b=new CBRect(this.left,this.top,this.right,this.bottom);if(b.left<a.left||b.left>=a.right)b.left=a.left;if(b.right>a.right||b.right<=a.left)b.right=a.right;if(b.top<a.top||b.top>=a.bottom)b.top=a.top;if(b.bottom>a.bottom||b.bottom<=a.top)b.bottom=a.bottom;return b}isInside(a,b){return a>=this.left&&a<=this.right&&
3330b>=this.top&&b<=this.bottom}getPath(){var a=new CBPath;a.push(this.getTopLeft());a.push(this.getTopRight());a.push(this.getBottomRight());a.push(this.getBottomLeft());return a}move(a,b){this.left+=a;this.top+=b;this.right+=a;this.bottom+=b}shrink(a,b){this.left+=a;this.right-=a;this.top+=b;this.bottom-=b}expand(a,b){this.shrink(-a,-b)}}
3331class CBVector{constructor(a,b,c){this.set(a,b,c)}set(a,b,c){this.x=a;this.y=b;this.z=c}add(a){return new CBVector(this.x+a.x,this.y+a.y,this.z+a.z)}subtract(a){return new CBPoint(this.x-a.x,this.y-a.y,this.z-a.z)}getLength(){return void 0!==this.z?Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z):Math.sqrt(this.x*this.x+this.y*this.y)}negate(){this.x=-this.x;this.y=-this.y;void 0!==this.z&&(this.z=-this.z)}toString(){return void 0!==this.z?"("+this.x+","+this.y+","+this.z+")":"("+this.x+","+this.y+
3332")"}}
3333class CBPath{constructor(){this.subPaths=[]}toString(){for(var a="Pth:",b=0;b<this.subPaths.length;b++)a+="s=",this.subPaths[b].forEach(function(c,d,e){a+=c.toString();e<d.length-1&&(a+=",")});return a}push(a){0===this.subPaths.length&&this.subPaths.push([]);this.subPaths[this.subPaths.length-1].push(a)}exec(a){a.beginPath();for(var b=0;b<this.subPaths.length;b++)1<this.subPaths[b].length&&this.execPoly(a,this.subPaths[b]);
3333a.closePath()}execPoly(a,b){a.moveTo(b[0].x,b[0].y);for(var c=1;c<b.length;c++)a.lineTo(b[c].x,b[c].y)}curve(a){for(var b=
33340;b<this.subPaths.length;b++)3<this.subPaths[b].length&&(a.beginPath(),this.execCurve(a,this.subPaths[b]),a.closePath())}execCurve(a,b){a.moveTo(b[0].x,b[0].y);var c;for(c=1;c<b.length-2;c++)a.quadraticCurveTo(b[c].x,b[c].y,(b[c].x+b[c+1].x)/2,(b[c].y+b[c+1].y)/2);a.quadraticCurveTo(b[c].x,b[c].y,b[c+1].x,b[c+1].y)}reverse(){this.subPaths.length&&this.subPaths[this.subPaths.length-1].reverse()}append(a){this.subPaths=this.subPaths.concat(a.subPaths)}}
3335var CanvasTools={clipRect:function(a,b){b.getPath().exec(a);a.clip()},clipRectFrame:function(a,b,c){b=b.getPath();c=c.getPath();c.reverse();b.append(c);this.clipPath(a,b)},drawRect:function(a,b,c){c&&(a.strokeStyle=c);b.getPath().exec(a);a.stroke()},fillRect:function(a,b,c){c&&(a.fillStyle=c);b.getPath().exec(a);a.fill()},clipPath:function(a,b){b.exec(a);a.clip()},drawLine:function(a,b,c,d,e){a.beginPath();a.moveTo(b,c);a.lineTo(d,e);a.stroke()},drawRoundedRect:function(a,b,c,d,e,f,g){d<2*f&&(f=d/
33362);e<2*f&&(f=e/2);a.beginPath();a.moveTo(b+f,c);a.arcTo(b+d,c,b+d,c+e,f);a.arcTo(b+d,c+e,b,c+e,f);a.arcTo(b,c+e,b,c,f);a.arcTo(b,c,b+d,c,f);g&&(a.fillStyle=g,a.closePath(),a.fill());a.stroke()},saveImage:function(a,b,c,d){if(a=CanvasTools.imgToBlob(a,c,d))return window.saveAs(a,b),a},imgToBlob:function(a,b,c){var d=document.createElement("canvas");d.width=b;d.height=c;a.data&&a.data.length?d.getContext("2d").putImageData(a,0,0):d.getContext("2d").drawImage(a,0,0);return CanvasTools.dataURItoBlob(d.toDataURL())},
3337dataURItoBlob:function(a){var b=atob(a.split(",")[1]);a=a.split(",")[0].split(":")[1].split(";")[0];for(var c=new ArrayBuffer(b.length),d=new Uint8Array(c),e=0;e<b.length;e++)d[e]=b.charCodeAt(e);if(window.Blob)return new Blob([c],{type:a})}};class CBColor{constructor(a,b,c,d){this.red=a;this.green=b;this.blue=c;this.alpha=void 0!==d?d:1}toString(){return`rgba( ${Math.round(this.red)}, ${Math.round(this.green)}, ${Math.round(this.blue)}, ${this.alpha} )`}}
3338class CBHSLColor{constructor(a,b,c,d){this.hue=a;this.saturation=b;this.lightness=c;this.alpha=d||1}toString(){return 1>this.alpha?`hsla( ${Math.round(this.hue)}, ${Math.round(this.saturation)}%, ${Math.round(this.lightness)}%, ${this.alpha} )`:`hsl( ${Math.round(this.hue)}, ${Math.round(this.saturation)}%, ${Math.round(this.lightness)}% )`}static get RED(){return 0}static get YELLOW(){return 60}static get GREEN(){return 120}static get CYAN(){return 180}static get BLUE(){return 240}static get MAGENTA(){return 300}}
3339"use strict";
3340class CBBitmap{constructor(a){this.loaded=!1;this.height=this.width=0;this.url="";this.callOnLoaded=function(){}}isValid(){return this.loaded}fromUrl(a){if(a){this.image=new Image;if(glApp&&glApp.config.externalCommonPath||-1!=a.search("chessbase.com"))if(0>a.search("data:image/png;base64")||!System.isSafari())this.image.crossOrigin="Anonymous";this.image.addEventListener("load",this.onLoaded.bind(this));this.image.addEventListener("error",this.onError.bind(this));this.url=a;this.image.src=a}else LogException("bmp._fromUrl",
3341"no url")}static createFromDB(a,b){var c=new CBBitmap;a.getItem(b,function(d,e){var f=!1;e&&!d&&((d=(window.URL||window.webkitURL).createObjectURL(e))?(c.fromUrl(d),c.urlToRevoke=d,f=!0):LogException("Bitmap::fromDB","imgURL null"));f||c.fromUrl(b)});return c}getPattern(a){if("undefined"!=typeof this.image&&this.loaded)return a.createPattern(this.image,"repeat")}copyFromCtx(a,b,c,d,e){try{this.imageData=a.getImageData(b,c,d,e),this.loaded=!0,this.width=d,this.height=e}catch(f){console.log(f)}}copyScaledFromCtx(a,
3342b,c,d,e,f,g){try{void 0===this.canvas&&(this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d")),this.canvas.width=d,this.canvas.height=e,0<b+d&&0<c+e&&this.context&&a&&(this.context.drawImage(a.canvas,b,c,f,g,0,0,d,e),this.imageData=this.context.getImageData(0,0,d,e)),this.loaded=!0,this.width=d,this.height=e}catch(h){console.log(h)}}draw(a,b,c,d,e,f,g,h,k){if(isNaN(b)||isNaN(c)){var l=this.url.substring(0,30);LogException("BmpDraw","NaN + "+l+Error().stack)}else if(l=
3343Function.prototype.call.bind(Array.prototype.slice),this.loaded)try{if(void 0!==this.imageData){var m=l(arguments);m.splice(0,1,this.imageData);a.putImageData.apply(a,m)}else void 0!==this.image&&(m=l(arguments),m.splice(0,1,this.image),a.drawImage.apply(a,m))}catch(n){LogException("BMP draw",n)}}drawStretched(a,b,c,d,e){this.loaded&&(void 0!==this.imageData?a.putImageData(this.imageData,b,c,d,e):void 0!==this.image&&a.drawImage(this.image,b,c,d,e))}drawTiled(a,b,c,d,e){this.loaded&&(void 0!==this.imageData?
3344this.tile(a,this.imageData,a.putImageData,b,c,d,e):void 0!==this.image&&this.tile(a,this.image,a.drawImage,b,c,d,e))}tile(a,b,c,d,e,f,g){if(isNaN(d)||isNaN(e))a=this.url.substring(0,30),LogException("Tile","NaN + "+a+Error().stack);else if(0==this.width||0==this.heigth)console.log("wh is NULL!"+this.width+", "+this.height);else{new CBRect(d,e,d+f,e+g);for(var h=e,k=d;h<e+g;){for(;k<d+f;){var l=this.width,m=this.height;k+l>d+f&&(l=d+f-k);h+m>e+g&&(m=e+g-h);try{c.call(a,b,0,0,l,m,k,h,l,m)}catch(n){LOG("Bitmap Exception: "+
3345n+", "+this.url,"LogException"),LogException("BMP tile: ",n)}k+=this.width}k=d;h+=this.height}}}onLoaded(){this.loaded=!0;this.width=this.image.width;this.height=this.image.height;this.callOnLoaded();this.urlToRevoke&&(window.URL||window.webkitURL).revokeObjectURL(this.urlToRevoke)}onError(){5}}"use strict";
3346class Sprite{constructor(){this.bitmap=new CBBitmap;this.backSave=new CBBitmap;this.hotY=this.hotX=this.backX=this.backY=-1;this.pos=new CBPoint(0,0);this.lastPos=new CBPoint(0,0);this.isVisible=this.loaded=!1;this.h=this.w=0}toString(){return this.pos.toString()}fromUrl(a){this.bitmap.callOnLoaded=this.onLoaded.bind(this);this.bitmap.fromUrl(a)}copyFromCtx(a,b,c){this.bitmap.copyFromCtx(a,b,c);this.onLoaded()}fromUrlSized(a,b){this.bitmap.callOnLoaded=function(){var c=document.createElement("canvas");
3347c&&(c=c.getContext("2d"))&&(this.bitmap.drawStretched(c,0,0,b,b),this.bitmap.copyFromCtx(c,0,0,b,b),this.onLoaded())}.bind(this);this.bitmap.fromUrl(a)}onLoaded(){this.w=this.bitmap.width;this.h=this.bitmap.height;this.hotX=Math.floor(this.w/2);this.hotY=Math.floor(this.h/2);this.loaded=!0}setPos(a){this.pos=a.cloneIntPoint()}moveTo(a,b){this.bitmap.loaded&&(this.lastPos=this.pos,this.pos=b=b.cloneIntPoint(),this.backSave.isValid()&&this.backSave.draw(a,this.backX-this.hotX,this.backY-this.hotY),
3348this.externalBG&&(this.backSave=new CBBitmap),this.externalBG=!1,this.backSave.copyFromCtx(a,b.x-this.hotX,b.y-this.hotY,this.w,this.h),this.backX=b.x,this.backY=b.y,this.drawWithShadow(a,b.x-this.hotX,b.y-this.hotY),this.isVisible=!0)}
3348setBackground(a){a&&(this.externalBG=!0,this.backSave=a,this.backX=this.pos.x,this.backY=this.pos.y)}hasBackground(){return this.backSave.loaded||this.externalBG}hide(a){if(this.backSave.isValid()&&this.isVisible)return this.backSave.draw(a,this.backX-this.hotX,this.backY-
3349this.hotY),this.isVisible=!1,!0}saveBeforeMove(a,b){b=b.cloneIntPoint();this.externalBG&&(this.backSave=new CBBitmap,this.externalBG=!1);this.backSave.copyFromCtx(a,b.x-this.hotX,b.y-this.hotY,this.w,this.h);this.backX=b.x;this.backY=b.y}moveToNoSave(a,b){this.bitmap.loaded&&(this.lastPos=this.pos,this.pos=b=b.cloneIntPoint(),this.drawWithShadow(a,b.x-this.hotX,b.y-this.hotY),this.isVisible=!0)}show(a){this.backSave.isValid()&&this.hotX&&(this.backSave.draw(a,this.backX-this.hotX,this.backY-this.hotY),
3350this.externalBG&&(this.backSave=new CBBitmap,this.externalBG=!1),this.backSave.copyFromCtx(a,this.backX-this.hotX,this.backY-this.hotY,this.w,this.h),this.drawWithShadow(a,this.backX-this.hotX,this.backY-this.hotY),this.isVisible=!0)}saveBackground(a){this.externalBG&&(this.backSave=new CBBitmap,this.externalBG=!1);this.backSave.copyFromCtx(a,this.backX-this.hotX,this.backY-this.hotY,this.w,this.h)}drawWithShadow(a,b,c){a.save();if(37<this.bitmap.width&&!this.noShadow){var d=Math.min(3,Math.round(Math.sqrt(this.bitmap.width/
335130)));a.shadowOffsetX=d;a.shadowOffsetY=d;a.shadowBlur=1*d;a.shadowColor="rgba( 40, 18, 10, 0.24 )"}this.bitmap.draw(a,b,c);
3351a.restore()}deleteBackground(){this.externalBG=!1;this.backSave=new CBBitmap;this.backY=this.backX=-1}setClickArea(a){this.clickArea=a}getMoveClipRect(){return new CBRect(Math.min(this.pos.x,this.lastPos.x)-this.hotX,Math.min(this.pos.y,this.lastPos.y)-this.hotY,Math.max(this.pos.x,this.lastPos.x)+this.hotX,Math.max(this.pos.y,this.lastPos.y)+this.hotY)}}
3352class CBAnimation{constructor(a){this.cbcanvas=a;this.STARTING_FPS=30;this.gameTime=this.lastTime=0;this.startTime=this.getTimeNow();this.fps=0;this.jobs=[];this.callInAnimation=[]}kill(){window.cancelAnimationFrame(this.requestFrame);this.callInAnimation=[];this.inAnimation=!1;if(this.jobs.length){LOG("Kill Animation, Jobs="+this.jobs.length,"LogRed","Board");for(var a=0;a<this.jobs.length;a++)this.jobs[a].deleteBackground();this.jobs=[];return!0}return!1}startMultiAnimation(a,b,c){this.forceFinish=
3353!1;this.lastTime=this.avFPSCnt=this.avFPS=0;this.startTime=this.getTimeNow();this.clipArea=c;this.callInAnimation.push(function(){this.mergeJobs(a,b)}.bind(this));this.requestFrame=window.requestAnimationFrame(function(d){this.doMultiAnimationStep(d)}.bind(this));this.inAnimation=!0}doMultiAnimationStep(a){this.callOnBeforeEveryStep&&this.callOnBeforeEveryStep();var b=10,c=1;void 0===a&&(a=new Date);this.tick(a);for(a=0;a<this.callInAnimation.length;a++)this.callInAnimation[a]();this.callInAnimation=
3354[];this.avFPSCnt+=1;this.avFPS+=this.fps;2<this.avFPSCnt&&(b=Math.floor(this.avFPS/this.avFPSCnt),40>b&&(c=1<b?Math.floor(40/b+.5):40));this.forceFinish?c=50:2<c&&LOG("Joining anim Steps: "+c+", fps="+b,"LogRed");var d=this.cbcanvas.bufferCtx,e=!0;for(a=0;a<this.jobs.length;a++)this.jobs[a].shouldHideInThisStep()&&this.jobs[a].hide(d);for(a=0;a<this.jobs.length;a++)this.jobs[a].isImmobileInThisStep()&&!this.jobs[a].getsInvisibleAtEnd()&&this.jobs[a].moveToNoSave(d,this.jobs[a].currPos);for(a=0;a<
3355this.jobs.length;a++)this.jobs[a].isStillMoving()&&(this.jobs[a].hasReachedEndPos()?this.jobs[a].currPos=this.jobs[a].ptTo:this.jobs[a].displace(c),this.jobs[a].saveBeforeMove(d,this.jobs[a].currPos));for(a=0;a<this.jobs.length;a++)this.jobs[a].isStillMoving()&&(this.jobs[a].moveToNoSave(d,this.jobs[a].currPos),this.cbcanvas.joinClipRect(this.jobs[a].getMoveClipRect())),this.jobs[a].prepNextStep(c)||(e=!1);this.clipArea&&this.cbcanvas.cutClipRect(this.clipArea);this.callOnAfterEveryStep&&this.callOnAfterEveryStep();
3356this.cbcanvas._drawDoubleBufferClipped();this.reorgJobs();e?(this.inAnimation=!1,this.callOnAnimFinished&&this.callOnAnimFinished(),this.jobs=[]):this.requestFrame=window.requestAnimationFrame(function(f){this.doMultiAnimationStep(f)}.bind(this));e||(3<this.avFPSCnt?this.currFPS=b:delete this.currFPS)}quickFinish(){window.cancelAnimationFrame(this.requestFrame);this.hideAll();this.forceFinish=!0;this.requestFrame=window.requestAnimationFrame(function(a){this.doMultiAnimationStep(a)}.bind(this))}hideAll(){this.jobs.forEach(function(a){a.shouldHideInThisStep()&&
3357a.hide(this.cbcanvas.bufferCtx)}.bind(this))}showAll(){this.jobs.forEach(function(a){a.shouldHideInThisStep()&&a.show(this.cbcanvas.bufferCtx)}.bind(this))}reorgJobs(){for(var a=[],b=0;b<this.jobs.length;b++)this.jobs[b].canDelete()||a.push(this.jobs[b]);this.jobs=a}mergeJobs(a,b){for(var c=this.cbcanvas.bufferCtx,d=0;d<this.jobs.length;d++)this.jobs[d].hide(c);for(d=0;d<a.length;d++)a[d].hide(c);for(d=0;d<this.jobs.length;d++)-1==this.jobs[d].sqTo&&this.jobs[d].moveTo(c,this.jobs[d].ptTo);for(d=
33580;d<this.jobs.length;d++)-1!=this.jobs[d].sqTo&&this.jobs[d].moveTo(c,this.jobs[d].ptTo);var e=0<this.jobs.length;this.jobs=[];for(d=0;d<a.length;d++)a[d].startAnimation(c,b),a[d].deleteBackground(),a[d].moveTo(c,a[d].ptFrom),this.jobs.push(a[d]);return e}tick(a){this.updateFrameRate(a);this.gameTime=this.getTimeNow()-this.startTime;this.lastTime=a}updateFrameRate(a){0==this.lastTime&&(this.lastTime=this.startTime);this.fps=0===this.lastTime||this.lastTime==a?this.STARTING_FPS:1E3/(a-this.lastTime)}getTimeNow(){return(new Date).getTime()}}
3359"use strict";
3360class PixelFilter{static sTicket=0;static callBacks={};constructor(){this.worker=null}initWorker(){this.worker||(this.worker=new Worker("/Common/Tools/Gra
3360phics/PixelFilterWorker.js"),this.worker.onmessage=this.onMessage.bind(this),this.worker.error=this.onError.bind(this))}onMessage(a){if("result"===a.data.id&&(this.isRunning=!1,PixelFilter.callBacks[a.data.ticket]))PixelFilter.callBacks[a.data.ticket](a.data.imageData)}onError(a){}abort(){this.deleteWorker(!0)}deleteWorker(a){this.worker&&(this.isRunning||
3361a)&&(this.worker.terminate(),delete this.worker)}darkenCorners(a,b){this.deleteWorker();this.initWorker();var c=++PixelFilter.sTicket;PixelFilter.callBacks=[];PixelFilter.callBacks[c]=b;this.isRunning=!0;this.worker.postMessage({cmd:"darkenCorners",imageData:a,ticket:c})}}"use strict";
3362class DataBuffer{constructor(){this.nSize=this.nPos=0;this.buffer=new ArrayBuffer(188);this.viewBuf=new DataView(this.buffer);this.nSizeMarker=[];this.nMarkedSize=[]}clear(){this.nSize=this.nPos=0;this.nSizeMarker=[];this.nMarkedSize=[]}rewind(){this.nPos=0;this.nSizeMarker=[];this.nMarkedSize=[]}getPos(){return this.nPos}setPos(a){if(a<=this.nSize&&a<=this.buffer.byteLength)this.nPos=a;else throw"Error: SetPos exceeds DataBuffer size";}getSize(){return this.nSize}setSize(a){if(a>=this.buffer.byteLength)throw"DBuf setSize illegal";
3363this.nSize=a}getWriteSize(){return this.nSize+4}getCheckSum16(){for(var a=0,b=0;b<this.nSize;b++)a+=this.viewBuf.getUint8(b)+b;return Math.abs(a%32767)}writeToDataView(a,b){a.setInt32(b,this.nSize);this._swapBytes(a,b,4);b+=4;for(var c=0;c<this.nSize;c++)a.setUint8(c+b,this.viewBuf.getUint8(c));return this.nSize+4}readFromDataView(a,b){this._swapBytes(a,b,4);var c=a.getInt32(b);if(35E4>c&&0<=c){this._checkAlloc(c);b+=4;for(var d=0;d<c;d++){var e=a.getUint8(d+b);this.viewBuf.setUint8(d,e)}this._incSize(c)}}Vr(a){a=
3364StrUtil.encodeUTF8(a);this.Ve(a)}Ve(a){this._checkAlloc(a.length+4);this.V13(a.length);for(var b=0;b<a.length;b++){var c=a.charCodeAt(b);this.viewBuf.setUint8(this.nPos+b,c)}this._incSize(a.length)}V12(a){var b=this.V19();if(b<=a&&25E4>b){a="";for(var c=0;c<b;c++){var d=this.viewBuf.getUint8(this.nPos+c);a+=String.fromCharCode(d)}a=StrUtil.decodeUTF8(a);this.nPos+=b}else throw Error("Data Error: Read String");return a}Va(a){this._checkAlloc(a.length+4);this.V13(a.length);for(var b=0;b<a.length;b++){var c=
3365a.charCodeAt(b);this.viewBuf.setUint8(this.nPos+b,c)}this._incSize(a.length)}Vb(a){var b="",c=this.V19();if(c<=a&&25E4>c){for(a=0;a<c;a++){var d=this.viewBuf.getUint8(this.nPos+a);b+=String.fromCharCode(d)}this.nPos+=c}else throw Error(String.f("Data Error: Read String, Len={0}, maxLen={1}",c,a));return b}writeByteLenASCIIString(a){this._checkAlloc(a.length+2);this.writeUint8(a.length+1);for(var b=0;b<a.length;b++){var c=a.charCodeAt(b);this.viewBuf.setUint8(this.nPos+b,c)}this.viewBuf.setUint8(this.nPos+
3366a.length,0);this._incSize(a.length+1)}readByteLenASCIIString(a){var b="",c=this.readUint8();0<c&&--c;if(1E3>c){for(var d=0;d<c;d++){var e=this.viewBuf.getUint8(this.nPos+d);b+=String.fromCharCode(e)}if(c<=a)this.nPos+=c+1;else throw Error(String.f("Data Error: Read ByteLenString, len={0}, maxLen={1}",c,a));}else throw Error(String.f("Data Error: Read ByteLenString > 1000, len={0}",c));return b}readSizedString(a){var b="";if(25E4>a){for(var c=0;c<a;c++){var d=this.viewBuf.getUint8(this.nPos+c);b+=
3367String.fromCharCode(d)}this.nPos+=a}else throw Error("Data Error: Read SizedString, max="+a);return b}writeSizedString(a){var b=a.length;this._checkAlloc(b);for(var c=0;c<b;c++){var d=a.charCodeAt(c);this.viewBuf.setUint8(this.nPos+c,d)}this._incSize(b)}readSizedUTF8String(a){if(25E4>a){var b="";for(var c=0;c<a;c++){var d=this.viewBuf.getUint8(this.nPos+c);b+=String.fromCharCode(d)}b=StrUtil.decodeUTF8(b);this.nPos+=a}else throw Error("Data Error: Read UTF8String, len="+a);return b}readByteArray(a){for(var b=
3368[],c=0;c<a&&this.nPos+c<this.nSize;c++)b.push(this.viewBuf.getUint8(this.nPos+c));this.nPos+=a;return b}writeByteArray(a,b){for(var c=0;c<a.length&&c<b;c++)this.writeByte(a[c])}writeDataBuffer(a){this.V13(a.getSize());this._checkAlloc(a.getSize());for(var b=0;b<a.getSize();b++)this.viewBuf.setUint8(this.nPos+b,a.viewBuf.getUint8(b));this._incSize(a.getSize())}readDataBuffer(){var a=new DataBuffer,b=this.V19();a._checkAlloc(b);for(var c=0;c<b;c++)a.viewBuf.setUint8(c,this.viewBuf.getUint8(this.nPos+
3369c));this.nPos+=b;a._incSize(b);a.nPos=0;return a}writeData(a){this._checkAlloc(a.getSize());for(var b=0;b<a.getSize();b++)this.viewBuf.setUint8(this.nPos+b,a.viewBuf.getUint8(b));this._incSize(a.getSize())}V1b(a){if(void 0===a)throw Error("V1b, value undefined");this._checkAlloc(1);a?this.viewBuf.setUint8(this.nPos,1):this.viewBuf.setUint8(this.nPos,0);this._incSize(1)}V1c(a){a=this.viewBuf.getUint8(this.nPos);this.nPos+=1;return 0!=a}writeUint8(a){if(void 0===a)throw Error("writeUint8, value undefined");
3370this._checkAlloc(1);this.viewBuf.setUint8(this.nPos,a);this._incSize(1)}readUint8(){var a=this.viewBuf.getUint8(this.nPos);this.nPos+=1;return a}readByte(){var a=this.viewBuf.getUint8(this.nPos);this.nPos+=1;return a}writeByte(a){if(void 0===a)throw Error("writeUint8, value undefined");this._checkAlloc(1);this.viewBuf.setUint8(this.nPos,a);this._incSize(1)}V14(a){if(void 0===a)throw Error("V14, value undefined");this._checkAlloc(2);this.viewBuf.setInt16(this.nPos,a);this._swapBytes(this.viewBuf,this.nPos,
33712);this._incSize(2)}V1a(){var a=0;this.nPos<=this.viewBuf.byteLength-2&&(this._swapBytes(this.viewBuf,this.nPos,2),a=this.viewBuf.getInt16(this.nPos),this._swapBytes(this.viewBuf,this.nPos,2),this.nPos+=2);return a}readShort(){return this.V1a()}writeShort(a){return this.V14(a)}Vv(a){if(void 0===a)throw Error("Vv, value undefined");this._checkAlloc(2);this.viewBuf.setUint16(this.nPos,a);this._swapBytes(this.viewBuf,this.nPos,2);this._incSize(2)}Vx(){var a=0;this.nPos<=this.viewBuf.byteLength-2&&(this._swapBytes(this.viewBuf,
3372this.nPos,2),a=this.viewBuf.getUint16(this.nPos),this._swapBytes(this.viewBuf,this.nPos,2),this.nPos+=2);return a}V13(a){if(void 0===a)throw Error("V13, value undefined");this._checkAlloc(4);this.viewBuf.setInt32(this.nPos,a);this._swapBytes(this.viewBuf,this.nPos,4);this._incSize(4)}writeFakeInt64(a){this.V13(a);this.V13(0)}readFakeInt64(){var a=this.V19();this.V19();return a}V19(){var a=0;this.nPos<=this.viewBuf.byteLength-4&&(this._swapBytes(this.viewBuf,this.nPos,4),a=this.viewBuf.getInt32(this.nPos),
3373this._swapBytes(this.viewBuf,this.nPos,4),this.nPos+=4);return a}
3373writeInt(a){return this.V13(a)}readInt(){return this.V19()}Vu(a){this._checkAlloc(4);this.viewBuf.setUint32(this.nPos,a);this._swapBytes(this.viewBuf,this.nPos,4);this._incSize(4)}Vw(){var a=0;this.nPos<=this.viewBuf.byteLength-4&&(this._swapBytes(this.viewBuf,this.nPos,4),a=this.viewBuf.getUint32(this.nPos),this._swapBytes(this.viewBuf,this.nPos,4),this.nPos+=4);return a}Vt(a){a=a.getYear()<<9|a.getMonth()<<5|a.getDay();this.Vu(a)}V11(){var a=
3374new CBDate,b=this.Vw();a.setYear(b>>9);a.setMonth(b>>5&15);a.setDay(b&31);return a}readCBTime(){var a=this.Vw();return new CBTime(a)}V15(a){if(void 0===a)throw Error("V15, value undefined");var b=Math.floor(a/4294967296);this.V13(a-b);this.V13(b)}readUint64(){if(this.nPos<=this.viewBuf.byteLength-8){this._swapBytes(this.viewBuf,this.nPos,8);var a=this.viewBuf.getUint32(this.nPos);this.nPos+=4;var b=this.viewBuf.getUint32(this.nPos);this.nPos+=4;return 4294967296*a+b}return 0}V18(){if(this.nPos<=this.viewBuf.byteLength-
33758){this._swapBytes(this.viewBuf,this.nPos,8);var a=this.viewBuf.getInt32(this.nPos);this.nPos+=4;var b=this.viewBuf.getUint32(this.nPos);this.nPos+=4;return 4294967296*a+b}return 0}writeFloat32(a){this._checkAlloc(4);this.viewBuf.setFloat32(this.nPos,a);this._swapBytes(this.viewBuf,this.nPos,4);this._incSize(4)}readFloat32(){this._swapBytes(this.viewBuf,this.nPos,4);var a=this.viewBuf.getFloat32(this.nPos);this.nPos+=4;return a}writeFloat64(a){this._checkAlloc(8);this.viewBuf.setFloat64(this.nPos,
3376a);this._swapBytes(this.viewBuf,this.nPos,8);this._incSize(8)}readFloat64(){this._swapBytes(this.viewBuf,this.nPos,8);var a=this.viewBuf.getFloat64(this.nPos);this.nPos+=8;return a}exportAsCompressedString(){for(var a=this.getSize(),b=[],c=0;c<a;c++){var d=this.viewBuf.getUint8(c);b[c]=d}return BinToString.ByteArrayToString(b,a)}constructFromString(a,b){this.clear();if(b){if(b=[],a=BinToString.StringToByteArray(b,a),0<a)for(var c=0;c<a;c++)this.writeByte(b[c])}else for(b=0,10<a.length&&(b=parseInt(a.substr(0,
337710),10)),0>b&&(b=0),c=0;c<b;c++){var d=a.substr(10+2*c,2);d=parseInt(d,16);this.writeByte(d)}}constructFromBase64(a){this.clear();a=StrUtil.base64.decodeToBinary(a);for(var b=new Uint8Array(a),c=0;c<a.byteLength;c++)this.writeByte(b[c]);this.writeByteArray(a,a.byteLength);this.rewind()}toBase64(){for(var a="",b=new Uint8Array(this.buffer),c=this.nSize,d=0;d<c;d++)a+=String.fromCharCode(b[d]);return window.btoa(a)}static arrToBase64(a){for(var b="",c=0;c<a.length;c++)b+=String.fromCharCode(a[c]);return window.btoa(b)}readBEInt32(){var a=
3378this.readUint8(),b=this.readUint8(),c=this.readUint8(),d=this.readUint8();return a<<24|b<<16|c<<8|d}writeBEInt32(a){if(void 0===a)throw Error("V13, value undefined");this._checkAlloc(4);this.viewBuf.setInt32(this.nPos,a);this._incSize(4)}readBEInt24(){var a=this.readUint8(),b=this.readUint8(),c=this.readUint8();return a<<16|b<<8|c}readBEInt16(){var a=this.readUint8(),b=this.readUint8();return 256*a+b}writeBEInt24(a){var b=a>>8,c=a&255;this.writeUint8(a>>16);this.writeUint8(b);this.writeUint8(c)}writeBEInt16(a){var b=
3379a&255;this.writeUint8(a>>8);this.writeUint8(b)}writeArray(a){var b=a.length;this.V13(b);for(var c=0;c<b;++c)a[c].write(this)}writeArrayShort(a){var b=a.length;this.V14(b);for(var c=0;c<b;++c)a[c].write(this)}readArray(a,b){var c=this.V19();65534<c&&CBDebug.assert(65535>c);a.length=c;for(var d=0;d<c;++d){var e=b(this);a[d]=e}}readArrayShort(a,b){var c=this.V1a();a.length=c;for(var d=0;d<c;++d){var e=b(this);a[d]=e}}beginSizedWrite(){this.nSizeMarker.push(this.getPos());this.V13(0)}endSizedWrite(){var a=
3380this.getPos();if(0<this.nSizeMarker.length){this.setPos(this.nSizeMarker[this.nSizeMarker.length-1]);var b=this.nSize;this.V13(a-this.nSizeMarker[this.nSizeMarker.length-1]-4);this.nSize=b;this.setPos(a);this.nSizeMarker.pop()}else throw Error("DB::EndWrite");}Vc(){this.nSizeMarker.push(this.getPos());this.nMarkedSize.push(this.V19())}Vm(){if(0<this.nSizeMarker.length&&0<this.nMarkedSize.length){var a=this.getPos()-this.nSizeMarker[this.nSizeMarker.length-1]-4;this.skip(this.nMarkedSize[this.nMarkedSize.length-
33811]-a);this.nSizeMarker.pop();this.nMarkedSize.pop()}else throw Error("DB::EndRead");}skipSizedRead(){var a=this.V19();this.skip(a)}skip(a){this.nPos+a<=this.nSize&&(this.nPos+=a)}writeAtPrevPos(a,b){var c=this.getPos();this.setPos(a);a=this.getSize();b();this.setSize(a);this.setPos(c)}
3381_checkAlloc(a){if(this.nPos+a>=this.buffer.byteLength||this.nSize+a>=this.buffer.byteLength){var b=Math.max(this.nPos,this.nSize),c=8*Math.floor(3*(b+a)/16+1);if(c<a+b)throw"DataBuffer Size";a=new ArrayBuffer(c);b=new DataView(a);
3382for(c=0;c<this.buffer.byteLength/4;c++)b.setUint32(4*c,this.viewBuf.getUint32(4*c));this.buffer=a;this.viewBuf=b}}_incSize(a){if(this.nPos+a>=this.buffer.byteLength)throw"DataBuffer overrun";this.nPos+=a;this.nSize+=a;if(this.nSize>=this.buffer.byteLength)throw"DataBuffer Size Limit exc.";}_swapBytes(a,b,c){for(var d=[],e=0;e<c;e++)d.push(a.getUint8(b+e));for(e=0;e<c;e++)a.setUint8(b+e,d[c-e-1])}}function createReadFactory(a){return function(b){var c=new a;c.read(b);return c}}
3383function createReadFactory2(a){return function(b){var c=new a;c.read2(b);return c}}"use strict";
3384class CBSet{constructor(a){this.bag=[];var b;if(0<arguments.length)for(b=0;b<a.length;b++)this.insert(a[b])}clear(){this.bag=[]}search(a,b){for(var c=this.bag.length,d,e=2==arguments.length?b:0;e<c;){d=e+Math.floor((c-e)/2);if(this.bag[d].setEquals(a))return d;a.setGreater(this.bag[d])?e=d+1:c=d}return e}insert(a){var b=this.search(a);void 0!==this.bag[b]&&this.bag[b].setEquals(a)||this.bag.splice(b,0,a)}contains(a){var b=this.search(a);return void 0!==this.bag[b]?this.bag[b].setEquals(a):!1}get(a){var b=
3385this.search(a);if(void 0!==this.bag[b]&&this.bag[b].setEquals(a))return this.bag[b]}size(){return this.bag.length}getElements(){return this.bag}equals(a){if(this.size()!=a.size())return!1;var b;for(b=0;b<this.bag.length;b++)if(!this.bag[b].setEquals(a.bag[b]))return!1;return!0}save(a,b){var c=new CBStorage;c.save(a+"_len",this.bag.length);for(var d=0;d<this.bag.length;d++)b&&!b(this.bag[d])||c.save(a+"_o"+d,this.bag[d])}load(a,b){var c=new CBStorage,d=c.load(a+"_len");if(d)for(var e=0,f=0;f<d;f++){var g=
3386c.load(a+"_o"+f);b?(g=b(g))&&(this.bag[e++]=g):this.bag[e++]=g}}}
3387class CBNativeSet{constructor(a){this.bag=[];var b;if(0<arguments.length)for(b=0;b<a.length;b++)this.insert(a[b])}clear(){this.bag=[]}search(a,b){for(var c=this.bag.length,d,e=2==arguments.length?b:0;e<c;){d=e+Math.floor((c-e)/2);if(this.bag[d]==a)return d;a>this.bag[d]?e=d+1:c=d}return e}insert(a){var b=this.search(a);void 0!==this.bag[b]&&this.bag[b]==a||this.bag.splice(b,0,a)}contains(a){var b=this.search(a);return void 0!==this.bag[b]?this.bag[b]==a:!1}get(a){var b=this.search(a);if(void 0!==
3388this.bag[b]&&this.bag[b]==a)return this.bag[b]}size(){return this.bag.length}getElements(){return this.bag}equals(a){if(this.size()!=a.size())return!1;var b;for(b=0;b<this.bag.length;b++)if(this.bag[b]!=a.bag[b])return!1;return!0}save(a,b){var c=new CBStorage;c.save(a+"_len",this.bag.length);for(var d=0;d<this.bag.length;d++)b&&!b(this.bag[d])||c.save(a+"_o"+d,this.bag[d])}load(a,b){var c=new CBStorage,d=c.load(a+"_len");if(d)for(var e=0,f=0;f<d;f++){var g=c.load(a+"_o"+f);b?(g=b(g))&&(this.bag[e++]=
3389g):this.bag[e++]=g}}}"use strict";
3390class VectorSender{static staticIdVector=0;static staticIdBunch=0;constructor(a){this.sendFn=a;this.sendBuffers={};this.endOfVec={}}receiveVector(a,b,c,d){var e={vec:[],overhead:new DataBuffer},f=a.getBuf().Vw();a.getBuf().Vw();var g=a.getBuf().Vw();a.getBuf().Vw();e.overhead=a.getBuf().readDataBuffer();if(0<g){for(var h=a.getBuf().V19(),k=0;k<h&&3E4>k;k++){var l=d(a.getBuf());e.vec.push(l)}b=new WebSockMessage(b);b.setUserType(c);b.getBuf().Vu(f);b.getBuf().Vu(0);b.getBuf().Vu(g);b.getBuf().Vu(0);
3391b.getBuf().V13(h);b.address(a.getIdReceiver(),a.Vo());this.sendFn(b)}return e}sendVector(a,b,c,d,e,f,g,h){var k=++VectorSender.staticIdVector,l=++VectorSender.staticIdBunch,m=0;do{var n=new DataBuffer;n.V13(k);n.V13(0);n.V13(l);n.V13(0);n.writeDataBuffer(g);var r=0,t=n.getPos();n.V13(r);if(c.length){var u;do{var x=n.getSize(),B=n.getPos();h(n,c[m]);(u=n.getSize()<d)||0==r?(r++,m++):(n.setPos(B),n.setSize(x))}while(u&&m<c.length);u=n.getPos();n.setPos(t);n.V13(r);n.setPos(u)}this.sendBuffers[l]={sender:a,
3392receiver:b,buf:n,idBunch:l,idVec:k,msgType:e,userType:f,nSent:0};l++}while(m<c.length);this.endOfVec[k]={idVec:k,data:{msgType:e,userType:f,overHead:g}};this.sendNextBunch(a,b,k)}sendNextBunch(a,b,c){var d=!1;for(f in this.sendBuffers)if(this.sendBuffers.hasOwnProperty(f)){var e=this.sendBuffers[f];d=d||e.idVec==c;if(0==c||e.idVec==c){if(0==e.nSent%10){var f=new WebSockMessage(e.msgType);f.setUserType(e.userType);f.getBuf().writeData(e.buf);f.address(a,b);this.sendFn(f);LOG("Send Bunch = "+e.idBunch+
3393", vec="+e.idVec+", sent="+e.nSent,"LogGreen")}e.nSent++;break}}!d&&(d=this.endOfVec[c])&&(f=new WebSockMessage(d.data.msgType),f.setUserType(d.data.userType),f.getBuf().writeFakeInt64(c),f.getBuf().writeFakeInt64(0),f.getBuf().writeDataBuffer(d.data.overHead),f.address(a,b),this.sendFn(f),delete this.endOfVec[c])}handleConfirmBunch(a){var b=a.getBuf().readFakeInt64(),c=a.getBuf().readFakeInt64(),d=a.getBuf().V19();this.sendBuffers[c]?LOG("Confirm Bunch = "+c+", idVec="+b+", nItems="+d,"LogGreen"):
3394LOG("Confirm Bunch not found: "+c+", idVec="+b,"LogError");delete this.sendBuffers[c];this.sendNextBunch(a.getIdReceiver(),a.Vo(),b);return d}}"use strict";class Side{static NONE=-1;static WHITE=0;static BLACK=1;static SIDE_OFFSET=3;static SIDE_MASK=8;static other(a){return a^Side.BLACK}static fromString(a){return"w"===a?Side.WHITE:Side.BLACK}static toString(a){return a===Side.WHITE?"w":"b"}}
3395class Piece{static NONE=0;static KING=1;static QUEEN=2;static KNIGHT=3;static BISHOP=4;static ROOK=5;static PAWN=6;static W_KING=1;static W_QUEEN=2;static W_KNIGHT=3;static W_BISHOP=4;static W_ROOK=5;static W_PAWN=6;static B_KING=9;static B_QUEEN=10;static B_KNIGHT=11;static B_BISHOP=12;static B_ROOK=13;static B_PAWN=14;static COLOUR=8;static WHITE=0;static BLACK=8;static JOKER=7;static PIECE_MASK=7;static SIDE_MASK=8;static g_arrPieces=" KQNBRP  kqnbrp".split("");static nominal(a){return a&Piece.PIECE_MASK}static equalType(a,
3396b){return(a&Piece.PIECE_MASK)==(b&Piece.PIECE_MASK)}static side(a){return(a&Side.SIDE_MASK)/8}static changeSide(a){return a^Side.SIDE_MASK}static make(a,b){return a|8*b}static isCol(a,b){return(a&Side.SIDE_MASK)==b}static isPawn(a){return(a&Piece.PIECE_MASK)==Piece.PAWN}static isKing(a){return(a&Piece.PIECE_MASK)==Piece.KING}static isVectorPiece(a){a&=Piece.PIECE_MASK;return a==Piece.QUEEN||a==Piece.BISHOP||a==Piece.ROOK}static toString(a){return Piece.g_arrPieces[a]}static fromString(a){a=Piece.g_arrPieces.indexOf(a);
3397return 0>a?Piece.NONE:a}}
3398class CastleRights{static NONE=0;static W_000=1;static W_00=2;static B_000=4;static B_00=8;
3398static W_ALL=CastleRights.W_00|CastleRights.W_000;static B_ALL=CastleRights.B_00|CastleRights.B_000;static ALL=CastleRights.W_ALL|CastleRights.B_ALL;static to960String(a,b,c){if(a===CastleRights.NONE)return"-";var d="";a&CastleRights.W_00&&(d+=String.fromCharCode("A".charCodeAt()+((b&CBSquare.COL_MASK)>>CBSquare.COL_OFFSET)));a&CastleRights.W_000&&(d+=String.fromCharCode("A".charCodeAt()+((c&CBSquare.COL_MASK)>>
3399CBSquare.COL_OFFSET)));a&CastleRights.B_00&&(d+=String.fromCharCode("a".charCodeAt()+((b&CBSquare.COL_MASK)>>CBSquare.COL_OFFSET)));a&CastleRights.B_000&&(d+=String.fromCharCode("a".charCodeAt()+((c&CBSquare.COL_MASK)>>CBSquare.COL_OFFSET)));return d}static toString(a){if(a===CastleRights.NONE)return"-";var b="";a&CastleRights.W_00&&(b+="K");a&CastleRights.W_000&&(b+="Q");a&CastleRights.B_00&&(b+="k");a&CastleRights.B_000&&(b+="q");return b}static fromString(a){var b=a.charAt(0);if("A"<=b&&"H">=b)return CastleRights.ALL;
3400b=CastleRights.NONE;a=new StringIterator(a);for(var c=a.Next();0!==c;c=a.Next())switch(c){case "K":b|=CastleRights.W_00;break;case "Q":b|=CastleRights.W_000;break;case "k":b|=CastleRights.B_00;break;case "q":b|=CastleRights.B_000}return b}}
3401class CBSquare{static ROW_OFFSET=0;static ROW_MASK=7;static COL_OFFSET=3;static COL_MASK=56;static A1=0;static A2=1;static A3=2;static A4=3;static A5=4;static A6=5;static A7=6;static A8=7;static B1=8;static B2=9;static B3=10;static B4=11;static B5=12;static B6=13;static B7=14;static B8=15;static C1=16;static C2=17;static C3=18;static C4=19;static C5=20;static C6=21;static C7=22;static C8=23;static D1=24;static D2=25;static D3=26;static D4=27;static D5=28;static D6=29;static D7=30;static D8=31;static E1=32;static E2=33;static E3=34;static E4=35;static E5=36;static E6=37;static E7=38;static E8=39;static F1=40;static F2=41;static F3=42;static F4=43;static F5=44;static F6=45;static F7=46;static F8=47;static G1=48;static G2=49;static G3=50;static G4=51;static G5=52;static G6=53;static G7=54;static G8=55;static H1=56;static H2=57;static H3=58;static H4=59;static H5=60;static H6=61;static H7=62;static H8=63;static C_A=0;static C_B=1;static C_C=2;static C_D=3;static C_E=4;static C_F=5;static C_G=6;static C_H=7;static R_1=0;static R_2=1;static R_3=2;static R_4=3;static R_5=4;static R_6=5;static R_7=6;static R_8=7;static g_arrSquareStrs="a1 a2 a3 a4 a5 a6 a7 a8 b1 b2 b3 b4 b5 b6 b7 b8 c1 c2 c3 c4 c5 c6 c7 c8 d1 d2 d3 d4 d5 d6 d7 d8 e1 e2 e3 e4 e5 e6 e7 e8 f1 f2 f3 f4 f5 f6 f7 f8 g1 g2 g3 g4 g5 g6 g7 g8 h1 h2 h3 h4 h5 h6 h7 h8".split(" ");static toString(a){return this.g_arrSquareStrs[a]}static getStr=CBSquare.toString;static getStrXY(a,b){return CBSquare.getStr(CBSquare.get64(a,
3402b))}static colToString(a){return String.fromCharCode("a".charCodeAt()+a)}static rowToString(a){return a+1}static colFromString(a){return a.charCodeAt(0)-"a".charCodeAt()}static rowFromString(a){return a.charCodeAt(0)-"1".charCodeAt()}static fromString(a){if(a&&2===a.length){var b=CBSquare.colFromString(a.charAt(0));a=CBSquare.rowFromString(a.charAt(1));return CBSquare.I(b,a)}}static R(a){return a&CBSquare.ROW_MASK}static C(a){return(a&CBSquare.COL_MASK)>>CBSquare.COL_OFFSET}static F(a){return(a&CBSquare.COL_MASK)>>
3403CBSquare.COL_OFFSET}static getRank=CBSquare.R;static getFile=CBSquare.C;static DIST(a,b){var c=CBSquare.R(a)-CBSquare.R(b);a=CBSquare.C(a)-CBSquare.C(b);return Math.sqrt(c*c+a*a)}static I(a,b){return 8*a+b}static gen(a,b){return 8*a+b}static get64=CBSquare.I;static isLegal(a,b){return a<=CBSquare.C_H&&a>=CBSquare.C_A&&b<=CBSquare.R_8&&b>=CBSquare.R_1}static isDark(a){var b=CBSquare.C(a);a=CBSquare.R(a);return!((b+a)%2)}static isLight(a){return!CBSquare.isDark(a)}static isCenterFile(a){return CBSquare.F(a)==
3404CBSquare.C_D||CBSquare.F(a)==CBSquare.C_E}static isCenterRank(a){return CBSquare.R(a)==CBSquare.R_4||CBSquare.R(a)==CBSquare.R_5}static isCenterSquare(a){return CBSquare.isCenterFile(a)&&CBSquare.isCenterRank(a)}static getDist(a,b){var c=CBSquare.getFile(a)-CBSquare.getFile(b);a=CBSquare.getRank(a)-CBSquare.getRank(b);return Math.sqrt(c*c+a*a)}static getFileDist(a,b){return CBSquare.getFile(a)-CBSquare.getFile(b)}static getPromRow(a){return a===Side.WHITE?CBSquare.R_8:CBSquare.R_1}}"use strict";
3405class Board{constructor(a){this.sqs=[];for(var b=0;64>b;b++)this.sqs.push(0);a&&this.setup()}static SIZE=64;setup(){this.sqs=[Piece.W_ROOK,Piece.W_PAWN,0,0,0,0,Piece.B_PAWN,Piece.B_ROOK,Piece.W_KNIGHT,Piece.W_PAWN,0,0,0,0,Piece.B_PAWN,Piece.B_KNIGHT,Piece.W_BISHOP,Piece.W_PAWN,0,0,0,0,Piece.B_PAWN,Piece.B_BISHOP,Piece.W_QUEEN,Piece.W_PAWN,0,0,0,0,Piece.B_PAWN,Piece.B_QUEEN,Piece.W_KING,Piece.W_PAWN,0,0,0,0,Piece.B_PAWN,Piece.B_KING,Piece.W_BISHOP,Piece.W_PAWN,0,0,0,0,Piece.B_PAWN,Piece.B_BISHOP,Piece.W_KNIGHT,
3406Piece.W_PAWN,0,0,0,0,Piece.B_PAWN,Piece.B_KNIGHT,Piece.W_ROOK,Piece.W_PAWN,0,0,0,0,Piece.B_PAWN,Piece.B_ROOK]}
3406clear(){this.sqs.forEach(function(a,b,c){c[b]=0})}fromPosStr(a){for(var b=Side.WHITE,c=Piece.KING,d=0;d<a.length;d++)switch(a[d]){case "K":c=Piece.KING;break;case "Q":c=Piece.QUEEN;break;case "R":c=Piece.ROOK;break;case "B":c=Piece.BISHOP;break;case "N":c=Piece.KNIGHT;break;case "P":c=Piece.PAWN;break;case "a":case "b":case "c":case "d":case "e":case "f":case "g":case "h":var e=a.charCodeAt(d),
3407f=a.charCodeAt(d+1);49<=f&&56>=f?this.sqs[(e-97<<3)+f-49]=c|b:98==e&&(b=Side.SIDE_MASK);break;case "w":b=Side.WHITE}}copyFrom(a){for(var b=0;b<a.length;b++)this.sqs[b]=a[b]}copyTo(a){for(var b=0;64>b;b++)a[b]=this.sqs[b]}getCopy(){var a=new Board;this.copyTo(a.sqs);return a}set(a,b){this.sqs[a]=b}get(a){return this.sqs[a]}change(a,b){this.sqs[b]=this.sqs[a];this.sqs[a]=0}promo(a,b,c){this.sqs[b]=c;this.sqs[a]=0}enPassant(a,b,c){this.sqs[b]=this.sqs[a];this.sqs[a]=0;this.sqs[c]=0}V9(a){for(var b=0;64>
3408b;b++)a.writeByte(this.sqs[b])}toDebugStrs(){for(var a=[],b=7;0<=b;b--){for(var c="",d=0;8>d;d++){var e=this.get(8*d+b);c=e?c+Piece.g_arrPieces[e]:CBSquare.isDark(8*d+b)?c+".":c+" "}a.push(c)}return a}findSamePieceClosestSquare(a,b,c,d){for(b=0;64>b;b++)if((void 0===d||!d[b])&&c[b]==a)return b;return-1}test(){var a=new Board;a.setup();a.toDebugStrs().forEach(function(b){LOG(b)})}}"use strict";
3409class Undo{constructor(a,b){void 0!==a?(this.cr=a.cr,this.ep=a.ep,this.mvd=a.board[b.from],this.vct=a.board[b.to],this.mvdUnique=a.uniquePiecePositions[b.from],this.vctUnique=a.uniquePiecePositions[b.to]):(this.cr=CastleRights.NONE,this.ep=0,this.mvd=this.vct=Piece.NONE);void 0!==b&&(this.fldVct=b.to);this.from2=this.to2=0}setEP(a,b,c){this.fldVct=b;this.vct=a;c&&(this.vctUnique=c)}setCastle(a,b){this.from2=a;this.to2=b}}"use strict";
3410class Move{constructor(a,b,c){this.to=this.from=0;this.prom=Piece.NONE;a&&(this.from=a);b&&(this.to=b);c&&(this.prom=c);this.annos=this.subLines=null;this.needRow=this.needCol=this.isAMate=this.isACheck=!1;this.vct=this.mvd=Piece.NONE;this.longCastling=this.shortCastling=!1}static g_mvW00=new Move(CBSquare.E1,CBSquare.G1);static g_mvW000=new Move(CBSquare.E1,CBSquare.C1);static g_mvB00=new Move(CBSquare.E8,CBSquare.G8);static g_mvB000=new Move(CBSquare.E8,CBSquare.C8);get piece(){return this.mvd}set piece(a){this.mvd=
3411a}get capt(){return this.vct}set capt(a){this.vct=a}isNullMove(){return this.from===this.to&&!this.from}isCastling(){return this.isShortCastling()||this.isLongCastling()}equals(a){return this.from===a.from&&this.to===a.to&&this.prom===a.prom}isValid(){return this.from!=this.to}_isShortCastling(){return this.equals(Move.g_mvW00)&&this.mvd===Piece.W_KING||this.equals(Move.g_mvB00)&&this.mvd===Piece.B_KING}isShortCastling(){return this.shortCastling}_isLongCastling(){return this.equals(Move.g_mvW000)&&
3412this.mvd===Piece.W_KING||this.equals(Move.g_mvB000)&&this.mvd===Piece.B_KING}isLongCastling(){return this.longCastling}setIsCastling(){this.shortCastling=this._isShortCastling();this.longCastling=this._isLongCastling()}isCheck(){return this.isACheck}setCheck(a){this.isACheck=a}isMate(){return this.isAMate}setMate(a){this.isAMate=a}isTake(){return this.vct!=Piece.NONE}getMoved(){return this.mvd}setMoved(a){this.mvd=a}getVictim(){return this.vct}setVictim(a){this.vct=a}getPiece(){return this.mvd}isProm(){return this.prom!=
3413Piece.NONE}isPawn(){return this.mvd&&(this.mvd&7)==Piece.PAWN}getSide(){return Piece.side(this.mvd)}isNeedCol(){return this.needCol}setNeedCol(a){this.needCol=a}isNeedRow(){return this.needRow}setNeedRow(a){this.needRow=a}getTreeMoveCount(){var a=1;this.subLines&&(a=this.subLines.reduce(function(b,c){return b+c.getTreeMoveCount()},a));return a}indexOfLine(a){return this.subLines?this.subLines.indexOf(a):-1}findLine(a){if(this.subLines)for(var b=0;b<this.subLines.length;++b){var c=this.subLines[b];
3414if(c[0].equals(a))return c}return null}removeLine(a){this.subLines&&(a=this.subLines.indexOf(a),0>a||this.subLines.splice(a,1))}removeLines(){this.subLines=null}getLine(a){return this.subLines[a]}getSubLines(){return this.subLines}getSubLinesCount(){return this.subLines?this.subLines.length:0}
3414hasLines(){return null!=this.subLines&&0<this.subLines.length}newLine(a,b){this.subLines||(this.subLines=[]);a=new MoveLine(a,b);this.subLines.push(a);return a}addLine(a){this.subLines||(this.subLines=[]);this.subLines.push(a)}insertLine(a,
3415b){this.subLines||(this.subLines=[]);this.subLines.splice(a,0,b)}swapLines(a,b){if(this.subLines){var c=this.subLines[a];this.subLines[a]=this.subLines[b];this.subLines[b]=c}}write(a){if(this.prom){var b=this.to|this.prom-Piece.QUEEN<<6;a.writeByte(this.from|64);a.writeByte(b)}else this.Chess960LongCastling||this.Chess960ShortCastling?(b=this.Chess960LongCastling?0===CBSQuare.R(this.from)?CBSQuare.C1:CBSQuare.C8:0===CBSQuare.R(this.from)?CBSQuare.G1:CBSQuare.G8,a.writeByte(b),a.writeByte(b)):(a.writeByte(this.from),
3416a.writeByte(this.to));this.writeAnnos(a);this.writeSubLines(a)}write2(a){if(this.prom){var b=this.to|this.prom-Piece.QUEEN<<6;a.writeByte(this.from|64);a.writeByte(b)}else this.Chess960LongCastling||this.Chess960ShortCastling?(b=this.Chess960LongCastling?0===CBSquare.R(this.from)?CBSquare.C1:CBSquare.C8:0===CBSquare.R(this.from)?CBSquare.G1:CBSquare.G8,a.writeByte(b),a.writeByte(b)):(a.writeByte(this.from),a.writeByte(this.to));b=0;this.annos&&this.annos.count()&&(b|=1);this.getSubLinesCount()&&(b|=
34172);a.writeUint8(b);b&1&&this.writeAnnos2(a);b&2&&this.writeSubLines2(a)}read(a){this.from=a.readByte();this.to=a.readByte();64==(this.from&192)&&(this.prom=Piece.QUEEN+(this.to>>6));this.from&=63;this.to&=63;this.from===this.to&&0!==this.from&&(this.from===CBSquare.C1?this.Chess960LongCastling=!0:this.from===CBSquare.C8?this.Chess960LongCastling=!0:this.from===CBSquare.G1?this.Chess960ShortCastling=!0:this.from===CBSquare.G8&&(this.Chess960ShortCastling=!0));this.readAnnos(a);this.readSubLines(a)}read2(a){this.from=
3418a.readByte();this.to=a.readByte();64==(this.from&192)&&(this.prom=Piece.QUEEN+(this.to>>6));this.from&=63;this.to&=63;this.from===this.to&&0!==this.from&&(this.from===CBSquare.C1?this.Chess960LongCastling=!0:this.from===CBSquare.C8?this.Chess960LongCastling=!0:this.from===CBSquare.G1?this.Chess960ShortCastling=!0:this.from===CBSquare.G8&&(this.Chess960ShortCastling=!0));var b=a.readByte();b&1&&this.readAnnos2(a);b&2&&this.readSubLines2(a)}readAnnos(a){this.annos=Annotation.readFactory(a)}readAnnos2(a){this.annos=
3419Annotation.readFactory2(a)}writeAnnos(a){Annotation.write(a,this.annos)}writeAnnos2(a){Annotation.write2(a,this.annos)}readSubLines(a){var b=a.readByte();if(127>=b){this.subLines=Array(b);for(var c=0;c<b;++c)this.subLines[c]=MoveLine.readFactory(a)}}readSubLines2(a){var b=a.readByte();if(127>=b){this.subLines=Array(b);for(var c=0;c<b;++c)this.subLines[c]=MoveLine.readFactory2(a)}}writeSubLines(a){var b=this.getSubLinesCount();a.writeByte(b);if(b)for(var c=0;c<b;++c)this.subLines[c].write(a)}writeSubLines2(a){var b=
3420this.getSubLinesCount();a.writeByte(b);if(b)for(var c=0;c<b;++c)this.subLines[c].write2(a)}static readFactory=createReadFactory(Move);static readFactory2=createReadFactory2(Move);moveLinesTo(a){a.subLines=this.subLines;this.subLines=null}toString(){var a=CBSquare.toString(this.from)+CBSquare.toString(this.to);this.prom!=Piece.NONE&&(a+=Piece.toString(this.prom).toLowerCase());return a}static g_regex=/^[a-h][1-8][a-h][1-8]([NBRQ])?$/i;static isValidString(a){return Move.g_regex.test(a)}static fromString(a){var b=
3421a.substring(0,2),c=a.substring(2,4);b=CBSquare.fromString(b);c=CBSquare.fromString(c);var d=void 0;4<a.length&&(a=a.charAt(4),d=Piece.nominal(Piece.fromString(a)));return new Move(b,c,d)}toJSON(){return{from:CBSquare.toString(this.from),to:CBSquare.toString(this.to),prom:"  Q N B R  ".split(" ")[this.prom%8]}}fromJSON(a){this.from=CBSquare.fromString(a.from);this.to=CBSquare.fromString(a.to);a=" KQNBR".search(RegExp(a.prom,"i"));this.prom=0<a?a:0;return{from:CBSquare.toString(this.from),to:CBSquare.toString(this.to),
3422prom:"  Q N B R  ".split(" ")[this.prom%8]}}setSubParentData(a,b,c){if(this.subLines)for(var d=0;d<this.subLines.length;++d){var e=this.subLines[d];e.setParentMoveIndex(b);e.setParentLine(a);c&&e.setSubParentData(!0)}}getAnno(){return this.annos}hasAnno(){return null!=this.annos}setAnnoItem(a,b){this.annos||(this.annos=new Annotation);this.annos.setItem(a,b)}setAnno(a){this.annos=a}getAnnoItem(a){return this.annos?this.annos.getItem(a):null}deleteAnnoItem(a){this.annos&&this.annos.deleteItem(a)}resetAnno(){this.annos=
3423null}unAnnotate(a){a||this.resetAnno();this.removeLines()}getBaggage(){return this.baggage}setBaggage(a){this.baggage=a}forAllMoves(a){a(this);if(this.subLines)for(var b=0;b<this.subLines.length;b++)this.subLines[b].forAllMoves(a)}getType(){return this.type}setType(a){this.type=a}getOldEP(){return this.oldEP}setOldEP(a){this.oldEP=a}getOldCastle(){return this.oldCastle}setOldCastle(a){this.oldCastle=a}setPiece(a){this.mvd=a}setProm(a){this.prom=a}swapColours(a){a&1&&(a&16?(this.from^=63,this.to^=
342463,this.getType()&15&&this.setType(this.getType()&-16|(this.getType()&5)<<1|(this.getType()&10)>>1),this.getOldCastle()&&this.setOldCastle((this.getOldCastle()&5)<<1|(this.getOldCastle()&10)>>1)):(this.from^=7,this.to^=7,this.getType()&15&&this.setType(this.getType()&-16|(this.getType()&3)<<2|(this.getType()&12)>>2),this.getOldCastle()&&this.setOldCastle((this.getOldCastle()&3)<<2|(this.getOldCastle()&12)>>2)),this.getPiece()&&this.setPiece(this.getPiece()^8),this.getVictim()&&this.setVictim(this.getVictim()^
34258))}unNormalize(a){var b=0;a&2&&(b^=56,this.getOldEP()&&this.setOldEP(9-this.getOldEP()));a&4&&(b^=7);if(a&8){var c=this.from,d=this.to;d=(d&7)<<3|d>>3&7;this.from(((c&7)<<3|c>>3&7)^b);this.to(d^b)}else b&&(this.from^=b,this.to^=b);a&1&&this.swapColours(a)}}"use strict";
3426class MoveRecord{constructor(a,b,c,d){this.from=a||0;this.to=b||0;this.type=c||0;this.prom=d||0}initFromMove(a){a&&(this.from=a.from,this.to=a.to,this.prom=a.prom,this.type=void 0!==a.type?a.type:0)}toString(){return CBSquare.toString(this.from)+"-"+CBSquare.toString(this.to)+", ty="+this.t
3426ype}fromDataBuf(a){this.from=a.readUint8();this.to=a.readUint8();this.type=a.readUint8();this.prom=a.readUint8()}V17(a){a.writeUint8(this.from);a.writeUint8(this.to);a.writeUint8(this.type);a.writeUint8(this.prom)}}
3427"use strict";
3428class MoveLine extends Array{constructor(a,b){super();this.parent=null;this.inxMvParent=0;a&&(this.parent=a,this.inxMvParent=b)}clone(a){return ObjUtil.clone2(this,a)}isMainLine(){return!this.parent}setMainLine(){this.parent=null;this.inxMvParent=0}getParentLine(){return this.parent}setParentLine(a){this.parent=a}getParentMoveIndex(){return this.inxMvParent}setParentMoveIndex(a){this.inxMvParent=a}getTreeMoveCount(){return this.reduce(function(a,b){return a+b.getTreeMoveCount()},0)}setSubParentData(a){this.forEach(function(b,c){b.setSubParentData(this,
3429c,a)}.bind(this))}swapMoves(a,b){a=[a,this.length-a];if(b)for(var c=0,d=b.length;c<d;++c)a.push(b[c]);a=this.splice.apply(this,a);this.setSubParentData();a=[0,b.length].concat(a);b.splice.apply(b,a);b.setSubParentData();b.setParentLine(this);return b}selfTest(a,b,c){CBDebug.assert(this.inxMvParent===c);CBDebug.assert(!b||null!=this.getParentMove()&&0<=this.getParentMove().indexOfLine(this));a=ObjUtil.clone(a);c=0;for(var d=this.length;c<d;++c){var e=this[c];if(e.hasLines()){CBDebug.assert(!b||c);
3430for(var f=e.getSubLines(),g=0;g<f.length;++g)f[g].selfTest(ObjUtil.clone(a),this,c)}a.makeMove(e)}}getParentMove(){return this.parent?this.parent[this.inxMvParent]:null}toString(){return this.join(" ")}static readFactory=createReadFactory(MoveLine);static readFactory2=createReadFactory2(MoveLine);read(a){a.readArray(this,Move.readFactory);this.setSubParentData();this.shiftTrainingAnnosBack()}read2(a){var b=a.readUint8();b&128&&(b=(b<<8|a.readUint8())&32767);if(0<b){if(2048<b)return!1;if(0<b){this.length=
3431b;for(var c=0;c<b;c++){var d=new Move;d.read2(a);this[c]=d}}}else if(0>b)return!1;this.setSubParentData();this.shiftTrainingAnnosBack()}write(a){this.shiftTrainingAnnosFwd();a.writeArray(this);this.shiftTrainingAnnosBack()}write2(a){this.shiftTrainingAnnosFwd();2048>=this.length&&(this.length&-128&&a.writeUint8(this.length<<8|128),a.writeUint8(this.length&255));for(var b=0;b<this.length;b++)this[b].write2(a);this.shiftTrainingAnnosBack()}hasLines(){return this.some(function(a){return a.hasLines()})}shiftTrainingAnnosBack(){for(var a=
34321;a<this.length;a++)if(this[a].hasAnno()&&this[a].getAnno().hasTraining()){var b=this[a].getAnno().getTraining();this[a].getAnno().setTraining(null);this[a].getAnno().empty()&&this[a].setAnno(null);this[a-1].setAnnoItem(AnnoType.TRAINING,b)}}shiftTrainingAnnosFwd(){for(var a=this.length-2;0<=a;a--)if(this[a].hasAnno()&&this[a].getAnno().hasTraining()){var b=this[a].getAnno().getTraining();this[a].getAnno().setTraining(null);this[a].getAnno().empty()&&this[a].setAnno(null);this[a+1].setAnnoItem(AnnoType.TRAINING,
3433b)}}isAnnotated(){return this.some(function(a){return a.hasLines()||a.hasAnno()})}setAnno(a){this.anno=a}getAnno(){return this.anno}setAnnoItem(a,b){this.anno||(this.anno=new Annotation);this.anno.setItem(a,b)}hasAnno(){return void 0!==this.anno}unAnnotate(a){this.forEach(function(b){b.unAnnotate(a)})}forAllMoves(a){this.forEach(function(b){b.forAllMoves(a)})}removeLines(){this.forEach(function(a){a.removeLines()})}static contextToLine(a,b){var c=[];a=ObjUtil.clone(a);for(var d=0;d<b.length;d++){var e=
3434ObjUtil.clone(b[d]);a.preSetMinCtx(e);c.push(e);a.makeMove(e)}return c}}"use strict";
3435class LineStackItem{constructor(a,b){this.line=void 0!=a?a:null;this.mvsToGo=void 0!=b?parseInt(b):0}getLine(){return this.line}getMovesToGo(){return this.mvsToGo}setMovesToGo(a){this.mvsToGo=parseInt(a)}incMovesToGo(){++this.mvsToGo}decMovesToGo(){--this.mvsToGo}isLineEnd(){return this.line.length===this.mvsToGo}isLineStart(){return 0===this.mvsToGo}pushMove(a){this.line.length=this.mvsToGo;this.line.push(a);++this.mvsToGo}deleteRemaining(){this.line.length=this.mvsToGo}deletePrevious(){this.line.splice(0,
3436this.mvsToGo-1);this.mvsToGo=1;this.line.setSubParentData();this.line.setMainLine();return this.line}shallowClone(){return new LineStackItem(this.line,this.mvsToGo)}}
3437class LineStack extends Array{constructor(a,b){super();a&&(b||=0,this.push(new LineStackItem(a,b)))}Top(){return this[this.length-1]}shallowClone(){var a=new LineStack;a.length=this.length;for(var b=0,c=this.length;b<c;++b)a[b]=this[b].shallowClone();return a}deleteRemaining(){this.Top()&&this.Top().deleteRemaining()}deletePrevious(){var a=this.Top(),b=a.deletePrevious();this.length=0;this.push(a);return b}gotoPrev(){var a=this.Top();a&&(a.decMovesToGo(),1<this.length&&0===a.getMovesToGo()&&this.pop())}promoteLine(){var a=
3438this.Top();if(a){var b=a.getLine(),c=a.getMovesToGo();a=b.getParentLine();var d=b.getParentMoveIndex(),e=a[d],f=e.indexOfLine(b);e.removeLine(b);var g=b[0];e.moveLinesTo(g);a.swapMoves(d,b);g.insertLine(f,b);c+=d;this.pop();a=this.Top();a.setMovesToGo(c)}}getSimplePath(){for(var a=[],b=null,c=0,d=this.length;c<d;++c){var e=this[c],f=e.getLine();e=e.getMovesToGo();var g=0;b&&(g=b.indexOfLine(f));a.push({inxLine:g,mvsToGo:e});b=f[e]}return a}selfTest(){for(var a=null,b=0,c=0,d=this.length;c<d;++c){var e=
3439this[c],f=e.getLine();e=e.getMovesToGo();CBDebug.assert(f.getParentLine()===a);CBDebug.assert(f.getParentMoveIndex()===b);CBDebug.assert(!a||0<=f.getParentMove().indexOfLine(f));a=f;b=e}}}const NORM_NONE=0,NORM_COL_SWAP=1,NORM_FILE_SWAP=2,NORM_RANK_SWAP=4,NORM_DIAG_SWAP=8,NORM_COL2_SWAP=16;
3440class Position{constructor(a){this.initFields();a?a.length&&("w"==a.charAt(0)?this.initString(a):this.initFEN(a)):this.initStartPos()}static NOEP=-1;copy(a){for(var b=0;b<this.board.length;++b)this.board[b]=a.board[b];for(b=0;b<this.uniquePiecePositions.length;b++)this.uniquePiecePositions[b]=a.uniquePiecePositions[b];this.sd=a.sd;this.ep=a.ep;this.cr=a.cr;this.ty=a.ty;2===this.ty&&(this.m_nWK00Sq=a.m_nWK00Sq,this.m_nWR00Sq=a.m_nWR00Sq,this.m_nWR000Sq=a.m_nWR000Sq,this.m_nBK00Sq=a.m_nBK00Sq,this.m_nBR00Sq=
3441a.m_nBR00Sq,this.m_nBR000Sq=a.m_nBR000Sq,this.m_nPosInx=a.m_nPosInx);this.lastKillOrPawn=a.lastKillOrPawn;this.numPly=a.numPly}equals(a){if(!a||this.sd!=a.sd||this.ep!=a.ep||this.cr!=a.cr||this.ty!=a.ty)return!1;for(var b=0;b<this.board.length;++b)if(this.board[b]!==a.board[b])return!1;return!0}plyToMvNum(a,b){return idiv(a,2)+1}static mvToPlyNum(a,b){return 2*(a-1)+b}getMoveNum(){return this.plyToMvNum(this.numPly,this.sd)}setMoveNum(a){this.numPly=Position.mvToPlyNum(a,this.sd)}getPlyNum(){return this.numPly}initStartPos(){this.sd=
3442Side.WHITE;this.ty=0;for(var a=CBSquare.C_A;a<=CBSquare.C_H;++a)this.board[CBSquare.I(a,CBSquare.R_2)]=Piece.W_PAWN,this.board[CBSquare.I(a,CBSquare.R_7)]=Piece.B_PAWN;this.board[CBSquare.A1]=this.board[CBSquare.H1]=Piece.W_ROOK;this.board[CBSquare.B1]=this.board[CBSquare.G1]=Piece.W_KNIGHT;this.board[CBSquare.C1]=this.board[CBSquare.F1]=Piece.W_BISHOP;this.board[CBSquare.D1]=Piece.W_QUEEN;
3442this.board[CBSquare.E1]=Piece.W_KING;this.board[CBSquare.A8]=this.board[CBSquare.H8]=Piece.B_ROOK;this.board[CBSquare.B8]=
3443this.board[CBSquare.G8]=Piece.B_KNIGHT;this.board[CBSquare.C8]=this.board[CBSquare.F8]=Piece.B_BISHOP;this.board[CBSquare.D8]=Piece.B_QUEEN;this.board[CBSquare.E8]=Piece.B_KING;this.uniquePiecePositions=[1,2,0,0,0,0,3,4,5,6,0,0,0,0,7,8,9,10,0,0,0,0,11,12,13,14,0,0,0,0,15,16,17,18,0,0,0,0,19,20,21,22,0,0,0,0,23,24,25,26,0,0,0,0,27,28,29,30,0,0,0,0,31,32];this.cr=CastleRights.ALL;this.numPly=this.lastKillOrPawn=0}boardEquals(a){for(var b=0;b<this.board.length&&64>b;b++)if(this.board[b]!==a[b])return!1;
3444return!0}initFEN(a){a=new StringIterator(a);var b=CBSquare.R_8,c=CBSquare.C_A,d;for(d=a.Next();0!==d&&!Char.IsWhiteSpace(d);d=a.Next())if("/"===d)--b,c=CBSquare.C_A;else if(Char.IsDigit(d))c+=Number(d);else{var e=CBSquare.I(c,b);d=Piece.fromString(d);this.board[e]=d;c++}a.isEOF()||(a.skipWhile(Char.IsWhiteSpace),a.isEOF()||(this.ty=0,this.sd=Side.fromString(a.Current()),a.skipWhile(Char.IsWhiteSpace),a.isEOF()||(b=a.AcceptUntil(Char.IsWhiteSpace,!0),this.cr=CastleRights.fromString(b),a.isEOF()||(a.skipWhile(Char.IsWhiteSpace),
3445b=a.AcceptUntil(Char.IsWhiteSpace,!0),"-"===b?this.ep=Position.NOEP:(b=CBSquare.fromString(b),this.ep=CBSquare.C(b)),this.numPly=Position.mvToPlyNum(1,this.sd),a.isEOF()||(a.skipWhile(Char.IsWhiteSpace),a.isEOF()||(b=a.AcceptUntil(Char.IsWhiteSpace,!0),this.lastKillOrPawn=Number(b),a.isEOF()||(a.skipWhile(Char.IsWhiteSpace),a.isEOF()||(a=a.AcceptUntil(Char.IsWhiteSpace,!0),(a=Number(a))||(a=1),this.numPly=Position.mvToPlyNum(a,this.sd)))))))))}initString(a){this.initEmpty();for(var b=a.length,c=!1,
3446d=0;d<b;d++)if(("b"==a[d]||"s"==a[d])&&"K"==a[d+1]){c="s"==a[d];break}var e=0,f=0;for(d=0;d<b;d++)switch(a[d]){case "K":e=Piece.KING;break;case "D":case "Q":e=Piece.QUEEN;break;case "T":case "R":e=Piece.ROOK;break;case "L":e=Piece.BISHOP;break;case "B":e=c?Piece.PAWN:Piece.BISHOP;break;case "S":case "N":e=Piece.KNIGHT;break;case "P":e=Piece.PAWN;break;case "a":case "b":case "c":case "d":case "e":case "f":case "g":case "h":48<a.charCodeAt(d+1)&&57>a.charCodeAt(d+1)?this.board[(a.charCodeAt(d)-97<<
34473)+a.charCodeAt(d+1)-49]=e|f:"b"!=a[d]||c||(f=Piece.BLACK);break;case "s":c&&(f=Piece.BLACK);break;case "w":f=Piece.WHITE;break;case ":":case "-":this.parseAttributes(a.slice(d+1)),d=b}0==this.cr&&(this.board[CBSquare.E1]==Piece.W_KING&&(this.board[CBSquare.H1]==Piece.W_ROOK?this.cr|=CastleRights.W_00:this.board[CBSquare.A1]==Piece.W_ROOK&&(this.cr|=CastleRights.W_000)),this.board[CBSquare.E8]==Piece.B_KING&&(this.board[CBSquare.H8]==Piece.B_ROOK?this.cr|=CastleRights.B_00:this.board[CBSquare.A8]==
3448Piece.B_ROOK&&(this.cr|=CastleRights.B_000)))}parseAttributes(a){LOG(a);"b"==a[0]&&(this.sd=Side.BLACK)}canMakeNullMove(){return!this.isCheck()}makeNullMove(){return this.makeMove(new Move(0,0))}unmakeNullMove(){return this.unmakeMove(new Move(0,0))}makeMove(a){if(a){var b=new Undo(this,a);++this.numPly;this.sd=Side.other(this.sd);var c=this.ep;this.ep=Position.NOEP;if(a.isNullMove())return b;var d=this.board[a.from],e=this.board[a.to],f=CBSquare.R(a.from),g=CBSquare.R(a.to),h=CBSquare.C(a.from),
3449k=CBSquare.C(a.to),l=!1;if(a.Chess960ShortCastling||a.Chess960LongCastling){if(a.Chess960ShortCastling)if(this.sd==Side.BLACK){l=this.uniquePiecePositions[this.m_nWK00Sq];var m=this.uniquePiecePositions[this.m_nWR00Sq];this.board[this.m_nWK00Sq]=Piece.NONE;this.board[this.m_nWR00Sq]=Piece.NONE;this.uniquePiecePositions[this.m_nWK00Sq]=Piece.NONE;this.uniquePiecePositions[this.m_nWR00Sq]=Piece.NONE;this.board[CBSquare.G1]=Piece.W_KING;this.board[CBSquare.F1]=Piece.W_ROOK;this.uniquePiecePositions[CBSquare.G1]=
3450l;this.uniquePiecePositions[CBSquare.F1]=m}else l=this.uniquePiecePositions[this.m_nBK00Sq],m=this.uniquePiecePositions[this.m_nBR00Sq],this.board[this.m_nBK00Sq]=Piece.NONE,this.board[this.m_nBR00Sq]=Piece.NONE,this.uniquePiecePositions[this.m_nBK00Sq]=Piece.NONE,this.uniquePiecePositions[this.m_nBR00Sq]=Piece.NONE,this.board[CBSquare.G8]=Piece.B_KING,this.board[CBSquare.F8]=Piece.B_ROOK,this.uniquePiecePositions[CBSquare.G8]=l,this.uniquePiecePositions[CBSquare.F8]=m;else this.sd==Side.BLACK?(l=
3451this.uniquePiecePositions[this.m_nWK00Sq],m=this.uniquePiecePositions[this.m_nWR000Sq],this.board[this.m_nWK00Sq]=Piece.NONE,this.board[this.m_nWR000Sq]=Piece.NONE,this.uniquePiecePositions[this.m_nWK00Sq]=Piece.NONE,this.uniquePiecePositions[this.m_nWR000Sq]=Piece.NONE,this.board[CBSquare.C1]=Piece.W_KING,this.board[CBSquare.D1]=Piece.W_ROOK,this.uniquePiecePositions[CBSquare.C1]=l,this.uniquePiecePositions[CBSquare.D1]=m):(l=this.uniquePiecePositions[this.m_nBK00Sq],m=this.uniquePiecePositions[this.m_nBR000Sq],
3452this.board[this.m_nBK00Sq]=Piece.NONE,this.board[this.m_nBR000Sq]=Piece.NONE,this.uniquePiecePositions[this.m_nBK00Sq]=Piece.NONE,this.uniquePiecePositions[this.m_nBR000Sq]=Piece.NONE,this.board[CBSquare.C8]=Piece.B_KING,this.board[CBSquare.D8]=Piece.B_ROOK,this.uniquePiecePositions[CBSquare.C8]=l,this.uniquePiecePositions[CBSquare.D8]=m);l=!0}l||(this.board[a.to]=this.board[a.from],this.board[a.from]=Piece.NONE,this.uniquePiecePositions[a.to]=this.uniquePiecePositions[a.from],this.uniquePiecePositions[a.from]=
3453Piece.NONE);Piece.nominal(d)===Piece.PAWN&&(k!==h&&k===c&&e===Piece.NONE&&(e=Piece.changeSide(d),c=CBSquare.I(k,f),this.board[c]=Piece.NONE,l=this.uniquePiecePositions[c],this.uniquePiecePositions[c]=Piece.NONE,b.setEP(e,c,l)),a.prom!==Piece.NONE&&(e=Piece.make(a.prom,Piece.side(d)),this.board[a.to]=e),2===Math.abs(f-g)&&(this.ep=
3453h));Piece.nominal(d)===Piece.KING&&(this.cr=this.sd===Side.WHITE?this.cr&~CastleRights.B_ALL:this.cr&~CastleRights.W_ALL,2===Math.abs(k-h)&&2!==this.ty&&(k===CBSquare.C_G?
3454(d=CBSquare.I(CBSquare.C_H,f),f=CBSquare.I(CBSquare.C_F,f)):(d=CBSquare.I(CBSquare.C_A,f),f=CBSquare.I(CBSquare.C_D,f)),this.board[f]=this.board[d],this.board[d]=Piece.NONE,this.uniquePiecePositions[f]=this.uniquePiecePositions[d],this.uniquePiecePositions[d]=Piece.NONE,b.setCastle(d,f)));if(this.cr)if(2===this.ty){if(this.cr&CastleRights.W_ALL)if(a.from===this.m_nWK00Sq)this.cr&=~CastleRights.W_ALL;else if(a.from===this.m_WR000Sq||a.to===this.m_WR000Sq)this.cr&=~CastleRights.W_000;else if(a.from===
3455this.m_WR00Sq||a.to===this.m_WR00Sq)this.cr&=~CastleRights.W_00;if(this.cr&CastleRights.B_ALL)if(a.from===this.m_nBK00Sq)this.cr&=~CastleRights.B_ALL;else if(a.from===this.m_BR000Sq||a.to===this.m_BR000Sq)this.cr&=~CastleRights.B_000;else if(a.from===this.m_BR00Sq||a.to===this.m_BR00Sq)this.cr&=~CastleRights.B_00}else{if(this.cr&CastleRights.W_ALL)if(a.from===CBSquare.E1)this.cr&=~CastleRights.W_ALL;else if(a.from===CBSquare.A1||a.to===CBSquare.A1)this.cr&=~CastleRights.W_000;else if(a.from===CBSquare.H1||
3456a.to===CBSquare.H1)this.cr&=~CastleRights.W_00;if(this.cr&CastleRights.B_ALL)if(a.from===CBSquare.E8)this.cr&=~CastleRights.B_ALL;else if(a.from===CBSquare.A8||a.to===CBSquare.A8)this.cr&=~CastleRights.B_000;else if(a.from===CBSquare.H8||a.to===CBSquare.H8)this.cr&=~CastleRights.B_00}return b}}unmakeMove(a,b){if(!a.isNullMove())if(a.Chess960LongCastling||a.Chess960ShortCastling)if(a.Chess960ShortCastling)if(this.sd===Side.WHITE){a=this.uniquePiecePositions[CBSquare.G8];var c=this.uniquePiecePositions[CBSquare.F8];
3457this.board[CBSquare.G8]=Piece.NONE;this.board[CBSquare.F8]=Piece.NONE;this.uniquePiecePositions[CBSquare.G8]=Piece.NONE;this.uniquePiecePositions[CBSquare.F8]=Piece.NONE;this.board[this.m_nBK00Sq]=Piece.B_KING;this.board[this.m_nBR00Sq]=Piece.B_ROOK;this.uniquePiecePositions[this.m_nBK00Sq]=a;this.uniquePiecePositions[this.m_nBR00Sq]=c}else a=this.uniquePiecePositions[CBSquare.G1],c=this.uniquePiecePositions[CBSquare.F1],this.board[CBSquare.G1]=Piece.NONE,this.board[CBSquare.F1]=Piece.NONE,this.uniquePiecePositions[CBSquare.G1]=
3458Piece.NONE,this.uniquePiecePositions[CBSquare.F1]=Piece.NONE,this.board[this.m_nWK00Sq]=Piece.W_KING,this.board[this.m_nWR00Sq]=Piece.W_ROOK,this.uniquePiecePositions[this.m_nWK00Sq]=a,this.uniquePiecePositions[this.m_nWR00Sq]=c;else this.sd===Side.WHITE?(a=this.uniquePiecePositions[CBSquare.C8],c=this.uniquePiecePositions[CBSquare.D8],this.board[CBSquare.C8]=Piece.NONE,this.board[CBSquare.D8]=Piece.NONE,this.uniquePiecePositions[CBSquare.C8]=Piece.NONE,this.uniquePiecePositions[CBSquare.D8]=Piece.NONE,
3459this.board[this.m_nBK00Sq]=Piece.B_KING,this.board[this.m_nBR000Sq]=Piece.B_ROOK,this.uniquePiecePositions[this.m_nBK00Sq]=a,this.uniquePiecePositions[this.m_nBR000Sq]=c):(a=this.uniquePiecePositions[CBSquare.C1],c=this.uniquePiecePositions[CBSquare.D1],this.board[CBSquare.C1]=Piece.NONE,this.board[CBSquare.D1]=Piece.NONE,this.uniquePiecePositions[CBSquare.C1]=Piece.NONE,this.uniquePiecePositions[CBSquare.D1]=Piece.NONE,this.board[this.m_nWK00Sq]=Piece.W_KING,this.board[this.m_nWR000Sq]=Piece.W_ROOK,
3460this.uniquePiecePositions[this.m_nWK00Sq]=a,this.uniquePiecePositions[this.m_nWR000Sq]=c);else if(this.board[a.from]=b.mvd,this.board[a.to]=Piece.NONE,this.board[b.fldVct]=b.vct,this.uniquePiecePositions[a.from]=b.mvdUnique,this.uniquePiecePositions[a.to]=Piece.NONE,this.uniquePiecePositions[b.fldVct]=b.vctUnique,b.to2||b.from2)this.board[b.from2]=this.board[b.to2],this.board[b.to2]=Piece.NONE,this.uniquePiecePositions[b.from2]=this.uniquePiecePositions[b.to2],this.uniquePiecePositions[b.to2]=Piece.NONE;
3461this.cr=b.cr;this.ep=b.ep;--this.numPly;this.sd=Side.other(this.sd)}Vd(){var a=this.generateSemiLegals();return this.filterLegals(a)}generateSemiLegals(a){for(var b=[],c=0;c<this.board.length;++c){var d=this.board[c];d!==Piece.NONE&&(a&&d!==a||Piece.side(d)===this.sd&&this._generateSemiLegalsFrom(c,d,b))}return b}generateSemiLegalsFrom(a,b){b||=this.board[a];var c=[];this._generateSemiLegalsFrom(a,b,c);return c}VdFrom(a,b){a=this.generateSemiLegalsFrom(a,b);return this.filterLegals(a)}_generateSemiLegalsFrom(a,
3462b,c){switch(b){case Piece.W_PAWN:case Piece.B_PAWN:this.generatePawn(b,a,c);break;case Piece.W_KNIGHT:case Piece.B_KNIGHT:this.generateKnight(b,a,c);break;case Piece.W_BISHOP:case Piece.B_BISHOP:this.generateBishop(b,a,c);break;case Piece.W_ROOK:case Piece.B_ROOK:this.generateRook(b,a,c);break;case Piece.W_QUEEN:case Piece.B_QUEEN:this.generateQueen(b,a,c);break;case Piece.W_KING:case Piece.B_KING:this.generateKing(b,a,c)}}generateSemiLegalsTo(a,b){return this.generateSemiLegals(b).filter(function(c){return c.to===
3463a})}static g_arrKnightMvs=[[2,1],[1,2],[-1,2],[-2,1],[-2,-1],[-1,-2],[1,-2],[2,-1]];static g_arrKingMvs=[[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1],[0,-1],[1,-1]];static g_arrBishopMvs=[[1,1],[-1,1],[-1,-1],[1,-1]];static g_arrRookMvs=[[1,0],[0,1],[-1,0],[0,-1]];generateKnight(a,b,c){this.generate(a,b,Position.g_arrKnightMvs,!1,c)}generateKing(a,b,c){this.generate(a,b,Position.g_arrKingMvs,!1,c);if(a===Piece.W_KING){if(!(this.cr&CastleRights.W_ALL))return;if(2===this.ty){if(this.isAttacked(this.m_nWK00Sq,
3464Side.BLACK))return;
3464if(this.cr&CastleRights.W_00){b=!0;for(var d=this.m_nWR00Sq>CBSquare.F1?CBSquare.A1-CBSquare.B1:CBSquare.B1-CBSquare.A1,e=this.m_nWR00Sq;b&&e!==CBSquare.F1;e+=d)0!==this.board[e+d]&&e+d!==this.m_nWK00Sq&&(b=!1);d=this.m_nWK00Sq>CBSquare.G1?CBSquare.A1-CBSquare.B1:CBSquare.B1-CBSquare.A1;if(b)for(e=this.m_nWK00Sq;b&&e!==CBSquare.G1;e+=d)0!==this.board[e+d]&&e+d!==this.m_nWR00Sq&&(b=!1);if(b)for(e=this.m_nWK00Sq;b&&e!==CBSquare.G1;e+=d)this.isAttacked(e+d,Side.BLACK)&&(b=!1);b&&(b=
3465new Move(this.m_nWK00Sq,this.m_nWR00Sq),b.Chess960ShortCastling=!0,b.Chess960CastlingFlags=String.fromCharCode("A".charCodeAt()+CBSquare.F(this.m_nWR00),"A".charCodeAt()+CBSquare.F(this.m_nWR000)),b.Chess960InitialWhiteKingPosition=this.m_nWK00Sq,b.Chess960InitialBlackKingPosition=this.m_nBK00Sq,c.push(b))}if(this.cr&CastleRights.W_000){b=!0;d=this.m_nWR000Sq>CBSquare.D1?CBSquare.A1-CBSquare.B1:CBSquare.B1-CBSquare.A1;for(e=this.m_nWR000Sq;b&&e!==CBSquare.D1;e+=d)0!==this.board[e+d]&&e+d!==this.m_nWK00Sq&&
3466(b=!1);d=this.m_nWK00Sq>CBSquare.C1?CBSquare.A1-CBSquare.B1:CBSquare.B1-CBSquare.A1;if(b)for(e=this.m_nWK00Sq;b&&e!==CBSquare.C1;e+=d)0!==this.board[e+d]&&e+d!==this.m_nWR000Sq&&(b=!1);if(b)for(e=this.m_nWK00Sq;b&&e!==CBSquare.C1;e+=d)this.isAttacked(e+d,Side.BLACK)&&(b=!1);b&&(b=new Move(this.m_nWK00Sq,this.m_nWR000Sq),b.Chess960LongCastling=!0,b.Chess960CastlingFlags=String.fromCharCode("A".charCodeAt()+CBSquare.F(this.m_nWR00Sq),"A".charCodeAt()+CBSquare.F(this.m_nWR000Sq)),b.Chess960InitialWhiteKingPosition=
3467this.m_nWK00Sq,b.Chess960InitialBlackKingPosition=this.m_nBK00Sq,c.push(b))}}else{if(this.isAttacked(CBSquare.E1,Side.BLACK))return;this.cr&CastleRights.W_00&&this.board[CBSquare.F1]===Piece.NONE&&this.board[CBSquare.G1]===Piece.NONE&&(this.isAttacked(CBSquare.F1,Side.BLACK)||this.isAttacked(CBSquare.G1,Side.BLACK)||c.push(Move.g_mvW00));this.cr&CastleRights.W_000&&this.board[CBSquare.D1]===Piece.NONE&&this.board[CBSquare.C1]===Piece.NONE&&this.board[CBSquare.B1]===Piece.NONE&&(this.isAttacked(CBSquare.D1,
3468Side.BLACK)||this.isAttacked(CBSquare.C1,Side.BLACK)||c.push(Move.g_mvW000))}}if(a===Piece.B_KING&&this.cr&CastleRights.B_ALL)if(2===this.ty){if(!this.isAttacked(this.m_nBK00Sq,Side.WHITE)){if(this.cr&CastleRights.B_00){b=!0;d=this.m_nBR00Sq>CBSquare.F8?CBSquare.A1-CBSquare.B1:CBSquare.B1-CBSquare.A1;for(e=this.m_nBR00Sq;b&&e!==CBSquare.F8;e+=d)0!==this.board[e+d]&&e+d!==this.m_nBK00Sq&&(b=!1);d=this.m_nBK00Sq>CBSquare.G8?CBSquare.A1-CBSquare.B1:CBSquare.B1-CBSquare.A1;if(b)for(e=this.m_nBK00Sq;b&&
3469e!==CBSquare.G8;e+=d)0!==this.board[e+d]&&e+d!==this.m_nBR00Sq&&(b=!1);if(b)for(e=this.m_nBK00Sq;b&&e!==CBSquare.G8;e+=d)this.isAttacked(e+d,Side.WHITE)&&(b=!1);b&&(b=new Move(this.m_nBK00Sq,this.m_nBR00Sq),b.Chess960ShortCastling=!0,b.Chess960CastlingFlags=String.fromCharCode("A".charCodeAt()+CBSquare.F(this.m_nWR00Sq),"A".charCodeAt()+CBSquare.F(this.m_nWR000Sq)),b.Chess960InitialWhiteKingPosition=this.m_nWK00Sq,b.Chess960InitialBlackKingPosition=this.m_nBK00Sq,c.push(b))}if(this.cr&CastleRights.B_000){b=
3470!0;d=this.m_nBR000Sq>CBSquare.D8?CBSquare.A1-CBSquare.B1:CBSquare.B1-CBSquare.A1;for(e=this.m_nBR000Sq;b&&e!==CBSquare.D8;e+=d)0!==this.board[e+d]&&e+d!==this.m_nBK00Sq&&(b=!1);d=this.m_nBK00Sq>CBSquare.C8?CBSquare.A1-CBSquare.B1:CBSquare.B1-CBSquare.A1;if(b)for(e=this.m_nBK00Sq;b&&e!==CBSquare.C8;e+=d)0!==this.board[e+d]&&e+d!==this.m_nBR000Sq&&(b=!1);if(b)for(e=this.m_nBK00Sq;b&&e!==CBSquare.C8;e+=d)this.isAttacked(e+d,Side.WHITE)&&(b=!1);b&&(b=new Move(this.m_nBK00Sq,this.m_nBR000Sq),b.Chess960LongCastling=
3471!0,b.Chess960CastlingFlags=String.fromCharCode("A".charCodeAt()+CBSquare.F(this.m_nWR00),"A".charCodeAt()+CBSquare.F(this.m_nWR000)),b.Chess960InitialWhiteKingPosition=this.m_nWK00Sq,b.Chess960InitialBlackKingPosition=this.m_nBK00Sq,c.push(b))}}}else this.isAttacked(CBSquare.E8,Side.WHITE)||(this.cr&CastleRights.B_00&&this.board[CBSquare.F8]===Piece.NONE&&this.board[CBSquare.G8]===Piece.NONE&&(this.isAttacked(CBSquare.F8,Side.WHITE)||this.isAttacked(CBSquare.G8,Side.WHITE)||c.push(Move.g_mvB00)),
3472this.cr&CastleRights.B_000&&this.board[CBSquare.D8]===Piece.NONE&&this.board[CBSquare.C8]===Piece.NONE&&this.board[CBSquare.B8]===Piece.NONE&&(this.isAttacked(CBSquare.D8,Side.WHITE)||this.isAttacked(CBSquare.C8,Side.WHITE)||c.push(Move.g_mvB000)))}generateRook(a,b,c){this.generate(a,b,Position.g_arrRookMvs,!0,c)}generateBishop(a,b,c){this.generate(a,b,Position.g_arrBishopMvs,!0,c)}generateQueen(a,b,c){this.generateRook(a,b,c);this.generateBishop(a,b,c)}generatePawn(a,b,c){var d=a===Piece.W_PAWN?
34731:-1,e=a===Piece.W_PAWN?CBSquare.R_8:CBSquare.R_1,f=CBSquare.C(b),g=CBSquare.R(b),h=Piece.side(a),k=g+d,l=CBSquare.I(f,k);e=k===e;this.board[l]===Piece.NONE&&(e?(c.push(new Move(b,l,Piece.QUEEN)),c.push(new Move(b,l,Piece.ROOK)),c.push(new Move(b,l,Piece.BISHOP)),c.push(new Move(b,l,Piece.KNIGHT))):(l=new Move(b,l),c.push(l)),a===Piece.W_PAWN&&g===CBSquare.R_2||a===Piece.B_PAWN&&g===CBSquare.R_7)&&(l=CBSquare.I(f,g+2*d),this.board[l]===Piece.NONE&&(l=new Move(b,l),c.push(l)));for(l=-1;1>=l;l+=2){var m=
3474f+l;k=g+d;if(CBSquare.isLegal(m,k)){k=CBSquare.I(m,k);var n=this.board[k];if(n!==Piece.NONE&&Piece.side(n)!==h)if(e)c.push(new Move(b,k,Piece.QUEEN)),c.push(new Move(b,k,Piece.ROOK)),c.push(new Move(b,k,Piece.BISHOP)),c.push(new Move(b,k,Piece.KNIGHT));else{var r=new Move(b,k);c.push(r)}n===Piece.NONE&&m===this.ep&&(n=h===Side.WHITE?CBSquare.R_5:CBSquare.R_4,m=CBSquare.I(m,n),m=this.board[m],g===n&&m===Piece.changeSide(a)&&(k=new Move(b,k),c.push(k)))}}}generate(a,b,c,d,e){a=Piece.side(a);for(var f=
3475CBSquare.R(b),g=CBSquare.C(b),h=0,k=c.length;h<k;++h){var l=c[h],m=g,n=f,r=d;do{m+=l[0];n+=l[1];if(!CBSquare.isLegal(m,n))break;var t=CBSquare.I(m,n),u=this.board[t];if(u!==Piece.NONE)if(Piece.side(u)===a)break;else r=!1;t=new Move(b,t);e.push(t)}while(r)}}filterLegals(a){var b=this;return a.filter(function(c){return!b.isSuicideMove(c)})}isProm(a,b){var c=this.sd;return this.board[a]==Piece.make(Piece.PAWN,c)&&CBSquare.R(b)==CBSquare.getPromRow(c)}isEnPassant(a,b){return this.board[a]==Piece.make(Piece.PAWN,
3476this.sd)&&CBSquare.F(a)!=CBSquare.F(b)&&0==this.board[b]}isLegalFromTo(a,b){var c=new Move(a,b);this.isProm(a,b)&&(c.prom=Piece.QUEEN);return this.isLegalMove(c)}isLegalFromToIgnoreColor(a,b){var c=new Move(a,b);this.isProm(a,b)&&(c.prom=Piece.QUEEN);a=this.isLegalMove(c);this.sd=Side.other(this.sd);c=this.isLegalMove(c);this.sd=Side.other(this.sd);return a||c}isLegalMove(a){return null!=a&&(a.isNullMove()||this.isSemiLegalMove(a))&&!this.isSuicideMove(a)}isSemiLegalMove(a){if(null==a)return!1;var b=
3477a.from,c=a.to;
3477if(b===c)return!1;var d=this.board[b];if(d===Piece.NONE||Piece.side(d)!==this.sd)return!1;var e=this.board[c];if(e!==Piece.NONE&&Piece.side(d)===Piece.side(e))if(this.sd===Side.WHITE){if(b!==this.m_nWK00Sq||c!==this.m_nWR00Sq&&c!==this.m_nWR000Sq)return!1}else if(b!==this.m_nBK00Sq||c!==this.m_nBR00Sq&&c!==this.m_nBR000Sq)return!1;return this.generateSemiLegalsFrom(b,d).some(a.equals.bind(a))}isSuicideMove(a){var b=this.makeMove(a),c=this.isSuicidePos();this.unmakeMove(a,b);return c}initFields(){this.board=
3478Array(Board.SIZE);this.uniquePiecePositions=Array(Board.SIZE);this.initEmpty()}initEmpty(){for(var a=0;64>a;a++)this.board[a]=Piece.NONE;this.sd=Side.WHITE;this.cr=0;this.ep=Position.NOEP;this.numPly=this.lastKillOrPawn=this.ty=0}toNormalizedFEN(){for(var a="",b=CBSquare.R_8;b>=CBSquare.R_1;--b){for(var c=0,d=CBSquare.C_A;d<=CBSquare.C_H;++d){var e=CBSquare.I(d,b);e=this.board[e];e===Piece.NONE?++c:(0<c&&(a+=c),c=0,a+=Piece.toString(e))}0<c&&(a+=c);b>CBSquare.R_1&&(a+="/")}a=a+" "+Side.toString(this.sd);
3479a+=" ";a=2===this.ty?a+CastleRights.to960String(this.cr,this.m_nWR00Sq,this.m_nR000Sq):a+CastleRights.toString(this.cr);a+=" ";this.ep===Position.NOEP?a+="-":(b=this.getEPField(),a+=CBSquare.toString(b));return a}toFEN(){var a=this.toNormalizedFEN();a+=" 0 ";var b=this.getMoveNum();return a+b}toString(){return this.toFEN()}toDescriptiveString(){for(var a=" KQNBRP".split(""),b="",c=[],d=[],e=0;16>e;e++)c.push([0,0,0,0,0,0,0,0,0,0]),d[e]=0;for(e=0;64>e;e++){var f=this.board[e]&15;f&&16>d[f]&&(c[f][d[f]++]=
3480e)}b+="w";for(e=1;7>e;e++)if(0<d[e]){1<e&&(b+=",");f=a[e];b+=String(f);for(var g=0;g<d[e];g++)f=c[e][g],b+=CBSquare.toString(f),g<d[e]-1&&(b+=",")}b+="/b";for(e=9;15>e;e++)if(0<d[e])for(9<e&&(b+=","),f=a[e&7],b+=String(f),g=0;g<d[e];g++)f=c[e][g],b+=CBSquare.toString(f),g<d[e]-1&&(b+=",");this.getBTM()&&(b+=":b");return b}getPiece(a){return this.board[a]}getPieces(){for(var a=[],b=0;b<this.board.length;++b){var c=this.board[b];c!==Piece.NONE&&(c=new PieceData(c,b),a.push(c))}return a}countPieces(a){for(var b=
34810,c=0;c<this.board.length;++c)this.board[c]==a&&b++;return b}countAllPieces(a){for(var b=0,c=0;c<this.board.length;++c)this.board[c]&&0!=(this.board[c]&Piece.SIDE_MASK)==!!a&&b++;return b}findKing(a){for(var b=0;b<this.board.length;++b)if(this.board[b]&&0!=(this.board[b]&Piece.SIDE_MASK)==a&&(this.board[b]&Piece.PIECE_MASK)==Piece.KING)return b;return-1}getBoard(){return this.board}isWTM(){return this.sd===Side.WHITE}isBTM(){return this.sd===Side.BLACK}setBTM(a){this.sd=a?Side.BLACK:Side.WHITE}getBTM(){return this.sd===
3482Side.BLACK}flipSideToMove(){this.sd=Side.other(this.sd)}Vj(){return this.sd}setSideToMove(a){this.sd=a}cloneAfterNullMove(){if(this.canMakeNullMove()){let a=ObjUtil.clone(this);a.makeNullMove();return a}}setCastleRights(a){this.cr=a}canCastle(a){return a?this.cr&(CastleRights.B_00|CastleRights.B_000):this.cr&(CastleRights.W_00|CastleRights.W_000)}getEPFile(){return this.ep===Position.NOEP?-1:this.ep%8}getCPPEPFile(){return this.ep===Position.NOEP?0:this.ep%8+1}setCPPEPFile(a){this.ep=0>=a?Position.NOEP:
3483a-1}getEPField(){return this.ep===Position.NOEP?-1:CBSquare.I(this.ep,this.sd===Side.WHITE?CBSquare.R_6:CBSquare.R_3)}getEPCol(){return this.ep}getEPVictimField(){return this.ep===Position.NOEP?-1:CBSquare.I(this.ep,this.sd===Side.WHITE?CBSquare.R_5:CBSquare.R_4)}getCastleRights(){return this.cr}getPossibleCastleRights(){var a=0;this.board[CBSquare.E1]===Piece.W_KING&&(this.board[CBSquare.A1]===Piece.W_ROOK&&(a|=CastleRights.W_000),this.board[CBSquare.H1]===Piece.W_ROOK&&(a|=CastleRights.W_00));this.board[CBSquare.E8]===
3484Piece.B_KING&&(this.board[CBSquare.A8]===Piece.B_ROOK&&(a|=CastleRights.B_000),this.board[CBSquare.H8]===Piece.B_ROOK&&(a|=CastleRights.B_00));return a}getPossibleEP(){for(var a=[],b=this.sd==Side.WHITE?CBSquare.R_5:CBSquare.R_4,c=Piece.make(Piece.PAWN,this.sd),d=Piece.changeSide(c),e=CBSquare.C_A;e<=CBSquare.C_H;++e){var f=CBSquare.I(e,b);this.board[f]===d&&(e>CBSquare.C_A&&this.board[CBSquare.I(e-1,b)]===c||e<CBSquare.C_H&&this.board[CBSquare.I(e+1,b)]===c)&&a.push(e)}return a}isAttacked(a,b){return 0<
3485this.getAttacksTo(a,b).length}getAttacksTo(a,b){var c=[];this._getAttacksTo(a,b,c);return c}_getAttacksTo(a,b,c){this.getPawnAttacksTo(a,b,c);this.getKnightAttacksTo(a,b,c);this.getKingAttacksTo(a,b,c);this.getRangedAttacksTo(a,b,c)}getIsPiece(a,b){return function(c){return c===a||b&&c===b}}getKnightAttacksTo(a,b,c){this.getAttacks(a,b,Position.g_arrKnightMvs,this.getIsPiece(Piece.make(Piece.KNIGHT,b)),!1,c)}
3485getKingAttacksTo(a,b,c){this.getAttacks(a,b,Position.g_arrKingMvs,this.getIsPiece(Piece.make(Piece.KING,
3486b)),!1,c)}getQueenAttacksTo(a,b,c){this.getAttacks(a,b,Position.g_arrBishopMvs,this.getIsPiece(Piece.make(Piece.QUEEN,b)),!0,c);this.getAttacks(a,b,Position.g_arrRookMvs,this.getIsPiece(Piece.make(Piece.QUEEN,b)),!0,c)}getPawnMovesTo(a,b,c){if(this.board[a]===Piece.NONE){var d=CBSquare.R(a),e=CBSquare.C(a);if(b!==Side.WHITE||d!==CBSquare.R_1&&d!==CBSquare.R_2)if(b!==Side.BLACK||d!==CBSquare.R_8&&d!==CBSquare.R_7){var f=b===Side.WHITE?-1:1;a=Piece.make(Piece.PAWN,b);b=b===Side.WHITE?CBSquare.R_4:CBSquare.R_5;
3487var g=CBSquare.I(e,d+f);this.board[g]===a?c.push(g):d===b&&this.board[g]===Piece.NONE&&(d=CBSquare.I(e,d+2*f),this.board[d]===a&&c.push(d))}}}getBishopAttacksTo(a,b,c){this.getAttacks(a,b,Position.g_arrBishopMvs,this.getIsPiece(Piece.make(Piece.BISHOP,b)),!0,c)}getRookAttacksTo(a,b,c){this.getAttacks(a,b,Position.g_arrRookMvs,this.getIsPiece(Piece.make(Piece.ROOK,b)),!0,c)}getRangedAttacksTo(a,b,c){this.getAttacks(a,b,Position.g_arrRookMvs,this.getIsPiece(Piece.make(Piece.ROOK,b),Piece.make(Piece.QUEEN,
3488b)),!0,c);this.getAttacks(a,b,Position.g_arrBishopMvs,this.getIsPiece(Piece.make(Piece.BISHOP,b),Piece.make(Piece.QUEEN,b)),!0,c)}static g_arrWhPawnAttks=[[1,1],[-1,1]];static g_arrBlPawnAttks=[[1,-1],[-1,-1]];getPawnAttacksTo(a,b,c){b===Side.WHITE?this.getAttacks(a,b,Position.g_arrWhPawnAttks,this.getIsPiece(Piece.W_PAWN),!1,c):this.getAttacks(a,b,Position.g_arrBlPawnAttks,this.getIsPiece(Piece.B_PAWN),!1,c)}getAttacks(a,b,c,d,e,f){if(!(0>a)){var g=CBSquare.R(a);a=CBSquare.C(a);for(var h=0,k=c.length;h<
3489k;++h){var l=c[h],m=a,n=g,r=e;do{m-=l[0];n-=l[1];if(!CBSquare.isLegal(m,n))break;var t=CBSquare.I(m,n),u=this.board[t];if(u!==Piece.NONE){if(Piece.side(u)!==b)break;else r=!1;d(u)&&f.push(t)}}while(r)}}}getKingsPos(a){a=Piece.make(Piece.KING,a);return this.board.indexOf(a)}getPiecePos(a,b){a=Piece.make(a,b);return this.board.indexOf(a)}isCheck(){var a=this.getKingsPos(this.sd),b=Side.other(this.sd);return this.isAttacked(a,b)}isSuicidePos(){var a=Side.other(this.sd);a=this.getKingsPos(a);return this.isAttacked(a,
3490this.sd)}isMate(){return this.isCheck()?!this.hasLegals():!1}isStaleMate(){return this.isCheck()?!1:!this.hasLegals()}swapSide(){return this.isCheck()||this.isMate()||this.isStaleMate()?!1:(this.makeMove(new Move),!0)}hasLegals(){return 0<this.Vd().length}getVictim(a){var b=this.board[a.to];return b!==Piece.NONE?b:Piece.nominal(this.board[a.from])===Piece.PAWN&&CBSquare.C(a.from)!==CBSquare.C(a.to)?(a=CBSquare.I(CBSquare.C(a.to),CBSquare.R(a.from)),this.board[a]):Piece.NONE}isTake(a){return this.getVictim(a)!==
3491Piece.NONE}calcNeed(a){var b=a.from,c=this.board[b],d={needCol:!1,needRow:!1},e=Piece.nominal(c);if(e===Piece.PAWN||e===Piece.KING)return d;for(var f=[],g=0;g<Board.SIZE;++g)this.board[g]===c&&g!==b&&f.push(g);if(!f.length||e===Piece.BISHOP&&f.every(function(n){return CBSquare.isDark(n)!==CBSquare.isDark(b)}))return d;g=e=!0;for(var h=!1,k=0,l=f.length;k<l;++k){var m=f[k];this.generateSemiLegalsFrom(m,c).some(function(n){return n.to===a.to})&&(h=!0,e&=CBSquare.C(m)!==CBSquare.C(b),g&=CBSquare.R(m)!==
3492CBSquare.R(b))}h&&(d.needCol=e||!g,d.needRow=!e);return d}preCalcCtx(a){this.preSetMinCtx(a);if(!a.isNullMove()){var b=this.calcNeed(a);a.setNeedCol(b.needCol);a.setNeedRow(b.needRow)}}preSetMinCtx(a){if(a.isNullMove())a.setMoved(Piece.make(Piece.PAWN,this.sd)),a.setVictim(Piece.NONE);else{a.setMoved(this.board[a.from]);var b=this.getVictim(a);a.setVictim(b);a.setIsCastling()}}postCalcCtx(a,b){if(a.isNullMove())a.setCheck(!1);else{var c=this.isCheck();a.setCheck(c);c&&b&&a.setMate(!this.hasLegals())}}read(a,
3493b){this.board=a.readByteArray(Board.SIZE);this.sd=a.readInt();this.ep=a.readByte()-1;this.cr=a.readByte();this.ty=b;this.numPly=0;2===b&&(this.m_nWK00Sq=a.readByte(),this.m_nBK00Sq=a.readByte(),this.m_nWR00Sq=a.readByte(),this.m_nWR000Sq=a.readByte(),this.m_nBR00Sq=a.readByte(),this.m_nBR000Sq=a.readByte(),this.m_nPosInx=a.readShort())}write(a){a.writeByteArray(this.board,Board.SIZE);a.writeInt(this.sd);a.writeByte(this.ep+1);a.writeByte(this.cr);2===this.ty&&(a.writeByte(this.m_nWK00Sq),a.writeByte(this.m_nBK00Sq),
3494a.writeByte(this.m_nWR00Sq),a.writeByte(this.m_nWR000Sq),a.writeByte(this.m_nBR00Sq),a.writeByte(this.m_nBR000Sq),a.writeShort(this.m_nPosInx))}copyTo(a){a.sd=this.sd;a.ep=this.ep;a.cr=this.cr;a.ty=this.ty;for(var b=0;64>b;b++)a.board[b]=this.board[b];for(b=0;64>b;b++)a.uniquePiecePositions[b]=this.uniquePiecePositions[b];2===this.ty&&(a.m_nWK00Sq=this.m_nWK00Sq,a.m_nWR00Sq=this.m_nWR00Sq,a.m_nWR000Sq=this.m_nWR000Sq,a.m_nBK00Sq=this.m_nBK00Sq,a.m_nBR00Sq=this.m_nBR00Sq,a.m_nBR000Sq=this.m_nBR000Sq,
3495a.m_nPosInx=this.m_nPosInx)}
3495static packBoard(a){for(var b=Array(32),c=0,d=b.length;c<d;++c)b[c]=a[2*c]|a[2*c+1]<<4;return b}static unpackBoard(a){for(var b=Array(2*a.length),c=0,d=a.length;c<d;++c)b[2*c]=a[c]&15,b[2*c+1]=a[c]>>4;return b}fillSquaresOfSide(a,b){for(var c=0;c<this.board.length;c++)Piece.side(this.board[c])==b&&(a[c]=this.board[c])}setEquals(a){for(var b=0;b<this.board.length;b++)if(this.board[b]!=a.board[b])return!1;return this.sd!=a.sd||this.ep!=a.ep||this.cr!=a.cr?!1:!0}setGreater(a){for(var b=
34960;b<this.board.length;b++)if(this.board[b]!=a.board[b])return this.board[b]>a.board[b];return this.sd!=a.sd?this.sd>a.sd:this.ep!=a.ep?this.ep>a.ep:this.cr!=a.cr?this.cr>a.cr:!1}dump(a){var b=new Board;b.copyFrom(this.board);b.toDebugStrs().forEach(void 0!==a?a:function(c){LOG(c)});b="s="+this.sd+", ep="+this.ep+", cr="+this.cr;void 0!==a?a(b):LOG(b)}isLegal(){var a=this.getPieces();if(32<a.length||2>a.length)return!1;for(var b=Array(Piece.B_PAWN+1),c=0;c<b.length;++c)b[c]=0;for(c=0;c<a.length;++c){var d=
3497a[c];++b[d.piece];if(Piece.nominal(d.piece)===Piece.PAWN&&(d=CBSquare.R(d.field),d==CBSquare.R_1||d==CBSquare.R_8))return!1}return 1!==b[Piece.W_KING]||1!==b[Piece.B_KING]||8<b[Piece.W_PAWN]||8<b[Piece.B_PAWN]?!1:!0}isBoardEqual(a){if(a.length!=this.board.length)return!1;for(var b=0;b<this.board.length;b++)if(this.board[b]!=a[b])return!1;return!0}findSquaresOfPiece(a){for(var b=[],c=0;c<this.board.length;c++)this.board[c]==a&&b.push(c);return b}static fromValues(a,b,c,d){var e=new Position;a.copyTo(e.board);
3498e.sd=b;e.setCastleRights(c);e.setCPPEPFile(d);e.ty=0;return e}swapColours(){var a=new Board;a.copyFrom(this.board);this.sd=1-this.sd;this.setCastleRights((this.cr&3)<<2|this.cr>>2&3);for(var b=0;64>b;b++)this.board[b^7]=a.sqs[b]?a.sqs[b]^8:0}normalizeEPFile(){if(this.ep){if(this.sd){var a=(this.ep-1<<3)+CBSquare.A4,b=!1;this.board[a]==(Piece.PAWN|Side.WHITE)&&(a>CBSquare.A4&&this.board[a-8]==(Piece.PAWN|Piece.BLACK)?b=!0:a<CBSquare.H4&&this.board[a+8]==(Piece.PAWN|Piece.BLACK)&&(b=!0))}else a=(this.ep-
34991<<3)+CBSquare.A5,b=!1,this.board[a]==(Piece.PAWN|Piece.BLACK)&&(a>CBSquare.A5&&this.board[a-8]==(Piece.PAWN|Piece.WHITE)?b=!0:a<CBSquare.H5&&this.board[a+8]==(Piece.PAWN|Piece.WHITE)&&(b=!0));b||(this.ep=0)}}cConv=[CBSquare.H8,CBSquare.G8,CBSquare.F8,CBSquare.E8,CBSquare.D8,CBSquare.C8,CBSquare.B8,CBSquare.A8,CBSquare.H7,CBSquare.G7,CBSquare.F7,CBSquare.E7,CBSquare.D7,CBSquare.C7,CBSquare.B7,CBSquare.B8,CBSquare.H6,CBSquare.G6,CBSquare.F6,CBSquare.E6,CBSquare.D6,CBSquare.C6,CBSquare.C7,CBSquare.C8,
3500CBSquare.H5,CBSquare.G5,CBSquare.F5,CBSquare.E5,CBSquare.D5,CBSquare.D6,CBSquare.D7,CBSquare.D8,CBSquare.H4,CBSquare.G4,CBSquare.F4,CBSquare.E4,CBSquare.E5,CBSquare.E6,CBSquare.E7,CBSquare.E8,CBSquare.H3,CBSquare.G3,CBSquare.F3,CBSquare.F4,CBSquare.F5,CBSquare.F6,CBSquare.F7,CBSquare.F8,CBSquare.H2,CBSquare.G2,CBSquare.G3,CBSquare.G4,CBSquare.G5,CBSquare.G6,CBSquare.G7,CBSquare.G8,CBSquare.H1,CBSquare.H2,CBSquare.H3,CBSquare.H4,CBSquare.H5,CBSquare.H6,CBSquare.H7,CBSquare.H8];bDiag=[!1,!1,!1,!1,!1,
3501!1,!1,!0,!1,!1,!1,!1,!1,!1,!0,!1,!1,!1,!1,!1,!1,!0,!1,!1,!1,!1,!1,!1,!0,!1,!1,!1,!1,!1,!1,!0,!1,!1,!1,!1,!1,!1,!0,!1,!1,!1,!1,!1,!1,!0,!1,!1,!1,!1,!1,!1,!0,!1,!1,!1,!1,!1,!1,!1];normalize(){var a=this.NORM_NONE;this.sd&&(this.swapColours(),a|=this.NORM_COL_SWAP);this.normalizeEPFile();var b=this.getKingsPos(Side.WHITE),c=this.getKingsPos(Side.BLACK);if(!this.cr){for(var d=!1,e=0;64>e;e++)if((this.board[e]&Piece.PIECE_MASK)==Piece.PAWN){d=!0;break}var f=0;32>(b&56)&&(a|=this.NORM_FILE_SWAP,f^=56);
3502d||(3<(b&7)&&(a|=this.NORM_RANK_SWAP,f^=7),e=b^f,this.cConv[e]!=e?a|=this.NORM_DIAG_SWAP:this.bDiag[e]&&(e=c^f,this.cConv[e]!=e&&(a|=this.NORM_DIAG_SWAP)));if(a&(this.NORM_FILE_SWAP|this.NORM_RANK_SWAP|this.NORM_DIAG_SWAP)){c=new Board;c.copyFrom(this.board);if(a&this.NORM_DIAG_SWAP)for(e=0;64>e;e++)b=e^f,b=(b&7)<<3|b>>3&7,this.board[b]=c[e];else if(f)for(e=0;64>e;e++)this.board[e]=c[e^f];this.ep&&a&NORM_FILE_SWAP&&(this.ep=9-this.ep)}}return a}unNormalize(a){this.normalizeEPFile();var b=0;a&this.NORM_FILE_SWAP&&
3503(b^=56);a&this.NORM_RANK_SWAP&&(b^=7);if(b||a&this.NORM_DIAG_SWAP){var c=new Board;c.copy(this.board);if(a&this.NORM_DIAG_SWAP)for(var d=0;64>d;d++)this.board[((d&7)<<3|d>>3&7)^b]=c[d];else if(b)for(d=0;64>d;d++)this.board[d]=c[d^b];this.ep&&a&this.NORM_FILE_SWAP&&(this.ep=9-this.ep)}a&this.NORM_COL_SWAP&&this.swapColours()}}
3504class PieceData{constructor(a,b){this.piece=a;this.field=b}toString(){var a=Piece.nominal(this.piece);return Piece.toString(a)+CBSquare.toString(this.field)}equals(a){return this.piece===a.piece&&this.field===a.field}}"use strict";
3505class Annotation{static DIAG_CHAR="[#]";toString(){var a="",b;for(b in this)this.hasOwnProperty(b)&&(a+=this[b].toString());return a}_read(a,b){for(var c=0;c<b;++c){a.readShort();var d=AnnoRec.readHeader(a);d.len-=AnnoRec.ANNO_HEAD_SIZE;var e=AnnoFactory.factory(d.type);e?(e.read(d.len,a),this.setItem(d.type,e)):a.skip(d.len)}return this}_read2(a,b){this._read(a,b);return this}write(a){var b=0,c;for(c in this)this.hasOwnProperty(c)&&"function"===typeof this[c].write&&b++;a.writeShort(b);for(c in this)this.hasOwnProperty(c)&&
3506"function"===typeof this[c].write&&this[c].write(a,c)}write2(a){var b=[],c;for(c in this)this.hasOwnProperty(c)&&b.push(c);var d=a.getPos();a.writeByte(0);var e=0;for(c=0;c<b.length;c++)this[b[c]].write&&(this[b[c]].write(a,b[c]),e++);b=a.getPos();a.setPos(d);a.writeByte(e);a.setPos(b)}static write(a,b){b?b.write(a):a.writeShort(0)}static write2(a,b){b?b.write2(a):a.writeByte(0)}read(a){var b=a.readShort();this._read(a,b)}read2(a){var b=a.readByte();b&&this._read2(a,b)}fromDataBuf(a){return this.read(a)}V17(a){return this.write(a)}static readFactory(a){var b=
3507a.readShort();return b?(new Annotation)._read(a,b):null}static readFactory2(a){var b=a.readUint8();return b?(new Annotation)._read2(a,b):null}empty(){for(var a in this)if(this.hasOwnProperty(a))return!1;return!0}count(){var a=0,b;for(b in this)this.hasOwnProperty(b)&&a++;return a}setItem(a,b){this[a]=b}hasItem(a){return!!this[a]}getItem(a){return this[a]}deleteItem(a){delete this[a]}addPreText(a){this[AnnoType.PRETEXT]=new TextAnno(a)}setPreText(a){this[AnnoType.PRETEXT]=new TextAnno(a)}addPostText(a){this[AnnoType.POSTTEXT]&&
3508this[AnnoType.POSTTEXT].m_str.length?this[AnnoType.POSTTEXT].addText(" "+a):this[AnnoType.POSTTEXT]=new TextAnno(a)}hasDiagram(){if(this[AnnoType.POSTTEXT]&&this[AnnoType.POSTTEXT].m_str.length)return-1!=this[AnnoType.POSTTEXT].m_str.search("[#]")}toggleDiagram(){this[AnnoType.POSTTEXT]&&this[AnnoType.POSTTEXT].m_str.length?-1!=this[AnnoType.POSTTEXT].m_str.search("[#]")?(this[AnnoType.POSTTEXT].m_str=this[AnnoType.POSTTEXT].m_str.replace("[#]",""),this[AnnoType.POSTTEXT].m_str.length||delete this[AnnoType.POSTTEXT]):
3509this[AnnoType.POSTTEXT].m_str+="[#]":this[AnnoType.POSTTEXT]=new TextAnno("[#]")}removeDiagram(){}hasPreText(){return this.hasItem(AnnoType.PRETEXT)}getPreText(){if(this.hasPreText())return this[AnnoType.PRETEXT].getString()}getPostText(){if(this.hasPostText())return this[AnnoType.POSTTEXT].getString()}hasPostText(){return this.hasItem(AnnoType.POSTTEXT)}addSymbol(a){this[AnnoType.SYMBOL]||(this[AnnoType.SYMBOL]=new SymbolsAnno);this[AnnoType.SYMBOL].addSymbol(a)}hasSymbol(){return void 0!==this[AnnoType.SYMBOL]}getSymbol(){return this[AnnoType.SYMBOL]}hasColSquares(){return this.hasItem(AnnoType.SQUARE_LIST)}hasArrows(){return this.hasItem(AnnoType.ARROW_LIST)}hasTraining(){return this.hasItem(AnnoType.TRAINING)}getTraining(){return this[AnnoType.TRAINING]}setTraining(a){a?
3510this[AnnoType.TRAINING]=a:delete this[AnnoType.TRAINING]}}"use strict";
3511class GameResultEnum{static GAME_UNFINISHED=-1;static BLACK_WINS=0;static DRAW=1;static WHITE_WINS=2;static LINE=3;static UNDEFINED_RESULT=3;static UNDEFINED=3;static isFinished(a){return a>=this.BLACK_WINS&&a<=this.WHITE_WINS}static toString(a){switch(a){case this.GAME_UNFINISHED:return lm.IN_PROGRESS;case this.WHITE_WINS:return"1\u20130";case this.BLACK_WINS:return"0\u20131";case this.DRAW:return"\u00bd\u2013\u00bd";case this.UNDEFINED_RESULT:return"";default:return""}}static fromString(a){switch(a){case "\u00bd\u2013\u00bd":case "1/2-1/2":case "1/2":return this.DRAW;
3512case "1\u20130":case "1-0":return this.WHITE_WINS;case "0\u20131":case "0-1":return this.BLACK_WINS}}}class GameResult{constructor(a){this.n=a}isFinished(){return GameResultEnum.isFinished(this.n)}toString(){return GameResultEnum.toString(this.n)}toPGNString(){switch(this.n){default:return"*";case GameResultEnum.WHITE_WINS:return"1-0";case GameResultEnum.BLACK_WINS:return"0-1";case GameResultEnum.DRAW:return"1/2-1/2"}}}
3513class GameHeader{constructor(){this.white=new PlayerData;this.black=new PlayerData;this.event=new EventData;this.player=[this.white,this.black];this.teamwhite=new TeamData;this.teamblack=new TeamData;this.result=GameResultEnum.LINE;this.clockParams=null;this.annotator="";this.board=this.subRound=this.round=0;this.eco="";this.result=GameResultEnum.LINE;this.eloBl=this.eloWh=0;this.date=new CBDate;this.clockParams=null}isValid(){return this.white.last||this.black.last||this.event.isValid()}getStrPlayers(a,
3514b){var c=this.white.getListStr(b||0);(b=this.black.getListStr(b||0))&&b.length?a?(a=c,0<this.eloWh&&(a+=" ("+this.eloWh+")"),a=a+" - "+b,0<this.eloBl&&(a+=" ("+this.eloBl+")")):a=c+"-"+b:a=c;return a}
3514toString(){var a=this.event.toString(),b=this.date.toLocaleString(),c=this.getStrPlayers(!0,999);a&&(c+=", "+a);b&&(c+=" "+b);return c}toCompactString(){var a=this.event.toString(),b=this.getStrPlayers(!1,0);a&&(b+=", "+a);return b}getWhite(){return this.white.getListStr(99)}getClockParams(){return this.clockParams}setClockParams(a){this.clockParams=
3515a}setWhite(a){this.white.init(a)}setWhiteTeam(a){this.teamwhite.white=a}getBlack(){return this.black.getListStr(99)}setBlack(a){this.black.init(a)}setBlackTeam(a){this.teamblack.team=a}getECO(){return this.eco}setECO(a){this.eco=a}getEvent(){return this.event.event}setEvent(a){this.event.event=a}getAnnotator(){return this.annotator}setAnnotator(a){this.annotator=a}getSite(){return this.event.site}setSite(a){this.event.site=a}isDefined(){return this.getWhite()||this.getBlack()}getResult(){return this.result}getCBResult(){return new GameResult(this.result)}setResult(a){var b=
3516this.result;this.result="undefined"!=typeof a?a:GameResultEnum.LINE;return b}setRoundStr(a){a&&(a=a.split("."),this.round=parseInt(a[0],10),1<a.length&&(this.subRound=parseInt(a[1],10)))}getRoundStr(){var a="";this.round&&(a=""+this.round,this.subRound&&(a=a+"."+this.subRound));return a}getEloWhite(){return this.eloWh}setEloWhite(a){this.eloWh=a}getEloBlack(){return this.eloBl}setEloBlack(a){this.eloBl=a}getMaxElo(){return Math.max(this.eloWh,this.eloBl)}setDateStr(a){this.date=CBDate.fromPGNString(a)}getLocaleDateStr(){return this.date.toLocaleString()}getDateStr(){return this.date.toPGNString()}setDeleted(a){this.flags=
3517(this.deleted=a)?this.flags|1:this.flags&-2}read(a){this.white=PlayerData.readFactory(a);this.black=PlayerData.readFactory(a);try{this.event=EventData.readFactory(a);SourceData.readFactory(a);this.annotator=AnnotatorData.readFactory(a).name;this.eloWh=a.readShort();this.eloBl=a.readShort();this.nEco=a.Vx();this.eco=GameHeader.ECOtoString(this.nEco);this.result=GameHeader.readResult(a);this.date=new CBDate;var b=a.readInt();this.date.constructFromNum(b);this.plyCount=a.readShort();this.round=a.readByte();
3518this.subRound=a.readByte();a.readInt();a.readInt();a.skipSizedRead()}catch(c){return console.log(c),!1}return!0}compactFromDataBuf(a){a.Vc();this.eType=a.V1a();this.nGame=a.V19();this.white=PlayerData.readFactory(a);this.black=PlayerData.readFactory(a);this.event=EventData.readFactory(a);this.eloWh=a.V1a();this.eloBl=a.V1a();this.result=GameHeader.readResult(a);this.date=new CBDate;this.date.fromDataBuf(a);this.plyCount=a.V1a();this.round=a.readByte();this.subRound=a.readByte();a.Vw();a.Vw();this.nEco=
3519a.Vx();this.eco=GameHeader.ECOtoString(this.nEco);this.flags=a.Vx();this.deleted=!!(this.flags&1);a.Vm()}compactToDataBuf(a){a.beginSizedWrite();void 0!==this.eType?a.V14(this.eType):a.V14(1);void 0!==this.nGame?a.V13(this.nGame):a.V13(0);this.white.write(a);this.black.write(a);this.event.write(a);a.writeShort(this.eloWh);a.writeShort(this.eloBl);GameHeader.writeResult(this.result,a);void 0===this.date&&(this.date=new CBDate(0));this.date.V17(a);this.plyCount?a.V14(this.plyCount):a.V14(0);a.writeByte(this.round);
3520a.writeByte(this.subRound);a.Vu(0);a.Vu(0);this.nEco?a.Vv(this.nEco):a.Vv(0);void 0===this.flags&&(this.flags=0);this.deleted&&(this.flags|=1);a.Vv(this.flags);a.endSizedWrite()}write(a){this.white.write(a);this.black.write(a);this.event.write(a);(new SourceData).write(a);(new AnnotatorData(this.annotator)).write(a);a.writeShort(this.eloWh);a.writeShort(this.eloBl);a.writeShort(0);GameHeader.writeResult(this.result,a);a.writeInt(0);this.plyCount?a.writeShort(this.plyCount):a.writeShort(0);a.writeByte(this.round);
3521a.writeByte(this.subRound);a.writeInt(0);a.writeInt(0);a.beginSizedWrite();a.endSizedWrite()}static readResult(a){var b=a.readByte();a.readByte();a.readByte();return b}static writeResult(a,b){b.writeByte(a);b.writeByte(0);b.writeByte(0)}static ECOtoString(a){var b=a>>7;if(0<b&&500>=b){b--;var c=String.fromCharCode("A".charCodeAt()+b/100)[0];b%=100;c+=String.fromCharCode("0".charCodeAt()+b/10)[0];c+=String.fromCharCode("0".charCodeAt()+b%10)[0];if(b=a&127)c+="/",100<=b?c+="99":(c+=String.fromCharCode("0".charCodeAt()+
3522b/10)[0],c+=String.fromCharCode("0".charCodeAt()+b%10)[0])}else c="";return c}toJson(){return{gameNo:this.nGame,white:this.white.getListStr(1),black:this.black.getListStr(1),event:this.event.event,date:this.date.getYear(),result:GameResultEnum.toString(this.result),elow:this.eloWh,elob:this.eloBl,eco:this.eco,round:this.round,subRound:this.subRound,plyCount:this.plyCount,flags:this.flags}}matchesFilterVal(a){return-1!=this.white.last.search(a)||-1!=this.black.last.search(a)||-1!=this.event.site.search(a)||
3523-1!=this.event.event.search(a)?!0:!1}}
3524class PlayerData{constructor(a,b){this.first=a?a:"";this.last=b?b:""}isValid(){return this.last||this.first}toString(){return this.first&&this.first.length&&this.last&&this.last.length?String.formatEx("{last}, {first}",this):this.last||this.first}getListStr(a,b){return a&&this.first&&this.last&&this.first.length&&this.last.length?b?this.last+b+this.first.substr(0,a):this.last+","+this.first.substr(0,a):this.last||this.first}static g_splitOnComma=!0;static g_splitOnSpace=!1;init(a){if(PlayerData.g_splitOnComma){var b=a.split(",");
3525if(2===b.length){this.first=b[1].trim();this.last=b[0].trim();return}}if(PlayerData.g_splitOnSpace&&(b=a.split(" "),1<b.length)){this.first=b[0];this.last=b.slice(1).join(" ");return}this.last=a;this.first=""}static create(a){var b=new PlayerData;b.init(a);return b}read(a){this.last=a.readByteLenASCIIString(50);this.first=a.readByteLenASCIIString(50);StrUtil.mayBeUtf8(this.last)&&(this.last=StrUtil.decodeUTF8(this.last));StrUtil.mayBeUtf8(this.first)&&(this.first=StrUtil.decodeUTF8(this.first));this.last=
3526this.last.trim();this.first=this.first.trim()}static readFactory=createReadFactory(PlayerData);write(a){a.writeByteLenASCIIString(this.last);a.writeByteLenASCIIString(this.first)}}
3527class EventData{constructor(){this.event=this.site="";this.rounds=this.flags=this.category=this.nation=this.type=this.dt=0}read(a){this.site=a.readByteLenASCIIString(100);this.event=a.readByteLenASCIIString(100);this.dt=a.readInt();this.type=a.readShort();this.nation=a.readShort();this.category=a.readByte();this.flags=a.readByte();this.rounds=a.readShort()}static readFactory=createReadFactory(EventData);write(a){a.writeByteLenASCIIString(this.site);a.writeByteLenASCIIString(this.event);a.writeInt(this.dt);
3528a.writeShort(this.type);a.writeShort(this.nation);a.writeByte(this.category);a.writeByte(this.flags);a.writeShort(this.rounds)}isValid(){return this.site||this.event}toString(){var a=this.event;this.site&&this.event&&this.site!=this.event&&(a+=" ");this.site!=this.event&&(a+=this.site);return a}static normalizeQueryString(a){a=a.replaceAll('"',"");a=a.replaceAll(".","");a=a.replaceAll(" ","-");a=a.replaceAll("&","-");a=a.replaceAll("/","-");a=a.replaceAll("--","-");return a=a.replaceAll("--","-")}}
3529class SourceData{constructor(){this.publisher=this.source="";
3529this.quality=this.version=this.verdt=this.pubdt=0}read(a){this.source=a.readByteLenASCIIString(100);this.publisher=a.readByteLenASCIIString(100);this.pubdt=a.readInt();this.verdt=a.readInt();this.version=a.readByte();this.quality=a.readByte()}static readFactory=createReadFactory(SourceData);write(a){a.writeByteLenASCIIString(this.source);a.writeByteLenASCIIString(this.publisher);a.writeInt(this.pubdt);a.writeInt(this.verdt);a.writeByte(this.version);
3530a.writeByte(this.quality)}}class TeamData{constructor(){this.team="";this.nation=this.seasoned=this.num=0}toString(){return this.num?String.formatEx("{team} {num}",this):this.team}read(a){this.team=a.readByteLenASCIIString(100);this.num=a.readShort();this.seasoned=a.readByte();this.nation=a.readByte()}static readFactory=createReadFactory(TeamData);write(a){a.writeByteLenASCIIString(this.team);a.writeShort(this.num);a.writeByte(this.seasoned);a.writeByte(this.nation)}}
3531class AnnotatorData{constructor(a){this.name="";a&&(this.name=a)}toString(){return this.name}read(a){this.name=a.readByteLenASCIIString(100)}static readFactory=createReadFactory(AnnotatorData);write(a){a.writeByteLenASCIIString(this.name)}}"use strict";const MoveEnterType={CANCEL:-1,TYPE_MASK:-64,LINE_MASK:63,QUERY:64,OVERWRITE_MAIN:128,OVERWRITE_LINE:256,NEWLINE:512,INSERT_MAIN:1024,NEWMAINLINE:2048,INSERT_LINE:4096};
3532class Game{constructor(a,b){this.construct(a,b);Game.InitListeners()}construct(a,b){this.stk=null;a||=new Position;this.start=a;b||=new MoveLine;this.mainLine=b;this.stk=new LineStack(this.mainLine);this.hdr=new GameHeader;this.initPost()}init(a,b){this.construct(a,b);this.fireOnChanged();this.fireOnHeaderChanged()}initPost(){this.cur=ObjUtil.clone(this.start);Game.initLine(this.start,this.mainLine)}assign(a,b){this.start=a.start;this.cur=a.cur;this.mainLine=a.mainLine;this.stk=a.stk;this.hdr=a.hdr;
3533this.replaceGameNo=a.replaceGameNo;this.replaceDBId=a.replaceDBId;b||(this.fireOnResetGame(),this.fireOnCurPosChanged(),this.fireOnChanged(),this.fireOnHeaderChanged())}clone(a){return ObjUtil.clone2(this,a)}getMoves(){return this.mainLine}setMoves(a){this.mainLine=a}exec(a,b){b=b||0;for(let d=0;d<a.mainLine.length&&(0==b||d<b);d++){var c=ObjUtil.clone(a.mainLine[d]);this.makeMove(c)}}getMainLine(){return this.getMoves()}getCurPos(){return this.cur}getStartPos(){return this.start}isNormalInit(){var a=
3534new Position;return ObjUtil.equals(this.start,a)}getNextMove(){var a=this.stk.Top();if(a){if(a.isLineEnd())return null;var b=a.getLine();a=a.getMovesToGo();return b[a]}return null}getLastMove(){if(this.stk){var a=this.stk.Top();if(!a||a.isLineStart())return null;var b=a.getLine();if(b)return a=a.getMovesToGo(),b[a-1]}return null}getPreviousMove(){return this.getLastMove()}static initLine(a,b){a=ObjUtil.clone(a);for(var c=0,d=b.length;c<d;++c){var e=b[c];a.preCalcCtx(e);if(e.hasLines())for(var f=e.getSubLines(),
3535g=0,h=f.length;g<h;++g)Game.initLine(a,f[g]);a.makeMove(e);a.postCalcCtx(e,c===b.length-1)}}reset(){this.construct();this.fireOnResetGame();this.fireOnCurPosChanged();this.fireOnChanged();this.fireOnHeaderChanged()}setResult(a){this.hdr.setResult(a);this.fireOnChanged();this.fireOnHeaderChanged()}getResult(){return this.hdr.getResult()}getCBResult(){return this.hdr.getCBResult()}getTopItem(){return this.stk.Top()}getTopLine(){if(this.stk.Top())return this.stk.Top().getLine()}getTopMovesToGo(){if(this.stk.Top())return this.stk.Top().getMovesToGo()}isLineEnd(){return this.stk.Top()?
3536this.stk.Top().isLineEnd():!1}isOnMainLine(){return 1===this.stk.length}isGameStart(){return 1===this.stk.length&&this.stk[0].isLineStart()}isGameEnd(){return 1===this.stk.length&&this.stk[0].isLineEnd()}getStackPos(a){for(var b=ObjUtil.clone(this.start),c=0,d=a.length;c<d;++c){var e=a[c],f=e.getLine();e=e.getMovesToGo();for(var g=0;g<e;++g)b.makeMove(f[g])}return b}getLinePos(a,b){a=Game.getStackForLine(a,b);return this.getStackPos(a)}setStack(a){this.stk=a;0<this.stk.length&&(this.mainLine=this.stk[0].line);
3537this.cur=this.getStackPos(this.stk)}getSimplePath(){return this.stk.getSimplePath()}getHeader(){return this.hdr}setHeader(a){this.hdr=a}getGameNo(){return this.hdr.nGame}requiresPremiumForDownload(){var a=0;this.forAllMoves(function(b){a++});return a>2*this.getMainLine().length?5<this.hdr.annotator.length:!1}countAllMoves(){var a=0;this.forAllMoves(function(){a++});return a}selfTest(){CBDebug.call(this.stk,this.stk.selfTest);CBDebug.call(this.mainLine,this.mainLine.selfTest,this.start,null,0)}getLineCnt(a){return this.stk.length}isOnLastMove(){return this.getMoveIndex()==
3538this.mainLine.length}getPlyNum(){return this.getCurPos().getPlyNum()}getMoveNo(){return this.getPlyNum()}getMoveCount(){return this.mainLine.length}getMoveBaggage(){return this.getLastMove()?this.getLastMove().getBaggage():this.baggage}setMoveBaggage(a){this.getLastMove()?this.getLastMove().setBaggage(a):this.baggage=a;this.fireOnChanged()}getAnno(a){if(this.getLastMove()){let b=this.getLastMove().getAnnoItem(a);if(a!=AnnoType.TRAINING||1<this.getMoveNo())return b}if(this.mainLine.anno)return this.mainLine.anno.getItem(a)}setAnno(a,
3539b){this.getLastMove()?(this.getLastMove().setAnnoItem(a,b),this.fireOnChanged()):(this.mainLine.anno=this.mainLine.anno||new Annotation,this.mainLine.anno.setItem(a,b));this.fireOnAnnoChanged(a,b)}removeAllAttributes(){this.getLastMove()&&(this.getLastMove().deleteAnnoItem(AnnoType.ARROW_LIST),this.getLastMove().deleteAnnoItem(AnnoType.SQUARE_LIST),this.fireOnChanged())}setAnnoBeforeFirstMove(a,b,c){this.mainLine.anno||(this.mainLine.anno=new Annotation);this.mainLine.anno.setItem(a,b);c||this.fireOnChanged()}getAnnoBeforeFirstMove(a){return this.mainLine.anno?
3540this.mainLine.anno.getItem(a):null}getOrCreateCurrAnno(){if(this.getPreviousMove())return this.getPreviousMove().hasAnno()||this.getPreviousMove().setAnno(new Annotation),this.getPreviousMove().getAnno();this.getMoves().hasAnno()||this.getMoves().setAnno(new Annotation);return this.getMoves().getAnno()}updateFromExtern(){this.fireOnChanged();this.fireOnCurPosChanged()}updateHeaderFromExtern(){this.fireOnHeaderChanged()}deleteAnnosInCurLine(a,b){for(var c=this.getCurLine(),d=0;d<c.length;d++)c[d]&&
3541(a?c[d].deleteAnnoItem(a):c[d].setAnno(null));b||this.fireOnChanged()}deleteAnno(a,b){this.getLastMove()&&(this.getLastMove().deleteAnnoItem(a),b||this.fireOnAnnoChanged())}getEvaluationProfile(){if(this.mainLine.anno&&this.mainLine.anno[AnnoType.EVAL_PROFILE])return this.mainLine.anno[AnnoType.EVAL_PROFILE];var a=this.getCurLine();if(a.length&&a[0].annos)return a[0].annos[AnnoType.EVAL_PROFILE]}initEvaluationProfile(a){this.mainLine.anno||(this.mainLine.anno=new Annotation);a=a||new EvalProfileAnno;
3542return this.mainLine.anno[AnnoType.EVAL_PROFILE]=a}deleteEvaluationProfile(){this.mainLine.anno&&delete this.mainLine.anno[AnnoType.EVAL_PROFILE]}toString(){var a=new NotationGenerator(V5),b=this.hdr.toString();b+="\r\n";for(var c=0;c<this.mainLine.length;c++){var d=a.getMoveNota(this.mainLine[c]),e=a.getStrMoveNumInLine(c,this.getStartPos().getPlyNum());b+=e+d;c<this.mainLine.length-1&&(b+=" ")}return b+=" "+this.hdr.getCBResult().toString()}onSync(a){if(window.glApp.panelMgr&&window.glApp.panelMgr.onSync)window.glApp.panelMgr.onSync(a)}mainLineEqual(a){for(var b=
3543Math.min(this.mainLine.length,a.mainLine.length),c=0;c<b;c++)if(!this.mainLine[c].equals(a.mainLine[c]))return!1;return!0}static createTestGame(){return new Game}delayChangedEvents(a){this.delayfireOnCurPosChanged(a);this.delayfireOnChanged(a);this.delayfireOnHeaderChanged(a);this.delayfireOnAnnoChanged(a)}skipChangedEvents(a){this.skipfireOnCurPosChanged(a);this.skipfireOnChanged(a);this.skipfireOnHeaderChanged(a);this.skipfireOnAnnoChanged(a)}continueChangedEvents(){this.continuefireOnCurPosChanged();
3544this.continuefireOnChanged();this.continuefireOnHeaderChanged();this.continuefireOnAnnoChanged()}getCurLine(){return this._getCurLine(!1)}getCurLineCut(){return this._getCurLine(!0)}getLineStartMoveNo(){for(var a=0,b=0;b<this.stk.length-1;b++)a+=this.stk[b].getMovesToGo();return a}_getCurLine(a){for(var b=[],c=0,d=this.stk.length;c<d;++c){var e=this.stk[c],f=e.getLine();e=e.getMovesToGo();a||c!=d-1||(e=f.length);e&&(b=b.concat(f.slice(0,e)))}return b}getCurLineIndex(){for(var a=0,b=0,c=this.stk.length;b<
3545c;++b)a+=this.stk[b].getMovesToGo();return a}setCurLineIndex(a){for(var b=new LineStack,c=0,d=this.stk.length;c<d;++c){var e=this.stk[c],f=e.getMovesToGo();if(c<d-1&&f<a)b.push(e),a-=f;else{c=e.getLine();f=a;a=new LineStackItem(c,f);b.push(a);break}}this.gotoStack(b)}jump(a){a=this.getMoveIndex()+a;1>a&&(a=1);a>this.mainLine.length&&(a=this.mainLine.length);this.gotoIndex(a);this.fireOnNavigate();this.fireOnCurPosChanged()}gotoFirst(){this.gotoIndex(0)}gotoLast(){this.gotoIndex(this.mainLine.length)}gotoIndex(a,
3546b){a=Game.getStackForIndex(this.mainLine,a);this.gotoStack(a,b)}gotoLine(a,b){a=Game.getStackForLine(a,b);this.gotoStack(a)}gotoSimplePath(a){a=this._getStackForSimplePath(this.mainLine,a);this.gotoStack(a)}triggerOnClickInNotation(a,b){this.fireOnClickInNotation(a,b)}gotoNext(){if(!this.isLineEnd()){var a=this.getNextMove();this.cur.makeMove(a);(a=this.getTopItem())&&a.incMovesToGo();this.fireOnCurPosChanged();this.fireOnNavigate()}}gotoPrev(a){if(!this.isGameStart()){var b=this.stk;b.gotoPrev();
3547this.gotoStack(b,a)}}gotoPrevClone(){if(!this.isGameStart()){var a=ObjUtil.clone(this.stk);a.gotoPrev();this.gotoStack(a)}}gotoStart(){this.gotoIndex(0);this.fireOnCurPosChanged();this.fireOnNavigate()}gotoEnd(){this.gotoIndex(this.mainLine.length);this.fireOnCurPosChanged();this.fireOnNavigate()}gotoStack(a,b){this.setStack(a);b||(this.fireOnCurPosChanged(),this.fireOnNavigate())}gotoMove(a,b){var c=this.getNextMove();return c?a.equals(c)?(a.mvd=c.mvd,this.gotoNext(),b&&this.fireOnMove(),!0):(a=
3548c.findLine(a))?(this.gotoLine(a,1),b&&this.fireOnMove(),!0):!1:!1}beginLineNextMove(a){var b=this.getNextMove();if(!b||!b.hasLines()||a>=b.getSubLines().length)return!1;a=b.getSubLines()[a][0];return this.gotoMove(a)?a:!1}endLine(){if(1<this.stk.length){var a=this.stk[this.stk.length-2],b=a.getLine();this.gotoLine(b,a.mvsToGo);return this.getMoveIndex()}}getMoveOffs(){return this.cur.numPly-this.start.numPly}getMoveIndex(){var a=0;if(0<this.stk.length){a=this.stk[this.stk.length-1];var b=a.getLine();
3549a=a.getMovesToGo();for(var c=this.stk.length-2;0<=c;--c){var d=this.stk[c].getLine(),e=b.getParentMoveIndex(),f=d[e],g=f.indexOfLine(b);CBDebug.assert(0<=g,"inxPrevLine >= 0");for(b=0;b<g;++b)a+=f.getLine(b).getTreeMoveCount();e+=1;for(f=d.length;e<f;
3549++e)if(g=d[e],g.hasLines()){b=0;for(var h=g.getSubLinesCount();b<h;++b)a+=g.getLine(b).getTreeMoveCount()}a+=d.length;b=d}}return a}static getStackForLine(a,b){for(var c=[];null!=a;b=a.getParentMoveIndex(),a=a.getParentLine())b=new LineStackItem(a,b),
3550c.push(b);for(a=new LineStack;0<c.length;)b=c.pop(),a.push(b);return a}_getStackForSimplePath(a,b){for(var c=new LineStack,d=0,e=b.length;d<e;++d){var f=b[d],g=new LineStackItem(a,f.mvsToGo);c.push(g);d<e-1&&(a=a[f.mvsToGo].getLine(f.inxLine))}return c}static getStackForIndex(a,b){b={complete:!1,inxMv:b};var c=new LineStack;Game._getStackForIndex(a,b,c);return c}static _getStackForIndex(a,b,c){var d=a.length;if(b.inxMv<=d)return c.push(new LineStackItem(a,b.inxMv)),b.complete=!0;b.inxMv-=d;for(d=
3551a.length-1;0<=d;--d){var e=a[d];if(e.hasLines()){c.push(new LineStackItem(a,d));for(var f=0,g=e.getSubLinesCount();f<g;++f){var h=e.getLine(f);Game._getStackForIndex(h,b,c);if(b.complete)return!0}c.pop()}}return!1}promoteLine(){if(this.isOnMainLine())return!1;CBDebug.call(this,this.selfTest);this.stk.promoteLine();CBDebug.call(this,this.selfTest);this.fireOnChanged();return!0}_shiftLine(a){CBDebug.call(this,this.selfTest);if(!this.isOnMainLine()){var b=this.getTopLine();if(b){var c=b.getParentMove(),
3552d=c.getSubLinesCount();d&&1!==d&&(b=c.indexOfLine(b),a=b+a,0>a||a>=d||(c.swapLines(b,a),CBDebug.call(this,this.selfTest),this.fireOnChanged()))}}}upLine(){this._shiftLine(-1)}downLine(){this._shiftLine(1)}deleteLine(){if(!this.isOnMainLine()){CBDebug.call(this,this.selfTest);var a=this.stk.shallowClone(),b=this.getTopLine();b.getParentMove().removeLine(b);a.pop();this.setStack(a);CBDebug.call(this,this.selfTest);this.fireOnCurPosChanged();this.fireOnChanged()}}deleteRemaining(a){this.stk.deleteRemaining();
3553a||this.fireOnChanged()}deletePrevious(){if(0!=this.getCurLine().length){var a=this.stk.shallowClone();a.gotoPrev();a=this.getStackPos(a);this.mainLine=this.stk.deletePrevious();this.start=a;this.fireOnChanged()}}unAnnotate(a){this.mainLine.unAnnotate(a);a=new LineStack(this.mainLine,0);this.setStack(a);this.fireOnChanged();this.fireOnCurPosChanged()}startLine(){this.gotoPrev()}forAllMoves(a){this.mainLine.forAllMoves(a)}map(a){var b=new Game;b.setState(this.getStateCopy());var c=b.getMoveIndex();
3554b.gotoStart();a=this._mapImpl(b,b.getMainLine(),a);b.gotoIndex(c);this.setState(b.getStateCopy());return a}_mapImpl(a,b,c){var d=[];b.forEach(f=>{f.hasLines()&&f.getSubLines().forEach(g=>{d=d.concat(this._mapImpl(a,g,c))});a.makeMove(f);d.push(c(a))});for(var e=0;e<b.length;e++)a.gotoPrev(!0);return d}CMP(a,b){return a.equals(b)}merge(a,b){var c=a.getStartPos();c=this._findPos(c);if(!c)return this.assign(a,b);c=c.Top();var d=c.getLine(),e=c.getMovesToGo();c=0;a=a.mainLine;for(var f=e;f<d.length&&
3555c<a.length&&this.CMP(d[f],a[c]);++f,++c);if(!(c>=a.length)){f>=d.length||(e=d[f],d=new MoveLine(d,f),e.addLine(d));for(;c<a.length;++c)d.push(a[c]);d.setSubParentData(!1);b||this.fireOnChanged()}}storeOnce(){this.storeState={start:ObjUtil.clone(this.start),cur:ObjUtil.clone(this.cur),mainLine:ObjUtil.clone(this.mainLine),stk:ObjUtil.clone(this.stk)}}restoreOnce(){this.storeState&&(this.start=ObjUtil.clone(this.storeState.start),this.cur=ObjUtil.clone(this.storeState.cur),this.mainLine=ObjUtil.clone(this.storeState.mainLine),
3556this.stk=ObjUtil.clone(this.storeState.stk),this.setStack(this.stk))}storeOnce2(){this.storeState={start:ObjUtil.clone2(this.start),cur:ObjUtil.clone2(this.cur),mainLine:ObjUtil.clone2(this.mainLine),stk:ObjUtil.clone2(this.stk)}}restoreOnce2(){this.storeState&&(this.start=ObjUtil.clone2(this.storeState.start),this.cur=ObjUtil.clone2(this.storeState.cur),this.mainLine=ObjUtil.clone2(this.storeState.mainLine),this.stk=ObjUtil.clone2(this.storeState.stk),this.setStack(this.stk))}getStateCopy(){return{start:ObjUtil.clone2(this.start),
3557cur:ObjUtil.clone2(this.cur),mainLine:ObjUtil.clone2(this.mainLine),stk:ObjUtil.clone2(this.stk)}}setState(a){this.storeState=a;this.restoreOnce2()}beginLine(a){this._makeMoveNewLine(a)}makeMove(a,b){0<=b&&63>=b&&(b=MoveEnterType.NEWLINE);if(this.gotoMove(a))return!0;var c=null,d=b&MoveEnterType.TYPE_MASK;b&=MoveEnterType.LINE_MASK;switch(d){case MoveEnterType.CANCEL&MoveEnterType.TYPE_MASK:case MoveEnterType.CANCEL:break;case MoveEnterType.NEWMAINLINE:c=this._makeMoveNewMainLine(a);break;case MoveEnterType.NEWLINE:c=
3558this._makeMoveNewLine(a);break;case MoveEnterType.INSERT_MAIN:c=this._makeMoveInsertMove(a);break;default:case MoveEnterType.OVERWRITE_MAIN:c=this._makeMoveOverwriteMain(a);break;case MoveEnterType.OVERWRITE_LINE:c=this._makeMoveOverwriteLine(a,b);break;case MoveEnterType.INSERT_LINE:c=this._makeMoveInsertLine(a,b)}if(c)return a.undo=c,!0;LogException("No Undo","Type="+d+", mv="+a);return!1}_makeMoveSetCtx(a){this.cur.preCalcCtx(a);var b=this.cur.makeMove(a);this.cur.postCalcCtx(a,!0);return b}_makeMoveOverwriteMain(a){return this._makeMoveInMain(a,
3559function(b,c){b.length=c+1})}_makeMoveInMain(a,b){var c=this._makeMoveSetCtx(a);c||LogException("MoveInMain, no undo",a);var d=this.stk.Top();if(d){var e=d.getLine(),f=d.getMovesToGo();e[f]=a;b(e,f);d.setMovesToGo(f+1)}a.undo=c;this.fireOnMove();this.fireOnCurPosChanged();return c}_makeMoveInsertMove(a){this._makeMoveInMain(a,function(b,c){this._cutIllegalMoves(this.cur,b,c+1)}.bind(this))}_makeMoveInLine(a,b,c){var d=this._makeMoveSetCtx(a),e=this.stk.Top(),f=e.getMovesToGo();b=e.getLine()[f].getLine(b);
3560b[0]=a;c(b);a=new LineStackItem(b,1);this.stk.push(a);this.fireOnMove();this.fireOnCurPosChanged();return d}_makeMoveOverwriteLine(a,b){return this._makeMoveInLine(a,b,function(c){c.length=1})}_makeMoveInsertLine(a,b){var c=function(d){this._cutIllegalMoves(this.cur,d,1)}.bind(this);return this._makeMoveInLine(a,b,c)}_makeMoveNewLine(a){var b=this._makeMoveSetCtx(a),c=this.stk.Top();if(c){var d=c.getLine(),e=c.getMovesToGo();e<d.length?(c=d[e].newLine(d,e),c=new LineStackItem(c,0),c.pushMove(a),this.stk.push(c)):
3561c.pushMove(a);this.fireOnMove();this.fireOnCurPosChanged();return b}}_makeMoveNewMainLine(a){a=this._makeMoveNewLine(a);this.promoteLine();return a}_cutIllegalMoves(a,b,c){c=c||0;for(a=ObjUtil.clone(a);c<b.length;++c){var d=b[c];if(!a.isLegalMove(d))break;if(d.hasLines())for(var e=d.getSubLinesCount()-1;0<=e;--e){var f=d.getLine(e);this._cutIllegalMoves(a,f);0===f.length&&d.removeLine(e)}a.makeMove(d)}b.length=c}fromBuf64(a){var b=new DataBuffer;b.constructFromBase64(a);a=new Game;var c=new GameHeader;
3562c.compactFromDataBuf(b);b.V19();a.readGameOnly2(b);a.setHeader(c);this.assign(a)}fromBuf642(a){var b=new DataBuffer;b.constructFromBase64(a);this.read(b);return this}fromBuf643(a){var b=new DataBuffer;b.constructFromBase64(a);this.read3(b);return this}toBuf64(){var a=new DataBuffer;this.write(a);return a.toBase64()}toBuf642(){var a=new DataBuffer;this.write2(a);return a.toBase64()}static arrayToBuf64(a){var b=new DataBuffer;b.Vv(a.length);a.forEach(c=>{var d=new DataBuffer;c.write(d);b.writeDataBuffer(d)});
3563return b.toBase64()}static arrayFromBuf64(a){var b=[],c=new DataBuffer;c.constructFromBase64(a);a=c.Vx();for(var d=0;d<a;d++){var e=c.readDataBuffer(),f=new Game;f.read(e);b.push(f)}return b}write(a){var b=this.getMoveIndex();a.writeInt(b);a.writeInt(0);this.hdr.write(a);this._writeGame(a)}write2(a){var b=this.getMoveIndex();a.writeInt(b);a.writeInt(0);this.hdr.write(a);this._writeGame2(a)}_writeStartPos(a){var b=new Position;b=ObjUtil.equals(this.start,b);a.V1b(b);b||(this.start.write(a),a.writeShort(0),
3564a.writeShort(this.start.getMoveNum()),a.V1b(b))}_writeMoves(a){this.mainLine.write(a)}
3564_writeMoves2(a){this.mainLine.write2(a)}_readMoves(a){this.mainLine.read(a)}_readMoves2(a){this.mainLine.read2(a)}read(a){var b=a.readInt(),c=a.readInt();this.hdr.read(a);this._readGame(a,c);this.initPost();CBDebug.call(this,this.selfTest);this.fireOnChanged();this.gotoIndex(b)}read2(a){var b=!1;this.hdr.read(a)&&(this._readGame2(a),b=!0);this.initPost();return b}read3(a){var b=a.readInt(),c=a.readInt();this.hdr.read(a);
35652===c&&(this.hdr.variant="chess960");this._readGame2(a,c);a.beginSizedWrite();a.endSizedWrite();this.initPost();CBDebug.call(this,this.selfTest);this.fireOnChanged();this.fireOnHeaderChanged();this.gotoIndex(b)}readGameOnly2(a){this._readGame2(a);this.initPost()}writeGameOnly2(a){this._writeGame2(a)}fromDataBuf(a){return this.read(a)}V17(a){return this.write(a)}_readStartPos(a,b){var c=a.V1c();!c&&(this.start.read(a,b),a.readShort(),b=a.readShort(),this.start.setMoveNum(b),c=a.V1c())&&(this.start=
3566new Position)}_writeGame(a){this._writeStartPos(a);(this.mainLine.anno||new Annotation).write(a);this._writeMoves(a);a.beginSizedWrite();a.endSizedWrite()}_writeGame2(a){this._writeStartPos(a);a.writeUint8(0);this._writeMoves2(a)}_readGame(a,b){this._readStartPos(a,b);b=new Annotation;b.read(a);this._readMoves(a);b.empty()||this.mainLine.setAnno(b);a.Vc();a.Vm()}_readGame2(a,b){this._readStartPos(a,b);b=new Annotation;b.read2(a);this._readMoves2(a);b.empty()||this.mainLine.setAnno(b)}static canCut(a,
3567b,c){c.preSetMinCtx(a);var d=c.sd,e=a.getMoved();c.getPiece(a.to);var f=a.from;a=a.to;var g=CBSquare.R(f);c=CBSquare.R(a);var h=Piece.make(Piece.PAWN,d),k=d===Side.WHITE?CBSquare.R_2:CBSquare.R_7;if(e===h&&g===k&&b.getPiece(f)===h)return!0;f=Piece.changeSide(h);d=d===Side.WHITE?CBSquare.R_7:CBSquare.R_2;return e===f&&c===d&&b.getPiece(a)===f||b.cr&CastleRights.W_ALL&&e===Piece.W_KING||b.cr&CastleRights.B_ALL&&e===Piece.B_KING?!0:!1}hasPos(a){return this._findPos(a)}_findPos1(a,b,c,d){if(c.isMainLine()&&
3568ObjUtil.equals(a,b))return d.push(new LineStackItem(c)),!0;b=ObjUtil.clone(b);for(var e=0;e<c.length;++e){var f=c[e];if(f.hasLines())for(var g=f.getSubLinesCount()-1;0<=g;--g){var h=f.getLine(g);d.push(new LineStackItem(c,e));if(this._findPos1(a,b,h,d))return!0;d.pop()}if(Game.canCut(f,a,b))break;else if(b.makeMove(f),ObjUtil.equals(a,b))return d.push(new LineStackItem(c,e+1)),!0}return!1}_findPos(a){var b=this.getStartPos(),c=new LineStack;return this._findPos1(a,b,this.mainLine,c)?c:null}gotoPos(a,
3569b){var c=this._findPos(a);if(!c)return!1;this.gotoStack(c,b);CBDebug.call(this,this.selfTest);CBDebug.assert(this.cur.equals(a));return!0}findInTree(a){for(this.gotoEnd();0<this.getMoveNo();){if(a.hasPos(this.getCurPos()))return this.getMoveNo();this.gotoPrev()}return-1}detStartMoveFromTraining(){var a=-1,b=0;this.forAllMoves(function(c){0>a&&(c.getAnnoItem(AnnoType.TRAINING)&&(a=b),b++)});return 0<=a?a+1:0}static InitListeners(){Game.prototype.fireEvent||(Vk.initForListeners(Game),Vk.addEvent(Game,
3570"CurPosChanged",function(){return[this,this.getCurPos()]}),Vk.addEvent(Game,"Navigate",function(){return[this]}),Vk.addEvent(Game,"Move",function(){return[this,this.getLastMove()]}),Vk.addEvent(Game,"Changed"),Vk.addEvent(Game,"HeaderChanged"),Vk.addEvent(Game,"AnnoChanged"),Vk.addEvent(Game,"ResetGame"),Vk.addEvent(Game,"GameEnd",function(){return[this,this.getResult()]}),Vk.addEvent(Game,"ClickInNotation"),Vk.addEvent(Game,"NotaDoubleClick"),Vk.addEvent(Game,"Eval"))}}"use strict";
3571var V5={arrStrPieces:[],strTakes:"x",strCheck:"+",strMate:"#",strProm:"",str00:"0-0",str000:"0-0-0",strNullMove:"--",bOmitPawnTakes:!1};V5.arrStrPieces[Piece.W_KING]=V5.arrStrPieces[Piece.B_KING]="K";V5.arrStrPieces[Piece.W_QUEEN]=V5.arrStrPieces[Piece.B_QUEEN]="Q";V5.arrStrPieces[Piece.W_ROOK]=V5.arrStrPieces[Piece.B_ROOK]="R";V5.arrStrPieces[Piece.W_BISHOP]=V5.arrStrPieces[Piece.B_BISHOP]="B";V5.arrStrPieces[Piece.W_KNIGHT]=V5.arrStrPieces[Piece.B_KNIGHT]="N";
3572V5.arrStrPieces[Piece.W_PAWN]=V5.arrStrPieces[Piece.B_PAWN]="";
3573class NotationGenerator{constructor(a){this.m_loc=a||V5}getLocalization(){return this.m_loc}getLineNota(a,b,c){var d=0;c&&(d=c);a=a.getMoveNum();for(c="";d<b.length;++d){var e=b[d],f=e.getMoved();f=Piece.side(f)===Side.WHITE;c+=this.getMoveNota(e,f||!d?a:0)+" ";f||++a}return c}genLineNotaFromEnd(a,b){var c=a.getMainLine().length;c-=b;0>c&&(c=0);c=Math.floor(c/2)+1;for(var d=[],e=b=Math.max(0,a.getMoveNo()-b);e<a.getMainLine().length;++e){var f=a.getMainLine()[e],g=f.getMoved();g=Piece.side(g)===Side.WHITE;
3574d.push(this.getMoveNota(f,g||e==b?c:0));g||++c}return d}getNota(a,b){var c=Math.floor(b.getCurPos().getMoveNum()/2+1);b.getCurPos().preCalcCtx(a);return this.getMoveNota(a,c)}getNota2(a,b){var c=Math.floor(b.getMoveNo()/2+1);b.getCurPos().preCalcCtx(a);return this.getMoveNota(a,c)}getMoveNota(a,b){var c="",d=a.getMoved();b&&(c=""+b+".",Piece.side(d)===Side.BLACK&&(c+=".."));a.isNullMove()?c+=this.m_loc.strNullMove:a.isShortCastling()||a.Chess960ShortCastling?c+=this.m_loc.str00:a.isLongCastling()||
3575a.Chess960LongCastling?c+=this.m_loc.str000:(1>d||15<d||(c+=this.m_loc.arrStrPieces[d]),a.isNeedCol()&&(c+=CBSquare.colToString(CBSquare.C(a.from))),a.isNeedRow()&&(c+=CBSquare.rowToString(CBSquare.R(a.from))),a.isTake()&&(d===Piece.W_PAWN||d===Piece.B_PAWN?(c+=CBSquare.colToString(CBSquare.C(a.from)),this.m_loc.bOmitPawnTakes||(c+=this.m_loc.strTakes)):c+=this.m_loc.strTakes),c+=CBSquare.toString(a.to),a.prom&&(c+=this.m_loc.strProm,c+=this.m_loc.arrStrPieces[a.prom]));a.isMate()?c+=this.m_loc.strMate:
3576a.isCheck()&&(c+=this.m_loc.strCheck);return c}getStrMoveNumInLine(a,b,c){var d=Position.prototype.plyToMvNum(a+b),e="";if(0==(a+b&1)||0==a)e=d.toString()+".",c?0==(a+b&1)&&(e+=".."):0!=(a+b&1)&&(e+="..");return e}static Localizations={invariant:V5};}var NotationLocalizations=NotationGenerator.Localizations;"use strict";
3577class SessionAction{constructor(){this.reserved1=0}init(a,b,c){this.id=-1;this.idGame=a;this.gameAction=b;this.controlMove=c||new MoveRecord;this.tickCount=new Date}getSockMsg(a){var b=new WebSockMessage(a);b.setUserType(a);
3577this.V17(b.getBuf());return b}fromDataBuf(a){this.id=a.V19();this.tickCount=a.V19();this.idGame=a.V19();this.controlMove=new MoveRecord;this.controlMove.fromDataBuf(a);this.reserved1=a.V19();this.reserved2=a.V19();this.gameAction=new GameAction;this.gameAction.fromDataBuf(a)}V17(a){this.isPlayingMove()&&
3578this.setNeedsReceipt();a.V13(this.id);a.V13(this.tickCount);a.V13(this.idGame);this.controlMove.V17(a);a.V13(this.reserved1||0);a.V13(this.reserved2||0);this.gameAction.V17(a)}setNeedsReceipt(){this.reserved1|=1}isAnEarlierMove(a){if(this.gameAction.type==GameActionEnum.MOVEDATA){var b=this.gameAction.moveData;if(this.gameAction.moveData.moveNo<a.getPlyNum()&&(b=new Move(b.move[0],b.move[1],b.move[2]),a.getMoves()[this.gameAction.moveData.moveNo].equals(b)&&(0==this.gameAction.moveData.moveNo||a.getMoves()[this.gameAction.moveData.moveNo-
35791].equals(this.controlMove))))return!0}return!1}isPlayingMove(){return this.gameAction.type==GameActionEnum.MOVEDATA}toString(){return"gameId="+this.idGame.toString(10)+" "+this.gameAction.toString()}}"use strict";
3580const Attack={isPawnFork:function(a,b){var c=ObjUtil.clone(a);a=c.board[b.from];if((a&Piece.PIECE_MASK)==Piece.PAWN){c.makeMove(b);c.sd=Side.other(c.sd);var d=[];c.generatePawn(a,b.to,d);if(2<=d.length){var e=0;d.forEach(function(f){(f=c.board[f.to])&&(f&Piece.PIECE_MASK)!=Piece.PAWN&&e++});return 2===e}}return!1},sumMaterial:function(a,b){var c=0,d=[0,0,900,325,325,450,100];a.board.forEach(function(e){e&&Piece.side(e)===b&&(c+=d[Piece.nominal(e)])});return c}};"use strict";
3581var AllowedColor={NONE:0,WHITE_ONLY:1,BLACK_ONLY:2,BOTH_COLORS:3,detFromOpponentSide:function(a){return a==Side.BLACK?AllowedColor.WHITE_ONLY:AllowedColor.BLACK_ONLY}};
3582class MoveEntry{constructor(a){this.initForListeners();this.board=a;this.fnToMove=function(){return null};this.withPreMove=!0;this.preMoves=[]}onMove(){var a=this.getMySide();null!==a&&a===this.getCurPos().Vj()&&this.processPreMove()}
3582getLastPreMoveToSq(){if(this.preMoves.length)return this.preMoves[this.preMoves.length-1].to}onSquareClicked(a){}clearPreMoves(){var a=0<this.preMoves.length;this.preMoves=[];return a}getPreMoveHsla(a){switch(a%7){case 0:return"hsla( 120, 90%, 40%, 0.9 )";case 1:return"hsla( 120, 00%, 100%, 0.9 )";
3583case 2:return"hsla( 5, 90%, 70%, 0.9 )";case 3:return"hsla( 180, 90%, 50%, 0.9 )";case 4:return"hsla( 180, 00%, 40%, 0.9 )";case 5:return"hsla( 0, 0%, 5%, 0.9 )";case 6:return"hsla( 270, 70%, 60%, 0.9 )"}}renderPreMoves(){try{for(var a=[],b=0;b<this.preMoves.length;b++){var c=this.preMoves[b];if(c){var d=this.getPreMoveHsla(b);a.push(new BoardArrow(c.from,c.to,d))}}a.length&&this.getBoardWin().queueBoardAttributes(a,{eraseQueue:!1,renderNow:!0,requestAnimInRender:!0})}catch(e){LogException("ME::rp",
3584e)}}boardWinMoveEntered(a,b,c){try{var d=this.getBoardWin().board,e=this.getMySide(),f=this.getMySide()===this.getCurPos().Vj();null===e&&(f=!0);if(this.colorOk(d.get(a),a)&&this.squareHasColorToMove(a)&&f){var g=new Move(a,b,c&7);this.fireOnStopClock();this.fireOnMoveEntered(g);return!0}if(this.withPreMove){var h=new Move(a,b,c&7),k=!1;this.preMoves.forEach(function(l){l.from==a&&l.to==b&&(k=!0)});k||(this.preMoves.push(h),LOG("PreMove entered: "+h+", tot="+this.preMoves.length))}}catch(l){LogException("MvE::Entd",
3585l)}return!1}squareHasColorToMove(a){a=this.getCurPos().getPiece(a);return a===Piece.NONE?!1:Piece.side(a)==this.getCurPos().Vj()}clearAttributesOnMouseDown(a){try{var b=!0;if(this.withPreMove){var c=this.getCurPos().getPiece(a);c&&Piece.side(c)!=this.getCurPos().Vj()&&Piece.side(c)===this.getMySide()&&(b=!1);a==this.getLastPreMoveToSq()&&(b=!1)}b&&this.board.undoAttributes(!0)}catch(d){LogException("ME::clr",d)}}static bInProcessPreMove=!1;processPreMove(){if(MoveEntry.bInProcessPreMove)return!1;
3586MoveEntry.bInProcessPreMove=!0;var a=!1;if(this.preMoves.length){var b=this.preMoves.shift();if(b&&(this.getCurPos().isLegalFromTo(b.from,b.to)&&this.getCurPos().Vj()==this.getMySide()?(LOG("Exec Legal PreMove: "+b,"LogBold"),this.fireOnStopClock(),(new Timer(function(){this.fireOnMoveEntered(b)}.bind(this))).runOnce(0),a=!0,this.renderPreMoves()):(LOG("PreMove illegal: "+b,"LogRed"),this.clearPreMoves()),this.getBoardWin().onAfterPremove&&a))this.getBoardWin().onAfterPremove()}MoveEntry.bInProcessPreMove=
3587!1;return a}getFirstSquareOfPremoveFrom(a){for(var b=this.preMoves.length-1;0<=b;b--)this.preMoves[b].to==a&&(a=this.preMoves[b].from);return a}fillSingleClickMove(a,b){var c={ok:!1,from:-1};try{if(a.get(b)==Piece.NONE){var d=this.getCurPos().Vd();d=d.filter(function(e){return e.to==b});if(c.ok=1==d.length&&this.isSingleClickColorOk())c.from=d[0].from}}catch(e){LogException("ME:FS",e)}return c}isLegalOrPremove(a,b,c){return this.colorOk(a.get(b),b)?this.getCurPos().isLegalFromTo(b,c)||this.isPremove(a,
3588b,c):!1}isLegal(a,b,c){return this.canMoveForCurSide()&&this.getGame()?this.getCurPos().isLegalFromTo(b,c):!1}isMyPiece(a){return!!(this.getBoardWin().board.get(a)&Piece.SIDE_MASK)==this.getCurPos().isBTM()&&0<this.getBoardWin().board.get(a)}isOpponentPiece(a){return!!(this.getBoardWin().board.get(a)&Piece.SIDE_MASK)!=this.getCurPos().isBTM()&&0<this.getBoardWin().board.get(a)}tryTwoClickMove(a,b){var c=this.getBoardWin().board;if(this.colorOk(c.get(a),a)&&this.getCurPos().isLegalFromTo(a,b)){c=0;
3589if(this.getBoardWin().isWhitePromoPawn(a)||this.getBoardWin().isBlackPromoPawn(a))c=Piece.QUEEN;return this.boardWinMoveEntered(a,b,c)}return!1}colorOk(a,b){switch(this.getAllowedColor()){case AllowedColor.BOTH_COLORS:return!0;case AllowedColor.WHITE_ONLY:return this.getCurPos().isWTM()||this.colorOkInPremove(a,Side.WHITE,b);case AllowedColor.BLACK_ONLY:return this.getCurPos().isBTM()||this.colorOkInPremove(a,Side.BLACK,b);default:return!1}}colorOkInPremove(a,b,c){return this.withPreMove&&(this.preMovesLeadTo(c)||
3590a&&Piece.side(a)==b)?!0:!1}canMoveForCurSide(){switch(this.getAllowedColor()){case AllowedColor.BOTH_COLORS:return!0;case AllowedColor.WHITE_ONLY:return this.getCurPos().isWTM();case AllowedColor.BLACK_ONLY:return this.getCurPos().isBTM();default:return!1}}isSingleClickColorOk(){switch(this.getAllowedColor()){case AllowedColor.WHITE_ONLY:return this.getCurPos().isWTM();case AllowedColor.BLACK_ONLY:return this.getCurPos().isBTM();default:case AllowedColor.BOTH_COLORS:return!0}}onPosInput(a){}allowBothColors(){this.setMySide(null)}isPremove(a,
3591b,c){return 0<=b&&0<=c&&63>=b&&63>c?this.preMovesLeadTo(b)?!0:(a=a.get(b))&&this.withPreMove&&this.getCurPos().isBTM()==(Piece.side(a)==Side.WHITE):!1}isLegalFromTo(a,b){return this.getCurPos().isLegalFromTo(a,b)}preMovesLeadTo(a){if(this.withPreMove)for(var b=0;b<this.preMoves.length;b++)if(this.preMoves[b].to==a)return!0;return!1}isPremovePromoPawn(a,b){if(-1==a)return!1;for(var c=this.preMoves.length-1;0<=c;c--)if(this.preMoves[c].to==a){var d=this.getCurPos().board[this.preMoves[0].from];if((d&
3592Piece.PIECE_MASK)==Piece.PAWN&&Piece.side(d)==b)return 6==CBSquare.getRank(a)||1==CBSquare.getRank(a)}return!1}mayEnPassant(a,b){return this.isLegalFromTo(a,b)?this.getCurPos().getEPCol()==CBSquare.getFile(b):!1}test(){}getGame(){return this.board.getGame()}getCurPos(){return this.getGame()?this.getGame().getCurPos():new Position}getBoardWin(){return this.board}getMySide(){return this.fnToMove()}setMySide(a){ObjUtil.isFunction(a)?this.fnToMove=a:this.fnToMove=function(){return a}}getAllowedColor(){switch(this.getMySide()){case Side.WHITE:return AllowedColor.WHITE_ONLY;
3593case Side.BLACK:return AllowedColor.BLACK_ONLY;default:return AllowedColor.BOTH_COLORS}}mayEnterBackwards(a,b){if(0<=b&&64>b)return a=a.get(b),this.getCurPos().isBTM()==(Piece.side(a)==Side.BLACK)}initForListeners(){MoveEntry.prototype.fireEvent||(Vk.initForListeners(MoveEntry),Vk.addEvent(MoveEntry,"MoveEntered"),Vk.addEvent(MoveEntry,"StopClock"))}}"use strict";
3594class GameKernel{static _uniqueId=1;constructor(a,b){this.game=b||new Game;protect(this,"game");this.setGameListeners();this.legalMoves=[];this.viewLink=a;this.isPostAnnoEdit=!0;this.uniqueId=GameKernel._uniqueId++;this.audioInst=new ChessAudioInstance;this.audioInst.setGame(this.game);this.fnInitGame=function(c){c.reset();
3594if(PGN&&glApp&&glApp.urlParams&&glApp.urlParams.pgn){var d=PGN.parseGame(glApp.urlParams.pgn);c.assign(d)}else glApp&&glApp.urlParams&&glApp.urlParams.buf64?(StrUtil.getURLParam("buf64"),
3595d=new Game,d.fromBuf64(glApp.urlParams.buf64),c.assign(d)):glApp&&glApp.urlParams&&glApp.urlParams.hasStartPos&&glApp.urlParams.hasStartPos()?(glApp.urlParams.fen?d=new Position(glApp.urlParams.fen):glApp.urlParams.pos&&(d=new Position,d.initString(glApp.urlParams.pos)),d.isLegal()&&c.assign(new Game(d))):this.playFromPgnGame&&!this.playFromPgnGame.isNormalInit()&&c.assign(new Game(this.playFromPgnGame.getStartPos()))};this.threatGate=new V10}destroy(){this.setBoardWin(null);this.audioInst.setGame(null);
3596this.removeGameListeners();this.releaseCommandHandlers();this.Vp&&this.Vp.destroy()}setAllowedColor(a){this.boardWin&&(this.boardWin.moveEntry.allowedColor=a)}linkCommandHandlers(){this.commandHandlerId=glApp.commands.registerCommandHandler(this);this.keyDownHandlerId=glApp.commands.registerkeyDownHandler(this)}releaseCommandHandlers(){glApp.commands.unregisterCommandHandler(this.commandHandlerId);glApp.commands.unregisterkeyDownHandler(this.keyDownHandlerId)}createControl(a,b,c,d){this.animateBoard=
3597!0;var e="undefined"===typeof this.boardArea;this.boardArea=new BoardArea(a,b,c,d);var f=(d?d.fnBoardFactory:null)||this.fnBoardFactory;if(f)var g=f(a,b,c,"ByKernel",d);else BoardControl?g=new BoardControl(a,b,c,"ByKernel",d):"object"===typeof PlaychessBoardControl&&(g=new PlaychessBoardControl(a,b,c,"ByKernel",d)),g&&d&&d.mixin&&mixObject(g,d.mixin);g&&(!d||!d.addTitle||glApp.panelMgr.hasLogo&&glApp.panelMgr.hasLogo()||g.addTitle(null,d.noClock),this.setBoardWin(g),this.Vp.createGUIElements(this.boardWin),
3598this.boardArea.addBoard(this.boardWin),e&&this.initGame(),this.boardWin&&this.boardWin.addStyleListener(),this.releaseCommandHandlers(),this.linkCommandHandlers());return this.boardArea}createControl3D(a,b,c){}on3DLoaded(){this.boardWin&&this.boardWin.setGame(this.game)}enableAudio(a){this.audioInst&&this.audioInst.enable(a)}setBlackIsBottom(a){this.boardWin&&this.boardWin.setBlackIsBottom(a)}setBoardWin(a){this.boardWin&&this.boardWin.moveEntry.removeOnMoveEnteredListener(this.idOnMoveEntered);if(this.boardWin=
3599a)this.boardWin.moveEntry&&(this.boardWin.moveEntry.setMySide&&this.boardWin.moveEntry.setMySide(this.getMySide.bind(this)),this.boardWin.moveEntry.addOnMoveEnteredListener&&(this.idOnMoveEntered=this.boardWin.moveEntry.addOnMoveEnteredListener(this.reactToEnteredMove.bind(this)))),this.boardWin.setGame(this.game),this.idGame&&(this.boardWin.idGame=this.idGame)}createNotaElement(a,b,c){this.notation=NotaElement.factory(a,b,null);this.notation.setGame(this.game);return this.notation}suppressNotationFromMoves(a){this.notation&&
3600this.notation.suppressNotationFromMoves(a)}onPanelsReady(){if(this.Vp)this.Vp.onPanelsReady()}setPlayingMode(a){this.modeState=this.modeState||{};this.Vp&&this.Vp.saveState(this.modeState);this.boardWin&&this.Vp&&(this.Vp.destroyGUIElements(this.boardWin),this.Vp.destroy());this.Vp=a;this.boardWin&&(this.Vp.createGUIElements(this.boardWin),this.Vp.onPanelsReady(),this.Vp&&this.Vp.loadState(this.modeState),this.Vp.updateGamePos(!0));this.boardArea&&this.boardArea.forceResize();this.Vp.getFnLoadSearchResult&&
3601(this.loadSearchResultGame=this.Vp.getFnLoadSearchResult())}static gMapTimeControls=null;static getTimeControl(a){GameKernel.initTimeControls();return GameKernel.gMapTimeControls[a]}static initTimeControls(){GameKernel.gMapTimeControls||(GameKernel.gMapTimeControls={},GameKernel.gMapTimeControls[glApp.Vy.LEVEL_BLITZ_3_0]={clockParams:new ClockParams(3,0)},GameKernel.gMapTimeControls[glApp.Vy.LEVEL_BLITZ_4_0]={clockParams:new ClockParams(4,0)},GameKernel.gMapTimeControls[glApp.Vy.LEVEL_BLITZ_5_0]=
3602{clockParams:new ClockParams(5,0)},GameKernel.gMapTimeControls[glApp.Vy.LEVEL_BLITZ_3_2]={clockParams:new ClockParams(3,2)},GameKernel.gMapTimeControls[glApp.Vy.LEVEL_BLITZ_5_5]={clockParams:new ClockParams(5,5)},GameKernel.gMapTimeControls[glApp.Vy.LEVEL_1_SECOND]={fixedTime:1E3},GameKernel.gMapTimeControls[glApp.Vy.LEVEL_5_SECONDS]={fixedTime:5E3},GameKernel.gMapTimeControls[glApp.Vy.LEVEL_15_SECONDS]={fixedTime:15E3},GameKernel.gMapTimeControls[glApp.Vy.LEVEL_40_SECONDS]={fixedTime:4E4})}execCommand(a){try{switch(a){case glApp.Vy.NEW_GAME:this.newGame();
3603break;case glApp.Vy.SETUP_POSITION:this.togglePosInputMode(this.Vp.posLegalChecker);break;case glApp.Vy.TAKEBACK:this.Vp.mayNavigate()&&this.game.gotoPrev();break;case glApp.Vy.EXECMOVE:this.Vp.mayNavigate()&&this.game.gotoNext();break;case glApp.Vy.START_LINE:this.startLine();break;case glApp.Vy.FLIP_BOARD:this.boardWin&&this.boardWin.flipBoard();break;case glApp.Vy.PROMOTE_LINE:this.Vp.onPromoteLine()&&(this.game.promoteLine(),this.Vp.afterPromoteLine()
3603);break;case glApp.Vy.DELETE_LINE:this.Vp.onDeleteLine()&&
3604(this.game.deleteLine(),this.Vp.afterDeleteLine());break;case glApp.Vy.CUT_LINE:this.Vp.onCutLine()&&(this.game.deleteRemaining(),this.Vp.afterCutLine());break;case glApp.Vy.DELETE_PREVIOUS_MOVES:this.Vp.onDeletePrevious()&&this.game.deletePrevious();break;case glApp.Vy.ADD_POST_TEXT:this._editAnno(!0);break;case glApp.Vy.ADD_PRE_TEXT:this._editAnno(!1);break;case glApp.Vy.INSERT_DIAGRAM:this.Vp.onInsertDiagram()&&this.insertDiagram();break;case glApp.Vy.ENGINE_PLUS_LINE:this.changeEngineLines(1);
3605break;case glApp.Vy.ENGINE_MINUS_LINE:this.changeEngineLines(-1);break;case glApp.Vy.ENGINE_THREAT:this.toggleEngineThreat();break;case glApp.Vy.OPEN_CMS:this.openCMS();break;case glApp.Vy.PLAYERDB_TEST:this.Vp.test();break;case glApp.Vy.GAME_COPYTOCLIPBOARD:this.copyGameToClipboard();break;case glApp.Vy.GAME_PASTEFROMCLIPBOARD:this.pasteGameFromClipboard();break;case glApp.Vy.MARK_GOOD:this.Vp.onAnnotate()&&this.addSymbol(AnnoMarkType.GOOD);break;case glApp.Vy.MARK_BAD:this.Vp.onAnnotate()&&this.addSymbol(AnnoMarkType.BAD);
3606break;case glApp.Vy.MARK_VERYGOOD:this.Vp.onAnnotate()&&this.addSymbol(AnnoMarkType.VERY_GOOD);break;case glApp.Vy.MARK_VERYBAD:this.Vp.onAnnotate()&&this.addSymbol(AnnoMarkType.VERY_BAD);break;case glApp.Vy.MARK_INTERESTING:this.Vp.onAnnotate()&&this.addSymbol(AnnoMarkType.INTERESTING);break;case glApp.Vy.MARK_DUBIOUS:this.Vp.onAnnotate()&&this.addSymbol(AnnoMarkType.DUBIOUS);break;case glApp.Vy.WHITE_WINS:this.Vp.onEval(AnnoEvalType.WHITE_WINS)&&this.addSymbol(AnnoEvalType.WHITE_WINS);break;case glApp.Vy.WHITE_BETTER:this.Vp.onEval(AnnoEvalType.WHITE_BETTER)&&
3607this.addSymbol(AnnoEvalType.WHITE_BETTER);break;case glApp.Vy.WHITE_SLIGHTLY:this.Vp.onEval(AnnoEvalType.WHITE_SLIGHTLY_BETTER)&&this.addSymbol(AnnoEvalType.WHITE_SLIGHTLY_BETTER);break;case glApp.Vy.EQUAL:this.Vp.onEval(AnnoEvalType.EQUAL)&&this.addSymbol(AnnoEvalType.EQUAL);break;case glApp.Vy.UNCLEAR:this.Vp.onEval(AnnoEvalType.UNCLEAR)&&this.addSymbol(AnnoEvalType.UNCLEAR);break;case glApp.Vy.BLACK_WINS:this.Vp.onEval(AnnoEvalType.BLACK_WINS)&&this.addSymbol(AnnoEvalType.BLACK_WINS);break;case glApp.Vy.BLACK_BETTER:this.Vp.onEval(AnnoEvalType.BLACK_BETTER)&&
3608this.addSymbol(AnnoEvalType.BLACK_BETTER);break;case glApp.Vy.BLACK_SLIGHTLY:this.Vp.onEval(AnnoEvalType.BLACK_SLIGHTLY_BETTER)&&this.addSymbol(AnnoEvalType.BLACK_SLIGHTLY_BETTER);break;case glApp.Vy.COMPENSATION:this.Vp.onEval(AnnoEvalType.COMPENSATION)&&this.addSymbol(AnnoEvalType.COMPENSATION)}}catch(b){a=glApp.Vy.toNumString(a),LogException(a,b)}}onKeyDown(a){var b=this.Vp.onKeyDown(a);if(!b&&a&&a.getKey)switch(this.breakLoop=b=!0,a.getKey()){default:b=!1;break;case a.A:a.ctrlKey?this._editAnno(!0):
3609b=!1;break;case a.F:a.ctrlKey?this.execCommand(CommandIds.FLIP_BOARD):b=!1;break;case a.N:a.ctrlKey?this.execCommand(CommandIds.NEW_GAME):b=!1;break;case a.LEFT:this.Vp.mayNavigate()&&this.game.gotoPrev();break;case a.RIGHT:this.handleCursorRight();break;case a.HOME:this.Vp.mayNavigate()&&this.game.gotoStart();break;case a.END:this.handleEnd();break;case a.PAGE_DOWN:this.handlePageDown();break;case a.PAGE_UP:this.Vp.mayNavigate()&&this.game.jump(-20);break;case a.SPACE:this.Vp.mayNavigate()&&(b=this.execCommand(CommandIds.ENGINE_MOVE_NOW));
3610break;case a.F2:a.altKey?this.execCommand(CommandIds.TOGGLE_ANALYSIS_ENGINE):b=!1}return b}onFileSelect(a,b){return!1}handleCursorRight(){this.Vp.mayGotoNext()&&this.game.gotoNext()}handleEnd(){this.Vp.mayGotoEnd()&&this.game.gotoEnd()}handlePageDown(){this.Vp.mayPageDown()&&this.game.jump(20)}togglePosInputMode(a){this.posInput?this.endPosInputMode():this.startPosInputMode(a)}doTest(){var a=new Position("8/7k/P7/8/K7/8/8/8 w - - 0 1");a=new Game(a);this.game.assign(a)}startPosInputMode(a){this.boardWin&&
3611(this.boardWin.destroyTitle(),this.posInput=new PosInputControl(this.boardWin.cbcanvas,this.boardWin.width,this.boardWin.height,"posInput",function(b){(new Timer(function(){this.endPosInputMode(b)}.bind(this))).launch()}.bind(this),a,{}),this.boardArea&&(this.boardArea.setPosInput(this.posInput),this.posInput.createButtons(),this.posInput.setPosition(this.getCurPos()),this.boardArea.calcGeometry()))}endPosInputMode(a){if(this.posInput){var b=new Game(this.posInput.createPosition());this.boardArea.removePosInput(this.boardWin);
3612this.posInput.destroy();delete this.posInput;this.Vp.createGUIElements(this.boardWin);a||this.game.assign(b);this.Vp.onPosInput(b.getCurPos());this.boardWin.moveEntry.onPosInput(b.getCurPos());this.setBlackIsBottom(b.getCurPos().getBTM())}}setPGN(a){a&&(this.game.assign(PGN.parseGame(a)),this.game.gotoFirst())}initGame(){this.fnInitGame(this.game,this);this.Vp.newGame(!1)}newGame(){this.boardWin&&(this.boardWin.prepareFullRedraw(),this.boardWin.destroyMessage(),this.boardWin.clearBoardAttributes(),
3613this.boardWin.moveEntry.clearPreMoves());this.Vp.resetGame(this.game);this.Vp.newGame(!0)}setGameListeners(){this.game&&(this.idNavListener=this.game.addOnNavigateListener(this._onGameNavigate.bind(this)),this.idMoveListener=this.game.addOnMoveListener(this._onGameMove.bind(this)),this.idChangeListener=this.game.addOnChangedListener(this._onGameChanged.bind(this)),this.idHeaderListener=this.game.addOnHeaderChangedListener(this._onHeaderChanged.bind(this)),this.idCurPosListener=this.game.addOnCurPosChangedListener(this._onGameCurPosChanged.bind(this)),
3614this.idResetGameListener=this.game.addOnResetGameListener(this._onResetGame.bind(this)),this.idClickInNotationListener=this.game.addOnClickInNotationListener(this._onClickInNotation.bind(this)),this.idAnnoChangedListener=this.game.addOnAnnoChangedListener(this._onAnnoChanged.bind(this)))}removeGameListeners(){this.game.removeOnNavigateListener(this.idNavListener);
3614this.game.removeOnMoveListener(this.idMoveListener);this.game.removeOnChangedListener(this.idChangeListener);this.game.removeOnHeaderChangedListener(this.idHeaderListener);
3615this.game.removeOnCurPosChangedListener(this.idCurPosListener);this.game.removeOnResetGameListener(this.idResetGameListener);this.game.removeOnClickInNotationListener(this.idClickOnNotationListener);this.game.removeOnAnnoChangedListener(this.idAnnoChangedListener)}getGameClickHandler(){return this.onDBGameClicked.bind(this)}onDBGameClicked(a,b){a.loadGameAsync(this.gameLoadedCallback.bind(this),b)}gameLoadedCallback(a){void 0!==a&&(this.loadSearchResultGame?this.loadSearchResultGame(a):(this.game.assign(a),
3616this.game.gotoFirst()))}stepRandomGame(a){1E4>a&&this.makeRandomMove()&&!this.breakLoop&&setTimeout(function(){this.stepRandomGame(a+1)}.bind(this),5)}stepRetractAll(a){0<this.game.getMoveIndex()&&!this.breakLoop&&(this.game.gotoPrev(),setTimeout(function(){this.stepRetractAll()}.bind(this),5))}makeRandomMove(){0==this.legalMoves.length&&(this.legalMoves=this.getCurPos().Vd());this.game.makeMove(this.legalMoves[Math.floor(Math.random()*this.legalMoves.length)]);return!0}
3616getMySide(){if(this.Vp)return this.Vp.getMySide()}setMySide(a){this.Vp&&
3617this.Vp.setMySide(a)}onReload(a){}reactToEnteredMove(a){try{if(this.game.getCurPos().isLegalMove(a)){try{var b=this.Vp.reactToEnteredMove(a)}catch(e){LogException("GK:ReactTo:pm.react",e)}if(!b)if(this.Vp.onEnteredMove(a)){if(!this.game.gotoMove(a)){var c=this.Vp.getMoveEnterType();this.nextMoveEnterType&&(c=this.nextMoveEnterType,this.nextMoveEnterType=null);var d=function(e,f){f!=MoveEnterType.CANCEL&&(this.game.makeMove(e,f),this.Vp.onAfterMoveEntry(a),this.checkIfTechnicalGameEnd())}.bind(this);
3618c!=MoveEnterType.QUERY&&d(a,c)}}else this.game.fireOnCurPosChanged()}}catch(e){LogException("GK:ReactTo",e)}}markLastMove(a,b){this.boardWin&&this.boardWin.markLastMove(a||!this.animateBoard,b)}markSquare(a,b){this.boardWin&&this.boardWin.markSquare(a,b)}drawArrow(a,b,c){this.boardWin&&this.boardWin.drawArrow(a,b,c)}execAndAnimCurrMove(a){if(this.boardWin){var b=this.boardWin.animSteps.forMove;System.isMobile()?this.boardWin.animSteps.forMove=a||4:this.boardWin.animSteps.forMove=a||10}this.game.gotoNext();
3619this.boardWin&&(this.boardWin.animSteps.forMove=b)}retractAndAnimCurrMove(a){if(this.boardWin){var b=this.boardWin.animSteps.forMove;System.isMobile()?this.boardWin.animSteps.forMove=a||2.5:this.boardWin.animSteps.forMove=a||6}this.game.gotoPrev();this.boardWin&&(this.boardWin.animSteps.forMove=b)}makeAndAnimMove(a,b){this.moveWithAnimation(function(){this.game.makeMove(a,MoveEnterType.OVERWRITE_MAIN)}.bind(this),b)}moveWithAnimation(a,b){var c=this.boardWin.animSteps.forMove;System.isMobile()?this.boardWin.animSteps.forMove=
3620b||4:this.boardWin.animSteps.forMove=b||10;a();this.boardWin.animSteps.forMove=c;this.boardWin.callOnAnimFinished=function(){this.boardWin.callOnAnimFinished=null}.bind(this)}setResult(a,b){this.game.setResult(a);this.Vp.onResult(a,b)}checkIfTechnicalGameEnd(){if(!this.isFinished()){var a={drawType:0},b=this.checkTechnicalResult(a);if(b!=GameResultEnum.UNDEFINED){this.Vp.suppressTechnicalResult||this.setResult(b,ResultFlags.TECHNICAL);if(this.onTechnicalGameEnd)this.onTechnicalGameEnd(b,a);return!0}}return!1}isFinished(){return this.game.hdr.getCBResult().isFinished()}isBTM(){return this.game.getCurPos().isBTM()}checkTechnicalResult(a){return GameKernel.staticCheckTechnicalResult(this.game,
3621a)}static staticCheckTechnicalResult(a,b){var c=(new DrawChecker).checkGame(a),d=GameResultEnum.UNDEFINED;switch(c){case DrawType.STALEMATE:case DrawType.MATERIAL:d=GameResultEnum.DRAW;break;case DrawType.MATE:d=a.getCurPos().isBTM()?GameResultEnum.WHITE_WINS:GameResultEnum.BLACK_WINS;break;case DrawType.THREE_TIMES:case DrawType.FIFTY_MOVES:case DrawType.MOVES_290:d=GameResultEnum.DRAW}b&&(b.drawType=c);return d}_onGameNavigate(){this.Vp.onGameNavigate()}_onGameMove(a){this.Vp.onGameMove(a)}_onGameCurPosChanged(){this.Vp.updateGamePos();
3622this._updateAnnoField()}_onGameChanged(a){this.Vp.updateGamePos(a);this._updateAnnoField()}_onHeaderChanged(a){this.Vp.updateHeader()}_onResetGame(){this.Vp.onResetGame();this.boardWin&&(this.boardWin.nextCurPosNoAnim=!0)}_onClickInNotation(){this.Vp.onClickInNotation()}_editAnno(a){this.viewLink&&(this.isPostAnnoEdit==a?this.viewLink.toggleAnnoField():this.viewLink.openAnnoField(),this.isPostAnnoEdit=a,this.viewLink.isAnnoFieldOpen()&&(this.game.getAnno(this.isPostAnnoEdit?AnnoType.POSTTEXT:AnnoType.PRETEXT),
3623this._updateAnnoField()))}changeEngineLines(a){this.Vp.changeEngineLines(a)}toggleEngineThreat(){this.threatGate.exec(function(){this.Vp.toggleThreat()}.bind(this),300)}_onAnnoChanged(a,b){if(this.Vp.onAnno)this.Vp.onAnno(a,b)}onAnnoEnter(a,b){null!=a&&(this.Vp.onTextAnno(a,this.isPostAnnoEdit)&&(a.length?this.game.setAnno(this.isPostAnnoEdit?AnnoType.POSTTEXT:AnnoType.PRETEXT,new TextAnno(a)):this.game.deleteAnno(this.isPostAnnoEdit?AnnoType.POSTTEXT:AnnoType.PRETEXT)),this.viewLink&&setTimeout(this.viewLink.closeAnnoField.bind(this.viewLink)))}_updateAnnoField(){if(this.viewLink&&
3624this.viewLink.isAnnoFieldOpen&&this.viewLink.isAnnoFieldOpen()){var a=this.game.getAnno(this.isPostAnnoEdit?AnnoType.POSTTEXT:AnnoType.PRETEXT);a?this.viewLink.setAnnoFieldText(a.getString()):this.viewLink.setAnnoFieldText("")}}addTextAnno(a){a&&a.length&&(this.game.getOrCreateCurrAnno().addPostText(a),this.game.fireOnChanged())}setPreTextAnno(a){a&&a.length&&(this.game.getOrCreateCurrAnno().setPreText(a),this.game.fireOnChanged())}insertDiagram(){var a=this.game.getOrCreateCurrAnno();a.toggleDiagram();
3625this.Vp.onTextAnno(a.getPostText()||"",!0)&&this.game.fireOnChanged()}deleteAnno(a,b){this.game.deleteAnno(a,!b)}addSymbol(a){this.game.getOrCreateCurrAnno().addSymbol(a);this.game.fireOnAnnoChanged()}removeSymbol(a){this.game.getOrCreateCurrAnno().addSymbol(a);this.game.fireOnAnnoChanged()}hasTimeAnnos(){for(var a=0;a<this.game.getMoves().length-1;a++){var b=this.game.getMoves()[a].getAnno();if(void 0===b||null===b||void 0===b.getItem(AnnoType.TIME))return!1}return 2<this.game.getMoves().length}addTimeAnno(a){a&&
3626this.game.getOrCreateCurrAnno().setItem(AnnoType.TIME,a)}addDiagram(){this.addTextAnno(Annotation.DIAG_CHAR)}hasTraining(){for(var a=0;a<this.game.getMoves().length-1;a++){var b=this.game.getMoves()[a].getAnno();if(b&&b.getItem(AnnoType.TRAINING))return!0}return!1}gotoFirstTrainingPosition(){for(var a=0;a<this.game.getMoves().length-1;a++){var b=this.game.getMoves()[a].getAnno();if(b){b.getItem(AnnoType.TRAINING)&&this.game.gotoIndex(a+1);break}if(this.game.getMoves()[a].hasLines())break}}getMoveNo(){return this.game.getMoveNo()}execEngineMove(a){this.game.makeMove(a);
3627this.markLastMove(!1);this.checkIfTechnicalGameEnd()}setIdGame(a){this.idGame=a;this.boardWin&&(this.boardWin.idGame=a)}getCurPos(){return this.game.getCurPos()}executeGameAction(a,b){var c=new DataBuffer,d=!0;"TEXT"==a&&(d=!1);c.constructFromString(b,d);c.rewind();a=new GameAction;a.fromDataBuf(c);a.isSetBoardOrientation()&&this.boardWin&&this.boardWin.setBlackIsBottom(1==a.nVal,!0);a.fillExecutedMove();c=this.game.getHeader().getWhite();a._doExecute(this.game);a=this.game.getHeader().getWhite();
3628this.game.updateFromExtern();0!=c.localeCompare(a)&&this.game.updateHeaderFromExtern()}executeGameAction2(a){a.isSetBoardOrientation()&&this.boardWin&&this.boardWin.setBlackIsBottom(1==a.nVal,!0);a.fillExecutedMove();var b=this.game.getHeader().getWhite();a._doExecute(this.game);a=this.game.getHeader().getWhite();this.game.updateFromExtern();0!=b.localeCompare(a)&&this.game.updateHeaderFromExtern()}copyGameToClipboard(){this.toClipboard(this.game.toString())}
3628toClipboard(a){if(window.clipboardData&&
3629clipboardData.setData){if(this.boardWin){this.boardWin.addMessage("You may now paste this game as text everywhere.",!0);var b=this.boardWin;(new Timer).runOnce(3E3,function(){b.destroyMessage()})}clipboardData.setData("Text",a)}}pasteGameFromClipboard(){if(window.clipboardData&&clipboardData.getData){var a=clipboardData.getData("Text");this.setPGN(a)}0<glApp.Vn.userName.length&&(new ActivityManager(glApp.Vn.userName,glApp.Vn.password)).getActivity(ACTIVITYTYPE.ACTIVITY_CLIPBOARD_GAME,this.pastGameHandler.bind(this))}pastGameHandler(a,
3630b){0!=a&&(this.setPGN(b),this.game.updateFromExtern())}startLine(){this.game.gotoPrev();this.nextMoveEnterType=MoveEnterType.NEWLINE}}"use strict";
3631let GameActionEnum={NOACTION:0,NEWGAME:1,SETGAME:2,GOTOMOVEINDEX:3,SETMOVE:4,MOVEDATA:5,SETANNOTATION:6,DELETELINE:7,PROMOTELINE:8,DELETEPREVIOUS:9,DELETEREMAINING:10,UNANNOTATE:11,ADDANNOTEXT:12,WEBORIGIN:13,SYNC:14,SETGAME2:15,SETGAMEMOVES:16,SETGAMEHEADER:17,SETBOARDORIENTATION:18,toString:function(a){for(var b in this)if(this[b]==a)return"GameAction: "+b;return"Unknown GameAction: "+a}};
3632class GameAction{constructor(){this.type=GameActionEnum.NOACTION;this.nVal=0;this.moveRecord=new MoveRecord}fromDataBuf(a){this.type=a.V19();this.nVal=a.V19();switch(this.type){case GameActionEnum.SETMOVE:this.moveRecord=new MoveRecord;this.moveRecord.fromDataBuf(a);break;case GameActionEnum.MOVEDATA:this.moveData=new MoveData;this.moveData.fromDataBuf(a);break;case GameActionEnum.SETGAME:this.setGame=new Game;this.setGame.fromDataBuf(a);break;case GameActionEnum.SETANNOTATION:case GameActionEnum.ADDANNOTEXT:this.anno=
3633new Annotation;this.anno.fromDataBuf(a);break;case GameActionEnum.SETGAME2:this.setGame=new Game;this.setGame.read3(a);break;case GameActionEnum.SETGAMEMOVES:this.moves=null;this.moves.fromDataBuf2(a,a.ReadInt());break;case GameActionEnum.SETGAMEHEADER:this.header=null,this.header.ReadFromDataBuffer(a,0)}}V17(a){a.V13(this.type);a.V13(this.nVal);switch(this.type){case GameActionEnum.SETMOVE:this.moveRecord.V17(a);break;case GameActionEnum.MOVEDATA:this.moveData.V17(a);break;case GameActionEnum.SETGAME:this.setGame.V17(a);
3634break;case GameActionEnum.SETANNOTATION:case GameActionEnum.ADDANNOTEXT:this.anno.V17(a)}}setMoveData(a){this.type=GameActionEnum.MOVEDATA;this.moveData=a}setSetMove(a){this.type=GameActionEnum.SETMOVE;this.moveRecord=a}setAnno(a){this.type=GameActionEnum.SETANNOTATION;this.anno=a}setMoveIndex(a){this.type=GameActionEnum.GOTOMOVEINDEX;this.nVal=a}setGame(a,b){this.type=GameActionEnum.SETGAME;this.setGame=a;this.nVal=0;this.nMoveIndex=b}setDeleteLine(){this.type=GameActionEnum.DELETELINE}setUnAnnotate(){this.type=
3635GameActionEnum.UNANNOTATE}setPromoteLine(){this.type=GameActionEnum.PROMOTELINE}setCutLine(){this.type=GameActionEnum.DELETEREMAINING}addText(a){this.anno=new Annotation;this.anno.addPostText(a);this.type=GameActionEnum.ADDANNOTEXT}isMove(){return this.type==GameActionEnum.MOVEDATA||this.type==GameActionEnum.SETMOVE}isMoveData(){return this.type==GameActionEnum.MOVEDATA}isGame(){return this.type==GameActionEnum.SETGAME}isGame2(){return this.type==GameActionEnum.SETGAME2}isSetBoardOrientation(){return this.type==
3636GameActionEnum.SETBOARDORIENTATION}isAnno(){return this.type==GameActionEnum.ADDANNOTEXT||this.type==GameActionEnum.SETANNOTATION}isMoveIndex(){return this.type==GameActionEnum.GOTOMOVEINDEX}isDeleteRemaining(){return this.type==GameActionEnum.DELETEREMAINING}getTimeCentiSecs(){if(this.moveData)return this.moveData.centiSecs}fillExecutedMove(){if(this.type==GameActionEnum.SETMOVE)return new Move(this.moveRecord.from,this.moveRecord.to,this.moveRecord.prom);if(this.type==GameActionEnum.MOVEDATA)return new Move(this.moveData.move[0],
3637this.moveData.move[1],this.moveData.move[2],this.moveData.type)}execute(a,b){var c=!0;b&&this.shouldCheckControlMoveBefore()&&((c=this.isControlMoveOk(a,b))||console.log("controlMove Not ok (1) : "+b.toString()));c&&(c=this._doExecute(a),!c&&b&&console.log("controlMove Not ok (exe) : "+b.toString()));c&&b&&this.shouldCheckControlMoveAfter()&&((c=this.isControlMoveOk(a,b))||console.log("controlMove Not ok (2) : "+b.toString()));return c}
3637toString(){var a=GameActionEnum.toString(this.type);switch(this.type){default:return a;
3638case GameActionEnum.MOVEDATA:return"MvData="+this.moveData.toString();case GameActionEnum.SETANNOTATION:return"SetAnno="+this.anno;case GameActionEnum.ADDANNOTEXT:return"AddAnno="+this.anno;case GameActionEnum.SETMOVE:return"SetMove="+this.moveRecord.toString();case GameActionEnum.NOACTION:return"No Action";case GameActionEnum.NEWGAME:return"New game";case GameActionEnum.SETGAME:return"Set game";case GameActionEnum.SETGAME2:return"Set game2";case GameActionEnum.GOTOMOVEINDEX:return"GotoMoveIndex:"+
3639this.nVal;case GameActionEnum.DELETELINE:return"DeleteLine:"+this.nVal;case GameActionEnum.PROMOTELINE:return"PromoteLine:"+this.nVal}}_doExecute(a){var b=!0;switch(this.type){case GameActionEnum.NEWGAME:a.reset();break;case GameActionEnum.GOTOMOVEINDEX:a.gotoIndex(this.nVal);(b=this.nVal===a.getMoveIndex())||LOG("GotoMoveIndex not ok");break;case GameActionEnum.SETMOVE:var c=new Move(this.moveRecord.from,this.moveRecord.to,this.moveRecord.prom);this.isValidMove(c,a.getCurPos())?(b=this.nVal,b===
3640MoveEnterType.QUERY&&a.getPlyNum()<a.getMoves().length&&(b=MoveEnterType.OVERWRITE_MAIN),b=a.makeMove(c,b)):b=!1;break;case GameActionEnum.MOVEDATA:b=this.executeMoveData(this.moveData,a);break;case GameActionEnum.SETGAME2:case GameActionEnum.SETGAME:a.assign(this.setGame);b=!0;break;case GameActionEnum.SETANNOTATION:this.nVal||0==a.getMoveOffs()?a.getMoves().setAnno(this.anno):(c=a.getPreviousMove())&&c.setAnno(this.anno);a.fireOnChanged();break;case GameActionEnum.DELETELINE:a.deleteLine();break;
3641case GameActionEnum.PROMOTELINE:a.promoteLine();break;case GameActionEnum.DELETEPREVIOUS:a.deletePrevious();break;case GameActionEnum.DELETEREMAINING:a.deleteRemaining();break;case GameActionEnum.UNANNOTATE:a.unAnnotate();break;case GameActionEnum.ADDANNOTEXT:(c=this.nVal||0==a.getMoveOffs()?a.getMoves().getAnno():a.getPreviousMove().getAnno())||(c=new Annotation);this.anno.hasPreText()?c.addPreText(this.anno.getPreText()):this.anno.hasPostText()&&c.addPostText(this.anno.getPostText());this.nVal||
36420==a.getMoveOffs()?a.getMoves().setAnno(c):a.getPreviousMove().setAnno(c);a.fireOnChanged();break;case GameActionEnum.SYNC:a.onSync(this.nVal);break;case GameActionEnum.SETGAMEMOVES:a.setMoves(this.moves);break;case GameActionEnum.SETGAMEHEADER:a.setHeader(this.header),a.fireOnChanged()}return b}shouldCheckControlMoveBefore(){return this.type==GameActionEnum.SETMOVE||this.type==GameActionEnum.MOVEDATA||this.type==GameActionEnum.SETANNOTATION||this.type==GameActionEnum.ADDANNOTEXT||this.type==GameActionEnum.PROMOTELINE||
3643this.type==GameActionEnum.DELETEREMAINING}shouldCheckControlMoveAfter(){return this.type==GameActionEnum.GOTOMOVEINDEX||this.type==GameActionEnum.DELETEPREVIOUS||this.type==GameActionEnum.DELETELINE}isControlMoveOk(a,b){var c=0==a.getMoveOffs()||a.getPreviousMove()&&a.getPreviousMove().equals(b);c||console.log("Cntrl move NOT OK: "+this.toString()+", ctrl="+b+", prev="+a.getPreviousMove());return c}changesMoves(){return this.type==GameActionEnum.SETMOVE||this.type==GameActionEnum.MOVEDATA||this.type==
3644GameActionEnum.NEWGAME||this.type==GameActionEnum.DELETELINE||this.type==GameActionEnum.PROMOTELINE||this.type==GameActionEnum.DELETEPREVIOUS||this.type==GameActionEnum.DELETEREMAINING}changesGame(){return this.type==GameActionEnum.SETMOVE||this.type==GameActionEnum.MOVEDATA||this.type==GameActionEnum.SETGAME||this.type==GameActionEnum.SETGAME2||this.type==GameActionEnum.NEWGAME||this.type==GameActionEnum.SETANNOTATION||this.type==GameActionEnum.ADDANNOTEXT||this.type==GameActionEnum.DELETELINE||
3645this.type==GameActionEnum.PROMOTELINE||this.type==GameActionEnum.DELETEPREVIOUS||this.type==GameActionEnum.DELETEREMAINING||this.type==GameActionEnum.UNANNOTATE||this.type==GameActionEnum.SETGAMEMOVES||this.type==GameActionEnum.SETGAMEHEADER}executeMoveData(a,b){var c=!1;try{var d=new Move(a.move[0],a.move[1],a.move[2]);this.isValidMove(d,b.getCurPos())?(b.enableEvents(!1),b.makeMove(d,MoveEnterType.OVERWRITE_MAIN),b.getOrCreateCurrAnno().setItem(AnnoType.TIME,new TimeAnno(TimeTools.getCBTimeOfCentiSecs(a.centiSecs))),
3646b.enableEvents(!0),b.fireOnMove(),b.fireOnCurPosChanged(),c=!0):LOG("Not a valid move: "+a.toString())}catch(e){LogException("GA::ExecMoveData",e)}return c}isValidMove(a,b){return b.isLegalMove(a)}}"use strict";
3647class ScriptCommand{constructor(){this.time=0;this.action=this.type="";this.aGA=new GameAction}fromString(a,b){let c="",d=0,e=0,f=0,g=0;for(let h=0;h<a.length;h++)":"==a[h]?(0==d?e=parseInt(c,10):1==d?f=parseInt(c,10):2==d&&(g=parseInt(c,10)),c="",d++):c+=a[h];this.time=g+60*f+3600*e;a=b.search(":");
3647-1!=a&&(this.type=b.substring(0,a),this.action=b.substring(a+1))}}"use strict";
3648var DrawType={NOT_DECIDED:0,MATE:1,STALEMATE:2,MATERIAL:3,THREE_TIMES:4,FIFTY_MOVES:5,MOVES_290:6,DRAW:7,WHITE_WINS:8,BLACK_WINS:9,TWO_TIMES:10};
3649class DrawChecker{checkGame(a){var b=this.checkPos(a.getCurPos());if(b!=DrawType.NOT_DECIDED)return b;if(5<=a.getPlyNum()){b=a.getCurPos().getCastleRights();var c=a.getMoves().length;if(590<c)return DrawType.MOVES_290;for(var d=Math.max(0,c-5),e=c-1;e>=d;e--){var f=a.getMoves()[e];if(f){if(!f.undo&&f.isValid()&&e<a.getPlyNum()-1){for(d=f=0;d<e;d++)a.getMoves()[d].undo&&f++;break}if(f.isTake()||f.isProm()||f.isPawn())return DrawType.NOT_DECIDED}else return DrawType.NOT_DECIDED}d=a.getCurPos().getEPCol();
3650var g=c-100,h=1,k=ObjUtil.clone(a.getCurPos());for(e=c;0<e;--e){f=a.getMoves()[--e];if(!f||!f.undo)break;if(f.isTake()||f.isProm()||f.isPawn())break;if(a.getCurPos().getEPCol()!=d)break;if(e<=g)return DrawType.FIFTY_MOVES;k.unmakeMove(f,f.undo);if(h&&b!=k.getCastleRights()&&(h=0,0>=g))break;if(0<e){f=a.getMoves()[e-1];if(f.isTake()||f.isProm()||f.isPawn())break;if(a.getCurPos().getEPCol()!=d)break;if(e<=g)return DrawType.FIFTY_MOVES;if(!f.undo)break;k.unmakeMove(f,f.undo);if(h){if(b!=k.getCastleRights()&&
3651(h=0,0>=g))break;if(d==k.getEPCol()&&k.boardEquals(a.getCurPos().board)&&(h++,3<=h))return DrawType.THREE_TIMES}}}}return DrawType.NOT_DECIDED}checkPos(a){if(!a.hasLegals())return a.isCheck()?DrawType.MATE:DrawType.STALEMATE;for(var b=[0,0,0,0,0,0,0,0],c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],d=0,e=0,f=0;64>f;f++)b[a.board[f]&7]++,c[a.board[f]&15]++,(a.board[f]&7)==Piece.BISHOP&&(a.board[f]&8?e=(f&1)==(f>>3&1)?e|1:e|2:d=(f&1)==(f>>3&1)?d|1:d|2);return b[Piece.QUEEN]||b[Piece.ROOK]||b[Piece.PAWN]||!(!b[Piece.BISHOP]&&
36521>=b[Piece.KNIGHT]||!b[Piece.KNIGHT]&&(1>=b[Piece.BISHOP]||3>d&&3>e&&(!d||!e||d==e)))?DrawType.NOT_DECIDED:DrawType.MATERIAL}canWin(a,b){var c=!1;try{var d=a.board,e=b==Side.WHITE?0:Side.SIDE_MASK;a=[];for(var f=0;16>f;f++)a[f]=0;for(f=0;64>f;f++)a[d[f]&15]++,d[f]&&(d[f]&Side.SIDE_MASK)==e&&(d[f]&Piece.PIECE_MASK)!=Piece.KING&&(c=!0);if(c&!a[Piece.W_PAWN]&&!a[Piece.B_PAWN]){var g=b==Side.WHITE?Piece.WHITE:Piece.BLACK;if(!(a[g|Piece.QUEEN]||a[g|Piece.ROOK]||1!=a[g|Piece.BISHOP]+a[g|Piece.KNIGHT]||
3653a[Piece.COLOUR-g|Piece.BISHOP]||a[Piece.COLOUR-g|Piece.KNIGHT]))if(a[g|Piece.BISHOP]){if(a[Piece.COLOUR-g|Piece.QUEEN]||a[Piece.COLOUR-g|Piece.ROOK])c=!1}else a[g|Piece.KNIGHT]&&a[Piece.COLOUR-g|Piece.QUEEN]&&!a[Piece.COLOUR-g|Piece.ROOK]&&(c=!1)}}catch(h){c=!0,LogException("CanWin",h)}return c}static getStrDrawType(a){switch(a){default:case DrawType.MATE:return"Mate";case DrawType.STALEMATE:return"Stalemate";case DrawType.MATERIAL:return"No Material";case DrawType.THREE_TIMES:return"Threefold Rep";
3654case DrawType.FIFTY_MOVES:return"50 Moves Rule";case DrawType.MOVES_290:return"290 Moves";case DrawType.DRAW:return"Draw";case DrawType.WHITE_WINS:return"WWin";case DrawType.BLACK_WINS:return"BWin";case DrawType.TWO_TIMES:return"Twofold Rep"}}}"use strict";
3655class BaseClock{static nextId=0;constructor(a){this.clockLink=a;this.updateTimer=new Timer(this.update.bind(this));this.isBlack=!1;this.id=++BaseClock.nextId}onTimeOverstepped(a){this.clockLink.showTimeOverstepped(a)}setNoClock(){this.clockLink.setText("---",!1);this.clockLink.setText("---",!0)}start(){}stop(){}isRunning(){return!1}setToMove(a){this.isBlack=a}onMove(a){this.setToMove(a);this.start()}initFromGame(a){}update(){}}"use strict";
3656class CMSIManager{constructor(a,b){this.kernel=a;this.cmsFiles=[]}addFile(a){this.cmsFiles.push(a)}GetIntelligentFileName(a,b,c,d,e){a=(new Position(a)).toFen();return this.extractFileNameFromFen(a)+"x"+String(b)+"y"+String(c)+"v"+d+"u"+e}extractFileNameFromFen(a){for(var b=0;b<a.length;b++)"/"==a[b]&&(a="z");return a}extractFenFromFileName(a){a=a.replace(/z/g,"/");var b=a.search("x");return-1!=b&&8<a.substr(0,b).length?a.substr(0,b):""}extractMoveFromFileName(a){var b=a.search("x"),c=a.search("y"),
3657d=a.search("v"),e=a.search("K"),f=a.search("k"),g=0,h=0;-1!=b&&-1!=c&&-1!=d&&d>c&&c>b&&-1!=e&&-1!=f&&(g=a.substr(b+1,c-b-1),a=a.substr(c+1,d-c-1),g=parseInt(g),h=parseInt(a));
3657return new Move(g,h,0,0)}extractStateFromFileName(a){var b=RecorderState.RecordStopped,c=a.search("v"),d=a.search("u"),e=a.search("K"),f=a.search("k");-1!=c&&-1!=d&&-1!=e&&-1!=f&&d>c&&4>d-c&&(a=a.substr(c+1,d-c-1),b=parseInt(a));return b}extractPointsFromFileName(a){var b=0,c=a.search("u");-1!=c&&(a=a.substr(c+1),b=parseInt(a));
3658return b}getPositionFromFileName(a){a=this.extractFenFromFileName(a);return a.length?new Position(a):null}belongsToPosition(a,b){if(b=this.getPositionFromFileName(b)){b=b.toFEN();a=a.toFEN();for(var c=0,d=0;d<a.length&&!(b.length<d)&&b[d]==a[d];d++)if(" "==a[d]&&(c++,3==c))return!0}return!1}getNextFileName(a){var b=a.substr(a.length-3,3);b++;for(var c=0;c<this.cmsFiles.length;c++)if(b==this.cmsFiles[c].substr(this.cmsFiles[c].length-3,3))return this.cmsFiles[c];return a}getPreviousFileName(a){var b=
3659a.substr(a.length-3,3);b--;0>b&&(b=0);for(var c=0;c<this.cmsFiles.length;c++)if(b==this.cmsFiles[c].substr(this.cmsFiles[c].length-3,3))return this.cmsFiles[c];return a}getFile(a){for(var b=0;b<this.cmsFiles.length;b++)if(-1!=this.cmsFiles[b].indexOf(a))return this.cmsFiles[b];return""}getNextQuestion(a){for(var b="",c=0,d=0;d<this.cmsFiles.length;d++)if(-1!=a.indexOf(this.cmsFiles[d])){c=d;break}for(d=c+1;d<this.cmsFiles.length;d++)if(1>=this.extractStateFromFileName(this.cmsFiles[d])){b=this.cmsFiles[d];
3660break}return b}collectFiles(a){for(var b=[],c=0;c<this.cmsFiles.length;c++)this.belongsToPosition(a,this.cmsFiles[c])&&b.push(this.cmsFiles[c]);return b}getFilesForNotation(a){for(var b=0,c=0;c<this.cmsFiles.length;c++)if(-1!=this.cmsFiles[c].indexOf(a)){b=c+1;break}a=this.cmsFiles.length;for(c=b+1;c<this.cmsFiles.length;c++){var d=this.extractStateFromFileName(this.cmsFiles[c]);if(2!=d&&3!=d){a=c;break}}for(c=[];b<a;b++)d=this.extractMoveFromFileName(this.cmsFiles[b]),d.from!=d.to&&(d.fen=this.getPositionFromFileName(this.cmsFiles[b]).toFEN(),
3661c.push(d));return c}}"use strict";var LineEvalType={LOWERBOUND:1,UPPERBOUND:2,EXACT:3};
3662class EngineValue{static EngineValue={MATE_VALUE:3E4,MATE_THRESHOLD:28E3,MOVE_VALUE:28E3,MOVE_THRESHOLD:26E3};static MIN_VALUE=-EngineValue.MATE_VALUE;static MAX_VALUE=EngineValue.MATE_VALUE;static getMateEval=function(a){return 0>a?-EngineValue.MATE_VALUE-a:EngineValue.MATE_VALUE-a};static getMovesToMate=function(a){return a>-EngineValue.MATE_THRESHOLD||a<EngineValue.MATE_THRESHOLD?-1:0>a?a-EngineValue.MATE_THRESHOLD:EngineValue.MATE_THRESHOLD-a};}
3663class EvaluationGrade{static evGrade={EV_TOTALLY_WINNING:200,EV_WINNING:140,EV_ADVANTAGE:70,EV_SLIGHT_ADVANTAGE:25};static getGlyph=function(a){return a>=EvaluationGrade.evGrade.EV_WINNING?SpecialGlyphs.W_DECIS_ADV:a>=EvaluationGrade.evGrade.EV_ADVANTAGE?SpecialGlyphs.W_MODER_ADV:a>EvaluationGrade.evGrade.EV_SLIGHT_ADVANTAGE?SpecialGlyphs.W_SLIGHT_ADV:a>=EvaluationGrade.evGrade.EV_SLIGHT_DISADVANTAGE?SpecialGlyphs.EQUAL_ACTIVE_POS:a>EvaluationGrade.evGrade.EV_DISADVANTAGE?SpecialGlyphs.B_SLIGHT_ADV:
3664a>EvaluationGrade.evGrade.EV_LOSING?SpecialGlyphs.B_MODER_ADV:SpecialGlyphs.B_DECIS_ADV};}EvaluationGrade.evGrade.EV_TOTALLY_LOSING=-EvaluationGrade.evGrade.EV_TOTALLY_WINNING;EvaluationGrade.evGrade.EV_LOSING=-EvaluationGrade.evGrade.EV_WINNING;EvaluationGrade.evGrade.EV_DISADVANTAGE=-EvaluationGrade.evGrade.EV_ADVANTAGE;EvaluationGrade.evGrade.EV_SLIGHT_DISADVANTAGE=-EvaluationGrade.evGrade.EV_SLIGHT_ADVANTAGE;var PredefinedEngineOptions={MultiPV:"MultiPV",Ponder:"Ponder"};
3665class UCIUtils{static getPosString(a){var b="position startpos";a.isNormalInit()||(b="position fen "+a.getStartPos().toFEN());a=a.getCurLineCut();if(0<a.length){b+=" moves";for(var c=0;c<a.length;++c)b+=" "+a[c].toString()}return b}static getGoString(a){var b=new StringBuilder;b.append("go ");a=a||{};a.depth?b.appendFormat("depth {0} ",a.depth):a.moveTime&&b.appendFormat("movetime {0} ",Math.round(a.moveTime));a.wTime&&b.appendFormat("wtime {0} ",Math.round(a.wTime));a.bTime&&b.appendFormat("btime {0} ",
3666Math.round(a.bTime));(a.infinite||ObjUtil.isEmpty(a))&&b.appendFormat("infinite ");return b.toString()}static getSetOptionString(a,b){a=String.formatEx("setoption name {0}",a);"undefined"!==typeof b&&(a+=String.formatEx(" value {0}",b));return a}}
3667class EngineInstance{constructor(a,b,c,d){EngineInstance.initForListeners();this.engOptionVals=null;this.url=a;this.worker=null;this.calculating=!1;this.tag=c||null;this.name=d;EngineInstance.szPool=2;EngineInstance.pool||(EngineInstance.pool=[]);this.cur=null;this.lines=[];this.meta={name:"",author:""};this.metaDone=!1;EngineInstance.szPool&&(this.idPoolTimeout=setInterval(this._poolTimeout.bind(this),EngineInstance.POOL_TIMEOUT));this.engOptionVals=EngineInstance._createPreDefaultOptions();this.id=
3668++EngineInstance.engineCount;
3668this.minDepthForFire=0;this.infinite=!1;this.pushing=0}static engineCount=0;static _createPreDefaultOptions(){var a={};a[PredefinedEngineOptions.MultiPV]=1;a[PredefinedEngineOptions.Ponder]="false";return a}setMinDepthForFire(a){this.minDepthForFire=a}getTag(){return this.tag}setTag(a){this.tag=a}_killWorker(){CBDebug.assert(null!=this.worker);CBDebug.assert(this.calculating);this.calculating=!1;LOG("Kill Eng calculating: "+this.calculating);this.worker.terminate();this.worker=
3669null;this.loadingWorker=!1}_handleBestMove(a){a=a.split(" ");var b=Move.fromString(a[1]),c;"ponder"==a[2]&&(c=Move.fromString(a[3]));this.calculating=!1;LOG("Best Move Eng calculating: "+this.calculating);this.fireOnBestMove(this,{move:b,ponder:c})}_handleInfo(a){for(var b=a.split(" "),c=a=null,d=null,e=1,f=null,g=null,h=null,k=null,l=null,m=null,n=LineEvalType.EXACT,r=!1,t=1;t<b.length;++t)switch(b[t]){case "depth":a=parseInt(b[++t]);break;case "seldepth":c=parseInt(b[++t]);break;case "nps":g=parseInt(b[++t]);
3670break;case "nodes":h=parseInt(b[++t]);break;case "score":var u=b[++t];d=parseInt(b[++t]);switch(u){case "mate":r=!0}break;case "time":k=parseInt(b[++t]);break;case "currmovenumber":m=parseInt(b[++t]);break;case "currmove":u=b[++t];l=Move.fromString(u);break;case "lowerbound":n=LineEvalType.LOWERBOUND;break;case "upperbound":n=LineEvalType.UPPERBOUND;break;case "multipv":e=parseInt(b[++t]);break;case "pv":for(f=[],++t;t<b.length;++t)if(u=b[t],Move.isValidString(u))f.push(Move.fromString(u));else{--t;
3671break}}c=c||a;a&&a>this.minDepthForFire&&this.fireOnInfo(this,a,c,h,g,k);l&&(this.linesOnly||this.fireOnCurMove(this,m,l));f&&(this.lines[e-1]=f,a>this.minDepthForFire||2>=a)&&(b=ObjUtil.clone(f),this.fireOnLine(this,a,c,n,r,d,e,b,{handicapStyle:0,analysis:this.currGoOptions&&this.currGoOptions.infinite}))}static g_regexMeta=/^id (\w+) (.*)$/i;_handleIdInfo(a){this.metaDone||(a=EngineInstance.g_regexMeta.exec(a))&&a.length&&(this.meta[a[1]]=a[2])}_handleUCIOK(a){this.metaDone||(this.metaDone=!0,this.linesOnly||
3672this.fireOnUCIInfo(this))}_handle(a){"readyok"!==a&&("uciok"===a?this._handleUCIOK():a.startsWith("id")?this._handleIdInfo(a):a.startsWith("option")||(a.startsWith("bestmove")?this._handleBestMove(a):a.startsWith("info")&&this._handleInfo(a)))}_onMessage(a){this.loadingWorker=!1;this._handle(a.data)}_onError(a){console.log("Eng Worker Error");a.preventDefault()}_post(a){try{this.worker&&this.worker.postMessage(a)}catch(b){LogException("Post",b)}}static POOL_TIMEOUT=5E3;_getWorker(){if(0==EngineInstance.pool.length)try{return new Worker(this.url)}catch(a){alert("Engine: "+
3673a)}return EngineInstance.pool.pop()}_poolTimeout(){EngineInstance.pool.length>=EngineInstance.szPool||0<this.pushing||(this.pushing++,this._pushWorker())}_pushWorker(){try{EngineInstance.isAjax?this._startWorkerAjax(function(a){EngineInstance.pool.push(a);this.pushing--}.bind(this)):EngineInstance.pool.push(new Worker(this.url))}catch(a){LogException("Engine "+this.url,a)}}_startWorker(){try{if(this.worker=this._getWorker())this.worker.onmessage=this._onMessage.bind(this),this.worker.onerror=this._onError.bind(this),
3674this._post("uci"),this._post("isready"),this._sendPendingOptions()}catch(a){LogException("Start this.url",a)}}initWorker(a,b){this.loadingWorker=!1;this.worker=a;this.worker.onmessage||(this.worker.onmessage=this._onMessage.bind(this),this.worker.onerror=this._onError.bind(this),this._post("uci"),this._post("isready"));this._sendPendingOptions();a=UCIUtils.getSetOptionString("UCI_Chess960",2===b.start.ty);var c=UCIUtils.getPosString(b),d=UCIUtils.getGoString(this.currGoOptions);""!=d&&(this.cur=ObjUtil.clone(b.getCurPos()),
3675this.lines=[],this._post(a),this._post(c),this._post(d))}go(a,b){try{this.currGoOptions=b||{infinite:!0};this.currGoOptions.nMultiPV=this.nMultiPV||1;this.currGoOptions.tag=this.tag;this.currGoOptions.game=a;this.infinite=this.currGoOptions.infinite||this.currGoOptions.analysis;this.stop();this.calculating=!0;this.linesOnly||this.fireOnSearchStart(this.currGoOptions);if(!this.worker&&!this.loadingWorker){this.loadingWorker=!0;
3675if(EngineInstance.isAjax){0<EngineInstance.pool.length?(this.initWorker(EngineInstance.pool.pop(),
3676a),this._poolTimeout()):this._startWorkerAjax(function(f){this.initWorker(f,a)}.bind(this));return}this._startWorker()}var c=UCIUtils.getSetOptionString("UCI_Chess960",2===a.start.ty),d=UCIUtils.getPosString(a),e=UCIUtils.getGoString(this.currGoOptions);""!=e&&(this.cur=ObjUtil.clone(a.getCurPos()),this.lines=[],this._post(c),this._post(d),this._post(e))}catch(f){LogException("EngineGo",f)}}getCurPos(){return this.cur}getLines(){return this.lines}getBestMove(){return 0==this.lines.length||0==this.lines[0].length?
3677null:this.lines[0][0]}stop(){this.worker&&this.calculating&&(this._post("quit"),this._killWorker(),this.fireOnStop(this.infinite))}getName(){return this.meta.name}isCalculating(){return this.calculating}setHighestMoveInBook(){}newGame(a){this.worker&&!this.calculating&&this._post("ucinewgame");this.linesOnly||this.fireOnNewGame(a)}dispose(){this.removeAllListeners()}exit(){this.stop();this.dispose();this.fireOnExit()}setOption(a,b){this.engOptionVals[a]=b;this.worker&&this._post(UCIUtils.getSetOptionString(a,
3678b))}getOption(a){return this.engOptionVals[a]}setMultiPV(a){this.setOption(PredefinedEngineOptions.MultiPV,a);this.nMultiPV=a}getMultiPV(){return this.getOption(PredefinedEngineOptions.MultiPV)}clearHash(){}setPonder(a){this.setOption(PredefinedEngineOptions.Ponder,a?"true":"false")}offerDrawToEngine(){return!1}_sendPendingOptions(){for(var a in this.engOptionVals)this.engOptionVals.hasOwnProperty(a)&&this._post(UCIUtils.getSetOptionString(a,this.engOptionVals[a]))}_startWorkerAjax(a){var b="https://pgn.chessbase.com/common/chess/engine/df14/df14AjaxData.js";
3679glApp.canRunWebAssembly()&&!System.isMobile()&&(b="https://pgn.chessbase.com/common/chess/engine/webasm/fritzajax3.js");this.url=b;$.ajax({url:b,type:"GET",data:{},async:!0,cache:!0,processData:!1,success:function(c){c=new Blob([c],{type:"application/javascript"});try{var d=new Worker(URL.createObjectURL(c));a(d)}catch(e){}}})}static initForListeners(){EngineInstance.prototype.fireEvent||(Vk.initForListeners(EngineInstance),Vk.addEvent(EngineInstance,"Line"),Vk.addEvent(EngineInstance,"LosingLine"),
3680Vk.addEvent(EngineInstance,"CurMove"),Vk.addEvent(EngineInstance,"CurLine"),Vk.addEvent(EngineInstance,"Info"),Vk.addEvent(EngineInstance,"BestMove"),Vk.addEvent(EngineInstance,"UCIInfo"),Vk.addEvent(EngineInstance,"NewGame"),Vk.addEvent(EngineInstance,"SearchStart"),Vk.addEvent(EngineInstance,"Exit"),Vk.addEvent(EngineInstance,"Stop"),Vk.addEvent(EngineInstance,"Threat"),Vk.addEvent(EngineInstance,"BeautyScore"),Vk.addEvent(EngineInstance,"BookMove"),Vk.addEvent(EngineInstance,"StrongMove"),Vk.addEvent(EngineInstance,
3681"Eval"),Vk.addEvent(EngineInstance,"Hints"),Vk.addEvent(EngineInstance,"MoveFeedback"),Vk.addEvent(EngineInstance,"StaticEval"))}}"use strict";
3682class AnalysisEngine{constructor(a){AnalysisEngine.DefaultOptions={};AnalysisEngine.engineCount=0;a=a||{};this.options=ObjUtil.copyTo(AnalysisEngine.DefaultOptions,a,!0);this.szPool=0;glApp.canRunWebAssembly()&&(this.szPool=2);this.loadEngineInstance();this.id=++AnalysisEngine.engineCount;AnalysisEngine.InitListeners();this.analysisTick=new Tick}static createGlobal(a){try{"undefined"!==typeof glApp&&!glApp.analysisEngine&&System.browserIsSafeForEngine()&&glApp.config.useAnalysisEngines&&(glApp.analysisEngine=
3683new AnalysisEngine(a||{minDepthForFire:5}))}catch(b){LogException("PM:initAnalysisEngine",b)}}destroy(){}loadEngineInstance(){this.engine=new EngineInstance(glApp.config.getEngineUrl()[0],this.szPool,1,"Analysis");this.options.minDepthForFire&&this.engine.setMinDepthForFire(this.options.minDepthForFire);this.idOnLine=this.engine.addOnLineListener(this._onLine.bind(this));this.idOnBestMove=this.engine.addOnBestMoveListener(this._onBest.bind(this))}onGameNavigate(){}engineGo(a,b){this._resetGoState();
3684this.kernel=a;b=b||this._getNVarsToCalc();this.engine.setMultiPV(b);this.engine.go(this.kernel.game,{infinite:!0});this.engine.fireOnThreat(!1);this.running=!0;this.analysisTick.start()}threatGo(a){this._resetGoState();this.engine.setMultiPV(2);this.engine.go(a,{infinite:!0});this.running=!0;this.analysisTick.start()}engineStop(){this.engine.stop();this.running=!1}clearLines(){this._resetGoState()}getMultiPV(){return this.engine.getMultiPV()}dispose(){this.engine.exit()}linkPlayingMode(a){a.getMarkedSquaresOnButtonDown&&
3685(a.clickHintTimer||(a.clickHintTimer=new Timer),a.kernel.boardWin.isHandlerBoard?(a.idOnLineListener||(a.idOnLineListener=this.addOnLineListener(a.onAnalysisLine.bind(a))),!a.idOnStrongMoveListener&&a.onAnalysisStrongMove&&(a.idOnStrongMoveListener=this.addOnStrongMoveListener(a.onAnalysisStrongMove.bind(a)))):(a.kernel.boardWin.fnMarkSquaresOnButtonDown=a.getMarkedSquaresOnButtonDown.bind(a),a.startClickHintTimer&&a.startClickHintTimer&&(a.kernel.boardWin.fnSquareClick=a.startClickHintTimer.bind(a)),
3686a.kernel.boardWin.fnSquareChangeInMouseMove=function(){a.clickHintTimer&&a.clickHintTimer.stop()}.bind(a),a.kernel.boardWin.fnSquareRelease=function(){a.clickHintTimer&&a.clickHintTimer.stop()}.bind(a),a.idOnLineListener||(a.idOnLineListener=this.addOnLineListener(a.onAnalysisLine.bind(a)),a.kernel.boardWin.idOnLineListener||(a.kernel.boardWin.idOnLineListener=this.addOnLineListener(a.kernel.boardWin.refreshMarkedSquares.bind(a.kernel.boardWin))))))}unlinkPlayingMode(a){a.clickHintTimer&&a.clickHintTimer.stop();
3687a.kernel.boardWin&&(a.kernel.boardWin.fnSquareClick=null,a.kernel.boardWin.fnMarkSquaresOnButtonDown=null,this.removeOnLineListener(a.kernel.boardWin.idOnLineListener),a.kernel.boardWin.idOnLineListener=null);this.removeOnLineListener(a.idOnLineListener);this.removeOnStrongMoveListener(a.idOnStrongMoveListener);a.idOnLineListener=null;a.idOnStaticEvalListener=null}linkPlayingModeForThreat(a){a.idOnThreatLineListener||(a.idOnThreatLineListener=this.addOnLineListener(a.onThreatLine.bind(a)))}unlinkPlayingModeForThreat(a){this.removeOnLineListener(a.idOnThreatLineListener);
3688a.idOnThreatLineListener=null}_getNVarsToCalc(){return this.nFixedVars?this.nFixedVars:128}getHintSquaresOnButtonDown(a){var b=[];if(0<this.lastDepth){var c=AnalysisEngine.linesToArray(this.curLines[this.lastDepth-1]);c.sort(function(e,f){return f.getEval()-e.getEval()});if(!c.length)return b;var d=c[0].getEval();
3688c.forEach(function(e){var f=e.getEval();e.getMove().from==a&&b.push({sq:e.getMove().to,clr:this._getTargetSqClr(f,d),txt:d-f})}.bind(this))}return b}getCounterMoveTo(a,b){if(0<this.lastDepth){var c=
3689AnalysisEngine.linesToArray(this.curLines[this.lastDepth-1]);c.sort(function(h,k){return k.getEval()-h.getEval()});if(c.length)for(var d=c[0].getEval(),e=0;e<c.length;e++){var f=c[e],g=f.getEval();if(f.getMove(0).from==a&&f.getMove(0).to==b)return{from:f.getMove(1).from,to:f.getMove(1).to,clr:this._getTargetSqClr(g,d)}}}}_getTargetSqClr(a,b){if(23E3<Math.abs(a))return new CBHSLColor(0,0,0,.6);a=b-a;b=[[2E4,0,95,55,1],[1E3,3,95,50,.9],[700,4,95,48,.9],[400,12,95,47,.9],[300,14,95,46,.9],[250,18,95,
369046,.75],[200,19,95,45,.9],[170,20,90,60,.9],[140,24,90,60,.9],[120,28,90,60,.9],[100,30,90,60,.9],[90,34,90,45,.9],[80,38,90,45,.75],[70,46,90,45,.75],[60,50,90,45,.75],[50,65,90,45,.75],[40,70,90,45,.55],[30,75,90,45,.55],[20,80,90,45,.55],[15,90,90,45,.55],[10,100,90,45,.55],[7,110,90,45,.55],[5,115,90,42,.7],[0,120,90,42,.74]];for(var c=0;c<b.length;c++)if(a>=b[c][0])return new CBHSLColor(b[c][1],b[c][2],b[c][3],b[c][4]);return new CBHSLColor(CBHSLColor.GREEN,90,40,.6)}_resetGoState(){this.curLines=
3691[];this.baseLines={};this.depthLines=[];this.depthArrLines=[];this.lastDepth=1;this.bestAt1Ply=null;this.firedStrong=!1}_onLine(a,b,c,d,e,f,g,h){if(d==LineEvalType.EXACT||e){if(b>this.lastDepth){this.maxPVNum=0;0<this.lastDepth&&this.curLines[this.lastDepth]&&this.storeLines(ObjUtil.clone(this.curLines[this.lastDepth]),this.lastDepth);if(this.lastDepth&&this.depthArrLines[this.lastDepth]&&this.depthArrLines[this.lastDepth].length){a=null;if(1<this.depthArrLines[this.lastDepth].length){var k=this.depthArrLines[this.lastDepth][1];
3692var l=this.depthArrLines[this.lastDepth][1].getEval();a=this.checkIfStrongMoveExists()}(!this.options.minDepthForFire||this.lastDepth>=this.options.minDepthForFire||1==this.lastDepth)&&this.fireOnLine(this.lastDepth,this.depthArrLines[this.lastDepth][0].getEval(),this.depthArrLines[this.lastDepth][0],l,k,a)}this.lastDepth=b;18E4<=this.analysisTick.getExpired()&&this.engineStop()}e&&(f=EngineValue.getMateEval(f));b=new EvaluatedLine(h,f);this.curLines[this.lastDepth]||(this.curLines[this.lastDepth]=
3693{});this.curLines[this.lastDepth][b.key()]=b}}storeLines(a,b){this.depthLines[b]=a;this.depthArrLines[b]=AnalysisEngine.linesToArray(a)}is1PlyBest(a){if(this.depthArrLines[1]&&this.depthArrLines[1].length&&this.depthArrLines[1][0].line[0].equals(a))return this.depthArrLines[1].hasClearlyBest(60)}everythingElseLoses(a){let b=a[0].getEval();return-200>a[1].getEval()&&-50<b}static linesToArray(a){var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(a[c]);b.sort(function(d,e){return e.getEval()-d.getEval()});
3694for(a=0;a<b.length;a++)b[a].lineNumber=a;b.getNLinesInEvalRange=function(d){for(var e=0,f=this[0].getEval(),g=1;g<this.length&&!(f-this[g].getEval()>d);g++)e++;return e};b.hasClearlyBest=function(d){return 1==b.length?!0:b[0].getEval()-b[1].getEval()>=d};return b}static getSortedLines(a){a=AnalysisEngine.linesToArray(a);a.sort(function(b,c){return c.getEval()-b.getEval()});return a}_onBest(a,b){}getBestMove(){if(3<this.lastDepth)return AnalysisEngine.getSortedLines(this.curLines[this.lastDepth])[0].getMove()}isBest(a){var b=
3695this.getBestMove();if(b)return b.equals(a)}getEval(){return 1<this.lastDepth&&this.depthArrLines[this.lastDepth-1]&&this.depthArrLines[this.lastDepth-1].length?this.depthArrLines[this.lastDepth-1][0].getEval():0}getBestEval(){if(this.curLines&&this.curLines.length){var a=AnalysisEngine.getSortedLines(this.curLines[this.lastDepth]);return 1>a.length?0:a[0].getEval()}return 0}isRecapture(a,b){return a.to==b.to&&0!=a.vct}isExchange(a,b,c){a=a.board;if(c)return b.to==c.to&&(a[c.to]&Piece.PIECE_MASK)==
3696(a[c.from]&Piece.PIECE_MASK)}checkIfStrongMoveExists(){var a={};if(6<this.lastDepth){var b=AnalysisEngine.getSortedLines(this.curLines[this.lastDepth]),c=this.hasBest(b)&&1<b.length;let e=!1;if(c){var d=new Att;let f=this.kernel.game.getCurPos();d=d.calc(f,c.from,c.to);if(0>d)a={move:c,att:d,sac:!0,trivial:this.is1PlyBest(c)},this.fireOnStrongMove(a),e=this.firedStrong=!0;else{let g=this.kernel.game;g.getMoveCount()&&this.hasClearlyBest(b)&&0==d&&(d=g.getMoves()[g.getMoves().length-1],this.isRecapture(d,
3697c)||this.isExchange(f,c,b[0].line[1])?LOG("Recapture: "+d+"/"+c):(a={move:c,att:0,precise:!0,win:90<b[0].getEval(),trivial:this.is1PlyBest(c),elseLoses:this.everythingElseLoses(b)},this.fireOnStrongMove(a),e=this.firedStrong=!0))}}this.firedStrong&&!e&&(this.fireOnStrongMove({cancel:!0}),this.firedStrong=!1)}return a}hasBest(a){if(1<a.length){var b=a[0].getEval(),c=Math.abs(b-a[1].getEval());if(c>Math.abs(b)/4&&50<c)return a[0].line[0]}}hasClearlyBest(a){if(1<a.length){var b=a[0].getEval(),c=Math.abs(b-
3698a[1].getEval());if(c>Math.abs(b)/3&&80<c)return a[0].line[0]}}detMoveValue(a){if(1<this.lastDepth){var b=AnalysisEngine.linesToArray(this.curLines[this.lastDepth]);b.sort(function(e,f){return f.getEval()-e.getEval()});if(1<b.length){for(var c=b[0].getEval(),d=0;d<b.length;d++)if(a.equals(b[d].getMove()))return a=b[d].getEval(),this.makeMoveValue(d,c,a);this.makeMoveValue(99,c,b[b.length-1].getEval())}}return this.makeMoveValue(-1)}makeMoveValue(a,b,c){return{inx:a,evBest:b,evDiff:Math.abs(b-c),lineEv:c,
3699playable(){return this.evDiff<Math.abs(this.evBest)/3||70>this.evDiff||400<this.lineEv},blunder(){return this.evDiff>Math.abs(this.evBest/2)&&100<this.evDiff},bigBlunder(){return this.evDiff>Math.abs(this.evBest)&&200<this.evDiff},recapt:!1}}static InitListeners(){AnalysisEngine.prototype.fireEvent||(Vk.initForListeners(AnalysisEngine),Vk.addEvent(AnalysisEngine,"Line"),Vk.addEvent(AnalysisEngine,"StrongMove"),
3699Vk.addEvent(AnalysisEngine,"StaticEval"))}}
3700class AnalysisMoves{constructor(){this.maxMoveNo=0;this.moves=[]}get(a){return this.moves[a]}setPlayed(a,b,c){this.moves[b]||(this.moves[b]=new AnalysisMove);this.moves[b].playedMove=a;this.moves[b].check=c;b>this.maxMoveNo&&(this.maxMoveNo=b)}isBestMove(a,b){if(this.moves[b])return this.moves[b].isBest(a)}isGoodMove(a,b){return this.moves[b]&&this.moves[b].isGood(a)}isOnlyMove(a,b){return this.moves[b]&&this.moves[b].isOnly(a)}isNonTrivialOnlyMove(a,b){return this.moves[b]&&this.moves[b].isNonTrivialOnly(a)}isNonTrivialBest(a,
3701b){return this.moves[b]&&this.moves[b].isNonTrivialBest(a)}getBestMove(a){if(0<a&&this.moves[a]&&this.moves[a-1]&&this.moves[a].line)return this.moves[a].line[0]}isBlunder(a){if(0<a&&this.moves[a]&&this.moves[a-1]){var b=this.moves[a].eval,c=b-this.moves[a-1].eval,d=b;this.moves[a-1].btm&&(c=-c,d=-d);if(-150>c&&Math.abs(c)>.5*Math.abs(b)&&0>d)return c}return 0}isPlayable(a){if(0<a&&this.moves[a]&&this.moves[a-1]){var b=this.moves[a].eval,c=b-this.moves[a-1].eval;this.moves[a-1].btm&&(c=-c);return-80>
3702c&&Math.abs(c)<Math.max(40,.4*Math.abs(b))}return!1}playedRecapture(a){if(0<a&&this.moves[a]&&this.moves[a-1]){var b=this.moves[a-1].playedMove;a=this.moves[a].playedMove;if(b&&b.to==a.to&&b.vct)return!0}return!1}isRecapture(a,b){return 0<a&&this.moves[a]&&(a=this.moves[a].playedMove)&&a.to==b.to?!0:!1}isOnlyLegal(a){return 0<a&&this.moves[a]?this.moves[a].isOnlyLegal():!1}wasInCheck(a){return 0<a&&this.moves[a]?this.moves[a].check:!1}playedCapture(a){return 0<a&&this.moves[a]?0!=this.moves[a].playedMove.vct:
3703!1}isNotWorse(a){return this.moves[a]&&this.moves[a].isEvalAboveForSide(-40)}secondLoses(a){return this.moves[a]&&this.moves[a].secondLoses()}punishedBlunder(a,b){return 0<a&&this.moves[a]&&this.moves[a-1]&&this.moves[a].line.length&&this.moves[a].line[0].equals(b)?(b=Math.abs(this.moves[a].eval-this.moves[a-1].eval),b>.4*Math.abs(this.moves[a-1].eval)&&150<b):!1}getEvals(){for(var a=[],b=0;b<this.maxMoveNo;b++)this.moves[b]&&this.moves[b].line&&(a[b]=this.moves[b].eval);return a}countAnalysed(a){for(var b=
37040,c=0;c<this.maxMoveNo;c++)this.moves[c]&&this.moves[c].line&&this.moves[c].btm==a&&b++;return b}}
3705var AnalysisMove=function(){var a=function(b,c,d,e,f,g){this.updateLines(b,c,d,e,f,g)};a.prototype.updateLines=function(b,c,d,e,f,g){b&&(this.line=b.line,2>=f&&(this.line1Ply=b.line));d&&(this.secondLine=d.line);this.secondEval=e;this.eval=c;this.depth=f;this.btm=g};a.prototype.isBest=function(b){return this.line&&this.line.length&&this.line[0].equals(b)};a.prototype.isGood=function(b){if(this.line&&this.line.length&&this.line[0].equals(b)||this.secondLine&&this.secondLine.length&&this.secondLine[0].equals(b)&&
3706this.secondMoveIsPlayable())return!0};a.prototype.secondMoveIsPlayable=function(){var b=Math.abs(this.eval-this.secondEval);return 25>b||b<.15*Math.abs(this.eval)};a.prototype.isBest1Ply=function(b){return this.line1Ply&&this.line1Ply.length&&this.line1Ply[0].equals(b)};a.prototype.isOnlyLegal=function(){if(this.line)return this.line.length&&!this.secondLine};a.prototype.isOnly=function(b){return this.line&&this.line.length&&this.line[0].equals(b)&&this.hasOnlyMove()};a.prototype.isNonTrivialOnly=
3707function(b){return this.isOnly(b)&&!this.isBest1Ply(b)};a.prototype.isNonTrivialBest=function(b){return this.isBest(b)&&!this.isBest1Ply(b)};a.prototype.hasOnlyMove=function(){if(this.secondLine&&this.secondLine.length){var b=Math.abs(this.eval-this.secondEval);if(30<b&&b>.3*Math.abs(this.eval))return!0}return!1};a.prototype.isEvalAboveForSide=function(b){var c=this.eval;this.btm&&(c=-this.eval);return c>=b};a.prototype.secondLoses=function(){if(this.secondEval){var b=this.btm?-this.secondEval:this.secondEval;
3708return this.isEvalAboveForSide(-60)&&-200>b}return!1};return a}();"use strict";
3709class Evaluation{static MATES=2E4;static CLEARLY_WINNING=420;static WINNING=350;static DECISIVE=250;static CLEARLY_BETTER=130;static BETTER=80;static SLIGHTLY=40;static EDGE=22;static INVALID=32767;constructor(a){this.val=a}static getEvalString(a){return a>Evaluation.MATES?lm.WHITE_MATES:a>Evaluation.CLEARLY_WINNING?lm.WHITE_CLEARLY_WINNING:a>Evaluation.WINNING?lm.WHITE_WINNING:a>Evaluation.DECISIVE?lm.WHITE_DECISIVE:a>Evaluation.CLEARLY_BETTER?lm.WHITE_CLEARLY_BETTER:a>Evaluation.BETTER?lm.WHITE_BETTER:
3710a>Evaluation.SLIGHTLY?lm.WHITE_SLIGHTLY:a>Evaluation.EDGE?lm.WHITE_EDGE:a<-Evaluation.MATES?lm.BLACK_MATES:a<-Evaluation.CLEARLY_WINNING?lm.BLACK_CLEARLY_WINNING:a<-Evaluation.WINNING?lm.BLACK_WINNING:a<-Evaluation.DECISIVE?lm.BLACK_DECISIVE:a<-Evaluation.CLEARLY_BETTER?lm.BLACK_CLEARLY_BETTER:a<-Evaluation.BETTER?lm.BLACK_BETTER:a<-Evaluation.SLIGHTLY?lm.BLACK_SLIGHTLY:a<-Evaluation.EDGE?lm.BLACK_EDGE:lm.EQUAL_POS}static getEmoticonUrl(a){a=Evaluation.getEmo(a);return getCommonPath()+String.f("Media/Emojis/Fritz/Fritz{0}.png",
3711a)}static getSmilingEmoticonUrl(){return Evaluation.getEmoticonUrl(Evaluation.BETTER+1)}static getAnalysisEmoticonUrl(){return this.getEmoUrl("Ruler.png")}static getBookEmoticonUrl(){return this.getEmoUrl("Books.png")}static getThinkingEmoticonUrl(){return getCommonPath()+"Media/Emojis/Fritz/FritzConcentrated.png"}static getStoppedEmoticonUrl(){return this.getEmoUrl("Sleeping.png")}static getHintEmoticonUrl(){return this.getEmoUrl("LightBulb.png")}static getStrongEmoticonUrl(){return this.getEmoUrl("Exclam.png")}static getEmoUrl(a){return getCommonPath()+
3712String.f("Media/Emojis/{0}",a)}static getEmo(a){return a>Evaluation.MATES?"Mates":a>Evaluation.CLEARLY_WINNING?"ClearlyWins":a>Evaluation.WINNING?"Wins":a>Evaluation.DECISIVE?"Decisive":a>Evaluation.CLEARLY_BETTER?"ClearlyBetter":a>Evaluation.BETTER?"Better":a>Evaluation.SLIGHTLY?"SlightlyBetter":a>Evaluation.EDGE?"Equal":a<-Evaluation.CLEARLY_WINNING?"ClearlyLosing":a<-Evaluation.WINNING?"Losing":a<-Evaluation.DECISIVE?"DecisivelyWorse":a<-Evaluation.CLEARLY_BETTER?"ClearlyWorse":a<-Evaluation.BETTER?
3713"Worse":a<-Evaluation.SLIGHTLY?"SlightlyWorse":"Equal"}static getListIcon(a){return a==Evaluation.INVALID?"":a>Evaluation.MATES?"mate":a>Evaluation.CLEARLY_BETTER?"whitewins":a>Evaluation.BETTER?"whitebetter":a>Evaluation.EDGE?"whiteslightly":a<-Evaluation.MATES?"mate":a<-Evaluation.CLEARLY_BETTER?"blackwins":a<-Evaluation.BETTER?"blackbetter":a<-Evaluation.EDGE?"blackslightly":"equal"}toString(){return Evaluation.getEvalString(this.val)}}"use strict";
3714class EvaluatedLine{constructor(a,b){this.line=a;this.eval=b}getEval(){return this.eval}getLine(){return this.line}length(){return this.line.length}
3714getMove(a){return this.line[a||0]||new Move(0,0,0)}key(){return this.getMove().toString()}toString(){return String.formatEx("{eval}: {line}",this)}}"use strict";
3715class EngineWrapper{constructor(a,b,c,d){this.nEngine=a;this.url=b;this.engine={};this.viewLink=c;this.gameLink=d}load(){var a=this;try{a.url.match(/http/i)?$.ajax({url:a.url,type:"GET",data:{},async:!0,cache:!0,processData:!1,success:function(b){b=new Blob([b],{type:"application/javascript"});a.engine=new Worker(URL.createObjectURL(b));a.engine.onmessage=EngineWrapper.prototype.onMessage.bind(a);a.engine.error=EngineWrapper.prototype.onError.bind(a);a.engine.postMessage({cmd:"reset"});a.isRunning=
3716!1}}):(this.engine=new Worker(this.url),this.engine.onmessage=EngineWrapper.prototype.onMessage.bind(this),this.engine.error=EngineWrapper.prototype.onError.bind(this),this.engine.postMessage({cmd:"reset"}),this.isRunning=!1)}catch(b){}}unLoad(){this.abort()}newGame(){this.abort();this.engine.postMessage({cmd:"reset"})}makeMove(a){this.engine.postMessage({cmd:"move",move:a.toJSON()})}search(a,b){this.isRunning=!0;this.engine.postMessage&&this.engine.postMessage({cmd:"search",timeout:a,maxdepth:b})}sendNewPos(a){this.abort();
3717a=a.toFEN();this.engine.postMessage&&(this.engine.postMessage({cmd:"position",fen:a}),this.viewLink&&this.viewLink.clearEngineOutput(this.nEngine))}sendNewGame(a,b){this.abort();this.engine.postMessage({cmd:"reset"});if(!a.isNormalInit()){var c={cmd:"position",fen:a.getStartPos().toFEN()};b.forEach(function(e){c[e.piece+"Table"]=this.getStrExternTable(e.vals)}.bind(this));this.engine.postMessage(c)}for(b=0;b<a.mainLine.length;b++){var d=a.mainLine[b].toJSON();this.engine.postMessage({cmd:"move",move:d})}this.viewLink&&
3718this.viewLink.clearEngineOutput(this.nEngine)}analyse(a){this.abort();a=a.toFEN();this.engine.postMessage({cmd:"position",fen:a});this.engine.postMessage({cmd:"analyze"});this.isRunning=!0;this.viewLink&&this.viewLink.clearEngineOutput(this.nEngine)}abort(){this.isRunning&&(this.engine.terminate(),this.isRunning=!1,this.load())}onMessage(a){if("pv"==a.data.id)this.gameLink.onEnginePV(this.nEngine,a.data);else"move"==a.data.id&&(this.gameLink.onEngineMove(this.nEngine,a.data),this.isRunning=!1)}onError(a){LOG("Error: "+
3719a.message);alert(a)}genGoodSquaresForWhitePieceEval(a,b){}getStrExternTable(a){for(var b=Array(64),c=0;64>c;c++)b[c]=0;a.forEach(function(d){var e=CBSquare.getRank(d.sq),f=CBSquare.getFile(d.sq);b[8*(7-e)+f]=d.val});return JSON.stringify(b)}getStrExternEval(){return""}}"use strict";
3720class ClockParams{static POOL_BLITZ=1;constructor(a,b){this.startMins=void 0!==a?a:0;this.incSecs=b||0;1>this.startMins&&0==this.incSecs&&(this.startMins=1);this.flags=this.addSecs=this.addMins=0}fromDataBuf(a){this.startMins=a.V19()&65535;this.incSecs=a.V19()&65535;this.addMins=a.V1a();this.addSecs=a.V1a();this.flags=a.V19();return!0}V17(a){a.V13(this.startMins&65535);a.V13(this.incSecs&65535);a.V14(this.addMins);a.V14(this.addSecs);a.V13(this.flags)}toString(){var a=this.startMins+"m + "+this.incSecs+
3721"s";this.addMins&&(a+=String.f(" (W add {0}m)",this.addMins));return a}canBePoolBlitz(){return 0==this.addMins&&0==this.addSecs&&0==this.incSecs&&(1==this.startMins||3==this.startMins||5==this.startMins)}static createFromSeekParams(a){var b=new ClockParams(3,0);a&&(a=a.split(","),a.length&&(b.startMins=a[0],0==b.startMins&&(b.startMins=5),1<a.length&&(b.incSecs=a[1])));return b}getSortVal(){return 40*this.startMins+this.incSecs}calcRatingType(){return 900<this.getAvGameTimeSeconds()?ServerEloRating.SLOW:
3722180<=this.getAvGameTimeSeconds()?ServerEloRating.BLITZ:ServerEloRating.BULLET}getGameTypeName(){switch(this.calcRatingType()){case ServerEloRating.BULLET:return"Bullet";case ServerEloRating.BLITZ:return"Blitz";case ServerEloRating.SLOW:return"Slow"}}getAvGameTimeSeconds(){return 60*this.startMins+40*this.incSecs}isBlitz(){return this.calcRatingType()==ServerEloRating.BLITZ}isBullet(){return this.calcRatingType()==ServerEloRating.BULLET}isSlow(){return this.calcRatingType()==ServerEloRating.SLOW}getStartSecs(){return 60*
3723this.startMins}modify(a,b){let c=this.startMins+this.addMins,d=this.startMins;b===Side.WHITE?this.addMins+=a-c:(a=d-a,this.startMins-=a,this.addMins+=a)}}"use strict";const TimeTrouble={SLIGHTLY_BEHIND:-1,BEHIND:-2,CLEARLY_BEHIND:-3,LOSING_ON_TIME:-4,ABOUT_EVEN:0,SLIGHTLY_AHEAD:1,AHEAD:2,CLEARLY_AHEAD:3};
3724class ChessClock extends BaseClock{static _uniqueId=1;constructor(a,b,c){super(a);this.fnTimeout=b;this.fnWarnClock=c;this.result=GameResultEnum.GAME_UNFINISHED;this.runsForward=!1;this.centiSecsBlack=this.centiSecsWhite=0;this.uniqueId=ChessClock._uniqueId++;this._isRunning=!1;this.mySide=null;this.warned=[];this.nextStartPenalty=[0,0];this.nextRestTimeInc=[0,0];this.clockParams=new ClockParams(3,0);this.restTimeAtStart=0}getWTimeMilli(){return 10*this.centiSecsWhite}getBTimeMilli(){return 10*this.centiSecsBlack}destroy(){}reinit(){this.setClockParams(this.clockParams)}setClockParams(a){this.warned=
3725[!1,!1];this.result=GameResultEnum.GAME_UNFINISHED;a?(this.clockParams=a,this.centiSecsWhite=6E3*(this.clockParams.startMins+this.clockParams.addMins)+this.clockParams.addSecs,this.centiSecsBlack=6E3*this.clockParams.startMins,0==this.clockParams.startMins&&(this.centiSecsBlack=this.centiSecsWhite=1E3),this.clockLink.showRestTime(new Date(10*this.centiSecsWhite),!1),this.clockLink.showRestTime(new Date(10*this.centiSecsBlack),!0),this.clockLink.setDisplayHours(3E3<this.clockParams.getAvGameTimeSeconds())):
3726(this.setNoClock(),delete this.clockParams);delete this.startTimeMillis;delete this.expiredAtStop;this.nextStartPenalty=[0,0];this.nextRestTimeInc=[0,0]}setRunsForward(a){this.runsForward=a;this.clockLink.setRunsForward(a)}initFromGame(a){this.stop();if(this.clockParams){for(var b=6E3*(this.clockParams.startMins+this.clockParams.addMins)+this.clockParams.addSecs,c=6E3*this.clockParams.startMins,d=this.runsForward?-1:1,e=0;e<a.getPlyNum();e++)if(e<a.getMoves().length){var f=a.getMoves()[e].getAnno();
3727f&&(f=f.getItem(AnnoType.TIME))&&(e&1?(c-=d*f.getTimeIn100th(),c+=d*this.clockParams.incSecs*100):(b-=d*f.getTimeIn100th(),b+=d*this.clockParams.incSecs*100))}this.isBlack=0!=(a.getMoves().length&1);a.expiredSecs&&a.expiredSecs[a.getMoves().length]&&(d=a.expiredSecs[a.getMoves().length],this.isBlack?c-=100*d:b-=100*d);this.centiSecsWhite=b;this.centiSecsBlack=c;this.takeStartTime();this.clockLink.setToMove&&this.clockLink.setToMove(this.isBlack);this.showTimes(b,c);a.isOnLastMove()&&(a.hdr.getCBResult().isFinished()?
3728this.clockLink.showResult(a.hdr.getResult()):(this.setToMove(a.getCurPos().isBTM()),this.start(!0)))}}onResult(a){this.isFinished()||(this.result=a,this.stop(),this.clockLink.showResult(a),LOG("Clock On result: "+this.result,"LogBold"))}unfinish(){this.result=GameResultEnum.GAME_UNFINISHED}isFinished(){return this.result>=GameResultEnum.BLACK_WINS&&this.result<=GameResultEnum.LINE}setToMove(a){LOG("Clock, setToMove, black= "+a);this.clockParams&&!this.isFinished()&&((this.isBlack=a)?this.centiSecsBlack+=
3729100*this.clockParams.incSecs:this.centiSecsWhite+=100*this.clockParams.incSecs,this.takeStartTime(),this.clockLink.setToMove&&this.clockLink.setToMove(a))}isRunning(){return this._isRunning}start(a){if(!this._isRunning&&this.clockParams&&!this.isFinished()){this._isRunning=!0;this.takeStartTime();var b=this.isBlack?1:0;a&&(this.startTimeMillis+=10*this.nextStartPenalty[b],this.restTimeAtStart+=this.nextRestTimeInc[b]);this.showTimes(this.centiSecsWhite,this.centiSecsBlack);this.updateTimer.runOnce(1E3);
3730delete this.expiredAtStop}}stop(){if(this._isRunning&&(this.updateTimer.stop(),this.startTimeMillis)){this._isRunning=!1;var a=(getTick()-this.startTimeMillis+5)/10;this.expiredAtStop=a;this.isFinished()||this.setExpired(a,this.isBlack)}}takeStartTime(){this.startTimeMillis=getTick();this.restTimeAtStart=this.isBlack?this.centiSecsBlack:this.centiSecsWhite}continue2(){if(!this._isRunning&&this.clockParams&&!this.isFinished()){var a=this.expiredAtStop;a?(this._isRunning=!0,this.takeStartTime(),this.startTimeMillis-=
373110*a,this.restTimeAtStart+=a,this.isBlack?this.centiSecsBlack+=a:this.centiSecsWhite+=a,this.showTimes(this.centiSecsWhite,this.centiSecsBlack),this.updateTimer.runOnce(1E3),delete this.expiredAtStop):this.start()}}getRestCentiSecs(a){return a?this.centiSecsBlack:this.centiSecsWhite}setPenalty(a,b,c){this.nextStartPenalty[b]=a;this.nextRestTimeInc[b]=c}showTimes(a,b){0<=a?this.clockLink.showRestTime(new Date(10*a),!1):this.clockLink.showRestTime(-1,!1);0<=b?this.clockLink.showRestTime(new Date(10*
3732b),!0):this.clockLink.showRestTime(-1,!0)}setExpired(a,b){if(this.clockParams)return this.clockLink.showCurrTime(new Date(10*a),b),this.clockLink.showCurrTime(new Date(10*a),b),a=this.runsForward?b?this.centiSecsBlack=this.restTimeAtStart+a:this.centiSecsWhite=this.restTimeAtStart+a:b?this.centiSecsBlack=this.restTimeAtStart-a:this.centiSecsWhite=this.restTimeAtStart-a,0>a?this.clockLink.showRestTime(-1,b):this.clockLink.showRestTime(new Date(10*a),b,this.getTimeTroubleIndex()),a}changeCurrMoveElapsedTime(a){this.clockParams&&
3733!this.isFinished()&&(this.startTimeMillis=getTick()-10*a)}addIncrementOnce(){if(this.clockParams&&!this.isFinished()){let a=this.getExpired();this.changeCurrMoveElapsedTime(a-100*this.clockParams.incSecs)}}reset(){this.setClockParams(new ClockParams(0,0))}getExpired(){return this.expiredAtStop?this.expiredAtStop:this.startTimeMillis?(getTick()-this.startTimeMillis+5)/10:0}getStrRestTimes(){var a=ChessClock.getTimeString(new Date(10*this.centiSecsWhite)),b=ChessClock.getTimeString(new Date(10*this.centiSecsBlack)),
3734c="";0<=this.centiSecsWhite&&(c=String.f("{0}={1}",lm.WHITE,a));a="";0<=this.centiSecsBlack&&(a=String.f("{0}={1}",lm.BLACK,b));(b=c)&&a&&(b+=", ");return b+a}getStrRestTimes2(a){var b=ChessClock.getTimeString(new Date(10*this.centiSecsWhite),!0);1==a&&(b=ChessClock.getTimeString(new Date(10*this.centiSecsBlack),!0));return b}createTimeAnno(){return new TimeAnno(TimeTools.getCBTimeOfCentiSecs(this.getExpired()))}setText(a,b){this.clockLink.setText(a,b)}update(){var a=(getTick()-this.startTimeMillis+
37355)/10,b=this.setExpired(a,this.isBlack);if(0<b){this.clockLink.setDisplayCentiSecs(1E3>b);var c=1E3;1E3>b&&(c=100);this.updateTimer.runOnce(c);15<a/100&&a>b/3&&this.fnWarnClock&&!this.warned[this.isBlack?1:0]&&(this.fnWarnClock(this.isBlack),this.warned[this.isBlack?1:0]=!0)}else LOG("Clock Timeout: "+this.uniqueId,"LogBold"),this.fnTimeout&&!this.isFinished()&&(this.clockLink.setText("TIME",this.isBlack),this.fnTimeout(this.uniqueId))}getTimeTroubleIndex(){if(null!=this.mySide){if(this.isBlack){var a=
3736this.centiSecsBlack;var b=this.centiSecsWhite}else a=this.centiSecsWhite,b=this.centiSecsBlack;return Math.abs(a-b)<.1*Math.abs(a)&&2E3<a?TimeTrouble.ABOUT_EVEN:a>b?a>1.2*b?a>2*b?TimeTrouble.CLEARLY_AHEAD:TimeTrouble.AHEAD:TimeTrouble.SLIGHTLY_AHEAD:a<.7*b?a<.5*b?a<.3*b&&1E3>a?TimeTrouble.LOSING_ON_TIME:TimeTrouble.CLEARLY_BEHIND:TimeTrouble.BEHIND:TimeTrouble.SLIGHTLY_BEHIND}return 0}static getTimeString(a,b,c){0>a&&(a=new Date(0));var d="";b&&(d=a.getUTCHours()+":");1E4>a.valueOf()&&!c?(b=a.getUTCSeconds(),
3737a=Math.floor(a.getUTCMilliseconds()/100),d=b+"."+a+"s"):(b=a.getUTCMinutes(),1==b.toString().length&&0<b&&(b="0"+b),d+=b,b=Math.floor(a.getUTCSeconds()),1==b.toString().length&&(b="0"+b),d+=":"+b);return d}flash(a){this.clockLink.flash(a)}}
3737ChessClock.prototype.continue=ChessClock.prototype.continue2;"use strict";
3738class AbstractPlayingMode{destroy(){}deleteClock(){}onTimeOverstepped(a){}onAnnotate(){this.saved=!1;return!0}onEval(){return this.onAnnotate()}onTextAnno(a,b){this.saved=!1;return!0}onInsertDiagram(){this.saved=!1;return!0}static onEval(a){this.saved=!1;return!0}onPromoteLine(){this.saved=!1;return!0}onDeletePrevious(){this.saved=!1;return!0}onCutLine(){this.saved=!1;return!0}onDeleteLine(){this.saved=!1;return!0}afterDeleteLine(){}afterPromoteLine(){}afterCutLine(){}onBeforeUnload(){}getMoveEnterType(){return MoveEnterType.OVERWRITE_MAIN}mayNavigate(){return!0}mayGotoNext(){return!0}mayGotoEnd(){return!0}mayPageDown(){return!0}mayLoadGames(){return!0}onKeyDown(a){return!1}isAnalysis(){return!1}setAnalysis(a){}engineMoveNow(){return!1}onResetGame(){}beforeGameLoad(){this.saveAndReset();
3739this.saved=!1}afterGameLoad(){}updateHeader(){}saveAndReset(){this.saveToCloud(!0);this.cntUpdates=0}onExit(){this.saveToCloud()}onEntry(){}shouldAnimatePosChange(){6;return System.V3()||!System.isNonCrossDomainIE()}saveToCloud(a){return glApp.cloudMgr&&glApp.cloudMgr.isConnected()&&!this.saved&&this.shouldSave(a)&&(6<this.kernel.game.getMoves().length||!this.kernel.game.isNormalInit())?(glApp.cloudMgr.saveGameToClipboard(this.kernel.game),this.saved=!0):!1}shouldSave(){return!0}updateGamePos(){}onGameMove(){}onGameNavigate(){}onClickInNotation(){}toggleAnalysis(){}onPosInput(a){}onEnteredMove(a){return!0}onAfterMoveEntry(a){}onResult(a){}updateClockFromGame(){}startClock(){}stopClock(){}getAllowedColor(){return AllowedColor.BOTH_COLORS}setLegals(a){}getMySide(){return null}setMySide(a){}userClosesBoard(){}setTimeControl(a){}setManualClock(){}setChessClock(){}resetGame(a){a.reset()}newGame(){}onPanelsReady(){}createGUIElements(a){}destroyGUIElements(a){}saveState(a){}loadState(a){}posLegalChecker(a){return a.isLegal()}reactToEnteredMove(a){return!1}blockLiveBookUpdate(a){}getFnLoadSearchResult(){return CloudPlayingModeMixin?
3740CloudPlayingModeMixin.getFnLoadSearchResult():null}}"use strict";
3741class PlayingMode extends AbstractPlayingMode{constructor(a){super();this.kernel=a;this.isAutoplay=!1}loadGame(a){this.beforeGameLoad();this.kernel.game.assign(a);this.afterGameLoad()}destroy(){this.deleteClock()}deleteClock(){this.clock=null;this.manualClock&&(this.manualClock.stop(),delete this.manualClock);this.chessClock&&(this.chessClock.stop(),delete this.chessClock)}onTimeOverstepped(a){if(this.clock)this.clock.onTimeOverstepped(a)}onEnteredMove(a){this.clock&&this.clock.stop();return!0}isAnalysis(){return!0}initThreatEngine(a){try{this.threatEngine=
3742new EngineWrapper(0,"https://pgn.chessbase.com/common/chess/engine/enginemin.js",null,this),System.isElectron()||this.threatEngine.load()}catch(b){LogException("PM:initThreatEngine",b)}}onEnginePV(a,b){}onEngineMove(a,b){}getCounterMoveTo(a,b){}getMoveEnterType(){return this.kernel.game.isLineEnd()?MoveEnterType.NEWLINE:glApp.allowMoveEntryDialog()?MoveEnterType.QUERY:this.isAnalysis()?MoveEnterType.NEWLINE:MoveEnterType.OVERWRITE_MAIN}onResult(a){if(this.clock)this.clock.onResult(a)}updateClockFromGame(){this.clock&&
3743this.clock.initFromGame(this.kernel.game)}startClock(){this.clock&&this.clock.start()}stopClock(){this.clock&&this.clock.stop()}getAllowedColor(){return AllowedColor.BOTH_COLORS}onGameNavigate(){this.updateClockFromGame()}setManualClock(a,b,c){delete this.chessClock;this.kernel.boardWin&&this.kernel.boardWin.getClockDisplay()&&(this.clock&&this.clock.stop(),this.manualClock=new ManualClock(this.kernel.boardWin.getClockDisplay()),this.manualClock.setTime(a,b,c),this.manualClock.onResult(this.kernel.game.hdr.getResult()),
3744this.clock=this.manualClock)}updateHeader(){if(this.manualClock)this.manualClock.onResult(this.kernel.game.hdr.getResult())}setChessClock(a){delete this.manualClock;this.kernel.boardWin&&this.kernel.boardWin.hasClock()&&(this.chessClock=new ChessClock(this.kernel.boardWin.getClockDisplay()),this.chessClock.setClockParams(a),a&&this.chessClock.initFromGame(this.kernel.game),this.clock=this.chessClock)}linkBoardHints(a){a.fnMarkSquaresOnButtonDown=this.getMarkedSquaresOnButtonDown.bind(this)}unlinkBoardHints(){this.kernel.boardWin&&
3745(this.kernel.boardWin.fnMarkSquaresOnButtonDown=null)}getMarkedSquaresOnButtonDown(a){return this.genLegalSquareHints(a)}getLegalSqClr(){return"hsla( 0, 0%, 50%, 0.25 )"}genLegalSquareHints(a){var b=[];
3745this.kernel.game.getCurPos().Vd().forEach(function(c){c.from==a&&b.push({sq:c.to,clr:this.getLegalSqClr()})}.bind(this));return b}goAnalysis(a){glApp.config.useAnalysisEngines&&glApp.analysisEngine&&glApp.analysisEngine.engineGo(this.kernel,a)}getTargetSquareHints(a){var b=[];if(Piece.side(this.kernel.getCurPos().board[a])!=
3746this.kernel.getCurPos().Vj())return b;glApp.analysisEngine&&(a=glApp.analysisEngine.getHintSquaresOnButtonDown(a),a.forEach(function(c){for(var d=!1,e=0;!d&&e<b.length;e++)b[e].sq==c.sq&&(d=!0);d||b.push(c)}),0==a.length&&!glApp.analysisEngine.running||4>glApp.analysisEngine.getMultiPV())&&(glApp.analysisEngine.engineStop(),this.goAnalysis(128));return b}onAnalysisStrongMove(a){}setIsAutoplay(a){this.isAutoplay=a}showDiagramHelp(a){a=DiagramAnimationController.parseDiagramHelp(a);this.kernel&&this.kernel.boardWin&&
3747(a.text&&this.kernel.boardWin.addBubble(a.text,a.sq,400,a.icon),a.attrs&&this.boardWin&&this.kernel.boardWin.addAttributes(a.attrs))}}const ResultFlags={NONE:0,TECHNICAL:2,MY_TIME:4,RESIGN:8,OPP_RESIGN:16,SERVER:32,FROM_OPPONENT:64};"use strict";
3748class EngineHostMode extends PlayingMode{constructor(a,b,c){super(a);this.szPool=b||0;this.engines=[];this.nEngines=0;this.panEng=null;this.panelMgr=c??glApp?.panelMgr;this.liveBookTimer=new Timer(this.liveBookTimeout.bind(this))}loadEngineInstance(a,b,c){a=new EngineInstance(a,this.szPool,b,c);if("undefined"==typeof RemoteEngineWrapper)return a;b=new RemoteEngineWrapper({url:"https://remoteengine.chessbase.com/engine"});return new DuoEngineWrapper(a,b)}changeEngineLines(a){var b=this.engines[0];
3749if(b){var c=b.getMultiPV();c=Math.max(c+a,1);this.nMultiVars=c=Math.min(c,64);this.stopAll();b.setMultiPV(c);this.goAll({analysis:!0,infinite:!0})}}toggleThreat(){}toggleAnalysisThreat(){}loadEngine(a,b){this.nEngines<a+1&&(this.nEngines=a+1);b=b||a;if(this.panelMgr.openEnginePanel){var c=this.panEng=this.panelMgr.openEnginePanel(b);c&&!this.engines[a]&&(a=this.engines[a]=this.loadEngineInstance(glApp.config.getEngineUrl()[b],b),c.setEngine(a),c.setAnalysis&&c.setAnalysis(this.isAnalysis()),this.addOn
3749BestMove(a),
3750a.setTag(b))}}isEngineLoaded(a){return!!this.engines[a]}unloadEngine(a){this.engines[a]&&(this.engines[a].exit(),delete this.engines[a])}onBestMove(a,b){this.kernel.game.getCurPos().isLegalMove(b.move)&&this.kernel.execEngineMove(b.move)}addOnBestMove(a){this.idOnBestMove||(this.idOnBestMove=a.addOnBestMoveListener(this.onBestMove.bind(this)))}removeOnBestMove(a){a.removeOnBestMoveListener(this.idOnBestMove);this.idOnBestMove=null}destroy(){this.stopAll();this.engines.forEach(function(a){a&&a.dispose()})}goAll(a){this.engines.forEach(function(b){b&&
3751b.go(this.kernel.game,a)}.bind(this))}stopAll(){this.engines.forEach(function(a){a&&a.stop()})}restart(){this.kernel.game.gotoFirst()}newGame(){this.stopAll();this.engines.forEach(function(a){a&&a.newGame(this.getHandicap())}.bind(this))}setEngineOff(){this.stopAll()}toggleHandicap(){this.setHandicap(!this.isHandicap())}setHandicap(a){}isHandicap(){return!1}getHandicap(){return 0}saveState(a){}loadState(a){}onAnno(a,b){}initAnalysisEngine(a){if(!glApp.analysisEngine&&"undefined"!==typeof glApp&&System.browserIsSafeForEngine()&&
3752glApp.config.useAnalysisEngines)return glApp.analysisEngine=new AnalysisEngine(a||{minDepthForFire:5}),!0}checkLiveBook(){if(this.shouldAccessLiveBook())this.updatePos&&this.updatePos.equals(this.kernel.game.getCurPos())&&!this.kernel.forceTBUpdate||(this.updatePos=ObjUtil.clone(this.kernel.game.getCurPos()),glApp.aTBLobby.requestAllMoves(this.kernel.game.getCurPos(),!1,!1,this.kernel.ticket),this.idLBListener||(this.idLBListener=glApp.aTBLobby.addOnLiveBookListener(this.liveBookListener.bind(this))),
3753this.idTBListener||(this.idTBListener=glApp.aTBLobby.addOnTBDataListener(this.tbDataListener.bind(this))),this.liveBookTimer.runOnce(5E3),this.kernel.forceTBUpdate=!1);else{var a=this.isOnTrainingMove();glApp.aTBLobby.fireOnLiveBookDisplay({ticket:this.kernel.ticket,moves:[],training:a})}}liveBookTimeout(){this.panelMgr.tbBook&&this.panelMgr.tbBook.setEmptyText(lm.FRESH_POSITION);this.nBookTimeouts++}liveBookListener(a){glApp.aTBLobby.fireOnLiveBookDisplay(a);this.liveBookTimer.stop();this.nBookTimeouts=
37540}shouldAccessLiveBook(){if(!this.blockLiveBook){var a=this.kernel.getCurPos();if(8<a.getPieces().length&&16>a.getPieces().length)return!1;if(glApp.aTBLobby&&glApp.aTBLobby.isLoggedIn()&&6>this.nBookTimeouts&&(60>this.kernel.game.getMoveNo()||8>=a.getPieces().length||2600<this.kernel.game.hdr.getMaxElo()))return!this.isOnTrainingMove()}}isOnTrainingMove(){if(this.kernel.game){var a=this.kernel.game.getAnno(AnnoType.TRAINING);a&&console.log("Anno: "+a);return a}}}"use strict";
3755class MiniPlayMode extends PlayingMode{static CBDefaultOptions={engineName:"Fritz"};static WAIT_FOR_BEST_TIMEOUT=300;static gateUpdate=new V10;static legalSqClr=new CBHSLColor(100,60,45,.7);constructor(a,b,c,d){super(a);c=c||{};this.nPlugin=d;this.options=ObjUtil.copyTo(MiniPlayMode.CBDefaultOptions,c,!0);this.kernel=a;this.engineSide=null;this.engineAnswers=!0;this.engineTimeouter=new Timer;this.clickHintTimer=new Timer;this.animTimer=new Timer;this.engUrl="https://pgn.chessbase.com/common/chess/engine/enginemin.js";
3756this.engine=[];this.engine[0]=new EngineWrapper(0,this.engUrl,null,this);this.engine[0].load();this.parseThinkTime(b.play||"700");this.suppressTechnicalResult=!0;this.hintMove=this.eval=null;this.saved=!1;this.clearBoardMsgTimer=new Timer(this.clearBoardMsg.bind(this));this.execEngineMoveTimer=new Timer;this.dataset=b;this.parseDataSet(b);this.engineStartTick=new Tick;this.hintCnt=0}destroy(){super.destroy();this.unlinkButtonDownHints();this.clickHintTimer&&this.clickHintTimer.stop();glApp.analysisEngine&&
3757(glApp.analysisEngine.engineStop(),glApp.analysisEngine.unlinkPlayingMode(this))}onEnginePV(a,b){b&&(this.eval=b.eval,this.engineSide===Side.BLACK&&(this.eval=-this.eval),b.pv&&2<=b.pv.moves.length&&(this.hintMove=new Move,this.hintMove.fromJSON(b.pv.moves[1])));this.options.idDOMEngOut&&b.pv.moves.length&&(a=new Move,a.fromJSON(b.pv.moves[0]),a=(new NotationGenerator).getNota(a,this.kernel),$("#"+this.options.idDOMEngOut).text(a+" / "+b.maxDepth))}onEngineMove(a,b){a=Math.max(0,1E3-this.engineStartTick.getExpiredMS());
3758this.execEngineMoveTimer.runOnce(a,function(){this.execEngineMove(b)}.bind(this))}execEngineMove(a){var b=new Move;b.fromJSON(a.move);this.kernel.game.getCurPos().isLegalMove(b)&&(this.kernel.execEngineMove(b),glApp.analysisEngine&&glApp.analysisEngine.engineGo(this.kernel),this.eval=a.eval,this.engineSide===Side.BLACK&&(this.eval=-this.eval),this.checkEvalGoal())}getMoveEnterType(){return MoveEnterType.OVERWRITE}onEntry(){}createGUIElements(a){this.boardWin=a;super.createGUIElements(a);this.kernel.onTechnicalGameEnd=
3759this.onTechnicalGameEnd.bind(this);glApp.analysisEngine?glApp.analysisEngine.linkPlayingMode(this):this.linkButtonDownHints();this.dataset.solved&&this.addCheckMark();this.dataset.level&&this.addLevelMark(this.dataset.level);this.hasClickGoal()&&(this.boardWin.clickHandler=this.boardSquareClickHandler.bind(this))}boardSquareClickHandler(a){for(var b=0;b<this.goals.length;b++){var c=this.goals[b];if(c.isClickGoal()){var d=c.checkClick(a);if(null!=this.onGoalMetResult(c,d))break}}}linkButtonDownHints(){this.clickHintTimer||
3760(this.clickHintTimer=new Timer);this.kernel.boardWin.fnMarkSquaresOnButtonDown=this.getMarkedSquaresOnButtonDown.bind(this);this.startClickHintTimer&&(this.kernel.boardWin.fnSquareClick=this.startClickHintTimer.bind(this));this.kernel.boardWin.fnSquareChangeInMouseMove=function(){this.clickHintTimer.stop()}.bind(this);this.kernel.boardWin.fnSquareRelease=function(){this.clickHintTimer.stop()}.bind(this)}unlinkButtonDownHints(){this.kernel.boardWin.fnSquareClick=null;this.kernel.boardWin.fnMarkSquaresOnButtonDown=
3761null}destroyGUIElements(a){super.destroyGUIElements(a)}
3761restart(){this.goals&&this.goals.forEach(function(b){b.isClickGoal&&b.sqsVisited&&this.removeVisitedSquareMarks(b.sqsVisited)}.bind(this));var a=this.dataset.moves;a?(new Position,this.kernel.game.assign(PGN.parseGame(a)),this.kernel.game.gotoLast()):this.kernel.game.gotoFirst();this.hintMove=this.eval=null;this.kernel.boardWin.allowInput=!0;this.kernel.boardWin.destroyMessage();this.kernel.boardWin.destroySideIcon()}parseDataSet(a){this.parseGoals(a);
3762this.parseVisualizations(a);this.parsePieceSquareTables(a);this.id=a.posid||"noid"}parseGoals(a){this.goals=[];(a=a.goals)&&a.split(";").forEach(function(b){var c=b.split(":");b=new MiniPMGoal;b.command=c[0].trim();1<c.length&&(c=c[1].split("/"),c.length&&(b.params=MiniPMGoal.splitParams(c[0]),1<c.length&&(b.control=c[1]),2<c.length&&(b.msg=c[2]),3<c.length&&(b.reply=c[3])));this.goals.push(b)}.bind(this))}hasResultGoal(){var a=!1;this.goals&&this.goals.forEach(function(b){b.isResultGoal()&&(a=!0)});
3763return a}hasClickGoal(){var a=!1;this.goals&&this.goals.forEach(function(b){b.isClickGoal()&&(a=!0)});return a}checkGoals(){var a=null;if(this.goals)for(var b=0;b<this.goals.length;b++){a=this.goals[b];var c=a.isMet(this.kernel.game);a=this.onGoalMetResult(a,c);if(null!=a)break}return a}onGoalMetResult(a,b){var c=getCommonPath()+"Media/Ribbons/Reader/Check24.png",d=null;if(!a.isDone()&&b){if(!a.feedBackDone)if("string"==typeof b)this.showGoalMsg(b,1600,c),a.sqsVisited&&(a.isClickGoal()?this.addVisitedSquareMarks(a.sqsVisited):
3764this.removeVisitedSquareMarks(a.sqsVisited));else{a.countMet++;b=a.getCountNeeded();d=a.msg||"Excellent, you reached your goal!";if(0>=b||a.countMet>=b){if(this.showGoalMsg(d,4500,a.getIcon()),a.feedBackDone=!0,a.isSuccessGoal())this.onGoalReached()}else this.showGoalMsg(a.countMet.toString()+"/"+b.toString()+"...",1500,c);a.sqsVisited&&a.isClickGoal()&&this.addVisitedSquareMarks(a.sqsVisited);if(this.isStopAfterGoal=a.isStopAfterGoal())this.kernel.boardWin.allowInput=!1}d=a}return d}showGoalMsg(a,
3765b,c){a=this.replaceVariables(a);var d=a.split("$");if(1<d.length){a=d[0];var e=d[1]}this.clearBoardMsgTimer.stop();d=-1;e&&(d=e.match(/([wb][KQBRNP])/g),null!=d?(e="w"==d[0][0]?0:1,d=this.kernel.getCurPos().getPiecePos(Piece.fromString(d[0][1]),e)):d=CBSquare.fromString(e));this.boardWin.addBubble(a,d,320,c);b&&this.clearBoardMsgTimer.runOnce(b)}replaceVariables(a){return a.replace("{NMoves}",Math.floor(this.kernel.game.getMoveNo()/2+1).toString())}onGoalReached(){this.stampCheckOk();if(window.playchessUser&&
3766!this.postedSuccess){var a=this.id+"-"+this.kernel.game.getMoveNo();glApp.resultPostBack.postSolved(window.playchessUser,a,1)}this.postedSuccess||SendEvent("Goal",this.id);this.postedSuccess=!0}stampCheckOk(){this.animTimer.runOnce(300,function(){if(glApp.chessAudio)glApp.chessAudio.onWellDone();this.boardWin.destroySideIcon();this.addCheckMark()}.bind(this))}addCheckMark(){this.boardWin.addSideIcon({url:getCommonPath()+"Media/Ribbons/Reader/Check48.png",cssClass:"cbBoardCheckMark",boardFract:12})}addLevelMark(a){this.boardWin.addSideIcon({url:getCommonPath()+
3767"Media/Ribbons/Reader/LevelHard64.png",cssClass:"cbBoardCheckMark",boardFract:12})}clearBoardMsg(){this.boardWin.destroyMessage()}showDiagramHelp(a){this.kernel.boardWin&&(0<this.kernel.game.getMainLine().length||!a||this.hintCnt?(this.kernel.boardWin.clearAll(),this.markHint()):a&&(this.hintEngine||this.initHintEngine(),a=DiagramAnimationController.parseDiagramHelp(a),this.boardWin&&this.boardWin.addBubble(a.text,a.sq,400,a.icon),a.attrs&&this.boardWin&&this.boardWin.addAttributes(a.attrs),this.hintCnt++),
3768this.launchClearHints())}
3768showChoiceFeedback(a){a=DiagramAnimationController.parseChoiceFeedback(a);this.boardWin&&this.boardWin.addAttributes(a);this.launchClearHints()}launchClearHints(){this.clearHintsTimer&&this.clearHintsTimer.stop();this.clearHintsTimer=new Timer(function(){this.kernel.boardWin.clearAll()}.bind(this));this.clearHintsTimer.runOnce(4E3)}onHintMove(a){var b=Hints.genSimpleHints(this.kernel.game,a);if(this.hintCnt<b.length){if(b.length){for(var c=[],d=[],e=this.hintCnt;e<b.length&&
3769e<this.hintCnt+1;e++)switch(b[e]){case HintTypes.FROM:this.kernel.markSquare(a.from,"hsla( 220, 70%, 60%, 0.8 )");d.push(new BoardColouredSquare(a.from,"hsla( 220, 70%, 60%, 0.8 )",!0));break;case HintTypes.TO:d.push(new BoardColouredSquare(a.to,"hsla( 220, 70%, 60%, 0.8 )",!0));break;case HintTypes.PIECE:this.kernel.game.getCurPos().findSquaresOfPiece(this.kernel.game.getCurPos().board[a.from]).forEach(function(f){this.kernel.markSquare(f,"hsla( 130, 50%, 40%, 0.3 )")}.bind(this));break;case HintTypes.CAPTURE:c.push("Capture something!");
3770break;case HintTypes.CHECK:c.push("Give a check!")}c.length&&(a=c.join(", "),this.boardWin.addBubble(a,-1,320,getCommonPath()+"Media/Emojis/lightbulb.png"));d.length&&this.boardWin.addAttributes(d)}this.hintCnt++}else this.boardWin.drawArrow(a.from,a.to,"hsla( 220, 70%, 60%, 0.8 )",9,!1,[4,6]),this.hintCnt=0}parseVisualizations(a){this.visuals=[];a=a.visuals;var b;a&&a.split(";").forEach(function(c){c=c.split(":");var d={command:c[0]};1<c.length&&(d.params=c[1]);this.visuals.push(d);"threat"==d.command&&
3771(b=!0)}.bind(this));b&&this.initThreatEngine()}markVisualizations(){if(this.visuals&&this.kernel.game.getPreviousMove()){var a=[];this.visuals.forEach(function(c){switch(c.command){case "check":this.kernel.getCurPos().isCheck()&&this.visualizeCheck(a,"hsla( 240, 70%, 60%, 0.7 )");break;case "mate":this.kernel.getCurPos().isMate()&&this.visualizeMate(a,"hsla( 240, 70%, 60%, 0.7 )");break;case "opposition":this.markOpposition(a);break;case "pawnsquare":this.markPawnSquare(a);break;case "threat":this.markThreat()}}.bind(this));
3772if(a.length&&this.kernel.game){var b=this.kernel.game.getMoveBaggage()||{};b.attributes=a;this.kernel.game.setMoveBaggage(b)}}}visualizeCheck(a,b){if(this.kernel.game.getPreviousMove()){var c=this.kernel.getCurPos(),d=c.getKingsPos(c.Vj());c.getAttacksTo(d,Side.other(c.Vj())).forEach(function(e){a.push(new BoardArrow(e,d,b,8,[2,7]))})}}visualizeMate(a){var b=this.kernel.game.getPreviousMove();if(b){var c=this.kernel.getCurPos().getKingsPos(this.kernel.getCurPos().Vj());a.push(new BoardColouredSquare(c,
3773"black"));b=this.kernel.game.getPreviousMove();a.push(new BoardArrow(b.to,c,"hsla( 0, 75%, 50%, 0.8 )",8,[2,7]))}}markOpposition(a){if(ChessKnowledge.isEndgame(this.kernel.getCurPos())){var b=this.kernel.game.getPreviousMove();if(b&&(b.mvd&Piece.PIECE_MASK)==Piece.KING){var c=this.kernel.getCurPos().getKingsPos(this.kernel.getCurPos().Vj()),d=this.kernel.getCurPos().getKingsPos(Side.other(this.kernel.getCurPos().Vj()));if(c=ChessKnowledge.getOpposition(c,d))c.forEach(function(e){0==this.kernel.getCurPos().board[e]&&
3774a.push(new BoardColouredSquare(e,"hsla( 10, 85%, 60%, 0.8 )"))}.bind(this)),a.push(new BoardColouredSquare(b.to,DiagramAnimationController.translateSquareColor("green",b.to)))}}}markPawnSquare(){}markThreat(){if(!this.isStopAfterGoal){var a=ObjUtil.clone(this.kernel.getCurPos());a.isCheck()||(a.sd=Side.other(a.sd),this.threatEngine&&(this.threatEngine.sendNewPos(a),this.threatEngine.search(300)))}}initThreatEngine(){var a=this;this.threatEngine=new EngineWrapper(2,this.engUrl,null,{onEnginePV:function(b,
3775c){},onEngineMove:function(b,c){b=new Move;b.fromJSON(c.move);a.onThreatMove(b)}});this.threatEngine.load()}markHint(){if(this.hintMove)this.onHintMove(this.hintMove);else this.hintEngine||this.initHintEngine(),this.hintEngine.sendNewPos(this.kernel.getCurPos()),this.hintEngine.search(500)}initHintEngine(){var a=this;this.hintEngine=new EngineWrapper(2,this.engUrl,null,{onEnginePV:function(b,c){},onEngineMove:function(b,c){b=new Move;b.fromJSON(c.move);a.onHintMove(b)}});this.hintEngine.load()}onThreatMove(a){this.boardWin.drawArrow(a.from,
3776a.to,"hsla( 0, 80%, 50%, 0.75 )",9,!0,[5,5])}addVisitedSquareMarks(a){a.forEach(function(b){b=CBSquare.fromString(b);b=new BoardColouredSquare(b,DiagramAnimationController.translateSquareColor("blue",b),!0);this.boardWin.permanentAttributes.push(b)}.bind(this));this.boardWin.renderQueuedAttributes(!0)}removeVisitedSquareMarks(a){a.forEach(function(b){b=CBSquare.fromString(b);for(var c=0;c<this.boardWin.permanentAttributes.length;c++)this.boardWin.permanentAttributes[c].sq==b&&(this.boardWin.permanentAttributes.splice(c,
37771),c--)}.bind(this));this.boardWin.renderQueuedAttributes(!0)}
3777checkResultGoal(){this.goals&&this.goals.forEach(function(a){if(a.isResultGoal()&&a.isMet(this.kernel.game))this.onGoalMet(a)}.bind(this))}checkEvalGoal(){this.goals&&null!=this.eval&&this.goals.forEach(function(a){!a.isDone()&&a.isEvalGoal()&&a.checkForEval(this.eval)&&(a.countMet++,this.onGoalMet(a))}.bind(this))}onGoalMet(a){a.msg&&this.showGoalMsg(a.msg,0,a.getIcon());this.isStopAfterGoal=a.isStopAfterGoal();if(a.isSuccessGoal())this.onGoalReached()}parsePieceSquareTables(a){var b=
3778[];(a=a.pst)&&a.split(";").forEach(function(c){c=c.split(":");if(1<c.length){var d=c[0].match(/([wb][KQBRNP])/g);if(d&&1==d.length){var e={piece:d[0]},f=[];c[1].split(",").forEach(function(g){var h=g.match(/([a-h][1-8])=(-*[\d]+)/);if(h&&3==h.length)f.push({sq:CBSquare.fromString(h[1]),val:parseInt(h[2])});else if(g.match(/ahead/i))for(g="b"==e.piece.charAt(0),h=0;64>h;h++){var k=h&7;f.push({sq:h,val:g?100*(49-k*k):100*k*k})}});e.vals=f;b.push(e)}}});this.pieceSquareTables=b}onGameNavigate(){super.onGameNavigate();
3779this.kernel.game.setResult(GameResultEnum.UNDEFINED_RESULT);this.goals&&this.goals.forEach(function(a){a.reset()});this.engineSide=null;this.isStopAfterGoal=!1;this.kernel.boardWin.allowInput=!0;this.options.idDOMEngOut&&$("#"+this.options.idDOMEngOut).text("")}resetGame(a){glApp.hasUrlGame()?this.kernel.fnInitGame(a):a.reset()}newGame(a){super.newGame();var b=this.kernel.game;b.gotoLast();this.engineAnswers=!0;b.isNormalInit()&&0==b.getMainLine().length?this.engineSide=Side.other(this.kernel.boardWin.getSideToShow()):
3780b.isNormalInit()||0!=b.getMainLine().length?this.engineSide=null:(this.engineSide=Side.other(b.getCurPos().Vj()),this.kernel.getCurPos().isMate()||this.kernel.getCurPos().isStaleMate()||this.kernel.boardWin.setBlackIsBottom(this.engineSide==Side.WHITE));if(!System.runsInIFrame()&&a)glApp.chessAudio.onNewGame();null!=this.engineSide&&b.getCurPos().Vj()!=this.engineSide&&glApp.analysisEngine&&glApp.analysisEngine.engineGo(this.kernel);this.boardWin.redraw()}setHeaderData(){var a=this.kernel.game.getHeader(),
3781b=this.getUserName();this.engineSide==Side.WHITE?(a.setWhite(this.options.engineName),a.setBlack(b)):(a.setWhite(b),a.setBlack(this.options.engineName))}getUserName(){var a=glApp.Vn.userName;glApp.isLoggedIn()&&a||(a=lm.GUEST);return a}levelToGameHeader(){this.kernel.game.hdr.event.event=this.getLevelStr();this.kernel.game.fireOnHeaderChanged()}getLevelStr(){return"Mini Play"}getAllowedColor(){return AllowedColor.detFromOpponentSide(this.engineSide)}getMySide(){return null==this.engineSide?null:Side.other(this.engineSide)}isAnalysis(){return!1}setAnalysis(a){throw Error("Cannot set analysis on playing mode");
3782}setTimeControl(a){}engineMoveNow(){}onEnteredMove(a){this.saved=!1;this.clickHintTimer.stop();try{glApp.analysisEngine&&glApp.analysisEngine.engineStop(),this.ponderHint=null,this.kernel.game.deleteRemaining(!0),null===this.engineSide&&(this.engineSide=Side.other(this.kernel.getCurPos().Vj()),this.setHeaderData()),this.kernel.boardWin.setBlackIsBottom(this.engineSide!==Side.BLACK),super.onEnteredMove(a),this.kernel.game.hdr.setResult(GameResultEnum.LINE)!=GameResultEnum.LINE&&this.kernel.game.fireOnHeaderChanged()}catch(b){LogException("AgEng::onEntrd",
3783b)}return!0}startSearch(){this.kernel.getCurPos().isLegal()&&(null===this.engineSide&&(this.engineSide=this.kernel.getCurPos().Vj()),this.kernel.getCurPos().Vj()!=this.engineSide||this.isStopAfterGoal||(this.engineStartTick=new Tick,this.engineGo(0)))}engineGo(a){this.ponderHint=null;this.engine[a].sendNewGame(this.kernel.game,this.pieceSquareTables);this.engine[a].search(this.thinkTime,this.plyDepth)}parseThinkTime(a){this.thinkTime=1E3;var b=a.match(/(\d+)ply/);b?this.plyDepth=b[1]:a.match(/\d+/)&&
3784(this.thinkTime=parseInt(a))}checkLiveBook(){}shouldShowBusyCursor(){return!1}onGameMove(){this.clearBoardAlways&&(this.kernel.boardWin.clearBoardAttributes(),this.kernel.boardWin.clearBaggageAttributes(),glApp.panelMgr.currPluginIsAnimatedDiagram()&&this.kernel.boardWin.clearPermanentAttributes());glApp.panelMgr.onUserMove(this.nPlugin);this.execEngineMoveTimer.stop();super.onGameMove();if(this.kernel.getCurPos().isLegal()&&this.engineAnswers){if(this.clock){CBDebug.assert(this.clock,"CLOCK NOT SET");
3785this.clock.stop();var a=this.clock.createTimeAnno();this.kernel.addTimeAnno(a)}var b=this.checkGoals();this.markVisualizations();
3785if(this.kernel.game.getCurPos().hasLegals())if(a=0,b&&b.reply&&null!=(a=b.reply.match(/([a-h][1-8])([a-h][1-8])([QBRN]*)/))){b=CBSquare.fromString(a[1]);a=CBSquare.fromString(a[2]);var c=new Move(b,a);(new Timer(function(){this.execEngineMoveTimer.runOnce(1E3,function(){this.kernel.game.getCurPos().isLegalMove(c)?this.kernel.execEngineMove(c):alert("Forced Reply illegal")}.bind(this))}.bind(this))).runOnce(10)}else this.startSearch()}}onResetGame(){}updateGamePos(){this.hintCnt=
37860;this.execEngineMoveTimer.stop();MiniPlayMode.gateUpdate.exec(function(){}.bind(this),200)}onTechnicalGameEnd(a,b){if(a!=GameResultEnum.DRAW||!b||b.drawType!=DrawType.MATERIAL||this.kernel.getCurPos().isStaleMate())a=GameResultEnum.toString(a),this.hasResultGoal()?this.checkResultGoal():(this.kernel.getCurPos().isMate()?a+=" ("+lm.MATE+")":this.kernel.getCurPos().isStaleMate()&&(a+=" ("+lm.STALEMATE+"!)"),this.boardWin&&(this.boardWin.addBubble(a,-1,250),this.clearBoardMsgTimer.stop()))}onResign(){var a=
3787String.formatEx(lm.RESIGNS,"Fritz");glApp.panelMgr.showBoardMessage(a,7E3);var b=this.engineSide==Side.BLACK?GameResultEnum.WHITE_WINS:GameResultEnum.BLACK_WINS;this.kernel.addTextAnno(a);this.kernel.setResult(b)}onLosingLine(a,b){a=b.getEval()-a.getEval();300<a&&this.kernel.addSymbol(AnnoMarkType.VERY_BAD);200<a&&this.kernel.addSymbol(AnnoMarkType.BAD);100<a&&this.kernel.addSymbol(AnnoMarkType.DUBIOUS)}userResigns(){if(!GameResultEnum.isFinished(this.kernel.game.getResult())){var a=this.engineSide==
3788Side.WHITE?GameResultEnum.WHITE_WINS:GameResultEnum.BLACK_WINS;this.kernel.addTextAnno(String.formatEx(lm.RESIGNS,this.getUserName()));this.kernel.setResult(a)}}onAnalysisLine(a,b,c){}getMarkedSquaresOnButtonDown(a,b){return this.kernel.getCurPos().Vj()==this.engineSide?[]:b&&!this.clickHintTimer.isActive()?this.getTargetSquareHints(a):this.genLegalSquareHints(a)}genLegalSquareHints(a){var b=[];this.kernel.game.getCurPos().Vd().forEach(function(c){c.from==a&&b.push({sq:c.to,clr:MiniPlayMode.legalSqClr})});
3789return b}startClickHintTimer(a){this.clickHintTimer.runOnce(600,function(){var b=this.getTargetSquareHints(a);this.kernel.boardWin.markSquares(b)}.bind(this))}getTargetSquareHints(a){if(this.kernel.getCurPos().Vj()==this.engineSide)return[];var b=[];this.lbInfo&&this.lbInfo.moves.forEach(function(c){c.move.from==a&&70<c.getNGames()&&b.push({sq:c.move.to,clr:new CBHSLColor(CBHSLColor.BLUE,80,60,.8)})}.bind(this));glApp.analysisEngine&&glApp.analysisEngine.getHintSquaresOnButtonDown(a).forEach(function(c){for(var d=
3790!1,e=0;!d&&e<b.length;e++)b[e].sq==c.sq&&(d=!0);d||b.push(c)});return b}}
3791class MiniPMGoal{constructor(){this.control="stop";this.reset()}reset(){this.countMet=0;this.feedBackDone=!1;this.sqsVisited=[]}isDone(){var a=this.getCountNeeded();return 0<a?this.countMet>=a:0<this.countMet}isMet(a,b){switch(this.command){default:return!1;case "piece":return this.checkPiece(a);case "move":return this.checkMove(a);case "firstmove":return this.checkFirstMove(a);case "journey":return this.checkJourney(a);case "mate":return this.checkForMate(a);case "stalemate":return this.checkForStaleMate(a);
3792case "threefold":return this.checkForThreefold(a);case "check":return this.checkForCheck(a);case "notcheck":return this.checkForNotCheck(a);case "result":return this.checkForResult(a);case "countmoves":return this.checkCountMoves(a)}}isMateGoal(){return"mate"==this.command}isCheckGoal(){return"check"==this.command}isResultGoal(){return"result"==this.command||"mate"==this.command||"stalemate"==this.command}isClickGoal(){return"click"==this.command}checkClick(a){var b=this.params[0].match(/[a-h?][1-8?](,[a-h?][1-8?])*/);
3793if(b&&b.length){b=b[0].split(",");for(var c=0;c<b.length;c++){var d=b[c];if(d.match(/\?/)){var e=-1,f=-1;"?"!=d.charAt(0)&&(e=CBSquare.colFromString(d.substr(0,1)));"?"!=d.charAt(1)&&(f=CBSquare.rowFromString(d.substr(1,1)));if(!(-1!=e&&CBSquare.getFile(a)!=e||-1!=f&&CBSquare.getRank(a)!=f||-1!=this.sqsVisited.indexOf(CBSquare.toString(a)))){this.sqsVisited.push(CBSquare.toString(a));var g=this.sqsVisited.length<b.length?this.sqsVisited.length.toString()+"/"+b.length.toString():!0;break}}else if(CBSquare.fromString(d)==
3794a&&-1==this.sqsVisited.indexOf(d)){this.sqsVisited.push(d);g=this.sqsVisited.length<b.length?this.sqsVisited.length.toString()+"/"+b.length.toString():!0;break}}}return g}isEvalGoal(){return"eval"==this.command}isSuccessGoal(){return this.control.match(/success/i)||this.control.match(/count/i)}getCountNeeded(){var a=this.control.match(/count=([0-9])+/i);return a&&a.length?parseInt(a[1]):-1}getIcon(){var a=this.control.match(/-([a-z0-9]+)/i);if(a&&1<a.length)return getCommonPath()+"Media/Emojis/"+
3795a[1]+".png"}
3795isStopAfterGoal(){if(this.control.match(/go/i))return!1;if(this.control.match(/stop/i)||this.control.match(/success/i))return!0;var a=this.getCountNeeded();if(0<a)return this.countMet>=a}checkPiece(a){if(this.params){var b=this.params[0];if(b.match(/[wb][KQBRNP?]/g)){var c=" KQNBRP?".split("").indexOf(this.params[0].charAt(1));if(1<=c){"b"==b.charAt(0)&&(c|=Piece.SIDE_MASK);var d=b.match(/[a-h?][1-8?]/g);if(d&&1==d.length&&"b?"!=d[0]){var e=b.substr(2,2);d=CBSquare.fromString(e);if(e.match(/\?/))for(b=
3796d=-1,"?"!=e.charAt(0)&&(d=CBSquare.colFromString(e.substr(0,1))),"?"!=e.charAt(1)&&(b=CBSquare.rowFromString(e.substr(1,1))),e=0;64>e;e++){if(-1==d||CBSquare.getFile(e)==d)if(-1==b||CBSquare.getRank(e)==b){var f=a.getCurPos().board[e];if(f==c||this.isJokerPieceOk(c,f))return!0}}else return a.getCurPos().board[d]==c}else if(d=b.match(/(x|!x)([KQNBRP])/))if(b=Piece.fromString(d[2].charAt(0)),a=a.getLastMove(),"x"==d[1]&&(a.vct&Piece.PIECE_MASK)==b&&(a.mvd==c||this.isJokerPieceOk(c,a.mvd))||"!x"==d[1]&&
3797(a.vct&Piece.PIECE_MASK)!=b&&(a.mvd==c||this.isJokerPieceOk(c,a.mvd)))return!0}}}}isJokerPieceOk(a,b){return(a&Piece.PIECE_MASK)==Piece.JOKER&&(b&Piece.SIDE_MASK)==(a&Piece.SIDE_MASK)}checkJourney(a){var b,c=this.params[0];if(c.match(/[wb][KQBRNP]/g)){var d=" KQNBRP".split("").indexOf(this.params[0].charAt(1));if(1<=d){"b"==c.charAt(0)&&(d|=Piece.SIDE_MASK);var e=a.getLastMove();if(e&&a.getCurPos().board[e.to]!=d)return;if((c=c.match(/[a-h?][1-8?](,[a-h?][1-8?])*/))&&c.length)for(c=c[0].split(","),
3798e=0;e<c.length;e++){var f=c[e];if(f.match(/\?/)){var g=-1,h=-1;"?"!=f.charAt(0)&&(g=CBSquare.colFromString(f.substr(0,1)));"?"!=f.charAt(1)&&(h=CBSquare.rowFromString(f.substr(1,1)));for(f=0;64>f;f++)if(!(-1!=g&&CBSquare.getFile(f)!=g||-1!=h&&CBSquare.getRank(f)!=h||a.getCurPos().board[f]!=d||-1!=this.sqsVisited.indexOf(CBSquare.toString(f))))return this.sqsVisited.push(CBSquare.toString(f)),b=this.sqsVisited.length<c.length?this.sqsVisited.length.toString()+"/"+c.length.toString():!0}else if(g=CBSquare.fromString(f),
3799a.getCurPos().board[g]==d&&-1==this.sqsVisited.indexOf(f)){this.sqsVisited.push(f);b=this.sqsVisited.length<c.length?this.sqsVisited.length.toString()+"/"+c.length.toString():!0;break}}}}return b}checkFirstMove(a){return 1==a.getMainLine().length&&this.checkMove(a)}checkMove(a){if(this.params){var b=this.params[0];if(b.match(/[wb][KQBRNP]/g)){var c=" KQNBRP".split("").indexOf(this.params[0].charAt(1));if(1<=c&&("b"==b.charAt(0)&&(c|=Piece.SIDE_MASK),(b=b.match(/([a-h][1-8])[-]?([a-h][1-8])/))&&3==
3800b.length)){var d=a.getPreviousMove();if(d&&d.from==CBSquare.fromString(b[1])&&d.to==CBSquare.fromString(b[2])&&a.getCurPos().board[d.to]==c)return!0}}}}checkForMate(a){var b=this.params[0];if(b.match(/[wb]/)&&a.getCurPos().isMate()&&("w"==b.charAt(0)&&!a.getCurPos().getBTM()||"b"==b.charAt(0)&&a.getCurPos().getBTM()))return!0}checkForStaleMate(a){var b=this.params[0];if(b.match(/[wb]/)&&a.getCurPos().isStaleMate()&&("w"==b.charAt(0)&&!a.getCurPos().getBTM()||"b"==b.charAt(0)&&a.getCurPos().getBTM()))return!0}checkForThreefold(a){return(new DrawChecker).checkGame(a)==
3801DrawType.THREE_TIMES}checkForCheck(a){if(a.getCurPos().isCheck())return!0}checkForNotCheck(a){if(!a.getCurPos().isCheck())return!0}checkForResult(a){switch(this.params[0]){case "1":case "draw":if(GameKernel.staticCheckTechnicalResult(a,{})==GameResultEnum.DRAW)return!0}return!1}checkCountMoves(a){var b=parseInt(this.params[0]);if(b)return a.getMainLine().length>=2*b}checkForEval(a){if(null!=a)switch(this.params[0]){case "draw":case "equal":case "1":return 60>Math.abs(a);
3801case "whitewins":case "win":case "2":return 200<
3802a;case "blackwins":case "loss":case "0":return-200>a;case "blackbetter":return-70>a;case "whitebetter":return 70<a;case "equalorwhitebetter":return-50<a;case "equalorblackbetter":return 50>a;case "whitemates":return 1E5<a;case "blackmates":return-1E5>a;case "whitenotmate":return-1E5<a;case "blacknotmate":return 1E5>a}}static splitParams(a){var b=[],c=a.match(/\[([\S]+)\]/);c&&0<c.length?(b.push(a.substr(0,c.index)+c[0]),a=a.substr(c.index+c[0].length),a.split(",").forEach(function(d){d&&b.push(d)})):
3803b=a.split(",");return b}}
3804const SimpleEngineModeMixin=function(){return{toggleEngine:function(a){if(this.isEngineLoaded(0))return this.unloadEngine(0),!1;this.loadEngine(0,a);this.updateGamePos();return!0},startEngine:function(a){if(!this.isEngineLoaded(0))return this.loadEngine(0,a),this.updateGamePos(),!0},stopEngine:function(){this.unloadEngine(0);glApp.analysisEngine&&this.useAnalysisAsEngine&&glApp.analysisEngine.engineStop()},incNMultiVars:function(a){this.nMultiVars+=a;1>this.nMultiVars&&(this.nMultiVars=1);64<this.nMultiVars&&
3805(this.nMultiVars=64)},goAll:function(){let a=this.isInThreat=!1;this.engines&&this.engines.forEach(function(b){b.setMultiPV(this.nMultiVars);b&&(b.go(this.kernel.game,{infinite:!0}),b.fireOnThreat(!1),a=!0)}.bind(this));this.engines&&0!=this.engines.length||!glApp.analysisEngine||!this.useAnalysisAsEngine||(this.goAnalysis(glApp.analysisEngine.nFixedVars||1),a=!0);return a},toggleThreat:function(){if(this.isInThreat)this.goAll();else{var a=ObjUtil.clone(this.kernel.game.cur);if(a.swapSide()){this.isInThreat=
3806!0;var b=new Game(a);this.engines&&this.engines.forEach(function(c){c.setMultiPV(this.nMultiVars);c&&(c.go(b,{infinite:!0}),c.fireOnThreat(!0))}.bind(this))}}},toggleAnalysisThreat:function(){if(glApp.analysisEngine)if(this.isInThreat)glApp.analysisEngine.engineGo(this.kernel),glApp.analysisEngine.engine.fireOnThreat(!1);else{var a=ObjUtil.clone(this.kernel.game.cur);a.swapSide()&&(this.isInThreat=!0,a=new Game(a),glApp.analysisEngine.engine.setMultiPV(1),glApp.analysisEngine.engine.go(a,{infinite:!0}),
3807glApp.analysisEngine.engine.fireOnThreat(!0))}}}}(),HintsMixin=function(){return{resetHints:function(){this.hints=[];this.lastHintTypeFired=HintTypes.NONE;this.hintMove=null},genHints:function(a,b,c,d,e,f){this.resetHints();this.hintEvals=[b,d];this.hintLine=MoveLine.contextToLine(this.kernel.game.getCurPos(),c.line);this.hintMove=this.hintLine[0];Hints.genAsync(this.kernel.game,this.hintMove,this.hintLine,b,!e,this.onHintsReady.bind(this),1E3,a)},getNextHintIndex:function(a,b){for(let c=0;c<a.length;c++)if(a[c].type==
3808b&&c<a.length-1)return c+1;return a.length?0:-1},hintsHaveChanged:function(a){if(a.length!=this.hints.length)return!0;for(let b=0;b<a.length;b++)if(!this.hints[b].equals(a[b]))return!0},stopHints:function(){this.stopAll();this.calcHints=!1},toggleHints:function(){this.stopAll();(this.calcHints=!this.calcHints)?(this.kernel.boardWin.undoAttributes(),this.initAnalysisEngine()&&glApp.analysisEngine.linkPlayingMode(this),this.goAnalysis()):this.goAll();return this.calcHints},showNextGeneratedHint:function(){if(this.hints&&
3809this.hints.length&&this.hintMove){let a=this.getNextHintIndex(this.hints,this.lastHintTypeFired);0<=a&&this.fireHints({hints:this.hints,index:a,hintMove:this.hintMove,hintMeter:this.hintMeter,pos:this.kernel.getCurPos(),force:!0});return!0}},onHintsReady:function(a,b,c,d){if(this.hintsHaveChanged(a)&&this.hintMove){this.hints=a;this.lastHintTypeFired=HintTypes.NONE;LOG("Hints:  "+this.hintLine,"LogBold");for(let e=0;e<a.length;e++)Hints.displayHint(b,this.kernel.getCurPos(),a[e],null,function(f){LOG(f,
3810"LogBold")}.bind(this));this.fireHints({hints:this.hints,index:0,hintMove:b,pos:this.kernel.getCurPos(),hintMeter:this.hintMeter,book:d,depth:c})}},onCreateGUIElements:function(){this.idNextHint=glApp.panelMgr.addOnNextHintListener(this.engineGiveHint.bind(this))},onDestroy:function(){glApp.panelMgr.removeOnNextHintListener(this.idNextHint)}}}();"use strict";
3811class AnalysisMode extends EngineHostMode{static POOL_SIZE=0;constructor(a,b,c){super(a,AnalysisMode.POOL_SIZE);this.kernel=a;this.maxEngine=b||1;this.currEngine=0;this.active=!0;this.posInfoTimer=new Timer(this.posInfoTimerHdl.bind(this));this.initAnalysisEngine();this.nMultiVars=1;this.clickHintTimeout=c?c.hintTimeout||500:500;
3811this.fnCheckLiveBook=c&&c.liveBookSilent?this.checkLiveBook.bind(this):this.checkLiveBookWithPanel.bind(this);this.nBookTimeouts=0;this.hintMeter=null;this.calcHints=!1;this.gateUpdate=
3812new V10;this.pendingMoveNow=!1;c&&(this.useAnalysisAsEngine=c.useAnalysisAsEngine)}destroy(){glApp.analysisEngine&&(glApp.analysisEngine.engineStop(),glApp.analysisEngine.unlinkPlayingMode(this));super.destroy();glApp.commands.fireChecked(CommandIds.TOGGLE_ANALYSIS_ENGINE,!1);this.onDestroy()}onPanelsReady(){for(var a=0;a<this.maxEngine;a++)this.loadEngine(a);glApp.commands.fireChecked(CommandIds.TOGGLE_ANALYSIS_ENGINE,!0);this.panEng&&(this.idOnEngMove=this.panEng.addOnMoveEnteredListener(this.kernel.reactToEnteredMove.bind(this.kernel)))}createGUIElements(a){super.createGUIElements(a);
3813a.shouldAnimatePosChange=this.shouldAnimatePosChange.bind(this);System.isMobile()&&(a.animSteps={forMove:.3,forPosition:.2});glApp.analysisEngine&&glApp.analysisEngine.linkPlayingMode(this);this.onCreateGUIElements()}onResetGame(){this.nBookTimeouts=0}onEnteredMove(a){return this.fnAcceptMove?this.fnAcceptMove(a):!0}onExit(){super.onExit();glApp.analysisEngine&&(glApp.analysisEngine.engineStop(),glApp.analysisEngine.clearLines())}onAfterMoveEntry(a){if(this.fnAfterMove)return this.fnAfterMove(a)}setEngineOff(){this.active=
3814!1;super.setEngineOff()}isAnalysis(){return!0}setAnalysis(a){this.active=a;glApp.commands.fireChecked(CommandIds.TOGGLE_ANALYSIS_ENGINE,a);for(var b=0;b<this.nEngines;++b)a||void 0===this.engines[b]||this.engines[b].abort();a&&this.updateGamePos()}setTimeControl(a){throw Error("Cannot set search time on analysis playing mode");}toggleAnalysis(){this.setAnalysis(!0);for(var a=0;a<this.maxEngine;++a)this.loadEngine(a);this.updateGamePos()}engineMoveNow(){}engineStop(){glApp.analysisEngine&&(glApp.analysisEngine.engineStop(),
3815glApp.analysisEngine.clearLines());this.stopAll()}static ENGINE_DELAY=100;static gateEngine=new V10;updateGamePos(a){var b=glApp.panelMgr.getKernel();if(this.kernel==b||null==b)this.engineStop(),this.isAutoplay||(AnalysisMode.gateEngine.exec(function(){this.active&&this.kernel.game.getCurPos().hasLegals()&&this.kernel.game.getCurPos().isLegal()&&(this.calcHints?this.goAnalysis(2):this.goAll({analysis:!0,infinite:!0}),this.calcStaticEval())}.bind(this),AnalysisMode.ENGINE_DELAY),this.gateUpdate.exec(function(){this.fnCheckLiveBook()}.bind(this),
3816a?10:400))}calcStaticEval(){if("undefined"!=typeof Evaluation){let a=(new PositionEvaluation(this.kernel.getCurPos())).evaluate();glApp.analysisEngine?glApp.analysisEngine.fireOnStaticEval(a):0<this.engines.length&&this.engines[0]&&this.engines[0].fireOnStaticEval(a)}}testEval(){}checkLiveBookWithPanel(){!glApp.aTBLobby||!glApp.aTBLobby.isLoggedIn()||this.updatePos&&this.updatePos.equals(this.kernel.game.getCurPos())&&!this.kernel.forceTBUpdate||(this.updatePos=ObjUtil.clone(this.kernel.game.getCurPos()),
3817glApp.panelMgr.tbBook&&(glApp.panelMgr.tbBook.clear("Requesting moves..."),glApp.panelMgr.tbBook.isVisible()&&glApp.aTBLobby.requestAllMoves(this.kernel.game.getCurPos(),!1,!1,this.kernel.ticket),this.idLBListener||(this.idLBListener=glApp.aTBLobby.addOnLiveBookListener(this.liveBookListener.bind(this))),this.idTBListener||(this.idTBListener=glApp.aTBLobby.addOnTBDataListener(this.tbDataListener.bind(this))),this.liveBookTimer.runOnce(5E3),glApp.aTBLobby.requestPosInfo(this.kernel.game.getCurPos()),
3818this.posInfoTimer.isActive||this.posInfoTimer.runOnce(15E3)),this.kernel.forceTBUpdate=!1)}tbDataListener(){}posInfoTimerHdl(){glApp.aTBLobby&&glApp.aTBLobby.hasIdReceived&&glApp.panelMgr.tbBook&&glApp.aTBLobby.requestPosInfo(this.kernel.game.getCurPos())}_engAnalysisTimeoutHdl(){this.active&&this.kernel.game.getCurPos().hasLegals()&&this.goAll()}getMoveEnterType(){return this.fnGetMoveEnterType?this.fnGetMoveEnterType():MoveEnterType.NEWLINE}getCounterMoveTo(a,b){if(glApp.analysisEngine)return glApp.analysisEngine.getCounterMoveTo(a,
3819b)}getMarkedSquaresOnButtonDown(a,b){if(!b||this.clickHintTimer&&this.clickHintTimer.isActive())return this.genLegalSquareHints(a);glApp.analysisEngine||this.initAnalysisEngine();return this.getTargetSquareHints(a)}afterDeleteLine(){if(this.session)this.session.onDeleteLine()}afterPromoteLine(){if(this.session)this.session.onPromoteLine()}afterCutLine(){if(this.session)this.session.onCutLine()}onGameNavigate(){super.onGameNavigate();if(this.session)this.session.onGameNavigate()}startClickHintTimer(a){this.kernel.game.getMoveOffs()<
3820this.startMoveNo||(this.clickHintTimer||(this.clickHintTimer=new Timer),this.clickHintTimer.runOnce(this.clickHintTimeout,function(){var b=this.getTargetSquareHints(a);this.kernel.boardWin.markSquares(b)}.bind(this)))}getLegalSqClr(){return"hsla( 0, 0%, 55%, 0.50 )"}onBestMove(a,b){}onAnalysisLine(a,b,c,d,e){if(this.kernel==glApp.panelMgr.getKernel()){if(!this.kernel.game.hasTBEval&&!glApp.isInOfficialRoom){var f=b;this.kernel.getCurPos().getBTM()&&(f=-f);this.kernel.game.fireOnEval(a,f,c)}(6<=a||
38212E4<b)&&this.calcHints&&this.genHints(a,b,c,d,e)}}onAnalysisStrongMove(a){}fireHints(a){a.moveNo=this.kernel.getMoveNo();if(glApp.panelMgr.displayHints){let b=glApp.panelMgr.displayHints(a);b&&b.forEach(function(c){c.displayed&&(this.lastHintTypeFired=a.hints[a.index].type)}.bind(this))}}engineGiveHint(){this.kernel.boardWin.undoAttributes();this.showNextGeneratedHint()}toggleEngine(a){if(this.isEngineLoaded(0))return this.unloadEngine(0),!1;this.loadEngine(0,a);this.updateGamePos();return!0}onAnno(a,
3822b){if(this.session)this.session.onAnnoEntered(a,b)}}SimpleEngineModeMixin&&mixin(AnalysisMode,SimpleEngineModeMixin);HintsMixin&&mixin(AnalysisMode,HintsMixin);
3823const AnnoType={POSTTEXT:2,SYMBOL:3,SQUARE_LIST:4,ARROW_LIST:5,DIAGRAM:6,TIME:7,DATE:8,TRAINING:9,JSON:10,JSONARRAY:11,BIGMAX:16,AUDIO:16,PICTURE:17,VIDEO:18,GAME_QUOTATION:19,PAWN_STRUCT:20,PIECE_PATH:21,MIDDLEGAME_CLASS:22,ENDGAME_CLASS:23,CRITICAL_POS:24,CORR:25,STREAM:26,CHESS_VARIANT:27,MAX:32,CAPTION:32,FRITZ_EVAL:33,MOVE_MEDAL:34,COLOR:35,TIME_CONTROL:36,SYNC:37,EVAL_PROFILE:38,AT_PDF_FILE:39,AUDIO_STREAM:40,MULTIPLE_CHOICE:41,GENERIC:127,ANNO_BITS:127,PRE_BIT:128,toString:function(a){for(var b in this)if(this[b]==
3824a)return"AnnoType: "+b;return"Unknown AnnoType: "+a}},AnnoMarkType={NONE:0,GOOD:1,BAD:2,VERY_GOOD:3,VERY_BAD:4,INTERESTING:5,DUBIOUS:6,ONLY_MOVE:8,ZUGZWANG:22,MYMOVE:165,IMPORTANT:166,WHITE:167,BLACK:168,BOTH:169},AnnoEvalType={NONE:0,EQUAL:11,UNCLEAR:13,BLACK_SLIGHTLY_BETTER:15,BLACK_BETTER:17,BLACK_WINS:19,WHITE_WINS:18,WHITE_BETTER:16,WHITE_SLIGHTLY_BETTER:14,COMPENSATION:44,COUNTERPLAY:132,INITIATIVE:36,ATTACK:40,ZEITNOT:138,DEVELOPMENT:32,NOVELTY:146},TextType={TT_ANSI:0,TT_RTF:1,TT_HTML:2,TT_TOKEN:3,
3825TT_JSON:4};AnnoType.PRETEXT=AnnoType.PRE_BIT|AnnoType.POSTTEXT;AnnoType.PRE_SQUARE_LIST=AnnoType.PRE_BIT|AnnoType.SQUARE_LIST;AnnoType.PRE_ARROW_LIST=AnnoType.PRE_BIT|AnnoType.ARROW_LIST;const Medal={BESTGAME:1,TOURN_DECISIVE:2,SAMPLE_OPENING:4,IMPORTANT_NOVELTY:8,PAWNSTRUCTURE:16,STRATEGY:32,TACTICS:64,ATTACK:128,DEFENSE:256,SACRIFICE:512,MATERIAL:1024,PIECEPLAY:2048,ENDGAME:4096,TACTICAL_BLUNDER:8192,STRATEGICAL_BLUNDER:16384,USER:32768};
3826var AnnoFactory={factory:function(a){return a in this?new this[a]:null}};class AnnoRec{static readHeader(a){return{inxMv:a.readBEInt24(),type:a.readByte(),len:a.readBEInt16()}}static writeHeader(a,b,c,d){a.writeBEInt24(b);a.writeByte(c);a.writeBEInt16(d)}static ANNO_HEAD_SIZE=6;}
3827class TextAnno{constructor(a,b){this.textType=b||TextType.TT_ANSI;this.m_str=a?a:""}getString(){return this.m_str}setString(a){this.m_str=a}toString(){return this.m_str}addText(a){this.m_str+=a}getType(){return this.textType}isType(a){return this.textType===a}write(a,b){var c=AnnoRec.ANNO_HEAD_SIZE+2+this.m_str.length;a.Vv(c);AnnoRec.writeHeader(a,0,b,c);a.writeByte(this.textType||TextType.TT_ANSI);a.writeByte(0);a.writeSizedString(this.m_str)}read(a,b){this.textType=b.readByte();b.readByte();this.m_str=
3828b.readSizedString(a-2);StrUtil.mayBeUtf8(this.m_str)&&(this.m_str=StrUtil.decodeUTF8(this.m_str))}}AnnoFactory[AnnoType.POSTTEXT]=TextAnno;AnnoFactory[AnnoType.PRETEXT]=TextAnno;
3829class JsonAnno{constructor(a){this.obj=a}getObject(){return this.obj}setObject(a){this.obj=a}toString(){return JSON.stringify(this.obj)}write(a){var b=JSON.stringify(this.obj),c=AnnoRec.ANNO_HEAD_SIZE+b.length;a.Vv(c);AnnoRec.writeHeader(a,0,AnnoType.JSON,c);a.writeSizedString(b)}read(a,b){a=b.readSizedString(a);a=JSON.parse(a);this.setObject(a)}}AnnoFactory[AnnoType.JSON]=JsonAnno;
3830class JsonArrayAnno{constructor(){this.arr=[]}push(a){this.arr.push(a)}get(a){return this.arr[a]}getArray(){return this.arr}write(a){var b=JSON.stringify(this.arr),c=AnnoRec.ANNO_HEAD_SIZE+b.length;a.Vv(c);AnnoRec.writeHeader(a,0,AnnoType.JSONARRAY,c);a.writeSizedString(b)}read(a,b){a=b.readSizedString(a);this.arr=JSON.parse(a)}}AnnoFactory[AnnoType.JSONARRAY]=JsonArrayAnno;
3831class SymbolsAnno extends Array{constructor(){super()}toString(){return"syms"}isExclusiveMark(a){return 1<=a&&6>=a}isExclusiveEval(a){return 11<=a&&19>=a||44==a}addSymbol(a){for(var b=0;b<this.length;b++)if(this.isExclusiveMark(this[b])&&this.isExclusiveMark(a)||this.isExclusiveEval(this[b])&&this.isExclusiveEval(a)){a!=this[b]&&this.push(a);this.splice(b,1);return}for(b=0;b<this.length;b++)if(a==this[b]){this.splice(b,1);return}this.push(a)}hasExclusiveEval(a){for(var b=0;b<this.length;b++)if(a==
3832this[b]&&this.isExclusiveEval(a))return!0;return!1}getEval(){for(var a=0;a<this.length;a++)if(this.isExclusiveEval(this[a]))return this[a];return 0}getMark(){for(var a=0;a<this.length;a++)if(this.isExclusiveMark(this[a]))return this[a];return 0}removeMyMoveMark(){for(var a=0;a<this.length;a++)if(this[a]===AnnoMarkType.MYMOVE){this.splice(a,1);break}}write(a){var b=AnnoRec.ANNO_HEAD_SIZE+this.length;a.Vv(b);AnnoRec.writeHeader(a,0,AnnoType.SYMBOL,b);for(b=0;b<this.length;b++)a.writeByte(this[b])}read(a,
3833b){for(var c=0;c<a;++c)this.push(b.readByte())}}AnnoFactory[AnnoType.SYMBOL]=SymbolsAnno;
3834class BoardColor{static NONE=0;static GREEN=1;static YELLOW=2;static RED=3;static LIGHTRED=4;static LIGHTGREEN=5;static BLUE=6;static CYAN=7;static ORANGE=8;static fromChar(a){switch(a){case "R":return BoardColor.RED;case "Y":return BoardColor.YELLOW;case "G":return BoardColor.GREEN;case "B":return BoardColor.BLUE;case "C":return BoardColor.CYAN;case "O":return BoardColor.ORANGE;default:return BoardColor.NONE}}static fromString(a){switch(a){case "R":return BoardColor.RED;case "LR":return BoardColor.LIGHTRED;
3835case "Y":return BoardColor.YELLOW;case "LG":return BoardColor.LIGHTGREEN;case "G":return BoardColor.GREEN;case "B":return BoardColor.BLUE;case "C":return BoardColor.CYAN;case "O":return BoardColor.ORANGE;default:return BoardColor.GREEN}}static toString(a){switch(a){case BoardColor.RED:return"R";case BoardColor.LIGHTRED:return"LR";case BoardColor.YELLOW:return"Y";case BoardColor.LIGHTGREEN:return"LG";case BoardColor.GREEN:return"G";case BoardColor.BLUE:return"B";case BoardColor.CYAN:return"C";case BoardColor.ORANGE:return"O"}return""}}
3836class ColSq{constructor(a,b){this.field=a;this.color=b}static STRING_LEN=3;init(a){this.color=BoardColor.GREEN;this.field=CBSquare.A1;4==a.length?(this.color=BoardColor.fromString(a.substring(0,2)),this.field=CBSquare.fromString(a.substring(2,4))):3==a.length&&(this.color=BoardColor.fromChar(a[0]),this.field=CBSquare.fromString(a.substring(1)))}static readFactory=createReadFactory(ColSq);read(a){this.color=a.readByte();this.field=a.readByte();this.color--;this.field--}write(a){a.writeByte(this.color+
38371);a.writeByte(this.field+1)}toString(){return BoardColor.toString(this.color)+CBSquare.toString(this.field)}getColour(){switch(this.color){case BoardColor.GREEN:return"hsla( 120, 65%, 50%, 0.75 )";case BoardColor.LIGHTGREEN:return"hsla( 120, 65%, 60%, 0.75 )";case BoardColor.YELLOW:return"hsla( 60, 65%, 50%, 0.8 )";case BoardColor.RED:return"hsla( 0, 65%, 50%, 0.75 )";case BoardColor.LIGHTRED:return"hsla( 0, 65%, 60%, 0.75 )";case BoardColor.BLUE:return"hsla( 240, 65%, 50%, 0.75 )";case BoardColor.CYAN:return"hsla( 180, 65%, 50%, 0.75 )";
3838case BoardColor.ORANGE:return"hsla( 20, 65%, 50%, 0.80 )"}}}class ColSqAnno extends Array{constructor(){super()}read(a,b){for(var c=0;c<a/2;c++){var d=new ColSq(0,0);d.read(b);this.push(d)}}write(a){var b=AnnoRec.ANNO_HEAD_SIZE+2*this.length;a.Vv(b);AnnoRec.writeHeader(a,0,AnnoType.SQUARE_LIST,b);for(b=0;b<this.length;b++)this[b].write(a)}toString(a){a||=",";return this.join(a)}}AnnoFactory[AnnoType.SQUARE_LIST]=ColSqAnno;
3839class ColArrow{constructor(a,b,c){this.from=a;this.to=b;this.color=c}static STRING_LEN=5;init(a){5==a.length?(this.from=CBSquare.fromString(a.substring(1,3)),this.to=CBSquare.fromString(a.substring(3,5)),this.color=BoardColor.fromChar(a[0])):6==a.length&&(this.from=CBSquare.fromString(a.substring(2,4)),this.to=CBSquare.fromString(a.substring(4,6)),this.color=BoardColor.fromString(a.substring(0,2)))}static readFactory=createReadFactory(ColArrow);read(a){this.color=a.readByte();this.from=a.readByte();
3840this.to=a.readByte();this.color--;this.from--;this.to--}write(a){a.writeByte(this.color+1);a.writeByte(this.from+1);a.writeByte(this.to+1)}toString(){return BoardColor.toString(this.color)}getColour(){switch(this.color){case BoardColor.GREEN:return"hsla( 120, 65%, 50%, 0.75 )";case BoardColor.LIGHTGREEN:return"hsla( 120, 65%, 60%, 0.75 )";case BoardColor.YELLOW:return"hsla( 60, 65%, 50%, 0.8 )";case BoardColor.RED:return"hsla( 0, 65%, 50%, 0.75 )";case BoardColor.LIGHTRED:return"hsla( 0, 65%, 60%, 0.75 )";
3841case BoardColor.BLUE:return"hsla( 240, 65%, 50%, 0.75 )";case BoardColor.CYAN:return"hsla( 180, 65%, 50%, 0.75 )";case BoardColor.ORANGE:return"hsla( 20, 65%, 50%, 0.80 )"}}}class ColArrowAnno extends Array{constructor(){super()}read(a,b){for(var c=0;c<a/3;c++){var d=new ColArrow;d.read(b);this.push(d)}}write(a){var b=AnnoRec.ANNO_HEAD_SIZE+3*this.length;a.Vv(b);AnnoRec.writeHeader(a,0,AnnoType.ARROW_LIST,b);for(b=0;b<this.length;b++)this[b].write(a)}toString(a){a||=",";return this.join(a)}}
3842AnnoFactory[AnnoType.ARROW_LIST]=ColArrowAnno;
3842AnnoFactory[AnnoType.DIAGRAM]=TextAnno;class EvalAnno{eval=0;depth=0;constructor(a,b){a&&(this.eval=a);b&&(this.depth=b);this.type=0}toString(){return this.eval+"/"+this.depth}read(a,b){this.eval=b.V1a();this.type=b.V1a();this.depth=b.V1a()}write(a){var b=AnnoRec.ANNO_HEAD_SIZE+6;a.Vv(b);AnnoRec.writeHeader(a,0,AnnoType.FRITZ_EVAL,b);a.V14(this.eval);a.V14(this.type);a.V14(this.depth)}}AnnoFactory[AnnoType.FRITZ_EVAL]=EvalAnno;
3843class TimeAnno{constructor(a){this.time=a||0}getString(){var a=this.time>>24,b=this.time>>16&255,c=this.time>>8&255,d=this.time&255,e="";0<a&&(e=a+":");0<b&&(10>b&&0<e.length&&(e+="0"),e+=b+":");10>c&&0<e.length&&(e+="0");0==b&&0==a&&10>c?(e+=c,a=Math.floor(d/10),0<a&&(e+="."+a)):(a=Math.round(c+d/100),60==a&&(a=59.9),e+=a);return e}fromCentiSecs(a){this.time=TimeTools.getCBTimeOfCentiSecs(a)}toString(){return"Time: "+Math.round(this.getTimeIn100th()/100)+"s"}read(a,b){this.time=b.readBEInt32()}write(a){var b=
3844AnnoRec.ANNO_HEAD_SIZE+4;a.Vv(b);AnnoRec.writeHeader(a,0,AnnoType.TIME,b);a.writeBEInt32(this.time)}getTimeIn100th(){return 36E4*(this.time>>24)+6E3*(this.time>>16&255)+100*(this.time>>8&255)+(this.time&255)}}AnnoFactory[AnnoType.TIME]=TimeAnno;class TimeControlAnno{constructor(){}toString(){return"TC=NOTIMPL"}read(a,b){for(var c=0;c<a;c++)b.readByte()}}AnnoFactory[AnnoType.TIME_CONTROL]=TimeControlAnno;
3845class SyncAnno{constructor(){this.data=[]}toString(){return"Sync"}read(a,b){for(var c=0;c<a;c++)this.data[c]=b.readByte()}write(a){var b=AnnoRec.ANNO_HEAD_SIZE+4;a.Vv(b);AnnoRec.writeHeader(a,0,AnnoType.SYNC,b);var c=0;for(b=this.data.length;c<b;++c)a.writeByte(this.data[c])}}AnnoFactory[AnnoType.SYNC]=SyncAnno;
3846class MoveMedalAnno{constructor(a){this.medal=a}toString(){return"Medal-"+this.medal}getString(){return this.toString()}getOneMedal(){return this.medal&Medal.SACRIFICE?Medal.SACRIFICE:this.medal&Medal.ENDGAME?Medal.ENDGAME:this.medal&Medal.STRATEGY?Medal.STRATEGY:this.medal&Medal.MATERIAL?Medal.MATERIAL:this.medal&Medal.PIECEPLAY?Medal.PIECEPLAY:this.medal&Medal.ATTACK?Medal.ATTACK:this.medal&Medal.TACTICAL_BLUNDER?Medal.TACTICAL_BLUNDER:this.medal}read(a,b){this.medal=b.readBEInt32()}write(a){var b=
3847AnnoRec.ANNO_HEAD_SIZE+4;a.Vv(b);AnnoRec.writeHeader(a,0,AnnoType.MOVE_MEDAL,b);a.Vu(this.medal)}}AnnoFactory[AnnoType.MOVE_MEDAL]=MoveMedalAnno;
3848class EvalProfileAnno{constructor(a,b,c){this.first=a||0;this.last=b||0;this.evalArr=c||[];this.min=32767;this.max=-32767;this.detMinMax()}static EV_INVALID=32767;detMinMax(){for(var a=0;a<this.evalArr.length;a++)this.evalArr[a]!=EvalProfileAnno.EV_INVALID&&(this.evalArr[a]>this.max&&(this.max=this.evalArr[a]),this.evalArr[a]<this.min&&(this.min=this.evalArr[a]))}range(){return Math.max(1,this.max-this.min)}toString(){return"MoveMedal"}isValid(){return this.last>this.first}read(a,b){this.evalArr=
3849[];this.last=this.first=0;a=b.readBEInt16();if(600>a){for(var c=0;c<a;c++){var d=new ArrayBuffer(4),e=new DataView(d);e.setInt8(0,b.readByte());e.setInt8(1,b.readByte());e.setInt8(2,b.readByte());e.setInt8(3,b.readByte());d=e.getInt16(2);e.getInt8(1);e=e.getInt8(0);-1==e?this.evalArr.push(EvalProfileAnno.EV_INVALID):(1==e&&(d=0>d?-3E4+d:3E4-d),this.evalArr.push(d))}this.last=a-1}this.detMinMax()}static readFactory=createReadFactory(EvalProfileAnno);write(a){var b=AnnoRec.ANNO_HEAD_SIZE+2+4*this.evalArr.length;
3850a.Vv(b);AnnoRec.writeHeader(a,0,AnnoType.EVAL_PROFILE,b);a.writeBEInt16(this.evalArr.length);for(b=0;b<this.evalArr.length;b++){var c=new ArrayBuffer(4);c=new DataView(c);this.evalArr[b]==EvalProfileAnno.EV_INVALID?(c.setInt8(0,255),c.setInt16(2,0)):(c.setInt8(0,0),c.setInt16(2,this.evalArr[b]));c.setInt8(1,0);a.writeBEInt32(c.getInt32(0))}}}AnnoFactory[AnnoType.EVAL_PROFILE]=EvalProfileAnno;
3851class TrainingAnno{constructor(a){this.move=a;this.type=0;this.best=-1;this.solved=!1;this.nHelpClicked=0;this.texts={};this.texts.en={question:"",help:"",answers:[]}}static lns=["en","de","es","it"];static lIds=[Language.ENG,Language.DEU,Language.ESP,Language.ITA];getQuestion(a){if(this.texts[a])return this.texts[a].question;for(a=0;a<TrainingAnno.lns.length;a++)if(this.texts[TrainingAnno.lns[a]])return this.texts[TrainingAnno.lns[a]].question}getHelp(a){if(this.texts[a])return this.texts[a].help;
3852for(a=0;a<TrainingAnno.lns.length;a++)if(this.texts[TrainingAnno.lns[a]])return this.texts[TrainingAnno.lns[a]].help}toString(){return"Training"}decodeLocals(a,b){a.Vw();a.Vx();var c=a.Vx();for(b=0;b<c&&10>b;b++){var d=this.decodeString(a),e=d.ln;e&&(this.texts[e]||(this.texts[e]={}),this.texts[e].question=d.str)}d=a.Vx();for(b=0;b<d&&10>b;b++)this.decodeString(a);c=a.Vx();for(b=0;b<c&&10>b;b++)if(d=this.decodeString(a),e=d.ln)this.texts[e]||(this.texts[e]={}),this.texts[e].help=d.str;d=a.Vx();for(b=
38530;b<d&&10>b;b++)this.decodeString(a)}readMoveInputItem(a){this.type=0;a.Vx();var b=a.getPos();this.decodeLocals(a,b);
3853b=a.readByte();for(var c=0;c<b&&60>c;c++){var d=a.readByte(),e=a.readByte(),f=a.readByte();a.readByte();var g=a.Vx();0==c&&(this.move=new Move(d,e,f));for(d=0;d<g;d++)this.decodeString(a)}a.getPos()}readMultipleChoiceItem(a){this.type=1;var b=this.best=-1;a.Vx();this.decodeLocals(a);for(var c=a.readByte(),d=0;d<c&&10>d;d++){var e=a.readByte();b<e&&(b=e,this.best=d);e=a.Vx();for(var f=
38540;f<e;f++){var g=this.decodeString(a),h=g.ln;h&&(this.texts[h]||(this.texts[h]={}),this.texts[h].answers||(this.texts[h].answers=[]),this.texts[h].answers[f]=g.str)}e=a.Vx();for(f=0;f<e;f++)this.decodeString(a)}}read(a,b){b.Vx();switch(b.readByte()){case 1:this.readMoveInputItem(b);break;case 2:this.readMultipleChoiceItem(b)}}write(a){var b=new DataBuffer;b.Vv(1);b.writeByte(1);var c=b.getPos();b.Vv(0);b.getPos();b.Vu(300);b.Vv(0);var d=b.getPos();b.Vv(0);for(var e=0,f=0;f<TrainingAnno.lns.length;f++)this.texts[TrainingAnno.lns[f]]&&
3855this.texts[TrainingAnno.lns[f]].question&&(e=this.encodeString(this.texts[TrainingAnno.lns[f]].question,b,e,TrainingAnno.lIds[f]));b.writeAtPrevPos(d,function(){b.Vv(e)});b.Vv(0);var g=0;d=b.getPos();b.Vv(0);for(f=0;f<TrainingAnno.lns.length;f++)this.texts[TrainingAnno.lns[f]]&&this.texts[TrainingAnno.lns[f]].help&&(g=this.encodeString(this.texts[TrainingAnno.lns[f]].help,b,g,TrainingAnno.lIds[f]));b.writeAtPrevPos(d,function(){b.Vv(g)});b.Vv(0);this.move?(b.writeByte(1),b.writeByte(this.move.from),
3856b.writeByte(this.move.to),b.writeByte(this.move.prom)):(b.writeByte(1),b.writeByte(0),b.writeByte(0),b.writeByte(0));b.writeByte(5);b.Vv(0);var h=b.getPos();b.writeAtPrevPos(c,function(){b.Vv(h)});c=AnnoRec.ANNO_HEAD_SIZE+b.getSize();a.Vv(c);AnnoRec.writeHeader(a,0,AnnoType.TRAINING,c);a.writeData(b)}decodeString(a){var b=a.readByte();a.readByte();var c=a.Vx();a=a.readSizedString(c);StrUtil.mayBeUtf8(a)&&(a=StrUtil.decodeUTF8(a));return{ln:Language.getParamOfLanguageId(b),str:a}}encodeString(a,b,
3857c,d){a&&(b.writeByte(d),b.writeByte(0),b.Vv(a.length),b.writeSizedString(a),c++);return c}}AnnoFactory[AnnoType.TRAINING]=TrainingAnno;
3858class MultipleChoiceAnno{constructor(a,b){this.question=a;this.answers=b}read(a,b){a=b.readSizedString(a);a=JSON.parse(a);this.question=a.question;this.answers=a.answers.map(c=>new MultipleChoiceAnswer(c.text,c.isCorrect))}write(a){let b=JSON.stringify({question:this.question,answers:this.answers}),c=AnnoRec.ANNO_HEAD_SIZE+b.length;a.Vv(c);AnnoRec.writeHeader(a,0,AnnoType.MULTIPLE_CHOICE,c);a.writeSizedString(b)}}class MultipleChoiceAnswer{constructor(a,b){this.text=a;this.isCorrect=b}}
3859AnnoFactory[AnnoType.MULTIPLE_CHOICE]=MultipleChoiceAnno;"use strict";
3860const SpecialGlyphs={NONE:0,GOOD_MOVE:1,BAD_MOVE:2,VERY_GOOD_MOVE:3,VERY_BAD_MOVE:4,SPECULATIVE_MOVE:5,DUBIOUS_MOVE:6,FORCED_MOVE:7,SINGULAR_MOVE:8,WORST_MOVE:9,DRAWN_POS:10,EQUAL_QUIET_POS:11,EQUAL_ACTIVE_POS:12,UNCLEAR_POS:13,W_SLIGHT_ADV:14,B_SLIGHT_ADV:15,W_MODER_ADV:16,B_MODER_ADV:17,W_DECIS_ADV:18,B_DECIS_ADV:19,W_CRASH_ADV:20,B_CRASH_ADV:21,W_ZUGZW:22,B_ZUGZW:23,W_SLIGHT_SPC:24,B_SLIGHT_SPC:25,W_MODER_SPC:26,B_MODER_SPC:27,W_DECIS_SPC:28,B_DECIS_SPC:29,W_SLIGHT_TEMP:30,B_SLIGHT_TEMP:31,W_MODER_TEMP:32,
3861B_MODER_TEMP:33,W_DECIS_TEMP:34,B_DECIS_TEMP:35,W_INITIATIVE:36,B_INITIATIVE:37,W_LASTING_INITIATIVE:38,B_LASTING_INITIATIVE:39,W_ATTACK:40,B_ATTACK:41,W_INSUFF_COMP:42,B_INSUFF_COMP:43,W_SUFF_COMP:44,B_SUFF_COMP:45,W_GOOD_COMP:46,B_GOOD_COMP:47,W_SLIGHT_CENTER:48,B_SLIGHT_CENTER:49,W_MODER_CENTER:50,B_MODER_CENTER:51,W_DECIS_CENTER:52,B_DECIS_CENTER:53,W_SLIGHT_KS:54,B_SLIGHT_KS:55,W_MODER_KS:56,B_MODER_KS:57,W_DECIS_KS:58,B_DECIS_KS:59,W_SLIGHT_QS:60,B_SLIGHT_QS:61,W_MODER_QS:62,B_MODER_QS:63,W_DECIS_QS:64,
3862B_DECIS_QS:65,W_BAD_FRST_RANK:66,B_BAD_FRST_RANK:67,W_GOOD_FRST_RANK:68,B_GOOD_FRST_RANK:69,W_BAD_PROTECTED_KING:70,B_BAD_PROTECTED_KING:71,W_GOOD_PROTECTED_KING:72,B_GOOD_PROTECTED_KING:73,W_BAD_PLACED_KING:74,B_BAD_PLACED_KING:75,W_GOOD_PLACED_KING:76,B_GOOD_PLACED_KING:77,W_VERY_WEAK_PAWNS:78,B_VERY_WEAK_PAWNS:79,W_MODER_WEAK_PAWNS:80,B_MODER_WEAK_PAWNS:81,W_MODER_STRONG_PAWNS:82,B_MODER_STRONG_PAWNS:83,W_VERY_STRONG_PAWNS:84,B_VERY_STRONG_PAWNS:85,W_BAD_KNIGHT:86,B_BAD_KNIGHT:87,W_GOOD_KNIGHT:88,
3863B_GOOD_KNIGHT:89,W_BAD_BISHOP:90,B_BAD_BISHOP:91,W_GOOD_BISHOP:92,B_GOOD_BISHOP:93,W_BAD_ROOK:94,B_BAD_ROOK:95,W_GOOD_ROOK:96,B_GOOD_ROOK:97,W_BAD_QUEEN:98,B_BAD_QUEEN:99,W_GOOD_QUEEN:100,B_GOOD_QUEEN:101,W_BAD_PIECES:102,B_BAD_PIECES:103,W_GOOD_PIECES:104,B_GOOD_PIECES:105,W_OP_VERY_BAD:106,B_OP_VERY_BAD:107,W_OP_BAD:108,B_OP_BAD:109,W_OP_GOOD:110,B_OP_GOOD:111,W_OP_VERY_GOOD:112,B_OP_VERY_GOOD:113,W_MG_VERY_BAD:114,B_MG_VERY_BAD:115,W_MG_BAD:116,B_MG_BAD:117,W_MG_GOOD:118,B_MG_GOOD:119,W_MG_VERY_GOOD:120,
3864B_MG_VERY_GOOD:121,W_EG_VERY_BAD:122,B_EG_VERY_BAD:123,W_EG_BAD:124,B_EG_BAD:125,W_EG_GOOD:126,B_EG_GOOD:127,W_EG_VERY_GOOD:128,B_EG_VERY_GOOD:129,W_SLIGHT_COUNTER:130,B_SLIGHT_COUNTER:131,W_MODER_COUNTER:132,B_MODER_COUNTER:133,W_DECIS_COUNTER:134,B_DECIS_COUNTER:135,W_MODER_ZEITNOT:136,B_MODER_ZEITNOT:137,W_SEVERE_ZEITNOT:138,B_SEVERE_ZEITNOT:139,WITH_IDEA:140,AIMED_AGAINST:141,BETTER_IS:142,WORSE_IS:143,EQUAL_IS:144,EDITORS_MARK:145,NOVELTY:146,WEAK_POINT:147,ENDGAME:148,LINE:149,DIAGONAL:150,
3865W_BISHOP_PAIR:151,B_BISHOP_PAIR:152,OPP_COLOR_BISHOPS:153,SAME_COLOR_BISHOPS:154,W_UNITED_PAWNS:155,B_UNITED_PAWNS:156,W_SEPARATE_PAWNS:157,B_SEPARATE_PAWNS:158,W_DOUBLE_PAWNS:159,B_DOUBLE_PAWNS:160,W_PASSED_PAWNS:161,B_PASSED_PAWNS:162,W_MORE_PAWNS:163,B_MORE_PAWNS:164,MY_MOVE:165,IMPORTANT:166,WHITE:167,BLACK:168,BOTH:169};var Vz={};Vz[SpecialGlyphs.NONE]="";Vz[SpecialGlyphs.GOOD_MOVE]="!";Vz[SpecialGlyphs.BAD_MOVE]="?";Vz[SpecialGlyphs.VERY_GOOD_MOVE]="\u203c";Vz[SpecialGlyphs.VERY_BAD_MOVE]="??";
3866Vz[SpecialGlyphs.SPECULATIVE_MOVE]="!?";Vz[SpecialGlyphs.DUBIOUS_MOVE]="?!";Vz[SpecialGlyphs.FORCED_MOVE]="!";Vz[SpecialGlyphs.SINGULAR_MOVE]="\ue021";Vz[SpecialGlyphs.WORST_MOVE]="";Vz[SpecialGlyphs.DRAWN_POS]="=";Vz[SpecialGlyphs.EQUAL_QUIET_POS]="=";Vz[SpecialGlyphs.EQUAL_ACTIVE_POS]="=";Vz[SpecialGlyphs.UNCLEAR_POS]="\u221e";Vz[SpecialGlyphs.W_SLIGHT_ADV]="\ue02f";Vz[SpecialGlyphs.B_SLIGHT_ADV]="\ue02e";Vz[SpecialGlyphs.W_MODER_ADV]="\u00b1";Vz[SpecialGlyphs.B_MODER_ADV]="\ue01a";
3867Vz[SpecialGlyphs.W_DECIS_ADV]="+-";
3867Vz[SpecialGlyphs.B_DECIS_ADV]="-+";Vz[SpecialGlyphs.W_CRASH_ADV]="+-";Vz[SpecialGlyphs.B_CRASH_ADV]="-+";Vz[SpecialGlyphs.W_ZUGZW]="\ue01d";Vz[SpecialGlyphs.B_ZUGZW]="\ue01d";Vz[SpecialGlyphs.W_SLIGHT_SPC]="\ue023";Vz[SpecialGlyphs.B_SLIGHT_SPC]="\ue023";Vz[SpecialGlyphs.W_MODER_SPC]="\ue023";Vz[SpecialGlyphs.B_MODER_SPC]="\ue023";Vz[SpecialGlyphs.W_DECIS_SPC]="\ue023";Vz[SpecialGlyphs.B_DECIS_SPC]="\ue023";Vz[SpecialGlyphs.W_SLIGHT_TEMP]="\ue02d";
3868Vz[SpecialGlyphs.B_SLIGHT_TEMP]="\ue02d";Vz[SpecialGlyphs.W_MODER_TEMP]="\ue02d";Vz[SpecialGlyphs.B_MODER_TEMP]="\ue02d";Vz[SpecialGlyphs.W_DECIS_TEMP]="\ue02d";Vz[SpecialGlyphs.B_DECIS_TEMP]="\ue02d";Vz[SpecialGlyphs.W_INITIATIVE]="\ue012";Vz[SpecialGlyphs.B_INITIATIVE]="\ue012";Vz[SpecialGlyphs.W_LASTING_INITIATIVE]="\ue012";Vz[SpecialGlyphs.B_LASTING_INITIATIVE]="\ue012";Vz[SpecialGlyphs.W_ATTACK]="\ue013";Vz[SpecialGlyphs.B_ATTACK]="\ue013";Vz[SpecialGlyphs.W_INSUFF_COMP]="\ue004\ue000";
3869Vz[SpecialGlyphs.B_INSUFF_COMP]="\ue004\ue000";Vz[SpecialGlyphs.W_SUFF_COMP]="\ue000";Vz[SpecialGlyphs.B_SUFF_COMP]="\ue000";Vz[SpecialGlyphs.W_GOOD_COMP]="\ue000";Vz[SpecialGlyphs.B_GOOD_COMP]="\ue000";Vz[SpecialGlyphs.W_SLIGHT_CENTER]="\ue01e";Vz[SpecialGlyphs.B_SLIGHT_CENTER]="\ue01e";Vz[SpecialGlyphs.W_MODER_CENTER]="\ue01e";Vz[SpecialGlyphs.B_MODER_CENTER]="\ue01e";Vz[SpecialGlyphs.W_DECIS_CENTER]="\ue01e";Vz[SpecialGlyphs.B_DECIS_CENTER]="\ue01e";Vz[SpecialGlyphs.W_SLIGHT_KS]="\ue00f";
3870Vz[SpecialGlyphs.B_SLIGHT_KS]="\ue00f";Vz[SpecialGlyphs.W_MODER_KS]="\ue00f";Vz[SpecialGlyphs.B_MODER_KS]="\ue00f";Vz[SpecialGlyphs.W_DECIS_KS]="\ue00f";Vz[SpecialGlyphs.B_DECIS_KS]="\ue00f";Vz[SpecialGlyphs.W_SLIGHT_QS]="\ue00e";Vz[SpecialGlyphs.B_SLIGHT_QS]="\ue00e";Vz[SpecialGlyphs.W_MODER_QS]="\ue00e";Vz[SpecialGlyphs.B_MODER_QS]="\ue00e";Vz[SpecialGlyphs.W_DECIS_QS]="\ue00e";Vz[SpecialGlyphs.B_DECIS_QS]="\ue00e";Vz[SpecialGlyphs.W_BAD_FRST_RANK]="\ue010\ue0181";
3871Vz[SpecialGlyphs.B_BAD_FRST_RANK]="\ue010\ue0188";Vz[SpecialGlyphs.W_GOOD_FRST_RANK]="";Vz[SpecialGlyphs.B_GOOD_FRST_RANK]="";Vz[SpecialGlyphs.W_BAD_PROTECTED_KING]="\ue010\ue024";Vz[SpecialGlyphs.B_BAD_PROTECTED_KING]="\ue010\ue024";Vz[SpecialGlyphs.W_GOOD_PROTECTED_KING]="";Vz[SpecialGlyphs.B_GOOD_PROTECTED_KING]="";Vz[SpecialGlyphs.W_BAD_PLACED_KING]="\ue010\ue024";Vz[SpecialGlyphs.B_BAD_PLACED_KING]="\ue010\ue024";Vz[SpecialGlyphs.W_GOOD_PLACED_KING]="";Vz[SpecialGlyphs.B_GOOD_PLACED_KING]="";
3872Vz[SpecialGlyphs.W_VERY_WEAK_PAWNS]="\ue010\ue029";Vz[SpecialGlyphs.B_VERY_WEAK_PAWNS]="\ue010\ue029";Vz[SpecialGlyphs.W_MODER_WEAK_PAWNS]="\ue010\ue029";Vz[SpecialGlyphs.B_MODER_WEAK_PAWNS]="\ue010\ue029";Vz[SpecialGlyphs.W_MODER_STRONG_PAWNS]="";Vz[SpecialGlyphs.B_MODER_STRONG_PAWNS]="";Vz[SpecialGlyphs.W_VERY_STRONG_PAWNS]="";Vz[SpecialGlyphs.B_VERY_STRONG_PAWNS]="";Vz[SpecialGlyphs.W_BAD_KNIGHT]="\ue010\ue028";Vz[SpecialGlyphs.B_BAD_KNIGHT]="\ue010\ue028";Vz[SpecialGlyphs.W_GOOD_KNIGHT]="";
3873Vz[SpecialGlyphs.B_GOOD_KNIGHT]="";Vz[SpecialGlyphs.W_BAD_BISHOP]="\ue010\ue027";Vz[SpecialGlyphs.B_BAD_BISHOP]="\ue010\ue027";Vz[SpecialGlyphs.W_GOOD_BISHOP]="";Vz[SpecialGlyphs.B_GOOD_BISHOP]="";Vz[SpecialGlyphs.W_BAD_ROOK]="\ue010\ue026";Vz[SpecialGlyphs.B_BAD_ROOK]="\ue010\ue026";Vz[SpecialGlyphs.W_GOOD_ROOK]="";Vz[SpecialGlyphs.B_GOOD_ROOK]="";Vz[SpecialGlyphs.W_BAD_QUEEN]="\ue010\ue025";Vz[SpecialGlyphs.B_BAD_QUEEN]="\ue010\ue025";Vz[SpecialGlyphs.W_GOOD_QUEEN]="";
3874Vz[SpecialGlyphs.B_GOOD_QUEEN]="";Vz[SpecialGlyphs.W_BAD_PIECES]="";Vz[SpecialGlyphs.B_BAD_PIECES]="";Vz[SpecialGlyphs.W_GOOD_PIECES]="";Vz[SpecialGlyphs.B_GOOD_PIECES]="";Vz[SpecialGlyphs.W_OP_VERY_BAD]="";Vz[SpecialGlyphs.B_OP_VERY_BAD]="";Vz[SpecialGlyphs.W_OP_BAD]="";Vz[SpecialGlyphs.B_OP_BAD]="";Vz[SpecialGlyphs.W_OP_GOOD]="";Vz[SpecialGlyphs.B_OP_GOOD]="";Vz[SpecialGlyphs.W_OP_VERY_GOOD]="";Vz[SpecialGlyphs.B_OP_VERY_GOOD]="";Vz[SpecialGlyphs.W_MG_VERY_BAD]="";
3875Vz[SpecialGlyphs.B_MG_VERY_BAD]="";Vz[SpecialGlyphs.W_MG_BAD]="";Vz[SpecialGlyphs.B_MG_BAD]="";Vz[SpecialGlyphs.W_MG_GOOD]="";Vz[SpecialGlyphs.B_MG_GOOD]="";Vz[SpecialGlyphs.W_MG_VERY_GOOD]="";Vz[SpecialGlyphs.B_MG_VERY_GOOD]="";Vz[SpecialGlyphs.W_EG_VERY_BAD]="\ue010\ue01f";Vz[SpecialGlyphs.B_EG_VERY_BAD]="\ue010\ue01f";Vz[SpecialGlyphs.W_EG_BAD]="\ue010\ue01f";Vz[SpecialGlyphs.B_EG_BAD]="\ue010\ue01f";Vz[SpecialGlyphs.W_EG_GOOD]="";Vz[SpecialGlyphs.B_EG_GOOD]="";
3876Vz[SpecialGlyphs.W_EG_VERY_GOOD]="";Vz[SpecialGlyphs.B_EG_VERY_GOOD]="";Vz[SpecialGlyphs.W_SLIGHT_COUNTER]="\ue017";Vz[SpecialGlyphs.B_SLIGHT_COUNTER]="\ue017";Vz[SpecialGlyphs.W_MODER_COUNTER]="\ue017";Vz[SpecialGlyphs.B_MODER_COUNTER]="\ue017";Vz[SpecialGlyphs.W_DECIS_COUNTER]="\ue017";Vz[SpecialGlyphs.B_DECIS_COUNTER]="\ue017";Vz[SpecialGlyphs.W_MODER_ZEITNOT]="\ue01c";
3876Vz[SpecialGlyphs.B_MODER_ZEITNOT]="\ue01c";Vz[SpecialGlyphs.W_SEVERE_ZEITNOT]="\ue01c";Vz[SpecialGlyphs.B_SEVERE_ZEITNOT]="\ue01c";
3877Vz[SpecialGlyphs.WITH_IDEA]="\u2206";Vz[SpecialGlyphs.AIMED_AGAINST]="\ue022";Vz[SpecialGlyphs.BETTER_IS]="\ue020";Vz[SpecialGlyphs.WORSE_IS]="\u2264";Vz[SpecialGlyphs.EQUAL_IS]="=";Vz[SpecialGlyphs.EDITORS_MARK]="RR";Vz[SpecialGlyphs.NOVELTY]="N";Vz[SpecialGlyphs.WEAK_POINT]="\ue010";Vz[SpecialGlyphs.ENDGAME]="\ue01f";Vz[SpecialGlyphs.LINE]="\ue018";Vz[SpecialGlyphs.DIAGONAL]="\ue019";Vz[SpecialGlyphs.W_BISHOP_PAIR]="\ue001";Vz[SpecialGlyphs.B_BISHOP_PAIR]="\ue001";
3878Vz[SpecialGlyphs.OPP_COLOR_BISHOPS]="\ue002";Vz[SpecialGlyphs.SAME_COLOR_BISHOPS]="\ue003";Vz[SpecialGlyphs.W_UNITED_PAWNS]="\ue02b";Vz[SpecialGlyphs.B_UNITED_PAWNS]="\ue02b";Vz[SpecialGlyphs.W_SEPARATE_PAWNS]="\ue02c";Vz[SpecialGlyphs.B_SEPARATE_PAWNS]="\ue02c";Vz[SpecialGlyphs.W_DOUBLE_PAWNS]="\ue007";Vz[SpecialGlyphs.B_DOUBLE_PAWNS]="\ue007";Vz[SpecialGlyphs.W_PASSED_PAWNS]="\ue008";Vz[SpecialGlyphs.B_PASSED_PAWNS]="\ue008";Vz[SpecialGlyphs.W_MORE_PAWNS]=">";Vz[SpecialGlyphs.B_MORE_PAWNS]=">";
3879Vz[SpecialGlyphs.MY_MOVE]="*";Vz[SpecialGlyphs.IMPORTANT]="**";Vz[SpecialGlyphs.WHITE]="";Vz[SpecialGlyphs.BLACK]="";Vz[SpecialGlyphs.BOTH]="";var PieceGlyphs={};PieceGlyphs[Piece.PAWN]="\ue029";PieceGlyphs[Piece.KNIGHT]="\ue028";PieceGlyphs[Piece.BISHOP]="\ue027";PieceGlyphs[Piece.ROOK]="\ue026";PieceGlyphs[Piece.QUEEN]="\ue025";PieceGlyphs[Piece.KING]="\ue024";var V6={};V6[Piece.PAWN]="\u2659";V6[Piece.KNIGHT]="\u2658";V6[Piece.BISHOP]="\u2657";V6[Piece.ROOK]="\u2656";V6[Piece.QUEEN]="\u2655";
3880V6[Piece.KING]="\u2654";Vz.getText=function(a){return Vz[a]};Vz.addTexts=function(a,b){var c={};c[GlyphType.MOVE_GLYPH]=c[GlyphType.PRE_GLYPH]=c[GlyphType.POST_GLYPH]="";for(var d=0,e=b.length;d<e;++d){var f=b[d],g=Vz.getText(f);c[GlyphType.getType(f)]+=g}return c[GlyphType.PRE_GLYPH]+a+c[GlyphType.MOVE_GLYPH]+c[GlyphType.POST_GLYPH]};
3881Vz.getMarksText=function(a){let b="";for(let c=0,d=a.length;c<d;++c){let e="";switch(a[c]){case SpecialGlyphs.GOOD_MOVE:e="!";break;case SpecialGlyphs.BAD_MOVE:e="?";break;case SpecialGlyphs.VERY_GOOD_MOVE:e="!!";break;case SpecialGlyphs.VERY_BAD_MOVE:e="??";break;case SpecialGlyphs.SPECULATIVE_MOVE:e="!?";break;case SpecialGlyphs.DUBIOUS_MOVE:e="?!"}b+=e}return b};var V8=ObjUtil.clone(V5);V8.arrStrPieces[Piece.W_KING]=V8.arrStrPieces[Piece.B_KING]=PieceGlyphs[Piece.KING];
3882V8.arrStrPieces[Piece.W_QUEEN]=V8.arrStrPieces[Piece.B_QUEEN]=PieceGlyphs[Piece.QUEEN];V8.arrStrPieces[Piece.W_ROOK]=V8.arrStrPieces[Piece.B_ROOK]=PieceGlyphs[Piece.ROOK];V8.arrStrPieces[Piece.W_BISHOP]=V8.arrStrPieces[Piece.B_BISHOP]=PieceGlyphs[Piece.BISHOP];V8.arrStrPieces[Piece.W_KNIGHT]=V8.arrStrPieces[Piece.B_KNIGHT]=PieceGlyphs[Piece.KNIGHT];V8.arrStrPieces[Piece.W_PAWN]=V8.arrStrPieces[Piece.B_PAWN]="";var UnicodeV8=ObjUtil.clone(V5);
3883UnicodeV8.arrStrPieces[Piece.W_KING]=UnicodeV8.arrStrPieces[Piece.B_KING]=V6[Piece.KING];UnicodeV8.arrStrPieces[Piece.W_QUEEN]=UnicodeV8.arrStrPieces[Piece.B_QUEEN]=V6[Piece.QUEEN];UnicodeV8.arrStrPieces[Piece.W_ROOK]=UnicodeV8.arrStrPieces[Piece.B_ROOK]=V6[Piece.ROOK];UnicodeV8.arrStrPieces[Piece.W_BISHOP]=UnicodeV8.arrStrPieces[Piece.B_BISHOP]=V6[Piece.BISHOP];UnicodeV8.arrStrPieces[Piece.W_KNIGHT]=UnicodeV8.arrStrPieces[Piece.B_KNIGHT]=V6[Piece.KNIGHT];
3884UnicodeV8.arrStrPieces[Piece.W_PAWN]=UnicodeV8.arrStrPieces[Piece.B_PAWN]="";var GlyphType={PRE_GLYPH:0,MOVE_GLYPH:1,POST_GLYPH:2,getType:function(a){return a<=SpecialGlyphs.WORST_MOVE||a>=SpecialGlyphs.MY_MOVE&&a<=SpecialGlyphs.BOTH||a===SpecialGlyphs.W_ZUGZW||a===SpecialGlyphs.B_ZUGZW?GlyphType.MOVE_GLYPH:a<=SpecialGlyphs.B_SEVERE_ZEITNOT||a>=SpecialGlyphs.NOVELTY?GlyphType.POST_GLYPH:GlyphType.PRE_GLYPH}};NotationLocalizations.glyphs=V8;NotationLocalizations.uglyphs=UnicodeV8;"use strict";
3885var TokenType={NONE:0,UNKNOWN:1,EOF:2,HEAD_OP:3,HEAD_CL:4,STR_VAR:5,STR_VAL:6,COMMENT:7,VAR_OP:8,VAR_CL:9,RES_STAR:10,RES_1_0:11,RES_0_1:12,RES_1_2:13,BUCK:14,CHECK:15,MATE:16,MOVE:17,ROCHADE:18,NULLMOVE:19,NUM:20,DOT:21,LONG_ROCHADE:22,SHORT_ROCHADE:23,BAD:24,VERY_BAD:25,GOOD:26,VERY_GOOD:27,BAD_GOOD:28,GOOD_BAD:29,WHITE_WINNING:30,BLACK_WINNING:31};
3886class Token{constructor(a,b){this.type=a||TokenType.UNKNOWN;this.str=b||""}toString(){var a=EnumToString(TokenType,this.type);this.str&&(a+="("+this.str+")");return a}}
3887class Vf{constructor(a){this.m_it=new StringIterator(a);this.m_it.Next();this.m_inHeader=!1}nextToken(){this.m_it.skipWhile(Char.IsWhiteSpace,!0);if(this.m_it.isEOF())return new Token(TokenType.EOF);var a=this.m_it.Current();this.m_it.Next();switch(a){case "X":case "#":return new Token(TokenType.MATE);case "+":return this.m_it.AcceptChar("-",!0)&&!this.m_it.AcceptStr("-+",!0)?new Token(TokenType.WHITE_WINNING):new Token(TokenType.CHECK);case "$":return new Token(TokenType.BUCK);case "*":return new Token(TokenType.RES_STAR,
3888a);case "[":return this.m_inHeader=!0,new Token(TokenType.HEAD_OP);case "]":return this.m_inHeader=!1,new Token(TokenType.HEAD_CL);case "(":return new Token(TokenType.VAR_OP);case ")":return new Token(TokenType.VAR_CL);case ".":return new Token(TokenType.DOT)}if(this.m_inHeader){if(Char.IsLetterOrDigit(a))return a+=this.m_it.AcceptWhile(Char.IsLetterOrDigit,!0),new Token(TokenType.STR_VAR,a);if('"'===a)return a=this.m_it.AcceptUntil(Char.getIsChar("]"),!0),a=a.trim(),'"'===a.charAt(a.length-1)&&(a=
3889a.slice(0,a.length-1)),new Token(TokenType.STR_VAL,a)}if("{"===a)return a=this.m_it.AcceptUntil(Char.getIsChar("}"),!0),this.m_it.skipWhile(Char.getIsChar("}"),!0),new Token(TokenType.COMMENT,a);if("0"===a){if(this.m_it.AcceptStr("-0-0",!0))return new Token(TokenType.LONG_ROCHADE);if(this.m_it.AcceptStr("-0",!0))return new Token(TokenType.SHORT_ROCHADE);if(this.m_it.AcceptStr("-1",!0))return new Token(TokenType.RES_0_1)}if("O"===a){if(this.m_it.AcceptStr("-O-O",!0))return new Token(TokenType.LONG_ROCHADE);
3890if(this.m_it.AcceptStr("-O",!0))return new Token(TokenType.SHORT_ROCHADE)}if("1"===a){if(this.m_it.AcceptStr("-0",!0))return new Token(TokenType.RES_1_0);if(this.m_it.AcceptStr("/2-1/2",!0))return new Token(TokenType.RES_1_2)}if(Char.IsDigit(a))return a+=this.m_it.AcceptWhile(Char.IsDigit,!0),new Token(TokenType.NUM,a);if("-"===a){if(this.m_it.AcceptChar("+",!0)&&!this.m_it.AcceptStr("+-",!0))return new Token(TokenType.BLACK_WINNING);if(this.m_it.AcceptChar("-",!0))return new Token(TokenType.NULLMOVE)}return"?"===
3891a?this.m_it.AcceptChar("?",!0)?new Token(TokenType.VERY_BAD):this.m_it.AcceptChar("!",!0)?new Token(TokenType.BAD_GOOD):new Token(TokenType.BAD):"!"===a?this.m_it.AcceptChar("?",!0)?new Token(TokenType.GOOD_BAD):this.m_it.AcceptChar("!",!0)?new Token(TokenType.VERY_GOOD):new Token(TokenType.GOOD):"Z"===a&&this.m_it.AcceptChar("0",!0)?new Token(TokenType.NULLMOVE):Vf.isMoveChar(a)?(a+=this.m_it.AcceptWhile(Vf.isMoveChar,!0),new Token(TokenType.MOVE,a)):new Token(TokenType.UNKNOWN,a)}static isMoveChar(a){return"a"<=
3892a&&"h">
3892=a||"1"<=a&&"8">=a||"x"===a||"="===a||"-"===a||Char.IsUpperCaseLetter(a)&&Piece.fromString(a)!==Piece.NONE}}class PGNLexer{constructor(a){this.m_stm=new Vf(a);this.m_last=null}peek(a){this.m_last||(this.m_last=this.m_stm.nextToken());return a&&a(this.m_last.type)?this.m_last:null}static getIsType(a){return function(b){return b===a}}pop(a){if(a=this.peek(a))this.m_last=null;return a}popT(a){return this.pop(PGNLexer.getIsType(a))}peekT(a){return this.peek(PGNLexer.getIsType(a))}}"use strict";
3893function PGNSubLine(){}PGNSubLine.prototype=[];
3894class PGNMove{constructor(a){this.m_strMove=null;this.m_isTake=this.m_isNullMove=this.m_isLongCastle=this.m_isShortCastle=this.m_isMate=this.m_isCheck=!1;this.m_prom=this.m_mvd=Piece.NONE;this.m_to=this.m_rowTo=this.m_colTo=this.m_rowFrom=this.m_colFrom=-1;a&&(this.m_strMove=a,this.init(a))}static g_regex=/^(K|Q|R|N|B)?([a-h]?)([1-8]?)(x|-?)([a-h])([1-8])(?:=?(K|Q|R|N|B))?$/;init(a){PGNMove.g_regex.exec(a)&&(this.m_mvd=Piece.fromString(RegExp.$1),this.m_mvd=Piece.nominal(this.m_mvd),RegExp.$2&&(this.m_colFrom=
3895CBSquare.colFromString(RegExp.$2)),RegExp.$3&&(this.m_rowFrom=CBSquare.rowFromString(RegExp.$3)),"x"===RegExp.$4&&(this.m_isTake=!0),RegExp.$5&&(this.m_colTo=CBSquare.colFromString(RegExp.$5)),RegExp.$6&&(this.m_rowTo=CBSquare.rowFromString(RegExp.$6)),RegExp.$7&&(this.m_prom=Piece.fromString(RegExp.$7),this.m_prom=Piece.nominal(this.m_prom)),(0>this.m_rowFrom||""===RegExp.$1)&&this.m_mvd===Piece.NONE&&(this.m_mvd=Piece.PAWN),0<=this.m_colTo&&0<=this.m_rowTo&&(this.m_to=CBSquare.I(this.m_colTo,this.m_rowTo)))}setNullMove(){this.m_isNullMove=
3896!0}isNullMove(){return this.m_isNullMove}setLongCastling(){this.m_isLongCastle=!0}isLongCastling(){return this.m_isLongCastle}setShortCastling(){this.m_isShortCastle=!0}isShortCastling(){return this.m_isShortCastle}setCheck(a){this.m_isCheck=a}setMate(a){this.m_isMate=a}isTake(){return this.m_isTake}matches(a){var b=a.from;return this.m_to!==a.to||this.m_mvd!==Piece.NONE&&(a=a.getMoved(),Piece.nominal(a)!==this.m_mvd)?!1:this.matchesFrom(b)}matchesFrom(a){return 0<=this.m_colFrom&&this.m_colFrom!==
3897CBSquare.C(a)||0<=this.m_rowFrom&&this.m_rowFrom!==CBSquare.R(a)?!1:!0}getMoved(){return this.m_mvd}getTo(){return this.m_to}getProm(){return this.m_prom}}class PGNComment{constructor(a){this.m_strComment=a}getComment(){return this.m_strComment}}class PGNGlyph{constructor(a){this.m_glyph=a}getGlyph(){return this.m_glyph}}class PGNMoveNum{constructor(a,b){this.m_num=a;this.m_isBlack=b}}
3898class PGNGame{constructor(){this.m_hdrs={};this.m_mainLine=new PGNSubLine}getHeaders(){return this.m_hdrs}getMainLine(){return this.m_mainLine}}
3899class PGNParser{constructor(a){this.m_lexer=a?a:new PGNLexer("")}acceptGame(){var a=new PGNGame;return this.acceptHeaders(a.m_hdrs)&&this.acceptGameNotation(a)?a:null}acceptGameNoMoves(){var a=new PGNGame;return this.acceptHeaders(a.m_hdrs)?a:null}acceptGameNotation(a){this.acceptNotation(a.m_mainLine);var b=this.acceptResult();null!=b&&(a.m_hdrs.result=b);return!0}static isResultTokenType(a){return a===TokenType.RES_0_1||a===TokenType.RES_1_0||a===TokenType.RES_1_2||a===TokenType.RES_STAR}acceptResult(){var a=
3900this.m_lexer.pop(PGNParser.isResultTokenType);if(a)switch(a.type){case TokenType.RES_0_1:return GameResultEnum.BLACK_WINS;case TokenType.RES_1_0:return GameResultEnum.WHITE_WINS;case TokenType.RES_1_2:return GameResultEnum.DRAW;case TokenType.RES_STAR:return GameResultEnum.LINE}return null}acceptNotation(a){for(var b=this.acceptNotaElem();null!=b;b=this.acceptNotaElem())a.push(b);return!0}acceptNotaElem(){var a=this.acceptMoveNum();return a||(a=this.acceptMove())||(a=this.acceptGlyph())||(a=this.acceptSubLine())?
3901a:(a=this.acceptComment())?a:null}static tokenTypeToGlyph(a){switch(a){case TokenType.BAD:return SpecialGlyphs.BAD_MOVE;case TokenType.BAD_GOOD:return SpecialGlyphs.DUBIOUS_MOVE;case TokenType.GOOD:return SpecialGlyphs.GOOD_MOVE;case TokenType.GOOD_BAD:return SpecialGlyphs.SPECULATIVE_MOVE;case TokenType.VERY_GOOD:return SpecialGlyphs.VERY_GOOD_MOVE;case TokenType.VERY_BAD:return SpecialGlyphs.VERY_BAD_MOVE;case TokenType.WHITE_WINNING:return SpecialGlyphs.W_DECIS_ADV;case TokenType.BLACK_WINNING:return SpecialGlyphs.B_DECIS_ADV;
3902default:return SpecialGlyphs.NONE}}isGlyphType(a){return PGNParser.tokenTypeToGlyph(a)!==SpecialGlyphs.NONE}acceptGlyph(){if(this.m_lexer.popT(TokenType.BUCK)){var a=this.m_lexer.popT(TokenType.NUM);return new PGNGlyph(Number(a.str))}return(a=this.m_lexer.pop(this.isGlyphType))?(a=PGNParser.tokenTypeToGlyph(a.type),new PGNGlyph(a)):null}acceptSubLine(){if(this.m_lexer.popT(TokenType.VAR_OP)){var a=new PGNSubLine;this.acceptNotation(a);this.m_lexer.popT(TokenType.VAR_CL);return a}return null}acceptComment(){var a=
3903this.m_lexer.popT(TokenType.COMMENT);return a?new PGNComment(a.str):null}acceptMoveNum(){var a=this.m_lexer.popT(TokenType.NUM);if(a){for(var b=0;this.m_lexer.popT(TokenType.DOT);)++b;
3903return new PGNMoveNum(Number(a.str),1<b)}return null}static isMoveTokenType(a){return a===TokenType.MOVE||a===TokenType.LONG_ROCHADE||a===TokenType.SHORT_ROCHADE||a===TokenType.NULLMOVE}acceptMove(){var a=this.m_lexer.pop(PGNParser.isMoveTokenType);if(a){var b=new PGNMove;switch(a.type){case TokenType.MOVE:b.init(a.str);
3904break;case TokenType.LONG_ROCHADE:b.setLongCastling();break;case TokenType.SHORT_ROCHADE:b.setShortCastling();break;case TokenType.NULLMOVE:b.setNullMove()}if(a.type!==TokenType.NULLMOVE){a=null!=this.m_lexer.popT(TokenType.CHECK);var c=!1;a||(c=null!=this.m_lexer.popT(TokenType.MATE));b.setCheck(a);b.setMate(c)}return b}return null}acceptHeaders(a){for(;this.acceptHeader(a););return!0}acceptHeader(a){if(this.m_lexer.popT(TokenType.HEAD_OP)){var b=this.m_lexer.popT(TokenType.STR_VAR),c=this.m_lexer.popT(TokenType.STR_VAL);
3905this.m_lexer.popT(TokenType.HEAD_CL);b&&(b=b.str.toLowerCase(),a[b]=c.str);return!0}return!1}static toColSq(a){for(var b=new ColSqAnno,c=0,d=a.length;c<d;++c){var e=a[c],f=new ColSq;f.init(e);b.push(f)}return b}static toColArrow(a){for(var b=new ColArrowAnno,c=0,d=a.length;c<d;++c){var e=a[c],f=new ColArrow;f.init(e);b.push(f)}return b}static toDiag(a){var b="";0<a.length&&(b=a[0]);return new TextAnno(b)}static toTime(a){a=a[0].split(":");a=3600*Number(a[0])+60*Number(a[1])+Number(a[2]);var b=new TimeAnno;
3906b.fromCentiSecs(100*a);return b}static toEval(a){var b=.01*Number(a[0]),c=0;1<a.length&&(c=Number(a[1]));return new EvalAnno(b,c)}static toTraining(a){var b=new TrainingAnno;b.type=0;if(7<=a.length&&2==a[0].length){var c=-1;b.move=Move.fromString(a[4]);for(var d=0;d<a.length/7;d++)if(2==a[7*d].length){b.texts[a[7*d].toLowerCase()]={question:a[7*d+1],help:a[7*d+2]};var e=parseInt(a[7*d+6]);c<e&&(c=e,b.move=Move.fromString(a[7*d+4]))}}else b.move=a[3],b.texts.en={question:a[0],help:a[1]};b.fromPGN=
3907!0;return b}static toMultipleChoice(a){var b=new TrainingAnno;b.type=1;if(7<=a.length&&2>=a[0].length){for(var c=-1,d=parseInt(a[0]),e=1;e<=d;++e){var f=parseInt(a[e]);c<f&&(c=f,b.best=e-1)}for(c=d+1;c<a.length;c+=2*d+4)if(2==a[c].length)for(e=a[c].toLowerCase(),b.texts[e]={question:a[c+1],help:a[c+2],answers:[]},f=c+4;f<c+4+2*d;f+=2)b.texts[e].answers.push(a[f])}b.fromPGN=!0;return b}static toEvalProfile(a){var b=[];if(3<a.length){for(var c=parseInt(a[0]),d=parseInt(a[1]),e=0;e<d-c+1;e++)b.push(parseInt(a[e+
39082]));a=new EvalProfileAnno(c,d,b);a.fromPGN=!0;return a}}static toMedal(a){return new MoveMedalAnno(parseInt(a[0]))}static PGNAnnoResolver={cal:{func:PGNParser.toColArrow,type:AnnoType.ARROW_LIST},csl:{func:PGNParser.toColSq,type:AnnoType.SQUARE_LIST},dia:{func:PGNParser.toDiag,type:AnnoType.DIAGRAM},eval:{func:PGNParser.toEval,type:AnnoType.FRITZ_EVAL},emt:{func:PGNParser.toTime,type:AnnoType.TIME},tqu:{func:PGNParser.toTraining,type:AnnoType.TRAINING},tmc:{func:PGNParser.toMultipleChoice,type:AnnoType.TRAINING},
3909mdl:{func:PGNParser.toMedal,type:AnnoType.MOVE_MEDAL},evp:{func:PGNParser.toEvalProfile,type:AnnoType.EVAL_PROFILE}};static g_regexEval=/(-?(?:\d?\d\.\s?\d\d?)|(?:#\d+))\/\s?(\d+)/;static toAnno(a,b){if(0<=b.indexOf("/")){var c=b.replace(/\r/g," ");c=c.replace(/\n/g," ");c=c.replace(/\s\s/g," ");var d=PGNParser.g_regexEval.exec(c);d&&(b=d[1],b=b.replace(/\s/g,""),b=0===b.indexOf("#")?32E3:0===b.indexOf("-#")?-32E3:Number(b),b=new EvalAnno(b,Number(d[2])),a.setAnnoItem(AnnoType.FRITZ_EVAL,b),b=d.index,
3910d=d[0].length,b=c.substring(0,b)+c.substring(b+d))}if(0<=b.indexOf("[%")){c=[];b=PGNCommand.process(b,c);var e=0;for(d=c.length;e<d;++e){var f=c[e];if(f.m_cmd in PGNParser.PGNAnnoResolver){var g=PGNParser.PGNAnnoResolver[f.m_cmd],h=g.type;(f=g.func(f.m_args))&&a.setAnnoItem(h,f)}}}b&&a.setAnnoItem(AnnoType.POSTTEXT,new TextAnno(b))}}
3911class PGN{static checkUndefined(a){return void 0===a?"":"?"===a?"":a}static isDefined(a){return a&&"?"!==a}static toHeader(a){var b=new GameHeader;b.setWhite(PGN.checkUndefined(a.white));b.setBlack(PGN.checkUndefined(a.black));b.setEvent(PGN.checkUndefined(a.event));b.setSite(PGN.checkUndefined(a.site));b.setAnnotator(PGN.checkUndefined(a.annotator));b.setECO(PGN.checkUndefined(a.eco));var c=a.result;"string"===typeof c?b.setResult(GameResultEnum.fromString(c)):b.setResult(c);
3911b.setRoundStr(PGN.checkUndefined(a.round));
3912PGN.isDefined(a.whiteelo)&&b.setEloWhite(parseInt(a.whiteelo));PGN.isDefined(a.blackelo)&&b.setEloBlack(parseInt(a.blackelo));PGN.isDefined(a.date)&&b.setDateStr(a.date);PGN.isDefined(a.timecontrol)&&b.setClockParams(PGN.toClockParams(a.timecontrol));PGN.isDefined(a.plycount)&&(b.plyCount=parseInt(a.plycount)+1>>1);PGN.isDefined(a.variant)&&-1!=a.variant.indexOf("960")&&(b.variant="Chess960");return b}static rexCP=/^(\d+)(?:\+(\d+))?$/;static toClockParams(a){return(a=PGN.rexCP.exec(a))?new ClockParams(Number(a[1])/
391360,Number(a[2])):new ClockParams}static toGame(a){var b=null,c=a.getHeaders();c.fen&&(b=c.fen);b&&PGN.checkChess960(b);c=PGN.toHeader(c);b=new Position(b);PGN.Chess960CastlingFlags&&(b.ty=2,b.m_nWK00Sq=PGN.Chess960InitialWhiteKingPosition,b.m_nBK00Sq=PGN.Chess960InitialBlackKingPosition,b.m_nWR00Sq=PGN.Chess960InitialWhiteRookPosition2,b.m_nWR000Sq=PGN.Chess960InitialWhiteRookPosition1,b.m_nBR00Sq=PGN.Chess960InitialBlackRookPosition2,b.m_nBR000Sq=PGN.Chess960InitialBlackRookPosition1,b.m_nPosInx=
3914-1);a=a.getMainLine();a=PGN.toLine(b,a);a=new Game(b,a);a.setHeader(c);return a}static checkChess960(a){a=a.split(" ");var b=a[2],c=b.charAt(0);"A"<=c&&"H">=c?(PGN.Chess960CastlingFlags=b,a=a[0],a=a.substring(a.length-8),b=a.indexOf("K"),c=b%8,PGN.Chess960InitialWhiteKingPosition=CBSquare.I(c,0),PGN.Chess960InitialBlackKingPosition=CBSquare.I(c,7),b=a.indexOf("R"),c=b%8,PGN.Chess960InitialWhiteRookPosition1=CBSquare.I(c,0),PGN.Chess960InitialBlackRookPosition1=CBSquare.I(c,7),b=a.indexOf("R",b+1),
3915c=b%8,PGN.Chess960InitialWhiteRookPosition2=CBSquare.I(c,0),PGN.Chess960InitialBlackRookPosition2=CBSquare.I(c,7)):PGN.clearChess960Fields()}static toMove(a,b){if(a.isLongCastling()){var c=b.isWTM()?Move.g_mvW000:Move.g_mvB000;PGN.Chess960CastlingFlags&&(c=b.isWTM()?new Move(PGN.Chess960InitialWhiteKingPosition,PGN.Chess960InitialWhiteRookPosition1):new Move(PGN.Chess960InitialBlackKingPosition,PGN.Chess960InitialBlackRookPosition1),c.Chess960LongCastling=!0);if(PGN.trustLegal||b.isLegalMove(c))return ObjUtil.clone(c)}if(a.isShortCastling()&&
3916(c=b.isWTM()?Move.g_mvW00:Move.g_mvB00,PGN.Chess960CastlingFlags&&(c=b.isWTM()?new Move(PGN.Chess960InitialWhiteKingPosition,PGN.Chess960InitialWhiteRookPosition2):new Move(PGN.Chess960InitialBlackKingPosition,PGN.Chess960InitialBlackRookPosition2),c.Chess960ShortCastling=!0),PGN.trustLegal||b.isLegalMove(c)))return ObjUtil.clone(c);if(a.isNullMove())return new Move;var d=a.getTo(),e=a.getMoved(),f=b.Vj(),g=a.getProm();e!==Piece.PAWN&&(g=Piece.NONE);c=[];switch(e){case Piece.KNIGHT:b.getKnightAttacksTo(d,
3917f,c);break;case Piece.BISHOP:b.getBishopAttacksTo(d,f,c);break;case Piece.ROOK:b.getRookAttacksTo(d,f,c);break;case Piece.QUEEN:b.getQueenAttacksTo(d,f,c);break;case Piece.KING:b.getKingAttacksTo(d,f,c);break;case Piece.PAWN:a.isTake()?(e=b.getPiece(d),e===Piece.NONE&&d===b.getEPField()&&(e=b.getEPVictimField(),e=b.getPiece(e)),e!==Piece.NONE&&Piece.side(e)!==f&&b.getPawnAttacksTo(d,f,c)):(e=b.getPiece(d),e===Piece.NONE&&b.getPawnMovesTo(d,f,c));break;default:return null}if(!c.length)return null;
3918if(1===c.length&&PGN.trustLegal)return new Move(c[0],d,g);a=a.matchesFrom.bind(a);c=c.filter(a);if(!c.length)return null;if(1===c.length&&PGN.trustLegal)return new Move(c[0],d);a=c.map(function(h){return new Move(h,d)});a=b.filterLegals(a);return a.length?1===a.length?a[0]:null:null}static detectLineEnd(a){for(var b=["\r\n","\n","\r"],c=0,d=b.length;c<d;++c){var e=b[c];if(0<=a.indexOf(e))return e}return null}static fixMixed(a){a=a.replace(/\r\n/g,"\n");return a=a.replace(/\r/g,"\n")}static canBeMixed(a){return 0<=
3919a.indexOf("\r\r")||0<=a.indexOf("\n\n")}static Chess960CastlingFlags=null;static Chess960InitialWhiteKingPosition=null;static Chess960InitialBlackKingPosition=null;static Chess960InitialWhiteRookPosition1=null;static Chess960InitialWhiteRookPosition2=null;static Chess960InitialBlackRookPosition1=null;static Chess960InitialBlackRookPosition2=null;static splitGames(a){var b=a.indexOf("[");-1==b&&(b=a.indexOf("1."));0<b&&(a=a.slice(b));b=[];var c=PGN.detectLineEnd(a);if(null==c)return[a];"\r\n"===c&&
3920PGN.canBeMixed(a)&&(a=PGN.fixMixed(a),c="\n");var d=c+c+"[";c=2*c.length;for(var e=0,f=a.indexOf(d,e);-1!=f&&e<a.length;f=a.indexOf(d,e))e=a.substring(e,f),b.push(e),e=f+c;e<a.length&&(a=a.substring(e),b.push(a));return b}static g_regexHdr=/\[(\w+)\s+"([\s\S]*?)"\]/g;static g_regexWS=/^\s*$/;static repair(a){var b=PGN.detectLineEnd(a);b||="\r\n";for(var c=PGN.g_regexHdr,d=PGN.g_regexWS,e=new StringBuilder,f=c.lastIndex=0,g;g=c.exec(a);){var h=g.index;f=a.substring(f,h);d.test(f)||(e.append(b),e.append(f.trim()),
3921e.append(b),e.append(b));f=g[1];var k=g[2];k=k.replace(/\r/g," ");k=k.replace(/\n/g," ");e.appendFormat('[{0} "{1}"]',f,k);e.append(b);f=h+g[0].length}a=a.substring(f);d.test(a)||(e.append(b),e.append(a.trim()),e.append(b),e.append(b));return e.toString()}static trustLegal=!0;static clearChess960Fields(){PGN.Chess960CastlingFlags=null;PGN.Chess960InitialWhiteKingPosition=null;PGN.Chess960InitialBlackKingPosition=null;PGN.Chess960InitialWhiteRookPosition1=null;PGN.Chess960InitialWhiteRookPosition2=
3922null;PGN.Chess960InitialBlackRookPosition1=null;PGN.Chess960InitialBlackRookPosition2=null}static parseGame(a){return a?(PGN.clearChess960Fields(),a=new PGNLexer(a),(a=(new PGNParser(a)).acceptGame())?PGN.toGame(a):null):new Game}static parseGameNoMoves(a){return a?(a=new PGNLexer(a),(a=(new PGNParser(a)).acceptGameNoMoves())?PGN.toGame(a):null):new Game}static parseHeader(a){a=new PGNLexer(a);var b={};(new PGNParser(a)).acceptHeaders(b);return b?PGN.toHeader(b):null}static toLine(a,b){var c=ObjUtil.clone(a);
3923a=new MoveLine;for(var d=null,e=null,f=null,g=0,h=b.length;g<h;++g){var k=b[g];if(!(k instanceof PGNMoveNum))if(k instanceof PGNMove){k=PGN.toMove(k,c);if(!k)break;d=c.makeMove(k);e=k;a.push(k);f&&(f.m_strComment&&0==f.m_strComment.indexOf("[%")?PGNParser.toAnno(e,f.getComment()):e.setAnnoItem(AnnoType.PRETEXT,new TextAnno(f.getComment())),f=null)}else if(k instanceof PGNSubLine){if(e){c.unmakeMove(e,d);k=PGN.toLine(c,k);e.addLine(k);var l=a.length-1;k.setParentLine(a);k.setParentMoveIndex(l);c.makeMove(e)}}else k instanceof
3924PGNComment?e?(k=k.getComment(),PGNParser.toAnno(e,k)):(f=k,1>=b.length&&(k=k.getComment(),"["==k[0]&&"[#]"!=k||a.setAnnoItem(AnnoType.PRETEXT,new TextAnno(f.getComment())))):k instanceof PGNGlyph&&e&&((l=e.getAnnoItem(AnnoType.SYMBOL))||(l=new SymbolsAnno),l.push(k.getGlyph()),e.setAnnoItem(AnnoType.SYMBOL,l))}for(b=0;b<a.length-1;b++)a[b].hasAnno()&&a[b].getAnno().hasTraining()&&(c=a[b].getAnno().getTraining(),d=a[b+1],c.move=new Move(d.from,d.to,d.prom));0<a.length&&a[0].hasAnno()&&a[0].getAnno().hasTraining()&&
3925(c=a[0].getAnno().getTraining(),a.setAnnoItem(AnnoType.TRAINING,c),a[0].deleteAnnoItem(AnnoType.TRAINING));return a}}
3926class PGNCommand{constructor(a,b){a||="";b||=[];this.m_cmd=a;this.m_args=b}init(a,b){this.m_cmd=a;PGNCommand.initArgs(b,this.m_args)}static initArgs(a,b){a=a.replace(/[\n]/g," ");a=a.replace(/[\r]/g,"");var c=/(".*?")|([-\w\n]+),|([-:\w\n]+)$/g;c.lastIndex=0;var d;do if(d=c.exec(a)){var e=d[1]||d[2]||d[3];if(e)'"'===e[0]&&(e=e.substring(1),'"'===e[e.length-1]&&(e=e.substring(0,e.length-1))),b.push(e),c.lastIndex===d.index&&++c.lastIndex,d=0<=d.index;else break}else break;while(d)}static g_regexWhole=/\[%(\w+)((?:"[^"]*"|[^"\]]*)*)\]/;static process(a,
3927b){for(;a;){var c=PGNCommand.g_regexWhole.exec(a);if(c){var d=new PGNCommand,e=c[0];d.init(c[1],c[2]);b.push(d);a=a.substring(0,c.index)+a.substring(c.index+e.length)}else break}return a}}"use strict";var PGNLocalization=ObjUtil.copyTo(V5,{strProm:"=",str00:"O-O",str000:"O-O-O"},!0);
3928class PGNWriter{static notaGen=new NotationGenerator(PGNLocalization);static isDefined(a){return a&&"?"!==a}static writeHeader(a,b){var c=b.getHeader();PGNWriter.writeHeaderItem(a,"Event",c.getEvent());PGNWriter.writeHeaderItem(a,"White",c.getWhite());PGNWriter.writeHeaderItem(a,"Black",c.getBlack());PGNWriter.writeHeaderItem(a,"Site",c.getSite());PGNWriter.writeHeaderItem(a,"Round",c.getRoundStr());PGNWriter.writeHeaderItem(a,"Annotator",c.getAnnotator());PGNWriter.writeHeaderItem(a,"Result",c.getCBResult().toPGNString());
3929b.getStartPos().m_nWR00&&(c.variant="chess960");PGNWriter.isDefined(c.variant)&&PGNWriter.writeHeaderItem(a,"Variant",c.variant);PGNWriter.writeHeaderItem(a,"Date",c.getDateStr());c.getEloWhite()&&PGNWriter.writeHeaderItem(a,"WhiteElo",c.getEloWhite());c.getEloBlack()&&PGNWriter.writeHeaderItem(a,"BlackElo",c.getEloBlack());PGNWriter.writeHeaderItem(a,"PlyCount",b.getMainLine().length);if(!b.isNormalInit()){PGNWriter.writeHeaderItem(a,"Setup",1);b=b.getStartPos().toFEN();if(PGNWriter.isDefined(c.variant)&&
3930"chess960"==c.variant.toLowerCase()){b=b.split(" ");var d=b[0],e=d.substring(d.length-8);d=e.indexOf("R");e=e.indexOf("R",d+1);d=String.fromCharCode(d%8+65);e=String.fromCharCode(e%8+65);d=e+d+e.toLowerCase()+d.toLowerCase();b=b[0]+" "+b[1]+" "+d+" "+b[3]+" "+b[4]+" "+b[5]}PGNWriter.writeHeaderItem(a,"FEN",b)}if(c=c.getClockParams())b=c.getStartSecs().toString(),c.incSecs&&(b+="+"+c.incSecs),PGNWriter.writeHeaderItem(a,"TimeControl",b)}static writeCmd(a,b){a.appendFormat("[%{0}",b);if(arguments.length-
39312){a.append(" ");for(var c=2;c<arguments.length;++c){var d=arguments[c];2<c&&a.append(",");a.append(d)}}a.appendFormat("]")}static writeTimeAnno(a,b){b=b.getTimeIn100th();var c=Math.floor(b/36E4);b-=36E4*c;var d=Math.floor(b/6E3);PGNWriter.writeCmd(a,"emt",String.formatEx("{0}:{1}:{2}",c,d,Math.round((b-6E3*d)/100,1)))}static writeColSqAnno(a,b){let c="";for(let d=0;d<b.length;
3931d++){let e=b[d],f=CBSquare.toString(e.field),g="Y";switch(e.color){case 1:g="G";break;case 2:g="Y";break;case 3:g="R";break;
3932case 4:g="LR";break;case 5:g="LG";break;case 6:g="B";break;case 7:g="C";break;case 8:g="O"}c+=g+f;d<b.length-1&&(c+=",")}a.appendFormat("[%csl {0}]",c)}static writeMedalAnno(a,b){a.appendFormat("[%mdl {0}]",b.medal)}static writeArrows(a,b){let c="";for(let d=0;d<b.length;d++){let e=b[d],f=CBSquare.toString(e.from),g=CBSquare.toString(e.to),h="Y";switch(e.color){case 1:h="G";break;case 2:h="Y";break;case 3:h="R";break;case 4:h="LR";break;case 5:h="LG";break;case 6:h="B";break;case 7:h="C";break;case 8:h=
3933"O"}c+=h+f+g;d<b.length-1&&(c+=",")}a.appendFormat("[%cal {0}]",c)}static writeTrainingAnno(a,b){if(0>b.best){var c=[];for(var d of Object.keys(b.texts))c.push(`"${d}", "${b.texts[d].question||""}", "${b.texts[d].help||""}", "", "${b.move}", "", 10`);b=c.join(",");a.appendFormat("[%tqu {0}]",b)}else{d=[];var e=0;let g=["0"];for(var f of Object.keys(b.texts))b.best===e?g.push("10"):g.push("0"),++e;g[0]=e.toString();e=g.join(",");for(c of Object.keys(b.texts))for(d.push(`"${c}", "${b.texts[c].question||
3934""}", "${b.texts[c].help||""}", ""`),f=0;f<b.texts[c].answers.size;++f)d.push(`"${b.texts[c].answers[f]||""}", ""`);e+=","+d.join(",");a.appendFormat("[%tmc {0}]",e)}}static writeEvaluationProfile(a,b){b=[b.first,b.last,...b.evalArr].join();a.append(`[%evp ${b}]`)}static writePostAnno(a,b){var c=b.getItem(AnnoType.SYMBOL);if(c)for(var d=0,e=c.length;d<e;++d)a.appendFormat("${0} ",c[d]);c=b.count();b.hasItem(AnnoType.SYMBOL)&&--c;b.hasItem(AnnoType.PRETEXT)&&--c;b.hasItem(AnnoType.EVAL_PROFILE)&&--c;
3935c&&(a.append("{"),(c=b[AnnoType.TIME])&&PGNWriter.writeTimeAnno(a,c),(c=b[AnnoType.SQUARE_LIST])&&PGNWriter.writeColSqAnno(a,c),(c=b[AnnoType.ARROW_LIST])&&PGNWriter.writeArrows(a,c),(c=b[AnnoType.TRAINING])&&PGNWriter.writeTrainingAnno(a,c),(c=b[AnnoType.MOVE_MEDAL])&&PGNWriter.writeMedalAnno(a,c),(b=b[AnnoType.POSTTEXT])&&a.append(b.getString()),a.append("} "))}static writePreAnno(a,b){let c=b[AnnoType.EVAL_PROFILE];if((b=b[AnnoType.PRETEXT])||c)a.append("{"),c&&PGNWriter.writeEvaluationProfile(a,
3936c),b&&a.append(b.getString()),a.append("} ")}static writeMove(a,b,c,d){if(b){var e=b.getAnno();b.hasAnno()&&PGNWriter.writePreAnno(a,e);var f=b.getMoved();if(d||Piece.side(f)===Side.WHITE)a.append(c),a.append("."),Piece.side(f)===Side.BLACK&&a.append(".."),a.append(" ");d=PGNWriter.notaGen.getMoveNota(b);a.append(d);a.append(" ");b.hasAnno()&&PGNWriter.writePostAnno(a,e);if(b.hasLines())for(e=0;e<b.getSubLinesCount();++e)a.append("("),d=b.getLine(e),PGNWriter.writeLine(a,d,c),a.append(")")}}static writeLine(a,
3937b,c){for(var d=0;d<b.length;++d){var e=b[d];if(e){var f=e.getMoved();PGNWriter.writeMove(a,e,c,0==d);Piece.side(f)===Side.BLACK&&++c}else break}}static writeGame(a,b){var c=1;b.isNormalInit()||(c=b.getStartPos().getMoveNum());let d=b.getAnnoBeforeFirstMove();d&&(PGNWriter.writePreAnno(a,d),PGNWriter.writePostAnno(a,d));PGNWriter.writeLine(a,b.getMainLine(),c)}static writeHeaderItem(a,b,c){a.appendFormat('[{0} "{1}"]',b,c);a.append("\r\n")}static toPGN(a){var b=new StringBuilder;PGNWriter.writeHeader(b,
3938a);b.append("\r\n");PGNWriter.writeGame(b,a);b.append(a.hdr.getCBResult().toPGNString());b.append("\r\n");b.append("\r\n");return b.toString()}static arrayToPGN(a){return a.map(PGNWriter.toPGN).join("\n")}static toUrlPGN(a){a=PGNWriter.toPGN(a);for(var b=['Site "?"','Round "?"','Date "????.??.??"','Result "*"'],c=0;c<b.length;c++)a=a.replace("/["+b[c]+"/]/ig","");a=encodeURI(a);a=a.replace(/\.%20/ig,".");a=a.replace(/%0D%0A/ig,"%20");a=a.replace(/%20%20/ig,"%20");return a=a.replace(/%20%20/ig,"%20")}static toFEN(a){var b=
3939new StringBuilder;a=a.getCurPos().toFEN();b.append(a);return b.toString()}}"use strict";
3940class CBDatabase{constructor(){this.nGames=0;this.games=[];this.headers=[];this.nUsers=0;this.setStartGameIndex(0);this.setPageSize(200);this.filterText=""}setupListeners(a){}incUsers(){this.nUsers++}decUsers(){this.nUsers--}getNUsers(){return this.nUsers}getCopySrcId(){}beginUse(){this.manager&&this.manager.beginUse(this)}endUse(){this.manager&&this.manager.endUse(this)}importGames(a,b){alert("not implemented")}isLoadFromFile(){return!0}canSaveTo(){return!1}shouldShowLastGame(){return!1}getGameCount(){return this.nGames}getDisplayTitle(){return"Database"}isSortable(){return this.isLoadFromFile()}getHeaderJson(a){return{gameNo:a,white:"Not available",
3941black:"",event:"",date:new CBDate(0),result:"",eco:""}}loadHeadersJsonAsync(a,b,c){var d=[];for(LOG("Headers Async: "+b+" - "+c);b<=c&&b<=this.getGameCount();b++){var e=this.getHeaderJson(b);d.push(e)}(new Ext.util.DelayedTask).delay(100,function(){a(d)})}getGame(a){return new Game}loadGameAsync(a,b){var c=this.getGame(b);(new Timer(function(){a(c)})).runOnce(10)}toggleDeleteMark(a){}toggleDeleteMarks(a){}removeDeletedGames(){}setSubSet(a){this.subSet=a}addToSubSet(a){this.subSet||(this.subSet=[]);
3942this.subSet=this.subSet.concat(a)}clearSubSet(){delete this.subSet}getSetSize(){return this.subSet?this.subSet.length:this.getGameCount()}getGameNoInSet(a){return this.subSet&&a<=this.subSet.length&&0<a?this.subSet[a-1]:a}getSetInxOfGameNo(a){if(this.subSet)for(var b=0;b<this.subSet.length;b++){if(this.subSet[b]==a)return b+1}else return a}setFilter(a){this.headers.filter(function(b){return void 0!==b}).length!=this.nGames&&this.manager?this.manager&&this.manager.requestFilterSet(this.getCopySrcId(),
3943a):this.filterLocalHeaders(a)}clearFilter(){this.clearSubSet()}filterLocalHeaders(a){glApp.panelMgr.EXTIsNotSupported||ToolButtons.showBusyMask("Searching locally ... ",null,2E4);a=new RegExp(a,"i");LOG(a);LOG(typeof a);for(var b=[],c=1;c<this.headers.length;c++)this.headers[c].matchesFilterVal(a)&&b.push(this.headers[c].nGame);glApp.panelMgr.EXTIsNotSupported||ToolButtons.hideBusyMask();this.setSubSet(b)}sortHeaders(a,b){}getPageSize(){return this.pageSize}setPageSize(a){1>a&&(a=1);this.pageSize=
3944a}getStartGameIndex(){return this.startGameIndex}setStartGameIndex(a){0>a&&(a=0);this.startGameIndex=a}getEndGameIndex(){var a=this.getStartGameIndex()+this.getPageSize();a>this.getSetSize()&&(a=this.getSetSize());return a}getPagedGamesHeadersJson(){for(var a=[],b=this.getStartGameIndex();b<this.getEndGameIndex();b++)if(this.subSet){if(this.subSet[b]<=this.getGameCount()){var c=this.getHeaderJson(this.subSet[b]);a.push(c)}}else c=this.getHeaderJson(b+1),a.push(c);return a}}"use strict";
3945class PgnDatabase extends CBDatabase{constructor(a,b){super();this.pgn="";this.gameStrings=[];this.headers=[];this.games=[];this.loadFinished=!1;this.callbackOnLoaded=b;"string"==typeof a?this._fromText(a):(this._fromFile(a),this.fileName=a.name)}getGameCount(){return this.gameStrings.length}getDisplayTitle(){return this.fileName}getCopySrcId(){return function(a){for(var b=[],c=0;c<a.length;c++){var d=this.getGame(a[c]);b.push(d)}return b}.bind(this)}
3945getHeaderJson(a){if(0>=a)return null;void 0===
3946this.headers[a]&&a<this.gameStrings.length+1&&(this.headers[a]=PGN.parseHeader(this.gameStrings[a-1]));var b=this.headers[a];return b?(b.nGame=a,b.toJson()):super.getHeaderJson(a)}loadHeadersJsonAsync(a,b,c){if(this.loadFinished)this.loadHeadersImpl(a,b,c);else{var d=this.callbackOnLoaded;this.callbackOnLoaded=function(){d&&d(this);this.loadHeadersImpl(a,b,c)}.bind(this)}}loadHeadersImpl(a,b,c){var d=[];for(LOG("Headers Async: "+b+" - "+c);b<=c&&b<=this.getGameCount();b++){var e=this.getHeaderJson(b);
3947d.push(e)}(new Ext.util.DelayedTask).delay(100,function(){a(d)})}getGame(a){return a?PGN.parseGame(this.gameStrings[a-1]):new Game}importGames(a,b){alert("Sorry, you cannot save into a PGN database.")}toString(){for(var a="",b=1;b<=this.getGameCount();b++){var c=this.getGame(b);c=PGNWriter.toPGN(c);a+=c}return a}_fromText(a){this.gameStrings=PGN.splitGames(a);void 0!==this.callbackOnLoaded&&this.callbackOnLoaded(this);this.loadFinished=!0}_fromFile(a){if("function"==typeof FileReader){var b=new FileReader;
3948b.onloadend=function(){this._loadDone(b)}.bind(this);b.onerror=function(){this._loadError(b)}.bind(this);b.onprogress=function(){LOG("On Progress")}.bind(this);b.onload=function(){LOG("On Load")}.bind(this);b.readAsText(a)}}_loadDone(a){a.result&&(this.gameStrings=PGN.splitGames(a.result),void 0!==this.callbackOnLoaded&&this.callbackOnLoaded(this));this.loadFinished=!0}_loadError(a){alert("Could not load file, sorry");this.loadFinished=!0}loadHeaderIfMissing(a){this.headers[a]||(this.headers[a]=PGN.parseHeader(this.gameStrings[a-
39491]),this.headers[a].nGame=a)}filterLocalHeaders(a){glApp.panelMgr.EXTIsNotSupported||ToolButtons.showBusyMask("Searching locally ... ",null,2E4);a=new RegExp(a,"i");for(var b=[],c=1;c<=this.getGameCount();c++)this.loadHeaderIfMissing(c),this.headers[c].matchesFilterVal(a)&&b.push(this.headers[c].nGame);glApp.panelMgr.EXTIsNotSupported||ToolButtons.hideBusyMask();this.setSubSet(b)}sortHeaders(a,b){glApp.panelMgr.EXTIsNotSupported||ToolButtons.showBusyMask("Sorting ... ",null,2E4);for(var c=[],d=0;d<
3950this.getSetSize();d++){var e=this.subSet?this.subSet[d]:d+1;this.loadHeaderIfMissing(e);c[d]=this.headers[e]}(function(f,g,h){f=f.sort(function(k,l){return h?k[g]>l[g]?1:k[g]<l[g]?-1:0:l[g]>k[g]?1:l[g]<k[g]?-1:0})})(c,a,b);a=[];for(d=0;d<c.length;d++)a.push(c[d].nGame);this.setSubSet(a);glApp.panelMgr.EXTIsNotSupported||ToolButtons.hideBusyMask()}}"use strict";
3951var StreamingItemType={NONE:0,WMV:1,MP4:2,SMOOTHSTREAMING:4,THUMB:8,META:16,GAMEACTIONS:32,MPEGDASH:64,HLSV3:128,HLSV4:256,WOWZA:512},BroadcastStreamingItemEx=function(){var a=function(b,c){this.strUrl=b;this.type=c};a.prototype.fromDataBuf=function(b){this.strUrl=b.V12(2048);this.type=b.V19()};return a}();"use strict";
3952var StreamingDataFlags={NONE:0,LIVE:1},BroadcastStreamingDataEx=function(){var a=function(){this.items=[]};a.prototype.add=function(b){this.items.push(b)};a.prototype.fromDataBuf=function(b){this.nGameId=b.V19();for(var c=b.V19(),d=0;d<c;d++){var e=new BroadcastStreamingItemEx;e.fromDataBuf(b);this.items.push(e)}this.nFlags=b.V19();this.nCosts=b.V19()};a.prototype.isLive=function(){return this.nFlags&StreamingDataFlags.LIVE};a.prototype.getURL=function(b){for(var c="",d=0;d<this.items.length;d++)b&
3953this.items[d].type&&(c=this.items[d].strUrl);return c};return a}();"use strict";var ChatStreamData=function(){var a=function(){};a.prototype.read=function(b){b.rewind();try{this.strMsg=b.Vb(4096)}catch(c){LogException("ChatStreamData Msg Len exception")}this.m_eWeight=b.V1a();this.m_eColName=b.V1a();this.m_eReserved=b.V1a();this.m_eEmosound=b.V1a();this.m_nFlags=b.V19();this.m_nTotalReceivers=b.V19();this.m_nChannel=b.V19();this.m_nReserved=b.V19();this.m_strSenderName=b.Vb(50)};return a}();
3954let RecorderState={RecordStopped:0,RecordNormal:1,RecordSolution:2,RecordGoodMove:3,RecordOtherMoves:4,RecordOtherMovesNoVideo:5};"use strict";
3955let MediaPlayerType={MediaPlayerUnknown:0,MediaPlayerWMV:1,MediaPlayerFlash:2,MediaPlayerHTML:3,MediaPlayerSL:4,MediaPlayerMPEGDASH:5,MediaPlayerAzure:6,MediaPlayerWowza:7},RadioManager=function(){var a=MediaPlayerType.MediaPlayerUnknown,b=0,c=function(d,e){this.playerAuthenticated=!1;this.gameActions=[];this.chatActions=[];this.el=e;this.gameHeaderStr="";CBQ(this.el).html("<div id='wmpHolder'></div>");this.baseurl=glApp.config.getVideoPortalUris()[0];a=d;this.determineBrowser()};c.prototype.cleanUp=
3956function(){this.remove("MediaPlayer1")};c.prototype.remove=function(d){(d=document.getElementById(d))&&d.parentNode.removeChild(d)};c.prototype.getPlayerType=function(){return a};c.prototype.detectWMP=function(){};c.prototype.getWidth=function(){if(a==MediaPlayerType.MediaPlayerAzure){var d=amp("azuremediaplayer");if(d)return d.width()}return 0};c.prototype.getHeight=function(){if(a==MediaPlayerType.MediaPlayerAzure){var d=amp("azuremediaplayer");if(d)return d.height()}return 0};c.prototype.determineBrowser=
3957function(){switch(a){case MediaPlayerType.MediaPlayerAzure:this.prepareAzure();break;case MediaPlayerType.MediaPlayerUnknown:this.prepareLegacy()}};c.prototype.prepareAzure=function(){a==MediaPlayerType.MediaPlayerAzure&&this.setupAzureMediaPlayer()};c.prototype.prepareLegacy=function(){window.chrome&&window.chrome.webstore?this.setupHLS():System.isMobile()?this.setupHTML():!this.isWindows()&&System.isWebKit()?this.setupHTML():this.isWindows()?System.isActivexEnabled()?(this.detectWMP(),null!=this.P&&
3958this.P.version?this.setupWMV():this.setupHelp()):this.setupHLS():this.setupHTML()};c.prototype.isMp4Client=function(){var d=!1;System.isActivexEnabled()&&(this.detectWMP(),null!=this.P&&this.P.version&&(d=!0));return!d};c.prototype.generateWindowsMediaPlayer=function(d,e,f,g){d=document.getElementById(d);e='<object ID="MediaPlayer1"';e=window.MSStream||0<=navigator.userAgent.indexOf("MSIE")?e+'height="90%" width="100%" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" >':e+'type="application/x-ms-wmp" height="300" width="600" ';
3959d&&(d.innerHTML=e+'<param name="autoStart" value="true" /><param name="playCount" value="1" /></object>
3959<LAYER id="contentNav" TOP=20 LEFT=190 WIDTH=240><NOLAYER><DIV id="contentIE" CLASS="content"></DIV></NOLAYER></LAYER>')};c.prototype.generateHLSPlayer=function(d,e,f){d=document.getElementById(d);jwplayer("wmpHolder").setup({file:"http://video.chessbase.com/js/hls1/hls0.m3u8",image:"http://shop.chessbase.com/pics/p_6251",autostart:!0,width:"100%",height:"100%",primary:"flash"});return d};c.prototype.generateHTMLPlayer=
3960function(d,e,f,g){d=document.getElementById(d);g='<video src="'+g+'" controls autoplay></video>';d&&(d.innerHTML=g);g=document.getElementsByTagName("video")[0];g.addEventListener("loadeddata",function(){this.getStartTimeFromDB();this.getCMSIFenPositions()}.bind(this));g.addEventListener("ended",function(){setTimeout(this.callGetNextIdAtEnd.bind(this),500)}.bind(this));return d};c.prototype.generateSLPlayer=function(d,e,f){};c.prototype.onError=function(){alert("onError")};c.prototype.generateHTMLHelp=
3961function(d){if(d=document.getElementById(d))d.innerHTML='For instructions click on the <a href="http://play.chessbase.com/js/apps/playchess/playchesscms.html">link</a>';return d};c.prototype.stop=function(){if(a==MediaPlayerType.MediaPlayerWMV){var d=document.getElementById("MediaPlayer1");null!=d&&null!=d.controls&&d.controls.stop()}};c.prototype.isWindows=function(){return-1!=navigator.appVersion.indexOf("Win")};c.prototype.autoPlay=function(){var d=StrUtil.getURLParam("autoplay"),e=!0;null!=d&&
3962(e="false"!=d);return e};c.prototype.generateAzureMediaPlayer=function(d,e,f,g){var h=this.autoPlay(),k=Language.getStrUserLanguage();d=document.getElementById(d);var l=CBQ.get("azuremediaplayer");if(g&&0<g.length){if(null==l){var m={nativeControlsForTouch:!1,language:k,autoplay:h,controls:!0,width:f,height:e,poster:"",logo:{enabled:!1}};System.isWebKit()&&(m={nativeControlsForTouch:!1,language:k,techOrder:["azureHtml5JS","html5","flashSS","silverlightSS"],controls:!0,autoplay:h,width:f,height:e,
3963poster:"",logo:{enabled:!1}});d.innerHTML=h?"<video id='azuremediaplayer' class='azuremediaplayer amp-default-skin' controls autoplay amp-big-play-centered tabindex='0'> </video></div>":"<video id='azuremediaplayer' class='azuremediaplayer amp-default-skin' controls amp-big-play-centered tabindex='0'> </video></div>";l=amp("azuremediaplayer",m);amp("azuremediaplayer").src([{src:g,type:"application/vnd.ms-sstr+xml"}]);amp("azuremediaplayer").ready(function(){CBQ(".amp-logo")&&CBQ(".amp-logo").remove();
3964System.isIPhone()||System.isIPad()||l.play()});l.addEventListener("error",function(){var n=l.error();if(n){var r=n.code>>28;n=(n.code&8388607)>>23;if(!System.isIPhone()&&!System.isIPad()){var t=this.getAzureError(l);alert("Sorry, There is a problem with the Video Player: "+t+r+","+n)}}}.bind(this));amp("azuremediaplayer").removeEventListener("loadeddata");amp("azuremediaplayer").addEventListener("loadeddata",function(){this.getStartTimeFromDB();this.getCMSIFenPositions()}.bind(this));amp("azuremediaplayer").removeEventListener("loadedmetadata");
3965amp("azuremediaplayer").addEventListener("loadedmetadata",function(){}.bind(this));amp("azuremediaplayer").isLive()||(amp("azuremediaplayer").removeEventListener("ended"),amp("azuremediaplayer").addEventListener("ended",function(){setTimeout(this.callGetNextIdAtEnd.bind(this),500)}.bind(this)))}amp("azuremediaplayer").src([{src:g,type:"application/vnd.ms-sstr+xml"}]);System.isIPhone()||System.isIPad()||h&&amp("azuremediaplayer").play();amp("azuremediaplayer").controls(!0);amp("azuremediaplayer").options({logo:{enabled:!1}})}return d};
3966c.prototype.getAzureError=function(d){var e="Unknown Error: ";d.error().code&amp.errorCode.abortedErrStart?e="MEDIA_ERR_ABORTED: ":d.error().code&amp.errorCode.networkErrStart?e="MEDIA_ERR_NETWORK: ":d.error().code&amp.errorCode.decodeErrStart?e="MEDIA_ERR_DECODE: ":d.error().code&amp.errorCode.srcErrStart?e="MEDIA_ERR_SRC_NOT_SUPPORTED: ":d.error().code&amp.errorCode.encryptErrStart?e="MEDIA_ERR_ENCRYPTED errors: ":d.error().code&amp.errorCode.srcPlayerMismatchStart&&(e="SRC_PLAYER_MISMATCH error: ");
3967return e};c.prototype.setupAzureMediaPlayer=function(){a=MediaPlayerType.MediaPlayerAzure};c.prototype.setupNanoPlayer=function(){this.generateNanoPlayer("wmpHolder",240,320)};c.prototype.setupWMV=function(){LOG("Setup WMV");this.generateWindowsMediaPlayer("wmpHolder",240,320,"");document.getElementById("MediaPlayer1");a=MediaPlayerType.MediaPlayerWMV};c.prototype.setupHLS=function(){LOG("Setup Flash");this.htmlHolder=this.generateHLSPlayer("wmpHolder",240,320);a=MediaPlayerType.MediaPlayerFlash};
3968c.prototype.setupHTML=function(){LOG("Setup HTML");a=MediaPlayerType.MediaPlayerHTML};c.prototype.setupSL=function(d){};c.prototype.setupAzure=function(d){var e=100,f=100;CBQ.get("azuremediaplayer")||(e=this.generateHTMLHelp("wmpHolder"),f=e.offsetParent.clientWidth,e=e.offsetParent.clientHeight);System.isHTTPS()&&(d=d.replace("http://","https://"));this.htmlHolder=this.generateAzureMediaPlayer("wmpHolder",e,f,d)};c.prototype.setupHelp=function(){this.generateHTMLHelp("wmpHolder")};c.prototype.reportChannel=
3969function(d){LOG("RadionManager::ReportChannel");a==MediaPlayerType.MediaPlayerHTML?(this.htmlHolder=this.generateHTMLPlayer("wmpHolder",240,320,"http://video.chessbase.com/js/hls"+d.sChannel+"/hls0.m3u8"),document.getElementsByTagName("video")[0].play()):a==MediaPlayerType.MediaPlayerFlash&&(this.nChannel=d.sChannel,jwplayer("wmpHolder").load([{file:"http://video.chessbase.com/js/hls"+d.sChannel+"/hls2.m3u8"}]))};c.prototype.downloadFile=function(d){this.askstarttime=!0;var e="",f=CBQ.get("userid");
3970f&&(e=encodeURIComponent(f.innerHTML));d=this.baseurl+"Replay/GetGameActions?id="+d+"&user="+e;this.gameActions=[];this.chatActions=[];CBAJAX.load(d,this.onLoadGameActions.bind(this),{responseType:"text"})};c.prototype.downloadGameActionsFile=function(d){this.gameActions=[];this.chatActions=[];CBAJAX.load(d,this.onLoadGameActions.bind(this),{responseType:"text"})};c.prototype.onLoadGameActions=function(d){d=JSON.parse(d);this.game=new Game;this.cachepos=[];this.cachetime=[];if(d.length)for(var e=
39710;e<d.length;e++){var f=d[e],g=new ScriptCommand;g.time=f.Time;g.type=f.GameActionType;g.action=f.GameActionContent;this.gameActions.push(g);var h=new DataBuffer,k=!0;"TEXT"==g.type&&(k=!1);h.constructFromString(f.GameActionContent,k);h.rewind();g=new GameAction;g.fromDataBuf(h);
3971g.fillExecutedMove();g._doExecute(this.game);h=this.game.getCurPos();this.cachepos.push(h);this.cachetime.push(f.Time)}this.endEventFired=!1;if(0<this.gameActions.length)this.onScriptCommand(this.gameActions[0].type,this.gameActions[0].action);
3972this.currenttime=0;null==this.myTimer&&(this.myTimer=setInterval(this.CMSGameActionsHandler.bind(this),1E3));(d=CBQ.get("userid"))&&encodeURIComponent(d.innerHTML);CBQ.get("videoid")};c.prototype.onLoadChat=function(d){d=JSON.parse(d);if(d.length)for(var e=0;e<d.length;e++){var f=d[e],g=new ScriptCommand;g.time=f.Time;g.type=f.GameActionType;g.action=f.GameActionContent;this.chatActions.push(g)}};c.prototype.onCurGameChanged=function(){var d=this.gameKernel.getCurPos();if(this.cachepos)for(var e=
39730;e<this.cachepos.length;e++)if(d.equals(this.cachepos[e])){this.setStartTime(this.cachetime[e]);break}};c.prototype.b64_to_utf8=function(d){return decodeURIComponent(escape(window.atob(d)))};c.prototype.reportBroadcastStreamingData=function(d){LOG("RadionManager::reportBroadcastStreamingData ");if(a==MediaPlayerType.MediaPlayerWMV){d=d.getURL(StreamingItemType.WMV);var e=document.getElementById("MediaPlayer1");e&&(e.URL=d,e.data=d)}else if(a==MediaPlayerType.MediaPlayerAzure)d=d.getURL(StreamingItemType.SMOOTHSTREAMING),
39740<d.length&&this.setupAzure(d);else if(a!=StreamingItemType.SMOOTHSTREAMING)if(a==MediaPlayerType.MediaPlayerHTML){d=d.getURL(StreamingItemType.MP4);this.htmlHolder=this.generateHTMLPlayer("wmpHolder",240,320);if(e=document.getElementsByTagName("video")[0])e.src=d;e.play();this.doResize(e.offsetParent.clientWidth,e.offsetParent.clientHeight)}else a==MediaPlayerType.MediaPlayerFlash&&(d=d.getURL(StreamingItemType.MP4),jwplayer("wmpHolder").setup({file:d,image:"http://shop.chessbase.com/pics/p_6251",
3975autostart:!0,width:"100%",height:"90%"}))};c.prototype.doResize=function(d,e){if(a==MediaPlayerType.MediaPlayerAzure){if(document.getElementById("azuremediaplayer")){var f=amp("azuremediaplayer");f&&(f.height(e),f.width(d))}}else if(a==MediaPlayerType.MediaPlayerHTML){if(f=document.getElementsByTagName("video")[0])f.height=e,f.width=d}else if(f=document.getElementById("MediaPlayer1"))f.width=d,f.height=e;a==MediaPlayerType.MediaPlayerFlash&&jwplayer("wmpHolder").resize(d,e-40)};c.prototype.onSync=
3976function(d){document.getElementById("MediaPlayer1")};c.prototype.onScriptCommand=function(d,e){null!=this.gameKernel&&this.gameKernel.executeGameAction(d,e);if(null!=this.watchSessions)this.watchSessions.onGameActionFromStream(d,e)};c.prototype.play=function(){if(this.autoPlay()&&a==MediaPlayerType.MediaPlayerAzure){var d=amp("azuremediaplayer");d&&d.play()}};c.prototype.getCurrentTime=function(){if(a==MediaPlayerType.MediaPlayerAzure)try{var d=amp("azuremediaplayer");if(d&&d.currentTime)return d.currentTime()}catch(e){return-1}else if(a==
3977MediaPlayerType.MediaPlayerWMV){if(d=document.getElementById("MediaPlayer1"),d.controls&&d.controls.currentPosition)return d.controls.currentPosition}else{if(a==MediaPlayerType.MediaPlayerHTML)return document.getElementsByTagName("video")[0].currentTime;if(a!=MediaPlayerType.MediaPlayerSL&&a==MediaPlayerType.MediaPlayerFlash)return this.currenttime=jwplayer("wmpHolder").getPosition()}return 0};c.prototype.mustExecute=function(d,e){return d>=e&d<e+1};c.prototype.CMSGameActionsHandler=function(d){d=
3978this.getCurrentTime();var e=!1;if(!this.endEventFired){for(h=0;h<this.chatActions.length;h++)if(this.mustExecute(this.chatActions[h].time,d)){var f=this.chatActions[h].action;if(f){var g=new DataBuffer;g.constructFromString(f,!0);g.rewind();(new ChatStreamData).read(g)}}for(var h=0;h<this.gameActions.length;h++)if(this.mustExecute(this.gameActions[h].time,d)){if(0!=d)this.onScriptCommand(this.gameActions[h].type,this.gameActions[h].action);e=!0;if(60<=d-b){if(f=CBQ.get("videoid")){f=f.innerHTML;g=
3979Math.floor(d)/60;g=Math.floor(g);this.endEventFired=!1;var k="",l=CBQ.get("userid");l&&(k=encodeURIComponent(l.innerHTML));1<g&&(CBAJAX.load(this.baseurl+"Replay/AddSnippetViewed?id="+encodeURIComponent(f)+"&time="+g+"&user="+k,this.onSnippetViewed.bind(this),{responseType:"text"}),0!=this.gameHeaderStr.localeCompare(this.gameKernel.game.hdr.toString())&&
3979(this.gameHeaderStr=this.gameKernel.game.hdr.toString(),this.gameKernel.Vp.saveToCloud(!0)))}b=d}}else if(e)break}};c.prototype.saveToCloud=function(){glApp.cloudMgr&&
3980glApp.cloudMgr.isLoggedIn()&&glApp.cloudMgr.saveGameToClipboard(this.gameKernel.game)};c.prototype.callGetNextIdAtEnd=function(){var d=CBQ.get("videoid");d&&(d=this.baseurl+"Replay/GetNextIdAtEnd?id="+encodeURIComponent(d.innerHTML)+"&fen="+encodeURIComponent(this.gameKernel.game.getCurPos().toFEN()),CBAJAX.load(d,this.onNextVideo.bind(this),{responseType:"text"}))};c.prototype.showTimedMessage=function(d,e){glApp.panelMgr.showMessage(d);this.gameKernel.boardWin.addMessage(d,!0);(new Timer(function(){this.gameKernel.boardWin.destroyMessage()}.bind(this))).runOnce(e)};
3981c.prototype.showMessage=function(d){glApp.panelMgr.showMessage(d);this.gameKernel.boardWin.addMessage(d,!0);(new Timer(function(){this.gameKernel.boardWin.destroyMessage()}.bind(this))).runOnce(3E3)};c.prototype.onNextVideo=function(d){d=JSON.parse(d);var e=d.ID,f=d.MSG;2<f.length?this.showMessage(f):(d=d.STATE,"3"==d?(this.showMessage("please try again"),this.gameKernel.Vp.restoreMoveEnterPosition()):2<e.length&&("5"==d?window.location.href=this.baseurl+"Replay/Video?id="+e:(CBQ.set("videoid",e),
3982this.loadVideoFromId(e))))};c.prototype.playSolution=function(d){this.showMessage("Solution");d=this.baseurl+"Replay/GetSolution?id="+encodeURIComponent(d);CBAJAX.load(d,this.onGetSolution.bind(this),{responseType:"text"})};c.prototype.onGetSolution=function(d){d=JSON.parse(d);var e=d.ID;d=d.MSG;2<d.length?this.showMessage(d):this.loadVideoFromId(e)};c.prototype.onSnippetViewed=function(d){d=JSON.parse(d);a!=MediaPlayerType.MediaPlayerAzure||this.playerAuthenticated||(0!=d.localeCompare("Ok")?(CBQ.set("videoid",
3983""),amp("azuremediaplayer").pause(),amp("azuremediaplayer").controls(!1),0==d.localeCompare("Expert")?this.gameKernel.boardWin.addMessage("You have to purchase this video in order to watch it",!0):this.gameKernel.boardWin.addMessage("Please login with your Premium account",!0)):this.playerAuthenticated=!0)};c.prototype.renderPartial=function(d){d="Replay/RenderPartial?id="+encodeURIComponent(d);var e=new XMLHttpRequest;e.open("POST",this.baseurl,!0);e.setRequestHeader("Content-type","application/x-www-form-urlencoded");
3984e.setRequestHeader("X-Requested-With","XMLHttpRequest");e.onload=function(){};e.send(d)};c.prototype.setStartTime=function(d){if("0"!=d)if(a==MediaPlayerType.MediaPlayerAzure){var e=amp("azuremediaplayer");e&&e.currentTime(1*d)}else a==MediaPlayerType.MediaPlayerWMV?(e=document.getElementById("MediaPlayer1"),e.controls&&e.controls.currentPosition&&(e.controls.currentPosition=d)):a==MediaPlayerType.MediaPlayerHTML&&(document.getElementsByTagName("video")[0].currentTime=d);a==MediaPlayerType.MediaPlayerAzure&&
3985this.play()};c.prototype.loadVideoFromId=function(d){this.downloadFile(d);a==MediaPlayerType.MediaPlayerHTML?(d=System.isMobile()&&!System.isIPad()?this.baseurl+"Replay/GetAllMP4Mobile?id="+d:this.baseurl+"Replay/GetAllMP4?id="+d,CBAJAX.load(d,this.onGetAllSmoothStreaming.bind(this),{responseType:"text"})):(d=this.baseurl+"Replay/GetAllSmoothStreaming?id="+d,CBAJAX.load(d,this.onAll.bind(this),{responseType:"text"}))};c.prototype.onAll=function(d){d=JSON.parse(d);for(var e=new BroadcastStreamingDataEx,
3986f=0;f<d.length;f++){var g=d[f].URLType,h=d[f].URL;"SS"==g?(g=StrUtil.base64.decode(h),g=new BroadcastStreamingItemEx(g,StreamingItemType.SMOOTHSTREAMING),e.add(g)):"WMV"==g?(g=StrUtil.base64.decode(h),g=new BroadcastStreamingItemEx(g,StreamingItemType.WMV),e.add(g)):"MP4"==g?(g=StrUtil.base64.decode(h),g=new BroadcastStreamingItemEx(g,StreamingItemType.MP4),e.add(g)):"GA"==g&&(g=StrUtil.base64.decode(h),g=new BroadcastStreamingItemEx(g,StreamingItemType.GAMEACTIONS),e.add(g))}"function"==typeof getAllFinished&&
3987getAllFinished();this.reportBroadcastStreamingData(e)};c.prototype.getCMSIFenPositions=function(){var d=CBQ.get("videoid");d&&(d=this.baseurl+"Replay/GetCSMIFenPositions?id="+encodeURIComponent(d.innerHTML),CBAJAX.load(d,this.onCMSIFenPositions.bind(this),{responseType:"text"}))};c.prototype.onCMSIFenPositions=function(d){d=JSON.parse(d);for(var e=[],f=0;f<d.length;f++){var g=new Move(d[f].From,d[f].To,0);g.fen=d[f].Fen;e.push(g)}this.suppressNotationFromMoves(e)};c.prototype.suppressNotationFromMoves=
3988function(d){null!=glApp.panelMgr.notaElement&&glApp.panelMgr.notaElement.suppressNotationFromMoves(d)};c.prototype.getStartTimeFromDB=function(){var d=CBQ.get("gotopos");if(d&&"0"!=d.innerHTML)(new Timer(function(){this.setStartTime(d.innerHTML)}.bind(this))).runOnce(1E3);else{var e=CBQ.get("videoid");if(e){e=e.innerHTML;var f="";if(f=CBQ.get("userid"))f=f.innerHTML,e=this.baseurl+"Replay/GetStartTime?id="+encodeURIComponent(e)+"&user="+encodeURIComponent(f),CBAJAX.load(e,this.onGetStartTime.bind(this),
3989{responseType:"text"})}}};c.prototype.onGetStartTime=function(d){d=JSON.parse(d);this.setStartTime(d)};c.prototype.onWMV=function(d){d=d.substring(1,d.length-2);alert(d);d=StrUtil.base64.decode(d);var e=new BroadcastStreamingDataEx;d=new BroadcastStreamingItemEx(d,StreamingItemType.WMV);e.add(d);this.reportBroadcastStreamingData(e)};c.prototype.onGA=function(d){d=d.substring(1,d.length-2);alert(d);d=StrUtil.base64.decode(d);var e=new BroadcastStreamingDataEx;d=new BroadcastStreamingItemEx(d,StreamingItemType.GAMEACTIONS);
3990e.add(d);this.reportBroadcastStreamingData(e)};c.prototype.onMP4=function(d){d=d.substring(1,d.length-2);alert(d);d=StrUtil.base64.decode(d);var e=new BroadcastStreamingDataEx;d=new BroadcastStreamingItemEx(d,StreamingItemType.MP4);e.add(d);this.reportBroadcastStreamingData(e)};c.prototype.autoTest=function(){amp("azuremediaplayer").pause();this.autoTest=new RadioTestManager(this.gameKernel);this.autoTest.start()};return c}();"use strict";
3991class VideoManager{constructor(a,b,c,d,e,f,g,h){this.videoUrl="";this.playerInstance=a;this.playerAuthenticated=!1;this.onGameActionHdl=d;this.onEndOfVideoHdl=e;this.loadVideoHandler=h;this.autoplay=f;this.gameActions=[];this.chatActions=[];this.el=c;this.gameHeaderStr="";this.token=g;this.name="azuremediaplayer"+Math.floor(1E6*Math.random());CBQ(this.el).html("<div id='wmpHolder"+a+"' style='height:100%;'></div>");this.baseurl=glApp.config.getVideoPortalUris()[0];this.playerType=b;this.determineBrowser()}cleanUp(){this.remove("MediaPlayer1")}remove(a){(a=
3992document.getElementById(a))&&a.parentNode.removeChild(a)}getPlayerType(){return this.playerType}detectWMP(){}getWidth(){if(this.playerType==MediaPlayerType.MediaPlayerAzure){var a=amp("azuremediaplayer");if(a)return a.width()}return 0}getHeight(){if(this.playerType==MediaPlayerType.MediaPlayerAzure){var a=amp("azuremediaplayer");if(a)return a.height()}return 0}determineBrowser(){switch(this.playerType){case MediaPlayerType.MediaPlayerAzure:this.prepareAzure();break;case MediaPlayerType.MediaPlayerWowza:this.prepareWowza();
3993break;case MediaPlayerType.MediaPlayerUnknown:this.prepareLegacy()}}prepareAzure(){this.playerType==MediaPlayerType.MediaPlayerAzure&&this.setupAzureMediaPlayer()}prepareWowza(){this.playerType==MediaPlayerType.MediaPlayerWowza&&this.setupWowzaMediaPlayer()}prepareLegacy(){window.chrome&&window.chrome.webstore?this.setupHLS():System.isMobile()?this.setupHTML():!this.isWindows()&&System.isWebKit()?this.setupHTML():this.isWindows()?System.isActivexEnabled()?(this.detectWMP(),null!=this.P&&this.P.version?
3994this.setupWMV():this.setupHelp()):this.setupHLS():this.setupHTML()}isMp4Client(){var a=!1;System.isActivexEnabled()&&(this.detectWMP(),null!=this.P&&this.P.version&&(a=!0));return!a}generateHTMLPlayer(a,b,c,d){a=document.getElementById(a);d='<video src="'+d+'" controls autoplay></video>';a&&(a.innerHTML=d);d=document.getElementsByTagName("video")[0];d.addEventListener("loadeddata",function(){}.bind(this));d.addEventListener("ended",function(){setTimeout(this.callGetNextIdAtEnd.bind(this),500)}.bind(this));
3995return a}generateSLPlayer(a,b,c){}onError(){alert("onError")}generateHTMLHelp(a){if(a=document.getElementById(a))a.innerHTML='For instructions click on the <a href="http://play.chessbase.com/js/apps/playchess/playchesscms.html">link</a>';return a}stop(){if(this.playerType==MediaPlayerType.MediaPlayerWMV){var a=document.getElementById("MediaPlayer1");null!=a&&null!=a.controls&&a.controls.stop()}}isWindows(){return-1!=navigator.appVersion.indexOf("Win")}autoPlay(){var a=StrUtil.getURLParam("autoplay");
3996return null!=a&&0<a.length?"false"!=a:this.autoplay}generateAzureMediaPlayer(a,b,c,d,e){var f=this.autoPlay();e&&(f=e);this.videoUrl=d;
3996System.runsInIFrame()&&(f=!1);e=Language.getStrUserLanguage();a=document.getElementById(a);var g=document.getElementById(this.name);if(d&&0<d.length){if(null==g){var h={nativeControlsForTouch:!1,language:e,autoplay:f,controls:!0,width:c,height:b,poster:"",logo:{enabled:!1}};System.isWebKit()&&(h={nativeControlsForTouch:!1,language:e,techOrder:["azureHtml5JS","html5",
3997"flashSS","silverlightSS"],controls:!0,autoplay:f,width:c,height:b,poster:"",logo:{enabled:!1},plugins:{ga:{eventsToTrack:"playerConfig loaded playTime percentsPlayed start end play pause error buffering fullscreen seek bitrate".split(" "),debug:!1}}});a||console.log("holder undefined");a.innerHTML=`<video  webkit-playsinline='true' playsinline='true' id='${this.name}' class='azuremediaplayer amp-default-skin' controls ${f?"autoplay":""} amp-big-play-centered tabindex='0'> </video>`;g=amp(this.name,
3998h);amp(this.name).src([{src:d,type:"application/vnd.ms-sstr+xml"}]);amp(this.name).ready(function(){CBQ(".amp-logo")&&CBQ(".amp-logo").remove();System.isIPhone()||System.isIPad()||System.runsInIFrame()||this.autoPlay()&&g.play()}.bind(this));g.addEventListener("error",function(){var k=g.error();if(k){var l=k.code>>28;k=(k.code&8388607)>>23;if(!System.isIPhone()&&!System.isIPad()){var m=this.getAzureError(g);alert("Sorry, There is a problem with the Video Player: "+m+l+","+k)}}}.bind(this));amp(this.name).removeEventListener("loadeddata");
3999amp(this.name).addEventListener("loadeddata",function(){this.startTimer();this.getStartTimeFromDB();this.loadVideoHandler(this.playerInstance)}.bind(this));amp(this.name).removeEventListener("loadedmetadata");amp(this.name).addEventListener("loadedmetadata",function(){}.bind(this));amp(this.name).isLive()||(amp(this.name).removeEventListener("ended"),amp(this.name).addEventListener("ended",function(){this.onEndOfVideoHdl(this.playerInstance,this.currentvideoid)}.bind(this)))}b=amp(this.name);b.src([{src:d,
4000type:"application/vnd.ms-sstr+xml"}]);System.isIPhone()||System.isIPad()||f&&(System.runsInIFrame()||b.play());b.controls(!0);b.options({logo:{enabled:!1},autoplay:f})}return a}getAzureError(a){var b="Unknown Error: ";a.error().code&amp.errorCode.abortedErrStart?b="MEDIA_ERR_ABORTED: ":a.error().code&amp.errorCode.networkErrStart?b="MEDIA_ERR_NETWORK: ":a.error().code&amp.errorCode.decodeErrStart?b="MEDIA_ERR_DECODE: ":a.error().code&amp.errorCode.srcErrStart?b="MEDIA_ERR_SRC_NOT_SUPPORTED: ":a.error().code&
4001amp.errorCode.encryptErrStart?b="MEDIA_ERR_ENCRYPTED errors: ":a.error().code&amp.errorCode.srcPlayerMismatchStart&&(b="SRC_PLAYER_MISMATCH error: ");return b}generateWowzaMediaPlayer(a,b,c,d,e){b=this.autoPlay();e&&(b=e);this.videoUrl=d;System.runsInIFrame()&&(b=!1);Language.getStrUserLanguage();a=document.getElementById(a);e=document.getElementById("wowzamediaplayer"+this.playerInstance);d&&0<d.length&&(null==e?(a.innerHTML="<div  id='wowzamediaplayer"+this.playerInstance+"'  style='max-height:100%;' </video> ",
4002e=flowplayer("#wowzamediaplayer"+this.playerInstance,{src:d,token:this.token,muted:!1,autoplay:b}),e.addEventListener("ended",function(){this.onEndOfVideoHdl(this.playerInstance,this.currentvideoid)}.bind(this)),e.muted=!1,b&&e.play(),e.addEventListener("loadedmetadata",function(){this.startTimer();this.getStartTimeFromDB();this.loadVideoHandler(this.playerInstance)}.bind(this)),this.startTimer(),this.getStartTimeFromDB()):(e.children[0].setSrc(this.videoUrl),d=flowplayer("#wowzamediaplayer"+this.playerInstance),
4003b&&d.play()));return a}setupWowzaMediaPlayer(){this.playerType=MediaPlayerType.MediaPlayerWowza}setupAzureMediaPlayer(){this.playerType=MediaPlayerType.MediaPlayerAzure}setupNanoPlayer(){this.generateNanoPlayer("wmpHolder",240,320)}setupHTML(){LOG("Setup HTML");this.playerType=MediaPlayerType.MediaPlayerHTML}setupSL(a){}setupAzure(a,b){var c=320,d=320;if(!CBQ.get(this.name)){var e=this.generateHTMLHelp("wmpHolder"+this.playerInstance);e&&e.offsetParent&&(d=e.offsetParent.clientWidth,c=e.offsetParent.clientHeight)}System.isHTTPS()&&
4004(a=a.replace("http://","https://"));this.htmlHolder=this.generateAzureMediaPlayer("wmpHolder"+this.playerInstance,c,d,a,b)}setupWowza(a,b){var c=320,d=320;if(!CBQ.get("wowzamediaplayer"+this.playerInstance)){var e=this.generateHTMLHelp("wmpHolder"+this.playerInstance);e&&e.offsetParent&&(d=e.offsetParent.clientWidth,c=e.offsetParent.clientHeight)}System.isHTTPS()&&(a=a.replace("http://","https://"));this.htmlHolder=this.generateWowzaMediaPlayer("wmpHolder"+this.playerInstance,c,d,a,b)}setupHelp(){this.generateHTMLHelp("wmpHolder")}
4004reportChannel(a){LOG("RadionManager::ReportChannel");
4005this.playerType==MediaPlayerType.MediaPlayerHTML?(this.htmlHolder=this.generateHTMLPlayer("wmpHolder",240,320,"http://video.chessbase.com/js/hls"+a.sChannel+"/hls0.m3u8"),document.getElementsByTagName("video")[0].play()):this.playerType==MediaPlayerType.MediaPlayerFlash&&(this.nChannel=a.sChannel,jwplayer("wmpHolder").load([{file:"http://video.chessbase.com/js/hls"+a.sChannel+"/hls2.m3u8"}]))}onLoadChat(a){a=JSON.parse(a);if(a.length)for(var b=0;b<a.length;b++){var c=a[b],d=new ScriptCommand;d.time=
4006c.Time;d.type=c.GameActionType;d.action=c.GameActionContent;this.chatActions.push(d)}}onCurGameChanged(){var a=this.gameKernel.getCurPos();if(this.cachepos)for(var b=0;b<this.cachepos.length;b++)if(a.equals(this.cachepos[b])){this.setStartTime(this.cachetime[b]);break}}b64_to_utf8(a){return decodeURIComponent(escape(window.atob(a)))}reportBroadcastStreamingData(a,b){LOG("RadionManager::reportBroadcastStreamingData ");if(this.playerType==MediaPlayerType.MediaPlayerWMV){if(a=a.getURL(StreamingItemType.WMV),
4007b=document.getElementById("MediaPlayer1"))b.URL=a,b.data=a}else if(this.playerType==MediaPlayerType.MediaPlayerAzure)a=a.getURL(StreamingItemType.SMOOTHSTREAMING),0<a.length&&this.setupAzure(a,b);else if(this.playerType==MediaPlayerType.MediaPlayerWowza)a=a.getURL(StreamingItemType.WOWZA),0<a.length&&this.setupWowza(a,b);else if(this.playerType!=StreamingItemType.SMOOTHSTREAMING)if(this.playerType==MediaPlayerType.MediaPlayerHTML){a=a.getURL(StreamingItemType.MP4);this.htmlHolder=this.generateHTMLPlayer("wmpHolder",
4008240,320);if(b=document.getElementsByTagName("video")[0])b.src=a;b.play();this.doResize(b.offsetParent.clientWidth,b.offsetParent.clientHeight)}else this.playerType==MediaPlayerType.MediaPlayerFlash&&(a=a.getURL(StreamingItemType.MP4),jwplayer("wmpHolder").setup({file:a,image:"http://shop.chessbase.com/pics/p_6251",autostart:!0,width:"100%",height:"90%"}))}doResize(a,b){if(this.playerType==MediaPlayerType.MediaPlayerAzure){var c=document.getElementById(this.name);c&&(c=amp(this.name))&&(c.height(b),
4009c.width(a))}else if(this.playerType==MediaPlayerType.MediaPlayerWowza)document.getElementById("wowzamediaplayer"+this.playerInstance)&&(c=flowplayer("#wowzamediaplayer"+this.playerInstance))&&(c.volume=.5,c.muted=!1);else if(this.playerType==MediaPlayerType.MediaPlayerHTML){if(c=document.getElementsByTagName("video")[0])c.height=b,c.width=a}else if(c=document.getElementById("MediaPlayer1"))c.width=a,c.height=b;this.playerType==MediaPlayerType.MediaPlayerFlash&&jwplayer("wmpHolder").resize(a,b-40)}onSync(a){document.getElementById("MediaPlayer1")}onScriptCommand(a,
4010b){null!=this.gameKernel&&this.gameKernel.executeGameAction(a,b);if(null!=this.watchSessions)this.watchSessions.onGameActionFromStream(a,b)}getCurrentTime(){if(this.playerType==MediaPlayerType.MediaPlayerWowza)try{var a=flowplayer("#wowzamediaplayer"+this.playerInstance);if(a&&a.currentTime)return a.currentTime}catch(b){return-1}else if(this.playerType==MediaPlayerType.MediaPlayerAzure)try{if((a=amp(this.name))&&a.currentTime)return a.currentTime()}catch(b){return-1}else if(this.playerType==MediaPlayerType.MediaPlayerWMV){if(a=
4011document.getElementById("MediaPlayer1"),a.controls&&a.controls.currentPosition)return a.controls.currentPosition}else{if(this.playerType==MediaPlayerType.MediaPlayerHTML)return document.getElementsByTagName("video")[0].currentTime;if(this.playerType!=MediaPlayerType.MediaPlayerSL&&this.playerType==MediaPlayerType.MediaPlayerFlash)return this.currenttime=jwplayer("wmpHolder").getPosition()}return 0}mustExecute(a,b){return a>=b&a<b+1}CMSGameActionsHandler(a){a=this.getCurrentTime();if(this.playerType==
4012MediaPlayerType.MediaPlayerWowza){var b=flowplayer("#wowzamediaplayer"+this.playerInstance);if(b&&!b.paused)this.onGameActionHdl(this.playerInstance,a)}else if((b=amp(this.name))&&!b.paused())this.onGameActionHdl(this.playerInstance,a)}saveToCloud(){glApp.cloudMgr&&glApp.cloudMgr.isLoggedIn()&&glApp.cloudMgr.saveGameToClipboard(this.gameKernel.game)}showTimedMessage(a,b){glApp.panelMgr.showMessage(a);this.gameKernel.boardWin.addMessage(a,!0);(new Timer(function(){this.gameKernel.boardWin.destroyMessage()}.bind(this))).runOnce(b)}showMessage(a){glApp.panelMgr.showMessage(a);
4013this.gameKernel&&this.gameKernel.boardWin.addMessage(a,!0);(new Timer(function(){this.gameKernel&&this.gameKernel.boardWin.destroyMessage();glApp.panelMgr.destroyMessage()}.bind(this))).runOnce(3E3)}onNextVideo(a){a=JSON.parse(a);var b=a.ID,c=a.MSG;2<c.length?this.showMessage(c):(a=a.STATE,"3"==a?(this.showMessage("please try again"),this.gameKernel.Vp.restoreMoveEnterPosition()):2<b.length&&("5"==a?window.location.href=this.baseurl+"Replay/Video?id="+b:(CBQ.set("videoid",b),this.loadVideoFromId(b))))}playSolution(a){a=
4014this.baseurl+"Replay/GetSolution?id="+encodeURIComponent(a);CBAJAX.load(a,this.onGetSolution.bind(this),{responseType:"text"})}onGetSolution(a){a=JSON.parse(a);var b=a.ID;a=a.MSG;2<a.length?this.showMessage(a):this.loadVideoFromId(b)}disable(){this.playerType==MediaPlayerType.MediaPlayerAzure?(amp(this.name).pause(),amp(this.name).controls(!1)):this.playerType==MediaPlayerType.MediaPlayerWowza&&flowplayer("#wowzamediaplayer"+this.playerInstance).destroy()}onSnippetViewed(a){a=JSON.parse(a);this.playerType!=
4015MediaPlayerType.MediaPlayerAzure&&this.playerType!=MediaPlayerType.MediaPlayerWowza||this.playerAuthenticated||(0!=a.localeCompare("Ok")?(CBQ.set("videoid",""),0==a.localeCompare("Expert")?this.gameKernel.boardWin.addMessage("You have to purchase this video in order to watch it",!0):this.gameKernel.boardWin.addMessage("Please login with your Premium account",!0)):this.playerAuthenticated=!0)}renderPartial(a){a="Replay/RenderPartial?id="+encodeURIComponent(a);var b=new XMLHttpRequest;b.open("POST",
4016this.baseurl,!0);b.setRequestHeader("Content-type","application/x-www-form-urlencoded");b.setRequestHeader("X-Requested-With","XMLHttpRequest");b.onload=function(){};b.send(a)}
4016restart(){if(this.playerType==MediaPlayerType.MediaPlayerWowza){var a=flowplayer("#wowzamediaplayer"+this.playerInstance);a&&(a.currentTime=0)}else(a=amp(this.name))&&a.currentTime(0)}setStartTime(a){if("0"!=a)if(this.playerType==MediaPlayerType.MediaPlayerWowza){var b=flowplayer("#wowzamediaplayer"+this.playerInstance);b&&
4017(b.currentTime=1*a)}else this.playerType==MediaPlayerType.MediaPlayerAzure?(b=amp(this.name))&&b.currentTime(1*a):this.playerType==MediaPlayerType.MediaPlayerWMV?(b=document.getElementById("MediaPlayer1"),b.controls&&b.controls.currentPosition&&(b.controls.currentPosition=a)):this.playerType==MediaPlayerType.MediaPlayerHTML&&(document.getElementsByTagName("video")[0].currentTime=a);this.playerType==MediaPlayerType.MediaPlayerAzure&&(System.runsInIFrame()||this.play())}loadVideoFromId(a,b){this.currentvideoid=
4018a;$.get(this.baseurl+"Replay/GetAllSmoothStreaming?id="+a,function(c){if(c){for(var d=new BroadcastStreamingDataEx,e=0;e<c.length;e++){var f=c[e].URLType,g=c[e].URL;this.playerType==MediaPlayerType.MediaPlayerWowza?"WOWZA"==f&&(f=StrUtil.base64.decode(g),f=new BroadcastStreamingItemEx(f,StreamingItemType.WOWZA),d.add(f)):"SS"==f?(f=StrUtil.base64.decode(g),f=new BroadcastStreamingItemEx(f,StreamingItemType.SMOOTHSTREAMING),d.add(f)):"WMV"==f?(f=StrUtil.base64.decode(g),f=new BroadcastStreamingItemEx(f,
4019StreamingItemType.WMV),d.add(f)):"MP4"==f?(f=StrUtil.base64.decode(g),f=new BroadcastStreamingItemEx(f,StreamingItemType.MP4),d.add(f)):"GA"==f&&(f=StrUtil.base64.decode(g),f=new BroadcastStreamingItemEx(f,StreamingItemType.GAMEACTIONS),d.add(f))}"function"==typeof window.getAllFinished&&window.getAllFinished();this.reportBroadcastStreamingData(d,b)}}.bind(this)).fail(function(){}.bind(this))}startTimer(){this.currenttime=0;null==this.myTimer&&(this.myTimer=setInterval(this.CMSGameActionsHandler.bind(this),
40201E3))}getStartTimeFromDB(){var a=StrUtil.getURLParam("gotopos");if(a){var b=StrUtil.getURLParam("id");b&&this.currentvideoid===b&&(new Timer(function(){this.setStartTime(a)}.bind(this))).runOnce(1E3)}else{var c=CBQ.get("gotopos");if(c&&"0"!=c.innerHTML)(b=CBQ.get("videoid"))&&this.currentvideoid===b&&(new Timer(function(){this.setStartTime(c.innerHTML)}.bind(this))).runOnce(1E3);else if(this.currentvideoid){b=this.currentvideoid;var d="";if(d=CBQ.get("userid"))d=d.innerHTML,b=this.baseurl+"Replay/GetStartTime?id="+
4021encodeURIComponent(b)+"&user="+encodeURIComponent(d),$.get(b,function(e){e&&this.setStartTime(e)}.bind(this)).fail(function(){}.bind(this))}}}onWMV(a){a=a.substring(1,a.length-2);alert(a);a=StrUtil.base64.decode(a);var b=new BroadcastStreamingDataEx;a=new BroadcastStreamingItemEx(a,StreamingItemType.WMV);b.add(a);this.reportBroadcastStreamingData(b)}onGA(a){a=a.substring(1,a.length-2);alert(a);a=StrUtil.base64.decode(a);var b=new BroadcastStreamingDataEx;a=new BroadcastStreamingItemEx(a,StreamingItemType.GAMEACTIONS);
4022b.add(a);this.reportBroadcastStreamingData(b)}onMP4(a){a=a.substring(1,a.length-2);alert(a);a=StrUtil.base64.decode(a);var b=new BroadcastStreamingDataEx;a=new BroadcastStreamingItemEx(a,StreamingItemType.MP4);b.add(a);this.reportBroadcastStreamingData(b)}pause(){if(this.playerType==MediaPlayerType.MediaPlayerWowza){var a=flowplayer("#wowzamediaplayer"+this.playerInstance);a&&a.pause()}else amp(this.name).pause()}play(){if(this.playerType==MediaPlayerType.MediaPlayerWowza){if(this.videoUrl){var a=
4023flowplayer("#wowzamediaplayer"+this.playerInstance);a&&a.play()}}else amp&&this.playerInstance&&this.videoUrl&&(a=amp(this.name))&&a.play()}autoTest(){amp(this.name).pause();this.autoTest=new RadioTestManager(this.gameKernel);this.autoTest.start()}}"use strict";
4024class VideoElement{constructor(a,b,c,d,e,f,g,h){this.aMediaplayer=MediaPlayerType.MediaPlayerAzure;0<g.length&&(this.aMediaplayer=MediaPlayerType.MediaPlayerWowza);this.nInPage=a;this.token=g;this.hasListeners=!1;this.fnGetKernel=b;this.ticket=c;this.gaHandler=d;this.endvideoHandler=e;this.autoplay=f;this.initState();this.videoManager=null;this.loadVideoHdl=h}initElem(a){this.videoManager=new VideoManager(this.nInPage,this.aMediaplayer,a,this.gaHandler,this.endvideoHandler,this.autoplay,this.token,
4025this.loadVideoHdl)}initState(){}clear(){}
4025onNewGame(){}resize(a,b){this.videoManager.doResize(a,b)}disable(){this.videoManager.disable()}static initForListeners(){VideoElement.listenersInited||(Vk.initForListeners(VideoElement),VideoElement.listenersInited=!0)}static factory(a,b,c,d,e,f,g,h,k){b=new VideoElement(b||0,c,d,e,f,g,h,k);b.initElem(a);return b}}"use strict";
4026let LiveVideoManager=function(){var a="",b=function(c,d,e){this.onGameActionHdl=e;this.el=d;d=CBQ(this.el);this.nInstance=c;c="wmpHolder"+c;d.html("<div id='"+c+"' style='width:100%;height:100%;'></div>");this.name=c};b.prototype.setUrl=function(c){a=c;this.player&&this.player.pause();c="wmpHolder"+this.nInstance;this.remove(c);CBQ(this.el).html("<div id='"+c+"' style='width:100%;height:100%;'></div>");this.player=null;(new Timer(function(){this.generateLivePlayer(this.name,200,800)}.bind(this))).runOnce(500)};
4027b.prototype.cleanUp=function(){this.remove(this.myRadio)};b.prototype.remove=function(c){(c=document.getElementById(c))&&c.parentNode.removeChild(c)};b.prototype.generateLivePlayer=function(c,d,e){this.generateNanoPlayer(c,d,e)};b.prototype.generateNanoPlayer=function(c,d,e){d={source:{bintu:{apiurl:"https://bintu.nanocosmos.de:443",streamid:a}},playback:{autoplay:!0,muted:!1,metadata:!0},events:{onReady:function(f){},onPlay:function(f){},onPause:function(f){},onLoading:function(f){},onStartBuffering:function(f){},
4028onStopBuffering:function(f){},onStats:function(f){},onError:function(f){try{f&&f.data&&f.data.message||JSON.stringify(f)}catch(g){}},onMetaData:function(f){if(f.data.handlerName&&"onCuePoint"===f.data.handlerName)this.onMetaData(f.data.message)}.bind(this)}};this.player||(this.player=new NanoPlayer(this.name));this.player.instance=this;this.player.setup(d).then(function(f){try{JSON.stringify(f)}catch(g){alert(g)}},function(f){alert(f);try{var g=JSON.stringify(f);"{}"===g&&(g=f.message);f=g}catch(h){}document.getElementById("status").innerText=
4029"Setup Error: "+f});return c};b.prototype.onMetaData=function(c){this.onGameActionHdl(c,this.nInstance)};b.prototype.onCurGameChanged=function(){var c=this.gameKernel.getCurPos();if(this.cachepos)for(var d=0;d<this.cachepos.length;d++)c.equals(this.cachepos[d])&&this.setStartTime(this.cachetime[d
4029])};b.prototype.b64_to_utf8=function(c){return decodeURIComponent(escape(window.atob(c)))};b.prototype.doResize=function(c,d){var e=document.getElementById("wmpHolder0");e&&(e.style.height=d+"px",e.style.width=
4030c+"px")};b.prototype.onSync=function(c){document.getElementById("MediaPlayer1")};b.prototype.onScriptCommand=function(c,d){null!=this.gameKernel&&this.gameKernel.executeGameAction(c,d);if(null!=this.watchSessions)this.watchSessions.onGameActionFromStream(c,d)};b.prototype.play=function(){this.player&&this.player.play()};b.prototype.stop=function(){this.player?this.player.pause():alert("player not found (stop)")};b.prototype.showMessage=function(c){glApp.panelMgr.showMessage(c);this.gameKernel.boardWin.addMessage(c,
4031!0);(new Timer(function(){this.gameKernel.boardWin.destroyMessage()}.bind(this))).runOnce(3E3)};b.prototype.onAll=function(c){};return b}();"use strict";
4032let LiveVideoElement=function(){var a=function(b,c,d,e,f){this.aMediaplayer=MediaPlayerType.MediaPlayerAzure;this.nInPage=b;this.hasListeners=!1;this.fnGetKernel=c;this.ticket=d;this.gaHandler=e;this.endvideoHandler=f;this.initState()};a.prototype.initElem=function(b){this.videoManager=new LiveVideoManager(this.nInPage,b,this.gaHandler)};a.prototype.initState=function(){};a.prototype.clear=function(){};a.prototype.onNewGame=function(){};a.prototype.resize=function(b,c){this.videoManager.doResize(b,
4033c)};a.prototype.disable=function(){this.videoManager.disable()};a.prototype.setUrl=function(b){this.videoManager.setUrl(b)};Vk.initForListeners(a);return a}();LiveVideoElement.factory=function(a,b,c,d,e){b=new LiveVideoElement(b||0,c,d,e);b.initElem(a);return b};"use strict";
4034const OfflineVideoManager=function(){var a=MediaPlayerType.MediaPlayerUnknown,b=function(c,d,e,f,g){this.playerInstance=c;this.playerAuthenticated=!1;this.onGameActionHdl=f;this.onEndOfVideoHdl=g;this.gameActions=[];this.chatActions=[];this.el=e;this.gameHeaderStr="";CBQ(this.el).html("<div id='wmpHolder"+c+"'></div>");a=d;this.determineBrowser()};b.prototype.cleanUp=function(){this.remove("MediaPlayer1")};b.prototype.remove=function(c){(c=document.getElementById(c))&&c.parentNode.removeChild(c)};
4035b.prototype.getPlayerType=function(){return a};b.prototype.determineBrowser=function(){this.prepareAzure()};b.prototype.prepareAzure=function(){this.setupAzureMediaPlayer()};b.prototype.isMp4Client=function(){var c=!1;System.isActivexEnabled()&&(this.detectWMP(),null!=this.P&&this.P.version&&(c=!0));return!c};b.prototype.generateHTMLPlayer=function(c,d,e,f){this.currentvideoid=f;c=document.getElementById(c);f='<video controls playsinline autoplay poster="static/poster.png" id="video" src="'+f+'" type="video/mp4"></video>';
4036c&&(c.innerHTML=f);var g=document.getElementsByTagName("video")[0];g&&(g.load(),g.addEventListener("loadeddata",function(){System.isElectron()||0<g.currentSrc.length&&g.play()}.bind(this)),g.onloadstart=function(){this.showMessage("Loading...");System.isElectron()||0<g.currentSrc.length&&g.play()}.bind(this),g.onprogress=function(){System.isElectron()||this.showMessage("Processing...")}.bind(this),g.onwaiting=function(){System.isElectron()||this.showMessage("Waiting...")}.bind(this),g.addEventListener("ended",
4037function(){this.onEndOfVideoHdl(this.playerInstance,this.currentvideoid)}.bind(this)),System.isElectron()||0<g.currentSrc.length&&g.play(),this.startTimer());return c};b.prototype.generateSLPlayer=function(c,d,e){};b.prototype.onError=function(){alert("onError")};b.prototype.generateHTMLHelp=function(c){if(c=document.getElementById(c))c.innerHTML='For instructions click on the <a href="http://play.chessbase.com/js/apps/playchess/playchesscms.html">link</a>';return c};b.prototype.stop=function(){var c=
4038document.getElementsByTagName("video")[0];c&&(c.paused||c.pause())};b.prototype.getDuration=function(){var c=0,d=document.getElementsByTagName("video")[0];d&&(c=d.duration);return c};b.prototype.isWindows=function(){return-1!=navigator.appVersion.indexOf("Win")};b.prototype.autoPlay=function(){var c=StrUtil.getURLParam("autoplay"),d=!0;null!=c&&0<c.length&&(d="false"!=c);return d};b.prototype.disable=function(){var c=document.getElementById("wmpHolder0");c&&(c.innerHTML='<video controls type="video/mp4"></video>')}
4038;
4039b.prototype.setupAzureMediaPlayer=function(){a=MediaPlayerType.MediaPlayerAzure};b.prototype.setupHTML=function(){LOG("Setup HTML");a=MediaPlayerType.MediaPlayerHTML};b.prototype.setupSL=function(c){};b.prototype.setupAzure=function(c){this.htmlHolder=this.generateHTMLPlayer("wmpHolder"+this.playerInstance,320,320,c)};b.prototype.onCurGameChanged=function(){var c=this.gameKernel.getCurPos();if(this.cachepos)for(var d=0;d<this.cachepos.length;d++)if(c.equals(this.cachepos[d])){this.setStartTime(this.cachetime[d]);
4040break}};b.prototype.b64_to_utf8=function(c){return decodeURIComponent(escape(window.atob(c)))};b.prototype.setUrl=function(c){this.setupAzure(c)};b.prototype.doResize=function(c,d){if(a==MediaPlayerType.MediaPlayerAzure){var e=document.getElementsByTagName("video")[0];e&&(e.height=d,e.width=c,$("video#video").css("height",d+"px"))}};b.prototype.onSync=function(c){document.getElementById("MediaPlayer1")};b.prototype.onScriptCommand=function(c,d){null!=this.gameKernel&&this.gameKernel.executeGameAction(c,
4041d);if(null!=this.watchSessions)this.watchSessions.onGameActionFromStream(c,d)};b.prototype.getCurrentTime=function(){var c=document.getElementsByTagName("video")[0];return c?c.currentTime:0};b.prototype.setCurrentTime=function(c){var d=document.getElementsByTagName("video")[0];d&&(d.currentTime=c)};b.prototype.mustExecute=function(c,d){return c>=d&c<d+1};b.prototype.CMSGameActionsHandler=function(c){c=this.getCurrentTime();var d=document.getElementsByTagName("video")[0];if(d&&!d.paused)this.onGameActionHdl(this.playerInstance,
4042c)};b.prototype.saveToCloud=function(){glApp.cloudMgr&&glApp.cloudMgr.isLoggedIn()&&glApp.cloudMgr.saveGameToClipboard(this.gameKernel.game)};b.prototype.showTimedMessage=function(c,d){glApp.panelMgr.showMessage(c);this.gameKernel.boardWin.addMessage(c,!0);(new Timer(function(){this.gameKernel.boardWin.destroyMessage()}.bind(this))).runOnce(d)};b.prototype.showMessage=function(c){glApp.panelMgr.showMessage(c);this.gameKernel&&(this.gameKernel.boardWin.addMessage(c,!0),(new Timer(function(){this.gameKernel.boardWin.destroyMessage()}.bind(this))).runOnce(3E3))};
4043b.prototype.startTimer=function(){this.currenttime=0;null==this.myTimer&&(this.myTimer=setInterval(this.CMSGameActionsHandler.bind(this),1E3))};b.prototype.onWMV=function(c){c=c.substring(1,c.length-2);c=StrUtil.base64.decode(c);var d=new BroadcastStreamingDataEx;c=new BroadcastStreamingItemEx(c,StreamingItemType.WMV);d.add(c);this.reportBroadcastStreamingData(d)};b.prototype.onGA=function(c){c=c.substring(1,c.length-2);c=StrUtil.base64.decode(c);var d=new BroadcastStreamingDataEx;c=new BroadcastStreamingItemEx(c,
4044StreamingItemType.GAMEACTIONS);d.add(c);this.reportBroadcastStreamingData(d)};b.prototype.onMP4=function(c){c=c.substring(1,c.length-2);c=StrUtil.base64.decode(c);var d=new BroadcastStreamingDataEx;c=new BroadcastStreamingItemEx(c,StreamingItemType.MP4);d.add(c);this.reportBroadcastStreamingData(d)};b.prototype.pause=function(){var c=document.getElementsByTagName("video")[0];c&&(c.paused?c.play():c.pause())};b.prototype.play=function(){var c=document.getElementsByTagName("video")[0];c&&c.play()};
4045return b}();"use strict";
4046const OfflineVideoElement=function(){var a=function(b,c,d,e,f){this.aMediaplayer=MediaPlayerType.MediaPlayerAzure;this.nInPage=b;this.hasListeners=!1;this.fnGetKernel=c;this.ticket=d;this.gaHandler=e;this.endvideoHandler=f;this.initState()};a.prototype.initElem=function(b){this.videoManager=new OfflineVideoManager(this.nInPage,this.aMediaplayer,b,this.gaHandler,this.endvideoHandler)};a.prototype.initState=function(){};a.prototype.clear=function(){};a.prototype.onNewGame=function(){};a.prototype.resize=
4047function(b,c){this.videoManager.doResize(b,c)};a.prototype.disable=function(){this.videoManager.disable()};a.prototype.setUrl=function(b){this.videoManager.setUrl(b)};Vk.initForListeners(a);return a}();OfflineVideoElement.factory=function(a,b,c,d,e,f){b=new OfflineVideoElement(b||0,c,d,e,f);b.initElem(a);return b};"use strict";
4048class BoardTextures{constructor(a,b,c,d,e,f){BoardTextures.initForListeners();BoardTextures.initPixelFilter();this.localDB=localforage.createInstance({name:"Textures"});this.squaresW=this._loadBitmap(a);this.squaresB=this._loadBitmap(b);this.margin=this._loadBitmap(c);this.background=this._loadBitmap(d);this.callOnSquaresLoaded=function(){};
4048this.callOnBackgroundLoaded=function(){};this.squaresB.callOnLoaded=this._onSquaresLoaded.bind(this);this.squaresW.callOnLoaded=this._onSquaresLoaded.bind(this);
4049this.margin.callOnLoaded=this._onSquaresLoaded.bind(this);this.background.callOnLoaded=this._onBackgroundLoaded.bind(this);this.lastSizPix=0;this.cacheB=Array(64);this.cacheW=Array(64);this.clrCoordinates=e;this.clrMarginSepLine=f}destroy(){this.callOnSquaresLoaded=this.callOnBackgroundLoaded=null;this.removeAllListeners();this.abortCreateBackground();BoardTextures.clearCache()}static clearCache(){BoardTextures.pfCache={w:0,h:0,imageData:{}}}isBoardValid(){return this.squaresB.loaded&&this.squaresW.loaded&&
4050this.margin.loaded}getSquare(a,b){try{var c=CBSquare.isDark(a);if(!(0>a||63<a))return b==this.lastSizPix?c?void 0===this.cacheB[a]&&(this.cacheB[a]=this._cutSquare(a,b,c)):void 0===this.cacheW[a]&&(this.cacheW[a]=this._cutSquare(a,b,c)):(this.lastSizPix=b,this.cacheB=Array(64),this.cacheW=Array(64),c?this.cacheB[a]=this._cutSquare(a,b,c):this.cacheW[a]=this._cutSquare(a,b,c)),c?this.cacheB[a]:this.cacheW[a]}catch(d){LogException("Tex:getSquare",d)}}drawSquare(a,b,c,d){(b=this.getSquare(b,c))&&b.draw(a,
4051d.x,d.y)}getMarkedSquare(a,b){var c=document.createElement("canvas");c.width=c.height=b;c=c.getContext("2d",{willReadFrequently:!0});this.getSquare(a,b).draw(c,0,0);c.lineWidth=Math.max(1,b/16);c.strokeStyle=this.getOriginSquareMarkerClr();a=b-c.lineWidth;CanvasTools.drawRoundedRect(c,c.lineWidth/2,c.lineWidth/2,a,a,Math.max(1,a/4));a=new CBBitmap;a.copyFromCtx(c,0,0,b,b);return a}getOriginSquareMarkerClr(){return"hsla( 0, 10%, 10%, 0.4 )"}static initPixelFilter(){BoardTextures.pf||(BoardTextures.pf=
4052PixelFilter?new PixelFilter:{})}static pfCache={w:0,h:0,imageData:{}};createBackground(a,b,c){glApp.panelMgr.useBackgroundFilter()&&BoardTextures.pf&&600<b&&500<c&&this.background.loaded&&(this.background.drawTiled(a,0,0,b,c),a=a.getImageData(0,0,b,c),BoardTextures.pf.darkenCorners(a,function(d){BoardTextures.pfCache.w=d.width;BoardTextures.pfCache.h=d.height;BoardTextures.pfCache.imageData=d;this.fireOnBGReady()}.bind(this)))}abortCreateBackground(){BoardTextures.pf&&BoardTextures.pf.isRunning&&
4053BoardTextures.pf.abort()}drawBackground(a,b,c){this.background.loaded&&(BoardTextures.pfCache.w==b&&BoardTextures.pfCache.h==c?a.putImageData(BoardTextures.pfCache.imageData,0,0):this.background.drawTiled(a,0,0,b,c))}getTexturesForPieceStyle(a){switch(a){default:return CommandIds.BOARD2D_WOOD;case CommandIds.PIECES2D_OLDSTYLE:return CommandIds.BOARD2D_OLDWOOD;case CommandIds.PIECES2D_CRYSTALS:return CommandIds.BOARD2D_CRYSTALS;case CommandIds.PIECES2D_CRYSTALS_WOOD:return CommandIds.BOARD2D_CRYSTALS_WOOD;
4054case CommandIds.PIECES2D_USCF:return CommandIds.BOARD2D_USCF;case CommandIds.PIECES2D_HABSBURG:return CommandIds.BOARD2D_HABSBURG;case CommandIds.PIECES2D_WORLDCHESS:return CommandIds.BOARD2D_WORLDCHESS;case CommandIds.PIECES2D_FF:return CommandIds.BOARD2D_FF;case CommandIds.PIECES2D_BLUE:return CommandIds.BOARD2D_BLUE;case CommandIds.PIECES2D_RED:return CommandIds.BOARD2D_RED}}_loadBitmap(a){return CBBitmap.createFromDB(this.localDB,a)}_storeInLocalDB(a){if(!a.url||0!=a.url.search("blob:")){var b=
4055CanvasTools.imgToBlob(a.image,a.width,a.height);if(b)try{let c=0;this.localDB.iterate((d,e)=>{c+=d.size}).then(function(){console.log("TxtotSize = "+Math.round(c/1024)+"kB")});this.localDB.setItem(a.url,b)}catch(c){LogException("Tex::_storeInLocalDB",c)}}}_cutSquare(a,b,c){try{var d=Math.min(this.squaresB.width,this.squaresB.height),e=b,f=55;System.isMobile()&&(f=10);b<f?e=2*b:128<b&&(e=.5*b);if(this.squaresB&&this.squaresB.isValid()){var g=Math.floor((d-e)/7),h=83*CBSquare.getFile(a)%7*g,k=41*CBSquare.getRank(a)%
40567*g;0>h&&(h=0);0>k&&(k=0);var l=c?this.nYOffsBlack:0,m=new CBBitmap;this.ctx&&(b==e?m.copyFromCtx(this.ctx,h,k+l,b,b):m.copyScaledFromCtx(this.ctx,h,k+l,b,b,e,e));return m}}catch(n){LogException("Tex:cutSquare",n)}}_onSquaresLoaded(){this.squaresW.loaded&&this.squaresB.loaded&&this.margin.loaded&&(this.canvas=document.createElement("canvas"),this.canvas.width=Math.max(this.squaresW.width,this.squaresB.width),this.canvas.height=this.squaresW.height+this.squaresB.height,this.ctx=this.canvas.getContext("2d",
4057{willReadFrequently:!0}),this.squaresW.draw(this.ctx,0,0),this.nYOffsBlack=this.squaresW.height,this.squaresB.draw(this.ctx,0,this.nYOffsBlack),this.callOnSquaresLoaded&&this.callOnSquaresLoaded(),this._storeInLocalDB(this.squaresW),this._storeInLocalDB(this.squaresB),this._storeInLocalDB(this.margin))}
4057_onBackgroundLoaded(){this.callOnBackgroundLoaded&&this.callOnBackgroundLoaded();this._storeInLocalDB(this.background)}static initForListeners(){BoardTextures.listenersInited||(Vk.initForListeners(BoardTextures),
4058Vk.addEvent(BoardTextures,"BGReady"),BoardTextures.listenersInited=!0)}}"use strict";
4059var PieceSpriteFactory=function(){var a,b=0,c=function(e,f,g){this.id=++b;this.localDB=localforage.createInstance({name:"Pieces"});e||="DiagramTTFritz";this.loaded=!1;this.sqSidePix=g;this.sqRaster=f;this.bitmapAll=new CBBitmap;this.onLoadedHandlers=new Handlers(this);this.bitmapAll=CBBitmap.createFromDB(this.localDB,glApp.mediaPathChess+"Pieces/"+e+f+".png");this.bitmapAll.callOnLoaded=this._onLoaded.bind(this);this.urlsW=Array(6);this.urlsB=Array(6);this.name=e},d=[];c.getCachedFactory=function(e,
4060f,g){var h=d[f];h?h.nCacheUse++:(h=new PieceSpriteFactory(e,f,g),h.nCacheUse=0,d[f]=h,c.checkCache(f));return h};c.checkCache=function(e){var f=0;d.forEach(function(){f++});if(6<f){for(var g=1E5,h=-1,k=0;k<d.length;k++)d[k]&&d[k].nCacheUse<g&&k!=e&&(g=d[k].nCacheUse,h=k);0<=h&&delete d[h]}};c.resetCache=function(){d=[]};c.prototype.isValid=function(){return void 0!==this.urlsW[0]};c.prototype.addOnLoadedHandler=function(e){return this.onLoadedHandlers.add(e)};c.prototype.removeOnLoadedHandler=function(e){this.onLoadedHandlers.remove(e)};
4061c.prototype.createSprite=function(e){if(Piece.side(e)==Side.BLACK){var f=new Sprite;f.fromUrl(this.urlsB[Piece.nominal(e)-1]);f.piece=e;return f}f=new Sprite;f.fromUrl(this.urlsW[Piece.nominal(e)-1]);f.piece=e;return f};c.prototype.createPromoSprites=function(){this.ctx.clearRect(0,0,this.sqSidePix,this.sqSidePix);this.bitmapAll.draw(this.ctx,(Piece.W_QUEEN-1)*this.sqRaster,0,this.sqRaster,this.sqRaster,0,0,this.sqSidePix,this.sqSidePix);this.bitmapAll.draw(this.ctx,(Piece.W_KNIGHT-1)*this.sqRaster,
40620,this.sqRaster,this.sqRaster,.7*this.sqSidePix,0,.3*this.sqSidePix,.3*this.sqSidePix);this.bitmapAll.draw(this.ctx,(Piece.W_BISHOP-1)*this.sqRaster,0,this.sqRaster,this.sqRaster,.7*this.sqSidePix,.3*this.sqSidePix,.3*this.sqSidePix,.3*this.sqSidePix);this.bitmapAll.draw(this.ctx,(Piece.W_ROOK-1)*this.sqRaster,0,this.sqRaster,this.sqRaster,.7*this.sqSidePix,.6*this.sqSidePix,.3*this.sqSidePix,.3*this.sqSidePix);this.promoWhite=new Sprite(this.ctx);this.promoWhite.fromUrl(this.canvas.toDataURL());
4063this.ctx.clearRect(0,0,this.sqSidePix,this.sqSidePix);this.bitmapAll.draw(this.ctx,(Piece.B_QUEEN-3)*this.sqRaster,0,this.sqRaster,this.sqRaster,0,0,this.sqSidePix,this.sqSidePix);this.bitmapAll.draw(this.ctx,(Piece.B_KNIGHT-3)*this.sqRaster,0,this.sqRaster,this.sqRaster,.7*this.sqSidePix,0,.3*this.sqSidePix,.3*this.sqSidePix);this.bitmapAll.draw(this.ctx,(Piece.B_BISHOP-3)*this.sqRaster,0,this.sqRaster,this.sqRaster,.7*this.sqSidePix,.3*this.sqSidePix,.3*this.sqSidePix,.3*this.sqSidePix);this.bitmapAll.draw(this.ctx,
4064(Piece.B_ROOK-3)*this.sqRaster,0,this.sqRaster,this.sqRaster,.7*this.sqSidePix,.6*this.sqSidePix,.3*this.sqSidePix,.3*this.sqSidePix);this.promoBlack=new Sprite(this.ctx);this.promoBlack.fromUrl(this.canvas.toDataURL())};c.prototype.getPromoSprite=function(e){return e==Side.BLACK?this.promoBlack:this.promoWhite};c.prototype._onLoaded=function(){void 0===a&&(a=document.createElement("canvas"));this.canvas=a;this.canvas.width=this.sqSidePix;this.canvas.height=this.sqSidePix;this.ctx=this.canvas.getContext("2d");
4065for(var e=0;6>e;e++)this.ctx.clearRect(0,0,this.sqSidePix,this.sqSidePix),this.bitmapAll.draw(this.ctx,e*this.sqRaster,0,this.sqRaster,this.sqRaster,0,0,this.sqSidePix,this.sqSidePix),this.urlsW[e]=this.canvas.toDataURL();for(e=6;12>e;e++)this.ctx.clearRect(0,0,this.sqSidePix,this.sqSidePix),this.bitmapAll.draw(this.ctx,e*this.sqRaster,0,this.sqRaster,this.sqRaster,0,0,this.sqSidePix,this.sqSidePix),this.urlsB[e-6]=this.canvas.toDataURL();this.loaded=!0;this.createPromoSprites();this.onLoadedHandlers.execute();
4066this._storeInLocalDB(this.bitmapAll)};c.prototype._storeInLocalDB=function(e){if(!e.url||0!=e.url.search("blob:")){var f=CanvasTools.imgToBlob(e.image,e.width,e.height);if(f)try{this.localDB.iterate((g,h)=>{}).then(function(){}),this.localDB.setItem(e.url,f)}catch(g){LogException("PieceFact::_storeInLocalDB",g)}}};return c}();"use strict";
4067var spriteCache=[],BoardSprites=function(){var a=function(){this.spritesOnSq=[];this.reservoir=[];this.blindSprites=[]};a.clearCache=function(){spriteCache=[]};a.prototype.initSprites=function(b){var c=[0,1,2,3,3,3,10,0,0,1,2,3,3,3,10,0,0];this.spriteCount=c.reduce((f,g)=>f+g);for(var d=Piece.W_KING;d<=Piece.B_PAWN;d++){void 0==this.reservoir[d]&&(this.reservoir[d]=[]);for(var e=0;e<c[d];e++)this.reservoir[d].push(b.createSprite(d))}this.promoWhite=b.getPromoSprite(Side.WHITE);this.promoBlack=b.getPromoSprite(Side.BLACK);
4068this.sqSidePix=b.sqSidePix;this.name=b.name};a.prototype.create=function(b){this.initSprites(b)};a.prototype.copy=function(b){for(var c in b)b.hasOwnProperty(c)&&(this[c]=b[c])};a.prototype.setup=function(b,c,d){if(void 0!==b){if(this.spritesOnSq.length)for(var e=0;64>e;e++)void 0!==this.spritesOnSq[e]&&e!==d&&(this.reservoir[this.spritesOnSq[e].piece]&&(this.spritesOnSq[e].lastSq=e,this.reservoir[this.spritesOnSq[e].piece].push(this.spritesOnSq[e])),delete this.spritesOnSq[e]);for(e=0;64>e;e++){var f=
4069c[e];f&&e!==d&&(this.spritesOnSq[e]=this.createSprite(b,f,e),this.spritesOnSq[e].deleteBackgroun
4069d())}}};a.prototype.dumpReservoir=function(){};a.prototype.checkSpriteCount=function(b){};a.prototype.changeBoard=function(b,c,d){if(void 0!==b&&0!=this.reservoir.length){var e=[],f=[];for(var g=0;64>g;g+=1)0==c[g]||c[g]!=d[g]||void 0!==this.spritesOnSq[g]&&this.spritesOnSq[g].piece===c[g]||(LOG("Repair sprite squares at "+g,"error","board"),void 0!==this.spritesOnSq[g]&&this._toReservoir(this.spritesOnSq[g]),
4070this.spritesOnSq[g]=this.createSprite(b,c[g],g));for(var h=0;64>h;h+=1)0!==c[h]&&c[h]!=d[h]&&((g=this.spritesOnSq[h])||(g=this.createSprite(b,c[h],h)),f.push({square:h,piece:c[h],sprite:g}),delete this.spritesOnSq[h]);g=[];for(h=1;2>=h;h++)for(var k=0;64>k;k+=1)if(0!=d[k]&&c[k]!=d[k]&&!g[k]){for(var l=!1,m=-1,n=99999,r=0;r<f.length&&!l;r++)if(void 0!=f[r]&&f[r].piece==d[k]&&(2==h||CBSquare.getFile(f[r].square)==CBSquare.getFile(k))){var t=CBSquare.getDist(f[r],k);t<n&&(n=t,m=r)}0<=m&&(this.spritesOnSq[k]=
4071f[m].sprite,e.push(new PieceAnimationJob(d[k],this.spritesOnSq[k],f[m].square,k,glApp.Vh.getSquare(f[m].square,b.sqSidePix))),delete f[m],l=!0,g[k]=!0);l||2!=h||(this.spritesOnSq[k]=this.createSprite(b,d[k],k),e.push(new PieceAnimationJob(d[k],this.spritesOnSq[k],-1,k,glApp.Vh.getSquare(k,b.sqSidePix))))}for(r=0;r<f.length;r++)void 0!=f[r]&&(e.push(new PieceAnimationJob(f[r].piece,f[r].sprite,f[r].square,-1,glApp.Vh.getSquare(f[r].square,b.sqSidePix))),this._toReservoir(f[r].sprite),delete f[r]);
4072return e}};a.prototype.set=function(b,c){this.spritesOnSq[c]&&this._toReservoir(this.spritesOnSq[c]);b?this.spritesOnSq[c]=b:delete this.spritesOnSq[c]};a.prototype.giveBack=function(b){this._toReservoir(b)};a.prototype.createSprite=function(b,c,d){if(this.reservoir[c]&&0<this.reservoir[c].length){for(var e,f=!1,g=0;g<this.reservoir[c].length&&!f;g++)d==this.reservoir[c][g].lastSq&&((e=this.reservoir[c][g])&&(f=!0),this.reservoir[c].splice(g,1));f||((e=this.reservoir[c][0])||(e=b.createSprite(c)),
4073this.reservoir[c].shift());e.piece=c;e.sq=d;return e}LOG("Piece NOT in reservoir: "+CBSquare.getStr(d),"LogError","board");b=b.createSprite(c);b.sq=d;return b};a.prototype.getPromoSprite=function(b){return b==Side.BLACK?this.promoBlack:this.promoWhite};a.prototype.getBlindSprite=function(b,c){this.blindSprites[c]||(this.blindSprites[c]=b.createSprite(c));return this.blindSprites[c]};a.prototype.isAllLoaded=function(){for(var b=0;64>b;b++)if(void 0!==this.spritesOnSq[b]&&!this.spritesOnSq[b].loaded)return!1;
4074if(0==this.reservoir.length)return!1;for(b=Piece.W_KING;b<=Piece.B_PAWN;b++)for(var c=0;c<this.reservoir[b].length;c++)if(!this.reservoir[b][c]||!this.reservoir[b][c].loaded)return!1;return!0};a.prototype.change=function(b,c){void 0!==this.spritesOnSq[c]&&this._toReservoir(this.spritesOnSq[c]);this.spritesOnSq[c]=this.spritesOnSq[b];delete this.spritesOnSq[b]};a.prototype.promo=function(b,c,d,e){void 0!==this.spritesOnSq[c]&&this._toReservoir(this.spritesOnSq[c]);this.spritesOnSq[c]=this.createSprite(e,
4075d);this.spritesOnSq[b].deleteBackground();this._toReservoir(this.spritesOnSq[b]);delete this.spritesOnSq[b]};a.prototype.enPassant=function(b,c,d){this.spritesOnSq[c]=this.spritesOnSq[b];this._toReservoir(this.spritesOnSq[d]);delete this.spritesOnSq[d];delete this.spritesOnSq[b]};a.prototype.deleteBackgrounds=function(){for(var b=0;64>b;b++)void 0!==this.spritesOnSq[b]&&this.spritesOnSq[b].deleteBackground();this.promoWhite&&this.promoWhite.deleteBackground();this.promoBlack&&this.promoBlack.deleteBackground()};
4076a.prototype.getPiece=function(b){return this.spritesOnSq[b]};a.prototype._toReservoir=function(b){this.reservoir[b.piece].push(b)};a.prototype._getClickRect=function(b,c){return new CBRect(Math.floor(b.x-c/2),Math.floor(b.y-c/2),Math.floor(b.x+c/2),Math.floor(b.y+c/2))};return a}(),PieceAnimationJob=function(){var a=function(b,c,d,e,f){CBDebug.assert(void 0!==c);this.piece=b;this.sprite=c;this.sqFrom=d;this.sqTo=e;this.textureSqTo=f;this.ptFrom=this.ptTo=new CBPoint(0,0)};a.prototype.isBoardAttribute=
4077function(){return!1};a.prototype.isPieceAnim=!0;a.prototype.deleteBackground=function(){this.sprite.deleteBackgroun
4077d()};a.prototype.startAnimation=function(b,c){this.debug="started";this.sprite.hide(b);b=this.ptTo.subtract(this.ptFrom);var d=new CBVector(b.x,b.y);this.nAnimCountDown=Math.floor(d.getLength()/this.sprite.w*c+.5);this.isFirst=!0;5>this.nAnimCountDown&&(this.nAnimCountDown=5);this.vecDisplace=new CBVector(b.x/this.nAnimCountDown,b.y/this.nAnimCountDown);this.currPos=this.ptFrom;if(-1==
4078this.sqFrom||-1==this.sqTo)this.nAnimCountDown=0;-1==this.sqTo&&(this.capturedPiece=!0);this.totCountDown=this.nAnimCountDown};a.prototype.loaded=function(){return this.sprite&&this.sprite.loaded};a.prototype.hide=function(b){if(this.sprite){var c=!1,d=Math.floor(this.sprite.w/2);this.isFirst&&-1!=this.sqFrom?void 0!==this.textureSqTo&&(this.textureSqTo.draw(b,this.ptFrom.x-d,this.ptFrom.y-d),this.sprite.saveBeforeMove(b,this.currPos),c=!0):-2==this.nAnimCountDown&&-1==this.sqFrom&&void 0!==this.textureSqTo&&
4079(this.textureSqTo.draw(b,this.ptTo.x-d,this.ptTo.y-d),this.sprite.saveBeforeMove(b,this.currPos),c=!0);c||this.sprite.hide(b)}};a.prototype.show=function(b){this.sprite.show(b)};a.prototype.moveToNoSave=function(b,c){this.sprite.moveToNoSave(b,c)};a.prototype.moveTo=function(b,c){this.sprite.moveTo(b,c)};a.prototype.getPumpedW=function(){};a.prototype.getPumpedH=function(){};a.prototype.getPumpFactor=function(){if(this.totCountDown){var b=Math.min(1,(this.totCountDown-this.nAnimCountDown)/this.totCountDown);
4080return.5>b?1+1*b:1+(1-b)}return 1};a.prototype.saveBeforeMove=function(b,c){this.sprite.saveBeforeMove(b,c)};a.prototype.getMoveClipRect=function(){return this.sprite.getMoveClipRect()};a.prototype.deleteBackground=function(){this.sprite.deleteBackground()};a.prototype.displace=function(b){b=this.limitSteps(b);this.currPos.x+=b*this.vecDisplace.x;this.currPos.y+=b*this.vecDisplace.y};a.prototype.prepNextStep=function(b){b=this.limitSteps(b);this.nAnimCountDown-=b;this.isFirst=!1;return-2>this.nAnimCountDown};
4081a.prototype.canDelete=function(){return-2>this.nAnimCountDown};a.prototype.limitSteps=function(b){1>=this.nAnimCountDown?b=1:b>this.nAnimCountDown&&(b=this.nAnimCountDown);return b};a.prototype.isDeleteAtEnd=function(){return-1===this.sqTo};a.prototype.shouldHideInThisStep=function(){return-3<=this.nAnimCountDown&&void 0!==this.sprite};a.prototype.hasReachedEndPos=function(){return 0>=this.nAnimCountDown};a.prototype.isImmobileInThisStep=function(){return-1>=this.nAnimCountDown};a.prototype.getsInvisibleAtEnd=
4082function(){return-2>=this.nAnimCountDown&&this.isDeleteAtEnd()};a.prototype.isStillMoving=function(){return 0<=this.nAnimCountDown};return a}();"use strict";
4083var BoardFunAnimations=function(){var a=function(b){this.board=b;this.happyRook=null;this.animSteps=ObjUtil.clone(b.animSteps)};a.prototype.cancelFun=function(b){(new Timer(function(){this.board.animSteps=this.animSteps;this.board.redraw()}.bind(this))).runOnce(b)};a.prototype.happySize=a.prototype.defaultSize=64;a.prototype.stampHappy=function(){null==this.happyRook&&(this.happyRook=this.createFunSprite("Happy",this.happySize));var b=new BitmapAnimationJob(this.happyRook,this.getHappyStart(),this.getHappyEnd());
4084this.board.animSteps={forMove:3,forPosition:2};this.board.runFunAnimation([b]);this.cancelFun(3E3)};a.prototype.stampCheckOk=function(){null==this.checkMark&&(this.checkMark=this.createFunSprite("Check",this.defaultSize));var b=new BitmapAnimationJob(this.checkMark,this.getHappyStart(),this.getHappyEnd());this.board.animSteps={forMove:4,forPosition:2};this.board.runFunAnimation([b]);this.cancelFun(3E3)};a.prototype.getHappyStart=function(){var b=this.board.getInnerRect().getTopLeft();b.x+=this.happySize;
4085b.y+=this.happySize;return b};a.prototype.getHappyEnd=function(){var b=this.board.getInnerRect(),c=b.getTopLeft();c.x+=b.w/2;c.y+=b.h/2;return c};a.prototype.createFunSprite=function(b,c){b=glApp.mediaPathChess+"Sprites/"+b+c.toString()+".png";c=new Sprite;c.fromUrl(b);c.noShadow=!0;return c};return a}(),BitmapAnimationJob=function(){var a=function(b,c,d){CBDebug.assert(void 0!==b);this.sprite=b;this.ptFrom=c;this.ptTo=d};a.prototype.isBoardAttribute=function(){return!1};
4085a.prototype.deleteBackground=
4086function(){this.sprite.deleteBackground()};a.prototype.copyBackground=function(b){this.sprite.saveBeforeMove(b,this.ptFrom)};a.prototype.startAnimation=function(b,c){this.debug="started";this.copyBackground(b);b=this.ptTo.subtract(this.ptFrom);var d=new CBVector(b.x,b.y);this.nAnimCountDown=Math.floor(d.getLength()/this.sprite.w*c+.5);this.isFirst=!0;5>this.nAnimCountDown&&(this.nAnimCountDown=5);this.vecDisplace=new CBVector(b.x/this.nAnimCountDown,b.y/this.nAnimCountDown);this.currPos=this.ptFrom};
4087a.prototype.loaded=function(){return this.sprite&&this.sprite.loaded};a.prototype.hide=function(b){this.sprite&&this.sprite.hide(b)};a.prototype.show=function(b){this.sprite.show(b)};a.prototype.moveToNoSave=function(b,c){this.sprite.moveToNoSave(b,c)};a.prototype.moveTo=function(b,c){this.sprite.moveTo(b,c)};a.prototype.saveBeforeMove=function(b,c){this.sprite.saveBeforeMove(b,c)};a.prototype.getMoveClipRect=function(){return this.sprite.getMoveClipRect()};a.prototype.deleteBackground=function(){this.sprite.deleteBackground()};
4088a.prototype.displace=function(b){b=this.limitSteps(b);this.currPos.x+=b*this.vecDisplace.x;this.currPos.y+=b*this.vecDisplace.y};a.prototype.prepNextStep=function(b){b=this.limitSteps(b);this.nAnimCountDown-=b;this.isFirst=!1;return-2>this.nAnimCountDown};a.prototype.canDelete=function(){return-2>this.nAnimCountDown};a.prototype.limitSteps=function(b){1>=this.nAnimCountDown?b=1:b>this.nAnimCountDown&&(b=this.nAnimCountDown);return b};a.prototype.isDeleteAtEnd=function(){return-1===this.sqTo};a.prototype.shouldHideInThisStep=
4089function(){return-3<=this.nAnimCountDown&&void 0!==this.sprite};a.prototype.hasReachedEndPos=function(){return 0>=this.nAnimCountDown};a.prototype.isImmobileInThisStep=function(){return-1>=this.nAnimCountDown};a.prototype.getsInvisibleAtEnd=function(){return-2>=this.nAnimCountDown&&this.isDeleteAtEnd()};a.prototype.isStillMoving=function(){return 0<=this.nAnimCountDown};return a}();"use strict";
4090var attrId=0,BoardArrow=function(){function a(d){return 0<d?1:0>d?-1:0}var b=function(d,e,f,g,h){this.from=d;this.to=e;this.rgba=f;this.lineWidthPercent=g;this.id=++attrId;this.dash=h;this.zValue=0};b.prototype.draw=function(d){if(this.boardControl){d.save();var e=this.boardControl.getSquareCenterPos(this.from),f=this.boardControl.getSquareCenterPos(this.to),g=CBSquare.getFile(this.from),h=CBSquare.getRank(this.from),k=CBSquare.getFile(this.to),l=CBSquare.getRank(this.to);h=a(l-h);g=a(k-g);this.boardControl.blackIsBottom?
4091(f.x+=g*this.boardControl.nSqPix/4,f.y-=h*this.boardControl.nSqPix/4):(f.x-=g*this.boardControl.nSqPix/4,f.y+=h*this.boardControl.nSqPix/4);g=.5*this.boardControl.nSqPix;this.lineWidthPercent?(d.lineWidth=Math.max(1,this.boardControl.nSqPix*this.lineWidthPercent*.01),g=5*d.lineWidth):d.lineWidth=Math.max(1,.09*this.boardControl.nSqPix);d.lineCap="round";this.rgba?b.setStrokeFillStyles(d,this.rgba,e.x,e.y,f.x,f.y):(k=b.getHslYellow(),d.strokeStyle=(new CBHSLColor(k.h,k.s,k.l,.75)).toString(),d.fillStyle=
4092(new CBHSLColor(k.h,k.s,k.l,.9)).toString());b.drawArrow(d,e.x,e.y,f.x,f.y,3,1,Math.PI/8,g,.8*d.lineWidth,this.rgba,this.dash);
4092d.restore();return this._getClipRect()}};b.setStrokeFillStyles=function(d,e,f,g,h,k){if(e&&(e.alpha||e.hue)){f=d.createLinearGradient(f,g,h,k);var l=e.alpha;e.alpha=.15;f.addColorStop(0,e);e.alpha=.4;f.addColorStop(.4,e);e.alpha=.55;f.addColorStop(.6,e);e.alpha=l;f.addColorStop(1,e);d.strokeStyle=f;d.fillStyle=e}else e&&0==e.search("hsla")?(l=/hsla\(\s*(\d{1,3}),\s*(\d{1,3})%,\s*(\d{1,3})%,\s(.+)\)/g.exec(e),
4093f=d.createLinearGradient(f,g,h,k),g=String.f("hsla( {0}, {1}%, {2}%, {3} )",l[1],l[2],l[3],"0.15"),h=String.f("hsla( {0}, {1}%, {2}%, {3} )",l[1],l[2],l[3],"0.4"),k=String.f("hsla( {0}, {1}%, {2}%, {3} )",l[1],l[2],l[3],.55*l[4]),l=String.f("hsla( {0}, {1}%, {2}%, {3} )",l[1],l[2],l[3],l[4]),f.addColorStop(0,g),f.addColorStop(.4,h),f.addColorStop(.6,k),f.addColorStop(1,l),d.strokeStyle=f,d.fillStyle=e):(d.fillStyle=e,d.strokeStyle=e)};b.prototype.undo=function(d){if(this.boardControl){for(var e=CBSquare.getFile(this.from),
4094f=CBSquare.getRank(this.from),g=CBSquare.getFile(this.to),h=CBSquare.getRank(this.to),k=a(h-f),l=a(g-e),m=this.boardControl.hideCurrPiece();e!=g||f!=h;){this.boardControl.restoreSquare(d,CBSquare.I(e,f));if(0!=l&&0!=k){var n=CBSquare.I(e+l,f),r=CBSquare.I(e,f+k);0<=n&&64>n&&this.boardControl.restoreSquare(d,n);0<=r&&64>r&&this.boardControl.restoreSquare(d,r)}e!=g&&(e+=l);f!=h&&(f+=k)}0<=e&&0<=f&&this.boardControl.restoreSquare(d,CBSquare.I(e,f));m&&this.boardControl.unHideCurrPiece()}return this._getClipRect()};
4095b.prototype._getClipRect=function(){if(this.boardControl){var d=this.boardControl.getSquareRect(this.from);d=d.getUnion(this.boardControl.getSquareRect(this.to));if(this.lineWidthPercent){var e=this.boardControl.nSqPix*this.lineWidthPercent*.01;d.expand(e,e)}return d}return new CBRect(0,0,2E3,2E3)};b.prototype.toString=function(){return"Arrow: "+CBSquare.toString(this.from)+"-"+CBSquare.toString(this.to)};b.prototype.getId=function(){return"arrow"+this.from+this.to};var c=function(d,e,f,g,h,k,l,m){d.beginPath();
4096d.moveTo(e,f);d.lineTo(g,h);d.lineTo(k,l);switch(m){case 0:m=Math.sqrt((k-e)*(k-e)+(l-f)*(l-f));d.arcTo(g,h,e,f,.55*m);d.fill();break;case 1:d.lineTo(e,f);d.fill();break;case 2:d.stroke();break;case 3:d.quadraticCurveTo((e+g+k)/3,(f+h+l)/3,e,f);d.fill();break;case 4:if(k==e)m=l-f,k=(g+e)/2,g=(g+e)/2,l=h+m/5,m=h-m/5;else{m=Math.sqrt((k-e)*(k-e)+(l-f)*(l-f));g=((e+k)/2+g)/2;h=((f+l)/2+h)/2;k=(l-f)/(k-e);m=m/(2*Math.sqrt(k*k+1))/5;var n=k*m;k=g-m;l=h-n;g+=m;m=h+n}d.bezierCurveTo(k,l,g,m,e,f);d.fill()}};
4097c=function(d,e,f,g,h,k,l,m){d.beginPath();d.moveTo(e,f);d.lineTo(g,h);d.lineTo(k,l);switch(m){case 0:m=Math.sqrt((k-e)*(k-e)+(l-f)*(l-f));d.arcTo(g,h,e,f,.55*m);d.fill();break;case 1:d.lineTo(e,f);d.fill();break;case 2:d.stroke();break;case 3:d.quadraticCurveTo((e+g+k)/3,(f+h+l)/3,e,f);d.fill();break;case 4:if(k==e)m=l-f,k=(g+e)/2,g=(g+e)/2,l=h+m/5,m=h-m/5;else{m=Math.sqrt((k-e)*(k-e)+(l-f)*(l-f));g=((e+k)/2+g)/2;h=((f+l)/2+h)/2;k=(l-f)/(k-e);m=m/(2*Math.sqrt(k*k+1))/5;var n=k*m;k=g-m;l=h-n;g+=m;
4098m=h+n}d.bezierCurveTo(k,l,g,m,e,f);d.fill()}};b.drawFree=function(d,e,f,g,h,k,l,m){d.save();d.lineWidth=k;d.lineCap="round";BoardArrow.drawArrow(d,e,f,g,h,3,1,Math.PI/8,6*k,.8*d.lineWidth,l,m);d.restore()};b.drawArrow=function(d,e,f,g,h,k,l,m,n,r,t,u){k="undefined"!=typeof k?k:3;l="undefined"!=typeof l?l:1;m="undefined"!=typeof m?m:Math.PI/8;n="undefined"!=typeof n?n:10;r=r||0;var x="function"!=typeof k?c:k,B=g-e,y=h-f,A=Math.sqrt(B*B+y*y);if(0!=A){var aa=Math.atan2(h-f,g-e),ha=r*Math.cos(aa);r*=
4099Math.sin(aa);A=(A-.76*n)/A;l&1?(B=e+B*A-ha,y=f+y*A-r):(B=g,y=h);l&2?(ha=e+(g-e)*(1-A),A=f+(h-f)*(1-A)):(ha=e,A=f);d.save();t?b.setStrokeFillStyles(d,t,ha,A,B,y):(t=d.createLinearGradient(ha,A,B,y),r=b.getHslYellow(),t.addColorStop(0,(new CBHSLColor(r.h,r.s,r.l,.2)).toString()),t.addColorStop(.2,(new CBHSLColor(r.h,r.s,r.l,.35)).toString()),t.addColorStop(.65,(new CBHSLColor(r.h,r.s,r.l,.55)).toString()),t.addColorStop(1,(new CBHSLColor(r.h,r.s,r.l,.9)).toString()),d.strokeStyle=t);d.beginPath();u&&
4100d.setLineDash(u);d.moveTo(ha,A);d.lineTo(B,y);d.stroke();n=Math.abs(n/Math.cos(m));l&1&&(t=aa+Math.PI+m,u=g+Math.cos(t)*n,t=h+Math.sin(t)*n,y=aa+Math.PI-m,B=g+Math.cos(y)*n,y=h+Math.sin(y)*n,x(d,u,t,g,h,B,y,k));l&2&&(t=aa+m,u=e+Math.cos(t)*n,t=f+Math.sin(t)*n,y=aa-m,B=e+Math.cos(y)*n,y=f+Math.sin(y)*n,x(d,u,t,e,f,B,y,
4100k));d.restore()}};b.getHslYellow=function(){return{h:40,s:90,l:60}};return b}(),BoardColouredSquare=function(){var a=function(b,c,d){this.sq=b;this.rgba=c;this.isWholeSquare=d;this.id=
4101++attrId;this.zValue=0};a.prototype.draw=function(b){return this.drawFrame(b)};a.prototype.drawFrame=function(b){if(this.boardControl){var c=this.boardControl.getSquareCenterPos(this.sq);b.strokeStyle=this.rgba?b.fillStyle=this.rgba.toString():b.fillStyle="rgba( 255, 220, 10, 0.5 )";var d=16;this.isWholeSquare&&(d=10);b.lineWidth=Math.max(1,this.boardControl.nSqPix/d);this.boardControl.drawSquare(b,this.sq);d=this.boardControl.nSqPix-b.lineWidth;var e=d-0;CanvasTools.drawRoundedRect(b,c.x-d/2,c.y-
4102d/2,e,e,Math.max(1,e/3.5));this.boardControl.drawPiece(b,this.sq);return this._getClipRect()}};a.prototype.drawWhole=function(b){if(this.boardControl){var c=this.boardControl.getSquareCenterPos(this.sq);CBSquare.getFile(this.sq);CBSquare.getRank(this.sq);b.lineWidth=Math.max(1,.08*this.boardControl.nSqPix);this.rgba?b.strokeStyle=b.fillStyle=this.rgba:(b.strokeStyle="rgba( 255, 220, 10, 0.6 )",b.fillStyle="rgba( 255, 220, 10, 0.6 )");var d=.5*this.boardControl.nSqPix;b.fillRect(c.x-d,c.y-d,2*d,2*
4103d);return this._getClipRect()}};a.prototype.undo=function(b){if(this.boardControl){var c=CBSquare.getFile(this.sq),d=CBSquare.getRank(this.sq),e=this.boardControl.hideCurrPiece();this.boardControl&&this.boardControl.restoreSquare(b,CBSquare.I(c,d));e&&this.boardControl.unHideCurrPiece()}return this._getClipRect()};a.prototype._getClipRect=function(){return this.boardControl?this.boardControl.getSquareRect(this.sq):new CBRect(0,0,2500,2500)};a.prototype.toString=function(){return"Sq="+CBSquare.toString(this.sq)+
4104", Clr="+this.rgba};a.fromJson=function(b){this.sq=b.sq};a.prototype.getId=function(){return"square"+this.sq};return a}(),BoardLinePoint=function(){var a=function(b,c,d){this.sq=b;this.corner=c;this.inside=d;this.zValue=0};a.stringToPoints=function(b){var c=[];if(b=b.match(/[a-h][1-8][t,b][l,r]/ig))for(var d=0;d<b.length;d++){var e=CBSquare.fromString(b[d].substr(0,2));c.push(new BoardLinePoint(e,b[d].substr(2,2)))}return c};a.prototype.getXY=function(b,c){this.inside&&(c=0);var d=b.getPixPos(this.sq);
4105b=b.nSqPix;switch(this.corner){case "tl":d.x-=c/2;d.y-=c/2;break;case "tr":d.x+=b+c/2;d.y-=c/2;break;case "bl":d.x-=c/2;d.y+=b+c/2;break;case "br":d.x+=b+c/2;d.y+=b+c/2;break;case "ct":d.x+=b/2;d.y+=b/2;break;case "bm":d.x+=b/2+c/2;d.y+=b+c/2;break;case "tm":d.x+=b/2+c/2;d.y-=c/2;break;case "lm":d.x-=c/2;d.y+=b/2+c/2;break;case "rm":d.x+=b+c/2,d.y+=b/2+c/2}return d};a.prototype.getClipRect=function(b,c){var d=b.getPixPos(this.sq);b=b.nSqPix;b+=2*c;d.x-=c;d.y-=c;c=new CBRect;c.fromTwoPoints(d.x,d.y,
4106d.x+b,d.y+b);return c};a.prototype.toString=function(){return"Point: Sq="+CBSquare.toString(this.sq)+", Corner="+this.corner};a.prototype.getId=function(){return"point"+this.sq+this.corner};return a}(),BoardLine=function(){var a=function(b,c,d,e){this.points=b||[];this.thickPercent=c||10;this.clr=d;this.dash=e;this.id=++attrId;this.zValue=0};a.prototype.draw=function(b){b.save();b.strokeStyle=this.clr?b.fillStyle=this.clr:b.fillStyle="hsla( 0, 50%, 70%, 0.6 )";b.lineCap="round";b.lineWidth=this.getLineWidthPixel();
4107if(this.points.length){b.beginPath();this.dash&&this.dash.length&&b.setLineDash(this.dash);var c=this.points[0].getXY(this.boardControl,b.lineWidth);b.moveTo(c.x,c.y);for(var d=1;d<this.points.length;d++)c=this.points[d].getXY(this.boardControl,b.lineWidth),b.lineTo(c.x,c.y);b.stroke()}b.restore();return this._getClipRect()};a.prototype.undo=function(b){return this._getClipRect()};a.prototype.getLineWidthPixel=function(){return Math.max(1,this.boardControl.nSqPix*this.thickPercent/100)};a.prototype._getClipRect=
4108function(){for(var b=null,c=0;c<this.points.length;c++)b=null==b?this.points[c].getClipRect(this.boardControl,this.getLineWidthPixel()):b.getUnion(this.points[c].getClipRect(this.boardControl,this.getLineWidthPixel()));return b?b:new CBRect(0,0,2500,2500)};a.prototype.toString=function(){return"Line: "+this.clr.toString()+"/"+this.thickPercent};a.prototype.getId=function(){return"line"+this.points.join(",")};return a}(),BoardZone=function(){var a=function(c,d,e,f,g,h,k){this.from=c;this.to=d;this.thick=
4109e;this.clr=f;this.dash=g;
4109this.boardControl=h;this.inside=k;this.init();this.zValue=0};a.prototype.init=function(){this.edges=this.getEdgeSquares(this.from,this.to);this.id=this.getId();this.createLine()};a.prototype.getEdgeSquares=function(c,d){c=[c,d,8*Math.floor(c/8)+d%8,8*Math.floor(d/8)+c%8];b(c);return c};var b=function(c){c.sort(function(d,e){var f=Math.floor(d/8),g=Math.floor(e/8);return f!=g?f-g:d%8-e%8});c[2]=[c[3],c[3]=c[2]][0];c[2]==c[3]&&8>c[2]-c[1]&&(c[1]=[c[3],c[3]=c[1]][0])};a.prototype.createLine=
4110function(){var c=["bl","tl","tr","br"];this.boardControl.blackIsBottom&&(c=["tr","br","bl","tl"]);c=c.map(function(d,e){return new BoardLinePoint(this.edges[e],d,this.inside)}.bind(this));c.push(new BoardLinePoint(this.edges[0],this.boardControl.blackIsBottom?"tr":"bl",this.inside));c=new BoardLine(c,this.thick,this.clr,this.dash);c.boardControl=this.boardControl;this.line=c};a.prototype.draw=function(c){return this.line.draw(c)};a.prototype.undo=function(c,d){return this.line.undo(c,d)};a.prototype.toString=
4111function(){return"Zone: "+this.edges.join(",")};a.prototype.getId=function(){return"zone"+this.edges.join(",")};a.fromLiteral=function(c,d){Object.setPrototypeOf(c,a.prototype);c.boardControl=d;c.init();return c};return a}();
4112class BoardCircle{constructor(a,b){this.square=a;this.color=b;this.id=`circle ${a}`;this.zValue=0}draw(a){if(this.boardControl){var b=this.boardControl.getSquareCenterPos(this.square),c=this.boardControl.nSqPix/4.8;a.beginPath();a.arc(b.x,b.y,c,0,2*Math.PI);a.fillStyle=this.color;a.fill();return this._getClipRect()}}undo(a){if(!this.boardControl)return new CBRect(0,0,2500,2500);this.boardControl.restoreSquare(a,this.square);return this.boardControl.getSquareRect(this.square)}_getClipRect(){return this.boardControl?
4113this.boardControl.getSquareRect(this.sq):new CBRect(0,0,2500,2500)}}
4114class SymbolAtSquare{constructor(a,b){this.square=a.to;this.from=a.from;this.text=Vz.getMarksText(b);this.zValue=5;this.text.length&&(this.id=++attrId,this.undoRect=new CBRect(0,0,0,0),this.restoreBG=new CBBitmap,this.undoTimer=new Timer(function(){this.undo(this.ctx);this.boardControl&&this.boardControl.cbcanvas.requestAnimation()}.bind(this)))}isValid(){return 0<this.text.length}draw(a){this.ctx=a;if(this.boardControl&&this.text){a.save();var b=this.boardControl.getSquareRect(this.square),c=Math.max(8,
4115Math.round(b.w/3.6));a.font=`700 ${c}px ${"Roboto"}`;var d=b.right-b.w/14,e=b.top+c,f=a.measureText(this.text),g=f.actualBoundingBoxAscent+f.actualBoundingBoxDescent;this.onTheLeft()?d=b.left-f.width+b.w/14:7==CBSquare.F(this.square)&&(d-=.8*this.boardControl.nMarginW);b=d+f.width/2;g=e-g/2;f=.9*c;var h=.2*f,k=b-f,l=g-f;this.undoRect=new CBRect(k,l,k+2*f+1,l+2*f+1);this.restoreBG.copyFromCtx(a,k,l,2*f+c/3,2*f+c/3);h=a.createRadialGradient(b,g,f,b,g,h);k=100;l=35;switch(this.text){case "!":k=100;break;
4116case "!!":k=110;break;case "!?":k=80;break;case "?!":k=50;l=38;break;case "?":k=15;l=40;break;case "??":k=5,l=42}h.addColorStop(0,`hsla( ${k}, ${60}%, ${l}%,0.90`);h.addColorStop(1,`hsla( ${k}, ${65}%, ${l+10}%, 0.88`);a.fillStyle=h;a.beginPath();a.ellipse(b,g,f,f,0,2*Math.PI,!1);a.shadowOffsetX=c/8;a.shadowOffsetY=c/8;a.shadowColor="hsla( 0, 0%, 0%, 0.25 )";a.shadowBlur=c/4.5;a.fill();a.fillStyle="hsla( 0, 0%, 99%, 1.0 )";a.fillText(this.text,d,e);a.restore();this.undoTimer.runOnce(2E3);return this._getClipRect()}}onTheLeft(){return!1}undo(a){this.undoTimer.stop();
4117if(this.text){if(!this.boardControl)return new CBRect(0,0,2500,2500);this.restoreBG.draw(a,this.undoRect.left,this.undoRect.top);var b=[this.square],c=this.boardControl.blackIsBottom?-1:1;let d=this.boardControl.blackIsBottom?0:7;CBSquare.R(this.square)!=d&&(b.push(CBSquare.gen(CBSquare.F(this.square),CBSquare.R(this.square)+c)),CBSquare.F(this.square)!=d||this.onTheLeft())&&(this.onTheLeft()?(b.push(CBSquare.gen(CBSquare.F(this.square)-c,CBSquare.R(this.square))),b.push(CBSquare.gen(CBSquare.F(this.square)-
4118c,CBSquare.R(this.square)+c))):(b.push(CBSquare.gen(CBSquare.F(this.square)+c,CBSquare.R(this.square))),b.push(CBSquare.gen(CBSquare.F(this.square)+c,CBSquare.R(this.square)+c))));if(CBSquare.R(this.square)==d||CBSquare.F(this.square)==7-d&&this.onTheLeft()||CBSquare.F(this.square)==d&&!this.onTheLeft())for(this.boardControl.drawMargin(a),b=0;64>b;b++)this.boardControl.restoreSquare(a,b);else for(c=0;c<b.length;c++)this.boardControl.restoreSquare(a,b[c]);this.boardControl.addBoardColourAndArrowsFromAnno(!1,
4119a,!0);this.boardControl.markLastMove(!0,!0)}return this._getClipRect()}_getClipRect(){return this.boardControl?this.boardControl.getOuterRect():new CBRect(0,0,2500,2500)}}
4120class BoardText{constructor(a,b){this.move=a;this.text=this.removeUnwanted(b);this.id=++attrId;
4120this.undoRect=new CBRect(0,0,0,0);this.restoreBG=new CBBitmap;this.zValue=10;this.undoTimer=new Timer(function(){this.undo(this.ctx);this.boardControl&&this.boardControl.cbcanvas.requestAnimation()}.bind(this))}static isAcceptableText(a){if(a&&" [#]"!=a&&"[#]"!=a)return-1==a.search("Weighted Error")}removeUnwanted(a){let b=a.indexOf("[#]");return-1!=b?(a=a.split(""),a.splice(b,3),a.join("")):a}draw(a){this.ctx=
4121a;if(!this.boardControl||!this.text||2>=this.text.length)return this._getClipRect();a.save();var b=this.boardControl.getInnerRect(),c=this.boardControl.getSquareRect(this.move.to);let d=Math.max(8,Math.round(c.w/3.5));a.font=`${d}px ${"Roboto Condensed"}`;var e=a.measureText(this.text);e.width>b.w&&(this.text=this.text.substr(0,b.w/e.width*this.text.length-4),e=a.measureText(this.text));let f=e.fontBoundingBoxAscent+e.fontBoundingBoxDescent,g=Math.max(2.5*c.w,e.width+d),h=2*f,k=b.left+(b.w-g)/2,l=
4122b.top+(b.h-h)/2;l=c.top>b.top+.6*b.h?l-b.h/4:l+b.h/4;b=k+(g-e.width)/2;e=l+(h-f)/2+f-e.fontBoundingBoxDescent+1;a.shadowOffsetX=d/8;a.shadowOffsetY=d/8;a.shadowColor="hsla( 0, 0%, 0%, 0.3 )";a.shadowBlur=d/4;a.lineWidth=Math.max(1,c.w/30);a.strokeStyle="hsla( 0, 0%, 0%, 0.8 )";CanvasTools.drawRoundedRect(a,k,l,g,h,d/2,"hsla( 200, 20%, 10%, 0.40)");a.fillStyle="hsla( 0, 0%, 99%, 1.0 )";a.fillText(this.text,b,e);a.restore();this.undoTimer.runOnce(2500);return this._getClipRect()}undo(a){this.undoTimer.stop();
4123a||(a=this.ctx);if(a){if(this.text){if(!this.boardControl)return new CBRect(0,0,2500,2500);for(let b=0;64>b;b++)this.boardControl.restoreSquare(a,b)}return this.boardControl.getOuterRect()}}_getClipRect(){return this.boardControl?this.boardControl.getOuterRect():new CBRect(0,0,2500,2500)}}"use strict";
4124class BoardArea{constructor(a,b,c,d){this.cbcanvas=a;this.width=b;this.height=c;this.options=d;this.boards=[];this.shadows=[];a=System.isFirefox()||System.isSafari()||System.runsInIFrame();if(!a&&!this.isTransparent()){for(b=0;4>b;b++)this.shadows[b]=new DivElement(this.cbcanvas.canvas.parentElement,"BAreaShadow"+b),this.shadows[b].setVisible(!a&&0==b&&!glApp.isBoardOnlyApp());this.shadows[0].setCssClass("BoardAreaShadowT");this.shadows[1].setCssClass("BoardAreaShadowR");this.shadows[2].setCssClass("BoardAreaShadowB");
4125this.shadows[3].setCssClass("BoardAreaShadowL")}d&&d.suppressCalcGeometry||this.calcGeometry();this.idStyleListener=glSettings.addOnBoardStyleListener(function(){(new Timer(function(){this.calcGeometry()}.bind(this))).runOnce(300)}.bind(this));glApp.Vh.callOnBackgroundLoaded=this.onBackgroundTexturesLoaded.bind(this)}initGestures(a,b){if("undefined"!=typeof Hammer&&(this.gestures=new Hammer(this.cbcanvas.canvas,{}),this.gestures.get("swipe").set({direction:Hammer.DIRECTION_HORIZONTAL,velocity:.4,
4126enable:this.noPieceSelected.bind(this)}),this.gestures.on("swipe",function(c){a(c.direction)}),b))this.gestures.on("pinch",function(c){b(c.direction)})}addBoard(a){a&&(this.boards.push(a),a.idBoardAreaHandler=a.onReadyHandlers.add(this.onBoardReady.bind(this)))}noPieceSelected(){let a=!0;this.boards.forEach(function(b){b.currPiece&&(a=!1)});return a}removeBoard(a){a=this.getInxOfBoard(a);void 0!==a&&(a=this.boards.splice(a,1),a[0]&&a[0].destroy(),this.drawBackground(this.cbcanvas.bufferCtx),this.cbcanvas.requestRedraw(),
4127LOG("RemoveBoard: "+a[0].debugName))}getSizeRatio(){return this.width/this.height}onDestroyDOM(){this.removeAllBoards()}removeAllBoards(){for(var a=0;a<this.boards.length;a++)this.boards[a]&&this.boards[a].destroy();this.boards=[];this.calcGeometry()}setPosInput(a){this.boards=[];this.addBoard(a);this.drawBackground(this.cbcanvas.bufferCtx);this.calcGeometry()}removePosInput(a){this.boards=[];this.boards.push(a);this.calcGeometry();this.drawBackground(this.cbcanvas.bufferCtx);this.calcGeometry();
4128this.cbcanvas.requestRedraw()}getInxOfBoard(a){for(var b=0;b<this.boards.length;b++)if(this.boards[b]&&this.boards[b].uniqueId==a.uniqueId)return b}draw(a){try{this.drawForeground(a),this.needsShadows=!1}catch(b){LogException("AreaDraw",b)}}setBackgroundStyle(){this.cbcanvas.canvas.style.backgroundImage="url( '"+glApp.Vh.background.url+"' )"}drawWood(a){for(var b=0;b<this.boards.length;b++)this.boards[b]&&this.boards[b].drawWood(a,this.boardHasShadow())}drawForeground(a){for(var b=0;b<this.boards.length;b++)this.boards[b]&&
4129this.boards[b].draw(a,this.boardHasShadow())}
4129drawBackground(a){this.isTransparent()?this.needsShadows=!0:void 0!==a&&glApp.Vh.background&&glApp.Vh.background.loaded&&(glApp.Vh.drawBackground(a,this.width,this.height),this.needsShadows=!0)}beforeResize(){for(var a=0;a<this.boards.length;a++)this.boards[a]&&this.boards[a].beforeResize()}resize(a,b){this.width=a;this.height=b;this.calcGeometry()}forceResize(){this.resize(this.width,this.height)}getInfoWin(){if(!this.infoWin){var a=$("<div class='cbBoardAreaInfo'><div id='idBoardAreaInfo'></div></div>");
4130a.hide();$(this.cbcanvas.canvas.parentElement).parent().append(a);this.infoWin=a[0]}return this.infoWin}removeInfoWin(){this.infoWin&&$(this.infoWin).remove();delete this.infoWin}calcGeometry(){this.infoWin&&$(this.infoWin).hide();this.cbcanvas&&(this.bgListenerId&&glApp.Vh.removeOnBGReadyListener(this.bgListenerId),this.bgListenerId=glApp.Vh.addOnBGReadyListener(this.onBGReady.bind(this)),glApp.Vh.createBackground(this.cbcanvas.ctx,this.width,this.height));this.boards.forEach(function(e){e.setTitleVisible(!1)});
4131this.nBoardCallbacksExpected=this.boards.length;this.arrangeBoards();this.cbcanvas.block(!1);0===this.boards.length&&void 0!==this.cbcanvas.control&&this.cbcanvas.requestRedraw();var a=this.cbcanvas.pixToZoom(this.width),b=this.cbcanvas.pixToZoom(this.height),c=Math.min(b/50,10),d=Math.min(a/50,10);this.shadows&&4==this.shadows.length&&(this.shadows[0].setPosSize(0,0,a,d),this.shadows[1].setPosSize(a-d,c,c,b-2*c),this.shadows[2].setPosSize(0,b-c,a,c),this.shadows[3].setPosSize(0,c,d,b-2*c));this.infoWin&&
4132($(this.infoWin).css("width",a/2),a=this.height/10,$(this.infoWin).css("height",a),$(this.infoWin).css("position","absolute"),$(this.infoWin).css("top",this.height/60),$(this.infoWin).css("left",this.width/4))}static ifInside(a,b,c,d){var e=!1,f=c.event;void 0===f&&(f=c);for(c=0;c<a.length;c++)a[c]&&a[c].isInMyArea(d.x,d.y)&&(b.call(a[c],f,d),e=!0);return e}onMouseDown(a,b){this.boards.length&&BoardArea.ifInside(this.boards,this.boards[0].onMouseDown,a,b)}onContextMenu(a,b){this.boards.length&&BoardArea.ifInside(this.boards,
4133this.boards[0].onContextMenu,a,b)}onMouseUp(a,b){if(this.boards.length&&!BoardArea.ifInside(this.boards,this.boards[0].onMouseUp,a,b)&&1==this.boards.length)this.boards[0].onMouseUp(a,b)}onMouseWheel(a,b){this.boards.length&&BoardArea.ifInside(this.boards,this.boards[0].onMouseWheel,a,b)}onMouseMove(a,b){if(this.boards.length)if(1==this.boards.length)this.boards[0].onMouseMove(a,b);else BoardArea.ifInside(this.boards,this.boards[0].onMouseMove,a,b)}onMouseEnter(a,b){this.boards.length&&BoardArea.ifInside(this.boards,
4134this.boards[0].onMouseEnter,a,b)}onMouseLeave(a,b){this.boards.length&&BoardArea.ifInside(this.boards,this.boards[0].onMouseLeave,a,b)}onDoubleClick(a,b){}onBackgroundTexturesLoaded(){this.width&&this.cbcanvas&&glApp.Vh.createBackground(this.cbcanvas.ctx,this.width,this.height);this.cbcanvas.onControlBackgroundReady();if(void 0!==this.onReady)this.onReady()}getClickPos(a){var b=this.cbcanvas.canvas.getBoundingClientRect();
4134return new CBPoint(a.getX()-b.left,a.getY()-b.top)}getLayout(a,b,c){var d={w:10,
4135nX:a,nY:1};if(0==a)return d;var e=Math.max(b,c);d.w=Math.round(Math.min(Math.min(b,c)-0,Math.floor(e/a)));if(0==d.w)return d;e==b?(d.nX=a,d.nY=1):(d.nX=1,d.nY=a);e=a;for(var f=1;f<=a;){var g=Math.floor(Math.min(b/e,c/f));d.w<g&&(d.w=g,d.nX=e,d.nY=f);f++;e=Math.floor(a/f);a!=e*f&&e++}1==e&&1<f&&1==a?(d.h=c,d.w=b):d.h=d.w;return d}setBoardsSameSize(a){this.options.splitLayout=!a;this.arrangeBoards()}arrangeBoards(){if(0!=this.boards.length){var a=this.width,b=this.height,c=0,d=0;this.infoWin&&(b-=this.height/
41368,d+=this.height/8);var e=0;if(1<this.boards.length&&this.options.splitLayout){var f=this.width-this.height;if(Math.abs(f)>.2*Math.max(this.width,this.height)&&0<f){c=this.width-f;var g=Math.min(c,this.height);a=f;d=6;b=g-2*d;e=1}}f=this.getLayout(this.boards.length-e,a,b);if(0!=f.w){a=Math.floor((a-f.nX*f.w)/(f.nX+1));b=Math.floor((b-f.nY*f.h)/(f.nY+1));var h=new CBSize(f.w,f.h);if(1==this.boards.length)this.boards[0].setLeftSpace(a),this.boards[0].setPosSize(new CBPoint(a,0),h);else for(0<e&&(this.boards[0].setLeftSpace(a),
4137this.boards[0].setTitleVisible(!0),this.boards[0].setPosSize(new CBPoint(0,0),new CBSize(g,g))),g=0;g<f.nX;g++)for(var k=c+a+g*(a+f.w),l=0;l<f.nY;l++){var m=d+b+l*(b+f.w);e<this.boards.length&&(m=new CBPoint(k,m),this.boards[e].setLeftSpace(a),this.boards[e].setTitleVisible(!0),this.boards[e].setPosSize(m,h),e++)}}}}clearBackground(){this.drawBackground(this.cbcanvas.bufferCtx);this.cbcanvas.requestRedraw()}onBoardReady(a){--this.nBoardCallbacksExpected;0>=this.nBoardCallbacksExpected&&(this.drawBackground(this.cbcanvas.bufferCtx),
4138this.cbcanvas.requestRedraw(),this.boards.forEach(function(b){b.setTitleVisible(!0);void 0!==b.rightWin&&b.rightWin.setVisible(!0)}),this.nBoardCallbacksExpected=this.boards.length);this.infoWin&&$(this.infoWin).show()}onBGReady(){this.drawBackground(this.cbcanvas.bufferCtx);this.cbcanvas.requestRedraw()}isTransparent(){return this.options?this.options.transparent:!1}boardHasShadow(){return this.options?this.options.boardShadow&&this.needsShadows:this.needsShadows}}"use strict";var _uniqueId=1;
4139class RawBoardControl{constructor(){this.options={};this.permanentAttributes=[];this.clickOffs=new CBPoint(0,0);this.clickPos=new CBPoint(0,0)}init(a,b,c,d){this.cbcanvas||(this.cbcanvas=a,this.ptTopLeft={x:0,y:0},this.y=0,this.width=this.nBoardOuterW=b,this.height=this.nBoardOuterH=c,this.debugName=d,this.blackIsBottom=!1,this.allowInput=!0,this.enableEvaluation=!1,this.evaluation=0,this.enableCoordinates=!0,this.textAnnosOnBoard=!1,this.symAnnosOnBoard=!0,this.calcGeometry(),this.board=new Board,
4140this.moveEntry=new MoveEntry(this),this.legalFromSquares={},this.pieceFontName="DiagramTTFritz",glSettings&&(this.pieceFontName=glSettings.pieceFontName),this.boardSprites=new BoardSprites,this.animation=new CBAnimation(this.cbcanvas),this.jobsWaitingForSpriteLoad=[],this.onReadyHandlers=new Handlers(this),this.idPieceFactoryHandler=null,this.nMarginW=1,glApp.Vh.callOnSquaresLoaded=this.onSquareTexturesLoaded.bind(this),this.uniqueId=_uniqueId++,this.animSteps={forMove:.6,forPosition:1},this.resizeTimer=
4141new Timer(this.resizeHdl.bind(this)),this.animation.callOnAnimFinished=function(){this.currPiece&&this.buttonDown&&(this.currPiece.moveTo(this.cbcanvas.bufferCtx,this.currPiece.pos),this.cbcanvas.joinClipRect(this.currPiece.getMoveClipRect()));this.renderQueuedAttributes(!0);this.callOnAnimFinished&&this.callOnAnimFinished(this)}.bind(this),this.animation.callOnBeforeEveryStep=function(){this.currPiece&&this.buttonDown&&this.currPiece.hide(this.cbcanvas.bufferCtx)&&(this.currPiece.deleteBackground(),
4142this.cbcanvas.joinClipRect(this.currPiece.getMoveClipRect()))}.bind(this),this.animation.callOnAfterEveryStep=function(){this.currPiece&&this.buttonDown&&(this.currPiece.moveTo(this.cbcanvas.bufferCtx,this.currPiece.pos),this.cbcanvas.joinClipRect(this.currPiece.getMoveClipRect()))}.bind(this))}destroy(){this.destroyTitle();this.destroyMessage();this.destroyChoiceWin();this.destroyRightWin();this.destroyBottomWin();this.destroySubTitle();this.onReadyHandlers.remove(this.idBoardAreaHandler);this.onReadyHandlers.empty();
4143this.idStyleListener&&glSettings.removeOnBoardStyleListener(this.idStyleListener);this.setGame(null);this.enableEvaluation=!1;this.shouldAnimatePosChange=this.fnBoardClick=this.fnSquareRelease=this.fnSquareChangeInMouseMove=this.fnMarkSquaresOnButtonDown=this.fnSquareClick=null;this.pieceSpriteFactory&&null!=this.idPieceFactoryHandler&&this.pieceSpriteFactory.removeOnLoadedHandler(this.idPieceFactoryHandler);this.idPieceFactoryHandler=null}onRecycle(){}addStyleListener(){this.idStyleListener=glSettings.addOnBoardStyleListener(this.onBoardStyle.bind(this))}
4143onBoardStyle(a,
4144b){glApp.setBoardTextures(BoardTextures.prototype.getTexturesForPieceStyle(a));this.changeBoardStyle(a,b)}changeBoardStyle(a,b){PieceSpriteFactory.resetCache();this.pieceFontName=b;this.nStretchSqPix=this.nSqPix=0}setPosSize(a,b){this.ptSetPos=a;var c=new CBSize(0,0),d=new CBSize(0,0);void 0!==this.subTitleWin&&(d.h=this.cbcanvas.pixToZoom(7));this.ptTopLeft=new CBPoint(Math.round(a.x+c.w),Math.round(a.y+c.h));a=Math.round(b.h-c.h-d.h);this.width=Math.round(b.w-c.w);this.height=a;this.resize(this.width,
4145this.height)}getPos(){return this.ptSetPos?this.ptSetPos:this.ptTopLeft}beforeResize(){this.titleWin&&this.titleWin.setVisible(!1)}resize(a,b){this.killAnimations();this.width=this.nBoardOuterW=a;this.height=this.nBoardOuterH=b;a&&b?this.resizeTimer.runOnce(10):this.resizeTimer.stop();this.currPiece&&this.currPiece.deleteBackground()}resizeHdl(){this.resizeTimer.stop();this.killAnimations();this.renderedAttributes=[];var a=this.nSqPix;this.calcGeometry();a!=this.nSqPix||void 0===this.pieceSpriteFactory||
4146this.rightWin?(LOG("New Sprites:"+a+", was "+this.nSqPix),this.boardSprites=new BoardSprites,this.pieceSpriteFactory=this.createPieceSpriteFactory()):this.boardSprites.isAllLoaded()&&(this.boardSprites.deleteBackgrounds(),this.onReadyHandlers.count()?this.onReadyHandlers.execute():this.cbcanvas.requestRedraw());this.resizeTitle();if(void 0!==this.messageWin)this.messageWin.onResize(this);if(void 0!==this.choiceWin)this.choiceWin.onResize(this);if(void 0!==this.rightWin)this.rightWin.onResize(this);
4147void 0!==this.bottomWin&&(this.bottomWin.canShowIfHeight(this.height,this.cbcanvas)?(this.bottomWin.setVisible(!0),this.bottomWin.onResize(this)):this.bottomWin.setVisible(!1));this.subTitleWin&&(this.subTitleWin.onResize(this),this.subTitleWin.setVisible(!0))}onRedraw(){}resizeTitle(){this.canShowTitle()?(this.titleWin.onResize(this),this.titleWin.setVisible(!0)):this.titleWin&&this.titleWin.setVisible(!1)}createPieceSpriteFactory(){var a=PieceSpriteFactory.getCachedFactory(this.pieceFontName,this.nSqPix,
4148this.nStretchSqPix);a.loaded?(this.idPieceFactoryHandler=null,(new Timer(function(){this.createBoardSprites()}.bind(this))).runOnce(10)):this.idPieceFactoryHandler=a.addOnLoadedHandler(this.createBoardSprites.bind(this));return a}calcGeometry(a,b){var c=this.height,d;let e=this.getMarginDivisor();if(this.options){(d=this.options.topDist||0)||(d=c/e);var f=this.options.bottomDist||0;!f&&e&&(f=c/e)}else d=glApp.config.board2DTopOffset,f=glApp.config.board2DBottomOffset;c-=d+f;d=0;this.canShowTitle()&&
4149(d=this.titleWin.getDesiredHeight(this.height,this.cbcanvas),this.titleWin.getSpacingToBoard&&(d+=this.titleWin.getSpacingToBoard(this.height,this.cbcanvas)));a&&(d=a);c-=d;a=0;void 0!==this.bottomWin&&this.bottomWin.canShowIfHeight(this.height,this.cbcanvas)&&(a=this.bottomWin.getDesiredHeight(this.height,this.cbcanvas),this.bottomWin.confirmHeight(a,this.cbcanvas),a+=this.bottomWin.getSpacingToBoard(this.height,this.cbcanvas));b&&(a=b);c=Math.round(c-a);b=this.width;f=0;void 0!==this.rightWin&&
4150(f=this.rightWin.getDesiredWidth(this.width,this.height,this.cbcanvas));b-=f;b-=.056/window.devicePixelRatio*b;this.nBoardOuterW=Math.min(b,c);this.enableCoordinates=480<=this.nBoardOuterW;this.options&&this.options.minWForCoordinates&&(this.enableCoordinates=this.nBoardOuterW>=this.options.minWForCoordinates);this.nMarginW=this.calcMarginW();this.nBoardInnerW=this.nBoardOuterW-2*this.nMarginW;this.nDesiredSqPix=this.nSqPix=Math.floor(this.nBoardInnerW/8);this.nSqPix=RawBoardControl.getAvailSqPix(this.nDesiredSqPix);
41511>this.nSqPix&&(this.nSqPix=1);this.nStretchSqPix=10<this.nDesiredSqPix-this.nSqPix?this.nDesiredSqPix:this.nSqPix;this.nBoardInnerW=8*this.nStretchSqPix;this.nBoardOuterW=this.nBoardInnerW+2*this.nMarginW;this.sqOffs=0;this.x0=Math.floor(this.ptTopLeft.x+(this.width-this.nBoardOuterW-f)/2+.5);this.y0=Math.floor(this.ptTopLeft.y+d+Math.min((this.height-d-a-this.nBoardOuterW)/2,100));this.options&&this.options.shiftXPercent&&(this.x0=Math.floor(this.x0+this.nBoardOuterW*this.options.shiftXPercent/
4152100))}static getMaxSqPix(){return 350}static getAvailSqPix(a){var b=[450,400,350,300,256,220,200,180,170,160,152,144,138,132,126,120,114,110,106,102,98,94,90,88,84,82,80,78,76,74,72,70,68,66,64,62,60,58,56,54,52,50,48,46,44,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,12,10,8],c;for(c=0;c<b.length;c++)if(a>=b[c]){a=b[c];break}"DiagramTTFF"==this.pieceFontName&&160<a&&(a=160);c>=b.length&&(a=8);return a}
4152getMarginDivisor(){let a=60;this.options&&this.options.marginDistDivisor&&
4153(a=this.options.marginDistDivisor);return a}calcMarginW(){return this.enableCoordinates?this.options&&this.options.bigCoords?Math.max(12,Math.round(Math.min(24*Math.sqrt(window.devicePixelRatio),this.nBoardOuterW/25))):Math.max(6,Math.round(Math.min(18*Math.sqrt(window.devicePixelRatio),this.nBoardOuterW/this.getMarginDivisor()))):Math.round(Math.min(12,this.nBoardOuterW/this.getMarginDivisor()))}setTitleText(a){this.titleWin&&this.titleWin.setText(a);this.debugName=a}addTitle(a,b,c){void 0===this.titleWin&&
4154(this.titleWin=new BoardTitle(this,a,function(d){this.fnBoardClick(this.uniqueId);d.preventDefault()}.bind(this),"",b,function(d){c(d)},this.options.hasCloseBtn));return this.titleWin}addLogo(a){void 0===this.titleWin&&(this.titleWin=new BoardLogo(this,a));return this.titleWin}setTitleWin(a){this.destroyTitle();this.titleWin=a;this.resizeHdl()}setTitleAndBottom(a,b){this.destroyTitle();this.destroyBottomWin();this.titleWin=a;this.bottomWin=b}canShowTitle(){return window.glApp&&glApp.isBoardOnlyApp()?
4155this.titleWin&&210<Math.min(this.height,this.width):this.titleWin&&100<Math.min(this.height,this.width)}setTitleVisible(a){this.canShowTitle()&&this.titleWin.setVisible(a)}addSubTitle(){this.subTitleWin||(this.subTitleWin=new BoardSubTitle(this),this.resizeTimer.runOnce(10));return this.subTitleWin}setLeftSpace(a){this.nLeftSpace=a}addPlayingClock(a){return this.elemClock=this.titleWin=new PlayingClockElm(this,this.getOuterRect().h/16,a)}removePlayingClock(){this.elemClock&&(this.elemClock.destroy(),
4156this.elemClock=null,this.destroyTitle(),this.titleWin=null)}destroyTitle(){this.titleWin&&this.titleWin.destroy();delete this.titleWin}destroySubTitle(){this.subTitleWin&&(this.subTitleWin.destroy(),delete this.subTitleWin)}destroyMessage(){this.messageWin&&this.messageWin.destroy();delete this.messageWin}destroyChoiceWin(){this.choiceWin&&this.choiceWin.destroy();delete this.choiceWin}destroyRightWin(){this.rightWin&&this.rightWin.destroy();delete this.rightWin}destroyBottomWin(){this.bottomWin&&
4157this.bottomWin.destroy();delete this.bottomWin}hasClock(){return this.titleWin&&this.titleWin.getClock()}getClockDisplay(){if(this.titleWin)return this.titleWin.getClock()}addModalMessage(a){this.destroyMessage();return this.addMessage(a,!0,!0)}addMessage(a,b,c){if(this.messageWin||b)this.messageWin?this.messageWin.setText(a):(this.messageWin=new BoardMessage(this,a,c),this.messageWin.setVisible(!0)),this.messageWin.onResize(this)}addBoardChoice(a){this.choiceWin&&this.choiceWin.destroy();this.choiceWin=
4158new ChoiceButtons(a,{btnW:260,btnH:36});this.choiceWin.onResize(this)}addBubble(a,b,c,d){this.messageWin&&(this.messageWin.destroy(),delete this.messageWin);this.messageWin=new BoardBubble(a,b,c,d);this.messageWin.setVisible(!0);this.messageWin.onResize(this)}addRightWin(a){this.rightWin=a;this.rightWin.onResize(this)}addSideIcon(a){this.rightWin||(this.rightWin=new BoardSideIcon(this,a),this.rightWin.getDesiredWidth(this.width,this.height,this.cbcanvas),this.rightWin.onResize(this))}destroySideIcon(){this.rightWin&&
4159this.rightWin.destroy();delete this.rightWin}addBottomWin(a){if(this.bottomWin=a)this.bottomWin.onResize(this)}markAsSelected(a){glApp.isBoardOnlyApp()||this.titleWin&&this.titleWin.markAsSelected(a)}onMouseEnter(a,b){}onContextMenu(a,b){}onMouseLeave(a,b){this.getClickPos(b)}onMouseMove(a,b){b=this.getClickPos(b);if(this.enableEvaluation&&this.evaluation)if(this.evalBulgeRect&&this.evalBulgeRect.isInside(b.x,b.y)){var c=this.evaluation.strEval+"<br/><em>"+this.evaluation.strLine+"</em>";ttEvalGate.exec(function(){this.showEvalToolTip(new CBPoint(a.clientX,
4160a.clientY),c)}.bind(this),200)}else this.hideEvalToolTip();this.toMoveRect&&this.toMoveRect.isInside(b.x,b.y)&&this._game?(c=this._game.getCurPos().getBTM()?lm.BLACKS_MOVE:lm.WHITES_MOVE,c+=", "+lm.CLICK_TO_FLIP_BOARD,ttToMoveGate.exec(function(){this.showToMoveToolTip(new CBPoint(a.clientX,a.clientY),c)}.bind(this),200)):this.hideToMoveToolTip()}onMouseUp(a,b){a=this.getClickPos(b);this.toMoveRect&&this.toMoveRect.isInside(a.x,a.y)&&this.flipBoard()}showEvalToolTip(a,b){this.showToolTip("Eval",a,
4161b,new CBSize(190,40),ttToMoveGate)}hideEvalToolTip(){this.hideToolTip("Eval",ttEvalGate)}showToMoveToolTip(a,b){this.showToolTip("ToMove",a,b,new CBSize(140,35),ttToMoveGate,2500)}showToolTip(a,b,c,d,e,f){var g=this;
4161!g[a]&&c&&(glApp.isBoardOnlyApp()&&(b.x=b.x-d.w-5),g[a]=new ToolTip,g[a].setText(c),g[a].setPosSize(b,d),g[a].setVisible(!0),(new Timer(function(){g.hideToolTip(a,e)}.bind(g))).runOnce(f||6E3))}hideToMoveToolTip(){this.hideToolTip("ToMove",ttToMoveGate)}hideToolTip(a,b){b.stop();this[a]&&
4162(this[a].destroy(),delete this[a])}movePieceToSq(a,b){a&&(this.moveSprite(a,this.getSquareCenterPos(b)),a.lastSq=b)}moveSprite(a,b){a&&(a.moveTo(this.cbcanvas.bufferCtx,b),this.cbcanvas.requestAnimation(a.getMoveClipRect()))}hideSprite(a){a&&(a.hide(this.cbcanvas.bufferCtx),this.cbcanvas.requestAnimation(a.getMoveClipRect()))}getPromFromClickPos(a,b){a=this.getPixPos(a);return b.x<a.x+.7*this.nStretchSqPix?Piece.QUEEN:b.y<a.y+.3*this.nStretchSqPix?Piece.KNIGHT:b.y<a.y+.6*this.nStretchSqPix?Piece.BISHOP:
4163Piece.ROOK}setBoardAttributes(a,b){for(var c=0;c<a.length;c++);c=this.renderAttributes(a);a.length&&b&&this.cbcanvas.requestAnimation(c)}concatAttributes(a){if(this.renderedAttributes&&a)for(var b=0;b<a.length;b++)-1==this.renderedAttributes.indexOf(a[b])&&this.renderedAttributes.push(a[b]);else this.renderedAttributes=a}addAttributes(a,b){var c=!1;this.currPiece&&(c=this.currPiece.hide(this.cbcanvas.bufferCtx))&&console.log("currHiden on addAttr");this.queueBoardAttributes(a,{eraseQueue:!0,renderNow:!0,
4164requestAnimInRender:!0,permanent:b});c&&(this.currPiece.saveBackground(this.cbcanvas.bufferCtx),this.currPiece.show(this.cbcanvas.bufferCtx))}renderAttributes(a,b){this.concatAttributes(a);for(var c=null,d=0;d<a.length;d++){a[d].boardControl=this;var e=a[d].draw(b||this.cbcanvas.bufferCtx);c=c?c.getUnion(e):e}return c}undoAttributes(a){if(void 0!==this.renderedAttributes&&this.renderedAttributes.length){LOG("Undo Attributes: len="+this.renderedAttributes.length,"LogBoard");for(var b=null,c=0;c<this.renderedAttributes.length;c++){for(var d=
4165!1,e=0;!d&&e<this.permanentAttributes.length;e++)d=this.renderedAttributes[c].id==this.permanentAttributes[e].id||this.renderedAttributes[c].sq==this.permanentAttributes[e].sq&&"undefined"!=typeof this.renderedAttributes[c].sq;if(!d&&a&&this._game){var f=this._game.getMoveBaggage();if(f&&f.attributes)for(e=0;!d&&e<f.attributes.length;e++)d=this.renderedAttributes[c].id==f.attributes[e].id||this.renderedAttributes[c].sq==f.attributes[e].sq&&"undefined"!=typeof this.renderedAttributes[c].sq}d||(this.renderedAttributes[c].boardControl=
4166this,d=this.renderedAttributes[c].undo(this.cbcanvas.bufferCtx,function(g){return this.getPixPos(g)}.bind(this)),b=b?b.getUnion(d):d)}this.cbcanvas.requestAnimation(b);this.renderedAttributes=[].concat(this.permanentAttributes)}}queueBoardAttributes(a,b){if(b.permanent)if(2==b.permanent)for(var c=0;c<a.length;c++){for(var d=!1,e=0;!d&&e<this.permanentAttributes.length;e++)d=a[c].id==this.permanentAttributes[e].id;d||this.permanentAttributes.push(a[c])}else 1==b.permanent&&this._game&&(c=this._game.getMoveBaggage()||
4167{},c.attributes=(c.attributes||[]).concat(a),this._game.setMoveBaggage(c));else!this.queuedAttributes||b&&b.eraseQueue?this.queuedAttributes=a:(this.queuedAttributes=this.queuedAttributes.concat(a),this.queuedAttributes.sort((f,g)=>f.zValue-g.zValue));b.renderNow&&!this.isAnimationUnderway()?this.renderQueuedAttributes(b.requestAnimInRender,b.ctx):b.renderNow&&LOG("anim underway","LogError","board")}removeAttributeById(a){for(var b=0;b<this.permanentAttributes.length;b++)this.permanentAttributes[b].id==
4168a&&this.permanentAttributes.splice(b,1);this.redraw()}removeAttributes(a){var b=new CBRect(0,0,0,0);b=a.reduce((d,e)=>d.getUnion(e.undo(this.cbcanvas.bufferCtx,f=>this.getPixPos(f))),b);var c=a.map(d=>d.id);this.permanentAttributes=this.permanentAttributes.filter(d=>!c.contains(d.id));this.cbcanvas.requestAnimation(b)}clearBaggageAttributes(){this._game.setMoveBaggage(null)}clearPermanentAttributes(){this.permanentAttributes=[]}clearBoardAttributes(){this.queuedAttributes=[]}renderQueuedAttributes(a,
4169b){if(this.permanentAttributes){this.queuedAttributes=this.queuedAttributes||[];for(var c=0;c<this.permanentAttributes.length;c++)-1==this.queuedAttributes.indexOf(this.permanentAttributes[c])&&this.queuedAttributes.push(this.permanentAttributes[c])}this.queuedAttributes&&this.queuedAttributes.length&&(b=this.renderAttributes(this.queuedAttributes,b),a&&this.cbcanvas.requestAnimation(b),this.queuedAttributes=[])}clearAll(){this.clearBoardAttributes();this.destroyMessage();this.destroyChoiceWin();
4170this.redraw()}
4170isAnimationUnderway(){return this.jobsWaitingForSpriteLoad.length||this.animation.jobs.length||this.animation.inAnimation}runFunAnimation(a){this.jobsWaitingForSpriteLoad=(this.jobsWaitingForSpriteLoad||[]).concat(a);this.animateWhenSpritesReady();this.funAnimJobs=(this.funAnimJobs||[]).concat(a)}undoFunAnimations(){this.funAnimJobs&&this.funAnimJobs.forEach(function(a){a.hide(this.cbcanvas.bufferCtx)}.bind(this));this.funAnimJobs=[]}animateCapture(a){this.hideSprite(this.currPiece);
41710<=a&&(this.drawSquare(this.cbcanvas.bufferCtx,a),this.currPiece.saveBackground(this.cbcanvas.bufferCtx),this.moveSprite(this.currPiece,this.getSquareCenterPos(a)))}animateFromTo(a,b,c,d){if(void 0!==a){var e=c.subtract(b);this.nAnimCount=d;this.posAnimTarget=c;this.vecAnimDisplace=new CBVector(e.x/this.nAnimCount,e.y/this.nAnimCount);this.animSprite=a;this.animCurrPos=b;a=new CBRect;a.fromTwoPoints(b.x,b.y,c.x,c.y);this.cbcanvas.joinClipRect(a);this.idRequestStepAnim=window.requestAnimationFrame(this.doAnimateStep.bind(this))}}doAnimateStep(){this.animSprite.moveTo(this.cbcanvas.bufferCtx,
4172this.animCurrPos);this.animCurrPos=0===this.nAnimCount?this.posAnimTarget:this.animCurrPos.add(this.vecAnimDisplace);this.cbcanvas.joinClipRect(this.animSprite.getMoveClipRect());this.cbcanvas._drawDoubleBufferClipped();0<this.nAnimCount&&(this.idRequestStepAnim=window.requestAnimationFrame(this.doAnimateStep.bind(this)));this.nAnimCount--}loadedAll(){return void 0!==this.pieceSpriteFactory&&this.pieceSpriteFactory.loaded&&this.boardSprites.isAllLoaded()&&glApp.Vh.isBoardValid()?!0:!1}resetInternalBoard(){this.board=
4173new Board}setBoard(a,b){if(this.blindMoves)this.blindSqs=a;else if(this.undoAttributes(),this.undoFunAnimations(),!ObjUtil.equals(a,this.board.sqs)&&1<this.nStretchSqPix)if(this.loadedAll()){var c=!1;if(b&&this.canAnimate()){var d=this.boardSprites.changeBoard(this.pieceSpriteFactory,this.board.sqs,a);d&&d.length?(this.board.copyFrom(a),this.jobsWaitingForSpriteLoad=d,this.animateWhenSpritesReady(),this.checkCurrPieceCaptured(),c=this.isAnimated=!0):this.sqArrNotDrawn=a}c||(LOG("Set Board, No Animation",
4174"LogRed","board"),b&&this.animation.currFPS&&this.animation.currFPS++,this.board.copyFrom(a),this.queuedAttributes=[],this.redraw(),this.isAnimated=!1);this.drawToMove(this.cbcanvas.bufferCtx,!1)}else this.board.copyFrom(a)}prepareFullRedraw(){delete this.currPiece;this.buttonDown=!1;this.killAnimations();this.cbcanvas.cancelAnimationFrames()}redraw(a,b){if(this.isReady()){LOG("Redraw","LogBoard","board");try{if(!(1>=this.nStretchSqPix)){var c=-1;this.currPiece&&this.buttonDown&&-1!=this.fromSq&&
4175(c=this.fromSq);this.boardSprites.setup(this.pieceSpriteFactory,this.board.sqs,c);this.killAnimations();this.jobsWaitingForSpriteLoad=[];this.currPiece&&this.buttonDown&&this.currPiece.isVisible&&this.currPiece.deleteBackground();delete this.markedMove;if(!this.draw(this.cbcanvas.bufferCtx))return LOG("Draw failed in redraw","LogError","board"),!1;this.currPiece&&this.buttonDown&&(-1!=this.fromSq&&"undefined"!=typeof this.fromSq&&this.drawSquare(this.cbcanvas.bufferCtx,this.fromSq),this.currPiece.isVisible&&
4176LOG("CurrPiece in setBoard: "+this.currPiece.pieceName+", sq="+CBSquare.toString(this.fromSq)));this.addBoardColourAndArrowsFromAnno(!0);b||this.renderQueuedAttributes(!1);if(!a){var d=this.getOuterRect();this.currPiece&&(d=d.getUnion(this.currPiece.getMoveClipRect()));this.cbcanvas.requestAnimation(d)}this.sqArrNotDrawn=null;return!0}}catch(e){LogException("BoardRedraw",e)}}}checkCurrPieceCaptured(){this.currPiece&&-1!=this.fromSq&&this.board.sqs[this.fromSq]!=this.currPiece.piece&&(delete this.currPiece,
4177this.fromSq=-1)}canAnimate(){return!this.animation.currFPS||this.animation.currFPS>glApp.minFPS}killAnimations(){this.animation.kill();this.idRequestStepAnim&&(window.cancelAnimationFrame(this.idRequestStepAnim),this.idRequestStepAnim=0)}quickFinishAnimations(){this.animation.quickFinish();this.idRequestStepAnim&&(window.cancelAnimationFrame(this.idRequestStepAnim),this.idRequestStepAnim=0)}animateWhenSpritesReady(){function a(e,f,g){return 40>e.currFPS?30>e.currFPS?20>e.currFPS?.25:.5:Math.min(1,
4178f.forMove):3>g?f.forMove:f.forPosition}for(var b=!0,c=0;c<this.jobsWaitingForSpriteLoad.length;c++)this.jobsWaitingForSpriteLoad[c].loaded()||(this.jobsWaitingForSpriteLoad[c].tryLoadCnt=(this.jobsWaitingForSpriteLoad[c].tryLoadCnt||0)+1,b=20<this.jobsWaitingForSpriteLoad[c].tryLoadCnt);if(b){for(c=0;c<this.jobsWaitingForSpriteLoad.length;c++)if(this.jobsWaitingForSpriteLoad[c].isPieceAnim){b=-1==this.jobsWaitingForSpriteLoad[c].sqFrom?this.getPieceRepositoryPos(this.jobsWaitingForSpriteLoad[c].piece):
4179this.getSquareCenterPos(this.jobsWaitingForSpriteLoad[c].sqFrom);var d=-1==this.jobsWaitingForSpriteLoad[c].sqTo?this.getPieceRepositoryPos(this.jobsWaitingForSpriteLoad[c].piece):this.getSquareCenterPos(this.jobsWaitingForSpriteLoad[c].sqTo);this.jobsWaitingForSpriteLoad[c].ptFrom=b;this.jobsWaitingForSpriteLoad[c].ptTo=d}c=this.jobsWaitingForSpriteLoad;c.length&&this.animation.startMultiAnimation(c,a(this.animation,this.animSteps,c.length),this.getOuterRect());this.jobsWaitingForSpriteLoad=[]}else setTimeout(function(){this.animateWhenSpritesReady()}.bind(this),
4180100)}draw(a,b){if(!isNaN(this.x0)&&1<this.nStretchSqPix&&1<this.nDesiredSqPix){if(this.drawForeground(a,b))this.addBoardColourAndArrowsFromAnno(!1,this.cbcanvas.bufferCtx);else return!1;void 0!==this.drawExtras&&this.drawExtras(this.getOuterRect())}return!0}drawWood(a,b){return this.drawMargin(a,b)?this.drawSquares(a):(LOG("drawMargin failed","","board"),!1)}drawForeground(a,b){if(this.drawWood(a,b)){if(this.pieceSpriteFactory&&this.pieceSpriteFactory.loaded)return this.drawPieces(a),!0;LOG("drawForeground, pieceSpriteFactory",
4181"error","board")}return!1}getInnerRect(){return new CBRect(this.x0+this.nMarginW,this.y0+this.nMarginW,this.x0+this.nMarginW+this.nBoardInnerW,this.y0+this.nMarginW+this.nBoardInnerW)}getOuterRect(){return new CBRect(this.x0,this.y0,this.x0+this.nBoardOuterW,this.y0+this.nBoardOuterW)}drawMargin(a,b){if(4>this.nBoardOuterW)return!0;try{if(this.loadedAll())return a.save(),b&&this.setDefaultShadow(a,.6),glAp
4181p.Vh.margin.drawTiled(a,this.x0,this.y0,this.nBoardOuterW,this.nBoardOuterW),glApp.Vh.clrMarginSepLine&&
4182(a.lineWidth=1,CanvasTools.drawRect(a,this.getInnerRect(),glApp.Vh.clrMarginSepLine)),a.restore(),this.enableEvaluation&&this.drawEvalBulge(a,b,this.evaluation),this.enableCoordinates&&this.drawCoordinates(a),this.drawToMove(a),!0;LOG("drawMargin failed, not loaded all","","board");return!1}catch(c){LogException("RawB:DrawMargin",c)}}drawCoordinates(a){a.save();var b=Math.round(.8*this.nMarginW);a.font=b+"px "+glApp.config.defaultFont;var c=null;glApp.Vh&&(c=glApp.Vh.clrCoordinates);a.fillStyle=c||
4183"yellow";c=a.measureText("A").width;var d=this.x0+(this.nMarginW-c)/2,e=this.y0+this.nStretchSqPix/2+b/2+this.nMarginW-.2*b;glApp.panelMgr&&glApp.panelMgr.viewport&&glApp.panelMgr.viewport.rtl&&(d+=8*this.nStretchSqPix+this.nMarginW);for(var f=0;8>f;f++)this.blackIsBottom?a.fillText(f+1,d,e+f*this.nStretchSqPix):a.fillText(8-f,d,e+f*this.nStretchSqPix);d=this.x0+(this.nStretchSqPix-c)/2+this.nMarginW+.1*c;e=this.y0+this.nBoardInnerW+this.nMarginW+(this.nMarginW-b)/2+b-.2*b;for(f=0;8>f;f++)this.blackIsBottom?
4184a.fillText(String.fromCharCode(104-f),d+f*this.nStretchSqPix,e):a.fillText(String.fromCharCode(97+f),d+f*this.nStretchSqPix,e);a.restore()}drawToMove(a){if((!this.options||!this.options.noToMoveBulge)&&this._game){this.drawToMoveBackground(a);a.save();var b=.34*this.getBulgeW(this.getOuterRect().w),c=this.x0+2*this.nMarginW+this.nBoardInnerW+.9*b,d=this.y0+this.nBoardInnerW+2*this.nMarginW-b-.02*this.nBoardInnerW;a.beginPath();a.arc(c,d,b,0,2*Math.PI,!1);var e=a.createRadialGradient(c-.3*b,d-.2*b,
4185.1*b,c-.2*b,d-.2*b,b);this._game.getCurPos().getBTM()?(e.addColorStop(0,"rgba( 150, 150, 160, 1.0 )"),e.addColorStop(1,"rgba( 60, 30, 30, 1.0 )")):(e.addColorStop(0,"rgba( 250, 250, 255, 1.0 )"),e.addColorStop(1,"rgba( 220, 220, 225, 1.0 )"));a.fillStyle=e;a.lineWidth=0;this.setDefaultShadow(a,.8,2,3);a.fill();
4185a.restore();this.toMoveRect=new CBRect(c-b,d-b,c+2*b,d+2*b);this.cbcanvas.requestAnimation(this.toMoveRect)}}getBulgeW(a){return Math.min(Math.max(.054*a,5),30)}drawToMoveBackground(a){var b=
4186this.getOuterRect(),c=.09*b.h,d=this.getBulgeW(b.w),e=.4*c,f=new CBPath,g=b.bottom-c,h=b.bottom;b=b.right;this.toMoveBulgeRect=new CBRect(b,g,b+d,g-c);f.push(new CBPoint(b,g));f.push(new CBPoint(d/8+b,e/4+g));f.push(new CBPoint(d/2+b,e/2+g));f.push(new CBPoint(3*d/4+b,3*e/4+g));f.push(new CBPoint(d+b,e+g));f.push(new CBPoint(d+b,h));f.push(new CBPoint(b,h));a.save();f.curve(a);c=glApp.Vh.margin.getPattern(a);a.fillStyle=c||"brown";a.fill();a.restore()}setDefaultShadow(a,b,c,d){c=c||Math.max(1,Math.min(4,
4187Math.round(Math.sqrt(this.nBoardOuterW/60))));a.shadowOffsetX=c;a.shadowOffsetY=c;a.shadowBlur=d||3*c;a.shadowColor="rgba( 60, 30, 15, "+b+" )";return c}displayEvaluation(a,b){var c=a!=this.enableEvaluation;this.enableEvaluation=a;this.evaluation=b;a&&c?(new Timer(function(){this.resizeHdl();delete this.markedMove;this.markLastMove(!0)}.bind(this))).runOnce(500):a&&(this.drawEvalBulge(this.cbcanvas.bufferCtx,!1,this.evaluation),delete this.markedMove,this.cbcanvas.requestAnimation())}setEvaluationInvalid(){this.enableEvaluation&&
4188this.evaluation&&(this.evaluation.isInvalid=!0,(new Timer(function(){this.resizeHdl();delete this.markedMove;this.markLastMove(!0)}.bind(this))).runOnce(200))}displayCoordinates(a){this.enableCoordinates=a}drawEvalBulge(a,b,c){var d=this.getOuterRect();if(!(50>d.width)){this.evaluation=c;var e=.5*d.h,f=this.getBulgeW(d.w),g=.15*e,h=new CBPath,k=d.top+(d.h-e)/2;d=d.right;this.evalBulgeRect=new CBRect(d,k,d+f,k+e);h.push(new CBPoint(d,k));h.push(new CBPoint(f/8+d,g/4+k));h.push(new CBPoint(f/2+d,g/
41892+k));h.push(new CBPoint(7*f/8+d,3*g/4+k));h.push(new CBPoint(f+d,g+k));var l=k+(e-g);h.push(new CBPoint(f+d,l));h.push(new CBPoint(7*f/8+d,g/4+l));h.push(new CBPoint(f/2+d,g/2+l));h.push(new CBPoint(f/8+d,3*g/4+l));h.push(new CBPoint(d,l+g));a.save();h.curve(a);h=glApp.Vh.margin.getPattern(a);a.fillStyle=h||"brown";b&&this.setDefaultShadow(a,1);this.bulgeRect=new CBRect(d,k,d+f,k+e-2*g);a.fill();b=k+g+2;k=.35*f;d+=(f-k)/5;e=new CBRect(d,b,d+k,b+(e-2*g-4));g=a.createLinearGradient(e.left,e.top,e.right,
4190e.top);this.scaleEval(c.value,.3,143);d=new CBColor(216.75,216.75,216.75,1);b=new CBColor(255,255,255,1);k=new CBColor(191.25,191.25,191.25,1);g.addColorStop(0,d.toString());g.addColorStop(.3,b.toString());g.addColorStop(1,k.toString());a.lineWidth=e.w;a.strokeStyle=g;a.lineCap="round";this.setDefaultShadow(a,1,2,3);CanvasTools.drawLine(a,e.left+e.w/2,e.top,e.left+e.w/2,e.bottom);a.shadowColor="black";this.setDefaultShadow(a,0,0,0);this.drawEvalMarker(a,0,"black",e);c.isInvalid||(c=-this.scaleEval(c.value,
4191.7,333)*e.h/2+e.h/2+e.top,g=a.createLinearGradient(e.left+e.w/2,c-2,e.left+e.w/2,c+2),g.addColorStop(0,"rgba( 0, 220, 0, 1.0 )"),g.addColorStop(.4,"rgba( 0, 235, 0, 1.0 )"),g.addColorStop(1,"rgba( 0, 200, 0, 1.0 )"),a.strokeStyle=g,a.lineCap="round",a.lineWidth=Math.min(Math.max(2,f/2),7),this.setDefaultShadow(a,.6,1,2),CanvasTools.drawLine(a,e.left+1,c,e.right+1,c));
4191a.restore()}}drawEvalMarker(a,b,c,d){b=-this.scaleEval(100*b,.7,333)*d.h/2+d.h/2+d.top;a.strokeStyle=c;a.lineWidth=1;a.lineCap="";CanvasTools.drawLine(a,
4192d.left,b,d.right+1,b)}scaleEval(a,b,c){b=(Math.pow(b,.01*Math.abs(a))-1)/(b-1)*100;b>c&&(b=c);0>a&&(b=-b);return b/c}drawSquares(a){if(glApp.Vh.isBoardValid()){for(var b=0;64>b;b++)glApp.Vh.drawSquare(a,b,this.nStretchSqPix,this.getPixPos(b));return!0}LOG("drawSquares, board not valid","error","board");return!1}drawPieces(a){for(var b=0;64>b;b++){var c=this.boardSprites.getPiece(b);!c&&0<this.board.sqs[b]&&this.pieceSpriteFactory&&(LOG("Emergency Draw: "+b,"LogError"),c=this.boardSprites.createSprite(this.pieceSpriteFactory,
4193this.board.sqs[b],b));if(c){var d=this.getSquareCenterPos(b);c.moveToNoSave(a,d)}}}drawPiece(a,b){var c=this.boardSprites.getPiece(b);c&&(b=this.getSquareCenterPos(b),c.moveToNoSave(a,b))}restoreSquare(a,b){if(this.board.sqs[b]){var c=this.boardSprites.getPiece(b);if(c&&(glApp.Vh.drawSquare(a,b,this.nStretchSqPix,this.getPixPos(b)),c.isVisible)){var d=c.pos.cloneIntPoint();c.hide(a);c.moveToNoSave(a,this.getSquareCenterPos(b));c.setBackground(glApp.Vh.getSquare(b,this.nStretchSqPix));d!==c.pos&&c.moveTo(a,
4194d)}}else glApp.Vh.drawSquare(a,b,this.nStretchSqPix,this.getPixPos(b))}drawSquare(a,b){glApp.Vh.drawSquare(a,b,this.nStretchSqPix,this.getPixPos(b))}onSquareTexturesLoaded(){LOG("Textures OK","","board")}createBoardSprites(){void 0!==this.pieceSpriteFactory&&(this.pieceSpriteFactory.isValid()?this.boardSprites.sqSidePix!==this.nStretchSqPix&&(this.boardSprites.create(this.pieceSpriteFactory),this.boardSprites.setup(this.pieceSpriteFactory,this.board.sqs,this.getPixPos.bind(this)),setTimeout(this.drawIfAllReady.bind(this),
4195300)):LOG("PSpriteFactory not Valid Yet","LogRed","board"))}drawIfAllReady(){glApp.Vh.isBoardValid()&&this.boardSprites.isAllLoaded()?(this.sqArrNotDrawn&&(LOG("Set Buffered Board in DrawIfAllReady..","LogBold","board"),this.setBoard(this.sqArrNotDrawn,!1)),this.onReadyHandlers.count()&&this.onReadyHandlers.execute(),this.onRedraw(),this.cbcanvas.requestRedraw()):setTimeout(this.drawIfAllReady.bind(this),500)}isReady(){return glApp.Vh.isBoardValid()&&this.boardSprites&&this.boardSprites.isAllLoaded()}getPixPos(a){var b=
4196Math.floor(a/8);a%=8;this.blackIsBottom?(b=Math.floor(this.x0+this.nMarginW+this.sqOffs+(7-b)*this.nStretchSqPix),a=Math.floor(this.y0+this.nMarginW+this.sqOffs+a*this.nStretchSqPix)):(b=Math.floor(this.x0+this.nMarginW+this.sqOffs+b*this.nStretchSqPix),a=Math.floor(this.y0+this.nMarginW+this.sqOffs+(7-a)*this.nStretchSqPix));return new CBPoint(b,a)}getSquareRect(a){a=this.getPixPos(a);return new CBRect(a.x,a.y,a.x+this.nStretchSqPix,a.y+this.nStretchSqPix)}getSquareCenterPos(a){return this.getPixPos(a).add(this.getCenterOffs())}isInMyArea(a,
4197b){var c=new CBRect,d=this.toMoveRect?this.toMoveRect.w:0;c.fromPosSize(new CBPoint(this.x0,this.y0),new CBSize(this.width+d,this.height));return a>=c.left&&a<=c.right&&b>=c.top&&b<=c.bottom}getClickPos(a){ASSERT(void 0!==a.x);return new CBPoint(a.x,a.y)}getClickedSquare(a){var b=a.x-this.nMarginW-this.sqOffs-this.x0;a=a.y-this.nMarginW-this.sqOffs-this.y0;this.blackIsBottom?(b=7-Math.floor(b/this.nStretchSqPix),a=Math.floor(a/this.nStretchSqPix)):(b=Math.floor(b/this.nStretchSqPix),a=7-Math.floor(a/
4198this.nStretchSqPix));return 0<=b&&8>b&&0<=a&&8>a?8*b+a:-1}getGenerousClipRect(a,b){var c=CBSquare.getFile(a);a=CBSquare.getRank(a);var d=CBSquare.getFile(b),e=CBSquare.getRank(b);b=Math.max(c,d);var f=Math.min(a,e);c=CBSquare.get64(Math.min(c,d),Math.max(a,e));a=CBSquare.get64(b,f);c=this.getPixPos(c);a=this.getPixPos(a);a.add(new CBPoint(this.nStretchSqPix,this.nStretchSqPix));d=new CBRect;d.fromTwoPoints(c.x,c.y,a.x,a.y);d.expand(this.nStretchSqPix,this.nStretchSqPix);return d}getCenterOffs(){return new CBPoint(Math.floor(this.nStretchSqPix/
41992),Math.floor(this.nStretchSqPix/2))}getOffsFromSqCenter(a){var b=this.getPixPos(this.getClickedSquare(a)).add(this.getCenterOffs());LOG("Click="+a+", center="+b);LOG("Diff="+a.subtract(b));return b.subtract(a)}getPieceRepositoryPos(a){return new CBPoint(-500,-500)}handleRightButtonDown(a,b){this.redrawBlindBoard()}redrawBlindBoard(){this.blindMoves&&(this.backBoard=this.board.sqs.slice(),this.board.copyFrom(this.blindSqs),this.redraw(!1),this.board.copyFrom(this.backBoard))}handleRightButtonUp(a,
4200b){this.redraw(!1)}flipBoard(){this.setBlackIsBottom(!this.blackIsBottom,!0)}setBlackIsBottom(a,b){a!=this.blackIsBottom&&(this.blackIsBottom=a,this.killAnimations(),this.boardS
4200prites.deleteBackgrounds(),b&&(this.destroyMessage(),this.destroyChoiceWin(),this.prepareFullRedraw(),this.redraw(!0)),this.cbcanvas.requestRedraw(),this.titleWin&&this.titleWin.notifyBoardTurned&&this.titleWin.notifyBoardTurned(this),this.bottomWin&&this.bottomWin.notifyBoardTurned&&this.bottomWin.notifyBoardTurned(this))}getSideToShow(){return this.blackIsBottom?
4201Side.BLACK:Side.WHITE}setSideToShow(a){a!==this.getSideToShow()&&this.flipBoard()}setLegalFromSquares(a){this.legalFromSquares=a}setGame(a){this.permanentAttributes=[];this.blindMoves||this.resetInternalBoard();this._game&&(this._game.removeOnCurPosChangedListener(this.idCurPosListener),this._game.removeOnChangedListener(this.idChangeListener),this._game.removeOnNavigateListener(this.idNavigate),this._game.removeOnMoveListener(this.idMove),this._game.removeOnHeaderChangedListener(this.idHeader));
4202if(this._game=a){a=this._onGameCurPosChanged.bind(this);var b=this._onChanged.bind(this),c=this._onHeaderChanged.bind(this),d=this._onNavigate.bind(this),e=this._onMove.bind(this);this.idCurPosListener=this._game.addOnCurPosChangedListener(a);this.idChangeListener=this._game.addOnChangedListener(b);this.idNavigate=this._game.addOnNavigateListener(d);this.idMove=this._game.addOnMoveListener(e);this.idHeader=this._game.addOnHeaderChangedListener(c);this.idRest=this._game.addOnResetGameListener(this._onResetGame.bind(this));
4203this._onGameCurPosChanged(this._game,this._game.getCurPos(),!1);this._onHeaderChanged()}}getGame(){return this._game}_onGameCurPosChanged(a,b,c){"undefined"==typeof c&&this.shouldAnimatePosChange&&(c=this.shouldAnimatePosChange());this.nextCurPosNoAnim&&(this.nextCurPosNoAnim=c=!1);a=!1;this.isAnimationUnderway()?(this._game&&this.setBoard(this._game.getCurPos().board,!1),LOG("RawBoard._onCurPos::Redraw","","board"),a=!0):this._game&&this.setBoard(this._game.getCurPos().board,c);this.addBoardColourAndArrowsFromAnno();
4204a&&this.markLastMove(!1);this.moveEntry.renderPreMoves()}shouldAnimatePosChange(){return!0}_onChanged(){this.addBoardColourAndArrowsFromAnno()}_onResetGame(){this.moveEntry.clearPreMoves()}_onHeaderChanged(){this.titleWin&&this.titleWin.displaysHeader&&this.setTitleText(this._game.hdr.getStrPlayers(this.nStretchSqPix>this.cbcanvas.zoomToPix(42)))}_onMove(a,b){LOG("RawBoard._onMove "+b.toString(),"LogGreen","board");if(this.moveEntry)this.moveEntry.onMove()}_onNavigate(){this.markLastMove(!1)}addBoardColourAndArrowsFromAnno(a,
4205b,c){var d=[].concat(this.permanentAttributes);if(this._game){var e=this._game.getAnno(AnnoType.SQUARE_LIST);if(e)for(var f=0;f<e.length;f++){var g=new BoardColouredSquare(e[f].field,e[f].getColour());g.fromAnno=!0;d.push(g)}if(e=this._game.getAnno(AnnoType.ARROW_LIST))for(f=0;f<e.length;f++)g=new BoardArrow(e[f].from,e[f].to,e[f].getColour()),g.fromAnno=!0,d.push(g);f=this._game.getPreviousMove();c||(this.textAnnosOnBoard&&(c=this._game.getAnno(AnnoType.POSTTEXT))&&BoardText.isAcceptableText(c.toString())&&
4206(c=new BoardText(f,c.toString()),d.push(c)),this.symAnnosOnBoard&&(c=this._game.getAnno(AnnoType.SYMBOL))&&f&&(c=new SymbolAtSquare(f,c),c.isValid()&&d.push(c)))}this._game&&(c=this._game.getMoveBaggage())&&c.attributes&&(d=d.concat(c.attributes));0<d.length&&(c=!1,a||(c=!0,this.shouldAnimatePosChange&&(c=!this.shouldAnimatePosChange())),b&&(c=!0),this.removeLastAnnoAttribsFromQueue(),this.pieceSpriteFactory&&this.pieceSpriteFactory.loaded||(c=!1,b=null),this.queueBoardAttributes(d,{eraseQueue:!1,
4207renderNow:c,requestAnimInRender:c,ctx:b}))}markLastMove(a,b){if(this._game&&this._game.mainLine.length){var c=this._game.getLastMove();c&&(c!=this.markedMove||b)&&(this.markedMove=c,b=new BoardArrow(c.from,c.to),b.lastMove=!0,this.removeLastMarkedMoveFromQueue(),this.queueBoardAttributes([b],{eraseQueue:!1,renderNow:a||!this.canAnimate(),requestAnimInRender:!0}))}}removeLastMarkedMoveFromQueue(){if(this.queuedAttributes){var a=this.queuedAttributes.find(function(b){return b.lastMove});a=this.queuedAttributes.indexOf(a);
42080<=a&&this.queuedAttributes.splice(a,1)}}removeLastAnnoAttribsFromQueue(){if(this.queuedAttributes){do{var a=this.queuedAttributes.find(function(c){return c.fromAnno});var b=this.queuedAttributes.indexOf(a);0<=b&&this.queuedAttributes.splice(b,1)}while(a)}}markSquare(a,b,c,d,e){this.queueBoardAttributes([new BoardColouredSquare(a,b,c)],{eraseQueue:!1,renderNow:!e,requestAnimInRender:!0,permanent:d})}drawArrow(a,b,c,d,e,f){"undefined"!==typeof a&&this.queueBoardAttributes([new BoardArrow(a,b,c,d,f)],
4209{eraseQueue:!0,renderNow:!0,requestAnimInRender:!0,permanent:e})}drawLine(a){this.queueBoardAttributes([a],{eraseQueue:!0,renderNow:!0,requestAnimInRender:!0,permanent:!0})}markSquares(a){this.currPiece&&(this.currPiece.hide(this.cbcanvas.bufferCtx),this.currPiece.deleteBackgroun
4209d());for(var b=0;b<a.length;b++)this.queueBoardAttributes([new BoardColouredSquare(a[b].sq,a[b].clr)],{eraseQueue:!1,renderNow:b==a.length-1,requestAnimInRender:b==a.length-1});this.currPiece&&this.currPiece.moveTo(this.cbcanvas.bufferCtx,
4210this.currPiece.pos)}restoreSquares(a){a.forEach(function(b){this.restoreSquare(this.cbcanvas.bufferCtx,b.sq);this.restoreSquare(this.cbcanvas.ctx,b.sq)}.bind(this))}hideCurrPiece(){var a=this.currPiece;if(a&&a.hide(this.cbcanvas.bufferCtx))return!0}unHideCurrPiece(){var a=this.currPiece;a&&(a.deleteBackground(),this.moveSprite(a,a.pos),this.cbcanvas.joinClipRect(a.getMoveClipRect()))}isWhitePromoPawn(a){return(this.board.get(a)==Piece.W_PAWN||this.blindMoves&&this.blindSqs&&this.blindSqs[a]==Piece.W_PAWN)&&
42116==CBSquare.getRank(a)}isBlackPromoPawn(a){return(this.board.get(a)==Piece.B_PAWN||this.blindMoves&&this.blindSqs&&this.blindSqs[a]==Piece.B_PAWN)&&1==CBSquare.getRank(a)}drawPlayers(a,b,c,d){function e(Fa,Na,I,Ta){Fa=Fa.getListStr(Ta,", ");Na&&(Fa+="  "+Na);I&&(Fa+="   "+I);return Fa}var f=this.getOuterRect(),g=new CBRect(f.left,f.top-a,f.right,f.top-0),h=new CBRect(f.left,f.bottom+0,f.right,f.bottom+a+0);var k=d.players?new CBRect(h.left,h.bottom,h.right,h.bottom+a):h;let l=this.cbcanvas.bufferCtx;
4212l.strokeStyle=null;l.lineWidth=1;d.players&&(CanvasTools.fillRect(l,g,"hsla( 30, 10%, 8%, 0.9 )"),CanvasTools.fillRect(l,h,"hsla( 30, 10%, 8%, 0.9 )"));d.text&&CanvasTools.fillRect(l,k,"hsla( 30, 10%, 8%, 0.9 )");let m=this._game.hdr;var n=m.black,r=m.white;this.blackIsBottom&&([n,r]=[r,n]);n=c(m.white);c=c(m.black);r=d.photos&&!(n.nopic&&c.nopic);let t=Math.round(a*(r?.3:.5)),u="Roboto";900>f.w&&(u="Roboto Condensed");l.font=`${t}px "${u}"`;l.fillStyle="white";let x=Math.min(64,Nation.getRasteredFlagHeight(Math.floor(.8*
4213a))),B=Math.floor(.8*a),y=B/1.414,A=g.left+.25*a;f=(a-B)/2;let aa=Math.round(h.top+((a-x)/2*1.05+1)),ha=Math.round(g.top+((a-x)/2*1.05+1)),z=A,V=Math.round(h.top+f),ba=Math.round(g.top+f);r&&(A+=y+.15*a);let v=Math.round(A+x+.25*a),K=v;n.flag||(v-=x);c.flag||(K-=x);let C=h.bottom-(a-t)/2-t/10,da=g.bottom-(a-t)/2-t/10,ja=C,ea=v;d.players&&(ja+=a);ea=k.left+(k.w-l.measureText(d.text).width)/2;let ra=C;this.blackIsBottom&&([C,da]=[da,C],[aa,ha]=[ha,aa],[V,ba]=[ba,V]);let za=e(m.white,m.eloWh,n.title,
421499),na=e(m.black,m.eloBl,c.title,99),qa=m.event.event;l.measureText(za).width>g.w-3*a||l.measureText(na).width>g.w-3*a?(za=e(m.white,"",0,1),na=e(m.black,"",0,1),qa=""):l.measureText(na+qa+"  ").width>g.w-2*a-ha&&(qa="");let Ba=new CBBitmap,Ua=new CBBitmap,Ja=new CBBitmap,Pa=new CBBitmap,Ca=0,xa=2;d.photos&&n.pic&&xa++;d.photos&&c.pic&&xa++;Ba.callOnLoaded=function(){l.font=`${t}px "${u}"`;d.text&&l.fillText(d.text,ea,ja);if(d.players&&(l.fillText(za,v,C),Ba.drawStretched(l,A,aa,x,x),d.toMove&&!d.text)){l.save();
4215l.font=`italic ${.9*t}px serif`;let Fa=l.measureText(d.toMove).width;l.measureText(za).width+Fa+3*a<g.w&&(l.fillStyle="hsl( 120, 90%, 70% )",l.fillText(d.toMove,g.left+g.w-Fa-13,ra),l.fillStyle="white");l.restore()}++Ca==xa&&b&&b()}.bind(this);Ua.callOnLoaded=function(){d.players&&na&&(l.font=`${t}px "${u}"`,l.fillText(na,K,da),Ua.drawStretched(l,A,ha,x,x),l.fillText(qa,A+g.w-l.measureText(qa).width-a/2,da));++Ca==xa&&b&&b()}.bind(this);Ja.callOnLoaded=function(){Ja.drawStretched(l,z,V,y,B);++Ca==
4216xa&&b&&b()}.bind(this);Pa.callOnLoaded=function(){Pa.drawStretched(l,z,ba,y,B);++Ca==xa&&b&&b()}.bind(this);n.flagPath&&d.players?Ba.fromUrl(n.flagPath):Ba.callOnLoaded();c.flagPath&&d.players?Ua.fromUrl(c.flagPath):Ua.callOnLoaded();d.photos&&(n.pic&&Ja.fromUrl(n.pic),c.pic&&Pa.fromUrl(c.pic))}redrawWithPlayers(a,b,c){let d=Math.floor(this.height/(c.photos?10:16));var e=this._game.hdr,f=e.black;e=e.white;this.blackIsBottom&&([f,e]=[e,f]);f=c.players&&f.isValid()?d:0;e=c.players&&e.isValid()?d:0;
4217c.text&&(e+=d);this.calcGeometry(f,e);let g=this.getOuterRect();g.top-=f;g.bottom+=e;g.right+=0;this.boardSprites=new BoardSprites;this.pieceSpriteFactory=this.createPieceSpriteFactory();this.idOnReady=this.onReadyHandlers.add(function(){CanvasTools.fillRect(this.cbcanvas.bufferCtx,new CBRect(-4,-4,this.width+30,this.height+30),"white");this.redraw();this.drawPlayers(d,function(){let h=this.cbcanvas.bufferCtx.getImageData(g.left,g.top,g.w-1,g.h-1);this.onReadyHandlers.remove(this.idOnReady);a(h,g)}.bind(this),
4218b,c)}.bind(this))}replayToImages(a,b,c){function d(){return e.cbcanvas.bufferCtx.getImageData(f.left,f.top,f.w-1,f.h-1)}let e=this;var f;CanvasTools.fillRect(this.cbcanvas.bufferCtx,new CBRect(0,0,this.cbcanvas.canvas.width,this.cbcanvas.canvas.height),"green");this.cbcanvas.requestAnimation();let g=Math.floor(this.height/16);var h=this._game.hdr,k=h.black;h=h.white;this.blackIsBottom&&([k,h]=[h,k]);k=c.players&&k.isValid()?g:0;h=c.players&&h.isValid()?g:0;c.text&&(h+=g);this.calcGeometry(k,h);let l=
4219this.getOuterRect();l.top-=k;l.bottom+=h;l.right+=0;
4219this.boardSprites=new BoardSprites;this.pieceSpriteFactory=this.createPieceSpriteFactory();this.textAnnosOnBoard=!0;this.idOnReady=this.onReadyHandlers.add(function(){CanvasTools.fillRect(this.cbcanvas.bufferCtx,new CBRect(0,0,this.cbcanvas.canvas.width,this.cbcanvas.canvas.height),"white");this.drawPlayers(g,function(){let m=[];f=l;this._game.gotoIndex(0);this.redraw();m.push(d());for(var n=1;n<=this._game.getMoves().length;n++){this._game.gotoIndex(n);
4220this.redraw();let r=d();m.push(r)}this.undoAttributes();n=new BoardText(this._game.getPreviousMove(),c.toMove);this.queueBoardAttributes([n],{eraseQueue:!0,renderNow:!0,requestAnimInRender:!0,ctx:this.cbcanvas.bufferCtx});m.push(d());this.onReadyHandlers.remove(this.idOnReady);a(m,l)}.bind(this),b,c)}.bind(this))}}var ttEvalGate=new V10,ttToMoveGate=new V10;RawBoardControl.prototype._game=null;"use strict";
4221class BoardControl extends RawBoardControl{constructor(a,b,c,d,e){super();this.init(a,b,c,d);this.pieceFontName=PieceFonts[glSettings.pieceStyleId];this.markedSqsOnButtonDown=[];this.options=e;this.pieceTouchSq=-1}getGame(){return this._game}onMouseDown(a,b){if(this._game){glApp.Vh.abortCreateBackground();try{if(2==a.button)this.handleRightButtonDown(a,b);else if(!this.buttonDown&&(this.blindMoves||this.redraw(),this.destroyMessage(),new Tick,this.buttonDown=!0,this.clickPos=this.getClickPos(b),this.clickOffs=
4222this.getOffsFromSqCenter(this.clickPos),void 0!==this.fnBoardClick&&this.fnBoardClick(this.uniqueId,this.clickPos,a),this.allowInput)){var c=this.getClickedSquare(this.clickPos);this.moveEntry.clearAttributesOnMouseDown(c);-1!=c&&(this.blindMoves?this.flashBlindPiece(c):(this.currPiece=this.grabPiece(c,this.clickPos.add(this.clickOffs)),this.moveEntry.onSquareClicked(c)),this.fromSq=c,this.markedSqsOnButtonDown=[],this.fnMarkSquaresOnButtonDown&&(this.markedSqsOnButtonDown=this.markedSqsOnButtonDown.concat(this.fnMarkSquaresOnButtonDown(c))),
4223this.markSquares(this.markedSqsOnButtonDown),this.fnSquareClick&&this.fnSquareClick(c),(this.currPiece||this.hasPieceInAdjacentSquare(c))&&a.preventDefault())}}catch(d){LogException("BoardDown",d)}}}hasPieceInAdjacentSquare(a){for(var b=[-7,-8,-9,-1,1,7,8,9],c=0;c<b.length;c++){var d=a+b[c];if(0<=d&&64>=d&&this.board.sqs[d])return!0}return!1}onMouseUp(a,b){if(this._game)try{if(2==a.button)this.handleRightButtonUp(a,b);else if(this.getClickPos(b),this.buttonDown){this.buttonDown=!1;var c=this.clickPos=
4224this.getClickPos(b),d=!1;if(this.allowInput){new Tick;var e=this.getClickedSquare(c);if(-1==e){void 0!==this.currPiece&&(this.animateFromTo(this.currPiece,c,this.get
4224SquareCenterPos(this.fromSq),2),delete this.currPiece);this.fromSq=-1;super.onMouseUp(a,b);return}if(this.blindMoves)e!=this.fromSq&&(this.toSq=e,this.prom=0,this.handlePromo(this.fromSq,this.toSq,c,!1),this.moveEntry.boardWinMoveEntered(this.fromSq,this.toSq,this.prom));else if(void 0!==this.currPiece||this.fromSq===this.moveEntry.getLastPreMoveToSq()||
42250==this.board.get(e)||0<=this.fromSq&&0==this.board.get(this.fromSq)){if(e!==this.fromSq){this.pieceTouchSq=-1;var f=this.moveEntry.isLegalOrPremove(this.board,this.fromSq,e);!f&&this.moveEntry.isLegal(this.board,e,this.fromSq)&&this.moveEntry.mayEnterBackwards(this.board,e)&&(b=e,e=this.fromSq,this.fromSq=b,f=!0,this.currPiece=this.grabPiece(this.fromSq,this.getSquareCenterPos(this.fromSq)));f?(this.toSq=e,this.prom=0,d=this.moveEntry.isPremove(this.board,this.fromSq,this.toSq),this.moveEntry.colorOk(this.board.get(this.fromSq))&&
4226(this.board.get(e)&&!d&&this.animateCapture(e),this.handlePromo(this.fromSq,this.toSq,c,d)||this.handleEnPassant(this.fromSq,this.toSq,d)||(d||(this.boardSprites.change(this.fromSq,e),this.board.change(this.fromSq,e)),this.currPiece&&this.movePieceToSq(this.currPiece,e))),this.moveEntry.boardWinMoveEntered(this.fromSq,this.toSq,this.prom)||(this.currPiece&&(this.currPiece.moveTo(this.cbcanvas.bufferCtx,this.getSquareCenterPos(this.fromSq)),this.currPiece.lastSq=this.fromSq),d=!0,this.cbcanvas.requestAnimation(this.getGenerousClipRect(this.fromSq,
4227this.toSq),!0))):this.currPiece&&this.animateFromTo(this.currPiece,c,this.get
4227SquareCenterPos(this.fromSq),5);delete this.fromSq}else this.clickHandler?this.clickHandler(e):this.currPiece?(this.movePieceToSq(this.currPiece,e),this.moveEntry.isMyPiece(e)?this.pieceTouchSq=e:this.moveEntry.isOpponentPiece(e)&&(this.moveEntry.tryTwoClickMove(this.pieceTouchSq,e),this.pieceTouchSq=-1)):(this.moveEntry.tryTwoClickMove(this.pieceTouchSq,e),this.pieceTouchSq=-1);delete this.currPiece}a.preventDefault();this.fnSquareRelease&&
4228this.fnSquareRelease(e)}else this.currPiece&&(this.animateFromTo(this.currPiece,c,this.getSquareCenterPos(this.fromSq),5),delete this.currPiece);this.fromSq=-1;this.markedSqsOnButtonDown.length&&(this.markedSqsOnButtonDown=[]);this.redraw();d&&this.moveEntry.renderPreMoves()}}catch(g){LogException("BoardUp",g)}}onMouseWheel(a,b){}onMouseMove(a,b){try{if(this.allowInput){this.clickPos=this.getClickPos(b);var c=this.getClickedSquare(this.clickPos);this.moveSq=c;var d;if(this.isWhitePromoPawn(this.fromSq)){var e=
4229c;7==CBSquare.getRank(e)&&(d=this.blindMoves||this.moveEntry.isLegalOrPremove(this.board,this.fromSq,e))}else this.isBlackPromoPawn(this.fromSq)&&(e=c,0==CBSquare.getRank(e)&&(d=this.blindMoves||this.moveEntry.isLegalOrPremove(this.board,this.fromSq,e)));d?(this.currPiece&&(this.hideSprite(this.currPiece),this.currPiece.saveBackground(this.cbcanvas.bufferCtx)),this.drawPromChoice(e),LOG("Prom: "+e)):(void 0!==this.promoSprite&&(LOG("Delete PromoSprite"),this.hideSprite(this.promoSprite),delete this.promoSprite,
4230this.currPiece&&this.currPiece.deleteBackground()),this.currPiece&&(this.animation.hideAll(),this.moveSprite(this.currPiece,this.clickPos.add(this.clickOffs)),this.animation.showAll()));if(void 0!==this.currPiece)a.preventDefault(),c!=this.fromSq&&this.fnSquareChangeInMouseMove&&this.fnSquareChangeInMouseMove(c);else if(!this.blindMoves){d=!1;if(0<=c){var f=this.board.get(c);f===Piece.NONE||!this.moveEntry||this.moveEntry.getMySide()!=Piece.side(f)&&null!==this.moveEntry.getMySide()||(a.target.style.cursor=
4231this.busy?"wait":"pointer",d=!0)}d||(a.target.style.cursor=this.busy?"wait":"default")}}super.onMouseMove(a,b)}catch(g){LogException("BMMove",g)}}handlePromo(a,b,c,d){this.isWhitePromoPawn(a)?this.prom=this.getPromFromClickPos(b,c):this.isBlackPromoPawn(a)&&(this.prom=this.getPromFromClickPos(b,c)+Side.SIDE_MASK);return this.prom?(d?(this.drawSquare(this.cbcanvas.bufferCtx,this.toSq),this.currPiece.deleteBackground(),this.cbcanvas.requestAnimation(this.getSquareRect(this.toSq))):(this.blindMoves||
4232(this.boardSprites.promo(this.fromSq,this.toSq,this.prom,this.pieceSpriteFactory),this.board.promo(this.fromSq,this.toSq,this.prom)),this.drawSquare(this.cbcanvas.bufferCtx,this.toSq),this.blindMoves||(this.movePieceToSq(this.boardSprites.getPiece(this.toSq),this.toSq),this.drawSquare(this.cbcanvas.bufferCtx,this.fromSq))),delete this.promoSprite,!0):!1}drawPromChoice(a){void 0===this.promoSprite&&(this.promoSprite=this.boardSprites.getPromoSprite(Piece.side(this.board.sqs[this.fromSq])));LOG("Move Promo Sprite to: "+
4233CBSquare.toString(a));this.movePieceToSq(this.promoSprite,a)}handleEnPassant(a,b,c){var d;this.board.get(a)==Piece.W_PAWN&&4==CBSquare.getRank(a)&&this.moveEntry.mayEnPassant(a,b)?d=CBSquare.get64(CBSquare.getFile(b),4):this.board.get(a)==Piece.B_PAWN&&3==CBSquare.getRank(a)&&this.moveEntry.mayEnPassant(a,b)&&(d=CBSquare.get64(CBSquare.getFile(b),3));return void 0!==d?(c||(this.boardSprites.enPassant(a,b,d),this.board.enPassant(a,b,d),this.movePieceToSq(this.currPiece,this.toSq),this.drawSquare(this.cbcanvas.bufferCtx,
4234d),this.cbcanvas.requestAnimation(this.getSquareRect(d))),!0):!1}markPreMove(a,b){this.queueBoardAttributes([new BoardArrow(a,b,this.moveEntry.getPreMoveHsla())],{eraseQueue:!0,renderNow:!0,requestAnimInRender:!1})}grabPiece(a,b){var c=this.boardSprites.getPiece(a);c&&(c.fromSq=a);void 0===c&&a!==this.moveEntry.getLastPreMoveToSq()||!c||(c.pieceName=Piece.toString(this.board.get(a)),LOG(c.pieceName),c.hasBackground()?this.moveSprite(c,this.clickPos.add(this.clickOffs)):(c.pos=b,c.setBackground(glApp.Vh.getSquare(a,
4235this.nStretchSqPix||0))));return c}
4235flashBlindPiece(a){this.blindPiece=this.boardSprites.getBlindSprite(this.pieceSpriteFactory,this.blindSqs?this.blindSqs[a]:this.board.sqs[a]);var b=this.getSquareCenterPos(a);this.blindPiece.moveTo(this.cbcanvas.bufferCtx,b);this.cbcanvas.requestAnimation(this.getSquareRect(a));(new Timer(function(){b.x+=2;b.y+=2;this.blindPiece.moveTo(this.cbcanvas.bufferCtx,b);this.cbcanvas.requestAnimation(this.getSquareRect(a));this.hideSprite(this.blindPiece);this.blindPiece=
4236null}.bind(this))).runOnce(100)}setBusy(a){this.busy=a;this.cbcanvas.canvas.style.cursor=this.busy?"wait":"default"}test(){var a=["rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1","rnbqk2r/1p2bppp/p2p1n2/4p1B1/4P3/1NN5/PPP1BPPP/R2QK2R b KQkq - 0 8","4rk1r/pppb1ppp/2np4/8/3P4/2PBP3/PP1N2PP/R4RK1 w - - 0 15","b4rk1/p1p1qpp1/3p1n1p/4p3/4P2B/3P1N2/PRPQ1PPP/6K1 w - - 0 16","7r/3kp3/1p6/p1p1p3/3nP1p1/PPKPB1P1/5P2/R7 b - - 0 29"];this.testInx=void 0===this.testInx?0:this.testInx+1;this.testInx>
4237a.length-1&&(this.testInx=0);this.execStr(a[this.testInx])}refreshMarkedSquares(){this.buttonDown&&this.fromSq&&this.fromSq==this.moveSq&&(this.markedSqsOnButtonDown&&this.markedSqsOnButtonDown.length&&this.restoreSquares(this.markedSqsOnButtonDown),this.markedSqsOnButtonDown=[],this.fnMarkSquaresOnButtonDown&&(this.markedSqsOnButtonDown=this.markedSqsOnButtonDown.concat(this.fnMarkSquaresOnButtonDown(this.fromSq,!0))),this.markSquares(this.markedSqsOnButtonDown))}execStr(a){a=new Position(a);this.setBoard(a.board)}}
4238class HandlerBoardControl extends RawBoardControl{constructor(a,b,c,d,e,f={}){super();this.options=f;this.init(a,b,c,d);this.blockedForHandler=null;this.fnMakeMove=e;this.fnMakeMove||(this.fnMakeMove=function(g){this.moveEntry.boardWinMoveEntered(g.from,g.to,g.prom)}.bind(this));this.isHandlerBoard=!0;this.options.pieceFontName&&(this.pieceFontName=this.options.pieceFontName);this.promoZone=[];this.promSquare=-1}getHandlers(){throw Error("override");}callHandlers(a,...b){this.beginEvent();var c=this.buildHandlerContext(...b);
4239null!=this.blockedForHandler?this.blockedForHandler[a](...b,c)&&this.endBlockHandlers():this.handlers.forEach(d=>{if(!this.isPointerDown(c.evt)||d.shouldRun(c))d[a](...b,c)});this.endEvent()}isPointerDown(a){return"mousedown"==a.type||"touchstart"==a.type||"pointerdown"==a.type}blockHandlersFor(a){this.blockedForHandler=a}endBlockHandlers(){this.blockedForHandler=null}addHandler(a){this.handlers.push(a)}buildHandlerContext(...a){var b=new Position;this.getGame()&&b.copy(this.getGame().getCurPos());
4240return{position:b,board:this.board.getCopy(),evt:a[0],ptScaled:a[1]}}beginEvent(){this.moved=!1}endEvent(){}makeMove(a,b,c){if(!this.moved){var d=new Move(a,b);if(!d.isNullMove()){var e=this.boardSprites.getPiece(a);c=this.isLegal(a,b,c);var f=0!=this.board.get(b),g=this.isProm(a,b);c?(this.moved=!0,this.boardSprites.change(a,b),f&&c&&(this.drawSquare(this.cbcanvas.bufferCtx,b),e&&e.saveBackground(this.cbcanvas.bufferCtx)),this.board.change(a,b),this.movePieceToSq(e,b),this.drawSquare(this.cbcanvas.bufferCtx,
4241a)):e&&this.movePieceToSq(e,a);c&&!g&&this.fnMakeMove(d);c&&g&&(this.promSquare=b,this.prommove=d,this.drawPromChoices(b),this.blockHandlersFor(new PromotionClickHandler(this,b)))}}}static gameMakeMove(a){this.getGame().makeMove(a,MoveEnterType.NEWLINE)}isProm(a,b){if(this.getGame())return this.getGame().getCurPos().isProm(a,b)}isLegal(a,b,c){if(this.getGame())return c?this.getGame().getCurPos().isLegalFromToIgnoreColor(a,b):this.getGame().getCurPos().isLegalFromTo(a,b)}drawPromChoices(a){var b=7==
4242CBSquare.getRank(a)?Piece.WHITE:Piece.BLACK,c=[Piece.QUEEN,Piece.
4242KNIGHT,Piece.ROOK,Piece.BISHOP].map(e=>e|b),d=[a];d.push(d[0]+2*b/8-1);d.push(d[1]+2*b/8-1);d.push(d[2]+2*b/8-1);d.map((e,f)=>{this.board.set(e,c[f])});this.redraw();(new Timer(function(){this.promoZone=[new BoardZone(a+6*b/8-3,a,9,"hsla( 100, 80%, 40%, 0.7 )",[15,10],this,!1)];this.addAttributes(this.promoZone,0)}.bind(this))).runOnce(100)}onPromoClick(a){var b=this.prommove;b.prom=a;this.fnMakeMove(b);this.promSquare=-1;this.prommove=
4243null;this.endBlockHandlers();this.removeAttributes(this.promoZone);this.promoZone=[];this.redraw()}animateMove(a,b){var c=this.boardSprites.getPiece(a);a=this.getSquareCenterPos(a);b=this.getSquareCenterPos(b);this.animateFromTo(c,a,b,2)}onMouseDown(...a){if(this.allowInput)return this.callHandlers("onMouseDown",...a)}onMouseUp(...a){if(this.allowInput)return this.callHandlers("onMouseUp",...a)}onMouseMove(...a){return this.callHandlers("onMouseMove",...a)}onMouseEnter(...a){return this.callHandlers("onMouseEnter",
4244...a)}onMouseLeave(...a){return this.callHandlers("onMouseLeave",...a)}onContextMenu(...a){return this.callHandlers("onContextMenu",...a)}onMouseWheel(...a){return this.callHandlers("onMouseWheel",...a)}onDoubleClick(...a){return this.callHandlers("onDoubleClick",...a)}onRedraw(){-1!=this.promSquare&&this.drawPromChoices(this.promSquare)}}function makeBoardControlEvent(a){return function(...b){this.callHandlers(a,...b)}}
4245class ReplayHandlerBoardControl extends HandlerBoardControl{constructor(a,b,c,d,e,f){super(a,b,c,d||"RHBoard",null,e);this.handlers=this.getHandlers();f&&this.handlers.push(new ShowHintsBoardHandler(this,{fnShouldRun:BoardHandler.isLeftMouse},f))}getHandlers(){return[new MoveSpriteHandler(this,{fnShouldRun:BoardHandler.isLeftMouse}),new MakeMoveHandler(this,{fnShouldRun:BoardHandler.isLeftMouse}),new TwoClickMoveHandler(this,{fnShouldRun:BoardHandler.isLeftMouse}),new MousePointerHandler(this,{fnShouldRun:BoardHandler.isLeftMouse}),
4246new ShowLegalMovesBoardHandler(this,{fnShouldRun:BoardHandler.isLeftMouse}),new AttributeBoardHandler(this,{fnShouldRun:BoardHandler.isRightMouse}),new SelectBoardHandler(this,{fnShouldRun:BoardHandler.isClick}),new CallBoardControlClickHandler(this,{fnShouldRun:BoardHandler.isClick}),new RetractMoveHandler(this,{fnShouldRun:BoardHandler.isClick})]}}
4247class BoardHandler{constructor(a,b){this.control=a;this.options=b||{}}getBoardControl(){return this.control}getMoveEntry(){return this.getBoardControl().moveEntry}getBoard(){return this.getBoardControl().board}getCurrPiece(){return this.getBoardControl().currPiece}setCurrPiece(a){return this.getBoardControl().currPiece=a}deleteCurrPiece(){delete this.getBoardControl().currPiece;this.getBoardControl().currPiece=null}setFromSq(a){this.fromSq=a;this.getBoardControl().fromSq=a}setButtonDown(a){this.getBoardControl().buttonDown=
4248a}getCanvas(){return this.getBoardControl().cbcanvas}getBufferCtx(){return this.getBoardControl().cbcanvas.bufferCtx}getGame(){return this.getBoardControl().getGame()}getSquareCenterPos(a){return this.getBoardControl().getSquareCenterPos(a)}getBoardSprites(){return this.getBoardControl().boardSprites}getPieceSpriteFactory(){return this.getBoardControl().pieceSpriteFactory}getNSqPix(){return this.getBoardControl().nSqPix}getPixPos(a){return this.getBoardControl().getPixPos(a)}animateFromTo(a,b,c,d){return this.getBoardControl().animateFromTo(a,
4249b,c,d)}shouldRun(a){return this.options.fnShouldRun?this.options.fnShouldRun(a):!0}onMouseDown(a,b){}onMouseUp(a,b){}onMouseEnter(a,b){}onMouseLeave(a,b){}onMouseMove(a,b){}onContextMenu(a,b){}onMouseWheel(a,b){}onDoubleClick(a,b){}getClickPos(a){return this.getBoardControl().getClickPos(a)}getSquare(a){a=this.getBoardControl().getClickPos(a);return this.getBoardControl().getClickedSquare(a)}isValidSquare(a){return 0<=a&&63>=a}isProm(a,b){return this.getGame().getCurPos().isProm(a,b)}grabPiece(a,
4250b){var c=this.getBoardControl().boardSprites.getPiece(a);c&&(c.pieceName=Piece.toString(this.getBoardControl().board.get(a)),c.hide(this.getBufferCtx()),c.fromSq=a,c.setPos(this.getBoardControl().getSquareCenterPos(a)),c.setBackgroun
4250d(glApp.Vh.getSquare(a,this.getBoardControl().nSqPix)),c.moveTo(this.getBoardControl().cbcanvas.bufferCtx,c.pos),this.moveSprite(c,b));return c}moveSprite(a,b){a.moveTo(this.getBoardControl().cbcanvas.bufferCtx,b);this.getBoardControl().cbcanvas.requestAnimation(a.getMoveClipRect())}movePieceToSq(a,
4251b){this.moveSprite(a,this.getSquareCenterPos(b));a.lastSq=b}hideCurrPiece(){var a=this.getCurrPiece();if(a&&a.hide(this.getBufferCtx()))return!0}unHideCurrPiece(){var a=this.getCurrPiece();a&&(a.deleteBackground(),this.getBoardControl().moveSprite(a,a.pos),this.getCanvas().joinClipRect(a.getMoveClipRect()))}animateCapture(a){if(0<=a){var b=this.hideCurrPiece();this.drawSquare(this.getCanvas().bufferCtx,a);b&&this.unHideCurrPiece()}}drawSquare(a,b){glApp.Vh.drawSquare(a,b,this.getNSqPix(),this.getPixPos(b))}hideSprite(a){a&&
4252(a.hide(this.getCanvas().bufferCtx),this.getCanvas().requestAnimation(a.getMoveClipRect()));return a}}BoardHandler.isLeftMouse=function(a){return 0===a.evt.button||BoardHandler.isTouch(a.evt)};BoardHandler.isTouch=function(a){return"touchstart"==a.type||"touch"==a.pointerType};BoardHandler.isRightMouse=function(a){return 2===a.evt.button};BoardHandler.isShiftDown=function(a){return a.evt.shiftKey};BoardHandler.isAltDown=function(a){return a.evt.altKey};
4253BoardHandler.isClick=function(a){return BoardHandler.isLeftMouse(a)||BoardHandler.isRightMouse(a)};class SquareMovedBoardHandler extends BoardHandler{onMouseDown(a,b,c){this.from=this.getSquare(b);return!1}onMouseUp(a,b,c){a=!1;b=this.getSquare(b);this.from!==b&&this.isValidSquare(this.from)&&this.isValidSquare(b)&&(a=this.onSquareMove(this.from,b,c));delete this.from;return a}onSquareMove(a,b){}}
4254class SquareClickedBoardHandler extends BoardHandler{onMouseDown(a,b,c){this.from=this.getSquare(b);return!1}onMouseUp(a,b,c){a=!1;b=this.getSquare(b);this.from==b&&this.isValidSquare(this.from)&&(a=this.onSquareClick(this.from,c));delete this.from;return a}onSquareClick(a){}}
4255class MoveSpriteHandler extends BoardHandler{constructor(a,b){super(a,b)}onMouseDown(a,b){var c=this.getSquare(b);if(this.isValidSquare(c)){var d=this.hideCurrPiece();this.getBoardControl().quickFinishAnimations();d&&this.unHideCurrPiece();b=this.getClickPos(b);this.getBoardControl().clickPos=b;this.setCurrPiece(this.grabPiece(c,b))&&a.preventDefault();this.setFromSq(c);this.setButtonDown(!0)}}onMouseUp(a,b){a=this.getClickPos(b);b=this.getSquare(b);-1===b?(this.getCurrPiece()&&(this.animateFromTo(this.getCurrPiece(),
4256a,this.getSquareCenterPos(this.fromSq),2),this.deleteCurrPiece()),this.setButtonDown(!1),this.setFromSq(-1)):(a=new Move(this.fromSq,b),this.getMoveEntry().isLegal(this.getBoard(),this.fromSq,b)&&!a.isNullMove()?this.getCurrPiece()&&this.movePieceToSq(this.getCurrPiece(),b):this.getCurrPiece()&&this.movePieceToSq(this.getCurrPiece(),this.fromSq),this.setFromSq(null),this.setCurrPiece(null),this.setButtonDown(!1),this.getBoardControl().redraw())}onMouseMove(a,b){this.getCurrPiece()&&(b=this.getClickPos(b),
4257this.getBoardControl().animation.hideAll(),this.moveSprite(this.getCurrPiece(),b),this.getBoardControl().animation.showAll(),a.preventDefault())}drawPromChoices(a){var b=7==CBSquare.getRank(a)?Piece.WHITE:Piece.BLACK,c=[Piece.QUEEN,Piece.
4257KNIGHT,Piece.ROOK,Piece.BISHOP].map(e=>e|b),d=[a];d.push(d[0]+2*b/8-1);d.push(d[1]+2*b/8-1);d.push(d[2]+2*b/8-1);d.map((e,f)=>{this.getBoard().set(e,c[f])});this.getBoardControl().redraw();a=[new BoardZone(a+b-4,a,3,"blue")];this.getBoardControl().addAttributes(a,
42580)}hidePieces(a){return a.map(b=>{b=this.getBoardSprites().getPiece(b);b.hide(this.getCanvas().bufferCtx);return b})}}
4259class MakeMoveHandler extends BoardHandler{constructor(a,b){super(a,b);this.promSquare=-1}onMouseDown(a,b){this.from=this.getSquare(b)}onMouseUp(a,b){if(0<=this.from&&(a=this.getSquare(b),this.from!=a))this.onSquareMove(this.from,a)}onSquareMove(a,b){this.getMoveEntry().colorOk(this.getBoard().sqs[a],a)&&this.getBoardControl().makeMove(a,b)}handlePromClick(a){if(!(0>this.promSquare||63<this.promSquare)){var b=this.prommove;a=this.promSquare-a;0==CBSquare.getRank(this.promSquare)&&(a=-a);0>a||4<=a||
4260(b.prom=[Piece.QUEEN,Piece.KNIGHT,Piece.ROOK,Piece.BISHOP][a],this.getGame().makeMove(b,MoveEnterType.NEWLINE),this.promSquare=-1,this.prommove=null)}}}class RetractMoveHandler extends SquareMovedBoardHandler{constructor(a,b){super(a,b)}onSquareMove(a,b){var c=this.getGame().getLastMove();c&&c.from==b&&c.to==a&&this.getGame().isLineEnd()&&(this.getGame().gotoPrev(),this.getGame().deleteRemaining(!1))}}
4261class SingleClickMoveBoardHandler extends SquareClickedBoardHandler{constructor(a,b){super(a,b)}onSquareClick(a){var b=this.getGame().getCurPos().Vd().filter(c=>c.to==a&&!c.isNullMove());1===b.length&&(b=b[0].from,this.getBoardControl().makeMove(b,a))}}
4262class TwoClickMoveHandler extends SquareClickedBoardHandler{constructor(a,b){super(a,b);this.squareAttri=this.fromSq=null}onMouseDown(a,b,c){var d=this.getSquare(b);this.from!=d&&this.isValidSquare(d)&&this.removeColoredSquare();super.onMouseDown(a,b,c)}onSquareClick(a,b){null==this.fromSq?this.firstClick(a,b):this.secondClick(a,b)}firstClick(a,b){this.getBoard().get(a)&&this.hasMovesFrom(a,b)&&(b=this.hideCurrPiece(),this.squareAttri=new BoardColouredSquare(a,"rgba( 0, 92, 6, 0.5 )",!1),this.getBoardControl().addAttributes([this.squareAttri],
42630),this.setFromSq(a),b&&this.unHideCurrPiece())}secondClick(a,b){this.removeColoredSquare();this.squareAttri=null;this.getBoardControl().isLegal(this.fromSq,a)?this.getBoardControl().makeMove(this.fromSq,a):this.hasMovesFrom(a,b)?this.setFromSquare(a):this.setFromSquare(null)}colorSquare(a){a=new BoardColouredSquare(a,"rgba(0, 92, 6, 0.4)",!1);this.getBoardControl().addAttributes([a],0);return a}setFromSquare(a){null!=a&&(null!=this.squareAttri&&this.removeColoredSquare(),this.squareAttri=this.colorSquare(a));
4264this.setFromSq(a)}removeColoredSquare(){var a=this.hideCurrPiece();null!=this.squareAttri&&this.getBoardControl().removeAttributes([this.squareAttri]);this.squareAttri=null;a&&this.unHideCurrPiece()}hasMovesFrom(a,b){return b.position.Vd().some(c=>c.from==a)}}
4265class ShowLegalMovesBoardHandler extends BoardHandler{constructor(a,b,c,d){super(a,b);this.squareFrom=this.sqClicked=null;this.attributes=[];this.color=c||"rgba( 16, 19, 188, 0.3 )";this.clearOnMouseDown=d}onMouseDown(a,b){this.clearOnMouseDown&&(a=this.hideCurrPiece(),this.getBoardControl().clearAll(),a&&this.unHideCurrPiece());this.squareFrom=b=this.getSquare(b);this.sqClicked!=b&&(this.remove(),this.add(b))}onMouseUp(a,b,c){a=this.getSquare(b);if(this.squareFrom==a)this.onSquareClick(a);else this.onSquareMove(this.squareFrom,
4266a);this.squareFrom=null}onSquareClick(a){this.remove();this.sqClicked!=a&&this.add(a)}onSquareMove(a,b){}remove(){this.getBoardControl().removeAttributes(this.attributes);this.attributes=[]}add(a){if(this.getBoard().get(a)){var b=this.hideCurrPiece();this.square=a;var c=this.getGame().getCurPos().Vd().filter(d=>d.from==a).map(d=>d.to).map(d=>new BoardCircle(d,this.getColor()));this.getBoardControl().addAttributes(c,0);this.attributes=c;b&&this.unHideCurrPiece()}}getColor(){return this.color}}
4267class PromotionClickHandler extends SquareClickedBoardHandler{constructor(a,b){super(a);this.promSq=b}onSquareClick(a){if(-1==this.promSq)return!0;a=this.promSq-a;0==CBSquare.getRank(this.promSq)&&(a=-a);if(0>a||4<=a)return!1;
4267a=[Piece.QUEEN,Piece.KNIGHT,Piece.ROOK,Piece.BISHOP][a];this.getBoardControl().onPromoClick(a);return!0}}
4268class PremoveHandler extends SquareMovedBoardHandler{constructor(a,b){super(a,b)}onMouseDown(a,b){super.onMouseDown(a,b);2===a.button&&this.clear()}onMouseUp(a,b){var c=this.getSquare(b);this.from===c&&this.isValidSquare(c)&&this.clear();super.onMouseUp(a,b)}clear(){this.getMoveEntry().clearPreMoves()&&this.getBoardControl().undoAttributes()}onSquareMove(a,b){if(this.getMoveEntry().isPremove(this.getBoard(),a,b)){var c=this.getMoveEntry().getFirstSquareOfPremoveFrom(a);c=this.getBoard().get(c);var d=
4269Piece.NONE;(c&Piece.PIECE_MASK)!=Piece.PAWN||0!=CBSquare.R(b)&&7!=CBSquare.R(b)||(d=Piece.QUEEN);this.getMoveEntry().boardWinMoveEntered(a,b,d)||(this.getCanvas().requestAnimation(this.getBoardControl().getGenerousClipRect(a,b),!0),this.getMoveEntry().renderPreMoves())}}}
4270class AttributeBoardHandler extends BoardHandler{constructor(a,b){super(a,b);this.from=null}onMouseDown(a,b){this.from=this.getSquare(b)}onMouseUp(a,b){if(null!==this.from){b=this.getSquare(b);if(-1===this.from&&-1===b)this.onRemoveAll();if(-1!==this.from&&-1!==b){if(this.from===b)this.onSquare(b,a);else this.onArrow(this.from,b,a);this.from=null}}}onRemoveAll(){this.getGame().setAnno(AnnoType.ARROW_LIST,new ColArrowAnno);this.getBoardControl().redraw();this.getGame().setAnno(AnnoType.SQUARE_LIST,
4271new ColSqAnno);this.getBoardControl().redraw()}onArrow(a,b,c){a=new ColArrow(a,b,this.getColor(c));this.hasArrow(a)?this.removeArrow(a):this.addArrow(a);this.getBoardControl().redraw()}addArrow(a){var b=this.getGame().getAnno(AnnoType.ARROW_LIST)||new ColArrowAnno;b.push(a);this.getGame().setAnno(AnnoType.ARROW_LIST,b)}removeArrow(a){var b=this.getGame().getAnno(AnnoType.ARROW_LIST)||new ColArrowAnno;b.removeIf(c=>this.isSameArrow(c,a));this.getGame().setAnno(AnnoType.ARROW_LIST,b)}hasArrow(a){return(this.getGame().getAnno(AnnoType.ARROW_LIST)||
4272new ColArrowAnno).some(b=>this.isSameArrow(a,b))}isSameArrow(a,b){return a.from==b.from&&a.to==b.to}onSquare(a,b){a=new ColSq(a,this.getColor(b));this.hasSquare(a)?this.removeSquareMarker(a):this.addSquareMarker(a);this.getBoardControl().redraw()}addSquareMarker(a){var b=this.getGame().getAnno(AnnoType.SQUARE_LIST)||new ColSqAnno;b.push(a);this.getGame().setAnno(AnnoType.SQUARE_LIST,b)}removeSquareMarker(a){var b=this.getGame().getAnno(AnnoType.SQUARE_LIST)||new ColSqAnno;b.removeIf(c=>this.isSameSquare(c,
4273a));this.getGame().setAnno(AnnoType.SQUARE_LIST,b)}hasSquare(a){return(this.getGame().getAnno(AnnoType.SQUARE_LIST)||new ColSqAnno).some(b=>this.isSameSquare(b,a))}isSameSquare(a,b){return a.field==b.field}getColor(a){return a.altKey&&!a.shiftKey?a.ctrlKey?BoardColor.YELLOW:BoardColor.GREEN:BoardColor.RED}}
4274class ShowHintsBoardHandler extends BoardHandler{constructor(a,b,c,d){super(a,b);this.squareFrom=this.sqClicked=null;this.attributes=[];this.fnGetPlayingMode=c;this.clickHintTimer=new Timer;this.timeout=d||1E3;this.addLineListener()}addLineListener(){this.idOnLine=0;glApp.analysisEngine&&(this.idOnLine=glApp.analysisEngine.addOnLineListener(this.onLineListener.bind(this)))}onLineListener(a,b,c){this.buttonDown&&null!=this.squareFrom&&this.squareFrom==this.moveSq&&this.fired&&(a=this.hideCurrPiece(),
4275this.markedSqsOnButtonDown&&this.markedSqsOnButtonDown.length&&this.remove(),this.fnGetPlayingMode()&&(this.markedSqsOnButtonDown=this.fnGetPlayingMode().getMarkedSquaresOnButtonDown(this.moveSq,!0)))&&(LOG("ShowHints, lineListener..."),b=this.markedSqsOnButtonDown.map(d=>new BoardColouredSquare(d.sq,d.clr)),this.getBoardControl().addAttributes(b,0),this.attributes=b,a&&this.unHideCurrPiece())}onMouseDown(a,b){this.buttonDown=!0;this.squareFrom=this.getSquare(b);this.startClickHintTimer(this.squareFrom,
4276this.timeout)}onMouseUp(a,b,c){this.buttonDown=!1;this.stopClickHintTimer();this.remove();delete this.squareFrom;this.fired=!1}onMouseMove(a,b,c){this.moveSq=this.getSquare(b);this.getBoardControl().currPiece&&this.moveSq!=this.squareFrom&&this.stopClickHintTimer()}remove(){this.getBoardControl().removeAttributes(this.attributes);this.attributes=[]}startClickHintTimer(a,b){this.clickHintTimer.runOnce(b||1E3,function(){this.fired=!0;if(this.fnGetPlayingMode()){var c=this.markedSqsOnButtonDown=this.fnGetPlayingMode().getMarkedSquaresOnButtonDown(a,
4277!0);if(c&&c.length){var d=this.hideCurrPiece();c=c.map(e=>new BoardColouredSquare(e.sq,e.clr));this.getBoardControl().addAttributes(c,0);this.attributes=c;this.fnGetPlayingMode().notifyHinted&&this.fnGetPlayingMode().notifyHinted();d&&this.unHideCurrPiece()}else this.idOnLine||this.addLineListener()}}.bind(this))}stopClickHintTimer(){this.clickHintTimer.stop()}}
4278class MousePointerHandler extends BoardHandler{constructor(a,b){super(a,b)}onMouseMove(a,b){var c=this.getSquare(b);b=!1;0<=c&&(c=this.getBoard().get(c),c===Piece.NONE||!this.getMoveEntry()||this.getMoveEntry().getMySide()!=Piece.side(c)&&null!==this.getMoveEntry().getMySide()||
4278(a.target.style.cursor=this.busy?"wait":"pointer",b=!0));b||(a.target.style.cursor=this.busy?"wait":"default")}}
4279class SelectBoardHandler extends BoardHandler{constructor(a,b){super(a,b)}onMouseDown(a,b){void 0!==this.getBoardControl().fnBoardClick&&this.getBoardControl().fnBoardClick(this.getBoardControl().uniqueId,this.getClickPos(b),a)}}class CallBoardControlClickHandler extends SquareClickedBoardHandler{onSquareClick(a,b){b=this.getBoardControl();b.clickHandler&&b.clickHandler(a)}}"use strict";
4280var ClockElement=function(){var a=function(b,c){this.colorActive=glApp.config.clrActiveClock;this.colorActiveNormal=new CBColor(220,250,190);this.colorActiveEmphasize=new CBColor(50,110,0);this.colorInactive=new CBColor(140,140,100);this.colorFinished=this.colorActive;this.background=new DivElement(b,"clockBG");this.textWhite=new DivElement(this.background,"clockW");this.textBlack=new DivElement(this.background,"clockB");this.textWhite.setBoxSizing("border-box");this.textBlack.setBoxSizing("border-box");
4281this.config=c?c:{border:1,borderClr:"hsla( 0, 0%, 0%, 0.5 )"};this.initText(this.textWhite);this.initText(this.textBlack);this.displayCentiSecs=!1;this.displayHours=!0;this.textWhite.setText("0:00:00");this.textBlack.setText("0:00:00");this.timerToMove=new Timer(this.stopEmphasizeToMove.bind(this));this.runningClockId=0};a.prototype.destroy=function(){this.background.destroy()};a.prototype.setDisplayCentiSecs=function(b){this.displayCentiSecs=b};a.prototype.setDisplayHours=function(b){this.displayHours=
4282b};a.prototype.setText=function(b,c){c?this.textBlack.setText(b):this.textWhite.setText(b)};a.prototype.setTextWhite=function(b){this.textWhite.setText(b)};a.prototype.setTextBlack=function(b){this.textBlack.setText(b)};a.prototype.setVisible=function(b){this.background.setVisible(b)};a.prototype.initText=function(b){b.setBackgroundColor(new CBColor(0,0,0,.5));b.setColor(new CBColor(255,255,255,.9));b.setBorder(this.config.border,this.config.borderClr);b.setTextAlign("center");b.setFontFamily(glApp.config.defaultFont);
4283b.elDOM.addEventListener("mousedown",function(c){c.preventDefault()})};a.prototype.setPosSize=function(b,c,d,e){var f=new CBRect(0,0,Math.round(d/2),e-1),g=new CBRect(Math.round(d/2),0,d,e-1);this.background.setPos(b,c);this.background.setSize(d,e);this.textWhite.setPos(f.left,f.top);this.textWhite.setSize(f.getSize().w,f.getSize().h);this.textBlack.setPos(g.left,g.top);this.textBlack.setSize(g.getSize().w,g.getSize().h);b=Math.round(.7*e);do this.textWhite.setFontSize(b),this.textBlack.setFontSize(b),
4284--b,this.textWhite.setVerticalAlign((f.h-b)/2+2),this.textBlack.setVerticalAlign((f.h-b)/2+1);while(3<b&&(this.textWhite.getTextWidth()>f.w-5||this.textWhite.getTextHeight()>f.h-2));d=Math.max(1,Math.min(4,Math.round(Math.sqrt(d/100))));this.background.setBoxShadow(d,5*d,"rgba( 60, 30, 20, 0.6 )")};a.prototype.showResult=function(b){this.textWhite.setText(lm.RESULT+":");b==GameResultEnum.UNDEFINED_RESULT?this.textBlack.setText(lm.ABORTED):this.textBlack.setText(GameResultEnum.toString(b));this.textWhite.setColor(this.colorFinished);
4285this.textBlack.setColor(this.colorFinished)};a.prototype.showTimeOverstepped=function(b){this.textWhite.setText("TIME")};a.prototype.setToMove=function(b){b?(this.textWhite.setColor(this.colorInactive),this.textBlack.setColor(this.colorActive)):(this.textWhite.setColor(this.colorActive),this.textBlack.setColor(this.colorInactive))};a.prototype.showRestTime=function(b,c){b=this.getTimeString(b);c?this.textBlack.setText(b):this.textWhite.setText(b)};a.prototype.showCurrTime=function(b,c){};a.prototype.setRunsForward=
4286function(b){this.runsForward=b};a.prototype.emphasizeToMove=function(b){this.timerToMove.runOnce(b||8E3);this.textWhite.setBackgroundColor(this.colorActiveEmphasize);this.textBlack.setBackgroundColor(this.colorActiveEmphasize)};a.prototype.stopEmphasizeToMove=function(){this.textWhite.setBackgroundColor(new CBColor(0,0,0,.5));this.textBlack.setBackgroundColor(new CBColor(0,0,0,.5))};a.prototype.getTimeString=function(b){0>b&&(b=new Date(0));var c="";this.displayHours&&(c=b.getUTCHours()+":");if(4E3>
4287b.valueOf()&&!this.runsForward){var d=b.getUTCSeconds();b=Math.floor(b.getUTCMilliseconds()/100);1<b.toString().length&&(b="0");c=d+"."+b}else d=b.getUTCMinutes(),1==d.toString().length&&(d="0"+d),c+=d,d=Math.round(b.getUTCSeconds()),1==d.toString().length&&(d="0"+d),c+=":"+d;return c};a.prototype.flash=function(b){b?(this.textWhite.setText("GESTOPPT"),this.textBlack.setText("GESTOPPT"),$(this.textWhite.elDOM).addClass("blinkStoppedClock"),$(this.textBlack.elDOM).addClass("blinkStoppedClock")):($(this.textWhite.elDOM).removeClass("blinkStoppedClock"),
4288$(this.textBlack.elDOM).removeClass("blinkStoppedClock"))};return a}();"use strict";function LineStackItemHash(a){var b=a.getLine();a=a.getMovesToGo()|b.length<<8;0<b.length&&b[0]&&(a|=b[0].from<<16|b[0].to<<24);return a}function LineStackItemEq(a,b){return a.getLine()===b.getLine()&&a.getMovesToGo()===b.getMovesToGo()}
4289let cbNotationDefaults={game:null,useMatBalance:!0,useDiagrams:!0,useMedals:!0,useResult:!0,useColorMarkers:!0,useHeader:!0,moveClass:"",commentClass:"",resultClass:"",lineClass:"",colorMarkerClass:"",medalClass:"",isActive:!0,notationLocalization:null,setColorMarkersOnDiagrams:!0};function IsSpecialGlyph(a){return"\ue000"<=a}function IsSpecialGlyphCode(a){return 57344<=a}function OutText(a,b){b.append(a)}
4290function OutSpanText(a,b,c){b.append("<span class='");b.append(c);b.append("'>");b.append(a);b.append("</span>")}function EncodeGlyphs(a){for(var b="",c=0;c<a.length;
4290++c){var d=a.charCodeAt(c);b+=String.formatEx("&#{0};",d)}return b}
4291class NotaElement{static nInPageSeed=Math.floor(1048576*Math.random());constructor(a,b,c){NotaElement.initForListeners();this.nInPage=b;this.notaHeaderElement=new NotaHeaderElement(this.nInPage);this.notaFooterElement=new NotaFooterElement(this.nInPage,c);this.elementId=0;this.panel=a;this.gateUpdate=new V10;this.stopAtMoves=[];this.diagrams=[];this.reserveDiagrams=[];this.moveClassSelectors=[];this.height=0;this.m_selElem=this.m_ng=null;this.m_active=!0;this.m_lastClicked=this.m_game=null}initElem(a,
4292b){this.elementId=a="string"==typeof a?a:a.id;a=CBQ("#"+a);if(this.elem=a.single()){a.addClass("cbnota-container");this.precreateLayout();this._setOptions(b);this.scrollParent=CBQ(".nota-game",this.elem).single();a.on("dragover",this.onElementDragOver.bind(this)).on("dragenter",this.onElementDragEnter.bind(this)).on("drop",this.onElementDrop.bind(this)).on("mousewheel",this.onMouseWheel.bind(this)).on("DOMMouseScroll",this.onMouseWheel.bind(this));CBElement.isEventSupported("touchstart")&&(a.on("touchstart",
4293this.onButtonDown.bind(this)).on("touchend",this.onButtonUp.bind(this)).on("touchmove",this.onMouseMove.bind(this)).on("touchleave touchcancel",this.onMouseLeave.bind(this)),this.supportsTouch=!0);if(CBElement.isEventSupported("mousedown"))a.on("mousedown",this.onButtonDown.bind(this)).on("mouseup",this.onButtonUp.bind(this)).on("mousemove",this.onMouseMove.bind(this)).on("mouseleave",this.onMouseLeave.bind(this)).on("dblclick",this.onDoubleClick.bind(this));System.isSafari()&&$(".nota-game").css("padding-right",
4294"50px");this.headHolder=CBQ("#nota-head-"+this.nInPage).single();this.header=new DivElement(this.headHolder,this.getHeaderId(),{append:!1});this.header.setVisible(this.m_useHeader);this.m_useHeader||$(this.headHolder).hide();this.notaHeaderElement.initElem(this.getHeaderId(),b,null,this.nInPage);b.useMatBalance&&this.createMatBalance()}}hideHeader(){this.header.setVisible(!1);$(this.headHolder).hide()}destroy(){alert("NOTIMPL NotaEl")}createMatBalance(){if(null===CBQ.get(this.getFooterId())){var a=
4295CBQ.get(this.elementId);if(a){var b=CBQ("#nota-foot-"+this.nInPage).single();this.footer=new DivElement(b,this.getFooterId());this.footer.setVisible(!0);this.notaFooterElement.initElem(this.getFooterId())}}b=CBQ("#"+this.elementId);a&&b.removeClass("nomat")}getHeaderId(){return"theheader-"+this.nInPage}getFooterId(){return"thefooter-"+this.nInPage}destroyMatBalance(){var a=CBQ("#"+this.getFooterId()).single();a&&0<a.childNodes.length&&(a.removeChild(a.childNodes[0]),this.footer=null,CBQ("#"+this.elementId).addClass("nomat"))}setUseMatBalance(a){(this.useMatBalance=
4296a)?CBQ("#"+this.getFooterId()).show():CBQ("#"+this.getFooterId()).hide()}_setOptions(a){a.notationLocalization=a.notationLocalization||lm.NOTA_LOCALIZATION;this.m_ng=new NotationGenerator(a.notationLocalization);this.m_useDiagrams=a.useDiagrams;this.m_diagramOptions=void 0!==a.diagramOptions?a.diagramOptions:{};this.m_useHeader=a.useHeader;void 0!==a.useMatBalance&&(this.useMatBalance=a.useMatBalance);void 0!==a.useResult&&(this.m_useResult=a.useResult);this.m_active=a.isActive;this.m_options=a;a.game&&
4297this.setGame(a.game)}setOptions(a){this._setOptions(a)}setGame(a){this.notaHeaderElement.setGame(a);this.m_game&&(this.m_game.removeOnMoveListener(this.m_inxOnMove),this.m_game.removeOnNavigateListener(this.m_inxOnNavigate),this.m_game.removeOnChangedListener(this.m_inxOnChanged),this.m_game.removeOnHeaderChangedListener(this.m_inxOnHeaderChanged),this.m_game.removeOnAnnoChangedListener(this.m_inxOnAnnoChanged),this.m_game.removeOnEvalListener(this.m_inxOnEval));this.m_game=a;this.m_inxOnMove=this.m_game.addOnMoveListener(this.onMove.bind(this));
4298this.m_inxOnNavigate=this.m_game.addOnNavigateListener(b=>this.onNavigate(!1));this.m_inxOnChanged=this.m_game.addOnChangedListener(this.onChanged.bind(this));this.m_inxOnHeaderChanged=this.m_game.addOnHeaderChangedListener(this.onHeaderChanged.bind(this));this.m_inxOnAnnoChanged=this.m_game.addOnAnnoChangedListener(this.onChanged.bind(this));this.m_inxOnEval=this.m_game.addOnEvalListener(this.onEval.bind(this));this.initSubElements();
4298this.useMatBalance&&this.notaFooterElement.setGame(a);this.notaHeaderElement.setGame(a);
4299this.evProfileControl&&this.evProfileControl.setEvalArr(a.getEvaluationProfile())}setSize(a,b){this.height=b;this.notaHeaderElement.onResize(a,b);this.resizeDiagrams();this.resizeEvProfile(a,b);this.onNavigate(!0)}getGame(){return this.m_game}onMove(){this.initSubElements();this.markCurLine()}onHeaderChanged(){}onChanged(){this.initSubElements();this.markCurLine()}onEval(a,b,c){var d;Evaluation&&(d=Evaluation.getEvalString(b));this.evProfileControl||this.notaFooterElement.setText(d+".")}onHints(a){}onNavigate(a){a=
4300a||!1;var b=this.FindMoveElement();this.setSelItem(b,a);this.markCurLine();this.scheduleUpdate(this);this.evProfileControl&&this.evProfileControl.updateGame(this.m_game)}ResultToStr(a){return GameResultEnum.toString(a)}InitResult(a,b){(a=NotaElement.prototype.ResultToStr(a))&&OutSpanText(a,b,"cbgame-result")}scheduleUpdate(a){this.gateUpdate.exec(function(){a.matcontrol&&(a.matcontrol.setPos(a.m_game.getCurPos()),a.matcontrol.render())}.bind(this),200)}getLayoutHtml(){return String.formatEx("<div class='nota-container'><div class='nota-head-container'><div class='nota-head' id='nota-head-{0}'></div></div><div class='nota-game-container'><div class='nota-ogame'><div class='nota-igame'><div class='nota-game' data-inx-game='{0}'></div></div></div></div><div class='nota-foot-container'><div class='nota-foot' id='nota-foot-{0}'></div></div></div>",
4301this.nInPage)}precreateLayout(){CBQ(this.elem).html(this.getLayoutHtml());let a=getCommonPath()+"Media/Chess/WhiteMarbleBack.jpg";$(".nota-ogame").css("background-image",a);$(".nota-game").css("background-image",a);$(".cbline").css("background-image",a)}initSubElements(){this.diagrams&&this.diagrams.forEach&&this.diagrams.forEach(function(f){f.boardArea.changeParentElDOM(null)});this.reserveDiagrams=this.reserveDiagrams.concat(this.diagrams);this.diagrams=[];"undefined"==typeof this.m_game&&(this.m_game=
4302new Game);var a=new StringBuilder,b=this.m_game.getHeader(),c=this.m_game.getMainLine(),d=this.m_game.getStartPos().getMoveNum(),e={lineCnt:0,nodeCnt:0,breakForTraining:!1,foldCnt:0};if(this.bSuppressNotationForCMSI)e=new NotationGenerator,a=this.m_game.getCurPos().getMoveNum(),(b=this.m_game.getLastMove())?(e=e.getMoveNota(b,a),CBQ(".nota-game",this.elem).html(e)):CBQ(".nota-game",this.elem).html("Notation is hidden intentionally");else{NotaElement.initLine(this,c,0,0,d,0,a,e,0,0,0);this.m_useResult&&
4303!e.breakForTraining&&this.InitResult(b.getResult(),a);System.isMobile()&&this.createEmptyLines(a,2);CBQ(".nota-game",this.elem).html(a.toString());for(a=1;a<=e.foldCnt;a++)b=$("#fold"+a+this.nInPage),b.click(function(f){this.doOnFoldLine(f,function(g){g.toggle()})}.bind(this)),b.on("touchstart",function(f){this.doOnFoldLine(f,function(g){g.toggle()})}.bind(this)),b.on("fold",function(f){this.doOnFoldLine(f,function(g){g.hide()})}.bind(this)),b.on("unfold",function(f){this.doOnFoldLine(f,function(g){g.show()})}.bind(this));
4304this.afterInitDiagrams();(new Timer(function(){this.stopAtMoves&&0<this.stopAtMoves.length||this.createEvaluationProfile()}.bind(this))).runOnce(30);this.onNavigate(!0)}}createEmptyLines(a,b){for(let c=0;c<b;c++)OutText("<div class='nota-EmptyLine'></div>",a)}doOnFoldLine(a,b){var c=a.currentTarget.dataset.line,d=$(String.f(".cbmove[data-linecnt='{0}']:not([data-inx-mv='0'])",c));b(d);var e=$(String.f(".cbcomment[data-linecnt='{0}']",c));b(e);c=$(String.f("[data-linecnt-this='{0}']",c));b(c);d.length&&
4305(e=$(d[0]).parent().find(".cbcol-marker"),b(e));d.is(":visible")||c.is(":visible")?($(a.currentTarget).addClass("cbFoldBtn"),$(a.currentTarget).removeClass("cbUnFoldBtn"),$(a.currentTarget).parent().find(".cbUnFoldBtn").trigger("unfold")):($(a.currentTarget).addClass("cbUnFoldBtn"),$(a.currentTarget).removeClass("cbFoldBtn"))}static initLine(a,b,c,d,e,f,g,h,k,l,m){var n=++h.lineCnt,r=0;f||!b.isAnnotated()&&!b.hasAnno()||(r=1);0===f&&(a.useMatBalance?a.createMatBalance():a.destroyMatBalance());var t=
43060,u=0,x=0;b.hasAnno()&&b.getAnno()[AnnoType.PRETEXT]&&"["!=b.getAnno()[AnnoType.PRETEXT].toString()[0]&&(x+=b.getAnno()[AnnoType.PRETEXT].toString().length);if(b.hasAnno()&&b.getAnno()[AnnoType.JSONARRAY]){var B=b.getAnno()[AnnoType.JSONARRAY].getArray().filter(A=>"goal"===A.type).sum(A=>A.feedback.length);x+=B}b.forEach(function(A){A.forAllMoves(function(aa){t++;(aa=aa.getAnno())&&aa[AnnoType.POSTTEXT]&&(x+=aa[AnnoType.POSTTEXT].toString().length)});A.hasLines()&&u++});B=6>=f&&(10<t+x/8||1<m)&&(glApp.config.hasFolding||
4307a.m_options.hasFolding);if(1<=f&&B){B=(++h.foldCnt).toString()+a.nInPage.toString();var y=String.f("<span class='cbNodeBtn cbFoldBtn' data-line='{0}' data-level={2} id='{1}'></span>",n,"fold"+B,f)}g.appendFormat("<span class='cbline' data-inx-line='{0}' data-inx-mv-parent = '{1}' data-level='{2}' data-commented='{3}' data-linecnt-this='{4}' data-nodecnt-this='{5}' lastLine='{6}'>{7}",c,d,f,r,k,l,c===m-1?"1":"0",y);0===f&&a.createMovelessAnnoElement(b,g,h);if(!h.breakForTraining)for(c=!1,0<b.length&&
4308(c=b[0].getSide()===Side.WHITE),d=!0,k=0,B=b.length;k<B;++k){m=b[k];a.CreateMoveElements(m,k,b,e,c||d,f,g,h,n,l);if(h.breakForTraining)break;(c=!c)&&++e;d=m.hasLines()}g.append("</span>")}suppressNotationForCMSI(){this.bSuppressNotationForCMSI=!0;this.removeEvaluationProfile()}createMovelessAnnoElement(a,b,c){var d=a.getAnno();
4308if(d&&(d[AnnoType.POSTTEXT]||d[AnnoType.PRETEXT])){if(d[AnnoType.POSTTEXT]){var e=d[AnnoType.POSTTEXT].getString();this.createCommentElements(e,0,0,b,0)}d[AnnoType.PRETEXT]&&
4309(e=d[AnnoType.PRETEXT].getString(),"[#]"==e?this.createCommentElementsWithDiags(d[AnnoType.PRETEXT].getString(),0,a,d,!1,b,0):this.createCommentElements(e,0,0,b,0))}d&&d[AnnoType.TRAINING]&&(this.suppressDiagrams()||this.createDiagElements("Find the next move",0,a,d,!0,b,0,-1),c.breakForTraining=this.createTrainingElements(d[AnnoType.TRAINING],0,a,b,0,c))}static DIAG_CHAR="[#]";createCommentElementsWithDiags(a,b,c,d,e,f,g){if(a){if(0>a.indexOf(NotaElement.DIAG_CHAR))return this.createCommentElements(a,
4310b,c,f,g);var h=0;if(!this.suppressDiagrams())for(var k=a.indexOf(NotaElement.DIAG_CHAR);0<=k;k=a.indexOf(NotaElement.DIAG_CHAR,h))0<k-h&&(h=a.substring(h,k),this.createCommentElements(h,b,c,f,g)),this.wroteDiagram=this.createDiagElements("",b,c,d,e,f,g),h=k+NotaElement.DIAG_CHAR.length;h<a.length&&(h=a.substring(h),this.createCommentElements(h,b,c,f,g))}}suppressDiagrams(){return!1}createMedal(a,b,c,d,e){a&&(d.appendFormat("<span class='cbcomment cbmedal medal-{2}' data-inx-mv='{0}' data-linecnt='{1}'>",
4311b,e,a),d.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</span>"),d.append(" "))}createCommentElements(a,b,c,d,e){let f=c="";for(let g=0;g<a.length;g++){for(;g<a.length&&IsSpecialGlyph(a[g]);)c+=a[g],g++;c.length?(f+='<span class="cbspec-glyph">',f+=c,f+="</span>",c=""):f+=StrUtil.escapeHtmlEntities(a[g])}d.appendFormat("<span class='cbcomment' data-inx-mv='{0}' data-linecnt='{1}'>",b,e);d.append(f);d.append("</span>");d.append(" ")}static SOLUTION_HTML='<span class="cbTrainingLink cbTrainingSolution" data-inx-mv="{0}" data-linecnt="{1}">{2}</span>';static HELP_HTML='<span class="cbTrainingLink cbTrainingHelp" data-inx-mv="{0}" data-linecnt="{1}">{2}</span>';createTrainingElements(a,
4312b,c,d,e,f){c=Language.getStrUserLanguageTwoChars();d.appendFormat("<span class='cbcomment cbtraining' data-inx-mv='{0}' data-linecnt='{1}'>",b,e);d.append(StrUtil.escapeHtmlEntities(a.getQuestion(c)||lm.TRAINING_QUESTION));a.solved||(d.append('<div class="cbTrainingLinks">'),d.append(String.f(NotaElement.SOLUTION_HTML,b,e,lm.TRAINING_SOLUTION)),1<=a.nHelpClicked?(d.appendFormat("<span class='cbcomment cbtraining cbtraininghelptext' data-inx-mv='{0}' data-linecnt='{1}'>",b,e),d.append(StrUtil.escapeHtmlEntities(a.getHelp(c)||
4313"No help available")),d.append("</span>")):a.getHelp(c)&&d.append(String.f(NotaElement.HELP_HTML,b,e,lm.TRAINING_HELP)),d.append("</div>"),this.createEmptyLines(d,2));d.append("</span>");d.append(" ");return!a.solved}static CreateGlyphableText(a,b,c){if(a.length){for(var d=!0,e=0,f=a.length;e<f;++e)if(57344<=a.charCodeAt(e)){d=!1;break}if(d)OutText(a,b);else{d=!1;var g="";e=0;for(f=a.length;e<f;++e){var h=a[e],k="\ue000"<=h;k===d?g+=h:(d?OutSpanText(g,b,c):OutText(g,b),g=h,d=k)}g&&(d?OutSpanText(g,
4314b,c):OutText(g,b))}}}CreateGlyphableSpanText(a,b){b=document.createElement("span");NotaElement.CreateGlyphableText(a,b,"cbspec-glyph");return b}getMoveClasses(a){return this.moveClassSelectors.map(b=>b(a)).filter(IDENTITY).reduce((b,c)=>`${b} ${c}`,"")}CreateMoveElements(a,b,c,d,e,f,g,h,k,l){var m=a.getAnno();m&&m[AnnoType.PRETEXT]&&this.createCommentElementsWithDiags(m[AnnoType.PRETEXT].getString(),b,c,m,!1,g,k);var n=d;e||this.wroteDiagram||(n=null);this.wroteDiagram=!1;e=this.m_ng.getMoveNota(a,
4315n);n=`cbmove ${this.getMoveClasses(a)}`;if(m&&m[AnnoType.SYMBOL]){for(var r=m[AnnoType.SYMBOL],t=0;t<r.length;t++);e=Vz.addTexts(e,r)}0==b?g.appendFormat("<span class='"+n+"' data-inx-mv = '{0}' data-linecnt = '{1}' data-nodecnt = '{2}'>",b,k,l):g.appendFormat("<span class='"+n+"' data-inx-mv = '{0}' data-linecnt = '{1}'>",b,k);NotaElement.CreateGlyphableText(e,g,"cbspec-glyph");g.append("</span>");g.append(" ");m&&(m[AnnoType.SQUARE_LIST]||m[AnnoType.ARROW_LIST]?g.appendFormat("<span class='cbcol-marker' data-inx-mv='{0}'> </span>",
4316b):m[AnnoType.MOVE_MEDAL]&&g.appendFormat("<span class='cbmedal-marker' data-inx-mv='{0}'> </span>",b));g.append(" ");m&&m[AnnoType.TIME]&&this.createCommentElementsWithDiags(m[AnnoType.TIME].getString(),b,c,m,!0,g,k);m&&m[AnnoType.MOVE_MEDAL]&&this.createMedal(m[AnnoType.MOVE_MEDAL].getOneMedal(),b,c,g,k);m&&m[AnnoType.POSTTEXT]&&this.createCommentElementsWithDiags(m[AnnoType.POSTTEXT].getString(),b,c,m,!0,g,k);m&&m[AnnoType.JSONARRAY]&&(l=m[AnnoType.JSONARRAY].getArray().filter(u=>"goal"===u.type),
4317l.length&&this.createCommentElements(l[0].feedback,b,c,g,k));if(a.hasLines())for(a=a.getSubLines(),l=++h.nodeCnt,e=0,n=a.length;e<n;++e)NotaElement.initLine(this,a[e],e,b,d,f+1,g,h,k,l,n);m&&m[AnnoType.TRAINING]&&(this.suppressDiagrams()||this.createDiagElements("Find the next move",b,c,m,!0,g,k),h.breakForTraining=this.createTrainingElements(m[AnnoType.TRAINING],b,c,g,k,h));
4317m&&m[AnnoType.DIAGRAM]&&(d=m[AnnoType.DIAGRAM].getString(),this.createDiagElements(d,b,c,m,!0,g,k))}createDiagElements(a,b,
4318c,d,e,f,g,h){if(this.useDiagrams())return e||--b,e=b+1,h&&(e+=h),c=this.m_game.getLinePos(c,e),this.m_options.setColorMarkersOnDiagrams||(d=null),d=NotaElement.toFenEx(c,d),f.appendFormat("<span class='cbdia' data-fen='{0}' data-legend='{1}' data-inx-mv='{2}' data-linecnt='{3}'>",d,a,b,g),f.append("</span>"),!0}useDiagrams(){return 250>this.height&&0<this.height?!1:this.m_useDiagrams}static toFenEx(a,b){a=a.toFEN();b&&b[AnnoType.ARROW_LIST]&&(a=a+";"+b[AnnoType.ARROW_LIST].toString(";"));b&&b[AnnoType.SQUARE_LIST]&&
4319(a=a+";"+b[AnnoType.SQUARE_LIST].toString(";"));return a}static parseFenEx(a){a=a.split(";");for(var b=new Position(a[0]),c=new Annotation,d=new ColSqAnno,e=new ColArrowAnno,f=1,g=a.length;f<g;++f){var h=a[f];if(h.length==ColSq.STRING_LEN){var k=new ColSq;k.init(h);d.push(k)}else h.length==ColArrow.STRING_LEN&&(k=new ColArrow,k.init(h),e.push(k))}0<d.length&&c.setItem(AnnoType.SQUARE_LIST,d);0<e.length&&c.setItem(AnnoType.ARROW_LIST,e);return{anno:c,position:b}}removeClass(a){for(var b=Array.prototype.slice.call(document.getElementsByClassName(a)),
4320c=0,d=b.length;c<d;c++){var e=b[c];e.className=e.className.replace(new RegExp("(^|\\s+)"+a+"(\\s+|$)","g"),"$1")}}setSelItem(a,b){if(null!==a){this.m_selElem&&(CBQ(this.m_selElem).removeClass("cbcur-move"),this.m_selElem=null);var c=CBQ(this.elem);b||a?(this.m_selElem=a,CBQ(this.m_selElem).addClass("cbcur-move"),!NotaElement.clickInNotation&&this.m_selElem&&($(this.m_selElem).is(":visible")||$(this.m_selElem).parents().children(".cbNodeBtn").trigger("unfold"),this.isInPageVisible(this.m_selElem)||
4321b||this.scrollIntoView(this.m_selElem)),NotaElement.clickInNotation=!1):"scroll"!==c.css("overflow-y")&&window.scrollTo(c.getX(),c.getY())}}scrollCurElemIntoView(){if(this.m_selElem)return this.scrollIntoView(this.m_selElem)}blinkCurrElem(){this.blinkElem(this.m_selElem,"blinkShort")}blinkCurrElemMedium(){this.blinkElem(this.m_selElem,"blinkMedium")}blinkElem(a,b){a&&($(a).addClass(b),(new Timer(function(){$(b).removeClass(b)}.bind(this))).runOnce(600))}emphasizeMove(){this.scrollCurElemIntoView();
4322this.blinkElem(this.m_selElem,"blinkAnimation")}scrollIntoView(a){var b=CBRect.factory(this.scrollParent.getBoundingClientRect()),c=new CBRect(0,0,window.innerWidth,window.innerHeight);b=b.getCutAtBoundary(c);c=CBRect.factory(a.getBoundingClientRect());if(!b.isInside(c.left,c.top))if(a.scrollIntoView&&this.m_options.useScrollIntoView)a.scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"});else{b=a.offsetTop;a=b+a.offsetHeight;c=this.scrollParent.scrollTop;var d=this.scrollParent.clientHeight,
4323e=c+d,f=this.scrollParent.scrollTop;b<c?this.scrollParent.scrollTop=Math.max(0,b-30):a>e&&(this.scrollParent.scrollTop=a-d);b=Math.abs(this.scrollParent.scrollTop-f);300<b&&this.blinkCurrElem();return 0<b}}isInPageVisible(a){if(!this.isInViewport(a))return!1;var b=a.offsetTop;a=b+a.offsetHeight;var c=this.scrollParent.scrollTop,d=c+this.scrollParent.clientHeight;return b>=c&&a<=d}isInViewport(a){a=a.getBoundingClientRect();return 0<=a.top&&0<=a.left&&a.bottom<=document.documentElement.clientHeight&&
4324a.right<=document.documentElement.clientWidth}handleCursorDown(){var a=this.findMoveInAdjacentLine(this.m_selElem,!1);a&&(this.setSelItem(a),this.gameGotoElement(a))}handleCursorUp(){var a=this.findMoveInAdjacentLine(this.m_selElem,!0);a&&(this.setSelItem(a),this.gameGotoElement(a))}findMoveInAdjacentLine(a,b){if("undefined"!=typeof $&&a){a=$(a);var c=a.data("linecnt"),d=a.data("inx-mv");c=a.parent().find(String.f('[data-linecnt-this="{0}"][data-inx-mv-parent="{1}"]',c,d));if(c.length&&!b&&(d=$(c[0]).data("nodecnt-this"),
4325c=$(c[0]).find(String.f('[data-nodecnt="{0}"][data-inx-mv="0"]',d)),c.length))return c[0];var e=a.offset().top,f=[],g=1E7;c=function(h,k){h=$(k).offset().top-e;(b?0>h:0<h)&&Math.abs(h)<=g&&(g=Math.abs(h),f.push(k))};b?$($(this.elem).find(".cbmove").get().reverse()).each(c):$(this.elem).find(".cbmove, .cbtraininghelptext").each(c);f.sort(function(h,k){return Math.abs($(h).offset().top-e)-Math.abs($(k).offset().top-e)});for(c=1;c<f.length;c++)if(b){if($(f[c]).offset().top<$(f[0]).offset().top){f.length=
4326c;break}}else if($(f[c]).offset().top>$(f[0]).offset().top){f.length=c;break}a.offset();a.width();f.sort(function(h,k){return $(h).offset().left-$(k).offset().left});return f[0]}}findMoveInPrevLine(a,b){if("undefined"!=typeof $&&a){var c=null,d=1E7,e=0,f=$(a);$(a).prevAll().find(".cbmove").each(function(g,h){g=$(h).offset().top-f.offset().top;if(0>g){var k=Math.abs($(h).offset().left-f.offset().left);k<d&&(g==e||!c)&&(d=k,c=h,e=g)}}.bind(this));return c}}onMouseWheel(a){if(this.m_game&&this.m_active){var b=
4327"undefined"!=typeof a.wheelDelta?-a.wheelDelta:a.detail;"undefined"==typeof $&&(0>b?this.m_game.gotoPrev():this.m_game.gotoNext(),a.preventDefault())}}onButtonDown(a){this.ptTouchStart=this.ptTouchMove=new CBPoint(a);LOG("ButtonDown:"+this.ptTouchStart);this.buttonDown=!0;this.isTouch="touchstart"==a.type}static clickInNotation;onButtonUp(a){LOG("ButtonUp");this.buttonDown=!1;this.ptTouchMove&&2!=a.button&&10>this.ptTouchMove.getDist(this.ptTouchStart)&&(NotaElement.clickInNotation=!0,this.focus(),
4328this.onElementClick(a)&&this.fireOnMoveTouched())}onDoubleClick(a){this.m_game.fireOnNotaDoubleClick()}onContextMenu(a){this.onElementClick(a);glApp?.panelMgr?.execNotaContextMenu&&(glApp.panelMgr.execNotaContextMenu(a),a.preventDefault())}
4328focus(){glApp?.panelMgr?.notaPanel&&glApp.panelMgr.notaPanel.focus();var a=this.scrollParent;a?a.focus():alert("no parent for focus")}sign(a){return a?0>a?-1:1:0}static isIEDesk=0<System.getIEVersion()&&!System.isMobile();onMouseMove(a){if(this.buttonDown&&!NotaElement.isIEDesk){var b=
4329(new CBPoint(a)).subtract(this.ptTouchMove);b.y/=Math.min(2,window.devicePixelRatio);this.scrollParent.scrollTop-=this.sign(b.y)*Math.pow(Math.abs(b.y),1.7)*.7;this.ptTouchMove=new CBPoint(a);if(0<b.y&&0==this.scrollParent.scrollTop||0>b.y&&this.scrollParent.scrollTop+this.scrollParent.clientHeight>=this.scrollParent.scrollHeight)return}"touchmove"!=a.type&&a.preventDefault()}onMouseLeave(a){this.buttonDown=!1}onElementClick(a){if(!this.m_active||!this.m_game)return!1;var b=this.gameGotoElement(a.target,
4330!0);a.preventDefault();return b}gameGotoElement(a,b){var c=a;if(!$(c).is("[data-inx-mv]")&&((c=$(c).parents("[data-inx-mv]"))&&(c=c[0]),!c))return;this.m_lastClicked=c;var d=$(c).data("inx-mv"),e=0;++d;var f=[],g=!0,h=c.parentNode,k=!1,l=!1;$(h).is(".cbLine ")||(h=$(c).parents(".cbline")[0]);$(c).is(".cbTrainingLink")&&(k=$(c).is(".cbTrainingSolution"),l=$(c).is(".cbTrainingHelp"));for(c=h;g;c=c.parentNode)e=Number(e),d=Number(d),f.push({inxLine:e,mvsToGo:d}),c&&c.getAttribute&&(g=CBQ(c),e=g.data("inx-line"),
4331d=g.data("inx-mv-parent"),g=0!=g.data("level"));d=[];for(e=f.length-1;0<=e;--e)d.push(f[e]);this.m_game.gotoSimplePath(d);this.m_game.triggerOnClickInNotation(this.nInPage,{x:a.offsetLeft,y:a.offsetTop,w:this.scrollParent.clientWidth,t:this.scrollParent.offsetTop,b:this.scrollParent.offsetTop+this.scrollParent.clientHeight,l:this.scrollParent.getBoundingClientRect().left,r:this.scrollParent.offsetLeft+this.scrollParent.clientWidth,click:b});if(k||l)if(a=this.m_game.getAnno(AnnoType.TRAINING)){k&&
4332(a.solved=!0,LogStats("Solution: "+this.m_game.hdr.getStrPlayers(!1,0)));l&&a.nHelpClicked++;this.onChanged();k&&this.m_game.gotoNext();if(l)for(k=0;3>k;k++)this.handleCursorDown();this.scrollParent.scrollTop+=60}return!0}static maxCurLineClasses=6;markCurLine(){var a=this.m_selElem;if(a){var b=CBQ(a);if(!CBQ.is(a,"[data-inx-mv]")){a=b.parent("[data-inx-mv]");if(!a)return;b=CBQ(a)}var c=$("#"+this.elementId);this.clearCurLine(c);b=b.data("linecnt");1<b&&(c=c.find(String.formatEx('[data-linecnt="{0}"]',
4333b)),c.addClass("cbcurline"),this.markParentCurLine(c,0));this.markAlternatives($(a))}}clearCurLine(a){a.find(".cbcurAlternative").removeClass("cbcurAlternative");a.find(".cbcurline").removeClass("cbcurline");a.find(".cbcurlineparent").removeClass("cbcurlineparent");for(var b=1;b<=NotaElement.maxCurLineClasses;b++)a.find(".cbcurnode"+b).removeClass("cbcurnode"+b)}markParentCurLine(a,b){if(a.length&&(a=$(a[0]).parent("[data-inx-mv-parent]"))){var c=parseInt($(a).data("inx-mv-parent")),d=$(a).data("linecnt-this"),
4334e=$(a).data("nodecnt-this"),f=$(a).data("level");if(0<d){var g=$("#"+this.elementId);e=g.find(String.formatEx('[data-nodecnt="{0}"]',e));1<=e.length&&(f<NotaElement.maxCurLineClasses?e.addClass("cbcurnode"+f):e.addClass("cbcurnode"+NotaElement.maxCurLineClasses));d=String.formatEx('[data-linecnt="{0}"]',d);g=g.find(d);for(d=0;d<g.length;d++){e=$(g[d]);var h=parseInt(e.data("inx-mv"));h<=c&&1<f&&(h<=c-1?e.addClass("cbcurlineparent"):e.addClass("cbcurnode"+f))}this.markParentCurLine($(a),++b)}}}markAlternatives(a){var b=
4335a.data("linecnt"),c=a.data("inx-mv");a.parent().find(String.f('[data-linecnt-this="{0}"][data-inx-mv-parent="{1}"]',b,c)).each(function(d,e){d=$(e).data("nodecnt-this");$(e).find(String.f('[data-nodecnt="{0}"][data-inx-mv="0"]',d)).addClass("cbcurAlternative")})}FindMoveElement(){if(this.m_game){try{for(var a=this.m_game.getSimplePath(),b="",c=0,d=0,e=a.length;d<e;++d){b&&(b+=">");var f=a[d],g=f.mvsToGo;b+=String.formatEx("span.cbline[data-level='{2}'][data-inx-line='{0}'][data-inx-mv-parent='{1}']",
4336f.inxLine,c,d);d===e-1&&(b+=String.formatEx(">span.cbmove[data-inx-mv ='{0}']",Math.max(0,g-1)));c=g}var h=0==b.length;b=String.f("div.nota-game[data-inx-game='{0}']>",this.nInPage)+b;if(this.m_lastClicked&&CBQ.is(this.m_lastClicked,b))return this.m_lastClicked;if(!h){var k=CBQ(b);if(k&&1==k.length)return k[0]}}catch(l){console.log("Nota: "+l)}return null}}afterInitDiagrams(){if("undefined"!=typeof $&&glApp.panelMgr.createDiagramPlayingMode){var a=180;System.isMobile()&&(a=120);glApp.panelMgr.getDiagHeight&&
4337(a=glApp.panelMgr.getDiagHeight($(this.elem).width(),this.nInPage));var b=0;$("#"+this.elementId).find(".cbdia").each(function(c,d){this.m_diagramOptions.center&&$(d).css({marginLeft:"auto",marginRight:"auto"});if(0==$(d).find("div").length){$(d).width(1.1*a);$(d).height(a);var e=this.reserveDiagrams.pop();this.gameKernel=new GameKernel(glApp.panelMgr);var f={kernel:this.gameKernel,diagramDiv:d};f.kernel.setPlayingMode(glApp.panelMgr.createDiagramPlayingMode(f.kernel));f.kernel.fnInitGame=function(){return function(h,
4338k){k.boardWin&&(k.boardWin.allowInput=!1);h.reset();d&&(k=d.dataset.fen)&&(k=new Position(k),h.assign(new Game(k)))}}();var g=this.createDiv("diagarea",b);$(g).width(a);$(g).height(a);d.appendChild(g);e?(f.boardArea=e.boardArea,f.boardArea.changeParentElDOM(g),f.kernel.setBoardWin(f.boardArea.canvas.control.boards[0]),f.kernel.initGame()):(f.boardArea=new CanvasParent(g),f.boardArea.createCanvas(f.kernel,{topDist:1,bottomDist:1,marginDistDivisor:40,shiftXPercent:-1.65,minWForCoordinates:700,transparent:!0,
4339boardShadow:!1}),f.kernel.releaseCommandHandlers());f.boardArea.setSize(g.offsetWidth,g.offsetHeight);f.boardArea.setVisible(!0);this.diagrams.push(f);this.resizeDiagram(d,c);b++}}.bind(this))}}resizeDiagrams(){"undefined"!=typeof $&&$("#"+this.elementId).find(".cbdia").each(function(a,b){this.resizeDiagram(b,a)}.bind(this))}resizeDiagram(a,b){if(a&&"undefined"!=typeof $){var c=$(a).find("#diagarea"+b)[0],d=$(a).width();a=$(a).height();c&&this.diagrams[b]&&this.diagrams[b].boardArea&&this.diagrams[b].boardArea.setSize(d-
43401,a)}}static minHeightForEv=400;static idEvProf="idEvCanvas";createEvaluationProfile(){if(EvalProfileControl){var a=this.m_game.getEvaluationProfile();if(a&&a.isValid()){if(!$(`#${NotaElement.idEvProf}-${this.nInPage}`).length){let e=$("#"+this.elementId);var b=e.find(".nota-game"),c=b.height();0==c&&(c=e.height());var d=document.createElement("div");d.id=NotaElement.idEvProf+"-"+this.nInPage;
4340d.className="cbevprofile";$(d);450<System.zoomToPix(c)||System.isMobile()&&System.isPortraitScreen()||900<
4341window.innerHeight?($(d).insertBefore(e.find(".nota-foot-container")),d.style.margin="0",d.style.boxShadow=""):b.append(d);if(0==$(d).length)return;b=EvalProfileControl.createEvaluationCanvas(d,this.jumpToEvProfileMove.bind(this));this.evProfileControl=b.control;this.evCanvas=b.evCanvas;c<NotaElement.minHeightForEv?$(d).hide():($(d).show(),$(this.elem).find(".nota-EmptyLine").hide());this.evProfileControl&&this.evCanvas&&this.evCanvas.setSize(this.setEvCanvasWidth,this.getEvProfileHeight())}this.evProfileControl&&
4342this.evProfileControl.setEvalArr(a)}else this.evProfileControl&&this.evProfileControl.reset()}}jumpToEvProfileMove(a){this.m_game.gotoIndex(Math.min(a,this.m_game.mainLine.length));this.isInPageVisible(this.m_selElem)||this.scrollIntoView(this.m_selElem)}removeEvaluationProfile(){var a=$("#idEvCanvas-"+this.nInPage);a&&a.remove();delete this.evProfileControl}getEvProfileHeight(){var a=66;1150<window.innerHeight?a=80:800>window.innerHeight&&(a=600>window.innerHeight?40:55);return a}resizeEvProfile(a,
4343b){this.setEvCanvasWidth=a-26;a=$("#idEvCanvas-"+this.nInPage);b<NotaElement.minHeightForEv?(a.hide(),$(this.elem).find(".nota-EmptyLine").show()):(a.show(),$(this.elem).find(".nota-EmptyLine").hide());b=a.width();this.evCanvas&&(this.evCanvas.setSize(b,this.getEvProfileHeight()),this.setEvCanvasWidth=b)}createDiv(a,b){var c=document.createElement("div");c.id=a+b;c.className=a;return c}isActive(){return this.m_active}setActive(a){this.m_active=a}onElementDragOver(a){a.preventDefault()}onElementDragEnter(a){a.preventDefault()}onElementDrop(a){LOG("Drop:"+
4344a.dataTransfer);if(this.m_active){a.preventDefault();a=a.dataTransfer;var b=a.files;b.length?this.fromPGNFile(b[0]):(a=a.getData("text"))&&this.loadPGN(a)}}refoldToCurrentLine(){0==$(this.elem).find(".cbNodeBtn").length&&(this.initSubElements(),this.markCurLine());if(this.m_selElem){var a=$(this.m_selElem).parents().children(".cbNodeBtn");$(this.elem).find(".cbNodeBtn").not(a).each(function(b,c){$(c).trigger("fold")})}this.scrollCurElemIntoView()}unfoldAll(){glApp.config.hasFolding=!0;var a=$(this.elem).find(".cbNodeBtn");
43450==a.length?(this.initSubElements(),this.markCurLine(),a=$(this.elem).find(".cbNodeBtn"),a.each(function(b,c){$(c).trigger("fold")})):$(".cbmove:hidden")[0]?a.length&&a.each(function(b,c){$(c).trigger("unfold")}):$(".cbNodeBtn").remove();this.scrollCurElemIntoView()}fromPGNFile(a){if("function"==typeof FileReader){var b=new FileReader;b.onloadend=function(){this.pgnLoadDone(b)}.bind(this);b.readAsText(a)}}pgnLoadDone(a){this.loadPGN(a.result)}loadPGN(a){this.m_game.merge&&this.m_game.merge(PGN.parseGame(a))}static initForListeners(){NotaElement.listenersInited||
4346(Vk.initForListeners(NotaElement),Vk.addEvent(NotaElement,"MoveTouched"),NotaElement.listenersInited=!0)}static factory(a,b,c,d,e){b=new NotaElement(b,d||0,e);null==c&&(c=cbNotationDefaults,c.useMatBalance=glApp.panelMgr.useMatBalanceDefault());b.initElem(a,c);glApp.panelMgr&&(glApp.panelMgr.notaElement=b);return b}}"use strict";var NATION_FORMAT="Flags{0}/{1}.png",COUNTRY_FORMAT="<img src='{1}' alt='' height='{0}' width='{0}' style='vertical-align: {2};border:none;box-shadow:none' >";
4347class NotaHeaderElement{static pbCache={};constructor(a){this.m_selElem=this.m_ng=this.panel=this.playerDataSource=null;this.m_active=!0;this.m_game=null;this.arrPlayer=[null,null];this.arrPortrait=[null,null];this.w=500;this.h=400;this.elementId=0;this.gateUpdate=new V10;this.EMPTY_PERSON=glApp.mediaPath+"Buttons/Person.jpg";this.EMPTY_UNO=glApp.mediaPathFlags+"Flags16/United nations.png";this.requestedBlack=this.requestedWhite="";this.nInPage=a;this.titleText="";this.PERSON_FORMAT="<a href='http://pbserver.chessbase.com/Player?name={4},{5}&year={6}&ref=JSReader' target='_blank'><img class = 'cbplayerimage' src='{0}' alt='{4}' height='{2}' width='{3}'  playid='{1}' ></a>";
4348glApp.config.playerPicLink&&(this.PERSON_FORMAT="<a href='http://play.chessbase.com/user/{4}' target='_blank'><img class = 'cbplayerimage' src='{0}'height='{2}' width='{3}' playid='{1}' ></a>")}isCompact(a,b){return 400>a||320>b}isMoreCompact(a,b){return 300>a||150>b&&500>a}isVeryCompact(a,b){return this.m_options.smallHeader?!0:290>a||130>b&&360>a||80>b}isTiny(a,b){return 220>a||90>b&&300>a||70>b}isPracticallyInvisible(a,b){return 140>a||70>b}usePlayerBase(){return!this.isVeryCompact(this.w,this.h)}resetPlayerCache(){}initTemplates(a,
4349b){this.w=a;this.h=b;if(this.titleText)if(a=[].concat(this.titleText),this.titleIcon){b=String.formatEx(NotaHeaderElement.TITLE_PIC_FORMAT,this.titleIcon);var c='<div class="cbgame-header" id="ourheaderinside" ><table class="scroll notaTable" id="ourheader"><tr><td width="0%"><span class="cbplayerportrait">'+b+'</span></td><td width="0%"><span class="cbnota-title">'+a[0]+'</span></td><td width="0%"><span class="cbplayerportrait">'+b+"</span></td></tr>";for(b=1;b<a.length;b++)c+='<tr>
4349<td width="100%" colspan="3"><span class="cbnota-subtitle">'+
4350a[b]+"</span></td></tr>";c+="</table></div>"}else c='<div class="cbgame-header" id="ourheaderinside" ><span class="cbnota-title">'+this.titleText+"</span></div>";else c=this.isPracticallyInvisible(a,b)?'<div class="cbgame-header-tiny" id="ourheaderinside"  style="visibility:hidden;display:none;" ></div>':this.isTiny(a,b)?'<div class="cbgame-header-tiny" id="ourheaderinside" ><table class="notaTable" id="ourheader"><tr><span class="cbmain-header-verycompact"><td width="45%" class="cbplayerwhite"><span class="cbplayertiny">{white.list}</span></td><td width="10%" class="cbresult"><span >{resultStr}</span></td><td width="45%" class="cbplayerblack"><span class="cbplayertiny">{black.list}</span></td></tr></table></div>':
4351this.isVeryCompact(a,b)?'<div class="cbgame-header-verycompact" id="ourheaderinside" ><table class="notaTable" id="ourheader"><tr><span class="cbmain-header-verycompact"><td width="45%" class="cbplayerwhite"><span class="cbplayer">{white.list}</span><span class="cbelocompact">{eloWhStr}</span></td><td width="10%" class="cbresult"><span >{resultStr}</span></td><td width="45%" class="cbplayerblack"><span class="cbplayer">{black.list}</span><span class="cbelocompact">{eloBlStr}</span></td></tr></table></div>':
4352this.isMoreCompact(a,b)?'<div class="cbgame-header-morecompact" id="ourheaderinside" ><table class="scroll notaTable" style="table-layout:fixed" id="ourheader"><tr><span class="cbmain-header"><td colspan="2"class="cbflagwhite-morecompact"><span class="cbplayernation">{country[0]}</span></td><td colspan="9" class="cbplayerwhite"><span class="cbplayer" >{white.list}</span><span class="cbelocompact">{eloWhStr}</span></td><td colspan="2" class="cbresult"><span >{resultStr}</span></td><td colspan="9"  class="cbplayerblack"><span class="cbplayer">{black.list}</span><span class="cbelocompact">{eloBlStr}</span></td><td colspan="2" class="cbflagblack-morecompact"><span class="cbplayernation">{country[1]}</span></td></tr></table></div>':
4353this.isCompact(a,b)||System.isMobile()?'<div class="cbgame-header-compact" id="ourheaderinside" ><table class="scroll notaTable" style="table-layout:fixed" id="ourheader"><tr><span class="cbmain-header"><td colspan="9"class="cbplayerwhite"><span class="cbplayer" >{white.list}</span><span class="cbelocompact">{eloWhStr}</span></td><td colspan="2" class="cbresult"><span >{resultStr}</span></td><td colspan="9"  class="cbplayerblack"><span class="cbplayer">{black.list}</span><span class="cbelocompact">{eloBlStr}</span></td></tr><tr><td colspan="2" class="cbflagwhite"><span class="cbplayernation">{country[0]}</span></td><td colspan="1" class="cbfide cbfidecompact"><span>{titleWhStr}</span></td><td colspan="14" style="text-align:center"><span class="cbevent">{event.event}</span><span class="cbeventdate">{dateYear}</span></td><td colspan="1" class="cbfide cbfidecompact"><span>{titleBlStr}</span></td><td colspan="2" class="cbflagblack"><span class="cbplayernation">{country[1]}</span></td></tr></table></div>':
4354'<div class="cbgame-header" id="ourheaderinside" ><table class="scroll notaTable" id="ourheader" style="table-layout:fixed" ><tr><span class="cbmain-header"><td  class="cbplayerportrait" colspan="3" rowspan="2"><span >{portrait[0]}</span></td><td class="cbplayerwhite" colspan="8"><span class="cbplayer">{white.full}</span><span class="cbelo">{eloWhStr}</span></td><td colspan="2" class="cbresult"><span >{resultStr}</span></td><td class="cbplayerblack" colspan="8"><span class="cbplayer">{black.full}</span><span class="cbelo">{eloBlStr}</span></td><td class="cbplayerportrait" colspan="3" rowspan="2"><span>{portrait[1]}</span></td></tr><tr><td colspan="2" class="cbflagwhite" ><span class="cbplayernation">{country[0]}</span></td><td colspan="1" class="cbfide"><span>{titleWhStr}</span></td><td colspan="12" class="cbtourndata"><span class="cbevent">{event.event}</span><br/><span class="cbsite">{uniquePlace}</span><span class="cbeventdate">{dateStr}</span><span class="cbannotator">{annotatorStr}</span></td><td colspan="1" class="cbfide"><span>{titleBlStr}</span></td><td colspan="2" class="cbflagblack"<span class="cbplayernation">{country[1]}</span></td></tr></table></div>';
4355this.headerTemplate=function(){return String.formatEx(c,this)}}static EMPTY_PIC_FORMAT="<img src='{0}' alt='' height='24' width='24' style='display:none'>";static TITLE_PIC_FORMAT="<img src='{0}' alt='' height='24' width='24'>";static EMPTY_FLAG_FORMAT="<img src='{0}' alt='' height='16' width='16'>";InitEmptyHeader(a){a=a||new GameHeader;this.hdrItem=ObjUtil.clone(a);this.hdrItem.resultStr=NotaHeaderElement.ResultToStr(this.hdrItem.getResult());this.hdrItem.portrait=[null,null];this.hdrItem.country=
4356[null,null];this.hdrItem.geoIpNation=[0,0];this.hdrItem.title=[null,null];a.nationWhite&&(this.hdrItem.geoIpNation[0]=a.nationWhite);a.nationBlack&&(this.hdrItem.geoIpNation[1]=a.nationBlack);return this.headerTemplate&&this.headerTemplate.apply?this.headerTemplate.apply(this.hdrItem):" --- "}InitHeader(a,b){this.displayOpening("");try{-1==this.hdrItem.event.event.search(this.hdrItem.event.site)&&(this.hdrItem.uniquePlace=this.hdrItem.event.site)}catch(c){}-1!==this.hdrItem.annotator.search("Robot")&&
4357(this.hdrItem.annotator="");this.usePlayerBase()&&a&&(this.displayOpening(a.eco),this.hdrItem.eloWhStr=0<a.eloWh?a.eloWh:"",this.hdrItem.eloBl
4357Str=0<a.eloWh?a.eloBl:"",this.hdrItem.annotatorStr=a.annotator?"["+a.annotator+"]":"","[ChessBase]"==this.hdrItem.annotatorStr&&(this.hdrItem.annotatorStr=""),a.date.year&&(this.hdrItem.dateStr=a.date.toLocaleString(),this.hdrItem.dateYear=a.date.year),this.prepareHeader(this.hdrItem),this.requestPlayerBase(),this.hdrItem.titleWhStr=this.getTitleStr(this.hdrItem,
43580),this.hdrItem.titleBlStr=this.getTitleStr(this.hdrItem,1),this.bRequestPlayerBase=!1);if(b){if(this.headerTemplate&&this.headerTemplate.apply)return this.headerTemplate.apply(this.hdrItem)}else if(this.headerInsideTemplate.apply)return this.headerInsideTemplate.apply(this.hdrItem);return a?a.toString():null}getTitleStr(a,b){if(a.title&&CBTitle)return CBTitle.getStr(a.title[b])}requestPlayerBase(){if(LoginMode){var a=!1,b=this.hdrItem.getBlackKey();b=[this.hdrItem.getWhiteKey(),b];for(var c=Side.WHITE;c<=
4359Side.BLACK;++c){var d=NotaHeaderElement.pbCache[b[c]];d&&d.answered?(this.hdrItem.country[c]=d["country"+this.getFlagSize()],this.hdrItem.title[c]=d.title,c==Side.WHITE?this.requestedWhite=this.hdrItem.white:this.requestedBlack=this.hdrItem.black):(this.hdrItem.geoIpNation[c]?(a=new Nation(this.hdrItem.geoIpNation[c]),this.setHdrItemCountry(b[c],a,c)):this.hdrItem.country[c]=String.formatEx(NotaHeaderElement.EMPTY_FLAG_FORMAT,this.EMPTY_UNO),a=this.bRequestPlayerBase&&(!d||!d.requested));if(d&&d.answered){let e=
4360this.getPortraitSize();" "==this.hdrItem.country[c]&&(e=this.rasterPortraitToFlagSize(e));this.hdrItem.portrait[c]=d["portrait"+e];!this.hdrItem.portrait[c]&&d.portrait32&&(this.hdrItem.portrait[c]=d.portrait32)}else this.hdrItem.portrait[c]=String.formatEx(NotaHeaderElement.EMPTY_PIC_FORMAT,this.EMPTY_PERSON)}a&&this.gateUpdate.exec(function(){this.requestPlayerData()}.bind(this),500)}}rasterPortraitToFlagSize(a){return 34==a||40==a?32:64<a?64:a}prepareHeader(a){a.white.last=a.white.last.replace("-",
4361" ");a.black.last=a.black.last.replace("-"," ");var b=a.white.first.search(/\./);0<b&&a.white.first&&(a.white.first=a.white.first.slice(0,b));b=a.black.first.search(/\./);0<b&&a.black.first&&(a.black.first=a.black.first.slice(0,b));a.getWhiteKey=function(){var c=this.white.last;this.white.first&&(c+=this.white.first.slice(0,2));return c};a.getBlackKey=function(){var c=this.black.last;this.black.first&&(c+=this.black.first.slice(0,2));return c}}requestPlayerData(){var a=this.m_game.getHeader();this.prepareHeader(a);
4362var b=function(){if(glApp.playerLobby){this.requestedWhite=a.getWhite();this.requestedBlack=a.getBlack();var c=a.date.getYear();c||=CBDate.getThisYear();a.white.last&&(glApp.playerLobby.getPlayer(a.white.first,a.white.last,a.eloWh,c,this.onWhite.bind(this)),NotaHeaderElement.pbCache[a.getWhiteKey()]||(NotaHeaderElement.pbCache[a.getWhiteKey()]={}),NotaHeaderElement.pbCache[a.getWhiteKey()].requested=!0);a.black.last&&(glApp.playerLobby.getPlayer(a.black.first,a.black.last,a.eloBl,c,this.onBlack.bind(this)),
4363NotaHeaderElement.pbCache[a.getBlackKey()]||(NotaHeaderElement.pbCache[a.getBlackKey()]={}),NotaHeaderElement.pbCache[a.getBlackKey()].requested=!0)}else console.log("NoPB: "+a.white.last+"-"+a.black.last)}.bind(this);glApp.playerLobby?b():(new Timer(b)).runOnce(4E3)}_onPlayer(a,b){if(a&&a.player){var c=a.player.getFirstName(),d=a.player.getLastName(),e=this.buildCacheKey(d,c);NotaHeaderElement.pbCache[e]||(NotaHeaderElement.pbCache[e]={});NotaHeaderElement.pbCache[e].answered=!0;var f=a.player,g=
4364new Nation(0);this.arrPlayer[b]=f;f.m_NewCBPlayer&&(g=f.m_NewCBPlayer.m_HighData.m_aNation,g=new Nation(g),f=f.m_NewCBPlayer.m_HighData.m_aTitle,this.hdrItem.title[b]=f,NotaHeaderElement.pbCache[e].title=f,this.hdrItem.geoIpNation[b]||this.setHdrItemCountry(e,g,b));f=a.pic;a=[34,40,48,64,80,100,120];f&&f.length?(this.arrPortrait[b]="string"===typeof f?f:NotaHeaderElement.constructImageFromData(f),a.forEach(function(h){var k=this.hdrItem.date.year;k||=CBDate.getThisYear();k=String.formatEx(this.PERSON_FORMAT,
4365this.arrPortrait[b],b,h*Math.SQRT2,h,d,c,k);h==this.getPortraitSize()&&(this.hdrItem.portrait[b]=k);NotaHeaderElement.pbCache[e]["portrait"+h]=k;NotaHeaderElement.pbCache[e]["picData"+h]=this.arrPortrait[b]}.bind(this))):(this.isCompact(this.w,this.h)||this.isMoreCompact(this.w,this.h)||(f=this.getPortraitSize(),f=this.rasterPortraitToFlagSize(f),g=glApp.mediaPathFlags+String.formatEx(NATION_FORMAT,f,g.getStrFlag()),g=String.formatEx(COUNTRY_FORMAT,f,g,"top"),this.hdrItem.portrait[b]=NotaHeaderElement.pbCache[e]["portrait"+
4366f]=g,this.hdrItem.country[b]="",this.getFlagRaster().forEach(function(h){this.hdrItem.country[b]=" ";NotaHeaderElement.pbCache[e]["country"+h]=" "}.bind(this))),a.forEach(function(h){NotaHeaderElement.pbCache[e]["picData"+h]=this.arrPortrait[b]?this.arrPortrait[b]:this.EMPTY_PERSON;NotaHeaderElement.pbCache[e].nopic=!0}.bind(this)))}}buildCacheKey(a,b){if(b){var c=b.charAt(b.length-1);"0"<=c&&"9">=c&&(b=b.slice(0,b.length-1));a+=b.slice(0,2)}return a}getFlagAndPic(a){a=this.buildCacheKey(a.last,a.first);
4367return NotaHeaderElement.pbCache[a]?{flag:NotaHeaderElement.pbCache[a].country48,pic:NotaHeaderElement.pbCache[a].picData64,nopic:NotaHeaderElement.pbCache[a].nopic,title:CBTitle.getStr(NotaHeaderElement.pbCache[a].title),flagPath:NotaHeaderElement.pbCache[a].flagPath64}:{flag:"United Nations"}}setHdrItemCountry(a,b,c){if(b&&a&&(0==c||1==c)&&b.getStrFlag){var d=this.getFlagRaster();NotaHeaderElement.pbCache[a]||(NotaHeaderElement.pbCache[a]={});d.forEach(function(e){var f=glApp.mediaPathFlags+String.formatEx(NATION_FORMAT,
4368e,b.getStrFlag());var g=String.formatEx(COUNTRY_FORMAT,e,f,"middle");e==this.getFlagSize()&&(this.EMPTY_UNO=glApp.mediaPathFlags+String.formatEx("Flags{0}/United nations.png",e),this.hdrItem.country[c]=g);NotaHeaderElement.pbCache[a]["country"+e]=g;NotaHeaderElement.pbCache[a]["flagPath"+e]=f}.bind(this))}}getFlagSize(){return 500>this.w||400>this.h?400>this.w||300>this.h?16:24:750<this.w&&560<this.h?48:32}getFlagRaster(){return[16,24,32,48,64]}getPortraitSize(){return 380<this.w&&260<this.h?450<
4369this.w&&360<this.h?550<this.w&&450<this.h?650<this.w&&520<this.h?900<this.w?1E3<this.w?120:100:80:64:48:40:34}onWhite(a){this._onPlayer(a,Side.WHITE);this.scheduleUpdate(100)}onBlack(a){this._onPlayer(a,Side.BLACK);this.scheduleUpdate(100)}static constructImageFromData=function(a){return BinToString.ByteArrayToDataURI(a,"image/jpeg")};initElem(a,b){this.elementId=a;this._setOptions(b);a=CBQ("#"+a);if(CBElement.isEventSupported("touchstart"))a.on("touchend",this.onButtonUp.bind(this));if(CBElement.isEventSupported("mousedown"))a.on("mouseup",
4370this.onButtonUp.bind(this));this.initSubElements()}_setOptions(a){a.notationLocalization||(a.notationLocalization=V5);this.m_ng=new NotationGenerator(a.notationLocalization);this.m_useHeader=a.useHeader;this.m_useResult=a.useResult;this.m_active=a.isActive;this.smallHeader=a.smallHeader;this.m_options=a;a.game&&this.setGame(a.game)}setOptions(a){this._setOptions(a)}setGame(a){this.m_game&&(this.m_game.removeOnMoveListener(this.m_inxOnMove),this.m_game.removeOnNavigateListener(this.m_inxOnNavigate),
4371this.m_game.removeOnChangedListener(this.m_inxOnChanged),this.m_game.removeOnHeaderChangedListener(this.m_inxOnHeaderChanged));if(this.m_game=a)this.m_inxOnMove=this.m_game.addOnMoveListener(this.onMove.bind(this)),this.m_inxOnNavigate=this.m_game.addOnNavigateListener(this.OnNavigate.bind(this)),this.m_inxOnChanged=this.m_game.addOnChangedListener(this.OnChanged.bind(this)),this.m_inxOnHeaderChanged=this.m_game.addOnHeaderChangedListener(this.onHeaderChanged.bind(this)),this.bRequestPlayerBase=!0;
4372this.initSubElements()}getGame(){return this.m_game}onMove(){}OnChanged(){}onHeaderChanged(a){var b=null;this.m_game&&(b=this.m_game.getHeader());if(this.requestedWhite!==b.getWhite()||this.requestedBlack!==b.getBlack())this.bRequestPlayerBase=!0;a&&a.recalc&&(a=$("#notaEl").width(),b=$("#notaEl").height(),null==a&&(a=$("#notaEl"+this.nInPage).width(),b=$("#notaEl"+this.nInPage).height()),this.initTemplates(a,b));this.initSubElements()}OnNavigate(a){}static ResultToStr=function(a){return a==GameResultEnum.UNDEFINED_RESULT?
4373"-":GameResultEnum.toString(a)};displayOpening(a){3==a.length&&(this.hdrItem.eco=lm[a+"_ECO"])}scheduleUpdate(a){this.gateUpdate.exec(function(){this.updateSubElements();delete this.bRequestPlayerBase}.bind(this),a)}initSubElements(){function a(c){return c.first?"<a href='https://players.chessbase.com/en/player/"+c.last+"_"+c.first+"' target='_blank'>"+String.formatEx("{last}, {first}",c)+"</a>":"<a href='https://play.chessbase.com/user/"+c.last+"' target='_blank'>"+c.getListStr()+"</a>"}var b=null;
4374this.m_game&&(b=this.m_game.getHeader(),b.white.list=b.white.getListStr(1),b.black.list=b.black.getListStr(1),b.white.full=a(b.
4374white),b.black.full=a(b.black));this.InitEmptyHeader(b,!0);b=this.InitHeader(b,!0);CBQ("#theheader-"+this.nInPage).html(b)}updateSubElements(){var a=null;this.m_game&&(a=this.m_game.getHeader());a=this.InitHeader(a,!0);CBQ("#theheader-"+this.nInPage).html(a)}focus(){}onMouseMove(a){a.preventDefault()}showPlayerDetails(a,b,c){}onButtonUp(a){}onElementClick(a){if(!(!this.m_active||
4375600>window.innerHeight||700>window.innerWidth)){var b=a.target;CBQ.is(b,"[playid]")&&(b=CBQ(b).attr("playid"),this.showPlayerDetails(this.arrPlayer[b],0,this.arrPortrait[b]));a.preventDefault()}}isActive(){return this.m_active}setActive(a){this.m_active=a}onElementDragOver(a){a.preventDefault()}onElementDragEnter(a){a.preventDefault()}resize(a,b){DOM.resize(this.elementId,a,b)}setTitleOnly(a,b){this.titleText=a;this.titleIcon=b;this.initTemplates(this.w,this.h);this.updateSubElements()}onResize(a,
4376b){this.w=a;this.h=b;this.initTemplates(a,b);this.bRequestPlayerBase=!0;this.updateSubElements()}static factory(a,b){b=new NotaHeaderElement(b);b.initElem(a,cbNotationDefaults);return glApp.panelMgr.notaHeaderElement=b}}"use strict";
4377class NotaFooterElement{constructor(a,b){this.m_game=null;this.elementId=0;this.gateUpdate=new V10;this.matBalance=[];this.nInPage=a;this.ticket=b;NotaFooterElement.prototype.panel=null}static TABLE_CELL_FMT='<span class="piece-{0}"></span>';static TABLE_END_FMT="</div>";InitFooter(a){return this.generateHTML(a)}getPiece(a){return(Side.toString(Piece.side(a))+Piece.toString(a)).toLowerCase()}getTableStartFmt(){var a='<a href="'+(glApp?glApp.getAppUrl(glApp.Vy.SWITCHAPP_DATABASE):"https://database.chessbase.com")+
4378'" class="footer-book" id="footer-book{0}" target="_blank"></a><div class="footer-eval" id="footer-eval{0}"></div>';return a+'<div class="mat-balance">'}generateHTML(a){glApp&&glApp.config.externalCommonPath&&(NotaFooterElement.TABLE_CELL_FMT='<span style="background-image: url( {1}Media/Buttons/{0}-16px.png );"></span>');for(a=0;6>a;a++);var b=String.formatEx(this.getTableStartFmt(),this.nInPage);for(a=0;6>a;a++)if(0<this.matBalance[a+1])for(var c=0;c<this.matBalance[a+1];c++)b+=String.formatEx(NotaFooterElement.TABLE_CELL_FMT,
4379this.getPiece(a+1),getCommonPath());for(a=0;6>a;a++)if(0>this.matBalance[a+1])for(c=0;c<Math.abs(this.matBalance[a+1]);c++)b+=String.formatEx(NotaFooterElement.TABLE_CELL_FMT,this.getPiece(a+9),getCommonPath());return b+=NotaFooterElement.TABLE_END_FMT}collapseHeader(){CBQ("#thefooter-"+this.nInPage).addClass("notafooter-container")}expandHeader(){CBQ("#thefooter-"+this.nInPage).addClass("notafooter-container")}initElem(a){this.collapseHeader();this.elementId=a;this.update()}_setOptions(a){this.m_options=
4380a;a.game&&this.setGame(a.game)}setOptions(a){this._setOptions(a)}setText(a){CBQ("#footer-eval"+this.nInPage).text(a)}setGame(a){this.m_game&&(this.m_game.removeOnMoveListener(this.m_inxOnMove),this.m_game.removeOnNavigateListener(this.m_inxOnNavigate),this.m_game.removeOnChangedListener(this.m_inxOnChanged));if(this.m_game=a)this.m_inxOnMove=this.m_game.addOnMoveListener(this.onMove.bind(this)),this.m_inxOnNavigate=this.m_game.addOnNavigateListener(this.OnNavigate.bind(this)),this.m_inxOnChanged=
4381this.m_game.addOnChangedListener(this.OnChanged.bind(this));this.update()}getGame(){return this.m_game}onMove(){this.update()}OnChanged(){this.update()}OnNavigate(a){!this.liveBookListenerId&&glApp.aTBLobby&&(this.liveBookListenerId=glApp.aTBLobby.addOnLiveBookDisplayListener(this.liveBookListener.bind(this)));this.update()}update(){var a=[];for(var b=0;16>b;b++)a[b]=0;if(null!==this.getGame()){b=this.getGame().getCurPos();for(let c=0;64>c;c++)a[b.board[c]]++}for(b=1;7>b;b++)this.matBalance[b]=a[b]-
4382a[b+8];this.initSubElements()}scheduleUpdate(){this.gateUpdate.exec(function(){this.initSubElements()}.bind(this),200)}initSubElements(){var a=new StringBuilder;this.hasImbalance()&&CBQ(".footer-eval").text("");var b=this.InitFooter(!1);b.length&&a.append(b);CBQ("#thefooter-"+this.nInPage).html(a.toString());a=(a=CBQ("#notaparent"+this.nInPage))&&a.single()&&360<a.single().clientHeight;this.hasImbalance()||a?CBQ("#thefooter-"+this.nInPage).show():CBQ("#thefooter-"+this.nInPage).hide()}hasImbalance(){for(var a=
43830;6>a;a++)if(0!=this.matBalance[a+1])return!0;return!1}focus(){}onElementDragOver(a){a.preventDefault()}onElementDragEnter(a){a.preventDefault()}resize(a,b){DOM.resize(this.elementId,a,b)}liveBookListener(a){if(!System.isElectron()&&a&&(!this.ticket||this.ticket==a.ticket)){for(var b=0,c=0;c<a.moves.length;c++)b+=a.moves[c].getNGames();b?CBQ("#footer-book"+this.nInPage).text(lm.LIVE_BOOK+": "+b+" "+lm.GAMES):CBQ("#footer-book"+this.nInPage).text("")}}static factory(a,b){b=new NotaFooterElement(b);
4384b.initElem(a,cbNotationDefaults);return glApp.panelMgr.NotaFooterElement=b}}"use strict";
4385var BoardMessage=function(){var a=new CBColor(0,0,0,.25),b=new CBColor(255,255,250,.95),c=1,d=function(e,f,g){g=g||!1;this.uniqueId=c++;this.background=new DivElement(document.body,"bMessageBG"+this.uniqueId);this.background.setZIndex(99999);this.textEl=new DivElement(this.background,"bMessageText"+this.uniqueId);CBQ(this.background.elDOM).addClass("board-msg");g&&CBQ(this.background.elDOM).addClass("modal");e.messageWin=this;this.textEl.setText(f||"Empty Board Message");this.background.elDOM.addEventListener("mousedown",
4386function(h){g||(e.destroyMessage(),h.preventDefault())});this.textEl.elDOM.addEventListener("mousemove",function(h){h.preventDefault()})};d.prototype.destroy=function(){this.background.destroy()};d.prototype.setText=function(e){this.textEl.setText(e)};d.prototype.setVisible=function(e){this.background.setVisible(e)};d.prototype.onResize=function(e){var f=e.cbcanvas.getBoundingClientRect(),g=new CBRect(f.left,f.top,f.left+f.width,f.top+f.height);e.cbcanvas.pixToZoomRect&&(g=e.cbcanvas.pixToZoomRect(e.getOuterRect()));
4387var h=2;e.nSqPix&&(h=e.nSqPix);var k=Math.round(.7*g.w),l=Math.round(k/11),m=1;50<this.textEl.getText().length&&(l*=2.1,m=2);this.background.setPos((g.w-k)/2+g.left+f.left,(g.h-l)/2+g.top+f.top-l/2-(h-l)/2+window.pageYOffset);this.background.setSize(k,l);this.textEl.setPos(0,0);this.textEl.setSize(k,l);e.cbcanvas.pixToZoom&&this.textEl.setBorder(e.cbcanvas.pixToZoom(2),new CBColor(0,0,0,.7));
4387this.textEl.setBackgroundColor(a);this.textEl.setColor(b);400<k?this.textEl.setFontFamily("Roboto, Merriweather, Helvetica, sans-serif; font-stretch: expanded"):
4388250>k&&this.textEl.setFontFamily("Roboto, Merriweather, Helvetica, sans-serif; font-stretch: condensed");e=Math.max(5,.9*l/m);do this.textEl.setFontSize(e),--e;while(5<e&&this.textEl.getTextWidth()>.95*k&&this.textEl.getTextHeight()>.95*l);this.textEl.setCenteredText()};return d}(),BoardBubble=function(){var a=1,b=function(c,d,e,f,g){this.uniqueId=a++;this.square=d;if("undefined"==typeof this.square||null==this.square)this.square=-1;this.width=e||300;this.background=new DivElement(document.body,"bBubbleBG"+
4389this.uniqueId);$(this.background.elDOM).addClass("cbBoardBubble");this.setText(c,f);this.direction=g};b.TOP_RIGHT=0;b.BOTTOM_RIGHT=1;b.BOTTOM_LEFT=2;b.TOP_LEFT=3;b.prototype.destroy=function(){this.background.destroy()};b.prototype.setText=function(c,d){d?$(this.background.elDOM).html(String.f("{0}<img src='{1}' class='cbBoardBubbleIcon'>",c,d)):$(this.background.elDOM).text(c)};b.prototype.setVisible=function(c){this.background.setVisible(c)};b.prototype.onResize=function(c){var d=this.direction||
4390this.calcBestDirection(c,this.square),e=c.cbcanvas.getBoundingClientRect();new CBRect(e.left,e.top,e.left+e.width,e.top+e.height);if(c.cbcanvas.pixToZoomRect&&c.cbcanvas.pixToZoom){var f=c.cbcanvas.pixToZoomRect(c.getOuterRect());var g=2;c.nSqPix&&(g=c.nSqPix);$(this.background.elDOM).css("max-width",this.width);var h=$(this.background.elDOM).outerWidth(),k=$(this.background.elDOM).outerHeight(),l=(f.w-h)/2+f.left+e.left;f=(f.h-k)/2+f.top+e.top-k/2-(2.5*g-k)/2+window.pageYOffset;if(-1!=this.square){f=
4391c.cbcanvas.pixToZoomRect(c.getInnerRect());l=f.left+e.left;f=f.top+e.top+window.pageYOffset;e=this.square>>3;var m=7-(this.square&7);c.blackIsBottom&&(e=7-e,m=7-m);var n=c.cbcanvas.pixToZoom(8),r=c.cbcanvas.pixToZoom(40);switch(d){default:case b.TOP_RIGHT:l+=c.cbcanvas.pixToZoom((e+1)*g);l-=n;f+=c.cbcanvas.pixToZoom(m*g)-k;f-=r;break;case b.BOTTOM_RIGHT:l+=c.cbcanvas.pixToZoom((e+1)*g);l-=n;f+=c.cbcanvas.pixToZoom((m+1)*g);f+=r;break;case b.BOTTOM_LEFT:l+=c.cbcanvas.pixToZoom(e*g)-h;l+=n;f+=c.cbcanvas.pixToZoom((m+
43921)*g);f+=r;break;case b.TOP_LEFT:l+=c.cbcanvas.pixToZoom(e*g)-h,l+=n,f+=c.cbcanvas.pixToZoom(m*g)-k,f-=r}}else $(this.background.elDOM).removeClass("cbBoardBubbleTR cbBoardBubbleBR cbBoardBubbleTL cbBoardBubbleBL");if(l+h<window.innerWidth&&5<l&&-1!=this.square)switch(d){default:case b.TOP_RIGHT:$(this.background.elDOM).addClass("cbBoardBubbleTR");break;case b.TOP_LEFT:$(this.background.elDOM).addClass("cbBoardBubbleTL");break;case b.BOTTOM_RIGHT:$(this.background.elDOM).addClass("cbBoardBubbleBR");
4393break;case b.BOTTOM_LEFT:$(this.background.elDOM).addClass("cbBoardBubbleBL")}else $(this.background.elDOM).removeClass("cbBoardBubbleTR cbBoardBubbleBR cbBoardBubbleTL cbBoardBubbleBL"),5>l&&(l=5),l+h>window.innerWidth&&(l=window.innerWidth-h);$(this.background.elDOM).css({position:"absolute",left:l+"px",to
4393p:f+"px"})}};b.prototype.calcBestDirection=function(c,d){var e=this.countCoveredPieces(c,d,b.TOP_RIGHT),f=this.countCoveredPieces(c,d,b.BOTTOM_RIGHT),g=this.countCoveredPieces(c,d,b.BOTTOM_LEFT);
4394c=this.countCoveredPieces(c,d,b.TOP_LEFT);e=[e,f,g,c];f=-1;g=64;for(c=0;4>c;c++)e[c]<g&&(g=e[c],f=c);return f};b.prototype.countCoveredPieces=function(c,d,e){d=0;var f=this.square>>3,g=this.square&7;c.blackIsBottom&&(f=7-f,g=7-g);switch(e){default:case b.TOP_RIGHT:for(e=f+1;e<f+5&&8>e;e++)for(var h=g+1;h<g+3&&8>h;h++)0!=c.board.sqs[8*e+h]&&(d+=1,console.log(d));break;case b.BOTTOM_RIGHT:for(e=f+1;e<f+5&&8>e;e++)for(h=g-1;h>g-3&&0<h;h--)0!=c.board.sqs[8*e+h]&&d++;break;case b.BOTTOM_LEFT:for(e=f-1;e>
4395f-5&&0<e;e--)for(h=g-1;h>g-3&&0<h;h--)0!=c.board.sqs[8*e+h]&&d++;break;case b.TOP_LEFT:for(e=f-1;e>f-5&&0<e;e--)for(h=g+1;h<g+3&&8>h;h++)0!=c.board.sqs[8*e+h]&&d++}return d};return b}();"use strict";
4396var DiagramAnimationController=function(){var a=function(f,g,h,k){this.pos=ObjUtil.clone(g);this.boardWin=h;this.diagDiv=k;this.parseAnimations(f);this.timer=new Timer(this.timerHdl.bind(this));this.loopBeginInx=this.nAnim=0;this.timeScale=1;this.currBoard=ObjUtil.clone(this.pos.board);this.storeBoard=[];this.storeBoard[0]=ObjUtil.clone(this.pos.board);this.postedSuccess=!1};a.needsDiagramAnimButtons=function(f){var g=!1;f.forEach(function(h){if(h.match(/move:/i)||h.match(/beginloop/i))g=!0});return g};
4397a.parseDiagramHelp=function(f){var g={text:"",icon:null,sq:-1,attrs:[]};f=f.split("/");for(var h=0;h<f.length;h++){var k=f[h].match(/text:(.+)/i);if(k)g.text=k[1];else{var l=f[h].match(/arrow:([a-h][1-8][a-h][1-8]),(\d+),(\w+)(,dash)?/i);if(l){k=CBSquare.fromString(l[1].substr(0,2));var m=CBSquare.fromString(l[1].substr(2,2)),n=null;l[4]&&(n=[4,8]);g.attrs.push(new BoardArrow(k,m,DiagramAnimationController.translateArrowColor(l[3]),parseInt(l[2]),n))}else if(l=f[h].match(/file:([a-h][1-8][a-h][1-8]),(\d+),(.+)/i))k=
4398CBSquare.fromString(l[1].substr(0,2)),m=CBSquare.fromString(l[1].substr(2,2)),g.attrs.push(new BoardLine(a.getFilePoints(k,m),parseInt(l[2]),DiagramAnimationController.translateLineColor(l[3]),[2,10]));else if(l=f[h].match(/rank:([a-h][1-8][a-h][1-8]),(\d+),(.+)/i))k=CBSquare.fromString(l[1].substr(0,2)),m=CBSquare.fromString(l[1].substr(2,2)),g.attrs.push(new BoardLine(a.getRankPoints(k,m),parseInt(l[2]),DiagramAnimationController.translateLineColor(l[3]),[2,10]));else if(l=f[h].match(/diagonal:([a-h][1-8][a-h][1-8]),(\d+),(.+)/i))k=
4399CBSquare.fromString(l[1].substr(0,2)),m=CBSquare.fromString(l[1].substr(2,2)),g.attrs.push(new BoardLine(DiagramAnimationController.getDiagonalPoints(k,m),parseInt(l[2]),DiagramAnimationController.translateLineColor(l[3]),[2,15]));else if(k=f[h].match(/(mark|bigmark):(\[([a-h][1-8],?){2,}\]|[a-h][1-8]),(.{3,})/i))if(m=k[2],2<m.length){if(m=m.match(/([a-h][1-8])/g))for(l=0;l<m.length;l++)n=CBSquare.fromString(m[l]),g.attrs.push(new BoardColouredSquare(n,DiagramAnimationController.translateSquareColor(k[4],
4400n),"bigmark"==k[1]))}else m=CBSquare.fromString(k[2]),g.attrs.push(new BoardColouredSquare(m,DiagramAnimationController.translateSquareColor(k[4],m),"bigmark"==k[1]));else if(n=f[h].match(/bubble:([a-h][1-8])/i))g.sq=CBSquare.fromString(n[1]);else if(k=f[h].match(/icon:(.+)/))g.icon=getCommonPath()+"Media/Emojis/"+k[1]+".png";else if(k=f[h].match(/line:([a-h1-8tlbr-]+,(\d+),(.+))/))m=BoardLinePoint.stringToPoints(k[1].split(",")[0]),g.attrs.push(new BoardLine(m,k[2],DiagramAnimationController.translateLineColor(k[3])))}}return g};
4401a.parseChoiceFeedback=function(f){for(var g=[],h=0;h<f.length;h++){var k=f[h];switch(k.name){case "Mark":for(var l=0;l<k.squares.length;l++)g.push(new BoardColouredSquare(k.squares[l].sq,a.translateSquareColor(k.color,k.squares[l].sq),3<k.thick));break;case "Arrow":g.push(new BoardArrow(k.from.sq,k.to.sq,a.translateArrowColor(k.color),k.thick,k.dashed))}}return g};a.prototype.parseAnimations=function(f){this.animations=[];f.forEach(function(g){var h={},k="",l=g.indexOf(":");0<l?(h.command=g.substr(0,
4402l),k=g.substr(l+1),h.command.indexOf("$")&&(g=h.command.split("$"),h.command=g[0],h.subCommand=g[1])):h.command=g;1<k.length&&(k=k.split("/"),1<k.length?(h.time=parseFloat(k[1].substr(0,k[
44021].length-1)),isNaN(h.time)&&(h.time=0),3<=k.length&&(h.icon=getCommonPath()+"Media/Emojis/"+k[2]+".png")):h.time=0,this.isTextCommand(h.command)?h.params=[k[0]]:h.params=k[0].split(","));this.animations.push(h)}.bind(this))};a.prototype.setStartBoard=function(){this.boardWin.setBoard(this.pos.board);this.boardWin.redraw();
4403this.currBoard=ObjUtil.clone(this.pos.board)};a.prototype.rewind=function(f){this.timer.stop();this.nAnim=0;this.setStartBoard();this.clearColors();this.boardWin.destroyMessage();this.boardWin.destroySideIcon();f&&this.drawInvariants();this.userMoved=!1};a.prototype.onUserMove=function(){this.userMoved=!0};a.prototype.play=function(){this.userMoved&&this.rewind();0==this.nAnim&&this.setStartBoard();this.timeScale=1;this.timer.runOnce(0);this.isSingleStep=!1;this.onPlay()};a.prototype.step=function(){this.userMoved&&
4404this.rewind();0==this.nAnim&&this.setStartBoard();this.timeScale=1;this.isSingleStep=!0;this.timer.runOnce(0);this.onPlay()};a.prototype.stepBack=function(){this.userMoved&&this.rewind();this.timeScale=1;this.isSingleStep=!0;for(this.nAnim--;0<this.nAnim&&"move"!=this.animations[this.nAnim].command;)this.nAnim--;if(0>=this.nAnim)this.setStartBoard(),this.nAnim=0;else{var f=this.boardWin.animSteps;this.boardWin.animSteps={forMove:4,forPosition:4};this.boardWin.setBoard(this.storeBoard[this.nAnim],
4405!0);this.boardWin.animSteps=f;this.currBoard=ObjUtil.clone(this.storeBoard[this.nAnim]);this.clearText();this.clearColors()}};a.prototype.fastForward=function(){this.timeScale*=2;this.timer.runOnce(0);this.isSingleStep=!1};a.prototype.pause=function(){this.timer.stop()};a.prototype.continue=function(){};a.prototype.restartLoop=function(){this.timer.stop();this.nAnim=this.loopBeginInx+1;this.setStartBoard();this.timer.runOnce(0)};a.prototype.onPlay=function(){};a.prototype.onSuccess=function(){this.postedSuccess||
4406(this.boardWin.destroySideIcon(),this.boardWin.addSideIcon({url:getCommonPath()+"Media/Ribbons/Reader/Check48.png",cssClass:"cbBoardCheckMark",boardFract:10}),this.dataset=this.diagDiv.dataset,this.id=this.dataset.posid||"noid",window.playchessUser&&glApp.resultPostBack.postPlayed(window.playchessUser,this.id),this.postedSuccess||SendEvent("Play",this.id),this.postedSuccess=!0)};a.prototype.drawInvariants=function(){for(var f=!1,g=0;g<this.animations.length;g++){var h=this.animations[g];if(0==h.time||
44079999==h.time){var k=2;9999==h.time&&(k=1);switch(h.command){case "title":this.setTitle(h.params[0]);break;case "legend":this.setLegend(h.params[0]);break;case "text":this.setText(h.params[0]);break;case "bubble":this.setBubble(h.subCommand,h.params,h.icon);break;case "mark":a.drawMarks(this.boardWin,h.params,!1,k);f=!0;break;case "bigmark":a.drawMarks(this.boardWin,h.params,!0,k);f=!0;break;case "line":a.drawLines(this.boardWin,h.params,k);f=!0;break;case "arrow":a.drawArrows(this.boardWin,h.params,
4408k);f=!0;break;case "file":a.drawFile(this.boardWin,h.params,k);f=!0;break;case "rank":a.drawRank(this.boardWin,h.params,k);f=!0;break;case "diagonal":a.drawDiagonal(this.boardWin,h.params,k),f=!0}}else break}f&&this.boardWin.renderQueuedAttributes(!0)};a.prototype.setLegend=function(f){$(this.diagDiv).find(".diagText").text(f)};a.prototype.setText=function(f){this.boardWin.addBubble(f,"",320)};a.prototype.setBubble=function(f,g,h){var k=-1;f&&(k=CBSquare.fromString(f));this.boardWin.addBubble(g,k,
4409320,h)};a.prototype.clearText=function(f){this.boardWin.destroyMessage()};a.prototype.setTitle=function(f){$(this.diagDiv).find(".diagTitle").text(f)};var b={red:"hsla( 0, 85%, 50%, 0.70 )",lightred:"hsla( 0, 100%, 70%, 0.70 )",green:"hsla( 90, 70%, 40%, 0.7 )",yellow:"hsla( 40, 90%, 60%, 0.75 )",blue:"hsla( 220, 60%, 50%, 0.65 )",orange:"hsla( 24, 90%, 50%, 0.65 )",gold:"hsla( 42, 97%, 53%, 0.65 )",brown:"hsla( 14, 32%, 38%, 0.65 )",white:"hsla( 0, 0%, 100%, 0.9 )",black:"hsla( 0, 0%, 0%, 0.9 )"},
4410c={red:"hsla( 0, 80%, 50%, 0.7 )",lightred:"hsla( 0, 100%, 70%, 0.70 )",green:"hsla( 90, 75%, 45%, 0.7 )",yellow:"hsla( 40, 100%, 70%, 0.6 )",blue:"hsla( 220, 62%, 50%, 0.7 )",orange:"hsla( 24, 90%, 50%, 0.5 )",gold:"hsla( 42, 97%, 53%, 0.5 )",brown:"hsla( 14, 32%, 38%, 0.5 )",white:"hsla( 0, 0%, 100%, 0.9 )",black:"hsla( 0, 0%, 0%, 0.9 )"};a.drawMarks=function(f,g,h,k){var l=[];g.forEach(function(m){if(m.match(/[a-h][1-8]-[a-h][1-8]/i)){var n=0,r=0;m.charAt(3)>m.charAt(0)?n=1:m.charAt(3)<m.charAt(0)&&
4411(n=-1);m.charAt(4)>m.charAt(1)?r=1:m.charAt(4)<m.charAt(1)&&(r=-1);for(var t=Math.max(Math.abs(m.charCodeAt(3)-m.charCodeAt(0)),Math.abs(m.charCodeAt(4)-m.charCodeAt(1))),u=CBSquare.colFromString(m.charAt(0)),x=CBSquare.rowFromString(m.charAt(1)),B=0;B<=t;B++)l.push(CBSquare.I(u+B*n,x+B*r))}else m.match(/[a-h][0-9]/i)?l.push(CBSquare.fromString(m)):(l.forEach(function(y){var A=a.translateSquareColor(m,y);A||=b.green;f.markSquare(y,A,h,k)}.bind(this)),l=[])}.bind(this))};a.translateSquareColor=function(f,
4412g){return CBSquare.isDark(g)?c[f]:b[f]};a.prototype.clearColors=function(){this.boardWin.clearBaggageAttributes();this.boardWin.clearPermanentAttributes();this.boardWin.board.sqs=[];this.boardWin.setBoard(this.currBoard)};a.prototype.clearBoard=function(){this.boardWin.clearBaggageAttributes();this.boardWin.board.sqs=[];for(var f=0;64>f;f++)this.currBoard[f]=0;this.boardWin.setBoard(this.currBoard)};var d={red:"hsla( 0, 60%, 50%, 0.7 )",lightred:"hsla( 0, 100%, 70%, 0.70 )",green:"hsla( 90, 70%, 50%, 0.70 )",
4413yellow:"hsla( 40, 90%, 65%, 0.80 )",blue:"hsla( 220, 70%, 50%, 0.7 )",orange:"hsla( 24, 90%, 50%, 0.7 )",gold:"hsla( 42, 97%, 53%, 0.7 )",brown:"hsla( 14, 32%, 38%, 0.7 )",white:"hsla( 0, 0%, 100%, 0.9 )",black:"hsla( 0, 0%, 0%, 0.9 )"};a.drawArrows=function(f,g,h){var k=[],l=[],m=0;g.forEach(function(n){if(n.match(/[a-h][1-8][a-h][1-8]/i))k.push(CBSquare.fromString(n.substr(0,2))),l.push(CBSquare.fromString(n.substr(2,2)));else if(n.charAt(0).match(/[0-9]/))m=parseInt(n);else{for(var r=0;r<k.length;r++){var t=
4414n.split("+"),u=a.translateArrowColor(t[0]);u||=d.green;f.drawArrow(k[r],l[r],u,m,h,t[1]?[6,10]:null)}k=l=[];m=0}}.bind(this));for(g=0;g<k.length;g++)f.drawArrow(k[g],l[g],d.green,15,h)};a.translateArrowColor=function(f){return d[f]};var e={red:"hsla( 0, 80%, 50%, 0.75 )",lightred:"hsla( 0, 100%, 70%, 0.70 )",green:"hsla( 90, 75%, 50%, 0.65 )",yellow:"hsla( 40, 100%, 60%, 0.75 )",blue:"hsla( 220, 60%, 50%, 0.65 )",orange:"hsla( 24, 90%, 50%, 0.65 )",gold:"hsla( 42, 97%, 53%, 0.65 )",brown:"hsla( 14, 32%, 38%, 0.65 )",
4415white:"hsla( 0, 0%, 100%, 0.9 )",black:"hsla( 0, 0%, 0%, 0.9 )"};a.translateLineColor=function(f){return d[f]};a.drawLines=function(f,g,h){var k=[],l=[],m=0;g.forEach(function(n){var r=n.match(/[a-h][1-8][t,b][l,r]/ig);if(r)for(n=0;n<r.length;n++){var t=CBSquare.fromString(r[n].substr(0,2));l.push(new BoardLinePoint(t,r[n].substr(2,2)))}else if(n.charAt(0).match(/^[0-9]+$/))m=parseInt(n);else{r=n.split("+");(n=e[r[0]])||(n=e.green);t=[];switch(r[1]){default:case "dashed":r[1]&&(t=[6,12]);break;case "dotted":t=
4416[3,10]}r=new BoardLine(l,m,n,t);k.push(r);l=[];m=0}}.bind(this));f.addAttributes(k,h)};a.drawFile=function(f,g,h){var k=[],l=g[0];g=g[1]||"white";if(l){var m=CBSquare.fromString(l.substr(0,2));l=CBSquare.fromString(l.substr(2,2));k.push(new BoardLine(a.getFilePoints(m,l),6,DiagramAnimationController.translateLineColor(g)))}f.addAttributes(k,h)};a.drawRank=function(f,g,h){var k=[],l=g[0];g=g[1]||"white";if(l){var m=CBSquare.fromString(l.substr(0,2));l=CBSquare.fromString(l.substr(2,2));k.push(new BoardLine(a.getRankPoints(m,
4417l),6,DiagramAnimationController.translateLineColor(g)))}f.addAttributes(k,h)};a.drawDiagonal=function(f,g,h){var k=[],l=g[0];g=g[1]||"white";if(l){var m=CBSquare.fromString(l.substr(0,2));l=CBSquare.fromString(l.substr(2,2));k.push(new BoardLine(DiagramAnimationController.getDiagonalPoints(m,l),10,DiagramAnimationController.translateLineColor(g),[7,12]))}f.addAttributes(k,h)};a.getFilePoints=function(f,g){return[new BoardLinePoint(f,"bl"),new BoardLinePoint(g,"tl"),new BoardLinePoint(g,"tr"),new BoardLinePoint(f,
4418"br"),new BoardLinePoint(f,"bl")]};a.getRankPoints=function(f,g){return[new BoardLinePoint(f,"bl"),new BoardLinePoint(g,"br"),new BoardLinePoint(g,"tr"),new BoardLinePoint(f,"tl"),new BoardLinePoint(f,"bl")]};a.getDiagonalPoints=function(f,g){var h=CBSquare.getFile(f),k=CBSquare.getRank(f),l=CBSquare.getFile(g),m=CBSquare.getRank(g);h<l?k<m?(h=["bl","lm","bm"],k=["tm","tr","rm"]):(h=["tl","tm","lm"],k=["rm","br","bm"]):k<m?(h=["br","bm","rm"],k=["lm","tl","tm"]):(h=["tr","rm","tm"],k=["bm","bl","lm"]);
4419return[new BoardLinePoint(f,h[0]),new BoardLinePoint(f,h[1]),new BoardLinePoint(g,k[0]),new BoardLinePoint(g,k[1]),new BoardLinePoint(g,k[2]),new BoardLinePoint(f,h[2]),new BoardLinePoint(f,h[0])]};a.prototype.animMove=function(f,g){var h,k,l,m=!0;g.forEach(function(n){if(n.match(/[a-h][1-8][a-h\-][1-8\-]/i)){var r=n.substr(0,2);n=n.substr(2,2);h=CBSquare.fromString(r);"--"!=n?(k=CBSquare.fromString(n),this.currBoard[k]=this.currBoard[h]):m=!1;this.currBoard[h]=0}else if(n.match(/[wb][K,Q,N,B,R,P][a-h][1-8]/)){r=
4420"b"==n.charAt(0)?Piece.COLOUR:0;var t=" KQNBRP".split("").indexOf(n.charAt(1));n=n.substr(2,2);k=CBSquare.fromString(n);this.currBoard[k]=t+r;m=!1}else l=d[n]}.bind(this));g=f.animSteps;f.animSteps={forMove:6,forPosition:2};f.setBoard(this.currBoard,!0);f.animSteps=g;l&&m&&f.drawArrow(h,k,l,10,!1)};a.prototype.shouldShowAnimButtons=function(){this.animations.forEach(function(f){if("move "==f.command)return!0})};a.prototype.timerHdl=function(){this.storeBoard[this.nAnim]=ObjUtil.clone(this.currBoard);
4421var f=!1,g=this.animations[this.nAnim];switch(g.command){case "title":this.setTitle(g.params[0]);break;case "legend":this.setLegend(g.params[0]);break;case "text":this.setText(g.params[0]);break;case "bubble":this.setBubble(g.subCommand,g.params,g.icon);break;case "mark":a.drawMarks(this.boardWin,g.params,!1,!1);f=!0;break;case "bigmark":a.drawMarks(this.boardWin,g.params,!0,!1);f=!0;break;case "line":a.drawLines(this.boardWin,g.params,!1,!1);f=!0;break;case "clearcolor":this.clearColors();break;
4422case "clearboard":this.clearBoard();break;case "cleartext":this.clearText();break;case "clearall":this.clearColors();this.clearText();break;case "arrow":a.drawArrows(this.boardWin,g.params,!1);f=!0;break;case "file":a.drawFile(this.boardWin,g.params,!1);f=!0;break;case "rank":a.drawRank(this.boardWin,g.params,!1);f=!0;break;case "diagonal":a.drawDiagonal(this.boardWin,g.params,!1);f=!0;break;case "move":this.animMove(this.boardWin,g.params);break;case "beginloop":this.loopBeginInx=this.nAnim;break;
4423case "endloop":this.restartLoop();break;case "success":this.onSuccess()}f&&this.boardWin.renderQueuedAttributes(!0);if("endloop"==g.command||this.nAnim==this.animations.length-2)this.onSuccess();"endloop"!=g.command&&(this.nAnim++,this.nAnim>=this.animations.length?this.isSingleStep?this.anim--:this.nAnim=0:this.isSingleStep?this.skipInSingleStep(g.command)&&this.timer.runOnce(0):this.timer.runOnce(1E3*g.time/this.timeScale))};a.prototype.skipInSingleStep=function(f){return 0<="wait beginloop endloop legend cleartext clearcolor clearall arrow bigmark".split(" ").indexOf(f)};
4424a.prototype.isTextCommand=function(f){return 0<=["legend","text","t
4424itle","bubble"].indexOf(f)};return a}();"use strict";
4425class PosInputControl extends RawBoardControl{constructor(a,b,c,d,e,f,g){super();PosInputControl.initForListeners();this.init(a,b,c,d);this.fnCloseHandler=e;this.checkLegal=f;this.options=g}createButtons(){const a=new PosInputButtons(this.cbcanvas.canvas.parentElement,{onClear:this.clearBtnClicked.bind(this),onInit:this.initBtnClicked.bind(this),onWhite:this.wBtnClicked.bind(this),onBlack:this.bBtnClicked.bind(this),onSquare:this.squareBtnClicked.bind(this),onDone:this.doneBtnClicked.bind(this),onCancel:this.cancelBtnClicked.bind(this)});
4426this.addRightWin(a);this.buttons=this.rightWin;this.addOnBoardChangedListener(this.onChanged.bind(this));this.buttons.addOnBoardChangedListener(this.onChanged.bind(this));this.onReadyHandlers.add(()=>{this.buttons.setVisible(!0)})}getBTM(){return this.buttons.getBTM()}setPosition(a){this.setBoard(a.board);this.buttons.setBTM(a.isBTM());this.buttons.setCastleRights(a.getCastleRights())}createPosition(){const a=new Position;this.board.copyTo(a.board);a.setBTM(this.getBTM());a.cr=this.buttons.getCastleRights();
4427a.ep=this.buttons.getEP();return a}wBtnClicked(a,b){this.beginNewPiece(a)}bBtnClicked(a,b){this.beginNewPiece(a+Side.SIDE_MASK)}squareBtnClicked(){this.isNewPiece=!1;this.eraseSquares=!0;this.currPiece&&(this.hideSprite(this.currPiece),this.boardSprites.giveBack(this.currPiece),delete this.currPiece)}doneBtnClicked(){this.fnCloseHandler()}cancelBtnClicked(){this.fnCloseHandler(!0)}clearBtnClicked(){const a=[];for(let b=0;64>b;b++)a.push(0);this.setBoard(a,!1);this.onChanged();this.beginNewPiece(Piece.W_KING)}initBtnClicked(){var a=
4428new Position;this.setPosition(a);this.onChanged()}beginNewPiece(a){this.isNewPiece=!0;this.eraseSquares=!1;this.buttonDown=!0;this.currPiece&&(this.hideSprite(this.currPiece),this.boardSprites.giveBack(this.currPiece));this.currPiece=this.boardSprites.createSprite(this.pieceSpriteFactory,a);this.clickOffs=new CBPoint(0,0)}onMouseDown(a){a.preventDefault()}onMouseWheel(a,b){if(this.currPiece&&this.isNewPiece){var c=this.currPiece.piece&Piece.PIECE_MASK;0<a.wheelDelta?(c--,0>=c&&(c=Piece.PAWN)):(c++,
4429c>Piece.PAWN&&(c=Piece.KING));this.hideSprite(this.currPiece);this.boardSprites.giveBack(this.currPiece);this.currPiece=this.boardSprites.createSprite(this.pieceSpriteFactory,c|this.currPiece.piece&Piece.COLOUR);this.clickPos=this.getClickPos(b);this.clickOffs=new CBPoint(0,0);this.redraw();this.currPiece.moveTo(this.cbcanvas.bufferCtx,this.clickPos.add(this.clickOffs))}a.preventDefault()}onMouseUp(a,b){this.getClickPos(b);this.buttonDown=!1;if(this.allowInput)if(2==a.button&&this.isNewPiece&&this.currPiece){var c=
4430this.currPiece.piece;c^=Piece.COLOUR;this.hideSprite(this.currPiece);this.boardSprites.giveBack(this.currPiece);this.currPiece=this.boardSprites.createSprite(this.pieceSpriteFactory,c);this.clickPos=this.getClickPos(b);this.redraw();this.currPiece.moveTo(this.cbcanvas.bufferCtx,this.clickPos.add(this.clickOffs))}else new Tick,c=this.clickPos=this.getClickPos(b),b=this.getClickedSquare(c),void 0!==this.currPiece&&-1!=b?(b!==this.fromSq?(this.toSq=b,this.board.get(b)&&this.animateCapture(b),this.isNewPiece?
4431this.board.sqs[b]!=this.currPiece.piece?(c=this.currPiece.piece,this.boardSprites.set(this.currPiece,b),this.board.set(b,c)):this.eraseSquare(b):(this.boardSprites.change(this.fromSq,b),this.board.change(this.fromSq,b)),this.board.sqs[b]&&this.moveSprite(this.currPiece,this.getSquareCenterPos(b)),delete this.fromSq):this.currPiece&&this.moveSprite(this.currPiece,this.getSquareCenterPos(b)),c=!1,this.isNewPiece&&(this.currPiece=this.boardSprites.createSprite(this.pieceSpriteFactory,this.currPiece.piece),
4432c=this.buttonDown=!0),c||(this.currPiece&&(this.currPiece.lastSq=b),delete this.currPiece),a.preventDefault()):this.eraseSquares&&-1!=b&&this.eraseSquare(b),this.redraw(),this.fireOnBoardChanged(this);this.fromSq=-1}onContextMenu(a,b){this.getClickPos(b)}eraseSquare(a){this.boardSprites.set(null,a);this.board.set(a,0);this.drawSquare(this.cbcanvas.bufferCtx,a);this.cbcanvas.requestRedraw()}onMouseMove(a,b){this.allowInput&&(this.clickPos=this.getClickPos(b),this.getInnerRect().isInside(this.clickPos.x,
4433this.clickPos.y)?(this.getClickedSquare(this.clickPos),void 0!==this.currPiece&&(new Tick,this.moveSprite(this.currPiece,this.clickPos.add(this.clickOffs)),a.preventDefault())):this.hideSprite(this.currPiece),a.target.style.cursor=this.eraseSquares?"crosshair":"default")}onChanged(a){a=this.createPosition();this.buttons.setPossibleCastleRights(a.getPossibleCastleRights());var b=a.getPossibleEP().map(CBSquare.colToString);b.unshift("-");this.buttons.setPossibleEP(b);a=this.checkLegal?this.checkLegal(a):
4434a.isLegal()&&!a.isSuicidePos();this.buttons.canBeDone(a)}static initForListeners(){PosInputControl.listenersInited||(Vk.initForListeners(PosInputControl),Vk.addEvent(PosInputControl,"BoardChanged"),PosInputControl.listenersInited=!0)}}"use strict";
4435class PosInputButtons{constructor(a,b){PosInputButtons.initForListeners();this.background=new DivElement(a,"posInputBtnsBG");this.background.style["font-size"]=1/System.getDevicePixelRatio()+"em";this.btnSide=40;this.btnTotSide=44;this.btnHDist=5;this.handlers=b}createButtons(){if(!this.created){this.buttonsW=[];this.buttonsB=[];for(var a="KQNBRP".split(""),b=0;6>b;b++)this.buttonsW.push(this.createPieceButton("w"+a[b])),this.buttonsW[b].setHandler(function(c){return function(d){this.handlers.onWhite(c,
4436d)}.bind(this)}.call(this,b+1)),this.buttonsB.push(this.createPieceButton("b"+a[b])),this.buttonsB[b].setHandler(function(c){return function(d){this.handlers.onBlack(c,d)}.bind(this)}.call(this,b+1));this.squareBtn=this.createSquareButton(this.handlers.onSquare);this.clearBtn=this.createClearButton(this.handlers.onClear);this.initBtn=this.createInitButton(this.handlers.onInit);this.blackCheck=this.createCheckBox("Black's Move");this.w00Check=this.createCheckBox("w 0-0");this.b00Check=this.createCheckBox("b 0-0");
4437this.w000Check=this.createCheckBox("w 0-0-0");this.b000Check=this.createCheckBox("b 0-0-0");this.epSel=this.createSelect("EP");this.doneBtn=this.createDoneButton(this.handlers.onDone);this.cancelBtn=this.createCancelButton(this.handlers.onCancel);this.created=!0}}destroyButtons(){this.background.destroyChilds()}destroy(){this.background.destroy()}hideCancelDoneButtons(){this.doneBtn.style.display="none";this.cancelBtn.style.display="none"}getAvailSqPix(a){var b=[48,44,40,36,32],c;for(c=0;c<b.length;c++)if(a>=
4438b[c]){a=b[c];break}c>=b.length&&(a=8);return a}
4438getDesiredWidth(a,b){this.btnHDist=System.pixToZoom(Math.max(1,Math.min(6,b/96)));this.btnSide=this.getAvailSqPix(Math.round(.9*Math.max(16,Math.min(56,a/8-this.btnHDist))));this.btnTotSide=Math.round(this.btnSide/.9);return System.isPortraitScreen()?this.calcWidth():.95*this.calcWidth()}calcWidth(){return 2*this.btnTotSide+this.getBtnWideWidth(this.btnTotSide)+2*this.btnHDist}setVisible(a){this.background.setVisible(a)}getBTM(){return this.blackCheck.getChecked()}setBTM(a){this.blackCheck.setChecked(a)}setCastleRights(a){this.w00Check.setChecked(!!(a&
4439CastleRights.W_00));this.b00Check.setChecked(!!(a&CastleRights.B_00));this.w000Check.setChecked(!!(a&CastleRights.W_000));this.b000Check.setChecked(!!(a&CastleRights.B_000))}setPossibleCastleRights(a){var b=this.getCastleRights();this.setCastleRights(b&a);this.w00Check.setEnabled(!!(a&CastleRights.W_00));this.b00Check.setEnabled(!!(a&CastleRights.B_00));this.w000Check.setEnabled(!!(a&CastleRights.W_000));this.b000Check.setEnabled(!!(a&CastleRights.B_000))}getCastleRights(){var a=CastleRights.NONE;
4440this.w00Check.getChecked()&&(a|=CastleRights.W_00);this.b00Check.getChecked()&&(a|=CastleRights.B_00);this.w000Check.getChecked()&&(a|=CastleRights.W_000);this.b000Check.getChecked()&&(a|=CastleRights.B_000);return a}onResize(a){var b=a.cbcanvas.pixToZoomRect(a.getOuterRect());a.cbcanvas.pixToZoomRect(a.getOuterRect());a=b.right;b=b.top;this.createButtons();this.setPosSize(a,b,this.calcWidth(),8*this.btnTotSide+7*this.btnHDist)}setPosSize(a,b,c,d){this.x0=a;this.y0=b;this.w=c;this.h=d;this.calcGeometry()}calcGeometry(){for(var a=
4441this.btnTotSide,b=this.btnTotSide,c=this.btnHDist,d=this.btnHDist,e=this.x0+d,f=this.y0,g=0;6>g;g++)this.buttonsW[g].setPosSize(e,f,a,b),this.buttonsB[g].setPosSize(e+a+d,f,a,b),f+=c+b;e=this.x0+2*a+3*d;f=this.y0;this.squareBtn.setPosSize(e,f,a,b);f+=c+b;b=this.getBtnWideWidth(a);g=this.btnTotSide/2;var h=Math.max(8,Math.min(24,Math.round(this.btnTotSide/2.5)));this.clearBtn.setPosSize(e,f,b,g);f+=d+g;this.initBtn.setPosSize(e,f,b,g);f+=2*d+g;this.blackCheck.setPosSize(e,f,b,h);f+=d+h;this.w00Check.setPosSize(e,
4442f,b,h);f+=1+h;this.b00Check.setPosSize(e,f,b,h);f+=1+h;this.w000Check.setPosSize(e,f,b,h);f+=1+h;this.b000Check.setPosSize(e,f,b,h);f+=d+h;this.epSel.setPosSize(e,f,a,g);f+=d+g;a=1.4*g;this.cancelBtn.setPosSize(e,f,b,g);this.doneBtn.setPosSize(e,f+(c+g),b,a)}getBtnWideWidth(a){return Math.round(2.1*a+this.btnHDist)}createPieceButton(a){var b=new Button(this.background,"PieceBtn-"+a,"cb-button");b.setImage("/Common/Media/Buttons/"+a+"-"+this.btnSide+"px.png");return b}createSquareButton(a){var b=new Button(this.background,
4443"SqBtn");b.setImage("/Common/Media/Buttons/sqL-"+this.btnSide+"px.png");b.setHandler(a);return b}createClearButton(a){return this.createButton("Clear",a)}createInitButton(a){return this.createButton("Init",a)}createDoneButton(a){return this.createButton("Done",a)}createCancelButton(a){return this.createButton("Cancel",a)}createButton(a,b){var c=new Button(this.background);c.setText(a);c.setHandler(b);return c}canBeDone(a){LOG(a);this.doneBtn.setEnabled(a)}createCheckBox(a){var b=new CBCheckBox(this.background);
4444b.setText(a);b.setHandler("change",this.fireOnBoardChanged.bind(this));return b}setPossibleEP(a){var b=this.epSel.value;this.epSel.setOptions(a);0<=a.indexOf(b)&&(this.epSel.value=b);this.epSel.setEnabled(1<a.length)}getEP(){var a=this.epSel.getValue();switch(a){case "-":return Position.NOEP;default:return a&&a.length?a.charCodeAt(0)-97:Position.NOEP}}createSelect(a){a=new CBSelect(this.background);a.setHandler(function(){this.fireOnBoardChanged()}.bind(this));return a}static initForListeners(){PosInputButtons.listenersInited||
4445(Vk.initForListeners(PosInputButtons),Vk.addEvent(PosInputButtons,"BoardChanged"),PosInputButtons.listenersInited=!0)}}"use strict";
4446class ChessAudioInstance{constructor(){this.enabled=!0;this._game=null;this.sideToPlay={};this.sideToPlay[Side.WHITE]=!0;this.sideToPlay[Side.BLACK]=!0}setGame(a){this._game&&this._game.removeOnMoveListener(this.idOnMove);(this._game=a)&&!glApp.config.isSilentBoard&&(this.idOnMove=this._game.addOnMoveListener(this._onMove.bind(this)))}getGame(){return this._game}enable(a){this.enabled=a}enableSide(a,b){this.sideToPlay[a]=b}_onMove(){var a=this._game.getCurPos(),b=this._game.getLastMove();if(b&&this.enabled&&
4447glApp&&glApp.chessAudio)glApp.chessAudio.onMove(b,a)}}"use strict";
4448class ChessAudio{constructor(a,b){this.withTactics=b;this.folder=a;this.queue=new AudioQueue;this.allAudios=[];this.loaded=!1;this.newGame=this.createAudio("Board/newgame");this.moveSounds=[];this.strongMoves=[];this.moveCaptures=[];this.strongCaptures=[];this.strongCaptures.push(this.createAudio("Board/CaptStrong"));this.castle=this.createAudio("Board/castle");this.winApplause=[];this.drawApplause=this.createAudio("Server/clapping");this.drawOfferEng=this.createAudio("Server/draw");this.drawOfferDeu=
4449this.createAudio("Server/remis");this.ping=this.createAudio("Server/ping2");this.ringbell=this.createAudio("Server/ringbellonce");this.challengebell=this.createAudio("Server/ChallengeBell");this.playFaster=this.createAudio("Server/Feedback/faster");this.punches=[];this.grunts=[];this.myError=[];this.oppError=[];this.cheer=[];this.punishCap=[];this.punishNoCap=[];this.bestCap=[];this.bestNoCap=[];this.only=[];this.wellDone=[];this.alarm=this.createAudio("Server/Aooga")}stopAll(){this.queue.stopAll()}isEnabled(){return this.queue.isEnabled()}enable(a){return this.queue.enable(!!a)}loadAll(){this.individualApplause=
4450this.createAudio("Server/IndividualApplause");for(var a=1;11>=a;a++)this.moveSounds.push(this.createAudio("Board/move"+a));for(a=1;15>=a;a++)this.moveCaptures.push(this.createAudio("Board/capture"+a));if(!glApp.config.noPlayingAudios){for(a=1;5>=a;a++)this.winApplause.push(this.createAudio("Server/winapplause"+a));this.winApplause.push(this.createAudio("Server/cheer1"));this.winApplause.push(this.createAudio("Server/cheer2"));this.winApplause.push(this.createAudio("Server/cheer3"));this.winApplause.push(this.createAudio("Server/cheer5"))}if(this.withTactics){for(a=
44511;16>=a;
4451a++)this.punches.push(this.createAudio("Server/punch"+a));for(a=1;8>=a;a++)this.grunts.push(this.createAudio("Server/grunt"+a));for(a=1;9>=a;a++)this.myError.push(this.createAudio("Server/MyError"+a));for(a=1;5>=a;a++)this.cheer.push(this.createAudio("Server/Cheer"+a))}if((glApp.config.useAnalysisEngines||this.withTactics)&&!glApp.config.noPlayingAudios)for(a=1;5>=a;a++)this.oppError.push(this.createAudio("Server/OppError"+a));if(glApp.config.useAnalysisEngines&&!glApp.config.noPlayingAudios){var b=
4452["Plop","CluckCluck","FistInHand","Snap"],c=["Marseillaise","Yes","SoftClapClap"],d=["Cluck","DoubleSnap","Drawlips"],e=["CuckooWhistle","Moan","Moan2"],f=["Exhale","sharpinhale","sssinhale"],g=["WellDone"];for(a=0;a<b.length;a++)this.punishCap.push(this.createAudio("Server/Feedback/"+b[a]));for(a=0;a<c.length;a++)this.punishNoCap.push(this.createAudio("Server/Feedback/"+c[a]));for(a=0;a<d.length;a++)this.bestCap.push(this.createAudio("Server/Feedback/"+d[a]));for(a=0;a<e.length;a++)this.bestNoCap.push(this.createAudio("Server/Feedback/"+
4453e[a]));for(a=0;a<f.length;a++)this.only.push(this.createAudio("Server/Feedback/"+f[a]));for(a=0;a<g.length;a++)this.wellDone.push(this.createAudio("Server/Feedback/"+g[a]));for(a=1;2>=a;a++)this.strongMoves.push(this.createAudio("Board/moveStrong"+a))}(new Timer(function(){this.allAudios.forEach(function(h){h.load()});this.allAudios=[];this.loaded=!0}.bind(this))).runOnce(1E3)}onMove(a,b){this.queue.stopAll();a.isTake()?a.isStrong?this.playStrongCapture():this.playCapture():a.isCastling()?this.playCastle():
4454a.isStrong?this.playStrongMove():this.playMove()}playMove(){this.queue.push(this.moveSounds[Math.floor(Math.random()*this.moveSounds.length)])}playStrongMove(){this.queue.push(this.strongMoves[Math.floor(Math.random()*this.strongMoves.length)])}playCapture(){this.queue.push(this.moveCaptures[Math.floor(15*Math.random())])}playStrongCapture(){this.queue.push(this.strongCaptures[Math.floor(Math.random()*this.strongCaptures.length)])}playCastle(){this.queue.push(this.castle)}onWin(){this.queue.push(this.winApplause[Math.floor(9*
4455Math.random())])}onDraw(){this.queue.push(this.drawApplause)}onPing(){this.queue.push(this.ping)}onIndividualApplause(){this.individualApplause&&this.queue.push(this.individualApplause)}onFightChallengeReceived(){this.queue.push(this.challengebell)}onFightStart(){this.queue.push(this.ringbell)}onFightMyCorrect(){this.queue.push(this.punches[Math.floor(14*Math.random())])}onFightOppCorrect(){this.queue.push(this.grunts[Math.floor(Math.random()*this.grunts.length)])}onFightMyWrong(){this.queue.push(this.myError[Math.floor(Math.random()*
4456this.myError.length)])}onFightOppWrong(){this.queue.push(this.oppError[Math.floor(Math.random()*this.oppError.length)])}onFightCheer(){this.queue.push(this.cheer[Math.floor(Math.random()*this.cheer.length)])}warnPlayFaster(){this.queue.push(this.playFaster)}onPunishedBlunderCapture(){this.queue.push(this.punishCap[Math.floor(Math.random()*this.punishCap.length)])}onPunishedBlunderNoCapture(){this.queue.push(this.punishNoCap[Math.floor(Math.random()*this.punishNoCap.length)])}onBestMoveCapture(){this.queue.push(this.bestCap[Math.floor(Math.random()*
4457this.bestCap.length)])}onBestMoveNoCapture(){this.queue.push(this.bestNoCap[Math.floor(Math.random()*this.bestNoCap.length)])}onOnlyMove(){this.queue.push(this.only[Math.floor(Math.random()*this.only.length)])}onWellDone(){this.queue.push(this.wellDone[Math.floor(Math.random()*this.wellDone.length)])}opponentOffersDraw(){Language.getUserLanguageId()==Language.DEU?this.queue.push(this.drawOfferDeu):this.queue.push(this.drawOfferEng)}onNewGame(){this.queue.push(this.newGame)}onDisconnect(){this.queue.push(this.alarm)}onThreat(){this.queue.push(this.alarm)}onIncomingChallenge(){this.queue.push(this.challengebell)}createAudio(a){a=
4458new CBAudio(this.folder+a,null,!0);this.allAudios.push(a);return a}}"use strict";
4459var BoardBottomWin=function(){var a=function(b){this.config=b||{};this.config.hMinToShow=150;this.height=20};a.prototype.getDesiredHeight=function(b,c){return this.calcHeight(b,c)};a.prototype.calcHeight=function(b,c){c=c.zoomToPix(this.config.hMax);return Math.min(c,b/this.config.hScale)};a.prototype.confirmHeight=function(b,c){this.height=c.pixToZoom(b)};a.prototype.canShowIfHeight=function(b,c){return b>c.pixToZoom(this.config.hMinToShow)};a.prototype.getSpacingToBoard=function(b,c){return c?c.zoomToPix(this.config.spacing):
44600};a.prototype.getRect=function(b){var c=b.cbcanvas.canvas.getBoundingClientRect(),d=b.cbcanvas.pixToZoomRect(b.getOuterRect());d.h=this.height;var e=b.cbcanvas.pixToZoom(b.getOuterRect().h);d.move(c.left,c.top+e+b.cbcanvas.pixToZoom(this.config.spacing)-1);return d};return a}(),BoardURL=function(){var a=1,b=function(c,d){b.superClass.call(this,d);this.uniqueId=a++;this.background=new DivElement(document.body,"bBottomBG"+this.uniqueId);this.url=new DivElement(this.background,"bBottomURL"+this.uniqueId);
4461this.url.setURL(c.url,c.linkText,"BoardBottomURL",!0)};inherit(b,BoardBottomWin);b.prototype.onResize=function(c){var d=this.getRect(c),e=d.w;this.config.rightAlign&&(e-=c.nMarginW);this.background.setPos(d.left,d.top);this.background.setSize(e,d.h);this.url.setPos(0,0);this.url.setSize(e,d.h);this.url.elDOM.className="BoardBottomURL";this.url.setFontSize(d.h);this.url.setFontSize(Math.max(3,d.h));this.config.rightAlign?this.url.setRightAlign():this.url.setCenteredText();glApp.config.versionChessBaseCom&&
4462(this.url.linkNode.style.color="Black")};b.prototype.destroy=function(){this.background.destroy()};b.prototype.setVisible=function(c){this.background.setVisible(c)};return b}(),BoardDoubleURL=function(){var a=1,b=function(c,d){b.superClass.call(this,d);this.uniqueId=a++;this.background=new DivElement(document.body,"bBottomURLBG"+this.uniqueId);this.urlLeft=new DivElement(this.background,"bBottomURLLeft"+this.uniqueId);this.urlLeft.setURL(c.urlLeft,c.linkTextLeft,"BoardBottomURL",!0);this.urlRight=
4463new DivElement(this.background,"bBottomURLRight"+this.uniqueId);this.urlRight.setURL(c.urlRight,c.linkTextRight,"BoardBottomURL",!0)};inherit(b,BoardBottomWin);b.prototype.onResize=function(c){var d=this.getRect(c);c=c.cbcanvas.pixToZoom(c.nMarginW);var e=d.w;e-=2*c;this.background.setPos(d.left,d.top);this.background.setSize(e,d.h);e/=2;this.urlLeft.setPos(c,0);this.urlLeft.setSize(e,d.h);this.urlLeft.elDOM.className="BoardBottomURL";this.urlLeft.setFontSize(Math.max(4,d.h));this.urlLeft.setLeftAlign();
4464this.urlRight.setPos(e+c,0);this.urlRight.setSize(e,d.h);this.urlRight.elDOM.className="BoardBottomURL";this.urlRight.setFontSize(Math.max(4,d.h));this.urlRight.setRightAlign();if(glApp.config.versionChessBaseCom||glApp.config.transparent)this.urlLeft.linkNode.style.color="Black",this.urlRight.linkNode.style.color="Black"};b.prototype.destroy=function(){this.background.destroy()};b.prototype.setVisible=function(c){this.background.setVisible(c)};return b}();"use strict";
4465var BoardSideIcon=function(){var a=0,b=function(c,d){this.config=d;this.myId=++a;$(c.cbcanvas.canvas);this.img=$(String.f("<img src='{0}' class='{1}' id='cbBoardIcon{2}'/>",d.url,d.cssClass,this.myId));$(document.body).append(this.img);$(this.img).css("position","absolute");this.width=this.height=d.width||32};b.prototype.destroy=function(){$("#cbBoardIcon"+this.myId).remove()};b.prototype.setVisible=function(c){c?$(this.img).show():$(this.img).hide()};b.prototype.getDesiredWidth=function(c,d,e){this.width=
4466this.height=this.calcWidth(c,e);return 0===this.config.desiredWidth?0:this.config.desiredWidth||this.width};b.prototype.calcWidth=function(c,d){d=d.zoomToPix(this.config.width||48);return Math.min(d,c/this.config.boardFract)};b.prototype.onResize=function(c){var d=$(c.cbcanvas.canvas).offset().top,e=$
4466(c.cbcanvas.canvas).offset().left,f=c.cbcanvas.pixToZoomRect(c.getOuterRect());f.move(e,d);$(this.img).css("transition","0");$(this.img).css({left:f.left,top:f.top+f.h/2,width:this.width,height:this.width});
4467$(this.img).css("transition",this.config.transition||"left 0.8s, top 0.8s, width 0.5s, height 0.5s");(new Timer(function(){$(this.img).css({left:f.left+f.w-this.width/4,top:f.top+this.height/10})}.bind(this))).runOnce(0)};return b}();"use strict";
4468var BoardTitle=function(){var a=new CBColor(0,0,0,.3),b=new CBColor(210,255,170,.75),c=new CBColor(255,255,220,.9),d=1,e=function(f,g,h,k,l,m,n){this.board=f;this.uniqueId=d++;this.background=new DivElement(f.cbcanvas.canvas.parentNode,"bTitleBG"+this.uniqueId);l||(this.clock=new ClockElement(this.background));this.textEl=new DivElement(this.background,"bTitleText"+this.uniqueId);f.titleWin=this;this.onBoardCloseClick=g;this.textEl.setText(k||"Waiting for game...");$(this.textEl.elDOM).on("click",
4469h);$(this.textEl.elDOM).on("dblclick",m);this.clock&&($(this.clock.background.elDOM).on("click",h),$(this.clock.background.elDOM).on("dblclick",m));this.textEl.setBackgroundColor(a);this.textEl.setColor(c);this.textEl.setFontFamily(glApp.config.defaultCondensedFont);$(this.textEl).css("cursor","pointer");this.textEl.setBoxSizing("border-box");this.h=Math.round(f.cbcanvas.pixToZoom(this.calcHeight(f.height)))};e.prototype.destroy=function(){this.background.destroy()};e.prototype.displaysHeader=!0;
4470e.prototype.setText=function(f){this.textEl.setText(f);if(this.textW){f=this.getInitialFontH();do{this.textEl.setFontSize(f);--f;var g=this.textEl.getTextWidth();this.textEl.getTextHeight();LOG("TitleW:"+g)}while(4<f&&(this.textEl.getTextWidth()>this.textW-4||this.textEl.getTextHeight()>this.h-2))}};e.prototype.setVisible=function(f){this.background.setVisible(f)};e.prototype._selected=!1;e.prototype.markAsSelected=function(f){this._selected!=f&&((this._selected=f)?(this.textEl.setBackgroundColor(b),
4471this.textEl.setColor("black")):(this.textEl.setBackgroundColor(a),this.textEl.setColor(c)))};e.prototype.getClock=function(){return this.clock};e.prototype.getInitialFontH=function(){if(this.board){var f=Math.round(this.board.cbcanvas.pixToZoom(this.calcHeight(this.board.height)));f=Math.round(.65*f);8>f&&(f=8);return f}return 16};e.prototype.getDesiredHeight=function(f,g){return this.calcHeight(f)};e.prototype.calcHeight=function(f){var g=this.board?this.board.cbcanvas.zoomToPix(36):36;return Math.min(g,
4472f/16)};e.prototype.onResize=function(f){this.board=f;var g=f.cbcanvas.pixToZoomRect(f.getOuterRect());g.right--;var h=Math.round(f.cbcanvas.pixToZoom(this.calcHeight(f.height))),k=this.getInitialFontH();this.h=h;g.move(0,-this.h);g.h=this.h;this.btnW=this.btnEl?h:0;System.isMobile()&&this.btnEl&&this.btnW<System.pixToZoom(26)&&(this.btnW=System.pixToZoom(26));this.clockW=this.clock?Math.round(Math.min(260,.38*g.w)):0;g.w--;this.textW=g.w-this.clockW-this.btnW;this.background.setPos(g.left,g.top);
4473this.background.setSize(g.w,g.h);h=Math.max(1,Math.min(4,Math.round(Math.sqrt(g.w/100))));this.background.setBoxShadow(h,8*h,"rgba( 60, 30, 20, 0.5 )");this.clock&&this.clock.setPosSize(0,0,this.clockW,this.h);this.textEl.setPos(this.clockW,0);this.textEl.setSize(this.textW,this.h);this.textEl.setBorder(Math.max(1,f.cbcanvas.pixToZoom(1)),new CBColor(0,0,0,.5));this.markAsSelected(this._selected);this.textEl.setCenteredText();do this.textEl.setFontSize(k),--k,this.textEl.getTextWidth(),this.textEl.getTextHeight();
4474while(4<k&&(this.textEl.getTextWidth()>this.textW||this.textEl.getTextHeight()>this.h-2));this.textEl.setVerticalAlign(!0);this.btnEl&&(this.btnEl.setPos(g.w-this.btnW,this.h-this.btnW),this.btnEl.setSize(this.btnW,this.btnW))};e.prototype.onCloseClicked=function(f){if(void 0!==this.onBoardCloseClick)this.onBoardCloseClick(f)};return e}();"use strict";
4475var MultiBoard=function(){var a=function(b,c,d,e,f){this.cbcanvas=b;this.boardArea=new BoardArea(b,c,d,e);this.width=c;this.height=d;this.idStyleListener=glSettings.addOnBoardStyleListener(this.onBoardStyle.bind(this));this.keyDownHandlerId=glApp.commands.registerkeyDownHandler(this);this.nInPage=f||0};a.prototype.destroy=function(){glSettings.removeOnBoardStyleListener(this.idStyleListener);glApp.commands.unregisterkeyDownHandler(this.keyDownHandlerId)};a.prototype.onKeyDown=function(b){var c=!0;
4476switch(b.getKey()){default:c=!1;break;case b.TAB:this.selectNextBoard()}return c};a.prototype.onBoardStyle=function(b,c){glApp.setBoardTextures(BoardTextures.prototype.getTexturesForPieceStyle(b));if(this.boardArea.boards)for(var d=0;d<this.boardArea.boards.length;d++)this.boardArea.boards[d].onBoardStyle(b,c);this.boardArea.calcGeometry()};a.prototype.addBoard=function(b,c,d){0==this.boardArea.boards.length&&this.boardArea.clearBackgroun
4476d();d||b.addTitle(function(){return this.onBoardCloseClick(b,
4477c)}.bind(this),!1,function(f){return this.onDoubleClick(f)}.bind(this));glApp.isBoardOnlyApp()&&glApp.useBottomURL&&glApp.GetBottomURLData&&100<window.innerHeight&&(b.bottomWin=new BoardDoubleURL(glApp.GetBottomURLData(),{hScale:25,hMax:16,spacing:3,rightAlign:!0}));b.fnBoardClick=this.onBoardClick.bind(this);d=!1;if(null!=c){b.idGame=c;for(var e=0;!d&&e<this.boardArea.boards.length;e++)d=this.boardArea.boards[e].idGame==c}d||this.boardArea.addBoard(b)};a.prototype.count=function(){return this.boardArea&&
4478this.boardArea.boards?this.boardArea.boards.length:0};a.prototype.removeBoard=function(b){b&&(this.cbcanvas.block(!0),this.boardArea.removeBoard(b),this.boardArea.calcGeometry(),this.markSelectedBoard())};a.prototype.onDestroyDOM=function(){this.removeAllBoards()};a.prototype.removeAllBoards=function(){this.boardArea.removeAllBoards();this.cbcanvas.requestRedraw();this.drawBackground(this.cbcanvas.bufferCtx)};a.prototype.setNotation=function(b){this.notation=b};a.prototype.beforeResize=function(){this.boardArea.beforeResize()};
4479a.prototype.resize=function(b,c){this.width=b;this.height=c;this.boardArea.resize(b,c);this.markSelectedBoard()};a.prototype.setBoardsSameSize=function(b){this.boardArea.setBoardsSameSize(b)};a.prototype.markSelectedBoard=function(){if(this.idSelected){var b=this.getBoardById(this.idSelected);b&&b.markAsSelected(!0)}};a.prototype.draw=function(b){this.boardArea.draw(b)};a.prototype.drawForeground=function(b){this.boardArea.drawForeground(b)};a.prototype.drawBackground=function(b){this.boardArea.drawBackground(b)};
4480a.prototype.clearBackground=function(){};a.prototype.resizeCanvas=function(){this.cbcanvas&&(this.cbcanvas.reResize(),this.cbcanvas.afterResize=function(){this.markSelectedBoard()}.bind(this))};a.prototype.refreshBoards=function(){this.boardArea.calcGeometry();this.markSelectedBoard()};a.prototype.calcGeometry=function(){this.boardArea.calcGeometry()};a.prototype.onMouseDown=function(b,c){if(!glApp.lobby.boardAreaClickHandler||0!=b.button&&"undefined"!=typeof b.button)this.boardArea.onMouseDown(b,
4481c);else glApp.lobby.boardAreaClickHandler(b)};a.prototype.onMouseUp=function(b,c){this.boardArea.onMouseUp(b,c)};a.prototype.onMouseMove=function(b,c){this.boardArea.onMouseMove(b,c)};a.prototype.onMouseWheel=function(b,c){};a.prototype.onMouseEnter=function(b,c){this.boardArea.onMouseEnter(b,c)};a.prototype.onMouseLeave=function(b,c){this.boardArea.onMouseLeave(b,c)};a.prototype.onDoubleClick=function(b){if(this.onDblClick){var c=this.getBoardById(this.idSelected);if(c)this.onDblClick(c.idGame,b)}glApp.lobby.boardAreaDClickHandler&&
44820==b.button&&glApp.lobby.boardAreaDClickHandler(b)};a.prototype.toggleAnnoField=function(){glApp.panelMgr.toggleAnnoField&&glApp.panelMgr.toggleAnnoField()};a.prototype.openAnnoField=function(){glApp.panelMgr.openAnnoField()};a.prototype.isAnnoFieldOpen=function(){return glApp.panelMgr.isAnnoFieldOpen()};a.prototype.closeAnnoField=function(){glApp.panelMgr.closeAnnoField()};a.prototype.setAnnoFieldText=function(b){glApp.panelMgr.setAnnoFieldText(b)};a.prototype.outEngineMsg=function(b,c){};a.prototype.onBoardCloseClick=
4483function(b,c){if(!b.blockClose&&1!=this.boardArea.boards.length&&(this.removeBoard(b),void 0!==this.onCloseBoard))this.onCloseBoard(c,this.nInPage)};a.prototype.onBoardClick=function(b,c,d){if(b!=this.clickedBoardId){d=this.getBoardById(b);this.mark(d);if(void 0!==this.onClickBoard)this.onClickBoard(d.idGame,c);this.clickedBoardId=b}};a.prototype.markBoard=function(b){b<this.boardArea.boards.length&&this.mark(this.boardArea.boards[b])};a.prototype.mark=function(b){var c=this.getBoardById(this.idSelected);
4484c&&c!==b&&c.markAsSelected(!1);b?(b.markAsSelected(!0),this.idSelected=b.uniqueId):this.idSelected=-1};a.prototype.markBoardByGameId=function(b){b=this.getBoardByGameId(b);this.mark(b)};a.prototype.selectNextBoard=function(){var b=this.idSelected,c=this.boardArea.boards.findIndex(function(d){return d.uniqueId==b});0<=c&&(c+=1,c>=this.boardArea.boards.length&&(c=0));this.markBoard(c);if(this.onClickBoard&&this.boardArea.boards[c])this.onClickBoard(this.boardArea.boards[c].idGame)};a.prototype.getBoardByGameId=
4485function(b){return this.boardArea.boards.find(function(c){return c.idGame==b})};a.prototype.getBoardById=function(b){if(b)return this.boardArea.boards.find(function(c){return c.uniqueId==b})};return a}();"use strict";
4486var ChatElement=function(){var a=function(b,c){this.nInPage=b;this.fnOnEnter=c;this.myTabInx=1;this.nClubRoomPlayers=this.nReceivers=0};a.prototype.initElem=function(b,c){this.options=c;this.elementId=b="string"==typeof b?b:$(b).attr("id");b=$("#"+b);b.addClass("cbChatContainer");b[0].style.position="relative";this.elem=b[0];c=document.createElement("div");c.id=this.elementId+"-out";var d=document.createElement("input");d.id=this.elementId+"-in";d.placeholder="Please log in with your ChessBase Account to type chat here.";
4487this.createTitle();b.append(c);b.append(d);c=$(c);d=$(d);c[0].style.width="calc( 100% - 2px )";c[0].style.height="100%";c.addClass("cbChatOut");d.addClass("cbChatInp");c[0].style.width="calc( 100% - 8px) ";
4487if(this.options.toolbar){var e=$(String.f('<div class="{0}" id="{1}-tb"></div>',"cbChatToolBar",this.elementId));b.append(e);this._initToolBar(e)}d.keypress(this.inputKeypress.bind(this));d.focus(this.onFocus.bind(this));d.blur(this.onBlur.bind(this));if(this.elem&&(c.on("mousewheel",this.onMouseWheel.bind(this)).on("DOMMouseScroll",
4488this.onMouseWheel.bind(this)),CBElement.isEventSupported("touchstart")&&(c.on("touchstart",this.onButtonDown.bind(this)).on("touchend",this.onButtonUp.bind(this)).on("touchleave touchcancel",this.onMouseLeave.bind(this)),this.supportsTouch=!0),CBElement.isEventSupported("mousedown")))c.on("mousedown",this.onButtonDown.bind(this)).on("mouseup",this.onButtonUp.bind(this)).on("mouseleave",this.onMouseLeave.bind(this)).on("dblclick",this.onDoubleClick.bind(this));b.resize(this.resize.bind(this));var f;
4489this.options&&this.options.noInvite||(f=this.isOnLiveChess()?this.getInviteLoginText():"Click <a href=https://live.chessbase.com/Logon?returnurl="+encodeURIComponent(document.location)+' target="_blank">here to login</a> with your free ChessBase Account and type chat below.');this._addLine(f,"cbChatLine cbChatSeparator");this.addListeners()};a.prototype.addListeners=function(){glApp.lobby&&glApp.lobby.addOnPlayersAddedListener&&(glApp.lobby.addOnPlayersAddedListener(this.onPlayersAdded.bind(this)),
4490glApp.lobby.addOnPlayersRemovedListener(this.onPlayersRemoved.bind(this)),glApp.lobby.addOnSwitchGroupsListener(this.onSwitchGroups.bind(this)))};a.prototype.onSwitchGroups=function(b){glApp.lobby.isInSpecialRoom()&&this.toGeneralChat()};a.prototype.onPlayersAdded=function(b){glApp.lobby&&glApp.lobby.isInSpecialRoom()&&this.setNClubRoomPlayers(this.nClubRoomPlayers+b.length)};a.prototype.onPlayersRemoved=function(b){glApp.lobby&&glApp.lobby.isInSpecialRoom()&&this.setNClubRoomPlayers(Math.max(0,this.nClubRoomPlayers-
4491b.length))};a.prototype.setNChannelReceivers=function(b){glApp.lobby.isInSpecialRoom()||(this.nChannelReceivers=this.nReceivers=b,this.setInputPlaceHolder())};a.prototype.setNClubRoomPlayers=function(b){this.nClubRoomPlayers=this.nReceivers=b;this.setInputPlaceHolder()};a.prototype.setNKibitzChatReceivers=function(b){this.nKibitzReceivers=this.nReceivers=b;this.setInputPlaceHolder()};a.prototype.createTitle=function(){var b=$(String.f('<div id="{0}-title" class="cbChatTitle">Chat And Info</div>',
4492this.elementId));$(this.elem).append(b)};a.prototype.setTitle=function(b){$("#"+this.elementId+"-title").text(b)};a.prototype.setFnSendChat=function(b){this.fnOnEnter=b};a.prototype.getInviteLoginText=function(){return'<a href="https://live.chessbase.com/logon?returnurl='+encodeURIComponent(document.location)+'">Log in</a> with your free ChessBase Account and type chat below.'};a.prototype.isOnLiveChess=function(){return-1!=document.URL.search(/live.chessbase.com/i)||-1!=document.URL.search(/live.playchess.com/i)};
4493a.prototype.$Out=function(){return $("#"+this.elementId+"-out")};a.prototype.$In=function(){return $("#"+this.elementId+"-in")};a.prototype.toGeneralChat=function(){this.setTitle(String.f("{0} ({1})",lm.CHAT,lm.TO_ALL));this.options.toolbar&&$("#radBtnall"+this.nInPage).length&&($("#radBtnall"+this.nInPage).jqxRadioButton("check"),$("#radBtnopp"+this.nInPage).jqxRadioButton("uncheck"),$("#radBtnSpanopp"+this.nInPage).text(lm.TO_OPPONENT),$("#radBtnSpanopp"+this.nInPage).jqxRadioButton("disable"))};
4494a.prototype.toKibitzerChat=function(){this.setTitle(lm.TO_KIBITZERS);this.options.toolbar&&$("#radBtnall"+this.nInPage).length&&(this.toKibitzers=!0,this.toOpponent=this.toPlayer=!1,$("#radBtnopp"+this.nInPage).jqxRadioButton("check"),$("#radBtnSpanopp"+this.nInPage).text(lm.TO_KIBITZERS),$("#radBtnall"+this.nInPage).jqxRadioButton("uncheck"))};a.prototype.toOpponentChat=function(b){this.toPlayer=this.toKibitzers=!1;this.toOpponent=!0;this.signalIndividualChat(b);this.fnOnEnter=this.options.sendOpponent};
4495a.prototype.signalIndividualChat=function(b){this.setTitle("Chat with "+b);this.options.toolbar&&$("#radBtnall"+this.nInPage).length&&($("#radBtnopp"+this.nInPage).jqxRadioButton("check"),$("#radBtnall"+this.nInPage).jqxRadioButton("uncheck"),$("#radBtnSpanopp"+this.nInPage).text("-> "+b),this.receiverName=b)};a.prototype.setReceiverId=function(b,c){if(c=c||glApp.lobby.lists.clientNameMap[b])this.toKibitzers=!1,this.toPlayer=!0,this.toOpponent=!1,this.signalIndividualChat(c),this.fnOnEnter=this.options.sendPlayer,
4496this.idReceiver=b};a.prototype.sendTokenChat=function(b,c){this.toPlayer&&this.idReceiver?(this.outMyGameChat(c),glApp.lobby.sendChat(c,this.idReceiver,b)):this.toOpponent&&(this.outMyGameChat(c),glApp.lobby.playingSession.sendTokenChat(b,c))};a.prototype._fnReceiverClick=function(b,c){this.fnOnEnter=null;if(c)switch(b){case "opp":case "one":this.toKibitzers?(this.nReceivers=this.nKibitzReceivers,this.fnOnEnter=this.options.sendKibitzers):(this.nReceivers=1,this.toPlayer?this.fnOnEnter=this.options.sendPlayer:
4497this.receiverName&&(this.fnOnEnter=this.options.sendOpponent));this.fnOnEnter?this.setInputPlaceHolder():this.setInputPlaceHolderMsg(lm.PLEASE_SELECT_RECEIVER);break;case "all":this.setTitle(lm.TO_ALL),glApp.lobby.isInClubRoom()?this.nReceivers=this.nClubRoomPlayers:this.nReceivers=this.nChannelReceivers,this.setInputPlaceHolder(),this.fnOnEnter=this.options.sendGeneral}return null!=this.fnOnEnter};a.prototype.resize=function(){var b=0;this.options.toolbar&&(b=32);var c=$("#"+this.elementId),d=$("#"+
4498this.elementId+"-title"),e=$("#"+this.elementId+"-in"),f=$("#"+this.elementId+"-out"),g=f.width();e.outerWidth(g-8);e.height(20);c=c.height();e=e.outerHeight(!0);d=d.outerHeight(!0);d=c-d-e-b;0>d&&(d=10);f[0].style.height=d+"px";f[0].style.width="100%";f=$("#"+this.elementId+"-tb");f.length&&(f[0].style.height=b+"px")};a.prototype.hasFocus=function(){return $("#"+this.elementId+"-in").is(":focus")};a.prototype.onFocus=function(b){this._hasFocus=!0};a.prototype.onBlur=function(b){this._hasFocus=!1};
4499a.prototype.inputKeypress=function(b){13==b.keyCode&&(b=this.$In().val())&&(this.fnOnEnter&&(b=$($.parseHTML(b)).text(),b.length&&this.fnOnEnter(this.nInPage,b)),this.$In().val(""))};a.prototype.onButtonDown=function(b){this.buttonDown=!0};a.prototype.onButtonUp=function(b){this.buttonDown=!1};a.prototype.onDoubleClick=function(b){};a.prototype.onMouseWheel=function(b){};a.prototype.onMouseLeave=function(b){this.buttonDown=!1};a.prototype.out=function(b,c,d){"string"===typeof b?this.add(b,c,d):b.isToChannel()||
4500b.isToGroup()?this.isMyChat(b)||this.addChannelMsg(b):b.isOpponentChat?this.addIndividualMsg(b):b.isToSession()||b.isToObservers()||b.isToObserversAndPlayers()?this.addGameMsg(b):b.isPrivate()||b.isToIndividuals()?this.addIndividualMsg(b):this.add(b.toString(),c)};a.prototype.isMyChat=function(b){return b.idSender===glApp.lobby.getNIdBound()};a.prototype.outHtml=function(b){this._addLine(b);this._scrollToEnd()};a.prototype.outMyChannelChat=function(b){b=String.formatEx('<span class="cbChannelSender">-> {1}:</span><span class="cbChannelChat cbMyChat">{0}</span>',
4501b,lm.TO_ALL);this._addLine(b,"cbChatBubble cbChatRight");this._scrollToEnd()};a.prototype.outMyGameChat=function(b){b=String.formatEx('<span class="cbGameChatSender">-> {1}</span><span class="cbGameChat cbMyChat">{0}</span>',b,this.receiverName);this._addLine(b,"cbChatBubble cbChatRight");this._scrollToEnd()};a.prototype.addChannelMsg=function(b){if(b.isToGroup()||!glApp.lobby.isInSpecialRoom())b=String.formatEx('<span class="cbChannelSender">{0} ({1}): </span><span class="cbChannelChat">{1}</span>',
4502b.strSender,b.strMsg,lm.TO_ALL),this._addLine(b,"cbChatBubble cbChatLeft cbChannelBubble"),this._scrollToEnd()};a.prototype.addGameMsg=function(b){b=String.formatEx('<span class="cbGameChatSender">{0}:</span><span class="cbGameChat">{1}</span>',b.strSender,b.strMsg);this._addLine(b,"cbChatBubble cbChatLeft");this._scrollToEnd()};a.lineId=0;a.prototype.addIndividualMsg=function(b){var c="chatLine"+(++a.lineId).toString();c=String.formatEx('<span id="{2}"><span class="cbGameChatSender">{0}:</span><span class="cbGameChat">{1}</span></span>',
4503b.strSender,b.strMsg,c);c=this._addLine(c,"cbChatBubble cbChatLeft");this._scrollToEnd();$(c).click(function(){glApp.lobby.lists.registerClientName(b.idSender,b.strSender);this.setReceiverId(b.idSender)}.bind(this));glApp.panelMgr.signalIncomingChat(b.strSender)};a.prototype._scrollToEnd=function(){var b=$("#"+this.elementId+"-out");if(b.offset()){var c=b.offset().top,d=b.scrollTop(),e=b.find("div").last().offset().top;b.scrollTop(e-c+d)}};
4503a.prototype.add=function(b,c,d){if(b){var e=$("#"+this.elementId+
4504"-out"),f=!1;d&&(d=e.find("div").last(),d.length&&(d.text(d.text()+b),f=!0));!f&&(f=document.createElement("div"),b=$.parseHTML(b))&&($(f).html(b),$(f).addClass("cbChatLine"),$(f).addClass(c),e.append(f));this._scrollToEnd()}};a.prototype.addKibitzChat=function(b,c,d,e,f,g){if(b||f)this.addOriginLine(b,c,e,f),b=$($.parseHTML(d)).text(),e=this._addLine(b,"cbChatLine"),$(e).addClass("cbChatSeparator"),b=$("#"+this.elementId+"-out"),c=b.offset().top,d=b.scrollTop(),g&&(g=$(e).offset().top,b.scrollTop(g-
4505c+d))};a.prototype.addOriginLine=function(b,c,d,e){var f="";c&&c.white?(f=c.white.getListStr(1),(c=c.black.getListStr(1))&&(f+="-"+c)):"String "==typeof c&&(f=c);c="";var g="cbSessionName";d&&d.idGame&&(c=String.formatEx('onClick = "glApp.panelMgr.addGameById( {0}, {1}, {2} );"',this.nInPage,d.idGame,d.mvInx),g="cbChatGameLink");d="cbSender";b==this.user&&(d+=" cbChatUserName cbBigUserName");b=e?String.formatEx('<span class="cbSessionName {2}"{1}>{0}:</span>',f,c,g):String.formatEx('<span class="{4}">{0}:</span><span class="cbSessionName {3}"{2}>({1})</span>',
4506b,f,c,g,d);f="cbChatOrigin";e&&(f+=" cbAutoChat");this._addLine(b,f)};a.prototype.clear=function(){$("#"+this.elementId+"-out").html("")};a.prototype.outLoginOk=function(b){this.out("");this.user=b;b=String.formatEx("{0}<span class='cbChatUserName'>{1}</span>","Hello, ",b);this._addLine(b,"cbChatLoginOk cbChatSeparator");this.setInputPlaceHolder()};a.prototype.setInputPlaceHolder=function(){var b=lm.TYPE_CHAT_HERE;this.nReceivers&&(b+=" ("+this.nReceivers+" "+lm.RECEIVERS+")");this.setInputPlaceHolderMsg(b)};
4507a.prototype.setInputPlaceHolderMsg=function(b){var c=$("#"+this.elementId+"-in");c&&c.attr("placeholder",b)};a.prototype.inviteLogin=function(){var b=this.getInviteLoginText();this._addLine(b,"cbChatLine")};a.prototype._addLine=function(b,c){var d=$("#"+this.elementId+"-out"),e=document.createElement("div");c&&$(e).addClass(c);$(e).html($.parseHTML(b));d.append(e);return e};a.prototype._initToolBar=function(b){var c=this;$(b).jqxToolBar({width:"100%",tools:"custom | custom | button",theme:glApp.config.jqxTheme,
4508initTools:function(d,e,f){switch(e){case 0:return c._createRadioButton(f,lm.TO_OPPONENT,"opp",160,22,!1);case 1:return c._createRadioButton(f,lm.TO_ALL,"all",160,22,!0);case 2:f.jqxButton({width:130,height:22}),f.text("Shortcuts"),f.click(function(g){c._fnReceiverClick("opp",!0)&&(c.signalIndividualChat(c.receiverName),glApp.panelMgr.openChatMenu(g,f,50))})}}})};a.prototype._createRadioButton=function(b,c,d,e,f,g){c=$(String.f("<div id={1}><span id={2}>{0}</span></div>",c,"radBtn"+d+this.nInPage,
4509"radBtnSpan"+d+this.nInPage));b.append(c);c.jqxRadioButton({width:e,height:f,checked:g});var h=this;c.on("change",function(k){h._fnReceiverClick(d,k.args.checked)})};a.prototype.onTabSelect=function(b){b.args.item==this.myTabInx&&this._scrollToEnd()};return a}();ChatElement.factory=function(a,b,c,d){b=new ChatElement(b||0,c);b.initElem(a,d);return b};"use strict";
4510var LiveBookElement=function(){var a=function(d,e,f){this.nInPage=d;this.hasListeners=!1;this.fnGetKernel=e;this.ticket=f;this.stampToday=TBrainMove.getTimeStampToday();this.entries=[];this.config={minVisits:5};this.curMove=0;this.initListeners()};a.prototype.initElem=function(d,e){this.elementId=d="string"==typeof d?d:d.id;d=$("#"+d);d.addClass("cbBookContainer");this.elem=d[0];d.text(lm.CONNECTING);this.createGrid(d.width());if(glApp.acc)this.onAccountTypeListener(glApp.acc)};a.prototype.resize=
4511function(){$(this.elem).jsGrid("option","fields",this.getGridFields($(this.elem).width()));$(this.elem).jsGrid("option","height","100%");$(this.elem).jsGrid("option","width","100%");this.hasListeners||this.initListeners();$(this.elem).jsGrid("refresh")};a.prototype.createGrid=function(d){$(this.elem).jsGrid({width:"100%",height:"100%",heading:!0,filtering:!1,editing:!1,inserting:!1,updateOnResize:!0,sorting:!0,autoload:!0,noDataContent:"Replay and check the LiveBook here",rowClick:function(e){},controller:{loadData:function(e){e=
4512[];for(var f=0;f<this.entries.length;f++){var g={Move:this.entries[f].line,N:this.entries[f].getStrNGames(),Visits:this.entries[f].getStrNVisits(),Players:this.entries[f].getPlayers(),Result:this.entries[f].getStrResult(),Elo:this.entries[f].getStrElo()};e.push(g)}return e}.bind(this)},fields:this.getGridFields(d)});this.gridCreated=!0};a.prototype.getNGamesItemTemplate=function(d,e){if(this.curMove<b||this.isStandard)return"-"==d?String.formatEx('<span class="jsg-liveVisits">({0})</span>',e.Visits):
4513d;d="https://live.chessbase.com/logon?returnurl="+encodeURIComponent(document.location);return String.formatEx('<a class="jsg-premiumRequired" href="{0}">Login</a>',d)};a.prototype.getPlayersItemTemplate=function(d,e){if(0==this.curMove&&!this.isPremium)return"---";if(this.curMove<c||this.isPremium)return d;if(this.isStandard)return String.formatEx('<a class="jsg-premiumRequired" href="{0}">Premium Required</a>',"https://account.chessbase.com/en/matrix");d="https://live.chessbase.com/logon?returnurl="+
4514encodeURIComponent(document.location);return String.formatEx('<a class="jsg-premiumRequired" href="{0}">Premium Required</a>',d)};a.prototype.getGridFields=function(d){d=d||400;if(350>d)return[{name:"Move",type:"text",width:30,css:"jsg-liveMove"},{name:"N",type:"number",width:25,css:"jsg-liveNGames",itemTemplate:this.getNGamesItemTemplate.bind(this)},{name:"Result",type:"number",width:25,css:"jsg-liveResult"},{name:"Elo",type:"number",width:20,css:"jsg-liveElo"}];var e=[{name:"Move",type:"text",width:16,
4515css:"jsg-liveMove"},{name:"N",type:"number",width:16,css:"jsg-liveNGames",itemTemplate:this.getNGamesItemTemplate.bind(this)},{name:"Result",type:"number",width:11,css:"jsg-liveResult"},{name:"Elo",type:"number",width:7,css:"jsg-liveElo"}];320<d&&(e=e.concat([{name:"Players",type:"text",width:50,css:"jsg-livePlayers",itemTemplate:this.getPlayersItemTemplate.bind(this)}]));return e};a.prototype.isVisible=function(){return $(this.elem).is(":visible")};var b=12,c=7;a.prototype.liveBookListener=function(d){if(!this.ticket||
4516this.ticket==d.ticket){this.entries=[];var e="Position not in LiveBook";d.training&&(e="Training Position");$(this.elem).jsGrid("option","noDataContent",e);if(!this.isVisible())this.lbInfo=d;else if(this.fnGetKernel()&&this.fnGetKernel().getCurPos){if(d.moves.length){e=d.moves;var f=this.fnGetKernel().getCurPos(),g=f.Vj();6>=f.getPieces().length&&(d.sorted||TBrainMoveList.sortEval(e,g==Side.BLACK));if(!this.fnGetKernel())return;this.curMove=this.fnGetKernel().getCurPos().getPlyNum();for(e=f=0;e<d.moves.length;e++)f+=
4517d.moves[e].getNVisits();this.stampToday=TBrainMove.getTimeStampToday();f=6>=this.fnGetKernel().getCurPos().getPieces().length;this.entries=[];for(e=0;e<d.moves.length;e++)if(g=d.moves[e],f||this.passesMoveFilter(g)){var h=g.getMoveRecord();g={line:this.generateLine(d.position,h),nGames:g.m_performanceStats.getNGames(),Result:Math.round(g.m_performanceStats.getFPercent(d.position.isBTM()))+"%",elo:Math.round(g.m_performanceStats.getSortEloAv()),from:h.from,to:h.to,players:[],eval:g.getNEval(),nVisits:g.getNVisits(),
4518getStrElo:function(){return this.elo?this.elo:""},getStrNGames:function(){return this.nGames?this.nGames.toLocaleStr
4518ing(Language.getStrUserLanguage(),{maximumFractionDigits:0}):"-"},getStrNVisits:function(){return this.nVisits?this.nVisits.toLocaleString(Language.getStrUserLanguage(),{maximumFractionDigits:0}):""},getPlayers:function(){for(var k=[],l=0;l<this.players.length&&4>l;l++){var m=this.players[l].name;1600<window.innerWidth&&0==k.length&&this.players[l].year&&(m+=" ("+this.players[l].year+
4519")");k.push(m)}return k.join(", ")},getStrResult:function(){if(this.nGames)return this.Result;var k=this.eval;if(29750<Math.abs(k)){var l="#"+(3E4-Math.abs(k));0>k&&(l="-"+l);return l}if(27998==Math.abs(k))return 0<k?"+-":"-+";l="";0<k&&(l="+");return l+(.01*k).toFixed(2)}};this.entries.push(g)}this.entries=this.entries.sort(function(k,l){return l.nGames==k.nGames?l.nVisits-k.nVisits:l.nGames-k.nGames});1<this.entries.length&&this.searchOnlineDB()}$(this.elem).jsGrid("loadData")}}};a.prototype.passesMoveFilter=
4520function(d){var e=this.config.minVisits||2;return(0<d.getNGames()||300>this.stampToday-d.m_nTimeStamp||d.isMyMove)&&(d.getNVisits()>=e||d.hasEval())};a.prototype.searchOnlineDB=function(){if(glApp.onlineLobby&&glApp.panelMgr.usesOnlineDB&&glApp.panelMgr.usesOnlineDB()&&this.isPremium){glApp.onlineLobby.isConnected()||glApp.onlineLobby.connect();var d=new SearchMask;d.setSearchBoard(this.fnGetKernel().game.getCurPos().board,this.fnGetKernel().game.getCurPos().Vj());d.setUseBoard(!0);glApp.onlineLobby.search(d,
4521100,this.fnGetKernel().game.getMoveNo())}};a.prototype.onDBGamesListener=function(d){if(this.isVisible()){for(var e=!1,f=0;f<this.entries.length;f++)this.entries[f].players=[];for(var g=0;g<d.length;g++)if(d[g].nFlags&OnlineEntryEnum.FLAGS_ONLINE_GAME&&glApp.onlineLobby.firstMove<d[g].aGame.getCurLine().length){var h=d[g].aGame.getCurLine()[glApp.onlineLobby.firstMove];for(f=0;f<this.entries.length;f++)if(this.entries[f].from==h.from&&this.entries[f].to==h.to){var k="",l=0,m=d[g].aGame.hdr.date.year;
4522glApp.onlineLobby.firstMove&1?(k=d[g].aGame.hdr.black.getListStr(0),l=d[g].aGame.hdr.eloWh):(k=d[g].aGame.hdr.white.getListStr(0),l=d[g].aGame.hdr.eloBl);for(var n=!1,r=0;!n&&r<this.entries[f].players.length;r++)n=this.entries[f].players[r].name==k;if(!n){this.entries[f].players.push({name:k,elo:l,year:m});e=!0;break}}}if(e){for(f=0;f<this.entries.length;f++)this.entries[f].players=this.entries[f].players.sort(function(t,u){return u.elo-t.elo}).filter(function(t){return 2400<t.elo}),8<this.entries[f].players.length&&
4523(this.entries[f].players.length=8),this.entries[f].players=this.entries[f].players.sort(function(t,u){return u.year==t.year?u.elo-t.elo:u.year-t.year});$(this.elem).jsGrid("render")}}};a.prototype.generateLine=function(d,e){d=this.convertJSONLine(ObjUtil.clone(d),e);e=new NotationGenerator(V5);for(var f="",g=this.fnGetKernel().game.getStartPos().getBTM(),h=0;h<d.length;h++){var k=e.getMoveNota(d[h]),l=e.getStrMoveNumInLine(h,this.fnGetKernel().getCurPos().getPlyNum(),g);f+=l+k;h<d.length-1&&(f+=" ")}return f};
4524a.prototype.convertJSONLine=function(d,e){var f=[];d.isLegalMove(e)&&(d.preCalcCtx(e),d.makeMove(e),d.postCalcCtx(e,!0),f.push(e));return f};a.prototype.loginListener=function(d){};a.prototype.onAccountTypeListener=function(d){this.isPremium=3==d.type;this.isStandard=2==d.type||3==d.type};a.prototype.initListeners=function(){glApp.aTBLobby&&(this.hasListeners=!0,glApp.aTBLobby.addOnLiveBookDisplayListener(this.liveBookListener.bind(this)));glApp.onlineLobby&&glApp.onlineLobby.addOnGamesListener(this.onDBGamesListener.bind(this));
4525glApp.addOnAccountTypeListener(this.onAccountTypeListener.bind(this))};return a}();LiveBookElement.factory=function(a,b,c,d){b=new LiveBookElement(b||0,c,d);b.initElem(a);return b};"use strict";
4526let GuessingElement=function(){var a=function(e){this.nInPage=e},b,c,d={};a.prototype.initElem=function(e){this.elementId=e;e=$("#"+e);e.addClass("cbGuessingContainer");e[0].style.position="relative";var f="<div class='overlay'></div>"+String.f("<span id='GuessMoveTitle{0}' class='GuessMoveTitle'></span>",this.nInPage);f=f+"<br /><br />"+String.f("<div id='TopVotersDiv{0}' class='TopVotersDiv'></div>",this.nInPage);f+=String.f("<div id='TopVotersButtons{0}' class='TopVotersButtons'>",this.nInPage);
4527f=f+"<table class='topVotersTable'><tr align='center'>"+String.f("<td><button id='btnBackToMoveList{0}'>Move List</button></td>",this.nInPage);f=f+"</tr></table></div>"+String.f("<div id='GuessMoveDiv{0}' class='GuessMoveDiv'></div>",this.nInPage);f+=String.f("<div id='GuessMoveButtons{0}' class='GuessMoveButtons'></div>",this.nInPage);f+=String.f("<div id='GuessMoveOutput{0}' class='GuessMoveOutput'></div>",this.nInPage);e.html(f);var g=this.nInPage;$("#btnBackToMoveList"+this.nInPage).jqxButton({width:80,
4528height:30,theme:"chessbase"});$(String.f("#btnBackToMoveList{0}",this.nInPage)).unbind("click").bind("click",function(){$("#TopVotersDiv"+g).hide();$("#TopVotersButtons"+g).hide();$("#GuessMoveDiv"+g).show();$("#GuessMoveButtons"+g).show();$("#GuessMoveOutput"+g).show()});this.elem=e[0];this.showGuessMoveElements()};a.prototype.isVisible=function(e){return $("#GuessMoveTitle"+e).is(":visible")};a.prototype.showGuessMoveElements=function(){$("#TopVotersDiv"+this.nInPage).hide();$("#TopVotersButtons"+
4529this.nInPage).hide();$("#GuessMoveDiv"+this.nInPage).show();$("#GuessMoveButtons"+this.nInPage).show();$("#GuessMoveOutput"+this.nInPage).show()};a.prototype.requestMoveList=function(e){this.isVisible(e)&&(e=glApp.panelMgr.modules[e].getKernel(),glApp.lobby&&glApp.lobby.requestGuessMoveList&&e.game.stk.Top().isLineEnd()&&(c=e.idGame,glApp.lobby.requestGuessMoveList(e.idGame,e.getMoveNo(),!1)))};a.prototype.toggleVoteTable=function(e){e?($(String.f(".voteTable")).show(),$(String.f(".betTable")).hide()):
4530($(String.f(".voteTable")).hide(),$(String.f(".betTable")).show())};a.prototype.populateGuessMoveList=function(e,f){var g=$(String.f("<table></table>",this.nInPage));f?($(g).removeClass("voteTable"),$(g).addClass("betTable")):($(g).removeClass("betTable"),$(g).addClass("voteTable"));var h=$("<tr></tr>"),k=$("<td></td>").text("Move");h.append(k);f?(k=$("<td></td>").text("Quote"),h.append(k),k=$("<td></td>").text("Your Bet"),h.append(k)):(k=$("<td></td>").text("Votes"),h.append(k),k=$("<td></td>").text("Your Vote"),
4531h.append(k));g.append(h);for(h=0;h<e.length;h++)this.addRowToTable(e,h,g,f);h=$(String.f("#GuessMoveDiv{0}",this.nInPage));$(h).append(g);$(".colMove").click(function(){$(".selectedMove").removeClass("selectedMove");$(this).addClass("selectedMove")});this.addButtonsToTable(e,f);$("#btnVoteOnMove"+this.nInPage).jqxButton({width:100,height:30,theme:"chessbase"});
4531$("#btnRankingList"+this.nInPage).jqxButton({width:80,height:30,theme:"chessbase"});e=glApp.panelMgr.getKernel();e=e.game.hdr.white.last+" - "+
4532e.game.hdr.black.last;$("#GuessMoveTitle"+this.nInPage).text(e)};a.prototype.populateTopVotersDiv=function(e){e=""==e?"<br />No voting rankings available yet.<br /><br />":"<span class='RankHeader'>Current Rankings</span><br /><br /><table class='rankTable'>"+e+"</table><br />";$(String.f("#TopVotersDiv{0}",this.nInPage)).html(e)};a.prototype.populateGuessMoveOutput=function(e){$(String.f("#taOutput{0}",this.nInPage)).text(e)};a.prototype.addRowToTable=function(e,f,g,h){e=this.populateRow(e,f,h);
4533g.append(e)};a.prototype.populateRow=function(e,f,g){var h=$("<tr></tr>");e=e[f];$(h).data("MoveIndex",f);$(h).data("MoveNotation",e.moveNotation);g?($(h).data("Quote",e.quote),$(h).data("MyBet",e.moveNotation==d[c])):($(h).data("Votes",e.votes),$(h).data("MyVote",e.moveNotation==d[c]));f=$("<td class='colMove'></td>").text(e.moveNotation);h.append(f);g?(g=$("<td class='colQuote'></td>").text(e.quote),h.append(g),e=$("<td class='colMyBet'>"+(e.moveNotation==d[c]?"My Bet":"")+"</td>"),h.append(e)):
4534(g=$("<td class='colVotes'></td>").text(e.votes),h.append(g),e=$("<td class='colMyVote'>"+(e.moveNotation==d[c]?"My Vote":"")+"</td>"),h.append(e));return h};a.prototype.addButtonsToTable=function(e,f){var g=$(String.f("<table class='buttonsTable'></table>",this.nInPage)),h=$("<tr align='center'></tr>");f?(f=String.f("<button id='btnBetSelectedMove{0}' class='betTable'>Bet Selected Move</button>",this.nInPage),f=$("<td class='colButtonBetSelectedMove'></td>").html(f),h.append(f)):(f=String.f("<button id='btnVoteOnMove{0}' class='voteTable'>Vote on Move</button>",
4535this.nInPage),f=$("<td class='colButtonVoteOnMove'></td>").html(f),h.append(f),f=String.f("<button id='btnRankingList{0}' class='voteTable'>Rankings</button>",this.nInPage),f=$("<td class='colButtonRankings'></td>").html(f),h.append(f));g.append(h);h=$(String.f("#GuessMoveButtons{0}",this.nInPage));$(h).append(g);$(String.f("#btnVoteOnMove{0}, #btnBetSelectedMove{0}",this.nInPage)).unbind("click").bind("click",function(){if(0<$(".selectedMove").length){var l=$(".selectedMove").closest("tr"),m=l.data("MoveIndex");
4536b=l=l.data("MoveNotation");confirm("Move: "+l)&&glApp.lobby&&(l=glApp.panelMgr.getKernel(),$(String.f(".voteTable")).is(":visible")?glApp.lobby.sendUserMoveVote(l.idGame,l.getMoveNo(),e[m].move,0):glApp.lobby.sendUserMoveBet(l.idGame,l.getMoveNo(),e[m].move,1))}});var k=this.nInPage;$(String.f("#btnRankingList{0}",this.nInPage)).unbind("click").bind("click",function(){if(glApp.lobby){let l=glApp.panelMgr.getKernel();glApp.lobby.requestRankVotersList(l.idGame);$("#TopVotersDiv"+k).show();$("#TopVotersButtons"+
4537k).show();$("#GuessMoveDiv"+k).hide();$("#GuessMoveButtons"+k).hide();$("#GuessMoveOutput"+k).hide()}})};
4537a.prototype.addOutputTextBox=function(){var e=$(String.f("<table id='tblOutput{0}' class='tblOutput'></table>",this.nInPage)),f=$("<tr align='center'></tr>"),g=String.f("<textarea readonly id='taOutput{0}' class='taOutput cbChatInp'></textarea>",this.nInPage);g=$("<td class='colVoteOutput'></td>").html(g);f.append(g);e.append(f);f=$(String.f("#GuessMoveOutput{0}",this.nInPage));$(f).append(e);
4538glApp.panelMgr.voteBetOutput&&this.populateGuessMoveOutput(glApp.panelMgr.voteBetOutput)};a.prototype.markMyBet=function(){};a.prototype.markMyVote=function(){d[c]=b};return a}();GuessingElement.factory=function(a,b){b=new GuessingElement(b||0);b.initElem(a);return b};"use strict";
4539var EvalProfileControl=function(){var a=function(c,d,e,f,g,h){this.init(c,d,e,f);this.options=g;this.fnGotoMove=h;this.nMove=0},b=1;a.createEvaluationCanvas=function(c,d){c=new CanvasParent(c);if(null==c.canvasEl||null==c.canvasEl.elDOM||null==document.getElementById(c.canvasEl.elDOM.id))return{};let e={};e.evCanvas=c;c.setVisible(!0);let f=null;c.createCanvas({createControl:function(g,h,k,l){return f=new EvalProfileControl(g,h,k,"EvlProfile",l,d)}},{});e.control=f;return e};a.prototype.onDestroyDOM=
4540function(){};a.prototype.reset=function(){this.evArr&&(this.evArr.first=0,this.evArr.last=1,this.evArr.evalArr=[EvalProfileAnno.EV_INVALID,EvalProfileAnno.EV_INVALID]);this.redraw()};a.prototype.redraw=function(){this.cbcanvas.requestRedraw()};a.prototype.setEvalArr=function(c){c?(this.evArr=ObjUtil.clone(c),this.cbcanvas.requestRedraw()):this.reset()};a.prototype.init=function(c,d,e,f){this.debugName=f;this.cbcanvas=c;this.calcGeometry();this.uniqueId=b++;this.resizeTimer=new Timer(this.resizeHdl.bind(this))};
4541a.prototype.resize=function(c,d){this.width=c;this.height=d;c&&d?this.resizeTimer.runOnce(5):this.resizeTimer.stop()};a.prototype.calcGeometry=function(){};a.prototype.resizeHdl=function(){this.width&&this.height&&this.cbcanvas.requestRedraw()};a.prototype.onMouseDown=function(c,d){};a.prototype.onMouseUp=function(c,d){c=(d.x-this.getDist())/this.getBinWidth();this.fnGotoMove&&this.fnGotoMove(Math.floor(c))};a.prototype.onMouseWheel=function(c,d){};a.prototype.onMouseMove=function(c,d){};a.prototype.onDoubleClick=
4542function(c,d){};a.prototype.onMouseEnter=function(c,d){};a.prototype.onMouseLeave=function(c,d){};a.prototype.drawForeground=function(c){};a.prototype.updateGame=function(c){c&&c.isOnMainLine()&&this.markMove(c.getPlyNum())};a.prototype.markMove=function(c){this.nMove=c;this.width&&this.height&&this.cbcanvas.requestRedraw()};a.prototype.draw=function(c){this.evArr&&(this.fillBG(c),this.drawXAxis(c),this.drawYAxis(c),this.drawValues(c),this.drawMoveMarker(c))};a.prototype.getDist=function(){return Math.max(2,
4543this.height/16)};a.prototype.getYMiddle=function(){return Math.ceil((this.height-2*this.getDist())/2)};a.prototype.getHalfRange=function(){var c=this.evArr.range()/2;c=Math.floor(100*(c/100+1));200>c&&(c=200);1200<c&&(c=1200);return c};a.prototype.getYValue=function(c){if(32767==c)return 0;var d=this.getHalfRange(),e=0<c?1:0>c?-1:0;Math.abs(c)>d&&(c=d);c=0==c?0:Math.abs(c);d=Math.abs(d);return(this.height-2*this.getDist())/2*(c/d)*e};a.prototype.fillBG=function(c){if(this.width&&this.height){var d=
4544c.createLinearGradient(0,0,this.width,this.height);d.addColorStop(0,"hsla( 0, 0%,  97%, 1.0 )");d.addColorStop(1,"hsla( 0, 0%, 99%, 1.0 )");c.fillStyle=d;CanvasTools.fillRect(c,new CBRect(0,0,this.width,this.height))}};a.prototype.drawXAxis=function(c){var d=this.getDist(),e=this.getYMiddle()+1,f=this.width-this.getDist();c.strokeStyle="black";c.lineWidth=2;c.lineCap="round";CanvasTools.drawLine(c,d,e,f,e)};a.prototype.drawYAxis=function(c){var d=this.getDist()-2,e=this.getDist(),f=e+this.height-
45452*this.getDist();c.strokeStyle="black";c.lineWidth=2;c.lineCap="round";CanvasTools.drawLine(c,d,e,d,f)};a.prototype.getBinWidth=function(){if(!this.evArr)return 1;var c=Math.max(30,this.evArr.last+1);return Math.max(1,(this.width-2*this.getDist())/c)};a.prototype.drawMoveMarker=function(c){var d=(this.nMove+0)*this.getBinWidth()+this.getDist(),e=new CBRect(d,0,d+this.getBinWidth(),0+this.height);c.fillStyle="hsla( 30, 3%, 30%, 0.16 )";CanvasTools.fillRect(c,e);e=this.cbcanvas.zoomToPix(10);c.font=
4546String.formatEx("{0}px Roboto",e);c.fillStyle="black";var f=this.evArr.evalArr[this.nMove-this.evArr.first],g=.27*this.height;e=this.getYMiddle()-g;0<=f&&(e=this.getYMiddle()+g);g="";"undefined"!=typeof f&&f!=EvalProfileAnno.EV_INVALID&&(g=(f/100).toFixed(2),g+=", "+Evaluation.getEvalString(f));if(g){f=c.measureText(g).width;var h=-this.getBinWidth();d+h+f>this.width&&(h=this.width-f-d-5);c.fillText(g,d+h,e)}};a.prototype.drawValues=function(c){var d=this.getBinWidth();c.strokeStyle="hsla( 0, 0%, 0%, 0.4 )";
4547c.fillStyle="green";c.lineWidth=1;for(var e=0;e<this.evArr.last-this.evArr.first+1;e++){var f=Math.round((this.evArr.first+e)*d+this.getDist()),g=Math.round(f+d),h=this.getYMiddle(),k=this.evArr.evalArr[e],l=this.getYValue(k);l&&(c.fillStyle=0>l?28E3<Math.abs(k)?"hsla( 0, 30%, 30%, 1.0 )":"red":28E3<Math.abs(k)?"hsla( 120, 30%, 25%, 1.0 )":"green",k=Math.round(this.getYMiddle()-l),k<h&&(l=k,k=h,h=l),f=new CBRect(f,h,g,k),CanvasTools.fillRect(c,f),c.strokeStyle="black",CanvasTools.drawRect(c,f))}};
4548return a}(),VersionCodeEnum={JSPLAYCHESS:1101,JSLIVEBLITZ:1102,JSCBONLINE:1103,JSOPENINGS:1104,JSPREMIUM:1105,JSFRITZ:1106,JSTEST:1107,JSMYGAMES:1108,JSPLAYERDB:1109,JSTACTICS:1110,JSTACTICSBOARD:1111,JSCBONLINEBOARD:1112,JSPREMIUMBOARD:1113,JSENDGAMES:1114,JSLIVE:1115,JSREADER:1116,JSPLAY:1117,JSSTUDY:1118,JSINTERACTIVEFRITZ:1119,JSPLUGIN:1120,JSCBOFFLINE:1121,JSEDITOR:1122,JSPLAG:1123,toString:function(a){for(let b in VersionCodeEnum)if(VersionCodeEnum[b]==a)return b;return a}};
4549class VersionCode{constructor(a,b,c,d){this.nFamily=void 0!==a?a:VersionCodeEnum.JSPLAYCHESS;this.nMajor=void 0!==b?b:0;this.nMinor=void 0!==c?c:0;this.nBeta=void 0!==d?d:0}V17(a){a.V14(this.nFamily);a.V14(this.nMajor);a.V14(this.nMinor);a.V14(this.nBeta);a.V14(93);a.V14(0);a.V13(0);a.V14(0);a.V14(0)}toString(){return this.familyToString(this.nFamily)+" "+this.getStrVersion()}getStrVersion(a){var b=this.nMajor+"."+this.nMinor;this.nBeta&&(b+="."+this.nBeta);System.isCordova()&&(b+="c");System.browserIsSafeForEngine()?
4550b+="e":System.browserIsOld()&&(b+="o");System.isMobile()&&(b+="m");a&&System.getNCpus()&&(b+="-"+System.getNCpus());return b}familyToString(a){switch(a){default:return VersionCodeEnum.toString(a);case VersionCodeEnum.JSPLAYCHESS:return"Playchess";case VersionCodeEnum.JSLIVEBLITZ:return"LiveBlitz";case VersionCodeEnum.JSCBONLINE:return"OnlineDB";case VersionCodeEnum.JSOPENINGS:return"Openings";case VersionCodeEnum.JSFRITZ:return"Fritz";case VersionCodeEnum.JSMYGAMES:return"MyGames";case VersionCodeEnum.JSTRAINING:return"Training";
4551case VersionCodeEnum.JSENDGAMES:return"Endgames";case VersionCodeEnum.JSLIVE:return"Live";case VersionCodeEnum.JSREADER:return"Reader";case VersionCodeEnum.JSPLAY:return"Play";case VersionCodeEnum.JSSTUDY:return"Study";case VersionCodeEnum.JSPLAG:return"PLAG"}}GetNCompressedVersion64(){return this.nFamily<<48|this.nMajor<<32|this.nMinor<<16|this.nBeta}}CB.VersionCodeEnum=VersionCodeEnum;
4551CB.VersionCode=VersionCode;
4552var SockMsgId={NONE:0,WIN_INVALID_PASSWORD:17,WIN_ACCESS_DENIED:42,ALIVE:7001,LOGON:7002,LOGOFF:7003,YOUR_ID:7004,INVALID_PASSWORD:7005,RECONNECT_OK:7006,CLIENTPING:7007,CLIENTECHO:7008,BINDERTIMEOUT:7009,ALREADYLOGGEDON:7010,FORCE_LOGOFF:7011,INVALIDPASSWORD:7012,YOUR_LOGINTOKEN:7013,ACCOUNT_LOCKOUT:7014,IAMALIVE:7015,LOGIN_OTHER_MACHINE:7016,KICKEDOUT_OTHER_MACHINE:7017,IDLE_CLIENT_LOGOFF:7018,FRAGMENT:7019,CHAT:7020,STARTTYPINGCHAT:7021,ALERT:7022,PING_BY_NAME:7023,RESPOND_PING_BY_NAME:7024,USER:7030,
4553QUERY_SERVERALIVE:7040,SERVER_IS_ALIVE:7041,TEST:7042,CLIENTLIST:7050,ADDCLIENTS:7051,REMOVECLIENTS:7052,CLIENTDATACHANGE:7053,LISTFRAGMENTRECEIVED:7054,LISTUPDATECHANGE:7055,CLIENTDATACHANGELIST:7056,SESSIONSTATUSCHANGELIST:7057,REQUESTCLIENTLIST:7058,GROUPSTATUSCHANGE:7060,CHANGEGROUP:7061,DEFAULTGROUPS:7062,CHANNELDATA:7070,CHANNELSTATUSCHANGE:7071,REQUESTCHANNELS:7072,JOINCHANNEL:7073,GETBROADCASTURLS:7074,BROADCASTURLS_DATA:7075,GETGEOLEADERBOARD:7076,GEOLEADERBOARD_DATA:7077,GETFRIENDSLEADERBOARD:7078,
4554GETFRIENDSLEADERBOARD_REPLY:7079,REQUEST_STATISTICS:7080,STATISTICS_DATA:7081,RELAYFRIENDSMESSAGE:7082,FRIENDSMESSAGE_DATA:7083,GETACTIVEHLSSTREAMS:7084,GETACTIVEHLSSTREAMS_REPLY:7085,GROUPHTMLCHANGED:7086,REQUESTCLIENTDATA:7087,CLIENTDATA:7088,REQUESTBROADCASTURLSEX:7089,REQUESTBROADCASTURLSEX_DATA:7090,REQUESTGROUPS:7091,GROUPSDATA:7092,REQUESTPARENTGROUPS:7093,REQUESTONEGROUP:7094,QUERY_ONLINE_DB:7100,REQUEST_ONLINE_DB_GAMES:7101,REQUEST_ONLINE_DB_HEADERS:7102,REQUEST_ONLINE_DB_STATISTICS:7103,
4555REQUEST_ONLINE_DB_USER_INFO:7104,REQUEST_ONLINE_DB_ADMIN_INFO:7105,ONLINE_DB_NUMBERS:7106,ONLINE_DB_GAMES:7107,ONLINE_DB_HEADERS:7108,ONLINE_DB_STATISTICS:7109,ONLINE_DB_MAINTENANCE:7110,ONLINE_DB_USER_INFO:7111,ONLINE_DB_ADMIN_INFO:7112,MAINTENANCE_ONLINE_DB_UPDATE:7113,PLAYER_BASE_USER:7200,TERABRAIN_USER:7300,TERABRAIN_ERROR:7301,TERABRAIN_MAINTENANCE:7302,REQUEST_TERABRAIN_POSITION:7303,TERABRAIN_REQUEST:7304,TERABRAIN_ENGINE_SEARCHDATA:7305,TERABRAIN_BOOKINFO:7306,TERABRAIN_TABLEDATA:7307,CHECKSUM_ERROR:7350,
4556CLOUD_USER:7400,TRAINING_USER:7401,ANALYSIS_USER:7402,LIVE_USER:7403,GETAGORAKEY:7404,GETAGORAKEY_REPLY:7405,BLOCKVIDEO:7406,BLOCKVIDEO_REPLY:7407,WMF_STREAM:7408,WMF_STREAM_REPLY:7409,TOGGLE_WMF_STREAM:7410,TOGGLE_WMF_STREAM_REPLY:7411,GET_WMF_STATS:7412,GET_WMF_STATS_REPLY:7413,MEDIA_USER:7414,MUTE_AUDIO:7415,MUTE_AUDIO_REPLY:7416,REQUEST_AUTOTOURNAMENT_SERVICE:7417,REQUEST_AUTOTOURNAMENT_SERVICE_REPLY:7418,toString:function(a){for(var b in this)if(this[b]==a)return"SockMsg:"+b;return"Unknown SockMsg: "+
4557a},toNumString:function(a){return"SockMsgId="+a}};
4558class WebSockMessage{constructor(a){this.type=a||SockMsgId.NONE;this._init()}getType(){return this.type}setType(a){this.type=a}getUserType(){return this.userType}setUserType(a){this.userType=a}getIdReceiver(){return this.idReceiver}setIdReceiver(a){this.idReceiver=a}Vo(){return this.idSender}Vq(a){this.idSender=a}setVal(a){this.nVal=a}getVal(){return this.nVal}address(a,b){this.idSender=a;this.idReceiver=b}getBuf(){return this.buf}fillSendArrBuf(a,b){var c=16,d=0;a&&(c+=4,d=b?2:0);d=new ArrayBuffer(c+
4559this.buf.getWriteSize()+d);var e=new DataView(d);e.setInt16(0,this.type);e.setInt32(2,this.nVal);e.setInt32(6,this.idSender);e.setInt16(10,this.userType);e.setInt32(12,this.idReceiver);a?(e.setInt32(16,this.msgId),a=this.buf.writeToDataView(e,20),b&&e.setInt16(c+a,this.buf.getCheckSum16())):this.buf.writeToDataView(e,16);return d}fromReceiveBuf(a){if(16<=a.byteLength){var b=new DataView(a);this.type=b.getInt16(0);this.nVal=b.getInt32(2);this.idSender=b.getInt32(6);this.userType=b.getInt16(10);this.idReceiver=
4560b.getInt32(12);20<=a.byteLength&&(this.buf.readFromDataView(b,16),this.buf.rewind())}else throw Error("Illegal Message received");}toString(){var a="",b;for(b in SockMsgId)if(this.type==SockMsgId[b]){a+=b;break}this.userType&&(a+=", usr="+this.userType);a+=", sender="+this.idSender+", receiver="+this.idReceiver;this.buf.getSize()&&(a+=", bufsize="+this.buf.getSize());return a}_init(){this.nVal=this.idSender=this.idReceiver=this.userType=0;this.buf=new DataBuffer;this.msgId=0}
4560}CB.SockMsgId=SockMsgId;
4561CB.WebSockMessage=WebSockMessage;var LoginMode={NORMAL:1,GUEST:2},LogoffType={DEFAULT:0,REMOVE_WATCHER:1,RESIGN:2,ABORT:3},LoginFlags={YES2CHESS:32,HASWEBSOCKIDS:128,IS_WEAK_GUEST:1024,SPRINT_REQUESTS_NEXT_POS:2048,HAS_MSG_CHECKSUM:4096,JOIN_FIXED_ROOM:8192};
4562class LogonData{constructor(a,b,c,d,e,f){this.strName=a;this.strPass=b;this.nMode=c;this.version=glApp.versionCode;this.guid=d;this.language=Language.getStrUserLanguage();this.codepage=System.getWindowsCodePage();this.strRoom="";this.strRoomUrl=document.referrer;this.token=e||"";this.app=f||"";this.flags=0;this.documentUrl=""}Vi(a,b){var c=new WebSockMessage(SockMsgId.LOGON);try{c.address(ConnectId.UNKNOWN,ConnectId.SERVER);c.getBuf().V13(this.nMode);this.version.V17(c.getBuf());var d=this.strName;
4563StrUtil.hasASCIIgreater127(d)&&!StrUtil.mayBeUtf8(d)&&(d=StrUtil.encodeUTF8(d));var e=this.strPass;StrUtil.hasASCIIgreater127(e)&&!StrUtil.mayBeUtf8(e)&&(d=StrUtil.encodeUTF8(e));c.getBuf().Ve(d);c.getBuf().Ve(e);this.guid.V17(c.getBuf());c.getBuf().Va(this.language);c.getBuf().Va(navigator.platform);c.getBuf().V13(this.codepage);c.getBuf().Ve(this.strRoom);c.getBuf().Va(this.token);c.getBuf().Ve(0<this.strRoom.length?this.strRoomUrl:"");c.getBuf().Va(this.app);a&&(this.flags|=LoginFlags.HASWEBSOCKIDS);
4564b&&(this.flags|=LoginFlags.HAS_MSG_CHECKSUM);c.getBuf().V13(this.flags);c.getBuf().Va(navigator.userAgent);c.getBuf().Va(this.documentUrl)}catch(f){LogException("LogonMsg",f)}return c}setIsBeginner(){this.flags|=LoginFlags.IS_WEAK_GUEST}setRequestsSprintPos(){this.flags|=LoginFlags.SPRINT_REQUESTS_NEXT_POS}}CB.LoginMode=LoginMode;CB.LogoffType=LogoffType;CB.LoginFlags=LoginFlags;CB.LogonData=LogonData;
4565class YourIdData{constructor(){this.nId=ConnectId.NONE;this.nIdCMSArchive=this.nIdBroadcastGroup=this.nIdDefaultPlayingGroup=0;this.strUserId=this.strToken="";this.nFlags=this.Vs=0;this.dailyResources=new DailyResources;this.strGroup="";this.debugVal=0}fromSocketsMsg(a){a.getBuf().rewind();a=a.getBuf();this.nIdDefaultPlayingGroup=a.V19();this.nIdBroadcastGroup=a.V19();this.nId=a.V19();this.nIdCMSArchiv=a.V19();this.strToken=a.Vb(200);this.Vs=a.V1a();this.strUserId=a.Vb(200);this.nFlags=a.V19();this.dailyResources.read(a);
4566this.strGroup=a.Vb(200);
4566this.debugVal=a.V19()}isFromBridge(){return 0!==(this.nFlags&2)}getDailyResources(){return this.dailyResources()}}
4567class DailyResources{constructor(){this.nGroupVideoQuarters=this.nGroupVideoSessions=this.nCreateChannels=this.nSendMail=this.nApplausePoints=this.nEvalPoints=0}read(a){this.nEvalPoints=a.V1a()&31;this.nApplausePoints=a.V1a()&63;this.nSendMail=a.V1a()&63;a=a.V1a()&4095;this.nCreateChannels=a&15;this.nGroupVideoSessions=(a&240)>>4;this.nGroupVideoQuarters=(a&3840)>>8}}CB.YourIdData=YourIdData;CB.DailyResources=DailyResources;
4568class ChatData{constructor(){this.idReceiver=this.idSender=ConnectId.NONE;this.eColName=this.eWeight=0;this.strMsg="";this.eSound=0;this.strSender="";this.nTotalReceivers=this.flags=this.nChannel=0;this.arrReceivers=[];this.token=0;this.chatFlags={ITALIC:1,UNDERLINE:2,UTF8:256,AUTOMATIC:4096,TO_GROUP:8192,TO_OBSERVERS:16384,TO_CHANNEL:32768,TO_INDIVIDUALS:65536,TO_OBSERVERSANDPLAYERS:131072,TO_SESSION:262144}}static YELLOW=14;Vi(){var a=new WebSockMessage(SockMsgId.CHAT);a.address(this.idSender,this.idReceiver);
4569var b=a.getBuf();b.V14(this.eWeight);b.V14(this.eColName);b.Vr(this.strMsg);b.V14(this.eSound);b.Va(this.strSender);b.V13(this.nChannel);b.V13(this.nTotalReceivers);b.V13(this.flags);if(this.isToIndividuals()){b.V13(this.arrReceivers.length);for(var c=0;c<this.arrReceivers.length;c++)b.V13(this.arrReceivers[c])}b.Vu(this.token);return a}fromSocketsMsg(a){var b=a.getBuf();this.idReceiver=a.getIdReceiver();this.idSender=a.Vo();b.rewind();this.eWeight=b.V1a();this.eColName=b.V1a();try{var c=b.V19();
4570this.strMsg=b.readSizedUTF8String(c)}catch(d){LogException("Chat Msg Len exception, sender="+this.idSender)}this.eSound=b.V1a();try{this.strSender=b.Vb(210)}catch(d){LogException("Chat Sender exception, msg="+this.strMsg+", sender="+this.idSender)}this.nChannel=b.V19();this.nTotalReceivers=b.V19();this.flags=b.V19();if(this.isToIndividuals())for(a=b.V19(),c=0;c<a&&500>c;c++)this.arrReceivers.push(b.V19());this.token=b.Vw()}toString(){var a="";0<this.strSender.length&&(a+=this.strSender+":");return a+=
4571this.strMsg}isPrivate(){return 0==this.flags}isToIndividuals(){return 0!=(this.flags&this.chatFlags.TO_INDIVIDUALS)}setToIndividuals(a){setFlag(this,this.chatFlags.TO_INDIVIDUALS,a)}isToChannel(){return 0!=(this.flags&this.chatFlags.TO_CHANNEL)}setToChannel(a){setFlag(this,this.chatFlags.TO_CHANNEL,a)}isToSession(){return isFlag(this.flags,this.chatFlags.TO_SESSION)}setToSession(a){setFlag(this,this.chatFlags.TO_SESSION,a)}isToObservers(){return isFlag(this.flags,this.chatFlags.TO_OBSERVERS)}isToObserversAndPlayers(){return isFlag(this.flags,
4572this.chatFlags.TO_OBSERVERSANDPLAYERS)}setToObservers(a){setFlag(this,this.chatFlags.TO_OBSERVERS,a)}getIdSession(){return this.nChannel}setToGroup(a){setFlag(this,this.chatFlags.TO_GROUP,a)}isToGroup(){return 0!=(this.flags&this.chatFlags.TO_GROUP)}setIdSession(a){this.nChannel=a}setChannel(a){this.nChannel=a;this.setToChannel(!0)}setAutomatic(a){setFlag(this,this.chatFlags.AUTOMATIC,a)}isAutomatic(){return 0!=(this.flags&this.chatFlags.AUTOMATIC)}setReceivers(a){a.length?(this.idReceiver=a[0],this.arrReceivers=
4573a):(this.idReceiver=a,this.arrReceivers.push(a))}autoTests(){return"test OK"}}CB.ChatData=ChatData;var ConnectId={NONE:0,UNKNOWN:0,SERVER:1},SockState={CONNECTING:0,CONNECTED:1,CLOSING:2,CLOSED:3};
4574class Connection{constructor(a,b){this.connectId=ConnectId.NONE;this.uris=[].concat(b);this.nUri=0;glApp&&void 0!=glApp.config.nBridge&&glApp.config.nBridge<this.uris.length&&(this.nUri=glApp.config.nBridge);this.wsUri=this.uris[this.nUri];this.msgsWaitingToSend=new Queue;this.msgsWaitingToSendNoId=new Queue;this.onYourId=function(c){};this.onClose=function(c){};this.isFirstConnect=!0;this.firstConnectTries=0;this.onConnectionLoss=function(){};this.onServerDown=function(){};this.lobby=a;this.Vg=0;
4575this.error=!1;this.isActiveTicker=new Tick;this.weAreAliveTicker=new Tick;this.tryTimer=new Timer(this.periodicHandler.bind(this));this.tryTimerPeriod=200;this.msgCnt=0}open(){try{if(!this.testBreak)if(this.inErrorHandler)LogException("InErrorHandler");else{this.socket&&this.socket.close();this.socket=new WebSocket(this.wsUri);var a=this;this.error=!1;this.socket.onopen=function(){for(;!a.msgsWaitingToSendNoId.empty();)a.socket.readyState==SockState.CONNECTED?a.sendMessage(a.msgsWaitingToSendNoId.pop(),
4576!0,!0):(a.msgsWaitingToSendNoId.pop(),LOG("YOU DID SOMETHING BAD, YOU ARE SENDING BUT HAVE NOT WAITED FOR CONNECTION TO COMPLETE","LogException"));for(;!a.msgsWaitingToSend.empty();)a.socket.readyState==SockState.CONNECTED?a.sendMessage(a.msgsWaitingToSend.pop(),!1,!1):(a.msgsWaitingToSend.pop(),LOG("YOU DID SOMETHING BAD, YOU ARE SENDING BUT HAVE NOT WAITED FOR CONNECTION TO COMPLETE","LogException"));console.log("Connected:"+a.wsUri);this.tryTimerPeriod=200;(new Timer(function(){a.lobby.onConnect()})).runOnce(20)};
4577this.socket.onclose=function(b){5;a.onClose(a);if(void 0!==a.onBroken)a.onBroken();1E3<b.Code&&(glApp.LogConnection(a.lobby.getName()+"-Close="+b.Code),console.log("Close: "+closeCodes[b.Code]))};this.socket.onerror=function(b){console.log("Error: "+a.wsUri+" "+b);console.log("Error: "+b);a.isFirstConnect&&1<a.uris.length&&4>++a.firstConnectTries?(a.switchConnection(),a.open()):(a.error=!0,a.onSocketError(a))};this.socket.onmessage=function(b){a.tryTimer.stop();if(b.data instanceof ArrayBuffer){var c=
4578new WebSockMessage;try{c.fromReceiveBuf(b.data)}catch(d){EXCEPTION(d.toString())}a.V4(c);a.weAreAliveTicker.start()}else LOG(b.data,"","conn");a.Vg=0}}}catch(b){LogException("Conn",b)}}close(){(this.isConnected()||this.isConnecting())&&this.socket.close();this.tryTimer.stop()}isConnected(){return this.socket&&this.socket.readyState==SockState.CONNECTED}isConnecting(){return this.socket&&this.socket.readyState==SockState.CONNECTING}onSocketError(){this.inErrorHandler=!0;console.log("onSockError");
4579this.isFirstConnect?(this.onServerDown(),this.lobby.periodicPingTimer&&this.lobby.periodicPingTimer.stop(),this.tryTimer.runPeriodic(3E4)):(this.onConnectionLoss(),this.tryTimer.runPeriodic(Math.min(1E4,this.tryTimerPeriod+500*this.Vg)));this.inErrorHandler=!1}V4(a){this.isFirstConnect=!1;var b=!0;switch(a.getType()){default:b=!1;break;case SockMsgId.YOUR_ID:this.handleYourId(a);break;case SockMsgId.ALIVE:b=!1}b||(this.lobby.handleReceived(a),this.error=!1)}handleYourId(a){var b=new YourIdData;b.fromSocketsMsg(a);
4580this.connectId=b.nId;this.lobby.idReceived(b);this.onYourId(this)}sleepSync(a){for(a=(new Date).getTime()+a;(new Date).getTime()<a;);}sendMessage(a,b,c){if(this.socket){if(!a.getType())throw Error("Sending invalid sockMsg");a.msgId=b?0:++this.msgCnt;a.getIdReceiver()==ConnectId.NONE&&a.setIdReceiver(ConnectId.SERVER);a.Vq(this.connectId);this.socket.readyState==SockState.CONNECTED?(this.socket.binaryType="arraybuffer",a=a.fillSendArrBuf(!b,!c),this.socket.send(a)):this.socket.readyState!=SockState.CONNECTING&&
4581this.socket.readyState!=SockState.CLOSING&&this.socket.readyState!=SockState.CLOSED&&(this.error=!0,console.log("OnSocketerr1"),this.onSocketError())}}sendText(a){this.socket&&1==this.socket.readyState?(console.log("SENT: "+a),this.socket.send(a)):LOG("Connection not open")}breakForTesting(){LOG("Break Connection for Testing");this.close()}periodicHandler(){this.testBreak||(console.log("Conn Periodic, retries="+this.Vg+", "+this.lobby.connectId,"","conn"),this.tryTimer.runPeriodic(1E4),this.socket&&
4582this.socket.readyState!=SockState.CONNECTED&&this.error&&(this.Vg+=1,1<=this.Vg&&(this.isFirstConnect||6<this.Vg)&&this.switchConnection(),this.lobby.pingServer&&this.lobby.pingServer(!0,1==this.Vg?2E3:6E3,!0),5<this.Vg&&this.tryTimer.runPeriodic(5E4+3E4*Math.random())))}switchConnection(){this.nUri++;if(this.uris&&this.uris.length&&(this.nUri>=this.uris.length&&(this.nUri=0),this.wsUri=this.uris[this.nUri],console.log("Switch Conn: "+this.wsUri),this.lobby.onSwitchConn))this.lobby.onSwitchConn(this.nUri)}}
4583CB.ConnectId=ConnectId;CB.SockState=SockState;CB.Connection=Connection;
4584class ClientParams{constructor(a){this.guid=new CBGuid;this.password=this.userName="";this.stayLoggedIn=!0;var b="ClientGUID"+a,c=null,d=window;try{d.localStorage&&!System.runsInIFrame()?c=d.localStorage:d.sessionStorage&&(c=d.sessionStorage)}catch(f){console.log("Local Storage not accessible"),c=d.sessionStorage}if(c&&c[b]){a=JSON.parse(c[b]);for(var e in a)this.guid[e]=a[e]}else this.guid=new CBGuid,this.guid.fromRandom(a),c&&(c[b]=JSON.stringify(this.guid))}toString(){return"User="+this.userName+
4585", mode="+this.loginMode}saveLogin(){this.save("user",this.userName)}loadLogin(){this.userName=this.load("user")}getSessionStorage(){var a=null,b=window;try{b.sessionStorage?a=b.sessionStorage:b.localStorage&&(a=b.localStorage)}catch(c){a=b.sessionStorage}return a}getStorage(){var a=null,b=window;try{b.localStorage?a=b.localStorage:b.sessionStorage&&(a=b.sessionStorage)}catch(c){console.log("local storage not accessible"),a=b.sessionStorage}return a}storeRoom(a,b,c,d,e){this.set("room",a);this.set("roomurl",
4586b);this.set("banner",c);this.set("roomtext",d);this.set("training",e)}clearRoom(){this.set("room","");this.set("roomurl","");this.set("banner","");this.set("gradient","");this.set("roomtext","");this.set("tournRoom","");this.set("training","")}storeTournRoom(a,b){this.set("tournRoom",a);b&&this.set("roomId",b)}
4586storeRegisteredRoom(a){this.getStorage()&&(this.getStorage().RegRoom=a)}getRegisteredRoom(){this.getStorage()&&this.getStorage().RegRoom}storeBanner(a,b){this.set("banner",a);this.set("gradient",
4587b)}storeSeek(a){this.set("seek",a)}store(a,b){this.getSessionStorage()[b]=a}get(a){return this.getSessionStorage()[a]||""}set(a,b){this.getSessionStorage()[a]=b}load(a){return this.getStorage()?this.getStorage()[a]||"":""}save(a,b){this.getStorage()&&(this.getStorage()[a]=b)}isKibitz(){return this.get("kibitz")}startEngine(){if(!System.isMobile()){var a=this.get("layout");return a&&0<=a.search("engine")}}hasLayout(){return this.get("layout")}shouldDisplayBoardUrls(){return this.isKibitz()&&this.noRibbons()}noRibbons(){var a=
4588this.get("layout");return a&&0<=a.search("nomenu")}noPlayers(){var a=this.get("layout");return a&&0<=a.search("noplayers")}noLists(){return!0}receiveSeeksAlways(){return!1}noChat(){var a=this.get("layout");return a&&0<=a.search("nochat")}noBook(){var a=this.get("layout");return a&&0<=a.search("nobook")}noNota(){var a=this.get("layout");return a&&0<=a.search("nonota")}getTournRoom(){return this.get("tournRoom")}getRoomId(){return this.get("roomId")}hasRoom(){return!!this.getRoom()||!!this.getTournRoom()}hasTraining(){return!!this.getTraining()}getRoom(){return this.get("room")}getTraining(){return this.get("training")}getRoomUrl(){return this.get("roomurl")}getRoomText(){return this.get("roomtext")}getBanner(){return this.get("banner")}getGradient(){return this.get("gradient")}getPlay(){return this.get("play")}isPlay(){return this.get("play")}prepareLoginChange(){var a=
4589{banner:this.getBanner(),gradient:this.getGradient(),room:this.getRoom(),roomUrl:this.getRoomUrl()};this.keepStateAccrossLogin(a)}afterLoginChange(){var a=this.getStateAcrossLogin();a&&(this.resetStateAfterLogin(),this.storeBanner(a.banner,a.gradient))}keepStateAccrossLogin(a){try{var b=JSON.stringify(a);this.getStorage()&&(this.getStorage().AcrossLogin=b)}catch(c){console.log("ClientParams.keepSAL"+c)}}resetStateAfterLogin(a){try{this.getStorage()&&delete this.getStorage().AcrossLogin}catch(b){console.log("ClientParams.resetSAL"+
4590b)}}getStateAcrossLogin(){try{if(this.getStorage()){var a=this.getStorage().AcrossLogin;if(a)return JSON.parse(a)}}catch(b){console.log("ClientParams.getSAL"+b)}}clearLoginCookies(a){this.loginToken="";a||DOM.clearCookie("AccountName64");DOM.clearCookie("AccountToken");DOM.clearCookie("AccountMode");DOM.setCookie("CBCOMMON","")}clearCBCommonCookie(){DOM.setCookie("CBCOMMON","")}rememberLoginToken(){this.stayLoggedIn&&this.loginToken?DOM.setCookie("AccountToken",this.loginToken):LOG("RememberLoginToken, stayLoggedIn="+
4591this.stayLoggedIn+"="+this.loginToken)}clearLoginToken(){DOM.clearCookie("AccountToken");this.loginToken=""}hasUserAndPass(){return this.userName&&"guest"!=this.userName&&(this.loginToken||this.password)}requestTokenWithPassword(a){!this.loginToken&&this.password&&this.loginMode==LoginMode.NORMAL&&(new Timer(function(){(new AccountsManager(a)).pwLogin(this.userName,this.password,function(b){b&&b.Token&&(this.loginToken=unescape(b.Token),this.rememberLoginToken(),DOM.setAccountNameCookie(this.userName),
4592DOM.setCookie("AccountMode",LoginMode.NORMAL))}.bind(this))}.bind(this))).runOnce(100)}}CB.ClientParams=ClientParams;var LogOffReason={MAINTENANCE:0,ADMIN_ACTION:1,DOUBLE_LOGIN:2,IDLE_CLIENT:3,VIDEO_BLOCK:4};
4593class Connector{constructor(){this.hasIdReceived=!1;this.pingServerPeriodMS=12E3;this.reconnectBaseTime=5E3;this.bufferedMsgs=[];this.isFirstConn=!0;this.name="...";this.pingCount=this.connectCount=0;this.logClientEcho=this.silentServerPing=!0;this.timerReconnect=new Timer}create(a,b,c,d,e){this.pingTimer=new Timer(this.onServerPingTimeout.bind(this));this.user=b;this.utf8User=StrUtil.encodeUTF8(b);this.pass=c;this.conn=new Connection(this,a);this.loginMode=d;this.token=e;this.pingStart=getTick();
4594this.Vg=0;this.timerReconnect=new Timer;this.nMyLagMS=3E3;this.conn.onConnectionLoss=this.onConnLoss.bind(this);this.conn.onServerDown=this.hdlOnServerDown.bind(this);this.boundLoginOk=!1;d!=LoginMode.GUEST&&DOM.setAccountNameCookie(b);this.periodicPingTimer=new Timer(this.periodicPingHandler.bind(this))}hdlOnServerDown(a){if(void 0!==this.onServerDown)this.onServerDown();this.hasIdReceived=!1}onConnLoss(a){if(void 0!==this.onConnBroken)this.onConnBroken();this.hasIdReceived=!1;this.onServerNotAlive()}getName(){return"Connector"}connectUser(a,
4595b,c,d){this.pingTimer&&this.pingTimer.stop();this.userLoggedOff=this.forcedLogOff=!1;this.pingTimer=new Timer(this.onServerPingTimeout.bind(this));this.isConnected()&&this.hasIdReceived&&this.logOff();this.onChangeLogin();this.user=a;this.utf8User=StrUtil.encodeUTF8(this.user);this.pass=b;this.token=d;this.loginMode=c;this.pingStart=getTick();this.Vg=0;this.timerReconnect=new Timer;this.nMyLagMS=3E3;(new Timer(this.connectFresh())).runOnce(100);c!=LoginMode.GUEST&&DOM.setAccountNameCookie(a)}gateReconn=new V10;reconnectUser(a){this.gateReconn.exec(function(){this.forcedLogOff||
4596(a&&(this.hasIdReceived=!1,this.conn.close()),this.loginMode=this.pass||this.token?LoginMode.NORMAL:LoginMode.GUEST,this.connectUser(this.user,this.pass,this.loginMode,this.token),this.Vg++,this.timerReconnect.stop())}.bind(this),10*this.Vg)}connectFresh(){this.conn.close();this.hasIdReceived=!1;this.connect()}connect(){this.conn&&(this.boundLoginOk=this.hasIdReceived=!1,this.conn.close(),this.conn.open(),this.isSilent()||this.statusMsg(lm.CONNECTING,"LogBold"),this.periodicPingTimer.runPeriodic(this.pingServerPeriodMS),
4597this.connectCount++)}isConnected(){return this.conn?this.conn.isConnected():!1}isConnecting(){return this.conn?this.conn.isConnecting():!1}isLoggedIn(){return this.boundLoginOk&&this.isConnected()}wasLoggedIn(){return!this.isFirstConn&&!this.isConnected()}hasSockMsgIds(){return!1}hasSockCheckSum(){return!1}logonGuest(){this.isSilent()||(this.logIntoChat(this.getWaitForServerMsg(),"LogGreen","conn"),this.statusMsg(this.getWaitForServerMsg(),"LogGreen","conn"));var a=glApp.Vn.guid;System.runsInIFrame()&&
4598a.fromRandom(10);a=this.createLogonData(a,!0);this.modifyLoginData(a);this.sendNoId(a.Vi(this.hasSockMsgIds(),this.hasSockCheckSum()));this.userLoggedOff=!1}logon(){if(!this.hasIdReceived){this.boundLoginOk=!1;this.isSilent()||(this.logIntoChat(this.getWaitForServerMsg(),"LogGreen","conn"),this.statusMsg(this.getWaitForServerMsg(),"LogGreen","conn"));var a=this.createLogonData(glApp.Vn.guid,!1);this.modifyLoginData(a);this.sendNoId(a.Vi(this.hasSockMsgIds(),this.hasSockCheckSum()));this.userLoggedOff=
4599!1}}modifyLoginData(a){}createLogonData(a,b){return b?new LogonData("Guest","Pass",LoginMode.GUEST,a):new LogonData(this.user,this.pass,LoginMode.NORMAL,a,this.token)}clearLoginCookies(){glApp.Vn&&glApp.Vn.clearLoginCookies(!0)}getWaitForServerMsg(){return"Waiting for Server"}logOff(){LOG(this.name+" - ConnectorLogOff:"+this.user+" "+this.loginMode,"LogBold");this.periodicPingTimer&&this.periodicPingTimer.stop();if(this.hasIdReceived&&this.isConnected()){var a=new WebSockMessage(SockMsgId.LOGOFF);
4600a.address(this.conn.connectId,ConnectId.SERVER);a.buf.V13(0);this.send(a);this.loginMode=LoginMode.GUEST}this.onLogOff()}onLogOff(){this.periodicPingTimer&&this.periodicPingTimer.stop();this.hasIdReceived=this.boundLoginOk=!1;this.userLoggedOff=!0}onChangeLogin(){}changeLogin(){glApp.Vn&&glApp.Vn.prepareLoginChange&&glApp.Vn.prepareLoginChange();this.logOff(!0);window.location.replace(glApp.getLoginUrl())}handleBinderTimeout(){this.logIntoChat("Sorry, cannot reach the "+this.name+"server. It is in maintenance. Please try again in 15 minutes.",
4601"LogBold");this.conn.close();this.clearLoginCookies()}gatePing=new V10;pingServer(a,b,c){if(this.forcedLogOff)this.statusMsg(lm.PLEASE_LOGIN_SHORT);else if(this.conn&&this.conn.error&&!this.conn.isConnected()&&this.connect(),this.hasIdReceived||c)50<this.pingCount++||this.gatePing.exec(function(){this.sendSimple(SockMsgId.QUERY_SERVERALIVE);this.pingStart=getTick();this.pingTimer&&!this.pingTimer.isActive()&&this.pingTimer.runOnce(b||6E3);this.silentServerPing=a;this.periodicPingTimer&&this.periodicPingTimer.runPeriodic(this.pingServerPeriodMS)}.bind(this),
4602500)}onServerPingTimeout(){this.isSilent()||this.statusMsg(lm.RECONNECT);this.connect()}periodicPingHandler(){var a=this.conn.weAreAliveTicker.getExpiredMS();if(a>this.getMaxConnSilenceMS()&&(this.pingServer(!0,this.getConnTimeOutMS(),!0),a>this.getMaxConnSilenceMS()+this.periodicPingTimer.getTimeoutMs()))this.onServerNotAlive(a)}onServerNotAlive(a){}getConnTimeOutMS(){return 6E3}getMaxConnSilenceMS(){return 1E4}handleServerIsAlive(a){a=getTick()-this.pingStart;this.nMyLagMS=a/2;if(!this.silentServerPing){this.logIntoChat("Server Ping="+
4603a+"ms");if(glApp.chessAudio)glApp.chessAudio.onPing();this.isSilent()||this.statusMsg("Server OK")}if(this.onServerAlive)this.onServerAlive(a);this.pingTimer.stop();this.pingCount=0}handleAreYouAlive(){this.sendSimple(SockMsgId.IAMALIVE)}pingPlayer(a){this.sendSimple(SockMsgId.CLIENTPING,a);this.pingStart=getTick()}pingPlayerByName(a){var b=new WebSockMessage(SockMsgId.PING_BY_NAME);
4603b.address(this.conn.connectId,ConnectId.SERVER);b.buf.Va(a);this.send(b);this.pingStart=getTick()}handleRespondPingByName(a){a.getBuf().Vb(200);
4604a.getBuf().readInt()}handleForceLogoff(a){this.conn.tryTimer.stop();var b=a.getBuf().V19();a=a.getBuf().Vb(200);var c="Possibly for maintenance.";switch(b){case LogOffReason.ADMIN_ACTION:c="Administrator action.";break;case LogOffReason.MAINTENANCE:c="Planned server maintenance in progress.";break;case LogOffReason.DOUBLE_LOGIN:c=lm.DOUBLE_LOGIN+" ("+a+")";break;case LogOffReason.IDLE_CLIENT:c="User inactive.";break;case LogOffReason.VIDEO_BLOCK:c="Video blocked"}glApp.config.silentServers||this.displayForceLogOffMsg(c);
4605this.forcedLogOff=!0;this.onLogOff();this.onForcedLogOff()}onForcedLogOff(){}displayForceLogOffMsg(a){a=lm.SERVER_LOGGED_YOU_OFF+" "+a;this.statusMsg(a,"LogForceLogOff");this.logIntoChat(a)}notifyUserActivity(){}getNId(){return this.conn?this.conn.connectId:0}getNIdBound(){return void 0!==this.idBound?this.idBound:0}isGuest(){return this.client?this.client.isGuest():this.loginMode==LoginMode.NORMAL&&this.hasIdReceived?!1:!0}isPremium(){return this.isGuest?!1:this.client.isPremium()}signalOnConnect(){}onConnect(){this.signalOnConnect();
4606this.reconnectBaseTime=5E3;this.pingTimer.stop();this.loginMode!=LoginMode.NORMAL||glApp.forceGuestLogon()?this.logonGuest():this.logon()}idReceived(a){this.hasIdReceived=!0;this.Vg=0;this.timerReconnect.stop();this.isFirstConn=!1;this.Vs=a.Vs;a.dailyResources&&(glApp.Vn.MaxVideoGroupSessions=a.dailyResources.nGroupVideoSessions,glApp.Vn.MaxVideoGroupMinutes=15*a.dailyResources.nGroupVideoQuarters,0===glApp.Vn.MaxVideoGroupSessions&&0===glApp.Vn.MaxVideoGroupMinutes&&(glApp.Vn.MaxVideoGroupSessions=
460715,glApp.Vn.MaxVideoGroupMinutes=180),240>glApp.Vn.MaxVideoGroupMinutes&&(glApp.Vn.MaxVideoGroupMinutes=240));a.strToken&&!glApp.Vn.loginToken&&(glApp.Vn.loginToken=a.strToken,glApp.Vn.rememberLoginToken());this.token=a.strToken;a.strUserId&&"guest"!=a.strUserId.toLowerCase()&&(this.user=StrUtil.decodeUTF8(a.strUserId),glApp.Vn.userName=this.user,this.utf8User=a.strUserId,this.loginMode==LoginMode.NORMAL&&DOM.setCodedCookie("AccountBackName64",this.user));this.onIdReceived(a);if(glApp.panelMgr.onLoggedIn)glApp.panelMgr.onLoggedIn(this.loginMode==
4608LoginMode.NORMAL);this.bufferedMsgs=[]}onIdReceived(){}handleReceivedByConnector(a){var b=!0;switch(a.getType()){default:b=!1;break;case SockMsgId.ALIVE:this.handleAreYouAlive(a);break;case SockMsgId.BINDERTIMEOUT:this.handleBinderTimeout();break;case SockMsgId.INVALID_PASSWORD:case SockMsgId.INVALIDPASSWORD:this.handleInvalidPassword();break;case SockMsgId.ACCOUNT_LOCKOUT:this.handleAccountLockout();break;case SockMsgId.ALREADYLOGGEDON:this.onAlreadyLoggedOn();break;case SockMsgId.LOGIN_OTHER_MACHINE:this.onLoginOtherMachine();
4609break;case SockMsgId.KICKEDOUT_OTHER_MACHINE:this.onKickedOutOtherMachine();break;case SockMsgId.SERVER_IS_ALIVE:this.handleServerIsAlive(a);break;case SockMsgId.CLIENTPING:this.handleClientPing(a);break;case SockMsgId.CLIENTECHO:this.handleClientEcho(a);break;case SockMsgId.RESPOND_PING_BY_NAME:this.handleRespondPingByName(a);break;case SockMsgId.FORCE_LOGOFF:this.handleForceLogoff(a);break;case SockMsgId.YOUR_LOGINTOKEN:this.handleLoginToken(a);break;case SockMsgId.IDLE_CLIENT_LOGOFF:break;case SockMsgId.CHECKSUM_ERROR:this.handleCheckSumError(a)}return b}handleCheckSumError(a){console.log("Checksum error.")}handleInvalidPassword(){this.statusMsg("Sorry, your account '"+
4610this.user+"' or your password is not valid.","LogError");this.hasIdReceived=!1;this.clearLoginCookies();this.pingTimer.stop();this.periodicPingTimer.stop();if(this.onInvalidPassword)this.onInvalidPassword();else alert("Sorry, your password is not valid")}handleAccountLockout(){this.statusMsg("Sorry, your account is currently locked. Please wait one hour...","LogError");this.hasIdReceived=!1;this.clearLoginCookies();alert("Account currently locked.")}handleLoginToken(a){a.getBuf().V19();var b=a.getBuf().Vb(200);
4611this.token=b;this.Vs=a.getBuf().V19();a=a.getBuf().Vb(200);glApp.Vn.loginToken=b;a&&(this.user=glApp.Vn.userName=StrUtil.decodeUTF8(a),this.utf8User=a);glApp.Vn.rememberLoginToken();DOM.setCookie("AccountMode","1");if(this.onLoginToken)this.onLoginToken(b)}onAlreadyLoggedOn(){this.statusMsg("Already logged on: "+this.user+". Please log off or wait a few minutes.","LogBold");alert("Already logged on: "+this.user)}onKickedOutOtherMachine(){}onLoginOtherMachine(){this.timerReconnect.stop();this.periodicPingTimer.stop()}manageAccount(){this.hasIdReceived&&
4612(this.logOff(),window.location.replace(glApp.getManageAccountUrl()+"?user="+glApp.Vn.userCoded+"&token="+glApp.Vn.loginToken))}isSilent(){return!0}logIntoChat(a,b,c){this.isSilent()||(void 0===b&&(b="LogIntoChat"),glApp.panelMgr.chatOut&&a&&glApp.panelMgr.chatOut(a.toString(),b,c))}statusMsg(a,b,c){glApp.panelMgr.statusMsg?glApp.panelMgr.statusMsg(a):this.logIntoChat(a,b,c)}handleClientPing(a){let b=new WebSockMessage(SockMsgId.CLIENTECHO);
4612glApp.versionCode&&glApp.versionCode.V17(b.getBuf());b.address(this.getNId(),
4613a.Vo());this.send(b)}handleClientEcho(a){var b=getTick()-this.pingStart,c="Ping "+this.lists.clientNameMap[a.Vo()]+"="+b+"ms";this.logClientEcho&&this.logIntoChat(c);console.log(c);this.pingTimer.stop();this.fnOnClientEcho&&a.Vo()!=this.getNIdBound()&&this.fnOnClientEcho(a.Vo());return b}handleContinuousSelfEcho(a){}stupidClosureCompilerBugMsg={};sendSimple(a,b){this.stupidClosureCompilerBugMsg=new WebSockMessage(a);a=b;a||(a=ConnectId.SERVER);this.stupidClosureCompilerBugMsg.address(this.getNId(),
4614a);this.send(this.stupidClosureCompilerBugMsg)}send(a,b){if(!this.forcedLogOff&&!this.userLoggedOff)try{0==a.Vo()&&a.Vq(this.getNId()),0==a.getIdReceiver()&&a.setIdReceiver(ConnectId.SERVER),this.conn.sendMessage(a,!this.hasSockMsgIds(),!this.hasSockCheckSum()),this.conn.error?this.statusMsg(this.name+" not connected...","LogCAPError"):this.prevMsg=a,this.conn.error&&b&&this.bufferedMsgs.push(a),this.conn.isConnected()||this.initiateReconnect()}catch(c){LOG(c.toString()),this.initiateReconnect()}}sendNoId(a){try{0==
4615a.Vo()&&a.Vq(this.getNId()),0==a.getIdReceiver()&&a.setIdReceiver(ConnectId.SERVER),this.conn.sendMessage(a,!0,!0),this.conn.isConnected()||this.initiateReconnect()}catch(b){LOG(b.toString()),this.initiateReconnect()}}initiateReconnect(){if(!this.timerReconnect.isActive()&&!this.inTorture&&(LOG(this.name+" initiate reconn."),this.timerReconnect.runOnce(Math.min(6E4,this.reconnectBaseTime+1E3*this.Vg),function(){this.pingServer(!0)}.bind(this)),this.Vg++,3==this.Vg||0==this.Vg%7))this.onDisconnectAlarm()}onDisconnectAlarm(){}}
4616namespace("CB.V0.LogOffReason");namespace("CB.V0.Connector");CB.V0.LogOffReason=LogOffReason;CB.V0.Connector=Connector;"use strict";
4617class CloudDatabase extends CBDatabase{constructor(a,b,c){super();this.cloudId=a;this.manager=this.cloudManager=c;this.nGames=b;this.resetCaches();this.idHeaderListener=this.cloudManager.addOnHeadersChangedListener(this.onHeadersChanged.bind(this));this.idGameListener=this.cloudManager.addOnGameChangedListener(this.onGameChanged.bind(this));this.idGameNosListener=this.cloudManager.addOnGamesChangedByGameNoListener(this.onChangedByGameNo.bind(this));this.idHeaderNosListener=this.cloudManager.addOnHeadersChangedByGameNoListener(this.onChangedByGameNo.bind(this));
4618this.idGameAppendedListener=this.cloudManager.addOnGameAppendedListener(this.onGameAppended.bind(this));this.idChangeLoginListener=this.cloudManager.addOnChangeLoginListener(this.onChangeLogin.bind(this));this.idReorganizedListener=this.cloudManager.addOnReorganizedListener(this.onReorganized.bind(this));this.idDeletedListener=this.cloudManager.addOnDeletedListener(this.onDeleted.bind(this));this.dbItem=this.cloudManager.getCloudDBItem(this.cloudId);CloudDatabase.InitListeners();LOG("Created: "+this,
4619"LogGreen")}destroy(){LOG("Destroy: "+this,"LogRed");this.cloudManager.removeOnHeadersChangedListener(this.idHeaderListener);this.cloudManager.removeOnGameChangedListener(this.idGameListener);this.cloudManager.removeOnGamesChangedByGameNoListener(this.idGameNosListener);this.cloudManager.removeOnHeadersChangedByGameNoListener(this.idHeaderNosListener);this.cloudManager.removeOnGameAppendedListener(this.idGameAppendedListener);this.cloudManager.removeOnChangeLoginListener(this.idChangeLoginListener);
4620this.cloudManager.removeOnReorganizedListener(this.idReorganizedListener);this.cloudManager.removeOnDeletedListener(this.idDeletedListener);this.requestedHeaderNums=[]}toString(){return this.dbItem.title+"/"+this.cloudId}isLoadFromFile(){return!1}canSaveTo(){return!0}shouldShowLastGame(){return this.dbItem&&this.dbItem.type==CloudDBType.CLIPBOARD}setupListeners(a){void 0===a.idHeaderListener&&(a.idHeaderListener=this.addOnGameHeadersChangedListener(a.onGameHeadersChanged.bind(a)));void 0===a.idDBLengthListener&&
4621(a.idDBLengthListener=this.addOnDBLengthListener(a.onDBLengthListener.bind(a)));void 0===a.idDBDeletedListener&&(a.idDBDeletedListener=this.addOnDBDeletedListener(a.onDBDeletedListener.bind(a)));a.removeListeners=function(){this.removeOnGameHeadersChangedListener(a.idHeaderListener);this.removeOnDBLengthListener(a.idDBLengthListener);this.removeOnDBDeletedListener(a.idDBDeletedListener);delete a.idHeaderListener;delete a.idDBLengthListener;delete a.idDBDeletedListener}.bind(this)}resetCaches(){this.headers=
4622[];this.requestedHeaderNums=[];this.pendingHeaderJobs=[];this.pendingGameJobs=[]}getGameCount(){return this.nGames}setSubSet(a){super.setSubSet(a);this.fireOnDBLength(this.getSetSize())}addToSubSet(a){super.addToSubSet(a);this.fireOnDBLength(this.getSetSize())}clearSubSet(){super.clearSubSet();this.fireOnDBLength(this.getGameCount())}getCopySrcId(){return this.cloudId}getDisplayTitle(){return"Cloud: "+StrUtil.decodeUTF8(this.dbItem.owner+" - "+this.dbItem.title)}
4622getHeaderJson(a){if(1>a||a>this.nGames)ASSERT(0);
4623else{if(void 0===this.headers[a]){this.requestedHeaderNums[a]||(this.requestedHeaderNums[a]=1,this.cloudManager.loadHeader(this.cloudId,a));var b=new GameHeader;this.fillPlaceHolderHeader(b,a);b.nGame=a;this.headers[a]=b;void 0===this.headers[a].loadCnt?this.headers[a].loadCnt=0:this.headers[a].loadCnt++}else b=this.headers[a];return b.toJson()}}loadHeadersJsonAsync(a,b,c){c>this.getSetSize()&&(c=this.getSetSize());if(this.checkPendingHeaderJob(b,c))LOG("Job already underway: "+b+"-"+c);else{LOG("Cl-Load Hdrs Async: "+
4624b+" - "+c);var d=this;a={first:b,last:c,jsons:[],callback:a,count:0,calls:1,complete:function(){return this.count==this.last-this.first+1},addHeader:function(f){var g=d.getSetInxOfGameNo(f.nGame);g>=this.first&&g<=this.last&&!this.jsons[g-this.first]&&(this.jsons[g-this.first]=f.toJson(),this.count++)},timeOut:function(){for(var f=0;f<this.last-this.first+1;f++)if(!this.jsons[f]){var g=new GameHeader;d.fillPlaceHolderHeader(g,d.getGameNoInSet(f+1));this.jsons[f]=g.toJson()}try{for(f=0;f<this.calls;f++)this.callback(this.jsons)}catch(h){LOG("JobTimeOutException: "+
4625h,"LogException")}this.timeout=!0}};this.pendingHeaderJobs.push(a);a.timer=new Timer(a.timeOut.bind(a));for(c<b?a.timer.runOnce(100):a.timer.runOnce(1E4);b<=c&&b<=this.getSetSize();b++)if(a=this.getGameNoInSet(b)){if(!this.requestedHeaderNums[a]&&(this.requestedHeaderNums[a]=1,this.cloudManager.loadHeader(this.cloudId,a),void 0===this.headers[a])){var e=new GameHeader;this.fillPlaceHolderHeader(e);e.nGame=a;this.headers[a]=e}this.headers[a].loadCnt=0}}}checkPendingHeaderJob(a,b){for(var c=0;c<this.pendingHeaderJobs.length;c++){var d=
4626this.pendingHeaderJobs[c];if(d&&d.first<=a&&d.last>=b&&!d.timeout)return this.pendingHeaderJobs[c].calls++,!0}return!1}onHeadersChanged(a){for(var b=0;b<a.length;b++)a[b].header.loadCnt=void 0!==this.headers[a[b].nGame]?++this.headers[a[b].nGame].loadCnt:0,this.headers[a[b].nGame]=a[b].header,this.requestedHeaderNums[a[b].nGame]=0;for(var c=0;c<this.pendingHeaderJobs.length;c++)if(this.pendingHeaderJobs[c])for(b=0;b<a.length;b++)this.pendingHeaderJobs[c].addHeader(a[b].header);for(c=0;c<this.pendingHeaderJobs.length;c++)if(this.pendingHeaderJobs[c]&&
4627this.pendingHeaderJobs[c].complete()){b=this.pendingHeaderJobs[c];LOG("Complete Job: "+b.first+" - "+b.last);this.pendingHeaderJobs[c].timer.stop();try{for(var d=0;d<b.calls;d++)this.pendingHeaderJobs[c].callback(this.pendingHeaderJobs[c].jsons)}catch(e){LOG("PendingJ: "+e,"LogException")}LOG("Complete J after callback: "+b.first+" - "+b.last);delete this.pendingHeaderJobs[c]}b=!1;for(c=0;b&&c<this.pendingHeaderJobs.length;c++)this.pendingHeaderJobs[c]&&this.pendingHeaderJobs[c].timeout&&(b=!1);b&&
4628(this.pendingHeaderJobs=[]);this.fireOnGameHeadersChanged(a)}fillPlaceHolderHeader(a,b){a.white=new PlayerData("Waiting for Server...");a.loadCnt=0;a.nGame=b}getGame(a){return new Game}loadGameAsync(a,b){if(!(b>this.getGameCount())){LOG("Cloud Game: "+b);var c=this;a={gameNo:b,game:new Game,callback:a,loaded:!1,setGame:function(d){d.getGameNo()==b&&(this.game=d,this.loaded=!0)},timeOut:function(){for(var d=0;d<this.last-this.first+1;d++)if(!this.jsons[d]){var e=new GameHeader;c.fillPlaceHolderHeader(e);
4629this.game.setHeader(e);this.loaded=!0}LOG("Timeout Job: "+this.first+" - "+this.last);this.callback(this.game);this.timeout=!0}};a.timer=new Timer(a.timeOut.bind(a));a.timer.runOnce(1E4);this.pendingGameJobs.push(a);this.cloudManager.loadGame(this.cloudId,b)}}onGameChanged(a){if(a.cloudId==this.cloudId){for(var b=0;b<this.pendingGameJobs.length;b++)this.pendingGameJobs[b]&&this.pendingGameJobs[b].setGame(a.game);for(b=0;b<this.pendingGameJobs.length;b++)this.pendingGameJobs[b]&&this.pendingGameJobs[b].loaded&&
4630(LOG("Complete Game Job"),this.pendingGameJobs[b].timer.stop(),this.pendingGameJobs[b].callback(this.pendingGameJobs[b].game),delete this.pendingGameJobs[b]);LOG("...CloudDB OnGameChanged");this.reorgJobs(this.pendingGameJobs)}}onChangedByGameNo(a){if(a.cloudId==this.cloudId){for(var b=this.nGames,c=0;c<a.gameNos.length;c++)a.gameNos[c]>this.nGames&&(this.nGames=a.gameNos[c]);this.nGames>b&&this.clearSubSet();for(c=0;c<a.gameNos.length;c++)a.gameNos[c]<=this.nGames&&this.cloudManager.loadHeader(this.cloudId,
4631a.gameNos[c])}}onGameAppended(a){a.cloudId==this.cloudId&&(this.nGames++,this.requestedHeaderNums=[],this.clearSubSet())}onChangeLogin(){this.fireOnDBDeleted()}onReorganized(a){a.cloudId==this.cloudId&&(this.nGames=a.nNewLen,this.requestedHeaderNums=[],0<this.filterText.length&&this.setFilter(this.filterText),this.fireOnDBLength(this.nGames))}onDeleted(a){a.cloudId==this.cloudId&&this.fireOnDBDeleted()}toggleDeleteMark(a){if(this.headers[a]){var b=!this.headers[a].deleted;this.headers[a].setDeleted(b);
4632void 0===this.headers[a].loadCnt?this.headers[a].loadCnt=0:this.headers[a].loadCnt++;var c=new ServerHeaderResponse(this.cloudId,a,0,this.headers[a]);this.fireOnGameHeadersChanged([c]);this.cloudManager.sendMarkAsDeleted(this.cloudId,[a],[b])}}toggleDeleteMarks(a){for(var b=[],c=[],d=0;d<a.length;d++){var e=a[d];if(this.headers[e]){var f=!this.headers[e].deleted;this.headers[e].setDeleted(f);void 0===this.headers[e].loadCnt?this.headers[e].loadCnt=0:this.headers[e].loadCnt++;var g=new ServerHeaderResponse(this.cloudId,
4633e,0,this.headers[e]);this.fireOnGameHeadersChanged([g]);b.push(e);c.push(f)}}this.cloudManager.sendMarkAsDeleted(this.cloudId,b,c)}removeDeletedGames(){this.resetCaches();this.cloudManager.reorgOnServer(this.cloudId)}reorgJobs(a){for(var b=!0,c=0;b&&c<a.length;c++)a[c]&&a[c].timeout&&(b=!1)}importGames(a,b){"number"==typeof a?this.cloudManager.copyGamesTo(a,this.cloudId,b):"function"==typeof a&&(a=a(b),this.cloudManager.saveGames(this.cloudId,a))}static InitListeners(){CloudDatabase.prototype.fireEvent||
4634(Vk.initForListeners(CloudDatabase),Vk.addEvent(CloudDatabase,"GameHeadersChanged"),Vk.addEvent(CloudDatabase,"DBLength"),Vk.addEvent(CloudDatabase,"DBDeleted"))}}"use strict";
4634var CloudDBType={NONE:0,REP_WHITE:1,REP_BLACK:2,OWN_GAMES:3,PLAYCHESS:4,TACTICTRAINING:5,OPENINGS_BACKUP:6,TRAININGPOSITIONS:7,AGAINSTFRITZ:8,CLIPBOARD:9};
4635class CloudDBItem{constructor(){this.owner=this.title=this.name="";this.nGames=0;this.dateAccessed=new CBDate(0);this.allFileSize=this.cloudId=this.nUsage=0;this.dateCreated=new CBDate(0);this.flags=0;this.propFlags={CLOUDDBITEM_SHARED:1,CLOUDDBITEM_MAY_VIEW:131072,CLOUDDBITEM_MAY_LOAD:262144,CLOUDDBITEM_MAY_SAVE:524288,CLOUDDBITEM_MAY_ADMIN:1048576,CLOUDDBITEM_OWNER:2097152};this.propFlags.CLOUDDBITEM_ALLRIGHTS=this.propFlags.CLOUDDBITEM_MAY_VIEW|this.propFlags.CLOUDDBITEM_MAY_LOAD|this.propFlags.CLOUDDBITEM_MAY_SAVE|
4636this.propFlags.CLOUDDBITEM_MAY_ADMIN|this.propFlags.CLOUDDBITEM_OWNER}fromDataBuf(a){a.Vc();this.name=a.Vb(100);this.title=a.Vb(200);this.owner=a.Vb(100);this.nGames=a.V19();this.dateAccessed=a.V11();this.nUsage=a.V19();this.cloudId=a.readUint64();this.allFileSize=a.V18();this.dateCreated=a.V11();this.flags=a.V19();this.type=a.V19();a.Vm()}toString(){return this.name+", "+this.title+", "+this.owner+", nGames="+this.nGames+", type="+this.type}static DBNAME_EXISTS=-1;static QUOTA_EXCEEDED=-2;static TOO_MANY_DATABASES=-3;static CREATE_DB_OK=0;static TYPE_AGAINSTFRITZ=8;}
4637class CloudDBItemList{constructor(){this.items=[]}size(){return this.items.length}fromDataBuf(a){this.items=[];for(var b=a.Vw(),c=0;c<b&&200>c;c++){var d=new CloudDBItem;d.fromDataBuf(a);this.items.push(d)}}getById(a){for(var b=0;b<this.items.length;b++)if(this.items[b].cloudId==a)return this.items[b]}getIdByType(a){for(var b=0;b<this.items.length;b++)if(this.items[b].type==a)return this.items[b].cloudId;return 0}removeById(a){for(var b=0;b<this.items.length;b++)if(this.items[b].cloudId==a){this.items.splice(b,
46381);break}}containsName(a){for(var b=0;b<this.items.length;b++)if(this.items[b].name.toLowerCase()==a.toLowerCase())return!0;return!1}}class CloudGame{constructor(a){this.game=a;this.time=new DateAndTime(0)}V17(a){this.game.hdr.compactToDataBuf(a);a.V13(0);this.game.writeGameOnly2(a);this.time.V17(a)}}"use strict";
4639class ServerHeaderRequest{constructor(a,b,c){this.cloudId=a;this.nGame=b;this.dateAndTime=c}fromDataBuf(a){a.Vc();this.cloudId=a.Vw();a.Vw();this.nGame=a.V19();this.dateAndTime=new DateAndTime;this.dateAndTime.fromDataBuf(a);a.Vm()}V17(a){a.beginSizedWrite();a.Vu(this.cloudId);a.Vu(0);a.V13(this.nGame);void 0===this.dateAndTime&&(this.dateAndTime=new DateAndTime(0));this.dateAndTime.V17(a);a.endSizedWrite()}setEquals(a){return this.cloudId==a.cloudId&&this.nGame==a.nGame&&this.dateAndTime==a.dateAndTime}setGreater(a){return this.cloudId==
4640a.cloudId?this.nGame==a.nGame?this.dateAndTime>a.dateAndTime:this.nGame>a.nGame:this.cloudId>a.cloudId}}var ServerHeaderResponseType={HEADER:0,REQUEST_GAME:1,UPTODATE:2,NOT_AVAILABLE:3};
4641class ServerHeaderResponse{constructor(a,b,c,d){this.cloudId=a;this.nGame=b;this.eType=c;this.header=d}fromDataBuf(a){a.Vc();this.cloudId=a.V19();this.nGame=a.V19();this.eType=a.V19();switch(this.eType){case ServerHeaderResponseType.HEADER:this.header=new GameHeader,this.header.compactFromDataBuf(a),(new DateAndTime).fromDataBuf(a)}a.Vm()}}"use strict";
4642var CloudUserMsgId={NONE:0,REQUEST_DATABASES:1600,RESPOND_DATABASES:1601,REQUEST_MULTIPLE_HEADERS:1602,RESPOND_MULTIPLE_HEADERS:1603,CLIENTREQUEST_GAME:1604,SERVERRESPOND_GAME:1605,APPEND_GAME:1606,NOTIFY_HEADER_CHANGED:1607,NOTIFY_GAME_CHANGED:1608,NOTIFY_DB_REORGANIZED:1609,NOTIFY_DB_DELETED:1610,DISK_USED:1611,INC_USAGE:1612,CONFIRM_GAME:1613,RENAME_TITLE_TO_CLIENT:1614,CONFIRM_MULTIPLE_HEADERS:1615,CREATE_CLOUD_DB:1616,CLOUD_DB_CREATED:1617,DELETE_CLOUD_DB:1618,CLOUDDB_DELETE_FINISHED:1619,SET_DELETE_MARK:1620,
4643REORG_CLOUD_DB:1621,CLOUDDB_REORG_FINISHED:1622,COPY_GAMES_TO:1623,NOTIFY_COPY_DONE:1624,COPY_GAMES_FINISHED:1625,SEARCH_GAMES:1626,SEARCH_RESULT:1627,GAMES_TO_SERVER:1628,CONFIRM_GAMES_TO_SERVER:1629,STORE_POS_AND_MOVES:1630,CHECK_POS_AND_MOVES:1631,RESPOND_POS_AND_MOVES:1632,REMOVE_FROM_MYMOVES:1633,LOAD_MY_MOVES:1634,RESPOND_ALL_MYMOVES:1635,REMOVE_WHOLE_TREE:1636,RESPOND_TREE_REMOVED:1637,MAKE_MAIN_MOVEORDER:1638,STORE_EVAL:1639,UPLOAD_GAME:1640,STORE_TEXT:1641,NOTIFY_PLAYED:1642,START_DRILL:1643,
4644UNLEARN_WHOLE_TREE:1644,RESPOND_TREE_UNLEARNED:1645,RESPOND_COUNT_MYMOVES:1647,NOTIFY_MYMOVES_CHANGED:1648,STOP_DRILL:1649,SAVE_TO_CLIPBOARD:1650,SERVER_REQUESTGAME:1656,SEARCH_BY_MASK:1661,RESPOND_SEARCH_BY_MASK:1662,CANCEL_SEARCH_BY_MASK:1663,toString:function(a){for(var b in this)if(this[b]==a)return b;return"Unknown CloudUserMsgId: "+a},toNumString:function(a){return"CloudId="+a}};
4645let PosAndMoveFlags={MY_BLACK:1,MY_WHITE:2,MOVE_WHITE:4,MOVE_BLACK:8,REP_IMPORTANT:16,REP_EXCLUDE:32,WITH_TEXT:64,DRILLED:128,DELETED:256,WHITE:6,BLACK:9,MOVE:12,MYMOVE:3};
4646class ServerCloudManager extends Connector{constructor(){super();this.setRequestedHeaders=new CBSet;this.timerSend=new Timer;this.selectedCloudId=0;this.mapDBs={};this.headerResponseReceiver=new VectorSender(function(a){this.send(a)}.bind(this));this.gameSender=new VectorSender(function(a){this.send(a)}.bind(this));this.autoOpenDB=!1;this.lastMyMovesLoadMode=this.myMovesLoadMode=GetMovesType.NONE;this.name="cloud";this.reorgGate=new V10;ServerCloudManager.InitListeners()}createLobby(a,b,c,d,e){this.create(a,
4647b,c,d,e)}getName(){return"CloudMgr"}onChangeLogin(){this.fireOnChangeLogin();this.closeAllDatabases();glApp.setLoggedIn(this.isLoggedIn())}onLoginToken(){this.logIntoChat("Connected to CloudServer","","conn");this.boundLoginOk=!0;glApp.shouldRequestCloudDBsOnLogin()?this.requestDatabases():this.loginMode!=LoginMode.GUEST&&(glApp.setLoggedIn(!0),glApp.config.silentCloud||glApp.panelMgr.showMessage(String.formatEx(lm.LOGIN_WELCOME,this.user),2E3));glApp.showAccountType(this.Vs);glApp.panelMgr.study&&
46480==glApp.panelMgr.savedStudyToCloud&&(glApp.panelMgr.gameKernel.Vp.saveToCloud(glApp.panelMgr.study),glApp.panelMgr.savedStudyToCloud=!0)}onIdReceived(){!glApp.config.silentCloud&&ToolButtons&&ToolButtons.showBusyMask("Requesting databases ... ",null,5E3)}hasSockMsgIds(){return!0}hasSockCheckSum(){return!0}onLogOff(){super.onLogOff()}logIntoChat(a,b,c){5}testYesNo(a){LOG("YesNo="+a)}test(){}handleReceived(a){if(!this.handleReceivedByConnector(a))try{switch(a.getType()){default:TRACE("Unhandled: "+
4649a.toString());break;case SockMsgId.DEFAULTGROUPS:this.logIntoChat("Connected to CloudServer");this.boundLoginOk=!0;alert("Default Groups not expected...");break;case SockMsgId.CLOUD_USER:this.handleCloudMsg(a);break;case SockMsgId.INVALIDPASSWORD:this.clearLoginCookies()}}catch(b){a=SockMsgId.toNumString(a.getType()),LogException(a,b)}}handleChat(a){glApp.panelMgr.chatOut(a.toString())}isLoggedIn(){return this.boundLoginOk&&this.isConnected()}handleCloudMsg(a){try{switch(a.getUserType()){default:TRACE("Unhandled Cloud Msg: "+
4650a.toString());break;case 107:case 121:break;case CloudUserMsgId.RESPOND_DATABASES:this.handleRespondDatabases(a);break;case CloudUserMsgId.RESPOND_MULTIPLE_HEADERS:this.handleRespondMultipleHeaders(a);break;case CloudUserMsgId.SERVERRESPOND_GAME:this.handleServerRespondGame(a);break;case CloudUserMsgId.NOTIFY_GAME_CHANGED:this.handleGamesChanged(a);break;case CloudUserMsgId.NOTIFY_HEADER_CHANGED:this.handleHeaderChanged(a);break;case CloudUserMsgId.NOTIFY_DB_REORGANIZED:case CloudUserMsgId.NOTIFY_COPY_DONE:this.handleNotifyDBReorganized(a);
4651break;case CloudUserMsgId.COPY_GAMES_FINISHED:this.handleCopyGamesFinished(a);break;case CloudUserMsgId.NOTIFY_DB_DELETED:this.handleDBDeleted(a);break;case CloudUserMsgId.DISK_USED:this.handleDiskUsed(a);break;case CloudUserMsgId.CONFIRM_GAME:this.handleConfirmGameSaved();break;case CloudUserMsgId.CONFIRM_GAMES_TO_SERVER:this.handleConfirmGamesToServer(a);break;case CloudUserMsgId.RENAME_TITLE_TO_CLIENT:this.handleRenameTitle(a);break;case CloudUserMsgId.CLOUD_DB_CREATED:this.handleDBCreated(a);
4652break;case CloudUserMsgId.CLOUDDB_DELETE_FINISHED:this.deletionFinished(a);break;case CloudUserMsgId.CLOUDDB_REORG_FINISHED:this.reorgFinished(a);break;case CloudUserMsgId.SEARCH_RESULT:this.searchResult(a);break;case CloudUserMsgId.RESPOND_POS_AND_MOVES:this.respondPosAndMoves(a);break;case CloudUserMsgId.RESPOND_ALL_MYMOVES:this.respondAllMyMoves(a);break;case CloudUserMsgId.RESPOND_TREE_REMOVED:this.respondTreeRemoved(a);break;case CloudUserMsgId.RESPOND_TREE_UNLEARNED:this.respondTreeUnlearned(a);
4653break;case CloudUserMsgId.RESPOND_COUNT_MYMOVES:this.respondCountMyMoves(a);break;case CloudUserMsgId.NOTIFY_MYMOVES_CHANGED:this.notifyMyMovesChanged(a);break;case CloudUserMsgId.SERVER_REQUESTGAME:break;case CloudUserMsgId.RESPOND_SEARCH_BY_MASK:this.respondSearchByMask(a)}}catch(b){a=CloudUserMsgId.toNumString(a.getUserType()),LogException(a,b)}}handleReconnectOk(a){}requestDatabases(){var a=new WebSockMessage(SockMsgId.CLOUD_USER);a.setUserType(CloudUserMsgId.REQUEST_DATABASES);var b=this.user;
4654this.loginMode==LoginMode.GUEST&&(b="Guest");a.getBuf().Va(b);a.getBuf().V13(System.getWindowsCodePage());this.send(a)}handleRespondDatabases(a){ToolButtons&&ToolButtons.hideBusyMask();this.cloudDBItemList=new CloudDBItemList;
4654this.cloudDBItemList.fromDataBuf(a.getBuf());var b=a.getBuf().Vw(),c=a.getBuf().Vw(),d=a.getBuf().Vw(),e=a.getBuf().Vw();a.getBuf().Vw();this.logIntoChat("Received Databases... qKB="+b+", siz= "+c+", maxDB="+d+", lastDBId="+e);glApp.config.silentCloud||(0!=e&&this.autoOpenDB?
4655this.cloudDatabaseSelected(e,!0):glApp.panelMgr.openDatabasePanel&&glApp.panelMgr.selectCloudDatabase(this.user,this.cloudDBItemList,this.cloudDatabaseSelected.bind(this)));this.autoOpenDB=!1;this.fireOnDatabasesReceived(this.cloudDBItemList)}getCloudDBItem(a){return this.cloudDBItemList.getById(a)}cloudDatabaseSelected(a,b){if(0<=a){this.selectedCloudId&&this.endUse(this.selectedCloudId);var c=this.cloudDBItemList.getById(a);if(c){var d=this.openCloudDatabase(c);console.trace("CloudDB",d);glApp.panelMgr.showDatabase(d);
4656if(b&&("Clipboard"==c.name||"CloudClip"==c.name)&&glApp.panelMgr.gameKernel)glApp.panelMgr.gameKernel.onDBGameClicked(d,d.nGames);this.callAfterDBSelected&&((new Timer(this.callAfterDBSelected)).runOnce(100),this.callAfterDBSelected=null)}this.selectedCloudId=a;this.incDBUsage(a)}else this.selectedCloudId=0}setCallAfterDBSelected(a){this.callAfterDBSelected=a}openCloudDatabaseById(a){if(a=this.cloudDBItemList.getById(a))return this.openCloudDatabase(a)}openCloudDatabase(a){if(void 0!==this.mapDBs[a.cloudId])return this.beginUse(this.mapDBs[a.cloudId]),
4657this.mapDBs[a.cloudId];a=new CloudDatabase(a.cloudId,a.nGames,this);this.beginUse(a);return a}beginUse(a){void 0==this.mapDBs[a.cloudId]&&(this.mapDBs[a.cloudId]=a);this.mapDBs[a.cloudId].incUsers()}endUse(a){"object"===typeof a?a=a.cloudId:ASSERT("number"===typeof a);void 0!==this.mapDBs[a]&&(this.mapDBs[a].decUsers(),0>=this.mapDBs[a].getNUsers()&&(this.mapDBs[a].destroy(),delete this.mapDBs[a]))}closeAllDatabases(){for(var a in this.mapDBs)this.mapDBs.hasOwnProperty(a)&&(this.mapDBs[a].destroy(),
4658delete this.mapDBs[a])}incDBUsage(a){var b=new WebSockMessage(SockMsgId.CLOUD_USER);b.setUserType(CloudUserMsgId.INC_USAGE);b.getBuf().Vu(a);b.getBuf().Vu(0);this.send(b)}createDatabase(a){if(this.cloudDBItemList.containsName(a))alert(a+" exists.");else if(!this.isGuest()){var b=new WebSockMessage(SockMsgId.CLOUD_USER);b.setUserType(CloudUserMsgId.CREATE_CLOUD_DB);b.getBuf().Va(a);b.getBuf().V13(System.getWindowsCodePage());glApp.Vn.guid.V17(b.getBuf());this.send(b)}}handleDBCreated(a){var b=a.getBuf().V19();
4659a.getBuf().Vw();a.getBuf().Vw();a.getBuf().Vb(100);switch(b){case CloudDBItem.DBNAME_EXISTS:alert("Name Exists");break;case CloudDBItem.QUOTA_EXCEEDED:alert("Disk Space insufficient");break;case CloudDBItem.TOO_MANY_DATABASES:alert("Too many databases ");break;case CloudDBItem.CREATE_DB_OK:this.fireOnDatabaseCreated(),this.requestDatabases()}}deleteDatabase(){glApp.panelMgr.selectCloudDatabase(this.user,this.cloudDBItemList,this.dbSelectedForDelete.bind(this))}deleteDatabaseNoConfirm(a){var b=new WebSockMessage(SockMsgId.CLOUD_USER);
4660b.setUserType(CloudUserMsgId.DELETE_CLOUD_DB);b.getBuf().Vu(a);b.getBuf().Vu(0);this.send(b);this.bQuotaExceeded=!1;this.fireOnDeleted({cloudId:a});this.endUse(a);this.selectedCloudId==a&&(this.selectedCloudId=0)}dbSelectedForDelete(a){if(a){var b=this.getCloudDBItem(a);if(b){var c="<strong>"+StrUtil.decodeUTF8(b.title)+"</strong>";c+="</br></br>"+b.nGames+" games";c+="</br></br> Owner="+StrUtil.decodeUTF8(b.owner);ConfirmForm("Please confirm deletion of this database:",c,function(d){if("yes"==d||
4661"ok"==d)d=new WebSockMessage(SockMsgId.CLOUD_USER),d.setUserType(CloudUserMsgId.DELETE_CLOUD_DB),d.getBuf().Vu(a),d.getBuf().Vu(0),this.send(d),this.bQuotaExceeded=!1,this.fireOnDeleted({cloudId:a}),this.endUse(a),this.selectedCloudId==a&&(this.selectedCloudId=0)}.bind(this))}}}deletionFinished(a){var b=a.getBuf().Vw();a.getBuf().Vw();a.getBuf().Vb(100);this.cloudDBItemList.removeById(b);this.fireOnDeletionFinished(b)}handleRespondMultipleHeaders(a){a=this.headerResponseReceiver.receiveVector(a,SockMsgId.CLOUD_USER,
4662CloudUserMsgId.CONFIRM_MULTIPLE_HEADERS,function(e){var f=new ServerHeaderResponse;f.fromDataBuf(e);return f});a.overhead.V1c();for(var b=[],c=0;c<a.vec.length&&1E3>c;c++){var d=a.vec[c];switch(d.eType){default:throw"URTyp";case ServerHeaderResponseType.HEADER:b.push(d);case ServerHeaderResponseType.UPTODATE:case ServerHeaderResponseType.REQUEST_GAME:case CB.V0.V1:}}b.length&&this.fireOnHeadersChanged(b)}loadHeader(a,b,c){void 0==b&&alert("nGame");
4662this.setRequestedHeaders.insert(new ServerHeaderRequest(a,
4663b,c));40<this.setRequestedHeaders.size()?this.sendHeaderRequests():this.timerSend.runOnce(500,this.sendHeaderRequests.bind(this))}sendHeaderRequests(){var a=new WebSockMessage(SockMsgId.CLOUD_USER);a.setUserType(CloudUserMsgId.REQUEST_MULTIPLE_HEADERS);a.getBuf().V13(this.setRequestedHeaders.size());for(var b=0;b<this.setRequestedHeaders.size()&&100>b;b++)this.setRequestedHeaders.getElements()[b].V17(a.getBuf());this.send(a);this.setRequestedHeaders.clear()}loadGame(a,b,c){c=new WebSockMessage(SockMsgId.CLOUD_USER);
4664c.setUserType(CloudUserMsgId.CLIENTREQUEST_GAME);c.getBuf().Vu(a);c.getBuf().Vu(0);c.getBuf().V13(b);(new DateAndTime(0)).V17(c.getBuf());this.send(c)}handleServerRespondGame(a){var b=a.getBuf().Vw();a.getBuf().Vw();var c=a.getBuf().V19();a=this.gameFromBuf(a.getBuf());a.replaceDBId=b;a.replaceGameNo=c;this.fireOnGameChanged({cloudId:b,game:a})}handleGamesChanged(a){var b=a.getBuf().Vw();a.getBuf().Vw();for(var c=a.getBuf().V19(),d=[],e=0;e<c&&1E3>e;e++){var f=a.getBuf().V19();d.push(f)}this.fireOnGamesChangedByGameNo({cloudId:b,
4665gameNos:d})}handleHeaderChanged(a){var b=a.getBuf().Vw();a.getBuf().Vw();for(var c=[],d=a.getBuf().V19(),e=0;e<d&&100>e;e++)c.push(a.getBuf().V19());this.fireOnHeadersChangedByGameNo({cloudId:b,gameNos:c})}handleNotifyDBReorganized(a){ToolButtons&&ToolButtons.hideBusyMask();var b=a.getBuf().Vw();a.getBuf().Vw();if(a.getBuf().V19()){a=a.getBuf().V19();var c=this.cloudDBItemList.getById(b);c&&(c.nGames=a);this.fireOnReorganized({cloudId:b,nNewLen:a})}}handleCopyGamesFinished(a){ToolButtons&&ToolButtons.hideBusyMask();
4666var b=a.getBuf().Vw();a.getBuf().Vw();a.getBuf().Vb(100);a=a.getBuf().V19();this.callAfterDBSelected=null;var c=this.cloudDBItemList.getById(b);c&&(c.nGames=a);this.fireOnReorganized({cloudId:b,nNewLen:a})}handleDBDeleted(a){var b=a.getBuf().Vw();a.getBuf().Vw();this.fireOnDeleted({cloudId:b});this.endUse(b)}sendMarkAsDeleted(a,b,c){var d=new WebSockMessage(SockMsgId.CLOUD_USER);d.setUserType(CloudUserMsgId.SET_DELETE_MARK);d.getBuf().Vu(a);d.getBuf().Vu(0);d.getBuf().V13(b.length);for(a=0;a<b.length;a++)d.getBuf().V13(b[a]),
4667d.getBuf().V1b(c[a]);glApp.Vn.guid.V17(d.getBuf());(new DateAndTime(0)).V17(d.getBuf());this.send(d)}reorgOnServer(a){if(!this.isGuest()){var b=new WebSockMessage(SockMsgId.CLOUD_USER);b.setUserType(CloudUserMsgId.REORG_CLOUD_DB);b.getBuf().Vu(a);b.getBuf().Vu(0);glApp.Vn.guid.V17(b.getBuf());this.send(b);(a=this.cloudDBItemList.getById(a))&&ToolButtons&&ToolButtons.showBusyMask("Cleaning Up "+a.name,null,2E4)}}reorgFinished(a){ToolButtons&&ToolButtons.hideBusyMask();var b=a.getBuf().Vw();a.getBuf().Vw();
4668a.getBuf().Vb(100);a=a.getBuf().V19();this.callAfterDBSelected=null;var c=this.cloudDBItemList.getById(b);c&&(c.nGames=a);this.fireOnReorganized({cloudId:b,nNewLen:a})}copyGamesTo(a,b,c){var d=new WebSockMessage(SockMsgId.CLOUD_USER);d.setUserType(CloudUserMsgId.COPY_GAMES_TO);d.getBuf().Vu(a);d.getBuf().Vu(0);d.getBuf().Vu(b);d.getBuf().Vu(0);glApp.Vn.guid.V17(d.getBuf());d.getBuf().V13(c.length);for(a=0;a<c.length;a++)d.getBuf().V13(c[a]);this.send(d);ToolButtons&&ToolButtons.showBusyMask("Copying games ... ",
4669null,2E4)}requestFilterSet(a,b){var c=new WebSockMessage(SockMsgId.CLOUD_USER);c.setUserType(CloudUserMsgId.SEARCH_GAMES);c.getBuf().Vu(a);c.getBuf().Vu(0);c.getBuf().Vr(b);glApp.Vn.guid.V17(c.getBuf());this.send(c);ToolButtons&&ToolButtons.showBusyMask("Searching on Server ... ",null,2E4)}searchResult(a){ToolButtons&&ToolButtons.hideBusyMask();var b=a.getBuf().Vw();a.getBuf().Vw();for(var c=a.getBuf().V19(),d=[],e=0;e<c&&1E4>e;e++){var f=a.getBuf().V19();d.push(f)}(a=this.cloudDBItemList.getById(b))&&
4670this.openCloudDatabase(a).setSubSet(d)}testSearchMask(a,b){this.searchByMask(b,a)}searchByMask(a,b){var c=new WebSockMessage(SockMsgId.CLOUD_USER);c.setUserType(CloudUserMsgId.SEARCH_BY_MASK);c.getBuf().Vu(a);c.getBuf().Vu(0);b.parseFreeText();b.V9(c.buf);this.send(c)}respondSearchByMask(a){var b=a.getBuf().Vw();a.getBuf().Vw();for(var c=a.getBuf().V19(),d=[],e=0;e<c;e++)d.push(a.getBuf().V19());e=a.getBuf().readInt();a.getBuf().readInt();a=a.getBuf().readInt();c&&(c=this.cloudDBItemList.getById(b))&&
4671(c=this.openCloudDatabase(c),a&1&&c.setSubSet([]),c.addToSubSet(d),5<c.subSet.length&&this.cancelSearchByMask(b));this.fireOnSearchByMask({cloudId:b,gameNos:d,bunchType:a,startIndex:e})}cancelSearchByMask(a){var b=new WebSockMessage(SockMsgId.CLOUD_USER);b.setUserType(CloudUserMsgId.CANCEL_SEARCH_BY_MASK);b.getBuf().Vu(a);b.getBuf().Vu(0);this.send(b)}handleDiskUsed(a){a.getBuf().Vw();a.getBuf().Vw()}handleRenameTitle(a){a.getBuf().Vw();a.getBuf().Vw();this.requestDatabases()}
4671gameFromBuf(a){var b=
4672new Game,c=new GameHeader;c.compactFromDataBuf(a);a.V19();b.readGameOnly2(a);b.setHeader(c);return b}gameToBuf(a,b){b.hdr.compactToDataBuf(a);a.V13(0);b.writeGameOnly2(a);return b}saveGameToDatabase(a,b,c){var d=new WebSockMessage(SockMsgId.CLOUD_USER);d.setUserType(CloudUserMsgId.APPEND_GAME);d.getBuf().Vu(b);d.getBuf().Vu(0);d.getBuf().V13(c);glApp.Vn.guid.V17(d.getBuf());(new DateAndTime(0)).V17(d.getBuf());this.gameToBuf(d.getBuf(),a);this.send(d)}saveGame(a,b){if(this.selectedCloudId){var c=
4673new WebSockMessage(SockMsgId.CLOUD_USER);c.setUserType(CloudUserMsgId.APPEND_GAME);c.getBuf().Vu(this.selectedCloudId);c.getBuf().Vu(0);void 0!==b?c.getBuf().V13(b):c.getBuf().V13(0);glApp.Vn.guid.V17(c.getBuf());(new DateAndTime(0)).V17(c.getBuf());this.gameToBuf(c.getBuf(),a);if(void 0===b){var d=this.openCloudDatabaseById(this.selectedCloudId);d&&(a.replaceDBId=this.selectedCloudId,a.replaceGameNo=d.getGameCount()+1)}this.send(c);void 0!==b?this.fireOnGamesChangedByGameNo({cloudId:this.selectedCloudId,
4674gameNos:[b]}):this.fireOnGameAppended({cloudId:this.selectedCloudId})}}handleConfirmGameSaved(a){this.fireOnConfirmGameSaved()}replaceGame(a){this.canReplaceGame(a)?this.saveGame(a,a.replaceGameNo):this.saveGame(a)}canReplaceGame(a){return a.replaceDBId&&a.replaceDBId==this.selectedCloudId&&0<a.replaceGameNo}saveGames(a,b){for(var c=[],d=0;d<b.length;d++)c.push(new CloudGame(b[d]));d=new DataBuffer;d.writeFakeInt64(a);glApp.Vn.guid.V17(d);b.length&&(ToolButtons&&ToolButtons.showBusyMask("Saving Games ... ",
4675null,1E3),this.gameSender.sendVector(this.getNId(),ConnectId.SERVER,c,2E4,SockMsgId.CLOUD_USER,CloudUserMsgId.GAMES_TO_SERVER,d,function(e,f){f.V17(e)}))}handleConfirmGamesToServer(a){a=this.gameSender.handleConfirmBunch(a);var b=this.cloudDBItemList.getById(this.selectedCloudId);this.fireOnConfirmGamesToServer(a);b&&(b.nGames+=a,this.reorgGate.exec(function(){ToolButtons&&ToolButtons.hideBusyMask();this.fireOnReorganized({cloudId:this.selectedCloudId,nNewLen:b.nGames})}.bind(this),2E3))}storePosAndMoves(a,
4676b){var c=this.createMsg(CloudUserMsgId.STORE_POS_AND_MOVES);this.gameToBuf(c.getBuf(),a);c.getBuf().V13(b);c.getBuf().V13(System.getWindowsCodePage());this.send(c)}storeEval(a,b){var c=this.createMsg(CloudUserMsgId.STORE_EVAL);this.gameToBuf(c.getBuf(),a);c.getBuf().V13(b);a=PosAndMoveFlags.MOVE_WHITE;this.isMovesLoadedFor(!0)&&(a=PosAndMoveFlags.MOVE_BLACK);c.getBuf().V13(a);c.getBuf().V13(System.getWindowsCodePage());this.send(c)}storeText(a,b){var c=this.createMsg(CloudUserMsgId.STORE_TEXT);this.gameToBuf(c.getBuf(),
4677a);c.getBuf().Va(StrUtil.encodeUTF8(b));a=PosAndMoveFlags.MOVE_WHITE;this.isMovesLoadedFor(!0)&&(a=PosAndMoveFlags.MOVE_BLACK);c.getBuf().V13(a);c.getBuf().V13(System.getWindowsCodePage());this.send(c)}notifyPlayed(a,b,c){var d=this.createMsg(CloudUserMsgId.NOTIFY_PLAYED);a.write(d.getBuf());
4677b.write2(d.getBuf());d.getBuf().V1b(c);d.getBuf().V13(System.getWindowsCodePage());this.send(d)}uploadToMyMoves(a){var b=this.createMsg(CloudUserMsgId.UPLOAD_GAME);this.gameToBuf(b.getBuf(),a);b.getBuf().V13(System.getWindowsCodePage());
4678this.send(b)}makeMainMoveOrder(a){var b=this.createMsg(CloudUserMsgId.MAKE_MAIN_MOVEORDER);this.gameToBuf(b.getBuf(),a);b.getBuf().V13(System.getWindowsCodePage());this.send(b)}removeFromMyMoves(a,b){var c=this.createMsg(CloudUserMsgId.REMOVE_FROM_MYMOVES);a.write(c.getBuf());delete b.annos;(new Move(b.from,b.to,b.prom)).write2(c.getBuf());c.getBuf().V13(System.getWindowsCodePage());this.send(c)}removeWholeTree(a,b,c){var d=this.createMsg(CloudUserMsgId.REMOVE_WHOLE_TREE);a.write(d.getBuf());b.write2(d.getBuf());
4679d.getBuf().V13(c);d.getBuf().V13(System.getWindowsCodePage());this.send(d)}respondTreeRemoved(a){var b=a.getBuf().Vw();a.getBuf().V19();LOG("Removed: "+b+" moves.","LogBold");this.reloadMyMoves();glApp.panelMgr.blockLiveBookUpdates(BlockUpdateMode.FORCE_UPDATE);1<b&&glApp.panelMgr.showMessage(b+" "+lm.MOVES_UNMARKED,4E3)}respondTreeUnlearned(a){var b=a.getBuf().Vw();a.getBuf().V19();glApp.panelMgr.showMessage(b+" "+lm.MOVES_UNLEARNED,4E3)}unlearnWholeTree(a,b,c){var d=this.createMsg(CloudUserMsgId.UNLEARN_WHOLE_TREE);
4680a.write(d.getBuf());
4680b.write2(d.getBuf());d.getBuf().V13(c);d.getBuf().V13(System.getWindowsCodePage());this.send(d)}respondCountMyMoves(a){}checkPosAndMoves(a,b,c){var d=this.createMsg(CloudUserMsgId.CHECK_POS_AND_MOVES);a.write(d.getBuf());d.getBuf().V1b(b?!0:!1);d.getBuf().writeInt(c||0);d.getBuf().V13(System.getWindowsCodePage());this.send(d,!0)}respondPosAndMoves(a){var b=new Position;b.read(a.getBuf());for(var c=a.getBuf().V19(),d=[],e=[],f=0;f<c&&200>f;f++){var g=new Move;g.read2(a.getBuf());
4681e=a.getBuf().Vw();var h=a.getBuf().V19(),k=a.getBuf().readUint8(),l=a.getBuf().Vb(300),m=a.getBuf().readUint8(),n=a.getBuf().Vx(),r=a.getBuf().readUint8();d.push({move:g,visits:e,flags:h,eval:k,correct:m,txt:l,date:n,learnPercent:r})}c={count:0,total:0,drilled:0,learned:0,quote:0,toString:function(){return"Stats: cnt="+this.count+", total="+this.total+", drilled="+this.drilled+", learned="+this.learned},getPercent:function(){return this.total?Math.round(100*this.quote/this.total):0}};c.count=a.getBuf().Vw();
4682c.total=a.getBuf().Vw();c.drilled=a.getBuf().Vw();c.learned=a.getBuf().Vw();c.quote=a.getBuf().readFloat64();this.fireOnMyMoves({position:b,moves:d,stats:c})}loadMyMoves(a,b){this.lastLoadMyMovesStartGame=b;glApp.panelMgr.blockLiveBookUpdates&&glApp.panelMgr.blockLiveBookUpdates(BlockUpdateMode.BLOCKED);var c=this.createMsg(CloudUserMsgId.LOAD_MY_MOVES);c.getBuf().V13(a);this.gameToBuf(c.getBuf(),b);c.getBuf().V13(System.getWindowsCodePage());this.send(c)}reloadMyMoves(){this.lastLoadMyMovesStartGame||
4683(this.lastLoadMyMovesStartGame=new Game);this.loadMyMoves(this.lastMyMovesLoadMode,this.lastLoadMyMovesStartGame)}
4683respondAllMyMoves(a){var b=this.gameFromBuf(a.getBuf()),c=a.getBuf().Vw();a=a.getBuf().V19();switch(a){case GetMovesType.ALL:var d="Both Colors";break;case GetMovesType.WHITE:d="White";break;case GetMovesType.BLACK:d="Black"}b.hdr.white=new PlayerData("","My Moves");b.hdr.black=new PlayerData("",d);0==c?(b="No Marked Moves Found.",a!=GetMovesType.ALL&&(b=d+" - "+b),glApp.panelMgr.showMessage(b,
46845E3),glApp.panelMgr.shakeMarkButton(),b=new Game):glApp.panelMgr.stopShakeMarkButton();glApp.panelMgr.loadGame(b);glApp.panelMgr.setLayoutMyMoves(!0,a==GetMovesType.BLACK);this.lastMyMovesLoadMode=this.myMovesLoadMode=a;glApp.panelMgr.blockLiveBookUpdates(BlockUpdateMode.NOT_BLOCKED)}notifyMyMovesChanged(a){glApp.notifyMyMovesChanged()}startDrill(a,b){var c=this.createMsg(CloudUserMsgId.START_DRILL);a.write(c.getBuf());c.getBuf().V13(b);c.getBuf().V13(System.getWindowsCodePage());this.send(c)}stopDrill(){var a=
4685this.createMsg(CloudUserMsgId.STOP_DRILL);a.getBuf().V13(System.getWindowsCodePage());this.send(a)}saveGameToClipboard(a){if(!(3>a.getMainLine().length&&a.isNormalInit())){var b=this.createMsg(CloudUserMsgId.SAVE_TO_CLIPBOARD);this.gameToBuf(b.getBuf(),a);b.getBuf().V13(System.getWindowsCodePage());this.send(b)}}createMsg(a){var b=new WebSockMessage(SockMsgId.CLOUD_USER);b.setUserType(a);a=this.user;this.loginMode==LoginMode.GUEST&&(a="Guest");b.getBuf().Va(StrUtil.encodeUTF8(a));return b}onResetGame(){this.myMovesLoadMode=
4686-1}isMovesLoadedForAny(){return 0<=this.myMovesLoadMode}isMovesLoadedFor(a){switch(this.myMovesLoadMode){default:return!1;case GetMovesType.ALL:return!0;case GetMovesType.BLACK:return a;case GetMovesType.WHITE:return!a}}displayForceLogOffMsg(a){var b=glApp.panelMgr.getKernel();b&&b.boardWin&&!glApp.config.silentCloud&&b.boardWin.addMessage("Server logged you off: "+a,!0)}static InitListeners(){ServerCloudManager.prototype.fireEvent||(Vk.initForListeners(ServerCloudManager),Vk.addEvent(ServerCloudManager,
4687"HeadersChanged"),Vk.addEvent(ServerCloudManager,"HeadersChangedByGameNo"),Vk.addEvent(ServerCloudManager,"GameChanged"),Vk.addEvent(ServerCloudManager,"GamesChangedByGameNo"),Vk.addEvent(ServerCloudManager,"GameAppended"),Vk.addEvent(ServerCloudManager,"ChangeLogin"),Vk.addEvent(ServerCloudManager,"Reorganized"),Vk.addEvent(ServerCloudManager,"Deleted"),Vk.addEvent(ServerCloudManager,"DeletionFinished"),Vk.addEvent(ServerCloudManager,"DatabasesReceived"),Vk.addEvent(ServerCloudManager,"SearchByMask"),
4688Vk.addEvent(ServerCloudManager,"ConfirmGamesToServer"),Vk.addEvent(ServerCloudManager,"DatabaseCreated"),Vk.addEvent(ServerCloudManager,"ConfirmGameSaved"),Vk.addEvent(ServerCloudManager,"MyMoves"))}}"use strict";
4689CloudUserMsgId={NONE:0,REQUEST_DATABASES:1600,RESPOND_DATABASES:1601,REQUEST_MULTIPLE_HEADERS:1602,RESPOND_MULTIPLE_HEADERS:1603,CLIENTREQUEST_GAME:1604,SERVERRESPOND_GAME:1605,APPEND_GAME:1606,NOTIFY_HEADER_CHANGED:1607,NOTIFY_GAME_CHANGED:1608,NOTIFY_DB_REORGANIZED:1609,NOTIFY_DB_DELETED:1610,DISK_USED:1611,INC_USAGE:1612,CONFIRM_GAME:1613,RENAME_TITLE_TO_CLIENT:1614,CONFIRM_MULTIPLE_HEADERS:1615,CREATE_CLOUD_DB:1616,CLOUD_DB_CREATED:1617,DELETE_CLOUD_DB:1618,CLOUDDB_DELETE_FINISHED:1619,SET_DELETE_MARK:1620,
4690REORG_CLOUD_DB:1621,CLOUDDB_REORG_FINISHED:1622,COPY_GAMES_TO:1623,NOTIFY_COPY_DONE:1624,COPY_GAMES_FINISHED:1625,SEARCH_GAMES:1626,SEARCH_RESULT:1627,GAMES_TO_SERVER:1628,CONFIRM_GAMES_TO_SERVER:1629,STORE_POS_AND_MOVES:1630,CHECK_POS_AND_MOVES:1631,RESPOND_POS_AND_MOVES:1632,REMOVE_FROM_MYMOVES:1633,LOAD_MY_MOVES:1634,RESPOND_ALL_MYMOVES:1635,REMOVE_WHOLE_TREE:1636,RESPOND_TREE_REMOVED:1637,MAKE_MAIN_MOVEORDER:1638,STORE_EVAL:1639,UPLOAD_GAME:1640,STORE_TEXT:1641,NOTIFY_PLAYED:1642,START_DRILL:1643,
4691UNLEARN_WHOLE_TREE:1644,RESPOND_TREE_UNLEARNED:1645,RESPOND_COUNT_MYMOVES:1647,NOTIFY_MYMOVES_CHANGED:1648,STOP_DRILL:1649,SAVE_TO_CLIPBOARD:1650,LOAD_ALL_MYMOVES_EX:1651,COUNT_MYMOVES_EX:1652,CHECK_POS_AND_MOVES_EX:1653,REQUEST_REPERTOIRELIST:1654,RESPOND_REPERTOIRELIST:1655,SERVER_REQUESTGAME:1656,NOTIFY_MYMOVES_CHANGED_CONFIRM:1657,REQUEST_DRILL_STATISTICS:1658,RESPOND_DRILL_STATISTICS:1659,DRILL_INCREMENT:1660,toString:function(a){for(var b in this)if(this[b]==a)return b;return"Unknown CloudUserMsgId: "+
4692a}
4692,toNumString:function(a){return"MyMovesId="+a}};
4693const MyMovesManager=function(){var a=function(){this.initForListeners();this.setRequestedHeaders=new CBSet;this.timerSend=new Timer;this.selectedMyMovesId=0;this.mapDBs={};this.headerResponseReceiver=new VectorSender(function(b){this.send(b)}.bind(this));this.gameSender=new VectorSender(function(b){this.send(b)}.bind(this));this.autoOpenDB=!1;this.lastMyMovesLoadMode=this.myMovesLoadMode=GetMovesType.NONE;this.name="MyMoves";this.myMoves=[]};inherit(a,Connector);a.prototype.createLobby=function(b,
4694c,d,e,f){this.create(b,c,d,e,f)};a.prototype.getName=function(){return"MyMovesMgr"};a.prototype.onChangeLogin=function(){glApp.setLoggedIn(this.isLoggedIn())};a.prototype.onLoginToken=function(){this.logIntoChat("Connected to MyMovesServer","","conn");this.boundLoginOk=!0;this.loginMode!==LoginMode.GUEST&&(glApp.setLoggedIn(!0),glApp.panelMgr.getKernel()&&this.checkPosAndMoves(glApp.panelMgr.getKernel().getCurPos()));glApp.showAccountType(this.Vs)};a.prototype.onIdReceived=function(b){b.isFromBridge()||
4695(this.boundLoginOk=!0,this.loginMode!==LoginMode.GUEST?b.strUserId&&(glApp.Vn.userName=StrUtil.decodeUTF8(b.strUserId),this.user=StrUtil.decodeUTF8(b.strUserId),this.utf8User=b.strUserId,b.strToken&&(glApp.Vn.loginToken=b.strToken,DOM.setCookie("AccountMode",LoginMode.NORMAL),glApp.Vn.rememberLoginToken(),this.Vs=b.Vs,glApp.setLoggedIn(!0),glApp.showAccountType(this.Vs),this.loadRepFromUrl()||glApp.panelMgr.getKernel()&&this.checkPosAndMoves(glApp.panelMgr.getKernel().getCurPos())),this.fnOnIdReceived&&
4696this.fnOnIdReceived()):(this.user="Guest"+this.getNId(),this.utf8User="Guest"+this.getNId()))};a.prototype.hasSockMsgIds=function(){return!0};a.prototype.hasSockCheckSum=function(){return!0};a.prototype.loadRepFromUrl=function(){if(!this.hasLoadedRepFromUrl&&glApp.urlParams&&glApp.urlParams.repName&&glApp.urlParams.repPath){this.hasLoadedRepFromUrl=!0;var b=new RepertoireItem;b.name=glApp.urlParams.repName;b.path=glApp.urlParams.repPath;b.global=!0;b.eMode=parseInt(glApp.urlParams.repMode);b.eLevel=
46970;(new Timer).runOnce(10,function(){this.setAndLoadMyMovesByName(b,new Game)}.bind(this));return!0}};a.prototype.onLogOff=function(){this.superClass.onLogOff.apply(this,arguments)};a.prototype.logIntoChat=function(b,c,d){5};a.prototype.testYesNo=function(b){LOG("YesNo="+b)};a.prototype.test=function(){};a.prototype.handleReceived=function(b){if(!this.handleReceivedByConnector(b))try{switch(b.getType()){default:TRACE("Unhandled: "+b.toString());break;case SockMsgId.DEFAULTGROUPS:this.logIntoChat("Connected to MyMovesServer");
4698this.boundLoginOk=!0;alert("Default Groups not expected...");break;case SockMsgId.CLOUD_USER:this.handleMyMovesMsg(b);break;case SockMsgId.INVALIDPASSWORD:this.clearLoginCookies()}}catch(c){b=SockMsgId.toNumString(b.getType()),LogException(b,c)}};a.prototype.handleChat=function(b){glApp.panelMgr.chatOut(b.toString())};a.prototype.isLoggedIn=function(){return this.boundLoginOk&&this.isConnected()};a.prototype.handleMyMovesMsg=function(b){try{switch(b.getUserType()){default:TRACE("Unhandled MyMoves Msg: "+
4699b.toString());break;case CloudUserMsgId.DISK_USED:this.handleDiskUsed(b);break;case CloudUserMsgId.RESPOND_POS_AND_MOVES:this.respondPosAndMoves(b);break;case CloudUserMsgId.RESPOND_ALL_MYMOVES:this.respondAllMyMoves(b);break;case CloudUserMsgId.RESPOND_TREE_REMOVED:this.respondTreeRemoved(b);break;case CloudUserMsgId.RESPOND_TREE_UNLEARNED:this.respondTreeUnlearned(b);break;case CloudUserMsgId.RESPOND_COUNT_MYMOVES:break;case CloudUserMsgId.NOTIFY_MYMOVES_CHANGED:this.notifyMyMovesChanged(b);break;
4700case CloudUserMsgId.NOTIFY_MYMOVES_CHANGED_CONFIRM:break;case CloudUserMsgId.RESPOND_REPERTOIRELIST:this.handleRepertoireList(b);break;case CloudUserMsgId.NOTIFY_GAME_CHANGED:break;case CloudUserMsgId.RESPOND_DRILL_STATISTICS:this.handleDrillStatistics(b);break;case CloudUserMsgId.DRILL_INCREMENT:this.handleDrillIncrement(b)}}catch(c){b=CloudUserMsgId.toNumString(b.getUserType()),LogException(b,c)}};a.prototype.handleReconnectOk=function(b){};a.prototype.handleDiskUsed=function(b){b.getBuf().Vw();
4701b.getBuf().Vw()};a.prototype.gameFromBuf=function(b){var c=new Game,d=new GameHeader;d.compactFromDataBuf(b);b.V19();c.readGameOnly2(b);c.setHeader(d);return c};a.prototype.gameToBuf=function(b,c){c.hdr.compactToDataBuf(b);b.V13(0);c.writeGameOnly2(b);return c};a.prototype.storePosAndMoves=function(b,c){var d=this.createMsg(CloudUserMsgId.STORE_POS_AND_MOVES);this.gameToBuf(d.getBuf(),b);d.getBuf().V13(c);d.getBuf().V13(System.getWindowsCodePage());this.send(d)};a.prototype.storeEval=function(b,c){var d=
4702this.createMsg(CloudUserMsgId.STORE_EVAL);this.gameToBuf(d.getBuf(),b);d.getBuf().V13(c);b=PosAndMoveFlags.MOVE_WHITE;this.isMovesLoadedFor(!0)&&(b=PosAndMoveFlags.MOVE_BLACK);d.getBuf().V13(b);d.getBuf().V13(System.getWindowsCodePage());this.send(d)};a.prototype.storeText=function(b,c){var d=this.createMsg(CloudUserMsgId.STORE_TEXT);this.gameToBuf(d.getBuf(),b);d.getBuf().Va(StrUtil.encodeUTF8(c));b=PosAndMoveFlags.MOVE_WHITE;this.isMovesLoadedFor(!0)&&(b=PosAndMoveFlags.MOVE_BLACK);d.getBuf().V13(b);
4703d.getBuf().V13(System.getWindowsCodePage());this.send(d)};a.prototype.notifyPlayed=function(b,c,d){var e=this.createMsg(CloudUserMsgId.NOTIFY_PLAYED);
4703b.write(e.getBuf());c.write2(e.getBuf());e.getBuf().V1b(d);e.getBuf().V13(System.getWindowsCodePage());this.send(e)};a.prototype.uploadToMyMoves=function(b){var c=this.createMsg(CloudUserMsgId.UPLOAD_GAME);this.gameToBuf(c.getBuf(),b);c.getBuf().V13(System.getWindowsCodePage());this.send(c)};a.prototype.makeMainMoveOrder=function(b){var c=this.createMsg(CloudUserMsgId.MAKE_MAIN_MOVEORDER);
4704this.gameToBuf(c.getBuf(),b);c.getBuf().V13(System.getWindowsCodePage());this.send(c)};a.prototype.removeFromMyMoves=function(b,c){if(c&&this.isMovesLoadedForAny()){var d=this.createMsg(CloudUserMsgId.REMOVE_FROM_MYMOVES);b.write(d.getBuf());delete c.annos;(new Move(c.from,c.to,c.prom)).write2(d.getBuf());d.getBuf().V13(System.getWindowsCodePage());this.send(d)}};a.prototype.removeWholeTree=function(b,c,d){var e=this.createMsg(CloudUserMsgId.REMOVE_WHOLE_TREE);b.write(e.getBuf());c.write2(e.getBuf());
4705e.getBuf().V13(d);e.getBuf().V13(System.getWindowsCodePage());this.send(e)};a.prototype.respondTreeRemoved=function(b){var c=b.getBuf().Vw();b.getBuf().V19();LOG("Removed: "+c+" moves.","LogBold");this.reloadMyMoves();glApp.panelMgr.blockLiveBookUpdates(BlockUpdateMode.FORCE_UPDATE);1<c&&glApp.panelMgr.showMessage(c+" "+lm.MOVES_UNMARKED,4E3)};a.prototype.respondTreeUnlearned=function(b){var c=b.getBuf().Vw();b.getBuf().V19();glApp.panelMgr.showMessage(c+" "+lm.MOVES_UNLEARNED,4E3)};a.prototype.unlearnWholeTree=
4706function(b,c,d){var e=this.createMsg(CloudUserMsgId.UNLEARN_WHOLE_TREE);b.write(e.getBuf());c.write2(e.getBuf());e.getBuf().V13(d);e.getBuf().V13(System.getWindowsCodePage());this.send(e)};a.prototype.respondCountMyMoves=function(b){};a.prototype.checkPosAndMoves=function(b,c,d){var e=this.createMsg(CloudUserMsgId.CHECK_POS_AND_MOVES);b.write(e.getBuf());e.getBuf().V1b(c?!0:!1);e.getBuf().writeInt(d||0);e.getBuf().V13(System.getWindowsCodePage());this.send(e,!0)};a.prototype.checkPosAndMovesEx=function(b,
4707c,d){if(!this.currRepListItem)return this.checkPosAndMoves(b,c,d);var e=this.createMsg(CloudUserMsgId.CHECK_POS_AND_MOVES_EX);this.repListItemToPosMovesId(this.currRepListItem,e.getBuf());b.write(e.getBuf());e.getBuf().V1b(c?!0:!1);e.getBuf().writeInt(d||0);e.getBuf().V13(System.getWindowsCodePage());this.send(e,!0)};a.prototype.respondPosAndMoves=function(b){var c=new Position;c.read(b.getBuf());for(var d=b.getBuf().V19(),e=[],f=0;f<d&&200>f;f++){var g=new Move;g.read2(b.getBuf());var h=b.getBuf().Vw(),
4708k=b.getBuf().V19(),l=b.getBuf().readUint8(),m=b.getBuf().Vb(300),n=b.getBuf().readUint8(),r=b.getBuf().Vx(),t=b.getBuf().readUint8();e.push({move:g,visits:h,flags:k,eval:l,correct:n,txt:m,date:r,learnPercent:t})}d={count:0,total:0,drilled:0,learned:0,quote:0,toString:function(){return"Stats: cnt="+this.count+", total="+this.total+", drilled="+this.drilled+", learned="+this.learned},getPercent:function(){return this.total?Math.round(100*this.quote/this.total):0}};d.count=b.getBuf().Vw();d.total=b.getBuf().Vw();
4709d.drilled=b.getBuf().Vw();d.learned=b.getBuf().Vw();d.quote=b.getBuf().readFloat64();this.fireOnMyMoves({position:c,moves:e,stats:d})};a.prototype.setAndLoadMyMovesByName=function(b,c){this.myMovesLoadMode<GetMovesType.GLOBAL_WHITE&&(c=new Game);this.currRepListItem=b;this.myMovesLoadMode=0===b.eMode?GetMovesType.GLOBAL_WHITE:GetMovesType.GLOBAL_BLACK;glApp.panelMgr.blockLiveBookUpdates&&glApp.panelMgr.blockLiveBookUpdates(BlockUpdateMode.BLOCKED);var d=this.createMsg(CloudUserMsgId.LOAD_ALL_MYMOVES_EX);
4710this.repListItemToPosMovesId(b,d.getBuf());d.getBuf().V13(this.myMovesLoadMode);this.gameToBuf(d.getBuf(),c);d.getBuf().V13(System.getWindowsCodePage());this.send(d)};a.prototype.reloadGlobalMyMoves=function(b,c,d){if(this.currRepListItem&&this.currRepListItem.path&&this.currRepListItem.name){var e=this.currRepListItem.path.split("\\")[0];this.currRepListItem.path=this.makeServerPath(e,b,c,this.currRepListItem.eMode);this.setAndLoadMyMovesByName(this.currRepListItem,d)}};a.prototype.makeServerPath=
4711function(b,c,d,e){switch(c){case RepDepth.EASY:b+="\\Easy";break;case RepDepth.CLUB:b+="\\Club";break;case RepDepth.TOURNAMENT:b+="\\Tourn";break;case RepDepth.MASTER:b+="\\Profi"}switch(d){case RepStyle.FASHION:b+="-Fashion";break;case RepStyle.SIDELINES:b+="-SideLines"}1===e?b=b+="-Black":0===e&&(b=b+="-White");return b};
4711a.prototype.repListItemToPosMovesId=function(b,c){c.Va(b.name);c.Va(b.path);c.V1b(b.global)};a.prototype.loadCurrentMyMoves=function(b,c){this.currRepListItem&&b>=GetMovesType.GLOBAL_WHITE?
4712this.setAndLoadMyMovesByName(this.currRepListItem,c):this.loadMyMoves(b,c)};a.prototype.loadMyMoves=function(b,c,d){this.currRepListItem=null;this.loadMyMovesHdl=d;this.doLoadMyMoves(b,new Game)};a.prototype.doLoadMyMoves=function(b,c){this.lastLoadMyMovesStartGame=c;glApp.panelMgr.blockLiveBookUpdates&&glApp.panelMgr.blockLiveBookUpdates(BlockUpdateMode.BLOCKED);var d=this.createMsg(CloudUserMsgId.LOAD_MY_MOVES);d.getBuf().V13(b);this.gameToBuf(d.getBuf(),c);d.getBuf().V13(System.getWindowsCodePage());
4713this.send(d)};a.prototype.annoLatestMyMovesMove=function(b){var c=-1,d=-1;this.myMoves[1]&&(c=b.findInTree(this.myMoves[1]));this.myMoves[2]&&(d=b.findInTree(this.myMoves[2]));var e=function(f,g,h){3<g&&(f.gotoIndex(g),f=f.getOrCreateCurrAnno(),h?f.addPostText("My Moves - Black"):f.addPostText("My Moves - White"))};e(b,c,!1);e(b,d,!0);return Math.max(c,d)};a.prototype.resetGame=function(){var b=glApp.panelMgr.getKernel();b&&b.game.assign(new Game);this.lastLoadMyMovesStartGame=new Game};a.prototype.reloadMyMoves=
4714function(){this.lastLoadMyMovesStartGame||(this.lastLoadMyMovesStartGame=new Game);this.loadMyMoves(this.lastMyMovesLoadMode,this.lastLoadMyMovesStartGame)};a.prototype.respondAllMyMoves=function(b){var c=this.gameFromBuf(b.getBuf()),d=b.getBuf().Vw();b=b.getBuf().V19();switch(b){case GetMovesType.ALL:var e="Both Colors";break;case GetMovesType.WHITE:e="White";break;case GetMovesType.BLACK:e="Black"}c.hdr.white=new PlayerData("","My Moves");c.hdr.black=new PlayerData("",e);0==d?(c="No Marked Moves Found.",
4715b!=GetMovesType.ALL&&b<GetMovesType.GLOBAL_WHITE&&(c=e+" - "+c),glApp.panelMgr.showMessage(c,5E3),glApp.panelMgr.shakeMarkButton&&glApp.panelMgr.shakeMarkButton(),c=new Game):glApp.panelMgr.stopShakeMarkButton&&glApp.panelMgr.stopShakeMarkButton();b>=GetMovesType.GLOBAL_WHITE&&this.removeAllMyMoveAnnos(c);glApp.panelMgr.loadGame(c);this.myMovesLoadMode=b;var f;this.currRepListItem&&(f=this.currRepListItem.getNotaHeaderTitleLines());glApp.panelMgr.setLayoutMyMoves&&glApp.panelMgr.setLayoutMyMoves(!0,
4716b,f);this.lastMyMovesLoadMode=b;glApp.panelMgr.blockLiveBookUpdates&&glApp.panelMgr.blockLiveBookUpdates(BlockUpdateMode.NOT_BLOCKED);this.loadMyMovesHdl&&(this.loadMyMovesHdl(),delete this.loadMyMovesHdl);this.myMoves[b]=c};a.prototype.removeAllMyMoveAnnos=function(b){b.forAllMoves(function(c){(c=c.getAnno())&&(c=c.getSymbol())&&c.removeMyMoveMark()})};a.prototype.notifyMyMovesChanged=function(b){glApp.notifyMyMovesChanged()};a.prototype.startDrill=function(b,c){var d=this.createMsg(CloudUserMsgId.START_DRILL);
4717b.write(d.getBuf());d.getBuf().V13(c);d.getBuf().V13(System.getWindowsCodePage());this.send(d);this.drillStats={positions:0,visited:0,memScore:0,getPercent:function(){return this.positions?Math.round(100*this.memScore/this.positions):0},getVisitedPercent:function(){return this.positions?Math.round(100*this.visited/this.positions):0}};this.requestDrillStatistics(b,c===GetMovesType.BLACK)};a.prototype.stopDrill=function(){var b=this.createMsg(CloudUserMsgId.STOP_DRILL);b.getBuf().V13(System.getWindowsCodePage());
4718this.send(b)};a.prototype.requestRepertoireList=function(b){var c=this.createMsg(CloudUserMsgId.REQUEST_REPERTOIRELIST);this.repListItemToPosMovesId({name:"",path:"",global:!0}
4718,c.getBuf());c.getBuf().V13(b?1:0);this.send(c)};a.prototype.handleRepertoireList=function(b){var c=new RepertoireItemList;c.fromDataBuf(b.getBuf());b=b.getBuf().V1c();this.fireOnRepertoires({list:c,black:b})};a.prototype.requestDrillStatistics=function(b,c){c=c?GetMovesType.BLACK:GetMovesType.WHITE;var d=this.createMsg(CloudUserMsgId.REQUEST_DRILL_STATISTICS);
4719b.write(d.getBuf());d.getBuf().writeInt(c);this.send(d)};a.prototype.handleDrillStatistics=function(b){b=b.getBuf();b.Vc();this.drillStats.positions=b.Vw();this.drillStats.visited=b.Vw();this.drillStats.memScore=b.readFloat64();b.Vm();glApp.panelMgr.scorePanel.showDrillStats(this.drillStats)};a.prototype.handleDrillIncrement=function(b){if(this.drillStats){b=b.getBuf();b.Vc();var c=b.readFloat64(),d=b.Vw();this.drillStats.visited+=d;this.drillStats.memScore+=c;b.Vm();glApp.panelMgr.scorePanel.showDrillStats(this.drillStats)}};
4720a.prototype.createMsg=function(b){var c=new WebSockMessage(SockMsgId.CLOUD_USER);c.setUserType(b);b=this.user;this.loginMode==LoginMode.GUEST&&(b="Guest");c.getBuf().Va(StrUtil.encodeUTF8(b));return c};a.prototype.onResetGame=function(){this.myMovesLoadMode=GetMovesType.NONE};a.prototype.isMovesLoadedForAny=function(){return this.myMovesLoadMode>=GetMovesType.ALL&&this.myMovesLoadMode<GetMovesType.GLOBAL_WHITE};a.prototype.getLoadedMovesSide=function(){switch(this.lastMyMovesLoadMode){default:return Side.NONE;
4721case GetMovesType.ALL:case GetMovesType.WHITE:case GetMovesType.GLOBAL_WHITE:return Side.WHITE;case GetMovesType.BLACK:case GetMovesType.GLOBAL_BLACK:return Side.BLACK}};a.prototype.isMovesLoadedFor=function(b){switch(this.myMovesLoadMode){default:return!1;case GetMovesType.ALL:return!0;case GetMovesType.BLACK:return b;case GetMovesType.WHITE:return!b}};a.prototype.displayForceLogOffMsg=function(b){var c=glApp.panelMgr.getKernel();c&&c.boardWin&&c.boardWin.addMessage("Server logged you off: "+b,!0)};
4722a.prototype.initForListeners=function(){a.prototype.fireEvent||(Vk.initForListeners(a),Vk.addEvent(a,"MyMoves"),Vk.addEvent(a,"Repertoires"))};return a}();"use strict";
4723class DOM{static get(a){return document.getElementById(a)}static inputAdd(a,b){throw Error("Not implemented because CB.input not found");}static add(a,b,c){var d=document.createElement("div");b&&b.length?(b=document.createElement(b),b.innerText=a):b=document.createTextNode(a);void 0!==c&&(d.className=c);d.appendChild(b);document.body.appendChild(d)}static addUrl(a,b,c){var d=document.createElement("div"),e=document.createElement("a");e.href=a;e.target="_blank";b&&b.length&&(e.textContent=b);void 0!==
4724c&&(d.className=c);d.appendChild(e);document.body.appendChild(d)}static addBr(){var a=document.createElement("br");document.body.appendChild(a)}static insertBefore(a,b,c){a=document.createTextNode(a);var d=document.createElement("div");d.className=void 0!==c?c:"Text";document.body.appendChild(d);d.appendChild(a);void 0!==document.getElementById(b)?document.body.insertBefore(d,document.getElementById(b)):document.body.appendChild(d)}static getCookie(a){for(var b=document.cookie.split(";"),c=0;c<b.length;c++){var d=
4725b[c].split("="),e=d[0].trim();d=1<d.length?d[1]:"";if(e==a)return decodeURIComponent(d)}return""}static codeAccountName(a){return StrUtil.base64.encode(StrUtil.htmlEncode(a))}static setAccountNameCookie(a){"guest"!=a&&this.setCodedCookie("AccountName64",a)}static getAccountNameCookie(a){return this.getCodedCookie("AccountName64",a)}static setCodedCookie(a,b){DOM.setCookie(a,this.codeAccountName(b))}static getCodedCookie(a,b){a=DOM.getCookie(a);a=StrUtil.base64.decode(a);b&&(a=StrUtil.htmlDecode(a),
4726a=a.replace("%25","%"),a=a.replace("%20"," "));return a}static setCookie(a,b){var c=new Date;if(b){c.setYear(c.getFullYear()+1);var d=c.toGMTString()}else d="Thu, 01 Jan 1970 00:00:01 GMT";c=".chessbase.com";-1!=document.URL.search(/localhost/i)&&(c="localhost");a=a+"="+encodeURIComponent(b)+";expires="+d+";path=/;";c.length&&(a+="domain="+c+";");document.cookie=a+"SameSite=Lax;"}static clearCookie(a){DOM.setCookie(a,"")}static addCls(a,b){void 0!==a&&(a.className=0<a.className.length?a.className+
4727(" "+b):b)}static removeCls(a,b){void 0!==a&&(a.className=a.className.replace(new RegExp("\b"+b+"\b"),""))}static resize(a,b,c){if("string"===typeof a||"number"===typeof a)a=document.getElementById(a);void 0!==a&&(a.style.width=b,a.style.height=c)}static setText(a,b){a&&("undefined"==typeof a.textContent?a.innerText=b:a.textContent=b)}}function textOut(a,b){LOG(a,b);DOM.add(a,"",b)}function TRACE(a){window.glApp.config.debug&&textOut(a,"LogTrace")}
4728function EXCEPTION(a,b){void 0!==b&&(a+=" ("+b+")");textOut(a,"LogException")}function CHAT(a){textOut(a,"LogChat")}
4729class CBCSS{static docStyle;
4729static getStyleSheet(){if(void 0===CBCSS.docStyle){var a=document.createElement("style");a.setAttribute("media","screen");a.appendChild(document.createTextNode(""));document.head.appendChild(a);CBCSS.docStyle=a.sheet}return CBCSS.docStyle}static createStyleSheet(a){var b=document.createElement("style");b.id=a;b.setAttribute("media","screen");b.appendChild(document.createTextNode(""));document.head.appendChild(b);return b.sheet}static addRules(a,b){try{void 0!==CBCSS.getStyleSheet().addRule?
4730CBCSS.getStyleSheet().addRule(a,b):CBCSS.getStyleSheet().insertRule(a+" { "+b+" }",CBCSS.getStyleSheet().cssRules.length)}catch(c){LogException("CSS:addRules",c)}}static getGradToRight(a,b){return"background-image:linear-gradient( to right,"+a+","+b+")"}static getCenteredText(){return"display:block;margin-left:auto;margin-right:auto;text-align:center"}static getHeader(a,b,c){return c?"<"+a+' style="'+c+'">'+b+"</"+a+">":"<"+a+">"+b+"</"+a+">"}static findKeyframesRule(a){for(var b=CBCSS.getStyleSheet(),
4731c=0;c<b.cssRules.length;++c)if(b.cssRules[c].type==window.CSSRule.KEYFRAMES_RULE&&b.cssRules[c].name==a)return b.cssRules[c];c=System.isWebKit()?"-webkit-":"";void 0===b.insertRule?b.addRule("@"+c+"keyframes "+a+"{ 0% { top: 10px } 100% { top: 30px } }"):b.insertRule("@"+c+"keyframes "+a+"{ 0% { top: 10px } 100% { top: 30px } }",b.cssRules.length);for(c=0;c<b.cssRules.length;++c)if(b.cssRules[c].type==window.CSSRule.KEYFRAMES_RULE&&b.cssRules[c].name==a)return b.cssRules[c];return null}static iconCache={};static addIcon(a){a=
4732[].concat(a);for(var b=0;b<a.length;b++)1<a[b].length&&void 0==CBCSS.iconCache[a[b]]&&(CBCSS.getStyleSheet().insertRule("."+a[b]+"{ background-image: url( "+window.glApp.config.getRibbonPath()+a[b]+".png ) !important; }",0),CBCSS.iconCache[a[b]]=1)}}"use strict";
4733var CBQ=function(){function a(r){var t=document.createElement("div");t.innerHTML=r;return t.childNodes}function b(r){k.prototype[r]=function(){return this.arr[r].apply(this,arguments)}}function c(r){k.prototype[r]=function(t){this.on(r,t)}}var d=/^#(\w|-)+$/,e=/^.(\w|-)+$/,f=/^\w+$/,g=/^\[(\w|-)+\]$/,h=/^<.*>$/,k=function(r,t){this.initInstForListeners();var u=[];if(null!=r&&""!=r)if("string"===typeof r){t=t||document;var x=(new k(t)).single();r=r.trim();r.startsWith(">")?(u=r.replace(">","").trim(),
4734u=(new k(u,x)).arr.filter(function(B){return B.parentNode==x})):d.test(r)?(r=r.substring(1),u=(u=document.getElementById(r))?[u]:[]):f.test(r)?u=x.getElementsByTagName(r):h.test(r)?u=a(r):x&&(u=x.querySelectorAll(r,x))}else"object"===typeof r&&(u=r.proloJQ?r.arr:[r]);this.length=u.length;this.arr=[];for(r=0;r<u.length;++r)this[r]=u[r],this.arr.push(u[r]);this.proloJQ=!0};b("indexOf");b("find");b("findIndex");b("find");b("some");b("every");b("map");b("filter");b("reduce");b("forEach");k.prototype.single=
4735function(){return 1===this.arr.length?this.arr[0]:null};k.prototype.first=function(){return this.arr[0]};k.prototype.last=function(){return this.arr[this.arr.length-1]};k.prototype.addClass=function(r){this.forEach(function(t){t.classList&&t.classList.add(r)});return this};k.prototype.removeClass=function(r){r?this.forEach(function(t){t.classList&&t.classList.remove(r)}):this.forEach(function(t){t.className=""});return this};k.prototype.toggleClass=function(r){this.forEach(function(t){t.classList&&
4736t.classList.toggle(r)});return this};k.prototype.hide=function(){this.forEach(function(r){if("none"!==r.style.display){var t=r.style.display;r.oldDisplay="none"!=t?t:"block";r.style.display="none"}})};k.prototype.show=function(){this.forEach(function(r){r.style.display&&"none"!==r.style.display||(r.style.display=r.oldDisplay||"block",delete r.oldDisplay)})};k.prototype.setDisplay=function(r){this.forEach(function(t){t.style.display=r})};k.prototype.toggle=function(r){r?this.show():this.hide()};k.prototype.parent=
4737function(r){for(var t=this.single().parentNode;null!=t;t=t.parentNode)if(n.is(t,r))return t;return null};k.prototype.on=function(r,t){this.forEach(function(u){u.addEventListener(r,t)});return this};k.prototype.off=function(r,t){this.forEach(function(u){u.removeEventListener(r,t)});return this};c("mousemove");c("mousedown");c("mouseup");c("click");k.prototype.html=function(r){if(void 0===r)return this.single().innerHTML;this.forEach(function(t){t.innerHTML=r});return this};k.prototype.text=function(r){if(void 0===
4738r)return this.single().textContent?this.single().textContent:this.single().innerHTML;this.forEach(function(t){t.textContent?t.textContent=r:t.innerText=r});return this};k.prototype.prependTo=function(r){var t=(new k(r)).single();this.forEach(function(u){t.insertBefore(u,t.firstChild)})};k.prototype.prepend=function(r){var t=new k(r);this.forEach(function(u){t.prependTo(u)})};k.prototype.appendTo=function(r){var t=(new k(r)).single();this.forEach(function(u){t.appendChild(u)});return this};k.prototype.append=
4739function(r){var t=new k(r);this.forEach(function(u){t.appendTo(u)});return this};k.prototype.insertBefore=function(r){var t=new k(r);this.forEach(function(u){t.forEach(function(x){x.parentNode&&x.parentNode.insertBefore(u,x)})});return this};k.prototype.empty=function(){this.html("");return this};k.prototype.remove=function(){this.forEach(function(r){r.parentNode&&r.parentNode.removeChild(r)});return this};k.prototype.attr=function(r,t){if(void 0===t){var u=this.single().attributes[r];return u?u.value:
4740null}this.forEach(function(x){x.setAttribute(r,t)});return this};k.prototype.data=function(r,t){return this.attr("data-"+r,t)};var l=/^[+-]?(([0-9]*\.[0-9]+)|[0-9]+)/,m="marginTop marginBottom marginLeft marginRight paddingTop paddingBottom paddingLeft paddingRight height width minHeight minWidth maxHeight maxWidth borderWidth left top bottom right".split(" ");k.prototype.css=function(r,t){if(r&&"object"==typeof r&&!t){for(var u in r)r.hasOwnProperty(u)&&this.css(u,r[u]);return this}var x=minusToCamel(r);
4741if(void 0===t)return this.arr.length?getComputedStyle(this.arr[0])[x]:null;this.forEach(function(B){var y=t;null==y&&(y="");y=y.toString();var A=y;var aa=l.exec(A);aa?(aa=aa[0],A=A.substring(aa.length),A={val:parseFloat(aa),unit:A}):A=null;A&&!A.unit&&(y+=0<=m.indexOf(x)?"px":"");B.style[x]=y});return this};k.prototype.position=function(){return{top:parseFloat(this.css("top")),left:parseFloat(this.css("left"))}};k.prototype.initInstForListeners=function(){k.prototype.fireEvent||(Vk.initInstForListeners(n),
4742Vk.addInstEvent(n,"Ready"))};var n=function(r,t){return ObjUtil.isFunction(r)&&!t?(n.addOnReadyListener(r),null):new k(r,t)};n.is=function(r,t,u){return r?t?e.test(t)?(t=t.replace(".",""),r.classList&&r.classList.contains(t)):d.test(t)?(t=t.replace("#",""),r.id===t):f.test(t)?r.tagName==t:g.test(t)?(t=t.replace("[",""),t=t.replace("]",""),r.attributes&&r.hasAttribute(t)):0<=n(t,u).indexOf(r):!0:!1};n.get=function(r){return n("#"+r).single()};n.set=function(r,t){n("#"+r).single().innerHTML=t};n.fn=
4743k.prototype;return n}();"use strict";
4744var CBElement=function(){var a=0,b={append:!0},c=function(e,f,g,h){e&&(void 0===this.elDOM&&(this.elDOM=document.createElement(e)),e=h||{},e=ObjUtil.copyTo(b,e,!0),this.uniqueId||(this.uniqueId=++a),this.childs=[],this.isChild=!1,void 0!==f?f instanceof CBElement?(this.parentDOM=f.elDOM,f.addChild(this),this.isChild=!0):this.parentDOM=f:this.parentDOM=document.body,this.elDOM.id=g?g:"CBEl"+this.uniqueId,this.debug=this.elDOM.id,f=e.append,this.parentDOM&&(f?this.parentDOM.appendChild(this.elDOM):this.parentDOM.insertBefore(this.elDOM,
4745this.parentDOM.firstChild)),this.style=this.elDOM.style,this.setVisible(!1))};c.prototype.destroy=function(){this.destroyed||(this.childs.forEach(function(e,f){this.childs[f]&&this.childs[f].destroy()}.bind(this)),void 0!==this.extJSEl&&this.elDOM.removeChild(this.extJSEl.getEl().dom),this.parentDOM.removeChild(this.elDOM),this.destroyed=!0)};c.prototype.changeParentElDOM=function(e){if(this.isChild)throw"!Change parent ElDom on Child El ";this.parentDOM&&this.parentDOM.contains(this.elDOM)&&this.parentDOM.removeChild(this.elDOM);
4746(this.parentDOM=e)&&this.parentDOM.appendChild(this.elDOM)};c.prototype.addChild=function(e){this.childs[e.uniqueId]=e};c.prototype.removeChild=function(e){delete this.childs[e.uniqueId]};c.prototype.destroyChilds=function(){this.childs.forEach(function(e,f){this.childs[f]&&this.childs[f].destroy()}.bind(this));this.childs=[]};c.prototype.setVisible=function(e){this.style.visibility=e?"visible":"hidden";this.childs.forEach(function(f,g){this.childs[g]&&this.childs[g].setVisible(e)}.bind(this));void 0!==
4747this.extJSEl&&(e?this.extJSEl.show():this.extJSEl.hide())};c.prototype.isVisible=function(){return"visible"==this.style.visibility};c.prototype.setRect=function(e){this.setPos(e.topLeft.x,e.topLeft.y);this.setSize(e.w,e.h)};c.prototype.setRelativePos=function(){this.style.position="relative"};c.prototype.setPos=function(e,f){e=Math.floor(e);f=Math.floor(f);this.x=e;this.y=f;this.style.position="absolute";this.style.left=Math.round(e)+"px";this.style.top=Math.round(f)+"px"};c.prototype.getSize=function(){return{w:this.elDOM.width,
4748h:this.elDOM.height}};c.prototype.setSize=function(e,f){e=Math.floor(e);f=Math.floor(f);this.w=e;this.h=f;this.elDOM.width=e;this.elDOM.height=f;this.style.width=e+"px";this.style.height=f+"px";void 0!==this.extJSEl&&(this.extJSEl.setWidth(e),this.extJSEl.setHeight(f));this.vAlign&&(this.style.lineHeight=f+"px");this.onResize()};c.prototype.onResize=function(){};c.prototype.setHeight=function(e){this.h=e=Math.floor(e);this.style.height=e+"px";void 0!==this.extJSEl&&this.extJSEl.setHeight(e)};c.prototype.setPosSize=
4749function(e,f,g,h){this.setPos(e,f);this.setSize(g,h)};c.prototype.setZIndex=function(e){this.style.zIndex=e};c.prototype.setBorder=function(e,f,g){e=Math.floor(e);this.style.borderWidth=e+"px";void 0!==f&&(this.style.borderColor=f);this.style.borderStyle=void 0!==g?g:"solid"};c.prototype.setBoxSizing=function(e){this.style.boxSizing=e};c.prototype.setCssClass=function(e){this.elDOM.className=e};c.prototype.setBoxShadow=function(e,f,g){this.style.boxShadow=e+"px "+e+"px "+f+"px 0px "+g};c.prototype.setRounded=
4750function(e){e=Math.floor(e);this.style.borderRadius=e+"px"};
4750c.prototype.setBackgroundColor=function(e){this.backgroundColor=e.toString();this.style.backgroundColor=e.toString()};c.prototype.setColor=function(e){this.style.color=e.toString()};c.prototype.setMargin=function(e){this.style.margin=e+"px"};c.prototype.setPadding=function(e){this.style.padding=e+"px"};c.prototype.setZIndex=function(e){this.style.zIndex=e};c.prototype.setExtJSElement=function(e){this.extJSEl=e};c.enablePointerEvents=function(e,
4751f){e.style.pointerEvents=f?"all":"none"};c.prototype.setClickHandler=function(e){this.elDOM.addEventListener("click",e)};c.prototype.setHandler=function(e,f){this.elDOM.addEventListener(e,f)};c.prototype.getDomElement=function(){return this.elDOM};c.addClass=function(e,f){if(!e.className||0>e.className.indexOf(f))e.className+=" "+f};c.removeClass=function(e,f){e.className=e.className.replace(f,"");e.className=e.className.replace(/\s+/g," ")};var d={select:"input",change:"input",submit:"form",reset:"form",
4752error:"img",load:"img",abort:"img"};c.isEventSupported=function(e){var f=document.createElement(d[e]||"div");e="on"+e;var g=e in f;g||(f.setAttribute(e,"return;"),g="function"==typeof f[e]);return g};c.prototype.setWoodenBackground=function(){this.elDOM.style.background="#101010";this.elDOM.style.backgroundImage="url( "+getCommonPath()+"Media/Chess/OrangeBrighterSoft.jpg )";this.elDOM.style.backgroundSize="100% 100%";this.elDOM.style.backgroundRepeat="no-repeat";this.elDOM.style.backgroundPosition=
4753"bottom left"};return c}();"use strict";
4754var DivElement=function(){var a=function(b,c,d){DivElement.superClass.call(this,"div",b,c,d)};inherit(a,CBElement);a.prototype.setImage=function(b,c,d){void 0===this.imageNode?(this.imageNode=document.createElement("img"),this.imageNode.setAttribute("src",b),this.imageNode.setAttribute("flag","alternate text"),this.imageNode.setAttribute("height",d+"px"),this.imageNode.setAttribute("width",c+"px"),this.elDOM.appendChild(this.imageNode)):this.imageNode.setAttribute("src",b)};a.prototype.setCssClass=
4755function(b){this.elDOM.className=b};a.prototype.setText=function(b){"undefined"!=typeof b&&(void 0===this.textNode&&(this.textNode=document.createElement("span"),this.textNode.style.display="inline-block",this.elDOM.appendChild(this.textNode),this.textNode.style.cursor="pointer"),b=b.toString(),b.replace(/</g,"("),b.replace(/>/g,")"),this.textNode.textContent?this.textNode.textContent=b:this.textNode.innerText?this.textNode.innerText=b:this.textNode.innerHTML=b)};a.prototype.setTextAlign=function(b){this.style.textAlign=
4756b;this.textNode&&(this.textNode.textAlign=b)};a.prototype.getText=function(){if(this.textNode){if(this.textNode.textContent)return this.textNode.textContent;if(this.textNode.innerText)return this.textNode.innerText}return""};a.prototype.setZIndex=function(b){this.style.zIndex=b};a.prototype.setFontSize=function(b){if(b)void 0!==this.linkNode?this.linkNode.style.fontSize=Math.round(b)+"px":(this.textNode&&(this.textNode.style.fontSize=Math.round(b)+"px"),this.style.fontSize=Math.round(b)+"px",this.fontH=
4757Math.round(b),this.centeredText&&this.setCenteredText());else throw Error("FontSize = 0");};a.prototype.setFontFamily=function(b){this.style.fontFamily=b;this.textNode&&(this.textNode.style.fontFamily=b)};a.prototype.setFontWeight=function(b){this.style.fontWeight=b};a.prototype.setVerticalAlign=function(b){void 0===this.textNode&&this.setText(" ");void 0!==this.textNode&&(this.textNode.style.verticalAlign=b,this.textNode.style.display="inline-block",this.textNode.style.lineHeight="normal",void 0!==
4758this.h&&(this.style.lineHeight=this.h+"px"))};a.prototype.setCenteredText=function(){this.setTextAlign("center");this.setVerticalAlign("middle");this.centeredText=!0;this.style.display="block";this.vAlign=!0};a.prototype.setRightAlign=function(){this.setAlign("right")};a.prototype.setLeftAlign=function(){this.setAlign("left")};a.prototype.setAlign=function(b){this.setTextAlign(b);this.setVerticalAlign("middle");this.centeredText=!1;this.style.display="block"};a.prototype.getTextWidth=function(){return void 0!==
4759this.textNode?this.textNode.clientWidth:0};a.prototype.getTextHeight=function(){return void 0!==this.textNode?this.textNode.clientHeight:0};a.prototype.setHoverBright=function(){$(this.elDOM).hover(function(){$(this).css("filter","brightness(108%)")},function(){$(this).css("filter","brightness(100%)")})};a.prototype.setURL=function(b,c,d,e){void 0===this.linkNode&&(this.linkNode=document.createElement("a"),this.elDOM.appendChild(this.linkNode));this.linkNode.href=b;this.linkNode.target="_blank";c&&
4760c.length&&(this.linkNode.textContent?this.linkNode.textContent=c:this.linkNode.innerText=c);d&&d.length&&(this.linkNode.className=d);e&&this.linkNode.setAttribute("onclick","if ( typeof ( ga ) !== 'undefined' && System.V3() ) ga( 'send', 'event', 'link', \""+(c+'");'))};return a}();"use strict";
4761var ToolTip=function(){var a=new CBColor(255,255,248,.95),b=new CBColor(0,0,0,.9),c=1,d=function(){this.uniqueId=c++;this.background=new DivElement(document.body,"bTTipBG"+this.uniqueId);this.textEl=new DivElement(this.background,"bSTTipText"+this.uniqueId);this.background.elDOM.style.zIndex=99999;
4761this.textEl.setBackgroundColor(a);this.textEl.setColor(b);this.textEl.setFontFamily("Roboto, Helvetica, sans-serif")};d.prototype.destroy=function(){this.background.destroy()};d.prototype.setText=function(e){this.textEl.setText(e)};
4762d.prototype.setVisible=function(e){this.background.setVisible(e)};d.prototype.setPosSize=function(e,f){var g=Math.max(8,Math.round(.4*f.h)),h=new CBRect(e.x,e.y,e.x+f.w,e.y+f.h),k=f.w,l=(h.w-k)/2;h.w=k;h.move(l,0);this.background.setPos(e.x,e.y);this.background.setSize(f.w,f.h);h=Math.max(1,Math.min(4,Math.round(Math.sqrt(f.w/100))));this.background.setBoxShadow(h,8*h,"rgba( 60, 30, 20, 0.3 )");this.textEl.setPos(0,0);this.textEl.setSize(f.w,f.h);this.textEl.setBorder(1,new CBColor(0,0,0,.5));this.textEl.setRounded(4);
4763this.textEl.setCenteredText();do this.textEl.setFontSize(g),--g;while(4<g&&(this.textEl.getTextWidth()>k||this.textEl.getTextHeight()>f.h-3));LOG("ToolTip: pos="+e.x+", "+e.y)};return d}();"use strict";
4764class CanvasElement extends CBElement{constructor(a,b){super("canvas",a,b);this._uniqueId=b}setCssClass(a){this.elDOM.className=a}setCanvasSize(a,b){this.elDOM.width=a;this.elDOM.height=b}render(){}setWoodenBackground(){this.elDOM.style.background="#101010";this.elDOM.style.backgroundImage="url( "+getCommonPath()+"Media/Chess/OrangeBrighterSoft.jpg )";this.elDOM.style.backgroundSize="100% 100%";this.elDOM.style.backgroundRepeat="no-repeat";this.elDOM.style.backgroundPosition="bottom left"}}"use strict";
4765_uniqueId=(new Date).getTime()+Math.floor(Math.random()+1E5);
4766class CanvasParent{constructor(a){this.uniqueId=_uniqueId++;this.background=new DivElement(a,"aCanvParentBG"+this.uniqueId);this.background.setRelativePos();this.canvasEl=new CanvasElement(this.background,"aCanvParentCanvas"+this.uniqueId)}createCanvas(a,b){return this.canvas=new CBCanvas2D(this.canvasEl.elDOM.id,a,b)}changeParent(a){this.background.elDOM.parentElement.removeChild(this.background.elDOM);a&&a.appendChild(this.background.elDOM)}getElDom(){return this.background.elDOM}changeParentElDOM(a){this.background.changeParentElDOM(a)}setVisible(a){this.background.setVisible(a)}setPosSize(a,b,
4767c,d){this.background.setPosSize(a,b,c,d);this.canvasEl.setPosSize(0,0,c,d);this.canvas&&this.canvas.resize(c,d)}setSize(a,b){this.background.setSize(a,b);this.canvasEl.setSize(a,b);this.canvas&&this.canvas.resize(a,b)}getSize(){return this.canvasEl.getSize()}showText(a,b,c){let d=this.canvas.bufferCtx;d.font=b;d.shadowBlur=4;d.shadowColor="hsla(0,0%,0%, 0.35)";d.fillStyle=c;d.fillText(a,60,100);this.canvas.requestAnimation()}setWoodenBackground(){this.background.setWoodenBackground()}}"use strict";
4768var UIElement=function(){var a=function(b,c,d){a.superClass.call(this,b,c,d);this.elDOM&&(this.elDOM.className="cb-button",this.elDOM.addEventListener("mousedown",this.onMouseDown.bind(this)),this.elDOM.addEventListener("mouseup",this.onMouseUp.bind(this)),this.elDOM.addEventListener("mouseover",this.onMouseOver.bind(this)),this.elDOM.addEventListener("mouseleave",this.onMouseLeave.bind(this)))};inherit(a,CBElement);a.prototype.setText=function(b){b.replace(/</g,"(");b.replace(/>/g,")");this.elDOM.innerHTML=
4769b};a.prototype.setEnabled=function(b){this.elDOM.disabled=!b};a.prototype.getEnabled=function(){return!this.elDOM.disabled};a.prototype.setHandler=function(b){this.elDOM.addEventListener("click",function(c){b(c)})};a.prototype.setBackgroundColor=function(b){this.backgroundColor=b.toString();this.style.backgroundColor=b.toString()};a.prototype.setHoverColor=function(b){this.hoverColor=b.toString()};a.prototype.setClickColor=function(b){this.clickColor=b.toString()};a.prototype.onMouseDown=function(){this.clickColor&&
4770(this.style.backgroundColor=this.clickColor)};a.prototype.onMouseUp=function(){this.hoverColor?this.style.backgroundColor=this.hoverColor:this.backgroundColor&&(this.style.backgroundColor=this.backgroundColor)};a.prototype.onMouseOver=function(){this.hoverColor&&(this.style.backgroundColor=this.hoverColor)};a.prototype.onMouseLeave=function(){this.backgroundColor&&(this.style.backgroundColor=this.backgroundColor)};a.prototype.setColor=function(b){this.style.color=b.toString()};return a}();"use strict";
4771var CBSelect=function(){var a=function(b,c){CBSelect.superClass.call(this,"select",b,c);
4771this.elDOM.className="cb-select";Object.defineProperty(this,"value",{get:this.getValue,set:this.setValue});Object.defineProperty(this,"enabled",{get:this.getEnabled,set:this.setEnabled})};inherit(a,CBElement);a.prototype.setValue=function(b){this.elDOM.value=b};a.prototype.getValue=function(){return this.elDOM.value};a.prototype.setEnabled=function(b){this.elDOM.disabled=!b};a.prototype.getEnabled=function(){return!this.elDOM.disabled};
4772a.prototype.setOptions=function(b){this.clearOptions();b.forEach(function(c){c=c||"";var d=document.createElement("option");"object"===typeof c?(d.text=c.text,d.value=c.value):(d.text=c,d.value=c);this.elDOM.add(d)}.bind(this))};a.prototype.setHandler=function(b){this.elDOM.addEventListener("change",function(c){b(c)})};a.prototype.clearOptions=function(){for(;this.elDOM.firstChild;)this.elDOM.removeChild(this.elDOM.firstChild)};return a}();"use strict";
4773var Button=function(){var a=function(b,c,d){b&&(a.superClass.call(this,"button",b,c),this.elDOM.className=d||"cb-button")};inherit(a,CBElement);a.prototype.setImage=function(b){this.style.backgroundImage="url( "+b+")";this.style.backgroundRepeat="no-repeat";this.style.backgroundPosition="center"};a.prototype.setHandler=function(b){this.elDOM.addEventListener("click",b)};a.prototype.setText=function(b){var c=this.elDOM;c&&("undefined"==typeof c.textContent?c.innerText=b:c.textContent=b)};a.prototype.setEnabled=
4774function(b){this.elDOM.disabled=!b};return a}(),CloseButton=function(){var a=function(b,c,d){a.superClass.call(this,b,c,"cb-CloseButton");this.textNode=document.createElement("span");this.textNode.style.display="inline-block";"undefined"!=typeof this.textNode.textContent?this.textNode.textContent="x":this.textNode.innerText="x";this.textNode.style.cursor="default";this.textNode.style.fontFamily="Roboto, Helvetica, sans-serif";this.textNode.style.alignSelf="center";this.elDOM.style.display="flex";
4775this.elDOM.style.flexDirection="column";this.elDOM.appendChild(this.textNode);d&&this.setHandler(d)};inherit(a,Button);a.prototype.onResize=function(){var b=Math.round(.8*this.h);this.style.fontSize=b+"px";this.textNode.style.fontSize=b+"px"};return a}(),CBInput=function(){var a=function(b,c,d){b&&(CBInput.superClass.call(this,"input",b,c),this.elDOM.className=d||"cb-input")};inherit(a,CBElement);a.prototype.setImage=function(b){this.style.backgroundImage="url( "+b+")";this.style.backgroundRepeat=
4776"no-repeat";this.style.backgroundPosition="center"};a.prototype.setChangeHandler=function(b){this.elDOM.addEventListener("change",b)};a.prototype.setText=function(b){var c=this.elDOM;c&&("undefined"==typeof c.textContent?c.innerText=b:c.textContent=b)};a.prototype.setEnabled=function(b){this.elDOM.disabled=!b};return a}();"use strict";
4777var CBCheckBox=function(){var a=function(b,c){CBCheckBox.superClass.call(this,"form",b,c);this.checkId=this.elDOM.id+"-chk";this.htmlFirstPart='<input type="checkbox" id='+this.checkId+" />";this.elDOM&&(this.elDOM.innerHTML=this.htmlFirstPart)};inherit(a,CBElement);a.prototype.setChecked=function(b){var c=document.getElementById(this.checkId);c.checked=c.defaultChecked=b};a.prototype.getChecked=function(){return document.getElementById(this.checkId).checked};a.prototype.setEnabled=function(b){document.getElementById(this.checkId).disabled=
4778!b};a.prototype.getEnabled=function(){return!document.getElementById(this.checkId).disabled};a.prototype.setText=function(b){b.replace(/</g,"(");b.replace(/>/g,")");this.elDOM&&(this.elDOM.innerHTML=this.htmlFirstPart+b)};return a}();"use strict";
4779class CBCanvas2D{constructor(a,b,c){this.canvas=document.getElementById(a);if(null===this.canvas)throw Error(`ID ${a} not found.`);this.ctx=this.canvas.getContext("2d");this._createDoubleBuffer(a);this._addListeners(a);this.idDOM=a;this.zoomRatio=this.calcZoomRatio();this.control=b.createControl(this,this.canvas.width,this.canvas.height,c);this.lastW=this.canvas.width;this.lastH=this.canvas.height;if(b.onControlReady)b.onControlReady(this.control);this.resizeTimer=new Timer(this.resizeHdl.bind(this))}destroyDOM(){this.resizeTimer.stop();
4780this.el&&null!=this.el.destroy&&this.el.destroy();this.control.onDestroyDOM()}drawLine({fromx:a,fromy:b},{tox:c,toy:d}){this.ctx.beginPath();this.ctx.moveTo(a,b);this.ctx.lineTo(c,d);this.ctx.stroke()}drawText({x:a,y:b},c,d,e){void 0!==e&&(this.ctx.fillStyle=e);void 0!==d&&(this.ctx.font=`${d}px sans serif`);this.ctx.fillText(c,a,b)}resize(a,b){5>a&&(a=5);5>b&&(b=5);this.blockResize||(this.control&&this.control.beforeResize&&this.control.beforeResize(),this.resizeTimer.runOnce(10,()=>{this.resizeHdl(a,
4781b)}));this.lastW=a;this.lastH=b}reResize(){this.lastW&&this.lastH&&this.resize(this.lastW,this.lastH)}setBlockResize(a){this.blockResize=a}onContextMenu(a){LOG(`ContextMenu: ${a.pageX}, ${a.pageY}`,"","mouse");const b=this.zoomToPixEvent(a),c=new CBRect;c.fromRect(this.canvas.getBoundingClientRect());LOG(`Scaled: ${b.x}, ${b.y}, boundRect=${c}`,"","mouse");if(this.control.onContextMenu)this.control.onContextMenu(a,b);a.preventDefault();return!1}_addListeners(a){a=CBQ.get(a);a=CBQ(a);a.on("touchmove",
4782this.onTouchMove.bind(this));if(CBElement.isEventSupported("mousedown"))a.on("dblclick",this.onDoubleClick.bind(this));CBElement.isEventSupported("pointerdown")&&(a.on("pointerdown",this.onMouseDown.bind(this)),a.on("pointerup",this.onMouseUp.bind(this)),a.on("pointermove",this.onMouseMove.bind(this)),a.on("pointerwheel",this.onMouseWheel.bind(this)),a.on("pointerenter",this.onMouseEnter.bind(this)),a.on("pointerleave",this.onMouseLeave.bind(this)));if(CBElement.isEventSupported("contextmenu"))a.on("contextmenu",
4783this.onContextMenu.bind(this));a.on("keydown",this.onKeyDown.bind(this));a.on("keyup",this.onKeyUp.bind(this));a.on("keypress",this.onKeyPress.bind(this))}onMouseDown(a){LOG("&nbsp;");const b=this.zoomToPixEvent(a);this.control.onMouseDown(a,b);return!1}onMouseUp(a){LOG("Mouse Up","","mouse");const b=this.zoomToPixEvent(a);this.control.onMouseUp(a,b);return!1}onMouseMove(a){const b=this.zoomToPixEvent(a);this.control.onMouseMove(a,b);return!1}onMouseWheel(a){const b=this.zoomToPixEvent(a);this.control.onMouseWheel(a,
4784b)}onDoubleClick(a){const b=this.zoomToPixEvent(a);LOG(`DCLICK:${this.getClickPos(b)}`,"","mouse");this.getClickPos(b);this.control.onDoubleClick(a,b)}onMouseEnter(a){const b=this.zoomToPixEvent(a);this.control.onMouseEnter(a,b)}onMouseLeave(a){const b=this.zoomToPixEvent(a);this.control.onMouseLeave(a,b)}onTouchStart(a){if(!this.isDefaultPrevented(a)){LOG("Touch Start","","touch");a.touches&&(this.touchStartX=a.touches[0].clientX,this.touchStartY=a.touches[0].clientY);const b=this.zoomToPixEvent(a);
4785this.control.onMouseDown(a,b)}}onTouchEnd(a){if(!this.isDefaultPrevented(a)){delete this.touchStartX;const b=this.zoomToPixEvent(a);this.control.onMouseUp(a,b)}}onTouchMove(a){a.preventDefault()}isDefaultPrevented({parentEvent:a,defaultPrevented:b}){return void 0!==a&&void 0!==a.browserEvent?a.browserEvent.defaultPrevented:b}onTouchLeave(a){delete this.touchStartX}onTouchCancel(a){delete this.touchStartX;LOG("Touch Cancel","","touch")}onKeyDown(a){LOG("Key Down")}onKeyUp(a){LOG("Key Up")}onKeyPress(a){LOG("Key Press")}zoomToPixEvent({touches:a,
4786changedTouches:b,pageX:c,pageY:d}){return a&&a.length?new CBPoint(this.zoomToPixX(a[0].pageX),this.zoomToPixY(a[0].pageY)):b&&b.length?new CBPoint(this.zoomToPixX(b[0].pageX),this.zoomToPixY(b[0].pageY)):new CBPoint(this.zoomToPixX(c),this.zoomToPixY(d))}zoomToPixX(a){return(a-this.canvas.getBoundingClientRect().left-window.pageXOffset)*this.zoomRatio}zoomToPixY(a){return(a-this.canvas.getBoundingClientRect().top-window.pageYOffset)*this.zoomRatio}pixToZoomX(a){return this.canvas.getBoundingClientRect().left-
4787window.pageXOffset+a/this.zoomRatio}pixToZoomY(a){return this.canvas.getBoundingClientRect().top-window.pageYOffset+a/this.zoomRatio}pixToZoom(a){return this.zoomRatio?Math.round(a/this.zoomRatio):a}zoomToPix(a){return this.zoomRatio?a*this.zoomRatio:a}zoomToPixRect(a){const b=this.zoomToPix(a.left),c=this.zoomToPix(a.top);return new CBRect(b,c,b+a.w*this.zoomRatio,c+a.h*this.zoomRatio)}pixToZoomRect(a){const b=this.pixToZoom(a.left),c=this.pixToZoom(a.top);return new CBRect(b,c,b+a.w/this.zoomRatio,
4788c+a.h/this.zoomRatio)}getClickPos(a){const b=this.canvas.getBoundingClientRect();
4788return new CBPoint(a.getX()-b.left,a.getY()-b.top)}getBoundingClientRect(){const a=this.canvas.getBoundingClientRect();return new CBRect(a.left,a.top,a.right,a.bottom)}execStr(a){}_createDoubleBuffer(a){this.buffer=document.createElement("canvas");this.buffer.width=this.canvas.width;this.buffer.height=this.canvas.height;this.bufferCtx=this.buffer.getContext("2d")}cutClipRect(a){this.clipRect=this.clipRect?this.clipRect.getCutAtBoundary(a):
4789a}_drawDoubleBufferClipped(){this.ctx.save();this.clipRect?CanvasTools.clipRect(this.ctx,this.clipRect):CanvasTools.clipRect(this.ctx,new CBRect(1,1,this.canvas.width-1,this.canvas.height-1));this.ctx.globalCompositeOperation="copy";try{this.ctx.drawImage(this.buffer,0,0)}catch(a){}this.ctx.restore();delete this.clipRect;this.dirty=!1;this.requestIdClipped=null}_drawDoubleBuffer(){LOG("DrawDBuff");const a=this.ctx.globalCompositeOperation;this.ctx.globalCompositeOperation="copy";this.ctx.drawImage(this.buffer,
47900,0);this.ctx.globalCompositeOperation=a;this.dirty=!1;delete this.clipRect;this.requestId=null}joinClipRect(a){this.clipRect=this.clipRect?this.clipRect.getUnion(a):a}cancelAnimationFrames(){this.requestIdClipped&&window.cancelAnimationFrame(this.requestIdClipped);this.requestId&&window.cancelAnimationFrame(this.requestId)}block(a){this.blocked=a}requestAnimation(a){this.blocked||1>this.canvas.width||1>this.canvas.height||(a?(this.joinClipRect(a),this.dirty=!0,this.requestIdClipped&&window.cancelAnimationFrame(this.requestIdClipped),
4791this.requestIdClipped=window.requestAnimationFrame(this._drawDoubleBufferClipped.bind(this))):(this.dirty=!0,this.requestId&&window.cancelAnimationFrame(this.requestId),this.requestIdClipped&&window.cancelAnimationFrame(this.requestIdClipped),this.clipRect=new CBRect(1,1,this.canvas.width,this.canvas.height),this.requestId=window.requestAnimationFrame(this._drawDoubleBufferClipped.bind(this))))}onControlForegroundReady(){this.control.drawForeground(this.bufferCtx)}onControlBackgroundReady(){this.control&&
4792this.control.drawWood&&this.control.drawWood(this.bufferCtx)}resizeHdl(a,b){a=Math.floor(a);b=Math.floor(b);this.scaleToBrowserZoom(a,b)||(this.clipRect=this.lastClipRect=new CBRect(0,a,0,b),this.zoomRatio=1,this.setCanvasSizeNonZoomed(this.canvas,a,b),this.setCanvasSizeNonZoomed(this.buffer,a,b),this.control&&this.control.resize(a,b));this.afterResize&&this.afterResize()}setCanvasSizeNonZoomed(a,b,c){a.width=b;a.height=c;a.style.width=`${b}px`;a.style.height=`${c}px`}scaleToBrowserZoom(a,b){return 1!=
4793this.calcZoomRatio()?(this.clipRect=this.lastClipRect=new CBRect(0,a,0,b),this.zoomRatio=this.calcZoomRatio(),this.scaleCanvas(this.canvas,this.ctx,a,b,this.zoomRatio),this.scaleCanvas(this.buffer,this.bufferCtx,a,b,this.zoomRatio),this.control.resize(a*this.zoomRatio,b*this.zoomRatio),!0):!1}calcZoomRatio(){let a=window.devicePixelRatio;a=Math.min(3,a);System.overrideDeviceZoom(a);return a}scaleCanvas(a,b,c,d,e){a.width=Math.round(c*e);a.height=Math.round(d*e);a.style.width=`${c}px`;a.style.height=
4794`${d}px`;LOG(`CanvasWH=${a.width}, ${a.height}`,"","canv")}getBackStorePixelRatio(){return this.ctx.webkitBackingStorePixelRatio||this.ctx.mozBackingStorePixelRatio||this.ctx.msBackingStorePixelRatio||this.ctx.oBackingStorePixelRatio||this.ctx.backingStorePixelRatio||1}getDevicePixelRatio(){alert(0);return window.devicePixelRatio}hide(){this.canvas.style.visibility="hidden"}show(){this.canvas.style.visibility="visible"}requestRedraw(){this.blocked||(delete this.clipRect,this.control&&this.control.draw(this.bufferCtx),
4795this.requestAnimation(new CBRect(1,1,this.canvas.width-1,this.canvas.height-1),!0))}static drawEllipse(a,b,c,d,e){a.save();a.beginPath();a.translate(b-d,c-e);a.scale(d,e);a.arc(1,1,1,0,2*Math.PI,!1);
4795a.restore();a.lineWidth=5;a.stroke()}}
4796(function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c<b.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"];for(c=0;c<b.length&&!window.cancelAnimationFrame;++c)window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(d,
4797e){var f=(new Date).getTime(),g=Math.max(0,16-(f-a));e=window.setTimeout(function(){d(f+g)},g);a=f+g;return e});window.cancelAnimationFrame||(window.cancelAnimationFrame=function(d){clearTimeout(d)})})();"use strict";
4798class CBStorage{constructor(){window.localStorage?this.storage=window.localStorage:window.sessionStorage&&(this.storage=window.sessionStorage)}save(a,b){b&&void 0!==this.storage&&(this.storage[a]=JSON.stringify(b))}load(a){if(void 0!==this.storage&&this.storage[a]&&"undefined"!==this.storage[a])return JSON.parse(this.storage[a])}}"use strict";
4799var CBAudio=function(){var a=1,b=function(c,d,e){this.audio=document.createElement("audio");var f=this.getFormat();this.ok=!1;f?(this.url=c+f,this.audio.addEventListener("canplay",this.onCanPlay.bind(this),!1),this.audio.addEventListener("canplaythrough",this.onCanPlayThrough.bind(this),!1),this.audio.addEventListener("ended",this.onEnded.bind(this),!1),this.audio.addEventListener("error",this.onError.bind(this),!1),this.audio.addEventListener("abort",this.onError.bind(this),!1),this.audio.src=c+
4800f,this.fnEnded=d,this.isQueued=this.canPlay=!1,this.uniqueId=a++,e?this.audio.preload="none":(this.audio.preload="metadata",this.audio.load(),this.ok=!0)):(LOG("Audio not supported","LogError"),this.url="!format!")};b.prototype.load=function(){this.audio&&this.audio.load();this.ok=!0};b.prototype.toString=function(){return this.url};b.prototype.play=function(){try{this.audio.play()}catch(c){}};b.prototype.pause=function(){try{this.audio.pause()}catch(c){console.log("Pause Audio: "+c)}};b.prototype.onCanPlay=
4801function(){};b.prototype.onCanPlayThrough=function(){};b.prototype.onEnded=function(){this.fnEnded&&this.fnEnded(this.uniqueId)};b.prototype.onError=function(){};b.prototype.getFormat=function(){if(this.audio.canPlayType){var c=this.audio.canPlayType("audio/mpeg");if(""!=c)return".mp3";c=this.audio.canPlayType("audio/ogg");if(""!=c)return".ogg"}return""};return b}(),AudioQueue=function(){var a=function(){this.queue=[];this.nextId=0;this.enabled=!0};a.prototype.push=function(b){if(this.enabled&&b){var c=
4802b;"string"==typeof b&&(c=new CBAudio(b));c.fnEnded=this.callBackPlayed.bind(this);c.ok&&this.queue.push(c);if(1==this.queue.length)try{c.play()}catch(d){console.log("Audio: "+d)}}};a.prototype.enable=function(b){(this.enabled=b)||this.stopAll()};a.prototype.isEnabled=function(){return this.enabled};a.prototype.stopAll=function(){this.currPlaying&&this.currPlaying.pause();for(var b=0;b<this.queue.length;b++)this.queue[b]&&this.queue[b].pause();this.queue=[];delete this.currPlaying};Object.defineProperty(a.prototype,
4803"length",{get:function(){return this.queue.length},set:function(b){this.queue.length>b&&this.queue.splice(0,this.queue.length-b)},enumerable:!0});a.prototype.callBackPlayed=function(b){for(var c=0;c<this.queue.length;c++)if(this.queue[c]&&this.queue[c].uniqueId==b){c<this.queue.length-1&&this.queue[c+1].play();this.queue.splice(c,1);break}};return a}();
4804class Queue{constructor(){this.nOffset=0;this.queue=[]}getLength(){return this.queue.length-this.nOffset}empty(){return 0==this.queue.length}push(a){this.queue.push(a)}pop(){if(0!=this.queue.length){var a=this.queue[this.nOffset];2*++this.nOffset>=this.queue.length&&(this.queue=this.queue.slice(this.nOffset),this.nOffset=0);return a}}front(){return 0<this.queue.length?this.queue[this.nOffset]:void 0}}CB.Queue=Queue;"use strict";
4805var BinToString={StringToByteArray:function(a,b){for(var c=0,d=0,e=0,f=0;f<b.length;f++){var g=b[f].charCodeAt(0);if(63>g||126<g)return 1;g-=63;2>=d?(e|=g<<2-d,d+=6,8<=d&&(d-=8,a[c++]=e&255,e=0)):(d-=2,e|=g>>d,a[c++]=e&255,e=g<<8-d)}return c},ByteArrayToString:function(a,b){var c="";if(0<b){for(var d=[],e=0,f=0,g=0;f<b;)2>=g?(d[e++]=63+(a[f]>>2-g&63)&255,g+=6,8<=g&&(f++,g-=8)):(g-=2,d[e]=a[f]<<g&63,f++,f<b?d[e]|=a[f]>>8-g&63:g=0,d[e++]+=63);for(a=d[e]=0;a<e;a++)c+=String.fromCharCode(d[a])}else c=
4806"";return c},ByteArrayToBase64:function(a){for(var b="",c,d,e,f,g,h,k=0;k<a.length;)c=a[k++],d=a[k++],e=a[k++],f=c>>2,c=(c&3)<<4|d>>4,g=(d&15)<<2|e>>6,h=e&63,isNaN(d)?g=h=64:isNaN(e)&&(h=64),b=b+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
4806+/=".charAt(f)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(c)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(g)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(h);
4807return b},ByteArrayToDataURI:function(a,b){a=this.ByteArrayToBase64(a);return"data:"+b+";charset=utf-8;base64,"+a}},EvalMixin=function(){return{hasDebugInfo:function(){return!1},$Id:function(a){return $(String.f("#{0}-{1}",a,this.nInPage))},onStaticEvalIcons:function(a){this.getIconNames().forEach(function(d){let e=a[d];if(e){let f=!0;for(let g=0;2>g;g++)try{let h=e,k=!0;e.length&&(h=e[g],k=e[0].valid||e[1].valid);let l=g?"b":"w";l+=d;if(k){let m=this.getDiodHTML(h,d,g,this.diodH),n=this.getDiodTextHTML(h,
4808d,g,this.diodH);this.$Id(String.f("id{0}Diods",l)).html(m);this.hasDebugInfo()&&this.$Id(String.f("id{0}Text",l)).html(n);if(!e.length)break;m.length&&(f=!1)}else this.$Id(String.f("id{0}Diods",l)).html("")}catch(h){}this.$Id(String.f("id{0}",d)).css("display",f?"none":"flex")}}.bind(this));if(a.Complexity){var b=this.getComplexityHTML(a.Complexity,16);this.$Id("idComplexity").html(b)}if(a.Activity){var c=Math.min(16,this.diodH);b=this.getActivityHTML(a.Activity[0],c,"w");c=this.getActivityHTML(a.Activity[1],
4809c,"b");this.$Id("idActivityW").html(b);this.$Id("idActivityB").html(c)}},getPosInfoHTMLVerti:function(){let a=this.diodH,b="<div class='engOutPieceEvalsVerti'>",c=this.getIconNames();c.pop();c.forEach(function(d){b+=this.getPieceEvalLineVerti(d,a)}.bind(this));b+="<div class='engOutVertiActivity'>"+this.getActivityLine()+"</div>";b+="<div class='engOutVertiComplexity'>"+this.getComplexityLine()+"</div>";return b+="</div>"},getPosInfoHTMLHori:function(){let a=this.diodH,b="<div class='engOutPieceEvalsHori'>";
4810b+="<div class='engOutPieceEvalsPieces'>";b+="<div style='display:flex;flex-direction:row'>";let c=this.getIconNames();System.isMobile()&&c.pop();c.forEach(function(d){b+=this.getPieceEvalLineHori(d,a)}.bind(this));b+="</div>";b+="</div>";b+="<div style='display:flex;flex-direction:row'>";b+="<div class='engOutHoriActivity'>"+this.getActivityLine()+"</div>";b+="<div class='engOutHoriComplexity'>"+this.getComplexityLine()+"</div>";b+="</div>";return b+="</div>"},getIconNames:function(){return"Kings Queens Rooks Bishops Knights Pawns Attacks".split(" ")},
4811getPieceEvalLineHori:function(a,b){let c=String.f("<div class='engOutPieceEvalLineHori' id='id{0}-{1}'>",a,this.nInPage);c+=this.getPieceEvalHTML("w"+a,b);c+=this.getPieceEvalHTML("b"+a,b);return c+"</div>"},getPieceEvalLineVerti:function(a,b){let c=String.f("<div class='engOutPieceEvalLineVerti' id='id{0}-{1}'>",a,this.nInPage);c+=this.getPieceEvalHTML("w"+a,b);c+=this.getPieceEvalHTML("b"+a,b);return c+"</div>"},getPieceEvalHTML:function(a,b){let c=String.f("<div class='engOutPieceEval' id='id{0}-{1}'>",
4812a,this.nInPage);c+=this.getPieceEvalIcon(a,b);c+=String.f("<div class='engOutEvalDiods' id='id{0}Diods-{1}'>",a,this.nInPage);c=c+"</div>"+String.f("<div class='engOutEvalTexts' id='id{0}Text-{1}'>",a,this.nInPage);return c+"</div></div>"},getDimStyle:function(a){return String.f("style='width:{0}px;height:{0}px'",a)},getDimDiodStyle:function(a,b,c){let d=Math.round(a/9);return String.f("style='height:{0}px;width:{0}px;margin:{1}px;border-radius:{2}px;{3}'",a-2*d,d,b?Math.round(a/8):Math.round(a/3),
4813c)},getIconSrc:function(a,b){return getCommonPath()+"Media/Chess/Icons/"+a+b+".png"},getPieceEvalIcon:function(a,b){return String.f("<div class='engOutEvalIcon' {0}><img src='{1}'/></div>",this.getDimStyle(b),this.getIconSrc(a,b))},getPieceEvalDiod:function(a,b,c,d,e,f){f=f?"engOutBlinkDiod":"";a=String.f("<div class='engOutEvalDiod', id='{0}-{1}'>",a,this.nInPage);a+=String.f("<div class='engOutEvalDiodInner {0}' {1} title='{2}'></div>",f,this.getDimDiodStyle(b,e,c),d);return a+"</div>"},getPieceEvalBtn:function(a,
4814b){return String.f("<div class='engOutEvalButton'><button id='{0}-{1}'></button></div>","id"+a,this.nInPage)},getComplexityLine:function(){let a=String.f("<div class='engOutComplexity' id='idComplexityLine-{0}'>",this.nInPage);a+=String.f("<div class='engOutComplexitySteps' id='idComplexity-{0}'>",this.nInPage);return a+"</div></div>"},getComplexityIcon:function(a){return this.getIcon("Complexity","Sharpness/Complexity",a)},getActivityLine:function(){return String.f("<div class='engOutActivity' id='idActivityLine'><div class='engOutActivitySteps' id='idActivityW-{0}'></div><div class='engOutActivitySteps' id='idActivityB-{0}'></div></div>",
4815this.nInPage)},getActivityIcon:function(a,b){return this.getIcon(b+"Activity","Control/Activity",a)},getIcon:function(a,b,c){a=getCommonPath()+String.f("Media/Chess/Icons/{0}",a)+c+".png";return String.f("<div class='engOutEvalIcon' {0}><img src='{1}' style='width:100%;height:100%'/ title='{2}'></div>",this.getDimStyle(c),a,b)},getDiodHTML:function(a,b,c,d){let e=a.getNVals(),f="";for(let g=0;g<e;g++){let h=String.f("{0}{1}{2}",c?"b":"w",b,g),k=a.getDiodGradient(g),l="";a.getDiodTip&&(l=a.getDiodTip(g));
4816f+=this.getPieceEvalDiod(h,d,k,l,a.squareDiod,a.getDiodBlinks(g))}return f},getComplexityHTML:function(a,b){let c=a.getNIcons(),d="";for(let e=0;e<=c;e++)d+=this.getComplexityIcon(b);d+=String.f("<div class='engOutComplexityText'>{0}</div>",a.text());this.hasDebugInfo()&&(d+=String.f("<div style='padding-left:5px'>{0}</div>",a.scalarVal));return d},getActivityHTML:function(a,b,c){let d=a.getNIcons(),e="";for(let f=0;f<=d;f++)e+=this.getActivityIcon(b,c);this.hasDebugInfo()&&(e+=String.f("<div style='padding-left:2px';font-size='7px'>{0}</div>",
4817a.val));return e},getDiodTextHTML:function(a){let b=a.getNVals(),c="";for(let d=0;d<b;d++)c+=String.f("<div>{0}{1}</div>",a.getDiodText(d),d<b-1?", ":"");return c},getDiodGradient:function(a){return String.f("background-image: radial-gradient( hsl( {0}, 60%, 70% ), hsl( {0}, 60%, 50% ) )",a)}}}();"use strict";function getSymbol(a){a=EvaluationGrade.getGlyph(a);return Vz.getText(a)}
4818function getInfoString(a){if(a.handicap){var b=Handicap.getTypeStr(a.handicap);return String.formatEx("{5}: {0}, {1} {2} {3}={4}s",b,lm.DEPTH,a.depth,lm.TIME,idiv(a.totalTime,1E3),lm.LEVEL)}return String.formatEx(lm.ENG_SEARCH_INFO_FMT,a.depth,a.maxDepth,idiv(a.nps,1E3),idiv(a.totalTime,1E3))}
4819function onDragStart(a){var b=CBQ(a.target),c=b.data("pv");c=c.trim();c=c.split(" ").map(Move.fromString);b=b.parent("[data-pos]");b=CBQ(b);b=new Position(b.data("pos"));c=new Game(b,c);c=PGNWriter.toPGN(c);a.dataTransfer.setData("text",c)}
4820class EngineLinesElement{constructor(a,b,c){this.nInPage=a||0;this.noFeedback=!!b;this.initState();this.analysisLayout=!1;this.diodH=24;this.lastHeight=this.lastWidth=-1;this.showPosInfo=!1;this.showEvProfile=!0;this.maxLines=1;this.panelManager=c??glApp?.panelMgr}hasDebugInfo(){return!1}static defaultOptions={scrollLines:!0,autoHints:!0,clickAssist:!0};getAnalysisHTML(a){return String.f("<div class='engOutContainer' id='engOutContainer-{0}'><div class='engOutLine engOutPane' id='engOutLine-{0}'><div class='engOutLineLeft' id='engOutLineLeft-{0}'><div class='engOutCalculation' id='engOutCalculation-{0}'><div class='engOutVariation' id='engOutVariation-{0}'></div><div class='engOutSearchInfo' id='engOutSearchInfo-{0}'></div><button class='engOutNextHintBtn' id='engOutNextHintBtn-{0}'>{3}</button><div class='engOutEval' id='engOutEval-{0}' style='margin-top:5px'><div class='engOutEvalText engOutPane' id='engOutEvalText-{0}'></div></div></div><div class='engOutEvProfile' id='engOutEvProfile-{0}'><div class='cbevprofile' id='idEvEngCanvas-{0}'></div></div><div class='engOutPosInfo' id='engOutPosInfo-{0}'>{1}{2}</div></div><div class='engOutLineRight'id='engOutLineRight-{0}'><div class='engOutBtn engOutBtnPlus' id='engOutBtnPlus-{0}'></div><div class='engOutBtn engOutBtnMinus' id='engOutBtnMinus-{0}'></div><div class='engOutBtn engOutBtnThreat' id='engOutBtnThreat-{0}'></div><div class='engOutBtn engOutBtnHints' id='engOutBtnHint-{0}'></div><div class='engOutBtn engOutBtnEval' id='engOutBtnEval-{0}'></div></div></div></div><div class='engine-info-text' id='engine-info-text-{0}'></div>",
4821a,this.getPosInfoHTMLHori(),this.getDebugPosInfoHTML(),lm.NEXT_HINT)}getIconNames(){return"Kings Queens Rooks Bishops Knights Pawns".split(" ")}getDebugPosInfoHTML(){this.hasDebugInfo();return""}getPosInfoTitle(a){return String.f("<div class='engOutPosInfoTitle' style='font-size:{0}px;margin-bottom:{1}px'>{2}",.7*a,.15*a,"Position:")+"</div>"}supportsHints(){return this.panelManager.getKernel()&&this.panelManager.getKernel().Vp&&this.panelManager.getKernel().Vp.engineG
4821iveHint&&this.panelManager.fnToggleHints}resize(){var a=
4822this.$Id("engOutContainer");let b=a.width();a=a.height();var c=this.getEvProfDiv();this.showEvProfile&&200<a&&this.panelManager.isMobileLayout()?(c.show(),this.createEvaluationProfile()):c.hide();c=this.$Id("engOutPosInfo");this.showPosInfo?c.show():c.hide();this.supportsHints(this.nInPage)?this.$Id("engOutBtnHint").show():this.$Id("engOutBtnHint").hide();if(b!=this.lastWidth||a!=this.lastHeight){this.diodH=16;400<b&&!this.hasDebugInfo()&&260<a&&(this.diodH=24);for(let e=0;2>e;e++)this.getIconNames().forEach(function(f){var g=
4823["w","b"][e]+f;f=this.$Id("id"+g).find("img");g=this.getIconSrc(g,this.diodH);f.attr("src",g)}.bind(this));if(this.analysisLayout)[".engOutPieceEval",".engOutActivitySteps"].forEach(function(e){$(e).css("margin-right",.5*this.diodH+"px");$(e).css("min-width","0")}.bind(this));else{let e=Math.max(3.3*this.diodH,.45*b);[".engOutPieceEval",".engOutActivitySteps"].forEach(function(f){$(f).css("min-width",e+"px");$(f).css("margin-right","3px")})}c=this.$Id("idComplexityLine").find("img");var d=this.getIconSrc("Complexity",
482416);c.attr("src",d);c=this.$Id("idActivityW").find("img");d=this.getIconSrc("wActivity",16);c.attr("src",d);c=this.$Id("idActivityB").find("img");d=this.getIconSrc("bActivity",16);c.attr("src",d);c=this.$Id("engOutLine");d=this.$Id("engOutLineRight");b>.7*a?(c.css("flex-direction","row"),c.css("justify-content","flex-start"),d.css("flex-direction","column")):(c.css("flex-direction","column-reverse"),c.css("justify-content","flex-end"),d.css("flex-direction","row"),d.css("margin-bottom","10px"));if(this.staticEval)this.onStaticEvalIcons(this.staticEval)}this.lastWidth=
4825b;this.lastHeight=a}getLineHTML(a){return String.f("<div class='line'><div class='nota'><div class='pvnum'></div><div class='symbol'></div><div class='{0}'></div></div><div class='data'></div><div class='evStr'></div></div>",a||"pv")}getHintHTML(a,b){b&&(a+=String.f(" ({0}={1})",lm.DEPTH,b));return String.f("<div class='engOutHintLine'>{0}</div>",a)}initElem(a,b){this.options=ObjUtil.copyTo(EngineLinesElement.defaultOptions,b||{},!0);if(b=glApp.Vn.load("engOutOptions"))b=JSON.parse(b),ObjUtil.copyTo(b,
4826this.options);this.el=a;this.setAnalysisLayout(!0);this.switchLinesToInfo()}createHtml(a){var b=$(this.el);a=a();b.html(a);b=this.$Id("engOutVariation");this.elLines=b[0];this.elContainer=this.$Id("engOutContainer");b.on("click",this.onLinesClick.bind(this));this.$Id("engOutBtnPlus").click(this.onPlusBtn.bind(this));this.$Id("engOutBtnMinus").click(this.onMinusBtn.bind(this));this.$Id("engOutBtnThreat").click(this.onThreatBtn.bind(this));this.$Id("engOutBtnHint").click(this.onHintBtn.bind(this));
4827this.$Id("engOutBtnEval").click(this.onEvalBtn.bind(this));this.$Id("engOutBtnPlus").attr("title",lm.MORE_LINES);this.$Id("engOutBtnMinus").attr("title",lm.LESS_LINES);this.$Id("engOutBtnThreat").attr("title",lm.CALCULATE_THREAT);this.$Id("engOutBtnHint").attr("title",lm.HINTS_ONLY);this.$Id("engOutBtnEval").attr("title","Visual Evaluation");this.$Id("engOutNextHintBtn").click(this.onNextHintBtn.bind(this));this.$Id("engOutNextHintBtn").hide();this.$Id("engine-info-text").html(this.options.loadingTitle||
4828"<br/>&nbsp;&nbsp;&nbsp;"+lm.LOADING_ENGINE);this.scrollParent=this.elContainer;this.noFeedback&&this.$Id("engOutFeedback").hide()}destroy(){}initState(){this.lastDepth=this.lastPos=this.lastTime=this.lastNodes=this.lastNps=null}setEngine(a){if(this.engine){let b=this.engine;b.engine&&(b=b.engine);this.idOnLine&&(b.removeOnLineListener(this.idOnLine),b.removeOnLosingLineListener(this.idOnLosingLine),b.removeOnInfoListener(this.idOnInfo),b.removeOnNewGameListener(this.idOnNewGame),b.removeOnSearchStartListener(this.idOnSearchStart),
4829b.removeOnExitListener(this.idOnExit),b.removeOnStopListener(this.idOnStop),b.removeOnThreatListener(this.idOnThreat),b.removeOnBookMoveListener(this.idOnBookMove),b.removeOnStrongMoveListener(this.idOnStrongMove),b.removeOnBestMoveListener(this.idOnBestMove),b.removeOnStaticEvalListener(this.idOnStaticEval))}if(this.engine=a)a=this.engine,a.engine&&!a.addOnLosingLineListener&&(a=a.engine),a&&a.addOnLineListener&&(this.idOnLine=a.addOnLineListener(this.onEngineLine.bind(this)),this.idOnLosingLine=
4830a.addOnLosingLineListener(this.onLosingLine.bind(this)),this.idOnInfo=a.addOnInfoListener(this.onEngineInfo.bind(this)),this.idOnNewGame=a.addOnNewGameListener(this.onNewGame.bind(this)),this.idOnSearchStart=a.addOnSearchStartListener(this.onSearchStart.bind(this)),this.idOnExit=a.addOnExitListener(this.onExit.bind(this)),this.idOnStop=a.addOnStopListener(this.onStop.bind(this)),this.idOnThreat=a.addOnThreatListener(this.onThreat.bind(this)),this.idOnBestMove=a.addOnBestMoveListener(this.onBestMove.bind(this)),
4831this.idOnStaticEval=a.addOnStaticEvalListener(this.onStaticEval.bind(this)));glApp.analysisEngine&&!this.idOnStaticEvalAnalysis&&(this.idOnStaticEvalAnalysis=glApp.analysisEngine.addOnStaticEvalListener(this.onStaticEval.bind(this)))}
4831onLinesClick(a){a.preventDefault();var b=a.target;a=CBQ(b);CBQ.is(b,".line")||(b=a.parent(".line"));b&&(a=CBQ(b).data("mv"),Move.isValidString(a)&&(a=Move.fromString(a),this.fireOnMoveEntered(a)))}onPlusBtn(a){a.preventDefault();this.panelManager.fnIncMultiVars(this.nInPage,
48321)}onMinusBtn(a){a.preventDefault();this.panelManager.fnIncMultiVars(this.nInPage,-1)}onThreatBtn(a){a.preventDefault();this.panelManager.fnToggleThreat(this.nInPage)}onHintBtn(a){a.preventDefault();this.panelManager.fnToggleHints&&this.panelManager.fnToggleHints(this.nInPage)}onEvalBtn(a){a.preventDefault();this.showPosInfo=!this.showPosInfo;this.panelManager.onEngineLayoutChange(this.nInPage)}onNextHintBtn(a){a.preventDefault();this.panelManager.fireOnNextHint()}onAssistCheck(a){a.preventDefault();
4833this.panelManager.fireOnClickAssist(this.isClickAssist())}clear(a){this.clearLines();this.strong=null;this.maxLines=1}clearLines(){$(this.elLines).find(".line").remove();this.$Id("engOutVariation").empty();this.$Id("engOutSearchInfo").empty()}onNewGame(a){this.clear({str:lm.NEW_GAME});this.switchInfoToLines();this.signalBeautyScore();lm.LEVEL&&this.setVariationText(lm.LEVEL+"="+Handicap.getTypeStr(a));this.setAnalysisLayout()}displayInfo(a,b){this.clear();this.switchLinesToInfo();this.setInfoText(a,
4834b)}onSearchStart(a){this.clear(a);this.switchInfoToLines();this.setEvalStr("---");a&&(a.analysis||a.infinite)&&(this.evalArr=a.game?a.game.getEvaluationProfile():null,this.game=a.game,this.setAnalysisLayout(),this.hideInfo(),a=a.nMultiPV||1,this.panelManager.getKernel()&&this.panelManager.getKernel().Vp.isInThreat?this.setVariationText(String.f("{1} ({0} {2}) ...",a,lm.CALCULATE_THREAT,lm.VARIATIONS),"pvHandicap"):this.setVariationText(String.f("{1} ({0} {2}) ...",a,lm.START_ANALYSIS,lm.VARIATIONS),
4835"pvHandicap"),this.onStaticEval({}),this.evProfileControl&&this.evProfileControl.updateGame(this.game))}onBestMove(a,b){}onMoveFeedBack(a){let b="";a.str&&(b=a.str,a.blunder());b&&LOG(b)}onStaticEval(a){a.valid&&(this.staticEval=a);this.onStaticEvalIcons(a);this.resize()}onStaticEvalDebug(a){"Kings Pawns Passed Attacks Activity Complexity".split(" ").forEach(function(b){var c="";if(a[b]){c=a[b];let d="";for(let e=0;2>e;e++)try{let f=c;c.length?(f=c[e],f.valid&&(d+=String.f("<div style='width:50%'><span style='font-weight:bold'>{0}</span>&nbsp;<span style='font-style:italic'>{1}</span></div>",
4836f.str(),f.dbg()),d+="&nbsp;&nbsp;")):f.valid&&(d+=String.f("<div><span style='font-weight:bold'>{0}</span>&nbsp;<span style='font-style:italic'>{1}</span></div>",f.str(),f.dbg()));if(!c.length)break}catch(f){}c=d}b=String.f("engOut{0}",b);c.length?(this.$Id(b).html(c),this.$Id(b).show()):$(b).hide()}.bind(this));a.test&&this.outTestBB(a.test);a.colors&&this.outColors(a.colors)}outTestBB(a){}outColors(a){}signalBeautyScore(){}onExit(a){this.clear();this.setVariationText(lm.ENGINE_STOPPED,"engineStopped")}onStop(a){a&&
4837(this.clear(),this.setVariationText(lm.ANALYSIS_STOPPED),this.hideInfo());this.setEvalStr("---")}onThreat(a){a?this.$Id("engOutVariation").addClass("cbEngineThreat"):this.$Id("engOutVariation").removeClass("cbEngineThreat")}onEngineInfo(a,b,c,d,e,f){this.lastNps=e||this.lastNps;this.lastNodes=d||this.lastNodes;this.lastTime=f||this.lastTime}onEngineLine(a,b,c,d,e,f,g,h,k){this.switchInfoToLines();this.hideInfo();if(d===LineEvalType.EXACT||e){var l=a.getMultiPV();CBQ(this.elLines).data("lines",l);
4838d=1<l;this.maxLines=l;a=a.getCurPos();l=a.toFEN();CBQ(this.elLines).data("pos",l);(this.lastPos&&!a.equals(this.lastPos)||this.lastDepth&&this.lastDepth>b)&&this.clearLines();d||this.options.scrollLines||this.clearLines();d&&1==g&&this.$Id("line",this.elLines).addClass("outdated");this.lastPos=a;this.lastDepth=b;Game.initLine(a,h);var m=new NotationGenerator(lm.NOTA_LOCALIZATION);k.analysis||(h=h.slice(0,1));l=m.getLineNota(a,h);var n=f;e?(0>n&&(n=-n),n=m.getLocalization().strMate+n):(a.isWTM()||
4839(n=-n),n=(n/100).toFixed(2));l=k.analysis?"("+n+") "+l:" "+l;c={id:"pv",line:h,pv:h,eval:f,evalStr:Evaluation&&!e?Evaluation.getEvalString(100*n)+".":"",nps:this.lastNps,depth:b,maxDepth:c,totalTime:this.lastTime,handicap:k.handicapStyle,analysis:k.analysis,num:g};c.pv.lineStr=l;e&&(f=0>f?-Number.MAX_VALUE:Number.MAX_VALUE);e=f;a.isBTM()&&(e=-e);c.symbol=getSymbol(e);this.outCommonData(c);this.outLine(c,d,b);d||this.scrollBottom();System.isElectron()&&"undefined"!==typeof electronBridge&&electronBridge.updateTouchBarInfo(c.evalStr)}}onLosingLine(a,
4840b){}scrollBottom(){this.scrollParent&&(this.scrollParent.scrollTop=this.scrollParent.scrollHeight)}fillOutLine(a,b,c){if(CBQ(".pv",a)&&CBQ(".pvnum",a)){a.on("dragstart",onDragStart);CBQ(".pv",a).text(b.pv.lineStr);c=$(this.el).width();200<c&&CBQ(".pvnum",a).text(b.num+".");b.evalStr&&this.setEvalStr(b.evalStr);200<c&&!b.handicap&&(c=new StringBuilder,NotaElement.CreateGlyphableText(b.symbol,c,"cbspec-glyph"),c=c.toString(),CBQ(".symbol",a).html(c));a.data("pvnum",b.num);a.data("depth",b.depth);a.data("mv",
4841b.pv[0].toString());a.css("order",b.num);var d=new StringBuilder;b.handicap?d.appendFormat(String.f(lm.CALCULATES_MOVE,b.pv[0])):b.pv.forEach(function(e){d.appendFormat("{0} ",e)});a.data("pv",d.toString());a.removeClass("outdated");this.hideInfo()}}setEvalStr(a){this.$Id("engOutEvalText").text(a)}showInfo(){this.$Id("engine-info-text").show()}hideInfo(){let a=this.$Id("engine-info-text").is(":visible");this.$Id("engine-info-text").hide();return a}
4841showLines(){this.$Id("engOutContainer").show();this.analysisLayout?
4842this.$Id("engOutContainer").css("display","block"):this.$Id("engOutContainer").css("display","flex")}hideLines(){this.$Id("engOutContainer").hide()}switchInfoToLines(){let a=this.hideInfo();this.showLines();return a}switchLinesToInfo(){this.showInfo();this.hideLines()}setAnalysisLayout(a){if(!this.analysisLayout||a)this.analysisLayout=!0,this.createHtml(function(){return this.getAnalysisHTML(this.nInPage)}.bind(this)),this.showAnalysisButtons()}showAnalysisButtons(){this.$Id("engOutLineRight").show()}hideAnalysisButtons(){this.$Id("engOutLineRight").hide()}setInfoText(a,
4843b){this.$Id("engine-info-text").text(a);this.$Id("engine-info-text").removeClass("findStrong");b&&this.$Id("engine-info-text").addClass(b);System.isElectron()&&"undefined"!==typeof electronBridge&&electronBridge.updateTouchBarInfo(a)}setVariationText(a,b){var c="engOutVariationText";b&&(c+=" "+b);this.$Id("engOutVariation").html(String.f("<div class='{1}'>{0}</div>",a,c))}outCommonData(a){this.$Id("engOutSearchInfo").text(getInfoString(a))}outLine(a,b){b?(b=String.formatEx(".line[data-pvnum='{0}']",
4844a.num),b=CBQ(b,this.elLines),0==b.length&&(1==a.num&&this.$Id("engOutVariation").empty(),b=CBQ(this.getLineHTML("pv")),this.$Id("engOutVariation").append(b)),this.fillOutLine(b,a,!0)):(b="pv",a.handicap&&(b+=" pvHandicap"),b=CBQ(this.getLineHTML(b),this.elLines),this.fillOutLine(b,a,!1),this.$Id("engOutVariation").empty(),this.$Id("engOutVariation").append(b))}setHintMode(a){a?(this.onThreat(!1),this.$Id("engOutNextHintBtn").show()):this.$Id("engOutNextHintBtn").hide()}onHints(a){this.switchInfoToLines();
4845this.clearLines();this.setEvalStr("");let b=this,c={displayed:!1},d=a.hints[a.index];d&&(Hints.displayHint(a.hintMove,a.pos,d,this.panelManager.getBoardUI(),function(e){e=b.getHintHTML(e,a.depth);b.$Id("engOutVariation").append($(e))}),c={displayed:!0});c.displayed||b.$Id("engOutVariation").html("No Hints");return c}static idEvProf="idEvEngCanvas";getEvProfDiv(){return $("#"+EngineLinesElement.idEvProf+"-"+this.nInPage)}createEvaluationProfile(){if(this.evalArr&&this.evalArr.isValid()){var a=this.getEvProfDiv();
4846if(!this.evProfileControl){let b=EvalProfileControl.createEvaluationCanvas(a[0],this.jumpToEvProfileMove.bind(this));this.evProfileControl=b.control;this.evCanvas=b.evCanvas}this.evProfileControl&&(this.evProfileControl.setEvalArr(this.evalArr),this.evCanvas&&this.evCanvas.setSize(a.width(),60))}else this.evProfileControl&&this.evProfileControl.reset(),this.getEvProfDiv().hide()}jumpToEvProfileMove(a){this.game.gotoIndex(Math.min(a,this.game.mainLine.length))}}mixin(EngineLinesElement,EvalMixin);
4847Vk.initForListeners(EngineLinesElement);Vk.addEvent(EngineLinesElement,"MoveEntered");"use strict";
4848var AutoEnginePanelMgrMixin=function(){return{autoEngPanel:null,_autoShowEngine:!1,getAutoEngPanel:function(){return this.autoEngPanel},setAutoShowEngine:function(a){this._autoShowEngine!==a&&(this._autoShowEngine=a,this.toggleEnginePanel(a))},getAutoShowEngine:function(){return this._autoShowEngine},toggleAutoShowEngine:function(){this._autoShowEngine=!this._autoShowEngine;this.toggleEnginePanel(this._autoShowEngine);return this._autoShowEngine},toggleEnginePanel:function(a){glApp.commands.fireChecked(CommandIds.TOGGLE_ANALYSIS_AUTO_ENGINE,
4849a);var b=this.getEngPanelLocation(),c=b.region;b=b.container;a?(this.autoEngPanel||(this.autoEngPanel=CBPanels.createAutoEnginePanel(0,{h:System.pixToZoom(.26*window.innerHeight),region:c,autoInit:!0,active:!0})),this.beforeShowAutoEngPanel(),b.contains(this.autoEngPanel)||(b.add(this.autoEngPanel),b.updateLayout())):this.autoEngPanel&&(b.remove(this.autoEngPanel,!0),this.afterHideAutoEngPanel(),this.autoEngPanel.setGame(null),this.autoEngPanel.disposeEngine(),this.autoEngPanel=null);return this.autoEngPanel},
4850beforeShowAutoEngPanel:function(){},afterHideAutoEngPanel:function(){}}}(),AutoEngineAppMixin=function(){}(),AutoEngineGUIElements=function(){return{createAutoEngineBtn:function(a){return ToolButtons.toggleBtn(a,lm.ANALYSIS_ENGINE,"Engine",CommandIds.TOGGLE_ANALYSIS_AUTO_ENGINE,lm.ANALYSIS_ENGINE,CBWeight(4),"RunningEngine")},createToolBarEngineBtn:function(){return ToolButtons.smallBtn("","Engine16",CommandIds.TOGGLE_ANALYSIS_AUTO_ENGINE,lm.ANALYSIS_ENGINE)}}}();
4851class RemoteEngineWrapper{constructor({url:a}){this.initForListeners();this.url=a||"https://remoteengine.chessbase.com/engine";this.connection=(new signalR.HubConnectionBuilder).withUrl(this.url).build();this.connection.on("OnConnected",this.onConnected.bind(this));this.connection.on("OnEnginePV",this.onEnginePV.bind(this));this.connection.start({withCredentials:!1}).then(this.onConnectionEstablished.bind(this)).catch(()=>{console.log("Connection failed")});this.fen="";this.multiPv=1;this.connected=
4852!1;this.afterConnectedFunc=[];this.lastDepth=0}onConnectionEstablished(){this.connected=!0;for(let a of this.afterConnectedFunc)a()}go(a,b){this.lastDepth=0;this.sendNewPos(a.getCurPos())}newGame(){}makeMove(a){}sendNewPos(a){if(this.connected){var b=a.toFEN();this.lastDepth=0;this.connection.invoke("SwitchPosition",this.fen,b,this.getMultiPV());this.fen=b}else this.afterConnectedFunc.push(()=>this.sendNewPos(a))}onConnected(){}onEnginePV(a){if(!(a.fen&&""!=a.fen&&a.fen!=this.fen||a.multiPV>this.multiPv||
4853a.depth<this.lastDepth)){this.lastDepth=a.depth;var b=2E4<Math.abs(a.eval),c=a.eval;b&&(c=0<c?3E4-c:-3E4-c);a.depth&&this.fireOnInfo(this,a.depth,a.selDepth,a.nodes,a.nps,a.milliSeconds);this.fireOnLine(this,a.depth,a.selDepth,a.evalType,b,c,a.multiPV,a.pv.map(d=>new Move(d.from,d.to,d.prom)),{handicapStyle:0,analysis:!0})}}setTag(a){}stop(){this.connected?this.connection.invoke("Stop",this.fen):this.afterConnectedFunc.push(()=>this.stop())}setMultiPV(a){this.multiPv=a}getMultiPV(){return this.multiPv}getCurPos(){return new Position(this.fen)}exit(){this.connection.stop()}dispose(){this.connection.stop();
4854this.removeAllListeners()}initForListeners(){RemoteEngineWrapper.prototype.fireEvent||(Vk.initForListeners(RemoteEngineWrapper),Vk.addEvent(RemoteEngineWrapper,"Line"),Vk.addEvent(RemoteEngineWrapper,"LosingLine"),Vk.addEvent(RemoteEngineWrapper,"CurMove"),Vk.addEvent(RemoteEngineWrapper,"CurLine"),Vk.addEvent(RemoteEngineWrapper,"Info"),Vk.addEvent(RemoteEngineWrapper,"BestMove"),
4854Vk.addEvent(RemoteEngineWrapper,"UCIInfo"),Vk.addEvent(RemoteEngineWrapper,"NewGame"),Vk.addEvent(RemoteEngineWrapper,
4855"SearchStart"),Vk.addEvent(RemoteEngineWrapper,"Exit"),Vk.addEvent(RemoteEngineWrapper,"Stop"),Vk.addEvent(RemoteEngineWrapper,"Threat"),Vk.addEvent(RemoteEngineWrapper,"BeautyScore"),Vk.addEvent(RemoteEngineWrapper,"BookMove"),Vk.addEvent(RemoteEngineWrapper,"StrongMove"),Vk.addEvent(RemoteEngineWrapper,"Eval"),Vk.addEvent(RemoteEngineWrapper,"Hints"),Vk.addEvent(RemoteEngineWrapper,"MoveFeedback"),Vk.addEvent(RemoteEngineWrapper,"StaticEval"))}}
4856class DuoEngineWrapper{constructor(a,b){this.initForListeners();a.addOnLineListener(this.onBrowserLine.bind(this));a.addOnInfoListener(this.onBrowserInfo.bind(this));a.addOnBestMoveListener(this.onBrowserBestMove.bind(this));b.addOnLineListener(this.onRemoteLine.bind(this));b.addOnInfoListener(this.onRemoteInfo.bind(this));this.browserEngine=a;this.remoteEngine=b;this.cur=null;this.lines=[];this.browserDepth=3;this.useRemote=!1}onBrowserInfo(a,b,c,d,e,f){this.browserDepth=Math.max(this.browserDepth,
4857b);this.fireOnInfo(this,b,c,d,e,f)}onBrowserLine(a,b,c,d,e,f,g,h,k){this.browserDepth=Math.max(this.browserDepth,b);this.lines[g-1]=h;this.fireOnLine(this,b,c,d,e,f,g,h,k)}onBrowserBestMove(a,b){this.fireOnBestMove(this,b)}onRemoteInfo(a,b,c,d,e,f){this.useRemote&&this.fireOnInfo(this,b,c,d,e,f)}onRemoteLine(a,b,c,d,e,f,g,h){b<=this.browserDepth||(this.browserEngine.stop(),this.useRemote=!0,this.lines[g-1]=h,this.fireOnLine(this,b,c,d,e,f,g,h,{handicapStyle:0,analysis:!0}))}getTag(){return this.tag}setTag(a){this.tag=
4858a}go(a,b){this.browserDepth=3;this.useRemote=!1;this.remoteEngine.go(a,b);this.browserEngine.go(a,b);this.cur=ObjUtil.clone(a.getCurPos())}getCurPos(){return this.cur}getLines(){return this.lines}getBestMove(){return 0===this.lines.length||0===this.lines[0].length?null:this.lines[0][0]}stop(){this.browserEngine.stop();this.remoteEngine.stop();this.fireOnStop(!1)}getName(){return"Duo"}isCalculating(){return this.browserEngine.isCalculating()}newGame(){return this.browserEngine.newGame()}makeMove(a){}exit(){this.browserEngine.exit();
4859this.remoteEngine.exit();this.fireOnExit()}dispose(){this.browserEngine.dispose();this.remoteEngine.dispose()}setOption(a,b){this.browserEngine.setOption(a,b)}getOption(a){return this.browserEngine.getOption(a)}setMultiPV(a){this.browserEngine.setMultiPV(a);this.remoteEngine.setMultiPV(a)}getMultiPV(){return this.browserEngine.getMultiPV()}initForListeners(){DuoEngineWrapper.prototype.fireEvent||(Vk.initForListeners(DuoEngineWrapper),Vk.addEvent(DuoEngineWrapper,"Line"),Vk.addEvent(DuoEngineWrapper,
4860"LosingLine"),Vk.addEvent(DuoEngineWrapper,"CurMove"),Vk.addEvent(DuoEngineWrapper,"CurLine"),Vk.addEvent(DuoEngineWrapper,"Info"),Vk.addEvent(DuoEngineWrapper,"BestMove"),Vk.addEvent(DuoEngineWrapper,"UCIInfo"),Vk.addEvent(DuoEngineWrapper,"NewGame"),Vk.addEvent(DuoEngineWrapper,"SearchStart"),Vk.addEvent(DuoEngineWrapper,"Exit"),Vk.addEvent(DuoEngineWrapper,"Stop"),Vk.addEvent(DuoEngineWrapper,"Threat"),Vk.addEvent(DuoEngineWrapper,"BeautyScore"),Vk.addEvent(DuoEngineWrapper,"BookMove"),Vk.addEvent(DuoEngineWrapper,
4861"StrongMove"),Vk.addEvent(DuoEngineWrapper,"Eval"),Vk.addEvent(DuoEngineWrapper,"Hints"),Vk.addEvent(DuoEngineWrapper,"MoveFeedback"),Vk.addEvent(DuoEngineWrapper,"StaticEval"))}}"use strict";
4862let HintTypes={NONE:0,FROM:1,TO:2,CAPTURE:3,CHECK:4,PIECE:5,MATE_THREAT:9,DOUBLE_ATTACK:10,PIN:11,GARDEZ_PAWN:14,GARDEZ_QUEEN:16,GARDEZ_ROOK:17,GARDEZ_MINOR_PIECE:18,EVADES_ATTACK:19,COVERS_PIECE:20,SACRIFICE:21,RECAPTURE:40,GARDEZ_QUEEN_ME:41,GARDEZ_ROOK_ME:42,GARDEZ_MINOR_PIECE_ME:43,GARDEZ_PAWN_ME:44,MATE_THREAT_MYKING:50,MATE:51,BOOK:52,EXCHANGE:53,OFFER_EXCHANGE:54,PASSED_PAWN:55,PROMOTE:56,THREAT:57,THREAT_AGAINST_ME:58,THREAT_MOVE:59,BLOCK_ATTACK:61,BLOCK_CHECK:62,EVADE_CHECK:63,EVADES_EXCHANGE:65,
4863ONLY_MOVE:66,WIN_MATERIAL:67,FULL_MOVE:98,TEXT:99,NUM:100,toString:function(a){if("string"==typeof a)return a;let b=HintTypes;switch(a){case b.NONE:return"---";case b.FROM:return"From";case b.TO:return"To";case b.PIN:return lm.PIN_IMP;case b.CAPTURE:return lm.CAPTURE_SOMETHING;case b.CHECK:return lm.GIVE_CHECK;case b.PIECE:return"Piece";case b.MATE_THREAT:return lm.THREATEN_MATE;case b.MATE_THREAT_MYKING:return lm.OPP_THREATENS_MATE;case b.GARDEZ_QUEEN:return lm.ATTACK_THE_QUEEN;case b.GARDEZ_ROOK:return lm.ATTACK_A_ROOK;
4864case b.GARDEZ_MINOR_PIECE:return lm.ATTACK_A_MINOR_PIECE;case b.GARDEZ_PAWN:return lm.ATTACK_A_PAWN;case b.GARDEZ_QUEEN_ME:return lm.OPP_THREATENS_QUEEN;case b.GARDEZ_ROOK_ME:return lm.OPP_THREATENS_ROOK;case b.GARDEZ_MINOR_PIECE_ME:return lm.OPP_THREATENS_MINOR;case b.GARDEZ_PAWN_ME:return lm.OPP_THREATENS_PAWN;case b.RECAPTURE:return lm.RECAPTURE_MATERIAL;case b.MATE:return lm.MATE_IMP;case b.BOOK:return lm.STILL_IN_BOOK;case b.EXCHANGE:return lm.EXCHANGE_IMP;case b.OFFER_EXCHANGE:return lm.OFFER_EXCHANGE_IMP;
4865case b.PASSED_PAWN:return lm.CREATE_PASSED_PAWN;case b.PROMOTE:return lm.PROMOTE_IMP;case b.THREAT:return lm.THREATEN_IMP;case b.THREAT_AGAINST_ME:return lm.WATCH_OUT;case b.THREAT_MOVE:return"threat is";case b.COVERS_PIECE:return lm.COVER_SOMETHING;case b.BLOCK_ATTACK:return lm.BLOCK_ATTACK;case b.EVADES_ATTACK:return lm.EVADE_ATTACK_IMP;case b.EVADES_EXCHANGE:return lm.EVADE_EXCHANGE_IMP;case b.EVADE_CHECK:return lm.EVADE_CHECK;case b.BLOCK_CHECK:return lm.BLOCK_CHECK;case b.DOUBLE_ATTACK:return lm.DOUBLE_ATTACK_IMP;
4866case b.SACRIFICE:return lm.SACRIFICE_SOMETHING;case b.ONLY_MOVE:return lm.ONLY_MOVE;case b.WIN_MATERIAL:return lm.WIN_MATERIAL}for(var c in this)if(this[c]==a)return c;return"Unknown HintType: "+a}};
4867class Hint{constructor(a,b,c){this.type=a||HintTypes.NONE;this.text="";this.sq=b||-1;this.move=c;this.piece=this.n=0}equals(a){if(a)return this.type==a.type&&this.sq==a.sq&&this.text==a.text}static makeTextHint(a,b){let c=new Hint;c.text=a;c.sq=b||-1;c.type=HintTypes.TEXT;return c}static makeHint(a,b){let c=new Hint;c.type=a;c.sq=b||-1;return c}display(a,b){this.type==HintTypes.THREAT_MOVE?(b&&b.drawArrow(this.move.from,this.move.to,"hsla( 0, 50%, 50%, 0.9 )"),a(lm.RED_ARROW_THREAT)):a(this.toString())}getText(){return this.text+
4868this.getDecorateText()}getDecorateText(){let a="";this.book&&this.type!=HintTypes.BOOK?a+=" ("+lm.THEORY+")":this.strong&&(a=this.strong.precise?a+(" ("+lm.PRECISE_MOVE+")"):a+(" ("+lm.BRILLIANT_MOVE+")"));return a}toString(){return this.toStringSimple()+this.getDecorateText()}toStringSimple(a){let b="";this.type!=HintTypes.FULL_MOVE&&this.type!=HintTypes.FROM&&(b=this.text||HintTypes.toString(this.type));b&&3<b.length&&a&&(a=b.charAt(b.length-1),b="."==a||"!"==a?b.substring(0,b.length-1)+":":b+":");
4869return b}isRedundantToCapture(){let a=HintTypes;return this.type==a.RECAPTURE||this.type==a.EXCHANGE}isFullMove(){return this.type==HintTypes.FULL_MOVE}isOpeningHint(){return this.type==HintTypes.BOOK||this.book}sortVal(){if(this.nSort)return this.nSort;let a=HintTypes;switch(this.type){default:case a.NONE:throw"Hint.sortVal";case a.FULL_MOVE:return 0;case a.FROM:return 1;case a.TO:return 2;case a.PIECE:return 3;case a.CHECK:return 8;case a.CAPTURE:return 3<this.n?21:9;case a.TEXT:return 20;case a.PIN:return 23;
4870case a.BOOK:return 25;case a.EXCHANGE:return 30;case a.GARDEZ_PAWN:return 32;case a.GARDEZ_MINOR_PIECE:return 33;case a.GARDEZ_ROOK:return 34;case a.GARDEZ_QUEEN:return 35;case a.OFFER_EXCHANGE:return this.piece==Piece.PAWN?31:36;case a.GARDEZ_PAWN_ME:return 41;case a.GARDEZ_MINOR_PIECE_ME:return 42;case a.GARDEZ_ROOK_ME:return 43;case a.GARDEZ_QUEEN_ME:return 45;case a.COVERS_PIECE:return 46;case a.BLOCK_ATTACK:case a.BLOCK_CHECK:return 47;case a.EVADES_ATTACK:case a.EVADES_EXCHANGE:case a.EVADE_CHECK:return 48;
4871case a.THREAT_MOVE:return 55;case a.THREAT:return 56;case a.THREAT_AGAINST_ME:return 57;case a.RECAPTURE:return 65;case a.PASSED_PAWN:return 60;case a.PROMOTE:return 61;case a.DOUBLE_ATTACK:return 62;case a.SACRIFICE:return 70;case a.WIN_MATERIAL:return 71;case a.MATE_THREAT:return 80;case a.MATE:return 82;case a.MATE_THREAT_MYKING:return 85;case a.ONLY_MOVE:return 90}}}
4872let Hints=function(){var a=function(){};a.engUrl="/Common/Chess/Engine/Enginemin.js";a.engine=new EngineWrapper(0,a.engUrl,null,a);System.isElectron()||a.engine.load();a.evalOfHintNormed=0;a.genAsync=function(b,c,d,e,f,g,h,k){LOG("genAsync");let l=[];var m=b.getCurPos(),n=ObjUtil.clone(m);n.makeMove(c);let r=!1;n.canMakeNullMove()&&(n.makeNullMove(),r=!0);n.isLegal()?(a.fnAfterSearch=function(t,u){l=[];m.Vj()===Side.BLACK&&(e=-e,t=-t);a.evalAfterNullMove=t;a.evalOfHintNormed=e;f&&(l=[new Hint(HintTypes.ONLY_MOVE)].concat(l));
48732E4<e&&(l=[new Hint(HintTypes.MATE)].concat(l));r&&2E4<t&&(l=[new Hint(HintTypes.MATE_THREAT)].concat(l));m.isCheck()&&(l=this.checkInCheckHints(m,b.getLastMove(),c,l));a.isRecapture(m,b,c)?l=[new Hint(HintTypes.RECAPTURE)].concat(l):a.isExchange(m,c,d)&&(l=[new Hint(HintTypes.EXCHANGE)].concat(l));l=this.checkPromotionHint(m,c,l);l=this.checkPassedPawnHint(m,c,d,l);l=this.checkDoubleAttackHint(m,c,l);l=this.checkPinHint(m,n,c,l);l=this.checkOfferExchangeHint(m,c,d,l);var x=new Move;u.moves[0]&&r&&
4874(x.fromJSON(u.moves[0]),l=this.checkGardezHint(n,m,c,x,Piece.QUEEN,t,400,HintTypes.GARDEZ_QUEEN,l),l=this.checkGardezHint(n,m,c,x,Piece.ROOK,t,250,HintTypes.GARDEZ_ROOK,l),l=this.checkGardezHint(n,m,c,x,Piece.KNIGHT,t,200,HintTypes.GARDEZ_MINOR_PIECE,l),l=this.checkGardezHint(n,m,c,x,Piece.BISHOP,t,200,HintTypes.GARDEZ_MINOR_PIECE,l),l=this.checkGardezHint(n,m,c,x,Piece.PAWN,t,40,HintTypes.GARDEZ_PAWN,l),t=m.Vj()===Side.WHITE?a.evalAfterNullMove>a.evalOfHintNormed:a.evalAfterNullMove<a.evalOfHintNormed,
4875LOG(String.f("EvalAfterNull = {0}, evalOfHint = {1}, Consistent = {2}, gardez={3}",a.evalAfterNullMove,a.evalOfHintNormed,t,x)),t?l=this.checkThreatHint(m,c,x,a.evalAfterNullMove,a.evalOfHintNormed,l):LOG("Inconsistent"));x=m.Vd();x=this.genSimpleHints(b,c,x);t=a.genMovingPieceHint(m,d,c,!1);t.hint&&l.push(t.hint);t.strHint&&(u=Hint.makeTextHint(t.strHint),t.nSort&&(u.nSort=t.nSort),l.push(u),l=l.concat(x.filter(
4875B=>B.type!=HintTypes.PIECE&&B.type!=HintTypes.FROM)));t.strHint||t.hint||(l=l.concat(x));
4876l=a.filterOutCapture(l);l.push(new Hint(HintTypes.FULL_MOVE));this.continueAsync(b,c,d,l,g,h,k)},a.engine.sendNewPos(n),a.engine.search(h||1500,15)):g(l,c,k)};a.continueAsync=function(b,c,d,e,f,g,h){LOG("Continue Async");var k=b.getCurPos(),l=ObjUtil.clone(k);let m=!1;l.canMakeNullMove()&&(l.makeNullMove(),m=!0);l.isLegal()?(a.fnAfterSearch=null,a.fnAfterSearch2=function(n,r){let t=ObjUtil.clone(e);if(m){let x=n;l.Vj()===Side.BLACK&&(x=-n);2E4<n&&(t=[new Hint(HintTypes.MATE_THREAT_MYKING)].concat(t));
4877var u=new Move;if(r.moves[0]){u.fromJSON(r.moves[0]);t=this.checkGardezMeHint(l,k,c,u,Piece.QUEEN,n,400,HintTypes.GARDEZ_QUEEN_ME,t);t=this.checkGardezMeHint(l,k,c,u,Piece.ROOK,n,170,HintTypes.GARDEZ_ROOK_ME,t);t=this.checkGardezMeHint(l,k,c,u,Piece.KNIGHT,n,150,HintTypes.GARDEZ_MINOR_PIECE_ME,t);t=this.checkGardezMeHint(l,k,c,u,Piece.BISHOP,n,150,HintTypes.GARDEZ_MINOR_PIECE_ME,t);t=this.checkGardezMeHint(l,k,c,u,Piece.PAWN,n,80,HintTypes.GARDEZ_PAWN_ME,t);if(k.Vj()===Side.WHITE?x<a.evalOfHintNormed:
4878x>a.evalOfHintNormed)t=this.checkThreatMeHint(k,c,u,a.evalOfHintNormed,x,t);t=this.checkCoverMeHint(l,k,c,u,t);t=this.checkWinMaterial(b,d,t)}}t&&(t.sort(function(x,B){return B.sortVal()-x.sortVal()}),f(t,c,h))},a.engine.sendNewPos(l),a.engine.search(g||1500,15)):f(e,c,h)};a.checkPinHint=function(b,c,d,e){if(d.vct)return e;var f=new Att;b=f.evaluatePins(b);f=f.evaluatePins(c);if(!c.getBTM()&&f.valW)for(c=0;c<f.pinsW.length;c++){if(f.pinsW[c].pinnerSq==d.to&&!b.hasPinnedW(f.pinsW[c].pinnedSq)){e=[new Hint(HintTypes.PIN)].concat(e);
4879break}}else if(!c.getBTM()&&f.valB)for(c=0;c<f.pinsB.length;c++)if(f.pinsB[c].pinnerSq==d.to&&!b.hasPinnedB(f.pinsB[c].pinnedSq)){e=[new Hint(HintTypes.PIN)].concat(e);break}return e};a.checkDoubleAttackHint=function(b,c,d){b=(new Att).checkDoubleAttack(b,c);if(b.length){let e="";b.forEach(function(f){e+=CBSquare.toString(f)+","});LOG("Squares: "+e);d.push(new Hint(HintTypes.DOUBLE_ATTACK,c.to))}return d};a.checkPassedPawnHint=function(b,c,d,e){if((b.board[c.from]&Piece.PIECE_MASK)==Piece.PAWN&&d){let f=
4880b.board[c.from]&Piece.COLOUR;if(!ChessKnowledge.isPassedPawn(b,c.from,f)&&d.length&&d[0].equals(c)){b=ObjUtil.clone(b);b.makeMove(d[0]);for(let g=1;g<d.length&&0!=d[g].vct;g++)b.makeMove(d[g]);ChessKnowledge.isPassedPawn(b,c.to,f)&&(e=[new Hint(HintTypes.PASSED_PAWN,c.to)].concat(e))}}return e};a.checkInCheckHints=function(b,c,d,e){c&&d.to!=c.to&&(Piece.nominal(b.board[d.from])==Piece.KING?e.push(new Hint(HintTypes.EVADE_CHECK,d.to)):e.push(new Hint(HintTypes.BLOCK_CHECK,d.to)));return e};a.checkPromotionHint=
4881function(b,c,d){(b.board[c.from]&Piece.PIECE_MASK)==Piece.PAWN&&(b=CBSquare.getRank(c.to),7==b||0==b)&&(d=[new Hint(HintTypes.PROMOTE,c.to)].concat(d));return d};a.checkOfferExchangeHint=function(b,c,d,e){if(!d)return e;let f=!1;if(f=2<=d.length&&d[1].to==c.to&&Piece.equalType(b.board[c.from],b.board[d[1].from])){let g=ObjUtil.clone(b);g.makeMove(d[0]);0<(new Att).calc(g,d[1].from,d[1].to)&&(f=!1)}f||=3<=d.length&&d[2].from==c.to&&0!=d[2].vct&&Piece.equalType(b.board[c.from],b.board[d[2].to]);if(!f){let g=
4882ObjUtil.clone(b);g.makeMove(c);let h=!1;g.Vd().forEach(function(k){k.to==c.to&&Piece.equalType(g.board[k.from],b.board[c.from])&&0==(new Att).calc(g,k.from,k.to)&&(h=!0)});f=h}f&&0==b.board[c.to]&&(d=new Hint(HintTypes.OFFER_EXCHANGE),d.piece=Piece.nominal(b.board[c.from]),e=[d].concat(e));return e};a.checkGardezHint=function(b,c,d,e,f,g,h,k,l){g=c.getBTM()?g<-h:g>h;(b.board[e.to]&Piece.PIECE_MASK)==f&&g&&!d.vct&&(d=new Att,0<d.calc(b,e.from,e.to)&&(d.hasSafeCapture(c,e.to,h)||(l=[new Hint(k,e.to)].concat(l))));
4883return l};a.checkGardezMeHint=function(b,c,d,e,f,g,h,k,l){c.getBTM()&&(f|=Piece.COLOUR);b.board[e.to]==f&&g>h&&(g=d.from==e.to||d.to==e.from,g||(g=new Att,c=ObjUtil.clone(c),c.makeMove(d),b=g.hasSafeCapture(b,e.to),d=g.hasSafeCapture(c,e.to),g=b&&!d),g&&(l=l.concat([new Hint(k,e.to)])));return l};a.checkThreatHint=function(b,c,d,e,f,g){e=Math.abs(e-f);(b.getBTM()?f<1.2*e:f>1.2*-e)&&e>Math.abs(f/2)&&200<e&&2E4>e&&!c.vct&&!b.board[d.to]&&(g=g.concat([new Hint(HintTypes.THREAT,d.to)]));return g};a.checkThreatMeHint=
4884function(b,c,d,e,f,g){let h=Math.abs(f-e);(b.getBTM()?150<f:-150>f)&&h>Math.abs(e/2)&&200<h&&2E4>h&&!c.vct&&!b.board[d.to]&&(g=g.concat([new Hint(HintTypes.THREAT_AGAINST_ME,d.to)]),g=g.concat([new Hint(HintTypes.THREAT_MOVE,-1,d)]),LOG("Threat Me: "+h+"/ev="+f));return g};a.checkCoverMeHint=function(b,c,d,e,f){let g=new Att;0<g.calc(b,e.from,e.to)&&((b=ObjUtil.clone(c),d.from!=e.to||c.board[d.to])?d.from!=e.to&&d.to!=e.from&&(b.makeMove(d),0>=g.calc(b,e.from,e.to)&&0==d.vct&&(g.coversFromTo(b,c.Vj(),
4885d.to,e.to)?f.push(new Hint(HintTypes.COVERS_PIECE,e.to)):g.coversFromTo(b,c.Vj(),e.from,d.to)&&f.push(new Hint(HintTypes.BLOCK_ATTACK,e.to)))):Piece.equalType(c.board[e.from],c.board[d.from])?f.push(new Hint(HintTypes.EVADES_EXCHANGE,e.to)):f.push(new Hint(HintTypes.EVADES_ATTACK,e.to)));return f};a.checkWinMaterial=function(b,c,d){if(!c)return d;let e=[];var f=ObjUtil.clone(b.getStartPos()),g=new Att,h=b.getMoveNo();for(var k=0;k<h;k++){var l=b.getMoves()[k];if(!l)return d;e.push({capt:0!=f.board[l.to],
4886diff:g.materialDiff(f)});f.makeMove(l)}for(k=0;k<c.length;k++)l=c[k],e.push({capt:0!=f.board[l.to],diff:g.materialDiff(f)}),f.makeMove(l);c=0;f=null;for(g=h-1;0<g&&null==f;g--)0==e[g].capt?(c++,4<=c&&(f=e[g].diff)):c=0;c=0;if(null!=f){f=e[h-1].diff;g=null;for(k=!1;h<e.length&&null==g;h++)if(0==e[h].capt)if(c++,2<=c&&k)g=e[h].diff;else{if(4<=c&&!k)break}else k=!0,c=0;null!=g&&(b.getCurPos().getBTM()?g<f:g>f&&150<Math.abs(f-g))&&d.push(new Hint(HintTypes.WIN_MATERIAL))}return d};a.genSimpleHints=function(b,
4887c,d){for(var e=[],f=[],g=0;g<HintTypes.NUM;g++)f[g]=0;b=b.getCurPos();d||=b.Vd();var h=!1;for(g=0;g<d.length;g++){var k=d[g];b.preSetMinCtx(k);c.from==k.from&&f[HintTypes.FROM]++;c.from==k.from&&f[HintTypes.TO]++;c.mvd==k.mvd&&c.from!=k.from&&f[HintTypes.PIECE]++;k.vct&&f[HintTypes.CAPTURE]++;var l=new Position;l.copy(b);l.makeMove(k);l.isCheck()&&(f[HintTypes.CHECK]++,k.equals(c)&&(h=!0))}2<=f[HintTypes.CHECK]&&h&&e.push(new Hint(HintTypes.CHECK));2<=f[HintTypes.CAPTURE]&&c.vct&&!f[HintTypes.RECAPTURE]&&
4888(d=new Hint(HintTypes.CAPTURE),d.n=f[HintTypes.CAPTURE],e.push(d));3<=f[HintTypes.PIECE]?e.push(new Hint(HintTypes.PIECE)):2<=f[HintTypes.FROM]&&(c.piece&Piece.PIECE_MASK)!=Piece.PAWN&&e.push(new Hint(HintTypes.FROM,c.from));2<=f[HintTypes.TO_SQ]&&e.push(new Hint(HintTypes.TO_SQ,c.to));return e};a.filterOutCapture=function(b){b.find(c=>c.isRedundantToCapture())&&(b=b.filter(c=>c.type!=HintTypes.CAPTURE));return b};a.onEnginePV=function(b,c){a.fnAfterSearch?a.fnAfterSearch(c.eval,c.pv):a.fnAfterSearch2&&
4889a.fnAfterSearch2(c.eval,c.pv)};a.onEngineMove=function(b,c){};a.genStrPieceHint=function(b,c){return lm.MOVE_IMP+" "+a.getYourPieceAcc(b,c)};a.getStrPieceHint=function(b){var c=lm.MOVE_IMP+" ";
4889switch(b&Piece.PIECE_MASK){case Piece.KING:c+=lm.YOUR_KING_ACC;break;case Piece.QUEEN:c+=lm.YOUR_QUEEN_ACC;break;case Piece.ROOK:c+=lm.YOUR_ROOK_ACC;break;case Piece.KNIGHT:c+=lm.YOUR_KNIGHT_ACC;break;case Piece.BISHOP:c+=lm.YOUR_BISHOP_ACC;break;case Piece.PAWN:c+=lm.YOUR_PAWN_ACC}return c};a.getYourPieceAcc=
4890function(b,c){let d=b&=Piece.PIECE_MASK;c.getBTM()&&(d|=Piece.COLOUR);c=1==c.countPieces(d);switch(b){case Piece.KING:return lm.YOUR_KING_ACC;case Piece.QUEEN:return c?lm.YOUR_QUEEN_ACC:lm.A_QUEEN_ACC;case Piece.ROOK:return c?lm.YOUR_ROOK_ACC:lm.A_ROOK_ACC;case Piece.KNIGHT:return c?lm.YOUR_KNIGHT_ACC:lm.A_KNIGHT_ACC;case Piece.BISHOP:return c?lm.YOUR_BISHOP_ACC:lm.A_BISHOP_ACC;case Piece.PAWN:return c?lm.YOUR_PAWN_ACC:lm.A_PAWN_ACC}};a.genStrPieceOnSqHint=function(b,c,d){return this.genStrPieceHint(b,
4891d)+" "+CBSquare.toString(c)};a.getStrPieceOnSqHint=function(b,c){return this.getStrPieceHint(b)+" "+CBSquare.toString(c)};a.displayHint=function(b,c,d,e,f){b&&(d.text?f(d.getText()):d.type==HintTypes.FROM?this.showFromSqHint(c,d.sq,f,e):d.type==HintTypes.TO?e&&e.markSquare(d.sq):d.type==HintTypes.PIECE?this.showPieceHint(c.board[b.from],c,f):d.type==HintTypes.FULL_MOVE?(e&&e.drawArrow(b.from,b.to,"hsla( 90, 50%, 50%, 0.9 )",12,[10,6]),f(lm.GREEN_ARROW_MOVE)):d.display(f,e))};a.showFromSqHint=function(b,
4892c,d,e){d(a.genStrPieceOnSqHint(b.board[c],c,b)+".")};a.showPieceHint=function(b,c,d){d(a.genStrPieceHint(b,c)+".")};a.genMovingPieceHint=function(b,c,d,e){let f={strHint:""};var g=b.getBTM(),h=b.board[d.from],k=CBSquare.R(d.from),l=CBSquare.R(d.to);if((g?l>=CBSquare.R_7&&k<CBSquare.R_5:l<=CBSquare.R_2&&k>CBSquare.R_4)&&!d.vct)return{strHint:lm.RETREAT_A_PIECE};if(d.isCastling())return{strHint:lm.CASTLE_IMP};switch(h&Piece.PIECE_MASK){case Piece.KING:f=a.genKingHints(b,c,h,d,e);break;case Piece.PAWN:f=
4893a.genPawnHints(b,c,h,d,e);break;case Piece.BISHOP:f=a.genBishopHints(b,c,h,d,e);break;case Piece.KNIGHT:f=a.genKnightHints(b,c,h,d,e);break;case Piece.ROOK:f=a.genRookHints(b,c,h,d,e);break;case Piece.QUEEN:f=a.genQueenHints(b,c,h,d)}return f};a.genQueenHints=function(b,c,d,e){c={strHint:""};d=a.getYourPieceAcc(d,b);c.strHint=lm.MOVE_IMP+" "+d+".";-300>(new Att).calc(b,e.from,e.to)?(c.hint=new Hint(HintTypes.SACRIFICE,e.to),c.strHint=lm.SAC_IMP+" "+d+".",c.nSort=50):!e.vct&&4<a.countMovesOf(b,Piece.QUEEN)&&
4894(.5>Math.random()&&!a.isDiagonalMove(e)?CBSquare.isLight(e.to)?c.strHint=lm.MOVE_IMP+" "+d+" "+lm.TO_A_LIGHT_SQUARE+".":c.strHint=lm.MOVE_IMP+" "+d+" "+lm.TO_A_DARK_SQUARE+".":(b=a.getRankDiff(e,b.getBTM()),2<=Math.abs(b)?0<b?c.strHint=String.f(lm.ADVANCE_FORMAT,d):0>b&&(c.strHint=String.f(lm.RETREAT_FORMAT,d)):CBSquare.F(e.from)==CBSquare.F(e.to)?c.strHint=lm.MOVE_IMP+" "+d+" "+lm.VERTICALLY+".":CBSquare.R(e.from)==CBSquare.R(e.to)?c.strHint=lm.MOVE_IMP+" "+d+" "+lm.HORIZONTALLY+".":c.strHint=lm.MOVE_IMP+
4895" "+d+" "+lm.DIAGONALLY+"."));return c};a.genKingHints=function(b,c,d,e){c={strHint:""};if(3<=a.countMovesOf(b,Piece.KING)){var f=a.getRankDiff(e,b.getBTM()),g=a.getFileDiff(e,b.getBTM()),h=CBSquare.F(e.from);e=CBSquare.F(e.to);0!=f&&(0==g||.5>Math.random())?0<f?c.strHint=String.f(lm.ADVANCE_FORMAT,a.getYourPieceAcc(d,b)):0>f&&(c.strHint=String.f(lm.RETREAT_FORMAT,a.getYourPieceAcc(d,b))):0!=g&&CBSquare.isCenterFile(e)&&!CBSquare.isCenterFile(h)?c.strHint=lm.CENTRALIZE+" "+a.getYourPieceAcc(d,b)+
4896".":0!=g&&0==f&&(c.strHint=2==Math.abs(g)?lm.CASTLE_IMP:lm.MOVE_KING_SIDEWAYS)}return c};a.genPawnHints=function(b,c,d,e){d={strHint:""};12>=b.getMoveNum()?d.strHint=String.f(lm.MOVE_YOUR_FILE_PAWN,CBSquare.colToString(CBSquare.F(e.from))):2==a.getRankDiff(e,b.getBTM())?d.strHint=lm.MAKE_PAWN_DOUBLE_STEP:a.preparesOpenFile(b,e,c)?a.isAttackFileAgainstKing(b,CBSquare.F(e.from))&&(d.strHint=lm.OPEN_ATTACK_FILE,d.nSort=40):3<a.countMovesOf(b,Piece.PAWN)&&(CBSquare.isCenterFile(e.from)?d.strHint=lm.MOVE_CENTER_PAWN:
4897CBSquare.F(e.from)<CBSquare.C_E?d.strHint=lm.MOVE_QSIDE_PAWN:d.strHint=lm.MOVE_KSIDE_PAWN);return d};a.genBishopHints=function(b,c,d,e){let f={strHint:""};var g=new Att;d=a.getYourPieceAcc(d,b);-100>g.calc(b,e.from,e.to)?(f.hint=new Hint(HintTypes.SACRIFICE,e.to),f.strHint=lm.SAC_IMP+" "+d+".",f.nSort=50):e.vct||(g=b.getBTM(),2==b.countPieces(Piece.BISHOP|(g?Piece.COLOUR:0))?(CBSquare.isLight(e.from)?f.strHint=lm.MOVE_LIGHT_BISHOP:f.strHint=lm.MOVE_DARK_BISHOP,24>
4897=b.getMoveNum()&&(g&&CBSquare.R(e.from)==
4898CBSquare.R_8||!g&&CBSquare.R(e.from)==CBSquare.R_1)&&(b=a.genDevelopBishopHint(b,c,e),b.strHint&&(f=b))):0>a.getRankDiff(e,b.getBTM())?f.strHint=lm.RETREAT_BISHOP:f.strHint=lm.ADVANCE_BISHOP);return f};a.genDevelopBishopHint=function(b,c,d){let e={strHint:""};if(b.getBTM()){var f=CBSquare.F8;var g=CBSquare.C8;var h=CBSquare.G8;var k=CBSquare.B8;var l=Piece.B_KNIGHT}else f=CBSquare.F1,g=CBSquare.C1,h=CBSquare.G1,k=CBSquare.B1,l=Piece.W_KNIGHT;if(d.from==f)if(b.board[h]==l)e.strHint=lm.DEVELOP_KSIDE;
4899else{if(a.isCastleMove(c[2],CBSquare.C_G)||a.isCastleMove(c[4],CBSquare.C_G))e.strHint=lm.PREPARE_CASTLING}else if(d.from==g)if(b.board[k]==l)e.strHint=lm.DEVELOP_QSIDE;else if(a.isCastleMove(c[2],CBSquare.C_C)||a.isCastleMove(c[4],CBSquare.C_C))e.strHint=lm.PREPARE_CASTLING;return e};a.genKnightHints=function(b,c,d,e){c={strHint:""};d=a.getYourPieceAcc(d,b);c.strHint=lm.MOVE_IMP+" "+d+".";if(-100>(new Att).calc(b,e.from,e.to))c.hint=new Hint(HintTypes.SACRIFICE,e.to),c.strHint=lm.SAC_IMP+" "+d+".",
4900c.nSort=50;else if(!e.vct){let f=(d=b.getBTM())?7:0;12>=b.getMoveNum()&&CBSquare.F(e.from)==f&&(CBSquare.C(e.from)==CBSquare.C_B?c.strHint=lm.DEVELOP_QN:CBSquare.C(e.from)==CBSquare.C_G&&(c.strHint=lm.DEVELOP_KN));c.strHint||(CBSquare.isCenterSquare(e.to)?c.strHint=lm.CENTRALIZE_KNIGHT:(b=a.getRankDiff(e,d),c.strHint=2==b?lm.ADVANCE_KNIGHT:-2==b?lm.RETREAT_KNIGHT:lm.MOVE_KNIGHT_SIDEWAYS))}return c};a.genRookHints=function(b,c,d,e){let f={strHint:""};d=a.getYourPieceAcc(d,b);f.strHint=lm.MOVE_IMP+
4901" "+d+".";if(-150>(new Att).calc(b,e.from,e.to))f.hint=new Hint(HintTypes.SACRIFICE,e.to),f.strHint=lm.SAC_IMP+" "+d+".",f.nSort=50;else if(!e.vct&&3<a.countMovesOf(b,Piece.ROOK)&&(d=b.getBTM(),f=a.genDoubleRooksHint(b,c,e),f.strHint||(f=a.genDoubleRooks7thHint(b,c,e)),!f.strHint)){c=b.countPieces(Piece.W_PAWN)+b.countPieces(Piece.B_PAWN);var g=a.getRankDiff(e,d),h=a.getFileDiff(e,d),k=CBSquare.F(e.from);e=CBSquare.F(e.to);6<=c&&(!a.isOpenFile(b,k)&&a.isOpenFile(b,e)?f.strHint=lm.ROOK_TO_OPEN_FILE:
4902!a.isHalfOpenFile(b,k,d)&&a.isHalfOpenFile(b,e,d)?f.strHint=lm.ROOK_TO_HALFOPEN_FILE:0==h?f.strHint=3<=g?lm.ADVANCE_ROOK:-3>=g?lm.RETREAT_ROOK:lm.MOVE_ROOK_VERTICALLY:0==g&&(CBSquare.isCenterFile(e)&&!CBSquare.isCenterFile(k)?f.strHint=lm.CENTRALIZE_ROOK:f.strHint=lm.MOVE_ROOK_HORIZONTALLY))}return f};a.isOpenFile=function(b,c){for(var d=0;8>d;d++)if((b.board[8*c+d]&Piece.PIECE_MASK)==Piece.PAWN)return!1;return!0};a.isHalfOpenFile=function(b,c,d){b=b.board;let e=!1;if(d)for(d=6;1<d;d--){var f=8*c+
4903d;if(b[f]==Piece.PAWN&&4>=d)e=!0;else if(b[f]==(Piece.PAWN|Piece.COLOUR))return!1}else for(d=1;6>=d;d++)if(f=8*c+d,b[f]==(Piece.PAWN|Piece.COLOUR)&&2<d)e=!0;else if(b[f]==Piece.PAWN)return!1;return e};a.isClosedFile=function(b,c,d){for(var e=0;8>e;e++)if(b.board[8*c+e]==(Piece.PAWN|(d?Piece.BLACK:0)))return!0;return!1};a.opensFile=function(b,c,d){return!1};a.preparesOpenFile=function(b,c,d){var e=b.getBTM();if(CBSquare.R(c.to)==(e?3:4)&&CBSquare.F(c.from)==CBSquare.F(c.to)&&4<=d.length)for(b=ObjUtil.clone(b),
4904b.makeMove(d[0]),b.makeMove(d[1]),e=2;e<d.length;e++)if(b.makeMove(d[e]),d[e].from==c.to&&Piece.nominal(b.board[d[e].to])==Piece.PAWN)return a.isOpenFile(b,CBSquare.F(c.to)),!0};a.isAttackFileAgainstKing=function(b,c){var d=b.getKingsPos(Side.other(b.Vj()));d=CBSquare.F(d);if(b.getBTM()?(0==c||1==c)&&2>=d:(6==c||7==c)&&5<=d)return b.getBTM()?2<=b.countPieces(Piece.B_ROOK)+b.countPieces(Piece.B_QUEEN):2<=b.countPieces(Piece.W_ROOK)+b.countPieces(Piece.W_QUEEN)};a.countOtherRooksInFile=function(b,c,
4905d){let e=0;var f=CBSquare.F(c.to);let g=b.getBTM();for(var h=0;8>h;h++)if(g&&0<h||!g&&7>h){var k=8*f+h;b.board[k]==Piece.ROOK|(d?Piece.BLACK:0)&&k!=c.from&&k!=c.to&&e++}return e};a.countOtherRooksOnRank=function(b,c,d){let e=0;for(var f=CBSquare.R(c.to),g=0;8>g;g++){var h=8*g+f;b.board[h]==Piece.ROOK|(d?Piece.BLACK:0)&&h!=c.from&&h!=c.to&&e++}return e};a.genDoubleRooksHint=function(b,c,d){let e={strHint:""};if(a.isOpenFile(b,CBSquare.F(d.to))&&1==a.countOtherRooksInFile(b,d,b.getBTM())&&CBSquare.F(d.to)!=
4906CBSquare.F(d.from))e.strHint=lm.DOUBLE_ROOKS,e.nSort=40;else{var f=CBSquare.F(d.to);if(CBSquare.F(d.from)==f&&2==b.countPieces(b.board[d.from])&&c)for(b=2;b<c.length&&6>=b;b+=2){var g=c[b];g&&(g.mvd&Piece.PIECE_MASK)==Piece.ROOK&&CBSquare.F(g.to)==f&&CBSquare.F(g.from)!=f&&g.to==d.from&&g.from!=d.to&&(e.strHint=lm.PREPARE_DOUBLE_ROOKS,e.nSort=40)}}return e};a.genDoubleRooks7thHint=function(b,c,d){c={strHint:""};a.isOpenFile(b,CBSquare.F(d.to))&&1==a.countOtherRooksOnRank(b,d,b.getBTM())&&CBSquare.F(d.to)==
4907CBSquare.F(d.from)&&(c.strHint=lm.DOUBLE_ROOKS_7TH,c.nSort=40);return c};a.isCastleMove=function(b,c){if(b)return(b.mvd&Piece.PIECE_MASK)==Piece.KING&&CBSquare.F(b.to)==c&&CBSquare.F(b.from)==CBSquare.C_E};a.countMovesOf=function(b,c){var d=0;
4907b.Vd().forEach(function(e){(b.board[e.from]&Piece.PIECE_MASK)==c&&d++});return d};a.getRankDiff=function(b,c){return c?CBSquare.R(b.from)-CBSquare.R(b.to):CBSquare.R(b.to)-CBSquare.R(b.from)};a.getFileDiff=function(b,c){return c?CBSquare.F(b.from)-CBSquare.F(b.to):
4908CBSquare.F(b.to)-CBSquare.F(b.from)};a.isVerticalMove=function(b){return CBSquare.F(b.from)==CBSquare.F(b.to)};a.isHorizontalMove=function(b){return CBSquare.R(b.from)==CBSquare.R(b.to)};a.isDiagonalMove=function(b){return Math.abs(CBSquare.R(b.from)-CBSquare.R(b.to))==Math.abs(CBSquare.F(b.from)-CBSquare.F(b.to))};a.isRecapture=function(b,c,d){let e=c.getLastMove();if(e&&0!=e.vct&&e.to==d.to&&2<c.getMoveCount()&&(c=c.getMoves()[c.getMoveCount()-2],0==c.vct||c.to!=e.to))return 0<=(new Att).calc(b,
4909d.from,d.to)};a.isExchange=function(b,c,d){return d?1<d.length&&c.to==d[1].to&&0!=c.vct&&(c.vct&Piece.PIECE_MASK)==(b.board[c.from]&Piece.PIECE_MASK):!1};return a}();"use strict";
4910class Commands{constructor(){Commands.initForListeners();this.uniqueKeyDownHandlerId=this.uniqueCommandHandlerId=0;this.commandHandlers=[];this.keyDownHandlers=[];this.toggleButtons={};this.disableShortCutCounter=0;this.curStateChange={}}registerCommandHandler(a){this.uniqueCommandHandlerId+=1;this.commandHandlers[this.uniqueCommandHandlerId]=a;return this.uniqueCommandHandlerId}unregisterCommandHandler(a){delete this.commandHandlers[a]}commandHandler(a,b){try{for(var c=0;c<this.commandHandlers.length&&
4911(void 0===this.commandHandlers[c]||!this.commandHandlers[c].execCommand(a,b));c++);}catch(d){a=glApp.Vy.toNumString(a),LogException(a,d)}}onFileSelect(a,b){for(var c=0;c<this.commandHandlers.length;c++)if(void 0!==this.commandHandlers[c]&&this.commandHandlers[c].onFileSelect)this.commandHandlers[c].onFileSelect(a,b)}onTextFieldChange(a,b){LOG("TextFieldChange: "+a+", "+b);for(var c=0;c<this.commandHandlers.length;c++)if(void 0!==this.commandHandlers[c]&&this.commandHandlers[c].onTextFieldChange)this.commandHandlers[c].onTextFieldChange(a,
4912b)}onRegisterField(a,b){for(var c=0;c<this.commandHandlers.length;c++)if(void 0!==this.commandHandlers[c]&&this.commandHandlers[c].onRegisterField)this.commandHandlers[c].onRegisterField(a,b)}addPressedButton(a,b){}handleKeyPressed(a){}registerkeyDownHandler(a){this.uniqueKeyDownHandlerId+=1;this.keyDownHandlers[this.uniqueKeyDownHandlerId]=a;return this.uniqueKeyDownHandlerId}unregisterkeyDownHandler(a){delete this.keyDownHandlers[a]}handleKeyDown(a){try{if(0>=this.disableShortCutCounter)for(var b=
49130;b<this.keyDownHandlers.length;b++){if(void 0!==this.keyDownHandlers[b]&&this.keyDownHandlers[b].onKeyDown(a)){a.stopEvent();break}}else LOG("KeyHandlers disabled: "+this.disableShortCutCounter,"LogError")}catch(c){LogException("KeyDown="+a.getKey(),c)}return!0}execCommandLine(a){for(var b=0;b<this.commandHandlers.length&&(void 0===this.commandHandlers[b]||!this.commandHandlers[b].execCommandLine||!this.commandHandlers[b].execCommandLine(a));b++);}enableShortCuts(){--this.disableShortCutCounter;
49140>this.disableShortCutCounter&&CBDebug.assert("Shortcut counter");LOG("EnableShortcuts="+this.disableShortCutCounter)}disableShortCuts(){this.disableShortCutCounter+=1;LOG("DisableShortcuts="+this.disableShortCutCounter,"LogError LogBold")}getCurStateChange(){return this.curStateChange}fireChecked(a,b){this.curStateChange={id:a,state:b};this.fireOnChecked()}fireEnabledChanged(a,b){this.curStateChange={id:a,state:b};this.fireOnEnabledChanged()}fireVisibleChanged(a,b){this.curStateChange={id:a,state:b};
4915this.fireOnVisibleChanged()}static initForListeners(){Commands.prototype.fireEvent||(Vk.initForListeners(Commands),Vk.addEvent(Commands,"Checked",function(){return[this.getCurStateChange()]}),Vk.addEvent(Commands,"EnabledChanged",function(){return[this.getCurStateChange()]}),Vk.addEvent(Commands,"VisibleChanged",function(){return[this.getCurStateChange()]}))}}
4916var CommandIds={NONE:0,FLIP_BOARD:1,NEW_GAME:2,TAKEBACK:3,EXECMOVE:4,TOGGLE_ANALYSIS_ENGINE:5,SETUP_POSITION:6,ENGINE_MOVE_NOW:7,TOGGLE_ANALYSIS_AUTO_ENGINE:8,ENGINE_HINT:9,ADD_POST_TEXT:10,ADD_PRE_TEXT:11,PROMOTE_LINE:12,DELETE_LINE:13,CUT_LINE:14,MARK_GOOD:15,MARK_BAD:16,MARK_VERYGOOD:17,MARK_VERYBAD:18,MARK_INTERESTING:19,MARK_DUBIOUS:20,WHITE_WINS:30,WHITE_BETTER:31,WHITE_SLIGHTLY:32,EQUAL:33,UNCLEAR:34,BLACK_WINS:36,BLACK_BETTER:37,BLACK_SLIGHTLY:38,COMPENSATION:35,INSERT_DIAGRAM:39,DELETE_PREVIOUS_MOVES:40,
4917OPEN_PGN_DATABASE:60,OPEN_CMS:63,ENGINE_PLUS_LINE:70,ENGINE_MINUS_LINE:71,ENGINE_THREAT:72,DOWNLOAD_PGN:75,START_LINE:80,PIECES2D_FRITZ:100,PIECES2D_CRYSTALS:101,PIECES2D_CRYSTALS_WOOD:115,PIECES2D_USCF:102,PIECES2D_OLDSTYLE:103,PIECES2D_HABSBURG:104,PIECES2D_WORLDCHESS:105,PIECES2D_BLUE:106,PIECES2D_FF:107,PIECES3D_FRITZ:120,PIECES3D_MODERN:121,PIECES3D_ROOM:122,PIECES3D_BALLOON:123,PIECES3D_METAL:124,PIECES3D_FUTURE:125,PIECES3D_BLACKWHITE:126,PIECES3D_CHARACTER:127,PIECES_LAST:128,TOGGLE_PIECES:140,
4918BOARD2D_WOOD:200,BOARD2D_CRYSTALS:201,BOARD2D_CRYSTALS_WOOD:202,BOARD2D_USCF:203,BOARD2D_OLDWOOD:204,BOARD2D_HABSBURG:205,BOARD2D_FF:206,BOARD2D_WORLDCHESS:207,BOARD2D_BLUE:208,BOARD2D_RED:209,GO_BACK:210,GO_HOME:211,CMS_SOLUTION:212,CMS_TRYAGAIN:213,CMS_PREVIOUS:214,CMS_NEXT:215,PLAYERDB_TEST:231,SEND_FEEDBACK:240,GAME_COPYTOCLIPBOARD:250,GAME_PASTEFROMCLIPBOARD:251,BOARD2D_GRAY:259,SWITCHAPP_PLAY:260,SWITCHAPP_LIVE:261,SWITCHAPP_DATABASE:262,SWITCHAPP_MYGAMES:263,SWITCHAPP_FRITZ:264,SWITCHAPP_FF:265,
4919SWITCHAPP_TACTICS:266,SWITCHAPP_OPENINGS:267,SWITCHAPP_VIDEO:268,SWITCHAPP_NEWS:269,LOGIN:300,LOGOUT:301,CHANGE_PASSWORD:302,MANAGE_ACCOUNT:303,MANAGE_FRIENDS:304,INVITE_FRIEND:305,HELP:306,TOGGLE_HANDICAP:400,LANG_ENGLISH:400,LANG_DEUTSCH:401,LANG_ESPANOL:402,LANG_DUTCH:403,LANG_ROMANIAN:404,LANG_CHINESE:405,LANG_FRENCH:406,LANG_RUSSIAN:407,LANG_NORWEGIAN:408,LANG_POLISH:409,LANG_ITALIAN:410,LANG_HEBREW:411,LANG_CATALAN:412,LANG_TURKISH:413,LANG_SLOWENIAN:414,LANG_GREEK:4
491915,LANG_UKRAINIAN:416,LANG_VIETNAMESE:417,
4920LANG_ARABIC:418,LANG_SERBIAN:419,LANG_LITHUANIAN:420,LANG_PORTUGUESE:421,LANG_FARSI:422,LANG_GAELIC:423,LANG_CROATIAN:424,LANG_CZECH:425,LANG_HINDI:426,TRANSLATE_PAGE:500,TEST:9999,toNumString:function(a){return"CommandId="+a}};"NOMINIFY=glApp,panelMgr,config,getExternalCommonPath";function getCommonPath(){return System.isElectron()?"Common/":"/Common/"}
4921var AppConfigDebug={externalCommonPath:!1,iconPath:"play",getEngineUrl:function(){return glApp.canRunWebAssembly()?(EngineInstance.isAjax=!0,["https://pgn.chessbase.com/common/chess/engine/webasm/fritzajax3.js"]):["/Common/Chess/Engine/df14/df14.js"]},getExternalCommonPath:function(){return System.isElectron()?"file://Common/":"https://pgn.chessbase.com/common/"},getRibbonPath:function(){return getCommonPath()+"Media/Ribbons/"},getPlaychessUris:function(){System.isHTTPS();return["wss://cbridge2.chessbase.com:6008",
4922"wss://cbridge3.chessbase.com:443","wss://cbridge4.chessbase.com:443"]},getLiveUris:function(){return["ws://test.chessbase.com:7003"]},getLiveResult:function(){var a=System.isHTTPS();return[(a?"https":"http")+"://liveserver.chessbase.com:"+(a?6009:80)]},getDBBridgeUris:function(){return System.isHTTPS()?["wss://dbserver.chessbase.com:443"]:["ws://dbserver.chessbase.com:7000"]},getCloudServerUris:function(){return System.isHTTPS()?["wss://cloudserver.chessbase.com:6008"]:["ws://cloudserver.chessbase.com:7000"]},
4923getMyMovesServerUris:function(){return["wss://mymovesserver.chessbase.com:443"]},getTrainingUris:function(){return System.isHTTPS()?["wss://trainingserver.chessbase.com:443"]:["ws://trainingserver.chessbase.com:7000","wss://trainingserver.chessbase.com:6008"]},getRemoteUris:function(){return System.isHTTPS()?["wss://trainingserver.chessbase.com:443"]:["ws://trainingserver.chessbase.com:7000","wss://trainingserver.chessbase.com:6008"]},getPlBridgeUris:function(){let a=["ws://pbridge.chessbase.com:7000",
4924"ws://pbridge2.chessbase.com:7000"];System.isHTTPS()&&(a=["wss://pbridge.chessbase.com:443","wss://pbridge2.chessbase.com:443"]);if(.5<Math.random()){let b=a[1];a[1]=a[0];a[0]=b}return a},getTbBridgeUris:function(){return System.isHTTPS()?["wss://tbridge.chessbase.com:443","wss://tbridge2.chessbase.com:443"]:["ws://tbridge2.chessbase.com:7000","ws://tbridge.chessbase.com:7000"]},getAccountUris:function(){return System.isHTTPS()?["https://users.chessbase.com","https://usersback.chessbase.com"]:["http://users.chessbase.com",
4925"http://usersback.chessbase.com"]},getVideoPortalUris:function(){System.isHTTPS();return["https://videos.chessbase.com/"]},studiesServerUrl:"https://studies.chessbase.com",loginWebUrl:"http://account.chessbase.com",createAccountWebUrl:"https://play.chessbase.com/createAccount",createAccountWebUrl2:"https://play.chessbase.com/createAccount",resetPasswordWebUrl:"http://account.chessbase.com/en/pwd-recovery",resetPasswordWebUrl2:"http://account.chessbase.com/{0}/pwd-recovery",versionChessBaseCom:!1,
4926editAccountUrl:"https://play.chessbase.com/{0}/me",helpUrl:"http://help.chessbase.com/Apps/{0}/index.html",getFlagPath:function(a){return getCommonPath()+"Media/FlagsIso/"+a+"/"},has3DBoard:!1,board2DTopOffset:0,board2DBottomOffset:0,useAnalysisEngines:!0,debug:!0,jqxTheme:"chessbase",defaultFont:"Roboto, sans serif",defaultCondensedFont:"Roboto Condensed, Arial Narrow, sans serif",boardBG:getCommonPath()+"Media/Chess/OrangeBrighterSoftBacklightLessSatur.jpg",imgSuffix:"",clrActiveClock:new CBColor(220,
4927250,190),bgActiveClock:"hsla( 240, 20%, 10%, 1.0 )"},AppConfigRelease=ObjUtil.copyTo(AppConfigDebug,{release:!0,loginWebUrl:"http://account.chessbase.com",getEngineUrl:function(){return glApp.canRunWebAssembly()?(EngineInstance.isAjax=!0,["https://pgn.chessbase.com/common/chess/engine/webasm/fritzajax3.js"]):["/Common/Chess/Engine/df14/df14.js"]},getExternalCommonPath:function(){return System.isElectron()?"file://Common/":"https://pgn.chessbase.com/common/"},getPlaychessUris:function(){return System.isHTTPS()?
4928["wss://playserver.chessbase.com:443"]:["ws://playserver.chessbase.com:7000"]},getMyMovesServerUris:function(){return System.isHTTPS()?["wss://mymovesserver.chessbase.com:443"]:["ws://mymovesserver.chessbase.com:7001"]},getTrainingUris:function(){return System.isHTTPS()?["wss://trainingserver2.chessbase.com:443","wss://trainingserver.chessbase.com:6008"]:["wss://trainingserver2.chessbase.com:443","wss://trainingserver.chessbase.com:6008","ws://trainingserver2.chessbase.com:7000"]},getRemoteUris:function(){return System.isHTTPS()?
4929["wss://raytrace.chessbase.com:6008"]:["ws://raytrace.chessbase.com:7003","wss://raytrace.chessbase.com:6008"]},getDBBridgeUris:function(){return System.isHTTPS()?["wss://dbserver.chessbase.com:443"]:["ws://dbserver.chessbase.com:7000"]},getCloudServerUris:function(){return System.isHTTPS()?["wss://cloudserver.chessbase.com:6008"]:["ws://cloudserver.chessbase.com:7000"]},getAccountUris:function(){return System.isHTTPS()?["https://users.chessbase.com"]:["http://users.chessbase.com"]},getLiveUris:function(){return["wss://liveserver.chessbase.com:6008"]},
4930getLiveResult:function(){var a=System.isHTTPS();return[(a?"https":"http")+"://liveserver.chessbase.com:"+(a?6009:80)]},createAccountWebUrl:"https://account.chessbase.com/en/create-account",createAccountWebUrl2:"https://account.chessbase.com/{0}/create-account",resetPasswordWebUrl:"http://account.chessbase.com/en/pwd-recovery",resetPasswordWebUrl2:"http://account.chessbase.com/{0}/pwd-recovery",editAccountUrl:"https://play.chessbase.com/{0}/me",debug:!1},!0);
4931const V1d=function(){var a=function(){initArrayUtil();this.initForListeners();void 0===this.config&&(this.config=AppConfigRelease);this.mediaPath=getCommonPath()+"Media/";this.mediaPathChess=this.mediaPath+"Chess/";this.mediaPathFlags="https://pgn.chessbase.com/common/media/Flags/";this.minFPS=16;document.onmousemove=this.resetIdle.bind(this);document.onkeypress=this.resetIdle.bind(this);this.idleTimer=new Timer;this.lastActionTick=new Tick;this.loggedIn=!1;this.appName=this.appTitle="ChessBase App";
4932this.acc={name:"Free",type:0};window.localforage&&localforage.config({driver:localforage.INDEXEDDB,name:"ChessBase",version:1,storeName:"CBCache"})};a.prototype.initInstance=function(){this.commands=new Commands;setGlobaSettings(new GlobalSettings);this._initResources();this.idleTimer.runPeriodic(6E4,this.onIdle.bind(this));this.extendCommandIds(CommandIds,this.getAppSpecificCommandIds());this.commandHandlerId=this.commands.registerCommandHandler(this);this.detLanguage();System.isMobile()||glApp.initToolTips();
4933window.onerror=function(c,d,e,f,g){if(-1!=c.search(/ResizeObserver/i))console.log("ResizeObserver shit");else{var h="Main";0<=d.search("df14")&&(h="Engine");0<=d.search("enginemin")&&(h="EngineMin");d=String.formatEx("line={0}, col={1}, typ={2}",e,f,h);
4933g&&g.stack&&(d+="/"+g.stack);LogException(c,d);LogExceptionRemote(c,d);"Engine"==g&&glApp&&glApp.panelMgr&&glApp.panelMgr.showMessage("Sorry, cannot load the engine, please use the Chrome Browser or Firefox")}};this.initAnalytics()};a.prototype.getAppSpecificCommandIds=
4934function(){console.log("getAppCommandIds")};a.prototype.exitInstance=function(){glSettings.destroy()};a.prototype.detLanguage=function(){this.setLanguageFromUrlParam()};a.prototype.setLanguageFromUrlParam=function(){var c=StrUtil.getURLParam("lang");c&&(c=Language.getLanguageIdOfParam(c),glSettings.languageCommandId=glSettings.getCommandIdOfLanguage(c));"undefined"!=typeof glSettings.languageCommandId?glSettings.changeLanguage(glSettings.languageCommandId):this.changeLanguage(Language.getUserLanguageId())};
4935a.prototype.overrideLanguageFromPlugin=function(c){if(c=this.getPluginLanguage(c)){var d=Language.getLanguageIdOfParam(c);glSettings.languageCommandId=glSettings.getCommandIdOfLanguage(d);return c}};a.prototype.getPluginLanguage=function(c){c=$(c);if(c.length)return c[0].dataset.language};a.prototype.initAnalytics=function(){"undefined"!==typeof ga&&System.V3()&&ga("set","anonymizeIp",!0)};a.prototype.isBoardOnlyApp=function(){return!1};a.prototype.getLoginUrl=function(){return this.config.loginWebUrl};
4936a.prototype.getManageAccountUrl=function(){return this.config.loginWebUrl+"en/me"};a.prototype._initResources=function(){glSettings.boardTextureId||(glSettings.boardTextureId=this.getDefaultBoardCmdId());var c=glSettings.boardTextureId;glSettings.boardTextureId=void 0;this.setBoardTextures(c);this.config.delayAudioInit||(this.chessAudio=new ChessAudio(glApp.config.getExternalCommonPath()+"Media/Sounds/",!0))};a.prototype.getDefaultBoardCmdId=function(){return CommandIds.BOARD2D_WOOD};a.prototype.setBoardTextures=
4937function(c){this.Vh&&this.Vh.destroy();if(glSettings.boardTextureId!=c)switch(c){default:c=CommandIds.BOARD2D_WOOD;case CommandIds.BOARD2D_WOOD:case CommandIds.BOARD2D_CRYSTALS_WOOD:case CommandIds.BOARD2D_USCF:case CommandIds.BOARD2D_OLDWOOD:this.Vh=new BoardTextures(this.mediaPathChess+"LightSquaresCoolerBrighterSofter.jpg",this.mediaPathChess+"DarkSquaresLessSatur.png",this.mediaPathChess+"MarginBrighter.jpg",this.mediaPathChess+"OrangeBrighterSoftBacklightLessSatur.jpg","hsl( 46, 70%, 80% )",
4938"black");break;case CommandIds.BOARD2D_CRYSTALS:this.Vh=new BoardTextures(this.mediaPathChess+"WhiteMarbleCut.jpg",this.mediaPathChess+"GreyMarble.jpg",this.mediaPathChess+"DarkMarginCut.jpg",this.mediaPathChess+"WhiteMarbleBack.jpg");break;case CommandIds.BOARD2D_HABSBURG:this.Vh=new BoardTextures(this.mediaPathChess+"LightSquaresCooler.png",this.mediaPathChess+"DarkSquaresOrange.png",this.mediaPathChess+"MarginBrighter.jpg",this.mediaPathChess+"OrangeBrighterSoftBacklight.jpg");break;case CommandIds.BOARD2D_FF:this.Vh=
4939new BoardTextures(this.mediaPathChess+"LightSquaresFFTan.jpg",this.mediaPathChess+"DarkSquaresFFTan.jpg",this.mediaPathChess+"MarginFFTan2.jpg",this.mediaPathChess+"Backgroun
4939dFFBlue.jpg");break;case CommandIds.BOARD2D_WORLDCHESS:this.Vh=new BoardTextures(this.mediaPathChess+"WorldChessLightSquares.jpg",this.mediaPathChess+"WorldChessDarkSquares.jpg",this.mediaPathChess+"WorldChessDarkSquares.jpg",this.mediaPathChess+"WorldChessBackground.jpg","white","white");break;case CommandIds.BOARD2D_BLUE:this.Vh=
4940new BoardTextures(this.mediaPathChess+"BlueLightSquares.jpg",this.mediaPathChess+"BlueDarkSquares.jpg",this.mediaPathChess+"BlueDarkSquares.jpg",this.mediaPathChess+"BlueBackground.jpg","white","white");break;case CommandIds.BOARD2D_RED:this.Vh=new BoardTextures(this.mediaPathChess+"RedLightSquares.jpg",this.mediaPathChess+"RedDarkSquares.jpg",this.mediaPathChess+"RedMargin.jpg",this.mediaPathChess+"RedBackground.jpg","white","white");break;case CommandIds.BOARD2D_GRAY:this.Vh=new BoardTextures(this.mediaPathChess+
4941"GreyLightSquares.jpg",this.mediaPathChess+"GreyDarkSquares.jpg",this.mediaPathChess+"GreyDarkSquares.jpg",this.mediaPathChess+"BlueBackground.jpg","white","white")}glSettings.boardTextureId=c};a.prototype.boardMenuBtn=function(c){return glApp.config.has3DBoard?ToolButtons.menuBtn(c,lm.BOARDS,"Board2DSquares",[lm.BOARD_FRITZ,lm.BOARD_CRYSTALS,lm.BOARD_CRYSTALS+" (Wood)",lm.BOARD_USCF,lm.BOARD_OLDSTYLE,lm.BOARD_HABSBURG,"-",lm.BOARD3D_FRITZ,lm.BOARD3D_MODERN,lm.BOARD3D_ROOM,lm.BOARD3D_BALLOON,lm.BOARD3D_METAL,
4942lm.BOARD3D_FUTURE,lm.BOARD3D_BLACKWHITE],"wQFritz16 wQCrystals16 wQCrystals16 wQUSCF16 wQOldstyle16 wQHabsburg16  Fritz16 Modern16 Room16 Balloon16 Metal16 Future16 BlackWhite16".split(" "),[CommandIds.PIECES2D_FRITZ,CommandIds.PIECES2D_CRYSTALS,CommandIds.PIECES2D_CRYSTALS_WOOD,CommandIds.PIECES2D_USCF,CommandIds.PIECES2D_OLDSTYLE,CommandIds.PIECES2D_HABSBURG,null,CommandIds.PIECES3D_FRITZ,CommandIds.PIECES3D_MODERN,CommandIds.PIECES3D_ROOM,CommandIds.PIECES3D_BALLOON,CommandIds.PIECES3D_METAL,CommandIds.PIECES3D_FUTURE,
4943CommandIds.PIECES3D_BLACKWHITE],void 0,"",CBWeight(8)):ToolButtons.menuBtn(c,lm.BOARDS,"Board2DSquares",[lm.BOARD_FRITZ,lm.BOARD_CRYSTALS,lm.BOARD_CRYSTALS+"(Wood)",lm.BOARD_USCF,lm.BOARD_OLDSTYLE,lm.BOARD_HABSBURG],"wQFritz16 wQCrystals16 wQCrystals16 wQUSCF16 wQOldstyle16 wQHabsburg16".split(" "),[CommandIds.PIECES2D_FRITZ,CommandIds.PIECES2D_CRYSTALS,CommandIds.PIECES2D_CRYSTALS_WOOD,CommandIds.PIECES2D_USCF,CommandIds.PIECES2D_OLDSTYLE,CommandIds.PIECES2D_HABSBURG],void 0,"",CBWeight(12))};a.prototype.switchAppMenuBtn=
4944function(c){return!System.isMobile()||1E3<window.innerWidth||1E3<window.innerHeight?ToolButtons.menuBtn(c,lm.OTHER_TOOLS,"SwitchApp",[lm.MENU_PLAYCHESS_TOOL,"Live Chess",lm.MENU_TACTICS_TOOL,lm.MENU_VIDEO_TOOL,lm.MENU_FRITZ_TOOL,lm.MENU_OPENINGS_TOOL,lm.MENU_DATABASE_TOOL,lm.MENU_MYGAMES_TOOL,lm.MENU_FRITZ_CHESSTER_TOOL,"News"],"WebAppPlay16 WebAppLive16 WebAppTactics16 WebAppVideos16 WebAppFritz16 WebAppOpenings16 WebAppDatabase16 WebAppMyGames16 WebAppFF16 WebAppNews16".split(" "),[CommandIds.SWITCHAPP_PLAY,
4945CommandIds.SWITCHAPP_LIVE,CommandIds.SWITCHAPP_TACTICS,CommandIds.SWITCHAPP_VIDEO,CommandIds.SWITCHAPP_FRITZ,CommandIds.SWITCHAPP_OPENINGS,CommandIds.SWITCHAPP_DATABASE,CommandIds.SWITCHAPP_MYGAMES,CommandIds.SWITCHAPP_FF,CommandIds.SWITCHAPP_NEWS],void 0,"",CBWeight(1)):ToolButtons.menuBtn(c,lm.OTHER_TOOLS,"SwitchApp",[lm.MENU_PLAYCHESS_TOOL,lm.MENU_TACTICS_TOOL,lm.MENU_DATABASE_TOOL,lm.MENU_OPENINGS_TOOL,lm.MENU_VIDEO_TOOL,lm.MENU_FRITZ_TOOL],"WebAppPlay16 WebAppTactics16 WebAppDatabase16 WebAppOpenings16 WebAppVideos16 WebAppFritz16".split(" "),
4946[CommandIds.SWITCHAPP_PLAY,CommandIds.SWITCHAPP_TACTICS,CommandIds.SWITCHAPP_DATABASE,CommandIds.SWITCHAPP_OPENINGS,CommandIds.SWITCHAPP_VIDEO,CommandIds.SWITCHAPP_FRITZ],void 0,"",CBWeight(1))};a.prototype.loginMenuBtn=function(c){return ToolButtons.menuBtn(c,lm.LOGIN,"Login",[lm.LOGIN,lm.LOGOUT,lm.CHANGE_PASSWORD,lm.ACCOUNT,lm.INVITE_FRIEND],["Login16","Logout16","ChangePassword16","Account16","MailGames16"],[CommandIds.LOGIN,CommandIds.LOGOUT,CommandIds.CHANGE_PASSWORD,CommandIds.MANAGE_ACCOUNT,
4947CommandIds.INVITE_FRIEND],void 0,"",CBWeight(16))};a.prototype.getAvailableLanguages=function(){return[Language.ENG,Language.DEU,Language.ESP,Language.NED,Language.ROM,Language.CHN,Language.FRA,Language.RUS,Language.NOR,Language.POL,Language.ITA,Language.HEB,Language.CAT,Language.TRK,Language.SLO,Language.GRK,Language.UKR,Language.VIE,Language.ARA,Language.SER,Language.LIT,Language.BRA,Language.FAR,Language.GAL,Language.CRO,Language.CZE,Language.HIN]};a.prototype.languageBtn=function(c){var d=this.getAvailableLanguages(),
4948e=Language.getNativeLangNames(d);e.push("Your Language Here!");var f=Language.getFlagNames(d);f.push(Language.getRibbonFlagName(Language.UN));d=glSettings.getLanguageCommandIds(d);d.push(CommandIds.TRANSLATE_PAGE);c=ToolButtons.menuBtn(c,lm.LANGUAGE,"",e,f,d,void 0,"",CBWeight(14),!0);glSettings.languageBtn=c;glSettings.languageCommandId?glSettings.changeLangButtonFlag(glSettings.languageCommandId):c.changeFlagIcon(Language.getRibbonFlagName(Language.getUserLanguageId()));return c};a.prototype.getLocalizationArr=
4949function(c){var d=[];Loc.Playchess&&Loc.Playchess[c]&&d.push(Loc.Playchess[c]);Loc.Chess[c]?(LOG("Chess.Localization="+c+" ok","","loc"),d.push(Loc.Chess[c])):LOG("Chess.Localization="+c+" not found");LOG("locArr for "+c+"="+d.join(","),"","loc");return d};a.prototype.changeLanguage=function(c){var d=this.getLocalizationArr("ENG");(c=this.getLocalizationArr(Language.getInternalName(c)))&&(d=d.concat(c));setGlobalLoc(new Localization(d))};a.prototype.resetIdle=function(){this.lastActionTick.start()};
4950a.prototype.isIdle=function(){return 12E4<this.lastActionTick.getExpiredMS()};a.prototype.allowMoveEntryDialog=function(){return!1};var b=!1;a.prototype.onIdle=function(){this.isIdle()?(this.idleFunc&&this.idleFunc(),b=!0):(b&&this.notIdleFunc&&this.notIdleFunc(),b=!1)};a.prototype.initToolTips=function(){"undefined"!==typeof Ext&&Ext.QuickTips.init()};a.prototype.getCommandIdFromVersionCode=function(){var c=0;switch(glApp.versionCode.nFamily){case VersionCodeEnum.JSPLAYCHESS:c=glApp.Vy.SWITCHAPP_PLAY;
4951break;case VersionCodeEnum.JSREADER:c=glApp.Vy.SWITCHAPP_LIVE;break;case VersionCodeEnum.JSCBONLINE:c=glApp.Vy.SWITCHAPP_DATABASE;break;case VersionCodeEnum.JSPREMIUM:c=glApp.Vy.SWITCHAPP_PLAY;break;case VersionCodeEnum.JSFRITZ:c=glApp.Vy.SWITCHAPP_FRITZ;break;case VersionCodeEnum.JSMYGAMES:c=glApp.Vy.SWITCHAPP_MYGAMES;break;case VersionCodeEnum.JSTRAINING:c=glApp.Vy.SWITCHAPP_TACTICS;break;case VersionCodeEnum.JSOPENINGS:c=glApp.Vy.SWITCHAPP_OPENINGS}return c};a.prototype.getAppUrl=function(c){var d=
4952"http://www.chessbase.com";switch(c){case glApp.Vy.SWITCHAPP_PLAY:d="http://play.chessbase.com";break;case glApp.Vy.SWITCHAPP_LIVE:d="http://live.chessbase.com";break;case glApp.Vy.SWITCHAPP_TACTICS:d="http://tactics.chessbase.com";break;case glApp.Vy.SWITCHAPP_DATABASE:d="https://database.chessbase.com";break;case glApp.Vy.SWITCHAPP_MYGAMES:d="http://mygames.chessbase.com";break;case glApp.Vy.SWITCHAPP_OPENINGS:d="http://mymoves.chessbase.com";break;case glApp.Vy.SWITCHAPP_FRITZ:d="http://fritz.chessbase.com";
4953break;case glApp.Vy.SWITCHAPP_VIDEO:d="http://videos.chessbase.com";break;case glApp.Vy.SWITCHAPP_FF:d=Language.getUserLanguageId()==Language.DEU?"http://fritzundfertig.chessbase.com":"http://fritzandchesster.chessbase.com";break;case glApp.Vy.SWITCHAPP_NEWS:d=Language.getUserLanguageId()==Language.DEU?"http://de.chessbase.com":"http://en.chessbase.com"}return d};a.prototype.execCommand=function(c){try{var d=!0;switch(c){default:d=!1;break;case void 0:break;case glApp.Vy.SWITCHAPP_PLAY:case glApp.Vy.SWITCHAPP_LIVE:case glApp.Vy.SWITCHAPP_DATABASE:case glApp.Vy.SWITCHAPP_MYGAMES:case glApp.Vy.SWITCHAPP_FRITZ:case glApp.Vy.SWITCHAPP_FF:case glApp.Vy.SWITCHAPP_TACTICS:case glApp.Vy.SWITCHAPP_OPENINGS:case glApp.Vy.SWITCHAPP_VIDEO:case glApp.Vy.SWITCHAPP_NEWS:var e=
4954this.getAppUrl(c);break;case glApp.Vy.LOGOUT:this.setLoggedIn(!1);break;case CommandIds.CHANGE_PASSWORD:this.changePassword();break;case CommandIds.MANAGE_ACCOUNT:e=String.formatEx(this.config.editAccountUrl,Language.getParamOfLanguageId(glSettings.getLanguageId()));break;case CommandIds.MANAGE_FRIENDS:this.manageFriends();break;case CommandIds.INVITE_FRIEND:this.inviteFriend();break;case CommandIds.HELP:this.openHelp()}e&&(window.location=e+"?ref="+this.appName+"&lang="+Language.getParamOfLanguageId(glSettings.getLanguageId()))}catch(f){c=
4955glApp.Vy.toNumString(c),LogException(c,f)}return d};a.prototype.extendCommandIds=function(c,d){if(d){for(var e in c)c.hasOwnProperty(e)&&void 0===d[e]&&(d[e]=c[e]);this.Vy=d}};a.prototype.setLoggedIn=function(c){this.loggedIn=c;c||(glApp.Vn.loginToken="",glApp.Vn.loginMode=LoginMode.GUEST,DOM.clearCookie("AccountToken"),DOM.clearCookie("AccountMode"),glApp.Vn.clearCBCommonCookie());LOG("LoggedIN = "+c,"","acc");c||glApp.showAccountType(0);this.fireOnLogin(c)};a.prototype.changePassword=function(){};
4956a.prototype.changePasswordHandler=function(c,d){LOG(c+"/"+d);(new AccountsManager(glApp.shortAppName)).changePassword(glApp.Vn.userName,c,d,glApp.Vn.loginToken,this.changePWOkHandler)};a.prototype.changePWOkHandler=function(c){LOG(c);c&&1==c.ResultType?alert("Password changed."):alert("Could not change password")};a.prototype.hasUserName=function(){var c=DOM.getAccountNameCookie(!0)||glApp.Vn.userName;return 0<c.length&&"guest"!=c};a.prototype.manageFriends=function(){(new AccountsManager(glApp.shortAppName)).getFriends(glApp.Vn.userName,
4957glApp.Vn.loginToken,"0",this.getFriendsOkHandler)};a.prototype.getFriendsOkHandler=function(c){LOG(c);c&&"OK"==c.Result&&new AccountsManager(glApp.shortAppName)};a.prototype.setFriends=function(c,d){c.setFriends(glApp.Vn.userName,glApp.Vn.loginToken,"0",d,a.prototype.setFriendsOkHandler)};a.prototype.setFriendsOkHandler=function(c){LOG(c)};a.prototype.inviteFriend=function(){var c=this.getCommandIdFromVersionCode(glApp.versionCode.nFamily);c=a.prototype.getAppUrl(c);c="mailto:%20&subject="+escape(this.shortAppName)+
4958"&body="+escape("Join me using "+this.appName+" "+c);window.location.href=c};a.prototype.showAdvertising=function(){};a.prototype.openHelp=function(){var c=String.formatEx(this.config.helpUrl,Language.getHelpParamOfLanguageId(glSettings.getLanguageId()));window.open(c,"_blank")};a.prototype.getAccountType=function(){return this.acc&&this.acc.type?this.acc.type:0};a.prototype.isPremium=function(){return 3<=this.getAccountType()};a.prototype.isLoggedIn=function(){return 2<=this.getAccountType()};a.prototype.animatedBoard=
4959function(){return!0};a.prototype.isExtJS=function(){return"undefined"!=typeof Ext};a.prototype.allowMoveEntryDialog=function(){return this.isExtJS()};a.prototype.forceGuestLogon=function(){return System.runsInIFrame()||glApp.Vn.noRibbons()};a.prototype.showAccountType=function(c){this.acc={name:"Free",type:c};switch(c){case 0:case 1:this.acc.name="Free";break;case 2:this.acc.name="Standard";break;case 3:this.acc.name="Premium"}this.fireOnAccountType(this.acc)};a.prototype.passToFritzOnline=function(c){glApp.saveGameToLocalStorage();
4960var d=ObjUtil.clone(c);d.deleteRemaining();d.unAnnotate();d=PGNWriter.toUrlPGN(d);c=2E3<d.length?"?fen="+c.getCurPos().toFEN():"?pgn="+d;window.location="http://fritz.chessbase.com"+c+"&ref=pgn"};a.prototype.saveGameToLocalStorage=function(c){if(this.panelMgr.getKernel&&this.panelMgr.getKernel()&&PGNWriter){var d=this.panelMgr.getKernel().game,e=PGNWriter.toPGN(d),f=encodeURI(e);if(3900<f.length||c)c=ObjUtil.clone2(d),c.removeAllListeners(),c.unAnnotate(),e=PGNWriter.toPGN(c);f=encodeURI(e);3900>
4961f.length&&(DOM.setCookie("CBLastGame",e),DOM.setCookie("CBLastMoveIndex",d.getMoveIndex()),d.replaceGameNo&&(DOM.setCookie("CBLastGameNo",d.replaceGameNo),DOM.setCookie("CBLastGameDBId",d.replaceDBId)));glApp.Vn.save("CBLastGame",e)}};a.prototype.loadGameFromLocalStorage=function(){if((!glApp.urlParams||!(glApp.urlParams.pgn||glApp.urlParams.buf64||glApp.urlParams.pos||glApp.urlParams.fen))&&this.panelMgr.getKernel&&this.panelMgr.getKernel()&&PGN){var c=DOM.getCookie("CBLastGame"),d="",e="";c?(d=
4962DOM.getCookie("CBLastGameNo"),e=DOM.getCookie("CBLastGameDBId")):c=glApp.Vn.load("CBLastGame");if(c)return c=PGN.parseGame(c),"My Moves"!=c.hdr.white.last&&(d&&e&&(c.replaceGameNo=parseInt(d),c.replaceDBId=parseInt(e)),c.getCurPos().isLegal()&&(this.panelMgr.getKernel().game.assign(c),(d=DOM.getCookie("CBLastMoveIndex"))&&this.panelMgr.getKernel().game.gotoIndex(parseInt(d)))),0<c.getMoveCount()}};a.prototype.tryLogin=function(c){glApp.Vn.userName=DOM.getAccountNameCookie(!0)||glApp.Vn.userName;glApp.Vn.loginToken=
4963DOM.getCookie("AccountToken");if(glApp.Vn.loginToken&&glApp.Vn.userName&&"guest"!=glApp.Vn.userName)return(new AccountsManager(glApp.shortAppName)).tokenLogin(glApp.Vn.userName,glApp.Vn.loginToken,c),!0;glApp.Vn.clearCBCommonCookie();5;return!1};a.prototype.tryUserPassLogin=function(c){return glApp.Vn.hasUserAndPass()?((new AccountsManager(glApp.shortAppName)).pwLogin(glApp.Vn.userName,glApp.Vn.password,c),!0):!1};a.prototype.debugLogin=function(){5};a.prototype.connectPlayerLobby=function(c){glApp.playerLobby=
4964new ServerPlayerLobby;glApp.playerLobby.create(glApp.config.getPlBridgeUris(),"Guest","",LoginMode.GUEST);c&&glApp.playerLobby.connect()};a.prototype.logOffPlayerLobby=function(){glApp.playerLobby&&glApp.playerLobby.logOff()};a.prototype.connectTeraBrainLobby=function(){glApp.aTBLobby&&glApp.aTBLobby.isConnected()||(glApp.aTBLobby=new ServerTeraBrainLobby,glApp.aTBLobby.create(glApp.config.getTbBridgeUris(),"Guest","",LoginMode.GUEST),glApp.aTBLobby.connect())};a.prototype.logOffTeraBrainLobby=function(){glApp.aTBLobby&&
4965glApp.aTBLobby.logOff()};a.prototype.connectOnlineDBLobby=function(c){glApp.onlineLobby=new OnlineLobby;glApp.onlineLobby.createLobby(glApp.config.getDBBridgeUris(),"Guest","",LoginMode.GUEST);c&&glApp.onlineLobby.connect()};a.prototype.logOffOnlineLobby=function(){glApp.onlineLobby&&glApp.onlineLobby.logOff()};a.prototype.setExternalCommonPath=function(c){getCommonPath=function(){return System.isElectron()?"Common/":"https://pgn.chessbase.com/common/"};this.config.externalCommonPath=!0;this.mediaPath=
4966getCommonPath()+"Media/";this.mediaPathChess=this.mediaPath+"Chess/";c.engine&&(c=System.getIEVersion(),EngineInstance.isAjax=12<=c||!c,this.config.getEngineUrl=function(){return EngineInstance.isAjax&&!System.isElectron()?System.canRunWebAssembly()?["https://pgn.chessbase.com/Common/Chess/Engine/WebAsm/FritzAjax3.js"]:["https://pgn.chessbase.com/Common/Chess/Engine/df14/df14ajaxdata.js"]:System.canRunWebAssembly()?["/Common/Chess/Engine/WebAsm/Fritz.js"]:["/Common/Chess/Engine/df14/df14.js"]})};
4967a.prototype.getUserFromUrl=function(){var c=StrUtil.getURLParam("user"),d=StrUtil.getURLParam("pass");return c.length&&d.length?(glApp.Vn.userCoded=c,c=StrUtil.base64.decode(c),d=StrUtil.base64.decode(d),c=StrUtil.htmlDecode(c),glApp.Vn.userName=c,glApp.Vn.password=d,glApp.Vn.loginMode=LoginMode.NORMAL,!0):!1};a.prototype.isPlugin=function(){return!1};a.prototype.canRunWebAssembly=function(){return System.canRunWebAssembly()};a.prototype.initForListeners=function(){a.prototype.fireEvent||(Vk.initForListeners(a),
4968Vk.addEvent(a,"Login"),Vk.addEvent(a,"AccountType"))};return a}();let glApp;function setGlobalApp(a){glApp=a;window.glApp=glApp}function getGlobalApp(){return glApp}var PieceFonts={};
4968PieceFonts[CommandIds.PIECES2D_FRITZ]="DiagramTTFritz";PieceFonts[CommandIds.PIECES2D_CRYSTALS]="DiagramTTCrystals";PieceFonts[CommandIds.PIECES2D_CRYSTALS_WOOD]="DiagramTTCrystals";PieceFonts[CommandIds.PIECES2D_USCF]="DiagramTTUSCF";PieceFonts[CommandIds.PIECES2D_OLDSTYLE]="DiagramTTOldstyle";
4969PieceFonts[CommandIds.PIECES2D_HABSBURG]="DiagramTTHabsburg";PieceFonts[CommandIds.PIECES2D_WORLDCHESS]="DiagramTTWorldChess";PieceFonts[CommandIds.PIECES2D_BLUE]="DiagramTTFritz";PieceFonts[CommandIds.PIECES2D_FF]="DiagramTTFF";PieceFonts[CommandIds.PIECES3D_FRITZ]="Fritz";PieceFonts[CommandIds.PIECES3D_MODERN]="Modern";PieceFonts[CommandIds.PIECES3D_ROOM]="Room";PieceFonts[CommandIds.PIECES3D_BALLOON]="Balloon";PieceFonts[CommandIds.PIECES3D_METAL]="Metal";
4970PieceFonts[CommandIds.PIECES3D_FUTURE]="Future";PieceFonts[CommandIds.PIECES3D_BLACKWHITE]="BlackWhite";PieceFonts[CommandIds.PIECES3D_CHARACTER]="Character";
4971function buildOldBrowserLandingPage(){LogBrowser("Old");DOM.add("www.playchess.com","h1","NonMobiH1");DOM.add("Play chess and kibitz grand master games","h3","NonMobiH3");DOM.addBr();DOM.add("We are sorry, your browser needs an update.","","NonMobiBody");DOM.add("Please install the latest version.","","NonMobiBody");DOM.addBr();DOM.add("We recommend using Chrome or Firefox. Thank you!","","NonMobiBody");DOM.addBr();DOM.addBr();DOM.addUrl("http://www.playchess.com","www.playchess.com","NonMobiLink");
4972DOM.addBr();DOM.addBr();DOM.addBr();DOM.addBr();DOM.addBr();DOM.addBr();DOM.addBr();DOM.addBr();navigator.userAgent&&DOM.add(navigator.userAgent,"","NonMobiBody")}function LogExceptionRemote(a,b){window.remoteLogUrl&&$.ajax(window.remoteLogUrl,{method:"POST",data:JSON.stringify({message:a,stack:b}),contentType:"application/json",dataType:"json",crossDomain:!0})}function LogStats(a){"undefined"!==typeof ga&&System.V3()&&ga("send","event","Stats",a)}
4973function padInt(a,b){a="000000000"+a;return a.substr(a.length-b)}function LogReplayed(a,b){"undefined"!==typeof ga&&System.V3()&&ga("send","event","Replayed",a,"",padInt(b,6))}function LogNoContact(){"undefined"!==typeof ga&&System.V3()&&ga("send","event","NoContact",glApp.versionCode.toString())}function LogBrowser(a){5;"undefined"!==typeof ga&&System.V3()&&ga("send","event","Browser",a)}function LogConnection(a){5;"undefined"!==typeof ga&&System.V3()&&ga("send","event","Connect",a)}
4974function LogVersion(){if("undefined"!==typeof ga&&System.V3()&&(ga("send","event","Version",glApp.versionCode.toString()),glSettings&&"undefined"!=typeof glSettings.languageCommandId)){var a=glSettings.V2(glSettings.languageCommandId);ga("send","event","Lang",Language.getParamOfLanguageId(a))}}function LogConversion(a){"undefined"!==typeof ga&&System.V3()&&ga("send","pageview","Goal/"+a)}function LogPage(a){"undefined"!==typeof ga&&System.V3()&&ga("send","pageview",a)}
4975function SendEvent(a,b,c){"undefined"!==typeof ga&&System.V3()&&ga("send","event",a,b,c)}function PostSpiegelEvent(){}"use strict";
4976class GlobalSettings{constructor(){GlobalSettings.initForListeners();this.commandHandlerId=glApp.commands.registerCommandHandler(this);this.keyDownHandlerId=glApp.commands.registerkeyDownHandler(this);this.boardTextureId=glApp.config.defaultBoardTextureId||CommandIds.BOARD2D_WOOD;this.pieceStyleId=CommandIds.PIECES2D_FRITZ;this.pieceStyleId3D=CommandIds.PIECES3D_FRITZ;this.load();glApp.config.forceBoardTextureId&&(this.pieceStyleId=glApp.config.forcePieceStyleId,this.boardTextureId=glApp.config.forceBoardTextureId);
4977this.pieceFontName=PieceFonts[this.pieceStyleId];this.b3dSelected=!1}destroy(){glApp.commands.unregisterCommandHandler(this.commandHandlerId);glApp.commands.unregisterkeyDownHandler(this.keyDownHandlerId);this.save()}save(){var a=new CBStorage;a.save("pieceStyleId",this.pieceStyleId);a.save("boardTextureId",this.boardTextureId);a.save("pieceStyleId3D",this.pieceStyleId3D);a.save("langCommandId",this.languageCommandId)}load(){var a=new CBStorage;this.pieceStyleId=a.load("pieceStyleId");this.pieceStyleId3D=
4978a.load("pieceStyleId3D");this.boardTextureId=a.load("boardTextureId");this.languageCommandId=a.load("langCommandId");this.pieceFontName=PieceFonts[this.pieceStyleId]}isBlueBoard(){return this.boardTextureId==CommandIds.BOARD2D_BLUE}isRedBoard(){return this.boardTextureId==CommandIds.BOARD2D_RED}sendFeedback(a,b){(new FeedbackManager).send(a,b)}static boardGate=new V10;execCommand(a){try{switch(a){case CommandIds.SEND_FEEDBACK:glSettings.inDialog();break;case CommandIds.LANG_ENGLISH:case CommandIds.LANG_DEUTSCH:case CommandIds.LANG_ESPANOL:case CommandIds.LANG_DUTCH:case CommandIds.LANG_ROMANIAN:case CommandIds.LANG_CHINESE:case CommandIds.LANG_FRENCH:case CommandIds.LANG_RUSSIAN:case CommandIds.LANG_NORWEGIAN:case CommandIds.LANG_POLISH:case CommandIds.LANG_ITALIAN:case CommandIds.LANG_HEBREW:case CommandIds.LANG_CATALAN:case CommandIds.LANG_TURKISH:case CommandIds.LANG_SLOWENIAN:case CommandIds.LANG_GREEK:case CommandIds.LANG_UKRAINIAN:case CommandIds.LANG_VIETNAMESE:case CommandIds.LANG_ARABIC:case CommandIds.LANG_SERBIAN:case CommandIds.LANG_LITHUANIAN:case CommandIds.LANG_PORTUGUESE:case CommandIds.LANG_FARSI:case CommandIds.LANG_GAELIC:case CommandIds.LANG_CROATIAN:case CommandIds.LANG_CZECH:case CommandIds.LANG_HINDI:this.changeLanguage(a);
4979break;case CommandIds.TRANSLATE_PAGE:window.open("https://docu.chessbase.com/translate.html","_blank");break;case CommandIds.PIECES2D_FRITZ:case CommandIds.PIECES2D_CRYSTALS:case CommandIds.PIECES2D_CRYSTALS_WOOD:case CommandIds.PIECES2D_USCF:case CommandIds.PIECES2D_OLDSTYLE:case CommandIds.PIECES2D_HABSBURG:case CommandIds.PIECES2D_WORLDCHESS:case CommandIds.PIECES2D_BLUE:case CommandIds.PIECES2D_FF:this.changeBoardStyle(a);break;case CommandIds.TOGGLE_PIECES:GlobalSettings.boardGate.exec(this.nextBoardStyle(),
49803E3);break;case CommandIds.PIECES3D_FRITZ:case CommandIds.PIECES3D_MODERN:case CommandIds.PIECES3D_ROOM:case CommandIds.PIECES3D_BALLOON:case CommandIds.PIECES3D_METAL:case CommandIds.PIECES3D_FUTURE:case CommandIds.PIECES3D_BLACKWHITE:case CommandIds.PIECES3D_CHARACTER:System.isWebGlCapable()?this.change3DBo
4980ardStyle(a):(alert(lm.BROWSER_DOESNT_SUPPORT_3D),this.changeBoardStyle(CommandIds.PIECES2D_FRITZ))}}catch(b){a=glApp.Vy.toNumString(a),LogException(a,b)}}onKeyDown(a){return!1}onFileSelect(a,
4981b){return!1}setIsDialogActive(a){glApp.panelMgr.setIsFormOpen(a)}inDialog(){return glApp.panelMgr.getIsFormOpen()}change3DBoardStyle(a){glApp.panelMgr.deleteCanvasPanel&&(this.b3dSelected?glApp.panelMgr.deleteCanvasPanel3D():glApp.panelMgr.deleteCanvasPanel(),this.b3dSelected=!0,this.pieceFontName3D=PieceFonts[a],this.pieceStyleId3D=a,glApp.panelMgr.addCanvasPanel3D())}changeBoardStyle(a){this.b3dSelected&&(this.b3dSelected=!1,glApp.panelMgr.deleteCanvasPanel3D(),glApp.panelMgr.addCanvasPanel());
4982BoardSprites.clearCache();this.pieceFontName=PieceFonts[a];this.pieceStyleId=a;this.fireOnBoardStyle(a,this.pieceFontName)}nextBoardStyle(){this.pieceStyleId=this.pieceStyleId?this.pieceStyleId+1:CommandIds.PIECES2D_FRITZ+1;this.pieceStyleId>=CommandIds.PIECES_LAST&&(this.pieceStyleId=CommandIds.PIECES2D_FRITZ);!glApp.config.has3DBoard&&this.pieceStyleId>=CommandIds.PIECES3D_FRITZ&&(this.pieceStyleId=CommandIds.PIECES2D_FRITZ);this.pieceStyleId>=CommandIds.PIECES3D_FRITZ?System.isWebGlCapable()?this.change3DBoardStyle(this.pieceStyleId):
4983this.changeBoardStyle(this.pieceStyleId):this.changeBoardStyle(this.pieceStyleId)}getPieceFontName(){return this.pieceFontName}changeLanguage(a,b){var c=this.languageCommandId;this.changeLangButtonFlag(a);this.languageCommandId=a;glApp.changeLanguage(this.V2(a));glApp.appUrl&&c!=a&&!b&&(this.save(),window.location=glApp.appUrl+"?lang="+Language.getParamOfLanguageId(glSettings.getLanguageId()))}changeLangButtonFlag(a){this.languageBtn&&this.languageBtn.changeFlagIcon(Language.getRibbonFlagName(this.V2(a)))}V2(a){switch(a){default:alert("languageId: "+
4984a);case CommandIds.LANG_ENGLISH:return Language.ENG;case CommandIds.LANG_DEUTSCH:return Language.GER;case CommandIds.LANG_ESPANOL:return Language.ESP;case CommandIds.LANG_DUTCH:return Language.NED;case CommandIds.LANG_ROMANIAN:return Language.ROM;case CommandIds.LANG_CHINESE:return Language.CHN;case CommandIds.LANG_FRENCH:return Language.FRA;
4984case CommandIds.LANG_RUSSIAN:return Language.RUS;case CommandIds.LANG_NORWEGIAN:return Language.NOR;case CommandIds.LANG_POLISH:return Language.POL;case CommandIds.LANG_ITALIAN:return Language.ITA;
4985case CommandIds.LANG_HEBREW:return Language.HEB;case CommandIds.LANG_CATALAN:return Language.CAT;case CommandIds.LANG_TURKISH:return Language.TRK;case CommandIds.LANG_SLOWENIAN:return Language.SLO;case CommandIds.LANG_GREEK:return Language.GRK;case CommandIds.LANG_UKRAINIAN:return Language.UKR;case CommandIds.LANG_VIETNAMESE:return Language.VIE;case CommandIds.LANG_ARABIC:return Language.ARA;case CommandIds.LANG_SERBIAN:return Language.SER;case CommandIds.LANG_LITHUANIAN:return Language.LIT;case CommandIds.LANG_PORTUGUESE:return Language.BRA;
4986case CommandIds.LANG_FARSI:return Language.FAR;case CommandIds.LANG_GAELIC:return Language.GAL;case CommandIds.LANG_CROATIAN:return Language.CRO;case CommandIds.LANG_CZECH:return Language.CZE;case CommandIds.LANG_HINDI:return Language.HIN}}getCommandIdOfLanguage(a){switch(a){default:case Language.ENG:return CommandIds.LANG_ENGLISH;case Language.GER:return CommandIds.LANG_DEUTSCH;case Language.ESP:return CommandIds.LANG_ESPANOL;case Language.NED:return CommandIds.LANG_DUTCH;case Language.ROM:return CommandIds.LANG_ROMANIAN;
4987case Language.CHN:return CommandIds.LANG_CHINESE;case Language.FRA:return CommandIds.LANG_FRENCH;case Language.RUS:return CommandIds.LANG_RUSSIAN;case Language.NOR:return CommandIds.LANG_NORWEGIAN;case Language.POL:return CommandIds.LANG_POLISH;case Language.ITA:return CommandIds.LANG_ITALIAN;case Language.HEB:return CommandIds.LANG_HEBREW;case Language.CAT:return CommandIds.LANG_CATALAN;case Language.TRK:return CommandIds.LANG_TURKISH;case Language.SLO:return CommandIds.LANG_SLOWENIAN;case Language.UKR:return CommandIds.LANG_UKRAINIAN;
4988case Language.GRK:return CommandIds.LANG_GREEK;case Language.VIE:return CommandIds.LANG_VIETNAMESE;case Language.ARA:return CommandIds.LANG_ARABIC;case Language.SER:return CommandIds.LANG_SERBIAN;case Language.LIT:return CommandIds.LANG_LITHUANIAN;case Language.BRA:return CommandIds.LANG_PORTUGUESE;case Language.FAR:return CommandIds.LANG_FARSI;case Language.GAL:return CommandIds.LANG_GAELIC;case Language.CRO:return CommandIds.LANG_CROATIAN;case Language.CZE:return CommandIds.LANG_CZECH;case Language.HIN:return CommandIds.LANG_HINDI}}getLanguageCommandIds(a){var b=
4989[];a.forEach(function(c){b.push(this.getCommandIdOfLanguage(c))}.bind(this));return b}isRTLLanguage(){return this.languageCommandId&&(this.languageCommandId==CommandIds.LANG_HEBREW||this.languageCommandId==CommandIds.LANG_ARABIC||this.languageCommandId==CommandIds.LANG_FARSI)}getLanguageId(){return this.languageCommandId?this.V2(this.languageCommandId):Language.getUserLanguageId()}static initForListeners(){GlobalSettings.prototype.fireEvent||(Vk.initForListeners(GlobalSettings),Vk.addEvent(GlobalSettings,
4990"BoardStyle"),Vk.addEvent(GlobalSettings,"BoardStyle3D"))}}function setGlobaSettings(a){glSettings=a}var glSettings;"use strict";
4991var FeedbackManager=function(){var a=function(){};a.prototype.send=function(b,c){this.strAddress=b;this.strComment=c;b=LoginMode.GUEST;ServerPlayerLobby?(this.aPlayerLobby=new ServerPlayerLobby(glApp.config.getPlBridgeUris(),"Guest","",b),this.aPlayerLobby.connect(this.onConnected,this)):alert("Thank you")};a.prototype.onConnected=function(b){b.aPlayerLobby&&(b.aPlayerLobby.sendFeedback(b.strAddress,b.strComment,this.feedbackReceived),b.aPlayerLobby.logOff(),alert("Thank you"))};a.prototype.feedbackReceived=
4992function(b){};return a}(),AccountPanelMgrMixin=function(){return{onLogin:function(){LOG("Login="+glApp.isLoggedIn());this.gameKernel&&this.gameKernel.game.fireOnChanged({forceUpdate:!0});this.setLoginHtml(glApp.isLoggedIn())},setLoginHtml:function(a){if(this.infoPanel){if(a)this.infoPanel.setHeight(450<window.innerHeight?28:20),Ext.apply(this.infoPanel,{overflowY:"auto"}),this.infoPanel.update('<div class="CBInfoLoggedIn">'+this.getLoggedInHtml()+"</div>"),this.infoPanel.setBodyStyle(this.getLoginInfoGradient()+
4993";color:white;text-transform:uppercase");else{var b=window.innerHeight/3;this.eastContainer&&this.eastContainer.el&&(b=this.eastContainer.getHeight());System.isMobile()&&900>window.innerHeight?this.infoPanel.setHeight(Math.min(b,120)):this.infoPanel.setHeight(Math.min(b,160));Ext.apply(this.infoPanel,{overflowY:"scroll"});this.infoPanel.update('<div class="CBInfoNotLoggedIn">'+this.getPleaseLoginHtml()+"</div>");this.infoPanel.setBodyStyle(CBCSS.getGradToRight("rgba(254, 254,252,25
49935)","rgba( 251, 251,247,255)")+
4994";color:black;text-transform:none;")}this.infoPanel.loggedIn=a;glApp.Vn.noLists()&&this.infoPanel.el&&this.infoPanel.setVisible(!1)}},getLoginInfoGradient:function(){return CBCSS.getGradToRight("rgba(6, 216,19,255)","rgba(24, 147,23,255)")},getGuestInfoGradient:function(){return CBCSS.getGradToRight("hsl( 120, 15%, 30% )","hsl( 0, 15%, 20% )")},getPleaseLoginHtml:function(a){a=CBCSS.getHeader("h3",lm.LOGIN_PLEASE_LOGIN,"margin-top:4px");a+=this.getLoginInviteHeader()+"<br/>";if(!System.isMobile()||
4995900<window.innerHeight)a+=this.getFunctionalityText()+"<br/>",a+=lm.LOGIN_ACCOUNT_FREE+"<br/><br/>";System.isCordova()||(a+=this.genCreateAccountLink());return a},genCreateAccountLink:function(){return'<a href="'+glApp.config.createAccountWebUrl+'" style="color:#8B0A16">'+lm.LOGIN_CREATE_LINK+"</a>"},getLoggedInHtml:function(){return String.f(lm.LOGIN_WELCOME,glApp.Vn.userName)},getLoginInviteHeader:function(){return String.f(lm.GENERAL_INVITE,glApp.appTitle)},getFunctionalityText:function(){return lm.PLEASE_LOGIN},
4996resizeInfoPanel:function(){var a=!1;if(this.infoPanel&&this.infoPanel.el)if(this.infoPanel.loggedIn){var b=22;450<window.innerHeight&&(b=650<window.innerHeight?30:26);this.infoPanel.setHeight(b);a=!0}else this.eastContainer&&(b=Math.min(220,Math.max(20,.3*this.eastContainer.getHeight())),this.infoPanel.setHeight(b));return a}}}();
4997let AccountAppMixin=function(){return{accountLogin:function(a,b){glApp.Vn.userName=DOM.getAccountNameCookie(!0)||glApp.Vn.userName;glApp.Vn.loginToken=DOM.getCookie("AccountToken");if(!a&&glApp.Vn.loginToken&&glApp.Vn.userName&&"guest"!=glApp.Vn.userName)a=new AccountsManager(glApp.shortAppName),glApp.Vn.userName&&"guest"!=glApp.Vn.userName&&glApp.Vn.password?a.pwLogin(glApp.Vn.userName,glApp.Vn.password,this.receiveTokenHandler.bind(this)):a.tokenLogin(glApp.Vn.userName,glApp.Vn.loginToken,this.tokenLoginHandler.bind(this));
4998else this.onRequestLogin(b)},onRequestLogin:function(a){this.enterLoginForm(a)},enterLoginForm:function(a,b){glApp.panelMgr.showAccountsForm(a,"",b)},tokenLoginHandler:function(a){a&&1!=a.ResultType&&!a.timeout?(this.setLoggedIn(!1),this.enterLoginForm()):a.timeout?(DOM.clearCookie("AccountToken"),this.setLoggedIn(!1)):(this.setLoggedIn(!0),this.onTokenLoginOk(),glApp.showAccountType(a.Subscription));this.loginPending=!1},onTokenLoginOk:function(){},receiveTokenHandler:function(a){if(a&&a.Token){var b=
4999unescape(a.Token);glApp.Vn.loginToken=b;LOG("AccToken = "+b,"","acc");glApp.Vn.rememberLoginToken();a.userId&&1==a.ResultType&&(glApp.Vn.userName=a.userId);DOM.setAccountNameCookie(glApp.Vn.userName);this.setLoggedIn(!0);ToolButtons&&ToolButtons.showBusyMask("Logged in OK: "+glApp.Vn.userName);Timer.launch(function(){ToolButtons&&ToolButtons.hideBusyMask()},600);this.onTokenLoginOk()}else{LOG("No Token Received in token handler");if(a&&1!=a.Result&&!a.timeout&&!a.error)this.onInvalidToken();a.timeout&&
5000DOM.clearCookie("AccountToken","");this.setLoggedIn(!1);this.loginPending=!1}},onInvalidToken:function(){glApp.panelMgr.showAccountsForm()?glApp.panelMgr.showAccountsForm(lm.PW_INVALID,glApp.Vn.userName):this.enterLoginForm(String.formatEx(lm.PW_INVALID,glApp.Vn.userName))},isLoggedIn:function(){return this.loggedIn||!!this.loginPending},setLoggedIn:function(a){this.superClass.setLoggedIn.apply(this,arguments);a?document.title=this.appTitle+" - "+glApp.Vn.userName:(document.title=this.appTitle+" - not logged in",
5001this.loginPending=!1)}}}();var FilterFlagsEnum={OLSM_NULL:0,OLSM_USE_BOARD:1,OLSM_WINS:16,OLSM_DRAWS:32,OLSM_LOSSES:64,OLSM_WINS_ONLY:128,OLSM_WHITE:256,OLSM_BLACK:512,OLSM_IGNORE_COLORS:1024,OLSM_BEST_GAMES:4096,OLSM_USE_MATERIAL:8192};
5002class SearchMask{constructor(){this.YEAR_NONE=this.ELO_NONE=0;this.freeText=this.m_strPlaceMask=this.m_strTitle=this.m_strBlMask=this.m_strWhMask="";this.m_nMinECO=0;this.m_nMaxECO=65535;this.m_iMinYear=0;this.m_iMaxYear=3E3;this.m_iBlackMinElo=this.m_iWhiteMinElo=0;this.m_board=new Board;this.m_eSideToMove=0;this.m_nFlags=FilterFlagsEnum.OLSM_WINS|FilterFlagsEnum.OLSM_DRAWS|FilterFlagsEnum.OLSM_LOSSES|FilterFlagsEnum.OLSM_WHITE|FilterFlagsEnum.OLSM_BLACK;this.init()}init(a){}V9(a){a.beginSizedWrite();
5003a.writeByte(1);a.Va(this.m_strWhMask);a.Va(this.m_strBlMask);a.Va(this.m_strTitle);a.Va(this.m_strPlaceMask);
5003a.writeInt(this.m_iMinYear);a.writeInt(this.m_iMaxYear);a.writeInt(this.m_iWhiteMinElo);a.writeInt(this.m_iBlackMinElo);a.Vv(this.m_nMinECO);a.Vv(this.m_nMaxECO);a.writeInt(this.m_nFlags);if(this.getUseBoard()){a.writeByte(this.m_eSideToMove);for(var b=0;64>b;b++)a.writeByte(this.m_board[b])}a.Va(this.freeText);a.endSizedWrite()}setSearchBoard(a,b){this.m_board=a;this.m_eSideToMove=b}SETFLAG(a,
5004b){this.m_nFlags=b?this.m_nFlags|a:this.m_nFlags&~a}ISFLAG(a){return 0!=(this.m_nFlags&a)}setIgnoreColors(a){this.SETFLAG(FilterFlagsEnum.OLSM_IGNORE_COLORS,a)}setUseBoard(a){this.SETFLAG(FilterFlagsEnum.OLSM_USE_BOARD,a)}getUseBoard(){return this.ISFLAG(FilterFlagsEnum.OLSM_USE_BOARD)}setUseMaterial(a){this.SETFLAG(FilterFlagsEnum.OLSM_USE_MATERIAL,a)}getUseMaterial(){return this.ISFLAG(FilterFlagsEnum.OLSM_USE_MATERIAL)}setWins(a){this.SETFLAG(FilterFlagsEnum.OLSM_WINS,a)}setDraws(a){this.SETFLAG(FilterFlagsEnum.OLSM_DRAWS,
5005a)}setLosses(a){this.SETFLAG(FilterFlagsEnum.OLSM_LOSSES,a)}setWhite(a){this.SETFLAG(FilterFlagsEnum.OLSM_WHITE,a)}setBlack(a){this.SETFLAG(FilterFlagsEnum.OLSM_BLACK,a)}setGoodGames(a){this.SETFLAG(FilterFlagsEnum.OLSM_BEST_GAMES,a)}setFreeText(a){this.freeText=a}parseFreeText(){var a="",b=this.freeText.split(" "),c=0;if(1<b.length)for(var d=0;d<b.length;d++)b[d].replace(" ",""),isNaN(b[d])?(a&&(a+=" "),a+=b[d]):c=b[d];
50050<c&&(this.freeText=a,this.m_iMinYear=this.m_iMaxYear=c)}toString(){return"searchmask="+
5006this.freeText+" board= "+this.m_board.toString()}}CB.FilterFlagsEnum=FilterFlagsEnum;CB.SearchMask=SearchMask;
5007class OnlineStatEntry{constructor(a){a?(this.moves=[],this.strScore=this.strGames=this.strMoves="",this.iLastYear=0,null!=a&&(this.strMoveNr=a.nota,this.aMove=new Move(a.from,a.to,a.prom))):this.clear()}iLastYear;nWhiteEloSum=0;nBlackEloSum=0;nWhiteEloCount=0;nBlackEloCount=0;nLosses=0;nDraws=0;nWins=0;nGames=0;nDate=0;score=0;strMoveNr="?";moves=[];aMove=new Move;clear(){this.nGames=this.nDate=this.nLosses=this.nDraws=this.nWins=this.nWhiteEloCount=this.nBlackEloCount=this.nWhiteEloSum=this.nBlackEloSum=
50080;this.moves=[]}getMove(a){return a<this.moves.length?this.moves[a]:new Move}getNMoves(){return this.moves.length}getNWhiteEloAv(){return 0<this.nWhiteEloCount?Math.round(this.nWhiteEloSum/this.nWhiteEloCount):0}getNBlackEloAv(){return 0<this.nBlackEloCount?Math.round(this.nBlackEloSum/this.nBlackEloCount):0}getNEloAv(a){return a==Side.WHITE?this.getNWhiteEloAv():this.getNBlackEloAv()}V7(a,b){a.Vc();this.nGames=a.Vw();this.strGames=this.nGames.toString();this.nDate=a.Vw();this.iLastYear=(new CBDate(this.nDate)).year>>
50099;this.nLosses=a.Vw();this.nDraws=a.Vw();this.nWins=a.Vw();a.Vw();this.nWhiteEloCount=a.Vw();this.nWhiteEloSum=a.V18();this.nBlackEloCount=a.Vw();this.nBlackEloSum=a.V18();var c=a.readUint8();if(0<c){var d=new NumBoard;d.init(b.board,d.FORMAT_1);for(var e=new NotationGenerator(lm.NOTA_LOCALIZATION),f=new MoveCoder,g=0;g<c;++g){var h=f.decode(a.readUint8(),g);if(0<h&&h<d.FULL_MOVE_INFO){var k=new Position;b.copyTo(k);var l=new Move;d.decode(l,h,k.getBTM());k.isLegalMove(l)&&(k.preCalcCtx(l),k.makeMove(l),
5010k.postCalcCtx(l,!0),h=e.getMoveNota(l),l.nota=h,this.moves.push(l))}}}a.Vm();return!0}}CB.OnlineStatEntry=OnlineStatEntry;
5011class OnlineStatistics{constructor(){this.vecStat=[]}clear(){this.vecStat=[]}V7(a,b){this.clear();var c=a.Vw(),d=b.toFEN(),e=new Position(d);if(0<c&&(d=new OnlineStatEntry,d.V7(a,e),--c,0<c))for(e=0;e<d.getNMoves()&&0<c;++e,--c){var f=b.toFEN();f=new Position(f);var g=d.getMove(e);f.preCalcCtx(g);f.makeMove(g);f.postCalcCtx(g,!0);g=new OnlineStatEntry(g);g.V7(a,f);this.vecStat.push(g)}return!0}getEntry(a){return this.vecStat[a]}Count(){return this.vecStat.length}}CB.OnlineStatistics=OnlineStatistics;
5012var OnlineEntryEnum={FLAGS_ONLINE_NONE:0,FLAGS_ONLINE_ID:1,FLAGS_ONLINE_HEADER:2,FLAGS_ONLINE_GAME:2,toString:function(a){for(var b in this)if(this[b]==a)return"OnlneEntryId: "+b;return"Unknown OnlineEntryId: "+a}};class OnlineEntry{aGame;aHeader;aDB;nGameNr;aGameNr;nFlags;constructor(){this.aGame=new Game}}CB.OnlineEntryEnum=OnlineEntryEnum;CB.OnlineEntry=OnlineEntry;
5013class GameEncoder{constructor(){this.numBits=[1,6,6,5,5,5,3,1,1,6,6,5,5,5,3,1];this.theBits=[0,32,34,18,20,22,6,0,0,33,35,19,21,23,7,0];this.isUniqe=[0,255,255,255,255,255,6,14,255,255,255,255,255,255,255,255,255,255,3,11,4,12,5,13,255,255,255,255,255,255,255,255,1,9,2,10,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255];this.moveDecode18=[90,170,153,97,156,120,48,246,217,33,251,89,244,117,179,207,138,229,61,134,20,71,41,42,47,157,19,
5014128,51,253,27,168,57,178,205,242,200,185,0,139,132,58,106,30,59,86,194,64,214,53,10,84,5,186,72,131,85,11,100,103,243,191,212,6,29,225,177,38,227,180,160,143,215,122,95,187,199,236,226,88,175,119,218,184,209,222,98,163,62,83,142,112,65,166,174,167,16,197,137,189,66,32,107,255,74,79,123,155,34,46,75,76,196,245,249,173,221,210,198,39,223,44,224,4,231,9,111,109,96,182,146,70,94,69,23,254,172,145,93,234,56,36,102,148,115,55,108,105,21,220,40,77,150,99,114,181,37,63,144,110,235,158,202,211,240,101,91,
5015149,12,43,15,68,248,125,219,7,49,67,17,206,203,193,1,171,104,232,228,113,26,247,28,129,204,147,216,80,195,165,3,140,161,116,208,183,31,241,22,130,118,78,151,82,87,121,8,252,35,192,213,133,14,45,54,50,250,176,73,126,60,201,169,25,13,92,190,233,81,230,127,135,162,152,164,141,124,154,238,239,24,136,188,237,159,52,2,18];this.HUFF_960=128;this.HUFF_CASTLE=64;this.HUFF_EP=32}decodeMove2(a,b){var c=[];c[0]=Piece.QUEEN;c[1]=Piece.ROOK;c[2]=Piece.BISHOP;c[3]=Piece.KNIGHT;a.From=b>>6&63;a.To=b>>0&63;a.SetProm(c[b>>
501612&3]);a.SetMoveType(0);return!0}decode(a,b){var c=!1,d=b.getPos()-4;b.rewind();for(var e=[],f=0;f<d;f++)e[f]=b.readUint8();if(0<d&&e[0]<=d){b=new Position;0<e[0]?(HuffToPos3(b,e,d),a.setStartPosition(b),c=e[0],CBDebug.assert(!1)):(a.getStartPos().NormalInit=!0,c=1);f=new NumBoard;for(f.init(b.board,f.FORMAT_1);c<d;){var g=new Move,h=this.moveDecode18[e[c]]-c;++c;if(h>=f.FULL_MOVE_INFO)if(h==f.FULL_MOVE_INFO){if(c+2>d)break;h=this.moveDecode18[e[c]]-c;++c;h|=this.moveDecode18[e[c]]-c<<8;++c;decodeMove2(g,
5017h)}else break;
5017else 0<h&&f.decode(g,h,b.getBTM());this.addMoveInfo(b,g);a.makeMove(g);f.execute(g,b)}c=!0}return c}PosToHuff2(a,b,c){var d,e;this.index=0;b[this.index++]=0;var f=d=b[this.index]=0;for(e=2;64>d;d++){var g=a.board[d]&15;f+=this.numBits[g];if(8<f){b[this.index]|=this.theBits[g]>>f-8;if(++e>c)return ERRCODE.EC_CANCEL;this.index++;b[this.index]=0;f-=8}b[this.index]|=this.theBits[g]<<8-f;if(8<=f){f=0;if(++e>c)return ERRCODE.EC_CANCEL;this.index++;b[this.index]=0}}g=d=0;a.getCastleRights()&&
5018(g|=this.HUFF_CASTLE,d+=4);a.getEPFile()&&(g|=this.HUFF_EP,d+=3);if(d){if(8<f+d){if(++e>c)return ERRCODE.EC_CANCEL;this.index++;b[this.index]=0}a.getCastleRights()?(b[this.index]|=a.getCastleRights()&15,a.getEPFile()&&(b[this.index]|=(a.getEPFile()-1&7)<<4)):a.getEPFile()&&(b[this.index]|=a.getEPFile()-1&7)}b[0]=e|g;return 0}posToHuff3(a,b,c){var d;this.index=0;b[this.index]=0;index++;b[this.index]=0;a.GetBTM()&&(b[this.index]=128);var e=0;var f=1;for(d=2;64>e;e++){var g=a[e]&15;f+=this.numBits[g];
5019if(8<f){b[this.index]|=this.theBits[g]>>f-8;if(++d>c)return ERRCODE.EC_CANCEL;this.index++;b[index]=0;f-=8}b[this.index]|=this.theBits[g]<<8-f;if(8<=f){f=0;if(++d>c)return ERRCODE.EC_CANCEL;this.index++;b[this.index]=0}}g=e=0;0<a.getCastleRights()&&(g|=this.HUFF_CASTLE,e+=4);0<a.getCPPEPFile()&&(g|=this.HUFF_EP,e+=3);if(0<e){if(8<f+e){if(++d>c)return ERRCODE.EC_CANCEL;this.index++;b[this.index]=0}0<a.getCastleRights()?(b[this.index]|=a.getCastleRights()&15,0<a.getCPPEPFile()&&(b[this.index]|=(a.getCPPEPFile()-
50201&7)<<4)):0<a.getCPPEPFile()&&(b[this.index]|=a.getCPPEPFile()-1&7)}else 0==f&&--d;b[this.index]=d|g;return ERRCODE.EC_OK}huffToPos3(a,b,c){var d,e=0,f;for(d=0;64>d;d++)a[d]=0;d=b[e]&(HUFF_960|HUFF_CASTLE|HUFF_EP);var g=b[e]&31;if(8<g&&g<c){0<(d&HUFF_CASTLE)?(a.SetCastleRights(b[g-1]&15),0<(d&HUFF_EP)?a.setCPPEPFile((b[g-1]>>4&7)+1):a.setCPPEPFile(0)):(a.SetCastleRights(CastleRights.NONE),0<(d&HUFF_EP)?a.setCPPEPFile((b[g-1]&7)+1):a.setCPPEPFile(0));e++;a.SetSideToMove(0<(b[e]&128)?Side.BLACK:Side.WHITE);
5021d=0;c=1;for(f=64;64>d&&c<g;d++){var h=0,k=0;do h<<=1,0<(b[e]&f)&&(h|=1),k++,f>>=1,0==f&&(f=128,e++,c++);while(255==isUniqe[h]&&6>k);if(255==isUniqe[h])break;a[d]=Piece(isUniqe[h])}if(64>d)return a.SetGroundPos(),ERRCODE.EC_CANCEL}else return a.SetGroundPos(),ERRCODE.EC_CANCEL;a.FindKings();return ERRCODE.EC_OK}addMoveInfo(a,b){a.preCalcCtx(b);a.makeMove(b);a.postCalcCtx(b,!0)}}CB.GameEncoder=GameEncoder;class NumBoardImpl{constructor(){this.numBoard=[];this.piecePos=[]}}
5022class NumBoard{constructor(){this.numBoard=this.m_aImpl.numBoard;this.piecePos=this.m_aImpl.piecePos}MOVE_EP=16;MOVE_DOUBLE=32;MOVE_PROM=64;moveOffs_Chess=[0,0,0,0,0,0,0,4,2,1,0,0,0,0,0,3,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,0,0,6,7,0,0,0,0,0,5,0,0,1,2,3,4,5,6,7,14,1,0,0,0,6,21,8,0,15,0,0,0,22,7,9,0,0,16,0,23,0,0,10,0,0,0,17,0,0,0,11,0,0,25,0,18,0,0,12,3,26,0,0,0,19,4,13,27,2,0,0,0,5,20,0,0,1,0,0,0,1,0,0,2,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
50230,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,2];moveOffs2=[0,0,0,0,0,0,0,4,2,1,0,0,0,0,0,3,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,0,0,6,7,0,0,0,0,0,5,0,0,1,2,3,4,5,6,7,14,1,0,0,0,6,21,8,0,15,0,0,0,22,7,9,0,0,16,0,23,0,0,10,0,0,0,17,0,0,0,11,0,0,25,0,18,0,0,12,3,26,0,0,0,19,4,13,27,2,0,0,0,5,20,0,0,1,0,0,0,1,0,0,2,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,2];tableOffs_Chess=[0,0,1,1,1,1,2,
50240,0,0,1,1,1,1,2,0];tableOffs2=[0,0,1,1,1,1,2,0,0,0,1,1,1,1,2,0];wPawnOffs_Chess=111;pieceMov_Chess=[0,1,9,8,15,7,63,56,57,16,48,1,2,3,4,5,6,7,8,16,24,32,40,48,56,9,18,27,36,45,54,63,15,22,29,36,43,50,57,1,2,3,4,5,6,7,8,16,24,32,40,48,56,1,2,3,4,5,6,7,8,16,24,32,40,48,56,9,18,27,36,45,54,63,15,22,29,36,43,50,57,9,18,27,36,45,54,63,15,22,29,36,43,50,57,17,10,58,49,55,62,14,23,17,10,58,49,55,62,14,23,1,2,9,57,1,2,9,57,1,2,9,57,1,2,9,57,1,2,9,57,1,2,9,57,1,2,9,57,1,2,9,57,1,2,3,4,5,6,7,8,16,24,32,40,
502548,56,9,18,27,36,45,54,63,15,22,29,36,43,50,57,1,2,3,4,5,6,7,8,16,24,32,40,48,56,9,18,27,36,45,54,63,15,22,29,36,43,50,57,1,2,3,4,5,6,7,8,16,24,32,40,48,56,9,18,27,36,45,54,63,15,22,29,36,43,50,57,17,10,58,49,55,62,14,23,0,0,1,9,8,15,7,63,56,57,16,48];bPawnMov_Chess=[7,6,63,15,7,6,63,15,7,6,63,15,7,6,63,15,7,6,63,15,7,6,63,15,7,6,63,15,7,6,63,15];pieceNum_Chess=[0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,5,5,5,5,5,5,5,5,5,5,5,5,5,5,21,21,21,21,21,21,21,21,21,21,
502621,21,21,21,4,4,4,4,4,4,4,4,4,4,4,4,4,4,20,20,20,20,20,20,20,20,20,20,20,20,20,20,3,3,3,3,3,3,3,3,19,19,19,19,19,19,19,19,6,6,6,6,22,22,22,22,38,38,38,38,54,54,54,54,70,70,70,70,86,86,86,86,102,102,102,102,118,118,118,118,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,34,37,37,37,37,37,37,37,37,37,37,37,37,37,37,36,36,36,36,36,36,36,36,36,36,36,36,36,36,35,35,35,35,35,35,35,35,0,0,
502717,17,17,17,17,17,17,17,17,17];pieceOffs_Chess=[0,1,11,95,53,39,111,0,0,1,11,95,53,39,111,0,0,237,143,103,67,53,115,0,0,237,143,103,67,53,115,0,0,0,171,227,199,199,119,0,0,0,171,227,199,199,119,0,0,0,0,0,0,0,123,0,0,0,0,0,0,0,123,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,131,0,0,0,0,0,0,0,131,0,0,0,0,0,0,0,135,0,0,0,0,0,0,0,135,0,0,0,0,0,0,0,139,0,0,0,0,0,0,0,139,0];pieceInx_Chess=[0,24,0,1,2,3,26,0,0,25,12,13,14,15,27,0,0,42,4,5,6,7,28,0,0,43,16,17,18,19,29,0,0,0,8,9,10,11,30,0,0,0,20,21,
502822,23,31,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,33,0,0,0,0,0,0,0,34,0,0,0,0,0,0,0,35,0,0,0,0,0,0,0,36,0,0,0,0,0,0,0,37,0,0,0,0,0,0,0,38,0,0,0,0,0,0,0,39,0,0,0,0,0,0,0,40,0,0,0,0,0,0,0,41,0];maxPiece_Chess=[0,16,48,48,48,48,128,0,0,16,48,48,48,48,128,0];maxPiece_MultiKing=[0,32,48,48,48,48,128,0,0,32,48,48,48,48,128,0];moveOffs=[];tableOffs=[];pieceMov=[];pieceNum=[];bPawnMov=[];pieceOffs=[];pieceInx=[];maxPiece=[];wPawnOffs=0;FORMAT_0=0;FORMAT_1=1;FULL_MOVE_INFO=235;CB_ORIGIN1=236;KING2_START=237;KING2_END=246;CB_LINE_START=254;CB_LINE_END=255;IsMultiByte(a){return a==
5029this.FULL_MOVE_INFO}m_aImpl=new NumBoardImpl;numBoard=[];piecePos=[];MOVEPIECE(a,b){a&&a<this.maxPiece[a&Piece.PIECE_MASK]&&(this.piecePos[this.pieceInx[a]]=b)}init(a,b){var c=[],d;this.moveOffs=this.moveOffs_Chess;this.tableOffs=this.tableOffs_Chess;this.pieceMov=this.pieceMov_Chess;this.pieceNum=this.pieceNum_Chess;this.bPawnMov=this.bPawnMov_Chess;this.pieceOffs=this.pieceOffs_Chess;this.pieceInx=this.pieceInx_Chess;this.maxPiece=this.maxPiece_Chess;this.wPawnOffs=this.wPawnOffs_Chess;for(d=0;48>
5030d;d++)this.piecePos[d]=255;for(d=0;16>d;d++)c[d]=d;switch(b){case this.FORMAT_1:for(d=63;0<=d;d--)b=a[d]&15,0<b?(this.numBoard[d]=c[b],c[b]<this.maxPiece[b&Piece.PIECE_MASK]&&(this.piecePos[this.pieceInx[c[b]]]=d,c[b]+=16),CBDebug.assert(0<this.numBoard[d])):this.numBoard[d]=0;break;default:for(d=0;64>d;d++)b=a[d],0<b?(this.numBoard[d]=c[b],c[b]<this.maxPiece[b&Piece.PIECE_MASK]&&(this.piecePos[this.pieceInx[c[b]]]=d,c[b]+=16)):this.numBoard[d]=0}}promote(a,b){for(b|=a&Piece.COLOUR;b<this.maxPiece[b&
503115];){if(255==this.piecePos[this.pieceInx[b]]){this.piecePos[this.pieceInx[b]]=this.piecePos[this.pieceInx[a]];break}b+=16}this.numBoard[this.piecePos[this.pieceInx[a]]]=b;this.piecePos[this.pieceInx[a]]=255;return 0}capture(a){if(a)if((a&Piece.PIECE_MASK)==Piece.PAWN)this.MOVEPIECE(a,255);else if(a<this.maxPiece[a&15]){this.MOVEPIECE(a,255);for(var b=this.maxPiece[a&15]-16,c=a;c<b;c+=16){this.piecePos[this.pieceInx[c]]=this.piecePos[this.pieceInx[c+16]];if(255==this.piecePos[this.pieceInx[c]])break;
5032this.numBoard[this.piecePos[this.pieceInx[c]]]=c;this.piecePos[this.pieceInx[c+16]]=255}if(255!=this.piecePos[this.pieceInx[b|a&15]])for(a=this.maxPiece[a&15]|a&15,c=0;64>c;c++)if(this.numBoard[c]==a){this.piecePos[this.pieceInx[a-16]]=c;this.numBoard[c]=a-16;break}}return 0}execute(a,b){if(!a.IsNullMove){var c=a.from,d=a.to,e=this.numBoard[c],f=this.numBoard[d];e||CBDebug.assert("no piece to move");this.numBoard[d]=this.numBoard[c];this.numBoard[c]=0;this.MOVEPIECE(e,d);f&&(f&Piece.PIECE_MASK)!=
5033Piece.KING&&this.capture(f);if(a.isCastling()||a.isProm())a.isProm()?a.IsProm()&&this.promote(e,a.prom):a.isCastling()&&(b.getBTM()?a.isLongCastling()?(this.MOVEPIECE(this.numBoard[CBSquare.A8],d+(CBSquare.B8-CBSquare.A8)),this.numBoard[d+(CBSquare.B8-CBSquare.A8)]=this.numBoard[CBSquare.A8],this.numBoard[CBSquare.A8]=0):a.isShortCastling()&&(this.MOVEPIECE(this.numBoard[CBSquare.H8],CBSquare.F8),this.numBoard[CBSquare.F8]=this.numBoard[CBSquare.H8],this.numBoard[CBSquare.H8]=0):a.isLongCastling()?
5034(this.MOVEPIECE(this.numBoard[CBSquare.A1],d+(CBSquare.B1-CBSquare.A1)),this.numBoard[d+(CBSquare.B1-CBSquare.A1)]=this.numBoard[CBSquare.A1],this.numBoard[CBSquare.A1]=0):a.isShortCastling()&&(this.MOVEPIECE(this.numBoard[CBSquare.H1],CBSquare.F1),this.numBoard[CBSquare.F1]=this.numBoard[CBSquare.H1],this.numBoard[CBSquare.H1]=0))}}encode(a,b){CBDebug.assert(0<this.numBoard[a.from]);if(0<this.numBoard[a.from]&&this.numBoard[a.from]<this.maxPiece[a.CB.Piece.Nominal()]){b=(a.to&56)-(a.from&56)&56|
5035(a.To&7)-(a.From&7)&7;b=this.pieceOffs[this.numBoard[a.from]]+this.moveOffs[64*this.tableOffs[a.CB.Piece.Nominal()]+b];
5035CBDebug.assert(b<this.FULL_MOVE_INFO||16<this.maxPiece[Piece.KING]&&b>=this.KING2_START&&b<=this.KING2_END);var c=new Move;this.decode(c,b,(this.numBoard[a.fr]&Piece.COLOUR)==Piece.COLOUR);CBDebug.assert(c.From==a.From&&c.To==a.To)}}decode(a,b,c){CBDebug.assert(b<this.FULL_MOVE_INFO||16<this.maxPiece[Piece.KING]&&b>=this.KING2_START&&b<=this.KING2_END);var d=this.pieceMov[b],e=this.pieceNum[b];
5036c&&(e|=Side.SIDE_MASK,(e&Piece.PIECE_MASK)==Piece.PAWN&&(d=this.bPawnMov[b-this.wPawnOffs]));a.from=this.piecePos[this.pieceInx[e]]&63;a.to=(a.from&56)+(d&56)&56|a.from+d&7;a.prom=0;for(a=a.type=0;64>a;a++)0!=this.numBoard[a]&&this.numBoard[a]<this.maxPiece[this.numBoard[a]&Piece.PIECE_MASK]&&this.piecePos[this.pieceInx[this.numBoard[a]]]!=a&&CBDebug.assert(!1)}}CB.NumBoardImpl=NumBoardImpl;CB.NumBoard=NumBoard;
5037class MoveCoder{constructor(){}moveEncode5=[175,19,103,190,68,10,140,151,223,107,246,5,157,148,55,183,154,253,47,116,49,229,57,41,143,241,162,69,231,40,97,237,66,128,75,71,126,217,215,129,232,122,153,135,80,225,127,205,152,239,110,82,134,125,244,227,197,165,123,105,196,169,14,173,181,216,33,46,193,13,106,21,58,18,38,178,60,167,102,195,27,245,194,185,159,50,9,29,114,121,204,136,202,34,84,54,52,133,247,15,218,138,233,210,76,243,211,1,48,42,224,236,219,139,12,4,98,150,209,85,155,124,39,207,230,235,6,
5038187,95,0,222,203,177,45,130,24,200,92,199,163,74,20,36,77,189,160,176,198,26,201,248,3,250,8,188,249,240,146,251,174,56,65,35,111,99,171,59,83,254,142,238,89,101,113,234,118,87,206,100,212,158,23,119,144,7,37,186,220,53,70,78,172,30,108,44,2,112,117,213,168,16,94,149,156,192,214,242,64,93,51,131,191,11,115,109,252,104,62,22,79,81,228,184,72,226,147,161,63,96,43,25,61,180,137,67,31,17,145,91,221,132,86,166,141,170,28,120,88,208,255,32,179,182,164,90,73];moveDecode5=[129,107,195,151,115,11,126,184,
5039153,86,5,212,114,69,62,99,200,236,73,1,141,71,218,181,135,230,148,80,245,87,192,235,250,66,93,162,142,185,74,122,29,23,109,229,194,133,67,18,108,20,85,209,96,188,95,14,160,22,72,166,76,231,217,227,207,161,32,234,4,27,189,35,223,255,140,34,104,143,190,219,44,220,51,167,94,119,241,176,247,171,254,238,137,208,201,128,228,30,116,164,178,172,78,2,216,59,70,9,193,214,50,163,196,173,88,213,19,197,175,182,246,89,41,58,121,53,36,46,33,39,134,210,240,97,52,43,91,233,101,113,6,243,169,24,183,237,157,225,13,
5040202,117,7,48,42,16,120,203,12,180,84,145,226,26,139,253,57,242,77,199,61,244,165,191,63,159,0,146,132,75,251,232,64,252,15,222,83,186,127,154,144,3,211,204,68,82,79,60,56,147,138,136,149,92,131,90,47,177,123,248,118,103,106,179,198,205,38,65,37,100,112,187,239,130,8,110,45,224,55,221,21,124,28,40,102,174,125,111,31,170,49,156,25,206,105,54,81,10,98,150,155,152,158,215,17,168,249];moveEncode19=[115,113,245,122,119,36,91,210,93,137,56,239,159,205,160,142,246,17,125,46,62,241,57,130,39,88,11,70,204,
5041118,173,135,54,30,199,68,154,186,55,27,168,53,175,123,52,49,129,221,206,1,73,169,18,209,58,165,183,72,31,198,251,6,63,2,101,229,136,32,60,71,41,37,110,250,197,51,43,150,105,163,238,26,191,116,249,207,208,75,215,40,158,111,120,134,234,67,176,86,121,185,124,83,240,24,89,244,13,196,223,78,38,231,103,79,171,145,184,151,149,69,188,181,161,0,195,44,5,178,172,174,66,133,80,217,254,236,146,132,157,235,96,242,140,87,74,247,100,219,95,99,187,224,85,255,155,22,237,192,148,126,141,167,189,139,180,20,47,23,182,
5042222,179,131,220,3,253,200,127,7,16,33,214,152,211,42,14,97,64,45,77,227,19,29,248,153,156,112,147,109,61,233,225,218,81,144,213,59,84,9,166,104,76,194,228,232,212,48,177,252,203,143,34,10,162,35,98,106,65,90,25,190,193,138,128,92,230,4,15,107,21,243,201,108,102,12,202,114,94,28,216,164,117,82,226,170,8,50];moveDecode19=[123,49,63,173,235,126,61,177,254,207,221,26,243,106,184,236,178,17,52,190,165,238,155,167,103,228,81,39,247,191,33,58,67,179,220,223,5,71,110,24,89,70,183,76,125,187,19,166,215,45,
5043255,75,44,41,32,38,10,22,54,205,68,198,20,62,186,226,130,95,35,119,27,69,57,50,144,87,210,188,109,113,132,202,251,101,206,152,97,143,25,104,227,6,233,8,246,148,140,185,224,149,146,64,242,112,209,78,225,237,241,197,72,91,195,1,245,0,83,250,29,4,92,98,3,43,100,18,159,176,232,46,23,171,137,131,93,31,66,9,231,163,142,160,15,219,203,115,136,196,158,118,77,117,181,193,36,154,194,138,90,12,14,122,222,79,249,55,208,161,40,51,253,114,128,30,129,42,96,216,127,170,164,121,168,56,116,99,37,150,120,162,229,82,
5044157,230,211,124,107,74,59,34,175,240,244,218,28,13,48,85,86,53,7,182,214,204,180,88,248,133,201,147,172,47,169,108,151,200,252,189,212,65,234,111,213,199,94,139,135,156,80,11,102,21,141,239,105,2,16,145,192,84,73,60,217,174,134,153];decode(a,b){return this.moveEncode19[a-b]}}CB.MoveCoder=MoveCoder;var OnlineDBUserMsgId={NONE:0,REQUEST_AUTOCOMPLETE:1350,AUTOCOMPLETE:1351,toString:function(a){for(var b in this)if(this[b]==a)return b;return"Unknown OnlineDBUserMsgId: "+a}};
5045class OnlineLobby extends Connector{constructor(){super();this.idGroup=0;this.maxGames=100;this.firstMove=0;this.name="OnlineDB";this.games=[];this.statboard=new Board;this.statside=0;this.me;this.searchOnReady=!0;this.isScrollLoading=this.isReady=!1;this.scrollLoadCount=50;this.maxGamesScrollLoad=500;this.searchIndices=[];OnlineLobby.InitListeners()}createLobby(a,b,c,d){this.create(a,b,c,d)}testYesNo(a){LOG("YesNo="+a)}hasSockMsgIds(){return!0}hasSockCheckSum(){return!0}getStatistics(a,b){if(0<this.getNId()){glApp.panelMgr.dbBook&&
5046glApp.panelMgr.dbBook.startupdate();this.me=this;this.me.statboard=new Board;for(var c=0;64>c;c++)this.me.statboard[c]=a[c];this.statside=b;c=new WebSockMessage(SockMsgId.REQUEST_ONLINE_DB_STATISTICS);c.buf.beginSizedWrite();c.buf.writeByte(b);for(b=0;64>b;b++)c.buf.writeByte(a[b]);c.buf.endSizedWrite();this.send(c)}}search(a,b,c){glApp.panelMgr.dbGames&&glApp.panelMgr.dbGames.startupdate();var d=new WebSockMessage(SockMsgId.QUERY_ONLINE_DB);this.games=[];this.games.length=0;a.parseFreeText();a.V9(d.buf);
5047this.maxGames=b||50;this.firstMove=c||0;this.isScrollLoading=!1;this.searchIndices=[];this.send(d)}scrollLoad(){let a=Math.min(this.scrollLoadCount,this.searchIndices.length);0>=a||(this.isScrollLoading=!0,this.getGames(this.searchIndices.slice(0,a)),this.searchIndices=this.searchIndices.slice(a))}getHeaders(a){var b=new WebSockMessage(SockMsgId.REQUEST_ONLINE_DB_HEADERS);b.buf.Vu(a.length);for(var c=0;c<a.length;c++)b.buf.Vu(a[c]);this.send(b)}getOneGame(a){var b=new WebSockMessage(SockMsgId.REQUEST_ONLINE_DB_GAMES);
5048b.setVal(1);b.buf.Vu(1);b.buf.Vu(a);this.send(b)}getGames(a){var b=new WebSockMessage(SockMsgId.REQUEST_ONLINE_DB_GAMES);b.setVal(2);b.buf.Vu(a.length);for(var c=0;c<a.length;c++)b.buf.Vu(a[c]);this.send(b)}requestInfo(){var a=new WebSockMessage(SockMsgId.REQUEST_ONLINE_DB_USER_INFO);this.send(a)}handleReceived(a){if(!this.handleReceivedByConnector(a))try{switch(a.getType()){default:TRACE("Unhandled: "+a.toString());break;case SockMsgId.DEFAULTGROUPS:this.requestInfo();break;case SockMsgId.ONLINE_DB_STATISTICS:this.handleOnlineStatistics(a);
5049break;case SockMsgId.ONLINE_DB_USER_INFO:this.handleOnlineDBUserInfo(a);break;case SockMsgId.ONLINE_DB_NUMBERS:this.handleOnlineDBNumbers(a);break;case SockMsgId.ONLINE_DB_GAMES:this.handleGames(a);break;case SockMsgId.ONLINE_DB_HEADERS:this.handleHeaders(a);break;case SockMsgId.USER:this.handleUserMsg(a)}}catch(b){LogException(SockMsgId.toNumString(a.getType()),b)}}handleHeaders(a){a=a.getBuf();for(var b=[],c=a.Vw(),d=0;d<c;d++){a.Vc();var e=a.Vw(),f=new DataBuffer;if(0<e){for(var g=a.Vw(),h=0;h<
5050g;h++)f.writeUint8(a.readUint8());g=new Game;if(!this.loadHeader(g,f))break;for(f=0;f<this.games.length;f++)if(this.games[(f+d)%this.games.length].aGameNr==e){this.games[(f+d)%this.games.length].aGame.hdr=g.hdr;this.games[(f+d)%this.games.length].nFlags=OnlineEntryEnum.FLAGS_ONLINE_HEADER;b.push(this.games[(f+d)%this.games.length]);break}}a.Vm()}this.fireOnGames(b)}handleGames(a){var b=a.getBuf(),c=b.Vw();if(1==c&&1==a.getVal())b.Vc(),a=b.Vw(),0<a&&(c=new Game,this.readGame(c,b)&&glApp.panelMgr.loadGame(c)),
5051b.Vm();else{for(var d=[],e=0;e<c;e++){b.Vc();a=b.Vw();if(0<a){var f=new Game;if(this.readGame(f,b,a))d.push({aGame:f,aGameNr:a,nFlags:OnlineEntryEnum.FLAGS_ONLINE_HEADER|OnlineEntryEnum.FLAGS_ONLINE_GAME});else break}b.Vm()}this.isScrollLoading?this.fireOnScrollLoad(d):this.fireOnGames(d)}}handleOnlineDBNumbers(a){a=a.getBuf();var b=a.Vw(),c=a.Vw(),d=Math.min(b,this.maxGames);b=Math.min(b,this.maxGamesScrollLoad);this.fireOnNumbers(c);for(c=0;c<d;c++){var e=a.Vw();if(0<e){var f=new OnlineEntry;f.nFlags=
5052OnlineEntryEnum.FLAGS_ONLINE_ID;f.aGameNr=e;this.games.push(f)}}for(c=d;c<b;c++)e=a.Vw(),this.searchIndices.push(e);if(glApp.panelMgr&&glApp.panelMgr.setGames)glApp.panelMgr.setGames(this.games);else if(glApp.panelMgr.usesOnlineDB&&glApp.panelMgr.usesOnlineDB()){a=[];for(d=0;d<this.games.length;d++)this.games[d].nFlags==OnlineEntryEnum.FLAGS_ONLINE_ID&&a.push(this.games[d].aGameNr);0<a.length&&this.getGames(a)}}handleOnlineStatistics(a){a=a.getBuf();for(var b=new Position,c=0;64>c;c++)b.board[c]=
5053this.me.statboard[c];b.sd=this.me.statside;c=new OnlineStatistics;c.V7(a,b);this.fireOnStatistics(c)}handleOnlineDBUserInfo(a){this.nGamesInDatabase=a.getBuf().Vw();this.isReady=!0;if(this.searchOnReady){a=new SearchMask;var b=0;if(this.getGameForFirstSearch){var c=this.getGameForFirstSearch();b=c.getCurPos().getPlyNum()}else c=new Game;var d=decodeURIComponent(StrUtil.trimQuotes(StrUtil.getURLParam("search")));d?a.freeText=d:(a.setSearchBoard(c.getCurPos().board,c.getCurPos().Vj()),a.setUseBoard(!0));
5054this.fireOnReady(this.nGamesInDatabase);this.search(a,50,b)}else this.fireOnReady(this.nGamesInDatabase)}handleUserMsg(a){try{switch(a.getUserType()){default:LOG("UserMsg="+UserMsgId.toString(a.getUserType()));break;case OnlineDBUserMsgId.AUTOCOMPLETE:this.handleAutoComplete(a)}}catch(b){LogException(UserMsgId.toNumString(a.getUserType()),b)}}requestAutoComplete(a,b,c){this.autoCompleteCallbackFn=b;this.combo=c;a=new GameAutoCompleteRequest(a,GameAutoCompleteEnum.ACR_LASTNAME);b=new WebSockMessage(SockMsgId.USER);
5055a.write(b.buf);b.setUserType(OnlineDBUserMsgId.REQUEST_AUTOCOMPLETE);this.send(b)}handleAutoComplete(a){var b=new GameAutoCompleteAnswer;b.read(a.getBuf());this.autoCompleteCallbackFn(this.combo,b)}readGame(a,b,c){try{return a.read2(b)}catch(d){console.log(d)}return!1}loadHeader(a,b){try{return b.rewind(),a.hdr.read(b),!0}catch(c){LogException("OL-LH:"+c)}return!1}handleChat(a){glApp.panelMgr.chatOut(a.toString())}handleReconnectOk(a){}static InitListeners(){OnlineLobby.prototype.fireEvent||(Vk.initForListeners(OnlineLobby),
5056Vk.addEvent(OnlineLobby,"Statistics"),Vk.addEvent(OnlineLobby,"Games"),Vk.addEvent(OnlineLobby,"Ready"),Vk.addEvent(OnlineLobby,"Numbers"),Vk.addEvent(OnlineLobby,"ScrollLoad"))}}namespace("CB.V0.OnlineLobby");CB.OnlineDBUserMsgId=OnlineDBUserMsgId;CB.V0.OnlineLobby=OnlineLobby;var GameAutoCompleteEnum={ACR_NONE:0,ACR_LASTNAME:1,ACR_FIRSTNAME:2,ACR_EVENT:4,ACR_SITE:8,toString:function(a){for(var b in this)if(this[b]==a)return"GameAutoCompleteId: "+b;return"Unknown GameAutoCompleteId: "+a}};
5057class GameAutoCompleteRequest{constructor(a,b){this.m_strRequest=a;this.m_nFlags=b}write(a){a.beginSizedWrite();a.V13(this.m_nFlags);a.Vr(this.m_strRequest);a.endSizedWrite()}}class GameAutoCompleteAnswer{constructor(){}read(a){this.data=[];a.Vc();for(var b=a.V19(),c=0;c<b;c++){var d=a.V12(80);this.data.push(d)}a.Vm()}}CB.GameAutoCompleteEnum=GameAutoCompleteEnum;CB.GameAutoCompleteRequest=GameAutoCompleteRequest;CB.GameAutoCompleteAnswer=GameAutoCompleteAnswer;
5058var LocalPlayerBase=function(){var a=function(){this.instance=localforage.createInstance({name:"Player"})};a.prototype.instance=null;a.prototype.createDatabase=function(){};a.prototype.setPlayer=function(b,c,d){d?c=this.getLastNameKey(d)+","+this.getFirstNameKey(c):(c=b.player.player.m_NewCBPlayer.m_aKey,c=this.getLastNameKey(c.m_sLastName)+","+this.getFirstNameKey(c.m_sFirstName));this.instance.setItem(c,b)};a.prototype.beginGetPlayer=function(b,c,d,e,f,g){b=this.getFirstNameKey(b);c=this.getLastNameKey(c);
5059this.instance.getItem(c+","+b).then(function(h){h?f(h):g("Player not found")})};a.prototype.getPlayer=function(b,c,d,e,f){b=this.getFirstNameKey(b);c=this.getLastNameKey(c);return this.instance.getItem(`${c},${b}`)};a.prototype.getFirstNameKey=function(b){return b?b.split(/[\s-]/gi)[0]:""};a.prototype.getLastNameKey=function(b){return b.replace(/[\s-]/gi,"")};return a}();"use strict";
5060class ServerPlayerLobby extends Connector{constructor(){super();ServerPlayerLobby.initForListeners();this.name="Players";this.idPictureTicket=this.idCandidateTicket=this.idPlayerTicket=0;this.playerContext={};this.reconnectBaseTime=6E4;this.localPB=new LocalPlayerBase;this.requestQueue=[];this.connectTries=0}connect(a,b){this.callbackfnConnected=a;super.connect()}logon(){if(!this.hasIdReceived){var a=new LogonData(this.user,this.pass,LoginMode.NORMAL,glAp
5060p.Vn.guid);this.send(a.Vi(!0,!0))}}logOff(){if(this.hasIdReceived&&
5061!this.loggedOff){var a=new WebSockMessage(SockMsgId.LOGOFF);a.address(this.conn.connectId,ConnectId.SERVER);a.buf.V13(0);this.send(a);this.pingTimer.stop();this.loggedOff=!0}}notifyUserActivity(){}hasSockMsgIds(){return!0}hasSockCheckSum(){return!0}getNId(){return this.conn.connectId}getNIdBound(){return this.idBound}isGuest(){return this.client?this.client.isGuest():!0}onConnect(){this.connectTries=0;this.pingTimer.stop();this.loginMode==LoginMode.GUEST?this.logonGuest():this.logon()}sendFeedback(a,
5062b,c){this.callbackFeedback=c;c=new WebSockMessage(SockMsgId.PLAYER_BASE_USER);c.setUserType(PlayerUserMsgId.SEND_FEEDBACK);c.buf.Vr(a);c.buf.Vr(b);c.buf.V13(glApp.versionCode.nFamily);c.buf.Vr(Language.getStrUserLanguage());this.send(c)}byteArrayToBase64(a){var b="";a=new Uint8Array(a);for(var c=a.byteLength,d=0;d<c;d++)b+=String.fromCharCode(a[d]);return window.btoa(b)}Base64ToByteArray(a){a=window.atob(a);for(var b=a.length,c=new Uint8Array(b),d=0;d<b;d++)c[d]=a.charCodeAt(d);return c.buffer}addToStorage(a,
5063b,c){this.localPB.setPlayer({player:a,created:new Date},b,c)}playerFound(a,b){a=a.player;var c=new Player;c.m_NewCBPlayer=new NewCBPlayer;c.m_NewCBPlayer.m_aKey=new PlayerKey;c.m_NewCBPlayer.m_HighData=new HighPlayerData;c.setFirstName(a.player.m_NewCBPlayer.m_aKey.m_sFirstName);c.setLastName(a.player.m_NewCBPlayer.m_aKey.m_sLastName);c.setNation(a.player.m_NewCBPlayer.m_HighData.m_aNation);c.setTitle(a.player.m_NewCBPlayer.m_HighData.m_aTitle);b({player:c,pic:a.pic})}storageObjToPlayer(a){a=a.player;
5064var b=new Player;b.m_NewCBPlayer=new NewCBPlayer;b.m_NewCBPlayer.m_aKey=new PlayerKey;b.m_NewCBPlayer.m_HighData=new HighPlayerData;b.setFirstName(a.player.m_NewCBPlayer.m_aKey.m_sFirstName);b.setLastName(a.player.m_NewCBPlayer.m_aKey.m_sLastName);b.setNation(a.player.m_NewCBPlayer.m_HighData.m_aNation);b.setTitle(a.player.m_NewCBPlayer.m_HighData.m_aTitle);return b}getLocalPlayer(a,b,c,d){this.localPB.beginGetPlayer(a,b,0,0,e=>{var f=e.created;f&&f.setDate(f.getDate()+1);f&&f>new Date?c(this.storageObjToPlayer(e)):
5065d()},d)}getPlayer(a,b,c,d,e,f){var g=function(k){var l=k.created;l.getMonth||console.log("Weird date.getMonth problem ");l.getMonth&&l.setMonth(l.getMonth()+1)>new Date?this.playerFound(k,e):h()}.bind(this),h=function(k){12>++this.connectTries&&(this.isLoggedIn()||this.conn.isConnected()||this.conn.isConnecting()||this.connect(),this.requestWithTicket(a,b,c,d,function(l){this.addToStorage(l,a,b);e(l)}.bind(this)),f&&f())}.bind(this);this.localPB.beginGetPlayer(a,b,c,d,g.bind(this),h.bind(this))}async startGetMultiFlags(a,
5066b){let c=function(k,l){let m=[];for(let n=0;n<k.length;n++)m.push({player:{player:k[n].player},data:l[n]});d(m)},d=function(k){for(var l=0;l<k.length;l++)k[l]&&0!=k[l].player.found&&b(k[l].player.player,k[l].data)};var e=[];e=a;var f=[];f=e.map(k=>this.localPB.getPlayer(k.firstName,k.lastName,0,0));f=await Promise.all(f);for(let k=0;k<f.length;k++)f[k]&&(f[k].data=a[k]);d(f);f.map((k,l)=>k?{player:e[l],data:k.player}:null).filter(k=>k);f=f.map((k,l)=>k?null:e[l]);f=f.filter(k=>k);let g=[];g.push([]);
5067let h=0;for(a=0;a<f.length;a++)if(g[h].push(f[a]),20<=g[h].length){let k=g[h];(new Timer(function(){this.requestMultiPlayerInfo(k,function(l){return function(m){c(m,k)}}(h),!1)}.bind(this))).runOnce(700*(h+1));g.push([]);h++}g[h].length&&this.requestMultiPlayerInfo(g[h],function(k){return function(l){c(l,g[k])}}(h),!1)}workRequestQueue(){for(;0<this.requestQueue.length;)this.requestQueue.pop()()}requestMultiPlayerInfo(a,b,c){if(this.boundLoginOk){this.idPlayerTicket++;var d=this;this.playerContext[this.idPlayerTicket]=
5068{fnCallback:function(h){if(c)for(var k=0;k<h.length;k++)h[k].found&&d.addToStorage(h[k],a[k].firstName,a[k].lastName);b(h)}};var e=new WebSockMessage(SockMsgId.PLAYER_BASE_USER);c?e.setUserType(PlayerUserMsgId.QUERY_JS_MULTI_PLAYER_WITH_PIC):e.setUserType(PlayerUserMsgId.QUERY_JS_MULTI_PLAYER_INFO);e.buf.Vu(this.idPlayerTicket);var f=new DataBuffer;f.Vu(a.length);for(var g=0;g<a.length;g++)f.Vr(String.formatEx("{0}#{1}",a[g].lastName,a[g].firstName)),f.Vu(a[g].elo);e.buf.writeDataBuffer(f);this.send(e)}else!this.isLoggedIn()&&
50694>++this.connectTries&&!this.conn.isConnected()&&!this.conn.isConnecting()&&this.connect(),this.requestQueue.unshift(function(){this.requestMultiPlayerInfo(a,b,c)}.bind(this))}requestWithTicket(a,b,c,d,e){if(this.boundLoginOk){LOG("PBReq="+b,"","pb");this.idPlayerTicket++;this.playerContext[this.idPlayerTicket]={fnCallback:e,elo:c,year:d,player:{},pic:null};var f=new WebSockMessage(SockMsgId.PLAYER_BASE_USER);f.setUserType(PlayerUserMsgId.QUERY_JS_PLAYER_BY_NAME_AND_ELO);f.buf.Vu(this.idPlayerTicket);
5070f.buf.Vr(a);f.buf.Vr(b);f.buf.Vu(c);f.buf.Vu(d);this.send(f)}else this.requestQueue.push(function(){this.requestWithTicket(a,b,c,d,e)}.bind(this)),LOG("PlayerLobby no boundLogin")}
5070handleReceived(a){if(!this.handleReceivedByConnector(a)){LOG("PBReply="+a.getType()+"/"+a.getUserType(),"","pb");try{switch(a.getType()){default:TRACE("Unhandled: "+a.toString());break;case SockMsgId.DEFAULTGROUPS:this.boundLoginOk=!0;this.callbackfnConnected&&this.callbackfnConnected();this.workRequestQueue();this.fireOnConnected();
5071break;case SockMsgId.BINDERTIMEOUT:break;case SockMsgId.INVALIDPASSWORD:break;case SockMsgId.ALREADYLOGGEDON:break;case SockMsgId.CHAT:this.handleChat(a);break;case SockMsgId.RECONNECT_OK:this.handleReconnectOk(a);break;case SockMsgId.PLAYER_BASE_USER:this.handleUserMsg(a)}}catch(b){a=SockMsgId.toNumString(a.getType()),LogException(a,b)}}}handleUserMsg(a){try{switch(a.getUserType()){default:LOG("UserMsg="+PlayerUserMsgId.toString(a.getUserType()));break;case PlayerUserMsgId.ANS_JS_PLAYER_BY_NAME_AND_ELO:this.handleFillJSPlayer(a);
5072break;case PlayerUserMsgId.SEND_FEEDBACK_ANS:this.handleFeedback(a);break;case PlayerUserMsgId.ANS_JS_PLAYER_MULTI_PLAYER_INFO:this.handleFillJSPlayerArray(a);break;case PlayerUserMsgId.ANS_JS_MULTI_PLAYER_WITH_PIC:this.handleFillJSPlayerArrayWithPics(a)}}catch(b){a=PlayerUserMsgId.toNumString(a.getUserType()),LogException(a,b)}}handleMultiNationInfo(a){this.handleTicket(a)}handleFillPlayerItemByNameAndThumb(a){this.handleTicket(a)}handleMultiPlayerItemBNat(a){this.handleTicket(a)}handleGetBatchId(a){this.handleTicket(a)}handleCurrentPBVersion(a){a.getBuf().Vw()}handleFillPlayerByCSID(a){this.handleTicket(a)}handleFillJSPlayer(a){a=
5073a.getBuf();var b=a.Vw(),c=new Player;c.m_NewCBPlayer=new NewCBPlayer;c.m_NewCBPlayer.m_aKey=new PlayerKey;c.m_NewCBPlayer.m_HighData=new HighPlayerData;var d=a.V1c();LOG("JSPlayer: found="+d,"LogBlue","pb");if(d)if(c.setFirstName(a.V12(100)),c.setLastName(a.V12(100)),a.readInt(),c.setNation(a.readInt()),c.setTitle(a.readShort()),0!=a.readInt()){d=a.Vw();LOG("JSPlayer: found Picture, size="+d,"LogBlue","pb");for(var e=[],f=0;f<d;f++)e.push(a.readUint8());this.playerContext[b]&&this.playerContext[b].fnCallback({player:c,
5074pic:e})}else this.playerContext[b]&&this.playerContext[b].fnCallback({player:c})}handleFillJSPlayerArray(a){a=a.getBuf();var b=a.Vw();a.V19();for(var c=[];a.nPos<a.nSize;){var d=new Player;d.m_NewCBPlayer=new NewCBPlayer;d.m_NewCBPlayer.m_aKey=new PlayerKey;d.m_NewCBPlayer.m_HighData=new HighPlayerData;var e=a.V1c();d.setLastName(a.V12(100));d.setFirstName(a.V12(100));a.Vw();d.setNation(a.Vw());d.setTitle(a.readShort());c.push({found:e,player:d})}this.playerContext[b]&&this.playerContext[b].fnCallback(c)}handleFillJSPlayerArrayWithPics(a){a=
5075a.getBuf();var b=a.Vw();a.Vw();for(var c=[];a.nPos<a.nSize;){var d=new Player;d.m_NewCBPlayer=new NewCBPlayer;d.m_NewCBPlayer.m_aKey=new PlayerKey;d.m_NewCBPlayer.m_HighData=new HighPlayerData;var e=a.V1c();d.setLastName(a.V12(100));d.setFirstName(a.V12(100));a.Vw();d.setNation(a.Vw());d.setTitle(a.readShort());var f=null;if(0!=a.V19()){var g=a.Vw();f=[];for(var h=0;h<g;h++)f.push(a.readUint8())}c.push({found:e,player:d,pic:f})}this.playerContext[b]&&this.playerContext[b].fnCallback(c)}handleTicket(a){a=
5076a.getBuf();if(1==a.Vw()){a.Vw();a.Vw();var b=new Player;b.V7(a);this.callbackPlayer(b,this.me)}else{a.Vw();if(2==a.Vw()){var c=a.Vw();b=[];for(var d=0;d<c;d++)b.push(a.ReadByte())}this.callbackPortrait(b,this.me)}}handleFeedback(a){alert("thanks")}handleChat(a){var b=new ChatData;b.fromSocketsMsg(a);b.isToSession()?(a=this.watchSessions.getTitleOfSession(b.getIdSession()),a.length&&(b.strMsg="("+a+"): "+b.strMsg),glApp.panelMgr.chatOut(b.toString(),"LogKibitzChat")):glApp.panelMgr.chatOut(b.toString())}handleReconnectOk(a){var b=
5077a.getBuf().readInt();LOG("Reconnect OK, groupId="+b+", N="+a.getVal()+" idRecv="+a.getIdReceiver(),"Bold");this.fireOnConnected()}logIntoChat(){}send(a){try{0==a.Vo()&&a.Vq(this.getNId()),0==a.getIdReceiver()&&a.setIdReceiver(ConnectId.SERVER),this.conn.sendMessage(a,!this.hasSockMsgIds(),!this.hasSockCheckSum())}catch(b){LOG(b.toString()),this.timerReconnect.isActive()||this.inTorture||(this.timerReconnect.runOnce(Math.min(6E4,5E3+1E3*this.Vg),function(){this.pingServer(!0)}.bind(this)),this.Vg++)}}test(){this.logIntoChat("Start Torture");
5078this.torturer=new Torturer("ws://localhost");this.torturer.run()}test2(){this.logIntoChat("Stop Torture");this.torturer&&this.torturer.stop()}
5078sendRandomMessage(){for(var a=0;10>a;a++)switch(Math.floor(15*Math.random())){case 0:this.pingServer();break;case 1:this.changeGroup(13);break;case 2:this.changeGroup(14);break;case 3:this.requestChannels();break;case 4:this.updatePlayerStatus();break;case 5:this.lists.requestGameList(!0);break;case 7:this.lists.onShowPlayers();this.lists.onHideGames();break;
5079case 8:this.lists.onShowGames();this.lists.onHidePlayers();break;case 9:case 10:case 11:case 12:var b=new WebSockMessage(7E3+Math.floor(100*Math.random()));b.address(this.getNId(),ConnectId.SERVER);b.getType()!=SockMsgId.LOGOFF&&b.getType()!=SockMsgId.LOGON&&this.send(b);break;case 13:case 14:b=new WebSockMessage(SockMsgId.USER),b.setUserType(1E3+Math.floor(100*Math.random())),b.address(this.getNId(),ConnectId.SERVER),this.send(b)}}static initForListeners(){ServerPlayerLobby.prototype.fireEvent||
5080(Vk.initForListeners(ServerPlayerLobby),Vk.addEvent(ServerPlayerLobby,"Connected"))}}"use strict";var Candidate=function(){var a=function(){};a.prototype.read=function(b){this.strLastName=b.V12(100);this.strFirstName=b.V12(100);this.aNation=b.Vw();this.nElo=b.Vw()};return a}();"use strict";
5081var HighPlayerData=function(){var a=function(){};a.prototype.V7=function(b){this.setDeathDate(b.V11());this.setCurrentTitle(new CBTitle(b.Vx()));this.setNation(b.Vx());this.setBornNation(b.Vx());this.setIsMale(b.V1c())};a.prototype.setDeathDate=function(b){this.m_aDeathDate=b};a.prototype.getDeathDate=function(){return this.m_aDeathDate};a.prototype.getCurrentTitle=function(){return this.m_aTitle};a.prototype.setCurrentTitle=function(b){this.m_aTitle=b};a.prototype.getNation=function(){return this.m_aNation};
5082a.prototype.setNation=function(b){this.m_aNation=b};a.prototype.getBornNation=function(){return this.m_aBornNation};a.prototype.setBornNation=function(b){this.m_aBornNation=b};a.prototype.getIsMale=function(){return this.m_isMale};a.prototype.setIsMale=function(b){this.m_isMale=b};return a}();"use strict";
5083var LowPlayerData=function(){var a=function(){};a.prototype.read=function(b){this.m_Titles=[];this.m_TitleDate=[];this.m_OtherNations=[];this.m_ChangeDate=[];for(var c=0;5>c;c++){var d=new CBTitle(b.Vx());this.m_Titles.push(d);d=b.V11();this.m_TitleDate.push(d)}this.m_ChangedBornNation=b.V11();for(c=0;10>c;c++)d=b.Vx(),this.m_OtherNations.push(d),d=b.V11(),this.m_ChangeDate.push(d)};a.prototype.getPrevTitle=function(b){return this.m_Titles[b]};a.prototype.setPrevTitle=function(b,c){this.m_Titles[b]=
5084c};a.prototype.getPrevTitleDate=function(b){return this.m_TitleDate[b]};a.prototype.setPrevTitleDate=function(b,c){this.m_TitleDate[b]=c};a.prototype.getChangedBornNation=function(){return this.m_ChangedBornNation};a.prototype.setChangedBornNation=function(b){this.m_ChangedBornNation=b};a.prototype.getNextNation=function(b){return this.m_OtherNations[b]};a.prototype.setNextNation=function(b,c){this.m_OtherNations[b]=c};a.prototype.getNextChangedDate=function(b){return this.m_ChangeDate[b]};a.prototype.setNextChangedDate=
5085function(b,c){this.m_ChangeDate[b]=c};a.prototype.getMaxTitles=function(){return 5};a.prototype.getMaxNations=function(){return 10};return a}();"use strict";
5086var NewCBPlayer=function(){var a=function(){this.m_aKey=new PlayerKey};a.prototype.V7=function(b,c){this.m_aKey=new PlayerKey;if(0<(c&Player.prototype.PL.PL_DATA_KEY)&&!this.m_aKey.V7(b))return!1;this.m_HighData=new HighPlayerData;0<(c&Player.prototype.PL.PL_DATA_HIGH)&&this.m_HighData.V7(b);this.m_LowData=new LowPlayerData;0<(c&Player.prototype.PL.PL_DATA_LOW)&&this.m_LowData.read(b);return!0};a.prototype.getLastName=function(){return this.m_aKey.getLastName()};a.prototype.setLastName=function(b){this.m_aKey.setLastName(b)};
5087a.prototype.getFirstName=function(){return this.m_aKey.getFirstName()};a.prototype.setFirstName=function(b){this.m_aKey.setFirstName(b)};a.prototype.setKey=function(b){this.m_aKey=b};a.prototype.getKey=function(){return this.m_aKey};a.prototype.getRHighPlayerData=function(){return this.m_HighData};a.prototype.getRLowPlayerData=function(){return this.m_LowData};a.prototype.getMaxTitles=function(){return this.GetRLowPlayerData().getMaxTitles()};a.prototype.getMaxNations=function(){return this.GetRLowPlayerData().getMaxNations()};
5088return a}();"use strict";
5089var Player=function(){var a=function(){};a.prototype.PFN={PFN_RAW:0,PFN_ARR:1,PFN_BMP:2};a.prototype.PL={PL_DATA_KEY:1,PL_DATA_HIGH:2,PL_DATA_LOW:4,PL_DATA_ELO:8,PL_DATA_ONE_
5089ELO:16,PL_DATA_PICS:32,PL_DATA_ONE_PIC:64};a.prototype.PL_DATA_ALL=a.prototype.PL.PL_DATA_KEY+a.prototype.PL.PL_DATA_HIGH+a.prototype.PL.PL_DATA_LOW+a.prototype.PL.PL_DATA_ELO+a.prototype.PL.PL_DATA_PICS;a.prototype.V7=function(b){try{b.Vc(),this.m_nDataMask=b.V19(),this.m_NewCBPlayer=new NewCBPlayer,this.m_NewCBPlayer.V7(b,this.m_nDataMask),
5090this.m_EloArray=new EloArray,0<(this.m_nDataMask&this.PL.PL_DATA_ELO)?this.m_EloArray.V7(b):0<(this.m_nDataMask&this.PL.PL_DATA_ONE_ELO)&&this.m_EloArray.readLatestFromDataBuffer(b),this.m_MMNameArray=new MMNameArray,0<(this.m_nDataMask&this.PL.PL_DATA_PICS)?this.m_MMNameArray.V7(b):0<(this.m_nDataMask&this.PL.PL_DATA_ONE_PIC)&&this.m_MMNameArray.V7(b),this.setModifyDate(b.V11()),b.Vm()}catch(c){return!1}return!0};a.prototype.getRPlayerKey=function(){return this.m_NewCBPlayer.GetKey()};a.prototype.getCBId=
5091function(){return this.m_NewCBPlayer.GetKey().GetCBId()};a.prototype.setCBId=function(b){this.m_NewCBPlayer.GetKey().SetCBId(b)};a.prototype.getMediaId=function(){return this.m_nMediaId};a.prototype.setMediaId=function(b){this.m_nMediaId=b};a.prototype.getRKey=function(){return this.m_NewCBPlayer.GetKey()};a.prototype.getRNewCBPlayer=function(){return this.m_NewCBPlayer};a.prototype.getREloArray=function(){return this.m_EloArray};a.prototype.getRMMNameArray=function(){return this.m_MMNameArray};a.prototype.hasFotos=
5092function(){return 0<this.m_MMNameArray.Count()};a.prototype.getFirstName=function(){return this.m_NewCBPlayer.getFirstName()};a.prototype.setFirstName=function(b){this.m_NewCBPlayer.setFirstName(b)};a.prototype.setFirstName2=function(b){this.m_NewCBPlayer.setFirstName(b)};a.prototype.getLastName=function(){return this.m_NewCBPlayer.getLastName()};a.prototype.setLastName=function(b){this.m_NewCBPlayer.setLastName(b)};a.prototype.getBirthDate=function(){return this.getRPlayerKey().GetBirthDate()};a.prototype.setBirthDate=
5093function(b){this.getRPlayerKey().setBirthDate(b)};a.prototype.getIdenticalCount=function(){return this.getRPlayerKey().getIdenticalCount()};a.prototype.getTitle=function(){return this.m_NewCBPlayer.getRHighPlayerData().getCurrentTitle()};a.prototype.setTitle=function(b){this.m_NewCBPlayer.getRHighPlayerData().setCurrentTitle(b)};a.prototype.getNation=function(){return this.m_NewCBPlayer.getRHighPlayerData().GetNation()};a.prototype.setNation=function(b){this.m_NewCBPlayer.getRHighPlayerData().setNation(b)};
5094a.prototype.getBornNation=function(){return this.m_NewCBPlayer.getRHighPlayerData().getBornNation()};a.prototype.getDeathDate=function(){return this.m_NewCBPlayer.getRHighPlayerData().GetDeathDate()};a.prototype.setDeathDate=function(b){this.m_NewCBPlayer.getRHighPlayerData().setDeathDate(b)};a.prototype.getIsMal=function(){return this.m_NewCBPlayer.getRHighPlayerData().getIsMale()};a.prototype.setIsMale=function(b){this.m_NewCBPlayer.getRHighPlayerData().setIsMale(b)};a.prototype.setDataMask=function(b){this.m_nDataMask=
5095b};a.prototype.getDataMask=function(){return this.m_nDataMask};a.prototype.getVersion=function(){return this.m_nVersion};a.prototype.setDateCached=function(b){this.m_dCached=b};a.prototype.getDateCached=function(){return this.m_dCached};a.prototype.setModifyDate=function(b){this.m_aModifyDate=b};a.prototype.getModifyDate=function(){return this.m_aModifyDate};return a}();"use strict";
5096var PlayerKey=function(){var a=function(b,c){this.m_nIdenticalCount=0;this.m_nCBId=-1;this.m_sFirstName=b;this.m_sLastName=c};a.prototype.write=function(b){b.Vr(this.m_sLastName);b.Vr(this.m_sFirstName);b.Vt(this.m_aBirthDate);b.Vv(this.m_nIdenticalCount);b.Vu(this.m_nCBId)};a.prototype.V7=function(b){this.m_sLastName=b.V12(100);this.m_sFirstName=b.V12(100);this.m_aBirthDate=b.V11();this.m_nIdenticalCount=b.Vx();this.m_nCBId=b.Vw();return!0};a.prototype.getStr=function(){var b=this.m_sLastName;return b+=
5097", "+this.m_sFirstName};a.prototype.getCheckSum=function(){for(var b=0,c=0;c<this.m_sLastName.Length;c++)b+=this.m_sLastName[c];for(c=0;c<this.m_sFirstName.Length;c++)b+=this.m_sFirstName[c];b+=this.m_aBirthDate.GetYear();return b+=this.m_nIdenticalCount};a.prototype.getFirstName=function(){return this.m_sFirstName};a.prototype.setFirstName=function(b){this.m_sFirstName=b};a.prototype.getLastName=function(){return this.m_sLastName};a.prototype.setLastName=function(b){this.m_sLastName=b};a.prototype.getBirthDate=
5098function(){return this.m_aBirthDate};a.prototype.setBirthDate=function(b){this.m_aBirthDate=b};a.prototype.getIdenticalCount=function(){return this.m_nIdenticalCount};a.prototype.setIdenticalCount=function(b){this.m_nIdenticalCount=b};a.prototype.incIdenticalCount=function(){this.m_nIdenticalCount++};a.prototype.getCBId=function(){return this.m_nCBId};a.prototype.setCBId=function(b){this.m_nCBId=b};a.prototype.m_aBirthDate=new CBDate;return a}();
5099let PlayerUserMsgId={QUERY_MULTI_NATION_INFO:1300,QUERY_FILL_PLAYERITEM_BY_NAME_AND_THUMB:1301,QUERY_FILL_PLAYERITEM_BY_NAME:1302,QUERY_FILL_MULTIPLAYERITEM_BNAT:1303,QUERY_GET_BATCH_ID:1304,QUERY_CURRENT_PB_VERSION:1305,QUERY_FILL_PLAYER_BY_CBID:1306,QUERY_FILL_CA
5099NDIDATES_ARRAY:1307,QUERY_FILL_PICTURE:1308,ANS_MULTI_NATION_INFO:1309,ANS_FILL_PLAYERITEM_BY_NAME_AND_THUMB:1310,ANS_FILL_PLAYERITEM_BY_NAME:1311,ANS_FILL_MULTIPLAYERITEM_BNAT:1312,ANS_GET_BATCH_ID:1313,ANS_CURRENT_PB_VERSION:1314,ANS_FILL_PLAYER_BY_CBID:1315,
5100ANS_FILL_CANDIDATES_ARRAY:1316,ANS_FILL_PICTURE:1317,SEND_FEEDBACK:1320,SEND_FEEDBACK_ANS:1321,QUERY_JS_PLAYER_BY_NAME_AND_ELO:1322,ANS_JS_PLAYER_BY_NAME_AND_ELO:1323,QUERY_JS_MULTI_PLAYER_INFO:1324,ANS_JS_PLAYER_MULTI_PLAYER_INFO:1325,QUERY_JS_MULTI_PLAYER_WITH_PIC:1326,ANS_JS_MULTI_PLAYER_WITH_PIC:1327,toString:function(a){for(var b in this)if(this[b]==a)return b;return"Unknown PBUserMsgId: "+a},toNumString:function(a){return"PlUserMsgId="+a}};"use strict";
5101var EloArray=function(){var a=function(){};a.prototype.V7=function(b){b.Vc();this.clear();var c=b.Vw();if(4096<c)return!1;if(0<c)for(var d=b.V1c(),e=0;e<c;e++){var f=new EloNumber(d);f.V7(b);this.vecElo.push(f)}b.Vm();return!0};a.prototype.readLatestFromDataBuffer=function(b){return this.ReadFromDataBuffer(b)};a.prototype.clear=function(){this.vecElo?this.vecElo.clear():this.vecElo=[]};a.prototype.getTrendStr=function(b){for(var c=this.count()-1,d="",e=0;e<b;e++){var f=c-1;if(0<=f){for(var g=this.vecElo[c].getDate().month;0<=
5102f&&6>Math.abs(g-this.vecElo[f].getDate().month);)f--;0<=f&&(c=this.vecElo[c].getNElo()-this.vecElo[f].getNElo(),d=10<=Math.abs(c)?0<c?"+"+d:"-"+d:"0"+d);c=f}}return d.length==b?d:""};a.prototype.getNBestElo=function(b){b=this.vecElo[0].getNElo();this.vecElo[0].getDate();for(var c=0;c<this.vecElo.length;c++){var d=this.vecElo[c];d.getNElo()>b&&(b=d.getNElo(),d.getDate())}return b};a.prototype.getNWorstElo=function(b){b=this.vecElo[0].getNElo();this.vecElo[0].getDate();for(var c=0;c<this.vecElo.length;c++){var d=
5103this.vecElo[c];d.getNElo()<b&&(b=d.getNElo(),d.getDate())}return b};a.prototype.getApproxElo=function(b,c){for(var d=0,e=0,f=0;f<this.vecElo.length;f++){var g=this.vecElo[f];g.getDate().getYear()>=b&&g.getDate().getYear()<=c&&(d+=g.getNElo(),e++)}return 0<e?d/e:0};a.prototype.getBestMatchEloByDate=function(b){b=0;0<this.vecElo.length&&(b=this.vecElo[this.vecElo.length-1].getNElo());return b};a.prototype.count=function(){return this.vecElo.length};a.prototype.get=function(b){return b<this.vecElo.length?
5104this.vecElo[b]:new EloNumber};return a}();"use strict";var EloNumber=function(){var a=function(b){this.bOld=b};a.prototype.V7=function(b){b.Vc();this.nRatingId=b.Vw();this.nElo=b.Vx();this.aDate=b.V11();this.bFide=b.V1c();this.aRating=new ExtRatingType12;this.aRating.V7(b);this.nRank=b.Vw();b.Vm()};a.prototype.getDate=function(){return this.aDate};a.prototype.getNElo=function(){return this.aRating.getRating()};return a}();"use strict";
5105var ExtRatingType12=function(){var a=function(){};a.prototype.V7=function(b){this.nFlags=b.Vx();this.nRating=b.Vx();this.aNation=b.readUint8();this.sProvider=b.Vx();return!0};a.prototype.getRating=function(){return this.nRating};return a}();"use strict";
5106var MMNameArray=function(){var a=function(){};a.prototype.V7=function(b){var c=b.Vx();this.clear();for(var d=0;d<c;d++){var e=new PLMMRecord;e.V7(b);this.append(e)}};a.prototype.getRecord=function(b){return this.vecMM[b]};a.prototype.append=function(b){this.vecMM.push(b)};a.prototype.count=function(){return this.vecMM.Count};a.prototype.clear=function(){this.vecMM?this.vecMM.clear():this.vecMM=[]};return a}();"use strict";
5107var PLMMRecord=function(){var a=function(){};a.prototype.V7=function(b){this.nSerial=b.Vw();this.aDate=b.V11();this.nMediaType=b.Vx();this.sName=b.Vb(100);this.sAuthor=b.Vb(100);this.sLocation=b.Vb(100);this.isExact=b.V1c()};a.prototype.V9=function(b){b.Vu(this.nSerial);b.Vt(this.aDate);b.Vv(this.nMediaType);b.Va(this.sName);b.Va(this.sAuthor);b.Va(this.sLocation);b.V1b(this.isExact)};return a}();"use strict";
5108var CBTitle=function(){var a=function(b){this.eTitleCode=b};a.prototype.Code={CBTC_NONE:0,CBTC_MARKED:1,CBTC_HGM:2,CBTC_WFM:4,CBTC_WIM:8,CBTC_FM:16,CBTC_IM:32,CBTC_WWCH:64,CBTC_WCH:128};a.prototype.Code.CBTC_WGM=a.prototype.Code.CBTC_WIM|a.prototype.Code.CBTC_WFM;a.prototype.Code.CBTC_GM=a.prototype.Code.CBTC_IM|a.prototype.Code.CBTC_FM;a.getStr=function(b){if((b&a.prototype.Code.CBTC_GM)==a.prototype.Code.CBTC_GM)return"GM";if((b&a.prototype.Code.CBTC_WGM)==a.prototype.Code.CBTC_WGM)return"WGM";
5109if(b&a.prototype.Code.CBTC_WCH)return"WCH";if(b&a.prototype.Code.CBTC_WWCH)return"WWCH";if(b&a.prototype.Code.CBTC_WIM)return"WIM";if(b&a.prototype.Code.CBTC_WFM)return"WFM";if(b&a.prototype.Code.CBTC_IM)return"IM";if(b&a.prototype.Code.CBTC_FM)return"FM";if(b&a.prototype.Code.CBTC_HGM)return"HGM"};a.prototype.getAllTitles=function(){var b="";0<(this.eTitleCode&a.prototype.Code.CBTC_WCH)&&(b+="WCH, ");0<(this.eTitleCode&a.prototype.Code.CBTC_WWCH)&&(b+="WWCH, ");(this.eTitleCode&a.prototype.Code.CBTC_GM)==
5110a.prototype.Code.CBTC_GM?b+="GM, ":0<(this.eTitleCode&a.prototype.Code.CBTC_IM)?b+="IM, ":0<(this.eTitleCode&a.prototype.Code.CBTC_FM)&&(b+="FM, ");(this.eTitleCode&a.prototype.Code.CBTC_WGM)==a.prototype.Code.CBTC_WGM?b+="WGM, ":0<(this.eTitleCode&a.prototype.Code.CBTC_WIM)?b+="WIM, ":0<(this.eTitleCode&a.prototype.Code.CBTC_WFM)&&(b+="WFM, ");0<(this.eTitleCode&a.prototype.Code.CBTC_HGM)&&(b+="HGM, ");0<(this.eTitleCode&a.prototype.Code.CBTC_MARKED)&&(b+="VIP, ");return b};return a}();"use strict";
5111class ChessKnowledge{constructor(){}static isEndgame(a){var b=Attack.sumMaterial(a,Side.WHITE),c=Attack.sumMaterial(a,Side.BLACK);return 12>a.getPieces().length&&2100>b+c}static getOpposition(a,b){var c=CBSquare.getFile(a),d=CBSquare.getFile(b);a=CBSquare.getRank(a);b=CBSquare.getRank(b);if(c==d&&2==Math.abs(a-b))return d=[],a>b?(0<=c-1&&8>b+1&&d.push(8*(c-1)+b+1),8>b+1&&d.push(8*(c+0)+b+1),8>c+1&&8>
5111b+1&&d.push(8*(c+1)+b+1)):(0<=c-1&&8>a+1&&d.push(8*(c-1)+a+1),8>a+1&&d.push(8*(c+0)+a+1),8>c+1&&8>
5112a+1&&d.push(8*(c+1)+a+1)),d;if(a==b&&2==Math.abs(c-d))return a=[],c>d?(8>d+1&&0<=b-1&&a.push(8*(d+1)+b-1),8>d+1&&a.push(8*(d+1)+b+0),8>d+1&&8>b+1&&a.push(8*(d+1)+b+1)):(8>c+1&&0<=b-1&&a.push(8*(c+1)+b-1),8>c+1&&a.push(8*(c+1)+b+0),8>c+1&&8>b+1&&a.push(8*(c+1)+b+1)),a}static isPassedPawn(a,b,c){a=a.board;if((a[b]&Piece.PIECE_MASK)==Piece.PAWN&&(a[b]&Piece.COLOUR)==c){c=CBSquare.getFile(b);var d=CBSquare.getRank(b);if(a[b]&Piece.COLOUR)for(b=Piece.PAWN,--d;1<=d;d--){var e=-1,f=void 0,g=-1;7>c&&(e=CBSquare.gen(c+
51131,d));0<c&&(g=CBSquare.gen(c-1,d));f=CBSquare.gen(c,d);if(0<=e&&a[e]==b||0<=g&&a[g]==b||(a[f]&Piece.PIECE_MASK)==Piece.PAWN)return!1}else for(b=Piece.PAWN|Piece.COLOUR,d+=1;6>=d;d++)if(g=e=-1,0<c&&(e=CBSquare.gen(c-1,d)),7>c&&(g=CBSquare.gen(c+1,d)),f=CBSquare.gen(c,d),0<=e&&a[e]==b||0<=g&&a[g]==b||(a[f]&Piece.PIECE_MASK)==Piece.PAWN)return!1;return!0}return!1}static testPassedPawns(){var a=[{fen:"8/8/7k/2P5/8/5K2/8/8 w - - 0 1",passed:!0,sq:20},{fen:"8/8/2p4k/2P5/8/5K2/8/8 b - - 0 1",passed:!1,sq:21},
5114{fen:"8/8/7k/8/3pP3/3P3K/8/8 w - - 0 1",passed:!0,sq:35},{fen:"8/8/7k/1P6/1P6/7K/8/8 w - - 0 1",passed:!1,sq:11},{fen:"8/8/7k/1P6/1P6/7K/8/8 w - - 0 1",passed:!0,sq:12},{fen:"8/8/5p1k/8/4P3/7K/8/8 w - - 0 1",passed:!1,sq:45},{fen:"8/8/4p3/3P3k/8/6K1/8/8 w - - 0 1",passed:!1,sq:28},{fen:"8/7k/8/7K/2p5/8/2P5/8 w - - 0 1",passed:!1,sq:19},{fen:"8/7k/8/7K/8/8/7p/8 w - - 0 1",passed:!0,sq:57}];for(let c=0;c<a.length;c++){var b=new Position(a[c].fen);console.log(String.f("{1}. Passed Pawns {0}",a[c].fen,
5115c));(b=ChessKnowledge.isPassedPawn(b,a[c].sq,b.board[a[c].sq]&Piece.COLOUR))?console.log(String.f("Passed OK on {0}",CBSquare.toString(a[c].sq))):console.log(String.f("NO Passed Pawn {0}",CBSquare.toString(a[c].sq)));b!=a[c].passed?console.log("TEST FAILED"):console.log("TEST OK")}}}"use strict";
5116class BeautyScore{constructor(){this.reset()}reset(){this.active=!0;this.movesWithoutHint=this.totalHangVal=this.hangPieceScore=this.hangPieceCount=this.totalSacVal=this.sacsScore=this.sacsCount=this.mateScore=0;this.smotheredMate=this.mateWithAPawn=this.fullBoardMate=this.hintedThis=!1;this.totalSacValPerMove=[];this.totalHangValPerMove=[];this.sacsScorePerMove=[];this.hangPieceScorePerMove=[];this.saccedQueens=[];this.saccedRooks=[];this.saccedBishops=[];this.saccedKnights=[];this.saccedPawns=[];
5117this.maxHang=null;this.maxHangDiff=0;this.underPromotionScorePerMove=[];this.underPromotionScore=0;this.doubleRooksSeventhRank=!1}getScore(){return this.getMateScore()+this.sacsScore+this.hangPieceScore+this.underPromotionScore+(this.doubleRooksSeventhRank?5:0)}toString(){return String.f("Beauty Score - Mate: {0}, SacsScore={1}/{2}, HangPieceScore={3}/{4}",this.getMateScore(),this.sacsScore,this.sacsCount,this.hangPieceScore,this.hangPieceCount)}updateBeautyScores(a){this.totalSacValPerMove=this.totalSacValPerMove.splice(0,
5118a);this.sacsScorePerMove=this.sacsScorePerMove.splice(0,a);this.sacsCount=this.getSacsCount();this.totalSacVal=this.getTotalSacVal();this.sacsScore=this.getSacsScore();this.totalHangValPerMove=this.totalHangValPerMove.splice(0,a);this.hangPieceScorePerMove=this.hangPieceScorePerMove.splice(0,a);this.hangPieceCount=this.getHangPiecesCount();this.totalHangVal=this.getTotalHangVal();this.hangPieceScore=this.getHangPiecesScore();this.underPromotionScorePerMove=this.underPromotionScorePerMove.splice(0,
5119a);this.underPromotionScore=this.getUnderPromotionScore()}getSacsScore(){return this.sacsScorePerMove.reduce((a,b)=>a+b,0)}getSacsCount(){return this.totalSacValPerMove.filter(function(a){return 0!=a}).length}getTotalSacVal(){return this.totalSacValPerMove.reduce((a,b)=>a+b,0)}getSaccedPieceCount(a){return a.reduce((b,c)=>b+c,0)}getHangPiecesScore(){return this.hangPieceScorePerMove.reduce((a,b)=>a+b,0)}getHangPiecesCount(){return this.totalHangValPerMove.filter(function(a){return 0!=a}).length}getTotalHangVal(){return this.totalHangValPerMove.reduce((a,
5120b)=>a+b,0)}getUnderPromotionScore(){return this.underPromotionScorePerMove.reduce((a,b)=>a+b,0)}getUnderPromotionCount(){return this.underPromotionScorePerMove.filter(function(a){return 0!=a}).length}initScoreArray(a,b){a.length=b;
5120for(var c=a[b]=0;c<b;c++)void 0==a[c]&&(a[c]=0);return a}onEnteredMove(a,b,c){if(!this.isQueensGambit(a,b)){var d=a.getCurPos();this.hintedThis?this.hintedMoves++:this.movesWithoutHint++;this.hintedThis=!1;if(c){c=this.calcSacScoreOnMove(a,b,d);var e=new Game;e.exec(a);
5121let h=Att.pieceVal(e.getCurPos().board[b.to]);e.makeMove(b);var f=new Att,g=f.getHangingPieces(e.getCurPos(),d.Vj(),0);d=f.getHangingPieces(e.getCurPos(),Side.other(d.Vj()),0);f=0;g=this.getMaxHangVal(e,g,b.to);g>h&&(LOG("MaxHangMeVal=",g),e=this.getMaxHangVal(e,d,-1),LOG("MaxHangOppVal=",e),a=this.getNonRecaptureHang(a,b),this.maxHangDiff=Math.max(0,f=g-e+a),0>=this.maxHangDiff&&this.resetHangingPiecesVars());return{score:c.score,att:c.attCalc,hang:f,hasBeauty(){return 0>this.att||0<this.hang}}}return 0}}calcSacScoreOnMove(a,
5122b,c){a=a.getMoveIndex();let d=(new Att).calc(c,b.from,b.to),e=0;this.totalSacValPerMove=this.initScoreArray(this.totalSacValPerMove,a);this.saccedQueens=this.initScoreArray(this.saccedQueens,a);this.saccedRooks=this.initScoreArray(this.saccedRooks,a);this.saccedBishops=this.initScoreArray(this.saccedBishops,a);this.saccedKnights=this.initScoreArray(this.saccedKnights,a);this.saccedPawns=this.initScoreArray(this.saccedPawns,a);if(0>d){this.totalSacValPerMove[a]=Math.abs(d);this.totalSacVal=this.getTotalSacVal();
5123this.sacsCount=this.getSacsCount();switch(c.board[b.from]){case Piece.W_QUEEN:case Piece.B_QUEEN:this.saccedQueens[a]=1;break;case Piece.W_ROOK:case Piece.B_ROOK:this.saccedRooks[a]=1;break;case Piece.W_BISHOP:case Piece.B_BISHOP:this.saccedBishops[a]=1;break;case Piece.W_KNIGHT:case Piece.B_KNIGHT:this.saccedKnights[a]=1;break;default:this.saccedPawns[a]=1}e=1;-200>d&&(e+=3);-400>=d&&(e+=5);-650>d&&(e+=8)}this.sacsScorePerMove=this.initScoreArray(this.sacsScorePerMove,a);this.sacsScorePerMove[a]=
5124e;this.sacsScore=this.getSacsScore();return{score:e,attCalc:d}}isQueensGambit(a,b){return 2==a.getMoveCount()&&19==b.to}getMaxHangVal(a,b,c){var d=0;for(let e=0;e<b.length;e++)if(b[e].attackVal>d&&b[e].sq!=c){let f=this.getCapturedOnSquareVal(a,b[e].sq);LOG(String.f("CaptOnSqVal={0} {1}",f,CBSquare.toString(b[e].sq)));b[e].attackVal-f>d&&(d=b[e].attackVal-f,this.maxHang=b[e])}return d}getCapturedOnSquareVal(a,b){for(a.gotoEnd();0<a.getMoveNo();)if(a.gotoPrev(),a.getNextMove().to==b)return Att.pieceVal(a.getCurPos().board[b]);
5125return 0}getNonRecaptureHang(a,b){var c=a.getLastMove();return c.vct&&b.to!=c.to&&(c=this.getCapturedOnSquareVal(a,c.to),a=Att.pieceVal(a.getCurPos().board[b.to]),c>a)?c-a:0}resetHangingPiecesVars(){this.maxHang=null;this.maxHangDiff=0}addHangingPieceScore(a,b){var c=a.getMoveIndex()-2,d=1;200<this.maxHangDiff&&(d+=3);400<=this.maxHangDiff&&(d+=5);650<this.maxHangDiff&&(d+=8);a.gotoPrev();a.getNextMove().to==b.sq?(this.totalSacValPerMove=this.initScoreArray(this.totalSacValPerMove,c),this.totalSacValPerMove[c]=
5126this.maxHangDiff,this.sacsCount=this.getSacsCount(),this.totalSacVal=this.getTotalSacVal(),this.sacsScorePerMove=this.initScoreArray(this.sacsScorePerMove,c),this.sacsScorePerMove[c]=d,this.sacsScore=this.getSacsScore()):(this.totalHangValPerMove=this.initScoreArray(this.totalHangValPerMove,c),this.totalHangValPerMove[c]=this.maxHangDiff,this.hangPieceCount=this.getHangPiecesCount(),this.totalHangVal=this.getTotalHangVal(),this.hangPieceScorePerMove=this.initScoreArray(this.hangPieceScorePerMove,
5127c),this.hangPieceScorePerMove[c]=d,this.hangPieceScore=this.getHangPiecesScore())}addMateScore(a){this.mateScore++;this.fullBoard(a)&&(this.mateScore+=3,this.fullBoardMate=!0);this.isMateWithAPawn(a)&&(this.mateScore+=5,this.mateWithAPawn=!0);this.isSmotheredMate(a)&&(this.mateScore+=6,this.smotheredMate=!0);this.queensOnBoard(a)&&this.mateScore++;this.sideToMoveIsMaterialUpLT(a,200)&&this.mateScore++;this.sideToMoveIsMaterialUpLT(a,-100)&&this.mateScore++}getMateScore(){return this.mateScore}notifyHinted(){this.hintedMoves++;
5128this.hintedThis=!1}notifyNotHinted(){this.hintedMoves++;this.hintedThis=!1}queensOnBoard(a){return 0<a.countPieces(Piece.W_QUEEN)&&0<a.countPieces(Piece.B_QUEEN)}fullBoard(a){return 1==a.countPieces(Piece.W_QUEEN)&&1==a.countPieces(Piece.B_QUEEN)&&2==a.countPieces(Piece.W_ROOK)&&2==a.countPieces(Piece.B_ROOK)&&2==a.countPieces(Piece.W_BISHOP)&&2==a.countPieces(Piece.B_BISHOP)&&2==a.countPieces(Piece.W_KNIGHT)&&2==a.countPieces(Piece.B_KNIGHT)&&8==a.countPieces(Piece.W_PAWN)&&8==a.countPieces(Piece.B_PAWN)}isMateWithAPawn(a){var b=
5129Piece.B_KING,c=Piece.W_PAWN,d=-9,e=7;a.Vj()==Side.WHITE&&(b=Piece.W_KING,c=Piece.B_PAWN,d=-7,e=9);for(var f=0;64>f&&a.board[f]!=b;f++);return a.board[f+d]==c||a.board[f+e]==c?!0:!1}isSmotheredMate(a){var b=Piece.B_KING,c=Piece.W_KNIGHT,d=[17,-17,15,-15,10,-10,6,-6];a.Vj()==Side.WHITE&&(b=Piece.W_KING,c=Piece.B_KNIGHT);for(var e=0;64>e&&a.board[e]!=b;e++);for(b=0;b<d.length;b++)if(a.board[e+d[b]]==c){c=[8,-8,9,-9,7,-7,1,-1];d=e%8+1;b=parseInt(e/8)+1;for(var f=0;f<c.length;f++)if(!(63<e+c[f])){var g=
5130(e+c[f])%8+1,h=parseInt((e+c[f])/8)+1;if(!(1<Math.abs(d-g)||1<Math.abs(b-h))&&a.board[e+c[f]]==Piece.NONE)return!1}return!0}return!1}checkUnderPromotionScore(a,b){this.underPromotionScorePerMove=this.initScoreArray(this.underPromotionScorePerMove,a);switch(b.prom){case Piece.W_ROOK:case Piece.B_ROOK:this.underPromotionScorePerMove[a]=5;break;case Piece.W_BISHOP:case Piece.B_BISHOP:this.underPromotionScorePerMove[a]=10;break;case Piece.W_KNIGHT:case Piece.B_KNIGHT:this.underPromotionScorePerMove[a]=
513112}}checkDoubleRooksSeventhRank(a,b){var c=b.to%8+1;a=a.getCurPos();var d=0;if(a.board[b.to]==Piece.W_ROOK&&7==c)for(b=CBSquare.A7;b<=CBSquare.H7&&(a.board[b]!=Piece.W_ROOK||(d++,2!=d));b+=8);else if(a.board[b.to]==Piece.B_ROOK&&2==c)for(d=0,b=CBSquare.A2;b<=CBSquare.H2&&(a.board[b]!=Piece.B_ROOK||(d++,2!=d));b+=8);this.doubleRooksSeventhRank=2==d}sideToMoveIsMaterialUpLT(a,b){var c=Attack.sumMaterial(a,Side.WHITE),d=Attack.sumMaterial(a,Side.BLACK);return a.Vj()==Side.WHITE?c-d<b:d-c<b}}
5132class SwapStack{constructor(a){this.swapVal=Array(32);this.next=1;this.sign=-1;this.swapVal[0]=a}
5132add(a){this.swapVal[this.next]=this.swapVal[this.next-1]+this.sign*a;this.next++;this.sign=-this.sign}pop(){this.next--}miniMax(){let a=0;if(0<this.next){this.next--;for(this.sign=this.next&1?-1:1;0<this.next;)0>this.sign?this.swapVal[this.next]<this.swapVal[this.next-1]&&(this.swapVal[this.next-1]=this.swapVal[this.next]):this.swapVal[this.next]>this.swapVal[this.next-1]&&(this.swapVal[this.next-1]=this.swapVal[this.next]),
5133this.next--,this.sign=-this.sign;a=this.swapVal[0]}return a}}
5134class Att{constructor(){Att.MU1=1;Att.MU2=2;Att.ML1=4;Att.ML2=8;Att.MD1=16;Att.MD2=32;Att.MR1=64;Att.MR2=-128;Att.MU2R1=Att.MU1|Att.MU2|Att.MR1;Att.MU1R2=Att.MU1|Att.MR1|Att.MR2;Att.MD1R2=Att.MD1|Att.MR1|Att.MR2;Att.MD2R1=Att.MD1|Att.MD2|Att.MR1;Att.MD2L1=Att.MD1|Att.MD2|Att.ML1;Att.MD1L2=Att.MD1|Att.ML1|Att.ML2;Att.MU1L2=Att.MU1|Att.ML1|Att.ML2;Att.MU2L1=Att.MU1|Att.MU2|Att.ML1;Att.SEARCH_A=0;Att.SEARCH_F=56;Att.SEARCH_R=7;Att.cDir=[Att.ML1|Att.MD1,Att.ML1|Att.MD2,Att.ML1,Att.ML1,Att.ML1,Att.ML1,
5135Att.ML1|Att.MU2,Att.ML1|Att.MU1,Att.ML2|Att.MD1,Att.ML2|Att.MD2,Att.ML2,Att.ML2,Att.ML2,Att.ML2,Att.ML2|Att.MU2,Att.ML2|Att.MU1,Att.MD1,Att.MD2,0,0,0,0,Att.MU2,Att.MU1,Att.MD1,Att.MD2,0,0,0,0,Att.MU2,Att.MU1,Att.MD1,Att.MD2,0,0,0,0,Att.MU2,Att.MU1,Att.MD1,Att.MD2,0,0,0,0,Att.MU2,Att.MU1,Att.MR2|Att.MD1,Att.MR2|Att.MD2,Att.MR2,Att.MR2,Att.MR2,Att.MR2,Att.MR2|Att.MU2,Att.MR2|Att.MU1,Att.MR1|Att.MD1,Att.MR1|Att.MD2,Att.MR1,Att.MR1,Att.MR1,Att.MR1,Att.MR1|Att.MU2,Att.MR1|Att.MU1];Att.cCov=[Att.MD1L2,
5136-17,Att.MU1L2,-15,Att.MD1R2,15,Att.MU1R2,17,Att.MD2L1,-10,Att.MU2L1,-6,Att.MD2R1,6,Att.MU2R1,10,Att.MD1|Att.ML1,-9,Att.MD1|Att.MR1,7,Att.MU1|Att.MR1,9,Att.MU1|Att.ML1,-7,Att.ML1,-8,Att.MD1,-1,Att.MR1,8,Att.MU1,1,Att.MD1|Att.ML1,-9,Att.ML1,-8,Att.MU1|Att.ML1,-7,Att.MD1,-1,Att.MU1,1,Att.MD1|Att.MR1,7,Att.MR1,8,Att.MU1|Att.MR1,9,Att.MU1|Att.ML1,-7,Att.MU1|Att.MR1,9,Att.MD1|Att.ML1,-9,Att.MD1|Att.MR1,7];Att.cAttChess=[Att.MD1L2,-17,Att.MU1L2,-15,Att.MD1R2,15,Att.MU1R2,17,Att.MD2L1,-10,Att.MU2L1,-6,Att.MD2R1,
51376,Att.MU2R1,10,Att.MD1|Att.ML1,-9,Att.MD1|Att.MR1,7,Att.MU1|Att.MR1,9,Att.MU1|Att.ML1,-7,Att.ML1,-8,Att.MD1,-1,Att.MR1,8,Att.MU1,1,Att.MD1|Att.ML1,-9,Att.ML1,-8,Att.MU1|Att.ML1,-7,Att.MD1,-1,Att.MU1,1,Att.MD1|Att.MR1,7,Att.MR1,8,Att.MU1|Att.MR1,9,Att.MD1|Att.ML1,-9,Att.MD1|Att.MR1,7,Att.MU1|Att.ML1,-7,Att.MU1|Att.MR1,9];Att.S_KING=32;Att.S_QUEEN=16;Att.S_KNIGHT=0;Att.S_BISHOP=16;Att.S_ROOK=24;Att.S_PAWN_W=48;Att.S_PAWN_B=52;Att.S_QUEEN_EX=56}getAttacksOnPieces(a,b){a=ObjUtil.clone(a);var c=!0;b!==
5138Side.other(a.Vj())&&(a.canMakeNullMove()?a.makeNullMove():c=!1);var d=[];if(c){let f=a.Vd();for(let g=0;g<f.length;g++){c=f[g].to;var e=a.board[c];if(e&&Piece.side(e)==b){let h=this.calc(a,f[g].from,f[g].to);d[c]?(h>d[c].maxAtt&&(d[c].maxAtt=h,d[c].maxAttN=d[c].att.length),d[c].att.push(h),d[c].from.push(f[g].from)):d[c]={piece:e,att:[h],maxAttN:0,maxAtt:h,from:[f[g].from],getMaxAttFromSq(){return this.from[this.maxAttN]}}}}}return d}getHangingPieces(a,b,c){a=this.getAttacksOnPieces(a,b);b=[];for(let d=
51390;d<a.length;d++)a[d]&&a[d].maxAtt>c&&b.push({sq:d,piece:a[d].piece,attackVal:a[d].maxAtt,attackSq:a[d].getMaxAttFromSq(),toString(){return String.f("sq={0}, p={1}, fr={2}",CBSquare.toString(this.sq),this.piece,CBSquare.toString(this.attackSq))}});return b}getCoveredSquares(a,b){var c=ObjUtil.clone(a),d=!0;b!=c.Vj()&&(c.canMakeNullMove()?c.makeNullMove():d=!1);let e=new Set;if(d)for(d=0;64>d;d++){let f=a.board[d],g=[];f&&Piece.side(f)==b&&(g=this.getCoveredSqs(f,c,d),g.forEach(function(h){e.add(h)}))}return e}getCoveredSqs(a,
5140b,c){let d=[];switch(Piece.nominal(a)){case Piece.KING:d=this.getKingCoveredSqs(c);break;case Piece.QUEEN:d=this.getQueenCoveredSqs(b,c);break;case Piece.ROOK:d=this.getRookCoveredSqs(b,c);break;case Piece.BISHOP:d=this.getBishopCoveredSqs(b,c);break;case Piece.KNIGHT:d=this.getKnightCoveredSqs(c);break;case Piece.PAWN:d=this.getPawnCoveredSqs(c,b.board[c]&Piece.COLOUR)}return d}getPawnCoveredSqs(a,b){let c=new Set;b=b?Att.S_PAWN_B:Att.S_PAWN_W;let d=Att.cDir[a];d&Att.cCov[b+0]||c.add(a+Att.cCov[b+
51411]);b+=2;d&Att.cCov[b+0]||c.add(a+Att.cCov[b+1]);return c}getKnightCoveredSqs(a){let b=new Set,c=Att.S_KNIGHT,d=Att.cDir[a];for(let e=7;0<=e;
5141e--,c+=2)d&Att.cCov[c+0]||b.add(a+Att.cCov[c+1]);return b}getKingCoveredSqs(a){let b=new Set,c=Att.S_KING,d=Att.cDir[a];for(let e=7;0<=e;e--,c+=2)d&Att.cCov[c+0]||b.add(a+Att.cCov[c+1]);return b}getBishopCoveredSqs(a,b){let c=new Set,d=Att.S_BISHOP,e=4,f;for(;e--;){let g=Att.cCov[d++],h=Att.cCov[d++];for(f=b;!(Att.cDir[f]&g||(f+=h,c.add(f),a.board[f])););}return c}getRookCoveredSqs(a,
5142b){let c=new Set,d=Att.S_ROOK,e=4,f;for(;e--;){let g=Att.cCov[d++],h=Att.cCov[d++];for(f=b;!(Att.cDir[f]&g||(f+=h,c.add(f),a.board[f])););}return c}getQueenCoveredSqs(a,b){let c=this.getRookCoveredSqs(a,b);this.getBishopCoveredSqs(a,b).forEach(function(d){c.add(d)});return c}coversFromTo(a,b,c,d){a=ObjUtil.clone(a);var e=!0;b!=a.Vj()&&(a.canMakeNullMove()?a.makeNullMove():e=!1);if(e){a=a.board;e=b?Piece.BLACK:Piece.WHITE;let f=Att.cDir[d],g,h,k,l,m;b=b?Att.S_PAWN_B:Att.S_PAWN_W;if(!(f&Att.cAttChess[b+
51430])&&a[d+Att.cAttChess[b+1]]==e+Piece.PAWN&&c==d+Att.cAttChess[b+1])return!0;b+=2;if(!(f&Att.cAttChess[b+0])&&a[d+Att.cAttChess[b+1]]==e+Piece.PAWN&&c==d+Att.cAttChess[b+1])return!0;b=Att.S_KNIGHT;for(g=8;g--;b+=2)if(!(f&Att.cAttChess[b+0])&&a[d+Att.cAttChess[b+1]]===e+Piece.KNIGHT&&c==d+Att.cAttChess[b+1])return!0;b=Att.S_BISHOP;for(g=4;g--;)for(k=Att.cAttChess[b++],l=Att.cAttChess[b++],h=d;!(Att.cDir[h]&k);)if(h+=l,m=a[h]){if(m==Piece.BISHOP+e&&h==c)return!0;break}b=Att.S_ROOK;for(g=4;g--;)for(k=
5144Att.cAttChess[b++],l=Att.cAttChess[b++],h=d;!(Att.cDir[h]&k);)if(h+=l,m=a[h]){if(m==Piece.ROOK+e&&h==c)return!0;break}b=Att.S_QUEEN;for(g=8;g--;)for(k=Att.cAttChess[b++],l=Att.cAttChess[b++],h=d;!(Att.cDir[h]&k);)if(h+=l,m=a[h]){if(m==Piece.QUEEN+e&&h==c)return!0;break}b=Att.S_KING;for(g=8;g--;b+=2)if(!(f&Att.cAttChess[b])&&a[d+Att.cAttChess[b+1]]==e+Piece.KING&&c==d+Att.cAttChess[b+1])return!0}return!1}isPawnFork(a,b){var c=ObjUtil.clone(a);a=c.board[b.from];if((a&Piece.PIECE_MASK)==Piece.PAWN){c.makeMove(b);
5145c.sd=Side.other(c.sd);var d=[];c.generatePawn(a,b.to,d);if(2<=d.length){var e=0;d.forEach(function(f){(f=c.board[f.to])&&(f&Piece.PIECE_MASK)!=Piece.PAWN&&e++});return 2===e}}return!1}sumMaterial(a,b){var c=0;a.board.forEach(function(d){d&&Piece.side(d)===b&&(c+=Att.pieceVal(d))}.bind(this));return c}materialDiff(a){return this.sumMaterial(a,Side.WHITE)-this.sumMaterial(a,Side.BLACK)}calcAll(a,b){a=ObjUtil.clone(a);var c=new SwapStack(0);let d=b;for(;64>d;){var e=a.Vd();d=this.getAttackSq(a,e,b);
514664>d&&(c.add(this.calcGain(a,d,b)),d=this.getBestAttackSq(a,e,d,b),e=new Move(d,b),a.isProm(d,b)&&(e.prom=Piece.make(Piece.QUEEN,a.Vj())),a.makeMove(e))}return c.miniMax()}calc(a,b,c){if(!a.isLegalFromTo(b,c))return 0;var d=ObjUtil.clone(a);for(a=new SwapStack(this.calcGain(a,b,c));64>b;){var e=new Move(b,c);d.isProm(b,c)&&(e.prom=Piece.make(Piece.QUEEN,d.Vj()));d.makeMove(e);e=d.Vd();b=this.getAttackSq(d,e,c);64>b&&(a.add(this.calcGain(d,b,c)),b=this.getBestAttackSq(d,e,b,c))}return a.miniMax()}calcPL(a,
5147b,c){for(var d=ObjUtil.clone(a),e=new SwapStack(this.calcGain(a,b,c));64>b;){var f=new Move(b,c);d.isProm(b,c)&&(f.prom=Piece.make(Piece.QUEEN,d.Vj()));d.makeMove(f);b=this.getAttackSqPL(d,c,a.getBTM());if(64>b){if(Piece.isKing(d.board[c])){e.pop();break}e.add(this.calcGain(d,b,c));b=this.getBestAttackSqPL(d,b,c)}}return e.miniMax()}static pieceVal(a){return[0,15E3,900,325,325,500,100][a&Piece.PIECE_MASK]}calcGain(a,b,c){var d=Att.pieceVal(a.board[c]);(a.board[b]&Piece.PIECE_MASK)==Piece.PAWN&&(a.isProm(b,
5148c)?d+=Att.pieceVal(Piece.QUEEN)-Att.pieceVal(Piece.PAWN):a.isEnPassant(b,c)&&(d+=Att.pieceVal(Piece.PAWN)));return d}getAttackSq(a,b,c){for(var d=-1,e=2E4,f=0;f<b.length;f++)b[f].to==c&&Att.pieceVal(a.board[b[f].from])<e&&(d=f,e=Att.pieceVal(a.board[b[f].from]));return 0<=d?b[d].from:64}getAttackSqPL(a,b,c){a=a.board;let d=c?Piece.BLACK:Piece.WHITE,e=Att.cDir[b],f,g,h,k,l;if(a[b]){c=c?Att.S_PAWN_B:Att.S_PAWN_W;if(!(e&Att.cAttChess[c+0])&&a[b+Att.cAttChess[c+1]]==d+Piece.PAWN)return b+Att.cAttChess[c+
51491];c+=2;if(!(e&Att.cAttChess[c+0])&&a[b+Att.cAttChess[c+1]]==d+Piece.PAWN)return b+Att.cAttChess[c+1];c=Att.S_KNIGHT;for(f=8;f--;c+=2)if(!(e&Att.cAttChess[c+0])&&a[b+Att.cAttChess[c+1]]===d+Piece.KNIGHT)return b+Att.cAttChess[c+1];c=Att.S_BISHOP;for(f=4;f--;)for(h=Att.cAttChess[c++],k=Att.cAttChess[c++],g=b;!(Att.cDir[g]&h);)if(g+=k,l=a[g]){if(l==Piece.BISHOP+d)return g;break}c=Att.S_ROOK;for(f=4;f--;)for(h=Att.cAttChess[c++],k=Att.cAttChess[c++],g=b;!(Att.cDir[g]&h);)if(g+=k,l=a[g]){if(l==Piece.ROOK+
5150d)return g;break}c=Att.S_QUEEN;for(f=8;f--;)for(h=Att.cAttChess[c++],k=Att.cAttChess[c++],g=b;!(Att.cDir[g]&h);)if(g+=k,l=a[g]){if(l==Piece.QUEEN+d)return g;break}c=Att.S_KING;for(f=8;f--;c+=2)if(!(e&Att.cAttChess[c])&&a[b+Att.cAttChess[c+1]]==d+Piece.KING)return b+Att.cAttChess[c+1]}}getBestAttackSq(a,b,c,d){var e=64,f=a.board[c]&Piece.PIECE_MASK;if(f==Piece.QUEEN||f==Piece.ROOK)for(var g=0;g<b.length;g++){var h=b[g];if(h.to==d&&h.from!=c&&(a.board[h.from]&Piece.PIECE_MASK)==f){e=h.from;break}}64>
5151e?(f=a.board[c],a.board[c]=0,b=this.countCheck(a.board,d,!a.getBTM()),a.board[c]=f,f=a.board[e],a.board[e]=0,d=this.countCheck(a.board,d,!a.getBTM()),a.board[e]=f,b<d&&(e=c)):e=c;return e}getBestAttackSqPL(a,b,c){var d=64,e=a.board[b]&Piece.PIECE_MASK;if(e==Piece.QUEEN||e==Piece.ROOK)e=a.board[b],a.board[b]=Piece.PIECE_MASK,d=this.getAttackSqPL(a,c,a.getBTM()),a.board[b]=e;if(64>d){e=a.board[b];a.board[b]=Piece.PIECE_MASK;let f=this.countCheck(a,c,!a.getBTM());a.board[b]=e;e=a.board[d];a.board[d]=
5152Piece.PIECE_MASK;c=this.countCheck(a,c,!a.getBTM());a.board[d]=e;f<=c&&(d=b)}else d=b;return d}countCheck(a,b,c){var d=Att.cDir[b],e=c?Piece.BLACK:Piece.WHITE,f,g=0,h,k,l=Att.S_KNIGHT;for(h=8;h--;l+=2)d&Att.cAttChess[l+0]||a[b+Att.cAttChess[l+1]]===e+Piece.KNIGHT&&++g;l=Att.S_BISHOP;for(h=4;h--;){var m=Att.cAttChess[l++];var n=Att.cAttChess[l++];for(k=b;!(Att.cDir[k]&m);)if(k+=n,(f=a[k])&&(f==Piece.QUEEN+e||f===Piece.BISHOP+e)){++g;break}}l=Att.S_ROOK;for(h=4;h--;)for(m=Att.cAttChess[l++],n=Att.cAttChess[l++],
5153k=b;!(Att.cDir[k]&m);)if(k+=n,(f=a[k])&&(f==Piece.QUEEN+e||f==Piece.ROOK+e)){++g;break}l=Att.S_KING;for(h=8;h--;l+=2)d&Att.cAttChess[l]||a[b+Att.cAttChess[l+1]]==e+Piece.KING&&++g;l=c?Att.S_PAWN_B:Att.S_PAWN_W;d&Att.cAttChess[l]||a[b+Att.cAttChess[l+1]]==e+Piece.PAWN&&++g;l+=2;d&Att.cAttChess[l]||a[b+Att.cAttChess[l+1]]==e+Piece.PAWN&&++g;return g}evaluatePins(a){let b=[];var c=[];let d=0,e=0;a=ObjUtil.clone(a);a.ep=0;for(let g=0;64>g;g++){var f=a.board[g];Piece.isVectorPiece(f)&&(Piece.isCol(f,Piece.WHITE)?
5154(a.setSideToMove(Side.BLACK),f=this.getPinValue(a,g),d+=f.pinEval,b=b.concat(f.pins)):(a.setSideToMove(Side.WHITE),c=this.getPinValue(a,g),e+=c.pinEval,c=b.concat(c.pins)))}return{valW:d,valB:e,pinsW:b,pinsB:c,hasPinnedW(g){for(let h=0;h<this.pinsW.length;h++)if(this.pinsW[h].pinnedSq==g)return!0},hasPinnedB(g){for(let h=0;h<this.pinsB.length;h++)if(this.pinsB[h].pinnedSq==g)return!0}}}getPinValue(a,b){let c=[],d=0,e=null,f=4,g=a.board;switch(g[b]&Piece.PIECE_MASK){case Piece.QUEEN:e=Att.S_QUEEN;
5155f=8;break;case Piece.BISHOP:e=Att.S_BISHOP;break;case Piece.ROOK:e=Att.S_ROOK}if(e){let n=a.getBTM()?Piece.BLACK:Piece.WHITE;for(;f--;)for(var h=Att.cAttChess[e++],k=Att.cAttChess[e++],l=b;!(Att.cDir[l]&h);)if(l+=k,g[l]){let r=g[l];if(Piece.isCol(r,n)){let t=l;for(;!(Att.cDir[l]&h);)if(l+=k,g[l]){k=g[l];if(Piece.isCol(k,n)&&!Piece.isPawn(k)){h=ObjUtil.clone(a);h.ep=0;let u=Att.pieceVal(k),x=u;if(!Piece.isKing(k)){var m=h.board[t];h.board[t]=0;h.flipSideToMove();x=Piece.isKing(r)||h.isCheck()?u=this.calcPL(h,
5156b,l):u=this.calc(h,b,l);h.board[t]=m;h.flipSideToMove()}0<x&&(Piece.isKing(r)||(m=h.isCheck()?this.calcPL(h,b,t):this.calc(h,b,t),0>=m&&(m=Att.pieceVal(r)>>1),x>m&&(x=m)),u&&(h.flipSideToMove(),this.hasSafeCapture(h,b)&&(x=0),h.flipSideToMove()));0<x&&(c.push({gain:x,pinner:h.board[b],pinned:r,pinnedTo:k,pinnerSq:b,pinnedSq:t,pinnedToSq:l,toString(){return String.f("Sq={0}, gain={1}, pinner={2}",CBSquare.toString(this.pinnedSq),this.gain,CBSquare.toString(this.pinnerSq))}}),x=Piece.isKing(k)?(x>>
51572)+10:(x>>3)+5,d+=x)}break}}break}}return{pins:c,pinEval:d}}checkDoubleAttack(a,b){let c=ObjUtil.clone(a);c.preCalcCtx(b);c.makeMove(b);let d=c.isCheck();if(d&&c.isMate())return[];let e=ObjUtil.clone(c);c.setSideToMove(Side.other(c.Vj()));if(b.vct||this.countCheck(c,b.to,a.getBTM()))return 0;let f=c.board,g=a.getBTM()?0:Piece.COLOUR,h=[];for(let k=0;64>k;k++)f[k]&&(f[k]&Piece.COLOUR)==g&&(f[k]==Piece.KING+g&&d?h.push(k):0>this.calcAll(c,k)&&h.push(k));if(1<h.length){let k=this.getCoveredSquares(a,
5158a.Vj()),l=[];h.forEach(function(m){k.has(m)||this.hasSafeCapture(e,b.to,0,m)||l.push(m)}.bind(this));if(1<l.length)return l}return[]}hasSafeCapture(a,b,c,d){let e=-1;"undefined"!=typeof d&&(e=d);d=!1;c=c||0;if(a.isCheck()){var f=a.generateSemiLegals();for(var g=0;g<f.length;g++)if(f[g].to==b&&(-1==e||e==f[g].from)){var h=f[g];if(this.calcPL(a,h.from,h.to)>=c){d=!0;break}}}else for(f=a.Vd(),g=0;g<f.length;g++)if(h=f[g],h.to==b&&(-1==e||e==h.from)&&this.calc(a,h.from,h.to)>=c){d=!0;break}return d}static testPins(){var a=
5159[{fen:"4k3/8/2r5/1B6/8/8/8/2K5 w - - 0 0",value:135,sq:12},{fen:"5k2/8/8/8/6b1/5R2/8/3K4 b - - 0 1",value:135,sq:51},{fen:"k3q2R/8/8/8/8/8/5K2/B7 w - - 0 1",value:235,sq:63},{fen:"k3n2R/8/8/8/8/8/5K2/8 w - - 0 0",value:91,sq:63},{fen:"1k3q2/8/8/8/5b2/3N4/2K5/5R2 w - - 0 1",value:45,sq:40},{fen:"1k3q2/8/8/8/5b2/8/2K5/5R2 w - - 0 1",value:25,sq:40},{fen:"1k3q2/8/8/8/5b2/8/Q1K4n/5R2 w - - 0 1",value:0,sq:40},{fen:"2r5/5k2/4n3/2B5/8/8/8/2Q3K1 b - - 0 1",value:45,sq:23},{fen:"k7/8/8/8/4b2K/8/7P/7B w - - 0 0",
5160value:0,sq:56},{fen:"k7/8/8/8/4n2K/8/7P/7B w - - 0 0",value:91,sq:56},{fen:"r3k2R/8/8/8/8/8/8/5K2 b q - 0 1",value:67,sq:63},{fen:"k7/7Q/8/8/4b2K/6P1/6B1/1q6 b - - 0 1",value:67,sq:63},{fen:"1nb1q2k/1r3r1p/p3p2B/1p1pP3/2pP2Q1/7R/PPB2PP1/R5K1 b - - 0 30",value:67,sq:63},{fen:"7k/7p/7B/8/8/7R/8/6K1 w - - 0 1",value:67,sq:63}],b=new Att;for(let e=0;e<a.length;e++){var c=new Position(a[e].fen);console.log(String.f("{1}. W/B Pins for {0}",a[e].fen,e));c=b.evaluatePins(c);if(c.valW){console.log(String.f("White Val {0}",
5161c.valW));for(var d=0;d<c.pinsW.length;d++)console.log(String.f("{0}",c.pinsW[d].toString()))}if(c.valB)for(console.log(String.f("Black Val {0}",c.valB)),d=0;d<c.pinsB.length;d++)console.log(String.f("{0}",c.pinsB[d].toString()))}}static testAtt(){}
5161static testCovers(){var a=[{fen:"8/8/2P4r/8/2R5/7k/8/7K w - - 0 1",from:"c4",side:0,yes:["c6","c2"],no:["c7","c8","h8","g2"]},{fen:"8/7k/8/7K/1p6/3N4/8/8 w - - 0 1",from:"d3",side:0,yes:"b4 c5 e5 f4 f2 e1 c1 b2".split(" "),no:"a2 c7 g2 h5 h7 e8".split(" ")},
5162{fen:"7k/8/8/8/4P3/8/8/7K w - - 0 1",from:"e4",side:0,yes:["d5","f5"],no:["e5","e4"]},{fen:"8/p7/k7/8/2n5/P3Q3/K7/8 b - - 0 1",from:"c4",side:1,yes:"a3 e3 a5 b6 d6 e5 d2 b2".split(" "),no:"a2 c7 g2 h5 h7 e8".split(" ")},{fen:"8/3NBN2/4k3/3RPN2/8/2K5/8/8 b - - 0 1",from:"e6",side:1,yes:"d7 e7 f7 f6 f5 e5 d5 d6".split(" "),no:"d4 e8 f8 f4 f3 d2 d1 a6".split(" ")},{fen:"8/8/p3p3/8/2B5/8/5K1k/8 w - - 0 1",from:"c4",side:0,yes:"a6 e6 b5 d5 a2 d3".split(" "),no:["b2","e5","f7","g8"]}],b=new Att;for(let e=
51630;e<a.length;e++){console.log("Test Cover for:"+a[e].fen);for(var c=0;c<a[e].yes.length;c++){var d=b.coversFromTo(new Position(a[e].fen),a[e].side,CBSquare.fromString(a[e].from),CBSquare.fromString(a[e].yes[c]));console.log("Test Yes:"+a[e].yes[c]+" => "+d);d?console.log("OK"):console.log("Wrong!")}for(c=0;c<a[e].no.length;c++)d=b.coversFromTo(new Position(a[e].fen),a[e].side,CBSquare.fromString(a[e].from),CBSquare.fromString(a[e].no[c])),console.log("Test No:"+a[e].no[c]+" => "+d),d?console.log("Wrong!"):
5164console.log("OK")}}static testDoubleAttacks(){var a=[{fen:"7k/7p/b4b2/8/8/8/2R3P1/7K w - - 0 1",move:"c2c6",double:!0},{fen:"7k/8/8/8/4n3/8/8/3Q3K b - - 0 1",move:"e4f2",double:!0},{fen:"4R3/1b5k/8/4p3/8/8/8/4K3 w - - 0 1",move:"e8e7",double:!0}],b=new Att;for(let d=0;d<a.length;d++){console.log("Test Double Attack Cover for:"+a[d].fen);var c=new Move.fromString(a[d].move);let e=new Position(a[d].fen);c=b.checkDoubleAttack(e,c);let f="Covered: ";b.getCoveredSquares(e,Side.other(e.Vj())).forEach(function(g){f+=
5165g.toString()+","});console.log(f);0<c.length==a[d].double?console.log("OK"):console.log("Wrong!")}}static testCoveredSquares(){var a=[{fen:"7k/6q1/2p1rn2/8/8/8/1P5B/1KQ1R3 w - - 0 1",sq:"h8",piece:1},{fen:"7k/6q1/2p1rn2/8/8/8/1P5B/1KQ1R3 w - - 0 1",sq:"b1",piece:1}],b=new Att;for(let e=0;e<a.length;e++){console.log("Test Covered for:"+a[e].fen);var c=new Position(a[e].fen),d={};let f="";switch(a[e].piece){case Piece.KING:d=b.getKingCoveredSqs(CBSquare.fromString(a[e].sq));f="King: ";d.forEach(function(k){f+=
5166CBSquare.toString(k)+","});break;case Piece.BISHOP:d=b.getBishopCoveredSqs(c,CBSquare.fromString(a[e].sq));f="Bishop: ";d.forEach(function(k){f+=CBSquare.toString(k)+","});break;case Piece.ROOK:d=b.getRookCoveredSqs(c,CBSquare.fromString(a[e].sq));f="Rook: ";d.forEach(function(k){f+=CBSquare.toString(k)+","});break;case Piece.QUEEN:d=b.getQueenCoveredSqs(c,CBSquare.fromString(a[e].sq)),f="Queen: ",d.forEach(function(k){f+=CBSquare.toString(k)+","})}console.log(f);d=b.getCoveredSquares(c,Side.WHITE);
5167c=b.getCoveredSquares(c,Side.BLACK);let g="",h="";d.forEach(function(k){g+=CBSquare.toString(k)+","});c.forEach(function(k){h+=CBSquare.toString(k)+","});console.log("All White: "+g);console.log("All Black: "+h)}}}
5168class Analyser{constructor(a){this.kernel=a;this.game=a.game;this.nVisitsAtPly20=0;this.checkBookPly=20;a=this.game.getMoveIndex();this.game.gotoIndex(this.checkBookPly);this.checkLiveBook();this.game.gotoIndex(a)}destructor(){glApp.aTBLobby.removeOnLiveBookDisplayListener(this.idLBListener)}getGifDelays(a,b,c,d){if(d&&this.hasThinkTimes())return this.getDelaysByThinkTimes(a,b,c);d=[];let e=this.guessMaxBookMove();d.push(1E3);let f=this.game.getMoveIndex();for(c+=1;c<=this.game.getMoves().length;c++){this.game.gotoIndex(c);
5169let k=(new PositionEvaluation(this.game.getCurPos())).evaluate().Complexity.scalarVal,l=0;if(c<this.game.getMoves().length-1){var g=new Att,h=this.game.getNextMove();h&&(g=g.calc(this.game.getCurPos(),h.from,h.to),-200>g&&(l=-400>g?l+1.5*(a+3*b)/4:l+1.5*(a+2*b)/3))}g=this.game.getMoves()[c];h=this.game.getMoves()[c-1];this.isRecapture(h,g)?g=a:(g=a,c>e&&100<k&&(g=(4*a+b)/5,150<k&&(g=(2*a+b)/3,200<k&&(g=(a+b)/2,300<k&&(g=(a+2*b)/3,400<k&&(g=b))))),g+=l);l||(g+=.7*this.getExtraDelayOnAnno());d.push(g)}d.push((b+
5170a)/2);this.game.gotoIndex(f);return d}getDelaysByThinkTimes(a,b,c){let d=this.game.getMoveIndex(),e=this.guessMaxBookMove();var f=0,g=this.game.getMoves().length-c;for(var h=c;h<this.game.getMoves().length;h++)f+=this.getTimeOfMove(h)+1;f/=g;for(g=[];c<=this.game.getMoves().length;c++){h=this.getTimeOfMove(c);this.game.gotoIndex(c);h=(h/=f)?a+(1-Math.exp(-(h/3)))*(b-a):a;let k=this.getExtraDelayOnAnno();h+=k;h=Math.round(h);c<e?g.push(.8*h):g.push(h)}g.push(2*b);this.game.gotoIndex(d);return g}getExtraDelayOnAnno(){let a=
51710;
5171if(this.game.getAnno(AnnoType.SYMBOL))a=800;else if(this.game.getAnno(AnnoType.POSTTEXT))a=2E3;else{let b=this.game.getAnno(AnnoType.ARROW_LIST);b&&(a=1<b.length?3E3:2E3)}return a}getTimeOfMove(a){return this.game.getMoves()[a]?(a=this.game.getMoves()[a].getAnno())?(a=a.getItem(AnnoType.TIME))?a.getTimeIn100th():100:100:0}hasThinkTimes(a){let b=0;if(this.game.getMoves().length<=a)return!1;for(;a<this.game.getMoves().length;a++){let c=this.game.getMoves()[a].getAnno();c?c.getItem(AnnoType.TIME)||
5172b++:b++}return 3>=b}guessMaxBookMove(){return this.nVisitsAtPly20?500<this.nVisitsAtPly20?this.checkBookPly+4:100<this.nVisitsAtPly20?this.checkBookPly:this.checkBookPly-4:12}checkLiveBook(){this.idLBListener=glApp.aTBLobby.addOnLiveBookDisplayListener(this.onLiveBook.bind(this));glApp.aTBLobby.requestAllMoves(this.game.getCurPos(),!1,!1,this.kernel.ticket)}onLiveBook(a){a.tbInfo&&(this.nVisitsAtPly20=a.tbInfo.m_nVisits)}isRecapture(a,b){return a&&b&&0!=a.vct&&a.to==b.to}}"use strict";
5173class BitBoard{constructor(a,b){this.low=UShort(a);this.high=UShort(b)}equals(a){return this.low===a.low&&this.high===a.high}copy(){return new BitBoard(this.low,this.high)}empty(){return!this.low&&!this.high}notEmpty(){return this.low||this.high}isZero(a){a=UShort(a);return 32>a?!(this.low&1<<a):!(this.high&1<<a-32)}isSet(a){return!this.isZero(a)}setBit(a){a=UShort(a);32>a?this.low=UShort(this.low|1<<a):this.high=UShort(this.high|1<<a-32);return this}clearBit(a){a=UShort(a);32>a?this.low=UShort(this.low&
5174~(1<<a)):this.high=UShort(this.high&~(1<<a-32));return this}popcnt(){return popcnt32(this.low)+popcnt32(this.high)}clearLSB(){this.low?this.low=popLSB32(this.low):this.high=popLSB32(this.high);return this}LSB(){return this.low?getLSB32(this.low):32+getLSB32(this.high)}popLSB(){let a=this.LSB();this.clearLSB();return a}MSB(){return this.high?32+getMSB32(this.high):getMSB32(this.low)}AND(a){this.low=UShort(this.low&a.low);this.high=UShort(this.high&a.high);return this}AND_NOT(a){this.low=UShort(this.low&
5175~a.low);this.high=UShort(this.high&~a.high);return this}OR(a){this.low=UShort(this.low|a.low);this.high=UShort(this.high|a.high);return this}XOR(a){this.low=UShort(this.low^a.low);this.high=UShort(this.high^a.high);return this}NOT(){this.low=UShort(~this.low);this.high=UShort(~this.high);return this}makeN(){let a=this.copy();a.SHLEFT();return a}makeE(){let a=this.copy();a.SHUP();return a}makeS(){let a=this.copy();a.SHRIGHT();return a}makeW(){let a=this.copy();a.SHDOWN();return a}makeNW(){let a=this.copy();
5176a.SHLEFT();a.SHDOWN();return a}makeNE(){let a=this.copy();a.SHLEFT();a.SHUP();return a}makeSW(){let a=this.copy();a.SHRIGHT();a.SHDOWN();return a}makeSE(){let a=this.copy();a.SHRIGHT();a.SHUP();return a}SHUP(){let a=UShort((this.low&4278190080)>>>24);this.low=UShort(this.low<<8);this.high=UShort(this.high<<8|a);return this}SHDOWN(){let a=UShort((this.high&255)<<24);this.low=UShort(this.low>>>8|a);this.high=UShort(this.high>>>8);return this}fileA(){return makeBB(255,0)}fileH(){return makeBB(0,255)}rank1(){return new BitBoard(16843009,
517716843009)}rank8(){return new BitBoard(2155905152,2155905152)}SHLEFT(){this.AND_NOT(this.rank8());let a=UShort((this.low&2147483648)>>>31);this.low=UShort(this.low<<1);this.high=UShort(this.high<<1|a);return this}SHRIGHT(){this.AND_NOT(this.rank1());let a=UShort((this.high&1)<<31);this.low=UShort(this.low>>>1|a);this.high=UShort(this.high>>>1);return this}SHL(a){a=UShort(a);31<a?(this.high=UShort(this.low<<a-32),this.low=UShort(0)):0<a&&(this.high=UShort(this.high<<a|this.low>>>32-a),this.low=UShort(this.low<<
5178a));return this}SHR(a){a=UShort(a);31<a?(this.low=this.high>>>a-32,this.high=UShort(0)):0<a&&(this.low=UShort(this.low>>>a|this.high<<32-a),this.high>>>=a);return this}SHIFT(a){63<a||-63>a?this.low=this.high=UShort(0):0<a?this.SHL(a):0>a&&this.SHR(-a);return this}toSet(){let a=[],b=this.copy(),c=b.popcnt();for(;a.length<c;){let d=b.LSB();if(0<=d)a.push(d),b.clearLSB();else break}return a}}function UShort(a){return a>>>0}
5179function popcnt32(a){a=UShort(a);a-=a>>>1&1431655765;a=(a&858993459)+(a>>>2&858993459);return 16843009*(a+(a>>>4)&252645135)>>>24}function popLSB32(a){a=UShort(a);return UShort(a&a-1)}
5179function getLSB32(a){a=UShort(a);return popcnt32((a&-a)-1)}function getMSB32(a){return a?31-Math.clz32(UShort(a)):0}
5180const Boards={ZERO:zeroBB(),ONE:allSetBB(),LIGHT_SQUARES:lightBB(),DARK_SQUARES:darkBB(),FILES:fileBBs(),RANKS:rankBBs(),DIAGONALS:diagBBs(),ANTIDIAGONALS:antiDiagBBs(),CENTER_FILES:centerFiles(),WHITE_SPACE:whiteSpace(),BLACK_SPACE:blackSpace(),RANK1:rankBB(0),RANK2:rankBB(1),RANK3:rankBB(2),RANK4:rankBB(3),RANK5:rankBB(4),RANK6:rankBB(5),RANK7:rankBB(6),RANK8:rankBB(7),FILE_A:fileBB(0),FILE_B:fileBB(1),FILE_C:fileBB(2),FILE_D:fileBB(3),FILE_E:fileBB(4),FILE_F:fileBB(5),FILE_G:fileBB(6),FILE_H:fileBB(7),
5181OUTPOSTAREAS:[outpostArea(0),outpostArea(1)],BORDER:fileBB(0).OR(fileBB(7)).OR(rankBB(0)).OR(rankBB(7)),INNERRANKS:rankBB(0).OR(rankBB(7)).NOT(),INNER_FOUR:rankBB(2).OR(rankBB(3)).OR(rankBB(4)).OR(rankBB(5)),SLIDING_MASKS:[rankBB(7).NOT(),allSetBB(),rankBB(0).NOT()],REVERSE_RANKS:reverseRankBBs(),CENTER:fileBB(3).OR(fileBB(4)).AND(rankBB(3).OR(rankBB(4))),BIG_CENTER:fileBB(2).OR(fileBB(3)).OR(fileBB(4)).OR(fileBB(5)).AND(rankBB(3).OR(rankBB(4)))};Boards.KNIGHT_MOVEMENTS=knightBBs();
5182Boards.KING_MOVEMENTS=kingBBs();Boards.RELATIVE_RANK=[Boards.RANKS,Boards.REVERSE_RANKS];Boards.INNER=Boards.BORDER.copy().NOT();Boards.LIGHT_INNER=Boards.LIGHT_SQUARES.copy().AND(Boards.INNER);Boards.DARK_INNER=Boards.DARK_SQUARES.copy().AND(Boards.INNER);Boards.LIGHT_CENTER=Boards.LIGHT_SQUARES.copy().AND(Boards.CENTER);Boards.DARK_CENTER=Boards.DARK_SQUARES.copy().AND(Boards.CENTER);Boards.SHELTER_000=[fileBB(0).OR(fileBB(1)).OR(fileBB(2)).AND(rankBB(1).OR(rankBB(2))),fileBB(0).OR(fileBB(1)).OR(fileBB(2)).AND(rankBB(5).OR(rankBB(6)))];
5183Boards.SHELTER_00=[fileBB(5).OR(fileBB(6)).OR(fileBB(7)).AND(rankBB(1).OR(rankBB(2))),fileBB(5).OR(fileBB(6)).OR(fileBB(7)).AND(rankBB(5).OR(rankBB(6)))];Boards.MASK_00=[Boards.RANK1.copy().OR(Boards.RANK2).OR(Boards.RANK3).AND(Boards.FILE_F.copy().OR(Boards.FILE_G).OR(Boards.FILE_H)),Boards.RANK6.copy().OR(Boards.RANK7).OR(Boards.RANK8).AND(Boards.FILE_F.copy().OR(Boards.FILE_G).OR(Boards.FILE_H))];
5184Boards.MASK_000=[Boards.RANK1.copy().OR(Boards.RANK2).OR(Boards.RANK3).AND(Boards.FILE_A.copy().OR(Boards.FILE_B).OR(Boards.FILE_C)),Boards.RANK6.copy().OR(Boards.RANK7).OR(Boards.RANK8).AND(Boards.FILE_A.copy().OR(Boards.FILE_B).OR(Boards.FILE_C))];Boards.WEIGHT_AREA=[Boards.RANK3.copy().OR(Boards.RANK4).OR(Boards.RANK5).OR(Boards.RANK6).OR(Boards.RANK7).OR(Boards.RANK8),Boards.RANK6.copy().OR(Boards.RANK5).OR(Boards.RANK4).OR(Boards.RANK3).OR(Boards.RANK2).OR(Boards.RANK1)];
5185Boards.PASSEDPAWN_RANKS=[rankBB(3).OR(rankBB(4)).OR(rankBB(5)).OR(rankBB(6)),rankBB(4).OR(rankBB(3)).OR(rankBB(2)).OR(rankBB(1))];Boards.KING_00=[Boards.RANK1.copy().OR(Boards.RANK2).AND(Boards.FILE_G.copy().OR(Boards.FILE_H)),Boards.RANK7.copy().OR(Boards.RANK8).AND(Boards.FILE_G.copy().OR(Boards.FILE_H))];Boards.KING_000=[Boards.RANK1.copy().OR(Boards.RANK2).AND(Boards.FILE_A.copy().OR(Boards.FILE_B).OR(Boards.FILE_C)),Boards.RANK7.copy().OR(Boards.RANK8).AND(Boards.FILE_A.copy().OR(Boards.FILE_B).OR(Boards.FILE_C))];
5186function makeBB(a,b){return new BitBoard(a,b)}function zeroBB(){return makeBB(0,0)}function twoZeroBB(){return[zeroBB(),zeroBB()]}function allSetBB(){return makeBB(4294967295,4294967295)}function lightBB(){return makeBB(1437226410,1437226410)}function darkBB(){return makeBB(2857740885,2857740885)}function fileBB(a){return makeBB(255,0).SHL(8*a)}function rankBB(a){return makeBB(16843009,16843009).SHL(a)}function fileBBs(){let a=[];for(let b=0;8>b;++b)a.push(fileBB(b));return a}
5187function centerFiles(){let a=fileBB(2);for(let b=3;5>=b;b++)a.OR(fileBB(b));return a}function rankBBs(){let a=[];for(let b=0;8>b;++b)a.push(rankBB(b));return a}function reverseRankBBs(){let a=[];for(let b=7;0<=b;b--)a.push(rankBB(b));return a}function squareBB(a){return zeroBB().setBit(a)}function diagBB(a){return makeBB(270549120,16909320).AND(allSetBB().SHIFT(8*a)).SHIFT(a)}function diagBBs(){let a=[];for(let b=-7;8>b;++b)a.push(diagBB(b));return a}
5188function antiDiagBB(a){return makeBB(134480385,2151686160).AND(allSetBB().SHIFT(8*-a)
5188).SHIFT(a)}function antiDiagBBs(){let a=[];for(let b=-7;8>b;++b)a.push(antiDiagBB(b));return a}
5189function knightBB(a){var b=zeroBB().setBit(a);a=b.copy().SHR(1).AND_NOT(Boards.FILES[7]);var c=b.copy().SHR(2).AND_NOT(Boards.FILES[7]).AND_NOT(Boards.FILES[6]);let d=b.copy().SHL(1).AND_NOT(Boards.FILES[0]);b=b.copy().SHL(2).AND_NOT(Boards.FILES[0]).AND_NOT(Boards.FILES[1]);c=c.OR(b);a=a.OR(d);return c.copy().SHL(8).OR(c.SHR(8)).OR(a.copy().SHL(16)).OR(a.SHR(16))}function knightBBs(){let a=[];for(let b=0;64>b;++b)a.push(knightBB(b));return a}
5190function kingBB(a){var b=zeroBB().setBit(a);a=b.copy().SHR(1).AND_NOT(Boards.FILES[7]).OR(b.copy().SHL(1).AND_NOT(Boards.FILES[0]));let c=b.copy().OR(a).SHR(8);b=b.copy().OR(a).SHL(8);return a.OR(c).OR(b)}function kingBBs(){let a=[];for(let b=0;64>b;++b)a.push(kingBB(b));return a}function whiteSpace(){let a=centerFiles().OR(fileBB(1)).OR(fileBB(6)),b=rankBB(1).OR(rankBB(2)).OR(rankBB(3)).OR(rankBB(4));a.AND(b);return a}
5191function blackSpace(){let a=centerFiles().OR(fileBB(1)).OR(fileBB(6)),b=rankBB(3).OR(rankBB(4)).OR(rankBB(5)).OR(rankBB(6));a.AND(b);return a}function oneRankBack(a){return a.copy().AND_NOT(Boards.RANK1).SHR(1)}function oneRankForward(a){return a.copy().AND_NOT(Boards.RANK8).SHL(1)}function margins(){return fileBB(0).OR(fileBB(7)).OR(rankBB(0)).OR(rankBB(7))}function inner(){return margins().NOT()}
5192function outpostArea(a){return a?inner().AND(rankBB(1).OR(rankBB(2)).OR(rankBB(3)).OR(rankBB(4))):inner().AND(rankBB(3).OR(rankBB(4)).OR(rankBB(5)).OR(rankBB(6)))}"use strict";
5193const Constants={NUM_RANKS:8,NUM_FILES:8,FILE_CHARS:"abcdefgh",RANK_CHARS:"12345678",PIECE_CHARS:"\u2659\u265f\u2658\u265e\u2657\u265d\u2656\u265c\u2655\u265b\u2654\u265a",Pieces:{PAWN:0,KNIGHT:1,BISHOP:2,ROOK:3,QUEEN:4,KING:5},NUM_PIECES:6,Colors:{WHITE:0,BLACK:1},WHITE:0,BLACK:1,PIECE_NAMES:"pawn knight bishop rook queen king".split(" "),ALG_NAMES:" NBRQK",MoveTypes:{QUIET:0,DOUBLE_PAWN_PUSH:1,KING_CASTLE:2,QUEEN_CASTLE:3,CAPTURE:4,EN_PASSANT_CAPTURE:5,KNIGHT_PROMOTION:8,BISHOP_PROMOTION:9,ROOK_PROMOTION:10,
5194QUEEN_PROMOTION:11,KNIGHT_PROMOTION_CAPTURE:12,BISHOP_PROMOTION_CAPTURE:13,ROOK_PROMOTION_CAPTURE:14,QUEEN_PROMOTION_CAPTURE:15},ALL_WHITE:6,ALL_BLACK:7,CORNERS:[7,63,0,56],Status:{NORMAL:0,CHECKMATE:1,DRAW:2}},Pieces={PAWN:0,KNIGHT:1,BISHOP:2,ROOK:3,QUEEN:4,KING:5};"use strict";function perft(a,b){if(!a)return 1;let c=0;for(let d of b.availableMoves(!0))b.makeMove(d)&&(c+=perft(a-1,b),b.unmakeMove());return c}function casIdx(a,b){return a+(b?0:2)}
5195function casRkSq(a,b){return Constants.CORNERS[casIdx(a,b)]}function pieceChar(a,b){return Constants.PIECE_CHARS.charAt(2*a+b)}function otherColor(a){return a^1}function idxToRank(a){return a>>>3}function idxToFile(a){return a&7}function rfToIdx(a,b){return b+a*Constants.NUM_FILES}function isLight(a,b){return!!((a+b)%2)}function rfToAlg(a,b){return Constants.FILE_CHARS[b]+Constants.RANK_CHARS[a]}
5196function algToIdx(a){let b=Constants.RANK_CHARS.indexOf(a[1]);a=Constants.FILE_CHARS.indexOf(a[0]);return rfToIdx(b,a)}function idxToAlg(a){return rfToAlg(idxToRank(a),idxToFile(a))}"use strict";
5197class BitMove{constructor(a,b,c,d,e){this.val=b&63|(a&63)<<6|(c&15)<<12|(d&7)<<16|((e||0)&7)<<19}to(){return this.val&63}from(){return this.val>>>6&63}type(){return this.val>>>12&15}piece(){return this.val>>>16&7}isCapt(){return!!(this.type()&4)}captPiece(){return this.val>>>19&7}isPromo(){return!!(this.type()&8)}isCas(){return this.type()===Constants.MoveTypes.KING_CASTLE||this.type()===Constants.MoveTypes.QUEEN_CASTLE}promoPiece(){return this.isPromo()?Constants.Pieces.KNIGHT+(this.type()&3):Constants.Pieces.PAWN}captSq(){return this.type()!==
5198Constants.MoveTypes.EN_PASSANT_CAPTURE?this.to():this.to()+(this.from()<this.to()?-Constants.NUM_FILES:Constants.NUM_FILES)}toCBMove(){}toString(){return idxToAlg(this.from())+idxToAlg(this.to())}}"use strict";
5199const Square={A1:0,A2:1,A3:2,A4:3,A5:4,A6:5,A7:6,A8:7,B1:8,B2:9,B3:10,B4:11,B5:12,B6:13,B7:14,B8:15,C1:16,C2:17,C3:18,C4:19,C5:20,C6:21,C7:22,C8:23,D1:24,D2:25,D3:26,D4:27,D5:28,D6:29,D7:30,D8:31,E1:32,E2:33,E3:34,E4:35,E5:36,E6:37,E7:38,E8:39,F1:40,F2:41,F3:42,F4:43,F5:44,F6:45,F7:46,F8:47,G1:48,G2:49,G3:50,G4:51,G5:52,G6:53,G7:54,G8:55,H1:56,H2:57,H3:58,H4:59,H5:60,H6:61,H7:62,H8:63,RANK_1:0,RANK_2:1,RANK_3:2,RANK_4:3,RANK_5:4,RANK_6:5,RANK_7:6,RANK_8:7,FILE_A:0,FILE_B:1,FILE_C:2,FILE_D:3,FILE_E:4,
5200FILE_F:5,FILE_G:6,FILE_H:7,MD_BL:-9,MD_LEFT:-8,MD_FL:-7,MD_BACK:-1,MD_FORWARD:1,MD_BR:7,MD_RIGHT:8,MD_FR:9,fileDiff(a,b){return(a>>3)-(b>>3)},rankDiff(a,b){return(b&7)-(a&7)}};
5201class BitPos{constructor(){this.bitboards=[Boards.RANKS[1].copy().OR(Boards.RANKS[6]),squareBB(Square.B1).OR(squareBB(Square.G1)).OR(squareBB(Square.B8)).OR(squareBB(Square.G8)),squareBB(Square.C1).OR(squareBB(Square.F1)).OR(squareBB(Square.C8)).OR(squareBB(Square.F8)),squareBB(Square.A1).OR(squareBB(Square.H1)).OR(squareBB(Square.A8)).OR(squareBB(Square.H8)),squareBB(Square.D1).OR(squareBB(Square.D8)),squareBB(Square.E1).OR(squareBB(Square.E8)),Boards.RANKS[0].copy().OR(Boards.RANKS[1]),Boards.RANKS[6].copy().OR(Boards.RANKS[7])];
5202this.turn=Constants.Colors.WHITE;this.cas=15;this.enPas=-1;this.init()}fromChessPos(a){a.getBTM()?this.turn=Constants.Colors.BLACK:this.turn=Constants.Colors.WHITE;this.cas=0;a.cr&&CastleRights.W_00&&(this.cas|=1);a.cr&&CastleRights.B_00&&(this.cas|=2);a.cr&&CastleRights.W_000&&(this.cas|=4);a.cr&&CastleRights.B_000&&(this.cas|=8);this.enPas=a.getEPFile();for(var b=0;8>b;b++)this.bitboards[b]=zeroBB();a=a.board;for(b=0;64>b;b++)if(a[b]){let c=0!=(a[b]&8),d=b;switch(a[b]&7){case Piece.KING:this.bitboards[5].setBit(d);
5203break;case Piece.QUEEN:this.bitboards[4].setBit(d);break;case Piece.ROOK:this.bitboards[3].setBit(d);break;case Piece.BISHOP:this.bitboards[2].setBit(d);break;case Piece.KNIGHT:this.bitboards[1].setBit(d);break;case Piece.PAWN:this.bitboards[0].setBit(d)}c?this.bitboards[Constants.ALL_BLACK].setBit(d):this.bitboards[Constants.ALL_WHITE].setBit(d)}this.init()}toChessPos(){let a=new Position;a.initEmpty();a.sd=this.turn==Constants.Colors.BLACK?Side.BLACK:Side.WHITE;a.ep=this.enPas;a.cr=0;this.cas&1&&
5204(a.cr|=CastleRights.W_00);this.cas&2&&(a.cr|=CastleRights.B_00);this.cas&4&&(a.cr|=CastleRights.W_000);this.cas&8&&(a.cr|=CastleRights.B_000);let b=this.getOccupied();for(let c=0;64>c;c++){let d=c;if(b.isSet(c)){let e=this.bitboards[Constants.ALL_BLACK].isSet(c),f=0;this.bitboards[0].isSet(c)&&(f=Piece.PAWN);this.bitboards[1].isSet(c)&&(f=Piece.KNIGHT);this.bitboards[2].isSet(c)&&(f=Piece.BISHOP);this.bitboards[3].isSet(c)&&(f=Piece.ROOK);this.bitboards[4].isSet(c)&&(f=Piece.QUEEN);this.bitboards[5].isSet(c)&&
5205(f=Piece.KING);a.board[d]=f|(e?Piece.COLOUR:0)}}return a}init(){this.halfMoves=0;this.pieceList=[];this.moves=[];this.hist=[];for(let a=0;64>a;a++)this.pieceList[a]=this.getPieceFromBB(a)}colorBB(a){return this.bitboards[Constants.ALL_WHITE+a]}getPieces(a){return this.bitboards[Constants.ALL_WHITE+a].copy()}pieceBB(a){return this.bitboards[a]}getPiecesOfSide(a,b){return this.bitboards[a].copy().AND(this.bitboards[Constants.ALL_WHITE+b])}getPawns(a){return this.getPiecesOfSide(Pieces.PAWN,a)}getKnights(a){return this.getPiecesOfSide(Pieces.KNIGHT,
5206a)}getBishops(a){return this.getPiecesOfSide(Pieces.BISHOP,a)}getRooks(a){return this.getPiecesOfSide(Pieces.ROOK,a)}getQueens(a){return this.getPiecesOfSide(Pieces.QUEEN,a)}getKing(a){return this.getPiecesOfSide(Pieces.KING,a)}kingPos(a){return this.getPiecesOfSide(Pieces.KING,a).LSB()}getOccupied(){return this.bitboards[Constants.ALL_WHITE].copy().OR(this.bitboards[Constants.ALL_BLACK])}emptyBB(){return this.getOccupied().NOT()}inCheck(){return this.isAttacked(otherColor(this.turn),this.kingPos(this.turn))}pawnAttack(a,
5207b){let c=a===Constants.Colors.WHITE;a=b.copy().AND_NOT(Boards.FILES[0]).SHIFT(c?7:-9);b=b.copy().AND_NOT(Boards.FILES[Constants.NUM_FILES-1]).SHIFT(c?9:-7);return a.OR(b)}slidingAttack(a,b,c,d){a=a.copy();let e=zeroBB();d=d*Constants.NUM_FILES+c;c=Boards.SLIDING_MASKS[1+c];for(a.SHIFT(d);!a.AND(c).empty();a.AND_NOT(b).SHIFT(d))e.OR(a);return e}bishopAttack(a,b){return this.slidingAttack(a.copy(),b,1,1).OR(this.slidingAttack(a.copy(),b,1,-1)).OR(this.slidingAttack(a.copy(),b,-1,1)).OR(this.slidingAttack(a.copy(),
5208b,-1,-1))}rookAttack(a,b){return this.slidingAttack(a.copy(),b,0,1).OR(this.slidingAttack(a.copy(),b,0,-1)).OR(this.slidingAttack(a.copy(),b,1,0)).OR(this.slidingAttack(a.copy(),b,-1,0))}isAttacked(a,b){var c=this.getPiecesOfSide(Pieces.PAWN,a);
5208if(this.pawnAttack(a,c).isSet(b))return!0;c=this.getKnights(a);if(!Boards.KNIGHT_MOVEMENTS[b].copy().AND(c).empty())return!0;c=this.getPiecesOfSide(Pieces.KING,a);if(!Boards.KING_MOVEMENTS[b].copy().AND(c).empty())return!0;c=this.getOccupied();let d=this.getPiecesOfSide(Pieces.QUEEN,
5209a),e=this.getPiecesOfSide(Pieces.BISHOP,a).copy().OR(d);if(this.bishopAttack(e,c).isSet(b))return!0;a=this.getPiecesOfSide(Pieces.ROOK,a).copy().OR(d);return this.rookAttack(a,c).isSet(b)?!0:!1}hasCasRight(a,b){return 0!==(this.cas&1<<casIdx(a,b))}clearCasRight(a,b){this.cas&=~(1<<casIdx(a,b))}canCastle(a,b){if(!this.hasCasRight(a,b))return!1;let c=b?1:-1,d=a===Constants.Colors.WHITE?4:60,e=this.getOccupied();return e.isSet(d+c)||e.isSet(d+2*c)||!b&&e.isSet(d+3*c)||!this.isCasLegal(a,b)?!1:!0}isCasLegal(a,
5210b){let c=otherColor(a);b=b?1:-1;a=a===Constants.Colors.WHITE?4:60;return!this.isAttacked(c,a)&&!this.isAttacked(c,a+b)&&!this.isAttacked(c,a+2*b)}isDraw(){if(100<=this.halfMoves)return!0;if(!this.pieceBB(Pieces.PAWN).empty()||!this.pieceBB(Pieces.ROOK).empty()||!this.pieceBB(Pieces.QUEEN).empty())return!1;var a=this.colorBB(Constants.Colors.WHITE).popcnt();let b=this.colorBB(Constants.Colors.BLACK).popcnt();if(4>a+b)return!0;if(!this.pieceBB(Pieces.KNIGHT).empty())return!1;a=this.pieceBB(Pieces.BISHOP);
5211return a.copy().AND(Boards.LIGHT_SQUARES).equals(a)||a.copy().AND(Boards.DARK_SQUARES).equals(a)?!0:!1}status(){return this.availableMoves().length?this.isDraw()?Constants.Status.DRAW:Constants.Status.NORMAL:this.inCheck()?Constants.Status.CHECKMATE:Constants.Status.DRAW}availableMoves(a,b){b=this.getMoves(!!b);return a?b:b.filter(this.isLegalMove,this)}isLegalMove(a){this.update(a);let b=this.inCheck();this.revert(a);return!b}getMoves(a){let b=[],c=this.turn,d=this.colorBB(c),e=this.colorBB(otherColor(c));
5212var f=this.getOccupied();let g=this;const h=(A,aa,ha)=>{for(;!A.empty();){let z=A.popLSB();b.push(new BitMove(z-aa,z,ha,Pieces.PAWN,g.getPieceFromPL(z)))}};var k=(A,aa,ha)=>{h(A.copy(),aa,ha?Constants.MoveTypes.QUEEN_PROMOTION_CAPTURE:Constants.MoveTypes.QUEEN_PROMOTION);h(A.copy(),aa,ha?Constants.MoveTypes.ROOK_PROMOTION_CAPTURE:Constants.MoveTypes.ROOK_PROMOTION);h(A.copy(),aa,ha?Constants.MoveTypes.BISHOP_PROMOTION_CAPTURE:Constants.MoveTypes.BISHOP_PROMOTION);h(A.copy(),aa,ha?Constants.MoveTypes.KNIGHT_PROMOTION_CAPTURE:
5213Constants.MoveTypes.KNIGHT_PROMOTION)};const l=(A,aa,ha)=>{for(;!aa.empty();){let z=aa.popLSB();d.isZero(z)&&b.push(new BitMove(A,z,e.isSet(z)?Constants.MoveTypes.CAPTURE:Constants.MoveTypes.QUIET,ha,g.getPieceFromPL(z)))}};var m=1-2*c,n=Constants.NUM_FILES*m,r=this.getPiecesOfSide(Pieces.PAWN,c);let t=Boards.RANKS[c?0:Constants.NUM_RANKS-1];if(!a){var u=r.copy().AND(Boards.RANKS[c?6:1]).SHIFT(2*n).AND_NOT(f).AND_NOT(f.copy().SHIFT(n));h(u,2*n,Constants.MoveTypes.DOUBLE_PAWN_PUSH);u=r.copy().SHIFT(n).AND_NOT(f);
5214h(u.copy().AND_NOT(t),n,Constants.MoveTypes.QUIET);k(u.copy().AND(t),n,!1)}let x=Boards.FILES[c?Constants.NUM_FILES-1:0];u=n-m;var B=r.copy().AND_NOT(x).SHIFT(u).AND(e);h(B.copy().AND_NOT(t),u,Constants.MoveTypes.CAPTURE);k(B.copy().AND(t),u,!0);B=Boards.FILES[c?0:Constants.NUM_FILES-1];n+=m;let y=r.copy().AND_NOT(B).SHIFT(n).AND(e);h(y.copy().AND_NOT(t),n,Constants.MoveTypes.CAPTURE);k(y.copy().AND(t),n,!0);0<=this.enPas&&(k=squareBB(this.enPas+m).AND(r).AND_NOT(x).SHIFT(u),h(k,u,Constants.MoveTypes.EN_PASSANT_CAPTURE),
5215m=squareBB(this.enPas-m).AND(r).AND_NOT(B).SHIFT(n),h(m,n,Constants.MoveTypes.EN_PASSANT_CAPTURE));m=a?e:Boards.ONE;for(r=this.getKnights(c).copy();!r.empty();)k=r.popLSB(),l(k,Boards.KNIGHT_MOVEMENTS[k].copy().AND(m),Pieces.KNIGHT);for(r=this.getPiecesOfSide(Pieces.QUEEN,c).copy();!r.empty();)k=r.popLSB(),l(k,this.bishopAttack(squareBB(k),f).OR(this.rookAttack(squareBB(k),f)).AND(m),Pieces.QUEEN);for(r=this.getPiecesOfSide(Pieces.BISHOP,c).copy();!r.empty();)k=r.popLSB(),l(k,this.bishopAttack(squareBB(k),
5216f).AND(m),Pieces.BISHOP);for(r=this.getPiecesOfSide(Pieces.ROOK,c).copy();!r.empty();)k=r.popLSB(),l(k,this.rookAttack(squareBB(k),f).AND(m),Pieces.ROOK);f=this.kingPos(c);l(f,Boards.KING_MOVEMENTS[f].copy().AND(m),Pieces.KING);a||(this.canCastle(c,!0)&&b.push(new BitMove(f,f+2,Constants.MoveTypes.KING_CASTLE,Pieces.KING,null)),this.canCastle(c,!1)&&b.push(new BitMove(f,f-2,Constants.MoveTypes.QUEEN_CASTLE,Pieces.KING,null)));return b}capture(a,b,c){this.pieceBB(a).clearBit(c);this.colorBB(b).clearBit(c);
5217this.pieceList[c]=null}uncapture(a,b,c){this.pieceBB(a).setBit(c);this.colorBB(b).setBit(c);this.pieceList[c]=a}move(a,b,c,d){let e=squareBB(c).OR(squareBB(d));this.pieceBB(a).XOR(e);this.colorBB(b).XOR(e);this.pieceList[c]=null;this.pieceList[d]=a}casRook(a,b){let c=casRkSq(a,b);this.move(Pieces.ROOK,a,c,c+(b?-2:3))}unCastleRook(a,b){let c=casRkSq(a,b);this.move(Pieces.ROOK,a,c+(b?-2:3),c)}promote(a,b,c,d){this.pieceBB(a).clearBit(d);this.pieceBB(b).setBit(d);this.pieceList[d]=b}update(a){a.isCapt()&&
5218this.capture(a.captPiece(),otherColor(this.turn),a.captSq());a.isCas()&&this.casRook(this.turn,a.type()===Constants.MoveTypes.KING_CASTLE);this.move(a.piece(),this.turn,a.from(),a.to());a.isPromo()&&this.promote(Pieces.PAWN,a.promoPiece(),this.turn,a.to())}revert(a){a.isPromo()&&this.promote(a.promoPiece(),Pieces.PAWN,this.turn,a.to());this.move(a.piece(),this.turn,a.to(),a.from());a.isCas()&&this.unCastleRook(this.turn,a.type()===Constants.MoveTypes.KING_CASTLE);a.isCapt()&&this.uncapture(a.captPiece(),
5219otherColor(this.turn),a.captSq())}makeMove(a){this.update(a);if(this.inCheck())return this.revert(a),!1;this.moves.push(a);this.hist.push(this.enPas);this.hist.push(this.cas);this.hist.push(this.halfMoves);a.type()===Constants.MoveTypes.DOUBLE_PAWN_PUSH?this.enPas=a.to():this.enPas=-1;var b=this.turn;a.piece()===Pieces.KING?(this.clearCasRight(b,!0),this.clearCasRight(b,!1)):a.piece()===Pieces.ROOK&&(a.from()===casRkSq(b,!0)?this.clearCasRight(b,!0):a.from()===casRkSq(b,!1)&&this.clearCasRight(b,
5220!1));b=otherColor(b);a.captPiece()===Pieces.ROOK&&(a.captSq()===casRkSq(b,!0)?this.clearCasRight(b,!0):a.captSq()===casRkSq(b,!1)&&this.clearCasRight(b,!1));a.isCapt()||a.piece()===Pieces.PAWN?this.halfMoves=0:this.halfMoves++;this.turn=b;return!0}unmakeMove(){if(0< !this.moves.length)return null;let a=this.moves.pop();this.turn=otherColor(this.turn);this.revert(a);this.halfMoves=this.hist.pop();this.cas=this.hist.pop();this.enPas=this.hist.pop();return a}getPieceFromPL(a){return this.pieceList[a]}getPieceFromBB(a){for(let b=
5221Pieces.PAWN;b<=Pieces.KING;b++)if(this.pieceBB(b).isSet(a))return b;return null}static toBitSquare(a){return(a&7)<<3|a>>3}static toCBSquare(a){return(a&7)<<3|a>>3}static toBitPiece(a){return[-1,5,4,1,2,3,0][Piece.nominal(a)]}static toCBPiece(a){return[Piece.PAWN,Piece.KNIGHT,Piece.BISHOP,Piece.ROOK,Piece.QUEEN,Piece.
5221KING][a]}static toCBSet(a){let b=[];a=a.copy();let c=a.popcnt();for(;b.length<c;){let d=a.LSB();if(0<=d)b.push(BitPos.toCBSquare(d)),a.clearLSB();else break}return b}static test(){var a=
5222new Position("r3r1k1/pp3pbp/1qp3p1/2B5/2BP2b1/Q1n2N2/P4PPP/3R1K1R b - - 0 17"),b=new BitPos;b.fromChessPos(a);a=b.toChessPos();a.dump();b=b.availableMoves();b.forEach(function(c){LOG(c.toString())});a.Vd().length!=b.length&&LOG("Test Failed")}}"use strict";function vecOut(a){let b="";for(let c=0;c<a.length;c++)b+=String.f("{0}",a[c].toFixed(1)),c<a.length-1&&(b+="/");return b}
5223class PositionEvaluation{constructor(a){this.bitPos=new BitPos;this.bitPos.fromChessPos(a);this.pos=a;this.toMove=a.Vj();this.init();this.initScores();this.initStatics();this.initAttackParams();this.buildAttacks(a);this.calcMaterial();this.initKing();this.initPawns();this.initPinned();this.initMobility();PositionEvaluation.MAX_HUE=150}init(){PositionEvaluation.initCalled||(PositionEvaluation.initCalled=!0,PositionEvaluation.bbSquare=[],PositionEvaluation.allRookAttacks=[],PositionEvaluation.allBishopAttacks=
5224[],PositionEvaluation.allKnightAttacks=[],PositionEvaluation.allKingAttacks=[],PositionEvaluation.allPawnAttacks=[[],[]],PositionEvaluation.kingRing=[[],[]],PositionEvaluation.kingZone=[],PositionEvaluation.between=[],PositionEvaluation.lines=[],PositionEvaluation.kingDistance=[],PositionEvaluation.ranksInFront=[[],[]],PositionEvaluation.passedMask=[[],[]],PositionEvaluation.forward=[[],[]],PositionEvaluation.adjacentFiles=[],PositionEvaluation.neighbourFiles=[])}evaluate(){var a=this.spaces();let b=
5225this.pawns(),c=this.knights(),d=this.bishops(),e=this.rooks(),f=this.queens(),g=this.kings(),h=this.attacks(),k=[b[0].passed,b[1].passed],l=this.activity(c,d,e,f);for(let r=0;2>r;r++)g[r].myDistToPasseds=k[0].kingDist[r]+k[1].kingDist[r],g[r].oppDistToPasseds=k[0].kingDist[1-r]+k[1].kingDist[1-r];let m=[],n=[];[a,b,c,d,e,f,g,h,k,l].forEach(function(r){r.length&&(r[0].test&&(m=m.concat(r[0].test)),r[1].test&&(m=m.concat(r[1].test)),r[0].colors&&(n=r[0].colors),r[1].colors&&(n=r[1].colors))});a={Spaces:a,
5226Pawns:b,Knights:c,Bishops:d,Rooks:e,Queens:f,Kings:g,Attacks:h,Passed:k,Activity:l,valid:!0,test:m,colors:n};a.Complexity=this.complexity(a);a.test=a.test.concat(a.Complexity.test);return a}complexity(a){let b={valid:!0,val:[0,0],kingAtt:[0,0],weakAtt:[0,0],area:[0,0],weightArea:[0,0],weakPawns:0,candidates:0,passVal:0,attack:0,safety:[0,0],developed:[0,0],asym:0,shelter:0,storm:0,mat:this.matInhomogen,potential:a.Attacks[0].potential+a.Attacks[1].potential,getNIcons(){let g=-1,h=[0,58,140,260,410];
5227for(let k=0;k<h.length;k++)this.scalarVal>h[k]&&(g=k);return g},str(){return String.f("ComplexityMG={0}",this.scalarVal.toFixed(2))},dbg(){return String.f("Weak={0}/P={1}, Pass={2}, Cand={3}, Potent={4}, KingAtt={5}, Area={6}, Safety={7}, Attack={8}, Asym={9}, Material={10}, Shelter={11}, Storm={12}, Dev={13}",this.weakAtt,this.weakPawns,this.passVal.toFixed(1),this.candidates,this.potential,this.kingAtt,vecOut(this.weightArea),vecOut(this.safety),this.attack,this.asym,this.mat.toFixed(1),this.shelter.toFixed(1),
5228this.storm.toFixed(1),vecOut(this.developed))},text(){let g=-1,h=[0,58,140,260,410,500];for(let k=0;k<h.length;k++)this.scalarVal>h[k]&&(g=k);return["",lm.TECHNICAL,lm.CALM,lm.NORMAL,lm.SHARP,lm.VERY_SHARP,lm.BOARD_ON_FIRE][g+1]},test:[]};for(var c=0;2>c;c++)b.weakPawns+=a.Pawns[c].nWeak,b.candidates=a.Pawns[c].nCandidates,b.kingAtt[c]+=a.Knights[c].kingAtt+a.Bishops[c].kingAtt+a.Rooks[c].kingAtt+a.Queens[c].kingAtt,b.weakAtt[c]+=a.Knights[c].weakAtt+a.Bishops[c].weakAtt+a.Rooks[c].weakAtt+a.Queens[c].weakAtt,
5229b.safety[c]=a.Kings[c].safety,b.weightArea[c]=a.Activity[c].val,b.developed[c]=a.Activity[c].devel;b.val=this.add(b.val,this.mult(this.cpxMatInhomogen,this.matInhomogen));c=0;var d=[1,2,6,15];for(var e=0;2>e;e++){for(var f=3;6>=f;f++)c+=d[f-3]*this.passedPawns[e].copy().AND(Boards.RELATIVE_RANK[e][f]).popcnt();0<a.Passed[e].front&&(c+=.5*a.Passed[e].front)}b.passVal=c;b.val=this.add(b.val,this.mult(this.cpxPassed,c));c=this.mult(this.cpxAsym,this.pawnAsym);b.val=this.add(b.val,c);for(d=0;2>d;d++)b.attack=
5230a.Attacks[d].hanging+a.Attacks[d].badness+a.Attacks[d].controlThem+a.Attacks[d].pawnAttacks+a.Attacks[d].nTwiceAttacked+a.Attacks[d].nAttacked,b.val=this.add(b.val,this.mult(this.cpxArea,.2*b.weightArea[d])),b.val=this.add(b.val,this.mult(this.cpxWeakPawns,a.Pawns[d].nWeak)),b.val=this.add(b.val,this.mult(this.cpxCandidates,a.Pawns[d].nCandidates)),b.val=this.add(b.val,this.mult(this.cpxPawnPush,a.Pawns[d].pushCnt)),b.val=this.add(b.val,this.mult(this.cpxCenterPush,a.Pawns[d].centerPushCnt)),b.val=
5231this.add(b.val,this.mult(this.cpxTension,a.Pawns[d].tension)),b.val=this.add(b.val,this.mult(this.cpxPawnKingRing,.3*a.Pawns[d].kring)),b.val=this.add(b.val,this.mult(this.cpxHanging,a.Attacks[d].hanging)),b.val=this.add(b.val,this.mult(this.cpxBadness,a.Attacks[d].badness)),b.val=this.add(b.val,this.mult(this.cpxControl,a.Attacks[d].controlThem)),b.val=this.add(b.val,this.mult(this.cpxWeakBack,a.Attacks[d].weakBack)),b.val=this.add(b.val,this.mult(this.cpxPawnAttacks,a.Attacks[d].pawnAttacks)),b.val=
5232this.add(b.val,this.mult(this.cpxAttack,a.Attacks[d].nAttacked)),b.val=this.add(b.val,this.mult(this.cpxUndef,a.Attacks[d].undefendedVal)),b.val=this.add(b.val,this.mult(this.cpxTwice,a.Attacks[d].nTwiceAttacked)),b.val=this.add(b.val,this.mult(this.cpxPotential,.1*a.Attacks[d].potential)),0>
5232a.Kings[d].safety&&(e=-Math.max(-60,a.Kings[d].safety),2>b.developed[1-d]&&(e/=2),f=this.pos.canCastle(d)?this.cpxSafetyCanCastle:this.cpxSafety,b.val=this.add(b.val,this.mult(f,e)),0>a.Kings[d].shelter&&!this.pos.canCastle(d)&&
5233(e=[-this.phaseScaleKingSafety*this.cpxShelter[0]/100,-this.phaseScaleKingSafety*this.cpxShelter[1]/100],b.val=this.add(b.val,this.mult(e,a.Kings[d].shelter)),b.shelter=-a.Kings[d].shelter*e[0]),0<a.Kings[d].storm&&!this.pos.canCastle(d)&&(e=[this.phaseScaleKingSafety*this.cpxStorm[0]/100,this.phaseScaleKingSafety*this.cpxStorm[1]/100],b.val=this.add(b.val,this.mult(e,.1*a.Kings[d].storm)),b.storm=.1*a.Kings[d].storm*e[0])),b.val=this.add(b.val,this.mult(this.cpxQueenPin,a.Queens[d].queenPinCnt())),
5234b.val=this.add(b.val,this.mult(this.cpxConnected,a.Passed[d].connected));a=this.pinned[0].popcnt()+this.pinned[1].popcnt();b.val=this.add(b.val,this.mult(this.cpxPins,a));this.oppBishops&&(b.val[1]=this.scaleDiffBishops(this.ppScaleDown,b.val[1]));b.scalarVal=this.scalarEv(b.val);b.asym=this.scalarEv(c);return b}activity(a,b,c,d){return[this.evalActivity(0,a,b,c,d),this.evalActivity(1,a,b,c,d)]}evalActivity(a,b,c,d,e){let f=0,g=0,h=0,k=0,l=0,m={},n=[];if(this.isLegal()){let r={pns:null,kn:[this.getKnights(a)],
5235bi:[this.getBishops(a)],ro:[this.getRooks(a)],qu:[this.getQueens(a)]},t={pns:this.attackedBy[a][Pieces.PAWN],kn:b[a].areaBBs,bi:c[a].areaBBs,ro:d[a].areaBBs,qu:e[a].areaBBs};k=this.calcWeightArea(a,r,n);f+=2*k;l=this.calcWeightArea(a,t,n);f=Math.round(100*(l?f+.5*l:0))/100;[b,c,d,e].forEach(function(u){u[a].mob.forEach(function(x){h+=x})});m=this.calcDev(t);this.totPieces[a]&&(g=Math.round((m.area-.7*m.queenArea)/this.totPieces[a]*10)/10,b=squareBB(this.bitPos.kingPos(a)),b.copy().AND(Boards.KING_00[a]).notEmpty()?
5236g+=.8:b.copy().AND(Boards.KING_000[a]).notEmpty()&&(g+=.8))}return{val:f,valid:!0,locArea:k,moveArea:l,mobility:h,devel:g,test:n,getNIcons(){let r=-1,t=[0,5,10,14.5,18];for(let u=0;u<t.length;u++)this.val>t[u]&&(r=u);return r},str(){return String.f("Activity={0}",this.val.toFixed(3))},dbg(){return String.f("MoveArea={0}, LocArea={1}, Devel={2}, Mobil={3}",l.toFixed(1),k.toFixed(1),this.devel.toFixed(1),this.mobility,m.queenArea)}}}calcDev(a){let b=zeroBB(),c=0;for(var d=0;d<a.kn.length;d++)c+=a.kn[d].popcnt(),
5237b.OR(a.kn[d]);for(d=0;d<a.bi.length;d++)c+=a.bi[d].popcnt(),b.OR(a.bi[d]);for(d=0;d<a.ro.length;d++)c+=a.ro[d].popcnt(),b.OR(a.ro[d]);d=0;for(let e=0;e<a.qu.length;e++){let f=a.qu[e].popcnt();c+=f;d+=f;b.OR(a.qu[e])}c+=a.pns.copy().AND(Boards.CENTER).popcnt();c+=b.copy().AND(Boards.CENTER).popcnt();return{bbAreaDev:b,area:c,queenArea:d}}calcWeightArea(a,b,c){let d=[0,0],e;e=this.calcPawnWeightArea(a,b,c);d=this.add(d,e);e=this.calcKnightWeightArea(a,b,c);d=this.add(d,e);e=this.calcBishopWeightArea(a,
5238b,c);d=this.add(d,e);e=this.calcRookWeightArea(a,b,c);d=this.add(d,e);e=this.calcQueenWeightArea(a,b,c);d=this.add(d,e);return.1*this.scalarEv(d)}calcPawnWeightArea(a,b){if(!b.pns)return[0,0];let c=[0,0],d=[[[0,0],[0,0],[0,0],[0,0]],[[0,0],[0,0],[0,0],[0,0]],[[.1,1],[.2,1],[.2,1],[.3,1]],[[1,1],[1.5,1],[2,1],[2.5,1]],[[2,1],[3,1],[4,1],[6,1]],[[4,1],[6,1],[8,1],[10,1]],[[16,1],[25,1],[32,1],[36,1]],[[20,1],[30,1],[40,1],[48,1]]];b=b.pns;for(let e=0;8>e;e++){let f=b.copy().AND(Boards.RELATIVE_RANK[a][e]);
5239if(f.popcnt())for(let g=0;8>g;g++){let h=Math.min(g,Square.FILE_H-g);f.copy().AND(fileBB(g)).popcnt()&&(c=this.add(c,d[e][h]))}}return c}calcQueenWeightArea(a,b,c){return this.calcPieceWeightArea(a,Pieces.QUEEN,b,b.qu,[[[1,1],[1,1],[1,1],[1,1]],[[1,1],[2,1],[1.5,1],[1.8,1]],[[1,1],[2,1],[1.6,1],[2,1]],[[2,1],[2,1],[1.7,1],[2.1,1]],[[2,1],[2,1],[1.8,1],[2.2,1]],[[2,1],[3,1],[2,1],[2.4,1]],[[2.4,1],[4,1],[2.1,1],[2.5,1]],[[2.6,1],[5,1],[2.2,1],[3,1]]],c)}calcKnightWeightArea(a,b,c){return this.calcPieceWeightArea(a,
5240Pieces.KNIGHT,b,b.kn,[[[.5,1],[1,1],[1,1],[1,1]],[[1,1],[1,1],[1,1],[1,1]],[[1.5,1],[1.5,1],[2,1],[2,1]],[[2,1],[2,1],[3,1],[4,1]],[[3,1],[3,1],[4,1],[4,1]],[[4,1],[4,1],[5,1],[5,1]],[[5,1],[5,1],[6,1],[6,1]],[[4,1],[4,1],[5,1],[6,1]]],c)}calcBishopWeightArea(a,b,c){return this.calcPieceWeightArea(a,Pieces.BISHOP,b,b.bi,[[[.5,1],[1,1],[1,1],[1,1]],[[1,1],[2,1],[2,1],[2,1]],[[1.5,1],[2,1],[2,1],[3,1]],[[2,1],[2,1],[2,1],[3,1]],[[3,1],[2,1],[2,1],[4,1]],[[3,1],[3,1],[3,1],[5,1]],[[4,1],[4,1],[4,1],
5241[4,1]],[[3,1],[3,1],[3,1],[3,1]]],c)}calcRookWeightArea(a,b,c){return this.calcPieceWeightArea(a,Pieces.ROOK,b,b.ro,[[[1,1],[1,1],[2,1],[3,1]],[[1,1],[2,1],[2,1],[3,1]],[[1,1],[2,1],[2,1],[3,1]],[[2,1],[2,1],[2,1],[3,1]],[[3,1],[2,1],[2,1],[3,1]],[[3,1],[3,1],[3,1],[3,1]],[[4,1],[4,1],[4,1],[4,1]],[[3,1],[3,1],[3,1],[3,1]]],c)}calcPieceWeightArea(a,b,c,d,e,f){c=[0,0];let g=this.calcSpecialBBs(a,b,f);for(let k=0;k<d.length;k++){let l=d[k].copy();for(let m=0;8>m;m++){let n=l.copy().AND(Boards.RELATIVE_RANK[a][m]);
5242if(n.popcnt())for(let r=0;8>r;r++){var h=Math.min(r,Square.FILE_H-r);let t=n.copy().AND(fileBB(r));t.notEmpty()&&(h=this.calcSpecialBonus(a,b,e[m][h],t,g,f),c=this.add(c,h))}}}return c}calcSpecialBonus(a,b,c,d,e,f){let g=[1,1];d.copy().AND(e.closeChecks).notEmpty()?(g=this.add(g,[2,.2]),d.copy().AND(this.attackedByTwo[a]).notEmpty()&&(g=this.add(g,[2,.1]))):d.copy().AND(e.checks).notEmpty()?g=this.add(g,[.8,.1]):d.copy().AND(this.kingRing[1-a]).notEmpty()?g=this.add(g,[.5,0]):d.copy().AND(this.kingRing[a]).notEmpty()&&
5243(g=this.add(g,[.1,0]));b!=Pieces.QUEEN&&d.copy().AND(e.gardez).notEmpty()&&(g=this.add(g,[.6,.1]));d.copy().AND(e.weakPawns).notEmpty()&&(g=this.add(g,[.5,1.5]));d.copy().AND(e.neutralizeAtt).notEmpty()&&(g=this.add(g,[.3,.4]));d.copy().AND(e.rookGardez).notEmpty()&&(g=this.add(g,[.5,.5]));d.copy().AND(e.passedPath).notEmpty()&&(g=this.add(g,[.5,1.6]));d.copy().AND(e.passedBehind).notEmpty()&&(g=this.add(g,[.2,1]));d.copy().AND(e.oppPieces).notEmpty()&&(g=this.add(g,[.2,.4]));d.copy().AND(e.pawnPushMe).notEmpty()&&
5244(g=this.add(g,[.3,.5]));g=this.checkMajorPiecePawnPush(a,b,d,e.pawnPushMe,g,f);d.copy().AND(e.pawnPushOpp).notEmpty()&&(g=this.add(g,[.3,.5]));return this.mult(c,this.scalarEv(g))}calcSpecialBBs(a,b,c){c={};var d=allSetBB().AND_NOT(this.getAttackedByPiece(1-a,Pieces.PAWN)),e=this.bitPos.kingPos(1-a);c.checks=this.attackedBy[a][b].copy().AND(this.getAttacks(b,e,this.getAllPieces(),1-a));c.closeChecks=c.checks.copy().AND(this.kingRing[1-a]);c.gardez=zeroBB();b!=Pieces.QUEEN&&(e=this.getQueens(1-a).LSB(),
524564>e&&(c.gardez=this.attackedBy[a][b].copy().AND(this.getAttacks(b,e,this.getAllPieces(),1-a)).AND(d)
5245));e=this.weakPawns[1-a].copy();for(c.weakPawns=zeroBB();e.notEmpty();){var f=e.popLSB();c.weakPawns.OR(this.getAttacks(b,f,this.getAllPieces(),1-a)).AND(d)}c.neutralizeAtt=zeroBB();for(e=this.attackedByAll[1-a].copy().AND_NOT(this.attackedBy[a][Pieces.PAWN]).AND_NOT(this.attackedBy[1-a][Pieces.PAWN]).AND_NOT(this.getPieces(1-a));e.notEmpty();)f=e.popLSB(),c.neutralizeAtt.OR(this.getAttacks(b,f,this.getAllPieces(),
52461-a));c.rookGardez=zeroBB();if(b==Pieces.BISHOP||b==Pieces.KNIGHT)for(e=this.getRooks(1-a);e.notEmpty();)f=e.popLSB(),c.rookGardez.OR(this.getAttacks(b,f,this.getAllPieces(),1-a)).AND(d);c.passedPath=zeroBB();f=this.passedPawns[a].copy();for(e=zeroBB();f.notEmpty();){var g=f.popLSB();e.OR(PositionEvaluation.forward[a][g])}for(f=this.passedPawns[1-a].copy();f.notEmpty();)g=f.popLSB(),e.OR(PositionEvaluation.forward[1-a][g]);for(;e.notEmpty();)f=e.popLSB(),c.passedPath.OR(this.getAttacks(b,f,this.getAllPieces(),
52471-a));c.passedPath.AND(d);c.passedBehind=zeroBB();if(b==Pieces.ROOK||b==Pieces.QUEEN){for(b=this.passedPawns[a].copy();b.notEmpty();)e=b.popLSB(),c.passedBehind.OR(PositionEvaluation.forward[1-a][e]);for(b=this.passedPawns[1-a].copy();b.notEmpty();)e=b.popLSB(),c.passedBehind.OR(PositionEvaluation.forward[a][e])}c.passedBehind.AND(d);c.oppPieces=zeroBB();d=this.getPieces(1-a).AND_NOT(this.attackedBy[1-a][Pieces.PAWN]).AND_NOT(this.getKing(1-a));c.oppPieces=d;d=this.getPawns(a).AND(Boards.RELATIVE_RANK[a][1]);
5248d=a?d.makeS():d.makeN();d.AND_NOT(this.getAllPieces());d=a?d.makeS():d.makeN();d.AND_NOT(this.getAllPieces());b=this.getPawns(a);b=a?b.makeS():b.makeN();b.AND_NOT(this.getAllPieces()).AND(Boards.PASSEDPAWN_RANKS[a]);c.pawnPushMe=b.OR(d);c.pawnPushMe.AND_NOT(this.makePawnAtt(this.getPawns(a),a));d=this.getPawns(1-a).AND(Boards.RELATIVE_RANK[1-a][1]);d=a?d.makeN():d.makeS();d.AND_NOT(this.getAllPieces());d=a?d.makeN():d.makeS();d.AND_NOT(this.getAllPieces());b=this.getPawns(1-a);b=a?b.makeN():b.makeS();
5249b.AND_NOT(this.getAllPieces()).AND(Boards.PASSEDPAWN_RANKS[1-a]);c.pawnPushOpp=b.OR(d);c.pawnPushOpp.AND_NOT(this.makePawnAtt(this.getPawns(1-a),1-a));return c}checkMajorPiecePawnPush(a,b,c,d,e,f){if(b==Pieces.ROOK)for(b=d.copy(),d=c.LSB();b.notEmpty();)f=b.popLSB(),f>>3==d>>3&&PositionEvaluation.forward[1-a][f].copy().AND(c).notEmpty()&&(f+=0==a?Square.MD_BACK:Square.MD_FORWARD,PositionEvaluation.forward[1-a][f].copy().AND(this.getAllPawns()).empty()&&(e=this.add(e,[1,1])));return e}evalSpace(a){let b=
5250a?1:0,c=a?0:1,d=0,e=0,f=0,g,h,k=this.cntBlockedPawns[b];2E3<this.pieceMaterial()&&(g=b?Boards.BLACK_SPACE.copy():Boards.WHITE_SPACE.copy(),g.AND_NOT(this.getPawns(b)),g.AND_NOT(this.getAttackedByPiece(c,Pieces.PAWN)),h=this.pawnSpace(b).copy().AND(g).AND_NOT(this.getAttackedBy(c)),d=g.popcnt()+3*h.popcnt(),f=this.pos.countAllPieces(a),e=f+this.cntBlockedPawns[b]);return{val:d*e*e/10,factor:d,factor2:e,freeCnt:g?g.popcnt():0,closeCnt:h?h.popcnt():0,nPieces:f,test:[],str(){return String.f("Space{0}={1}",
5251["W","B"][a],this.val)},dbg(){return String.f("N={0}/{1} Pieces={2}, Blocked={3}",this.factor,this.factor2,this.nPieces,k)}}}spaces(){let a=this.evalSpace(0),b=this.evalSpace(1);return[a,b]}evalKnights(a){let b=a?1:0,c=a?0:1,d=this.getKnights(b),e=0,f=[0,0],g=[],h=[],k=[],l=[],m=[],n=[],r=0,t=[],u=0,x=0;for(;d.notEmpty();){let z=[0,0];var B=d.popLSB();n.push(B);let V=squareBB(B);var y=this.mult(this.pstKnight[this.relSq(B,b)],.1);z=this.add(z,y);k.push(this.scalarEv(y));this.minorBlocksPawnMask[b].copy().AND(V).notEmpty()&&
5252(z=this.add(z,[10,5]));y=PositionEvaluation.allKnightAttacks[B].copy();e+=y.popcnt();this.attackedByTwo[b].OR(this.attackedByAny[b].copy().AND(y));this.attackedByAny[b].OR(y);this.attackedByPiece[b][Pieces.KNIGHT].OR(y);var A=y.copy().AND(this.mobilityArea[b]).popcnt();if(V.copy().AND(this.pinned[b]).empty()){A=this.sMobilityBonusKnight[A];l.push(A);z=this.add(z,A);A=PositionEvaluation.allKnightAttacks[B].copy().AND_NOT(this.getPieces(b));r+=A.popcnt();t.push(A);A=y.copy().AND(this.weakPawns[c]);
5253A.notEmpty()&&(A=A.popcnt(),u+=A,A=this.mult(this.sWeakPawnAttack[0],A),z=this.add(z,A));if(y.copy().AND(this.kingRing[c]).notEmpty()){this.numKingAttackers[b]++;A=.5*y.copy().AND(this.kingRing[c]).AND_NOT(this.attackedBy[c][Pieces.KING]).AND_NOT(this.getPieces(b)).popcnt();this.kingAttackPower[b]+=this.vKingAttackPower[Pieces.KNIGHT];let ba=y.copy().AND(this.attackedBy[c][Pieces.KING]);A+=ba.popcnt();x+=A;z=this.add(z,[6*A,0]);this.closeKingAttackers[b]+=A}A=this.bitPos.kingPos(c);y=PositionEvaluation.allKnightAttacks[A].copy().AND(y);
5254y.empty()||(y=this.mult([this.vKnightCheck[y.popcnt()-1&3],0],.2),m.push(y),z=this.add(z,y));V.copy().AND(this.outPosts[b]).notEmpty()&&(B=this.evalOutpost(b,Pieces.KNIGHT,B,V),z=this.add(z,[B,B]))}f=this.add(f,z);g.push(z);h.push(this.scalarEv(z))}let aa=[];g.forEach(function(z){aa.push(z[0])});let ha=[];l.forEach(function(z){ha.push(this.scalarEv(z))}.bind(this));return{val:this.scalarEv(f),valid:0<n.length,evs:g,attCnt:e,area:r,areaBBs:t,weakAtt:u,kingAtt:x,pst:k,mob:ha,checks:m,test:[],getVal(z){return h[z]},
5255getNVals(){return n.length}
5255,getDiodColor(z){return PositionEvaluation.getValColor(this.getVal(z),0,50,0,PositionEvaluation.MAX_HUE)},getDiodGradient(z){return PositionEvaluation.getGradient(this.getDiodColor(z))},getDiodBlinks(z){return 65<this.getVal(z)},getDiodText(z){return this.getVal(z)},getDiodSq(z){return n[z]},getDiodTip(z){return String.f("{0} {1}",this.getStrPiece(),CBSquare.toString(n[z]))},getStrPiece(){return"Knight"},str(){return String.f("Knight{0}={1}, Sqs={2}",["W","B"][a],this.val,
5256PositionEvaluation.debugSqs(n))},dbg(){return String.f("Tot={0}, attCnt={2}, area={3}, mob={4}, checks={5}",aa,this.pst,e,r,this.mob,this.checks)}}}knights(){return[this.evalKnights(0),this.evalKnights(1)]}bishops(){return[this.evalSliders(0,Pieces.BISHOP),this.evalSliders(1,Pieces.BISHOP)]}rooks(){return[this.evalSliders(0,Pieces.ROOK),this.evalSliders(1,Pieces.ROOK)]}queens(){return[this.evalSliders(0,Pieces.QUEEN),this.evalSliders(1,Pieces.QUEEN)]}evalSliders(a,b){let c=a?1:0,d=a?0:1,e=this.bitPos.getPiecesOfSide(b,
5257a);let f=[0,0],g=[],h=[],k=[],l=[],m=0,n=[],r=[],t=[],u=[],x=[],B=0,y=0,A=-30,aa=30,ha=[[0,0],[0,0]];for(;e.notEmpty();){let ea=[0,0];var z=e.popLSB();u.push(z);var V=this.relSq(z,a),ba=squareBB(z);switch(b){case Pieces.BISHOP:ea=this.add(ea,this.mult(this.pstBishop[V],.5));this.minorBlocksPawnMask[c].copy().AND(ba).empty()||(ea=this.add(ea,[5,5]));k.push(this.pstBishop[V][0]);A=-33;aa=50;break;case Pieces.ROOK:ea=this.add(ea,this.mult(this.pstRook[V],.5));k.push(this.pstRook[V][0]);A=-53;aa=50;break;
5258case Pieces.QUEEN:ea=this.add(ea,this.mult(this.pstQueen[V],.5));var v=this.bitPos.kingPos(d);ea=this.add(ea,this.sQueenKingDist[Math.min(Math.abs((z>>3)-(v>>3)),Math.abs((z&7)-(v&7)))]);k.push(this.pstQueen[V][0]);A=-10;aa=30}v=this.getAllPieces().XOR(this.mobilityArea[c].copy().AND(this.getKnights(d).OR(this.getRooks(d))));var K=this.getAllPieces().XOR(this.mobilityArea[c].copy().AND(this.getKnights(d).OR(this.getBishops(d))));V=this.getAttacks(b,z,this.getAllPieces()).AND_NOT(this.getPieces(c));
5259switch(b){case Pieces.BISHOP:var C=v.copy().XOR(this.getAllQueens());C=this.getAttacks(b,z,C);break;case Pieces.ROOK:C=K.copy().XOR(this.getRooks(c).OR(this.getAllQueens()));C=this.getAttacks(b,z,C);break;case Pieces.QUEEN:C=this.getAllPieces(),C=this.getAttacks(Pieces.BISHOP,z,C).OR(this.getAttacks(Pieces.ROOK,z,C))}m+=V.popcnt();t.push(V);this.attackedByTwo[c].OR(this.attackedByAny[c].copy().AND(C));this.attackedByAny[c].OR(C);this.attackedByPiece[c][b].OR(C);ba.copy().AND(this.getPinned()).notEmpty()&&
5260C.AND(PositionEvaluation.lines[z][this.bitPos.kingPos(c)]);v=C.copy().AND(this.weakPawns[d]);v.notEmpty()&&(v=v.popcnt(),B+=v,v=this.mult(this.sWeakPawnAttack[b-Pieces.KNIGHT],v),ea=this.add(ea,v));C.copy().AND(this.kingRing[d]).notEmpty()?(this.numKingAttackers[c]++,this.kingAttackPower[c]+=this.vKingAttackPower[b],v=.5*C.copy().AND(this.kingRing[d]).AND_NOT(this.attackedBy[d][Pieces.KING]).AND_NOT(this.getPieces(c)).popcnt(),K=C.copy().AND(this.attackedBy[d][Pieces.KING]),v+=K.popcnt(),y+=v,ea=
5261this.add(ea,[2*v,0]),this.closeKingAttackers[c]+=v,n.push(v+1)):n.push(0);b==Pieces.QUEEN&&(C.AND_NOT(this.attackedBy[d][Pieces.KNIGHT].copy().OR(this.attackedBy[d][Pieces.BISHOP]).OR(this.attackedBy[d][Pieces.ROOK])),PositionEvaluation.ranksInFront[d][Square.RANK_5-a].copy().AND(C).empty()&&(ea=this.sub(ea,8)));v=C.copy().AND(this.mobilityArea[c]).popcnt();K=this.bitPos.kingPos(d);switch(b){case Pieces.BISHOP:ea=this.add(ea,this.sMobilityBonusBishop[v]);l.push(this.sMobilityBonusBishop[v]);V=this.getAttacks(Pieces.BISHOP,
5262K,this.getAllPieces()).AND(V);V.empty()||(V=this.mult([this.vBishopCheck[V.popcnt()-1&1],0],.1),r.push(V),ea=this.add(ea,V));break;case Pieces.ROOK:ea=this.add(ea,this.sMobilityBonusRook[v]);l.push(this.sMobilityBonusRook[v]);V=this.getAttacks(Pieces.ROOK,K,this.getAllPieces()).AND(V);V.empty()||(V=this.mult([this.vRookCheck[V.popcnt()-1&3],0],.1),r.push(V),ea=this.add(ea,V));break;case Pieces.QUEEN:ea=this.add(ea,this.sMobilityBonusQueen[v]),l.push(this.sMobilityBonusQueen[v]),V=this.getAttacks(Pieces.QUEEN,
5263K,this.getAllPieces()).AND(V),V.empty()||(V=this.mult([this.vQueenCheck[V.popcnt()-1&7],0],.05),r.push(V),ea=this.add(ea,V))}b==Pieces.BISHOP&&(V=ba.copy().AND(Boards.LIGHT_SQUARES).notEmpty()?0:1,V=this.bishopPenalty[a][V],ha[a]=this.add(ha[a],V),ea=this.sub(ea,V),ba.copy().AND(this.outPosts[c]).notEmpty()&&(ba=this.evalOutpost(c,Pieces.BISHOP,z,ba),ea=this.add(ea,ba)),ba=this.getPawns(a),ba.OR(this.getPawns(d).AND(this.attackedBy[d][Pieces.PAWN]).AND_NOT(this.attackedBy[c][Pieces.PAWN])),this.getAttacks(Pieces.BISHOP,
5264z,ba).AND(PositionEvaluation.allKingAttacks[this.bitPos.kingPos(d)]).notEmpty()&&(ea=this.add(ea,[5,0])),1<this.getAttacks(Pieces.BISHOP,z,this.getAllPawns()).AND(Boards.CENTER).popcnt()&&(ea=this.add(ea,[10,0])));b==Pieces.ROOK&&(ea=this.add(ea,this.rookBonus[c][z>>3]),this.relRank(z,a)>Square.RANK_4&&(ba=rankBB(z&7).AND(this.getPawns(d)).AND(this.attackedBy[d][Pieces.PAWN]),ea=this.add(ea,[0,ba.popcnt()])),fileBB(z>>3).copy().AND(this.getQueens(c)).notEmpty()&&(ba=this.getQueens(c).LSB(),PositionEvaluation.between[z][ba]&&
5265PositionEvaluation.between[z][ba].copy().AND(this.getPawns(c)).empty()&&(ea=this.add(ea,[4,2]))));b==Pieces.QUEEN&&(z=this.getSliderStops(this.getRooks(d).OR(this.getBishops(d)),z,d),z.blockers.AND(this.getPieces(c)),ba=z.blockers.popcnt(),ea=this.sub(ea,[-2*ba,-1*ba]),x.push(z.blockers.notEmpty()?z.blockers.LSB():-1));f=this.add(f,ea);g.push(ea);h.push(this.scalarEv(ea))}let da=[];g.forEach(function(ea){da.push(ea[0])});let ja=[];l.forEach(function(ea){ja.push(this.scalarEv(ea))}.bind(this));return{val:this.scalarEv(f),
5266valid:0<u.length,evs:g,area:m,areaBBs:t,kingAtt:y,weakAtt:B,checks:r,queenPins:x.length,bishPenalty:this.scalarEv(ha[a]),queenPinCnt(
5266){let ea=0;for(let ra=0;ra<x.length;ra++)0<=x[ea]&&ea++;return ea},mob:ja,p:b,getVal(ea){return h[ea]},getNVals(){return u.length},getDiodColor(ea){return PositionEvaluation.getValColor(this.getVal(ea),A,aa,0,PositionEvaluation.MAX_HUE)},getDiodGradient(ea){return PositionEvaluation.getGradient(this.getDiodColor(ea))},getDiodBlinks(ea){return this.getVal(ea)>aa+5},getDiodText(ea){return this.getVal(ea)},
5267getDiodSq(ea){return u[ea]},getDiodTip(ea){return String.f("{0} {1} ",this.getStrPiece(),CBSquare.toString(u[ea]))},getStrPiece(){return["Bishop","Rook","Queen"][b-2]},str(){return String.f("{0}{1}={2}, Sqs={3}",["Bish","Rook","Queen"][b-2],["W","B"][a],this.val,PositionEvaluation.debugSqs(u))},dbg(){let ea=String.f("Tot={0}, Mob={1}, Area={2}, King={3}",da,ja,m,n);b==Pieces.QUEEN?ea+=String.f(", qPins={0}",this.queenPinCnt()):b==Pieces.BISHOP&&(ea+=String.f(", Penalty={0}",this.bishPenalty));this.checks.length&&
5268(ea+=String.f(", checks={0}",this.checks));return ea},test:[]}}evalOutpost(a,b,c,d){var e=this.relSq(c,a);e=b==Pieces.KNIGHT?this.vOutpostBonus[e-3-8]:this.vOutpostBonus[e+1-8];let f=3&this.pos.countPieces(Piece.KNIGHT+(a?8:0));(Boards.LIGHT_SQUARES.copy().AND(d).notEmpty()?Boards.LIGHT_SQUARES.copy():Boards.DARK_SQUARES.copy()).AND(this.getBishops(1-a)).notEmpty()&&(f+=4);d.copy().AND(this.attackedBy[a][Pieces.PAWN]).notEmpty()&&(f+=8);b==Pieces.BISHOP&&(f+=16);e=e*this.vOutpostFactor[f]>>4;d.copy().AND(this.outPosts2[a]).notEmpty()&&
5269(e=15*e>>6);b==Pieces.KNIGHT&&(b=PositionEvaluation.allKnightAttacks[c].copy().AND(this.outPosts[a]),b.AND(this.attackedBy[a][Pieces.PAWN]),b.notEmpty()&&(e+=e/8));return e}evalPawns(){var a=twoZeroBB(),b=twoZeroBB();this.outPosts=[Boards.OUTPOSTAREAS[0].copy(),Boards.OUTPOSTAREAS[1].copy()];this.passedPawns=twoZeroBB();this.weakPawns=twoZeroBB();this.candidatePawns=[allSetBB(),allSetBB()];let c=[[0,0],[0,0]],d=[0,0],e=[0,0],f=[0,0],g=[[0,0],[0,0]],h=[],k=[[],[]];for(var l=0;2>l;l++){var m=l?1:0,
5270n=1-m,r=this.getPawns(m);let A=this.getPawns(n),aa=r.copy(),ha=[0,0];for(h[l]=[];!aa.empty();){let z=aa.popLSB();var t=squareBB(z);let V=z>>3;var u=z&7,x=this.relRank(z,m);ha=this.mult(this.pstPawn[this.relSq(z,m)],.5);ha=this.add(ha,[2,0]);c[l]=this.add(c[l],ha);A.copy().AND(PositionEvaluation.allPawnAttacks[m][z]).empty()&&a[m].OR(fileBB(V));this.outPosts[n].AND_NOT(PositionEvaluation.passedMask[l][z].copy().AND(PositionEvaluation.neighbourFiles[V]));let ba=!r.copy().AND(PositionEvaluation.forward[l][z]).empty();
5271ba&&(this.candidatePawns[n].AND_NOT(PositionEvaluation.neighbourFiles[V]),this.candidatePawns[m].AND_NOT(t),ha=this.sub(ha,this.sDoubledPawn[V]),e[l]++);var B=A.copy().AND(PositionEvaluation.passedMask[l][z]).empty();B&&!ba&&this.passedPawns[l].OR(t);let v=A.copy().AND(PositionEvaluation.forward[l][z]).empty()?0:1;var y=r.copy().AND(PositionEvaluation.neighbourFiles[V]).empty();y?(b[l].OR(PositionEvaluation.passedMask[l][z].copy().OR(t)),B||this.weakPawns[l].OR(t),this.candidatePawns[l].AND_NOT(fileBB(V)),
5272ha=this.sub(ha,this.sIsolatedPawn[8*v+V])):r.copy().AND(PositionEvaluation.allPawnAttacks[n][z]).empty()&&(ha=this.sub(ha,[1,2]));let K=!rankBB(u).OR(rankBB(u-1+2*l)).AND(PositionEvaluation.neighbourFiles[V]).AND(r).empty();K&&(ha=this.add(ha,this.sConnectedPawn[6*V+x-1]));let C=!A.copy().AND(PositionEvaluation.allPawnAttacks[l][z]).empty();C&&(ha=this.add(ha,this.sPawnLever[x]));!(B||y||K||C)&&x<=Square.RANK_4&&r.copy().AND(PositionEvaluation.neighbourFiles[V]).AND(PositionEvaluation.ranksInFront[n][u]).empty()&&
5273(u=0==l?Square.MD_FORWARD:Square.MD_BACK,x=z,B=A.copy().AND(PositionEvaluation.allPawnAttacks[l][x+u]),B.empty()&&r.copy().AND(PositionEvaluation.allPawnAttacks[l][x]).empty()&&(x+=u,B=A.copy().AND(PositionEvaluation.allPawnAttacks[l][x+u]),B.empty()&&r.copy().AND(PositionEvaluation.allPawnAttacks[l][x]).empty()&&(x+=u,B=A.copy().AND(PositionEvaluation.allPawnAttacks[l][x+u]),B.empty()&&r.copy().AND(PositionEvaluation.allPawnAttacks[l][x]).empty()&&(x+=u,B=A.copy().AND(PositionEvaluation.allPawnAttacks[l][x+
5274u])))),B.empty()?ha=this.sub(ha,[0,1]):(this.weakPawns[m].OR(t),y=0,v||ba?(y+=16,A.isSet(x+u)||(y+=8)):1<B.popcnt()&&(y+=8),ha=this.sub(ha,this.sBackwardPawn[V+y
5274]),this.candidatePawns[l].AND_NOT(t)));t=.5*this.pawnAtKingZone(l,z);f[l]+=t;ha=this.add(ha,[t,.1*t]);g[l]=this.add(g[l],ha);h[l].push(ha[0]);k[l].push(z)}2E3<this.pieceMaterial()&&(m=l?Boards.BLACK_SPACE.copy():Boards.WHITE_SPACE.copy(),m.AND_NOT(this.getPawns(l)),m.AND_NOT(this.getAttackedByPiece(n,Pieces.PAWN)),n=this.pawnSpace(l).copy().AND(m).AND_NOT(this.getAttackedBy(n)),
5275d[l]=n.popcnt(),g[l][0]+=d[l])}l=this.getPawns(0);n=this.getPawns(1);m=a[0].copy().AND_NOT(a[1]);a=a[1].copy().AND_NOT(a[0]);this.candidatePawns[0].AND(m.copy().AND(l).AND_NOT(this.passedPawns[0]));this.candidatePawns[1].AND(a.copy().AND(n).AND_NOT(this.passedPawns[1]));for(a=0;2>a;a++)for(m=this.candidatePawns[a].copy();m.notEmpty();)r=m.popLSB(),r=this.relRank(r,a),g[a]=this.add(g[a],this.sCandidatePawn[r-1]);b=b[0].copy().AND(b[1]).AND(rankBB(2).OR(rankBB(5)));b.empty()||(a=b.copy().AND(rankBB(5)).popcnt(),
5276g[0]=this.add(g[0],[a,-a]),b=b.copy().AND(rankBB(2)).popcnt(),g[1]=this.add(g[1],[b,-b]));b=this.passedPawns[0].copy().OR(this.candidatePawns[0]);b.empty()||n.empty()||!(b.MSB()>>3>n.MSB()>>3||b.LSB()>>3<n.LSB()>>3)||(g[0]=this.add(g[0],[-3,8]));b=this.passedPawns[1].copy().OR(this.candidatePawns[1]);b.empty()||l.empty()||!(b.MSB()>>3>l.MSB()>>3||b.LSB()>>3<l.LSB()>>3)||(g[1]=this.add(g[1],[-3,8]));this.passedPawns[0].AND(Boards.PASSEDPAWN_RANKS[0]);this.passedPawns[1].AND(Boards.PASSEDPAWN_RANKS[1]);
5277b=Boards.CENTER.copy().AND(this.getPawns(0)).notEmpty();a=Boards.CENTER.copy().AND(this.getPawns(1)).notEmpty();b&&!a&&(g[0][0]+=3);a&&!b&&(g[1][0]+=3);
5277this.calcPawnFeatures(l,n);b=this.attackedBy[0][Pieces.PAWN].copy().AND(this.getPawns(1));a=[];l=this.getPawns(0).popcnt()-this.getPawns(1).popcnt();0<=l?(g[0][0]+=6*l,g[0][1]+=8*l):(g[1][0]-=6*l,g[1][1]-=8*l);for(let A=0;2>A;A++)l=this.getPawns(A),l=A?l.makeS():l.makeN(),l.AND_NOT(this.getAllPawns()),n=l.copy().AND(Boards.CENTER),a[A]={val:this.scalarEv(g[A]),
5278valid:0<k[A].length,nWeak:this.weakPawns[A].popcnt(),nPassed:this.passedPawns[A].popcnt(),nDoubled:e[A],blocked:this.cntBlockedPawns[A],nCandidates:this.candidatePawns[A].popcnt(),pushCnt:l.popcnt(),centerPushCnt:n.popcnt(),tension:b.popcnt(),space:d[A],pst:c[A],pawnEvs:h[A],sqs:k[A],kring:f[A],str(){return String.f("Pawns{0}={1}",["W","B"][A],this.getVal())},dbg(){return String.f("Weak={0}, Pass={1}, Doubl={2}, Cand={3}, Evals={4}, Blockd={5}, PushCnt={6}/{7}, Tens={8}, Space={9}, KRing={10}, pst={11}",
5279this.nWeak,this.nPassed,this.nDoubled,this.nCandidates,vecOut(this.pawnEvs),this.blocked,this.pushCnt,this.centerPushCnt,this.tension,this.space.toFixed(1),this.kring.toFixed(1),vecOut(this.pst))},getNVals(){return this.sqs.length?1:0},getVal(){let aa=this.val;this.passed&&(aa+=this.passed.val);return aa},getDiodColor(){return PositionEvaluation.getValColor(this.getVal(),-10,30,0,PositionEvaluation.MAX_HUE)},getDiodGradient(aa){return PositionEvaluation.getGradient(this.getDiodColor(aa))},getDiodBlinks(){return!1},
5280getDiodText(){return this.getVal()},getDiodTip(){return"Pawns"}};a[0].test=[];return a}pawnAtKingZone(a,b){var c=this.bitPos.kingPos(1-a);c=PositionEvaluation.kingZone[c].copy();let d=this.kingRing[1-a].copy().AND_NOT(c).AND(PositionEvaluation.allPawnAttacks[a][b]);c.AND(PositionEvaluation.allPawnAttacks[a][b]);b=d.popcnt();b+=3*c.popcnt();return b*=Math.sqrt(this.attackPotential[a]+1)}calcPawnFeatures(a,b){var c=[Boards.OUTPOSTAREAS[0].copy(),Boards.OUTPOSTAREAS[1].copy()];this.outPosts2=twoZeroBB();
5281var d=c[0].copy().AND_NOT(this.outPosts[0].copy().OR(this.getAllPawns()));for(d.AND(this.attackedBy[0][Pieces.PAWN].copy().AND_NOT(this.attackedBy[1][Pieces.PAWN]));d.notEmpty();){var e=d.popLSB();if(e>=-Square.MD_FL){var f=squareBB(e);e+=Square.MD_FL;var g=squareBB(e);if(a.copy().AND(g).notEmpty()||PositionEvaluation.forward[0][e].copy().AND(b).empty()||g.copy().AND(this.attackedBy[0][Pieces.PAWN]).AND_NOT(this.attackedBy[1][Pieces.PAWN]).notEmpty())e+=2*Square.MD_RIGHT,e<=Square.H8&&(g=squareBB(e),
5282(a.copy().AND(g).notEmpty()||PositionEvaluation.forward[0][e].copy().AND(b).empty()||g.copy().AND(this.attackedBy[0][Pieces.PAWN]).AND_NOT(this.attackedBy[1][Pieces.PAWN]).notEmpty())&&this.outPosts2[0].OR(f))}}d=c[1].copy().AND_NOT(this.outPosts[1].copy().OR(this.bitPos.bitboards[Pieces.PAWN]));for(d.AND(this.attackedBy[1][Pieces.PAWN].copy().AND_NOT(this.attackedBy[0][Pieces.PAWN]));d.notEmpty();)if(c=d.popLSB(),c>=-Square.MD_BL&&(e=squareBB(c),c+=Square.MD_BL,f=squareBB(c),b.copy().AND(f).notEmpty()||
5283PositionEvaluation.forward[1][c].copy().AND(a).empty()||f.copy().AND(this.attackedBy[1][Pieces.PAWN]).AND_NOT(this.attackedBy[0][Pieces.PAWN]).notEmpty()))c+=2*Square.MD_RIGHT,c<=Square.H8&&(f=squareBB(c),(b.copy().AND(f).notEmpty()||PositionEvaluation.forward[1][c].copy().AND(a).empty()||f.copy().AND(this.attackedBy[1][Pieces.PAWN]).AND_NOT(this.attackedBy[0][Pieces.PAWN]).notEmpty())&&this.outPosts2[1].OR(e));this.outPosts[0].OR(this.outPosts2[0]);this.outPosts[1].OR(this.outPosts2[1]);d=b.makeS().AND(a);
5284g=4*(2<=Boards.LIGHT_INNER.copy().AND(d).popcnt()?1:0);var h=4*(2<=Boards.DARK_INNER.copy().AND(d).popcnt()?1:0);d=3<=Boards.LIGHT_INNER.copy().AND(this.getPawns(0)).popcnt()?1:0;c=3<=Boards.LIGHT_INNER.copy().AND(this.getPawns(1)).popcnt()?1:0;e=Boards.LIGHT_CENTER.copy().AND(this.getPawns(0)).popcnt();f=Boards.LIGHT_CENTER.copy().AND(this.getPawns(1)).popcnt();h=h+2*c+d;this.bishopPenalty[0][0]=this.add(this.sBishopPawnColor[g+2*d+c],e);this.bishopPenalty[1][0]=this.add(this.sBishopPawnColor[h],
5285f);d=a.makeN().AND(b);a=4*(2<=Boards.LIGHT_INNER.copy().AND(d).popcnt()?1:0);b=4*(2<=Boards.DARK_INNER.copy().AND(d).popcnt()?1:0);d=3<=Boards.DARK_INNER.copy().AND(this.getPawns(0)).popcnt()?1:0;c=3<=Boards.DARK_INNER.copy().AND(this.getPawns(1)).popcnt()?1:0;e=Boards.DARK_CENTER.copy().AND(this.getPawns(0)).popcnt();f=Boards.DARK_CENTER.copy().AND(this.getPawns(1)).popcnt();h=b+2*c+d;this.bishopPenalty[0][1]=this.add(this.sBishopPawnColor[a+2*d+c],e);this.bishopPenalty[1][1]=this.add(this.sBishopPawnColor[h],
5286f);for(a=0;8>a;a++)this.kingFileQuality[a]=5;for(a=0;8>a;a++)this.rookBonus[0][a]=[0,0],this.rookBonus[1][a]=[0,0],fileBB(a).AND(this.getAllPawns()).empty()?(this.rookBonus[0][a]=[12,0],this.rookBonus[1][a]=[12,0],this.kingFileQuality[a]-=3,0<a&&this.kingFileQuality[a-1]--,7>a&&this.kingFileQuality[a+1]--):fileBB(a).AND(this.getPawns(0)).empty()?(this.rookBonus[0][a]=[6,13],this.kingFileQuality[a]-=2):fileBB(a).AND(this.getPawns(1)).empty()&&(this.rookBonus[1][a]=[6,13],this.kingFileQuality[a]-=2)}pawns(){let a=
5287this.evalPawns();a[0].passed=this.evalPassed(0);a[1].passed=this.evalPassed(1);return a}evalKings(a){let b=this.evalKingPawns(a,0!=(this.pos.cr&(a?CastleRights.B_ALL:CastleRights.W_ALL)));var c=this.evalKingSafety(a,25<=this.phaseScaleKingSafety?1:0);ObjUtil.copyTo(c,b);b.val=.3*this.scaleKingSafety(64,this.phaseScaleKingSafety,b.val);b.val+=.1*this.scalarEv(b.pst);this.safety=c=1.2*this.scaleKingSafety(64,this.phaseScaleKingSafety,c.safety);b.val+=c;b.str=function(){return String.f("King{0}={1},evSh={2}",
5288["W","B"][a],this.val.toFixed(3),this.ev)};b.dbg=function(){return String.f("Shelt={0}/Storm={1}/Safe={2}(atts={3}), pst={4}/file={5}",this.shelter,this.storm,this.safety,this.nAtts,this.pst,this.fileQual)};b.getNVals=function(){return 1};b.getVal=function(){let d=this.val;return d-=this.myDistToPasseds/5-this.oppDistToPasseds/40};b.getDiodColor=function(){return PositionEvaluation.getValColor(this.getVal(),-40,30,0,PositionEvaluation.MAX_HUE)};b.getDiodGradient=function(d){return PositionEvaluation.getGradient(this.getDiodColor
5288(d))};
5289b.getDiodBlinks=function(){return!1};b.getDiodText=function(){return Math.round(this.getVal())};b.getDiodTip=function(){return"King"};return b}evalKingPawns(a,b){let c=this.bitPos.kingPos(a),d=this.compareShelter(a);b?(b=this.pos.getCastleRights(),a&&(b>>=2),this.psKing[a]=this.sCastlingBonus[b&3]):this.psKing[a]=this.pstKing[this.relSq(c,a)];c>>3==Square.FILE_E&&(this.psKing[a]=this.add(this.psKing[a],[-150,0]));this.pawnStormDanger[a]=.05*d.storm2;this.isLegal()||(this.psKing[a]=[-1E3,-1E3]);return{ev:d.ev,
5290val:d.ev[0],valid:!0,shelter:d.shelter2,storm:d.storm2,pst:this.psKing[a],fileQual:d.fileQual,test:d.test}}compareShelter(a){var b=this.bitPos.kingPos(a);b=this.evalShelter(a,b);if(0!=(this.pos.cr&(a?CastleRights.B_ALL:CastleRights.W_ALL))){if(a&&this.pos.cr&CastleRights.B_00||!a&&this.pos.cr&CastleRights.W_00){let c=this.evalShelter(a,this.relSq(Square.G1,a));c.ev[0]>b.ev[0]&&(b=c)}if(a&&this.pos.cr&CastleRights.B_000||!a&&this.pos.cr&CastleRights.W_000)a=this.evalShelter(a,this.relSq(Square.C1,
5291a)),a.ev[0]>b.ev[0]&&(b=a)}return b}evalShelter(a,b){let c=[[-10,40,45,35,30,15,20],[-40,35,25,-40,-20,-10,-6],[-10,40,15,-2,20,3,-30],[-30,-10,-20,-40,-40,-60,-140]],d=[[70,-150,-100,70,50,30,10],[35,-15,90,30,25,-5,3],[-5,40,130,20,0,-10,-5],[-8,-6,70,5,8,-7,-15]],e=a?1:0;var f=a?0:1;a=[0,0];let g=[0,0],h=[0,0],k=b>>3;if(this.isLegal()){let r=this.getPawns(e).AND_NOT(PositionEvaluation.forward[f][b]);b=this.getPawns(f).AND_NOT(PositionEvaluation.forward[f][b]);a[0]+=2*this.kingFileQuality[k];k<
5292Square.FILE_B&&(k=Square.FILE_B);k>Square.FILE_G&&(k=Square.FILE_G);for(f=k-1;f<=k+1;f++){var l=r.copy().AND(fileBB(f));let t=e?l.MSB():l.LSB();var m=l.notEmpty()?this.relRank(t,e):0;l=b.copy().AND(fileBB(f));t=e?l.MSB():l.LSB();l=l.notEmpty()?this.relRank(t,e):0;var n=Math.min(f,Square.FILE_H-f);a=this.add(a,[c[n][m],0]);m&&m==l-1?l==Square.RANK_3&&(g[0]+=40):(m=d[n][l],0==n&&1<=l&&2>=l&&(n=Boards.FILE_G,0==f&&n==Boards.FILE_B,b.copy().AND(n).notEmpty()||this.attackedBy[e][Pieces.PAWN].copy().AND(squareBB(t)).notEmpty())&&
5293(m=120-20*l),g=this.add(g,[m,0]))}h=this.sub(h,g);h=this.add(h,a)}return{ev:h,shelter2:this.scalarEv(a),storm2:this.scalarEv(g),fileQual:this.kingFileQuality[k],test:[]}}evalKingSafety(a,b){if(!this.numKingAttackers[1-a]&&25>this.attackPotential[1-a])return{safety:0,nAtts:0};let c=this.bitPos.kingPos(a),d=0;var e=a?1:0;a=a?0:1;var f=this.attackedByAny[a].copy().AND(this.attackedBy[e][Pieces.KING]).AND_NOT(this.attackedByTwo[e]),g=this.vKingsafetyFactor[2+5*b],h=this.vKingsafetyFactor[3+5*b],k=this.vKingsafetyFactor[4+
52945*b];let l=this.numKingAttackers[a]*this.kingAttackPower[a]/8+this.pawnStormDanger[e]+this.vKingsafetyFactor[5*b]*this.closeKingAttackers[a]+this.vKingsafetyFactor[1+5*b]*f.popcnt();l+=g*(this.pinned[e].popcnt()?1:0);l+=h*(4*(this.attackPotential[a]-20)-this.attackPotential[e])/8;g=this.getKnights(e).OR(this.getBishops(e));if(g.notEmpty()){let m=h=0;for(;g.notEmpty();)m+=PositionEvaluation.kingDistance[c][g.popLSB()],h+=4;l+=k*m/h-9}k=this.attackedBy[a][Pieces.KNIGHT].copy().OR(this.attackedBy[a][Pieces.BISHOP]);
5295k.AND(this.kingRing[e]).empty()&&(k=this.attackedBy[e][Pieces.KNIGHT].copy().OR(this.attackedBy[e][Pieces.BISHOP]),k.AND(this.kingRing[e]).notEmpty()&&(l-=5));k=this.attackedBy[a][Pieces.QUEEN].copy().AND(this.attackedBy[e][Pieces.KING]).AND_NOT(this.getPieces(a));k.notEmpty()&&(k.AND(this.attackedBy[a][Pieces.PAWN].copy().OR(this.attackedBy[a][Pieces.KNIGHT]).OR(this.attackedByPiece[a][Pieces.BISHOP]).OR(this.attackedByPiece[a][Pieces.ROOK])),k.copy().AND(f).notEmpty()&&(g=k.copy().AND(f).popcnt(),
5296l+=this.vQueenContactCheck[g-1],g=this.attackedBy[e][Pieces.KING].copy().AND_NOT(this.getPieces(e)).AND_NOT(this.attackedByAny[a]),g=Math.min(3,g.popcnt()),h=this.pos.Vj()==e?1:0,l*=this.vEvasionBonus[4*h+g]),k=k.copy().AND_NOT(f),b&&k.notEmpty()&&(l+=this.vUnsafeQueenContactCheck[k.popcnt()-1]));k=f.copy().AND(this.attackedByPiece[a][Pieces.ROOK]).AND_NOT(this.getPieces(a));k.notEmpty()&&(k.AND(this.attackedBy[a][Pieces.PAWN].copy().OR(this.attackedBy[a][Pieces.KNIGHT]).OR(this.attackedByPiece[a][Pieces.BISHOP]).OR(this.attackedByPiece[a][Pieces.QUEEN])),
5297f=k.popcnt(),l+=this.vRookContactCheck[f]);l=Math.max(0,l);if(b){b=this.getPieces(a).OR(this.attackedByAny[e]).NOT();
5297e=this.attackedBy[e][Pieces.PAWN].copy().OR(this.getPawns(a)).NOT();f=this.getAttacks(Pieces.ROOK,c,this.getAllPieces());g=this.getAttacks(Pieces.BISHOP,c,this.getAllPieces());k=f.copy().OR(g).AND(b).AND(this.attackedBy[a][Pieces.QUEEN]);k.notEmpty()&&(l+=this.vQueenCheck[k.popcnt()-1&7]);k=f.copy().AND(b).AND(this.attackedBy[a][Pieces.ROOK]);k.notEmpty()&&(l+=this.vRookCheck[k.popcnt()-
52981&3]);k=g.copy().AND(b).AND(this.attackedBy[a][Pieces.BISHOP]);k.notEmpty()&&(l+=this.vBishopCheck[k.popcnt()-1&1]);k=g.copy().AND(e).AND(this.attackedBy[a][Pieces.BISHOP]);k.notEmpty()&&(d-=this.vCheckThreat[1]);k=PositionEvaluation.allKnightAttacks[c].copy().AND(this.attackedByPiece[a][Pieces.KNIGHT]).AND(b);if(k.notEmpty())for(l+=this.vKnightCheck[k.popcnt()-1&3],b=zeroBB();k.notEmpty();)b.OR(PositionEvaluation.allKnightAttacks[k.popLSB()]),1<b.AND(this.getKnights(a)).popcnt()&&(l+=12);k=PositionEvaluation.allKnightAttacks[c].copy().AND(this.attackedByPiece[a][Pieces.KNIGHT]).AND(e);
5299k.notEmpty()&&(d-=this.vCheckThreat[0]);d+=-Math.min(440,(-l+168*l*l)/32768)}else d=-Math.min(450,(-l+117*l*l)/32768);return{safety:Math.round(1E5*d)/1E5,nAtts:Math.round(100*l)/100}}kings(){return[this.evalKings(0),this.evalKings(1)]}evalAttacks(a){var b=this.bitPos.kingPos(a);let c=[],d=[0,0],e=!1;var f=a?1:0,g=a?0:1;let h=[0,0],k=[0,0],l=[0,0];if(this.relRank(b,a)==Square.RANK_1){var m=Boards.RELATIVE_RANK[a][Square.RANK_1].copy().AND(this.attackedByPiece[g][Pieces.ROOK].copy().OR(this.attackedByPiece[g][Pieces.QUEEN])).AND_NOT(this.attackedByAny[f]);
5300m.notEmpty()&&(m=Boards.RELATIVE_RANK[a][Square.RANK_2].copy().AND(PositionEvaluation.allKingAttacks[b]).AND_NOT(this.getPieces(f).OR(this.attackedByAny[g])),m.empty()&&(e=!0))}var n=this.getPieces(f).AND(this.attackedByPiece[g][Pieces.KING]).AND_NOT(this.attackedByPiece[f][Pieces.PAWN]);n.notEmpty()&&(b=3*Math.min(2,n.copy().AND(this.getPawns(f)).popcnt()),b+=Math.min(2,n.copy().AND_NOT(this.getPawns(f)).popcnt()),d=this.sub(d,this.sKingAttacks[b]));b=[0,0];m=[0,0];let r=0,t=0;n=this.getPieces(f).XOR(this.getPawns(f)).XOR(this.getKing(f)).AND(this.attackedByAny[g]);
5301c.push(n.copy());h[f]=n.popcnt();let u=0;var x=0,B=new Att,y=ObjUtil.clone(this.pos),A=y.canMakeNullMove();y.Vj()==a&&A&&y.makeNullMove();if(A){for(;n.notEmpty();){A=n.popLSB();var aa=squareBB(A),ha=BitPos.toBitPiece(this.pos.board[A]);let ba=this.pos.Vj()==f?1:0;var z=this.attackedByPiece[g][Pieces.PAWN].copy();ha>Pieces.BISHOP&&(z.OR(this.attackedByPiece[g][Pieces.KNIGHT].copy().OR(this.attackedByPiece[g][Pieces.BISHOP])),ha>Pieces.ROOK&&z.OR(this.attackedByPiece[g][Pieces.ROOK]));z=aa.copy().AND(z).notEmpty();
5302ba+=z?2:0;z=aa.copy().AND(this.attackedByAny[f]).notEmpty();ba+=z?4:0;aa=aa.copy().AND(this.getPinned()).notEmpty();ba+=aa?8:0;ha=PositionEvaluation.attackParams[ha-Pieces.KNIGHT][ba];b=this.add(b,ha.scAttack);m=this.add(m,ha.scHanging);r+=ha.hanging;t+=ha.badness;
5302A=B.calcAll(y,A);u+=Math.abs(A)}for(n=this.getPawns(a);n.notEmpty();)A=n.popLSB(),(A=B.calcAll(y,A))&&x++,u+=Math.abs(A)}else d=this.sub(d,this.sCheckAttack);t=Math.min(15,t);b=this.mult(b,this.vAttackBadness[t]/64);d=this.sub(d,b);h[f]+=
5303.6*x;x=this.getPawns(f).AND(this.attackedByPiece[f][Pieces.PAWN]).AND(this.attackedByAny[g]).popcnt();h[f]+=.3*x;x=this.getPawns(f);x=f?x.makeS():x.makeN();x.AND_NOT(this.getAllPieces());B=x.copy().AND(f?Boards.RANK6:Boards.RANK3);B=f?B.makeS():B.makeN();x.OR(B.AND_NOT(this.getAllPieces()));B=this.attackedByAll[g].copy().NOT().OR(this.attackedByAll[f]).AND_NOT(this.attackedBy[g][Pieces.PAWN]);x.AND(B);x=this.makePawnAtt(x,f).AND(this.getPieces(g).AND_NOT(this.getPawns(g)));k[a]=x.popcnt();d=this.add(d,
5304this.mult(this.sPawnThreat,k[a]));x=this.attackedBy[g][Pieces.PAWN].copy().OR(this.attackedByTwo[g].copy().AND_NOT(this.attackedByTwo[f]));x=this.attackedByAll[g].copy().AND_NOT(x).AND(this.attackedByAll[f]).AND_NOT(this.getAllPieces()).AND_NOT(this.attackedBy[f][Pieces.PAWN]);l[a]=x.popcnt();B=this.getPieces(f).AND_NOT(this.attackedByAny[g]).AND_NOT(this.attackedByAny[f]).AND_NOT(this.getKing(f));for(x=[0,0];B.notEmpty();){y=B.popLSB();for(n=PositionEvaluation.allBishopAttacks[y].copy().AND(this.getBishops(g).OR(this.getQueens(g)));n.notEmpty();)A=
5305n.popLSB(),PositionEvaluation.between[y][A].copy().AND(this.getPieces(f).OR(this.getPawns(g))).empty()&&1==PositionEvaluation.between[y][A].copy().AND(this.getPieces(g).AND_NOT(this.blockedPawns[g])).popcnt()&&(x=this.add(x,this.matVal[BitPos.toBitPiece(this.pos.board[y])]));for(n=PositionEvaluation.allRookAttacks[y].copy().AND(this.getRooks(g).OR(this.getQueens(g)));n.notEmpty();)A=n.popLSB(),PositionEvaluation.between[y][A].copy().AND(this.getPieces(f).OR(this.getPawns(g))).empty()&&1==PositionEvaluation.between[y][A].copy().AND(this.getPieces(g).AND_NOT(this.blockedPawns[g])).popcnt()&&
5306(x=this.add(x,this.matVal[BitPos.toBitPiece(this.pos.board[y])]))}f=this.attackedByTwo[a].copy().AND(this.getPieces(1-a)).popcnt();g=this.attackedByTwo[1-a].copy().AND(this.getPieces(a)).popcnt();let V=this.isLegal()?1:0;return{val:this.scalarEv(d),valid:!0,oppVal:0,test:c,weakBack:e?1:0,hanging:r,badness:t,scHanging:m,scAttack:b,nAttacked:h[a],nTwiceAttacked:g,nAttackingTwice:f,pawnAttacks:k[a],controlThem:l[a],potential:this.attackPotential[a],undefendedVal:this.scalarEv(x)/300,attackedVal:u,str(){return String.f("AttackVal{0}={1}",
5307["W","B"][a],this.val)},dbg(){return String.f("WeakBR={0}, hanging={1}, badness={2}, nAttacked={3}, twice={4}, pushAtt={5}, control={6}, undefVal={7}, potntl={8}, matVal={9}",this.weakBack,this.hanging,this.badness,this.nAttacked.toFixed(1),this.nTwiceAttacked,this.pawnAttacks,this.controlThem,this.undefendedVal.toFixed(1),this.potential,this.attackedVal)},squareDiod:!0,getDiodVal(){return this.val-Math.pow(u,.7)-4*this.nAttacked-4*this.nTwiceAttacked},getNVals(){return V},getDiodGradient(){var ba=
5308this.oppVal,v=[0,10,20,40,60,90,120],K=0;for(let C=0;C<v.length;C++)ba>v[C]&&(K=C);v=[[0,80],[20,70],[30,63],[40,55],[50,50],[60,45],[70,40],[75,40]];ba=String.f("hsl( {0}, {1}%, {2}% )",340,v[K][0],v[K][1]+4);K=String.f("hsl( {0}, {1}%, {2}% )",340,v[K][0],v[K][1]-4);return String.f("background-image: radial-gradient( {0}, {1} )",ba,K)},getDiodBlinks(){return!1},getDiodText(){return Math.round(this.oppVal)}}}attacks(){let a=this.evalAttacks(0),b=this.evalAttacks(1);b.oppVal=-a.getDiodVal();a.oppVal=
5309-b.getDiodVal();return[a,b]}evalPassed(a){var b=[0,0];b=1-a;let c=0;var d=a?Square.MD_BACK:Square.MD_FORWARD,e=this.passedPawns[a].copy(),f=[0,0];let g=[0,0],h=!1;for(;e.notEmpty();){h=!0;var k=e.popLSB(),l=k>>3,m=this.relRank(k,a)-Square.RANK_4,n=PositionEvaluation.allPawnAttacks[b][k].copy().AND(this.getPawns(a)).notEmpty()?1:0;f=this.add(f,this.sPPRankBonus[m+4*n]);f=this.add(f,this.sPPFileBonus[l]);3>c&&l<Square.FILE_H&&e.copy().AND(fileBB(l+1)).notEmpty()&&(f=this.add(f,this.sConnectedPPBonus[c]),
5310c++);l=k+d;n=PositionEvaluation.kingDistance[this.bitPos.kingPos(a)][l];1<n&&7>n&&PositionEvaluation.kingPathNextStep[this.bitPos.kingPos(a)][l].copy().AND_NOT(this.attackedByAny[b].copy().OR(this.getPieces(a))).empty()&&n++;n=this.sPPOwnKingDistance[n+8*m];g[a]+=n[1];f=this.sub(f,n);n=PositionEvaluation.kingDistance[this.bitPos.kingPos(b)][l];n=this.sPPOpponentKingDistance[n+8*m];g[b]+=n[1];f=this.add(f,n);let r=PositionEvaluation.forward[a][k].copy();n=r.copy();let t=PositionEvaluation.forward[b][k].copy().AND(this.getAllRooks().OR(this.getAllQueens()));
5311t.notEmpty()&&t.AND(this.getAttacks(Pieces.ROOK,k,this.getAllPieces()));this.getPieces(a).AND(t).empty()&&r.AND(this.attackedByAny[a]);this.getPieces(b).AND(t).empty()&&n.AND(this.attackedByAny[b].copy().OR(this.getPieces(b)));l=squareBB(l);k=(r.copy().AND(l).notEmpty()?1:0)+(r.equals(PositionEvaluation.forward[a][k])?1:0);l=(n.copy().AND(l).empty()?1:0)+(n.empty()?1:0);f=this.add(f,this.sPPBlock[9*m+3*k+l])}b=f;if(this.oppBishops)for(b[1]=this.scaleDiffBishops(this.ppScaleDown,b[1]),d=0;2>d;d++)g[d]=
5312this.scaleDiffBishops(.6*this.ppScaleDown,g[d]);d=this.passedPawns[0].copy();e=this.passedPawns[1].copy();f=0;d.notEmpty()&&(f=d.copy().AND(Boards.RANK7).notEmpty()?5:d.copy().AND(Boards.RANK6).notEmpty()?4:d.copy().AND(Boards.RANK5).notEmpty()?3:d.copy().AND(Boards.RANK4).notEmpty()?2:1);e.notEmpty()&&(f=e.copy().AND(Boards.RANK2).notEmpty()?f+30:e.copy().AND(Boards.RANK3).notEmpty()?24:e.copy().AND(Boards.RANK4).notEmpty()?18:e.copy().AND(Boards.RANK5).notEmpty()?12:f+6);m=0;if(0==a&&d.notEmpty()||
53131==a&&e.notEmpty())m=this.vFrontmostPP[f]/(4+this.attackPotential[0]+this.attackPotential[1]),a&&(m=-m),b[1]+=m;return{val:this.scalarEv(b),valid:h,connected:c,front:m,test:[],kingDist:[this.scalarEv([0,g[0]]),this.scalarEv([0,g[1]])],str(){return String.f("Passed{0}={1}",["W","B"][a],this.val)},dbg(){return String.f("KDistW={0}, B={1}, conn={2}, front={3}",this.kingDist[0],this.kingDist[1],this.connected,this.front)}}}scalarEv(a){a=this.phaseScale*a[0]+(64-this.phaseScale)*a[1];return 0<a?(a+32)/
531464:(a-32)/64+.5}scaleKingSafety(a,b,c){a*=c*b;return 0<a?(a+2048)/4096:(a-2048)/4096+.5}scaleDiffBishops(a,b){a*=b;return 0<a?(a+32)/64:(a-32)/64+.5}testPST(a){return{colSqs:this.toColors(this.pstKing,a,1)}}testAttacks(a){return[PositionEvaluation.allPawnAttacks[0][Square.E4],PositionEvaluation.allPawnAttacks[0][Square.A7],PositionEvaluation.allPawnAttacks[1][Square.H2],PositionEvaluation.allPawnAttacks[1][Square.D6]]}slidingAttack(a,b,c,d){a=a.copy();let e=zeroBB();d=d*Constants.NUM_FILES+c;c=Boards.SLIDING_MASKS[1+
5315c];
5315for(a.SHIFT(d);!a.AND(c).empty();a.AND_NOT(b).SHIFT(d))e.OR(a);return e}testBetween(a){return[PositionEvaluation.between[Square.G7][Square.B2],PositionEvaluation.between[Square.A2][Square.F7],PositionEvaluation.between[Square.F8][Square.F1],PositionEvaluation.between[Square.A8][Square.H8]]}testPinned(a){a=new PositionEvaluation(a);return[a.pinned[0],a.pinned[1],a.discoCandidates[0]]}testPawns(a){let b=new PositionEvaluation(a);b.evalPawns();let c=Boards.OUTPOSTAREAS[0].copy().AND_NOT(b.outPosts[0].copy().OR(b.bitPos.bitboards[Pieces.PAWN]));
5316c.AND(b.attackedBy[0][Pieces.PAWN]).AND_NOT(b.attackedBy[1][Pieces.PAWN]);switch(a.numPly){default:case 0:return[b.outPosts[0]];case 1:return[c];case 2:return[b.attackedBy[0][Pieces.PAWN]];case 3:return[b.attackedBy[1][Pieces.PAWN]];case 4:return[Boards.OUTPOSTAREAS[0]]}}testKnights(a){new PositionEvaluation(a);a=a.Vj();let b=this.bitPos.getKnights(a),c=[];for(;!b.empty();){var d=b.popLSB();squareBB(d).copy().AND(this.pinned[a]).empty()?(d=PositionEvaluation.allKnightAttacks[d].copy(),c.push(d.copy().AND(this.mobilityArea[a]))):
5317c.push(zeroBB())}return c}testKings(){return[]}testRooks(){this.evalSliders(0,Pieces.ROOK);return[]}getPinned(){return this.pinned[0].copy().OR(this.pinned[1])}getAllPieces(){return this.bitPos.bitboards[Constants.ALL_WHITE].copy().OR(this.bitPos.bitboards[Constants.ALL_BLACK])}getPawns(a){return this.bitPos.getPawns(a)}getAllPawns(){return this.bitPos.bitboards[Pieces.PAWN].copy()}getAllQueens(){return this.bitPos.bitboards[Pieces.QUEEN].copy()}getAllRooks(){return this.bitPos.bitboards[Pieces.ROOK].copy()}getAllBishops(){return this.bitPos.bitboards[Pieces.BISHOP].copy()}getRooks(a){return this.bitPos.getRooks(a)}getKnights(a){return this.bitPos.getKnights(a)}getBishops(a){return this.bitPos.getBishops(a)}getQueens(a){return this.bitPos.getQueens(a)}getKing(a){return this.bitPos.getKing(a)}getPieces(a){return this.bitPos.getPieces(a)}getNonPawns(a){return this.getPieces(a).AND_NOT(this.getPawns(a))}getOccupied(){return this.bitPos.getOccupied()}getAttackedByPiece(a,
5318b){return this.attackedBy[a][b]}getAttackedBy(a){return this.attackedByAll[a]}pawnSpace(a){let b=this.getPawns(a);a?(b.OR(b.copy().SHLEFT()),b.OR(b.copy().SHLEFT()),b.OR(b.copy().SHLEFT())):(b.OR(b.copy().SHRIGHT()),b.OR(b.copy().SHRIGHT()),b.OR(b.copy().SHRIGHT()));return b}pieceMaterial(){let a=this.pos.board,b=0;for(let c=0;64>c;c++){let d=Piece.nominal(a[c]);d&&d!=Piece.PAWN&&d!=Piece.KING&&(b+=Att.pieceVal(d))}return b}initStatics(){if(!(0<PositionEvaluation.bbSquare.length)){for(var a=0;64>
5319a;a++)PositionEvaluation.bbSquare.push(squareBB(a));a=[Square.MD_BACK+Square.MD_BL,Square.MD_BACK+Square.MD_BR,Square.MD_FORWARD+Square.MD_FL,Square.MD_FORWARD+Square.MD_FR,Square.MD_RIGHT+Square.MD_FR,Square.MD_RIGHT+Square.MD_BR,Square.MD_LEFT+Square.MD_FL,Square.MD_LEFT+Square.MD_BL];for(var b=0;8>b;b++)for(var c=0;8>c;c++){var d=(b<<3)+c,e=PositionEvaluation.bbSquare[d].copy().XOR(fileBB(b).OR(rankBB(c)));PositionEvaluation.allRookAttacks[d]=e;e=zeroBB();var f=d+Square.MD_BL;for(var g=Math.min(c,
5320b);0<g;g--)e.OR(PositionEvaluation.bbSquare[f]),f+=Square.MD_BL;f=d+Square.MD_FL;for(g=Math.min(7-c,b);0<g;g--)e.OR(PositionEvaluation.bbSquare[f]),f+=Square.MD_FL;f=d+Square.MD_FR;for(g=Math.min(7-c,7-b);0<g;g--)e.OR(PositionEvaluation.bbSquare[f]),f+=Square.MD_FR;f=d+Square.MD_BR;for(g=Math.min(c,7-b);0<g;g--)e.OR(PositionEvaluation.bbSquare[f]),f+=Square.MD_BR;PositionEvaluation.allBishopAttacks[d]=e;e=zeroBB();for(f=0;8>f;++f)g=d+a[f],g<Square.A1||g>Square.H8||2<Math.abs(Square.rankDiff(g,d))||
5321Math.abs(2<Square.fileDiff(g,d))||e.OR(PositionEvaluation.bbSquare[g]);PositionEvaluation.allKnightAttacks[d]=e}for(a=0;8>a;a++)for(b=0;8>b;b++)c=(a<<3)+b,d=zeroBB(),0<a&&d.OR(squareBB(a-1<<3|b)),7>a&&d.OR(squareBB(a+1<<3|b)),PositionEvaluation.allPawnAttacks[0][c]=7>b?d.makeN():zeroBB(),PositionEvaluation.allPawnAttacks[1][c]=0<b?d.makeS():zeroBB();for(a=0;8>a;a++)for(b=0;8>b;b++)c=(a<<3)+b,d=PositionEvaluation.allPawnAttacks[0][c].copy().OR(PositionEvaluation.allPawnAttacks[1][c]),a>Square.FILE_A&&
5322d.OR(squareBB((a-1<<3)+b)),a<Square.FILE_H&&d.OR(squareBB((a+1<<3)+b)),b>Square.RANK_1&&d.OR(squareBB((a<<3)+(b-1))),b<Square.RANK_7&&d.OR(squareBB((a<<3)+(b+1))),PositionEvaluation.allKingAttacks[c]=d.copy(),PositionEvaluation.kingZone[c]=d.copy().OR(squareBB(c)),PositionEvaluation.kingRing[0][c]=d.copy().OR(d.makeN()),PositionEvaluation.kingRing[1][c]=d.copy().OR(d.makeS());this.initBetweens()}}initBetweens(){if(!PositionEvaluation.between.length){for(var a=0;64>a;a++){PositionEvaluation.between[a]=
5323[];PositionEvaluation.lines[a]=[];PositionEvaluation.kingDistance[a]=[];for(var b=0;b<a;b++)PositionEvaluation.between[a][b]=PositionEvaluation.between[b][a],PositionEvaluation.lines[a][b]=PositionEvaluation.lines[b][a],PositionEvaluation.kingDistance[a][b]=PositionEvaluation.kingDistance[b][a];for(b=a;64>b;b++){if(a!=b){var c=void 0,d=PositionEvaluation.bbSquare[a],e=PositionEvaluation.bbSquare[b];if(PositionEvaluation.allRookAttacks[a].isSet(b)){c=a>>3;var f=b>>3;let g=a&7,h=b&7;c=this.slidingAttack(d,
5324e,g==h?0:g>h?-1:1,c==f?0:c>f?-1:1)}else PositionEvaluation.allBishopAttacks[a].isSet(b)&&(c=this.slidingAttack(d,e,0<(b&7)-(a&7)?1:-1,0<(b>>3)-(a>>3)?1:-1));c&&(PositionEvaluation.lines[a][b]=c.copy(),c.AND_NOT(d),c.AND_NOT(e),PositionEvaluation.between[a][b]=c)}PositionEvaluation.kingDistance[a][b]=Math.max(Math.abs(Square.rankDiff(a,b)),Math.abs(Square.fileDiff(a,b)))}}PositionEvaluation.kingPathNextStep=[];for(a=0;64>a;a++)for(PositionEvaluation.kingPathNextStep[a]=[],b=0;64>b;b++)if(PositionEvaluation.kingPathNextStep[a].push(zeroBB()),
5325d=PositionEvaluation.kingDistance[a][b],!(1>=d))for(e=PositionEvaluation.allKingAttacks[a].copy();e.notEmpty();)c=e.popLSB(),f=squareBB(c),d>PositionEvaluation.kingDistance[c][b]&&PositionEvaluation.kingPathNextStep[a][b].OR(f)}}buildAttacks(a){this.attackedBy=[];this.attackedByAll=[];this.attackedByAny=[];this.attackedByTwo=[];this.attackedByPiece=[];for(var b=0;2>b;b++){this.attackedBy[b]=[];this.attackedByPiece[b]=[];for(var c=0;6>c;c++)this.attackedBy[b].push(new BitBoard(0,0)),this.attackedByPiece[b].push(new BitBoard(0,
53260));this.attackedByAll[b]=new BitBoard(0,0)}b=a.board;c=new Att;for(let d=0;64>d;d++)if(b[d]){let e=0!=(b[d]&Piece.COLOUR),f=Piece.nominal(b[d]),g=c.getCoveredSqs(f,a,d);this.addToAttackedBy(g,f,e)}for(a=0;a<Constants.NUM_PIECES;a++)this.attackedByAll[Constants.WHITE].OR(this.attackedBy[Constants.WHITE][a]),this.attackedByAll[Constants.BLACK].OR(this.attackedBy[Constants.BLACK][a]);this.pawnDoubleAtt=[];for(a=0;2>a;a++)this.pawnDoubleAtt[a]=this.makePawnDoubleAtt(this.getPawns(a),a);this.cntBlockedPawns=
5327[];this.blockedPawns=[];this.blockedPawns[0]=this.getPawns(0).SHLEFT().AND(this.getPawns(1));this.blockedPawns[1]=this.getPawns(1).SHRIGHT().AND(this.getPawns(0));this.cntBlockedPawns[0]=this.getPawns(0).SHLEFT().AND(this.getPawns(1).OR(this.pawnDoubleAtt[1])).popcnt();this.cntBlockedPawns[1]=this.getPawns(1).SHRIGHT().AND(this.getPawns(0).OR(this.pawnDoubleAtt[0])).popcnt();this.kingRing=[PositionEvaluation.kingRing[0][this.bitPos.kingPos(0)],PositionEvaluation.kingRing[1][this.bitPos.kingPos(1)]];
5328this.attackedByAny[0]=this.attackedBy[0][Pieces.PAWN].copy().OR(this.attackedBy[0][Pieces.KING]);this.attackedByAny[1]=this.attackedBy[1][Pieces.PAWN].copy().OR(this.attackedBy[1][Pieces.KING]);this.attackedByTwo[0]=this.attackedBy[0][Pieces.PAWN].copy().AND(this.attackedBy[0][Pieces.KING]);this.attackedByTwo[1]=this.attackedBy[1][Pieces.PAWN].copy().AND(this.attackedBy[1][Pieces.KING]);for(a=0;2>a;a++)this.attackedByPiece[a][Pieces.KING]=this.attackedBy[a][Pieces.KING].copy(),this.attackedByPiece[a][Pieces.PAWN]=
5329this.attackedBy[a][Pieces.PAWN].copy()}addToAttackedBy(a,b,c){a.forEach(function(d){this.attackedBy[c?1:0][BitPos.toBitPiece(b)].setBit(d)}.bind(this))}makePawnDoubleAtt(a,b){return b==Constants.WHITE?a.makeNW().AND(a.makeNE()):a.makeSW().AND(a.makeSE())}makePawnAtt(a,b){return b==Constants.WHITE?a.makeNW().OR(a.makeNE()):a.makeSW().OR(a.makeSE())}getSliderStops(a,b,c){let d={blockers:zeroBB(),pinners:zeroBB()},e=PositionEvaluation.allRookAttacks[b].copy().AND(this.getRooks(c)).OR(PositionEvaluation.allBishopAttacks[b].copy().AND(this.getBishops(c)));
5330e.AND(a);for(a=this.getAllPieces().XOR(e);e.notEmpty();){let f=e.popLSB(),g=PositionEvaluation.between[b][f].copy().AND(a);1==g.popcnt()&&(d.blockers.OR(g),g.copy().AND(this.getPieces(1-c)).notEmpty()&&d.pinners.setBit(f))}return d}add(a,b){return"number"===typeof b?[a[0]+b,a[1]+b]:[a[0]+b[0],a[1]+b[1]]}sub(a,b){return"number"===typeof b?[a[0]-b,a[1]-b]:[a[0]-b[0],a[1]-b[1]]}mult(a,b){return[a[0]*b,a[1]*b]}maxEv(a,b){return[Math.max(a[0],b[0]),Math.max(a[1],b[1])]}initScores(){this.pstPawn=[[0,0],
5331[-1,0],[-4,2],[-4,5],[-4,5],[-2,3],[6,3],[0,0],[0,0],[2,2],[-1,2],[-2,4],[-1,3],[5,2],[3,2],[0,0],[0,0],[1,3],[-2,1],[4,1],[2,2],[5,1],[-5,1],[0,0],[0,0],[-5,4],[0,0],[8,0],[4,0],[-9,0],[-12,0],[0,0],[0,0],[-5,4],[0,0],[8,0],[4,0],[-9,0],[-12,0],[0,0],[0,0],[1,3],[-2,1],[4,1],[2,2],[5,1],[-5,1],[0,0],[0,0],[2,2],[-1,2],[-2,4],[-1,3],[5,2],[3,2],[0,0],[0,0],[-1,0],[-4,2],[-4,5],[-4,5],[-2,3],[6,3],[0,0]];this.pstKnight=[[-35,-26],[-16,-16],[-7,-8],[6,-12],[6,-11],[4,-20],[-14,-19],[-54,-19],[-19,-28],
5332[0,-14],[9,-6],[20,-11],[20,-8],[13,-15],[-8,-18],[-22,-26],[-11,-11],[10,-2],[21,6],[34,4],[32,5],[30,0],[7,-4],[-10,-12],[-3,1],[18,11],[29,16],[40,11],[38,13],[38,8],[11,6],[6,-1],[-3,1],[18,11],[29,16],[40,11],[38,13],[38,8],[11,6],[6,-1],[-11,-11],[10,-2],[21,6],[34,4],[32,5],[30,0],[7,-4],[-10,-12],[-19,-28],[0,-14],[9,-6],[20,-11],[20,-8],[13,-15],[-8,-18],[-22,-26],[-35,-26],[-16,-16],[-7,-8],[6,-12],[6,-11],[4,-20],[-14,-19],[-54,-19]];this.pstBishop=[[-15,-18],[-9,-13],[-6,-10],[-7,-9],
5333[-7,-8],[-8,-7],[-13,-9],[-23,-12],[-6,-12],[7,-7],[5,-4],[5,-4],[5,-3],[2,-1],[1,-5],[-13,-9],[-9,-14],[1,-6],[5,-3],[4,-3],[3,-4],[3,-3],[-1,-5],[-13,-10],[-12,-6],[-2,1],[2,3],[5,3],[3,4],[1,4],[-2,0],[-13,-5],[-12,-6],[-2,1],[2,3],[5,3],[3,4],[1,4],[-2,0],[-13,-5],[-9,-14],[1,-6],[5,-3],[4,-3],[3,-4],[3,-3],[-1,-5],[-13,-10],[-6,-12],[7,-7],[5,-4],[5,-4],[5,-3],[2,-1],[1,-5],[-13,-9],[-15,-18],[-9,-13],[-6,-10],[-7,-9],[-7,-8],[-8,-7],[-13,-9],[-23,-12]];this.pstRook=[[-17,-2],[-14,-4],[-15,-3],
5334[-13,-5],[-1,-3],[-1,-2],[2,-4],[-14,-1],[-14,-7],[-11,-9],[-11,-7],[-8,-8],[4,-4],[4,-4],[7,-5],[-11,-3],[-13,-9],[-11,-9],[-11,-8],[-9,-8],[3,-3],[6,-4],[12,-8],[-10,-3],[-13,-8],[-9,-9],[-10,-8],[-9,-7],[1,-3],[7,-4],[18,-9],[-12,-5],[-13,-8],[-9,-9],[-10,-8],[-9,-7],[1,-3],[7,-4],[18,-9],[-12,-5],[-13,-9],[-11,-9],[-11,-8],[-9,-8],[3,-3],[6,-4],[12,-8],[-10,-3],[-14,-7],[-11,-9],[-11,-7],[-8,-8],[4,-4],[4,-4],[7,-5],[-11,-3],[-17,-2],[-14,-4],[-15,-3],[-13,-5],[-1,-3],[-1,-2],[2,-4],[-14,-1]];
5335this.pstQueen=[[-11,-12],[-5,-8],[-4,-5],[-2,-1],[-1,-5],[1,-9],[2,-13],[-8,-20],[-6,-8],[-2,-1],[1,3],[2,8],[4,7],[4,-1],[4,1],[-4,-8],[-5,-7],[0,2],[3,14],[4,17],[6,14],[5,8],[9,1],[0,-8],[-3,-6],[3,7],[4,17],[7,22],[10,16],[5,11],[11,4],[3,-7],[-3,-6],[3,7],[4,17],[7,22],[10,16],[5,11],[11,4],[3,-7],[-5,-7],[0,2],[3,14],[4,17],[6,14],[5,8],[9,1],[0,-8],[-6,-8],[-2,-1],[1,3],[2,8],[4,7],[4,-1],[4,1],[-4,-8],[-11,-12],[-5,-8],[-4,-5],[-2,-1],[-1,-5],[1,-9],[2,-13],[-8,-20]];this.pstKing=[[90,-18],
5336[88,7],[66,35],[64,45],[77,42],[66,38],[42,31],[32,19],[101,0],[97,26],[82,50],[87,56],[107,54],[101,49],[74,42],[58,31],[83,23],[90,42],[88,57],[99,63],[111,62],[108,56],[79,51],[57,40],[73,31],[84,48],[93,59],[106,63],[118,62],[97,61],[81,51],[46,48],[73,31],[84,48],[93,59],[106,63],[118,62],[97,61],[81,51],[46,48],[83,23],[90,42],[88,57],[99,63],[111,62],[108,56],[79,51],[57,40],[101,0],[97,26],[82,50],[87,56],[107,54],[101,49],[74,42],[58,31],[90,-18],[88,7],[66,35],[64,45],[77,42],[66,38],[42,
533731],[32,19]];this.sQueenKingDist=[[0,-12],[0,-17],[0,-7],[0,-12],[0,-8],[0,-12],[0,-18],[0,-20]];this.sWeakPawnAttack=[[4,17],[6,15],[5,19],[3,10]];this.sMobilityBonusKnight=[[-13,-8],[4,1],[18,6],[23,8],[28,9],[33,10],[36,11],[38,9],[38,7]];this.sMobilityBonusBishop=[[-15,-6],[-2,2],[11,7],[17,14],[25,17],[31,24],[36,27],[40,28],[41,30],[42,30],[44,31],[46,28],[49,30],[53,23]];
5337this.sMobilityBonusRook=[[-48,-39],[-36,-20],[-21,-18],[-16,-6],[-11,4],[-7,10],[-3,20],[1,29],[5,35],[8,41],[11,42],[12,
533844],[13,46],[16,43],[17,40]];this.sMobilityBonusQueen=[[-28,-9],[-19,-16],[-4,-18],[0,-18],[4,-12],[7,-5],[9,3],[12,10],[13,10],[14,11],[14,12],[14,13],[14,14],[15,13],[15,14],[15,16],[15,16],[16,15],[17,15],[16,16],[15,16],[15,15],[10,19],[13,17],[11,17],[8,20],[11,16],[16,15]];this.sKingAttacks=[[0,1],[0,3],[0,0],[0,8],[0,11],[0,9],[0,18],[0,20],[0,14]];this.sBishopPawnColor=[[-1,11],[5,6],[6,17],[9,17],[8,16],[15,16],[14,17],[17,19]];this.sCastlingBonus=[[0,0],[70,49],[76,42],[76,73]];this.sPPRankBonus=
5339[[21,0],[56,4],[83,16],[177,37],[22,1],[60,4],[91,21],[182,42]];this.sPPFileBonus=[[6,6],[1,1],[-2,-2],[-7,-7],[-7,-7],[-2,-2],[1,1],[6,6]];this.sConnectedPPBonus=[[9,1],[17,8],[-10,11]];this.sPPOwnKingDistance=[[0,16],[0,8],[0,8],[0,15],[0,25],[0,34],[0,44],[0,53],[0,40],[0,0],[0,10],[0,24],[0,43],[0,61],[0,78],[0,101],[0,91],[0,28],[0,35],[0,54],[0,91],[0,123],[0,156],[0,183],[0,187],[0,27],[0,40],[0,54],[0,83],[0,124],[0,156],[0,186]];this.sPPOpponentKingDistance=[[0,-15],[0,16],[0,21],[0,31],
5340[0,36],[0,44],[0,54],[0,64],[0,-21],[0,26],[0,50],[0,74],[0,102],[0,127],[0,154],[0,176],[0,-45],[0,31],[0,73],[0,126],[0,174],[0,223],[0,281],[0,328],[0,-72],[0,26],[0,120],[0,206],[0,278],[0,350],[0,443],[0,528]];this.sPPBlock=[[1,1],[14,14],[19,19],[7,7],[21,21],[29,29],[9,9],[17,17],[21,21],[1,1],[28,28],[46,46],[12,12],[46,46],[59,59],[11,11],[48,48],[67,67],[14,14],[77,77],[116,116],[44,44],[91,91],[153,153],[44,44],[116,116],[166,166],[8,8],[147,147],[173,173],[68,68],[189,189],[250,250],[56,
534156],[164,164],[259,259]];this.sDoubledPawn=[[11,16],[10,26],[10,32],[8,36],[8,36],[10,32],[10,26],[11,16]];this.sIsolatedPawn=[[17,26],[18,29],[20,25],[22,26],[22,26],[20,25],[18,29],[17,26],[9,11],[11,13],[15,4],[15,5],[15,5],[15,4],[11,13],[9,11]];this.sConnectedPawn=[[0,0],[3,3],[4,4],[10,10],[11,11],[64,64],[1,1],[3,3],[6,6],[13,13],[13,13],[53,53],[4,4],[6,6],[5,5],[14,14],[25,25],[56,56],[-1,-1],[6,6],[6,6],[16,16],[31,31],[81,81],[-1,-1],[6,6],[6,6],[16,16],[31,31],[81,81],[4,4],[6,6],[5,5],
5342[14,14],[25,25],[56,56],[1,1],[3,3],[6,6],[13,13],[13,13],[53,53],[0,0],[3,3],[4,4],[10,10],[11,11],[64,64]];this.sPawnLever=[[0,0],[1,14],[0,-1],[1,-11],[12,1],[30,-2],[0,0],[0,0]];this.sBackwardPawn=[[18,19],[18,18],[17,20],[17,23],[17,23],[17,20],[18,18],[18,19],[15,19],[15,26],[15,20],[21,22],[21,22],[15,20],[15,26],[15,19],[11,3],[10,-5],[10,-5],[13,-5],[13,-5],[10,-5],[10,-5],[11,3],[10,5],[11,4],[12,-3],[14,-4],[14,-4],[12,-3],[11,4],[10,5]];this.sCandidatePawn=[[0,-10],[0,-10],[2,-9],[3,-3],
5343[-6,9]];this.sLoneRookMalus=[[0,-49],[0,35],[0,9],[0,-14],[0,-22],[0,0],[0,0],[0,0]];this.sBishopPair=[[60,27],[35,60],[34,39],[31,22]];this.matVal=[[80,100],[310,265],[335,290],[530,475],[1010,930]];this.sCheckAttack=[30,30];this.vKingsafetyFactor=[16,13,34,20,18,13,20,10,5,11];this.vKingAttackPower=[0,30,16,28,40];this.vUnsafeQueenContactCheck=[5,13,19,51,19];this.vQueenContactCheck=[94,148,242,288,104];this.vRookContactCheck=[-1,20,70,139,30];this.vEvasionBonus=[33,21,18,16,28,27,26,17];this.vQueenCheck=
5344[50,100,160,174,196,197,232,243];this.vRookCheck=[42,74,99,79];this.vBishopCheck=[9,14];this.vKnightCheck=[21,28,50,70];this.vCheckThreat=[3,1];this.vFrontmostPP=[0,9,23,36,37,30,-9,0,9,18,39,49,-23,-9,0,7,20,37,-36,-18,-7,0,11,35,-37,-39,-20,-11,0,20,-30,-49,-37,-35,-20,0];this.vAttackBadness=[23,25,27,27,32,30,29,28,29,26,26,26,26,25,23,26];this.sPPScaleDown=[-2,55,69,52,29,51,53,36,30,59,60,98,32,63,68,89];this.sDifferentBishops=[-26,-4,-26,42,-31,-23,-19,-15,-34,-18,-18,-33,-31,-14,-10,-9];this.sFeatureWeight=
5345[55,42,40,50,62,85,64,1];this.vOutpostBonus=[7,8,12,18,5,8,5,3,11,15,13,6,8,17,6,0,16,22,12,18,12,15,9,1,16,22,12,18,12,15,9,1,11,15,13,6,8,17,6,0,7,8,12,18,5,8,5,3];this.vOutpostFactor=[4,15,21,24,9,15,22,88,41,27,32,38,22,25,28,28,3,21,27,59,16,19,18,16,32,24,29,16,19,21,23,15];this.sPawnThreat=[6,3];this.cpxMatInhomogen=[5,5];this.cpxArea=[6,3];this.cpxWeakPawns=[6,3];this.cpxPassed=[5,8];this.cpxConnected=[10,10];this.cpxCandidates=[1,1];this.cpxPawnPush=[1,1];this.cpxCenterPush=[6,1];this.cpxTension=
5346[6,6];this.cpxPawnKingRing=[8,1];this.cpxHanging=[10,6];this.cpxAsym=[3,4];this.cpxBadness=[3,3];this.cpxControl=[2,1];this.cpxPotential=[5,5];this.cpxWeakBack=[25,10];this.cpxPawnAttacks=[8,4];this.cpxAttack=[5,7];this.cpxTwice=[5,7];this.cpxUndef=[4,3];this.cpxPins=[8,5];this.cpxQueenPin=[6,4];this.cpxSafety=[2.1,1];this.cpxSafetyCanCastle=[1.5,1];this.cpxShelter=[2,2];this.cpxStorm=[2,1]}calcMaterial(){var a=[[0,0],[0,0]];this.pieces=[[],[]];this.totPieces=[0,0];for(var b=0;2>b;b++)for(var c=0;2>
5347c;c++)for(var d=Pieces.PAWN;d<Pieces.KING;d++){var e=BitPos.toCBPiece(d)+(b?8:0);e=this.pos.countPieces(e);a[b][c]+=e*this.matVal[d][c];c||(this.pieces[b][d]=e,this.totPieces[b]+=e)}this.material=a;this.matScore=[a[0][0]-a[1][0],a[0][1]-a[1][1]];this.attackPotential=[];this.supporters=[];a=0;for(b=0;2>b;b++)c=this.pos.countPieces(Piece.KNIGHT|8*b),d=this.pos.countPieces(Piece.BISHOP|8*b),e=this.pos.countPieces(Piece.ROOK|8*b),this.attackPotential[b]=15*this.pos.countPieces(Piece.QUEEN|8*b)+3*c+2*
5348d+5*e,this.supporters[b]=c+d+e,a+=this.attackPotential[b];this.phaseScale=Math.min(64,(this.material[0][0]+this.material[1][0])/72);30==a&&0==this.supporters[0]+this.supporters[1]&&(a=24);this.phaseScaleKingSafety=13>a?0:Math.min(64,a);a=this.supporters[0];b=this.supporters[1];1==this.pos.countPieces(Piece.QUEEN)&&!this.pos.countPieces(Piece.B_QUEEN)&&!a&&2<b&&this.sub(this.matScore,[0,20]);1==this.pos.countPieces(Piece.B_QUEEN)&&!this.pos.countPieces(Piece.W_QUEEN)&&!b&&2<a&&this.sub(this.matScore,
5349[0,20]);this.pos.countPieces(Piece.PAWN)||1!=this.pos.countPieces(Piece.ROOK)||!this.pos.countPieces(Piece.B_PAWN)||this.pos.countPieces(Piece.KNIGHT)||this.pos.countPieces(Piece.BISHOP)||this.pos.countPieces(Piece.BISHOP)||(this.matScore=this.sub(this.matScore,this.sLoneRookMalus[this.pos.countPieces(Piece.B_PAWN)-1]));this.pos.countPieces(Piece.B_PAWN)||1!=this.pos.countPieces(Piece.B_ROOK)||!this.pos.countPieces(Piece.PAWN)||this.pos.countPieces(Piece.B_KNIGHT)||this.pos.countPieces(Piece.B_BISHOP)||
5350this.pos.countPieces(Piece.B_BISHOP)||(this.matScore=this.sub(this.matScore,this.sLoneRookMalus[this.pos.countPieces(Piece.W_PAWN)-1]));a=this.pos.countPieces(Piece.PAWN);b=this.pos.countPieces(Piece.B_PAWN);c=a+b;d=Math.max(0,c-1)>>2;this.bishopPair=[!1,!1];2==this.pos.countPieces(Piece.BISHOP)&&(this.matScore=this.add(this.matScore,this.sBishopPair[d]),this.bishopPair[0]=!0);2==this.pos.countPieces(Piece.B_BISHOP)&&(this.matScore=this.add(this.matScore,this.sBishopPair[d]),this.bishopPair[0]=!0);
5351for(this.ppScaleDown=this.scOppColorBish=0;1==this.pos.countPieces(Piece.BISHOP)&&1==this.pos.countPieces(Piece.B_BISHOP)&&0!=c;){d=this.pos.countAllPieces(0)+this.pos.countAllPieces(1)-c-2-2;if(8<=d)break;c=4*[0,0,1,1,1,2,2,2,3,3,3,3,3,3,3,3,3][c]+(d>>1);this.ppScaleDown=this.sPPScaleDown[c];if(a==b)break;this.scOppColorBish=this.matVal[0][1]*(a-b);this.scOppColorBish=this.scaleDiffBishops(this.sDifferentBishops[c],this.scOppColorBish);a=Boards.LIGHT_SQUARES.copy().AND(this.getBishops(0)).notEmpty();
5352b=Boards.LIGHT_SQUARES.copy().AND(this.getBishops(1)).notEmpty();if(this.oppBishops=a!=b)this.matScore=this.add(this.matScore,this.scOppColorBish);break}this.matInhomogen=0;a=this.pos.countPieces(Piece.KNIGHT);b=this.pos.countPieces(Piece.KNIGHT|8);c=this.pos.countPieces(Piece.BISHOP);d=this.pos.countPieces(Piece.BISHOP|8);e=this.pos.countPieces(Piece.ROOK);let f=this.pos.countPieces(Piece.ROOK|8),g=this.pos.countPieces(Piece.QUEEN),h=this.pos.countPieces(Piece.QUEEN|8),k=this.pos.countPieces(Piece.PAWN),
5353l=this.pos.countPieces(Piece.PAWN|8);this.matInhomogen=Math.abs(a+c-b-d)*Math.sqrt(this.matVal[Pieces.BISHOP][0])*.3;this.matInhomogen+=Math.abs(e-f)*Math.sqrt(this.matVal[Pieces.ROOK][0])*.3;this.matInhomogen+=Math.abs(g-h)*Math.sqrt(this.matVal[Pieces.QUEEN][0])*.3;a+c==b+d&&(this.matInhomogen+=Math.abs(a-b));this.matInhomogen+=Math.abs(k-l)}initKing(){this.sqKing=[this.bitPos.getPiecesOfSide(Pieces.KING,0).LSB(),this.bitPos.getPiecesOfSide(Pieces.KING,1).LSB()];this.psKing=[];this.pawnShelter=
5354[];this.pawnStormDanger=[];this.numKingAttackers=[];this.closeKingAttackers=[0,0];this.kingAttackPower=[0,0];if(this.isLegal()){let a=PositionEvaluation.kingRing[0][this.sqKing[0]].copy();this.numKingAttackers[1]=a.AND(this.attackedBy[1][Pieces.PAWN]).popcnt();this.numKingAttackers[1]+=a.AND(this.attackedBy[1][Pieces.KING]).popcnt();a=PositionEvaluation.kingRing[1][this.sqKing[1]].copy();this.numKingAttackers[0]=a.AND(this.attackedBy[0][Pieces.PAWN]).popcnt();this.numKingAttackers[0]+=a.AND(this.attackedBy[0][Pieces.KING]).popcnt()}else PositionEvaluation.initCalled=
5355!1}isLegal(){return 64>this.sqKing[0]&&64>this.sqKing[1]}initPawns(){this.minorBlocksPawnMask=[];this.minorBlocksPawnMask[0]=Boards.RANK2.copy().OR(Boards.RANK3).OR(Boards.RANK4).AND_NOT(this.attackedBy[1][Pieces.PAWN]);this.minorBlocksPawnMask[0].AND(this.getPawns(1).makeS());this.minorBlocksPawnMask[1]=Boards.RANK7.copy().OR(Boards.RANK6).OR(Boards.RANK5).AND_NOT(this.attackedBy[0][Pieces.PAWN]);this.minorBlocksPawnMask[1].AND(this.getPawns(0).makeN());var a=allSetBB(),b=zeroBB();for(var c=0;8>
5356c;c++)a.XOR(rankBB(c)),PositionEvaluation.ranksInFront[0][c]=a.copy(),PositionEvaluation.ranksInFront[1][c]=b.copy(),b.XOR(rankBB(c));PositionEvaluation.adjacentFiles[0]=fileBB(0).OR(fileBB(1));PositionEvaluation.adjacentFiles[7]=fileBB(6).OR(fileBB(7));PositionEvaluation.neighbourFiles[0]=fileBB(1);PositionEvaluation.neighbourFiles[7]=fileBB(6);for(a=1;6>=a;a++)PositionEvaluation.adjacentFiles[a]=fileBB(a-1).OR(fileBB(a)).OR(fileBB(a+1)),PositionEvaluation.neighbourFiles[a]=fileBB(a-1).OR(fileBB(a+
53571));for(a=0;2>a;a++)for(b=0;64>b;b++)PositionEvaluation.passedMask[a][b]=PositionEvaluation.ranksInFront[a][b&7].copy().AND(PositionEvaluation.adjacentFiles[b>>3]),PositionEvaluation.forward[a][b]=PositionEvaluation.ranksInFront[a][b&7].copy().AND(fileBB(b>>3));a=this.getPawns(0);b=this.getPawns(1);this.pawnAsym=0;for(c=0;8>c;c++)a.copy().AND(fileBB(c)).popcnt()!=b.copy().AND(fileBB(c)).popcnt()&&this.pawnAsym++;this.bishopPenalty=[[],[]];this.kingFileQuality=[];this.rookBonus=[[],[]]}initPinned(){this.pinned=
5358[zeroBB(),zeroBB()];if(this.isLegal()){this.discoCandidates=[zeroBB(),zeroBB()];for(let d=0;2>d;d++){let e=this.sqKing[d];var a=this.getRooks(1-d).OR(this.getQueens(1-d)),b=this.getBishops(1-d).OR(this.getQueens(1-d));a=PositionEvaluation.allRookAttacks[e].copy().AND(a);b=PositionEvaluation.allBishopAttacks[e].copy().AND(b);a.OR(b);for(b=this.getPieces(d);!a.empty();){var c=a.popLSB();c=PositionEvaluation.between[c][e].copy().AND(this.getOccupied());1<c.popcnt()||(c.copy().AND(b).notEmpty()?this.pinned[d].OR(c):
5359this.discoCandidates[d].OR(c))}}}}
5359initMobility(){let a=this.attackedBy[1][Pieces.PAWN].copy().OR(this.getPawns(0)).OR(this.getKing(0)),b=this.attackedBy[0][Pieces.PAWN].copy().OR(this.getPawns(1)).OR(this.getKing(1));this.mobilityArea=[a.NOT(),b.NOT()]}getAttacks(a,b,c,d){switch(a){default:case Pieces.KING:return PositionEvaluation.allKingAttacks[b];case Pieces.PAWN:return PositionEvaluation.allPawnAttacks[d][b];case Pieces.KNIGHT:return PositionEvaluation.allKnightAttacks[b];case Pieces.BISHOP:return this.bitPos.bishopAttack(squareBB(b),
5360c);case Pieces.ROOK:return this.bitPos.rookAttack(squareBB(b),c);case Pieces.QUEEN:return this.bitPos.rookAttack(squareBB(b),c).OR(this.bitPos.bishopAttack(squareBB(b),c))}}initAttackParams(){if(!PositionEvaluation.attackParams){var a=[58,77,74,10,120,122,122,98,37,40,16,-4,105,112,87,41,52,61,48,6,90,93,101,50,4,25,0,2,104,75,56,30],b=[0,0,9,6,5,3];PositionEvaluation.attackParams=[];for(let d=Pieces.KNIGHT;d<Pieces.KING;d++){PositionEvaluation.attackParams[d-Pieces.KNIGHT]=[];for(let e=0;16>e;e++){let f=
5361{scHanging:[0,0],scAttack:[0,0],hanging:0,badness:1};var c=d-1;let g=0!=(e&2),h=0!=(e&4);g&&(c+=4);h&&(c+=8);if(g||!h)f.scHanging=this.add(f.scHanging,[91,300,310,500,1E3,9E3][d]),f.hanging++,f.badness+=2;e&1?c+=16:f.badness++;c=a[c];e&8?(f.badness+=2,g&&(f.badness+=2),f.scAttack=this.mult([c,c],b[d]),f.scAttack=this.mult(f.scAttack,.25)):f.scAttack=c;PositionEvaluation.attackParams[d-Pieces.KNIGHT].push(f)}}}}relSq(a,b){return a^7*b}relRank(a,b){return this.relSq(a,b)&7}testShifts(a){return a?this.getPawns(0).makeSE():
5362this.getPawns(0).makeSW()}toColors(a,b,c){let d=[],e=99999,f=-9999;for(var g=0;64>g;g++){var h=a[this.relSq(g,b)][c];h<e&&(e=h);h>f&&(f=h)}for(g=0;64>g;g++)h=a[this.relSq(g,b)][c],d.push(PositionEvaluation.getPSTColor(h,e,f));return d}static getValColor(a,b,c,d,e){let f=1;if(d>e){f=-1;var g=d;d=e;e=g}if(c<=b)return"black";g=(e-d)/(c-b);4<g&&(g=4);a<b&&(a=b);a>c&&(a=c);a=Math.ceil((a-b)*g);return-1==f?e-a:a+d}static getPSTColor(a,b,c){return String.f("hsl( {0}, 90%, 60% )",PositionEvaluation.getValColor(a,
5363b,c,0))}static getGradient(a){return String.f("background-image: radial-gradient( hsl( {0}, 60%, 70% ), hsl( {0}, 60%, 50% ) )",a)}static debugSqs(a){return a.map(function(b){return CBSquare.toString(b)}).join()}}"use strict";
5364var CPUInfo=function(){var a=function(){this.m_nLogicalCores=this.m_nPhysicalCores=this.m_nPhysicalProcs=this.m_nNumaNode=0};a.prototype.V9=function(b){b.beginSizedWrite();b.Vu(this.m_nNumaNodes);b.Vu(this.m_nPhysicalProcs);b.Vu(this.m_nPhysicalCores);b.Vu(this.m_nLogicalCores);b.endSizedWrite();return!0};return a}(),PosTree=function(){var a=function(){};a.prototype.numBits=[1,6,6,5,5,5,3,1,1,6,6,5,5,5,3,1];a.prototype.theBits=[0,32,34,18,20,22,6,0,0,33,35,19,21,23,7,0];a.prototype.isUniqe=[0,255,
5365255,255,255,255,6,14,255,255,255,255,255,255,255,255,255,255,3,11,4,12,5,13,255,255,255,255,255,255,255,255,1,9,2,10,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255];a.prototype.HUFF_960=128;a.prototype.HUFF_CASTLE=64;a.prototype.HUFF_EP=32;a.prototype.posToHuff3=function(b,c,d){var e,f=0;c[f]=0;f++;c[f]=0;b.getBTM()&&(c[f]=128);var g=0;var h=1;for(e=2;64>g;g++){var k=b.board[g]&15;h+=this.numBits[k];if(8<h){c[f]|=this.theBits[k]>>h-
53668;if(++e>d)return 1;f++;c[f]=0;h-=8}c[f]|=this.theBits[k]<<8-h;if(8<=h){h=0;if(++e>d)return 1;f++;c[f]=0}}k=g=0;0<b.getCastleRights()&&(k|=this.HUFF_CASTLE,g+=4);0<b.getCPPEPFile()&&(k|=this.HUFF_EP,g+=3);if(0<g){if(8<h+g){if(++e>d)return 1;f++;c[f]=0}0<b.getCastleRights()?(c[f]|=b.getCastleRights()&15,0<b.getCPPEPFile()&&(c[f]|=(b.getCPPEPFile()-1&7)<<4)):0<b.getCPPEPFile()&&(c[f]|=b.getCPPEPFile()-1&7)}else 0==h&&--e;c[0]=e|k;for(b=0;b<=f;b++)c[b]&=255;return 0};a.prototype.huff3ToPos=function(b,
5367c,d){var e,f=0,g;b.ep=Position.NOEP;for(e=0;64>e;e++)b.board[e]=0;e=c[f]&(this.HUFF_960|this.HUFF_CASTLE|this.HUFF_EP);var h=c[f]&31;if(8<h&&h<d){0<(e&this.HUFF_CASTLE)?(b.setCastleRights(c[h-1]&15),b.ep=0<(e&this.HUFF_EP)?c[h-1]>>4&7:Position.NOEP):(b.setCastleRights(CastleRights.NONE),b.ep=0<(e&this.HUFF_EP)?c[h-1]&7:Position.NOEP);f++;0<(c[f]&128)?b.setBTM(!0):b.setBTM(!1);e=0;d=1;for(g=64;64>e&&d<h;e++){var k=0,l=0;do k<<=1,0<(c[f]&g)&&(k|=1),l++,g>>=1,0==g&&(g=128,f++,d++);while(255==this.isUniqe[k]&&
53686>l);
5368if(255==this.isUniqe[k])break;b.board[e]=this.isUniqe[k]}if(64>e)return b.initStartPos(),1}else return b.initStartPos(),1;return 0};return a}();"use strict";
5369var HashPosition=function(){var a=function(b){this.m_cPos=[];for(var c=0;24>c;c++)this.m_cPos.push(0);b&&(new PosTree).posToHuff3(b,this.m_cPos,this.m_cPos.length)};a.prototype.Len=function(){return this.m_cPos[0]&31};a.prototype.IsSet=function(){return 0!=this.m_cPos[0]};a.prototype.Clear=function(){for(var b=0;b<this.m_cPos.Length;b++)this.m_cPos[b]=0};a.prototype.GetBTM=function(){return 0!=(this.m_cPos[1]&128)};a.prototype.HashPosition=function(b,c){};a.prototype.V9=function(b){b.beginSizedWrite();
5370b.writeByteArray(this.m_cPos,this.m_cPos.length);b.endSizedWrite();return!0};a.prototype.V7=function(b){b.Vc();for(var c=0;c<this.m_cPos.length;c++)this.m_cPos[c]=b.readByte();b.Vm();return!1};a.prototype.getPosition=function(){var b=new PosTree,c=new Position;b.huff3ToPos(c,this.m_cPos,this.m_cPos.length);return c};a.prototype.FillPos=function(b){};a.prototype.SetPos=function(b){};a.prototype.Normalize=function(b){};a.prototype.UnNormalize=function(b){};a.prototype.IsStartPosition=function(){return!1};
5371a.prototype.IsFinalPosition=function(){return!1};a.prototype.GetStartPos=function(){return this.m_sStartPosition};return a}();"use strict";
5372var HashTableData=function(){var a=1,b=function(){this.m_nIdDiscoverer=0;this.pos=new HashPosition;this.move=[]};b.emptyFactory=function(){for(var c=new b,d=0;d<TBRAIN.HASH_LINE_CNT;d++)c.move.push(new HashMoveData);return c};b.prototype.V9=function(c){c.beginSizedWrite();this.pos.V9(c);c.writeUShort(TBRAIN.HASH_LINE_CNT);for(var d=0;d<TBRAIN.HASH_LINE_CNT;++d)this.m_aMove[d].V9(c);c.V15(this.m_nPopularity);c.writeUnsigned(this.m_nIdDiscoverer);c.writeInt(this.m_nFlags);c.writeUnsigned(TBrainMove.CALCTIME_REASONABLE_THRESH);
5373c.writeUnsigned(TBrainMove.CALCTIME_DISCOVERY);c.writeUnsigned(TBrainMove.CALCTIME_DONATION);c.writeUnsigned(TBrainMove.CALCTIME_DEEP);c.writeUnsigned(this.m_nGames);c.wndSizedWrite();return!0};b.prototype.V7=function(c){c.Vc();this.pos.V7(c);for(var d=c.Vx(),e=0;e<TBrainMove.prototype.HASH_LINE_CNT&&e<d;++e)null==this.move[e]&&(this.move[e]=new HashMoveData),this.move[e].V7(c);this.m_nPopularity=c.readUint64();this.m_nIdDiscoverer=c.Vw();this.m_nFlags=c.Vw();this.m_nReasonableThresh=c.Vw();this.m_nDiscoveryThresh=
5374c.Vw();this.m_nDonationThresh=c.Vw();this.m_nDeepAnalysisThresh=c.Vw();0==this.m_nDeepAnalysisThresh&&(this.m_nDeepAnalysisThresh=TBrainMove.prototype.CALCTIME_DEEP);this.m_nGames=c.Vx();c.Vm();return!0};b.prototype.clear=function(){for(var c=0;c<TBRAIN.HASH_LINE_CNT;++c)this.m_aMove[c].clear();this.pos.Clear();this.m_nGames=this.m_nPopularity=this.m_nFlags=this.m_nIdDiscoverer=0};b.generateLine=function(c,d,e,f){f=f||3;var g="",h=[];if(d&&d.m_aLine){h=this.convertToCBMoveLine(ObjUtil.clone(c),d.m_aLine);
5375c=new NotationGenerator(V5);d=e.game.getStartPos().getBTM();for(var k=0;k<h.length&&k<f;k++)if(h[k].from!=h[k].to){var l=c.getMoveNota(h[k]),m=c.getStrMoveNumInLine(k,e.getCurPos().getPlyNum(),d);g+=m+l;k<h.length-1&&(g+=" ")}}return{line:h,lineNota:g}};b.convertToCBMoveLine=function(c,d){for(var e=[],f=0;f<d.length;f++){var g=new Move(d[f]&63,d[f]>>6&63,d[f]>>12&7);c.isLegalMove(g)&&(c.preCalcCtx(g),c.makeMove(g),c.postCalcCtx(g,!0),e.push(g))}return e};b.prototype.Dump=function(){};b.prototype.Count=
5376function(){return TBRAIN.HASH_LINE_CNT};b.prototype.Empty=function(){return this.m_aMove[0].Empty()};b.prototype.FillPos=function(c){this.pos.FillPos(c)};b.prototype.GetHashPosition=function(){return this.pos};b.prototype.GetMove=function(c){CBDebug.assert(c<TBRAIN.HASH_LINE_CNT);return c<TBRAIN.HASH_LINE_CNT?this.m_aMove[c]:this.m_aMove[0]};b.prototype.SetMove=function(c,d){CBDebug.assert(d<TBRAIN.HASH_LINE_CNT);d<TBRAIN.HASH_LINE_CNT&&(this.m_aMove[d]=c)};b.prototype.GetNPopularity=function(){return this.m_nPopularity};
5377b.prototype.SetNPopularity=function(c){this.m_nPopularity=c};b.prototype.GetNGames=function(){return this.m_nGames};b.prototype.GetNIdDiscoverer=function(){return this.m_nIdDiscoverer};b.prototype.SetNIdDiscoverer=function(c){this.m_nIdDiscoverer=c};b.prototype.IsDiscovered=function(){return!!a};b.prototype.SetIsDiscovered=function(c){a=!0};b.prototype.GetNReasonableThresh=function(){return this.m_nReasonableThresh};b.prototype.GetNDiscoveryThresh=function(){return this.m_nDiscoveryThresh};
5377b.prototype.GetNDonationThresh=
5378function(){return this.m_nDonationThresh};b.prototype.GetNDeepAnalysisThresh=function(){return this.m_nDeepAnalysisThresh};return b}();"use strict";
5379var MachineInfo=function(){var a=function(){this.m_aCPUInfo=new CPUInfo;this.m_nFlags=this.m_nSpeed=0};a.prototype.read=function(b){};a.prototype.GetCPUInfo=function(){return this.m_aCPUInfo};a.prototype.IsValid=function(){return 0<this.m_nSpeed};a.prototype.GetNSpeed=function(){return this.m_nSpeed};a.prototype.SetNSpeed=function(b){this.m_nSpeed=b};a.prototype.HasHyperThreading=function(){return isFlag(1,this.m_nFlags)};a.prototype.V9=function(b){b.beginSizedWrite();this.m_aCPUInfo.V9(b);b.Vu(this.m_nSpeed);
5380b.Vu(this.m_nFlags);b.endSizedWrite();return!0};a.prototype.ReadFromDataBuffer=function(b){return!0};a.prototype.CreateMachineGuid=function(){var b=new CBGuid;b.CreateFromHardware();return b};return a}();"use strict";
5381var ClientMachineInfo=function(){var a=function(){};inherit(a,MachineInfo);a.prototype.read=function(b){this.strLastName=b.V12(100);this.strFirstName=b.V12(100);this.aNation=b.Vw();this.nElo=b.Vw()};a.prototype.Init=function(){this.m_nSpeed=0;this.s_bInited=!0};a.prototype.GetNSpeed=function(){this.s_bInited&&0!=this.m_nSpeed||(this.Init(),0==this.m_nSpeed&&(this.m_nSpeed=1E5));return this.m_nSpeed};return a}();"use strict";
5382var GamePerformanceStats=function(){var a=function(){};a.prototype.initEmpty=function(){this.strFirstName=this.strLastName="";this.m_nResultSum=this.m_nResultCount=this.m_nEloSum=this.m_nEloCount=this.nElo=this.aNation=0};a.prototype.read=function(b){this.strLastName=b.V12(100);this.strFirstName=b.V12(100);this.aNation=b.Vw();this.nElo=b.Vw()};a.prototype.plus=function(b,c){b=new a(b);b.m_nEloCount+=c.m_nEloCount;var d=b.m_nEloSum+c.m_nEloSum;4294957295<d?(b.m_nEloSum=d/2,b.m_nEloCount/=2):b.m_nEloSum=
5383d;d=b.m_nResultSum+c.m_nResultSum;c=b.m_nResultCount+c.m_nResultCount;4294957295<d||4294957295<c?(b.m_nResultSum=d/2,b.m_nResultCount=c/2):(b.m_nResultSum=d,b.m_nResultCount=c);return b};a.prototype.V9=function(b){b.WriteUnsigned(this.m_nEloSum);b.WriteUnsigned(this.m_nEloCount);b.WriteUnsigned(this.m_nResultSum);b.WriteUnsigned(this.m_nResultCount)};a.prototype.V7=function(b){this.m_nEloSum=b.Vw();this.m_nEloCount=b.Vw();this.m_nResultSum=b.Vw();this.m_nResultCount=b.Vw();return!0};a.prototype.getSortResult=
5384function(){return 0!=this.m_nResultCount?500*this.m_nResultSum/this.m_nResultCount:0};a.prototype.getSortEloAv=function(){return 0!=this.m_nEloCount?this.m_nEloSum/this.m_nEloCount:0};a.prototype.getFPercent=function(b){return 0!=this.m_nResultCount?b?100-50*this.m_nResultSum/this.m_nResultCount:50*this.m_nResultSum/this.m_nResultCount:0};a.prototype.getNGames=function(){return Math.max(this.m_nEloCount,this.m_nResultCount)};return a}();"use strict";
5385var HashMoveData=function(){var a=function(){this.m_aLine=[0]};a.prototype.read=function(b){};a.prototype.WriteToDataBuffer=function(b){return!0};a.prototype.V7=function(b){b.Vc();this.m_nConfidence=b.Vw();this.m_nEval=b.V1a();this.m_nDepth=b.readByte();this.m_nFlags=b.readByte();for(var c=b.Vx(),d=0;d<TBrainMove.prototype.HASH_LINE_LEN&&d<c;++d)this.m_aLine[d]=b.Vx();this.m_nEngineId=b.Vw();this.m_nUserId=b.Vw();this.m_nTimeStamp=b.Vx();this.m_nCalcDepth=b.Vx();this.m_bReasonableDepth=b.V1c();this.m_nRankingListWeight=
5386b.Vw();b.Vm();return!0};a.prototype.Empty=function(){return!0};a.prototype.MovesEqualTo=function(b){return!1};a.prototype.ToString=function(){for(var b=0;b<TBRAIN.HASH_LINE_LEN;++b);return"??"};a.prototype.SetTimeStamp=function(b){this.m_nTimeStamp=TBrainTimeStamp.DateToUShort(b)};a.prototype.GetTimeStamp=function(){return TBrainTimeStamp.UShortToDate(this.m_nTimeStamp)};a.prototype.Test=function(b,c){return!1};a.prototype.fillVariation=function(b,c){return!1};a.prototype.FillEvaluation=function(b,
5387c){return!0};a.prototype.SetMove=function(b,c){return!1};a.prototype.FillMove=function(b,c){return!1};a.prototype.IsMate=function(){return 29E3<Math.Abs(this.m_nEval)};a.prototype.GetNCalcDepthPercent=function(b){return 0!=this.GetNCalcDepth()?100*b/this.GetNCalcDepth()+.5:0};a.prototype.Count=function(){return TBRAIN.HASH_LINE_LEN};a.prototype.Clear=function(){};a.prototype.GetNEval=function(){return 0};a.prototype.setNEval=function(b){this.m_nEval=b;setFlag(this,TBRAIN.EVAL_MOVE_NO,!1)};a.prototype.GetNMoveNo=
5388function(){return 0};a.prototype.SetNMoveNo=function(b){this.m_nEval=b;setFlag(this,TBRAIN.EVAL_MOVE_NO,!0)};a.prototype.GetNDepth=function(){return this.m_nDepth};a.prototype.SetNDepth=function(b){this.m_nDepth=b};a.prototype.GetNConfidence=function(){return this.m_nConfidence};a.prototype.SetNConfidence=function(b){this.m_nConfidence=b};a.prototype.GetMove=function(b){return 0};a.prototype.SetMove=function(b,c){};a.prototype.IsEval=function(){return!isFlagObj(this,TBRAIN.EVAL_MOVE_NO)};a.prototype.IsMoveNo=
5389function(){return isFlagObj(this,TBRAIN.EVAL_MOVE_NO)};a.prototype.etNEngineId=function(){return this.m_nEngineId};a.prototype.SetNEngineId=function(b){this.m_nEngineId=b};a.prototype.GetNUserId=function(){return this.m_nUserId};a.prototype.SetNUserId=function(b){this.m_nUserId=b};a.prototype.UserIsLogin=function(){return isFlagObj(this,TBRAIN.USER_IS_LOGIN)};a.prototype.SetUserIsLogin=function(b){setFlag(this,TBRAIN.USER_IS_LOGIN,b)};a.prototype.SetNTimeStamp=function(b){this.m_nTimeStamp=b};a.prototype.GetNCalcDepth=
5390function(){return this.m_nCalcDepth};a.prototype.IsReasonableDepth=function(){return this.m_bReasonableDepth};a.prototype.SetIsReasonableDepth=function(b){this.m_bReasonableDepth=b};a.prototype.IsDisco=function(){return this.m_nCalcDepth>=TBrainMove.CALCTIME_DISCOVERY};a.prototype.IsDeep=function(){return this.m_nCalcDepth>=TBrainMove.CALCTIME_DEEP};a.prototype.GetRankingListWeight=function(){return this.m_nRankingListWeight};a.prototype.SetRankingListWeight=function(b){this.m_nRankingListWeight=
5391b};return a}();"use strict";
5392var HashTableRequest=function(){var a=function(){this.m_aMachineGuid=new CBGuid;this.m_nCpus=this.m_nSecs=this.m_nFlags=0;this.m_nVariations=1;this.m_nNodes=this.m_nMoveNo=this.m_nHashSize=0;this.m_fMachineFact=this.m_fEngineFact=1};a.prototype.GetFormFactor=function(){return 0};a.prototype.GetFCalcDepth=function(b){return 0};a.prototype.GetNCalcTime=function(){return TBServerBinder(GetFCalcDepth(uint(m_nSecs+1))*m_fEngineFact*m_fMachineFact)};a.prototype.GetNTodaysTimeStamp=function(){return TBrainTimeStamp.GetNTodaysTimeStamp()};
5393a.prototype.WriteToDataBuffer=function(b){b.BeginSizedWrite();m_aMachine.WriteToDataBuffer(b);b.WriteString(m_strEngine);b.WriteUnsigned(m_nFlags);pos.WriteToDataBuffer(b);m_aMove.WriteToDataBuffer(b);b.WriteUnsigned(m_nSecs);b.WriteUnsigned(m_nCpus);b.WriteUnsigned(m_nVariations);m_aMachineGuid.WriteToDataBuffer(b);b.WriteUnsigned(m_nHashSize);b.WriteData(m_cCheckSum,m_cCheckSum.Length);b.WriteInt(m_nMoveNo);b.WriteInt64(m_nNodes);b.EndSizedWrite();return!0};a.prototype.V7=function(b){b.BeginSizedRead();
5394m_aMachine.ReadFromDataBuffer(b);m_strEngine=b.ReadString();m_nFlags=b.ReadUnsigned();pos.ReadFromDataBuffer(b);m_aMove.ReadFromDataBuffer(b);m_nSecs=b.ReadUnsigned();m_nCpus=b.ReadUnsigned();16<m_nCpus&&(m_nCpus=16);m_nVariations=Math.Min(64,Math.Max(1,b.ReadUnsigned()));1>m_nVariations&&(m_nVariations=1);m_aMachineGuid.ReadFromDataBuffer(b);m_nHashSize=b.ReadUnsigned();m_nMoveNo=b.ReadInt();m_nNodes=b.ReadInt64();b.EndSizedRead();return!0};a.prototype.CreateGame=function(){return new CBGame};a.prototype.GetMachine=
5395function(){return m_aMachine};a.prototype.SetMachine=function(b){m_aMachine=b};a.prototype.GetStrEngine=function(){return m_strEngine};a.prototype.SetStrEngine=function(b){m_strEngine=b};a.prototype.GetMachineGuid=function(){return m_aMachineGuid};a.prototype.SetMachineGuid=function(b){m_aMachineGuid=b};a.prototype.SetNSecs=function(b){m_nSecs=b};a.prototype.GetNSecs=function(){return m_nSecs};a.prototype.GetPosition=function(){return pos};a.prototype.GetTaggedHashPos=function(){return new TaggedHashPos(pos,
5396GetNMoveNo())};a.prototype.FillPosition=function(b){pos.FillPos(b);b.SetMoveNo(GetNMoveNo())};a.prototype.SetPosition=function(b){pos=new HashPosition(b);m_nMoveNo=b.GetMoveNo()};a.prototype.GetMove=function(b){return TBServerBinderm_aMove.GetMove(b)};a.prototype.GetNEval=function(){return m_aMove.GetNEval()};a.prototype.GetNMoveNo=function(){return m_nMoveNo};a.prototype.SetNMoveNo=function(b){m_nMoveNo=b};a.prototype.GetNDepth=function(){return m_aMove.GetNDepth()};a.prototype.IsEval=function(){return m_aMove.IsEval()};
5397a.prototype.IsMoveNo=function(){return m_aMove.IsMoveNo()};a.prototype.GetNCpus=function(){return m_nCpus};a.prototype.SetNCpus=function(b){m_nCpus=TBServerBinderr};a.prototype.GetNVariation=function(){return m_nVariations};a.prototype.SetNVariations=function(b){m_nVariations=TBServerBinderr};a.prototype.SetEngineFact=function(b){m_fEngineFact=b};a.prototype.SetMachineFact=function(b){m_fMachineFact=b};a.prototype.SetSilent=function(b){SETFLAG(1,b)};a.prototype.IsSilent=function(){return ISFLAG(1)};
5398a.prototype.SetFirstRequest=function(b){SETFLAG(2,b)};a.prototype.IsFirstRequest=function(){return ISFLAG(2)};a.prototype.SetUCI=function(b){SETFLAG(65536,b)};a.prototype.IsUCI=function(){return ISFLAG(TBServerBinderHTR.HTR_UCI_ENGINE)};a.prototype.SetUnreliableData=function(b){SETFLAG(256,b)};a.prototype.IsUnreliableData=function(){return ISFLAG(TBServerBinderHTR.HTR_UNRELIABLE_DATA)};a.prototype.IsEvalNormed=function(){return ISFLAG(TBServerBinderHTR.HTR_EVAL_NORMED)};a.prototype.SetIsEvalNormed=
5399function(b){SETFLAG(TBServerBinderHTR.HTR_EVAL_NORMED,b)};a.prototype.GetCheckSum=function(b){};return a}();"use strict";var RequestBoard=function(){return function(a,b){this.aBoard=a;this.sMove=b}}();"use strict";
5400var TaggedHashPos=function(){var a=function(b,c,d){this.pos=new HashPosition(b);this.m_nMoveNo=c;this.m_nTicket=this.m_nConnectIdSolver=this.m_nConnectIdSubmissor=0;this.m_strTag=d};a.prototype.IsSet=function(){return this.pos.IsSet()};a.prototype.IsStartPosition=function(){return this.pos.IsStartPosition()};a.prototype.IsFinalPosition=function(){return this.pos.IsFinalPosition()};a.prototype.GetStrTag=function(){return this.m_strTag};a.prototype.SetStrTag=function(b){this.m_strTag=b};a.prototype.WriteToDataBuffer=
5401function(b){this.pos.WriteToDataBuffer(b);b.BeginSizedWrite();b.WriteInt(this.m_nMoveNo);b.WriteString(this.m_strTag);b.EndSizedWrite()};a.prototype.ReadFromDataBuffer=function(b){if(!this.pos.ReadFromDataBuffer(b))return!1;b.BeginSizedRead();this.m_nMoveNo=b.ReadInt();this.m_strTag=b.ReadString();var c=0<=this.m_nMoveNo;b.EndSizedRead();return c};a.prototype.CreatePosition=function(){var b=this.pos.CreatePosition();b.SetMoveNo(this.m_nMoveNo);return b};return a}();"use strict";
5402const TBRAIN={HASH_LINE_LEN:3,HASH_LINE_CNT:3,MAX_STR:63,EVAL_MOVE_NO:1,USER_IS_LOGIN:2,USER_MAY_DISCOVER:4,USER_TRUSTWORTHY:8,EVAL_NORMED:16},TBrainMove=function(){var a=function(){this.move=new Move;this.m_performanceStats=new GamePerformanceStats;this.m_nFlags=0};a.TBLineFeedbackType={TBLINEFB_LIKE:0,TBLINEFB_DISLIKE:1,TBLINEFB_REPORT:2};a.CALCTIME_MINIMAL=210;a.CALCTIME_REASONABLE_THRESH=260;a.CALCTIME_DONATION=265;a.CALCTIME_DISCOVERY=305;a.CALCTIME_DEEP=a.CALCTIME_CRAZY=450;var b=a.TBRAINMOVE_HASEVAL=
54031;a.TBRAINMOVE_HASCOMMENT=2;a.prototype.HASH_LINE_LEN=3;a.prototype.HASH_LINE_CNT=3;a.prototype.CALCTIME_DEEP=370;a.prototype.getMoveRecord=function(){return this.move};a.prototype.getLine=function(c){CBDebug.assert(c<TBRAIN.HASH_LINE_LEN);return c<TBRAIN.HASH_LINE_LEN?this.m_aLine[c]:0};a.prototype.getLine=function(c,d){CBDebug.assert(d<TBRAIN.HASH_LINE_LEN);this.m_aLine[d]=c};a.prototype.getNEval=function(){return this.m_nEval};a.prototype.getNTimeStamp=function(){return this.m_nTimeStamp};a.prototype.setNTimeStamp=
5404function(c){this.m_nTimeStamp=c};a.prototype.hasEval=function(){return isFlag(this.m_nFlags,b)||0!=this.m_nEval};a.prototype.setHasEval=function(c){this.m_nFlags=c?this.m_nFlags|b:this.m_nFlags&~b};a.prototype.hasComment=function(){};a.prototype.setHasComment=function(c){};a.prototype.getPerformanceStats=function(){return this.m_performanceStats};a.prototype.getNGames=function(){return this.m_performanceStats.getNGames()};a.prototype.getEloAv=function(){return this.m_performanceStats.getSortEloAv()};
5405a.prototype.initNaked=function(c){this.move=c;this.m_nFlags=this.m_nTimeStamp=this.m_nEval=0;this.m_aLine=[];this.m_performanceStats.initEmpty()};a.prototype.V9=function(c){c.BeginSizedWrite();c.WriteInt64(this.m_nVisits);c.WriteBYTE(this.move.frSq);c.WriteBYTE(this.move.toSq);c.WriteBYTE(this.move.nType);c.WriteBYTE(this.move.nProm);c.WriteShort(this.m_nEval);c.WriteUShort(this.m_nTimeStamp);c.WriteShort(this.m_nFlags);this.m_performanceStats.WriteToDataBuffer(c);c.EndSizedWrite()};a.prototype.V7=
5406function(c){c.Vc();this.m_nVisits=c.V18();this.move.from=c.readUint8();this.move.to=c.readUint8();this.move.nType=c.readUint8();this.move.prom=c.readUint8();this.m_nEval=c.V1a();this.m_nTimeStamp=c.Vx();this.m_nFlags=c.V1a();this.m_performanceStats.V7(c);this.m_aLine=[];for(var d=0;d<a.prototype.HASH_LINE_LEN;++d){var e=c.Vx();this.m_aLine.push(e)}c.Vm();return!0};a.prototype.getTimeStamp=function(){return TBrainTimeStamp.UShortToDate(this.m_nTimeStamp)};a.prototype.getNVisits=function(){return this.m_nVisits};
5407a.getTimeStampToday=function(){var c=new CBDate;c.setToday();c.setYear(c.getYear()-1945);return c.getNum()};a.prototype.toString=function(){return this.move.toString()+", N="+this.getNGames()+",ev="+this.m_nEval};return a}();"use strict";
5408var TBrainMoveList=function(){var a=function(){this.moves=[]};a.prototype.V9=function(b){b.BeginSizedWrite();b.WriteInt(this.getNFormat());b.WriteUnsigned(this.count());for(var c=0;c<this.count();c++)this[c].WriteToDataBuffer(b);b.EndSizedWrite()};a.prototype.V7=function(b){b.Vc();b.readInt();this.clear();for(var c=b.readInt(),d=0;d<c;d++){var e=new TBrainMove;e.V7(b);this.add(e)}b.Vm();return!0};a.prototype.clear=function(){this.moves=[]};a.prototype.count=function(){return this.moves.length};a.prototype.add=
5409function(b){this.moves.push(b)};a.prototype.get=function(b){return this.moves[b]};a.prototype.getNFormat=function(){return 2};a.prototype.getMaxGames=function(){for(var b=0,c=0;c<this.moves.length;c++)this.moves[c].getNGames()>b&&(b=this.moves[c].getNGames());return b};
5409a.sortEval=function(b,c){b.sort(function(d,e){return c?d.m_nEval-e.m_nEval:e.m_nEval-d.m_nEval})};a.prototype.getHintedBestMove=function(b,c){c=c||50;if(0==this.moves.length)return b;for(var d=this.moves[0].m_nEval,e=0;e<this.moves.length;e++)if(Math.abs(this.moves[e].m_nEval-
5410d)<c){if(this.moves[e].move.equals(b))return b}else break;LOG("EngineHintMove not Best: "+b,"LogError");return this.moves[0].move};return a}();"use strict";
5411var TeraBrainChessUser=function(){var a=function(){};a.prototype.GetStrName=function(){return m_strName};a.prototype.GetRank=function(){return m_aRank};a.prototype.SetRank=function(b){m_aRank=b};a.prototype.GetNAccountAgeDays=function(){return m_nAccountAgeDays};a.prototype.SetNAccountAgeDays=function(b){m_nAccountAgeDays=b};a.prototype.HasSerial=function(){return ISFLAG(1)};a.prototype.HasPremium=function(){return ISFLAG(2)};a.prototype.IsSilenced=function(){return ISFLAG(4)};a.prototype.GetGeoCoordinates=
5412function(){return m_aGeoCoords};a.prototype.GetNLocalFlags=function(){return m_nFlags};a.prototype.GetNUFDFlags=function(){return m_nUFDFlags};return a}();"use strict";
5413var TeraBrainInfo=function(){var a=function(){this.pos=new HashPosition;this.moveList=new TBrainMoveList};a.prototype.read=function(){};a.prototype.fromMessage=function(b){b=b.GetPDataBuf();b.Rewind();this.V7(b)};a.prototype.V9=function(b){b.beginSizedWrite();this.pos.V9(b);b.V15(this.m_nVisits);this.moveList.V9(b);b.wndSizedWrite()};a.prototype.V7=function(b){b.Vc();this.pos.V7(b);this.m_nVisits=b.V18();this.moveList.V7(b);b.Vm();return!0};a.prototype.toString=function(){return""};a.prototype.getSocketsMessage=
5414function(){var b=new WebSockMessage(SockMsgId.TERABRAIN_BOOKINFO);this.V9(b.GetPDataBuf());return b};a.prototype.getNVisits=function(){return this.m_nVisits};a.prototype.getMoveList=function(){return this.moveList};a.prototype.setMoveList=function(b){this.moveList=b};a.prototype.getHashPosition=function(){return this.pos};return a}();"use strict";const TeraBrainRequestType={TBREQUEST_LB_UPLOADONLY:0,TBREQUEST_LB_POSINFO:1,TBREQUEST_LB_ALLMOVES:2,TBREQUEST_SEARCH_INFO:3};
5415var ServerTeraBrainLobby=function(){var a=function(){this.initForListeners();this.m_nUsageCnt=this.idGroup=0;this.m_bLoggedIn=!1;this.m_nUserReliability=0;this.m_bLaunchRankingDia=this.m_bAdmin=!1;this.m_nAnalysisTicket=0;this.m_bIsInAnalysis=this.m_bLaunchAnalysisByEngineNames=this.m_bSuppressRequests=!1;this.m_nAnalysisMoveLimit=1;this.m_bInEngineDonation=!1;this.m_nEngineId=this.m_nDonationPositions=0;this.associativeArray=[];this.tableDataHandlers={};this.timerClear=new Timer(function(){this.setEmptyTable()}.bind(this),
54162E3);this.name="TBrain";this.tracker=new PositionTracker};inherit(a,Connector);a.prototype.execCommand=function(b){if(!this.hasIdReceived)return!1;switch(b){case LobbyIds.PING_SERVER:this.pingServer(!0)}};a.prototype.notifyUserActivity=function(){};a.prototype.modifyLoginData=function(b){b.documentUrl=document.URL;glApp.isAnyPlugin||(b.documentUrl+=" (off)")};a.prototype.onIdReceived=function(b){this.fnOnIdReceived&&this.fnOnIdReceived()};a.prototype.displayForceLogOffMsg=function(b){console.log("TBrain: "+
5417(lm.SERVER_LOGGED_YOU_OFF+" "+b))};a.prototype.request=function(b,c,d,e,f,g,h){this.m_bSuppressRequests||(this.s_aMachineInfo=new ClientMachineInfo,c=new TeraBrainRequest(c,d,this.s_aMachineInfo),c.setIsNormedEval(!0),c.setCountVisit(!e),c.setConfirmRequested(f),c.setIsHumanServerGame(g),c.setIsMultiRequest(h),e=c.getSocketsMessage(),e.setVal(b),this.send(e))};a.prototype.requestPosInfo=function(b){this.hasIdReceived&&(this.request(1,b,TeraBrainRequestType.TBREQUEST_SEARCH_INFO,!0,!1,!0),this.timerClear.runOnce(2E3))};
5418a.prototype.requestWithTicket=function(b,c,d){this.hasIdReceived&&(this.tableDataHandlers[b]=d,this.request(b,c,TeraBrainRequestType.TBREQUEST_SEARCH_INFO,!0,!1,!0))};a.prototype.requestAllMoves=function(b,c,d,e,f){if(this.hasIdReceived){var g=this.tracker.track(b);this.request(e||1,b,TeraBrainRequestType.TBREQUEST_LB_ALLMOVES,g,d,c,f)}};a.requestHotPosition=function(){var b=new WebSockMessage(SockMsgId.TERABRAIN_USER);b.setUserType(TeraBrainUserMsgType.TBUSER_REQ_HOTPOSITION);this.send(b)};a.prototype.requestEngineNames=
5419function(b){var c=new WebSockMessage(SockMsgId.TERABRAIN_USER);c.setUserType(TeraBrainUserMsgType.TBUSER_REQ_ENGINENAMES);c.buf.Vu(b.length);for(var d=0;d<b.length;d++)c.buf.Vu(b[d]);this.send(c)};a.prototype.handleReceived=function(b){if(!this.handleReceivedByConnector(b))switch(b.getType()){default:TRACE("Unhandled: "+b.toString());break;case SockMsgId.DEFAULTGROUPS:this.onConnectedToBoundServer();break;case SockMsgId.CHAT:break;case SockMsgId.TERABRAIN_BOOKINFO:this.handleInfoMsg(b);break;case SockMsgId.TERABRAIN_TABLEDATA:this.handleTableData(b);
5420break;case SockMsgId.TERABRAIN_USER:this.handleUserMsg(b)}};a.prototype.handleUserMsg=function(b){switch(b.getUserType()){default:LOG("UserMsg="+TeraBrainUserMsgType.toString(b.getUserType()));break;case TeraBrainUserMsgType.TBUSER_ENGINENAMES:this.handleEngineNames(b);break;case TeraBrainUserMsgType.TBUSER_USERENTRIES:break;case TeraBrainUserMsgType.TBUSER_HOTPOSITION:break;case TeraBrainUserMsgType.TBUSER_CONFIRM_REQUEST:this.handleConfirmRequest(b);case TeraBrainUserMsgType.TBUSER_CONFIRMCOMMENT_REQUEST:case TeraBrainUserMsgType.TBUSER_COMMENTS:case TeraBrainUserMsgType.TBUSER_ADD_COMMENT:case TeraBrainUserMsgType.TBUSER_REFRESH_COMMENT:case TeraBrainUserMsgType.TBUSER_CONFIRM_LOGIN:case TeraBrainUserMsgType.TBUSER_RANKINGLIST:case TeraBrainUserMsgType.TBUSER_DEEP_VAR:case TeraBrainUserMsgType.TBUSER_SLAVE_ANALYSIS:case TeraBrainUserMsgType.TBUSER_RETRACT:case TeraBrainUserMsgType.TBUSER_SUBMIT_PO
5420SITION_DONE:case TeraBrainUserMsgType.TBUSER_SUBMIT_GAME_RESPONSE:case TeraBrainUserMsgType.TBUSER_ANALYSE_GAME_RESPONSE:case TeraBrainUserMsgType.TBUSER_USERDATA:case TeraBrainUserMsgType.TBUSER_LOCALTREE:}};
5421a.prototype.handleInfoMsg=function(b){this.aTBI=new TeraBrainInfo;this.aTBI.V7(b.getBuf());b={position:this.aTBI.pos.getPosition(),moves:this.aTBI.moveList.moves,ticket:b.getVal(),tbInfo:this.aTBI};this.fireOnLiveBook(b)};a.prototype.handleConfirmRequest=function(b){this.fireOnLiveBook({moves:[],ticket:b.getVal()})};a.prototype.onConnectedToBoundServer=function(){this.boundLoginOk=!0;this.callOnConnect?(this.callOnConnect(),this.callOnConnect=null):this.requestPosInfo(new Position)};a.prototype.handleTableData=
5422function(b){this.timerClear.stop();this.aHTD=new HashTableData;this.aHTD.V7(b.getBuf());for(var c=[],d=0;d<TBrainMove.prototype.HASH_LINE_CNT;++d)null==this.associativeArray[this.aHTD.move[d].m_nEngineId]?c.push(this.aHTD.move[d].m_nEngineId):this.aHTD.move[d].EngineName=this.associativeArray[this.aHTD.move[d].m_nEngineId];0<c.length?this.requestEngineNames(c):(c=this.aHTD.pos.getPosition(),glApp.panelMgr.tbPanel&&glApp.panelMgr.tbPanel.update(c,this.aHTD),this.tableDataHandlers[b.getVal()]&&(this.tableDataHandlers[b.getVal()](b.getVal(),
5423this.aHTD),delete this.tableDataHandlers[b.getVal()]),this.fireOnTBData({position:c,table:this.aHTD}))};a.prototype.setEmptyTable=function(){this.aHTD||(this.aHTD=new HashTableData);var b=HashTableData.emptyFactory();glApp.panelMgr.tbPanel&&glApp.panelMgr.tbPanel.update(this.aHTD.pos.getPosition(),b)};a.prototype.handleEngineNames=function(b){for(var c=b.getBuf().Vw(),d=0;d<c;d++){b.getBuf().Vc();var e=b.getBuf().Vb(255),f=b.getBuf().Vw();this.associativeArray[f]=e;b.getBuf().readFloat64();b.getBuf().Vm()}if(this.aHTD){for(b=
54240;b<TBrainMove.prototype.HASH_LINE_CNT;++b)this.aHTD.move&&this.aHTD.move[b]&&(this.aHTD.move[b].EngineName=this.associativeArray[this.aHTD.move[b].m_nEngineId]);b=this.aHTD.pos.getPosition();glApp.panelMgr.tbPanel&&(glApp.panelMgr.tbPanel.update(b,this.aHTD),this.timerClear.stop(),this.fireOnTBData({position:b,table:this.aHTD}))}};a.prototype.LogInPlayChessName=function(){var b=new WebSockMessage(SockMsgId.TERABRAIN_USER);b.SetUserType(TeraBrainUserMsgType.TBUSER_CHESSSERVER_LOGIN);var c=b.GetPDataBuf();
5425c.WriteString(this.m_strUsername);c.WriteString(this.m_strPassword);this.InquireMachineGuid();this.m_sMachineGuid.IsZero()?CBDebug.assert(!1):(this.m_sMachineGuid.WriteToDataBuffer(c),this.send(b))};a.prototype.LogOutPlayChessName=function(b){b=new WebSockMessage(SockMsgId.TERABRAIN_USER);b.SetUserType(TeraBrainUserMsgType.TBUSER_CHESSSERVER_LOGOUT);var c=b.GetPDataBuf();this.InquireMachineGuid();this.m_sMachineGuid.IsZero()?CBDebug.assert(!1):(this.m_sMachineGuid.WriteToDataBuffer(c),this.send(b));
5426this.m_bLoggedIn=!1;this.ResetLoginData()};a.prototype.ResetLoginData=function(){this.m_nUserReliability=0;this.m_bAdmin=!1;this.m_nUserId=0};a.prototype.InquireMachineGuid=function(){this.m_sMachineGuid.IsZero();return this.m_sMachineGuid};a.prototype.GetNUserId=function(){return this.m_nUserId};a.prototype.GetNEngineId=function(){return this.m_nEngineId};a.prototype.ShouldUsePlayChessName=function(){return!0};a.prototype.UseEngineInAnalysis=function(){return!1};a.prototype.GetMaxServerSilentSeconds=
5427function(){return 30};a.prototype.hasSockMsgIds=function(){return!0};a.prototype.hasSockCheckSum=function(){return!0};a.prototype.handleChat=function(b){var c=new ChatData;c.fromSocketsMsg(b);c.isToSession()?(b=this.watchSessions.getTitleOfSession(c.getIdSession()),b.length&&(c.strMsg="("+b+"): "+c.strMsg),glApp.panelMgr.chatOut(c.toString(),"LogKibitzChat")):glApp.panelMgr.chatOut(c.toString())};a.prototype.sendRandomMessage=function(){for(var b=0;10>b;b++);};a.prototype.initForListeners=function(){a.prototype.fireEvent||
5428(Vk.initForListeners(a),Vk.addEvent(a,"LiveBook"),Vk.addEvent(a,"TBData"),Vk.addEvent(a,"LiveBookDisplay"))};return a}(),TeraBrainUserMsgType={TBUSER_REQ_ENGINENAMES:1400,TBUSER_ENGINENAMES:1401,TBUSER_REQ_USERENTRIES:1402,TBUSER_USERENTRIES:1403,TBUSER_CHAT_TO_ALL:1404,TBUSER_INJECT_GAME:1420,TBUSER_CHESSSERVER_LOGIN:1421,TBUSER_CHESSSERVER_LOGOUT:1422,TBUSER_CONFIRM_LOGIN:1423,TBUSER_HOTPOSITION:1424,TBUSER_REQ_HOTPOSITION:1425,TBUSER_CONFIRM_REQUEST:1426,TBUSER_DEEP_CHECK:1427,TBUSER_DEEP_VAR:1428,
5429TBUSER_BEGIN_DONATION:1429,TBUSER_END_DONATION:1430,TBUSER_SLAVE_ANALYSIS:1431,TBUSER_RETRACT_REQUEST:1432,TBUSER_RETRACT:1433,TBUSER_SUBMIT_PO
5429SITION:1434,TBUSER_SUBMIT_POSITION_DONE:1435,TBUSER_SUBMIT_GAME:1436,TBUSER_SUBMIT_GAME_RESPONSE:1437,TBUSER_ANALYSE_GAME:1438,TBUSER_ANALYSE_GAME_RESPONSE:1439,TBUSER_COMMENTS:1440,TBUSER_REQ_COMMENTS:1441,TBUSER_ADD_COMMENT:1442,TBUSER_COMMENT_FEEDBACK:1443,TBUSER_REFRESH_COMMENT:1444,TBUSER_CONFIRMCOMMENT_REQUEST:1445,TBUSER_REQ_RANKINGLIST:1460,TBUSER_RANKINGLIST:1461,
5430TBUSER_BACKUP_DATABASES:1462,TBUSER_TEST:1463,TBUSER_ADMIN_RESET_RANKING:1464,TBUSER_ADMIN_BLOCK_DISCOVERY:1465,TBUSER_REQUEST_PERSONALDATA:1466,TBUSER_USERDATA:1467,TBUSER_REQUEST_LOCALTREE:1468,TBUSER_LOCALTREE:1469,TBUSER_SUSPICIOUS_LINE:1480,TBUSER_RESET_LIN:1481,TBUSER_FEEDBACK_ON_LINE:1481,TBUSER_SET_MACHINE_FACTOR:1482,toString:function(a){for(var b in this)if(this[b]==a)return b;return"Unknown TBUserMsgId: "+a}};"use strict";var TBREQ_NORM_EVAL=1,TBREQ_MULTI_REQ=2;
5431class TeraBrainRequest{constructor(a,b,c){this.m_eRequestType=b;this.m_aHashPos=new HashPosition(a);this.m_aMachineInfo=c;this.m_nMoveNo=a.getMoveNum();this.m_bCountVisit=!0;this.m_bHumanServerGame=this.m_bConfirmRequested=!1;this.m_nFlags=0}requestsPosInfo=function(){return this.m_eRequestType==TeraBrainRequestType.TBREQUEST_LB_POSINFO};requestsAllMoves(){return this.m_eRequestType==TeraBrainRequestType.TBREQUEST_LB_ALLMOVES}requestsSearchInfo(){return this.m_eRequestType==TeraBrainRequestType.TBREQUEST_SEARCH_INFO}isUploadOnly(){return this.m_eRequestType==
5432TeraBrainRequestType.TBREQUEST_LB_UPLOADONLY}getHashPos(){return this.m_aHashPos}getMoveNo(){return this.m_nMoveNo}setMoveNo(a){this.m_nMoveNo=a}getTaggedPos(){return new TaggedHashPos(this.getHashPos(),this.getMoveNo())}countVisit(){return this.m_bCountVisit}setCountVisit(a){this.m_bCountVisit=a||!1}confirmRequested(){return this.m_bConfirmRequested}setConfirmRequested(a){this.m_bConfirmRequested=a||!1}isHumanServerGame(){return this.m_bHumanServerGame}setIsHumanServerGame(a){this.m_bHumanServerGame=
5433a||!1}isNormedEval(){return this.ISFLAG(TBREQ_NORM_EVAL)}setIsNormedEval(a){this.SETFLAG(TBREQ_NORM_EVAL,a)}setIsMultiRequest(a){this.SETFLAG(TBREQ_MULTI_REQ,a)}SETFLAG(a,b){this.m_nFlags=b?this.m_nFlags|a:this.m_nFlags&~a}ISFLAG(a){return 0!=(this.m_nFlags&a)}fromMessage(a){a=a.getPDataBuf();a.rewind();this.V7(a)}getSocketsMessage(){var a=new WebSockMessage(SockMsgId.TERABRAIN_REQUEST);this.V9(a.buf);return a}V9(a){a.beginSizedWrite();a.Vu(this.m_eRequestType);this.m_aHashPos.V9(a);this.m_aMachineInfo.V9(a);
5434a.Vu(this.m_nMoveNo);a.V1b(this.m_bCountVisit);a.V1b(this.m_bConfirmRequested);a.V1b(this.m_bHumanServerGame);a.Vu(this.m_nFlags);a.endSizedWrite()}V7(a){a.BeginSizedRead();this.m_eRequestType=TeraBrainRequestType(a.ReadInt());this.m_aHashPos.ReadFromDataBuffer(a);this.m_aMachineInfo.ReadFromDataBuffer(a);this.m_nMoveNo=a.ReadUint32();this.m_bCountVisit=a.ReadBool();this.m_bConfirmRequested=a.ReadBool();this.m_bHumanServerGame=a.ReadBool();this.m_nFlags=a.ReadUint32();a.EndSizedRead();return!0}}"use strict";
5435var TBrainTimeStamp=function(){var a=function(){};a.prototype.UShortToDate=function(b){var c=b&31,d=b>>5&15;b=1945+(b>>9&127);return new CBDate(Math.Min(CBDate.Today().GetDate(),(new CBDate(b,d,c)).GetDate()))};a.prototype.DateToUShort=function(b){var c=Math.Max(1945,b.GetYear());return b.GetDay()|b.GetMonth()<<5|c-1945<<9};a.prototype.GetNTodaysTimeStamp=function(){return this.DateToUShort(CBDate.Today())};return a}();"use strict";
5436var PositionTracker=function(){var a=function(){this.set=new CBSet;this.trackCnt=0;this.enabled=!0};a.prototype.save=function(){(new CBStorage).save("posns_trackCnt",this.trackCnt);this.set.save("posns",function(b){return 200>this.trackCnt-b.lastSeenAt}.bind(this))};a.prototype.load=function(){this.trackCnt=(new CBStorage).load("posns_trackCnt")||0;this.set.load("posns",function(b){if(b){var c=new Position;c.copy(b.pos);c=new TrackedPos(c);c.cnt=b.cnt;c.lastSeenAt=b.lastSeenAt;return c}})};a.prototype.track=
5437function(b){if(this.enabled){this.trackCnt++;if(this.set.contains(new TrackedPos(b)))return b=this.set.get(new TrackedPos(b)),b.inc(),b.lastSeenAt=this.trackCnt,!0;b=new TrackedPos(b);b.lastSeenAt=this.trackCnt;this.set.insert(b)}return!1};a.prototype.getAge=function(b){b=this.set.get(new TrackedPos(b));return void 0!==b&&0!=b.cnt?this.trackCnt-b.lastSeenAt:-1};return a}(),TrackedPos=function(){var a=function(b){this.pos=ObjUtil.clone(b);this.lastSeenAt=this.cnt=0};a.prototype.setEquals=function(b){return this.pos.setEquals(b.pos)};
5438a.prototype.setGreater=function(b){return this.pos.setGreater(b.pos)};a.prototype.inc=function(){this.cnt++};return a}(),ServerClientFlags={CCDATA_RECEIVES_PAYMENTS:1,CCDATA_ENGINE_ALLOWED:2,CCDATA_PREMIUM_ACCOUNT:4,CCDATA_NO_GAME_DOWNLOAD:8},ServerClientData=function(){var a=function(){this.nConnQuality=this.n8Reserved=this.n8Flags2=this.n8InputLang=this.n8Language=this.n8NonPureFlags=this.n8Flags=this.nRank=this.nId=0;this.strText=this.strName="";this.n16Reserved=this.n16Flags=this.eStatus=this.eTitle=
5439this.nRating=0;this.geoCoords=new GeoCoordinates;this.eloRating=new ServerEloRating};a.prototype.fromDataBuf=function(b){this.nId=b.V19();this.eStatus=b.V19()&65535;this.nRank=b.V19();this.n8Flags=b.readUint8();this.n8NonPureFlag=b.readUint8();this.n8Language=b.readUint8();this.n8InputLang=b.readUint8();this.n8Flags2=b.readUint8();this.n8Reserved=b.readUint8();this.nConnQuality=b.V1a();this.strName=b.Vb(200);this.strText=b.Vb(200);this.nRating=b.V19();this.eTitle=b.V19();b.V19();this.geoCoords.fromDataBuf(b);
5440this.n16Flags=b.V1a();this.n16Reserved=b.V1a();b.Vc();this.eloRating.fromDataBuf(b);b.Vm();return!0};a.prototype.isGuest=function(){return(this.nRank&15)==ServerRankEnum.GUEST};a.prototype.isPremium=function(){return this.n16Flags==ServerClientFlags.CCDATA_PREMIUM_ACCOUNT};a.prototype.isEventDirector=function(){return 0!==(this.eStatus&(ServerStatusEnum.TOURNDIRECTOR|ServerStatusEnum.SIMULMASTER))};return a}(),ServerClientList=function(){var a=function(){this.items=[]};a.prototype.fromSocketsMsg=
5441function(b){b=b.getBuf();for(var c=b.V19(),d=0;d<c;d++){var e=new ServerClientData;e.fromDataBuf(b)&&this.items.push(e)}};a.prototype.get=function(b){return this.items[b]};a.prototype.count=function(){return this.items.length};a.prototype.autoTests=function(){return"NOTIMPL"};return a}();"use strict";
5442var ServerRankEnum={NONE:-1,GUEST:0,PAWN:1,KNIGHT:2,BISHOP:3,ROOK:4,QUEEN:5,KING:6,TOPGM:7,VIP:8,SYSOP:9,CHESSBASE:10,NUM:11,getStrCode:function(a){switch(a&15){default:case this.GUEST:return"Guest";
5442case this.PAWN:return"Pawn";case this.KNIGHT:return"Knight";case this.BISHOP:return"Bishop";case this.ROOK:return"Rook";case this.QUEEN:return"Queen";case this.KING:return"King";case this.VIP:return"VIP";case this.TOPGM:return"topGM";case this.SYSOP:return"Sysop";case this.CHESSBASE:return"ChessBase"}},
5443getStrText:function(a){switch(a&15){default:case this.GUEST:return lm.GUEST;case this.PAWN:return lm.PAWN;case this.KNIGHT:return lm.KNIGHT;case this.BISHOP:return lm.BISHOP;case this.ROOK:return lm.ROOK;case this.QUEEN:return lm.QUEEN;case this.KING:return lm.KING;case this.VIP:return"VIP";case this.TOPGM:return"Top-GM";case this.SYSOP:return"Sysop";case this.CHESSBASE:return"ChessBase"}}},ServerRankFlags={FLAG_500DAYS:1,FLAG_1000DAYS:2,FLAG_100TOURNDIRS:16,FLAG_500TOURNDIRS:32,FLAG_HELPER:64,FLAG_PREMIUM:128,
5444FLAG_ROBOT:256},ServerRank=function(){function a(d,e,f,g){1<f.length&&CBCSS.addRules(".rnk-"+e+f,"background-image: url( ../../common/media/server/ranks"+g+"/"+e+f+g+".png ) !important;background-repeat:no-repeat; background-position:center;")}var b=!1,c=function(d,e){this.rank=d;this.flags=e;if(!b){for(d=ServerRankEnum.PAWN;d<=ServerRankEnum.KING;
5444d++)a(void 0,"w",ServerRankEnum.getStrCode(d),16),a(void 0,"b",ServerRankEnum.getStrCode(d),16);a(void 0,"","Guest",16);for(d=ServerRankEnum.TOPGM;d<ServerRankEnum.NUM;d++)a(void 0,
5445"",ServerRankEnum.getStrCode(d),16);a(void 0,"","Helper",16);b=!0}};c.prototype.fromCompressed=function(d){this.rank=d&255;this.flags=d>>16};c.prototype.getCompressed=function(){return this.flags<<16+this.rank};c.prototype.isBlackSymbol=function(){return 0!==(this.flags&ServerRankFlags.FLAG_500DAYS)||0!==(this.flags&ServerRankFlags.FLAG_1000DAYS)};c.prototype.isHelper=function(){return 0!=(this.flags&ServerRankFlags.FLAG_HELPER)};c.prototype.isPremium=function(){return 0!=(this.flags&ServerRankFlags.FLAG_PREMIUM)};
5446c.prototype.getStrCode=function(){return ServerRankEnum.getStrCode(this.rank)};c.prototype.getStrColumn=function(){var d=ServerRankEnum.getStrText(this.rank);return d+=this.getStrFlags()};c.prototype.getStrFlags=function(){var d="";this.flags&ServerRankFlags.FLAG_500DAYS&&(d+="+");this.flags&ServerRankFlags.FLAG_1000DAYS&&(d+="+");this.flags&ServerRankFlags.FLAG_100TOURNDIRS&&(d+="*");this.flags&ServerRankFlags.FLAG_500TOURNDIRS&&(d+="*");this.flags&ServerRankFlags.FLAG_PREMIUM&&(d+="!");return d};
5447c.prototype.getSortVal=function(){return this.rank==ServerRankEnum.CHESSBASE?0:this.isHelper()?256*ServerRankEnum.VIP+this.flags+1:256*this.rank+this.flags+1};c.prototype.getCSSClass=function(){if(this.isHelper())var d="rnk-Helper";else switch(this.rank){default:case ServerRankEnum.GUEST:d="rnk-Guest";break;case ServerRankEnum.PAWN:case ServerRankEnum.KNIGHT:case ServerRankEnum.BISHOP:case ServerRankEnum.ROOK:case ServerRankEnum.QUEEN:case ServerRankEnum.KING:d="rnk-"+(this.isBlackSymbol()?"b":"w")+
5448this.getStrCode();break;case ServerRankEnum.TOPGM:case ServerRankEnum.VIP:case ServerRankEnum.SYSOP:case ServerRankEnum.CHESSBASE:d="rnk-"+this.getStrCode()}return d};return c}();"use strict";
5449var ServerStatusEnum={GONE:1,STANDING:2,PLAYER:4,WATCHER:8,ANALYSER:16,CHAIRMAN:32,SEEKING:8192,TOURNDIRECTOR:32768,SIMULMASTER:65536,APPLYING:131072,UNAPPLYING:262144,REGISTERED:524288,SOLVER:16777216,IDLE:64,NOTIDLE:128,DISCONNECTED:1048576,YESGAMES:256,NOGAMES:512,HUMAN:1024,ENGINE:2048,CENTAUR:4096,VIDEO:16384,ENCODING:4194304,LISTENING:8388608,DGT_BOARD:2097152,OFFLINE:4194304,toString:function(a){if(a&this.GONE)var b=lm.GONE;else if(a&this.OFFLINE)b="Offline";else switch(a&this.ACTIONTYPE&~this.SEEKING){default:case this.STANDING:b=
5450"";break;case this.PLAYER:b=lm.PLAYING;break;case this.WATCHER:b=lm.KIBITZING;break;case this.CHAIRMAN:b=lm.CHAIRMAN;break;case this.SOLVER:b=lm.TACTICS;break;case this.REGISTERED:b="Registered";break;case this.APPLYING:b="Wants to join"}a&this.SEEKING&&(b.length&&(b+="/"),b+=lm.SEEKS);a&this.GONE||(a&this.IDLE&&(b.length&&(b+="/"),b+=lm.IDLE),a&this.NOGAMES&&!(a&this.PLAYER)&&(b.length&&(b+="/"),b+=lm.PAUSE),a&this.CENTAUR&&(b.length&&(b+="/"),b+="Centaur"),a&this.ENGINE&&(b.length&&(b+="/"),b+=
5451"Engine"),a&this.TOURNDIRECTOR&&(b=lm.TOURN_DIRECTOR),a&this.SIMULMASTER&&(b="Simul Master"),a&this.APPLYING&&(b="Wants in"),a&this.UNAPPLYING&&(b="Wants out"),a&this.REGISTERED&&(b="Registered"),a&this.DISCONNECTED&&(b+="Disconnected"));return b}};
5452(function(){var a=ServerStatusEnum;a.ACTIONTYPE=a.STANDING|a.PLAYER|a.WATCHER|a.SOLVER|a.SEEKING|a.ANALYSER|a.CHAIRMAN|a.APPLYING|a.UNAPPLYING|a.REGISTERED|a.SIMULMASTER|a.TOURNDIRECTOR;a.PLAYERTYPE=a.HUMAN|a.ENGINE|a.CENTAUR;a.IDLETYPE=a.IDLE|a.NOTIDLE|a.VIDEO|a.DISCONNECTED|a.ENCODING|a.LISTENING;a.PROMINENTTYPE=a.CHAIRMAN|a.TOURNDIRECTOR|a.SIMULMASTER;a.NOGAMETYPE=a.YESGAMES|a.NOGAMES})();
5453var ServerStatus=function(){var a=ServerStatusEnum,b=!1,c=function(d){this.flags=d;if(!b){d="Idle Pause Playing Kibitzing Seeking Tactics Chairman".split(" ");for(var e=0;e<d.length;e++){var f=d[e];if(1<f.length){var g="background-image: url( ../../common/media/server/status/"+f+16+".png ) !important;";g=glApp&&glApp.panelMgr&&glApp.panelMgr.viewport&&glApp.panelMgr.viewport.rtl?g+"background-repeat:no-repeat; background-position:right center;":g+"background-repeat:no-repeat; background-position:left center;";
5454CBCSS.addRules(".stat-"+f,g)}}b=!0}};c.prototype.toString=function(){return ServerStatusEnum.toString(this.flags)};c.prototype.getSortVal=function(){var d=0;if(this.flags&a.GONE)return d;d++;
5454if(this.flags&a.CHAIRMAN)return d;d++;if(this.flags&a.SIMULMASTER)return d;d++;if(this.flags&a.TOURNDIRECTOR)return d;d++;if(this.flags&a.DISCONNECTED)return d;d++;if(this.flags&a.REGISTERED)return d;d++;if(this.flags&a.APPLYING)return d;d++;if(this.flags&a.UNAPPLYING)return d;d++;if(this.flags&a.SOLVER)return d;
5455d++;if(this.flags&a.PLAYER)return d;d++;if(this.flags&a.WATCHER)return d;d++;if(this.flags&a.SEEKING)return d;d++;if(this.flags&a.YESGAMES)return d;d++;if(this.flags&a.NOGAMES)return d;d++;if(this.flags&a.DGT_BOARD)return d;d++;if(this.flags&a.IDLE)return d;d++;return d};c.prototype.applyChange=function(d){d.isStatusChange()&&(d.status&a.ACTIONTYPE&&(this.flags&=~a.ACTIONTYPE),d.status&a.PLAYERTYPE&&(this.flags&=~a.PLAYERTYPE),d.status&a.IDLETYPE&&(this.flags&=~a.IDLETYPE),d.status&a.NOGAMETYPE&&
5456(this.flags&=~a.NOGAMETYPE),this.flags|=d.status)};c.prototype.isPlaying=function(){return 0!=(this.flags&a.PLAYER)};c.prototype.getCSSClass=function(){var d="";if(!(this.flags&a.GONE))if(this.flags&a.IDLE)d="stat-Idle";else if(this.flags&a.NOGAMES&&!(this.flags&a.PLAYER))d="stat-Pause";else if(this.flags&a.SEEKING)d="stat-Seeking";else switch(this.flags&a.ACTIONTYPE){case a.PLAYER:d="stat-Playing";break;case a.WATCHER:d="stat-Kibitzing";break;case a.CHAIRMAN:d="stat-Chairman";break;case a.SOLVER:d=
5457"stat-Tactics"}return d};return c}();"use strict";
5458var ServerClientChangeEnum={STATUS:1,TEXT:2,VALUE1:4,VALUE2:8,ADDRESS:16,CONNQUAL:32},ServerClientChange=function(){var a=ServerClientChangeEnum,b=function(){};b.prototype.init=function(c){this.reserved=this.connQual=this.flags=0;this.id=c;this.status=this.val2=this.val1=0};b.prototype.fromDataBuf=function(c){this.flags=c.V19();this.connQual=c.V1a();this.reserved=c.V1a();this.id=c.V19();this.ISFLAG(a.VALUE1)?this.val1=c.V19():this.val1=0;this.ISFLAG(a.VALUE2)?this.val2=c.V19():this.val2=0;this.ISFLAG(a.STATUS)&&
5459(this.status=c.V19());this.ISFLAG(a.TEXT)&&(this.text=c.Vb(65))};b.prototype.V17=function(c){c.V13(this.flags);c.V14(this.connQual||0);c.V14(this.reserved||0);c.V13(this.id)||0;this.ISFLAG(a.VALUE1)&&c.writeInt(this.val1);this.ISFLAG(a.VALUE2)&&c.writeInt(this.val2);this.ISFLAG(a.STATUS)&&c.writeInt(this.status);this.ISFLAG(a.TEXT)&&c.Va(this.text)};b.prototype.toString=function(){var c="id="+this.id;this.ISFLAG(a.VALUE1)&&(c+=" val1="+this.val1);this.ISFLAG(a.VALUE2)&&(c+=" val2="+this.val2);this.ISFLAG(a.STATUS)&&
5460(c+=" stat="+ServerStatusEnum.toString(this.status));this.ISFLAG(a.TEXT)&&(c+=" txt="+this.text);return c};b.prototype.setStatusChange=function(c){if("number"!=typeof c)throw Error("CDC.setStatusChange must pass a number");this.flags|=a.STATUS;this.status=c};b.prototype.isStatusChange=function(){return this.ISFLAG(a.STATUS)};b.prototype.isChangedElo=function(){return this.ISFLAG(a.VALUE1)&&this.ISFLAG(a.VALUE2)&&1==this.val1};b.prototype.getChangedElo=function(){return this.isChangedElo()?this.val2&
546165535:0};b.prototype.ISFLAG=function(c){return 0!==(this.flags&c)};b.prototype.isSeeking=function(){return 0!=(this.status&ServerStatusEnum.SEEKING)&&this.isStatusChange()};b.prototype.isPlaying=function(){return 0!=(this.status&ServerStatusEnum.PLAYER)&&this.isStatusChange()};b.prototype.setIsPlaying=function(){this.status|=ServerStatusEnum.PLAYER;this.flags|=ServerClientChangeEnum.STATUS};b.prototype.isRegisteredStatus=function(){return this.isStatusChange&&0!==(this.status&ServerStatusEnum.REGISTERED)};
5462return b}(),UserMsgId={NONE:0,GAMESTATUS_LIVE:400,NOTIFY_NEWROUND_LIVE:870,CHALLENGE:1E3,CANCEL_SEEKS:1001,VALIDATE_SEEKS:1002,RESPOND_VALIDATE_SEEKS:1003,REQUEST_ALL_SEEKS:1004,RESPOND_ALL_SEEKS:1005,REQUESTGAMELIST:1100,GAMELIST:1101,ADDGAME:1102,REMOVEGAME:1103,GAMESTATUS:1200,GAME:1201,SESSIONACTION:1202,SETCLOCK:1203,STARTGAME:1204,TIME_PENALTY:1205,RESTARTGAME:1206,RESTARTTOURNGAME:1207,FOLLOW:1208,STOPFOLLOW:1209,FOLLOWEVENT:1210,REQUEST_SELECTED_CLIENTLIST:1211,SELECTED_CLIENTLIST:1212,REQUEST_FRIENDLIST:1213,
5463RESPOND_FRIENDLIST:1214,ADD_REMOVE_FRIEND_FOE:1215,STARTTOURNAMENTGAME:1216,QUERY_UNFINISHED_GAME:1217,STOP_CLOCK:1220,START_CLOCK:1221,ENTER_CLOCK:1222,ANALYSIS_FOCUS:1223,REQUEST_CALENDAR:1230,RESPOND_CALENDAR:1231,CALENDAR_ADD:1232,CALENDAR_RMV:1233,REQUEST_STANDING:1234,PAYMENTS_TRANSACTION:1240,PLAYEREVALUTION:1250,INFORMALAPPLAUSE:1251,NOTIFY_CLIENT:1260,REQUEST_BESTGAME:1261,RESPOND_BESTGAME:1262,CANCEL_BESTGAME:1263,REQUEST_ELODATA:1270,ELODATA:1271,FORMULA:1272,CONFIRM_REGISTRATION:1273,
5464TEMP_ELO:1274,NEW_ELO:1275,USERTODATABASEID:1276,REQUEST_OPPONENTS:1277,RESPOND_OPPONENTS:1278,GETPICTURE:1280,SETPICTURE:1281,GET
5464SMALLPICTURE:1282,SETSMALLPICTURE:1283,SETGEOPOS:1284,TOURNAMENT_FINISHED:1285,AUTOTOURN_STANDING:1286,TOURNAMENT_STANDING:1287,AUTOTOURN_STARTED:1288,AUTOTOURN_FINISHED:1289,EVENT_ENDED:1290,STARTBROADCAST:1291,BROADCASTSTARTED:1292,BROADCASTENDED:1293,DELETEGAMES:1362,toString:function(a){for(var b in this)if(this[b]==a)return"UserMsg:"+b;return"Unknown UserMsgId: "+
5465a},toNumString:function(a){return"UserMsgId="+a}};"use strict";
5466var ServerGameStatusEnum={UNDEFINED:-1,BLACKWINS:100,DRAW:101,WHITEWINS:102,ABORT:103,RESIGN:360,TIMEOVERSTEPPED:361,CLAIMFLAG:362,ACCEPT_CLAIMFLAG:363,REJECT_CLAIMFLAG:364,YOURMOVE_REQUEST:365,SIMUL_CLAIMWIN:366,OFFERDRAW:370,ACCEPTDRAW:371,REJECTDRAW:372,RETRACTDRAW:373,OFFERTAKEBACK:374,ACCEPTTAKEBACK:375,REJECTTAKEBACK:376,OFFERABORT:380,ACCEPTABORT:381,REJECTABORT:382,CLAIMWIN_ON_DISCONNECT:383,SERVER_FORCES_ABORT:384,EARLY_ABORT:385,ALLOW_ABORT:386,OFFERADJOURN:388,ACCEPTADJOURN:389,REJECTADJOURN:390,
5467RETRACTADJOURN:391,AUTOTOURN_NEXTGAME:420,AUTOTOURN_PLUSONE:421,AUTOTOURN_SETRESULT:422,QUERYBEGIN:500,BEGINOK:501,QUERYRESTART:502,RESTARTOK:503,TRANSMISSION_READY:504,WINDOWCLOSED:505,BEGINANALYSIS:506,GAMERESTARTED:507,LIVETIME:508,MINRANKCHAT:509,TWOMOVESDONE:510,QUERYBEGINBLACK:511,BEGINOKBLACK:512,FORCERELOAD:513,CHANGEGAME_TO_ANALYSIS:514,ADD_WATCHER:600,REMOVE_WATCHER:601,REQUEST_WATCHERLIST:602,REQUEST_GAMEUPDATE:603,REQUESTGAME_ADDWATCHER:604,WATCH_NUM:605,INVITE_WATCHER:620,BLOCK_AFTER_ILLEGAL:621,
5468RECEIVED_GAME_AFTER_ILLEGAL:622,STREAMINGON:650,STREAMINGOFF:651,BLOCK_ENGINES:670,ALLOW_ENGINES:671,MOVE_RECEIPT:672,toString:function(a){for(var b in this)if(this[b]==a)return"GChange: "+b;return"Unknown GameStatChange: "+a}};const gsEnum=ServerGameStatusEnum;
5469var ServerGameStatusChange=function(){var a=function(b,c,d){this.type=b||ServerGameStatusEnum.UNDEFINED;this.idGame=c||0;this.idPlayer=d||0;this.num=this.flags=0};a.prototype.init=function(b,c){this.idGame=b;this.idPlayer=c;this.num=this.flags=0};a.prototype.fromDataBuf=function(b){this.idGame=b.readInt();this.type=b.readInt();this.idPlayer=b.readInt();this.num=b.readInt();this.flags=b.readShort();this.reserved=b.readShort()};a.prototype.V17=function(b){b.writeInt(this.idGame);b.writeInt(this.type);
5470b.writeInt(this.idPlayer);b.writeInt(this.num);b.writeShort(this.flags);b.writeShort(1676)};a.prototype.isResult=function(){return 0<=this.type&&this.type<=ServerGameStatusEnum.ABORT};a.prototype.isWatcherChange=function(){return this.type==ServerGameStatusEnum.ADD_WATCHER||this.type==ServerGameStatusEnum.REQUESTGAME_ADDWATCHER||this.type==ServerGameStatusEnum.REMOVE_WATCHER};a.prototype.isResult=function(){return this.type==ServerGameStatusEnum.BLACKWINS||this.type==ServerGameStatusEnum.WHITEWINS||
5471this.type==ServerGameStatusEnum.DRAW};a.prototype.getWatchersInc=function(){return this.type==ServerGameStatusEnum.ADD_WATCHER||this.type==ServerGameStatusEnum.REQUESTGAME_ADDWATCHER?1:this.type==ServerGameStatusEnum.REMOVE_WATCHER?-1:0};a.prototype.getNum=function(){return this.num};a.prototype.toString=function(){return ServerGameStatusEnum.toString(this.type)+" gm="+this.idGame+", pl="+this.idPlayer+", flags="+this.flags};return a}();"use strict";
5472var ServerGameItemType={UNKNOWN:0,GAME:1,BROADCAST:2,ANALYSIS:4,SETUP:8,ABORTED:16,RATED:32,BULLET:64,BLITZ:128,SLOW:256,ENGINE:512,CENTAUR:1024,HTTP_STREAM:2048,STREAM:4096,IMPORTANT:8192,PREMIUM:16384,PRIVATE:32768,TOP_GAME:65536};ServerGameItemType.SORTMASK=ServerGameItemType.GAME|ServerGameItemType.BROADCAST|ServerGameItemType.ANALYSIS|ServerGameItemType.RATED|ServerGameItemType.IMPORTANT|ServerGameItemType.STREAM;ServerGameItemType.COMPUTER=ServerGameItemType.ENGINE|ServerGameItemType.CENTAUR;
5473var ServerGameItem=function(){var a=function(){};a.prototype.fromDataBuf=function(b){this.white=b.Vb(100);this.type=b.V1a();this.black=b.Vb(100);this.id=b.V19();this.idGroup=b.V19();this.result=b.V19();this.timeStart=b.V19();this.idWhite=b.V19();this.idBlack=b.V19();this.idChallenger=b.readInt();this.flags=b.readInt();this.tourn=b.Vb(100);this.eloWhite=b.V1a()&8191;this.eloBlack=b.V1a()&8191;this.round1=b.readUint8();this.round2=b.readUint8();this.kibitzCosts=b.V1a();b.Vc();var c=b.V19();this.watchers=
5474c&65535;this.moveLen=c>>22&511;this.eco=b.Vx();this.liveStat=b.Vx();b.Vm();this.clock=new ClockParams;this.clock.fromDataBuf(b);this.flags&SessionBits.WITHCLOCK||delete this.clock};a.prototype.toString=function(){return this.white+"-"+this.black+", "+this.tourn+" ("+this.round1+")"};a.prototype.equals=function(b){return this.white!=b.white||this.black!=b.black||this.tourn!=b.tourn||this.round!=b.round||this.round2!=b.round2||this.result!=b.result?!1:!0};a.prototype.getTitle=function(){return this.white?
5475this.white+" - ...":""};a.prototype.applyGameChange=function(b){b.isResult()&&(this.result=b.type-100);b.isWatcherChange()&&(this.watchers+=b.getWatchersInc())};a.prototype.isBlitz=function(){return 0!=(this.type&ServerGameItemType.BLITZ)};a.prototype.isBullet=function(){return 0!=(this.type&ServerGameItemType.BULLET)};a.prototype.isImportant=function(){return 0!=(this.type&ServerGameItemType.IMPORTANT)};a.prototype.isAnalysis=function(){return 0!=(this.type&ServerGameItemType.ANALYSIS)};a.prototype.isBroadcast=
5476function(){return 0!=(this.type&ServerGameItemType.BROADCAST)};a.prototype.isStream=function(){return 0!=(this.type&ServerGameItemType.STREAM)};
5476a.prototype.isHTTPStream=function(){return 0!=(this.type&ServerGameItemType.HTTP_STREAM)};a.prototype.isPrivate=function(){return 0!=(this.flags&SessionBits.PRIVATE)};a.prototype.isPremium=function(){return 0!=(this.flags&ServerGameItemType.PREMIUM)};a.prototype.mightBeEngineGame=function(){var b=(this.white.match(/\d/g)||[]).length,c=(this.black.match(/\d/g)||
5477[]).length,d=(this.black.match(/\./g)||[]).length,e=(this.black.match(/\./g)||[]).length,f=0<(this.white.match(/64/g)||[]).length&&0<(this.white.match(/bit/gi)||[]).length,g=0<(this.black.match(/64/g)||[]).length&&0<(this.black.match(/bit/gi)||[]).length;return 0<d&&0<e&&1<b&&1<c||f||g};a.prototype.getWatcherSortVal=function(){return GameResultEnum.isFinished(this.result)?this.watchers/2:this.watchers};a.prototype.shouldRequestImmediatelyInLive=function(){return 2<this.result&&(20<this.watchers||
54782300<this.eloWhite&&2300<this.eloBlack)||2600<this.eloWhite||2600<this.eloBlack};a.prototype.getWhitePlayerForPB=function(){let b=this.getPlayer(this.white);b.elo=this.eloWhite;b.black=!1;return b};a.prototype.getBlackPlayerForPB=function(){let b=this.getPlayer(this.black);b.elo=this.eloBlack;b.black=!0;return b};a.prototype.getPlayer=function(b){let c=b.split(",");"Nihal Sarin"==c[0]&&(c[1]="Sarin",c[0]="Nihal");return{firstName:c[1],lastName:c[0],id:this.id,str:b,valid:!!c[1]}};a.prototype.getEval=
5479function(){return this.idChallenger};a.prototype.getLiveStatus=function(){let b=this.liveStat;this.hasLiveGameStatus()&&(29E3<Math.abs(this.getEval())&&(b|=64),32767==this.getEval()&&(b&=-65));return b};a.prototype.hasLiveGameStatus=function(){return 0!=(this.liveStat&8192)};return a}();
5480ServerGameItem.getResultString=function(a,b){switch(a){case GameResultEnum.GAME_UNFINISHED:case GameResultEnum.WHITE_WINS:case GameResultEnum.BLACK_WINS:case GameResultEnum.DRAW:return GameResultEnum.toString(a);case GameResultEnum.UNDEFINED_RESULT:return b&(ServerGameItemType.ANALYSIS|ServerGameItemType.BROADCAST)?lm.FINISHED:lm.ABORTED}};
5481var ServerGameItemList=function(){function a(c,d,e){for(var f=0;f<c.length;f++)if(void 0===c[f].watchers||d.eloWhite>c[f].eloWhite){c.splice(f,0,d);c.length>e&&c.pop();return}c.length<e&&c.push(d)}var b=function(c){this.games=c?c:[]};b.prototype.fromDataBuf=function(c){for(var d=c.V19(),e=0;e<d;e++){var f=new ServerGameItem;f.fromDataBuf(c);this.games.push(f)}};b.prototype.empty=function(){return 0==this.games.length};b.prototype.getIdGroup=function(){if(this.games.length)return this.games[0].idGroup};
5482b.prototype.getAutoWatchByKibitzers=function(c){function d(g,h,k){if(h){for(var l=0;l<g.length;l++)if(void 0===g[l].watchers||h.getWatcherSortVal()>g[l].getWatcherSortVal()){g.splice(l,0,h);g.length>k&&g.pop();return}g.length<k&&g.push(h)}}for(var e=[],f=0;f<this.games.length;f++)!(e.length<c||this.games[f].isImportant()||e.length&&this.games[f].watchers>e[e.length-1].watchers)||this.games[f].isStream()||this.games[f].isAnalysis()||this.games[f].mightBeEngineGame()||GameResultEnum.isFinished(this.games[f].result)&&
5483!this.games[f].isBroadcast()||!this.games[f].isBlitz()&&!this.games[f].isBroadcast()||d(e,this.games[f],c);e.forEach(function(g,h,k){LOG(h+":"+g+" kibitzers="+g.watchers)});return e};b.prototype.getAutoWatchByElo=function(c){for(var d=[],e=0;e<this.games.length;e++)!(d.length<c||this.games[e].isImportant()||d.length&&this.games[e].eloWhite>d[d.length-1].eloWhite)||this.games[e].isStream()||this.games[e].isAnalysis()||GameResultEnum.isFinished(this.games[e].result)&&!this.games[e].isBroadcast()||!this.games[e].isBlitz()&&
5484!this.games[e].isBroadcast()||a(d,this.games[e],c);d.forEach(function(f,g,h){LOG(g+":"+f+" Elo="+f.eloWhite)});return d};b.prototype.getAutoWatchByEloRunning=function(c,d){for(var e=[],f=0;f<this.games.length;f++)(e.length<c||this.games[f].isImportant()||e.length&&this.games[f].eloWhite>e[e.length-1].eloWhite)&&!this.games[f].isStream()&&!this.games[f].isAnalysis()&&!GameResultEnum.isFinished(this.games[f].result)&&this.games[f].isBroadcast()&&this.games[f].watchers>d&&a(e,this.games[f],c);e.forEach(function(g,
5485h,k){LOG(h+":"+g+" Elo="+g.eloWhite)});return e};b.prototype.getAutoWatchInRoom=function(c){c=Math.min(c,9);let d=0,e=0,f="",g=!1;
5485this.games.forEach(function(l){f||(f&&f!=l.tourn&&(g=!0),f=l.tourn);l.round1>d&&(d=l.round1,e=0);l.round1==d&&e++}.bind(this));this.games.sort(function(l,m){return m.timeStart-l.timeStart});var h=[];if(this.games.length<=c)for(c=0;c<this.games.length;c++)(g||2>e||this.games[c].round1==d)&&h.push(this.games[c]);else{for(var k=0;k<this.games.length;k++)!(h.length<c||this.games[k].isImportant())||
5486this.games[k].isStream()||this.games[k].isAnalysis()||GameResultEnum.isFinished(this.games[k].result)||!(2>e||this.games[k].round1==d||g)||h.length<c&&h.push(this.games[k]);if(4>h.length&&h.length<c)for(k=0;k<this.games.length&&h.length<c;k++)GameResultEnum.isFinished(this.games[k].result)&&(2>e||this.games[k].round1==d||g)&&h.length<c&&h.push(this.games[k])}return h};b.prototype.timeOk=function(c){let d=c.clock.getAvGameTimeSeconds()/60;return CBTime.now().getDiffIn100ths(new CBTime(c.timeStart))/
54876E3<d};b.prototype.getAutoWatchByMedia=function(c,d){for(var e=[],f=0;f<this.games.length;f++)if((this.games[f].isStream()||this.games[f].isHTTPStream())&&this.games[f].isBroadcast()&&-1==this.games[f].result){var g=!this.games[f].isPrivate();g&&(this.games[f].isPremium()&&(g=!1,d&&(g=!0)),g&&e.push(this.games[f]))}e.forEach(function(h,k,l){LOG(k+":"+h+" kibitzers="+h.watchers)});d=[];for(f=0;f<e.length;f++)d.push(e[f]),g=new BroadcastPair(d[f].id,d[f].white+" - "+d[f].black,d[f].tourn),c.push(g);
5488return d};b.prototype.isStream=function(c){for(c=0;c<this.games.length;c++)if(this.games[c].isStream())return!0;return!1};b.prototype.getFiltered=function(c){for(var d=[],e=0;e<this.games.length;e++)c(this.games[e])&&d.push(this.games[e]);return d.length?new ServerGameItemList(d):new ServerGameItemList(this.getAutoWatchByKibitzers(4))};b.prototype.contains=function(c){for(let d=0;d<this.games.length;d++)if(this.games[d].equals(c))return!0};return b}();"use strict";
5489var ServerGameData=function(){var a=function(){};a.prototype.fromDataBuf=function(b){this.idGame=b.readInt();this.type=b.readInt();this.reserved=b.readInt();this.game=new Game;this.game.fromDataBuf(b);b.Vc();this.strBanner=b.Vb(255);this.strURL=b.Vb(255);this.strWrapUrl=b.Vb(255);this.expiredSecs=b.readInt();this.clockStopped=b.V1c();b.Vm()};a.prototype.V17=function(b){b.writeInt(this.idGame)};a.prototype.toString=function(){return"GameData: "+this.idGame+", type="+this.type.toString(16)+", "+this.game.hdr.white+
5490"-"+this.game.hdr.black};a.prototype.isStream=function(){return 0!=(this.type&ServerGameItemType.STREAM)};a.prototype.isBroadcast=function(){return 0!=(this.type&ServerGameItemType.BROADCAST)};a.prototype.isHTTPStream=function(){return 0!=(this.type&ServerGameItemType.HTTP_STREAM)};a.prototype.isPremiumOnly=function(){return 0!=(this.type&ServerGameItemType.PREMIUM)};return a}();"use strict";
5491var MoveData=function(){var a=function(b,c,d,e){b&&(this.move=[b.from,b.to,b.prom&7],this.moveNo=c,this.centiSecs=d,this.idGame=e);this.flags=0};a.prototype.toString=function(){return String.f("{0}. {1}-{2} ({3}cs)",this.moveNo,CBSquare.toString(this.move[0]),CBSquare.toString(this.move[1]),this.centiSecs)};a.prototype.fromDataBuf=function(b){this.idGame=b.V19();this.move=b.readByteArray(3);this.centiSecs=b.V19();this.moveNo=b.V1a();this.flags=b.V1a();this.eval=b.V19()};a.prototype.V17=function(b){b.V13(this.idGame);
5492b.writeByteArray(this.move,3);b.V13(this.centiSecs);b.V14(this.moveNo);b.V14(this.flags||0);b.V13(this.eval||0)};return a}();"use strict";
5493var SetClockData=function(){var a=function(){};a.prototype.fromDataBuf=function(b){this.whiteCentiSecs=b.readInt();this.blackCentiSecs=b.readInt();this.tickCount=b.readInt();this.flags=b.readInt()};a.prototype.getWhiteTime=function(){return this.whiteCentiSecs};a.prototype.getBlackTime=function(){return this.blackCentiSecs};a.prototype.isBlack=function(){return 0!=(this.flags&1)};return a}();"use strict";
5494var SessionBits={RATED:1,WITHCLOCK:2,ALLOWTRANSMITGAME:4,TAKEBACK:8,POOL_BLITZ:16,ANALYSIS:32,RESUME:64,IN_TOURNAMENT:128,IN_SIMUL:256,WITH_STARTMOVES:512,PRIVATE:1024,WITHSTREAMING:2048,WITH_MANUALCLOCK:4096,DUCATSSTAKE:8192,WHITE_ENGINE:16384,BLACK_ENGINE:32768,WHITE_CENTAUR:65536,BLACK_CENTAUR:131072,WHITE_GM:262144,BLACK_GM:524288,PREMIUM:1048576,AUTOSTARTENCODER:2097152,BLOCK_ENGINES:4194304,MATCH:8388608,SLAVE_RESTART:16777216,HAS_BETS:33554432,DISABLE_BETS:67108864,PREMIUM_MOVES:134217728,
5495WHITE_POOL_BLITZ:268435456,BLACK_POOL_BLITZ:536870912},ServerGameSession=function(){var a=1,b=function(d,e,f){this.lobby=d;this.idGame=e;this.viewLink=f;this.requestedGame=!1;this.nErrorCount=this.nGameRequests=0;this.isFirstRequest=!0;this.uniqueId=a++;this.receivingMoves=!0;this.bufferedActions=[];this.delayedSessionActions=[];this.nGameActionsDelay=0;this.m_bBlockedAfterIllegal=this.transmitAnalysis=!1};b.prototype.recycle=function(){LOG("Release Session:"+this.idGame,"LogBold");this.gameKernel&&
5496(this.gameKernel.animateBoard=!1,this.gameKernel.destroy(),this.gameKernel=null);this.nErrorCount=this.nGameRequests=0;this.receivingMoves=this.isFirstRequest=!0;this.board&&(this.board.allowInput=!0)};b.prototype.onRecycle=function(){this.recycle();if(this.board)this.board.onRecycle()};b.prototype.isFinished=function(){return this.gameKernel.isFinished()};b.prototype.toggleReceivingMoves=function(){this.receivingMoves=!this.receivingMoves;this.setReceivingMoves(this.receivingMoves);this.nGameRequests=
54970};b.prototype.setReceivingMoves=function(d,e){if(this.receivingMoves=d)this.lobby.watchSessions.requestGame(this.idGame),this.requestedGame=!0;this.board.allowInput=!0;glApp.commands.fireChecked(LobbyIds.RECEIVING_MOVES,this.receivingMoves);e||this.gameKernel&&(d?this.gameKernel.Vp.startClock():this.gameKernel.Vp.stopClock())};b.prototype.createBoard3D=function(d){throw Error("No 3D");};b.prototype.createBoard=function(d){var e={pieceFontName:glSettings.getPieceFontName(),hasCloseBtn:!0};this.board=
5498new ReplayHandlerBoardControl(d,100,100,"Watch",e);glApp.isBoardOnlyApp()?this.board.animSteps={forMove:2,forPosition:2}:this.board.animSteps={forMove:2,forPosition:3};System.isMobile()&&(this.board.animSteps={forMove:.6,forPosition:.5});this.board.allowInput=!0;this.idHandler=this.board.onReadyHandlers.add(this.onBoardReady.bind(this));return this.board};b.prototype.onBoardReady=function(){this.requestedGame||(this.requestGame(),this.requestedGame=!0,this.board.onReadyHandlers.remove(this.idHandler),
5499this.isFirstRequest&&this.lobby.watchSessions.addMeAsWatcher(this.idGame))};b.prototype.onGameData=function(d){try{this.isInGameRequest=!1;this.tickGameReceived=new Tick;LOG("Session "+this.idGame+" receives game: "+d,"LogGreen");this.gameKernel?(this.m_bBlockedAfterIllegal&&(this.m_bBlockedAfterIllegal=!1,this.lobby.sendGameStatusChange(new ServerGameStatusChange(ServerGameStatusEnum.RECEIVED_GAME_AFTER_ILLEGAL,this.idGame,this.lobby.getNIdBound()))),this.receivingMoves&&(this.gameKernel.game.assign(d.game),
5500this.gameKernel.game.gotoIndex(d.game.getMoveIndex()))):(this.gameKernel=new GameKernel(this.viewLink,d.game),this.gameKernel.setPlayingMode(new AnalysisMode(this.gameKernel,1,{useAnalysisAsEngine:!0})),this.gameKernel.setBoardWin(this.board),this.gameKernel.Vp.createGUIElements(this.board),this.gameKernel.animateBoard=!1,this.board.singleClickDisabled=!0,this.modifyPlayingMode(),this.board.prepareFullRedraw(),this.board.redraw(),d.game.iAmBlack&&this.board.setBlackIsBottom(!0),this.board.isHandlerBoard&&
5501!this.board.hasShowHintsHandler&&(this.board.addHandler(new ShowHintsBoardHandler(this.board,{fnShouldRun:BoardHandler.isLeftMouse},function(){return this.gameKernel.Vp}.bind(this))),this.board.hasShowHintsHandler=!0));this.clock?(this.gameKernel.game.expiredSecs=[],this.gameKernel.game.expiredSecs[this.gameKernel.game.getMoves().length]=d.expiredSecs,this.gameKernel.Vp.setChessClock(this.clock)):this.gameKernel.Vp.setChessClock(!1);d.clockStopped&&this.stopClock();this.board.debugName=d.game.hdr.getStrPlayers();
5502this.receivingMoves&&(this.moveIndexOnServer=this.gameKernel.game.getMoveIndex(),this.executeBufferedActions());this.board.cbcanvas?this.board.setTitleText(this.gameKernel.game.hdr.getStrPlayers(this.board.nSqPix>this.board.cbcanvas.zoomToPix(46))):this.board.setTitleText(this.gameKernel.game.hdr.getStrPlayers(20));this.bufferedActions=[];this.nErrorCount=0;this.gameKernel.animateBoard="undefined"!==typeof Ext?glApp.animatedBoard()||!Ext.isIE:glApp.animatedBoard();this.strBanner=d.strBanner;if((this.strURL=
5503d.strURL)&&(glApp.Vn.shouldDisplayBoardUrls()||glApp.isBoardOnlyApp())&&glApp.config.versionChessBaseCom){var e=this.strURL,f="?";-1!=e.search(RegExp("\\?","g"))&&(f="&");e+=f+"ref=link_from_playchess_com";this.board.destroyBottomWin();if(glApp.isBoardOnlyApp()){var g={urlRight:e,linkTextRight:StrUtil.shortenURL(this.strURL),linkTextLeft:lm.FULL_VIEW,urlLeft:"http://live.chessbase.com"};this.board.bottomWin=new BoardDoubleURL(g,{hScale:24,hMax:18,spacing:0,rightAlign:!0})}else this.board.bottomWin=
5504new BoardURL({linkText:StrUtil.shortenURL(this.strURL),url:e},{hScale:20,hMax:18,spacing:1})}(d.isStream()||d.isHTTPStream())&&this.setReceivingMoves(!1)}catch(h){LogException("GSess::onGameData:",h)}};b.prototype.onBroadcast=function(d){try{this.isInGameRequest=!1,this.tickGameReceived=new Tick,this.gameKernel.setPlayingMode(new AnalysisMode(this.gameKernel)),this.gameKernel.setBoardWin(this.board),this.modifyPlayingMode(),this.board.prepareFullRedraw(),this.board.redraw(),this.gameKernel.Vp.setChessClock(!1)}catch(e){LogException("GSess::onGameData:",
5505e)}};b.prototype.modifyPlayingMode=function(){this.gameKernel.Vp.session=this;this.gameKernel.Vp.fnAcceptMove=function(d){return!0}.bind(this);this.gameKernel.Vp.fnAfterMove=function(d){this.transmitAnalysis?this.receivingMoves&&this.transmitMove2(d):this.gameKernel.game.getMoveIndex()==this.moveIndexOnServer+1&&this.gameKernel.game.isOnMainLine()&&this.gameKernel.game.setAnno(AnnoType.PRETEXT,new TextAnno("Analysis:"));return!0}.bind(this)};b.prototype.getTitle=function(){if(this.gameKernel)return this.gameKernel.game.hdr.getStrPlayers(!1)};
5506b.prototype.executeBufferedActions=function(){for(var d=0;d<this.bufferedActions.length;
5506d++)LOG("ExecBuffered SessionAction","LogBold"),this.onSessionAction(this.bufferedActions[d],!0)};b.prototype.onSessionAction=function(d,e){if(this.receivingMoves)if(0<this.nGameActionsDelay)d.timeStamp=this.nGameActionsDelay,d.session=this,this.delayedSessionActions.push(d);else this.onProcessSessionAction(d,e);else d.gameAction.isMove()&&(e=d.gameAction.moveData.toString(),this.lobby.statusMsg("Unplugged: "+
5507this.gameKernel.game.hdr.getStrPlayers()+" ("+Math.floor(d.gameAction.moveData.moveNo/2+1)+"."+e+")"))};b.prototype.onProcessSessionAction=function(d,e){this.gameKernel.game.getCurPos().Vj();var f=this.transmitAnalysis;this.transmitAnalysis=!1;if(this.isInGameRequest)this.bufferedActions.push(d);else{if(!this.gameKernel)return;d.gameAction.changesGame()&&this.moveIndexOnServer!=this.gameKernel.game.getMoveIndex()&&this.gameKernel.game.gotoIndex(this.moveIndexOnServer);if(d.gameAction.execute(this.gameKernel.game,
5508d.controlMove)){if(d.gameAction.isMove()||d.gameAction.isGame())d.gameAction.isMove()&&(this.gameKernel.Vp.updateClockFromGame(),this.gameKernel.game.deleteAnno(AnnoType.PRETEXT)),this.gameKernel.markLastMove(!1,!1);d.gameAction.isAnno()&&this.board.redraw();0<this.nErrorCount&&LOG("Game in Legal Sync: "+this.gameKernel.game.hdr,"LogBold");this.nErrorCount=0;this.moveIndexOnServer=this.gameKernel.game.getMoveIndex();this.analysisAdded&&this.gameKernel.game.promoteLine()&&(e=this.gameKernel.game.getMoveIndex(),
5509this.gameKernel.game.unAnnotate(),this.gameKernel.game.gotoIndex(e),this.moveIndexOnServer=e)}else d.gameAction.isMove()&&!d.isAnEarlierMove(this.gameKernel.game)?(this.nErrorCount+=1,LOG(this.board.debugName+"-Illegal: "+d.gameAction+", "+this.nErrorCount,"LogError"),e||this.isFinished()||!(3<this.nErrorCount||6E3<this.tickGameReceived.getExpired())||(this.nGameRequests++,30>this.nGameRequests?(LOG("Illegal Actions, refresh: "+this.gameKernel.game.hdr+", "+this.nGameRequests,"LogError"),this.requestGame()):
5510LOG("Too many illegal moves: "+this.gameKernel.game.hdr,"LogError"))):d.gameAction.isMove()?LOG("Received an earlier move: "+this.gameKernel.game.hdr,"LogGreen"):LOG("Non move Session Action: "+d.gameAction,"LogGreen")}d.gameAction.changesMoves()&&(this.analysisAdded=!1);this.transmitAnalysis=f};b.prototype.setMoveEntryAnyTime=function(d){(this.transmitAnalysis=d)&&this.lobby.logIntoChat("You can now enter moves any time")};var c=1;b.prototype.transmitMove=function(d){this.gameKernel.game.getCurLine();
5511var e=new MoveRecord;e.initFromMove(d);d=new GameAction;d.setSetMove(e);if(e=this.getControlMove(!1)){var f=new SessionAction;f.init(this.idGame,d,e);f.id=c++;this.sendSessionAction(f)}else return!1};b.prototype.transmitMove2=function(d){var e=this.gameKernel.game.getCurLine().length-1,f=new MoveRecord;f.initFromMove(d);d=new GameAction;d.setSetMove(f);f=new MoveRecord(0,0,0);0<e&&f.initFromMove(this.gameKernel.game.getCurLineCut()[e-1]);f.type=0;if(f)e=new SessionAction,e.init(this.idGame,d,f),e.id=
5512c++,this.sendSessionAction(e);else return!1};b.prototype.transmitGame=function(){var d=new GameAction;d.setGame(this.gameKernel.game,this.gameKernel.game.getMoveIndex());var e=this.getControlMove(!1),f=new SessionAction;f.init(this.idGame,d,e);f.id=c++;this.sendSessionAction(f)};b.prototype.getControlMove=function(d){var e=new MoveRecord(0,0,0),f=this.gameKernel.game.getMoveNo();d&&f--;var g=!0;0<f&&(g=this.gameKernel.game.getPreviousMove(),e.initFromMove(g),g=this.gameKernel.game.getCurPos().Vj(),
5513d&&(g=Side.other(g)),g=0!=(f&1)==(g==Side.BLACK));e.type=0;if(g)return e};b.prototype.onGameNavigate=function(){if(this.transmitAnalysis){var d=new GameAction;d.setMoveIndex(this.gameKernel.game.getMoveIndex());var e=new SessionAction,f=this.getControlMove(!1);f&&(e.init(this.idGame,d,f),this.sendSessionAction(e))}};b.prototype.sendSessionAction=function(d){var e=new WebSockMessage(SockMsgId.USER);e.setUserType(UserMsgId.SESSIONACTION);e.address(this.lobby.getNId(),ConnectId.SERVER);e.setVal(this.idGame);
5514d.V17(e.getBuf());this.lobby.send(e);this.lobby.conn.error&&(this.lobby.logIntoChat("WARNING, you are disconnected","LogRed"),this.addTextAnno("!!You are disconnected!!",!0));this.transmitAnalysis&&(this.moveIndexOnServer=this.gameKernel.game.getMoveIndex())};b.prototype.simpleAction=function(d){if(this.transmitAnalysis){var e=new GameAction;d(e);d=new SessionAction;var f=this.getControlMove(!1);f&&(d.init(this.idGame,e,f),this.sendSessionAction(d))}};b.prototype.onAnnoEntered=function(d,e){if(this.transmitAnalysis){var f=
5515new GameAction,g=new Annotation;g.setItem(d,e);d||e||(g=this.gameKernel.game.getOrCreateCurrAnno());f.setAnno(g);d=new SessionAction;if(e=this.getControlMove(!1))d.init(this.idGame,f,e),this.sendSessionAction(d)}};b.prototype.onUnAnnotate=function(){this.simpleAction(function(d){d.setUnAnnotate()})};b.prototype.onDeleteLine=function(){this.simpleAction(function(d){d.setDeleteLine()})};b.prototype.onPromoteLine=function(){this.simpleAction(function(d){d.setPromoteLine()})};b.prototype.onCutLine=function(){this.simpleAction(function(d){d.setCutLine()})};
5516b.prototype.requestGame=function(){this.isInGameRequest=!0;this.lobby.watchSessions.requestGame(this.idGame)};b.prototype.onGameStatusChange=function(d){switch(d.type){default:LOG("Session.onGSC: "+d
5516);break;case ServerGameStatusEnum.ADD_WATCHER:case ServerGameStatusEnum.REMOVE_WATCHER:case ServerGameStatusEnum.REQUESTGAME_ADDWATCHER:break;case ServerGameStatusEnum.WHITEWINS:this.finishGameWithResult(GameResultEnum.WHITE_WINS);break;case ServerGameStatusEnum.DRAW:this.finishGameWithResult(GameResultEnum.DRAW);
5517break;case ServerGameStatusEnum.BLACKWINS:this.finishGameWithResult(GameResultEnum.BLACK_WINS);break;case ServerGameStatusEnum.TIMEOVERSTEPPED:LOG("TIMEOVERSTEPPED","LogBold");if(this.gameKernel)this.gameKernel.Vp.onTimeOverstepped(this.idWhite!==d.idPlayer);this.idWhite==d.idPlayer?LOG("Time - White"):LOG("Time - Black");break;case ServerGameStatusEnum.BLOCK_AFTER_ILLEGAL:this.handleBlockAfterIllegal(d)}};b.prototype.handleBlockAfterIllegal=function(d){this.m_bBlockedAfterIllegal||(this.m_bBlockedAfterIllegal=
5518!0,this.lobby.watchSessions.requestGame(this.idGame))};b.prototype.finishGameWithResult=function(d){this.isFinished()||(this.gameKernel.setResult(d),glApp.panelMgr.onWatchResult())};b.prototype.isFinished=function(){return!this.gameKernel||this.gameKernel.game.hdr.getCBResult().isFinished()};b.prototype.setClock=function(d){this.gameKernel&&this.gameKernel.Vp.setManualClock(d.getWhiteTime(),d.getBlackTime(),d.isBlack())};b.prototype.stopClock=function(d){this.gameKernel&&(d=this.gameKernel.Vp,d.clock&&
5519(d.clock.stop(),d.clock.flash(!0),this.clockStopped=!0))};b.prototype.startClock=function(d){this.gameKernel&&(d=this.gameKernel.Vp,d.clock&&(d.clock.flash(!1),d.clock.continue(),this.clockStopped=!1))};b.prototype.enterClock=function(d){if(this.gameKernel){var e=this.gameKernel.Vp,f=e.clock.getExpired();e.clock.stop();e.clock.clockParams.modify(d.min,d.side);e.clock.initFromGame(this.gameKernel.game);d.side==this.gameKernel.game.getCurPos().Vj()&&e.clock.changeCurrMoveElapsedTime(f)}};b.prototype.onReconnect=
5520function(){this.receivingMoves&&(this.setReceivingMoves(!0),this.board&&this.board.addMessage("Reconnected",!0))};b.prototype.onConnBroken=function(){};b.prototype.toString=function(){return this.gameKernel?this.gameKernel.game.hdr.getStrPlayers():this.idGame};b.prototype.delayGameActions=function(d){this.nGameActionsDelay=d;0<this.nGameActionsDelay&&!this.myTimer&&(this.myTimer=setInterval(this.onBufferedGameActionsHandler.bind(this),1E3))};b.prototype.mustExecute=function(d){return 0<d.timeStamp&&
5521(d.timeStamp--,0==d.timeStamp)?!0:!1};b.prototype.execute=function(d){d.session.onProcessSessionAction(d,!0)};b.prototype.onBufferedGameActionsHandler=function(){this.delayedSessionActions.forEach(function(d){ServerGameSession.prototype.mustExecute(d)&&(ServerGameSession.prototype.execute(d),d.session.gameKernel&&d.session.gameKernel.game.updateFromExtern())})};return b}();"use strict";
5522class ManualClock extends BaseClock{constructor(a){super(a)}setTime(a,b,c){this.stop();a||b?(this.currTime=this.startTime=(new Date).getTime(),0<=a&&(this.whiteTime=a),0<=b&&(this.blackTime=b),0<=this.whiteTime&&(this.isBlack=!1,this.update()),0<=this.blackTime&&(this.isBlack=!0,this.update()),this.isBlack=c,this.clockLink.setToMove(c),this.start()):this.setNoClock()}onResult(a){GameResultEnum.isFinished(a)&&(this.stop(),this.clockLink.showResult(a))}setToMove(a){this.isBlack=a;this.update();this.clockLink.setToMove(a);
5523this.clockLink.emphasizeToMove(8E3)}start(){this.updateTimer.runPeriodic(1E3);this.clockLink&&(this.clockLink.runningClockId&&this.clockLink.runningClockId!=this.id&&(CBDebug.assert(0),TRACE("Clock Collision!")),this.clockLink.runningClockId=this.id)}stop(){this.updateTimer.stop();this.clockLink&&(this.clockLink.runningClockId=0)}getExpired(){return((new Date).getTime()-this.startTime+5)/10}update(){var a=((new Date).getTime()-this.startTime+5)/10,b=((new Date).getTime()-this.currTime+5)/10;this.clockLink.showCurrTime(new Date(10*
5524b),this.isBlack);a=this.isBlack?this.blackTime-=a:this.whiteTime-=a;this.startTime=(new Date).getTime();0>a?this.clockLink.showRestTime(-1,this.isBlack):this.clockLink.showRestTime(new Date(10*a),this.isBlack)}}"use strict";
5525var ServerClockRange=function(){var a=function(b,c){this.nMins=b||0;this.nSecs=c||0};a.prototype.fromDataBuf=function(b){this.nMins=b.readInt();this.nSecs=b.readInt()};a.prototype.V17=function(b){b.writeInt(this.nMins);b.writeInt(this.nSecs)};a.prototype.toString=function(){return"ClockRange"};return a}();"use strict";
5526var ServerConnQuality=function(){var a=function(b){this.val=b||0};a.prototype.fromDataBuf=function(b){this.val=b.readShort()};a.prototype.V17=function(b){b.writeShort(this.val)};a.prototype.getPing=function(){return 30*(this.val>>8&255)};a.prototype.getDiscos=function(){return this.val&255};a.prototype.getSortVal=function(){return this.val};a.prototype.toString=function(){return this.getPing()+"ms"};return a}();"use strict";namespace("CB.V0.Lobby");
5527const ServerLobby=function(){var a=function(){this.initForListeners();this.idGroup=this.idGameMultiMedia=0;this.testId=1;this.name="play.chessbase.com";this.notAlive=0;this.lists=new ServerLobbyLists(this)};
5527inherit(a,Connector);a.prototype.createLobby=function(f,g,h,k,l,m,n,r){this.copyOptions(r);this.create(f,g,h,k);this.broadcastInfo=[];this.urlParams=l;this.watchSessions=new ServerWatchSessions(this);n&&(this.playingSession=n(this));this.commandHandlerId=glApp.commands.registerCommandHandler(this);
5528glApp.idleFunc=this.onIdle.bind(this);glApp.notIdleFunc=this.onIdle.bind(this);this.onInvalidPassword=m;this.joinEventTimer=new Timer(this.joinEventHdl.bind(this))};a.prototype.copyOptions=function(f){f&&Object.getOwnPropertyNames(f).forEach(function(g){this[g]=f[g]}.bind(this))};a.prototype.isSilent=function(){return!1};a.prototype.execCommand=function(f){if(!this.hasIdReceived&&f!=CommandIds.LOGIN&&f!=LobbyIds.PING_SERVER)return!1;try{var g=!0;switch(f){default:g=!1;break;case CommandIds.LOGIN:this.changeLogin();
5529break;case LobbyIds.ACCOUNT:this.requestElo();break;case LobbyIds.PING_SERVER:this.pingServer(!1,4E3);break;case LobbyIds.WATCH_LIVETOURNAMENTS:this.watchSessions.watchLiveTournaments();System.runsInIFrame()||(LogStats("WatchLive"),window.open("https://live.chessbase.com","_blank"));break;case LobbyIds.WATCH_LIVERADIO:this.watchSessions.watchLiveTournamentsRadio();break;case LobbyIds.BROWSE_CMS_ARCHIVE:this.watchSessions.browseCMSArchive();break;case LobbyIds.GO_DEFAULT_PLAYING_GROUP:this.gotoDefaultPlayingGroup();
5530break;case LobbyIds.RECEIVING_MOVES:this.watchSessions.toggleReceivingMoves();break;case LobbyIds.MORE_BOARDS:this.watchSessions.showMoreBoards();break;case LobbyIds.LESS_BOARDS:this.watchSessions.showLessBoards();break;case LobbyIds.NEXT_BOARD:this.watchSessions.showNextBoard();break;case LobbyIds.GOTO_LOBBY:this.gotoLobby();break;case CommandIds.TOGGLE_ANALYSIS_AUTO_ENGINE:this.watchSessions.toggleAutoEngine();break;case LobbyIds.CLOSE_FINISHEDGAMES:this.watchSessions.closeFinishedGames();break;
5531case LobbyIds.CLOSE_ALLGAMES:this.watchSessions.closeAllGames();break;case LobbyIds.FOLLOW_BESTGAME:this.watchSessions.kibitzBestGame(0);break;case LobbyIds.PLAY_BLITZ3:this.lists.changeToPlayingRoomAndSeek(new ClockParams(3,0),ServerFormula.createBlitzFormula());break;case LobbyIds.PLAY_BLITZ4:this.lists.changeToPlayingRoomAndSeek(new ClockParams(4,0),ServerFormula.createBlitzFormula());break;case LobbyIds.PLAY_BLITZ:this.lists.changeToPlayingRoomAndSeek(new ClockParams(3,0),ServerFormula.createBlitzFormula(),
5532new ServerClockRange(2,0));break;case LobbyIds.PLAY_BLITZ5:this.lists.changeToPlayingRoomAndSeek(new ClockParams(5,0),ServerFormula.createBlitzFormula());break;case LobbyIds.PLAY_BLITZ32:this.lists.changeToPlayingRoomAndSeek(new ClockParams(3,2),ServerFormula.createBlitzFormula());break;case LobbyIds.PLAY_BLITZ10:this.lists.changeToPlayingRoomAndSeek(new ClockParams(10,0),ServerFormula.create10MinFormula());break;case LobbyIds.PLAY_BULLET1:this.lists.changeToPlayingRoomAndSeek(new ClockParams(1,0),
5533ServerFormula.createBulletFormula());break;case LobbyIds.PLAY_BULLET:this.lists.changeToPlayingRoomAndSeek(new ClockParams(1,0),ServerFormula.createBlitzFormula(),new ServerClockRange(1,0));break;case LobbyIds.PLAY_SLOW:this.lists.changeToPlayingRoomAndSeek(new ClockParams(16,0),ServerFormula.createSlowFormula(),new ServerClockRange(9,5));break;case LobbyIds.PLAY_SLOW16:this.lists.changeToPlayingRoomAndSeek(new ClockParams(16,0),ServerFormula.createSlowFormula());break;case LobbyIds.PLAY_SLOW155:this.lists.changeToPlayingRoomAndSeek(new ClockParams(15,
55345),ServerFormula.createSlowFormula());break;case LobbyIds.PLAY_SLOW20:this.lists.changeToPlayingRoomAndSeek(new ClockParams(20,0),ServerFormula.createSlowFormula());break;case LobbyIds.PLAY_SLOW30:this.lists.changeToPlayingRoomAndSeek(new ClockParams(30,0),ServerFormula.createSlowFormula());break;case LobbyIds.PLAY_SLOW20_10:this.lists.changeToPlayingRoomAndSeek(new ClockParams(20,10),ServerFormula.createSlowFormula());break;case LobbyIds.CLAIM_WIN:this.playingSession.claimWin();break;case LobbyIds.PING_OPPONENT:this.playingSession&&
5535this.playingSession.pingOpponent();break;case LobbyIds.CLOSE_PLAYINGBOARD:this.playingSession.onBoardCloseClick();break;case LobbyIds.TOPBLITZ_COUNTRY:if(!glSettings.inDialog()&&this.checkLogin()){var h=new LeaderboardRequest;h.setLevel(LBRequestLevel.LBRequestLevel_Country);this.getGeoLeaderboard(h)}break;case LobbyIds.TOPBLITZ_STATE:!glSettings.inDialog()&&this.checkLogin()&&(h=new LeaderboardRequest,h.setLevel(LBRequestLevel.LBRequestLevel_State),this.getGeoLeaderboard(h));break;case LobbyIds.TOPBLITZ_CITY:!glSettings.inDialog()&&
5536this.checkLogin()&&(h=new LeaderboardRequest,h.setLevel(LBRequestLevel.LBRequestLevel_City),this.getGeoLeaderboard(h));break;case LobbyIds.TOPBLITZ_FRIENDS:glSettings.inDialog()||this.checkLogin()&&this.getLeaderboardFriends();break;case LobbyIds.SHOW_STATISTICS:glSettings.inDialog()||this.requestStatistics();break;case LobbyIds.EDIT_FRIENDS:glSettings.inDialog()||this.checkLogin()&&this.requestFriends();break;case LobbyIds.EDIT_FOES:glSettings.inDialog()||this.checkLogin()&&this.requestFoes();break;
5537case LobbyIds.SEND_FEEDBACK:glSettings.inDialog();break;case LobbyIds.LOBBY_TEST:this.test();case LobbyIds.LOBBY_TEST2:}if(g){var k=LobbyIds.toNumString(f);LogStats(k)}return g}catch(l){k=LobbyIds.toNumString(f),LogException(k,l),this.statusMsg(k+": "+l)}return!1};a.prototype.testYesNo=function(f){LOG("YesNo="+f)};a.prototype.getWaitForServerMsg=function(){return lm.WAITING_CHESS_SERVER};a.prototype.onConnBroken=function(){this.watchSessions.onConnBroken();if(this.playingSession.active)this.playingSession.onConnBroken()};
5538a.prototype.onTextFieldChange=function(f,g){switch(f){case LobbyIds.WATCH_MAXBOARDS:this.watchSessions.setMaxSessions(g);break;case LobbyIds.WATCH_MOVEDELAY:this.watchSessions.delayGameActions(this.watchSessions.idSelectedGame,g)}};
5538a.prototype.onRegisterField=function(f,g){switch(f){case LobbyIds.WATCH_MAXBOARDS:this.watchSessions.maxField=g;break;case LobbyIds.WATCH_MOVEDELAY:this.watchSessions.moveDelayField=g}};a.prototype.manageAccount=function(){};a.prototype.requestElo=function(){var f=new WebSockMessage(SockMsgId.USER);
5539f.address(this.getNId(),ConnectId.SERVER);f.setVal(this.getNIdBound());f.setUserType(UserMsgId.REQUEST_ELODATA);this.send(f)};a.prototype.handleEloData=function(f){var g=new ServerEloResultData;g.fromDataBuf(f.getBuf());this.lists.requestUserNamesOfDBIds(g)};a.prototype.getMyElo=function(){return this.client?this.client.eloRating.getElo(ServerEloRating.BLITZ):0};a.prototype.handleConfirmRegistration=function(f){f.getBuf().rewind();(f=f.getBuf().V1c())&&this.statusMsg(lm.YOU_ARE_REGISTERED+": "+this.user+
5540".","LogBold");this.registered=f;glApp.Vn.storeRegisteredRoom(this.playingRoomId);console.log("Registered in "+this.playingRoomId);this.fireOnRegistered(this.registered);this.updatePlayerStatus();this.requestTournStandings()};a.prototype.handleFinishedTournament=function(){this.registered=!1};a.prototype.handleStandings=function(f){var g=new TournStandings;g.swissFromBuf(f.getBuf())&&(g.registered=this.registered,this.fireOnTournStandings(g))};a.prototype.handleAutoTournStandings=function(f){this.isAutoTourn=
5541!0;var g=new TournStandings;g.autoTournFromBuf(f.getBuf())&&(g.registered=this.registered,this.fireOnTournStandings(g))};a.prototype.handleAutoTournStarted=function(f){f.getVal()==this.playingRoomId&&(this.isAutoTourn=!0,f=f.getBuf().readInt(),this.finishTournTime=new CBTime(f))};a.prototype.handleAutoTournFinished=function(f){f.getVal()==this.playingRoomId&&(this.isAutoTourn=!1,this.fireOnTournFinished(),this.logIntoChat(lm.TOURNAMENT_FINISHED))};a.prototype.handleGroupHtmlChanged=function(f){var g=
5542f.getBuf().V19();f=f.getBuf().Vb(1E3);this.fireOnGroupHtml(f);if(g==this.idGroup){try{glApp.panelMgr.setBrowserUrl&&glApp.panelMgr.setBrowserUrl(f),glApp.panelMgr.setLiveGameBanner&&glApp.panelMgr.setLiveGameBanner(f)}catch(h){}self.focus()}};a.prototype.joinChannel=function(f){var g=new WebSockMessage(SockMsgId.JOINCHANNEL);g.getBuf().V13(1);g.getBuf().V13(f);g.address(this.conn.connectId,ConnectId.SERVER);this.send(g)};a.prototype.handleRespondCalendar=function(f){console.log("Respond Calendar")};
5543a.prototype.handleCalendarAdd=function(f){console.log("Add Calendar")};a.prototype.handleCalendarRmv=function(f){console.log("Rmv Calendar")};a.prototype.handlePayment=function(f){var g=f.getBuf();g.readInt();f=g.readInt();let h=g.Vb(100);g.V1a();g=g.readByte();let k=String.f("You have received a payment of {0}.{1} ducats",f,g);this.fireOnPayment({ducats:f,cents:g,title:h,text:k});this.logIntoChat(k,"chatPayment");this.logIntoChat(h,"chatPayment");glApp.panelMgr.signal(h,6E4)};a.prototype.requestTournCalendar=
5544function(){this.requestByUMsg(UserMsgId.REQUEST_CALENDAR)};a.prototype.requestTournStandings=function(){20<this.idGroup&&this.requestByUMsg(UserMsgId.REQUEST_STANDING,this.idGroup)};a.prototype.requestByUMsg=function(f,g){var h=new WebSockMessage(SockMsgId.USER);h.address(this.getNId(),ConnectId.SERVER);h.setUserType(f);h.setVal(g||0);this.send(h)};a.prototype.createLogonData=function(f,g){g?(f=new LogonData("Guest","Pass",LoginMode.GUEST,f,"","playchess"),StrUtil.getURLParam("beginner").length&&
5545f.setIsBeginner()):f=new LogonData(this.user,this.pass,LoginMode.NORMAL,f,glApp.Vn.loginToken,"playchess");this.logIntoChat("Version "+glApp.versionCode.toString());glApp.Vn.getTournRoom()?(f.strRoom=glApp.Vn.getTournRoom(),f.flags|=LoginFlags.JOIN_FIXED_ROOM):(f.strRoom=glApp.Vn.getRoom(),f.strRoomUrl=glApp.Vn.getRoomUrl());glApp.config.yes2Chess&&(f.flags|=LoginFlags.YES2CHESS);return f};a.prototype.modifyLoginData=function(f){f.documentUrl=document.URL};a.prototype.onIdReceived=function(){glApp.idleFunc=
5546this.onIdle.bind(this);glApp.notIdleFunc=this.onIdle.bind(this);this.idGroup=0};a.prototype.handleDefaultGroups=function(f){var g=void 0===this.playingRoomId;this.idBound=f.getBuf().V19();this.defaultRoomId=this.clubRoomId=f.getBuf().V19();this.broadcastRoomId=f.getBuf().V19();this.mainHallId=f.getBuf().V19();this.cafeId=f.getBuf().V19();this.cmsArchiveId=f.getBuf().V19();this.normalPlayingRoomId=this.playingRoomId=this.loginMode!==LoginMode.NORMAL?this.cafeId:this.mainHallId;if(this.clubRoomId==
5547this.cafeId||this.clubRoomId==this.mainHallId)this.clubRoomId=0;var h=f.getBuf().Vb(100);if(h)this.onLoginToken(h);h=f.getBuf().readDataBuffer();this.readHintResources(h);h=f.getBuf().Vb(100);f.getBuf().V19();f=0;if(glApp.Vn.getRoom().length||glApp.Vn.getTournRoom().length)f=parseInt(glApp.Vn.getRoomId()),0<f&&(this.clubRoomId=f),this.playingRoomId=this.clubRoomId,0<parseInt(glApp.Vn.getTournRoom())&&(glApp.Vn.storeTournRoom(h),this.fireOnGroupName(h));g?(0!=this.clubRoomId&&this.requestOneGroup(this.clubRoomId),
5548this.actOnUrlParams()||(glApp.isLiveGamesApp&&glApp.isLiveGamesApp()?this.watchSessions.watchLiveTournaments():glApp.isBoardOnlyApp()||(this.changeGroup(this.getIdPlayingGroup()),glAp
5548p.Vn.getRoom().length&&glApp.panelMgr.setLiveGameBanner&&glApp.panelMgr.setLiveGameBanner(glApp.Vn.getRoomUrl(),""))),this.requestTournCalendar(),this.autoRunOnLogin&&this.autoRunOnLogin()):glApp.isBoardOnlyApp()||(this.playingSession.onReLogin(),0<f?this.changeGroup(f):(this.changeGroupNoReconnectTimer=new Timer(function(){this.isInClubRoom()&&
5549this.playingSession.requestUnfinishedGame(this.idGroup);if(0==this.watchSessions.count())this.changeGroup(this.getIdPlayingGroup());else this.watchSessions.onReconnect()}.bind(this)),this.changeGroupNoReconnectTimer.runOnce(6E3)));!glApp.Vn.loginToken&&glApp.Vn.password&&glApp.Vn.loginMode==LoginMode.NORMAL&&(new Timer(function(){(new AccountsManager("playchess")).pwLogin(glApp.Vn.userName,glApp.Vn.password,function(k){if(k&&k.Token){var l=unescape(k.Token);glApp.showAccountType(k.HighestSubscr);
5550glApp.lobby.onLoginToken(l,k.userId)}}.bind(this))})).runOnce(100);this.boundLoginOk=!0;glApp.fireOnLogin(this.loginMode==LoginMode.NORMAL);this.fireOnDefaultGroups();if(this.onDefaultGroups&&g)this.onDefaultGroups()};a.prototype.joinEventHdl=function(){this.joinEvent()};a.prototype.onLoginToken=function(f,g){glApp.Vn.loginToken=f;glApp.Vn.rememberLoginToken();DOM.setAccountNameCookie(glApp.Vn.userName);DOM.setCookie("AccountMode",LoginMode.NORMAL);g&&DOM.setCodedCookie("AccountBackName64",g)};a.prototype.onChangeLogin=
5551function(){glApp.fireOnLogin(this.boundLoginOk)};a.prototype.actOnUrlParams=function(){if(this.urlParams&&this.urlParams.play){var f=ServerFormula.createFromSeekParams(this.urlParams.play);f&&this.isGuest()&&(f.eloMin=0);var g=new ClockParams,h=new ServerClockRange;ServerChallenge.fillClockFromSeekParams(g,h,this.urlParams.play);this.lists.changeToPlayingRoomAndSeek(g,f,h);return!0}return this.urlParams&&this.urlParams.kibitz?(glApp.panelMgr.toggleKibitzing(),!0):!1};a.prototype.handleGroupStatusChange=
5552function(f){var g=new GroupStatusChange;if(g.fromDataBuf(f.getBuf())){for(f=0;f<g.changes.length;f++)g.changes[f].idGroup==this.idGroup&&(this.nPlayersInGroup=g.changes[f].nPeople);if(this.onGroupStatusReceived)this.onGroupStatusReceived(g.changes[0].idGroup);this.fireOnGroupStatus(g.changes)}};a.prototype.logOff=function(f){this.client=this.playingRoomId=void 0;f||glApp.Vn.clearRoom();if(this.hasIdReceived)if(this.playingSession.active)this.playingSession.onLogOff();else this.watchSessions.endKibitzingAndLogOff()||
5553(f=new WebSockMessage(SockMsgId.LOGOFF),f.address(this.conn.connectId,ConnectId.SERVER),f.buf.V13(0),this.send(f));this.onLogOff()};a.prototype.changeLogin=function(){glApp.Vn&&glApp.Vn.prepareLoginChange&&glApp.Vn.prepareLoginChange();glApp.changeLobbyLogin()};a.prototype.onForcedLogOff=function(){this.playingSession.onForcedLogOff()};a.prototype.displayForceLogOffMsg=function(f){this.superClass.displayForceLogOffMsg.call(this,f);glApp.panelMgr.signal(f,6E4)};a.prototype.requestChannels=function(){var f=
5554new WebSockMessage(SockMsgId.REQUESTCHANNELS);f.address(this.getNId(),ConnectId.SERVER);this.send(f)};a.prototype.onMobileBlur=function(){this.lists&&(this.lists.cancelSeeks(),this.playingSession&&this.playingSession.isFinished()&&this.playingSession.hasGame()&&this.playingSession.sendWindowClosed())};a.prototype.onBlur=function(){this.seekBlockTimer=new Timer(function(){glApp.Vn.receiveSeeksAlways()&&this.lists.sendSeeksBlocked()}.bind(this));this.seekBlockTimer.runOnce(6E4)};a.prototype.onFocus=
5555function(){this.seekBlockTimer&&this.seekBlockTimer.stop();glApp.Vn.receiveSeeksAlways()&&this.lists.sendReceiveSeeksAlways()};var b=0,c=[];a.prototype.handleReceived=function(f){if(0<b)c.push(f);else for(b=f.getType(),this.doHandleReceived(f);c.length;)f=c.shift(),this.doHandleReceived(f);b=0};a.prototype.doHandleReceived=function(f){if(!this.handleReceivedByConnector(f))switch(f.getType()){default:TRACE("Unhandled: "+f.toString());break;case SockMsgId.BINDERTIMEOUT:this.handleBinderTimeout();break;
5556case SockMsgId.ALREADYLOGGEDON:this.statusMsg("Already logged on: "+this.user+". Please log off or wait a few minutes.","LogBold");this.clearLoginCookies();break;case SockMsgId.CHAT:this.handleChat(f);break;case SockMsgId.STARTTYPINGCHAT:break;case SockMsgId.DEFAULTGROUPS:this.handleDefaultGroups(f);break;case SockMsgId.GROUPSTATUSCHANGE:this.handleGroupStatusChange(f);break;case SockMsgId.CLIENTLIST:this.lists.handleClientList(f);break;case SockMsgId.ADDCLIENTS:this.lists.handleAddClients(f);break;
5557case SockMsgId.REMOVECLIENTS:this.lists.handleRemoveClients(f);break;case SockMsgId.CLIENTDATACHANGE:this.lists.handleClientDataChange(f);break;case SockMsgId.CLIENTDATACHANGELIST:this.lists.handleClientDataChangeList(f);break;case SockMsgId.RECONNECT_OK:this.handleReconnectOk(f);break;case SockMsgId.CLIENTPING:this.handleClientPing(f);break;case SockMsgId.CHANNELDATA:this.handleChannelData(f);break;case SockMsgId.CHANNELSTATUSCHANGE:break;case SockMsgId.SESSIONSTATUSCHANGELIST:break;case SockMsgId.USER:this.handleUserMsg(f);
5558break;case SockMsgId.BROADCASTURLS_DATA:this.handleBroadcastURLS(f);break;case SockMsgId.GETACTIVEHLSSTREAMS_REPLY:this.handleGetActiveHLSStreams(f);break;case SockMsgId.GEOLEADERBOARD_DATA:this.handleGeoLeaderboardData(f);break;case SockMsgId.STATISTICS_DATA:this.handleStatisticsData(f);break;case SockMsgId.GETFRIENDSLEADERBOARD_REPLY:this.handleLeaderboardFriends(f);break;case SockMsgId.GROUPHTMLCHANGED:this.handleGroupHtmlChanged(f);break;case SockMsgId.REQUESTBROADCASTURLSEX_DATA:this.handleBroadcastURLsEx(f);
5559break;case SockMsgId.GROUPSDATA:this.handleGroupsData(f);break;case SockMsgId.GETAGORAKEY_REPLY:this.handleAgoraKey(f);break;case SockMsgId.BLOCKVIDEO_REPLY:this.handleBlockVideo(f);break;case SockMsgId.MUTE_AUDIO_REPLY:this.handleMuteAudio(f);break;case SockMsgId.WMF_STREAM:this.handleWMFStream(f);break;case SockMsgId.TOGGLE_WMF_STREAM_REPLY:this.handleToggleWMFStream(f);break;case SockMsgId.GET_WMF_STATS_REPLY:this.handleWMFStats(f);break;case SockMsgId.REQUEST_AUTOTOURNAMENT_SERVICE_REPLY:this.handleRequestAutoTournamentReply(f);
5560break;case SockMsgId.TEST:this.handleTestData(f)}};var d=0;a.prototype.handleUserMsg=function(f){0<d&&LogException("Reenter handleUserMsg: ",d+"/"+f.getUserType());d=f.getUserType();try{switch(f.getUserType()){case UserMsgId.GAMELIST:this.lists.handleGameList(f);break;case UserMsgId.GAMESTATUS:var g=f.getBuf(),h=new ServerGameStatusChange;h.fromDataBuf(g);try{h.idGame==this.playingSession.idGame||0===h.idGame?this.playingSession.handleGameStatusChange(h,g):this.playingSession.handleGameStatusChangeBeforeStart(h)}catch(n){LOG("gs1: "+
5561n)}try{this.watchSessions.handleGameStatusChange(h)}catch(n){LOG("gs2: "+n)}try{this.lists.handleGameStatusChange(h)}catch(n){LOG("gs3: "+n)}break;case UserMsgId.ADDGAME:this.lists.handleAddGame(f);break;case UserMsgId.REMOVEGAME:this.lists.handleRemoveGame(f);break;case UserMsgId.CHALLENGE:this.lists.handleChallenge(f);break;case UserMsgId.STARTGAME:if(this.canStartGame()){let n=new ServerStartGameData;
5561n.fromDataBuf(f.getBuf())&&(this.registered=n.isTournament(),glApp.setIsInOfficialRoom(this.registered),
5562this.playingSession.startGame(n),this.fireOnGameStarted(n))}break;case UserMsgId.RESTARTGAME:this.joinEventTimer.stop();let l=new ServerStartGameData;l.fromDataBuf(f.getBuf())&&(this.registered=l.isTournament(),glApp.setIsInOfficialRoom(this.registered),this.playingSession.restartGame(l)||this.watchSessions.restartGame(l),this.fireOnGameStarted(l));break;case UserMsgId.RESTARTTOURNGAME:this.joinEventTimer.stop();let m=new ServerStartGameData;m.fromDataBuf(f.getBuf())&&(this.playingSession.restartTournGame(m,
5563f.getBuf()),this.fireOnGameStarted(m));break;case UserMsgId.GAME:var k=new ServerGameData;k.fromDataBuf(f.getBuf());this.playingSession.handleGame(k)||this.watchSessions.handleGame(k);break;case UserMsgId.SESSIONACTION:this.playingSession.active?this.playingSession.handleSessionAction(f):this.watchSessions.handleSessionAction(f);break;case UserMsgId.SETCLOCK:this.watchSessions.handleSetClock(f);break;case UserMsgId.TIME_PENALTY:this.playingSession.handleTimePenalty(f);break;case UserMsgId.RESPOND_BESTGAME:this.watchSessions.handleRespondBestGame(f);
5564break;case UserMsgId.ELODATA:this.handleEloData(f);break;case UserMsgId.CONFIRM_REGISTRATION:this.handleConfirmRegistration(f);break;case UserMsgId.TOURNAMENT_FINISHED:this.handleFinishedTournament(f);break;case UserMsgId.TOURNAMENT_STANDING:this.handleStandings(f);break;case UserMsgId.AUTOTOURN_STANDING:this.handleAutoTournStandings(f);break;case UserMsgId.AUTOTOURN_FINISHED:this.handleAutoTournFinished(f);break;case UserMsgId.AUTOTOURN_STARTED:this.handleAutoTournStarted(f);break;case UserMsgId.SETPICTURE:this.handleSetPicture(f);
5565break;case UserMsgId.NOTIFY_CLIENT:this.handleNotifyClient(f);break;case UserMsgId.TEMP_ELO:case UserMsgId.NEW_ELO:this.handleTempElo(f);break;case UserMsgId.RESPOND_VALIDATE_SEEKS:this.lists.handleValidSeekIds(f);break;case UserMsgId.FOLLOWEVENT:this.watchSessions.handleFollowEvent(f);break;case UserMsgId.RESPOND_ALL_SEEKS:this.lists.handleAllSeeks(f);break;case UserMsgId.SELECTED_CLIENTLIST:this.lists.handleSelectedClientList(f);break;case UserMsgId.RESPOND_OPPONENTS:this.lists.handleRespondOpponents(f);
5566break;case UserMsgId.RESPOND_FRIENDLIST:this.lists.handleFriendList(f);break;case UserMsgId.ANALYSIS_FOCUS:this.handleAnalysisFocus(f);break;case UserMsgId.START_CLOCK:case UserMsgId.STOP_CLOCK:case UserMsgId.ENTER_CLOCK:this.handleTeamCaptainMsg(f);break;case UserMsgId.RESPOND_CALENDAR:this.handleRespondCalendar(f);break;case UserMsgId.CALENDAR_ADD:this.handleCalendarAdd(f);break;case UserMsgId.CALENDAR_RMV:this.handleCalendarRmv(f);break;case UserMsgId.PAYMENTS_TRANSACTION:this.handlePayment(f);
5567break;case UserMsgId.BROADCASTSTARTED:this.handleStartBroadcast(f);break;case UserMsgId.BROADCASTENDED:this.handleEndBroadcast(f)}}catch(l){f=UserMsgId.toNumString(f.getUserType()),"undefined"!==typeof ga&&ga("send","event","Catch",f+", "+l),LogException(f,l,Error.stack?new Error.stack:null)}d=0};a.prototype.onKickedOutOtherMachine=function(){this.statusMsg(this.user+": You have been logged off on another browser/machine","LogGreen");this.superClass.onKickedOutOtherMachine.apply(this,arguments)};
5568a.prototype.onLoginOtherMachine=function(){this.statusMsg(this.user+": You logged in successfully from another browser/machine","LogRed");this.superClass.onLoginOtherMachine.apply(this,arguments)};a.prototype.playingInTournament=function(){return glApp.isInOfficialTournament()&&!this.playingSession.isFinished()};a.prototype.getUserPic=function(f){var g=new WebSockMessage(SockMsgId.USER);g.address(this.getNId(),ConnectId.SERVER);g.getBuf().Va(f);g.setUserType(UserMsgId.GETPICTURE);this.send(g)};a.WebBroadcastTitle=
5569"Web Broadcast";a.prototype.startBroadcast=function(){var f=new WebSockMessage(SockMsgId.USER);f.address(this.getNId(),ConnectId.SERVER);var g=new ServerStartBroadcastData;g.idChairman=this.getNIdBound();g.idGroup=this.idGroup;g.strWhite=glApp.Vn.userName;g.strBlack=a.WebBroadcastTitle;var h=f.getBuf();g.V17(h);f.setUserType(UserMsgId.STARTBROADCAST);this.send(f)};a.prototype.sendMovesForAll=function(){for(var f in this.lists.clientMap)this.lists.clientMap[f]&&this.lists.clientMap.hasOwnProperty(f)&&
5570this.sendAnalysisFocus(this.watchSessions.idBroadcast,17,parseInt(f))};a.prototype.sendAnalysisFocus=function(f,g,h){var k=new WebSockMessage(SockMsgId.USER);k.address(this.getNId(),ConnectId.SERVER);var l=k.getBuf();l.writeShort(g);l.writeInt(this.getNId());l.writeInt(this.getNId());l.writeInt(h||0);l.writeInt(0);l.writeInt(0);k.setVal(f);k.setUserType(UserMsgId.ANALYSIS_FOCUS);this.send(k)};a.prototype.requestAutoTournament=function(f){var g=new WebSockMessage(SockMsgId.REQUEST_AUTOTOURNAMENT_SERVICE);
5571g.address(this.getNId(),ConnectId.SERVER);var h=g.getBuf();h.Va("jeroen");h.writeInt(this.idGroup);(new ClockParams(3,2)).V17(h);h.writeInt(f);h.writeInt(2);f=this.lists.buildClientList();h.writeInt(f.length);for(var k=0;k<f.length;k++)h.Vr(f[k].strName);this.send(g)};a.prototype.handleRequestAutoTournamentReply=function(f){f.getBuf().V1c()?this.statusMsg("AutoTournament start ok"):this.statusMsg("AutoTournament not available at the moment")};a.prototype.handleStartBroadcast=function(f){var g=new ServerStartBroadcastData;
5572g.fromDataBuf(f.getBuf());g.idChairman==this.getNIdBound()&&this.watchSessions.handleBroadcast(g)};a.prototype.stopBroadcast=function(){var f=new WebSockMessage(SockMsgId.USER);f.address(this.getNId(),ConnectId.SERVER);f.setVal(this.watchSessions.idBroadcast);f.setUserType(UserMsgId.ENDBROADCAST);this.send(f);return this.watchSessions.idBroadcast};a.prototype.handleEndBroadcast=function(f){};a.prototype.handleSetPicture=function(f){};a.prototype.handleNotifyClient=function(f){switch(f.getVal()){case ServerNotifyId.N_SEEK_MATCHES:f=
5573f.getBuf().readInt();glApp.panelMgr.signalWaitingForSeek(f);break;case ServerNotifyId.CLAIM_WIN_REJECTED:glApp.panelMgr.signalOpponentStillOnline();break;case ServerNotifyId.CLAIM_WIN_ACCEPTED:f=f.getBuf().readInt();this.playingSession.onMyClaimOk(f);break;case ServerNotifyId.CLIENT_NOT_RESPONDING:case ServerNotifyId.CLIENT_DISCONNECTED:case ServerNotifyId.CLIENT_CONNQUAL:case ServerNotifyId.CLIENT_OFFLINE:this.handleNotifyClientConnQual(f);break;case ServerNotifyId.CLAIM_GAME_DECIDED:this.statusMsg("Arbiter - Game finished!?");
5574break;case ServerNotifyId.OPPONENT_CLAIM_OK:this.playingSession.onOpponentClaimOk(f.getBuf());break;case ServerNotifyId.INFORMAL_APPLAUSE_RECEIVED:case ServerNotifyId.APPLAUSE_RECEIVED:glApp.chessAudio.onIndividualApplause();break;case ServerNotifyId.WELCOME:this.handleWelcome(f);break;case ServerNotifyId.OPPONENT_PLAYS_ANOTHER_GAME:this.handlePlaysAnotherGame(f);this.lists.removeAcceptedChallenge();break;case ServerNotifyId.NOT_IN_SAME_ROOM:this.lists.removeAcceptedChallenge()}};a.prototype.handlePlaysAnotherGame=
5575function(f){var g=new ServerClientChange;g.init(f.Vo());g.setIsPlaying();this.fireOnClientChanges([g])};a.prototype.handleWelcome=function(f){var g=f.getBuf().readInt();f=f.getBuf().Vb(100);this.logIntoChat(g+" users, "+f);glApp.panelMgr.signalWelcome(g);this.fireOnUsers(g)};a.prototype.handleTempElo=function(f){var g=f.getBuf().readInt(),h=f.getBuf().readInt();5E3<h&&(h=g);f.getBuf().readInt();this.fireOnNewElo({elo:g,old:h})};a.prototype.handleEnterClock=function(f){var g=new TeamCaptainEnterClock;
5576g.fromDataBuf(f.buf());this.playingSession.enterClock(g)};a.prototype.handleAnalysisFocus=function(f){var g=f.getBuf().V1a();this.watchSessions.handleAnalysisFocus(g,f.getVal())};a.prototype.handleTeamCaptainMsg=function(f){var g=new TeamCaptainEnterClock;g.fromDataBuf(f.getBuf());switch(f.getUserType()){case UserMsgId.STOP_CLOCK:this.playingSession.stopClock(g)||this.watchSessions.stopClock(g);break;case UserMsgId.START_CLOCK:this.playingSession.startClock(g)||this.watchSessions.startClock(g);break;
5577case UserMsgId.ENTER_CLOCK:this.playingSession.enterClock(g)||this.watchSessions.enterClock(g)}};a.prototype.canStartGame=function(){return!this.watchSessions.inRequestBestGame};a.prototype.handleChat=function(f){var g=new ChatData;g.fromSocketsMsg(f);var h=f.Vo();if(g.isToSession()&&h!=this.playingSession.idOpponent){if(this.watchSessions.getTitleOfSession){if(f=this.watchSessions.getTitleOfSession(g.getIdSession()))g.strMsg="("+f+"): "+g.strMsg;glApp.panelMgr.chatOut(g)}}else g.isOpponentChat=h==
5578this.playingSession.idOpponent,glApp.panelMgr.chatOut(g),f.Vo()!=ConnectId.SERVER&&this.playingSession.idOpponent!=h||this.playingSession.chatOut(g)};a.prototype.sendChat=function(f,g,h){var k=new ChatData;k.strMsg=f;k.setToIndividuals(!0);k.idSender=this.getNIdBound();k.setReceivers(g);k.setAutomatic(!0);0<parseInt(h)&&(k.token=parseInt(h));f=k.Vi();f.address(this.getNId(),g);this.send(f)};a.prototype.sendToChannel=function(f,g,h){this.rankOkForChat()&&(f=new ChatData,f.strMsg=g,f.setChannel(h),
5579f.idSender=this.getNIdBound(),f.eColName=ChatData.YELLOW,g=f.Vi(),g.address(this.getNId(),ConnectId.SERVER),this.send(g))};a.prototype.sendGameChat=function(f,g){if(this.rankOkForChat()){var h=new ChatData;h.strMsg=f;h.setToSession(!0);h.setToObservers(!0);h.setIdSession(g);h.eColName=14;f=h.Vi();f.address(this.getNId(),ConnectId.SERVER);this.send(f)}};a.prototype.chatToEventDirector=function(f,g){var h=this.lists.getEventDirectorId();h?this.sendChat(f,h):(this.lists.requestSelectedClientList(),this.lists.fnOnClientList=
5580function(){var k=this.lists.getEventDirectorId();k?this.sendChat(f,k):(this.logIntoChat(lm.NO_TD_PRESENT,"chatWarn"),g&&g())}.bind(this))};a.prototype.joinEvent=function(f){this.chatToEventDirector("Please register me",f);this.updatePlayerStatus(ServerStatusEnum.APPLYING)};a.prototype.leaveEvent=function(){this.chatToEventDirector("I want to leave, please.");this.updatePlayerStatus(ServerStatusEnum.UNAPPLYING)};a.prototype.rankOkForChat=function(){if(this.client){var f=new ServerRank;f.fromCompressed(this.client.nRank);
5581var g=glApp.config.minChatRank&&f.rank>=glApp.config.minChatRank;g||(0<f.rank?this.logIntoChat("Sorry, you can only listen to chat here.","LogError"):this.logIntoChat(lm.GUESTS_CANNOT_CHAT,"LogError"));return g}return!1};a.prototype.sendToChannel=function(f,g,h){this.rankOkForChat()&&(f=new ChatData,f.strMsg=g,f.setChannel(h),f.idSender=this.getNIdBound(),f.eColName=ChatData.YELLOW,g=f.Vi(),g.address(this.getNId(),ConnectId.SERVER),this.send(g))};a.prototype.sendToWholeRoom=function(f,g){this.rankOkForChat()&&
5582this.isInClubRoom()&&(f=new ChatData,f.strMsg=g,f.setToGroup(!0),f.setChannel(this.clubRoomId),f.idSender=this.getNIdBound(),f.eColName=ChatData.YELLOW,g=f.Vi(),g.address(this.getNId(),ConnectId.SERVER),this.send(g))};a.prototype.handleChannelData=function(f){var g=new ChannelData;g.fromSocketsMsg(f);this.fireOnChannelData(g)};a.prototype.sendGeoPos=function(f){var g=new WebSockMessage(SockMsgId.USER);g.setUserType(UserMsgId.SETGEOPOS);g.getBuf();
5582f.V17(g.getBuf());this.send(g)};a.prototype.handleReconnectOk=
5583function(f){this.inReconnect=!0;this.changeGroupNoReconnectTimer&&(this.changeGroupNoReconnectTimer.stop(),delete this.changeGroupNoReconnectTimer);var g=f.getBuf().readInt();f=f.getBuf().V1c();g!=this.idGroup&&this.changeGroup(g);this.statusMsg(lm.RECONNECTED_OK,"LogBold");f&&this.logIntoChat("Took over from another session.");if(!this.playingSession.onReconnect(f))this.watchSessions.onReconnect();navigator.connection&&navigator.connection.effectiveType&&this.logIntoChat("Network="+navigator.connection.effectiveType);
5584this.inReconnect=!1};a.prototype.handleBinderTimeout=function(){this.silentServerPing||(this.statusMsg("Sorry, cannot reach the server. Please try again in 15 minutes.","LogBold"),this.playingSession.statusMsg("Sorry, cannot reach the server."),this.clearLoginCookies(),this.loginMode=LoginMode.GUEST,this.conn.close())};a.prototype.getConnTimeOutMS=function(){return this.playingSession.active?this.playingSession.isSlow()?1E4:6E3:2E4};a.prototype.getMaxConnSilenceMS=function(){5;return this.playingSession.active?
55856E3:glApp.isBoardOnlyApp()||glApp.Vn.noRibbons()?18E5:3E4};a.prototype.getConnTimeOutMS=function(){return this.playingSession.active?4E3:6E3};a.prototype.handleClientPing=function(f){this.superClass.handleClientPing.call(this,f);var g=f.getBuf().readInt();f=f.getBuf().readInt();this.playingSession.handleClientPing(g,f)};a.prototype.handleBroadcastURLsEx=function(f){var g=new BroadcastStreamingDataEx;g.fromDataBuf(f.getBuf());1==f.getBuf().V19()?glApp.panelMgr.reportBroadcastStreamingData(g):alert("You need to upgrade your membership")};
5586a.prototype.getLiveStreams=function(f,g){this.idRadio=f;this.idTourn=g;CBAJAX.load("https://videos.chessbase.com/live/getlivestreams",this.onGetLiveStreams.bind(this),{responseType:"text"})};a.prototype.onGetLiveStreams=function(f){f=JSON.parse(f);for(var g=[],h=0;h<f.results.length;h++)if(-1==f.results[h].Channel){if(f.results[h].GameId==this.idRadio){for(var k=f.results[h].URL,l=f.results[h].StreamId,m=0;m<k.length;m++)"/"==k[m]&&k.substring(0,m);f.results[h].Private||(this.watchSessions.delayGameActions(f.results[h].GameId,
55871),g.push(l))}}else f.results[h].GameId==this.idRadio&&(glApp.panelMgr.addRadioPanel(this.watchSessions,MediaPlayerType.MediaPlayerUnknown),this.getActiveHLSStreams(this.idRadio));0<g.length&&glApp.panelMgr.addLiveRadioPanel(this.watchSessions,null,g)};a.prototype.handleBroadcastURLS=function(f){var g=f.getBuf().readInt();f.getBuf().V1c();var h=new PubPointData;h.fromDataBuf(f.getBuf());glApp.panelMgr.changeRadioURL(h,g);if(!h.isHTTPStream())for(f=0;f<this.broadcastInfo.length;f++)this.broadcastInfo[f].name==
5588h.strPubPoint&&(g=new HLSData,g.strPubPoint=this.broadcastInfo[f].name,g.sChannel=this.broadcastInfo[f].tourn,glApp.panelMgr.reportChannel(g))};a.prototype.isPremium=function(){if(this.client&&"undefined"!=typeof this.client.nRank){var f=new ServerRank;f.fromCompressed(this.client.nRank);return f.isPremium()}};a.prototype.checkLogin=function(){if(!this.isGuest())return!0;this.changeLogin();return!1};a.prototype.setPubPoint=function(f,g){this.pubPoint=f;this.getAzureLiveStreams()};a.prototype.getActiveHLSStreams=
5589function(f){this.idGameMultiMedia=f;f=new WebSockMessage(SockMsgId.GETACTIVEHLSSTREAMS);f.address(this.conn.connectId,ConnectId.SERVER);this.send(f)};a.prototype.handleGetActiveHLSStreams=function(f){var g=f.getBuf().Vw();this.broadcastInfo=[];if(1==g){var h=new HLSData;h.fromDataBuf(f.getBuf());h=new BroadcastPair(-1,h.strPubPoint,h.sChannel);this.broadcastInfo.push(h)}else for(var k=0;k<g;k++)if(h=new HLSData,h.fromDataBuf(f.getBuf()),this.pubPoint==h.strPubPoint||this.pubPoint.indexOf(-1<h.strPubPoint))h=
5590new BroadcastPair(-1,h.strPubPoint,h.sChannel),this.broadcastInfo.push(h);0<this.broadcastInfo.length?this.requestStreams(this.broadcastInfo):alert("For live broadcasts you need to login with your premium account")};a.prototype.requestStreams=function(f){0<f.length&&(this.requestBroadcastURL(this.idGameMultiMedia),this.requestBroadcastURLEx(this.idGameMultiMedia,StreamingItemType.GAMEACTIONS|StreamingItemType.WMV|StreamingItemType.SMOOTHSTREAMING|StreamingItemType.HLSV3|StreamingItemType.HLSV4|StreamingItemType.MP4))};
5591a.prototype.getGeoLeaderboard=function(f){var g=new WebSockMessage(SockMsgId.GETGEOLEADERBOARD);f.setType(LBRequestType.LBRequestType_User);f.setUser(this.user);f.setSubType(2);var h=new DataBuffer;f.V9(h);this.writeBufferToMsg(g,h);
5591g.address(this.conn.connectId,ConnectId.SERVER);this.send(g)};a.prototype.handleGeoLeaderboardData=function(f){for(var g=new DataBuffer,h=f.getBuf().Vw(),k=0;k<h;k++){var l=f.getBuf().readByte();g.writeByte(l)}g.rewind();f=new LeaderboardRequest;h=new Leaderboard;f.V7(g);
5592h.V7(g)};a.prototype.getLeaderboardFriends=function(f){f=new WebSockMessage(SockMsgId.GETFRIENDSLEADERBOARD);var g=new DataBuffer;g.V13(2);g.V13(0);g.Vr(this.user);this.writeBufferToMsg(f,g);f.address(this.conn.connectId,ConnectId.SERVER);this.send(f)};a.prototype.handleLeaderboardFriends=function(f){for(var g=new DataBuffer,h=f.getBuf().Vw(),k=0;k<h;k++){var l=f.getBuf().readByte();g.writeByte(l)}g.rewind();g.V19(0);(new Leaderboard).V7(g)};a.prototype.handleGroupsData=function(f){var g=f.getBuf().Vw(),
5593h=f.getBuf().Vw();f.getBuf().Vw();for(var k=[],l=0;l<g;l++){var m=new ServerGroup;m.V7(f.getBuf());k.push(m);1==g&&(m.isOfficial()||this.isInClubRoom())&&(glApp.setIsInOfficialRoom(m.isOfficial()),this.playingSession.requestUnfinishedGame(m.nId),this.groupName=m.strTitle,m.strUrl&&this.fireOnGroupUrl(m.strUrl),this.nameUnknown&&(this.nameUnknown=!1,this.fireOnGroupName(this.groupName)));(this.isInClubRoom()||m.isTournamentRoom())&&glApp.lobby.requestTournStandings()}this.lists.onGroupList(h,k)};a.prototype.isGameWithTakeback=
5594function(){return this.playingSession.startGameData.isRated()?glApp.isInOfficialTournament():!0};a.prototype.requestAgoraKey=function(f){var g=new WebSockMessage(SockMsgId.GETAGORAKEY);g.address(this.conn.connectId,ConnectId.SERVER);g.getBuf().V13(f);this.send(g)};a.prototype.handleAgoraKey=function(f){var g=f.getBuf().V12(512);f=f.getBuf().V12(512);this.fireOnAgoraKey(g,f)};a.prototype.handleWMFStream=function(f){var g=new MFStreamData;g.fromDataBuf(f.getBuf());this.fireOnMFStream(g)};a.prototype.sendWMFCommand=
5595function(f){var g=new WebSockMessage(SockMsgId.TOGGLE_WMF_STREAM);g.address(this.conn.connectId,ConnectId.SERVER);f.writeDataBuf(g.getBuf());this.send(g)};a.prototype.handleToggleWMFStream=function(f){var g=f.getBuf().Vw(),h=f.getBuf().Vw();f=f.getBuf().V12(512);this.fireOnMFStreamCommand(g,h,f)};a.prototype.getWMFStats=function(){var f=new WebSockMessage(SockMsgId.GET_WMF_STATS);f.address(this.conn.connectId,ConnectId.SERVER);this.send(f)};a.prototype.handleWMFStats=function(f){for(var g=f.getBuf().Vw(),
5596h=[],k=0;k<g;k++){var l=new MFStreamStats;l.fromDataBuf(f.getBuf());h.push(l)}this.fireOnMFStreamStats(h)};a.prototype.requestBlockVideo=function(f){var g=new WebSockMessage(SockMsgId.BLOCKVIDEO);g.address(this.conn.connectId,ConnectId.SERVER);g.getBuf().Vr(f);this.send(g)};a.prototype.handleBlockVideo=function(f){f=f.getBuf().V12(512);this.fireOnVideoBlock(f)};a.prototype.handleMuteVideo=function(f){f=f.getBuf().V12(512);this.fireOnAudioMute(f)};a.prototype.requestStatistics=function(){var f=new WebSockMessage(SockMsgId.REQUEST_STATISTICS);
5597f.address(this.conn.connectId,ConnectId.SERVER);this.send(f)};a.prototype.handleStatisticsData=function(f){(new StatisticsData).read(f.getBuf())};a.prototype.writeBufferToMsg=function(f,g){var h=g.getSize();f.buf.Vu(h);g.rewind();for(var k=0;k<h;k++){var l=g.readByte();f.buf.writeByte(l)}};a.prototype.writeUtf8UserAndCodePage=function(f){var g=this.user;StrUtil.hasASCIIgreater127(g)&&!StrUtil.mayBeUtf8(g)&&(g=StrUtil.encodeUTF8(g));f.Va(g);f.writeInt(System.getWindowsCodePage())};a.prototype.changeGroup=
5598function(f,g){if(f){this.idGroup=f;var h=new WebSockMessage(SockMsgId.CHANGEGROUP);h.setVal(f);this.send(h);this.fireOnSwitchGroups(g?g:this.getRoomType())}};a.prototype.gotoDefaultPlayingGroup=function(){this.playingRoomId=this.loginMode==LoginMode.NORMAL?this.mainHallId:this.cafeId?this.cafeId:14;this.lists.bFilterClientList=!0;this.changeToPlayingRoom()};a.prototype.gotoClubRoom=function(f){this.playingRoomId=this.clubRoomId;this.lists.bFilterClientList=!1;this.changeToPlayingRoom(f)};a.prototype.isInSpecialRoom=
5599function(){return this.isInClubRoom()};a.prototype.isInClubRoom=function(){return this.playingRoomId===this.clubRoomId};a.prototype.changeToPlayingRoom=function(f){return this.idGroup!=this.getIdPlayingGroup()||f?(this.changeGroup(this.getIdPlayingGroup()),!0):!1};a.prototype.changeToClubRoomOfId=function(f){this.lists.bFilterClientList=!1;this.clubRoomId=f;this.gotoClubRoom(!0);this.nameUnknown=!0;this.requestOneGroup(this.clubRoomId)};a.prototype.changeToPlayingRoomOfId=function(f){return this.idGroup!=
5600f?(this.lists.bFilterClientList=!0,this.playingRoomId=f,this.changeGroup(f),this.requestOneGroup(f),this.lists.requestSelectedClientList(),!0):!1};a.prototype.registeredInEvent=function(){return this.registered};a.prototype.changeToUnratedRoom=function(){return this.idGroup!=this.cafeId?(this.changeGroup(this.cafeId),!0):!1};a.prototype.toggleClubRoom=function(){this.isInClubRoom()?this.gotoDefaultPlayingGroup():this.gotoClubRoom();this.lists.requestSelectedClientList()};a.prototype.getIdPlayingGroup=
5601function(){return this.playingRoomId};a.prototype.getRoomType=function(){return this.idGroup==this.broadcastRoomId?ServerGroupType.BROADCASTS:ServerGroupType.PLAYING};a.prototype.pingAll=function(){this.pingServer(!1,5E3,!0);this.playingSession&&(this.playingSession.pingOpponent(),this.playingSession.pingMyself())};a.prototype.handleClientEcho=function(f){var g=this.superClass.handleClientEcho.apply(this,arguments);this.fireOnClientEcho({id:f.Vo(),ping:g})};a.prototype.handleRespondPingByName=function(f){var g=
5602f.getBuf().Vb(200);(f=f.getBuf().readInt())&&(this.lists.clientNameMap[f]=g);this.fireOnPingName({name:g,id:f})};a.prototype.detPlayerStatus=function(){var f=this.playingSession.active?ServerStatusEnum.PLAYER:this.watchSessions.length?ServerStatusEnum.WATCHER:ServerStatusEnum.STANDING;this.lists.isSeeking()&&(f|=ServerStatusEnum.SEEKING);f=glApp.isIdle()?f|ServerStatusEnum.IDLE:f|ServerStatusEnum.NOTIDLE;
5602this.registered&&(f|=ServerStatusEnum.REGISTERED);return new ServerStatus(f)};a.prototype.updatePlayerStatus=
5603function(f){var g=0;if(this.hasIdReceived){var h=new ServerClientChange;g=this.detPlayerStatus().flags;f&&(g|=f);h.setStatusChange(g);h.id=this.getNIdBound();f=new WebSockMessage(SockMsgId.CLIENTDATACHANGE);h.V17(f.getBuf());f.address(this.getNId(),ConnectId.SERVER);this.send(f);this.fireOnClientChanges([h])}return g};a.prototype.sendGameStatusChange=function(f,g){var h=new WebSockMessage(SockMsgId.USER);h.setUserType(UserMsgId.GAMESTATUS);var k=h.getBuf();h.setVal(f.type);f.V17(k);g&&h.setIdReceiver(g);
5604this.send(h)};a.prototype.sendEvaluation=function(f,g){var h=new WebSockMessage(SockMsgId.USER);h.setUserType(UserMsgId.PLAYEREVALUTION);f.V17(h.getBuf());g&&h.setIdReceiver(g);this.send(h)};a.prototype.requestBroadcastURL=function(f){var g=new WebSockMessage(SockMsgId.GETBROADCASTURLS);g.getBuf().V13(f);g.address(this.getNId(),ConnectId.SERVER);this.send(g)};a.prototype.requestAuthorization=function(){(new AccountsManager("videos")).pwLogin(this.user,this.pass,this.handleToken.bind(this))};a.prototype.deleteGame=
5605function(f){var g=new WebSockMessage(SockMsgId.USER);g.setUserType(UserMsgId.DELETEGAMES);g.getBuf().V13(1);g.getBuf().V13(f);this.send(g)};a.prototype.sendGame=function(){this.watchSessions.getCurSession().transmitGame()};a.prototype.handleNotifyClientConnQual=function(f){var g=f.getBuf().V19(),h=f.getBuf().V12(200),k=f.getBuf().V19();g=new ServerConnQuality(g);k==this.getNIdBound()&&(this.connQuality=g);if(this.playingSession.onClientConnQual)this.playingSession.onClientConnQual(k,g,f.getVal());
5606this.fireOnClientConnQual({qual:this.connQuality,id:k,notify:f.getVal(),name:h})};a.prototype.handleToken=function(f){if(f&&f.Token){f=unescape(f.Token);var g=new WebSockMessage(SockMsgId.REQUESTBROADCASTURLSEX);g.getBuf().V13(this.idStreamingGame);g.getBuf().V13(this.nStreamTypes);g.getBuf().Vr(f);g.address(this.getNId(),ConnectId.SERVER);this.send(g)}};a.prototype.requestBroadcastURLEx=function(f,g){this.idStreamingGame=f;this.nStreamTypes=g;this.requestAuthorization()};a.prototype.requestGroups=
5607function(f){var g=new WebSockMessage(SockMsgId.REQUESTGROUPS);g.address(this.getNId(),ConnectId.SERVER);g.nVal=f;this.send(g)};a.prototype.requestOneGroup=function(f){var g=new WebSockMessage(SockMsgId.REQUESTONEGROUP);g.address(this.getNId(),ConnectId.SERVER);g.nVal=f;this.send(g)};a.prototype.gotoLobby=function(){this.idGroup!=this.getIdPlayingGroup()?this.changeGroup(this.getIdPlayingGroup()):this.watchSessions.closeAllGames();glApp.panelMgr.deleteRadioPanel();glApp.panelMgr.setLobbyLayout()};
5608a.prototype.followBestGame=function(){this.followPlayer(0)};a.prototype.followPlayer=function(f){console.log("Follow:"+f);var g=new WebSockMessage(SockMsgId.USER);g.address(this.getNId(),ConnectId.SERVER);g.setVal(this.groupId);g.getBuf().V13(f);g.setUserType(UserMsgId.FOLLOW);this.send(g)};a.prototype.stopFollowing=function(){console.log("Stop Following");var f=new WebSockMessage(SockMsgId.USER);f.address(this.getNId(),ConnectId.SERVER);f.setUserType(UserMsgId.STOPFOLLOW);this.send(f)};a.prototype.sendApplause=
5609function(f,g){this.isGuest()?(g=new WebSockMessage(SockMsgId.USER),g.setUserType(UserMsgId.INFORMALAPPLAUSE),g.getBuf().V13(f),this.send(g),glApp.panelMgr.signalGuestApplauseSent()):(g=new ServerPlayerEvaluation(g),g.gameApplause=1,this.sendEvaluation(g,f),glApp.panelMgr.signalApplauseSent())};a.prototype.readHintResources=function(f){f.Vc();this.hintResources={};this.hintResources.availHints=f.V19()||3;this.hintResources.availThreats=f.V19()||3;this.hintResources.availAssists=f.V19()||3;this.hintResources.availFifty=
5610f.V19()||3;this.hintResources.availSpies=f.V19()||3;this.hintResources.availBook=f.V19()||3;this.hintResources.nGamesToday=f.V19()||0;f.Vm()};var e=!1;a.prototype.onIdle=function(){glApp.isIdle()!=e&&(this.updatePlayerStatus(),e=glApp.isIdle())};a.prototype.disconnectNoLogoff=function(){this.conn.close()};a.prototype.test=function(){this.logIntoChat("CONN BREAK");this.statusMsg("CONN BREAK");console.log("CONN BREAK");this.conn.breakForTesting()};a.prototype.pingPlayer=function(f){this.superClass.pingPlayer.call(this,
5611f)};a.prototype.handleAreYouAlive=function(f){var g=f.getBuf().readInt();g&&this.fireOnUsers(g);this.superClass.handleAreYouAlive.apply(this,f)};a.prototype.handleServerIsAlive=function(f){var g=f.getBuf().readInt();g&&this.fireOnUsers(g);this.superClass.handleServerIsAlive.apply(this,f);this.statusMsg("Server ok")};a.prototype.onServerNotAlive=function(f){this.fireOnServerNotAlive(f);1<++this.notAlive&&(this.statusMsg(String.f("Server not responding {0}",this.notAlive)),glApp.panelMgr.signalDisconnect())};
5612a.prototype.onServerAlive=function(f){this.fireOnServerAlive(f);this.notAlive=0};a.prototype.continuousSelfPingTest=function(){this.repeatPing=1E4;this.pingCntAbove2000=this.pingCntAbove1000=this.pingMax=this.pingSum=this.pingCount=0;this.pingPlayer(this.idBound)};a.prototype.handleContinuousSelfEcho=function(f){};a.prototype.test3=function(){(new ActivityManager(this.user,this.pass)).getActivity(1,this.acthandle)};a.prototype.hasSockMsgIds=function(){return!0};a.prototype.hasSockCheckSum=function(){return!0};
5613a.prototype.acthandle=function(f,g){};a.prototype.onDisconnectAlarm=function(){if(this.playingSession.active)glApp.chessAudio.onDisconnect()};a.prototype.sendRandomMessage=function(){for(var f=0;10>f;f++)switch(Math.floor(15*Math.random())){case 0:this.pingServer();break;case 1:this.changeGroup(13);break;case 2:this.changeGroup(14);break;case 3:this.requestChannels();break;case 4:this.updatePlayerStatus();break;case 5:this.lists.requestGameList(!0);break;case 6:this.lists.sendSeek(new ClockParams(3,
56142));break;case 7:this.lists.onShowPlayers();this.lists.onHideGames();break;case 8:this.lists.onShowGames();this.lists.onHidePlayers();break;case 9:case 10:case 11:case 12:var g=new WebSockMessage(7E3+Math.floor(100*Math.random()));g.address(this.getNId(),ConnectId.SERVER);g.getType()!=SockMsgId.LOGOFF&&g.getType()!=SockMsgId.LOGON&&this.send(g);break;case 13:case 14:g=new WebSockMessage(SockMsgId.USER),g.setUserType(1E3+Math.floor(100*Math.random())),g.address(this.getNId(),ConnectId.SERVER),this.send(g)}};
5615a.prototype.initForListeners=function(){a.prototype.fireEvent||(Vk.initForListeners(a),Vk.addEvent(a,"PlayersAdded"),Vk.addEvent(a,"PlayersRemoved"),Vk.addEvent(a,"ClientChanges"),Vk.addEvent(a,"ListStatus"),Vk.addEvent(a,"ClearClients"),Vk.addEvent(a,"GameList"),Vk.addEvent(a,"GamesAdded"),Vk.addEvent(a,"GameRemoved"),Vk.addEvent(a,"GameChange"),Vk.addEvent(a,"GameStarted"),Vk.addEvent(a,"SwitchGroups"),Vk.addEvent(a,"ChallengesAdded"),Vk.addEvent(a,"ChallengeChanged"),Vk.addEvent(a,"ChallengeRemoved"),
5616Vk.addEvent(a,"UserPic"),Vk.addEvent(a,"UserInfo"),Vk.addEvent(a,"UserRating"),Vk.addEvent(a,"ServerNotAlive"),Vk.addEvent(a,"ServerAlive"),Vk.addEvent(a,"NewElo"),Vk.addEvent(a,"LocalClient"),Vk.addEvent(a,"ClientEcho"),Vk.addEvent(a,"ClientConnQual"),Vk.addEvent(a,"Formula"),Vk.addEvent(a,"ValidSeeks"),Vk.addEvent(a,"ChannelData"),Vk.addEvent(a,"Users"),Vk.addEvent(a,"DefaultGroups"),Vk.addEvent(a,"SelectedClients"),Vk.addEvent(a,"Opponents"),Vk.addEvent(a,"PingName"),Vk.addEvent(a,"Friends"),Vk.addEvent(a,
5617"GroupStatus"),Vk.addEvent(a,"GroupHtml"),Vk.addEvent(a,"GroupName"),Vk.addEvent(a,"GroupUrl"),Vk.addEvent(a,"TournStandings"),Vk.addEvent(a,"AgoraKey"),Vk.addEvent(a,"VideoBlock"),Vk.addEvent(a,"AudioMute"),Vk.addEvent(a,"Registered"),Vk.addEvent(a,"TournFinished"),Vk.addEvent(a,"MFStream"),Vk.addEvent(a,"MFStreamCommand"),Vk.addEvent(a,"MFStreamStats"),Vk.addEvent(a,"Payment"),Vk.addEvent(a,"StartBroadcast"))};return a}(),LobbyIds={NONE:0,PING_SERVER:1E3,FOLLOW_BESTGAME:1001,WATCH_LIVETOURNAMENTS:1002,
5618PLAY_BLITZ:1003,PLAY_BULLET:1004,PLAY_SLOW:1005,WATCH_LIVERADIO:1006,LOGIN:1007,ACCOUNT:1008,GO_DEFAULT_PLAYING_GROUP:1009,PLAY_BLITZ3:1010,PLAY_BLITZ4:1011,PLAY_BLITZ5:1012,PLAY_BLITZ32:1013,PLAY_BLITZ10:1014,PLAY_SLOW16:1016,PLAY_SLOW155:1017,PLAY_SLOW20:1018,PLAY_SLOW30:1019,PLAY_SLOW20_10:1020,PING_PLAYER:1030,WATCH_SINGLEGAME:1031,RECEIVING_MOVES:1032,CLOSE_FINISHEDGAMES:1033,CLOSE_ALLGAMES:1034,ROOM_CHOICE:1035,BROWSE_CMS_ARCHIVE:1036,MORE_BOARDS:1037,LESS_BOARDS:1038,GOTO_LOBBY:1039,NEXT_BOARD:1040,
5619TOGGLE_GAMES_LIST:1041,CALCULATE_LINES:1042,ABORT:1050,RESIGN:1051,OFFER_DRAW:1052,APPLAUDE:1053,PING_OPPONENT:1054,ACCEPT_DRAW:1055,ACCEPT_ABORT:1056,CLAIM_WIN:1057,OFFER_REMATCH:1058,ACCEPT_REMATCH:1059,CLOSE_PLAYINGBOARD:1060,WATCH_MAXBOARDS:1070,TOPBLITZ_COUNTRY:1100,TOPBLITZ_STATE:1101,TOPBLITZ_CITY:1102,TOPBLITZ_FRIENDS:1103,SHOW_STATISTICS:1112,SEND_FEEDBACK:1115,EDIT_FRIENDS:1120,EDIT_FOES:1121,PLAY_BULLET1:1130,WATCH_MOVEDELAY:1200,LOBBY_TEST:2E3,LOBBY_TEST2:2001,toString:function(a){for(var b in this)if(this[b]==
5620a)return"LobbyId:"+b;return"Unknown LobbyId: "+a},toNumString:function(a){return"LobbyId="+a}},ServerNotifyId={NONE:0,CONNECTION_TOO_SLOW:1,N_SEEK_MATCHES:2,CLAIM_WIN_REJECTED:5,CLAIM_WIN_ACCEPTED:6,CLIENT_DISCONNECTED:7,CLIENT_NOT_RESPONDING:8,CLIENT_CONNQUAL:9,SEEK_MATCHED:10,CLAIM_GAME_DECIDED:11,OPPO
5620NENT_CLAIM_OK:12,INFORMAL_APPLAUSE_RECEIVED:13,OPPONENT_PLAYS_ANOTHER_GAME:14,CLIENT_OFFLINE:15,APPLAUSE_RECEIVED:16,WELCOME:17,NOT_IN_SAME_ROOM:18,RECENT_APPLAUSE_SENT:19,isDisco:function(a){return a==
5621ServerNotifyId.CLIENT_DISCONNECTED||a==ServerNotifyId.CLIENT_NOT_RESPONDING||a==ServerNotifyId.CLIENT_OFFLINE}};"use strict";
5622var ServerLiveSession=function(){var a=1,b=function(c,d,e,f,g){this.lobby=c;this.idGame=f;this.ticket=d;this.requestData=e;this.fnGetBackgroundKernel=this.fnGetKernel=g;this.requestedGame=!1;this.nErrorCount=this.nGameRequests=0;this.isFirstRequest=!0;this.uniqueId=a++;this.receivingMoves=!0;this.bufferedActions=[];this.delayedSessionActions=[];this.nGameActionsDelay=0;this.animatePosChange=!1;this.maxStatusMove=0};b.prototype.getKernel=function(){return this.fnGetKernel(this.idGame)};b.prototype.setToBackgroundKernel=
5623function(){this.fnGetKernel(this.idGame).Vp.deleteClock();this.fnGetBackgroundKernel().Vp.beforeGameLoad();this.fnGetBackgroundKernel().game.assign(this.fnGetKernel(this.idGame).game);this.fnGetKernel=this.fnGetBackgroundKernel};b.prototype.isFinished=function(){return this.getKernel().isFinished()};b.prototype.toggleReceivingMoves=function(){this.receivingMoves=!this.receivingMoves;this.setReceivingMoves(this.receivingMoves);this.nGameRequests=0};b.prototype.setReceivingMoves=function(c,d){if(this.receivingMoves=
5624c)this.requestGame(),this.requestedGame=!0;glApp.commands.fireChecked(LiveCmdIds.RECEIVING_MOVES,this.receivingMoves);d||this.getKernel()&&(c?this.getKernel().Vp.startClock():this.getKernel().Vp.stopClock())};b.prototype.sendGameStatusChange=function(c){var d=new WebSockMessage(SockMsgId.LIVE_USER);d.setUserType(UserMsgId.GAMESTATUS);d.getBuf();c.V17(d.getBuf());this.lobby.send(d)};b.prototype.onGameData=function(c){try{this.isInGameRequest=!1;this.tickGameReceived=new Tick;if(this.receivingMoves){var d=
5625this.getKernel(),e=-1,f=!0;d.game.isOnLastMove()||(e=d.game.getMoveIndex(),f=!d.game.mainLineEqual(c.game)&&c.game.getMoveIndex()<=c.game.getMoveCount(),this.gameDataBlocked=!0,console.log("Not on last move - blocked"));if(f){if(d.boardWin&&void 0!==d.boardWin.prepareFullRedraw){d.boardWin.prepareFullRedraw();var g=d.boardWin.shouldAnimatePosChange;d.boardWin.shouldAnimatePosChange=function(){return!1}}this.animatePosChange=!1;d.Vp.beforeGameLoad();f=-1;glApp.myMovesMgr&&(f=glApp.myMovesMgr.annoLatestMyMovesMove(c.game),
56260<=f&&console.log("mymoves devi="+f));d.game.assign(c.game);d.game.nGotoMove=c.game.getMoveIndex();var h=glApp.lobby.findMyMarkedMove(c.game);0<h&&(d.game.nGotoMove=h);f>d.game.nGotoMove&&(d.game.nGotoMove=f);0<=e&&(d.game.nGotoMove=e);d.game.gotoIndex(d.game.nGotoMove);0<h&&(d.deleteAnno(AnnoType.SYMBOL),d.addSymbol(AnnoMarkType.MYMOVE));d.idGame=c.idGame;this.idGame!=d.idGame&&console.log("idGame!");d.boardWin&&(g&&(d.boardWin.shouldAnimatePosChange=g),d.boardWin.redraw());this.updateBoardAttributes()}this.receivingMoves&&
5627(this.moveIndexOnServer=c.game.getMoveIndex(),this.executeBufferedActions());this.getKernel().markLastMove(!0,!0);this.bufferedActions=[];this.nErrorCount=0}this.animatePosChange=!0;this.idNavListener||(this.idNavListener=this.getKernel().game.addOnNavigateListener(this._onGameNavigate.bind(this)))}catch(k){LogException("LSess::onGameData:",k)}};b.prototype.shouldAnimatePosChange=function(){return this.animatePosChange};b.prototype.updateBoardAttributes=function(){var c=this.getKernel().boardWin,
5628d=this.getKernel().game;c&&(c.cbcanvas?c.setTitleText(d.hdr.getStrPlayers(c.nSqPix>c.cbcanvas.zoomToPix(42))):c.setTitleText(d.hdr.getStrPlayers(20)),this.setClock&&this.getKernel().Vp.setManualClock(this.setClock.getWhiteTime(),this.setClock.getBlackTime(),this.getKernel().game.getCurPos().getBTM()))};b.prototype.modifyPlayingMode=function(){this.getKernel().Vp.fnAcceptMove=function(){this.receivingMoves&&(this.analysisAdded=!0);return!0}.bind(this);this.getKernel().Vp.fnAfterMove=function(c){this.getKernel().game.getMoveIndex()==
5629this.moveIndexOnServer+1&&this.getKernel().game.isOnMainLine()&&this.getKernel().game.setAnno(AnnoType.PRETEXT,new TextAnno("Analysis:"));return!0}.bind(this)};b.prototype.getTitle=function(){if(this.getKernel())return this.getKernel().game.hdr.getStrPlayers(!1)};b.prototype.executeBufferedActions=function(){for(var c=0;c<this.bufferedActions.length;
5629c++)LOG("ExecBuffered SessionAction","LogBold","live"),this.onSessionAction(this.bufferedActions[c],!0)};b.prototype.onSessionAction=function(c,d){if(this.receivingMoves)if(0<
5630this.nGameActionsDelay)c.timeStamp=this.nGameActionsDelay,c.session=this,this.delayedSessionActions.push(c);else this.onProcessSessionAction(c,d);else c.gameAction.isMove()&&this.lobby.logIntoChat("Received a move: "+this.getKernel().game.hdr)};b.prototype.onProcessSessionAction=function(c,d){if(this.isInGameRequest)this.bufferedActions.push(c);else{if(!this.getKernel())return;this.getKernel().game.delayChangedEvents(1E3);if(!this.ignoreSetGameAction(c.gameAction)){var e=this.getKernel().game.getMoveIndex(),
5631f=e<=this.getKernel().game.mainLine.length,g=e!=this.moveIndexOnServer;this.moveIndexOnServer!=this.getKernel().game.getMoveIndex()&&this.getKernel().game.gotoIndex(this.moveIndexOnServer,!0);if(c.gameAction.execute(this.getKernel().game,c.controlMove)){if(c.gameAction.isMove()||c.gameAction.isGame())c.gameAction.isMove()&&(this.getKernel().Vp.updateClockFromGame(),this.getKernel().game.deleteAnno(AnnoType.PRETEXT),f||e
5631++),this.getKernel().markLastMove(!0,!0);0<this.nErrorCount&&LOG("Game in Legal Sync: "+
5632this.getKernel().game.hdr,"LogBold");this.nErrorCount=0;this.moveIndexOnServer=this.getKernel().game.getMoveIndex();g&&this.getKernel().game.gotoIndex(e,!0);this.analysisAdded&&this.getKernel().game.promoteLine()&&(d=this.getKernel().game.getMoveIndex(),this.getKernel().game.unAnnotate(),this.getKernel().game.gotoIndex(d),this.moveIndexOnServer=d)}else c.gameAction.isMove()&&!c.isAnEarlierMove(this.getKernel().game)?(this.nErrorCount+=1,LOG("Illegal: "+c.gameAction+", "+this.nErrorCount,"LogError"),
5633d||this.isFinished()||!(4<this.nErrorCount||this.tickGameReceived&&6E3<this.tickGameReceived.getExpired())||(this.nGameRequests++,5>this.nGameRequests?(LOG("Illegal Actions, refresh: "+this.getKernel().game.hdr+", "+this.nGameRequests,"LogError"),this.requestGame()):LOG("Too many illegal moves: "+this.getKernel().game.hdr,"LogError"))):c.gameAction.isMove()?LOG("Received an earlier move: "+this.getKernel().game.hdr,"LogGreen"):LOG("Non move Session Action: "+c.gameAction,"LogGreen")}this.getKernel().game.continueChangedEvents()}c.gameAction.changesMoves()&&
5634(this.analysisAdded=!1)};b.prototype.ignoreSetGameAction=function(c){return!1};b.prototype.requestGame=function(){this.isInGameRequest=!0;this.lobby.requestGame(this.idGame,this.ticket);console.log("Request Game")};b.prototype.onGameStatusChange=function(c){switch(c.type+100){default:LOG("Session.onGSC: "+c);break;case ServerGameStatusEnum.ADD_WATCHER:case ServerGameStatusEnum.REMOVE_WATCHER:case ServerGameStatusEnum.REQUESTGAME_ADDWATCHER:break;case ServerGameStatusEnum.WHITEWINS:this.finishGameWithResult(GameResultEnum.WHITE_WINS);
5635break;case ServerGameStatusEnum.DRAW:this.finishGameWithResult(GameResultEnum.DRAW);break;case ServerGameStatusEnum.BLACKWINS:this.finishGameWithResult(GameResultEnum.BLACK_WINS);break;case ServerGameStatusEnum.TIMEOVERSTEPPED:LOG("TIMEOVERSTEPPED","LogBold");if(this.getKernel())this.getKernel().Vp.onTimeOverstepped(this.idWhite!==c.idPlayer);this.idWhite==c.idPlayer?LOG("Time - White"):LOG("Time - Black")}};b.prototype.finishGameWithResult=function(c){this.isFinished()||this.getKernel().setResult(c)};
5636b.prototype.isFinished=function(){return!this.getKernel()||this.getKernel().game.hdr.getCBResult().isFinished()};b.prototype.onSetClock=function(c){this.setClock=c;this.getKernel()&&this.getKernel().Vp.setManualClock(c.getWhiteTime(),c.getBlackTime(),c.isBlack())};b.prototype.onReconnect=function(){this.receivingMoves&&this.setReceivingMoves(!0)};b.prototype.onConnBroken=function(){};b.prototype.toString=function(){return this.getKernel()?this.getKernel().game.hdr.getStrPlayers():this.idGame};b.prototype.delayGameActions=
5637function(c){this.nGameActionsDelay=c;0<this.nGameActionsDelay&&!this.myTimer&&(this.myTimer=setInterval(this.onBufferedGameActionsHandler.bind(this),1E3))};b.prototype.mustExecute=function(c){return 0<c.timeStamp&&(c.timeStamp--,0==c.timeStamp)?!0:!1};b.prototype.execute=function(c){c.session.onProcessSessionAction(c,!0)};b.prototype.onBufferedGameActionsHandler=function(){this.delayedSessionActions.forEach(function(c){ServerLiveSession.prototype.mustExecute(c)&&(ServerLiveSession.prototype.execute(c),
5638c.session.getKernel()&&c.session.getKernel().game.updateFromExtern())})};b.prototype._onGameNavigate=function(){this.gameDataBlocked&&this.getKernel().game.isOnLastMove()&&(this.gameDataBlocked=!1,this.requestGame())};return b}();"use strict";
5639var ServerLiveGameList=function(){var a=function(b,c,d){this.lobby=b;this.ticket=c;this.requestData=d;this.sessions={};this.kernels={}};a.prototype.onGameItemList=function(b){this.gameItemList=b;this.requestData.onList(function(){return this.gameItemList}.bind(this))};a.prototype.addSession=function(b,c,d,e){if(this.sessions[b])return!1;var f=new GameKernel;f.setPlayingMode(new AnalysisMode(f));this.kernels[b]=f;f.enableAudio(!1);f=new ServerLiveSession(this.lobby,this.ticket,this.requestData,b,function(){return this.kernels[b]}.bind(this));
5640var g=this.getGameItem(b);g&&(f.clock=g.clock);f.fnOnMove=c;f.fnOnRecentAnno=d;f.fnOnGameData=e;this.sessions[b]=f;return!0};a.prototype.getGameItem=function(b){if(this.gameItemList)for(var c=0;c<this.gameItemList.games.length;c++)if(this.gameItemList.games[c].id==b)return this.gameItemList.games[c]};a.prototype.onInitKibitzing=function(b,c,d){if(this.kernels[b]&&(d&&this.kernels[d]&&this.sessions[d].setToBackgroun
5640dKernel(),c)){d=this.sessions[b];if(c().boardWin&&void 0!==c().boardWin.prepareFullRedraw){c().boardWin.prepareFullRedraw();
5641var e=c().boardWin.shouldAnimatePosChange;c().boardWin.shouldAnimatePosChange=function(){return!1}}c().Vp.beforeGameLoad();c().game.assign(this.kernels[b].game);c().idGame=b;c().markLastMove(!0,!0);e&&(c().boardWin.shouldAnimatePosChange=e);d.fnGetKernel=c;d.updateBoardAttributes()}};a.prototype.setSessionToBackground=function(b){b&&this.sessions[b]&&this.sessions[b].setToBackgroundKernel()};a.prototype.notifySessionSwap=function(b,c){if(this.sessions[b]&&this.sessions[c]){var d=this.sessions[c].fnGetKernel;
5642this.sessions[c].fnGetKernel=this.sessions[b].fnGetKernel;this.sessions[b].fnGetKernel=d;this.sessions[b].updateBoardAttributes();this.sessions[c].updateBoardAttributes()}};a.prototype.onGameData=function(b){this.sessions[b.idGame]&&(this.sessions[b.idGame].onGameData(b),b.idGame==this.currGameId&&this.sessions[b.idGame].fnGetKernel(b.idGame).markLastMove(!0,!0),this.sessions[b.idGame].fnOnMove&&this.sessions[b.idGame].fnOnMove(b.idGame),this.sessions[b.idGame].fnOnGameData&&this.sessions[b.idGame].fnOnGameData(b))};
5643a.prototype.onSessionAction=function(b){var c=b.idGame;this.sessions[c]&&(this.sessions[c].onSessionAction(b),this.sessions[c].fnOnMove&&this.sessions[c].fnOnMove(c,b))};a.prototype.onGameStatusChange=function(b){var c=b.idGame;if(this.sessions[c])this.sessions[c].onGameStatusChange(b);c=GameResultEnum.UNDEFINED;switch(b.type+100){case ServerGameStatusEnum.WHITEWINS:c=GameResultEnum.WHITE_WINS;break;case ServerGameStatusEnum.DRAW:c=GameResultEnum.DRAW;break;case ServerGameStatusEnum.BLACKWINS:c=GameResultEnum.BLACK_WINS}if(c!=
5644GameResultEnum.UNDEFINED)for(b=0;b<this.gameItemList.games.length;b++)this.gameItemList.games[b].id&&(this.gameItemList.games[b].result=c)};a.prototype.onNewRoundGameLive=function(b){this.gameItemList&&!this.gameItemList.contains(b)&&(this.gameItemList.games.unshift(b),glApp.panelMgr.onNewGameItem(this.ticket-1,b))};a.prototype.onRecentAnno=function(b){this.sessions[b]&&this.sessions[b].fnOnRecentAnno&&this.sessions[b].fnOnRecentAnno(b)};a.prototype.onSetClock=function(b,c){if(this.sessions[c])this.sessions[c].onSetClock(b)};
5645a.prototype.onLiveStatus=function(b){let c=this.sessions[b.idGame];c?b.nMoves>=c.maxStatusMove&&(c.maxStatusMove=b.nMoves,glApp.panelMgr.onLiveGameStatus(this.ticket-1,b)):console.log("Unknown: "+b.eval+", "+b.idGame)};a.prototype.getPgn=function(){var b="",c;for(c in this.kernels)this.kernels[c].game&&this.kernels[c].game.getMoves().length&&(b+=PGNWriter.toPGN(this.kernels[c].game));return b};return a}(),ServerMarkedPosition=function(){var a=function(){this.pos={};this.flags=0};a.prototype.fromDataBuf=
5646function(b){b.Vc();this.pos=new Position;this.pos.read(b);var c=b.V19();this.pos.setMoveNum(c);this.flags=b.V19();b.Vm()};return a}();"use strict";
5647var LiveMsgId={NONE:0,START_KIBITZING:801,START_KIBITZING_GAMEID:802,REQUEST_LISTS:803,RESPOND_LISTS:804,ADD_GAME:805,RECENT_ANNO:806,FINISH_KIBITZING:807,FINISH_KIBITZING_GAMEID:808,REQUEST_MYMOVES_GAMES:809,RESPOND_MYMOVES_GAMES:810,REQUEST_GAME:811,GAME_STATUS:812,LIVE_CHAT:820,REQUEST_CHAT_LOG:821,RESPOND_CHAT_LOG:822,REQUEST_GUESS_MOVE_LIST:900,GUESS_MOVE_REFRESH_QUOTES:901,GUESSMOVE_BET:902,GUESSMOVE_VOTE:903,GUESSMOVE_REQUEST_MOVEQUOTE:904,GUESSMOVE_RESPONDLIST:905,GUESSMOVE_RESPONSE:906,GUESSMOVE_SERVERSTATUS:907,
5648GUESSMOVE_RANKVOTERSLIST:909,RESPOND_GAMEDATA:17,SESSIONACTION:200,GAMESTATUS_CHANGE:400,SETCLOCK:21,toNumString:function(a){return"LiveMsgId="+a},toString:function(a){for(var b in this)if(this[b]==a)return b;return"Unknown LiveMsgId: "+a}},LiveError={NONE:0,toString:function(a){switch(a){default:return"Msg="+a;case LiveError.NONE:return"None"}}},LiveCmdIds={NONE:0,PING_SERVER:1E3,RECEIVING_MOVES:2E3,toNumString:function(a){return"LiveCmdId="+a}},ServerLiveManager=function(){var a=!1,b=function(e){this.callBacks=
5649e;this.commandHandlerId=glApp.commands.registerCommandHandler(this);this.pingServerPeriodMS=2E4;this.markedPosns=[];this.waitingTimer=new Timer};b.prototype.getName=function(){return"Live"};inherit(b,Connector);
5649b.prototype.createLobby=function(e,f,g,h,k,l){l||glApp.panelMgr.showMessage(lm.CONNECTING);this.staySilent=l;this.create(e,f,g,h,k);System.shouldWarnIOS()&&(new Timer(function(){glApp.panelMgr.showAreaMsg("Please update to at least IOS 15.4")}.bind(this))).runOnce(2E3)};b.prototype.onChangeLogin=
5650function(){this.fireOnChangeLogin()};b.prototype.signalOnConnect=function(){};b.prototype.onSwitchConn=function(e){};b.prototype.requestLiveGames=function(e){};b.prototype.onIdReceived=function(e){console.log(lm);var f=String.formatEx(lm.CONNECTED_TO_SERVER,this.getName());console.log(f);this.logIntoChat(f,"LogGreen","conn");this.staySilent&&glApp.panelMgr.showMessage(f);this.boundLoginOk=!0;this.loginMode!=LoginMode.GUEST?(e.strUserId&&(glApp.Vn.userName=StrUtil.decodeUTF8(e.strUserId),this.user=
5651StrUtil.decodeUTF8(e.strUserId),this.utf8User=e.strUserId,e.strToken&&(glApp.Vn.loginToken=e.strToken,DOM.setCookie("AccountMode",LoginMode.NORMAL),glApp.Vn.rememberLoginToken())),document.title="Live Chess For "+this.user,glApp.setLoggedIn(!0)):(this.user="Guest"+this.getNId(),this.utf8User="Guest"+this.getNId());glApp.idleFunc=this.onIdle.bind(this);glApp.notIdleFunc=this.onIdle.bind(this);this.initGameKibitzing();this.initListKibitzing()};b.prototype.initGameKibitzing=function(){if(this.boundLoginOk&&
5652this.sessions&&this.sessions.length){var e=new WebSockMessage(SockMsgId.LIVE_USER);e.setUserType(LiveMsgId.START_KIBITZING);var f=e.getBuf();f.writeInt(this.sessions.length);for(var g=0;g<this.sessions.length;g++)this.requestDataToBuf(this.sessions[g].requestData,f),f.writeInt(this.sessions[g].ticket),f.V1b(!1),f.V1b(this.sessions[g].requestData.highestRoundOnly),this.requestDataToBuf2(this.sessions[g].requestData,f),this.sessions[g].requested=!0;e.address(this.getNId(),ConnectId.SERVER);this.send(e)}};
5653b.prototype.requestLiveLists=function(e){this.requestLists=e;this.liveGameLists=[];for(var f=0;f<e.length;f++){var g=new ServerLiveGameList(this,e[f].ticket,e[f].requestData);this.liveGameLists.push(g)}this.initListKibitzing()};b.prototype.testDisco=function(){console.log("CONN BREAK");this.conn.breakForTesting()};b.prototype.initListKibitzing=function(){if(this.boundLoginOk&&this.liveGameLists&&this.liveGameLists.length){var e=!1,f=new WebSockMessage(SockMsgId.LIVE_USER);f.setUserType(LiveMsgId.REQUEST_LISTS);
5654var g=f.getBuf();g.writeInt(this.liveGameLists.length);for(var h=0;h<this.liveGameLists.length;h++)if(this.liveGameLists[h].requestData.myMoves){this.requestMyMovesGames();e=!0;this.requestMyMoves();break}else this.requestDataToBuf(this.liveGameLists[h].requestData,g),g.writeInt(this.liveGameLists[h].ticket),g.V1b(!1),g.V1b(this.liveGameLists[h].requestData.highestRoundOnly),this.requestDataToBuf2(this.liveGameLists[h].requestData,g),this.liveGameLists[h].requested=!0;try{window.location?g.Va(window.location.hostname||
5655""):g.Va("")}catch(k){}e||(f.address(this.getNId(),ConnectId.SERVER),this.send(f))}};b.prototype.requestDataToBuf=function(e,f){f.Va(e.event||"");f.Va(e.round||"");f.Va(e.round2||"");f.Va(e.player||"");f.Va(e.white||"");f.Va(e.black||"");f.Va(e.date||"");f.writeInt(e.kibitzRank)};b.prototype.requestDataToBuf2=function(e,f){f.Va(e.team||"");f.Va(e.other||"");f.V1b(e.sharp);f.V1b(e.endgame);f.writeInt(e.minElo);f.Va(e.roundstr||"")};b.prototype.sendStartKibitzing=function(e,f){var g=new WebSockMessage(SockMsgId.LIVE_USER);
5656g.setUserType(LiveMsgId.START_KIBITZING_GAMEID);var h=g.getBuf();h.writeInt(e);h.writeInt(f);g.address(this.getNId(),ConnectId.SERVER);this.send(g)};b.prototype.sendFinishKibitzing=function(e,f){var g=new WebSockMessage(SockMsgId.LIVE_USER);g.setUserType(LiveMsgId.FINISH_KIBITZING_GAMEID);var h=g.getBuf();h.writeInt(e);h.writeInt(f);g.address(this.getNId(),ConnectId.SERVER);this.send(g)};b.prototype.initKibitzingById=function(e,f,g,h,k,l,m){if(this.boundLoginOk){var n=this.getLiveGameList(f);n&&(n.addSession(e,
5657h,l,m)&&this.sendStartKibitzing(e,f),n.onInitKibitzing(e,g,k))}};b.prototype.requestChatLog=function(e,f){var g=new WebSockMessage(SockMsgId.LIVE_USER);g.setUserType(LiveMsgId.REQUEST_CHAT_LOG);var h=g.getBuf();h.writeInt(f);h.writeInt(e);g.address(this.getNId(),ConnectId.SERVER);this.send(g)};
5657b.prototype.setSessionToBackground=function(e,f){this.boundLoginOk&&(e=this.getLiveGameList(e))&&e.setSessionToBackground(f)};b.prototype.notifySessionSwap=function(e,f,g){this.boundLoginOk&&(e=this.getLiveGameList(e))&&
5658e.notifySessionSwap(f,g)};b.prototype.requestMyMovesGames=function(){if(this.boundLoginOk&&this.liveGameLists&&this.liveGameLists.length){var e=new WebSockMessage(SockMsgId.LIVE_USER);e.setUserType(LiveMsgId.REQUEST_MYMOVES_GAMES);var f=e.getBuf();f.Va(glApp.Vn.userName);f.V13(System.getWindowsCodePage());e.address(this.getNId(),ConnectId.SERVER);this.send(e)}};b.prototype.requestMyMoves=function(){glApp.myMovesMgr?glApp.myMovesMgr.isLoggedIn()?this.doRequestMyMoves():glApp.myMovesMgr.fnOnIdReceived=
5659this.doRequestMyMoves.bind(this):(new Timer(function(){this.doRequestMyMoves()}.bind(this))).runOnce(2E3)};b.prototype.doRequestMyMoves=function(){glApp.myMovesMgr?(console.log("doReqMM"),glApp.myMovesMgr.loadMyMoves(GetMovesType.WHITE,null),glApp.myMovesMgr.loadMyMoves(GetMovesType.BLACK,null)):console.log("doReqMM, no MMM")};b.prototype.getPgn=function(e){if(e=this.getLiveGameList(e))return e.getPgn()};var c=!1;b.prototype.onIdle=function(){glApp.isIdle()!=c&&(this.updatePlayerStatus(),c=glApp.isIdle())};
5660b.prototype.updatePlayerStatus=function(){var e=0;if(this.hasIdReceived){var f=new ServerClientChange;e=this.detPlayerStatus().flags;f.setStatusChange(e);f.id=this.getNIdBound();var g=new WebSockMessage(SockMsgId.CLIENTDATACHANGE);f.V17(g.getBuf());g.address(this.getNId(),ConnectId.SERVER);this.send(g);this.fireOnClientChanges([f])}return e};b.prototype.detPlayerStatus=function(){var e=ServerStatusEnum.KIBITZING;e=glApp.isIdle()?e|ServerStatusEnum.IDLE:e|ServerStatusEnum.NOTIDLE;return new ServerStatus(e)};
5661b.prototype.hasSockMsgIds=function(){return!0};b.prototype.hasSockCheckSum=function(){return!0};b.prototype.execCommand=function(e){if(!this.hasIdReceived&&e!=CommandIds.LOGIN&&e!=LiveCmdIds.PING_SERVER)return!1;try{switch(e){case CommandIds.LOGIN:this.changeLogin();break;case LiveCmdIds.PING_SERVER:this.pingServer(!0);break;case CommandIds.TEST:this.test()}}catch(f){e=LiveCmdIds.toNumString(e),LogException(e,f)}};b.prototype.logIntoChat=function(e,f,g){};b.prototype.testYesNo=function(e){LOG("YesNo="+
5662e)};b.prototype.test=function(e){};b.prototype.test2=function(){this.logIntoChat("Stop Torture");this.torturer&&this.torturer.stop()};b.prototype.changeLogin=function(){glApp.Vn&&glApp.Vn.prepareLoginChange()&&glApp.Vn.prepareLoginChange()};b.prototype.handleReceived=function(e){if(!this.handleReceivedByConnector(e))try{switch(e.getType()){default:console.log("Unhandled: "+e.toString());break;case SockMsgId.LIVE_USER:case SockMsgId.USER:this.handleLiveUserMsg(e);break;case SockMsgId.RECONNECT_OK:this.handleReconnectOk(e);
5663break;case SockMsgId.CHAT:this.handleChat(e)}}catch(f){e=SockMsgId.toNumString(e.getType()),LogException(e,f)}};b.prototype.handleChat=function(e){var f=new ChatData;f.fromSocketsMsg(e);var g=e.getBuf().V19(),h=e.getBuf().V19(),k=new GameHeader;k.compactFromDataBuf(e.getBuf());e=e.getBuf().V19();f.isToSession()||f.isToObservers()?glApp.panelMgr.kibitzChatOut(f.strSender,k,f.strMsg,{idGame:h,ticket:g,mvInx:e},f.isAutomatic(),!0):glApp.panelMgr.chatOut(f.toString())};b.prototype.handleChatLog=function(e){var f=
5664[];e=e.getBuf();var g=e.V19();e.V19();for(var h=e.V19(),k=0;k<h;k++){e.Vc();var l={};l.sender=e.Vb(200);l.txt=e.Vb(1500);l.gameId=e.V19();l.hdr=new GameHeader;l.hdr.compactFromDataBuf(e);l.mvInx=e.V19();l.autoChat=e.V1c();l.txt.length&&f.push(l);e.Vm()}glApp.panelMgr.onChatLog(g,f)};b.prototype.sendChat=function(e,f,g){var h=new ChatData;h.idReceiver=ConnectId.SERVER;h.idSender=this.getNId();h.strMsg=g;h.strSender=e;h.nChannel=f;h.setToSession(!0);h.setToObservers(!0);h.eColName=14;e=h.Vi();e.setType(SockMsgId.LIVE_USER);
5665e.setUserType(LiveMsgId.LIVE_CHAT);this.send(e)};b.prototype.handleGuessMoveStatus=function(e){var f=new GuessMoveStatus;if(f.ReadFromDataBuffer(e.getBuf())){glApp.panelMgr.voteBetOutput="";switch(f.m_eType){case GuessMoveStatusType.SERVER_CONFIRMS_BET:e=new NotationGenerator;glApp.panelMgr.voteBetOutput="Server confirms bet: "+e.getNota2(f.m_move,glApp.panelMgr.getKernel());glApp.panelMgr.markMyBet();break;case GuessMoveStatusType.SERVER_ALREADY_BET_ON_MOVE:glApp.panelMgr.voteBetOutput="Server already bet on move";
5666break;case GuessMoveStatusType.SERVER_CONFIRMS_VOTE:e=new NotationGenerator;glApp.panelMgr.voteBetOutput="Server confirms vote: "+e.getNota2(f.m_move,glApp.panelMgr.getKernel());glApp.panelMgr.markMyVote();break;case GuessMoveStatusType.SERVER_ALREADY_VOTED_ON_MOVE:glApp.panelMgr.voteBetOutput="Server already voted on move";break;case GuessMoveStatusType.SERVER_CANNOT_BET:glApp.panelMgr.voteBetOutput="Server cannot bet";break;case GuessMoveStatusType.SERVER_NOT_CURRENT_MOVE:glApp.panelMgr.voteBetOutput=
5667"Server not on current move";break;case GuessMoveStatusType.SERVER_NOTIFY_VOTEMOVE_PLAYED:glApp.panelMgr.voteBetOutput="Your move has been played";glApp.panelMgr.updateUserVotes(!0);break;case GuessMoveStatusType.SERVER_NOTIFY_VOTEMOVE_NOTPLAYED:glApp.panelMgr.voteBetOutput="Your move has not been played";glApp.panelMgr.updateUserVotes(!1);break;case GuessMoveStatusType.SERVER_VOTE_TOO_LATE:glApp.panelMgr.voteBetOutput="Your vote was too late";break;case GuessMoveStatusType.SERVER_MOVE_QUOTE:glApp.panelMgr.voteBetOutput=
5668"Server confirms quote";break;case GuessMoveStatusType.SERVER_NO_SERIAL:glApp.panelMgr.voteBetOutput="Serial number required";break;case GuessMoveStatusType.SERVER_CANCELS_VOTE:glApp.panelMgr.voteBetOutput="Server cancels vote"}glApp.panelMgr.populateGuessMoveOutput(glApp.panelMgr.voteBetOutput)}};b.prototype.handleGuessMoveList=function(e){var f=e.getBuf();let g=f.readInt();f.readInt();let h=f.readInt();e=[];var k=new NotationGenerator;for(let l=0;l<h;l++){f.readInt();let m={move:new Move,moveNotation:"",
5669votes:0,quote:0};m.move.read(f);m.moveNotation=k.getNota2(m.move,glApp.panelMgr.getKernel());m.quote=f.V18();m.votes=f.V19();e.push(m)}f=String.f("GuessMoveList, game={0}, NMoves={1}",g,e.length);this.showBoardMsg(f);glApp.panelMgr.chatOut(f);glApp.panelMgr.populateGuessMoveList(e,a)};b.prototype.handleGuessMoveRankVotes=function(e){e=e.getBuf();e.readInt();e.readInt();e=e.V12(1E4);glApp.panelMgr.populateGuessMoveTopVoters(e)};b.prototype.displayForceLogOffMsg=function(e){this.callBacks.onForcedLogoff(e)};
5670b.prototype.handleReconnectOk=function(e){glApp.panelMgr.showPosText("Reconnected OK...");this.requestLists&&this.requestLiveLists(this.requestLists)};var d=0;b.prototype.handleLiveUserMsg=function(e){0<d&&LogException("Reenter handleLiveUserMsg: ",d);d=e.getUserType();try{switch(e.getUserType()){default:LOG("UserMsg="+UserMsgId.toString(e.getUserType()));break;case UserMsgId.GAMESTATUS_LIVE:try{this.handleGameStatusChange(e)}catch(f){LOG("gs2: "+f)}break;case UserMsgId.NOTIFY_NEWROUND_LIVE:this.handleNewRoundLive(e);
5671break;case LiveMsgId.RESPOND_LISTS:this.handleRespondLists(e);break;case LiveMsgId.RESPOND_MYMOVES_GAMES:this.handleRespondMyMovesGames(e);break;case LiveMsgId.RESPOND_GAMEDATA:this.handleGameData(e);break;case LiveMsgId.SESSIONACTION:this.handleSessionAction(e);break;case LiveMsgId.SETCLOCK:this.handleSetClock(e);break;case LiveMsgId.RECENT_ANNO:this.handleRecentAnno(e);break;case LiveMsgId.LIVE_CHAT:this.handleChat(e);break;case LiveMsgId.GAME_STATUS:this.handleLiveGameStatus(e);break;case LiveMsgId.RESPOND_CHAT_LOG:this.handleChatLog(e);
5672break;case LiveMsgId.GUESSMOVE_SERVERSTATUS:this.handleGuessMoveStatus(e);break;case LiveMsgId.GUESSMOVE_RESPONDLIST:this.handleGuessMoveList(e);break;case LiveMsgId.GUESSMOVE_RANKVOTERSLIST:this.handleGuessMoveRankVotes(e)}}catch(f){e=LiveMsgId.toNumString(e.getUserType()),LogException(e,f)}d=0};b.prototype.requestGame=function(e,f){var g=new WebSockMessage(SockMsgId.LIVE_USER);g.setUserType(LiveMsgId.REQUEST_GAME);var h=g.getBuf();h.writeInt(e);h.writeInt(f);g.address(this.getNId(),ConnectId.SERVER);
5673this.send(g)};b.prototype.handleGameData=function(e){var f=new ServerGameData;
5673f.fromDataBuf(e.getBuf());f.game.gotoIndex(f.game.getMoveIndex());var g=e.getBuf().V19();e.getBuf().V1c()&&!glApp.isPremium()&&console.log("Live: no premium");if(e=this.getLiveGameList(g))e.onGameData(f)};b.prototype.handleRespondLists=function(e){var f=e.getBuf();e=new ServerGameItemList;e.fromDataBuf(f);f=f.readInt();if(f=this.getLiveGameList(f))f.onGameItemList(e)};b.prototype.handleRespondMyMovesGames=function(e){var f=
5674e.getBuf();e=new ServerGameItemList;e.fromDataBuf(f);f.Vc();var g=f.V19();this.markedPosns=[];for(var h=0;h<g;h++){var k=new ServerMarkedPosition;k.fromDataBuf(f);this.markedPosns.push(k)}f.Vm();f=f.readInt();if(!e.empty()&&(f=this.getLiveGameList(f)))f.onGameItemList(e)};b.prototype.findMyMarkedMove=function(e){if(0<this.markedPosns.length){this.markedPosns.find=function(g){for(var h=0;h<this.length;h++)if(this[h].pos.boardEquals(g.board))return this[h].pos.getMoveNum();return-1};for(e.gotoEnd();0<
5675e.getMoveIndex();){var f=this.markedPosns.find(e.getCurPos());if(0<=f)return f;e.gotoPrev()}e.gotoEnd()}return 0};b.prototype.handleSessionAction=function(e){var f=new SessionAction;f.fromDataBuf(e.getBuf());e=e.getBuf().V19();LOG("SAction: "+e);if(e=this.getLiveGameList(e))e.onSessionAction(f)};b.prototype.handleGameStatusChange=function(e){var f=e.getBuf();e=new ServerGameStatusChange;e.fromDataBuf(f);f=f.V19();if(f=this.getLiveGameList(f))f.onGameStatusChange(e)};b.prototype.handleNewRoundLive=
5676function(e){var f=e.getBuf();e=new ServerGameItem;e.fromDataBuf(f);f=f.V19();if(f=this.getLiveGameList(f))f.onNewRoundGameLive(e)};b.prototype.handleRecentAnno=function(e){var f=e.getBuf().V19();e=e.getBuf().V19();if(f=this.getLiveGameList(f))f.onRecentAnno(e)};b.prototype.handleSetClock=function(e){var f=new SetClockData;f.fromDataBuf(e.getBuf());var g=e.getBuf().V19();e=e.getBuf().V19();if(g=this.getLiveGameList(g))g.onSetClock(f,e)};b.prototype.handleLiveGameStatus=function(e){var f=e.getBuf();
5677f.Vc();e=f.readInt();var g=f.readInt();let h=f.readFloat64(),k=[];k[0]=f.readFloat64();k[1]=f.readFloat64();let l=f.readInt(),m=f.readInt(),n=f.readInt(),r=f.V1c(),t=f.V1c(),u=[];u[0]=f.readFloat64();u[1]=f.readFloat64();let x=f.readInt(),B=f.readInt(),y=[];y[0]=f.readInt();y[1]=f.readInt();let A=f.V1a(),aa=f.V1a(),ha=f.V1a(),z=[];z[0]=f.readInt();z[1]=f.readInt();f.Vm();f=f.readInt();e={idGame:e,eval:g,complexity:h,king:k,activity:u,material:y,nMoves:l,opening:m,endgame:n,blunder:r,tactics:t,tactMove:x,
5678blundMove:B,sharpThresh:A,kingThresh:aa,activityThresh:ha,outpost:z,isMate(){return 29E3<Math.abs(this.eval)&&32767!=this.eval},isCompensation(){if(32767!=this.eval){let V=this.material[0]-this.material[1];if(0>V)return 0>V==0<this.eval}},isSharp(){return this.complexity>this.sharpThresh},isTactics(){return this.tactics&&this.nMoves<this.tactMove+10},isBlunder(){return this.blunder&&this.nMoves<this.blundMove+10},isEndgame(){return this.endgame||0<this.material[0]&&2450>=this.material[0]+this.material[1]},
5679isActivity(V){let ba=this.activity[V]-this.activity[1-V],v=this.material[V]-this.material[1-V];return V?ba<-this.activityThresh&&0<=v:ba>this.activityThresh&&0>=v},isAttack(V,ba){return 6<ba-l?!1:this.activity[V]>this.activity[1-V]+1&&2E3<this.material[V]&&-30>this.king[1-V]&&this.king[V]>this.king[1-V]+10&&(V?-60>this.eval:60<this.eval)&&280<this.complexity},isOutpost(V,ba){return 6<ba-l?!1:this.activity[V]>this.activity[1-V]+1&&0!=this.outpost[V]&&1500<this.material[V]}};if(g=this.getLiveGameList(f))g.onLiveStatus(e)};
5680b.prototype.getSession=function(e){};b.prototype.getLiveGameList=function(e){if(this.liveGameLists)for(var f=0;f<this.liveGameLists.length;f++)if(this.liveGameLists[f].ticket==e)return this.liveGameLists[f]};b.prototype.gameFromBuf=function(e){var f=new Game,g=new GameHeader;g.compactFromDataBuf(e);e.V19();f.readGameOnly2(e);f.setHeader(g);return f};b.prototype.onWait=function(){this.showBoardMsg(this.waitMsg|NaN)};b.prototype.showBoardMsg=function(e){if(glApp.panelMgr.getKernel()){let f=glApp.panelMgr.getKernel().boardWin;
5681f&&f.addMessage(e,!0)}};b.prototype.setNoPremiumWarningGame=function(e){4<e.getMoves().length&&(e.gotoIndex(4),e.deleteRemaining(!0),e.getMoves()[3].setAnnoItem(AnnoType.POSTTEXT,new TextAnno("Sorry, this broadcast is Premium only. Please login in with your Premium Account. Thanks!")))};b.prototype.requestGuessMoveList=function(e,f,g){var h=new WebSockMessage(SockMsgId.LIVE_USER);h.setUserType(LiveMsgId.REQUEST_GUESS_MOVE_LIST);h.setVal(e);var k=h.getBuf();k.writeInt(e);k.writeInt(f);k.V1b(g);k.Va(glApp.Vn.userName);
5682k.V13(System.getWindowsCodePage());h.address(this.getNId(),ConnectId.SERVER);a=g;this.send(h)};b.prototype.sendUserMoveVote=function(e,f,g,h){var k=new WebSockMessage(SockMsgId.LIVE_USER);k.setUserType(LiveMsgId.GUESSMOVE_VOTE);k.setVal(e);var l=k.getBuf();l.writeInt(e);l.writeInt(f);g.write(l);l.V15(h);l.Va(glApp.Vn.userName);l.V13(System.getWindowsCodePage());k.address(this.getNId(),ConnectId.SERVER);this.send(k)};b.prototype.sendUserMoveBet=function(e,f,g,h){var k=new WebSockMessage(SockMsgId.LIVE_USER);
5683k.setUserType(LiveMsgId.GUESSMOVE_BET);k.setVal(e);var l=k.getBuf();l.writeInt(e);l.writeInt(f);g.write(l);l.V15(h);l.Va(glApp.Vn.userName);l.V13(System.getWindowsCodePage());k.address(this.getNId(),ConnectId.SERVER);this.send(k)};b.prototype.requestRankVotersList=function(e){var f=new WebSockMessage(SockMsgId.LIVE_USER);f.setUserType(LiveMsgId.GUESSMOVE_RANKVOTERSLIST);f.setVal(e);var g=f.getBuf();g.writeInt(e);g.Va(glApp.Vn.userName);g.V13(System.getWindowsCodePage());f.address(this.getNId(),ConnectId.SERVER);
5684this.send(f)};Vk.initForListeners(b);Vk.addEvent(b,"ChangeLogin");Vk.addEvent(b,"ClientChanges");return b}(),LiveTorturer=function(){var a=function(b,c){this.wsUris=[b];this.liveLists=c;this.mustStop=!1;this.cntRobots=0;this.arrRobots=[];this.maxRobotsAllowed=30;0<=getInternetExplorerVersion()&&(this.maxRobotsAllowed=3)};a.prototype.run=function(){this.mustStop=!1;this.createTimer=new Timer(function(){this.periodicCreate()}.bind(this));this.logOffTimer=new Timer(function(){this.periodicLogOff()}.bind(this));
5685this.createTimer.runPeriodic(500);this.logOffTimer.runPeriodic(350);this.guid=new CBGuid;this.guid.fromRandom();this.arrRobots=[]};a.prototype.stop=function(){this.mustStop=!0;this.createTimer.stop();this.logOffTimer.stop();for(var b=0;b<this.arrRobots.length;b++)0<this.arrRobots[b].connectId?(this.arrRobots[b].logOff(),this.arrRobots[b].conn.tryTimer.stop(),LOG("LogOff on Stop")):(this.arrRobots[b].closeConn(),LOG("Close on Stop"))};a.prototype.periodicCreate=function(){this.arrRobots.length<this.maxRobotsAllowed&&
5686this.createRobot()&&LOG("Created Robot, NTot="+this.arrRobots.length+", logged in="+this.countLoggedIn(),"LogGreen")};a.prototype.periodicLogOff=function(){if(this.countLoggedIn()>this.maxRobotsAllowed/2||this.arrRobots.length==this.maxRobotsAllowed){var b=Math.floor(Math.random()*this.arrRobots.length);b<this.arrRobots.length&&(0<this.arrRobots[b].connectId?(this.arrRobots[b].logOff(),LOG("Log Off: "+this.arrRobots[b].connectId,"LogBold")):this.arrRobots[b].isTimeout()&&this.arrRobots[b].closeConn(),
5687this.arrRobots.splice(b,1))}};a.prototype.createRobot=function(){if(this.arrRobots.length<this.maxRobotsAllowed){var b=new CBGuid;b.fromRandom();80<Math.floor(100*Math.random())&&(b=this.guid);b=new LiveConnectionRobot(this,b,this.liveLists);try{return b.logOn(),this.arrRobots.push(b),!0}catch(c){for(LOG(c,"LogException");this.arrRobots.length;)this.arrRobots[0].isLoggedIn()?this.arrRobots[0].logOff():this.arrRobots[0].closeConn(),this.arrRobots.splice(0,1)}}};a.prototype.countLoggedIn=function(){for(var b=
56880,c=0;c<this.arrRobots.length;c+=1)0<this.arrRobots[c].connectId&&(b+=1);return b};return a}(),LiveConnectionRobot=function(){var a=function(b,c,d){this.conn=new Connection(this,b.wsUris);this.conn.tryTimer.stop();this.guid=c;this.liveLists=d};a.prototype.logOn=function(){this.hasIdReceived||(this.tick=new Tick,this.conn.open())};a.prototype.isTimeout=function(){return this.tick&&2E4<this.tick.getExpiredMS()};a.prototype.logOff=function(){try{if(this.hasIdReceived){var b=new WebSockMessage(SockMsgId.LOGOFF);
5689b.address(this.connectId,ConnectId.SERVER);b.buf.V13(0);this.conn.sendMessage(b,!0);this.conn.tryTimer.stop();delete this.tick}}catch(c){LOG(c)}};a.prototype.idReceived=function(b){LOG("idReceived: "+b.nId,"","conn");this.hasIdReceived=!0;this.Vg=0;this.connectId=b.nId;delete this.tick;(new Timer(function(){this.requestLiveLists(this.liveLists)}.bind(this))).runOnce(500)};a.prototype.onConnect=function(){LOG("OnConnect");void 0===this.guid&&(this.guid=new CBGuid,this.guid.fromRandom());var b=new LogonData("Guest",
5690"Guest",LoginMode.GUEST,this.guid,"","robot");this.conn.sendMessage(b.Vi(!1),!0)};
5690a.prototype.closeConn=function(){this.conn.close()};a.prototype.requestLiveLists=function(b){this.liveGameLists=[];for(var c=0;c<b.length;c++){var d=new ServerLiveGameList(this,b[c].ticket,b[c].requestData);this.liveGameLists.push(d)}this.initListKibitzing()};a.prototype.initListKibitzing=function(){if(this.liveGameLists&&this.liveGameLists.length){var b=new WebSockMessage(SockMsgId.LIVE_USER);b.setUserType(LiveMsgId.REQUEST_LISTS);
5691var c=b.getBuf();c.writeInt(this.liveGameLists.length);for(var d=0;d<this.liveGameLists.length;d++)this.requestDataToBuf(this.liveGameLists[d].requestData,c),c.writeInt(this.liveGameLists[d].ticket),this.liveGameLists[d].requested=!0;b.address(this.getNId(),ConnectId.SERVER);this.conn.sendMessage(b,!0)}};a.prototype.requestDataToBuf=function(b,c){c.Va(b.event||"");c.Va(b.round||"");c.Va(b.round2||"");c.Va(b.player||"");c.Va(b.white||"");c.Va(b.black||"");c.Va(b.date||"");c.writeInt(b.kibitzRank)};
5692a.prototype.handleReceived=function(b){try{switch(b.getType()){case SockMsgId.CHAT:this.handleChat(b);break;case SockMsgId.RECONNECT_OK:LOG("Reconnect OK","LogRed");break;case SockMsgId.ALIVE:this.handleAreYouAlive();break;case SockMsgId.DEFAULTGROUPS:this.idBound=b.getBuf().V19();this.boundLoginOk=!0;break;case SockMsgId.LIVE_USER:switch(b.getUserType()){case LiveMsgId.RESPOND_LISTS:this.handleRespondLists(b);break;case LiveMsgId.RESPOND_GAMEDATA:this.handleGameData(b);break;case LiveMsgId.SESSIONACTION:this.handleSessionAction(b)}}}catch(c){LOG("Exception: "+
5693c.toString(),"LogException")}};a.prototype.isLoggedIn=function(){return this.boundLoginOk&&this.conn&&this.conn.isConnected()};a.prototype.handleChat=function(b){var c=new ChatData;c.fromSocketsMsg(b);glApp.panelMgr.chatOut(c.toString())};a.prototype.handleAreYouAlive=function(){LOG("Server -> Robot: AYAlive? boundLogin="+this.boundLoginOk);var b=new WebSockMessage(SockMsgId.IAMALIVE);b.address(this.connectId,ConnectId.SERVER);this.conn.sendMessage(b,!0)};a.prototype.handleGameData=function(b){var c=
5694new ServerGameData;c.fromDataBuf(b.getBuf());c.game.gotoIndex(c.game.getMoveIndex());b=b.getBuf().V19();LOG("Game: "+b,"","rob");if(b=this.getLiveGameList(b))b.onGameData(c)};a.prototype.handleRespondLists=function(b){var c=b.getBuf();b=new ServerGameItemList;b.fromDataBuf(c);c=c.readInt();LOG("List: "+b.games.length,"","rob");if(c=this.getLiveGameList(c))c.onGameItemList(b)};a.prototype.handleSessionAction=function(b){var c=new SessionAction;c.fromDataBuf(b.getBuf());b=b.getBuf().V19();LOG("SAction: "+
5695b);this.getSession(b);if(b=this.getLiveGameList(b))b.onSessionAction(c)};a.prototype.getLiveGameList=function(b){if(this.liveGameLists)for(var c=0;c<this.liveGameLists.length;c++)if(this.liveGameLists[c].ticket==b)return this.liveGameLists[c]};a.prototype.sendChat=function(b){if(this.idBound){var c=new ChatData;c.strMsg=b;c.setToIndividuals(!0);c.idSender=this.idBound;c.setReceivers(this.idBound);c.setAutomatic(!0);b=c.Vi();b.address(this.getNId(),this.getNId());this.conn.sendMessage(b,!0)}};a.prototype.getNId=
5696function(){return this.conn.connectId};return a}();
5697const GuessMoveStatusType={STATUS_UNDEFINED:0,SERVER_MOVE_QUOTE:1,SERVER_CANCELS_BET:2,SERVER_CONFIRMS_BET:3,SERVER_CANNOT_BET:4,SERVER_ALREADY_BET_ON_MOVE:5,SERVER_NOT_CURRENT_MOVE:6,SERVER_BET_TOO_LATE:7,SERVER_NOTIFY_LOST_BET:8,SERVER_NOTIFY_WON_BET:9,SERVER_NOTIFY_WON_JACKPOT:10,SERVER_NOT_ENOUGH_DUCATS:11,SERVER_CANCELS_VOTE:12,SERVER_CONFIRMS_VOTE:13,SERVER_ALREADY_VOTED_ON_MOVE:14,SERVER_NOTIFY_VOTEMOVE_PLAYED:15,SERVER_NOTIFY_VOTEMOVE_NOTPLAYED:16,SERVER_VOTE_TOO_LATE:17,SERVER_NO_SERIAL:18,
5698STATUS_NUM:19},GAMEID_NIL=0;
5699class GuessMoveStatus{constructor(a=GuessMoveStatusType.STATUS_UNDEFINED,b=GAMEID_NIL,c=0,d=0){this.m_eType=a;this.m_fQuote=1;this.m_idGame=b;this.m_nMoveNo=c;this.m_nVotes=0;this.m_nTypedVal=d;this.keys=Object.keys(GuessMoveStatusType).reduce(function(e,f){return e[GuessMoveStatusType[f]]=f,e},{})}getEnum(a){return this.keys[a]}WriteToDataBuffer(a){}ReadFromDataBuffer(a){a.readInt();this.m_eType=a.V19();this.m_idGame=a.V19();this.m_nMoveNo=a.V19();
5699this.m_move=new Move;this.m_move.read(a);a.setPos(a.getPos()+
57004);this.m_nDucats=a.V19();this.m_nCents=a.readUint8();a.setPos(a.getPos()+3);this.m_fQuote=a.readFloat64();this.m_nVotes=a.Vw();this.m_nTypedVal=a.V19();return this.m_eType>=GuessMoveStatusType.STATUS_UNDEFINED&&this.m_eType<GuessMoveStatusType.STATUS_NUM}GetStr(){}GetWinAmount(){}IsWin(){return this.m_eType==GuessMoveStatusType.SERVER_NOTIFY_WON_BET||this.m_eType==GuessMoveStatusType.SERVER_NOTIFY_WON_JACKPOT}}
5701var Tournament=function(){var a=function(){};a.prototype.title=null;a.prototype.arcKey=null;a.prototype.player=null;a.prototype.rounds=null;a.prototype.availbeRounds=null;a.prototype.type=null;a.Types={koTwo:"ko",ko:"k.o.",roundrobin:"tourn",swiss:"swiss",sheveninger:"shev",match:"mat",team:"team"};a.prototype.getPlayerById=function(b){return this.player.filter(function(c){if(c.id==b||c.otherIds&&c.otherIds.contains(parseInt(b)))return!0})[0]};a.prototype.distinctPlayerForRound=function(b){b=this.rounds[b-
57021];for(var c=[],d,e=0;e<b.length;e++)d=b[e],0>c.indexOf(d.white)&&c.push(d.white),0>c.indexOf(d.black)&&c.push(d.black);return c.length};a.fromJson=function(b){return a.fromObject(JSON.parse(b))};a.fromObject=function(b){var c=new a;c.title=b.Tournaments[0].t.split("_").join(" ");c.arcKey=b.Tournaments[0].k;for(var d=[],e=function(m,n){m=(n.f+n.l).trim();for(n=0;n<d.length;n++){var r=d[n].lastName;var t=d[n].firstName;t=(t+r).trim();if(.2>Levenshtein.getDistance(m,t,3,1,1)/Math.max(m.length,t.length))return d[n]}},
5703f=0;f<b.Players.length;f++){var g=b.Players[f],h=e(d,g);h?(h.otherIds=h.otherIds||[],h.otherIds.push(g.i)):d.push(new TablePlayer(g.f,g.l,g.e,g.i))}c.player=d;e=b.Rounds;c.availbeRounds=e;var k=[],l=[];e.forEach(function(m,n,r){k.push([]);k[m-1]=[];l.push([]);l[m-1]=[];for(n=0;n<b["R-"+m+":"].length;n++){r=b["R-"+m+":"][n].b;var t=b["R-"+m+":"][n].p.split(/-|=/),u=c.getPlayerById(t[0]),x=c.getPlayerById(t[1]);t=t[2];if(0>t||2<t)t=null;var B=new Pairing(u,x,t);B.round=m;B.subround=r;t&&k[m-1].push(B);
5704l[m-1].push(B);B=t?t/2:null;var y=t?(2-t)/2:null;t&&(u.opponents.push(new OpponentEntry(x,B,!0,m,r)),x.opponents.push(new OpponentEntry(u,y,!1,m,r)))}}.bind(this));c.rounds=k;c.pairings=l;c.type=b.Tournaments[0].tt;c.strTB=b.Tournaments[0].tb;return c};a.PairingFromJson=function(b){return a.PairingFromObjecct(JSON.parse(b))};a.PairingfromObject=function(b){};return a}(),TablePlayer=function(){var a=function(b,c,d,e,f){this.firstName=b;this.lastName=c;this.elo=d;this.id=e;this.team=f;this.valuation=
5705new Valuation;this.valuation.elo=this.elo;this.valuation.name=this.getPbServerUrl();this.valuation.info=$("<div>",{class:"playerImageContainer"}).append($("<div>",{class:"name"}).html(this.valuation.name));this.valuation.nation=$("<div>",{class:"flag"}).append($("<img>",{class:"flagImg",src:"https://pgn.chessbase.com/Common/Media/Flags/Flags64/United Nations.png"}));this.valuation.title=$("<div>",{class:"title"}).text("");this.opponents=[]};a.prototype.team=null;a.prototype.opponents=null;a.prototype.id=
5706null;a.prototype.firstName=null;a.prototype.lastName=null;a.prototype.elo=null;a.prototype.valuation=null;a.prototype.getName=function(){return this.firstName?this.lastName+","+this.firstName:this.lastName};a.prototype.getDisplayeName=function(){return this.firstName&&this.firstName.length?this.lastName+","+this.firstName.substr(0,1):this.lastName};a.prototype.getFirstOpponentEntryForPlayer=function(b){return this.getAllOpponentEntriesForPlayer(b)[0]};a.prototype.getAllOpponentEntriesForPlayer=function(b){var c=
5707this.opponents.filter(function(d){return d.opponent===b});return c=c||[]};a.prototype.distinctOpponentCount=function(){var b=[];this.opponents.forEach(function(c){0>b.indexOf(c.opponent)&&b.push(c.opponent)});return b.length};a.prototype.getPbServerUrl=function(){this.getName();var b=this.getDisplayeName(),c=$("<a>");c.attr("href",String.formatEx("//players.chessbase.com/player/{0}_{1}?elo={2}",this.lastName,this.firstName,this.valuation.elo));c.text(b);return c.prop("outerHTML")};return a}(),RankingOptions=
5708function(){var a=function(b,c){this.tiebreakInfosArr=b;this.top=c};a.prototype.tiebreakInfosArr=null;a.prototype.top=1E4;return a}(),OpponentEntry=function(){var a=function(b,c,d,e,f){this.opponent=b;this.scoredPoints=c;this.isWhite=d;this.round=e;this.board=f};a.prototype.board=null;a.prototype.opponent=null;a.prototype.scoredPoints=null;a.prototype.isWhite=null;a.prototype.round=null;return a}(),Pairing=function(){var a=function(b,c,d){this.white=b;this.black=c;this.result=d};a.prototype.white=
5709null;a.prototype.black=null;a.prototype.result=null;return a}(),TableResult=function(){var a=function(b){};a.prototype.result=null;return a}(),Round=function(){var a=function(b,c){this.roundNr=b;this.pairingsArr=c};a.prototype.roundNr=null;a.prototype.pairingsArr=null;return a}(),TiebrakeInfo=function(){var a=function(b,c,d){this.propertyName=b;this.cutOffFront=this.streichWertungen=c;this.cutOffEnd=d};a.prototype.cutOffFront=null;a.prototype.cutOffEnd=null;a.prototype.propertyName=null;a.prototype.streichWertungen=
5710null;a.Names={bhz:"Buchholz",dirEnc:"Direct encounter",snb:"Sonneborn-Berger",avgElo:"Average Elo",perf:"Performance",wins:"Wins",bl:"Games with black",prog:"Comulative",blwins:"Wins with black",bhzsum:"Sum of opponents buchholz",koya:"Koya"};a.arrFromString=function(b){if(!b)return[];var c=[],d=/[a-zA-Z]+/;b.split(",").forEach(function(e){var f=d.exec(e)[0],g=e.match(/^\d+|\d+\b|\d+(?=\w)/g);g=g?g.map(function(l){return+l}):[];var h=0,k=0;0<g.length&&(h=g[0]);1<g.length&&(k=g[1]);e.replace(f,"");
5711c.push(new a(f,h,k))});return c};return a}();
5712const Valuation=function(){var a=function(){};a.prototype.points=null;a.prototype.buchholz=null;a.prototype.sonnebornberger=null;a.prototype.wins=null;a.prototype.avgElo=null;a.prototype.eloPerff=null;a.prototype.direkterVergleich=0;return a}(),TableMath=function(){var a={calc:function(c,d,e,f,g,h,k){return a.calcMethods[d](c,d,e||function(){return!0},f,g,h,k)},getOpponents:function(c,d,e){e=c.length-e;e=0>e?0:e;return c.sort(function(f,g){return g.opponent.valuation.points-f.opponent.valuation.points}).slice(d,
5713e)},calculateEloPerf:function(c,d,e,f,g,h){h=0<=h?h:0;d=a.getOpponents(c.opponents.filter(e),g,h).filter(function(k){return null!=k.scoredPoints});c=a.avg(d,function(k){return k.opponent.valuation.elo});d=Math.round(a.sum(d,function(k){return k.scoredPoints})/d.length*100);return c+b.getDiff(d)}
5713,calculatePoints:function(c,d,e,f,g,h,k){return a.sum(c.opponents.filter(e),function(l){return 1==l.scoredPoints?k.win:.5==l.scoredPoints?k.draw:0==l.scoredPoints?k.loss:l.scoredPoints})},calculateBuchHolz:function(c,
5714d,e,f,g,h){c=a.getOpponents(c.opponents.filter(e),g,h);return a.sum(c,a.buildGetPropertyFromOpEntryFunc("points"))},calculateSonnebornBerger:function(c,d,e,f,g,h){var k=0;a.getOpponents(c.opponents.filter(e),g,h).filter(e).forEach(function(l){k+=l.scoredPoints*l.opponent.valuation.points});return k},calculateWins:function(c,d,e,f,g,h){return a.getOpponents(c.opponents.filter(e),g,h).filter(function(k){return 1===k.scoredPoints}).length},calculateBlacks:function(c,d,e,f,g,h){return a.getOpponents(c.opponents.filter(e),
5715g,h).filter(function(k){return!k.isWhite}).length},calculateAvgElo:function(c,d,e,f,g,h){c=a.getOpponents(c.opponents.filter(e),g,h);return a.avg(c,a.buildGetPropertyFromOpEntryFunc("elo"))},calculateDirectEncounter:function(c,d,e,f,g,h){var k=!0,l=c.opponents.filter(function(m){return m.opponent.valuation.points==c.valuation.points});if(0==l.length)return 0;l.map(function(m){return m.opponent}).forEach(function(m){m.opponents.filter(function(n){return n.opponent.valuation.points==m.valuation.points}).length!=
5716l.length&&(k=!1)});return k?a.sum(l,function(m){return m.scoredPoints}):0},calculateComulative:function(c,d,e,f,g,h){c=c.opponents.filter(e);d=0;for(e=1;e<=c.length;e++)d+=e*c[c.length-e];return d},calculateBlackWins:function(c,d,e,f,g,h){return c.opponents.filter(e).filter(function(k){return!k.isWhite}).filter(function(k){return 1==k.scoredPoints}).length},calculateBuchHolzSum:function(c,d,e,f,g,h){c=c.opponents.filter(e);c=a.getOpponents(c,g,h);c=c.filter(function(k){return null!=k.scoredPoints});
5717c.forEach(function(k){k.opponent.valuation.bhz||(k.opponent.valuation.bhz=a.calculateBuchHolz(k.opponent,"bhz",e,f,g,h))});return a.sum(c,function(k){return parseFloat(k.opponent.valuation.bhz)})},calculateBuchHolzMinMax:function(c,d,e,f,g,h){return a.calculateBuchHolz(c,d,e,f,1,1)},calculateKoya:function(c,d,e,f,g,h){c=c.opponents.filter(function(k){return k.opponent.valuation.points>=k.opponent.opponents.length/2});return a.sum(c,function(k){return k.scoredPoints})},sum:function(c,d){var e=0;c.forEach(function(f){e+=
5718d(f)});return e},avg:function(c,d){return a.sum(c,d)/c.length},buildGetPropertyFromOpEntryFunc:function(c){return function(d){return parseFloat(d.opponent.valuation[c])}},max:function(c,d){let e=0;c.forEach(function(f){f=d(f);e=f>e?f:e});return e},min:function(c,d){let e=0;c.forEach(function(f){f=d(f);e=f<e?f:e});return e}};a.calcMethods={points:a.calculatePoints,buchholz:a.calculateBuchHolz,sonnebornberger:a.calculateSonnebornBerger,wins:a.calculateWins,avgElo:a.calculateAvgElo,eloPerf:a.calculateEloPerf,
5719direkterVergleich:a.calculateDirectEncounter,blacks:a.calculateBlacks,bl:a.calculateBlacks,bhz:a.calculateBuchHolz,snb:a.calculateSonnebornBerger,perf:a.calculateEloPerf,dirEnc:a.calculateDirectEncounter,prog:a.calculateComulative,blwins:a.calculateBlackWins,bhzsum:a.calculateBuchHolzSum,bhzminmax:a.calculateBuchHolzMinMax,koya:a.calculateKoya};var b={100:800,99:677,98:589,97:538,96:501,95:470,94:444,93:422,92:401,91:383,90:366,89:351,88:336,87:322,86:309,85:296,84:284,83:273,82:262,81:251,80:240,
572079:230,78:220,77:211,76:202,75:193,74:184,73:175,72:166,71:158,70:149,69:141,68:133,67:125,66:117,65:110,64:102,63:95,62:87,61:80,60:72,59:65,58:57,57:50,56:43,55:36,54:29,53:21,52:14,51:7,50:0,getDiff:function(c){return 50<c?this[c]:-this[100-c]}};return a}(),ArrayToTableConverter=function(){var a=function(){};a.convertToHtmlTable=function(b){var c=$("<table>"),d=$("<thead>"),e=$("<tbody>"),f=TableMath.max(b,function(n){return n.length});let g=$("<tr>");var h=0;b[0].forEach(function(n,r,t){var u=
5721$("<th>");n.colspan&&n.str?(u.html(n.str),u.attr("colspan",n.colspan),h+=n.colspan):(u.html(n),h++);r===t.length-1&&u.attr("colspan",f-h);g.append(u)});d.append(g);for(var k=1;k<b.length;k++){var l=b[k],m=$("<tr>");l.forEach(function(n,r,t){var u;a.isNumberField(n)&&(u="tdNumber");u=$("<td>",{class:u});u.html(n);r===t.length-1&&u.attr("colspan",f-r);m.append(u)});e.append(m)}c.append(d);c.append(e);return c};a.isNumberField=function(b){if(!b)return!1;if(b instanceof Number||"number"===typeof b||!isNaN(b)||
5722b.charCodeAt&&189==b.charCodeAt(0)||b&&$(b).text&&(b=$(b).text(),b instanceof Number||"number"===typeof b||!isNaN(b)||189==b.charCodeAt(0)))return!0};return a}();
5723var PlayerComparer=function(){var a=function(b){this.subComparer=b};a.prototype.subComparer=null;a.prototype.compare=function(b,c){};return a}(),HigherNumberComparer=function(){var a=function(b,c){this.subComparer=b;this.property=c};a.prototype.subComparer=null;a.prototype.property=null;a.prototype.compare=function(b,c){return b.valuation[this.property]===c.valuation[this.property]?this.subComparer?this.subComparer.compare(b,c):0:c.valuation[this.property]-b.valuation[this.property]};return a}(),
5724Comparer=function(){var a=function(){this.comparer=[]};a.prototype.comparer=null;a.prototype.addComparer=function(b){this.comparer.push(b)};a.prototype.removeComparer=function(b){b=this.comparer.indexOf(b);return this.comparer.slice(b)};a.prototype.removeComparerByIndex=function(b){return this.comparer.slice(b,1)};a.prototype.compare=function(b,c){var d=0,e=this.comparer.length;do{var f=this.comparer[d].compare(b,c);d++}while(0==f&&d<e);return f};a.fromTiebrakeInfos=function(b){var c=new a;c.addComparer(new HigherNumberComparer(null,
5725"points"));b.forEach(function(d){c.addComparer(new HigherNumberComparer(null,d.propertyName))});return c};return a}(),KoFormatter=function(){var a=function(){};a.prototype.sortRounds=function(c){var d=c[c.length-1];d.sort(function(h,k){return Math.max(k.white.elo,k.black.valuation.elo)-Math.max(h.white.elo,h.black.valuation.elo)});var e=0,f=[];d.forEach(function(h){var k=h.white.elo>h.black.elo?h.white:h.black;h=h.white.elo>h.black.elo?h.black:h.white;f.contains(k)||(k.sortIndex=++e,f.push(k));f.contains(h)||
5726(h.sortIndex=++e,f.push(h))});var g=1/3;for(d=c.length-2;0<=d;
5726d--)c[d].forEach(function(h){var k=h.white.elo>h.black.elo?h.white:h.black;h=h.white.elo>h.black.elo?h.black:h.white;k.sortIndex&&h.sortIndex||(k.sortIndex?h.sortIndex=k.sortIndex+g:h.sortIndex?k.sortIndex=h.sortIndex-g:console.log("How?"))}),g/=3;c.forEach(function(h){h.sort(function(k,l){return Math.min(k.white.sortIndex,k.black.sortIndex)-Math.min(l.white.sortIndex,l.black.sortIndex)})})};a.prototype.toHtml=function(c,d,e,f){d=c.players;
5727e=c.tournament.rounds;console.log(c);f=c.tournament.availbeRounds;this.sortRounds(e);for(var g=$("<div>",{class:"koContainer"}),h=$("<div>",{class:"koContent"}),k=0;k<f.length;k++){var l=f[k],m=$("<div>",{class:"koRound koRound-"+l});m.append(this.createRoundDiv(e[k],l,d,c));h.append(m)}g.append(h);return g};a.prototype.toHtmlOld=function(c,d,e,f){d=f.width;e=c.players;f=c.tournament.rounds;this.sortRounds(f);var g=c.tournament.availbeRounds,h=$("<div>",{class:"koContainer"}),k=$("<div>",{class:"koHead"});
5728k.append(this.createHead(g,c));for(var l=$("<div>",{class:"koContent"}),m=0;m<g.length;m++){var n=g[m],r=$("<div>",{class:"koRound koRound-"+n});r.append(this.createRoundDiv(f[m],n,e,c));l.append(r)}h.append(k);h.append($("<div>",{class:"koContentContainer"}).append(l));520<=d?h.css("width",500):h.css("width","100%");return h};
5728a.prototype.createHead=function(c,d){var e=$("<div>",{class:"arrowContainer"}),f=$("<div>",{class:"arrowLeftContainer arrowSideContainer"}),g=$("<img>",{src:"https://pgn.chessbase.com/Common/Media/Webimages/Arrow_left.png",
5729class:"arrow arrowLeft"}),h=$("<div>",{class:"arrowRightContainer arrowSideContainer"}),k=$("<img>",{src:"https://pgn.chessbase.com/Common/Media/Webimages/Arrow_right.png",class:"arrow arrowRight"}),l=$("<div>",{class:"roundNrContainer"}),m=$("<div>",{class:"roundNr"});l.append(m);f.append(g);h.append(k);e.append(f);e.append(l);e.append(h);var n=function(y){document.getElementById("koRoundSheet"+y)||(y=$("<style>",{id:"koRoundSheet"+y}).html(".cbtable .koContainer .koRound-"+y+"{display:none}"),$(document.head).append(y))},
5730r=function(y){document.head.removeChild(document.getElementById("koRoundSheet"+y))},t=function(y){f.next().children(".roundNr").text(y)};d.currentRoundIndex=d.currentRoundIndex||c.length-1;d.lastRoundIndex=d.lastRoundIndex||0;var u=d.currentRoundIndex,x=d.lastRoundIndex,B=c.length-1;for(d=0;d<c.length-1;d++)n(c[d]);t(c[c.length-1]);f.on("click",function(){0!=u&&(x=u,u--,t(c[u]),n(c[x]),r(c[u]),0==u&&f.children(".arrow").addClass("inactive"),u+1==B&&h.children(".arrow").removeClass("inactive"))});
5731h.on("click",function(){u!=B&&(x=u,u++,t(c[u]),n(c[x]),r(c[u]),0==u-1&&f.children(".arrow").removeClass("inactive"),u==B&&h.children(".arrow").addClass("inactive"))});u==B&&h.children(".arrow").addClass("inactive");0==u&&f.children(".arrow").addClass("inactive");return e};a.prototype.createRoundDiv=function(c,d,e,f){var g=$("<div>",{class:"koRoundDiv"}),h=[],k=0;e.forEach(function(t){k=Math.max(t.opponents.filter(function(u){return u.round==d}).length,k)});for(e=0;e<c.length;e++){var l=c[e],m=l.white,
5732n=l.black;if(!h.contains(m)&&!h.contains(n)){h.push(m);h.push(n);l=$("<div>",{class:"koMatch"});if(m.sortIndex<n.sortIndex){var r=this.createPlayerLine(m,n,d,f,k);m=this.createPlayerLine(n,m,d,f,k)}else r=this.createPlayerLine(n,m,d,f,k),m=this.createPlayerLine(m,n,d,f,k);l.append(r);l.append(m);g.append(l)}}return g};var b=function(c,d){return c.round!=d.round?c.round-d.round:c.board-d.board};a.prototype.createPlayerLine=function(c,d,e,f,g){c.opponents.sort(b);d=$("<div>",{class:"playerLine"});d.append(this.createPlayerDiv(c));
5733var h=[];c.opponents.filter(function(l){return l.round==e}).forEach(function(l){h.push(f.createGameLink(c,l))});for(var k=h.length;k<g;k++)h.push("-");g=f.getColoredResultsForPlayer(c,e);d.append(this.resultDiv(h,g));return d};a.prototype.createPlayerDiv=function(c){var d=$("<div>",{class:"playerDiv"});d.append($("<div>",{class:"title"}).html($(c.valuation.title.prop("outerHTML"))));d.append($(c.valuation.info.prop("outerHTML")));d.append($("<div>",{class:"rating"}).html(c.valuation.elo));d.append($("<div>",
5734{class:"nation"}).html(c.valuation.nation.prop("outerHTML")));return d};a.prototype.toHtmlOld=function(c,d,e,f){var g=this.buildD2Array(c);e=c.tournament.rounds;f=[];for(var h,k=0;k<c.tournament.availbeRounds.length;k++){var l=[];var m=0;h=k;let r=c.tournament.availbeRounds[k];d=Math.pow(2,r-1)-1;var n=2*d;m+=d;f.push(r);e[r-1].forEach(function(t,u,x){u=t.white;t=t.black;if(!(0<=l.indexOf(u))){l.push(u);l.push(t);var B=c.getResultsForPlayer(u,r);x=c.getResultsForPlayer(t,r);B=this.resultDiv(B);x=
5735this.resultDiv(x);g[m++][h]=u.getPbServerUrl();g[m++][h]=B;g[m++][h]=x;g[m++][h]=t.getPbServerUrl();m+=n}}.bind(this))}g.unshift(f);d=ArrayToTableConverter.convertToHtmlTable(g);d.addClass("cbko");return d};a.prototype.buildD2Array=function(c){var d=2*c.tournament.player.length+4;c=c.tournament.rounds.length;for(var e=[],f=0;f<d;f++){for(var g=[],h=0;h<c;h++)g.push("");e.push(g)}return e};a.prototype.toHtmlOld=function(c,d,e,f){f=c.players;var g=this.buildArray(c);d=c.tournament.rounds;e=[];f.forEach(function(r,
5736t,u){r.kosortrank=t});for(var h=0;h<c.tournament.availbeRounds.length;h++){var k=[];var l=0;let r=h;var m=c.tournament.availbeRounds[h];f=Math.pow(2,m)-2;var n=2*f;l+=f;e.push(m);d[m-1].forEach(function(t,u,x){u=t.white;t=t.black;if(!(0<=k.indexOf(u))){k.push(u);k.push(t);var B=c.getResultsForPlayer(u,m);x=c.getResultsForPlayer(t,m);B=this.resultDiv(B);x=this.resultDiv(x);g[l++][r]=u.getPbServerUrl();g[l++][r]=B;g[l++][r]=x;g[l++][r]=t.getPbServerUrl();l+=n}}.bind(this))}g.shift(e);return ArrayToTableConverter.convertToHtmlTable(g)};
5737a.prototype.resultDiv=function(c,d){var e=$("<div>");e.addClass("resultsBox");for(var f=0;f<c.length;f++){var g=$("<div>");g.html(c[f]);g.addClass("innerResultsBox");f<d.length&&g.addClass(d[f].isWhite?"w":"b");e.append(g)}c=TableMath.sum(d,h=>h.points);d=$("<div>");d.addClass("innerResultsBox");d.html(c);e.append(d);return $("<div>").append(e.clone()).html()};a.prototype.replaceHalf=function(c){return(c+"").split("0.5").join(".5").split(".5").join("&#189;")};a.prototype.getFunction=function(c){return c};
5738a.prototype.buildArray=function(c){var d=2*Math.pow(2,c.tournament.rounds.length);c=c.tournament.rounds.length;for(var e=[],f=0;f<d;f++){for(var g=[],h=0;h<c;h++)g.push("");e.push(g)}return e};return a}(),RoundRobinFormatter=function(){var a=function(){},b=function(c,d){var e=$("<tfoot>"),f=$("<tr>");d=$("<td>",{class:"tbTd",colspan:d});d.text(c);f.append(d);e.append(f);return e};a.prototype.toHtml=function(c,d,e,f){var g=f.width,h=[],k=[];d.forEach(function(r){k.push(r.headerName)});if(450<g)for(var l=
57391;l<=c.players.length;l++)k.push($("<div>",{class:"crossResultHeader"}).html(l));0<e.tiebreakInfosArr.length&&k.push({str:"TB",colspan:1});k.push("Perf.");h.push(k);var m=1;c.players.forEach(function(r){var t=[];d.forEach(function(u){t.push($("<div>",{class:u.propertyName}).html(r.valuation[u.propertyName]).prop("outerHTML"))});450<g&&c.players.forEach(function(u){var x=$("<div>",{class:"crossResult"}),B=r.getAllOpponentEntriesForPlayer(u);m=Math.max(m,B.filter(function(A){return A.scoredPoints}).length);
5740if(u===r)t.push('<div class="samePlayer"></div>');else if(0<B.length){var y=[];u="";4<B.length?u=TableMath.sum(B,function(A){return A.scoredPoints}):(B.forEach(function(A){A=c.createGameLink(r,A);y.push(A)}),u=y.map(function(A){return A.prop("outerHTML")}).join(" "));x.html(u);t.push(x.prop("outerHTML"))}else t.push("")});0<e.tiebreakInfosArr.length&&t.push($("<div>",{class:"tb"}).text(r.valuation[e.tiebreakInfosArr[0].propertyName]));t.push($("<div>",{class:"perf"}).text(r.valuation.perf));h.push(t)});
5741l=ArrayToTableConverter.convertToHtmlTable(h);if(f.caption){f=$("<caption>");var n=String.formatEx('<a href="http://live.chessbase.com/replay/{0}/0?anno=false">{1}</a>',c.tournament.arcKey,c.tournament.title);f.html(n);l.prepend(f)}f=TableMath.max(h,function(r){return r.length});n="TBs: "+e.tiebreakInfosArr.map(function(r){return TiebrakeInfo.Names[r.propertyName]}).join(", ");l.append(b(n,f));l.addClass("cbroundrobin");l.addClass("games-"+m);l.attr("cellpadding","0");return l};return a}(),SwissFormatter=
5742function(){var a=function(){};a.prototype.toHtml=function(b,c,d,e){var f=d.top||1E4;f=Math.min(f,b.players.length);var g=d.tiebreakInfosArr;d=b.players.slice(0,f);var h=[],k=[];c.forEach(function(m){k.push(m.headerName)});k.push({str:"TB",colspan:1});k.push("Perf.");h.push(k);d.forEach(function(m){var n=[];c.forEach(function(r){m.valuation[r.propertyName]instanceof jQuery?n.push($("<div>",{class:r.propertyName}).html($(m.valuation[r.propertyName].prop("outerHTML")))):n.push($("<div>",{class:r.propertyName}).html(m.valuation[r.propertyName]))});
57430<g.length&&n.push($("<div>",{class:"tb"}).html(m.valuation[g[0].propertyName]));n.push($("<div>",{class:"perf"}).text(m.valuation.perf));h.push(n)});d=ArrayToTableConverter.convertToHtmlTable(h);e.caption&&(b=String.formatEx('<a href="http://live.chessbase.com/replay/{0}/0?anno=false">{1}</a>',b.tournament.arcKey,b.tournament.title),e=$("<caption>"),e.html(b),d.prepend(e));var l=TableMath.max(h,function(m){return m.length});b=$("<tfoot>");e=g.map(function(m){return TiebrakeInfo.Names[m.propertyName]}).join(", ");
5744f=$("<tr>");l=$("<td>",{colspan:l});l.text("TBs: "+e);f.append(l);b.append(f);d.append(b);d.addClass("cbswiss");return d};a.prototype.toHtmlold=function(b,c,d,e){var f=d.top||1E4,g=d.tiebreakInfosArr;d=b.players;var h=$("<table>",{class:"simple_table"});e.caption&&(e=$("<caption>"),b=String.formatEx('<a href="http://live.chessbase.com/replay/{0}/0?anno=false">{0}</a>',b.tournament.title.split(" ").join("_")),e.html(b),h.append(e));b=$("<thead>");var k=$("<tbody>"),l=$("<tr>");
5744c.forEach(function(n){var r=
5745$("<th>");r.text(n.headerName);l.append(r)});e=$("<th>");e.text("Tiebrakers");e.attr("colspan",g.length);l.append(e);e=$("<tfoot>");e.text("TBs");b.append(l);h.append(b);h.append(e);var m=function(n,r){return function(t){var u=$("<td>");(n.valuation[t.propertyName]instanceof Number||"number"===typeof n.valuation[t.propertyName])&&u.addClass("tdNumber");u.html(n.valuation[t.propertyName]);r.append(u)}};d.filter(function(n){return n.valuation.rank<=f}).forEach(function(n){var r=$("<tr>");n=m(n,r);c.forEach(n);
5746g.forEach(n);k.append(r)});h.append(k);return h};return a}(),ITableFormatter=function(){var a=function(){};a.prototype.toHtml=function(b,c,d,e){};return a}(),TablePropertiesDeclarer=function(){var a=function(b,c){this.propertyName=b;this.headerName=c};a.prototype.propertyName=null;a.prototype.headerName=null;return a}(),MatchFormatter=function(){var a=function(){};a.prototype.toHtml=function(b,c,d,e){c=e.width||4E4;this.ranking=b;d=[];d.push([]);var f=b.players[0],g=b.players[1],h=f.valuation.nation||
5747g.valuation.nation,k=f.valuation.title||g.valuation.title,l=f.valuation.elo||g.valuation.elo,m=e.withPic&&(f.valuation.picture||g.valuation.picture);d.push(this.formPlayerLine(f,450<c,h,k,l,m));d.push(this.formPlayerLine(g,450<c,h,k,l,m));c=ArrayToTableConverter.convertToHtmlTable(d);e.caption&&(e=$("<caption>"),b=String.formatEx('<a href="http://live.chessbase.com/replay/{0}/0?anno=false">{1}</a>',b.tournament.arcKey,b.tournament.title),e.html(b),c.prepend(e));c.addClass("cbmatch");return c};a.prototype.formPlayerLine=
5748function(b,c,d,e,f,g){var h=[];e&&h.push($("<div>",{class:"title"}).html(b.valuation.title));h.push($("<div>",{class:"name"}).html(b.getPbServerUrl()));g&&h.push($("<div>",{class:"picture"}).html(b.valuation.picture));d&&h.push($("<div>",{class:"nation"}).html(b.valuation.nation));f&&h.push($("<div>",{class:"elo"}).html(b.valuation.elo));d=b.opponents.sort(function(k,l){return k.round-l.round});c&&d.forEach(function(k){h.push($("<div>",{class:"crossResult"}).html(this.ranking.createGameLink(b,k)).prop("outerHTML"))}.bind(this));
5749c=TableMath.sum(d,function(k){return k.scoredPoints});h.push($("<div>",{class:"points"}).text(c).prop("outerHTML"));return h};return a}(),SheveningerFormatter=function(){var a=function(){};a.prototype.toHtml=function(b,c,d,e){d=this._getTeams(b);c=d[0];var f=d[1];d=function(l,m){return m.valuation.points-l.valuation.points};c.sort(d);f.sort(d);d=$("<table>",{class:"shev"});var g=$("<tbody>"),h=$("<tr>");h.append($("<td>"));var k=0;f.forEach(function(l){var m=$("<td>",{class:"shev-rotate"});this._getPlayerDiv(l);
5750m.html(this._getPlayerDiv(l));l=l.getDisplayeName().length;k=Math.max(k,5*l+48);h.append(m)}.bind(this));g.append(h);c.forEach(function(l){var m=$("<tr>"),n=$("<td>");m.append(n);n.append(this._getPlayerDiv(l));f.forEach(function(r){l.getAllOpponentEntriesForPlayer(r).forEach(function(t){var u=$("<td>");u.html(b.createGameLink(l,t));m.append(u)})});g.append(m)}.bind(this));d.append(g);d.css("margin-top",Math.sqrt(Math.pow(k,2)));return d};a.prototype._getPlayerDiv=function(b){var c=$("<div>",{class:"outerPlayerDiv"}),
5751d=$("<div>",{class:"playerDiv"});d.append(b.valuation.nation);d.append(b.valuation.title);d.append(b.getPbServerUrl());d.append(b.valuation.elo);c.append(d);return d};a.prototype._getTeams=function(b){var c=[],d=[],e=b.players[0];e.opponents.forEach(function(h){d.push(h.opponent)});c.push(e);var f=d,g=c;for(e=0;c.length+d.length<b.players.length&&5>e;)b.players.forEach(function(h){if(c.contains(h))f=c,g=d;else if(d.contains(h))f=d,g=c;else return;if(h.opponents.some(function(k){return f.contains(k.opponent)}))return!1;
5752g.merge(h.opponents.map(function(k){return k.opponent}))}),e++;return[c,d]};return a}();Array.prototype.contains||(Array.prototype.contains=function(a){return 0<=this.indexOf(a)});Array.prototype.merge||(Array.prototype.merge=function(a){a||=[];a.forEach(function(b){this.contains(b)||this.push(b)}.bind(this))});
5753var Ranking=function(){var a=function(e,f,g,h,k){this.tournament=e;this.round=f;this.rankingOptions=g;this.formatOptions=h;this.players=this.tournament.player;this.tableOptions=k;this.pointMult={win:this.tableOptions.pointsWin,draw:this.tableOptions.pointsDraw,loss:this.tableOptions.pointsLoss};this.init()};a.prototype.tournament=null;a.prototype.round=null;a.prototype.rankingOptions=null;a.prototype.players=null;a.prototype.pointMult=null;a.prototype.tableOptions=null;a.prototype.htmlFormatter={swiss:new SwissFormatter,
5754tourn:new RoundRobinFormatter,rapid:new SwissFormatter,ko:new KoFormatter,match:new MatchFormatter,shev:new SheveningerFormatter,getFormatter:function(e){return this[e]||this.swiss}};a.prototype.htmlFormatter[Tournament.Types.swiss]=a.prototype.htmlFormatter.swiss;a.prototype.htmlFormatter[Tournament.Types.roundrobin]=a.prototype.htmlFormatter.tourn;a.prototype.htmlFormatter[Tournament.Types.ko]=a.prototype.htmlFormatter.ko;a.prototype.htmlFormatter[Tournament.Types.match]=a.prototype.htmlFormatter.match;
5755a.prototype.htmlFormatter[Tournament.Types.sheveninger]=a.prototype.htmlFormatter.shev;a.prototype.htmlFormatter[Tournament.Types.koTwo]=a.prototype.htmlFormatter.ko;a.prototype.htmlFormatter[Tournament.Types.team]=a.prototype.htmlFormatter.swiss;a.connected=!1;a.lobby=null;var b=function(e){return!("bye"==e.lastName.toLowerCase()||"bye"==e.firstName.toLowerCase())},c=function(e,f,g,h){e=$("<div>",{class:"player-opponent-box"});var k=$("<div>",{class:"player-opponent-lines"});
5755h.opponents.forEach(function(l,
5756m){var n=k.append,r=l.round,t=l.opponent.imgSource,u=l.opponent.valuation.nation.html(),x=l.opponent.valuation.title.html();l=String.f('<div class="opponent-line"><div class="opponent-line-round">{0}</div><div class="opponent-line-flag">{2}</div><div class ="opponent-line-title">{3}</div><div class="opponent-line-name">{4}</div><div class="opponent-line-elo">{5}</div><div class="opponent-line-color color-{6}"></div><div class="opponent-line-result">{7}</div></div>',r,t,u,x,l.opponent.valuation.name,
5757l.opponent.valuation.elo,l.isWhite?"white":"black",.5==l.scoredPoints?"&#189;":l.scoredPoints);n.call(k,l);m!=h.opponents.length-1&&k.append($("<hr>",{class:"opponent-line-seperator"}))});e.append(k);return e},d=function(e,f,g,h,k){e=TableMath.calc(h,"avgElo",function(l){return 100<l.opponent.valuation.elo},null,0,0,0);e=Math.round(e);k=TableMath.calc(h,"points",function(l){return!0},null,0,0,k);h=TableMath.sum(h.opponents,function(l){return null!=l.scoredPoints});return String.f('<div class="player-avg-line"><div class ="player-avg-line-avgelo inline-block">&#216 {0}</div><div class ="player-avg-line-points inline-block">{1}/{2}</div></div>',
5758e,k,h)};a.prototype.startGetPlayerFlag=async function(e){var f=[],g=function(r){var t=[];$(".cbtable tr, .cbpairing tr, .cbtable .playerDiv").each(function(u,x,B){$(x).find(".name a").each(function(y,A,aa){$(A).text()==r.getDisplayeName()&&t.push({row:x,index:y})})});return t},h=function(r,t){var u=g(r);r.imgSource=t.pic?window.URL.createObjectURL(new Blob([new Uint8Array(t.pic)],{type:"img/png"})):"";u.forEach(function(x,B){B=x.row;var y=x.index,A=(new Nation(t.player.m_NewCBPlayer.m_HighData.m_aNation)).getStrFlag();
5759A=String.formatEx("https://pgn.chessbase.com/Common/Media/Flags/Flags{1}/{0}.png",A,64);$(B).find(".flagImg");$($(B).find(".flagImg")[y]).attr("src",A);r.valuation.nation.find(".flagImg").attr("src",A);B=x.row;x=x.index;y=CBTitle.getStr(t.player.m_NewCBPlayer.m_HighData.m_aTitle);$($(B).find(".title")[x]).text(y);r.valuation.title.text(y)})},k=this,l=function(r,t){g(r).forEach(function(u,x){x=u.row;u=u.index;var B=k.pointMult,y=$("<span>",{class:"player-info-container"});var A=r.imgSource;var aa=
5760r.valuation.nation.html(),ha=r.valuation.title.html();A=String.formatEx('<div class="player-info-box"><div class="player-info-picture"><img src={0}></img></div><div class="player-info-personal"><div class="player-info-namerow"><div class="player-info-nation inline-block">{1}</div><div class ="player-info-title inline-block">{2}</div><div class ="player-info-name inline-block">{3}</div><div class ="player-info-elo inline-block">{4}</div></div></div></div>',A,aa,ha,r.valuation.name,r.valuation.elo);
5761A=$(A);aa=c(x,t,u,r);B=d(x,t,u,r,B);y.append(A);y.append($("<hr>",{class:"player-opponent-box-seperator"}));y.append(aa);y.append($("<hr>",{class:"opponent-average-box-seperator"}));y.append(B);$($(x).find(".playerImageContainer")[u]).append(y);r.valuation.info.append(y.prop("outerHTML"))})},m=[];m=e;var n=[];e=m.map(r=>glApp.playerLobby.localPB.getPlayer(r.firstName,r.lastName,0,0));e=await Promise.all(e);f=e.map((r,t)=>r?{player:m[t],data:r.player}:null).filter(r=>r);n=e.map((r,t)=>r?null:m[t]);
5762n=n.filter(r=>r);glApp.playerLobby.requestMultiPlayerInfo(n,function(r){for(var t=0;t<n.length;t++)f.push({player:n[t],data:r[t]});for(t=0;t<f.length;t++)0!=f[t].data.found&&h(f[t].player,f[t].data);for(t=0;t<f.length;t++)0!=f[t].data.found&&l(f[t].player,f[t].data)},!0)};a.prototype.determinType=function(){return this._isKO()?Tournament.Types.ko:this._isMatch()?Tournament.Types.match:this._isScheveninger()?Tournament.Types.sheveninger:this._isRoundRobin()?Tournament.Types.roundrobin:Tournament.Types.swiss};
5763a.prototype.determinTypeSoft=function(){if(this._isMatch())return Tournament.Types.match;if(this._isKO())return Tournament.Types.ko;if(this._isRoundRobin())return Tournament.Types.roundrobin;if(this._isTeamTourn()||this.tournament.type==Tournament.Types.roundrobin&&20<this.tournament.player.length)return Tournament.Types.team};a.prototype._isMatch=function(){return 2==this.players.length};a.prototype._isKO=function(){for(var e=this.tournament.availbeRounds.length,f=this.tournament.distinctPlayerForRound(this.tournament.availbeRounds[0]),
5764g=!1,h=1;h<e&&4<f;h++){g=!0;var k=this.tournament.distinctPlayerForRound(this.tournament.availbeRounds[h]);f/=k;if(1.8>f||2.2<f)return!1;f=k}return g};a.prototype._isTeamTourn=function(){return this.players.all(function(e){return e.team})};a.prototype._isRoundRobin=function(){var e=this.players.length;if(this.tournament.rounds.length+1===e||12>=e)return!0};a.prototype._isScheveninger=function(){if(3>this.tournament.rounds.length)return!1;var e=[],f=[],g=this.players[0];
5764g.opponents.forEach(function(m){f.push(m.opponent)});
5765e.push(g);var h=!0,k=f,l=e;h=!0;for(g=0;e.length+f.length<this.players.length&&5>g;)this.players.forEach(function(m){e.contains(m)?(k=e,l=f):f.contains(m)?(k=f,l=e):h=!1;m.opponents.some(function(n){return k.contains(n.opponent)})&&(h=!1);l.merge(m.opponents.map(function(n){return n.opponent}))}.bind(this)),g++;return h&&e.length==f.length&&e.length<=this.players.length/2};a.prototype.init=function(){this.tournament.type=this.tournament.type?this.determinTypeSoft()||this.tournament.type:this.determinType();
5766var e=0<this.round&&"0"!=this.round?function(h){return h.round<=this.round}.bind(this):function(h){return!0};this.players.forEach(function(h){h.allOpponents=h.opponents;h.opponents=h.opponents.filter(e)});this.players.forEach(function(h){h.valuation.points=TableMath.calc(h,"points",e,this.players,0,0,this.pointMult);null!=h.valuation.points&&void 0!=h.valuation.points&&(h.valuation.points=h.valuation.points.toFixed(1));h.valuation.gCount=h.opponents.filter(function(k){return void 0!=k.scoredPoints}).length}.bind(this));
5767this.rankingOptions.tiebreakInfosArr&&this.rankingOptions.tiebreakInfosArr.length||(this.tournament.type==Tournament.Types.swiss?this.rankingOptions.tiebreakInfosArr=[{propertyName:"bhz",cutOffFront:0,cutOffEnd:0}]:this.tournament.type==Tournament.Types.roundrobin&&(this.rankingOptions.tiebreakInfosArr=[{propertyName:"snb",cutOffFront:0,cutOffEnd:0}]));this.rankingOptions.tiebreakInfosArr.forEach(function(h){this.players.forEach(function(k){var l=TableMath.calc(k,h.propertyName,e,this.players,h.cutOffFront,
5768h.cutOffEnd);l=void 0!=l&&null!=l&&l.toFixed?l.toFixed(2):l;k.valuation[h.propertyName]=l}.bind(this))}.bind(this));this.players.forEach(function(h){h.valuation.perf=TableMath.calc(h,"perf",function(){return!0},this.players,0,0).toFixed(0);h.valuation.perf=isNaN(h.valuation.perf)?0:h.valuation.perf}.bind(this));var f=Comparer.fromTiebrakeInfos(this.rankingOptions.tiebreakInfosArr);f.addComparer(new HigherNumberComparer(null,"elo"));this.players.sort(f.compare.bind(f));this.players=this.players.filter(b);
5769for(var g=this.players[0].valuation.rank=1;g<this.players.length;g++)0===f.compare(this.players[g],this.players[g-1])?this.players[g].valuation.rank=this.players[g-1].valuation.rank:this.players[g].valuation.rank=g+1};a.prototype.createGameLink=function(e,f){var g=$("<a>");if(f.isWhite){e=e.lastName;var h=f.opponent.lastName}else h=e.lastName,e=f.opponent.lastName;e=String.formatEx("https://live.chessbase.com/replay/{2}/?w={0}&b={1}",e,h,this.tournament.arcKey.split(" ").join("_"));g.attr("href",
5770e);null!=f.scoredPoints&&(f=f.scoredPoints.toString().split("0.5").join(".5").split(".5").join("&#189;"),g.html(f));return g};a.prototype.getResultsForPlayer=function(e,f){return e.opponents.filter(function(g){return g.round==f}).sort(function(g,h){return parseInt(g.board)-parseInt(h.board)}).map(function(g){return g.scoredPoints})};a.prototype.getColoredResultsForPlayer=function(e,f){return e.opponents.filter(g=>g.round==f).sort((g,h)=>parseInt(g.board)-parseInt(h.board)).map(g=>({isWhite:g.isWhite,
5771points:g.scoredPoints}))};a.prototype.toHtml=function(e){e||=1E5;var f=[];f.push(new TablePropertiesDeclarer("rank","Rk."));System.isMobile()||f.push(new TablePropertiesDeclarer("title",""));f.push(new TablePropertiesDeclarer("info","Name"));f.push(new TablePropertiesDeclarer("elo","Rtg."));System.isMobile()||f.push(new TablePropertiesDeclarer("nation","Nt."));f.push(new TablePropertiesDeclarer("points","Pts."));f.push(new TablePropertiesDeclarer("gCount","n"));this.formatOptions.width=e;return this.htmlFormatter.getFormatter(this.tournament.type).toHtml(this,
5772f,this.rankingOptions,this.formatOptions)};a.prototype.calcPoints=function(e,f){return TableMath.sum(e.allOpponents.filter(function(g){return!f||g.round<f}),function(g){return this.getPoints(g.scoredPoints)}.bind(this))};a.prototype.getPoints=function(e){return 1==e?this.pointMult.win:.5==e?this.pointMult.draw:0==e?this.pointMult.loss:e};Vk.initForListeners(a);Vk.addEvent(a,"Changed");return a}(),Pairings=function(){var a=function(b){this.ranking=b;this.init()};a.prototype.ranking=null;a.prototype.init=
5773function(){for(var b=function(f){return function(g,h){var k=g.white.valuation["points"+f]+g.black.valuation["points"+f]-(h.white.valuation["points"+f]+h.black.valuation["points"+f]);return 0!=k?-k:-(Math.max(g.white.valuation.elo,g.black.valuation.elo)-Math.max(h.white.valuation.elo,h.black.valuation.elo))}},c=this.ranking.tournament.pairings,d=[],e=0;e<c.length;e++)d.push(this.createPairingsRound(c[e],this.ranking.tournament.availbeRounds[e])),d[e].sort(b(this.ranking.tournament.availbeRounds[e]));
5774this.pairings=d};a.prototype.createPairingsRound=function(b,c){var d=[];b.forEach(function(e){e.white.valuation["points"+c]=this.ranking.calcPoints(e.white,c);e.black.valuation["points"+c]=this.ranking.calcPoints(e.black,c);d.push(e)}.bind(this));d.roundNr=c;return d};a.prototype.RoundToHtml=function(b){var c=this.pairings[b-1];if(!c)return $("<div data-error='no pairings'>");var d=[];d.push(" Name Rtg. Nt. Pts.  Pts.  Name Rtg Nt.".split(" "));c=c.slice(0,this.ranking.tableOptions.top||1E4);
5774c.forEach(function(e){var f=
5775[],g=e.white,h=e.black;f.push(g.valuation.title);f.push(g.valuation.info);f.push(g.valuation.elo);f.push(g.valuation.nation);f.push($("<div>",{class:"points"}).html(this.FancyFraction(g.valuation["points"+b])));f.push(this.createResultLink(e,b));f.push($("<div>",{class:"points"}).html(this.FancyFraction(h.valuation["points"+b])));f.push(h.valuation.title);f.push($(h.valuation.info.prop("outerHTML")));f.push(h.valuation.elo);f.push(h.valuation.nation);d.push(f)}.bind(this));return ArrayToTableConverter.convertToHtmlTable(d)};
5776a.prototype.createResultLink=function(b,c){var d=b.result/2,e=1-d;null===b.result&&(d=e="&nbsp;");b=String.formatEx("http://live.chessbase.com/replay/{2}/{3}/?w={0}&b={1}",b.white.lastName,b.black.lastName,this.ranking.tournament.arcKey.split(" ").join("_"),c);return $("<a>").attr("href",b).html($("<div>",{class:"result"}).html(this.FancyFraction(d+"-"+e)))};a.prototype.FancyFraction=function(b){return b.toString().split("0.5").join(".5").split(".5").join("&#189;")};Vk.initForListeners(a);Vk.addEvent(a,
5777"Changed");return a}();"use strict";
5778class PluginManager{constructor(){$(window).unbind("resize");$(window).on("resize",this.resize.bind(this));this.elementsThatNeedDestroy=[]}init(){this.is3D=!1;this.boardTimer=[];this.nActivePlugin=-1;this.instantiated=!1;this.enableShortcuts=this.hasPlugins=!0;this.prevWindowWidth=window.innerWidth;this.prevWindowHeight=window.innerHeight;this.socialMedia=!0;this.socialMediaUrl="https://share.chessbase.com/SharedGames"}calcIsVerticalLayout(){this.isVerti=1.15*window.innerWidth<window.innerHeight&&
5779600>window.innerWidth}isVerticalScreen(){return 1.2*window.innerWidth<window.innerHeight}createDiv(a,b){var c=document.createElement("div");c.id=a;"undefined"!=typeof b&&(c.id+=b);c.className=a;return c}createEl(a,b,c){a=document.createElement(a);b&&(a.id=b+(c||0),a.className=b);return a}createUL(a,b,c){var d=document.createElement("ul");a&&(d.id=a+(b||0),d.className=a);c.forEach(function(e){var f=document.createElement("li");d.appendChild(f);$(f).text(e||0)});return d}createJQMenu(a,b,c,d,e,f,g){if(a){var h=
57800;c.forEach(function(t){t&&t.length>h&&(h=t.length)});$(a).remove("#"+b+d);var k=this.createDiv(b,d),l=this.createEl("ul","ul"+b,d);$(k).css("z-index",350);if(c.length){for(var m=0;m<c.length;m++){var n=this.createEl("li",b+"-item-"+m+"-",d);c[m]?$(n).html('<a href="#">'+c[m]+"</a>"):$(n).attr("type","separator");l.appendChild(n)}k.appendChild(l);$(a).append(k);var r=$("#"+b+d);r.jqxMenu({autoOpenPopup:g,mode:"popup",width:16+9*h,animationShowDuration:0,animationHideDuration:0,animationHideDelay:0,
5781animationShowDelay:0,autoCloseInterval:0,popupZIndex:99999});r.on("itemclick",function(t){var u=t.args.id.match(/[-][0-9]*[-]/),x=u[0].substring(1,u[0].length-1);e(x,t);r.jqxMenu("close");$(a).remove("#"+b+u)});r.on("closed",function(){f&&f();$(a).remove("#"+b+d)})}r[0].dataset.itemcount=c.length;return r[0]}}togglePopup(a,b,c,d){if(c)return $(a).jqxMenu("close"),!1;var e=a.dataset.itemcount;c=$(window).scrollTop();var f=$(window).scrollLeft(),g=b.clientX-20;5>g&&(g=5);var h=0;System.isMobile()&&
5782(h=2);b=b.clientY-Math.max(60,30+(25+h)*e)+(d||0);$(a).jqxMenu("open",g+f,b+c);System.isMobile()&&$(".jqx-item").css("font-size","18px");return!0}_createCanvasParent(a){var b=new CanvasParent(a);b.setSize(a.offsetWidth,a.offsetHeight);b.setVisible(!0);return b}stopResizeGate(){resizeGate.stop()}resize(a,b){this.prevWindowWidth||(this.prevWindowWidth=window.innerWidth);this.prevWindowHeight||(this.prevWindowHeight=window.innerHeight);((10<Math.abs(window.innerWidth-this.prevWindowWidth)||150<Math.abs(window.innerHeight-
5783this.prevWindowHeight)||!System.isMobile())&&(window.innerWidth!=this.prevWindowWidth||window.innerHeight-this.prevWindowHeight)||b)&&resizeGate.exec(function(){0<=this.maximized&&this.fnFullWindow(this.maximized);this.checkRecreateOrientation()||(this.resizePlugins(),this.prevWindowWidth=window.innerWidth,this.prevWindowHeight=window.innerHeight)}.bind(this),200)}resizePlugins(){var a=0;$(this.allPluginClasses).each(function(b,c){this.resizePlugin($(c),a);a++}.bind(this))}launchResizeBoard(a,b,c,
5784d){this.boardTimer[a]&&this.boardTimer[a].stop();this.boardTimer[a]=new Timer(function(){this.modules[a].boardArea&&this.resizeBoard(a,b,c)}.bind(this));this.boardTimer[a].runOnce(d)}resizeBoard(a,b,c){this.boardTimer[a]&&this.boardTimer[a].stop();this.modules[a].boardArea.setPosSize(0,0,b,c);this.modules[a].multiBoardCanvas&&this.modules[a].multiBoardCanvas.setPosSize(0,0,b,c)}isMobileLayout(){return this.isVerticalScreen()}checkRecreateOrientation(){this.currentMobileLayout!==this.isMobileLayout()&&
5785(this.recycled=[],this.destroyBoardMessage(),$(this.allPluginClasses).each(function(a,b){this.recycled[a]={};this.recycled[a].boardArea=this.modules[a].boardArea;this.recycled[a].boardWin=this.modules[a].boardArea.canvas.control.boards[0];this.recycled[a].kernel=this.modules[a].getKernel();$(b).empty()}.bind(this)),this.init(),this.createPlugins(),this.onRecreate())}onRecreate(){}checkBoardAreaChange(a,b,c){if(this.modules[c].boardAreaW==a&&this.modules[c].boardAreaH==b)return!1;this.modules[c].boardAreaW=
5786a;this.modules[c].boardAreaH=b;return!0}resizeActivePlugin(){this.resizePlugin($($(this.allPluginClasses)[this.nActivePlugin]),this.nActivePlugin)}isOnChessBaseCom(){return System.runsOnChessBaseNews()}instantiateButtons(a,b,c,d,e,f){for(var g="",h=0;h<d.length;h++){if(d[h].title){var k=e;d[h].css&&(k+=" "+d[h].css);var l="";d[h].subtxt?l=String.f("<span class='btnSubText'>{0}</span>",d[h].subtxt):d[h].txt&&(l=d[h].txt);g+=String.f('<{6} title="{0}" id="{4}-btn{1}-{2}" class="{3}">{5}</{6}>',d[h].title,
5787d[h].id,f,k,c,l,a)}else g+='<span class="toolBtnSep"></span>';this.buttonImages[f]||(this.buttonImages[f]={});this.buttonImages[f][d[h].id]=d[h].id;d[h].pic&&(this.buttonImages[f][d[h].id]=d[h].pic)}$(b).html(g);let m=this;for(h=0;h<d.length;h++)d[h].id&&(a=$(String.f("#{2}-btn{0}-{1}",d[h].id,f,c)),b=function(n,r){return function(t){m.nActivePlugin=r;d[n].handler(r,t);t.preventDefault()}}.call(this,h,f),function(n,r){return function(t){this.nActivePlugin=r;t.preventDefault()}}.call(this,h,f),a[0]&&
5788(a[0].onclick=b))}setButtonImages(a,b,c,d,e,f,g){if(b)for(var h='url( "'+getCommonPath()+'Media/Ribbons/{2}/{0}{1}.png" )',k=0;k<b.length;k++)if(b[k].id&&this.buttonImages[e]){var l=$(String.f("#{2}-btn{0}-{1}",b[k].id,e,a));l.css("background-image",String.f(h,this.buttonImages[e][b[k].id],c,f));g&&l.css("background-position",g);var m=d;b[k].css&&(m+=" "+b[k].css);l.attr("class",m)}}getKernel(){if("undefined"!=typeof this.nActivePlugin){if(this.modules[this.nActivePlugin]&&this.modules[this.nActivePlugin].getKernel())return this.modules[this.nActivePlugin].getKernel()}else if(this.modules&&
5789this.modules[0])return this.modules[0].getKernel();return null}showPosText(a,b){}showMessage(a,b){this.showBoardMessage(a,b||2E3)}showBoardMessage(a,b){this.getKernel()&&this.getKernel().boardWin&&(this.getKernel().boardWin.addMessage(a,!0),b&&(new Timer(function(){this.getKernel()&&this.getKernel().boardWin&&this.getKernel().boardWin.destroyMessage()}.bind(this))).runOnce(b))}create2DBoardArea(a){$("#boardArea"+a).empty();this.modules[a].boardArea=this._createCanvasParent(this.modules[a].panels.boardParent);
5790this.modules[a].boardArea.setVisible(!0);this.resize();this.resizePlugins()}create3DBoardArea(a){$("#boardArea"+a).empty();this.modules[a].boardArea=this._createCanvasParent3D(this.modules[a].panels.boardParent,a);this.modules[a].boardArea.setVisible(!0);this.resize();this.resizePlugins()}_createCanvasParent3D(a,b){throw Error("No 3D");}on3DLoaded(a){this.modules[a].getKernel().setBoardWin(this.modules[a].board3d)}onControlReady(){}getBoardTopOffset(){return Math.min(30,window.innerHeight/35)}toggle3DBoard(a){LogStats("Toggle3D");
5791this.is3D?this.create2DBoardArea(a):this.create3DBoardArea(a);this.is3D=!this.is3D}getMultiBoardOptions(){return{topDist:0,bottomDist:0,marginDistDivisor:60,shiftXPercent:-1.7,minWForCoordinates:260,splitLayout:!0,suppressCalcGeometry:!0}}setAutoShowEngine(){}getSplitterWidth(){return System.isMobile()?8:1800<screen.width?7:6}saveSplitSize(a,b){try{var c=$("#"+a+b);if(c.length){var d=$(c).jqxSplitter("panels");d&&d[0]&&glApp.Vn.save(a+"size",d[0].size)}}catch(e){LogException("RWM:saveSplitSize",e)}}loadSplitSize(a,
5792b){a=glApp.Vn.load(a+"size");return{size:parseFloat(a),coll:!1}}setSplitSize(a,b,c){$("#"+a+b).jqxSplitter({width:"100%",height:"100%",panels:[{size:c+"%"},{size:100-c+"%"}]})}createDiagramPlayingMode(a){return new PlayingMode}useBackgroundFilter(){return!1}useMatBalanceDefault(){return!0}pgnLinkClickHandler(a,b,c){document.getElementById(b);glApp.isPremium()||glApp.forceGuestLogon()?(c=c(),b=PGNWriter.toPGN(c),c=(c.hdr.getStrPlayers(!1,0)||"game")+".pgn",window.Blob?(console.log("Blob DL: "+c),b=
5793new Blob([b],{type:"text/plain;charset=utf-8"}),window.saveAs(b,c),a.preventDefault()):0<System.getIEVersion()&&(window.clipboardData&&clipboardData.setData&&(alert("On Internet Explorer the game has been pasted to the clipboard ('Ctrl-V')"),clipboardData.setData("Text",b)),a.preventDefault()),LogStats("PGN")):(alert("You need a Premium Account to download PGN files."),a.preventDefault())}pastePgn(a){navigator.clipboard&&navigator.clipboard.readText().then(function(b){var c=new Game;c.assign(PGN.parseGame(b));
5794c.getMainLine().length?this.getKernel().Vp.loadGame(c):this.showMessage("No game in clip board")}.bind(this))}editGameHeader(){var a=glApp.panelMgr.getKernel();a&&FormseditGameHeader(a.game.hdr,function(b){a.game.hdr=b;a.game.fireOnHeaderChanged()})}onFormOpen(){this.enableShortcuts=!1}onFormClose(){this.enableShortcuts=!0}isAnnoFieldVisible(){return this.annoField&&this.annoField.is(":visible")}openAnnoField(){this.addAnnoField()}closeAnnoField(){this.removeAnnoField()}isAnnoFieldOpen(){return this.isAnnoFieldVisible}toggleAnnoField(){this.isAnnoFieldVisible()?
5795this.removeAnnoField():this.addAnnoField()}addAnnoField(){void 0===this.annoField?($("#annoEdit")[0]&&$("#annoEdit").remove(),this.annoField=createTextField("annoEdit","","Enter text annotation",function(a,b){glApp.panelMgr.getKernel().onAnnoEnter(a,b)})):this.annoField.show();$(this.annoField).insertBefore("#notaToolbar0");$(this.annoField).focus();this.enableShortcuts=!1}removeAnnoField(){$(this.annoField).blur();$(this.annoField).hide();delete this.annoField;this.enableShortcuts=!0}setAnnoFieldText(a){void 0!==
5796this.annoField&&$(this.annoField).val(a)}fitsHorizontally(a,b){var c=window.innerWidth,d=$("#"+a).outerWidth();a=$("#"+a)[0].getBoundingClientRect();return(a.x||a.left)+d+b<c}
5796adaptRibbonButtons(a,b){if(0!=a.length){System.runsInIFrame()&&($("#idLoginStart").show(),$("#idAccount").show());a.forEach(function(e){$("#"+e).closest("td").show()}.bind(this));LOG("adaptRibbonButtons","LogBold");var c=0,d=$("td.ribbonTD").last().find('div[role="button"]');for(LOG("Visible="+d.length);!(!d.length||this.fitsHorizontally(d[0].id,
5797b||24)&&0!=d.width()||0<d.width()&&($("#"+a[c]).closest("td").hide(),LOG("buttonToRemove: "+a[c]),c++,c==a.length));)d=$("td.ribbonTD:visible").last().find('div[role="button"]:visible');0<c&&$(".ribbonSeparator").remove();System.runsInIFrame()&&(this.hasLoginInIFrame()||$("#idLoginStart").hide(),$("#idAccount").hide());glApp.showLoginButtonInRibbon(!glApp.isLoggedIn())}}hasLoginInIFrame(){return!1}createInfoPanel(a,b){if(!System.isMobile()&&!System.runsInIFrame()){this.infoPanel&&$("#"+this.infoPanel.id).remove();
5798if(b||glApp.isLoggedIn()||glApp.config.isMVCPlugin){var c=450<window.innerHeight?28:20;b=this.getLoggedInHtml();var d="CBInfoLoggedIn flex-fixed";var e=this.getLoginInfoGradient()+";color:white;text-transform:uppercase;"}else b=this.getPleaseLoginHtml(),d="CBInfoNotLoggedIn flex-fixed",e="background-color:white;color:black;text-transform:none;";d=$("<div id='infoDiv' class='"+d+"'></div>");$(d).css({border:1,overflow:"auto"});c&&$(d).css("line-height",String(c)+"px");$(d).attr("style",$(d).attr("style")+
5799e);$(d).html(b);$(a).prepend(d);this.infoPanel=$(d)[0];this.infoPanel.loggedIn=glApp.isLoggedIn();this.infoPanel.setHeight=function(f){};return this.infoPanel}return null}createLanguageButton(a){glApp.getAvailableLanguages()&&(a=a.concat([{id:languageOptionsId,buttons:[{id:languageButtonId,text:lm.LANGUAGE,icon:"Language"}]}]));return a}openLanguageMenu(){var a=$("#"+languageButtonId).position(),b=$("#"+languageButtonId).height(),c=a.left+2;a=a.top+b+14;b=this.createLanguageMenu($("#"+languageButtonId)[0]);
5800$(b).jqxMenu("open",c,a);$(b).jqxMenu({theme:"chessbase",width:150})}createLanguageMenu(a){for(var b=glApp.getAvailableLanguages(),c=Language.getNativeLangNames(b),d=Language.getFlagNames(b),e=[],f=0;f<d.length;f++)e.push("<img style='float: left; margin-right: 5px;' src='"+this.getLanguageFlagIcon(d[f],16)+"' />"+c[f]);var g=[];for(f=0;f<d.length;f++)c={index:f,commandId:glSettings.getCommandIdOfLanguage(b[f])},g.push(c);return this.createJQMenu(a,"languagesMenu",e,0,function(h){var k=$.grep(g,function(l){return l.index===
5801parseInt(h)})[0].commandId;glSettings.changeLanguage(k)},function(){})}openAccountMenu(){var a=$("#idAccount").position(),b=$("#idAccount").height(),c=a.left+2;a=a.top+b+14;b=this.createAccountMenu($("#idAccount")[0]);$(b).jqxMenu("open",c,a);$(b).jqxMenu({theme:"chessbase",width:150})}createAccountMenu(a){return this.createJQMenu(a,"accountMenu",[lm.ACCOUNT,lm.LOGOUT],0,function(b){switch(parseInt(b)){case 0:glApp.panelMgr.openAccountPage();break;case 1:glApp.panelMgr.logOut()}},function(){})}createAccountOptionsButton(a){return a=
5802a.concat([{id:"idAccountOptions",buttons:[{id:"idLoginStart",text:lm.LOGIN,icon:"Key"},{id:"idAccount",text:lm.ACCOUNT,icon:"Account"}]}])}showAccountsForm(a,b,c){a=DOM.getAccountNameCookie(!0);(new AccountForm).createLoginForm(lm.LOGIN,function(d){glApp.Vn.userName=d.idUser;glApp.Vn.password=d.idPassword;glApp.Vn.loginMode=LoginMode.NORMAL;(new AccountsManager(glApp.shortAppName)).pwLogin(glApp.Vn.userName,glApp.Vn.password,glApp.receiveTokenHandler.bind(glApp))}.bind(this),function(d){c&&c()}.bind(this),
5803a)}getLanguageFlagIcon(a,b){return glApp.config.getFlagPath(b)+a+".png"}setAnnoEditCss(){var a=$("#notaToolbar0").position().top,b=$("#notaToolbar0 ").width();$("#annoEdit").css({top:String(a-24)+"px",width:String(b-10)+"px",height:"22px"})}getNotationToolBarItemsHtml(a,b){var c=[{id:"downloadPgnId",title:"Download PGN",imgSrc:"../../Common/Media/Ribbons/MyGames/Download16.png",clickHandler:function(e){glApp.panelMgr.pgnLinkClickHandler(e,"downloadPgnId",function(){return glApp.panelMgr.getKernel().game})}},
5804{id:"btnFritzOnline",title:"Play out in Fritz Online",imgSrc:"../../Common/Media/Ribbons/MyGames/FritzOnline16.png",clickHandler:function(){glApp.passToFritzOnline(glApp.panelMgr.getKernel().game)}}
5804,{id:"btnTextBefore",title:lm.TEXT_BEFORE_TIP,imgSrc:"../../DocuWeb/Images/Buttons/16/Pretext16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.ADD_PRE_TEXT);glApp.panelMgr.setAnnoEditCss()}},{id:"btnTextAfter",title:lm.TEXT_AFTER_TIP,imgSrc:"../../DocuWeb/Images/Buttons/16/Posttext16.png",
5805clickHandler:function(){glApp.gameKernel.execCommand(a.ADD_POST_TEXT);glApp.panelMgr.setAnnoEditCss()}},{id:"btnStartLine",title:lm.START_LINE_TIP,imgSrc:"../../DocuWeb/Images/Buttons/16/StartLine16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.START_LINE)}},{id:"btnPromoteLine",title:lm.PROMOTE_LINE_TIP,imgSrc:"../../DocuWeb/Images/Buttons/16/PromoteLine16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.PROMOTE_LINE)}},{id:"btnDeleteLine",title:lm.DELETE_LINE_TIP,imgSrc:"../../DocuWeb/Images/Buttons/16/DeleteLine16.png",
5806clickHandler:function(){glApp.gameKernel.execCommand(a.DELETE_LINE)}},{id:"btnCutLine",title:lm.CUT_LINE_TIP,imgSrc:"../../DocuWeb/Images/Buttons/16/CutLine16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.CUT_LINE)}},{id:"btnMarkGood",title:"Good move",imgSrc:"../../DocuWeb/Images/Buttons/16/Good16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.MARK_GOOD)}},{id:"btnMarkBad",title:"Bad move",imgSrc:"../../DocuWeb/Images/Buttons/16/Bad16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.MARK_BAD)}},
5807{id:"btnMarkVeryGood",title:"Very good move",imgSrc:"../../DocuWeb/Images/Buttons/16/VeryGood16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.MARK_VERYGOOD)}},{id:"btnMarkVeryBad",title:"Very bad move",imgSrc:"../../DocuWeb/Images/Buttons/16/VeryBad16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.MARK_VERYBAD)}},{id:"btnMarkInteresting",title:"Interesting move",imgSrc:"../../DocuWeb/Images/Buttons/16/Interesting16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.MARK_INTERESTING)}},
5808{id:"btnMarkDubious",title:"Dubious move",imgSrc:"../../DocuWeb/Images/Buttons/16/Dubious16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.MARK_DUBIOUS)}},{id:"btnMarkMyMove",title:"Mark as My Move",imgSrc:"../../DocuWeb/Images/Buttons/16/MyMove16.png",clickHandler:function(){glApp.markCurrentMove(glApp.gameKernel,!1)}},{id:"btnMarkImportantMove",title:"Mark as Important Move",imgSrc:"../../DocuWeb/Images/Buttons/16/ImportantMove16.png",clickHandler:function(){glApp.markCurrentMove(glApp.gameKernel,
5809!0)}},{id:"btnUnmarkMove",title:"Unmark current move",imgSrc:"../../DocuWeb/Images/Buttons/16/Erase16.png",clickHandler:function(){glApp.unMarkCurrentMove(glApp.gameKernel)}},{id:"btnWhiteSlightly",title:"White has a slight advantage",imgSrc:"../../DocuWeb/Images/Buttons/16/WhiteSlightly16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.WHITE_SLIGHTLY)}},{id:"btnEqual",title:"The position is equal",imgSrc:"../../DocuWeb/Images/Buttons/16/Equal16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.EQUAL)}},
5810{id:"btnUnclear",title:"The position is unclear",imgSrc:"../../DocuWeb/Images/Buttons/16/Unclear16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.UNCLEAR)}},{id:"btnBlackSlightly",title:"Black has a slight advantage",imgSrc:"../../DocuWeb/Images/Buttons/16/BlackSlightly16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.BLACK_SLIGHTLY)}},{id:"btnWhiteBetter",title:"White is better",imgSrc:"../../DocuWeb/Images/Buttons/16/WhiteBetter16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.WHITE_BETTER)}},
5811{id:"btnBlackBetter",title:"Black is better",imgSrc:"../../DocuWeb/Images/Buttons/16/BlackBetter16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.BLACK_BETTER)}},{id:"btnWhiteWins",title:"White is winning",imgSrc:"../../DocuWeb/Images/Buttons/16/WhiteWins16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.WHITE_WINS)}},{id:"btnBlackWins",title:"Black is winning",imgSrc:"../../DocuWeb/Images/Buttons/16/BlackWins16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.BLACK_WINS)}},
5812{id:"btnCompensation",title:"Material compensation",imgSrc:"../../DocuWeb/Images/Buttons/16/Compensation16.png",clickHandler:function(){glApp.gameKernel.execCommand(a.COMPENSATION)}}];this.addSocialMediaButtons(c,"../../DocuWeb/Images/Buttons/16/");var d=$(b).width()-60;this.showNotationToolbarItems(d,26,c,$(b))}addSocialMediaButtons(a,b){this.socialMedia&&(a.splice(0,0,{id:"bt
5812nShareGame",title:"Share game",imgSrc:b+"Social16.png",clickHandler:function(){$("#btnShareGame").attr("disabled",!0);glApp.panelMgr.shareGame(glApp.gameKernel.game);
5813$("#btnShareGame").removeAttr("disabled")}}),a.splice(0,0,{id:"btnLikeGame",title:"Like game",imgSrc:b+"LikeNew16.png",clickHandler:function(){glApp.isLoggedIn()?($("#btnLikeGame").attr("disabled",!0),glApp.panelMgr.likeGame(glApp.gameKernel.game),$("#btnLikeGame").removeAttr("disabled")):glApp.panelMgr.showAlert("You need to be logged in to like games.",350,130)}}))}shareGame(a){var b=this.socialMediaUrl+"/Share/",c=PGNWriter.toPGN(a);a={gameText:encodeURIComponent(c),moveIndex:String(a.getMoveIndex())};
5814$.ajax({url:b,method:"POST",dataType:"json",contentType:"application/json; charset=UTF-8",data:JSON.stringify(a),success:function(d){glApp.panelMgr.showShareWindow(d.Url)},error:function(d,e,f){alert(f)}})}showShareWindow(a){var b=.9*$(window).width(),c=.9*$(window).height(),d=this.createDiv("divShareWindow",0);$(d).css({position:"fixed",left:"50%",top:"50%"});a="<div>   <div style='width: 100%; height: 100%;'>      <iframe style='border: 0;' width='100%' height='99%' src='"+(a+"'></iframe>   </div></div>");
5815$(d).html(a);$(d).jqxWindow({title:"ChessBase - Share Game",width:b,height:c,resizable:!1,draggable:!1,isModal:!0,theme:glApp.config.jqxTheme,modalOpacity:.3,showCloseButton:!0})}likeGame(a){var b=this.socialMediaUrl+"/Like/";a={userName:encodeURIComponent(glApp.Vn.userName),gameText:encodeURIComponent(PGNWriter.toPGN(a))};$.ajax({url:b,method:"POST",dataType:"json",contentType:"application/json; charset=UTF-8",data:JSON.stringify(a),success:function(c){glApp.panelMgr.showAlert(c.Message,600,210)},
5816error:function(c,d,e){alert(e)}})}showAlert(a,b,c){var d=this.createDiv("divAlert",0);$(d).css({position:"fixed",left:"50%",top:"50%"});a="<div style='text-align: center;'>   <div style='display: inline-block; word-break: break-word; padding: 10px;'>"+a+"      <br /><br /><button id='btnOK'>OK</button>   </div>";a+="</div>";$(d).html(a);$(d).jqxWindow({title:"Information",width:b,height:c,resizable:!1,draggable:!1,isModal:!0,modalOpacity:.3,showCloseButton:!1});$(d).find("#btnOK").jqxButton();$(d).find("#btnOK").click(function(){$(d).jqxWindow("close")})}showNotationToolbarItems(a,
5817b,c,d){var e=Math.floor(a/b);1>e&&(e=1);e<c.length?e--:e>c.length&&(e=c.length);a="";for(b=0;b<e;b++)a+="<button title='"+c[b].title+"' id='"+c[b].id+"'><img src='"+c[b].imgSrc+"' /></button>";e<c.length&&(a+="<button title='More symbols' id='btnMore'><b>...</b></button>");$(d).html(a);for(b=0;b<e;b++)$(d).find("#"+c[b].id)[0].addEventListener("click",c[b].clickHandler,!1);e<c.length&&$(d).find("#btnMore").click(function(){var f=$(d).find("#btnMore")[0].getBoundingClientRect(),g=f.left-280;f=f.top-
581826*(c.length-e)-5;glApp.panelMgr.showNotationToolbarItemsThatDoNotFit($(d).find("#btnMore"),g,f,c,e+1)})}showNotationToolbarItemsThatDoNotFit(a,b,c,d,e){var f=function(){$("#menuWrappernotationToolbarMenu0")[0]&&$("#menuWrappernotationToolbarMenu0").remove();for(var g=[],h=e-1;h<d.length;h++)g.push("<img style='float: left; margin-right: 5px;' src='"+d[h].imgSrc+"' />"+d[h].title);return glApp.panelMgr.createJQMenu(a,"notationToolbarMenu",g,0,function(k){d[parseInt(k)+e-1].clickHandler()},function(){})}();
5819$(f).jqxMenu("open",b,c);$(f).jqxMenu({theme:"chessbase",width:300})}showToolTip(a,b,c,d,e){if(a&&b){var f=$("#"+a);f.length&&(f.jqxTooltip({content:b,theme:glApp.config.jqxTheme,position:d||"bottom",name:a}),c&&(f.jqxTooltip("open"),f.jqxTooltip("close",c)),e&&(new Timer(function(){f.jqxTooltip("destroy")})).runOnce(e))}}destroyToolTip(a){$("#"+a).length&&$("#"+a).jqxTooltip("destroy")}createSwitchAppBar(a,b){var c=this.createDiv("switchBar",b);$(a).append(c);this._initSwitchToolBar(c,b)}_initSwitchToolBar(a,
5820b){var c=$('<div class="cbSwitchToolBar" id="switch-tb"></div>');$(a).append(c);var d=this;c=[];this.switchAppBtns=c=c.concat([{title:"Live Chess",id:"switch-Live",pic:"Live",subtxt:"Live Chess",handler:function(){d.redirectToLivePage()}},{title:"Tactics",id:"switch-Tactics",pic:"Tactics",subtxt:"Tactics",handler:function(){d.redirectTo("tactics")}},{title:"Videos",id:"switch-Videos",pic:"Videos",txt:"",subtxt:"Videos",handler:function(){d.redirectTo("videos")}},{title:"Fritz",id:"switch-Fritz",pic:"Fritz",
5821subtxt:"Fritz",handler:function(){d.redirectTo("fritz")}},{title:"Database",id:"switch-Database",pic:"Database",subtxt:"Database",handler:function(){d.redirectTo("database")}},{title:"Openings",id:"switch-Openings",pic:"Openings",subtxt:"Openings",handler:function(){d.redirectTo("mymoves")}},{title:"My Own Games",id:"switch-Mygames",pic:"mygames",subtxt:"My Games",handler:function(){d.redirectTo("mygames")}},{title:"Chess Quiz",id:"switch-quiz",pic:"quiz",subtxt:"Quiz",handler:function(){d.redirectTo("quiz")}},
5822{title:"Players",id:"switch-players",pic:"players",subtxt:"Players",handler:function(){d.redirectTo("players")}},{title:"News",id:"switch-news",pic:"news",subtxt:"News",handler:function(){d.redirectTo("en")}},{title:"Studies",id:"switch-studies",pic:"studies",subtxt:"Studies",handler:function(){d.redirectTo("studies")}}]);this.instantiateButtons("button",a,"a",c,"switchAppBtn",0);this.adaptSwitchAppButtons();this.setButtonImages("a",this.switchAppBtns,32,"switchAppBtn",b,"Switch","center 3px")}switchAppButtonfitsVertically(a,
5823b){var c=$(document.body).height(),d=$("#"+a).outerHeight();return $("#"+a).position().top-c+d+b<c}adaptSwitchAppButtons(){function a(f){return f.id===c[d]}for(var b=["a-btnswitch-quiz-0","a-btnswitch-news-0"],c=["switch-quiz","switch-news"],d=0,e=$(".switchAppBtn").last();d<b.length&&!this.switchAppButtonfitsVertically(e[0].id,24);)$("#"+b[d]).hide(),this.switchAppBtns.splice(this.switchAppBtns.findIndex(a),1),d++,e=$(".switchAppBtn").last()}redirectToLoginPage(){window.location=this.getLoginPageUrl()}createLogDiv(a){this.logDiv=
5824this.createEl("div","logDiv");$(a).append(this.logDiv);$(this.logDiv).html("<h1>LOG( x )</h1>")}getLoginPageUrl(){System.isCordova()||System.isMobile();return"https://play.chessbase.com/Logon?returnurl="+encodeURIComponent(document.location)}getCreateAccountUrl(){System.isCordova()||System.isMobile();return"https://play.chessbase.com/createAccount?returnurl="+encodeURIComponent(document.location)}redirectToLivePage(){LogStats("Live");this.redirectTo("live")}openAccountPage(){var a=String.formatEx(glApp.config.editAccountUrl,
5825Language.getParamOfLanguageId(glSettings.getLanguageId()));window.open(a)}openRegisterPage(){var a=this.getCreateAccountUrl();window.location.href=a}redirectTo(a,b){a=String.f("https://{0}.chessbase.com",a);b?window.open(a):window.location=a}setPgn(a,b){if(b){var c=new Game;c.assign(PGN.parseGame(b));a.getKernel().playFromPgnGame=c}}drawButtonHintArrow(a,b,c){this.drawOnFlashedCanvas(function(d){var e=$
5825(a).offset().left,f=$(a).offset().top,g=$(a).width();BoardArrow.drawFree(d,e-10,f+120,e+.4*g,f+
582620,9,"hsla( 130, 50%, 50%, 0.9 )");d.font="bold 30px Roboto";d.fillStyle="hsla( 120, 50%, 100%, 1.0 )";d.fillText(b,e+10,f+120)}.bind(this),c)}drawOnFlashedCanvas(a,b,c){var d=$(String.f("<canvas width={0}, height={1}>",window.innerWidth-10,window.innerHeight-10));$(document.body).append(d);$(d).css("zIndex",900);$(d).css("left",4);$(d).css("top",4);$(d).css("position","fixed");$(d).click(function(){d.remove()});a(d[0].getContext("2d"));(new Timer(function(){d.remove()})).runOnce(b||2E3)}getBoardUI(){if(this.getKernel()&&
5827this.getKernel().boardWin){let a=this.getKernel().boardWin;return{markSquare(b,c,d){a.markSquare(b,c,d)},drawArrow(b,c,d,e,f){a.drawArrow(b,c,d,e,!1,f)}}}}log(a){}logIntoChat(a,b){6}chatOut(){}addOnNextHintListener(){}removeOnNextHintListener(){}handleCommonKeyDown(a){if("INPUT"==a.target.nodeName||"TEXTAREA"==a.target.nodeName)return!0;if(this.instantiated){var b=!0,c=this.modules[0].getKernel();switch(a.which){default:b=!1;break;case 37:c.Vp.mayNavigate()&&c.game.gotoPrev();break;case 39:c.Vp.mayNavigate()&&
5828c.game.gotoNext();break;case 40:a.altKey&&(this.newGame?this.newGame():glApp.execCommand(CommandIds.NEW_GAME));break;case 66:a.ctrlKey&&c.boardWin&&c.boardWin.flipBoard();break;case 113:a.altKey&&(this.fnAnalysis?glApp.panelMgr.studyMode&&glApp.panelMgr.studyMode!=StudyMode.SOLVING||this.fnAnalysis():glApp.execCommand(CommandIds.TOGGLE_ANALYSIS_ENGINE));break;case 187:this.fnIncMultiVars&&!this.isMobileLayout()&&this.fnIncMultiVars(1);break;case 189:this.fnIncMultiVars&&!this.isMobileLayout()&&this.fnIncMultiVars(-1)}b&&
5829a.preventDefault();return b}}onEngineLayoutChange(){}createHamburger(a,b,c,d){function e(){$(l).removeClass("translateX0");$(l).find(".slideInItem").find(".slideInItem").addClass("subMenuClosed")}function f(n,r){let t=n.id||`item-${h++}`,u=`${t}${c}`,x="slideInItem";r&&(x+=" subMenuClosed");m+=`<div class="${x}" id="${u}">`;m+='<span class="slideInText">'+n.title+"</span>";m+=`<span class="slideInCheckMark" id="${t+"chk"+c}"></span>`;n.children&&n.children.forEach(function(B){f(B,r+1)});m+="</div>"}
5830function g(n,r){let t=`#${n.id||`item-${h++}`}${c}`;n.children?(n.children.forEach(function(u){g(u,r+1)}),$(t).click(function(){$(t+" > .slideInItem").toggleClass("subMenuClosed")})):$(t).click(function(u){let x=$(l).hasClass("translateX0");e();x&&n.handler(u)})}a=$(a);let h=0;a.css("display","flex");let k=`<div class="hambNav"><div class="hambIcon" id="hamburger${c}">`;for(let n=0;3>n;n++)k+='<div class="hambLine"></div>';a.html(k+"</div>"+`<div class="hambCaption" id="cbcaption${c}">Loading...</div>`+
5831"</div>");$(b).css("position","relative");let l=`#hamMenu${c}`,m=`<div id="hamMenu${c}" class="hambMenu">`;m+='<div class="slideInMenu">';d.forEach(function(n){f(n,0)});m+="</div>";m+="</div>";$(b).append($(m));h=0;d.forEach(function(n){g(n,0)},0);$(`#hamburger${c}`).click(function(){$(l).hasClass("translateX0")?$(l).removeClass("translateX0"):$(l).addClass("translateX0")});$(".hambCaption").click(e);$(".hambNav").css("display","flex");$(".hambNav").css("width","100%");return e}createSwiper(a,b,c,
5832d,e){let f=`<div class="swiper" style="height:100%;width:100%" id="swiper-${b}-${d}">`+'<div class="swiper-wrapper">';c.forEach(function(h){f+=`<div class="swiper-slide" id="swipe-${b}-${h.name}-${d}"></div>`});f=e?f+("</div>"+`<div class="swiper-button-prev" id="swiper-${b}-prv${d}"></div>`+`<div class="swiper-button-next" id="swiper-${b}-nxt${d}"></div>`+"</div>"):f+("</div>"+`<div class="swiper-pagination"  id="swiper-${b}-pag${d}"></div>`+`<div class="swiper-button-prev" id="swiper-${b}-prv${d}"></div>`+
5833`<div class="swiper-button-next" id="swiper-${b}-nxt${d}"></div>`+"</div>");$(a).append($(f));a={touchStartPreventDefault:!1,threshold:20,pagination:{el:`#swiper-${b}-pag${d}`},navigation:{prevEl:`#swiper-${b}-prv${d}`,nextEl:`#swiper-${b}-nxt${d}`}};e&&delete a.pagination;e=new Swiper(`#swiper-${b}-${d}`,a);e.on("slideChange",function(h){for(let k=0;k<c.length;k++)h.activeIndex==k&&c[k].fn&&c[k].fn(d),h.previousIndex==k&&c[k].fnLeave&&c[k].fnLeave(d)}.bind(this));a=$(e.navigation.nextEl);let g=$(e.navigation.prevEl);
5834a.css("bottom","40%");a.css("top","auto");g.css("bottom","40%");g.css("top","auto");$(".swiper-slide").width("100%");return e}createFloatBoard(a,b,c,d,e,f,g){let h=this.createDiv("floatBoard",a);$(h).css("position","fixed");var k="<div>Header</div><div>"+`<div id='board${a}'><canvas id='canvas${a}'></canvas></div>`+`<div id='eng${a}' class='cbFloatEng'></div>`+`<div id='buttons${a}'></div>`+"</div>";$(h).html(k);k=this.getButtonConfig().getBtnHBoard()+30;let l=e+k;$(h).jqxWindow({title:c,position:f,
5835width:d,height:l,resizable:!0,draggable:!0,isModal:!1,closeButtonAction:"close",showCloseButton:!0,theme:glApp.config.jqxTheme});$(h).find(".jqx-window-content").css({border:0,padding:0,overflow:"hidden",width:"100%",height:"100%"});c=$(h).find(`#buttons${a}`);this.createFloatButtons(c[0],a);let m=c.height(),n=$(h).find(`#board${a}`),r=n[0].offsetTop;n.css({width:"100%",height:l-r-m});c.css({"background-image":"linear-gradient( to right, hsla( 31, 20%, 77%, 1.0), hsla(31, 35%, 85%, 1.0) 40%, hsla( 31, 35%, 61%, 1.0) )",
5836"box-shadow":"0px 4px 8px -6px rgba( 0, 0, 0, 1.0) inset","box-sizing":"border-box"});let t=$.data(h,"jqxWindow").instance;t._dragHandler=function(x,B){if(x._isDragging&&!x.isResizing&&!x._resizeDirection){"undefined"===typeof x._enableResizeBackup&&(x._enableResizeBackup=x.enableResize);x.enableResize=!1;var y=$.jqx.position(B),A=x._windowPosition.x+(y.left-x._mousePosition.x);y=x._windowPosition.y+(y.top-x._mousePosition.y);y-=document.documentElement.scrollTop;x.move(A,y,B);B.preventDefault();
5837return!1}return!0};t._changeCursor=function(x,B){B-=document.documentElement.scrollTop;let y=Object.getPrototypeOf(t);y&&y._changeCursor.call(t,x,B)};c=$(h).find(`#canvas${a}`);let u=new CBCanvas2D(c[0].id,b,{topDist:2,bottomDist:2,marginDistDivisor:50,bigCoords:!1,shiftXPercent:0,minWForCoordinates:350,boardShadow:!1,noToMoveBulge:!0});u.resize(n.width(),n.height()+1);h._fnClose=function(){g(a);$(h).remove()};h.engOpen=!1;h.toggleEngine=function(){let x=$(h).find(`#eng${a}`),B=$(h).jqxWindow("height"),
5838y=$(h).jqxWindow("width");if(0>=x.height()){$(h).css("transition","height 0.2s");x.height(130);var A=$(h).position().top;130>A&&(A+=130/3);$(h).css("top",A-130);$(h).jqxWindow("resize",y,B+130);h.engOpen=!0;return x[0]}x.height(0);A=$(h).position().top;$(h).css("top",A+130);$(h).css("transition","none");$(h).jqxWindow("resize",y,B-130);x.html("");h.engOpen=!1};h.isMaxi=!1;h.toggleMaxi=function(){h.isMaxi||(h.wBeforeMaxi=h.clientWidth,h.hBeforeMaxi=h.clientHeight,h.lBeforeMaxi=h.offsetLeft,h.tBeforeMaxi=
5839h.offsetTop);h.isMaxi=!h.isMaxi;if(this.isMaxi){let x=Math.min(window.innerWidth,window.innerHeight),B=h.engOpen?20:65;$(h).css({left:window.innerWidth-20-x,top:2*B-5});
5839(new Timer(function(){$(h).jqxWindow("resize",x-40,x-2*B-10)}.bind(this))).runOnce(10)}else $(h).css({left:h.lBeforeMaxi,top:h.tBeforeMaxi}),(new Timer(function(){$(h).jqxWindow({width:h.wBeforeMaxi});$(h).jqxWindow("resize",h.wBeforeMaxi,h.hBeforeMaxi)}.bind(this))).runOnce(10)};h.doPosition=function(x){let B=document.documentElement.scrollTop;
5840x.x=Math.min(x.l+x.w,Math.round(window.innerWidth-d-20/window.devicePixelRatio));x.y-=.5*d;x.y<x.t+10&&(x.y=x.t+10);let y=Math.min(window.innerHeight,x.b);x.y+l>y-B-130/6&&(x.y=y-l-130/6);$(h).jqxWindow({position:x})};h.checkPosition=function(x){x=$(h).position().left;let B=$(h).position().top;x>window.innerWidth-d-20/window.devicePixelRatio&&$(h).css("left",window.innerWidth-d-20/window.devicePixelRatio);0>B&&$(h).css("top",0);0>x&&$(h).css("left",0)};$(h).find(".jqx-window-close-button").click(function(){h._fnClose()});
5841$(h).find(".jqx-window-close-button").on("touchend",function(){h._fnClose()});h.resizeGate=new V10;$(h).on("resizing",function(x){h.resizeGate.exec(function(){var B=$(h).find(`#eng${a}`).height();n.height(x.args.height-r-m-B);B=n.width();let y=n.height();u.resize(B,y+1);B=$(h).find(`#buttons${a}`);this.createFloatButtons(B[0],a)}.bind(this),200)}.bind(this));h.doPosition(f);h.checkPosition(f);return h}closeFloatBoard(a){let b=$("#floatBoard"+a);if(b.length&&this.floatBoard){for(let c=0;c<this.floatBoard.length;c++)this.floatBoard[c]&&
5842this.floatBoard[c]._fnClose();$(b).jqxWindow("close");delete this.floatBoard[a]}}}var resizeGate=new V10,languageButtonId="idSelectLanguage",languageOptionsId="idLanguageOptions";"use strict";
5843const AccountsManager=function(){var a=function(c){if(!c)throw"Accountsmanager: App required";this.app=c||"playchess";this.server=glApp.config.getAccountUris()[0];this.backupServer=glApp.config.getAccountUris()[1]};a.prototype.getxmlRequest=function(){return window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP")};a.prototype.pwLogin=function(c,d,e,f){LOG("AM, PWLogin:"+c+"/"+d,"","acc");if(c&&d){c=this.encodeAndBase64(c);var g=this.getCmdKey(c,"chk");this.doQuery({cmd:"chk",
5844user:c,app:this.app,pass:this.encodeAndBase64(d),key:g},function(h){h&&e(h,f)})}else e({error:!0},f)};a.prototype.tokenHandler=function(c){};a.prototype.tokenLogin=function(c,d,e){LOG("AM, TokenLogin:"+d);c=this.encodeAndBase64(c);var f=this.getCmdKey(c,"get");this.doQuery({cmd:"get",user:c,app:this.app,token:d,key:f},e)};a.prototype.changePassword=function(c,d,e,f,g){c=this.encodeAndBase64(c);var h=this.getCmdKey(c,"pw");this.doQuery({cmd:"pw",user:c,app:this.app,old:this.encodeAndBase64(d),"new":this.encodeAndBase64(e),
5845token:f,key:h},g)};a.prototype.activateTrainer=function(c,d,e,f){var g=this.encodeAndBase64(d);g=this.getCmdKey(g,"activatecenapp");this.doQuery({cmd:"activatecenapp",guid:c,serial:d,productid:e,key:g,user:this.encodeAndBase64(d)},f)};a.prototype.activateTrainerSilent=function(c,d,e,f){var g=this.encodeAndBase64(d);g=this.getCmdKey(g,"activatecenapp");this.doQuery({cmd:"activatecenapp",guid:c,serial:"",productid:e,key:g,user:this.encodeAndBase64(d)},f)};a.prototype.deactivateTrainer=function(c,d,
5846e){var f=this.encodeAndBase64(d);f=this.getCmdKey(f,"deactivatecenapp");this.doQuery({cmd:"deactivatecenapp",guid:c,serial:d,key:f,user:this.encodeAndBase64(d)},e)};a.prototype.getFriends=function(c,d,e,f){c=this.encodeAndBase64(c);var g=this.getCmdKey(c,"getfr");this.doQuery({cmd:"getfr",user:c,token:d,friendtype:e,key:g},f)};a.prototype.setFriends=function(c,d,e,f,g){for(var h="",k=0;k<f.length;k++)h+=f[k]+",";f=this.encodeAndBase64(h);c=this.encodeAndBase64(c);h=this.getCmdKey(c,"setfr");this.doQuery({cmd:"setfr",
5847user:c,token:d,friendtype:e,friends:f,key:h},g)};var b;a.prototype.doQuery=function(c,d){LOG("Accounts Query: "+c.cmd,"","acc");var e=[],f;for(f in c)e.push(encodeURIComponent(f)+"="+encodeURIComponent(c[f]));var g=e.join("&"),h=this.getxmlRequest();h.open("POST",this.server);h.setRequestHeader("Content-type","application/x-www-form-urlencoded");h.setRequestHeader("X-Requested-With","XMLHttpRequest");b=new Timer(function(){h.abort();this.server!==this.backupServer&&this.backupServer?(this.server=
5848this.backupServer,h.open("POST",this.backupServer),h.send(g)):d({timeout:!0})}.bind(this));b.runOnce(3E3);h.onload=function(){b.stop();if(4===h.readyState&&200===h.status){var k=h.responseText;d(k?JSON.parse(k):{})}else d({})};h.onerror=function(k){LOG("Accounts Error: "+k.data);b.stop();this.server!=this.backupServer&&this.backupServer?(this.server=this.backupServer,h.open("POST",this.backupServer),h.send(g),console.log("Retry AccountServer")):d({error:!0})}.bind(this);h.send(g)};a.prototype.getCmdKey=
5849function(c,d){0==c.Length&&(c="nameCoded");var e=d+c;c=c.split("");d=d.split("");e=e.split("");for(var f=0,g=0,h=0;h<e.length;h++)0!=(h&1)&&f<d.length?(e[h]=d[f],f++):g<c.length&&(e[h]=c[c.length-g-1],g++);return this.encodeAndBase64(e.join(""))};a.prototype.encodeAndBase64=function(c){c=StrUtil.escapeHtmlEntities(c);return StrUtil.base64.encode(c)};return a}();"use strict";
5850var AccountForm=function(){var a=function(){};a.prototype.createLoginForm=function(b,c,d,e){(new CBForm({id:"loginForm",title:b,width:320,height:230,modal:!0,okHandler:c,cancelHandler:d,fields:[{caption:"User:",type:"string",id:"idUser",val:e},{caption:"Password:",type:"password",id:"idPassword",val:""}],focusField:"idUser",accountButton:!0})).create()};return a}();"use strict";
5851var SerialForm=function(){var a=function(){};a.prototype.validator=function(b){$(b).jqxValidator({rules:[{input:"#idSerial0",message:"!",action:"keyup",rule:function(c,d){return 5===c.val().length?!0:!1}},{input:"#idSerial1",message:"",action:"keyup",rule:function(c,d){return 5===c.val().length?!0:!1}},{input:"#idSerial2",message:"",action:"keyup",rule:function(c,d){return 5===c.val().length?!0:!1}},{input:"#idSerial3",message:"",action:"keyup",rule:function(c,d){return 5===c.val().length?!0:!1}},
5852{input:"#idSerial4",message:"!",action:"keyup",rule:function(c,d){return 5===c.val().length?!0:!1}}]})};
5852a.prototype.createSerialForm=function(b,c,d,e){e="";if(window.clipboardData&&clipboardData.getData){var f=clipboardData.getData("Text");34<=f.length&&(e=f)}System.isElectron()&&"undefined"!==typeof electronBridge&&(f=electronBridge.readFromClipboard().trim(),34<=f.length&&(e=f));(new CBForm({id:"serialForm",title:b,width:680,height:200,modal:!0,okHandler:c,cancelHandler:d,fields:[{caption:lm.PRODUCT_KEY,
5853type:"serial",id:"idSerial",val:e}],focusField:"idSerial0",accountButton:!1,pasteButton:!0})).create()};return a}(),ProgressForm=function(){var a=function(){};a.prototype.createProgressForm=function(b){b=new CBForm({id:"serialForm",title:b,width:620,height:200,noButtons:!0,modal:!1,fields:[{caption:"Please Wait",type:"label"},{caption:"Progress",type:"progress",id:"idSerial",val:""}],accountButton:!1});b.create();this.progress=b.progressBar;this.label=b.label;this.nestDiv=b.nestDiv};return a}(),FeedbackForm=
5854function(){var a=function(){};a.prototype.createFeedbackForm=function(b,c,d){(new CBForm({id:"feedbackForm",title:b+" (version:"+glApp.versionCode.nMajor+"."+glApp.versionCode.nMinor+")",width:620,height:400,modal:!0,okHandler:c,cancelHandler:d,fields:[{caption:lm.SUBJECT+":",type:"string",id:"idSubject"},{caption:lm.MESSAGE+":",type:"stringmultiline",id:"idMessage",rows:10,cols:60}],focusField:"idSubject",accountButton:!1})).create()};return a}();"use strict";
5855var GetMovesType={NONE:-1,ALL:0,WHITE:1,BLACK:2,GLOBAL_WHITE:3,GLOBAL_BLACK:4},BlockUpdateMode={NOT_BLOCKED:0,BLOCKED:1,FORCE_UPDATE:2},CloudPanelMgrMixin=function(){function a(d,e){d.push([StrUtil.utf8ArrayToStr(e.title),e.nGames,e.cloudId,StrUtil.utf8ArrayToStr(e.owner)])}var b={openCloudDatabase:function(){glApp.initCloudManager()},nMaxOnlineDBGames:2,selectCloudDatabase:function(d,e,f){if(!this.getIsFormOpen()&&e){for(var g=[],h=[],k=StrUtil.encodeUTF8(d),l=0;l<e.size();l++)e.items[l].owner.toLowerCase()==
5856k.toLowerCase()?a(g,e.items[l]):a(h,e.items[l]);var m=-1;selectCloudDB(d,g,h,[{name:"title",type:"string"},{name:"games",type:"int"},{name:"cloudId",type:"int"},{name:"owner",type:"string"}],[{header:"Title",dataIndex:"title",flex:2},{header:"Games",dataIndex:"games",flex:1},{header:"Owner",dataIndex:"owner",flex:2}],function(n){n&&(m=n.cloudId);f(m)})}},blockLiveBookUpdates:function(d){this.getKernel().Vp.blockLiveBookUpdate(d)},loadGame:function(d){glApp.myMovesMgr&&glApp.myMovesMgr.isMovesLoadedForAny()||
5857glApp.pushGame(this.getKernel().game);this.getKernel().loadSearchResultGame(d)}},c=new V10;b.refreshOnlineDBGames=function(){this.dbGames&&this.dbGames.isVisible()&&(this.dbGames.setEmptyText("Searching..."),c.exec(function(){this.getKernel().Vp.searchOnlineDB()}.bind(this),500))};b.useMatBalanceDefault=function(){return 800<window.innerHeight};b.execCommand=function(d){try{switch(d){case glApp.Vy.ONLINEDB_SEARCH:this.getKernel().Vp.search();break;case CommandIds.TOGGLE_ANALYSIS_AUTO_ENGINE:this.toggleAutoShowEngine()&&
5858this.getAutoEngPanel().setGame(this.getKernel().game);break;case glApp.Vy.OPEN_CLOUDDATABASE:this.openCloudDatabase();break;case glApp.Vy.LOGIN:glApp.changeCloudLogin();break;case glApp.Vy.SAVE_CLOUDDB:glApp.saveToCloud(this.getKernel().game,0);break;case glApp.Vy.REPLACE_CLOUDDB:glApp.replaceInCloud(this.getKernel().game,0);break;case glApp.Vy.SAVE_WHITE_REPERTOIRE:glApp.saveToWhiteRepertoire(this.getKernel().game);break;case glApp.Vy.SAVE_BLACK_REPERTOIRE:glApp.saveToBlackRepertoire(this.getKernel().game);
5859break;case glApp.Vy.CREATE_CLOUDDB:glApp.createCloudDB();break;case glApp.Vy.DELETE_CLOUDDB:glApp.deleteCloudDB();break;case glApp.Vy.EDIT_HEADER:glApp.editHeader(this.getKernel().game);break;case glApp.Vy.LOAD_WHITE_MYMOVES:this.getKernel().boardWin.setBlackIsBottom(!1,!0);glApp.loadMyMoves(GetMovesType.WHITE,new Game);break;case glApp.Vy.LOAD_BLACK_MYMOVES:this.getKernel().boardWin.setBlackIsBottom(!0,!0);glApp.loadMyMoves(GetMovesType.BLACK,new Game);break;case glApp.Vy.MARK_CURRENT_MOVE:glApp.markCurrentMove(this.getKernel(),
5860!1);break;case glApp.Vy.IMPORTANT_CURRENT_MOVE:glApp.markCurrentMove(this.getKernel(),!0);break;case glApp.Vy.UNMARK_CURRENT_MOVE:glApp.unMarkCurrentMove(this.getKernel());break;case glApp.Vy.UPLOAD_TO_MYMOVES:glApp.uploadToMyMoves(this.getKernel())}}catch(e){d=glApp.Vy.toNumString(d),LogException(d,e)}};b.execNotaContextMenu=function(d){if(Ext&&Ext.create&&glApp.myMovesMgr){CBCSS.addIcon("MyMove16");CBCSS.addIcon("ImportantMove16");var e=[{text:lm.MARK_MOVE,handler:function(){glApp.markCurrentMove(glApp.panelMgr.getKernel(),
5861!1)},iconCls:"MyMove16"},{text:lm.MARK_IMPORTANT,iconCls:"ImportantMove16",handler:function(){glApp.markCurrentMove(glApp.panelMgr.getKernel(),!0)}}];if(glApp.myMovesMgr&&glApp.myMovesMgr.isMovesLoadedForAny())CBCSS.addIcon("EraseMove16"),CBCSS.addIcon("White16"),CBCSS.addIcon("Black16"),CBCSS.addIcon("Cutline16"),e=e.concat([{text:lm.UNMARK_MOVE,iconCls:"Erase16",handler:function(){glApp.unMarkCurrentMove(glApp.panelMgr.getKernel())}},"-",{text:lm.REMOVE_TREE_FROM_HERE,iconCls:"Cutline16",handler:function(){ConfirmForm(lm.DELETE_VARIATION_TREE,
5862lm.REMOVE_ALL_MY_MOVES,function(g){"yes"!=g&&"ok"!=g||glApp.removeWholeTreeFromCurrentMove(glApp.panelMgr.getKernel())})}}]);else{var f=glApp.Vy;e=e.concat(this.getMarkEvalItems("Good16 Bad16 VeryGood16 VeryBad16 Interesting16 Dubious16 WhiteWins16 WhiteBetter16 WhiteSlightly16 Equal16 Unclear16 BlackSlightly16 BlackBetter16 BlackWins16 Compensation16".split(" "),[f.MARK_GOOD,f.MARK_BAD,f.MARK_VERYGOOD,f.MARK_VERYBAD,f.MARK_INTERESTING,f.MARK_DUBIOUS,f.WHITE_WINS,f.WHITE_BETTER,f.WHITE_SLIGHTLY,f.EQUAL,
5863f.UNCLEAR,f.BLACK_SLIGHTLY,f.BLACK_BETTER,f.BLACK_WINS,f.COMPENSATION],"Strong Move;Bad Move;Brilliant Move;Blunder;Interesting Move;Dubious Move;White Is Winning;White Is Better;White: Slight Advantage;Equal;Unclear;Black: Slight Advantage;Black Is Better;Black Is Winning;Compensation".split(";")))}Ext.create("Ext.menu.Menu",{items:e}).showAt([d.clientX,d.clientY])}};b.getMarkEvalItems=function(d,e,f){for(var g=[],h=0;h<d.length;h++)g.push({text:f[h],iconCls:d[h],handler:function(){var k=e[h];return function(){glApp.commands.commandHandler(k)}}()});
5864return g};b.getNotaElement=function(){var d=Ext.ComponentManager.get("idNotaPanel");
5864if(d)return d.nota};b.shakeMarkButton=function(){CBQ(".MyMove32").addClass("shakeAnimation");CBQ(".MyMove24").addClass("shakeAnimation");CBQ(".iconMarkHelp").addClass("shakeAnimation")};b.stopShakeMarkButton=function(){CBQ(".MyMove32").removeClass("shakeAnimation");CBQ(".MyMove24").removeClass("shakeAnimation");CBQ(".iconMarkHelp").removeClass("shakeAnimation")};b.showMessage=function(d,e){this.getKernel()&&this.getKernel().boardWin&&
5865(this.getKernel().boardWin.addMessage(d,!0),e&&(new Timer(function(){this.getKernel().boardWin.destroyMessage()}.bind(this))).runOnce(e))};b.setLayoutMyMoves=function(d,e,f){if(this.notaElement){if(d){var g=e===GetMovesType.BLACK||e===GetMovesType.GLOBAL_BLACK;e=g?"/common/media/ribbons/Black32.png":"/common/media/ribbons/White32.png";g=g?lm.BLACK:lm.WHITE;var h=lm.MY_MOVES_FOR+"  "+g;f&&(Array.isArray(f)&&1<f.length?(f[1]+=" - "+g,h=f):h=f+" - "+g);this.notaElement.notaHeaderElement.setTitleOnly(h,
5866e)}else this.notaElement.notaHeaderElement.setTitleOnly("");glApp.panelMgr.canAnnotate=!d}};b.getNotationToolBarItems=function(d){return[ToolButtons.downloadPGNBtn("PGN","Save16","Download Game Notation","downloadPgnId",function(){return glApp.panelMgr.getKernel().game}),"-",ToolButtons.smallBtn(lm.TEXT_AFTER,"Posttext16",d.ADD_POST_TEXT,lm.TEXT_AFTER_TIP),"-",ToolButtons.smallBtn(lm.DELETE_LINE,"DeleteLine16",d.DELETE_LINE,lm.DELETE_LINE_TIP),ToolButtons.smallBtn(lm.CUT_LINE,"CutLine16",d.CUT_LINE,
5867lm.CUT_LINE_TIP),"-",ToolButtons.smallBtn("","MyMove16",d.MARK_CURRENT_MOVE,"Mark as 'My Move'"),ToolButtons.smallBtn("","ImportantMove16",d.IMPORTANT_CURRENT_MOVE,"Mark as Important Move"),ToolButtons.smallBtn("","Erase16",d.UNMARK_CURRENT_MOVE,"Unmark current move"),"-",ToolButtons.smallBtn("","WhiteSlightly16",d.WHITE_SLIGHTLY,"White has a slight advantage"),ToolButtons.smallBtn("","Equal16",d.EQUAL,"The position is equal"),ToolButtons.smallBtn("","Unclear16",d.UNCLEAR,"The position ist unclear"),
5868ToolButtons.smallBtn("","BlackSlightly16",d.BLACK_SLIGHTLY,"Black has a slight advantage"),ToolButtons.smallBtn("","WhiteBetter16",d.WHITE_BETTER,"White is better"),ToolButtons.smallBtn("","BlackBetter16",d.BLACK_BETTER,"Black is better"),ToolButtons.smallBtn("","WhiteWins16",d.WHITE_WINS,"White is winning"),ToolButtons.smallBtn("","BlackWins16",d.BLACK_WINS,"Black is winning"),ToolButtons.smallBtn("","Compensation16",d.COMPENSATION,"Material compensation"),"-",ToolButtons.smallBtn("","InsertDiagram16",
5869d.INSERT_DIAGRAM,lm.INSERT_DIAGRAM)]};return b}(),CloudAppMixin=function(){function a(){InputString("Name","New Database",function(f){f&&glApp.cloudMgr&&glApp.cloudMgr.createDatabase(f)}.bind(this))}function b(){glApp.cloudMgr&&glApp.cloudMgr.logOff();glApp.myMovesMgr&&glApp.myMovesMgr.logOff();glApp.aTBLobby&&glApp.aTBLobby.logOff();glApp.logOffPlayerLobby();glApp.logOffOnlineLobby();if(glApp.panelMgr.getKernel())glApp.panelMgr.getKernel().Vp.onBeforeUnload();glApp.exitInstance();glApp.myMovesMgr&&
5870!glApp.myMovesMgr.isMovesLoadedForAny()&&glApp.saveGameToLocalStorage()}function c(){glApp.cloudMgr&&glApp.myMovesMgr&&!System.runsInIFrame()&&(System.isMobile()&&(glApp.panelMgr.stopEngines&&glApp.panelMgr.stopEngines(),glApp.cloudBlurTimer&&glApp.stop&&glApp.stop(),glApp.cloudBlurTimer&&glApp.cloudBlurTimer.stop(),glApp.cloudBlurTimer=new Timer(function(){glApp.cloudMgr.logOff();glApp.myMovesMgr.logOff()}),glApp.cloudBlurTimer.runOnce(6E4)),glApp.myMovesMgr&&glApp.myMovesMgr.isMovesLoadedForAny()||
5871glApp.saveGameToLocalStorage())}function d(){glApp.cloudBlurTimer&&glApp.cloudBlurTimer.stop()}function e(){document.hidden?c():d()}return{initCloudManager:function(){if(void 0!==glApp.cloudMgr)glApp.cloudMgr.isLoggedIn()?glApp.cloudMgr.requestDatabases():this.loginToCloud();else{var f=this.copyUserName();f&&glApp.Vn.userName&&"guest"!==glApp.Vn.userName?(glApp.Vn.loginToken=f,this.createCloudManager(!0,null,f)):glApp.Vn.hasUserAndPass()&&this.createCloudManager(!0)}},initMyMovesManager:function(){if(void 0!==
5872glApp.myMovesMgr)glApp.myMovesMgr.isLoggedIn()||this.loginToMyMoves();else{var f=this.copyUserName();f&&glApp.Vn.userName&&"guest"!==glApp.Vn.userName?(glApp.Vn.loginToken=f,this.createMyMovesManager(!0,f)):glApp.Vn.hasUserAndPass()&&this.createMyMovesManager(!0)}},copyUserName:function(){glApp.Vn.userName||(glApp.Vn.userName=DOM.getAccountNameCookie(!0));glApp.Vn.userName||(glApp.Vn.userName=DOM.getCodedCookie("AccountBackName64",!0));glApp.Vn.loginMode=LoginMode.NORMAL;return DOM.getCookie("AccountToken")||
5873glApp.Vn.loginToken},createCloudManager:function(f,g,h){DOM.setAccountNameCookie(glApp.Vn.userName);glApp.config.silentCloud||glApp.panelMgr.EXTIsNotSupported||ToolButtons.showBusyMask(lm.CONNECTING);glApp.cloudMgr=new ServerCloudManager;glApp.cloudMgr.onServerDown=this.onCloudServerDown.bind(this);glApp.cloudMgr.onInvalidPassword=this.changeCloudLogin.bind(this);var k=glApp.Vn.userName,l=LoginMode.NORMAL;f||(k="Guest",l=LoginMode.GUEST);glApp.cloudMgr.createLobby(this.config.getCloudServerUris(),
5874k,glApp.Vn.password,l,h);this.windowEventsAdded||(this.windowEventsAdded=!0,window.addEventListener("beforeunload",b),glApp.isExtJS||window.addEventListener("unload",b),window.addEventListener("blur",c),window.addEventListener("focus",d),window.addEventListener("visibilitychange",e));glApp.cloudMgr.connect();glApp.cloudMgr.setCallAfterDBSelected(g);glApp.initCloudListeners(glApp.cloudMgr);glApp.panelMgr.getKernel()&&glApp.panelMgr.getKernel().game.addOnResetGameListener(function(){if(glApp.cloudMgr)glApp.cloudMgr.onResetGame()})},
5875createMyMovesManager:function(f,g){if(glApp.myMovesMgr)f=glApp.Vn.userName,h=LoginMode.NORMAL,glAp
5875p.myMovesMgr.createLobby(this.config.getMyMovesServerUris(),f,glApp.Vn.password,h,g);else{DOM.setAccountNameCookie(glApp.Vn.userName);glApp.myMovesMgr=new MyMovesManager;glApp.myMovesMgr.onServerDown=this.onMyMovesServerDown.bind(this);f=glApp.Vn.userName;var h=LoginMode.NORMAL;g?(glApp.myMovesMgr.isLoggedIn()&&glApp.myMovesMgr.logOff(),glApp.myMovesMgr.createLobby(this.config.getMyMovesServerUris(),
5876f,glApp.Vn.password,h,g)):glApp.myMovesMgr.createLobby(this.config.getMyMovesServerUris(),"guest","",LoginMode.GUEST,"");this.windowEventsAdded||(this.windowEventsAdded=!0,window.addEventListener("beforeunload",b),glApp.isExtJS||window.addEventListener("unload",b),window.addEventListener("blur",c),window.addEventListener("focus",d),window.addEventListener("visibilitychange",e));glApp.myMovesMgr.connect();glApp.initMyMovesListeners(glApp.myMovesMgr);glApp.panelMgr.getKernel()&&(glApp.panelMgr.getKernel().game.addOnResetGameListener(function(){if(glApp.myMovesMgr)glApp.myMovesMgr.onResetGame()}),
5877glApp.panelMgr.getKernel().game.addOnNotaDoubleClickListener(function(){glApp.onNotaDoubleClick()}))}},connectCloudManager:function(f,g,h){DOM.setAccountNameCookie(glApp.Vn.userName);glApp.config.silentCloud||glApp.panelMgr.EXTIsNotSupported||ToolButtons.showBusyMask(lm.CONNECTING);var k=glApp.Vn.userName,l=LoginMode.NORMAL;f||(k="Guest",l=LoginMode.GUEST);glApp.cloudMgr.connectUser(k,glApp.Vn.password,l,h);glApp.cloudMgr.setCallAfterDBSelected(g)},connectMyMovesManager:function(f,g){DOM.setAccountNameCookie(glApp.Vn.userName);
5878glApp.myMovesMgr.connectUser(glApp.Vn.userName,glApp.Vn.password,LoginMode.NORMAL,g)},initCloudListeners:function(f){},initMyMovesListeners:function(f){glApp.panelMgr.tbBook&&glApp.panelMgr.tbBook.initCloudListener(f);glApp.panelMgr.getKernel()&&glApp.panelMgr.getKernel().Vp.initMyMovesListener&&glApp.panelMgr.getKernel().Vp.initMyMovesListener(f)},onCloudServerDown:function(){this.config.silentCloud||alert("Sorry, Cloud Server is currently in maintenance, please wait a few minutes.")},onMyMovesServerDown:function(){this.config.silentCloud||
5879alert("Sorry, MyMoves Server is currently in maintenance, please wait a few minutes.")},onTokenLoginOk:function(){this.panelMgr.hasPlugins&&(this.initCloudManager(),this.initMyMovesManager())},onInvalidPassword:function(){},shouldRequestCloudDBsOnLogin:function(){return!1},loginToCloud:function(f){var g=DOM.getCookie("AccountToken");if(g){var h=DOM.getAccountNameCookie(!0);h&&(glApp.Vn.userName=h);glApp.Vn.loginMode=LoginMode.NORMAL;glApp.Vn.loginToken=g;void 0===glApp.cloudMgr?this.createCloudManager(!0,
5880f,g):this.connectCloudManager(!0,f,g)}else this.changeCloudLogin(f)},loginToMyMoves:function(){var f=DOM.getCookie("AccountToken");if(f){var g=DOM.getAccountNameCookie(!0);g&&(glApp.Vn.userName=g);glApp.Vn.loginMode=LoginMode.NORMAL;glApp.Vn.loginToken=f;void 0===glApp.myMovesMgr?this.createMyMovesManager(!0,f):this.connectMyMovesManager(!0,f)}},changeCloudLogin:function(f){},saveToCloud:function(f){var g=function(){FormseditGameHeader(f.hdr,function(){f.fireOnHeaderChanged();glApp.cloudMgr.saveGame(f)}.bind(this))}.bind(this);
5881void 0===glApp.cloudMgr||glApp.cloudMgr.isGuest()?glApp.loginToCloud(g):g()},replaceInCloud:function(f){var g=function(){FormseditGameHeader(f.hdr,function(){f.fireOnHeaderChanged();glApp.cloudMgr.replaceGame(f)}.bind(this))}.bind(this);void 0===glApp.cloudMgr||glApp.cloudMgr.isGuest()?glApp.loginToCloud(g):g()},editHeader:function(f){FormseditGameHeader(f.hdr,function(){f.fireOnHeaderChanged();glApp.cloudMgr.canReplaceGame(f)&&glApp.cloudMgr.replaceGame(f)})},saveToWhiteRepertoire:function(f){alert("NOTIMPL")},
5882saveToBlackRepertoire:function(f){alert("NOTIMPL")},createCloudDB:function(){void 0===glApp.cloudMgr||glApp.cloudMgr.isGuest()?this.loginToCloud():a.bind(this)()},deleteCloudDB:function(){void 0===glApp.cloudMgr||glApp.cloudMgr.isGuest()?this.loginToCloud():glApp.cloudMgr.deleteDatabase()},setLoggedIn:function(f){f?this.isPlugin()||(document.title=this.appTitle+" - "+glApp.Vn.userName):(glApp.cloudMgr&&glApp.cloudMgr.isLoggedIn()&&(glApp.cloudMgr.logOff(),delete glApp.cloudMgr),glApp.myMovesMgr&&
5883glApp.myMovesMgr.isLoggedIn()&&(glApp.myMovesMgr.isMovesLoadedForAny()&&glApp.panelMgr.getKernel().newGame(),glApp.myMovesMgr.logOff(),delete glApp.myMovesMgr),this.panelMgr.showDatabase&&this.panelMgr.showDatabase(null),this.isPlugin()||(document.title=this.appTitle+" - not logged in"),this.loginPending=!1);this.superClass.setLoggedIn.apply(this,arguments)},loadMyMoves:function(f,g){glApp.checkMyMovesLoggedIn()&&glApp.panelMgr.getKernel().Vp.mayLoadGames()&&(glApp.myMovesMgr.isMovesLoadedForAny()||
5884glApp.pushGame(glApp.panelMgr.getKernel().game),glApp.panelMgr.getKernel().Vp.shouldRefreshOnlineDB=!0,glApp.myMovesMgr.loadCurrentMyMoves(f,g),glApp.panelMgr.blockLiveBookUpdates(BlockUpdateMode.NOT_BLOCKED))},gameStack:[],pushGame:function(f){var g=new Game;g.assign(f);this.gameStack.push(g)},restorePrevGame:function(){if(this.gameStack.length){var f=this.gameStack.pop();glApp.panelMgr.getKernel().Vp.getFnLoadSearchResult().call(glApp.panelMgr.getKernel(),f)}},removeWholeTreeFromCurrentMove:function(f,
5885g){if(glApp.checkMyMovesLoggedIn()&&f.game.getMoveOffs()<=f.game.getCurLine().length){var h=new Game,k=f.game.getMoveOffs();g&&(k=f.game.getLineStartMoveNo());for(g=0;g<k;g++)h.makeMove(f.game.getCurLine()[g]);if(f=f.game.getCurLine()[g])f=new Move(f.from,f.to,f.prom),glApp.myMovesMgr.removeWholeTree(h.getCurPos(),f,glApp.myMovesMgr.myMovesLoadMode),h.gotoPrev()}},markCurrentMove:function(f,g){glApp.panelMgr.stopShakeMarkButton();g=g||!1;if(glApp.checkMyMovesLoggedIn()&&f.game.getMoveOffs()<=f.game.getCurLine().length&&
5886this.checkMyMovesLoadedForOtherSide(!f.getCurPos().getBTM())){f.game.deleteAnno(AnnoType.SYMBOL);g?f.addSymbol(AnnoMarkType.IMPORTANT):f.addSymbol(AnnoMarkType.MYMOVE);var h=this.cloneGameToCurPos(f.game);glApp.myMovesMgr.storePosAndMoves(h,g?3:2);h=new NotationGenerator;var k=f.game.getLastMove();if(k){var l=f.getCurPos().getMoveNum();h=h.getMoveNota(k,l);k=h+" "+lm.MARKED;g&&(k=h+" "+lm.MARKED_IMPORANT);f.boardWin.addMessage(k,!0);(new Timer(function(){f.boardWin.destroyMessage()})).runOnce(2E3);
5887glApp.myMovesMgr.isMovesLoadedFor(!f.getCurPos().getBTM())&&(h=this.cloneGameToCurPos(f.game,2),glApp.myMovesMgr.loadMyMoves(glApp.myMovesMgr.myMovesLoadMode,h))}}},checkMyMovesLoadedForOtherSide:function(f){if(0===this.panelMgr.getKernel().game.getMoveNo())glApp.panelMgr.showMessage(lm.ENTER_OR_CLICK_MOVE_AND_MARK,5E3);else{switch(glApp.myMovesMgr.myMovesLoadMode){default:case GetMovesType.ALL:f=!0;break;case GetMovesType.BLACK:var g=lm.CAUTION_YOU_ARE_EDITING_MOVES_FOR+" "+lm.BLACK+".";break;case GetMovesType.WHITE:f=
5888!f,g=lm.CAUTION_YOU_ARE_EDITING_MOVES_FOR+" "+lm.WHITE+"."}f||glApp.panelMgr.showMessage(g);return f}},makeMainMoveOrder:function(f){if(glApp.checkMyMovesLoggedIn()&&f.game.getMoveOffs()<=f.game.getCurLine().length){for(var g=new Game,h=0;h<f.game.getMoveOffs();h++)g.makeMove(f.game.getCurLine()[h]);glApp.myMovesMgr.makeMainMoveOrder(g);g=new NotationGenerator;if(h=f.game.getLastMove()){var k=f.getCurPos().getMoveNum();g=g.getMoveNota(h,k);f.boardWin.addMessage(g+" is main move order.",!0);(new Timer(function(){f.boardWin.destroyMessage()})).runOnce(2E3);
5889glApp.myMovesMgr.isMovesLoadedFor(!f.getCurPos().getBTM())&&glApp.myMovesMgr.reloadMyMoves()}}},unMarkCurrentMove:function(f){if(glApp.checkMyMovesLoggedIn()&&f.game.getMoveOffs()<=f.game.getCurLine().length&&this.checkMyMovesLoadedForOtherSide(!f.getCurPos().getBTM())){var g=f.game.getLastMove();if(g){f.game.deleteAnno(AnnoType.SYMBOL);var h=new Position;f.game.enableEvents(!1);f.game.gotoPrev();h.copy(f.game.getCurPos());f.game.gotoNext();glApp.myMovesMgr.removeFromMyMoves(h,g);f.game.enableEvents(!0);
5890h=new NotationGenerator;var k=f.getCurPos().getMoveNum();g=h.getMoveNota(g,k);f.boardWin.addMessage(g+" cleared.",!0);(new Timer(function(){f.boardWin.destroyMessage()})).runOnce(2E3);glApp.myMovesMgr.isMovesLoadedFor(!f.getCurPos().getBTM())&&(g=this.cloneGameToCurPos(f.game,2),glApp.myMovesMgr.loadMyMoves(glApp.myMovesMgr.myMovesLoadMode,g))}}},uploadToMyMoves:function(f){glApp.checkMyMovesLoggedIn()&&(f.boardWin.addMessage(lm.GAME_UPLOADED,!0),glApp.myMovesMgr.uploadToMyMoves(f.game),(new Timer(function(){f.boardWin.destroyMessage()})).runOnce(2E3),
5891glApp.myMovesMgr.reloadMyMoves())},isCloudLoggedIn:function(){return glApp.cloudMgr&&glApp.cloudMgr.isLoggedIn()},checkCloudLoggedIn:function(){if(glApp.cloudMgr){if(glApp.cloudMgr.isLoggedIn())return!0;
5891if(glApp.cloudMgr.wasLoggedIn()&&!glApp.cloudMgr.isConnected())return glApp.cloudMgr.reconnectUser(),!0}glApp.panelMgr.showMessage(lm.PLEASE_LOGIN_OPENINGS,3E3);return!1},isMyMovesLoggedIn:function(){return glApp.myMovesMgr&&glApp.myMovesMgr.isLoggedIn()},checkMyMovesLoggedIn:function(){if(glApp.myMovesMgr){if(glApp.myMovesMgr.isLoggedIn()&&
5892!glApp.myMovesMgr.isGuest())return!0;if(glApp.myMovesMgr.wasLoggedIn()&&!glApp.myMovesMgr.isConnected())return glApp.myMovesMgr.reconnectUser(),!0}glApp.panelMgr.showMessage(lm.PLEASE_LOGIN_OPENINGS,3E3);return!1},cloneGameToCurPos:function(f,g){for(var h=new Game,k=0;k<f.getMoveOffs()&&k<(g||999);k++){var l=f.getCurLine()[k];if(l){h.makeMove(new Move(l.from,l.to,l.prom));var m=h.getLastMove();l.annos&&l.annos[AnnoType.SYMBOL]&&(m.annos=new Annotation,m.annos[AnnoType.SYMBOL]=l.annos[AnnoType.SYMBOL])}else{alert("game logic problem");
5893break}}return h},onNotaDoubleClick:function(){this.loadMyMoves(glApp.myMovesMgr.myMovesLoadMode,new Game);glApp.panelMgr.refreshOnlineDBGames&&glApp.panelMgr.refreshOnlineDBGames()},notifyMyMovesChanged:function(){this.myMovesMgr.checkPosAndMoves(this.panelMgr.getKernel().game.getCurPos());this.myMovesMgr.isMovesLoadedFor(this.panelMgr.getKernel().getCurPos().getBTM())&&this.myMovesMgr.reloadMyMoves()}}}();
5894let CloudPlayingModeMixin={createGUIElements(a){this.superClass.createGUIElements.call(this,a);a.shouldAnimatePosChange=this.shouldAnimatePosChange.bind(this);this.setDefaultAnimSteps(a)},setDefaultAnimSteps(a){if(this.kernel)var b=a||this.kernel.boardWin;b&&(System.isMobile()?b.animSteps={forMove:.3,forPosition:.3}:b.animSteps={forMove:.6,forPosition:.6})},shouldAnimatePosChange(){return this.animatePos},blockLiveBookUpdate(a){if(this.blockUpdateMode!=BlockUpdateMode.FORCE_UPDATE||a!=BlockUpdateMode.NOT_BLOCKED)this.blockUpdateMode=
5895a},onAnnotate(){return glApp.myMovesMgr&&glApp.myMovesMgr.isMovesLoadedForAny()?(glApp.panelMgr.showMessage("Cannot annotate 'My Moves'",3E3),!1):this.canAnnotateLoadedGames()},onTextAnno(a,b){if(b){if(glApp.myMovesMgr&&glApp.myMovesMgr.isMovesLoadedForAny())return b=glApp.cloneGameToCurPos(this.kernel.game),glApp.myMovesMgr.storeText(b,a),!0}else glApp.myMovesMgr&&glApp.myMovesMgr.isMovesLoadedForAny()&&glApp.panelMgr.showMessage("'My Moves' can only have text after a move.");if(this.canAnnotateLoadedGames())return!0;
5896glApp.panelMgr.showMessage("You can only annotate your own moves");return!1},onEval(a){if(glApp.myMovesMgr&&glApp.myMovesMgr.isMovesLoadedForAny()){var b=this.kernel.game.getAnno(AnnoType.SYMBOL);b&&b.hasExclusiveEval(a)&&(a=0);b=glApp.cloneGameToCurPos(this.kernel.game);glApp.myMovesMgr.storeEval(b,a);return!0}if(this.canAnnotateLoadedGames())return!0;glApp.panelMgr.showMessage("You can only annotate your own moves");return!1},canAnnotateLoadedGames(){return!1},onPromoteLine(){return glApp.myMovesMgr&&
5897glApp.myMovesMgr.isMovesLoadedForAny()?(glApp.panelMgr.showMessage("Line ordering is automatic in 'My Moves'"),!1):!0},onDeleteLine(){if(glApp.myMovesMgr&&glApp.myMovesMgr.isMovesLoadedForAny())return ConfirmForm(lm.DELETE_VARIATION_TREE,lm.REMOVE_ALL_MY_MOVES,function(a){"yes"!=a&&"ok"!=a||glApp.removeWholeTreeFromCurrentMove(this.kernel,!0)}.bind(this)),!1;if(this.canAnnotateLoadedGames())return!0;glApp.panelMgr.showMessage("You can only annotate your own moves");return!1},onCutLine(){if(glApp.myMovesMgr&&
5898glApp.myMovesMgr.isMovesLoadedForAny())return ConfirmForm(lm.DELETE_VARIATION_TREE,lm.REMOVE_MOVES_FROM_HERE,function(a){"yes"!=a&&"ok"!=a||glApp.removeWholeTreeFromCurrentMove(this.kernel)}.bind(this)),!1;if(this.canAnnotateLoadedGames())return!0;glApp.panelMgr.showMessage("You can only annotate your own moves");return!1},cloudOnEnteredMove(a){try{var b=glApp.panelMgr.getNotaElement();b&&b.focus();if(glApp.myMovesMgr&&glApp.myMovesMgr.isMovesLoadedFor(this.kernel.getCurPos().getBTM())){var c=glApp.cloneGameToCurPos(this.kernel.game);
5899c.getCurPos().preCalcCtx(a);c.makeMove(a);glApp.myMovesMgr.storePosAndMoves(c,a,1)}}catch(d){alert("CloudEnter: "+d)}},newGame(){delete this.kernel.game.replaceGameNo;delete this.kernel.game.replaceDBId;if(glApp.myMovesMgr)glApp.myMovesMgr.onResetGame();glApp.panelMgr.setLayoutMyMoves(!1)},searchOnlineDB(){if(glApp.panelMgr.dbGames||glApp.panelMgr.usesOnlineDB&&glApp.panelMgr.usesOnlineDB()){var a=new SearchMask;a.setSearchBoard(this.kernel.game.getCurPos().board,this.kernel.game.getCurPos().Vj());
5900a.setUseBoard(!0);null!=glApp.onlineLobby&&glApp.onlineLobby.search(a,this.getOnlineDBMaxGames(),this.kernel.game.getMoveNo())}},getOnlineDBMaxGames(){return this.nMaxOnlineDBGames},getFnLoadSearchResult(){return function(a){this.Vp.beforeGameLoad();this.Vp.animatePos=!1;glApp.panelMgr.setLayoutMyMoves.call(glApp.panelMgr,!1);var b=ObjUtil.clone(this.game),c=b.getCurPos();void 0!==this.boardWin.prepareFullRedraw&&this.boardWin.prepareFullRedraw();this.game.assign(a,!0);a=0;if(this.game.isNormalInit())for(;60>
5901++a&&!this.game.gotoPos(c,!0)&&0<b.getMoveOffs();)b.gotoPrev(!0),c=b.getCurPos();this.game.fireOnResetGame();this.game.fireOnChanged();this.game.fireOnCurPosChanged();this.game.fireOnHeaderChanged();this.game.isNormalInit()?60>a&&0<a&&5<this.game.getMoveNo()&&1<this.game.getLineCnt()&&glApp.panelMgr.refoldToCurrentLine&&glApp.panelMgr.refoldToCurrentLine():this.game.gotoFirst();this.Vp.animatePos=!0;this.Vp.afterGameLoad()}},forceUpdateCloudOnGamePos(){this.blockUpdateMode=BlockUpdateMode.FORCE_UPDATE;
5902this.updateCloudOnGamePos()},updateCloudOnGamePos(){this.blockUpdateMode!=BlockUpdateMode.BLOCKED&&(this.gateUpdate||(this.gateUpdate=new V10),this.gateUpdate.exec(function(){glApp.panelMgr.tbBook&&glApp.aTBLobby&&glApp.aTBLobby.hasIdReceived&&(this.bookAnswers||!this.updatePos||!this.updatePos.equals(this.kernel.game.getCurPos())||this.blockUpdateMode==BlockUpdateMode.FORCE_UPDATE)&&(this.blockUpdateMode=BlockUpdateMode.NOT_BLOCKED,this.updatePos=ObjUtil.clone(this.kernel.game.getCurPos()),glApp.panelMgr.tbBook.clear(),
5903(glApp.panelMgr.tbBook.isVisible()||this.checkCloudWithHiddenBook())&&glApp.aTBLobby.requestAllMoves(this.kernel.game.getCurPos()),glApp.panelMgr.tbPanel&&(glApp.panelMgr.tbPanel.isVisible()||this.checkCloudWithHiddenBook())&&glApp.aTBLobby.requestPosInfo(this.kernel.game.getCurPos()),this.lbInfo=null,this.myMoves=[],glApp.myMovesMgr&&(glApp.panelMgr.tbBook&&glApp.panelMgr.tbBook.isVisible()||this.checkCloudWithHiddenBook())&&(this.myMoves=null,!glApp.myMovesMgr.isLoggedIn()&&glApp.myMovesMgr.wasLoggedIn()?
5904glApp.myMovesMgr.reconnectUser():glApp.myMovesMgr.isLoggedIn()&&(this.bookAnswers?glApp.myMovesMgr.checkPosAndMovesEx(this.kernel.game.getCurPos(),this.bookAnswers,this.playingSide):glApp.myMovesMgr.checkPosAndMoves(this.kernel.game.getCurPos(),this.bookAnswers,this.playingSide))),this.setDefaultAnimSteps())}.bind(this),100))},checkCloudWithHiddenBook(){return!1},initMyMovesListener(a){a.addOnMyMovesListener(this.myMovesListener.bind(this));glApp.addOnAccountTypeListener(this.VsListener.bind(this))},
5905myMovesListener(a){this.myMoves=a.moves},VsListener(a){switch(a.type){default:case 1:this.nMaxOnlineDBGames=5;break;case 2:this.nMaxOnlineDBGames=30;break;case 3:this.nMaxOnlineDBGames=50}}},CloudGUIElements={createCloudMenuBtn:function(a,b){return ToolButtons.menuBtn(b,"Databases","Cloud",["Open Cloud Database","Login","Save Game"],["Cloud16","Login16","Save16"],[a.OPEN_CLOUDDATABASE,a.LOGIN_CLOUDDB,a.SAVE_CLOUDDB],a.OPEN_CLOUDDATABASE,"Open database and save games")},createCloudAndPgnMenuBtn:function(a){return ToolButtons.menuBtn(32,
5906"Open","Open",["Open Cloud Database","Open PGN File"],["Cloud16","Open16"],[a.OPEN_CLOUDDATABASE,a.OPEN_PGN_DATABASE],a.OPEN_CLOUDDATABASE)},createCloudDatabaseMenuBtn:function(a,b){return ToolButtons.menuBtn(b,lm.DATABASES,"Cloud",[lm.OPEN_DATABASE,lm.CREATE_DATABASE,lm.DELETE_DATABASE],["Cloud16","CreateCloudDB16","Delete16"],[a.OPEN_CLOUDDATABASE,a.CREATE_CLOUDDB,a.DELETE_CLOUDDB],void 0,lm.DATABASE_FUNCTIONS)},createMarkMoveBtn:function(a,b){return ToolButtons.ribbonBtn(b,lm.MARK_MOVE,"MyMove",
5907a.MARK_CURRENT_MOVE,"Mark the current move as 'my move' to create a repertoire that you can drill.")},createLoadWhiteBtn:function(a,b){return ToolButtons.ribbonBtn(b,lm.LOAD_WHITE,"White",a.LOAD_WHITE_MYMOVES,"Load your White repertoire (marked moves) from the current position.")},createLoadBlackBtn:function(a,b){return ToolButtons.ribbonBtn(b,lm.LOAD_BLACK,"Black",a.LOAD_BLACK_MYMOVES,"Load your Black repertoire (marked moves) from the current position.")},createMyMoveMenuBtn:function(a,b,c,d){var e=
5908[lm.MARK_MOVE,lm.MARK_IMPORTANT,lm.UNMARK_MOVE],f=["MyMove16","ImportantMove16","Erase16"],g=[a.MARK_CURRENT_MOVE,a.IMPORTANT_CURRENT_MOVE,a.UNMARK_CURRENT_MOVE];c&&(e=e.concat(["-",lm.LOAD_WHITE,lm.LOAD_BLACK]),f=f.concat(["","White16","Black16"]),g=g.concat([null,a.LOAD_WHITE_MYMOVES,a.LOAD_BLACK_MYMOVES]));d&&(e.push(lm.UPLOAD_GAME),f.push("Upload16"),g.push(a.UPLOAD_TO_MYMOVES));return ToolButtons.menuBtn(b,lm.MY_MOVES,"MyMove",e,f,g,void 0,lm.MY_MOVE_MENU_TTIP)},createCloudBtn:function(a,b){return ToolButtons.ribbonBtn(b,
5909"Cloud Databases","Cloud",a.OPEN_CLOUDDATABASE,"Open the list of your databases (cloud)")},createCloudSaveBtn:function(a,b){return ToolButtons.ribbonBtn(b,"Save","Save",a.SAVE_CLOUDDB,"Append game to the current cloud database")},createCloudSaveReplaceMenuBtn:function(a,b){return ToolButtons.menuBtn(b,lm.SAVE,"Save",[lm.SAVE,lm.SAVE_AS_NEW,lm.EDIT_GAME],["Replace16","Save16","Edit16"],[a.REPLACE_CLOUDDB,a.SAVE_CLOUDDB,a.EDIT_HEADER],void 0,lm.SAVE_AND_REPLACE_GAMES)},createCloudLoginBtn:function(a,
5910b){return glApp.loginMenuBtn(b)}},ResultPostBack=function(){var a=function(){this.url="https://www.schach.de/";0<=window.location.href.search("test.schach.de")&&(this.url="http://test.schach.de:62068/",console.log("test url detected"))};a.prototype.postSolved=function(b,c,d){if(b&&c){var e=this.url;e+="users/solved?userId="+b+"&posId="+c+String.f("&points={0}",d);$.post(e,null,this.updateUserPoints.bind(this))}};a.prototype.postWrong=function(b,c,d){b&&c&&(d=this.url,d+="users/wrong?userId="+b+"&posId="+
5911c,$.post(d),console.log(d))};a.prototype.postPlayed=function(b,c){b&&c&&(b=this.url,b+="users/played?userId="+window.playchessUser+"&posId="+c,$.post(b))};a.prototype.updateUserPoints=function(b){isNaN(b)||$("#UserTotalPoints").text(b.toString())};return a}();
5912function FormseditGameHeader(a,b){if(0==a.date.year){var c=new Date;a.date.year=c.getYear()+1900;a.date.month=c.getMonth()+1;a.date.day=c.getDate()}c=String.f('<input id="txtWhiteELO" type="number" min="0" max="3500" size="4" value="{0}" />',a.eloWh?String(a.eloWh):"");var d=String.f('<input id="txtBlackELO" type="number" min="0" max="3500" size="4" value="{0}" />
5912',a.eloBl?String(a.eloBl):""),e=String.f('<input type="radio" name="result" value="whitewin"{0}>1-0',a.result==GameResultEnum.WHITE_WINS?
5913" checked":"");e+=String.f('<input type="radio" name="result" value="draw"{0}>\u00bd-\u00bd',a.result==GameResultEnum.DRAW?" checked":"");e+=String.f('<input type="radio" name="result" value="blackwin"{0}>0-1',a.result==GameResultEnum.BLACK_WINS?" checked":"");e+=String.f('<input type="radio" name="result" value="line"{0}>Line',GameResultEnum.isFinished(a.result)?"":" checked");var f=glApp.panelMgr.createDiv("editHeaderDialog",0);var g="<table>   <tr>      <td>         <table>            <tr>               <td style='width: 55px;'>White:</td>               <td><input id='txtWhiteSurname' placeholder='Surname' type='text' size='20' value=\""+
5914(a.white.last+'" /></td>');g+="               <td><input id='txtWhiteForename' placeholder='First Name' type='text' size='20' value=\""+a.white.first+'" /></td>';g=g+"               <td>ELO:</td>               <td>"+(c+"</td>            </tr>         </table>");g+="      </td>";g+="   </tr>";g+="   <tr>";g+="      <td>";g+="         <table>";g+="            <tr>";g+="               <td style='width: 55px;'>Black:</td>";g+="               <td><input id='txtBlackSurname' placeholder='Surname' type='text' size='20' value=\""+
5915a.black.last+'" /></td>';g+="               <td><input id='txtBlackForename' placeholder='First Name' type='text' size='20' value=\""+a.black.first+'" /></td>';g+="               <td>ELO:</td>";g+="               <td>"+d+"</td>";g+="            </tr>";g+="         </table>";g+="      </td>";g+="   </tr>";g+="   <tr>";g+="      <td>";g+="         <table>";g+="            <tr>";g+="               <td style='width: 55px;'>Event:</td>";g+="               <td><input id='txtEvent' placeholder='Event Name' type='text' size='20' value=\""+
5916a.event.event+'" /></td>';g+="               <td><input id='txtLocation' placeholder='Event Site' type='text' size='20' value=\""+a.event.site+'" /></td>';g+="            </tr>";g+="         </table>";g+="      </td>";g+="   </tr>";g+="   <tr>";g+="      <td>";g+="         <table>";g+="            <tr>";g+="               <td style='width: 55px;'>Year:</td>";g+="               <td><input id='txtYear' type='number' min='0' max='2200' size='4' value='"+a.date.getYear()+"' /></td>";g+="               <td>Month:</td>";
5917g+="               <td><input id='txtMonth' type='number' min='0' max='12' size='2' value='"+a.date.getMonth()+"' /></td>";g+="               <td>Day:</td>";g+="               <td><input id='txtDay' type='number' min='0' max='31' size='2' value='"+a.date.getDay()+"' /></td>";g+="            </tr>";g+="         </table>";g+="      </td>";g+="   </tr>";g+="   <tr>";g+="      <td>";g+="         <table>";g+="            <tr>";g+="               <td style='width: 55px;'>Result:</td>";g+="               <td>"+
5918e+"</td>";g+="           </tr>";g+="         </table>";g+="      </td>";g+="   </tr>";g+="   <tr>";g+="      <td style='float: right; margin-top: 15px;'>";g+="         <input type='button' id='ok' value='OK' style='margin-right: 10px;' />";g+="         <input type='button' id='cancel' value='Cancel' />";g+="      </td>";g+="   </tr>";g+="</table>";$(f).html(g);c=(window.innerWidth-590)/2;d=(window.innerHeight-340)/2+window.pageYOffset;$(f).jqxWindow({title:lm.EDIT_GAME,position:{x:c,y:d},width:590,
5919height:340,resizable:!1,isModal:!0,theme:glApp.config.jqxTheme,modalOpacity:.3,okButton:$("#ok"),cancelButton:$("#cancel"),showCloseButton:!1,keyboardCloseKey:"",initContent:function(){$("#ok").jqxButton({width:"90",height:"30",theme:glApp.config.jqxTheme});$("#cancel").jqxButton({width:"90",height:"30",theme:glApp.config.jqxTheme});$("#ok").focus();$("#editHeaderDialog0").find("input:not(:radio):not(:button)").jqxInput({height:24,theme:glApp.config.jqxTheme});$("#editHeaderDialog0").find("input:radio").jqxRadioButton({width:200,
5920theme:glApp.config.jqxTheme})}});glApp.panelMgr.onFormOpen();NodeList.prototype.forEach||(NodeList.prototype.forEach=function(h,k){for(var l=0,m=this.length;l<m;++l)h.call(k,this[l],l,this)});document.querySelectorAll("input[type=number]").forEach(function(h){h.addEventListener("keyup",function(k){k=$("#txtWhiteELO").val();var l=$("#txtBlackELO").val(),m=$("#txtYear").val(),n=$("#txtMonth").val(),r=$("#txtDay").val();k=0>k||3500<k||0>l||3500<l||0>m||2200<m||0>n||12<n||0>r||31<r?!1:!0;$("#ok").jqxButton({disabled:!k})})});
5921$("#ok").click(function(h){if(b){a.white.last=$("#txtWhiteSurname").val();a.white.first=$("#txtWhiteForename").val();a.eloWh=$("#txtWhiteELO").val();a.eloBl=$("#txtBlackELO").val();a.black.last=$("#txtBlackSurname").val();a.black.first=$("#txtBlackForename").val();a.event.event=$("#txtEvent").val();a.event.site=$("#txtLocation").val();h=$("#txtYear").val();
5921var k=$("#txtMonth").val(),l=$("#txtDay").val();0==h&&(k=0);0==k&&(l=0);a.date=new CBDate(h,k,l);$("#editHeaderDialog0").find("input[value=whitewin]").jqxRadioButton("checked")?
5922a.result=GameResultEnum.WHITE_WINS:$("#editHeaderDialog0").find("input[value=draw]").jqxRadioButton("checked")?a.result=GameResultEnum.DRAW:$("#editHeaderDialog0").find("input[value=blackwin]").jqxRadioButton("checked")?a.result=GameResultEnum.BLACK_WINS:a.result=GameResultEnum.UNDEFINED_RESULT;b(a);glApp.panelMgr.onFormClose()}$(f).jqxWindow("hide");$(f).remove()}).bind(this);$("#cancel").click(function(h){$(f).jqxWindow("hide");$(f).remove();glApp.panelMgr.onFormClose()}).bind(this)}"use strict";
5923let createTextField=function(a,b,c,d){var e=$("<input id='"+a+"' maxlength='255'></input>");$(e).attr("placeHolder",c);$(e).css("width","100%");$(e).css("height","25px");$(e).on("keypress",function(f){13==f.keyCode&&(f=$(e).val(),$(e).val(""),d(f,e))});return e},ConfirmForm=function(a,b,c){var d=glApp.panelMgr.createDiv("confirmDialog",0);var e="<div style='padding: 10px;'>"+a+"</div><div style='padding: 10px;'>";e+="   <div>";e+=b;e+="   </div>";e+="   <div>";e+="      <div style='float: right; margin-top: 15px;'>";
5924e+="         <input type='button' id='ok' value='OK' style='margin-right: 10px' />";e+="         <input type='button' id='cancel' value='Cancel' />";e+="      </div>";e+="   </div>";e+="</div>";$(d).html(e);b=150;"Please confirm deletion of this database:"==a&&(b=200);a=(window.innerWidth-350)/2;e=(window.innerHeight-b)/2;$(d).jqxWindow({position:{x:a,y:e},width:350,height:b,resizable:!1,isModal:!0,theme:glApp.config.jqxTheme,modalOpacity:.3,okButton:$("#ok"),cancelButton:$("#cancel"),showCloseButton:!1,
5925initContent:function(){$("#ok").jqxButton({width:"90",height:"30",theme:glApp.config.jqxTheme});$("#cancel").jqxButton({width:"90",height:"30",theme:glApp.config.jqxTheme});$("#ok").focus()}});$("#ok").click(function(f){$(d).jqxWindow("hide");$(d).remove();c("ok")}).bind(this);$("#cancel").click(function(f){$(d).jqxWindow("hide");$(d).remove();c("cancel")}).bind(this)},RadioChoice=function(a,b,c,d,e,f){let g=[],h=0;
5925c.forEach(function(k){g.push({id:"idRadio"+h++,text:k,checked:!1})});g[d].checked=
5926!0;(function(k,l){(new CBForm({id:"userForm",title:b,width:360,height:180,modal:!1,okHandler:function(m){e(m.idRadios)},fields:[{type:"radio",id:"idRadios",buttons:g}]})).create(k,null,l)})(a,f)},LoginForm=function(a,b,c,d,e){};"use strict";
5927let FritzTrainer=function(){var a=function(){this.nShopId="";this.fileList=[];this.indexInList=this.filesInDB=0};a.prototype.getLocalDB=function(){this.localDB||(this.localDB=localforage.createInstance({name:"GA"+this.nShopId}));return this.localDB};return a}(),ReaderHelper=function(){var a=function(){this.requestId=0;this.FritzTrainers=[];var b=new FritzTrainer;this.FritzTrainers.push(b);this.ActiveFritzTrainer=0;this.aProgressForm=null;this.homedir="undefined";this.localDB=localforage.createInstance({name:"GA"});
5928System.isElectron()&&"undefined"!==typeof electronBridge&&(this.homedir=electronBridge.getHomeDir())};a.prototype.onCheckHardware=function(b,c){var d=!1;null==b&&null!=c&&(c===this.getHardwareGuid()?d=!0:alert(lm.YOUR_SYSTEMS_CONFIGURATION_HAS_CHANGED));return d};a.prototype.trySilentActivation=function(b){this.silentCallback=b;b=this.getHardwareGuid();(new AccountsManager(glApp.shortAppName)).activateTrainerSilent(b,"hallolutz",this.FritzTrainers[0].nShopId,this.onSilentActivationResult.bind(this))};
5929a.prototype.onSilentActivationResult=function(b){var c=b.Reason;this.requestId=b.RequestId;this.addFritzTrainer(b.BindedProducts);"80"===c?(this.localDB.setItem("hardware",this.getHardwareGuid(),function(d,e){null!=d&&alert(d)}),this.downloadAllGameActions()):this.silentCallback()};a.prototype.checkHardware=function(b){var c=DOM.getCookie("hardware");null===c||""===c?this.localDB.getItem("hardware",function(d,e){b(d,e)}):b(null,c)};a.prototype.onGetItem=function(b){b&&(this.FritzTrainers[this.ActiveFritzTrainer].indexInList++,
5930this.checkNextGameActionFile())};a.prototype.onRemoveItems=function(){for(var b=0;b<this.FritzTrainers.length;b++)if(this.FritzTrainers[b].fileList){this.ActiveFritzTrainer=b;for(var c=0;c<this.FritzTrainers[b].fileList.length;c++){var d=this.constructItemName(this.FritzTrainers[b].fileList[c]);d=d.substr(0,d.length-4);this.FritzTrainers[b].getLocalDB().removeItem(d,function(e,f){})}}};a.prototype.removeProducts=function(){this.onRemoveItems()};a.prototype.downloadAllGameActions=function(){this.showProgressDialog();
5931this.FritzTrainers[this.ActiveFritzTrainer].indexInList=0;this.downloadNextGameActionFile()};a.prototype.downloadNextGameActionFile=function(){if(this.FritzTrainers[this.ActiveFritzTrainer].indexInList<this.FritzTrainers[this.ActiveFritzTrainer].fileList.length){var b=this.getHardwareGuid(),c=100*this.FritzTrainers[this.ActiveFritzTrainer].indexInList/this.FritzTrainers[this.ActiveFritzTrainer].fileList.length;this.aProgressForm.progress.jqxProgressBar("value",c);System.isElectron()&&"undefined"!==
5932typeof electronBridge&&electronBridge.updateProgressBar(glApp,c/100);c=this.constructItemName(this.FritzTrainers[this.ActiveFritzTrainer].fileList[this.FritzTrainers[this.ActiveFritzTrainer].indexInList]);var d=c.substr(0,c.length-4);$("#myLabel").text(lm.DOWNLOAD_STARTED+". "+lm.PLEASE_WAIT);var e="https://videos.chessbase.com/Replay/GetGameActionsTrainer?id="+(d+"&Request="+this.requestId+"&Product="+this.FritzTrainers[this.ActiveFritzTrainer].nShopId+"&Hardware="+b);$.get(e,function(f){$("#myLabel").text("Received");
5933f?f.length?($("#myLabel").text("Storing..."),this.FritzTrainers[this.ActiveFritzTrainer].getLocalDB().setItem(d,f,function(g,h){null!=g&&alert(g)}),this.onActivatedVideoDownload(this.FritzTrainers[this.ActiveFritzTrainer].fileList[this.FritzTrainers[this.ActiveFritzTrainer].indexInList]),this.FritzTrainers[this.ActiveFritzTrainer].indexInList++,(new Timer(function(){this.downloadNextGameActionFile()}.bind(this))).runOnce(100)):($(this.aProgressForm.nestDiv).jqxWindow("hide"),$(this.aProgressForm.nestDiv).remove(),
5934alert("No Data received: "+e)):alert("Error receiving data")}.bind(this)).fail(function(){$(this.aProgressForm.nestDiv).jqxWindow("hide");$(this.aProgressForm.nestDiv).remove();alert("Sorry downloading data failed, please try again in a moment")}.bind(this))}else this.ActiveFritzTrainer++,this.ActiveFritzTrainer<this.FritzTrainers.length?this.downloadAllGameActions():(this.ActiveFritzTrainer=0,System.isElectron()&&"undefined"!==typeof electronBridge&&electronBridge.updateProgressBar(glApp,-1),$(this.aProgressForm.nestDiv).jqxWindow("hide"),
5935$(this.aProgressForm.nestDiv).remove(),System.isElectron()&&"undefined"!==typeof electronBridge&&electronBridge.showAlert(glApp,lm.PRODUCT_IS_ACTIVATED))};a.prototype.removeProgress=function(){$(this.aProgressForm.nestDiv).jqxWindow("hide");$(this.aProgressForm.nestDiv).remove()};
5935a.prototype.isFileAvailable=function(b,c){b=this.constructItemName(b);b=b.substr(0,b.length-4);this.FritzTrainers[this.ActiveFritzTrainer].getLocalDB().getItem(b,function(d,e){c(e)})};a.prototype.descrambleTime=function(b){return parseInt(b)^
5936this.FritzTrainers[this.ActiveFritzTrainer].nShopId};a.prototype.descrambleAction=function(b,c,d){c=c%5+1;d=d.substr(0,c);return b&&d===b.substr(0,c)?b.substr(c):""};a.prototype.constructItemName=function(b){return this.FritzTrainers[this.ActiveFritzTrainer].nShopId+"-"+b};a.prototype.readGameActionListReady=function(){this.filesInDB=this.indexInList=0;this.checkNextGameActionFile()};a.prototype.readGameActionFileList=function(b){try{var c=new XMLHttpRequest;c.open("GET","gameactions.txt",!0);c.onreadystatechange=
5937function(){if(4===c.readyState&&(200===c.status||0==c.status)){var d=c.responseText;this.FritzTrainers[0].fileList=[];d=d.split("\r\n");for(var e=0;e<d.length;e++)0<d[e].length&&this.FritzTrainers[0].fileList.push(d[e]);b()}}.bind(this);c.send(null)}catch(d){LogException("RN:readGameActionFileList",d),b()}};a.prototype.readShopId=function(b){try{var c=new XMLHttpRequest;c.open("GET","shop.txt",!1);c.onreadystatechange=function(){if(4===c.readyState&&(200===c.status||0===c.status))for(var d=c.responseText.split("\r\n"),
5938e=0;e<d.length;e++)0<d[e].length&&(this.FritzTrainers[0].nShopId=d[e])}.bind(this);c.send(null)}catch(d){LogException("RWM:readShopId",d)}};a.prototype.getUnmaskedInfo=function(b){var c={renderer:"",vendor:""},d=b.getExtension("WEBGL_debug_renderer_info");null!=d&&(c.renderer=b.getParameter(d.UNMASKED_RENDERER_WEBGL),c.vendor=b.getParameter(d.UNMASKED_VENDOR_WEBGL));return c};a.prototype.getHardwareGuid=function(){var b=document.getElementById("glcanvas");var c="No graphics device found";"undefined"!==
5939typeof b&&(b=b.getContext("experimental-webgl"))&&(c=this.getUnmaskedInfo(b).vendor+this.getUnmaskedInfo(b).renderer);b=System.getHardwareId()+this.homedir;for(var d="",e=0;e<c.length;e++)if(e<b.length){var f=c[e].charCodeAt()^b[e].charCodeAt();d+=String.fromCharCode(65+f%26)}return d=System.getOSChar()+d};a.prototype.OnDeactivate=function(b){alert(lm.PRODUCT_IS_DEACTIVATED)};a.prototype.addFritzTrainer=function(b){if(b)for(var c=0;c<b.length;c++){var d=new FritzTrainer;d.nShopId=b[c].ProductId;for(var e=
5940b[c].FileList.split(";"),f=0;f<e.length;f++)d.fileList.push(e[f]);this.FritzTrainers.push(d)}};a.prototype.OnActivate=function(b){var c=b.Reason;this.requestId=b.RequestId;this.addFritzTrainer(b.BindedProducts);if("Server Maintenance"===b.Result)alert(lm.SERVER_IS_IN_MAINTENANCE);else switch(c){case "80":this.localDB.setItem("hardware",this.getHardwareGuid(),function(d,e){null!=d&&alert(d)});this.downloadAllGameActions();break;case "81":alert(lm.PRODUCT_KEY_ALREADY_USED_BEFORE);break;case "83":alert(lm.PRODUCT_KEY_IS_DISABLED);
5941break;case "84":alert(lm.PRODUCT_KEY_IS_INVALID);break;case "85":alert(lm.PRODUCT_KEY_ALREADY_ACTIVATED);break;case "86":alert(lm.PRODUCT_KEY_NOT_VALID_FOR_THIS_PRODUCT)}};a.prototype.showActivateDialog=function(b){this.onActivatedVideoDownload=b;var c=this.getHardwareGuid(),d=new AccountsManager(glApp.shortAppName);b=new SerialForm;DOM.setCookie("hardware",c,365);b.createSerialForm(lm.PLEASE_ACTIVATE_THIS_PRODUCT,function(e){e.idSerial=e.idSerial.trim();25===e.idSerial.length?(e=e.idSerial.toUpperCase(),
5942DOM.setCookie("serial",e,365),d.activateTrainer(c,e,this.FritzTrainers[0].nShopId,this.OnActivate.bind(this))):alert(lm.PRODUCT_KEY_CONTAINS_5_BLOCKS)}.bind(this),function(e){}.bind(this),"")};a.prototype.onValidDeactivate=function(b){var c=b.Reason,d=b.Result;this.addFritzTrainer(b.BindedProducts);if("Server Maintenance"===d)alert(lm.SERVER_IS_IN_MAINTENANCE);else switch(c){case "113":alert(lm.PRODUCT_KEY_NOT_VALID_FOR_THIS_PRODUCT);break;case "112":alert("No products activated");break;case "84":alert("Product key does not exists");
5943break;case "83":alert("General error with deactivation");break;case "110":this.removeProducts(),alert(lm.PRODUCT_IS_DEACTIVATED)}};a.prototype.showDeactivateDialog=function(){var b=new SerialForm,c=this.getHardwareGuid(),d=lm.DEACTIVATE_THIS_PRODUCT;TRACE("harwareid:"+c);
5943b.createSerialForm(d,function(e){e.idSerial=e.idSerial.trim();25===e.idSerial.length?(e=e.idSerial.toUpperCase(),(new AccountsManager(glApp.shortAppName)).deactivateTrainer(c,e,this.onValidDeactivate.bind(this))):alert(lm.PRODUCT_KEY_CONTAINS_5_BLOCKS)}.bind(this),
5944function(e){}.bind(this),"")};a.prototype.feedbackProduct=function(){(new FeedbackForm).createFeedbackForm(lm.SEND_YOUR_FEEDBACK,function(b){var c=b.idSubject;0<this.FritzTrainers.length&&(c+=" ("+this.FritzTrainers[0].nShopId+")",c+=" version:"+glApp.versionCode.nMajor+"."+glApp.versionCode.nMinor);b=b.idMessage;this.baseurl=glApp.config.getVideoPortalUris()[0];c=this.baseurl+"Public/ReportAProblem?subject="+encodeURIComponent(c)+"&message="+encodeURIComponent(b);$.get(c,function(d){alert("thank you")}.bind(this)).fail(function(){}.bind(this))}.bind(this),
5945function(b){}.bind(this),"")};a.prototype.showProgressDialog=function(){this.aProgressForm=new ProgressForm;this.aProgressForm.createProgressForm(lm.DOWNLOADING_FILES,function(b){}.bind(this),function(b){}.bind(this),"")};return a}();"use strict";(function(a){a.require=function(){a.each(arguments,function(b,c){0==a('head script[src="'+c+'"]').length&&document.write('
5945<script type="text/javascript" src="'+c+'">\x3c/script>')})}})(jQuery);
5946let ReaderMode={LIVE:1,REPLAY:2,DIAGRAM:3,TABLE:4,PAIRING:5,VIDEO:6,NOTA:7,OFFLINEVIDEO:8,RECORDER:9},ReaderLayout={BIG_BOARD:0,BIG_NOTA:1,MULTI_BOARD_2:2,MULTI_BOARD_4:3,USER_LAYOUT:4,HORIZONTAL:5,VIDEO:6,DESK_SPLITTED:7,DESK_SWIPED:8},NotaSize={SMALL:0,BIG:1};
5947class ReaderPM extends PluginManager{static replayClass=".cbreplay";static liveClass=".cblive";static notaClass=".cbnota";static diagramClass=".cbdiagram";static tableClass=".cbtable";static pairingClass=".cbpairing";static videoClass=".cbvideo";static offlinevideoClass=".cbofflinevideo";static recorderClass=".cbrecorder";splitterGateRoot=new V10;splitterGateEast=new V10;splitterGateEastWestNest=new V10;splitterGateNotaEng=new V10;multiVarGate=new V10;threatGate=new V10;hintGate=new V10;style=0;constructor(a){super(a);this.inDestroy=
5948!1;this.allPluginClasses=[ReaderPM.replayClass,ReaderPM.liveClass,ReaderPM.notaClass,ReaderPM.diagramClass,ReaderPM.tableClass,ReaderPM.pairingClass,ReaderPM.videoClass,ReaderPM.offlinevideoClass].join();this.coordinates=!0;this.loadLayout();this.layoutIds="layBB layBN layMB2 layMB4 layUs layHori layVid laySplt laySwip".split(" ");this.init();System.isElectron()&&glApp.connectPlayerLobby(!1);this.pluginDivPgn=[];this.liveTournHtml=[];this.loadedGameId=[];this.liveGameId=[];this.buttonGate=[];this.floatBoard=
5949[];this.swpBook=[];this.swpEng=[];this.swpList=[];this.swpNota=[];this.swpVideo=[];this.swpChat=[];ReaderPM.InitListeners();this.nUserBoardsDesk=0;this.addPgnFileInput()}loadLayout(){let a=ReaderLayout.DESK_SWIPED;window.innerWidth<.6*window.innerHeight&&(a=ReaderLayout.BIG_BOARD);System.isMobile()&&(a=ReaderLayout.BIG_BOARD,window.innerWidth>.65*window.innerHeight&&500<window.innerWidth||window.innerWidth>.7*window.innerHeight)&&(a=ReaderLayout.BIG_NOTA);this.layout=parseInt(glApp.Vn.load("ReaderLayout"))||
5950a;System.isMobile()?(this.layout>=ReaderLayout.HORIZONTAL&&(this.layout=ReaderLayout.BIG_BOARD),this.engBelowNota=!1):this.engBelowNota=!0;this.nUserBoards=parseInt(glApp.Vn.load("UserBoards"))||2;this.nUserNota=parseInt(glApp.Vn.load("UserNota"))||0;this.sound="false"!=glApp.Vn.load("Sound");this.boardsSameSize="false"!=glApp.Vn.load("BoardsSameSize")||this.layout==ReaderLayout.DESK_SWIPED;this.biggerFonts=parseInt(glApp.Vn.load("Fonts"))||13;this.vertiLayout=System.isIPad()?ReaderLayout.BIG_NOTA:
5951ReaderLayout.BIG_BOARD;this.engBelowNota="false"!=glApp.Vn.load("EngBelowNota")}init(){super.init();this.modules=[];this.diagrams=[];this.chat=[];this.guessing=[];this.book=[];this.video=[];this.offlinevideo=[];this.recorder=[];this.maximized=-1;this.engineOpen=!1;this.gridCreated=[];this.boardBtns=[];this.diagramBtns=[];this.tabNavBtns=[];this.buttonImages=[];this.tabNavSwitchDivs=[];this.listResized=[];this.notaResized=[];this.soundBtnSelector=[];this.notaSwiper=[];this.closeHamburger=[];this.northH=
5952[];this.availH=[];this.hasPlugins=0<$(this.allPluginClasses).length;System.isElectron()&&"undefined"!==typeof electronBridge&&electronBridge.setTitleTouchBar(glApp,"")}createPanels(){this.createHtml();return 0<this.modules.length}createHelper(){this.readerHelper=new ReaderHelper;this.readerHelper.readShopId()}onReady(){glApp.lobby&&(this.modules&&this.modules[0]&&(this.modules[0].isMyMovesLive||glApp.lobby.requestLiveLists(this.liveLists)),glApp.playerLobby&&glApp.playerLobby.addOnConnectedListener(this.onPlayerLobbyConnect.bind(this)))}loadAzurePlayer(a){if("undefined"===
5953typeof glApp.AzurePlayerLoaded){var b=document.createElement("link");b.href="//amp.azure.net/libs/amp/latest/skins/amp-default/azuremediaplayer.min.css";b.rel="stylesheet";b.type="text/css";document.getElementsByTagName("head")[0].appendChild(b);jQuery.getScript("//amp.azure.net/libs/amp/latest/azuremediaplayer.min.js",function(){glApp.AzurePlayerLoaded=!0;a()})}else a()}loadWowzaPlayer(a){if("undefined"===typeof glApp.WowzaPlayerLoaded){var b=document.createElement("link");b.href="//cdn.flowplayer.com/releases/native/3/stable/style/flowplayer.css";
5954b.rel="stylesheet";b.type="text/css";document.getElementsByTagName("head")[0].appendChild(b);jQuery.getScript("//cdn.flowplayer.com/releases/native/3/stable/flowplayer.min.js",function(){jQuery.getScript("//cdn.flowplayer.com/releases/native/3/stable/plugins/ovp.min.js",function(){jQuery.getScript("//cdn.flowplayer.com/releases/native/3/stable/plugins/hls.min.js",function(){glApp.WowzaPlayerLoaded=!0;a()});jQuery.getScript("//cdn.flowplayer.com/releases/native/3/stable/plugins/subtitles.min.js",function(){glApp.WowzaPlayerLoaded=
5955!0})})})}else a()}loadOfflinePlayer(a){this.createHelper();System.isElectron()&&this.readerHelper.checkHardware(function(b,c){null==b?this.readerHelper.onCheckHardware(b,c)||this.modules[0].offlineVideo.videoManager.disable():alert(b)}.bind(this));System.isElectron()&&"undefined"!==typeof electronBridge&&electronBridge.setMediaTouchBar(glApp,"Video");"undefined"===typeof glApp.OfflinePlayerLoaded&&(glApp.OfflinePlayerLoaded=!0);a()}createHtml(){this.createPlugins();glApp.addOnLoginListener(this.onLogInListener.bind(this));
5956this.initLiveGames();this.initDiagramAnimations()}testRecreate(){this.recreateTournament("Vienna-IM-February-2022",!glApp.isLive,"","de")}recreateTournament(a,b,c,d,e){this.liveGameId=[];this.loadedGameId=[];c=glApp.isLive;let f=this.nActivePlugin;0>f&&(f=0);let g=this.modules[f].pluginDiv;g&&(!b&&this.layoutHasMultiBoard()&&(this.layout=ReaderLayout.BIG_BOARD),a=this.createPluginDiv(a,b,d,e,f),$(g).replaceWith(a),glAp
5956p.isLive=0<$(ReaderPM.liveClass).length,c!=glApp.isLive&&(glApp.isLive?glApp.createLiveManager(!0):
5957glApp.lobby&&glApp.lobby.logOff()),this.checkRecreateOrientation(!0))}createPluginDiv(a,b,c,d,e){if(b)e=`<div class="cblive" data-language="${d}" data-event="${a}"`,"*"!=a&&(e+='data-round="max"'),e+="</div>";else{c=b="";let f="cbreplay",g="";"pgn"==a||"nota"==a?(d=$(this.modules[e].pluginDiv),(c=this.pluginDivPgn[e]||d.text())||(b=d.data("url")),d=d.data("language")||"","nota"==a&&(f="cbnota",g='data-noheader="false"')):(b=`${"https://liveserver.chessbase.com:6009"}/pgn/${a}/all.pgn`,"tactics"==
5958a?b="https://trainingserver.chessbase.com:6009/recent.pgn":"theory"==a&&(b="https://live.chessbase.com/en/TheoryPgn"));e=b?`<div class=${f} data-language="${d}" data-url="${b}" ${g}></div>`:`<div class=${f} data-language="${d}" ${g}>${c}</div>`}return e}checkRecreateOrientation(a){var b=this.isVerti;this.calcIsVerticalLayout();!this.isVerti&&b?this.vertiLayout=this.layout:this.isVerti&&!b&&(this.layout=this.vertiLayout);let c=document.documentElement.scrollTop;return b!=this.isVerti||a?($(this.allPluginClasses).each(function(d,
5959e){if(!this.isPureNota(d))if(this.isOfflineVideo(d))"undefined"==typeof glApp.offlinevideoEl&&(glApp.offlinevideoEl=[],glApp.videoDIV=[],glApp.offlinevideo=[]),glApp.offlinevideoEl[d]=document.getElementById("videoEl"+d),glApp.videoDIV[d]=glApp.offlinevideoEl[d].parentElement,glApp.offlinevideo[d]=this.offlinevideo[d],glAp
5959p.videoDIV[d].removeChild(glApp.offlinevideoEl[d]);else if(this.isVideo(d))"undefined"==typeof glApp.videoEl&&(glApp.videoEl=[],glApp.videoDIV=[],glApp.video=[]),glApp.videoEl[d]=
5960document.getElementById("videoEl"+d),glApp.videoDIV[d]=glApp.videoEl[d].parentElement,glApp.video[d]=this.video[d],glApp.videoDIV[d].removeChild(glApp.videoEl[d]);else if(this.isRecorder(d))"undefined"==typeof glApp.recoderEl&&(glApp.recorderEl=[],glApp.videoDIV=[],glApp.recorder=[]),glApp.recorderEl[d]=document.getElementById("videoEl"+d),glApp.videoDIV[d]=glApp.recorderEl[d].parentElement,glApp.recorder[d]=this.recorder[d],glApp.videoDIV[d].removeChild(glApp.recorderEl[d]);else if(this.isLive(d)){if(this.modules[d].list)for(var f=
59610;f<this.modules[d].list.length;f++)glApp.lobby.setSessionToBackground(this.modules[d].ticket,this.modules[d].list[f].id);$(e).empty(".root");delete this.modules[d].boardArea}}.bind(this)),this.init(),this.createPlugins(),a=this.createHelpText(glApp.isLoggedIn()),this.setHelpHtmlToAll(a),this.initLiveGames(),this.reconnectLive()&&glApp.lobby.requestLiveLists(this.liveLists),document.documentElement.scrollTop=c,!0):!1}switchLayout(a,b){!this.modules[b].getKernel()||a==this.layout&&this.layout!=ReaderLayout.USER_LAYOUT||
5962(this.layout=a,this.stopAllEngines(b),delete this.liveGameId[b],delete this.loadedGameId[b],this.isLive(b)?this.liveGameId[b]=this.modules[b].getKernel().idGame:this.loadedGameId[b]=this.modules[b].getKernel().game.gameNo,this.checkRecreateOrientation(!0),this.layoutIds.forEach(function(c){$("#"+c+"chk"+b).removeClass("slideInWithCheck")}),$("#"+this.layoutIds[this.layout]+"chk"+b).addClass("slideInWithCheck"),this.checkLayoutMenuItem(b))}reconnectLive(){if(glApp.lobby&&null!=glApp.lobby.requestLiveLists&&
5963glApp.isLive){if(glApp.lobby.isLoggedIn())return!0;glApp.lobby.connect();(new Timer(function(){this.clearKernels();glApp.lobby.requestLiveLists(this.liveLists)}.bind(this))).runOnce(3E3)}}clearKernels(a){}switchDeskLayout(a,b){switch(a){default:case ReaderLayout.DESK_SPLITTED:this.boardsSameSize=!1;break;case ReaderLayout.DESK_SWIPED:this.boardsSameSize=!0}this.switchLayout(a,b)}checkLayoutMenuItem(a){this.layoutIds.forEach(function(b){$("#"+b+"chk"+a).removeClass("slideInWithCheck")});$("#"+this.layoutIds[this.layout]+
5964"chk"+a).addClass("slideInWithCheck")}static staticTicket=0;static staticIdKernel=0;static createAnalysisMode(a){return new AnalysisMode(a,1,{hintTimeout:20,liveBookSilent:!0})}createReaderMode(a){return new ReaderPlayingMode(a,0,this)}calcIsVerticalLayout(){var a=$(".cbPluginHolder");a.length?this.isVerti=1.1*a.width()<a.height():(a=document.documentElement,this.isVerti=a.clientWidth<a.clientHeight)}createPlugins(){this.calcIsVerticalLayout();var a=0;ReaderPM.staticTicket=0;var b=function(e,f,g,
5965h,k,l){this.instantiated=!0;this.buttonImages[e]={};this.modifyDimensionsOnCreate(f,e);var m=this.pluginDivPgn[e]||$(f).text();if(m&&10<m.length)this.pluginDivPgn[e]=m,$(f).text(""),$(f).attr("data-move")&&(this.pgnStartMoveIndex=Number($(f).attr("data-move")));else{var n=StrUtil.getURLParam("c64");n||=$(f).data("c64");if(n){m=new Uint8Array(StrUtil.base64.decodeToBinary(n));m=UZIP.inflateRaw(m);n=new Game;let r=new DataBuffer;r.writeByteArray(m,m.length);r.rewind();n.read3(r);m=PGNWriter.toPGN(n)}}g=
5966this.initAbstractModule(f,a,g);h(g,a,m);this.modules.push(g);g.addKernel(this);h=l(f,a,g.getKernel(),"100%",m);g.panels=h;g.nota=h.nota;g.undo=[];g.redo=[];g.onBoardReady=function(){this.initAudio()}.bind(this);$(f).on("click",function(r){return function(t){if(this.nActivePlugin!=r&&0<=this.nActivePlugin)this.onPluginExit(this.nActivePlugin);if(this.nActivePlugin!=r)this.onPluginEntry(r);this.nActivePlugin=r;if(this.closeHamburger[r]&&50<t.offsetY&&50<t.offsetX)this.closeHamburger[r]()}.bind(this)}.call(this,
5967a));h.boardParent&&(g.boardArea=this._createCanvasParent(h.boardParent));g.engineOpen=!1;k(g,a,m);a++;g.mode==ReaderMode.LIVE&&($("#listParent"+e).text(lm.CONNECTING),$("#listParent"+e).addClass("msgInListParent"))},c=this,d=1;$(this.allPluginClasses).each(function(e,f){if($(f).is(ReaderPM.replayClass))c.doCreateReplayPlugin(f,e,b);else if($(f).is(ReaderPM.liveClass))c.doCreateLivePlugin(f,e,b,d),d++;else if($(f).is(ReaderPM.notaClass))c.doCreateNotaPlugin(f,e,b);else if($(f).is(ReaderPM.diagramClass))c.doCreateDiagramPlugin(f,
5968e,b);else if($(f).is(ReaderPM.tableClass))c.doCreateTablePlugin(f,e,b);else if($(f).is(ReaderPM.pairingClass))b.call(this,e,f,this.createReaderMode.bind(this),function(k){k.mode=ReaderMode.PAIRING},function(k,l,m){k.getKernel().fnInitGame=function(){};this.loadPairingData(f,l)}.bind(this),function(k,l,m,n){return this.createPluginElementsTable(k,l)}.bind(this));else if($(f).is(ReaderPM.videoClass)){var g=!0;$(f).attr("data-autoplay")&&-1!=$(f).attr("data-autoplay").search("false")&&(g=!1);var h="";
5969$(f).attr("data-id")&&(h=$(f).attr("data-id"));h="https://videos.chessbase.com/public/UseVideoPlayer?id="+encodeURIComponent(h);$.get(h,function(k){k&&("Wowza"===k.Player?this.loadWowzaPlayer(function(){c.doCreateVideoPlugin(f,e,b,g,k.Token)}.bind(this)):this.loadAzurePlayer(function(){c.doCreateVideoPlugin(f,e,b,g,"")}.bind(this)))}.bind(this)).fail(function(){}.bind(this))}else $(f).is(ReaderPM.offlinevideoClass)&&this.loadOfflinePlayer(function(){c.doCreateOfflineVideoPlugin(f,e,b)}.bind(this))}.bind(this));
5970glApp.isLive=0<$(ReaderPM.liveClass).length;glApp.isAnyPlugin=0<$(this.allPluginClasses).length;
5970$(document.body).unbind("keydown");$(document.body).on("keydown",function(e){this.chat[this.nActivePlugin]&&this.chat[this.nActivePlugin].hasFocus()||this.handleKeyDown(e,this.nActivePlugin||0)&&e.preventDefault()}.bind(this));$(document.body).unbind("orientationchange");$(document.body).on("orientationchange",function(e){this.onOrientationChange()}.bind(this));this.pluginCnt=a}doCreateReplayPlugin(a,b,
5971c){c.call(this,b,a,this.createReaderMode.bind(this),function(d,e){d.mode=ReaderMode.REPLAY},function(d,e,f){d.getKernel().fnInitGame=this.getFnKernelInitGame(a,e);this.createPgnDatabase(a,this.createDatabaseGrid.bind(this),e,f);d.toPgn=function(g){if(g=this.modules[g].pgnDatabase)return g.toString()}.bind(this)}.bind(this),function(d,e,f,g){g=d.dataset.layout;null!=g&&(this.layout=parseInt(g));return this.isMobileLayout()?this.createReplayMobile(d,e,f):this.createReplayDesktop(d,e,f)}.bind(this))}doCreateLivePlugin(a,
5972b,c,d){c.call(this,b,a,ReaderPM.createAnalysisMode,function(e){e.mode=ReaderMode.LIVE;e.isMyMovesLive="true"==a.dataset.mymoves;e.useFirstBoard=!1},function(e){e.requestData=this.createRequestData(a,d,b,this,e.ticket);e.pgnTitle="LiveGames_";e.pgnTitle+=e.requestData.event||e.requestData.player;e.pgnTitle+=".pgn";e.list=[];e.toPgn=this.moduleGamesToPgn.bind(this);this.resizePlugin($(a),b)}.bind(this),function(e,f,g,h){return this.isMobileLayout()?this.createReplayMobile(e,f,g):this.createReplayDesktop(e,
5973f,g)}.bind(this))}doCreateNotaPlugin(a,b,c){c.call(this,b,a,this.createReaderMode.bind(this),function(d,e){d.mode=ReaderMode.NOTA},function(d,e,f){d.getKernel().fnInitGame=this.getFnKernelInitGame(a,e);this.createPgnDatabase(a,function(g,h){},e,f);d.toPgn=function(g){if(g=this.modules[g].pgnDatabase)return g.toString()}.bind(this)}.bind(this),function(d,e,f,g){return this.createPureNota(d,e,f)}.bind(this))}doCreateDiagramPlugin(a,b,c){let d=this;c.call(this,b,a,function(e){a.dataset.play||a.dataset.anim||
5974a.dataset.choice?(e=new MiniPlayMode(e,a.dataset,null,b),e.clearBoardAlways=!!a.dataset.anim):(e=new AnalysisMode(e,1,{hintTimeout:20,liveBookSilent:!0}),e.fnGetMoveEnterType=function(){return MoveEnterType.NEWLINE},e.fnAfterMove=function(){d.showDiaReplayButtons(b,!0)}.bind(this),e.onEntry=function(){this.gateUpdate.exec(function(){glApp.analysisEngine&&glApp.analysisEngine.engineGo(this.kernel)}.bind(this),100)});return e},function(e){e.mode=ReaderMode.DIAGRAM},function(e,f,g){e.toPgn=function(h){h=
5975this.modules[h].getKernel().game;return PGNWriter.toPGN(h)}.bind(this);e.pgnTitle="Position.pgn";e.getKernel().fnInitGame=this.getFnKernelInitDiagram(a,b,this,g);this.resizeDiagram($(a),b)}.bind(this),function(e,f,g,h){this.modifyPlayingModeForTraining(e,f,g);return this.createPluginElementsDiagram(e,f,g)}.bind(this))}doCreateTablePlugin(a,b,c){c.call(this,b,a,this.createReaderMode.bind(this),function(d){d.mode=ReaderMode.TABLE},function(d,e,f){d.getKernel().fnInitGame=function(){};this.loadTableData(a,
5976e)}.bind(this),function(d,e,f,g){return this.createPluginElementsTable(d,e)}.bind(this))}hasPluginHolder(a){return $(a).parent().hasClass("cbPluginHolder")}getLayoutInPluginHolder(a){return this.isDeskLayout()&&(a=$(a).parent(),a.hasClass("cbPluginHolder")&&1.1*a.width()<a.height())?ReaderLayout.BIG_BOARD:this.layout}modifyDimensionsOnCreate(a,b){a.style.clear="both";if($(a).parent().hasClass("cbPluginHolder"))b=$(a),b.css("width","100%"),b.css("height","100%"),b.css("max-width","3000px"),"none"!=
5977b.css("max-height")&&b.css("max-height","30000px"),b.css("margin","0"),b.css("padding","0"),b.css("box-shadow","none"),b.css("border","0");else{let c=!1;["cbtable","cbdiagram","cbpairing","cbnota"].forEach(function(d){$(a).hasClass(d)&&(c=!0)});c||(this.isMobileLayout()?($(a).css("height","88vh"),System.runsOnChessBaseNews()&&500>window.innerWidth&&($(a).css("width",window.innerWidth-8),$(a).css("max-width","1000px"),$(a).css("margin-left","-16px"),$(a).css("margin-bottom","10px")),System.runsOnVideosChessBaseCom()?
5978$(a).css("height","80vh"):System.runsOnLiveChessBaseCom()?$(a).css("height","92vh"):System.urlSearch("elpais.com")&&($(a).css("margin-left","-16px"),$(a).css("max-width","96vw"),$(a).css("height","86vh"))):(a.style.minHeight="100px",a.style.minWidth="100px"),$(a).hasClass("cbofflinevideo")&&(b=$(a).width()/16*9,a.style.maxHeight=b+"px",a.style.minHeight=b+"px",a.style.Height=b+"px"))}}createPluginElementsDiagram(a,b,c,d){return{nota:null,boardParent:this.createDiagramElements(a,b)}}createPluginElementsTable(a,
5979b){return{nota:null,boardParent:null}}
5979createCrossTable(a,b,c,d,e){if(c.Players){c=Tournament.fromObject(c);var f=TiebrakeInfo.arrFromString(c.strTB||d.tbs);f=new RankingOptions(f,d.top);var g=new Ranking(c,d.round,f,e,d);this.modules[b].ranking=g;d=$(a).width();$(a).html("");g.addListener("Changed",function(){$(a).width();this.resizeTable(a,b);g.resized||(g.resized=!0)}.bind(this));d=g.toHtml(d)[0];a.appendChild(d);g.startGetPlayerFlag(g.players);this.resizeTable(a,b)}}createPairings(a,b,c,d,e){var f=
5980Tournament.fromObject(c);c=d.round;0==c&&(c=f.availbeRounds[f.availbeRounds.length-1]);d=new Ranking(f,1E4,{tiebreakInfosArr:[]},e,d);var g=new Pairings(d);g.round=c;this.modules[b].pairing=g;g.addListener("Changed",function(){this.resizePairings(a,b);g.resized||(g.resized=!0)}.bind(this));d=g.RoundToHtml(c)[0];a.appendChild(d);this.resizePairings(a,b)}doCreateVideoPlugin(a,b,c,d,e){c.call(this,b,a,this.createReaderMode.bind(this),function(f,g){f.mode=ReaderMode.VIDEO;f.autoplay=d;f.token=e},function(f,
5981g,h){f.getKernel().fnInitGame=this.getFnKernelInitGame(a,g);this.createVideoDatabase(a,this.createVideoGrid.bind(this),g,h);f.toPgn=function(k){var l=this.replayAllGameActions(k),m=PGNWriter.toPGN(l);this.modules[k].pgnTitle=l.hdr.getWhite()+" - "+l.hdr.getBlack()+".pgn";return m}.bind(this)}.bind(this),function(f,g,h,k){return this.isMobileLayout()?this.createReplayMobile(f,g,h):this.createReplayDesktop(f,g,h)}.bind(this))}doCreateOfflineVideoPlugin(a,b,c){c.call(this,b,a,this.createReaderMode.bind(this),
5982function(d,e){d.mode=ReaderMode.OFFLINEVIDEO},function(d,e,f){d.getKernel().fnInitGame=this.getFnKernelInitGame(a,e);this.createOfflineVideoDatabase(a,this.createOfflineVideoGrid.bind(this),e,f);d.toPgn=function(g){if(g=this.modules[g].pgnDatabase)return g.toString()}.bind(this)}.bind(this),function(d,e,f,g){return this.isMobileLayout()?this.createReplayMobile(d,e,f):this.createReplayDesktop(d,e,f)}.bind(this))}doCreateRecorderPlugin(a,b,c){c.call(this,b,a,this.createReaderMode.bind(this),function(d,
5983e){d.mode=ReaderMode.RECORDER},function(d,e,f){d.getKernel().fnInitGame=this.getFnKernelInitGame(a,e);this.createPgnDatabase(a,this.createDatabaseGrid.bind(this),e,f);d.toPgn=function(g){if(g=this.modules[g].pgnDatabase)return g.toString()}.bind(this)}.bind(this),function(d,e,f,g){return this.isMobileLayout()?this.createReplayMobile(d,e,f):this.createReplayDesktop(d,e,f)}.bind(this))}createReplayDesktop(a,b,c){switch(this.layout){default:case ReaderLayout.DESK_SPLITTED:return this.createReplaySplitted(a,
5984b,c);case ReaderLayout.DESK_SWIPED:return this.createReplaySwiped(a,b,c)}}createReplaySplitted(a,b,c){let d=this.createCommonDesktop(a,b,c);var e=this.createDiv("westNest",b);d.west.appendChild(e);var f=this.createDiv("westNorth",b);e.appendChild(f);var g=this.createDiv("westSouth",b);e.appendChild(g);var h=this.createDiv("eastNest",b);d.east.appendChild(h);var k=this.createDiv("eastLayer",b);h.appendChild(k);var l=this.createDiv("eastUpDownNest",b);k.appendChild(l);this.isOfflineVideo(b)&&this.createOfflineVideoDivs(l,
5985b);this.isVideo(b)&&this.createVideoDivs(l,b);this.isRecorder(b)&&this.createRecorderDivs(l,b);c=this.createNotaDivs(l,b,c);this.hasBook(b)&&this.createBookDivs(l,b);this.hasChat(b)&&this.createChatDivs(h,b);f=this.createBoardDivs(f,b);this.createEngineDivs(g,b);k=this.createDiv("listParent",b);g.appendChild(k);this.createSplittersHori(a,b,d.root,e,h,l);this.isAnyVideo(b)&&(new Timer(function(){this.inDestroy||(this.onVideoSplitterResize(b,!1),$("#root"+b)&&$("#root"+b).jqxSplitter("refresh"))}.bind(this))).runOnce(1500);
5986return{nota:c,boardParent:f}}createReplaySwiped(a,b,c){a=this.createCommonDesktop(a,b,c);let d=this.createBoardDivsMobile(a.west,null,b),e;this.isOfflineVideo(b)?(e=this.createVideoSwipedDesk(a.east,b,"swpParent"),this.createOfflineVideoMobile(e.video,b),this.swpEng[b]=0,this.swpNota[b]=1,this.swpList[b]=2,this.swpVideo[b]=1):this.isVideo(b)?(e=this.createVideoSwipedDesk(a.east,b,"swpParent"),this.createVideoMobile(e.video,b),this.swpEng[b]=0,this.swpNota[b]=1,this.swpList[b]=2,this.swpVideo[b]=1):
5987(this.hasEngBelowNota(b)?(e=this.createNotaAndEngSwipedDesk(a.east,b,"swpParent",!0),this.swpEng[b]=1):(e=this.createNotaSwipedDesk(a.east,b,"swpParent",!0),this.swpEng[b]=0),this.swpNota[b]=1,this.swpList[b]=2,this.swpChat[b]=3);let f=this.createBookDivs(e.book,b),g=this.createEngineDivsMobile(e.eng,b);c=this.createNotaDivs(e.nota,b,c);this.modules[b].nota=c;let h=void 0;e.chat&&(h=this.createChatDivs(e.chat,b));let k=this.createListHolder(e.list,b);this.createListParent(k,b);this.isLive(b)&&this.createListTools(e.list,
5988b);this.createSwipeLayoutSplitter(b,a.root);this.fnSelectNota(b);return{eng:g,boardParent:d,nota:c,book:f,chat:h}}createCommonDesktop(a,b,c){this.modules[b].noBook=null!=a.dataset.nobook;if(this.hasCaptionBar(b)){var d=this.createDiv("cbcaption",b);d.id="cbcaptionDesk"+b;a.appendChild(d)}c=this.createDiv("rootParent",b);a.appendChild(c);d&&(this.closeHamburger[b]=this.createHamburger(d,c,b,this.getHamburgerMenuDesktop(b)),$(".hambN
5988av").css("border-top-right-radius","20px"),$(".hambCaption").css("border-top-right-radius",
5989"20px"),$(a).css("border-top-right-radius","20px"),this.checkLayoutMenuItem(b));a=this.createDiv("root",b);c.appendChild(a);d=this.createDiv("west",b);a.appendChild(d);b=this.createDiv("east",b);a.appendChild(b);return{root:a,west:d,east:b}}createListHolder(a,b){b=this.createDiv("listHolder",b);a.appendChild(b);return b}createListParent(a,b){b=this.createDiv("listParent",b);a.appendChild(b);return b}createListTools(a,b){let c=`<div class="listTools" id="listTools${b}">
5990					 <div class="listToolsBtn" id="listToolsBtn${b}">${lm.SHOW_SELECTED_GAMES}</div>
5991					 <div class="listToolsBtn listToolsClear" id="listToolsClear${b}">Clear</div>
5992					  <div class="listToolsCheck" id="listToolsCheck${b}">${lm.SELECT_GAMES}</div>
5993					</div>`;$(a).append(c);a=$("#listToolsBtn"+b);a.jqxButton({width:170,height:14,theme:glApp.config.jqxTheme});let d=$("#listToolsClear"+b);d.jqxButton({width:110,height:14,theme:glApp.config.jqxTheme});let e=$("#listToolsCheck"+b);a.click(function(f){this.kibitzSelectedLiveGames(b)}.bind(this));d.click(function(){this.clearLiveGameSelection(b)}.bind(this));e.jqxCheckBox({width:170,height:18,checked:!1});e.click(function(){this.toggleLiveGameSelection(b)}.bind(this));return $(c)[0]}toggleLiveGameSelection(a){(this.isSelectingLiveGames=
5994!this.isSelectingLiveGames)?this.fillSelectedLiveGames(a):(this.showSelectedLiveGames(!1,a),this.selectedLiveGames=[])}clearLiveGameSelection(a){this.isSelectingLiveGames=!0;this.checkLiveSelectBox(a);this.showSelectedLiveGames(!1,a);this.selectedLiveGames=[];this.showSelectedLiveGames(!0,a)}setLiveGameSelection(a){this.isSelectingLiveGames||this.toggleLiveGameSelection(a);this.checkLiveSelectBox(a)}fillSelectedLiveGames(a){if(this.isSelectingLiveGames){this.showSelectedLiveGames(!1,a);this.selectedLiveGames=
5995[];let b=this.modules[a],c=$("#listParent"+a).find("td.jsg-invisible-id");b.kernel.forEach(function(d){let e=-1;for(let f=0;f<c.length;f++)if(parseInt($(c[f]).text())==d.idGame){e=f-2;break}0<=e&&(this.selectedLiveGames[e]=d.idGame)}.bind(this));this.showSelectedLiveGames(!0,a)}}msgHtml(a){return`<div class='cbLoadLiveListWait'>${a}</div>`}loadLiveTourns(a,b){if(a){b=$(String.f("<div id='liveTourns{0}' class='liveTourns'></div>",b));var c=$(this.msgHtml("Loading Tournaments ..."));b.append(c);$(a).append(b);
5996return b}}fnLoadLiveTourns(a){let b=$(`#liveTourns${a}`),c=b.find(".cbLiveListBody").html();if(this.liveListTick&&12E4>this.liveListTick.getExpiredMS()){if(c)return;if(this.liveTournHtml[a]){b.html(this.liveTournHtml[a]);return}}this.liveListTick=new Tick;b.load("https://live.chessbase.com/inAppList",function(d,e,f){"error"==e?this.msgHtml("Could not load https://live.chessbase.com/inAppList"):(console.log("OK: https://live.chessbase.com/inAppList"),this.liveTournHtml[a]=b.html())}.bind(this))}fnMaxSwiper(a){if(this.layout!=
5997ReaderLayout.HORIZONTAL){let b=$(`#north${a}`);$(`#south${a}`).hide();this.northH[a]=b.height();b.height(this.availH[a])}}fnRestoreSwiper(a){if(this.layout!=ReaderLayout.HORIZONTAL&&this.northH[a]){let b=$(`#north${a}`);$(`#south${a}`).show();b.height(this.northH[a]);delete this.northH[a]}}createNotaDivs(a,b,c,d){var e=this.createDiv("notaNest",b);a.appendChild(e);a=this.createDiv("notaparent",b);var f=this.createDiv("notaEl",b);a.appendChild(f);e.appendChild(a);c=this._createNotation(f,c,b);this.isOfflineVideo(b)||
5998d||(d=this.createDiv("belowNota",b),a=this.createDiv("notaButtons",b),d.appendChild(a),e.appendChild(d),this.createNotaButtons(a,b));return c}createBookDivs(a,b){var c=this.createDiv("bookparent",b),d=this.createDiv("bookEl",b);c.appendChild(d);a.appendChild(c);this.book[b]=this._createBook(d,b)}createChatDivs(a,b){var c=this.createDiv("westLayer",b);a.appendChild(c);this.chatTabs=new CBTabs({tabs:[{title:"Chat",id:"idTabChat"},{title:"Guess",id:"idTabGuessMoves"}]});this.chatTabs.create(c);this.chat[b]=
5999this._createChat("idTabChat",b);this.guessing[b]=this._createGuessing("idTabGuessMoves",b);let d=this.guessing[b];d&&$("#westLayer"+b+" li[role='tab']").click(function(){1==$("li[role='tab']").index($(this))&&(glApp.isLoggedIn()?d.requestMoveList(b):(alert("You need to be logged in to access this functionality"),glApp.panelMgr.chatTabs.select(0)))});$(".cbChatTitle").hide();$(this.chatTabs.nestDiv).unbind("selected");this.chatTabs.select(0)}clearGuessingElements(a){var b=$(String.f("#GuessMoveDiv{0}",
6000a));$(b).empty();b=$(String.f("#GuessMoveButtons{0}",a));$(b).empty();a=$(String.f("#GuessMoveOutput{0}",a));$(a).empty()}clearGuessingTopVotersDiv(a){a=$(String.f("#TopVotersDiv{0}",a));$(a).empty()}markMyBet(){this.guessing[0].markMyBet()}markMyVote(){this.guessing[0].markMyVote()}updateUserVotes(a){a=a?"https://live.chessbase.com/UUV":"https://live.chessbase.com/DUV";var b=glApp.Vn.userName;null!=b&&(b={UserName:encodeURIComponent(b)},$.ajax({url:a,method:"POST",dataType:"json",data:b}))}populateGuessMoveList(a,
6001b){this.clearGuessingElements(0);this.guessing[0].populateGuessMoveList(a,!1);this.guessing[0].populateGuessMoveList(a,!0);this.guessing[0].addOutputTextBox();this.guessing[0].toggleVoteTable(!b)}populateGuessMoveTopVoters(a){this.clearGuessingTopVotersDiv(0);this.guessing[0].populateTopVotersDiv(a)}populateGuessMoveOutput(a){this.guessing[0].populateGuessMoveOutput(a)}
6001showLoadingMask(){this.guessing[0].showLoadingMask()}hideLoadingMask(){this.guessing[0].hideLoadingMask()}createVideoDivs(a,b){var c=
6002this.createDiv("videoparent",b);if("undefined"!=typeof glApp.videoEl&&glApp.videoEl[b])c.appendChild(glApp.videoEl[b]),this.video[b]=glApp.video[b];else{var d=this.createDiv("videoEl",b);c.appendChild(d);d.style.height="100%";this.video[b]=this._createVideo(d,b)}a.appendChild(c)}createVideoMobile(a,b){var c=this.createDiv("videoparent",b);if("undefined"!=typeof glApp.videoEl&&glApp.videoEl[b])c.appendChild(glApp.videoEl[b]),this.video[b]=glApp.video[b];else{var d=this.createDiv("videoEl",b);c.appendChild(d);
6003d.style.height="100%";this.video[b]=this._createVideo(d,b)}a.append(c);return c}createOfflineVideoMobile(a,b){var c=this.createDiv("videoparent",b);if("undefined"!=typeof glApp.offlinevideoEl&&glApp.offlinevideoEl[b])c.appendChild(glApp.offlinevideoEl[b]),this.offlinevideo[b]=glApp.offlinevideo[b];else{var d=this.createDiv("videoEl",b);c.appendChild(d);d.style.height="100%";this.offlinevideo[b]=this._createOfflineVideo(d,b)}a.append(c);return c}createOfflineVideoDivs(a,b){var c=this.createDiv("videoparent",
6004b);if("undefined"!=typeof glApp.offlinevideoEl&&glApp.offlinevideoEl[b])c.appendChild(glApp.offlinevideoEl[b]),this.offlinevideo[b]=glApp.offlinevideo[b],this.offlinevideo[b].videoManager&&this.offlinevideo[b].videoManager.play();else{var d=this.createDiv("videoEl",b);c.appendChild(d);this.offlinevideo[b]=this._createOfflineVideo(d,b);this.modules[b].offlineVideo=this.offlinevideo[b]}a.appendChild(c)}createRecorderDivs(a,b){var c=this.createDiv("videoparent",b);if("undefined"!=typeof glApp.recorderEl&&
6005glApp.recorderEl[b])c.appendChild(glApp.recorderEl[b]),this.recorder[b]=glApp.recorder[b];else{var d=this.createDiv("videoEl",b);c.appendChild(d);this.recorder[b]=this._createRecorder(d,b);this.modules[b].recorder=this.recorder[b]}a.appendChild(c)}createBoardDivs(a,b){var c=this.createDiv("boardHolder",b);a.appendChild(c);var d=this.createDiv("boardArea",b);c.appendChild(d);var e=this.createDiv("belowBoard",b);b=this.createDiv("buttons",b);e.appendChild(b);a.appendChild(e);glSettings.isRedBoard()?
6006($(c).css("backgroundImage","url( "+getCommonPath()+"Media/Chess/RedBackground.jpg )"),$(e).css("backgroundImage","linear-gradient( to right, hsla( 31, 0%, 77%, 1.0), hsla(31, 0%, 85%, 1.0) 40%, hsla( 31, 5%, 61%, 1.0) )")):$(c).css("backgroundImage","url( "+getCommonPath()+"Media/Chess/OrangeBrighterSoftBacklightLessSatur.jpg )");return d}createBoardDivsMobile(a,b,c){var d=this.createDiv("boardHolder",c);$(d).css("backgroundImage","url( "+getCommonPath()+"Media/Chess/OrangeBrighterSoftBacklightLessSatur.jpg )");
6007var e=this.createDiv("boardArea",c);d.appendChild(e);a.appendChild(d);d=this.createDiv("belowBoard",c);c=this.createDiv("buttons",c);d.appendChild(c);(b||a).appendChild(d);return e}createEngineDivs(a,b){var c=this.createDiv("engineParent",b);b=this.createDiv("engineEl",b);c.appendChild(b);a.appendChild(c)}createEngineDivsMobile(a,b){var c=this.createDiv("engineParent",b);b=this.createDiv("engineEl",b);c.appendChild(b);a.appendChild(c);return b}createSplittersHori(a,b,c,d,e,f){var g=this.getSplitterWidth(),
6008h=0,k=50;$(a).is(ReaderPM.liveClass)&&(880<$(a).width()&&1100>$(a).width()?(k=60,780>$(a).height()&&(h=65)):(h=76,k=65));if($(a).is(ReaderPM.videoClass)||$(a).is(ReaderPM.offlinevideoClass)||$(a).is(ReaderPM.recorderClass))k=55,h=88;System.isMobile()&&500>window.innerWidth?k=h=65:$(a).width()<1.1*$(a).height()&&(k=65);h||=this.calcEngineSplitPercent($(a).width(),$(a).height()-30,k);this.createRootSplitter(b,c,g,k);this.createWestNestSplitter(b,d,g,h);this.createEastNestSplitter(b,e,g);this.isAnyVideo(b)?
6009this.createVideoSplitter(b,f,g,$(a).height()):this.createBookSplitter(b,f,g,$(a).height())}createSwipeLayoutSplitter(a,b){var c=this.getSplitterWidth();let d=this.isLive(a)?60:55;this.createRootSplitter(a,b,c,d);this.hasEngBelowNota(a)&&this.createNotaEngSplitter(a,c)}calcEngineSplitPercent(a,b,c){a=a*(100-c)/100+$(".belowBoard").height();return Math.min(85,100*a/b)}createRootSplitter(a,b,c,d){var e=this.loadSplitPos("root",a);d=e&&e.size?e.size:d;$(b).jqxSplitter({width:"100%",height:"100%",splitBarSize:c,
6010theme:glApp.config.jqxTheme,panels:[{size:d+"%",collapsible:!1},{size:100-d+"%",collapsible:!1}]});$(b).on("resize",function(f){LOG("RootResize","","resize");this.splitterGateRoot.exec(function(){this.onSplitterResize(a,!0)}.bind(this),100)}.bind(this))}createWestNestSplitter(a,b,c,d){var e=this.loadSplitPos("westNest",a);d=e&&e.size?Math.min(98,e.size):d;$(b).jqxSplitter({orientation:"horizontal",splitBarSize:c+1,theme:glApp.config.jqxTheme,panels:[{size:d+"%",collapsible:!1},{size:100-d+"%",collapsible:!1}]});
6011$(b).on("resize",function(f){LOG("WestNestResize","","resize");this.splitterGateRoot.exec(function(){this.onSplitterResize(a)}.bind(this),100)}.bind(this))}createEastNestSplitter(a,b,c){if(this.hasChat(a)){var d=(d=this.loadSplitPos("eastNest",a))&&d.size?d.size:75;$(b).jqxSplitter({orientation:"vertical",splitBarSize:c+2,theme:glApp.config.jqxTheme,panels:[{size:d+"%",collapsible:!1},{size:100-d+"%",collapsible:!1}]});$(b).on("resize",function(e){LOG("EastNestResize","","resize");this.splitterGateEast.exec(function(){this.onEastSplitterResize(a,
6012!1)}.bind(this),50)}.bind(this))}}createBookSplitter(a,b,c,d){if(this.hasBook(a)){var e=90;850<d&&(e=86);e=(d=this.loadSplitPos("eastUpDownNest",a))&&d.size?d.size:e;$(b).jqxSplitter({orientation:"horizontal",width:"100%",height:"100%",splitBarSize:c+2,theme:glApp.config.jqxTheme,panels:[{size:e+"%",collapsible:!1},{size:100-e+"%",collapsible:!1}]});$(b).on("resize",function(f){LOG("EastNestResize","","resize");this.splitterGateEastWestNest.exec(function(){this.onBookSplitterResize(a,!1)}.bind(this),
601350)}.bind(this))}}createVideoSplitter(a,b,c,d){if(this.isAnyVideo(a)){var e=90;850<d&&(e=60);this.isAnyVideo(a)&&(e=45);e=(d=this.loadSplitPos("eastUpDownNest",a))&&d.size?d.size:e;$(b).jqxSplitter({orientation:"horizontal",width:"100%",height:"100%",splitBarSize:c+2,theme:glApp.config.jqxTheme,panels:[{size:e+"%",collapsible:!1},{size:100-e+"%",collapsible:!1}]});$(b).on("resize",function(f){this.splitterGateEastWestNest.exec(function(){TRACE("resizevideo");this.onVideoSplitterResize(a,!1)}.bind(this),
6014150)}.bind(this))}}createNotaEngSplitter(a,b){let c=$(`#notaEngNest-${a}`);if(c.length){var d=80,e=this.loadSplitPos("notaEngNest-",a);e&&e.size&&(d=e.size);80<d&&(d=80);c.jqxSplitter({orientation:"horizontal",splitBarSize:b+1,width:"100%",height:"100%",theme:glApp.config.jqxTheme,panels:[{size:d+"%",collapsible:!1},{size:100-d+"%",collapsible:!1}]});c.on("resize",function(f){this.splitterGateNotaEng.exec(function(){this.onNotaEngSplitterResize(a)}.bind(this),100)}.bind(this))}}determineLayoutByPlugin(a,
6015b){this.isHorizontalMobile()?this.layout=ReaderLayout.HORIZONTAL:this.isVideo(a)?this.layout=ReaderLayout.VIDEO:this.hasPluginHolder(b)&&(this.layout=this.getLayoutInPluginHolder(b))}createReplayMobile(a,b,c){this.determineLayoutByPlugin(b,a);var d=this.createDiv("root",b);a.appendChild(d);if(!this.isHorizontalMobile()){var e=this.createDiv("mobCaption",b);d.appendChild(e)}var f=this.createDiv("main",b);d.appendChild(f);this.hasHamburgerMenu()&&(this.closeHamburger[b]=this.createHamburger(e,f,b,this.getHamburgerMenu(b)),
6016this.checkLayoutMenuItem(b));d=1!=this.getGameCount(b);switch(this.layout){case ReaderLayout.MULTI_BOARD_2:d=this.createEngPlusNotaListSwiped(f,b);a=this.createBoardParent(f,b,"south");f=this.createEngineDivsMobile(d.eng,b);c=this.createNotaDivs(d.nota,b,c,!0);this.createListParent(d.list,b);this.loadLiveTourns(d.tourns,b);d=this.createBookDivs(d.book,b);a=this.createBoardDivsMobile(a.board,null,b);this.swpEng[b]=-1;this.swpBook[b]=0;this.swpNota[b]=1;this.swpList[b]=2;this.fnSelectNota(b);break;
6017case ReaderLayout.BIG_BOARD:case ReaderLayout.MULTI_BOARD_4:case ReaderLayout.USER_LAYOUT:this.hasEngBelowNota(b)?(this.swpBook[b]=0,this.swpEng[b]=1,this.swpNota[b]=1,this.swpList[b]=-1,a=2):(this.swpBook[b]=0,this.swpEng[b]=1,this.swpNota[b]=2,this.swpList[b]=-1,a=3);e=this.createEngNotaListSwiped(f,b,"north",d);let g=this.createBoardParent(f,b,"south");f=this.createEngineDivsMobile(e.eng,b);c=this.createNotaDivs(e.nota,b,c,!0);d&&(this.createListParent(e.list,b),this.swpList[b]=a);this.loadLiveTourns(e.tourns,
6018b);d=this.createBookDivs(e.book,b);a=this.createBoardDivsMobile(g.board,null,b);
6018this.hasEngBelowNota(b)&&this.createNotaEngSplitter(b,this.getSplitterWidth());this.fnSelectNota(b);break;default:case ReaderLayout.BIG_NOTA:d=this.createNotaListSwiped(f,b);a=this.createBoardAndEng(f,b);f=this.createEngineDivsMobile(a.eng,b);c=this.createNotaDivs(d.nota,b,c,!0);this.createListParent(d.list,b);this.loadLiveTourns(d.tourns,b);d=this.createBookDivs(d.book,b);a=this.createBoardDivsMobile(a.board,a.buttons,
6019b);this.swpEng[b]=-1;this.swpBook[b]=0;this.swpNota[b]=1;this.swpList[b]=2;this.fnSelectNota(b);break;case ReaderLayout.HORIZONTAL:$("#main"+b).css("display","flex");d=this.isVideo(b)?this.createVideoSwipes(f,b,"mobWest"):this.createEngNotaListSwiped(f,b,"mobWest",d);e=this.createBoardParent(f,b,"mobEast");this.setSizeMobEastWest(a,b);f=this.createEngineDivsMobile(d.eng,b);c=this.createNotaDivs(d.nota,b,c,!0);this.createListParent(d.list,b);this.swpBook[b]=0;this.swpEng[b]=1;this.swpNota[b]=2;this.swpList[b]=
60203;this.isVideo(b)?(this.createVideoMobile(d.video,b),this.swpVideo[b]=3,this.swpList[b]=4):this.loadLiveTourns(d.tourns,b);d=this.createBookDivs(d.book,b);a=this.createBoardDivsMobile(e.board,null,b);this.isVideo(b)?this.fnSelectVideo(b):this.fnSelectNota(b);break;case ReaderLayout.VIDEO:d=this.createVideoSwipes(f,b,"north"),a=this.createBoardParent(f,b,"south"),f=this.createEngineDivsMobile(d.eng,b),c=this.createNotaDivs(d.nota,b,c,!0),this.createListParent(d.list,b),this.createVideoMobile(d.video,
6021b),d=this.createBookDivs(d.book,b),a=this.createBoardDivsMobile(a.board,null,b),this.swpBook[b]=0,this.swpEng[b]=1,this.swpNota[b]=2,this.swpVideo[b]=3,this.swpList[b]=4,this.fnSelectVideo(b)}return{nota:c,boardParent:a,eng:f,book:d}}getOpeners(a){return[{title:"PGN",id:"OpenPgn",handler:function(){$("#pgnFileInput").click()}.bind(this)},{title:"FEN",id:"OpenFen",handler:function(){$("#pgnFileInput").click()}.bind(this)}]}getSharers(a){let b=[{title:lm.SHARE_BOARD,id:"dlBoard",handler:function(){this.fnShareBoard(a)}.bind(this)},
6022{title:lm.SHARE_BOARD_USER,id:"dlBoardUser",handler:function(c){this.fnShareBoardUser(a,c)}.bind(this)},{title:lm.SHARE_PLAYABLE,id:"dlDiaLink",handler:function(c){this.shareDiaLinkUser(a,c)}.bind(this)},{title:lm.SHARE_GIF,id:"dlGif",handler:function(c){this.fnShareGifUser(a,c,!0)}.bind(this)},{title:lm.NOTATION+" (PGN)",id:"dlPgn",handler:function(){this.fnSaveDB(a)}.bind(this)},{title:"QR Code",id:"dlQR",handler:function(c){this.createQRCode(a,c,!0)}.bind(this)}];if(this.hasLiveChessLink(a)){let c=
6023this;b.push({title:lm.LINK_TO_THIS_GAME,id:"dlLiveLink",handler:function(d){console.log("Handler shareLive");c.shareLiveChessLink(a,d)}})}return b}hasLiveChessLink(a){return!1}getHamburgerMenu(a){let b=[];System.runsOnLiveChessBaseCom()&&b.push({title:lm.HOME,id:"Home",handler:function(){this.fnSelectBack(a)}.bind(this)});this.isVideo(a)||b.push({title:lm.OPEN+"...",id:"open",children:this.getOpeners(a)});b.push({title:lm.SHARE+"...",id:"share",children:this.getSharers(a)});if(!this.isVideo(a)){let c=
6024[{title:lm.BIG_BOARD,id:this.layoutIds[ReaderLayout.BIG_BOARD],handler:function(){this.switchLayout(ReaderLayout.BIG_BOARD,a)}.bind(this)},{title:lm.BIG_NOTATION,id:this.layoutIds[ReaderLayout.BIG_NOTA],handler:function(){this.switchLayout(ReaderLayout.BIG_NOTA,a)}.bind(this)}];this.isLive(a)&&(c=c.concat([{title:lm.TWO_BOARDS,id:this.layoutIds[ReaderLayout.MULTI_BOARD_2],handler:function(){this.switchLayout(ReaderLayout.MULTI_BOARD_2,a)}.bind(this)},{title:lm.FOUR_BOARDS,id:this.layoutIds[ReaderLayout.MULTI_BOARD_4],
6025handler:function(){this.switchLayout(ReaderLayout.MULTI_BOARD_4,a)}.bind(this)},{title:"User Layout",id:this.layoutIds[ReaderLayout.USER_LAYOUT],handler:function(d){this.fnUserLayout(a,d)}.bind(this)}]));b.push({title:lm.LAYOUT+"...",id:"layout",children:c})}b=b.concat({title:lm.FLIP_BOARD,id:"flip",handler:function(){this.fnFlipBoard(a)}.bind(this)});return b=b.concat({title:lm.SETTINGS,id:"pieces",handler:function(c){this.fnSettings(a,c)}.bind(this)})}getNewMenuItems(a){return[{title:lm.NEW_GAME,
6026id:"new",handler:function(){this.fnNewGame(a)}.bind(this)},{title:lm.EDIT_GAME,id:"edit",handler:function(){this.editGameHeader();this.fnSelectNota(a)}.bind(this)},{title:lm.SETUP_POSITION,id:"setupPos",handler:function(){this.setupPosition()}.bind(this)}]}getHamburgerMenuDesktop(a){let b=[];System.runsOnLiveChessBaseCom()&&b.push({title:lm.HOME,id:"Home",handler:function(){this.fnSelectBack(a)}.bind(this)});b.push({title:lm.NEW+" ...",id:"news",children:this.getNewMenuItems(a)});b.push({title:lm.OPEN+
6027"...",id:"open",children:this.getOpeners(a)});let c=[{title:lm.SPLITTED_LAYOUT,id:this.layoutIds[ReaderLayout.DESK_SPLITTED],handler:function(){this.switchDeskLayout(ReaderLayout.DESK_SPLITTED,a)}.bind(this)},{title:lm.SWIPED_LAYOUT,id:this.layoutIds[ReaderLayout.DESK_SWIPED],handler:function(){this.switchDeskLayout(ReaderLayout.DESK_SWIPED,a)}.bind(this)}];this.isLive(a)?c.push({title:lm.LAYOUT_SETTINGS,id:"laySet",handler:function(d){this.configDesktopLayout(a,d)}.bind(this)}):this.isVideo(a)||
6028c.push({title:lm.READING_MODE,id:"idLayNotaOnly",handler:function(){this.fnDeskToNota(a)}.bind(this)});b.push({title:lm.SHARE+"...",id:"share",children:this.getSharers(a)});b.push({title:lm.LAYOUT+"...",id:"layout",children:c});b=b.concat({title:lm.FLIP_BOARD,id:"flip",handler:function(){this.fnFlipBoard(a)}.bind(this)});return b=b.concat({title:lm.SETTINGS,id:"pieces",handler:function(d){this.fnSettings(a,d)}.bind(this)})}createSaveMenu=function(a,b){var c=[lm.DOWNLOAD+" & "+lm.COPY+" - PGN",lm.DOWNLOAD+
6029" - GIF",lm.SHARE_BOARD,lm.SHARE_PLAYABLE,lm.DOWNLOAD+" & "+lm.COPY+" - FEN",lm.DOWNLOAD+" - QR Code",lm.PASTE_PGN,lm.OPEN_PGN];this.hasLiveChessLink(b)&&c.push(lm.LINK_TO_THIS_GAME);
6029System.runsOnLocalHost()&&c.push("Debug - no function");let d=this.modules[0],e=this;return this.createJQMenu(a,"saveMenu",c,0,function(f,g){switch(parseInt(f)){case 0:e.fnSaveDB(b);break;case 4:e.fnSaveFEN(b);break;case 1:e.fnShareGifUser(b,g,!1);break;case 2:f=e.getStrToMove(b);e.doShareBoard(b,{save:!0,share:!1,players:!0,
6030toMove:f});break;case 3:e.shareDiaLinkUser(b,g);break;case 5:e.createQRCode(b,g);break;case 6:e.pastePgn(d);break;case 7:$("#pgnFileInput").click();break;case 8:e.shareLiveChessLink(b,g)}},function(){},!0)};symbolBtnHdl(a,b){var c=$(`#n-btnSymbolMenu-${a}`);if(0!=c.length){var d=b.clientX-10;a=this.createSymbolMenu(c[0],a);c=$(a).height();b=b.clientY+window.pageYOffset-c;b+c>window.innerHeight+window.pageYOffset&&(b=Math.max(0,window.innerHeight-c+window.pageYOffset));$(a).jqxMenu({mode:"popup",theme:"chessbase"});
6031$(a).jqxMenu("open",d,b);$(a).css("z-index",100)}}createSymbolMenu=function(a,b){let c=Vz,d=SpecialGlyphs,e=this;return this.createJQMenu(a,"symbolMenu",[lm.DELETE,c[d.GOOD_MOVE],c[d.BAD_MOVE],c[d.VERY_GOOD_MOVE],c[d.VERY_BAD_MOVE],c[d.SPECULATIVE_MOVE],c[d.DUBIOUS_MOVE],lm.TEXT_AFTER,lm.TEXT_BEFORE],0,function(f,g){g=glApp.Vy;let h=-1;switch(parseInt(f)){default:h=-1;break;case 0:e.clearMark(b);break;case 1:h=g.MARK_GOOD;break;case 2:h=g.MARK_BAD;break;case 3:h=g.MARK_VERYGOOD;break;case 4:h=g.MARK_VERYBAD;
6032break;case 5:h=g.MARK_INTERESTING;break;case 6:h=g.MARK_DUBIOUS;break;case 7:h=g.ADD_POST_TEXT;break;case 8:h=g.ADD_PRE_TEXT}-1!=h&&e.setMark(b,h)},function(){})};addAnnoField(){void 0===this.annoField?($("#annoEdit")[0]&&$("#annoEdit").remove(),this.annoField=createTextField("annoEdit","","Enter text annotation",function(a,b){glApp.panelMgr.getKernel().onAnnoEnter(a,b)})):this.annoField.show();$(this.annoField).insertBefore("#notaButtons"+this.nActivePlugin);$(this.annoField).focus();this.enableShortcuts=
6033!1}createEngPlusNotaListSwiped(a,b){var c=this.createDiv("north",b);a.appendChild(c);a=[{name:"book"},{name:"engplusnota"},{name:"list"}];this.addTourns(a,b);this.notaSwiper[b]=this.createSwiper(c,"north",a,b);c=$(`#swipe-north-engplusnota-${b}`);c.addClass("mobNotaEng");c.append($(`<div class='mobNotaEngNota' id='engNotaNota-${b}'></div>`));c.append($(`<div class='mobNotaEngEng' id='engNotaEng-${b}'></div>`));return{book:$(String.f("#swipe-north-book-{0}",b))[0],nota:$(`#engNotaNota-${b}`)[0],eng:$(`#engNotaEng-${b}`)[0],
6034list:$(String.f("#swipe-north-list-{0}",b))[0],tourns:$(String.f("#swipe-north-tourns-{0}",b)).first()}}createEngNotaListSwiped(a,b,c,d){var e=this.createDiv(c,b);a.appendChild(e);a=[];a=this.hasEngBelowNota(b)?[{name:"book"},{name:"notaEng",fn:function(){}.bind(this)}]:[{name:"book"},{name:"eng",fn:function(){this.fnStartAnalysis(b)}.bind(this)},{name:"nota",fn:function(){this.stopAllEngines(b)}.bind(this)}];d&&a.push({name:"list",fn:function(){this.isLive(b)&&this.reconnectLive()}.bind(this)});
6035this.addTourns(a,b);this.notaSwiper[b]=this.createSwiper(e,c,a,b);return this.hasEngBelowNota(b)?(d=$(`#swipe-${c}-notaEng-${b}`),d.addClass("swpNotaEng"),d.append($(`<div class='swpNotaNest' id='notaEngNest-${b}'></div>`)),d=$(`#notaEngNest-${b}`),d.addClass("swpNotaEngNest"),d.append($(`<div class='swpNotaEngNota' id='notaEngNota-${b}'></div>`)),d.append($(`<div class='swpNotaEngEng' id='notaEngEng-${b}'></div>`)),{book:$(String.f("#swipe-{1}-book-{0}",b,c))[0],nota:$(`#notaEngNota-${b}`)[0],eng:$(`#notaEngEng-${b}`)[0],
6036list:$(String.f("#swipe-{1}-list-{0}",b,c))[0],tourns:$(String.f("#swipe-{1}-tourns-{0}",b,c)).first(),video:$(String.f("#swipe-{1}-video-{0}",b,c)).first()}):{book:$(String.f("#swipe-{1}-book-{0}",b,c))[0],eng:$(String.f("#swipe-{1}-eng-{0}",b,c))[0],nota:$(String.f("#swipe-{1}-nota-{0}",b,c))[0],list:$(String.f("#swipe-{1}-list-{0}",b,c))[0],tourns:$(String.f("#swipe-{1}-tourns-{0}",b,c)).first(),video:$(String.f("#swipe-{1}-video-{0}",b,c)).first()}}createNotaListSwiped(a,b){var c=this.createDiv("north",
6037b);a.appendChild(c);a=[{name:"book"},{name:"nota"},{name:"list"}];this.addTourns(a,b);this.notaSwiper[b]=this.createSwiper(c,"north",a,b);return{book:$(String.f("#swipe-north-book-{0}",b))[0],nota:$(String.f("#swipe-north-nota-{0}",b))[0],list:$(String.f("#swipe-north-list-{0}",b))[0],tourns:$(String.f("#swipe-north-tourns-{0}",b)).first()}}createVideoSwipes(a,b,c){var d=this.createDiv(c,b);a.appendChild(d);a=[{name:"book"},{name:"eng",fn:function(){this.fnStartAnalysis(b)}.bind(this)},{name:"nota",
6038fn:function(){this.stopAllEngines(b)}.bind(this)},{name:"video",fn:function(){this.stopAllEngines(b)}.bind(this)},{name:"list"}];this.notaSwiper[b]=this.createSwiper(d,c,a,b,!0);return{book:$(String.f("#swipe-{1}-book-{0}",b,c))[0],eng:$(String.f("#swipe-{1}-eng-{0}",b,c))[0],nota:$(String.f("#swipe-{1}-nota-{0}",b,c))[0],video:$(String.f("#swipe-{1}-video-{0}",b,c)),list:$(String.f("#swipe-{1}-list-{0}",b,c))[0]}}addTourns(a,b){if(System.runsOnLiveChessBaseCom()||-1!=document.URL.search(/localhost/i))return a.push({name:"tourns",
6039fn:function(){this.fnLoadLiveTourns(b);this.fnMaxSwiper(b)}.bind(this),fnLeave:function(){this.fnRestoreSwiper(b)}.bind(this)}),!0}createNotaSwipedDesk(a,b,c,d){d=this.createDiv(c,b);a.appendChild(d);a=[{name:"engplusbook",fn:function(){this.fnStartAnalysis(b)}.bind(this)},{name:"nota",fn:function(){this.stopAllEngines(b)}.bind(this)},{name:"list"}];this.isLive(b)&&a.push({name:"chat"});this.notaSwiper[b]=this.createSwiper(d,c,a,b);a=$(`#swipe-${c}-engplusbook-${b}`);a.addClass("swpEngBook");
6039a.append($(`<div class='swpEngBookBook' id='engBookBook-${b}'></div>`));
6040a.append($(`<div class='swpEngBookEng' id='engBookEng-${b}'></div>`));return{nota:$(String.f("#swipe-{1}-nota-{0}",b,c))[0],eng:$(`#engBookEng-${b}`)[0],book:$(`#engBookBook-${b}`)[0],list:$(String.f("#swipe-{1}-list-{0}",b,c))[0],chat:$(String.f("#swipe-{1}-chat-{0}",b,c))[0]}}createNotaAndEngSwipedDesk(a,b,c,d){d=this.createDiv(c,b);a.appendChild(d);a=[{name:"book",fn:function(){}.bind(this)},{name:"notaEng",fn:function(){}.bind(this)},{name:"list"}];this.isLive(b)&&a.push({name:"chat"});this.notaSwiper[b]=
6041this.createSwiper(d,c,a,b);a=$(`#swipe-${c}-book-${b}`);a.addClass("swpEngBook");a.append($(`<div class='swpEngOnlyBook' id='engBookBook-${b}'></div>`));a=$(`#swipe-${c}-notaEng-${b}`);a.addClass("swpNotaEng");a.append($(`<div class='swpNotaNest' id='notaEngNest-${b}'></div>`));a=$(`#notaEngNest-${b}`);a.addClass("swpNotaEngNest");a.append($(`<div class='swpNotaEngNota' id='notaEngNota-${b}'></div>`));a.append($(`<div class='swpNotaEngEng' id='notaEngEng-${b}'></div>`));return{nota:$(`#notaEngNota-${b}`)[0],
6042eng:$(`#notaEngEng-${b}`)[0],book:$(`#engBookBook-${b}`)[0],list:$(String.f("#swipe-{1}-list-{0}",b,c))[0],chat:$(String.f("#swipe-{1}-chat-{0}",b,c))[0]}}createVideoSwipedDesk(a,b,c,d){d=this.createDiv(c,b);a.appendChild(d);a=[{name:"engplusbook",fn:function(){this.fnStartAnalysis(b)}.bind(this)},{name:"videoplusnota",fn:function(){this.stopAllEngines(b)}.bind(this)},{name:"list"}];this.isLive(b)&&a.push({name:"chat"});this.notaSwiper[b]=this.createSwiper(d,c,a,b);a=$(`#swipe-${c}-engplusbook-${b}`);
6043a.addClass("swpEngBook");a.append($(`<div class='swpEngBookBook' id='engBookBook-${b}'></div>`));a.append($(`<div class='swpEngBookEng' id='engBookEng-${b}'></div>`));a=$(`#swipe-${c}-videoplusnota-${b}`);a.addClass("swpVideoNota");a.append($(`<div class='swpVideoNotaVideo' id='vidNotaVid-${b}'></div>`));a.append($(`<div class='swpVideoNotaNota' id='vidNotaNota-${b}'></div>`));return{eng:$(`#engBookEng-${b}`)[0],book:$(`#engBookBook-${b}`)[0],nota:$(`#vidNotaNota-${b}`)[0],video:$(`#vidNotaVid-${b}`)[0],
6044list:$(String.f("#swipe-{1}-list-{0}",b,c))[0],chat:$(String.f("#swipe-{1}-chat-{0}",b,c))[0]}}createBoardParent(a,b,c){b=this.createDiv(c,b);a.appendChild(b);return{buttons:b,board:b}}createBoardAndEng(a,b){var c=this.createDiv("south",b);a.appendChild(c);a=this.createDiv("boardAndEng",b);let d=this.createDiv("board-sw",b);a.appendChild(d);b=this.createDiv("eng-se",b);a.appendChild(b);c.appendChild(a);return{buttons:c,board:d,eng:b}}createPureNota(a,b,c){var d=this.createDiv("notaroot",b);a.appendChild(d);
6045c=this.createNotaDivs(d,b,c,!0);(new Timer(function(){let e=document.documentElement.scrollTop,f=$(a).position().top,g=$(a).height();this.resizePureNota(b);if(e<f||e>f+g)document.documentElement.scrollTop=e}.bind(this))).runOnce(500);return{nota:c}}isMobileLayout(){return this.isVerti||System.isMobile()}isHorizontalMobile(){return System.isMobile()&&!this.isVerti}isSwipedLayout(){return this.isMobileLayout()||this.layout==ReaderLayout.DESK_SWIPED}isDeskLayout(){return this.layout==ReaderLayout.DESK_SWIPED||
6046this.layout==ReaderLayout.DESK_SPLITTED}createDiagramElements(a,b){this.modules[b].diagramAnimations=this.parseDiagramAnimation(a);this.modules[b].posId=a.dataset.posid;var c=a.dataset.title;if(c){var d=this.createDiv("aboveDiag",b);a.appendChild(d);var e=this.createDiv("diagTitle",b);d.appendChild(e);$(e).text(c)}c=this.createDiv("diagarea",b);a.appendChild(c);e=this.needsDiagramAnimButtons(b);d=!1;if("0"!=a.dataset.buttons||e){d=!0;var f=this.createDiv("belowDiag",b);a.appendChild(f);e=this.createDiv("diagButtons",
6047b);f.appendChild(e);this.needsDiagramAnimButtons(b)?this.createDiagramAnimButtons(e,a,b):this.createDiagramReplayButtons(e,a,b)}if(e=a.dataset.legend){f||(f=this.createDiv("belowDiag",b),a.appendChild(f));var g=this.createDiv("diagText",b);f.appendChild(g);$(g).text(e)}(e=a.dataset.choice)?this.createMultipleChoice(a,f,e,b):(d&&(f=this.createDiv("diaNota",b),a.appendChild(f),$(f).height(0),$(f).hide()),!a.dataset.noengine&&d&&(b=this.createDiv("diaEng",b),a.appendChild(b),$(b).height(0),$(b).hide()));
6048return c}createMultipleChoice(a,b,c,d){b||(b=this.createDiv("belowDiag",d),a.appendChild(b));a=this.createDiv("diagChoices",d);b.appendChild(a);
6048(c=JSON.parse(c))&&c.entries?(this.modules[d].diagramChoice=c,this.createChoiceTable(a,c,d),d=this.createDiv("diaChoiceFeedback",d),b.appendChild(d)):$(a).text("Parsing Error")}createChoiceTable(a,b,c){var d="<table>"+String.f("<thead><tr><th colspan='2'>{0}</th></thead>",b.title);for(var e=0;e<b.entries.length;e++){var f=String.f("<input type='checkbox' id='checkChoice{0}-{1}'/>",
6049c,e);d+=String.f("<tr><td>{0}</td><td>{1}</td></tr>",f,b.entries[e].text)}a.appendChild($(d+"</table>")[0]);$(a).find("input[type='checkbox']").each((g,h)=>{$(h).on("click",k=>this.onChoiceClick(c,g))})}onChoiceClick(a,b){if(this.modules[a].diagramChoice){var c=this.modules[a].diagramChoice.attrs;c&&c.length||(c=this.modules[a].diagramChoice.entries[b].attrs);this.modules[a].diagramChoice.entries[b].correct?($("#diaChoiceFeedback"+a).css("color","green"),window.playchessUser&&!this.modules[a].diagramChoice.entries[b].done&&
6050glApp.resultPostBack.postSolved(window.playchessUser,this.modules[a].posId||"noid",1),this.modules[a].diagramChoice.entries[b].done=!0,this.modules[a].getKernel().Vp.addCheckMark()):($("#diaChoiceFeedback"+a).css("color","red"),this.modules[a].getKernel().boardWin.destroySideIcon());$("#diaChoiceFeedback"+a).text(this.modules[a].diagramChoice.entries[b].feedback);this.modules[a].getKernel().boardWin.addAttributes([]);this.modules[a].getKernel().Vp.showChoiceFeedback(c)}for(c=0;c<this.modules[a].diagramChoice.entries.length;c++)c!=
6051b&&$(String.f("#checkChoice{0}-{1}",a,c)).prop("checked",!1)}hasAutoStartDiaAnimation(a){return!1}needsDiagramAnimButtons(a){if(this.modules[a]&&(a=this.modules[a].diagramAnimations))return DiagramAnimationController.needsDiagramAnimButtons(a)}currPluginIsAnimatedDiagram(){return this.needsDiagramAnimButtons(this.nActivePlugin)}parseDiagramAnimation(a){if(a=a.dataset.anim)if(a=a.replace(/[^^\S ]+/g,""))try{var b=a.split(";");for(a=0;a<b.length;a++)b[a]=b[a].trim();return b}catch(c){LOG("Animation error: "+
6052c)}}_createNotation(a,b,c){var d=ObjUtil.clone(cbNotationDefaults);d.useMatBalance=!this.isMobileLayout()&&!this.isPureNota(c)&&!this.isDiagram(c);d.useHeader=this.layoutHasNotaHeader(c);d.useScrollIntoView=d.hasFolding=this.isPureNota(c);d.useDiagrams=!this.isDiagram(c)&&(this.isPureNota(c)||700<window.innerWidth||!System.runsOnLiveChessBaseCom()&&!System.runsOnChessBaseNews());d.diagramOptions={center:this.isPureNota(c)};d.smallHeader=this.isVideo(c);a=NotaElement.factory(a,null,d,c,this.modules[c].ticket);
6053a.setGame(b.game);glSettings.isRedBoard()&&($(".nota-game").css("cssText","background-image: linear-gradient( hsl( 0, 0%, 99% ), hsl( 0, 0%, 97% ) !important"),$(".cbgame-header").css("cssText","background-image: linear-gradient( hsl( 0, 0%, 99% ), hsl( 0, 0%, 97% ) !important"));return a}_createChat(a,b){return ChatElement.factory(a,b,this.fnSendChat.bind(this),{noInvite:!1})}_createGuessing(a,b){return GuessingElement.factory(a,b)}_createBook(a,b){return LiveBookElement.factory(a,b,function(){return this.modules[b].getKernel()}.bind(this),
6054this.modules[b].ticket)}onVideoLoaded(a){this.refreshSplitters(a)}_createVideo(a,b){return VideoElement.factory(a,b,function(){return this.modules[b].getKernel()}.bind(this),this.modules[b].ticket,this.onGameAction.bind(this),this.onVideoEnd.bind(this),this.modules[b].autoplay,this.modules[b].token,this.onVideoLoaded.bind(this))}_createOfflineVideo(a,b){return OfflineVideoElement.factory(a,b,function(){return this.modules[b].getKernel()}.bind(this),this.modules[b].ticket,this.onGameAction.bind(this),
6055this.onOfflineVideoEnd.bind(this))}_createRecorder(a,b){return RecorderElement.factory(a,b,function(){return this.modules[b].getKernel()}.bind(this),this.modules[b].ticket,this.onGameAction.bind(this),this.onOfflineVideoEnd.bind(this))}chatOut(a,b){this.chat[0]&&this.chat[0].out(a,b)}getNPluginByTicket(a){for(var b=0;b<this.modules.length;b++)if(this.modules[b].ticket==a)return b;return 0}kibitzChatOut(a,b,c,d,e,f){var g=0;d&&d.ticket&&(g=this.getNPluginByTicket(d.ticket));this.chat[g]&&this.chat[g].addKibitzChat(a,
6056b,c,d,e,f)}loginOkOut(a,b){this.chat[a]&&this.chat[a].addKibitzChat(this,null,b,null,!0,!0)}onChatLog(a,b){var c=this.getNPluginByTicket(a);if(this.chat[c])for(c=0;c<b.length;c++)this.kibitzChatOut(b[c].sender,b[c].hdr,b[c].txt,{idGame:b[c].gameId,ticket:a,mvInx:b[c].mvInx},b[c].autoChat,c==b.length-1)}fnSendChat(a,b){if(glApp.isLoggedIn()&&glApp.Vn.userName){if((a=this.modules[a].getKernel())&&a.idGame)return glApp.lobby.sendChat(glApp.Vn.userName,a.idGame,b),a}else this.chat[a].inviteLogin()}createDatabaseGrid(a,
6057b,c){System.isElectron()?"undefined"!==typeof electronBridge&&electronBridge.setReplayTouchBar(glApp,"Replay"):glApp.playerLobby.isConnected()||glApp.playerLobby.connect();var d=this;$("#listParent"+b).jsGrid({width:"100%",height:"100%",heading:!0,filtering:!1,editing:!1,inserting:!1,updateOnResize:!1,sorting:!0,autoload:!1,rowClick:function(e){c(a.getGame(e.item.No),b,e.item.No);d.fnSelectNota(b,500)},onDataLoaded:function(e){d.modules[b].gridItems=e.data;(new Timer(function(){d.getPlayerFlagsOfGameList(e.data,
6058b)})).runOnce(1500)},controller:{loadData:function(e){e=[];for(var f=1;f<=a.getGameCount();f++){var g=a.getHeaderJson(f);g={White:g.white,Black:g.black,EloW:g.elow?g.elow:"-",EloB:g.elob?g.elob:"-",Res:g.result,ECO:g.eco,Event:g.event,Year:g.date?g.date:" ",No:f,Rnd:function(h){var k="";h.round&&(k=h.round,h.subRound&&(k+="."+h.subRound));return k}(g),Len:g.plyCount,getWhitePlayerForPB(){let h=this.getPlayer(this.White);h.elo=parseInt(this.EloW)||0;h.black=!1;return h},getBlackPlayerForPB(){let h=
6059this.getPlayer(this.Black);h.elo=parseInt(this.EloB)||0;h.black=!0;return h},getPlayer(h){let k=h.split(",");return{firstName:k[1],lastName:k[0],id:this.id,str:h,valid:!!k[1]}}};e.push(g)}return e}}});this.gridCreated[b]=!0;
6059$("#listParent"+b).jsGrid("loadData");this.resizePlugin($(this.modules[b].pluginDiv),b);(new Timer(function(){this.refreshSplitters(b);this.onSplitterResize(b);(new Timer(function(){this.refreshSplitters(b)}.bind(this))).runOnce(this.isAnyVideo(b)?100:2500)}.bind(this))).runOnce(this.isAnyVideo(b)?
6060160:1E3);this.isRecorder(b)&&(new Timer(function(){this.recorder[0].videoManager.setUrl()}.bind(this))).runOnce(100);2<a.getGameCount()&&this.fnSelectList(b);if(!this.loadFromDBByUrlParam(a,b,c)){let e=this.loadedGameId[b]?this.loadedGameId[b]:1;c(a.getGame(e),b,e);return!1}return!0}refreshSplitters(a){0<$("#westNest"+a).length&&$("#westNest"+a).jqxSplitter("refresh");0<$("#eastNest"+a).length&&$("#eastNest"+a).jqxSplitter("refresh");0<$("#root"+a).length&&$("#root"+a).jqxSplitter("refresh");$("#notaEngNest-"+
6061a).length&&$("#notaEngNest-"+a).jqxSplitter("refresh")}createLiveListGrid(a,b,c){glApp.playerLobby.isConnected()||glApp.playerLobby.connect();$("#listParent"+b).removeClass("msgInListParent");var d=this.getGridFields(this.getGridWidth(b),!0),e=this;$("#listParent"+b).jsGrid({width:"100%",height:"100%",heading:!0,filtering:!1,editing:!1,inserting:!1,updateOnResize:!1,sorting:!0,loadMessage:"Retrieving games ...",loadShading:!0,autoload:!1,rowClick:function(g){e.onLiveRowClick(g,b,c)},controller:{loadData:function(g){g=
6062a();e.modules[b].fnGetList=a;var h=[];for(let l=0;l<g.games.length;l++){var k=e.gameItemToGridData(l,g.games[l]);h.push(k)}e.getPlayerFlagsOfGameList(g.games,b);return h}},onDataLoaded:function(g){let h=a(),k=g.data;if(k.length==h.games.length)for(let l=0;l<k.length;l++)h.games[l].item=k[l];e.modules[b].data=g.data},onSorted:function(g){e.refreshGridIcons(b);e.fillSelectedLiveGames(b);e.modules[b].data=g.grid.data},onRefreshed:function(g){e.isSelectingLiveGames&&e.showSelectedLiveGames(!0,b);e.refreshGridIcons(b);
6063e.modules[b].data=g.grid.data},fields:d});this.gridCreated[b]=!0;$("#listParent"+b).jsGrid("loadData");jsGrid.sortStrategies.number=ReaderPM.numberSorter;var f=a();f.games.length&&(new Timer(function(){let g=this.modules[b];for(var h=0;h<this.modules[b].kernel.length;h++){let k=this.modules[b].kernel[h].idGame;!k&&h<f.games.length&&(k=f.games[h].id);c(k,b,0==h,0,!0)}for(h=0;h<f.games.length;h++)g.getKernelOfIdGame(f.games[h].id)||(f.games[h].shouldRequestImmediatelyInLive()||32>=h)&&64>=h&&c(f.games[h].id,
6064b,!1,0,!0);this.loadByUrlParam(f.games,b,c);this.isMobileLayout()?(this.liveGameId[b]&&(c(this.liveGameId[b],b,!1),this.changeSelectedGameKernel(this.liveGameId[b])),this.hasEngBelowNota(b)&&(this.refreshSplitters(b),this.resizeNotaMobile(b))):(this.refreshSplitters(b),this.onSplitterResize(b))}.bind(this))).runOnce(500)}onLiveRowClick(a,b,c){var d=$("#listToolsBtn"+b).length&&$("#listToolsBtn"+b).is(":visible");if(a.event.ctrlKey&&!this.isSelectingLiveGames&&d)this.isSelectingLiveGames=!0,this.clearLiveGameSelection(b);
6065else if(a.event.shiftKey&&d&&(d=this.modules[b].data)){this.clickedRow||(this.clickedRow=0);this.clearLiveGameSelection(b);this.isSelectingLiveGames=!0;for(c=this.clickedRow;c<=a.itemIndex;c++)this.selectRow(b,c,d[c].id);this.showSelectedLiveGames(!0,b);this.clickedRow=a.itemIndex;return}this.isSelectingLiveGames?this.selectRow(b,a.itemIndex,a.item.id,!0):(c(a.item.id,b,!1),this.fnSelectNota(b));this.clickedRow=a.itemIndex}selectRow(a,b,c,d){this.selectedLiveGames[b]=this.selectedLiveGames[b]&&d?
60660:c;a=$("#listParent"+a).find(`tr:nth-of-type(${b+1})`);a.length&&(this.selectedLiveGames[b]?a.addClass("jsg-selectedRow"):a.removeClass("jsg-selectedRow"))}checkLiveSelectBox(a){$("#listToolsCheck"+a).jqxCheckBox({checked:!0})}showSelectedLiveGames(a,b){this.selectedLiveGames&&this.selectedLiveGames.forEach(function(c,d){c=$("#listParent"+b).find(`tr:nth-of-type(${d+1})`);this.selectedLiveGames[d]&&a?c.addClass("jsg-selectedRow"):c.removeClass("jsg-selectedRow")}.bind(this))}getPlayerFlagsOfGameList(a,
6067b){if(System.V3()||System.runsOnLocalHost()){let c=[];function d(e){let f=!1;
6067c.forEach(function(g){g.lastName==e.lastName&&g.firstName==e.firstName&&(f=!0)});f||c.push(e)}a.forEach(function(e){var f=e.getWhitePlayerForPB();f.valid&&d(f);e.reqPBW=f;f=e.getBlackPlayerForPB();f.valid&&d(f);e.reqPBB=f}.bind(this));this.cntPBData=0;this.pbGate||(this.pbGate=[]);this.pbGate[b]||(this.pbGate[b]=new V10);glApp.playerLobby&&glApp.playerLobby.startGetMultiFlags(c,function(e,f){this.onPBData(e,f,b)}.bind(this))}}onPBData(a,
6068b,c){(a=a.m_NewCBPlayer.m_HighData.m_aNation)&&this.setFlags(c,a,b);this.pbGate[c].exec(function(){$("#listParent"+c).jsGrid("refresh")}.bind(this),1E3)}gameItemToGridData(a,b){a=this.getResIcon(b.result);let c=this.getStatIcon(b.getLiveStatus());var d=b.white,e=b.black,f=b.eloWhite?b.eloWhite:"-",g=b.eloBlack?b.eloBlack:"-",h=b.eco?GameHeader.ECOtoString(b.eco):"",k=b.tourn,l=b.watchers,m="";b.round1&&(m=b.round1,b.round2&&(m+="."+b.round2));return{White:d,Black:e,EloW:f,EloB:g,FlgW:0,FlgB:0,Res:a,
6069ECO:h,Event:k,NKib:l,Rnd:m,Len:Math.ceil(b.moveLen/2),id:b.id,St:c}}copyItemsToList(a,b){}onNewGameItem(a,b){$("#listParent"+a).jsGrid("loadData")}createVideoGrid(a,b,c){this.modules[b].getKernel().Interactive=a.Interactive;var d=this;null==this.modules[b].pluginDiv.dataset.nogrid&&($("#listParent"+b).jsGrid({width:"100%",height:"100%",heading:!1,filtering:!1,editing:!1,inserting:!1,updateOnResize:!1,sorting:!0,autoload:!1,rowClick:function(g){this.loadFromVideos(a,g.itemIndex,b,c);d.fnSelectVideo(b)}.bind(this),
6070controller:{loadData:function(g){g=[];if(a&&a.Items)for(var h=0;h<a.Items.length;h++){var k=a.Items[h];k={Duration:d.getDurationString(k.DurationSeconds),Name:k.Name,Id:k.Id};g.push(k)}return g}},fields:this.getVideoGridFields(this.getGridWidth(b),!1)}),this.gridCreated[b]=!0,$("#listParent"+b).jsGrid("loadData"));this.resize(!0);(new Timer(function(){this.onSplitterResize(b);0<$("#westNest"+b).length&&$("#westNest"+b).jqxSplitter("refresh");0<$("#eastNest"+b).length&&$("#eastNest"+b).jqxSplitter("refresh");
60710<$("#root"+b).length&&$("#root"+b).jqxSplitter("refresh")}.bind(this))).runOnce(1E3);if("undefined"==typeof glApp.videoEl){var e=0;if(a&&a.Items)for(var f=0;f<a.Items.length;f++)if(a.Preferred===a.Items[f].Id){e=f;break}(new Timer(function(){this.show||this.loadFromVideos(a,e,b,c);this.isMobileLayout()&&(this.fnSelectVideo(b),(new Timer(function(){this.resize(null,!0)}.bind(this))).runOnce(1E3))}.bind(this))).runOnce(100)}else this.setCaptionText(a.Items[0].Name,b);return!0}createOfflineVideoGrid(a,
6072b,c){this.modules[b].getKernel().Interactive=!1;$("#boardHolder"+b).height();$($(ReaderPM.replayClass)[b]).height();this.modules[b].database=a;this.modules[b].selectedLecture=0;var d=this;$("#listParent"+b).jsGrid({width:"400px",height:"100%",heading:!1,filtering:!1,editing:!1,inserting:!1,updateOnResize:!1,sorting:!0,autoload:!1,rowClick:function(g){d.modules[b].selectedLecture=b;this.loadFromOfflineVideos(d.modules[b].database,g.itemIndex,b,c);d.fnSelectNota(b)}.bind(this),controller:{loadData:function(g){g=
6073[];for(var h=0;h<d.modules[b].database.results.length;h++){var k=d.modules[b].database.results[h];g.push({Name:k.Name,Id:k.Id,url:k.url,gameId:k.gameId})}return g}},noDataContent:"Currently no broadcast",fields:this.getOfflineVideoGridFields(this.getGridWidth(b),!1)});this.gridCreated[b]=!0;$("#listParent"+b).jsGrid("loadData");this.resize(!0);(new Timer(function(){this.onSplitterResize(b);0<$("#westNest"+b).length&&$("#westNest"+b).jqxSplitter("refresh");0<$("#eastNest"+b).length&&$("#eastNest"+
6074b).jqxSplitter("refresh");0<$("#root"+b).length&&$("#root"+b).jqxSplitter("refresh")}.bind(this))).runOnce(100);if("undefined"==typeof glApp.videoEl){for(var e=0,f=0;f<a.results.length;f++)if(a.Preferred===a.results[f].Id){e=f;break}(new Timer(function(){this.loadFromOfflineVideos(a,e,b,c)}.bind(this))).runOnce(100)}else 0<a.results.length&&this.setCaptionText(a.results[0].Name,b);return!0}getDateString(a){return"undefined"!==typeof a?a.toString():"?"}getDurationString(a){var b=Math.floor(a/3600),
6075c=Math.floor((a-3600*b)/60);a=a-3600*b-60*c;b="0"+b+":";if(0!=c||""!==b)c=10>c&&""!==b?"0"+c:String(c),b+=c+":";return b=""===b?a+"s":b+(10>a?"0"+a:String(a))}loadByUrlParam(a,b,c){var d=decodeURIComponent(StrUtil.trimQuotes(StrUtil.getURLParam("w"))),e=decodeURIComponent(StrUtil.trimQuotes(StrUtil.getURLParam("b"))),f=StrUtil.trimQuotes(StrUtil.getURLParam("r")),g=StrUtil.trimQuotes(StrUtil.getURLParam("r2")),h=StrUtil.trimQuotes(StrUtil.getURLParam("mv"));if(d.length&&e.length)for(var k=0;k<a.length;k++)if(0==
6076a[k].white.indexOf(d)&&0==a[k].black.indexOf(e)){var l=0==f.length||a[k].roun
6076d1==parseInt(f);if(l=l&&0==g.length||a[k].round2==parseInt(g))return c(a[k].id,b,!1,h),this.nActivePlugin=b,!0}}loadFromDBByUrlParam(a,b,c){var d=decodeURIComponent(StrUtil.trimQuotes(StrUtil.getURLParam("w"))),e=decodeURIComponent(StrUtil.trimQuotes(StrUtil.getURLParam("b"))),f=StrUtil.trimQuotes(StrUtil.getURLParam("r")),g=StrUtil.trimQuotes(StrUtil.getURLParam("r2")),h=StrUtil.trimQuotes(StrUtil.getURLParam("mv"));if(d.length&&
6077e.length)for(var k=0;k<a.getGameCount()&&100>k;k++){var l=a.getHeaderJson(k+1);if(0==l.white.indexOf(d)&&0==l.black.indexOf(e)){var m=0==f.length||l.round==parseInt(f);if(m=m&&0==g.length||l.subRound==parseInt(g))return a=a.getGame(k+1),c(a,b,k+1,!1,parseInt(h)),this.nActivePlugin=b,!0}}return!1}onLiveGameAction(a,b){if(a.GA){a=a.GA;var c=new DataBuffer;c.constructFromBase64(a);c.rewind();c=c.exportAsCompressedString();this.modules[b].getKernel().executeGameAction("GC",c);this.modules[b].boardArea&&
6078this.modules[b].boardArea.canvas&&this.modules[b].boardArea.canvas.requestRedraw()}else a.ASKBESTMOVE&&(a=a.ASKBESTMOVE,c=new DataBuffer,c.constructFromBase64(a),c.rewind(),c=c.exportAsCompressedString(),a=new DataBuffer,a.constructFromString(c,!0),a.rewind(),c=new Position,c.read(a),this.modules[b].getKernel().Vp.posAskBestmove=c,this.modules[b].getKernel().boardWin.addMessage("Please enter your move",!0))}mustExecute(a,b){return a>=b&&a<b+1}replayAllGameActions(a){var b=new Game;if(this.video&&
6079this.video.length&&this.video[a].gameactions)for(var c=0;c<this.video[a].gameactions.length;c++){var d=this.video[a].gameactions[c].aGA;d.fillExecutedMove();d._doExecute(b)}return b}onGameAction(a,b){if(this.video&&this.video.length&&this.video[a].gameactions)for(var c=0;c<this.video[a].gameactions.length;c++)if(this.mustExecute(this.video[a].gameactions[c].time,b)&&(this.modules[a].getKernel().executeGameAction2(this.video[a].gameactions[c].aGA),this.modules[a].boardArea&&this.modules[a].boardArea.canvas&&
6080this.modules[a].boardArea.canvas.requestRedraw(),60<=b-this.modules[a].lastSnippedViewed&&!this.offlinevideo[a])){var d=this.modules[a].getKernel().Vp.videoid;if(d){var e=Math.floor(b)/60;e=Math.floor(e);this.modules[a].endEventFired=!1;var f="",g="";glApp.isLoggedIn()&&glApp.Vn.userName&&(g=glApp.Vn.userName);g&&(f=encodeURIComponent(g));if(1<e){this.baseurl=glApp.config.getVideoPortalUris()[0];g=DOM.getCookie("videoSerial");var h=DOM.getCookie("videoShop");d=this.baseurl+"Replay/AddSnippetViewed?id="+
6081encodeURIComponent(d)+"&time="+e+"&user="+f+"&serial="+g+"&shop="+h;$.get(d,function(k){"undefined"===typeof this.video[a].loginOk&&k&&0!=k.localeCompare("Ok")&&(this.video[a].videoManager.pause(),0==k.localeCompare("Expert")?this.fnHint("You have to purchase this video in order to watch it",a):this.showAccountsFormVideo(a))}.bind(this)).fail(function(){alert("onsnippedviewed")}.bind(this))}}this.modules[a].lastSnippedViewed=b}if(this.gameactions){for(c=0;c<this.gameactions.length;c++)this.mustExecute(this.gameactions[c].time,
6082b)&&(this.modules[a].getKernel().executeGameAction(this.gameactions[c].type,this.gameactions[c].action),this.modules[a].boardArea&&this.modules[a].boardArea.canvas&&this.modules[a].boardArea.canvas.requestRedraw());System.isElectron()&&"undefined"!==typeof electronBridge&&this.offlinevideo&&this.offlinevideo[a]&&this.offlinevideo[a].videoManager&&(c=this.offlinevideo[a].videoManager.getDuration(),b=parseInt(100*b/c,10),electronBridge.updateSlider(glApp,b))}}showAccountsForm(a){(new AccountForm).createLoginForm("Please Login with premium account",
6083function(b){glApp.Vn.userName=b.idUser;glApp.Vn.password=b.idPassword;glApp.Vn.loginMode=LoginMode.NORMAL;(new AccountsManager(glApp.shortAppName)).pwLogin(glApp.Vn.userName,glApp.Vn.password,this.receiveTokenHandler.bind(this),a)}.bind(this),function(b){}.bind(this),"")}showAccountsFormVideo(a){0<this.video.length&&this.video[a].videoManager.pause();(new AccountForm).createLoginForm("Login with premium account (v1)",function(b){glApp.Vn.userName=b.idUser;glApp.Vn.password=b.idPassword;glApp.Vn.loginMode=
6084LoginMode.NORMAL;(new AccountsManager(glApp.shortAppName)).pwLogin(glApp.Vn.userName,glApp.Vn.password,this.receiveTokenHandler.bind(this),a)}.bind(this),function(b){this.video&&0<this.video.length&&this.video[a].videoManager.disable()}.bind(this),"")}
6084receiveTokenHandler(a,b){"error"!=a&&"OK"==a.Result&&3<=a.HighestSubscr?(glApp.setLoggedIn(!0),this.video[b]&&(this.video[b].videoManager.play(),this.video[b].loginOk=!0)):this.video[b]&&this.video[b].videoManager.disable()}onOfflineVideoEnd(a,b){this.modules[a].endEventFired=
6085!0;System.isElectron()&&"undefined"!==typeof electronBridge&&electronBridge.setVideoEndTouchBar(glApp,"Video");if(this.modules[a].cmsiManager){var c=b,d=b.lastIndexOf("/");-1!=d&&(c=b.substr(d+1));b=this.modules[a].cmsiManager.extractStateFromFileName(c);if(3==b)this.fnHint("please try again",a),(a=this.modules[a].getKernel())&&a.Vp.restoreMoveEnterPosition();else if(0==b)System.isElectron()&&"undefined"!==typeof electronBridge&&electronBridge.setQuestionTouchBar(glApp,"Enter your Move");else if(2==
6086b){c=this.modules[a].cmsiManager.getNextQuestion(c);b=-1;if(c.length)for(d=0;d<this.modules[a].offlinevideoDatabase.results.length;d++)-1!=this.modules[a].offlinevideoDatabase.results[d].Id.indexOf(c)&&(b=d);-1!=b&&b<this.modules[a].offlinevideoDatabase.results.length&&this.loadNewOfflineVideo(a,this.modules[a].offlinevideoDatabase.results[b].Id)}}}onVideoEnd(a,b){var c=this.modules[a].getKernel();c.PositionMode||(this.modules[a].getKernel().Vp.videoid=b,this.modules[a].endEventFired=!0,this.baseurl=
6087glApp.config.getVideoPortalUris()[0],b=this.baseurl+"Replay/GetNextIdAtEnd?id="+encodeURIComponent(b)+"&fen="+encodeURIComponent(c.game.getCurPos().toFEN()),$.get(b,function(d){if(d){var e=d.ID,f=d.MSG;2<f.length?this.fnHint(f,a):"3"==d.STATE?(this.fnHint("please try again",a),c&&c.Vp.restoreMoveEnterPosition()):2<e.length&&(this.video[a].videoManager.restart(),this.loadNewVideo(a,e,!0))}}.bind(this)).fail(function(){}.bind(this)))}loadNewVideo(a,b,c){for(var d=0;d<this.modules[a].videoDatabase.Items.length;d++)this.modules[a].videoDatabase.Items[d].Id===
6088b&&this.setCaptionText(this.modules[a].videoDatabase.Items[d].Name,a);this.loadVideo(b,a,this.loadVideoGame.bind(this),c)}loadNewOfflineVideo(a,b){System.isElectron()&&"undefined"!==typeof electronBridge&&electronBridge.setMediaTouchBar(glApp,"Video");var c=this.modules[a].cmsiManager.getFile(b);if(c)this.loadOfflineVideo(this.modules[a].baseDir+c,a,this.loadOfflineVideoGame.bind(this));else{for(c=0;c<this.modules[a].offlinevideoDatabase.results.length;c++)this.modules[a].offlinevideoDatabase.results[c].Id.indexOf===
6089b&&this.setCaptionText(this.modules[a].offlinevideoDatabase.results[c].Name,a);this.loadOfflineVideo(b,a,this.loadOfflineVideoGame.bind(this))}}loadFromOfflineVideos(a,b,c,d){if(0<a.results.length){var e=a.results[b].url;this.setCaptionText(a.results[b].Name,c);this.loadOfflineVideo(e,c,d);if(c=this.modules[c].getKernel())c.idGame=a.results[b].url}}loadFromVideos(a,b,c,d){if(a.Items.length){var e=a.Items[b].Id;this.modules[c].getKernel().Vp.videoid=e;this.setCaptionText(a.Items[b].Name,c);this.loadVideo(e,
6090c,d,!1)}}onGaAvailable(a){this.gameactions=[];if(a)for(var b=this.readerHelper.getHardwareGuid(),c=0;c<a.length;c++){var d=a[c],e=new ScriptCommand;e.time=this.readerHelper.descrambleTime(d.Time);e.type=d.GameActionType;e.action=this.readerHelper.descrambleAction(d.C,e.time,b);0<e.action.length&&this.gameactions.push(e)}else this.modules[0].offlineVideo.videoManager.disable(),this.autostartVideo=!0,this.readerHelper.onActivatedVideoDownload=this.onActivatedVideoDownload.bind(this),this.readerHelper.trySilentActivation(this.onSilentActivation.bind(this))}onSilentActivation(a){this.readerHelper.showActivateDialog(this.onActivatedVideoDownload.bind(this))}onActivatedVideoDownload(a){this.autostartVideo&&
6091this.modules&&this.modules[0]&&this.modules[0].getKernel()&&this.modules[0].getKernel().Vp.videoid&&-1!==this.modules[0].getKernel().Vp.videoid.search(a)&&(this.autostartVideo=!1,(new Timer(function(){this.loadOfflineVideo(this.modules[0].getKernel().Vp.videoid,0,this.loadOfflineVideoGame.bind(this));this.readerHelper.removeProgress()}.bind(this))).runOnce(3E3))}loadOfflineVideo(a,b,c){if((this.modules[b].getKernel().Vp.videoid=a)&&this.offlinevideo[b]&&(this.offlinevideo[b].videoManager.setUrl(a),
60920<$("#eastNest"+b).length&&$("#eastNest"+b).jqxSplitter("refresh"),this.setVideoSize(b),c=a.replace(".mp4",".txt").replace(".mp3",".txt"),this.checkGAs(c),this.modules[b].cmsiManager)){for(c=0;c<a.length;c++);this.suppressNotationForCMSI(b)}}loadVideo(a,b,c,d){this.modules[b].lastSnippedViewed=0;this.modules[b].getKernel().Vp.videoid=a;(this.video[b].videoManager.currentvideoid=a)&&this.video[b]&&this.video[b].videoManager.loadVideoFromId(a,d);this.setLike(b);d="";glApp.isLoggedIn()&&glApp.Vn.userName&&
6093(d=glApp.Vn.userName);d&&=encodeURIComponent(d);this.baseurl=glApp.config.getVideoPortalUris()[0];$.get(this.baseurl+"Replay/GetGameActions?id="+a+"&user="+d,function(e){e&&c(e,b)}.bind(this)).fail(function(){this.resizePlugin($(this.modules[b].pluginDiv),b)}.bind(this))}static numberSorter(a,b){"number"!==typeof a&&(a=0);"number"!==typeof b&&(b=0);
6093return b-a}getResIcon(a){switch(a){case 2:return"win";case 1:return"draw";case 0:return"loss"}}getStatIcon(a){if(a&64)return"mate";if(a&4)return"blunder";
6094if(a&512)return"wAttacks";if(a&1024)return"bAttacks";if(a&16)return"tactics";if(a&1)return"fire";if(a&2048)return"wKnights";if(a&4096)return"bKnights";if(a&128)return"wActivity";if(a&256)return"bActivity";if(a&2)return"endgame"}getSymAnnoIcon(a){switch(a){case AnnoEvalType.EQUAL:return"equal";case AnnoEvalType.BLACK_SLIGHTLY_BETTER:return"blackslightly";case AnnoEvalType.BLACK_BETTER:return"blackbetter";case AnnoEvalType.BLACK_WINS:return"blackwins";case AnnoEvalType.WHITE_WINS:return"whitewins";
6095case AnnoEvalType.WHITE_BETTER:return"whitebetter";case AnnoEvalType.WHITE_SLIGHTLY_BETTER:return"whiteslightly";case AnnoMarkType.GOOD:case AnnoMarkType.VERY_GOOD:return"exclam"}}getEvalIconByEv(a){switch(a){case AnnoEvalType.EQUAL:return"equal";case AnnoEvalType.BLACK_SLIGHTLY_BETTER:return"blackslightly";case AnnoEvalType.BLACK_BETTER:return"blackbetter";case AnnoEvalType.BLACK_WINS:return"blackwins";case AnnoEvalType.WHITE_WINS:return"whitewins";case AnnoEvalType.WHITE_BETTER:return"whitebetter";
6096case AnnoEvalType.WHITE_SLIGHTLY_BETTER:return"whiteslightly"}}isReplay(a){return this.modules[a]&&this.modules[a].mode==ReaderMode.REPLAY}isLive(a){return this.modules[a]&&this.modules[a].mode==ReaderMode.LIVE}isDiagram(a){return this.modules[a].mode==ReaderMode.DIAGRAM}isTable(a){return this.modules[a].mode==ReaderMode.TABLE}isPairing(a){return this.modules[a].mode==ReaderMode.PAIRING}isPureNota(a){return this.modules[a].mode==ReaderMode.NOTA}isAnyVideo(a){return this.isVideo(a)||this.isOfflineVideo(a)||
6097this.isRecorder(a)}isVideo(a){return this.modules[a]&&this.modules[a].mode==ReaderMode.VIDEO}isOfflineVideo(a){return this.modules[a]&&this.modules[a].mode==ReaderMode.OFFLINEVIDEO}isRecorder(a){return this.modules[a]&&this.modules[a].mode==ReaderMode.RECORDER}hasChat(a){return this.layout==ReaderLayout.DESK_SWIPED?!0:this.isVerti||System.isMobile()&&!System.isAtLeastTablet()||700>window.innerHeight||1340>window.innerWidth||System.runsInIFrame()?!1:this.modules[a].mode==ReaderMode.LIVE}hasBook(a){if(0<=
6098a&&this.isAnyVideo(a)||!this.modules[a]||0<=a&&this.modules[a].noBook||System.runsInIFrame())return!1;System.V3();return!System.isMobile()||800<window.innerHeight&&300<window.innerWidth}hasCaptionBar(a){let b=$(this.modules[a].pluginDiv).attr("data-caption");if("false"==b)return!1;if(b||this.isMobileLayout())return!0;if(this.isOfflineVideo(a))return!1;System.runsOnLocalHost()&&!0;return System.runsOnVideosChessBaseCom()&&400>window.innerHeight?!1:550<window.innerHeight&&!System.runsOnLiveChessBaseCom()}getCaptionHeight(a){return $("#cbcaptionDesk"+
6099a).outerHeight()}getBottomHeight(a){return 0}setCaptionText(a,b){$("#cbcaption"+b).text(a)}setSingleGameCaption(a,b){let c=$("#cbcaption"+b).width(),d="";300<c&&(d=500<c?900<c?a.hdr.toString():a.hdr.getStrPlayers(650<c,99):a.hdr.getStrPlayers(!1,1));this.setCaptionText(d,b)}usesOnlineDB(){return this.hasBook(this.nActivePlugin)}static resultSortMap={win:18,draw:19,loss:20,whitewins:1,whitebetter:2,whiteslightly:3,equal:4,blackslightly:5,blackbetter:6,blackwins:7};static statSortMap={mate:1,blunder:2,
6100wAttacks:5,bAttacks:6,tactics:8,fire:10,wKnights:12,bKnights:13,wActivity:15,bActivity:16,endgame:18};getGridFields(a,b){var c=function(g,h){var k=0,l=0,m=0,n=0,r=/([0-9]*)\.?([0-9]*)/i;"number"===typeof g?k=g:(g=g.match(r),g[1]&&(k=parseInt(g[1])),g[2]&&(m=parseInt(g[2])));"number"===typeof h?l=h:(h=h.match(r),h[1]&&(l=parseInt(h[1])),h[2]&&(n=parseInt(h[2])));return 100*l+n-100*k-m},d=function(g,h){return(ReaderPM.resultSortMap[g]||9)-(ReaderPM.resultSortMap[h]||9)},e=function(g,h){return(ReaderPM.statSortMap[g]||
610199)-(ReaderPM.statSortMap[h]||99)},f=[];420>a?f=[{name:"White",type:"text",width:Math.floor(.25*a)},{name:"EloW",type:"text",width:Math.floor(.11*a)},{name:"Black",type:"text",width:Math.floor(.25*a)},{name:"EloB",type:"text",width:Math.floor(.11*a)},{name:"Res",type:"text",width:Math.floor(.1*a)}]:550>a?(f=[{name:"White",type:"text",width:Math.floor(.22*a)},{name:"EloW",type:"number",width:Math.floor(.08*a)},{name:"Black",type:"text",width:Math.floor(.21*a)},{name:"EloB",type:"number",width:Math.floor(.08*
6102a)},{name:"Res",type:"text",width:Math.floor(.09*a)}],b||f.push({name:"ECO",type:"text",width:Math.floor(.06*a)})):(f=660<a&&!System.isElectron()&&(System.V3()||System.runsOnLocalHost())?[{name:"White",type:"text",width:Math.floor(.1*
6102a)},{name:"EloW",type:"number",width:Math.floor(.05*a)},{name:"FlgW",type:"flgw",width:Math.floor(.03*a)},{name:"Black",type:"text",width:Math.floor(.1*a)},{name:"EloB",type:"number",width:Math.floor(.05*a)},{name:"FlgB",type:"flgb",width:Math.floor(.03*a)},{name:"Res",
6103type:"text",width:Math.floor(.032*a)}]:[{name:"White",type:"text",width:Math.floor(.1*a)},{name:"EloW",type:"number",width:Math.floor(.05*a)},{name:"Black",type:"text",width:Math.floor(.1*a)},{name:"EloB",type:"number",width:Math.floor(.05*a)},{name:"Res",type:"text",width:Math.floor(.04*a)}],b||(f.push({name:"Year",type:"number",width:Math.floor(.05*a)}),f.push({name:"ECO",type:"text",width:Math.floor(.045*a)})),f.push({name:"Event",type:"text",width:Math.floor(.12*a)}));360<a&&((420<a||!b&&400<
6104a)&&f.push({name:"Rnd",type:"number",width:Math.floor(.045*a),sorter:c}),600<a&&f.push({name:"Len",type:"number",css:"jsg-len",width:Math.floor(.04*a)}));b&&250<a&&(f=[{name:"St",type:"staticon",width:Math.min(30,Math.floor(.07*a)),sorter:e}].concat(f));b&&f.push({name:"id",type:"number",width:0*a,css:"jsg-invisible-id"});f.forEach(function(g){"White"==g.name||"Black"==g.name?g.css="jsg-player":"EloW"==g.name||"EloB"==g.name?(g.css="jsg-elo",g.align="center"):"FlgW"==g.name||"FlgB"==g.name?(g.css=
6105"jsg-flag",g.align="center",g.type=g.name.toLowerCase()):"ECO"==g.name?(g.css="jsg-eco",g.align="center"):"Res"==g.name&&(g.css="jsg-result",g.align="center",b&&(g.type="resicon",g.css="jsg-icon"),g.sorter=d);"Event"==g.name&&(g.css="jsg-event");"Rnd"==g.name&&(g.css="jsg-round")});return f}getVideoGridFields(a,b){b=[];b=[{name:"Duration",type:"text",width:Math.floor(.2*a)},{name:"Name",type:"text",width:Math.floor(.6*a)}];b.forEach(function(c){"Name"==c.name?c.css="jsg-name":"Duration"==c.name?c.css=
6106"jsg-duration":"Created"==c.name&&(c.css="jsg-created")});return b}getOfflineVideoGridFields(a,b){b=[];b=[{name:"Name",type:"text",width:Math.floor(.6*a)}];b.forEach(function(c){"Name"==c.name&&(c.css="jsg-name")});return b}resizePlugin(a,b){!this.inDestroy&&this.modules[b]&&(this.isDiagram(b)?this.resizeDiagram(a,b):this.isTable(b)?this.resizeTable(a,b):this.isPairing(b)?this.resizePairings(a,b):this.isPureNota(b)?this.resizePureNota(b):this.isMobileLayout()?this.resizeReplayMobile(a,b):this.resizeReplayDesktop(a,
6107b),this.isLive(b)&&this.refreshGridIcons(b))}resizeReplayDesktop(a,b){switch(this.layout){default:case ReaderLayout.DESK_SPLITTED:this.resizeReplaySplitted(a,b);break;case ReaderLayout.DESK_SWIPED:this.resizeReplaySwiped(a,b)}}resizeReplaySplitted(a,b){if(a&&this.modules&&this.modules[b]){var c=this.resizeDesktopCommon(b),d=this.getButtonConfig().getLineHBoard(),e=a.width(),f=a.height();a=this.getEngineH(b,$("#westSouth"+b).height(),c.nGames);var g=c.hasDB?.72*f-d-a:f-d-a;400>g&&(g=Math.max(80,Math.min(400,
6108f-5)));g>.5*e&&(g=Math.min(f-5,.5*e),c.hasDB||(a=f-d-g));e-=e-g;$("#east"+b)[0]&&($("#east"+b)[0].style.height="100%",$("#west"+b)[0].style.height="100%");this.resizeNotaHori(b);this.chat[b]&&this.chat[b].resize();this.book[b]&&this.book[b].resize();$("#boardHolder"+b)[0].style.width="100%";$("#boardHolder"+b)[0].style.height="calc( 100% - "+d+"px )";$("#belowBoard"+b)[0].style.width="100%";$("#belowBoard"+b)[0].style.height=d+2+"px";$("#buttons"+b)[0].style.width="100%";$("#buttons"+b)[0].style.height=
6109"100%";d=$("#boardHolder"+b).width();f=$("#boardHolder"+b).height();this.modules[b].boardArea&&!this.modules[b].boardArea.canvas&&(this.isLive(b)?this.createMultiBoard(b):(g={topDist:0,bottomDist:0,marginDistDivisor:42,bigCoords:!1,shiftXPercent:-1.7,minWForCoordinates:this.coordinates?280:9999,boardShadow:!0},this.modules[b].boardArea.createCanvas(this.modules[b].getKernel(),g),this.modules[b].getKernel().boardWin.onReadyHandlers.add(this.modules[b].onBoardReady.bind(this.modules[b]))));this.adaptMaxKernels(b,
6110d,f);this.launchResizeBoard(b,d,f,700);this.resizeEngineAndListHori(b,c.hasDB,a,c.nGames,e);this.recreateBoardButtons(b);this.setButtonImages("n",this.notaBtns,this.getButtonConfig().btnHNota,this.getButtonConfig().getCssNota(),b,"Reader");this.setNotaSize(b);this.setVideoSize(b);["#eastUpDownNest","#root","#westNest"].forEach(function(h){$(h+b).jqxSplitter("refresh")})}}resizeReplaySwiped(a,b){a&&this.modules&&this.modules[b]&&(this.resizeDesktopCommon(b),$("#east"+b)[0].style.height="100%",$("#west"+
6111b)[0].style.height="100%",this.resizeNotaMobile(b),this.resizeBoardMobile(b),this.resizeEngineMobile(b),this.resizeVideoMobile(b),this.resizeListSwiped(b),this.book[b]&&this.book[b].resize(),this.recreateBoardButtons(b),a=this.getButtonConfig(),this.setButtonImages("n",this.notaBtns,a.btnHNota,a.getCssNota(),b,"Reader"),["#root"].forEach(function(c){$(c+b).jqxSplitter("refresh")}))}
6111resizeDesktopCommon(a){var b=this.getCaptionHeight(a);b?(b+=this.getBottomHeight(a),$("#rootParent"+a).height("calc( 100% - "+
6112b+"px )")):$("#rootParent"+a).height("100%");b=this.getGameCount(a);var c=1<b;this.isRecorder(a)&&(c=!0);return{hasDB:c,nGames:b}}resizePureNota(a){this.modules[a].pgnDatabase&&this.loadGame(this.modules[a].pgnDatabase.getGame(1),a,1,!0);let b=$("#notaNest"+a).height(),c=$("#notaNest"+a).width();this.getButtonConfig();var d=$("#belowNota"+a).height()||0;d=b-d;this.modules[a].nota&&(this.modules[a].nota.setSize(c,d),this.nActivePlugin===a&&this.modules[a].nota.scrollCurElemIntoView(),this.modules[a].getKernel().game.getHeader().isValid()||
6113this.modules[a].nota.hideHeader());this.floatBoard[a]&&this.floatBoard[a].checkPosition({x:0,w:c});this.setNotaFontSize(15,c,b)}setNotaFontSize(a,b,c){let d=a;400>b&&500>c&&(d=a-1);250>c&&(d=150>c?a-3:a-2);this.biggerFonts&&(d+=this.biggerFonts-a+2);$(".nota-container").css("font-size",`${d}px`)}getBoardTopOffset(){return 900>window.innerHeight?0:10}setNotaSize(a){var b=CBQ("#notaparent"+a).single();if(b){var c=b.offsetWidth;b=b.offsetHeight;this.modules[a]&&this.modules[a].nota&&this.modules[a].nota.setSize(c,
6114b)}}setVideoSize(a){if(this.isOfflineVideo(a)){if(this.offlinevideo){var b=CBQ("#videoparent"+a).single();if(b){var c=b.offsetWidth;b=b.offsetHeight;this.offlinevideo[a].resize(c,b)}}}else this.isVideo(a)?this.video&&(b=CBQ("#videoparent"+a).single())&&(c=b.offsetWidth,b=b.offsetHeight,this.video[a].resize(c,b)):this.isRecorder(a)&&this.recorder&&(b=CBQ("#videoparent"+a).single())&&(c=b.offsetWidth,b=b.offsetHeight,this.recorder[a].resize(c,b))}resizeEngine(a){let b=this.modules[a].enginePanel;b&&
6115this.modules[a].engineOpen&&b.resize&&b.resize()}resizeReplayMobile(a,b){if(a&&this.modules&&this.modules[b]){System.runsOnVideosChessBaseCom()?$(a).css("height","80vh"):System.runsOnLiveChessBaseCom()||System.runsOnLocalHost()?$(a).css("height","100%"):System.runsOnChessBaseNews()&&$(a).css("height",.92*window.innerHeight+"px");if(this.isVerti){this.availH[b]=this.getNorthSouthAvailH(a,b);let c=1;switch(this.layout){case ReaderLayout.VIDEO:c=.6;break;case ReaderLayout.MULTI_BOARD_2:c=.51;break;case ReaderLayout.MULTI_BOARD_4:c=
61161.05;break;case ReaderLayout.USER_LAYOUT:switch(this.nUserNota){default:case NotaSize.SMALL:switch(this.nUserBoards){default:case 2:case 7:case 8:c=2.15;break;case 6:case 5:c=1.55;break;case 10:c=2.52}break;case NotaSize.BIG:switch(this.nUserBoards){default:c=1;break;case 9:c=1.1;break;case 12:c=1.25}}break;case ReaderLayout.BIG_NOTA:c=.6}a=this.getPanelHForBoard(a,b,c);$("#south"+b).css("height",a-1+"px");$("#north"+b).css("height",this.availH[b]-a-1+"px")}else this.setSizeMobEastWest(a,b);this.resizeNotaMobile(b);
6117this.resizeBoardMobile(b);this.resizeEngineMobile(b);this.resizeVideoMobile(b);this.resizeListMobile(b);this.recreateBoardButtons(b);a=this.getButtonConfig();this.setButtonImages("n",this.notaBtns,a.btnHNota,a.getCssNota(),b,"Reader")}}setSizeMobEastWest(a,b){var c=$(a).width();a=Math.floor(this.getPanelWForBoard(a,.9)-1);c=Math.round(c-a-1);$("#mobEast"+b).css("width",a+"px");$("#mobWest"+b).css("width",c+"px")}getNorthSouthAvailH(a,b){b=$("#mobCaption"+b).height();let c=0;this.hasButtonsInBoardDiv()||
6118(c=this.getButtonConfig().getLineHBoard());return $(a).height()-b-c}getPanelHForBoard(a,b,c){b=this.getNorthSouthAvailH(a,b);a=$(a).width();let d=this.getButtonConfig().getLineHBoard();this.hasButtonsInBoardDiv()||(d=0);c=a*c+d;90>b-c&&(c=b-90);150>c&&(c=150);650<c&&(c=650);return Math.round(c)}getPanelWForBoard(a,b){let c=$(a).width();a=$(a).height();let d=this.getButtonConfig().getLineHBoard();this.hasButtonsInBoardDiv()||(d=0);b*=a-d;100>c-b&&(b=c-100);150>b&&(b=150);return b}ribbonButtonsVisible(a){return 1<
6119this.getGameCount(a)||this.isOfflineVideo(a)||this.isRecorder(a)}showRibbonButtons(a,b){b?$("#tabNavButtons"+a)[0].style.height="32px":$("#tabNavButtons"+a)[0].style.height="0px"}showHidePrevNext(a,b){var c=$("#buttons"+a).width();(this.isLive(a)||b)&&(600<c||this.isMobileLayout())?($("#b-btnLoadNext-"+a).show(),$("#b-btnLoadPrev-"+a).show(),$("#n-btnLoadNext-"+a).show(),$("#n-btnLoadPrev-"+a).show()):($("#b-btnLoadNext-"+a).hide(),$("#b-btnLoadPrev-"+a).hide(),$("#n-btnLoadNext-"+a).hide(),$("#n-btnLoadPrev-"+
6120a).hide())}showHideGamesTab(a,b){b||$("#t-btnSelList-"+a).hide()}resizeBoard(a,b,c){this.boardTimer[a]&&this.boardTimer[a].stop();this.modules[a].boardArea.setSize(b,c);this.modules[a].multiBoard&&(this.adaptMaxKernels(a,b,c),this.modules[a].multiBoard.resize(b,c)
6120)}adaptMaxKernels(a,b,c){if(this.modules[a].multiBoard&&!(100>c)){var d=1,e=b/c;160<c&&(this.boardsSameSize?d=1.2>e&&600<b&&600<c?800<b&&800<c?9:4:1.2<e||800<c?2<e?2.6<e?3.1<e?12:10:8:1.5<e?6:4:2:1.25<e&&(d=1.9<e||800<c?2.3<e?3.3<e||600<
6121c?9:7:2.3<e&&450<c||800<c?7:5:480<c&&(1.8<e||900<c)?5:3));this.isMobileLayout()?this.layout==ReaderLayout.MULTI_BOARD_2?d=2:this.layout==ReaderLayout.MULTI_BOARD_4?d=4:this.layout==ReaderLayout.USER_LAYOUT?d=this.nUserBoards:this.layout==ReaderLayout.HORIZONTAL&&(d=1):0<this.nUserBoardsDesk&&(d=Math.min(this.nUserBoardsDesk,24));b=this.modules[a].changeNKernels(d,this);if(d>b)for(c=0,e=b;c<d-b&&e<this.modules[a].list.length;e++){var f=this.modules[a].list[e].id;this.hasKernelOfId(a,f)||(this.fnLoadLiveGame(f,
6122a),c++)}}}hasKernelOfId(a,b){for(var c=0;c<this.modules[a].kernel.length;c++)if(this.modules[a].kernel[c].idGame==b)return!0;return!1}createMultiBoard(a){let b=this;var c=this.modules[a].boardArea.createCanvas({createControl:function(d,e,f){var g=this.getMultiBoardOptions();g.suppressCalcGeometry=!0;d=new MultiBoard(d,e,f,g,a);d.onClickBoard=this.onClickBoard.bind(this);d.onDblClick=this.onDblClickBoard.bind(this);d.onCloseBoard=this.onBoardCloseBtn.bind(this);return d}.bind(this),onControlReady:function(){b.initAudio()}},
6123this.getMultiBoardOptions());this.modules[a].boardArea.setVisible(!0);this.modules[a].kernel=[];this.modules[a].multiBoard=c.control}getMultiBoardOptions(){return{topDist:this.isMobileLayout()?2:Math.min(4,Math.max(2,window.innerHeight/60))/window.devicePixelRatio,bottomDist:this.isMobileLayout()?1:Math.min(6,Math.max(2,window.innerHeight/60)/window.devicePixelRatio),marginDistDivisor:60,shiftXPercent:-1.7,minWForCoordinates:this.coordinates?280:9999,splitLayout:!this.isMobileLayout()&&!this.boardsSameSize,
6124suppressCalcGeometry:!0,hasCloseBtn:!this.isMobileLayout()}}createBoardWin(a,b,c){a=new ReplayHandlerBoardControl(a,100,100,"FirstB",b,function(){return this.modules[c].getKernel().Vp}.bind(this));a.animSteps={forMove:2,forPosition:2};System.isMobile()&&(a.animSteps={forMove:.6,forPosition:.5});a.singleClickDisabled=!0;a.allowInput=!0;return a}onClickBoard(a,b){this.nActivePlugin=this.getPluginOfIdGame(a);0<=this.nActivePlugin?this.stopAutoplay(this.nActivePlugin):this.nActivePlugin=0;this.changeSelectedGameKernel(a);
6125this.fnSelectNota(this.nActivePlugin)}initAudio(){glApp.chessAudio||System.isElectron()||glApp.AzurePlayerLoaded||glApp.WowzaPlayerLoaded||glApp.NanoPlayerLoaded||glApp.OfflinePlayerLoaded||(glApp.chessAudio=new ChessAudio(glApp.config.getExternalCommonPath()+"Media/Sounds/"),(new Timer(function(){glApp.chessAudio.loadAll()})).runOnce(5E3),glApp.chessAudio.enable(this.sound))}getPluginOfIdGame(a){if(1==this.pluginCnt)return 0;for(let b=0;b<this.modules.length;b++)if(this.isLive(b))for(let c=0;c<this.modules[b].kernel.length;c++)if(this.modules[b].kernel[c].idGame==
6126a)return b;return-1}onDblClickBoard(a,b){1==this.pluginCnt&&(this.nActivePlugin=0);0<=this.nActivePlugin&&this.trySwapWithBigBoard(a,this.nActivePlugin,!0);b.preventDefault()}onBoardCloseBtn(a,b){let c=this.modules[b];if(this.selectedLiveGames){let d=!1;for(let e=0;e<this.selectedLiveGames.length;e++)this.selectedLiveGames[e]==a&&(this.selectedLiveGames[e]=0,d=!0);d&&this.showSelectedLiveGames(!0,b)}glApp.lobby.setSessionToBackground(c.ticket,a);c.removeKernelOfIdGame(a);c.kernel.length&&this.changeSelectedGameKernel(c.kernel[0].idGame)}changeSelectedGameKernel(a){if(0>
6127this.nActivePlugin)if(1===this.pluginCnt)this.nActivePlugin=0;else return;var b=this.modules[this.nActivePlugin];try{b.getKernel()&&b.getKernel().releaseCommandHandlers();b.selectKernelByIdGame(a);var c=b.getKernel();c.linkCommandHandlers();var d=c.game,e=this.modules[this.nActivePlugin].nota;d&&e&&(c.Vp.saveToCloud(),e.setGame(d),c.forceTBUpdate=!0,c.boardWin&&(c.nextCurPosNoAnim=!1),d.fireOnCurPosChanged(),d.fireOnNavigate());b.multiBoard&&b.multiBoard.markBoardByGameId&&b.multiBoard.markBoardByGameId(a);
6128c.boardWin&&(c.boardWin.markLastMove(!1,!0),glApp.aTBLobby.isConnected()&&(glApp.aTBLobby.requestWithTicket(a,c.getCurPos(),function(f,g){this.tbTableHandler(f,g,this.nActivePlugin)}.bind(this)),c.boardWin.setEvaluationInvalid()))}catch(f){LogException("RWM:chngSelectedKernel",f)}}checkShowFullBtn(a,b,c){a>.9*window.innerWidth&&b>.9*window.innerHeight&&this.maximized!=c?$("#b-btnFullScreen-"+c).hide():$("#b-btnFullScreen-"+c).show()}resizeNotaHori(a){if($("#eastNest"+a)&&$("#eastNest"+a)[0]){var b=
6129this.getButtonConfig().lineHNota;this.isOfflineVideo(a)&&(b=0);$("#eastNest"+a)[0].style.height="100%";$("#eastLayer"+a)[0].style.height="100%";$("#eastUpDownNest"+a)[0].style.height="100%";$("#eastUpDownNest"+a)[0].style.width="100%";this.hasChat(a)||($("#eastNest"+a)[0].style.width="100%");this.hasBook(a)||this.isAnyVideo(a)||($("#notaNest"+a)[0].style.height="100%");var c=$("#notaNest"+a).height()-b;$("#notaparent"+a)[0].style.height=c+"px";this.isAnyVideo(a);$("#notaEl"+a).css("font-size",this.isMaximized()&&
61301E3<window.innerWidth?"1.3em":"0.9em");this.isOfflineVideo(a)||($("#belowNota"+a)[0].style.width="calc( 100% + 1px )",$("#belowNota"+a)[0].style.height=b+"px",$("#belowNota"+a)[0].style.top=c+"px")}}onEngineLayoutChange(a){if(this.isPureNota(a))this.resizeEngineMobile(a);
6130else if(this.isSwipedLayout())this.resizeEngine(a);else this.onSplitterResize(a,!0)}getEngineH(a,b,c){var d=12;let e=1,f=!1,g=this.getEngineElement();g&&(f=g.showPosInfo,e=g.maxLines);f&&(d=7);d=Math.min(f?220:120+14*Math.min(8,e),
6131Math.max(96,b-14*Math.min(d,c)));50>b-d&&(d=Math.max(30,b/2));2>c&&(d=b);!this.modules[a].engineOpen&&0<c&&(d=0);return d}getGameCount(a){if(this.modules&&this.modules[a]){if(this.modules[a].offlinevideoDatabase)return this.modules[a].offlinevideoDatabase.results.length;if(this.modules[a].videoDatabase&&this.modules[a].videoDatabase.Items)return this.modules[a].videoDatabase.Items.length;if(this.modules[a].pgnDatabase)return this.modules[a].pgnDatabase.getGameCount();if(this.modules[a].requestData&&
6132this.modules[a].requestData.isList())return Math.max(2,this.modules[a].list.length)}return 0}resizeEngineAndListHori(a,b,c,d,e){b?$("#engineParent"+a)[0].style.height=c+"px":$("#engineParent"+a)[0].style.height="100%";$("#engineParent"+a)[0].style.width="100%";(d=this.modules[a].engineOpen)||!b?($("#engineParent"+a).show(),d||($("#replayinfo"+a)[0]?$("#replayinfo"+a)[0].style.height="100%":this.recreateHelp(a))):($("#engineParent"+a).hide(),c=0);$("#listParent"+a)[0].style.width="100%";$("#listParent"+
6133a)[0].style.height="calc( 100% - "+c+"px )";b&&this.gridCreated[a]&&($("#listParent"+a).jsGrid("option","height","calc( 100% - "+c+"px )"),$("#listParent"+a).jsGrid("option","width","100%"),$("#listParent"+a).jsGrid("option","heading",!0),this.isOfflineVideo(a)?$("#listParent"+a).jsGrid("option","fields",this.getOfflineVideoGridFields(this.getGridWidth(a),this.isLive(a))):this.isVideo(a)?$("#listParent"+a).jsGrid("option","fields",this.getVideoGridFields(this.getGridWidth(a),this.isLive(a))):$("#listParent"+
6134a).jsGrid("option","fields",this.getGridFields(this.getGridWidth(a),this.isLive(a))))}resizeListMobile(a){let b=$("#listParent"+a);b.css("height","100%");b.css("width","100%");this.gridCreated[a]&&(this.isVideo(a)?$("#listParent"+a).jsGrid("option","fields",this.getVideoGridFields(this.getGridWidth(a),this.isLive(a))):$("#listParent"+a).jsGrid("option","fields",this.getGridFields(this.getGridWidth(a),this.isLive(a))))}resizeListSwiped(a){let b=$("#listParent"+a),c=$("#listHolder"+a),d=0;$("#listTools"+
6135a).length&&(d=52,$("#listTools"+a).show(),$("#listTools"+a).css("height",d+"px"),$("#listTools"+a).width("100%"));480>c.width()?$("#listToolsClear"+a).hide():$("#listToolsClear"+a).show();340>c.width()?($("#listToolsBtn"+a).hide(),$("#listToolsCheck"+a).hide()):($("#listToolsBtn"+a).show(),$("#listToolsCheck"+a).show());d?c.css("height",String.f("calc( 100% - {0}px",d)):c.css("height","100%");b.css("width","100%");this.gridCreated[a]&&(this.isVideo(a)?$("#listParent"+a).jsGrid("option","fields",this.getVideoGridFields(this.getGridWidth(a),
6136this.isLive(a))):$("#listParent"+a).jsGrid("option","fields",this.getGridFields(this.getGridWidth(a),this.isLive(a))))}resizeEngineAndListTabbed(a,b,c,d,e,f){$("#engineParent"+a).hide();$("#listParent"+a)[0].style.height=f+"px";$("#listParent"+a)[0].style.width=e+"px";b&&this.gridCreated[a]&&($("#listParent"+a).jsGrid("option","height",f+"px"),$("#listParent"+a).jsGrid("option","width",e+"px"),$("#listParent"+a).jsGrid("option","heading",!0),this.isOfflineVideo(a)?$("#listParent"+a).jsGrid("option",
6137"fields",this.getOfflineVideoGridFields(e,this.isLive(a))):this.isVideo(a)?$("#listParent"+a).jsGrid("option","fields",this.getVideoGridFields(e,this.isLive(a))):$("#listParent"+a).jsGrid("option","fields",this.getGridFields(e,this.isLive(a))))}resizeVideoAndListTabbed(a,b,c,d,e,f){$("#engineParent"+a).hide();$("#videoParent"+a)[0].style.height=f-34+"px";$("#videoParent"+a)[0].style.width=e+"px";this.setVideoSize(a);$("#listParent"+a)[0].style.height=f+"px";$("#listParent"+a)[0].style.width=e+"px";
6138b&&this.gridCreated[a]&&($("#listParent"+a).jsGrid("option","height",f+"px"),$("#listParent"+a).jsGrid("option","width",e+"px"),$("#listParent"+a).jsGrid("option","heading",!0),this.isOfflineVideo(a)?$("#listParent"+a).jsGrid("option","fields",this.getOfflineVideoGridFields(e,this.isLive(a))):this.isVideo(a)?$("#listParent"+a).jsGrid("option","fields",this.getVideoGridFields(e,this.isLive(a))):$("#listParent"+a).jsGrid("option","fields",this.getGridFields(e,this.isLive(a))))}resizeEngineAndListVerti(a,
6139b,c,d,e){$("#engineParent"+a).hide();$("#listParent"+a)[0].style.width="100%";$("#listParent"+a)[0].style.height="100%";b&&this.gridCreated[a]&&($("#listParent"+a).jsGrid("option","height","100%"),$("#listParent"+a).jsGrid("option","width","100%"),$("#listParent"+a).jsGrid("option","heading",!0),$("#listParent"+a).jsGrid("option","fields",this.getGridFields(e,this.isLive(a))))}resizeEngineMobile(a){$("#engineParent"+a).css("width","100%");$("#engineParent"+a).css("height","100%");this.resizeEngine(a)}resizeNotaMobile(a){let b=
6140$("#notaNest"+a).height();0>=b&&(b=100);let c=$("#notaNest"+a).width();this.getButtonConfig();var d=$("#belowNota"+a).height()||0;d=b-d;let e=$("#notaButtons"+a);600<(e.width()||0)&&e.css("margin-left",30);!this.isSwipedLayout()||this.hasEngBelowNota(a)||this.isMobileLayout()||this.isDiagram(a)||(d-=26);$("#notaparent"+a).css("height",d+"px");this.modules[a].nota&&(this.modules[a].nota.setSize(c,d),this.modules[a].nota.scrollCurElemIntoView());this.setNotaFontSize(14,c,b)}resizeVideoMobile(a){this.isAnyVideo(a)&&
6141($("#videoparent"+a).css("height","100%"),$("#videoparent"+a).css("width","100%"),this.setVideoSize(a))}resizeBoardMobile(a){var b=$("#south"+a).height()||$("#mobEast"+a).height()||$("#west"+a).height()||$("#westNorth"+a).height(),c=this.getButtonConfig().getLineHBoard(),d=b;this.hasButtonsInBoardDiv()&&(d-=c);b=$("#boardHolder"+a);b.css("width","100%");b.css("height",d+"px");d=$("#belowBoard"+a);d.css("width","100%");d.css("height",c+"px");c=$("#buttons"+a);c.css("width","100%");c.css("height","100%");
6142c=b.width();b=b.height();this.modules[a].boardArea&&!this.modules[a].boardArea.canvas&&(this.isLive(a)&&this.layoutHasMultiBoard()?this.createMultiBoard(a):(d=Math.max(1,Math.round(b/120)),d={topDist:d,bottomDist:Math.max(2,d),marginDistDivisor:50,bigCoords:!1,shiftXPercent:0,minWForCoordinates:this.coordinates?280:9999,boardShadow:this.layout==ReaderLayout.DESK_SWIPED,noToMoveBulge:!0},this.modules[a].boardArea.createCanvas(this.modules[a].getKernel(),d),this.modules[a].getKernel().boardWin.onReadyHandlers.add(this.modules[a].onBoardReady.bind(this.modules[a])),
6143this.initGestures(this.modules[a].boardArea.canvas.control,a)));this.adaptMaxKernels(a,c,b);this.launchResizeBoard(a,c,b,700)}hasHamburgerMenu(){return this.layout!=ReaderLayout.HORIZONTAL}hasButtonsInBoardDiv(){return this.layout==ReaderLayout.BIG_BOARD||this.layout==ReaderLayout.MULTI_BOARD_2||this.layout==ReaderLayout.MULTI_BOARD_4||this.layout==ReaderLayout.HORIZONTAL||this.layout==ReaderLayout.VIDEO||this.layout==ReaderLayout.DESK_SPLITTED||this.layout==ReaderLayout.DESK_SWIPED}hasEngineInSwipe(){return this.layout==
6144ReaderLayout.BIG_BOARD||this.layout==ReaderLayout.MULTI_BOARD_4||this.layout==ReaderLayout.VIDEO||this.layout==ReaderLayout.DESK_SPLITTED||this.layout==ReaderLayout.DESK_SWIPED}layoutHasMultiBoard(){return this.layout==ReaderLayout.HORIZONTAL||this.layout==ReaderLayout.USER_LAYOUT||this.layout==ReaderLayout.MULTI_BOARD_2||this.layout==ReaderLayout.MULTI_BOARD_4||this.layout==ReaderLayout.DESK_SPLITTED||this.layout==ReaderLayout.DESK_SWIPED}layoutHasNotaHeader(a){return this.isDiagram(a)?!1:this.isPureNota(a)?
6145!$(this.modules[a].pluginDiv).data("noheader"):this.isVerti?this.layout!=ReaderLayout.USER_LAYOUT||this.nUserNota!=NotaSize.SMALL:!0}
6145getGridWidth(a){return $("#listParent"+a).width()}getBoardWidth(a){return $("#boardHolder"+a).width()}onSplitterResize(a,b){if(!this.isMobileLayout())switch(this.layout){default:case ReaderLayout.DESK_SPLITTED:this.onSplitterResizeHori(a,b);break;case ReaderLayout.DESK_SWIPED:this.onSplitterResizeSwiped(a)}}onSplitterResizeHori(a,b){var c=$("#boardHolder"+a).width(),
6146d=$("#boardHolder"+a).height();if(this.checkBoardAreaChange(c,d,a)||b){this.modules[a].boardArea&&this.resizeBoard(a,c,d);d=this.getGameCount(a);b=1<d;var e=(d=this.getEngineH(a,$("#westSouth"+a).height(),d))?d+"px":"100%";$("#engineParent"+a)[0].style.height=e;$("#listParent"+a)&&($("#listParent"+a)[0].style.height="calc( 100% - "+d+"px )");this.recreateBoardButtons(a);b&&this.gridCreated[a]&&($("#listParent"+a).jsGrid("option","height","calc( 100% - "+d+"px )"),this.isOfflineVideo(a)?$("#listParent"+
6147a).jsGrid("option","fields",this.getOfflineVideoGridFields(c,this.isLive(a))):this.isVideo(a)?$("#listParent"+a).jsGrid("option","fields",this.getVideoGridFields(c,this.isLive(a))):$("#listParent"+a).jsGrid("option","fields",this.getGridFields(c,this.isLive(a))),$("#listParent"+a).jsGrid("refresh"));this.setNotaSize(a);this.setVideoSize(a);this.chat[a]&&this.chat[a].resize();this.isLive(a)&&this.refreshGridIcons(a);this.book[a]&&this.book[a].resize();this.resizeEngine(a);this.saveSplitSize("root",
6148a);this.saveSplitSize("westNest",a)}}onSplitterResizeSwiped(a,b){var c=$("#boardHolder"+a).width(),d=$("#boardHolder"+a).height();if(this.checkBoardAreaChange(c,d,a)||b)this.modules[a].boardArea&&this.resizeBoard(a,c,d),this.recreateBoardButtons(a),1<this.getGameCount(a)&&this.gridCreated[a]&&(b=$("#listParent"+a).width(),this.isVideo(a)?$("#listParent"+a).jsGrid("option","fields",this.getVideoGridFields(b,this.isLive(a))):$("#listParent"+a).jsGrid("option","fields",this.getGridFields(b,this.isLive(a)))),
6149this.resizeNotaMobile(a),this.resizeEngineMobile(a),this.resizeVideoMobile(a),this.resizeListSwiped(a),this.refreshGridIcons(a),this.saveSplitSize("root",a),this.saveSplitSize("westNest",a)}onRootSplitterCollapse(a){this.saveSplitColl("root",a)}onListSplitterCollapse(a){this.saveSplitColl("westNest",a)}onChatSplitterCollapse(a){this.saveSplitColl("eastNest",a)}onBookSplitterCollapse(a){this.saveSplitColl("eastUpDownNest",a)}loadSplitPos(a,b){if(this.isVideo(b)||this.isOfflineVideo(b))return null;
6150b=this.isLive(b)?"live":"";a=glApp.Vn.load(a+"size"+b);a=parseFloat(a);85<a&&(a=85);15>a&&(a=15);
6150return{size:a,coll:!1}}saveSplitSize(a,b){try{var c=$("#"+a+b);if(c&&c.length){var d=this.isLive(b)?"live":"",e=$(c).jqxSplitter("panels");e&&e[0]&&glApp.Vn.save(a+"size"+d,e[0].size)}}catch(f){LogException("RWM:saveSplitSize",f)}}saveSplitColl(a,b){}onNotaEngSplitterResize(a){this.resizeNotaMobile(a);this.saveSplitSize("notaEngNest-",a)}onEastSplitterResize(a){this.resizeNotaHori(a);this.chat[a]&&this.chat[a].resize();
6151this.book[a]&&this.book[a].resize();this.video[a]&&this.video[a].resize();this.setNotaSize(a);this.setVideoSize(a);this.saveSplitSize("eastNest",a)}onBookSplitterResize(a){this.resizeNotaHori(a);this.book[a]&&this.book[a].resize();this.saveSplitSize("eastUpDownNest",a)}onVideoSplitterResize(a){this.resizeNotaHori(a);this.setVideoSize(a);this.saveSplitSize("eastUpDownNest",a)}getButtonConfig(){function a(){return 100<window.innerHeight&&100<window.innerWidth}return System.isMobile()?{getLineHBoard:function(){return a()?
615260:44},getBtnHBoard:function(){return a()?48:32},getBtnHDiagram:function(b){return a()?32:24},lineHNota:42,btnHNota:32,getCssBoard:function(){return a()?"toolBtn toolBtn48":"toolBtn toolBtn32"}.bind(this),getCssDiagrams:function(b){return a()?"toolBtn toolBtn32":"toolBtn toolBtn24"}.bind(this),getCssNota:function(){return"toolBtn toolBtn32"}.bind(this),getCssEngine:function(){return"toolBtn toolBtnV16"}.bind(this),getCssTabNav:function(){return"tabNavBtn tabNavBtn32"}.bind(this),getTotalBtnWBoard(){let b=
6153this.getBtnHBoard();return 48==b?b+12:b+10}}:{getLineHBoard:function(){return 800<window.innerHeight?44:34}.bind(this),getBtnHBoard:function(){return 800<window.innerHeight?32:24}.bind(this),getBtnHDiagram:function(b){return 250<b?24:16},lineHNota:34,btnHNota:24,getCssBoard:function(){return 800<window.innerHeight?"toolBtn toolBtn32":"toolBtn"}.bind(this),getCssDiagrams:function(b){return 250<b?"toolBtn toolBtn24":"toolBtn toolBtn16"}.bind(this),getCssNota:function(){return"toolBtn"}.bind(this),getCssTabNav:function(){return"tabNavBtn tabNavBtn16"}.bind(this),
6154getCssEngine:function(){return"toolBtn toolBtnV16"}.bind(this),getTotalBtnWBoard(){let b=this.getBtnHBoard();switch(b){case 24:return 29;case 32:return 42;case 48:return 60;default:return b+10}}}}resizeDiagram(a,b){if(a){var c=360,d=a[0].dataset.size;if(d)if("auto"==d)this.isMobileLayout()?$(a).css("width","100vw"):($(a).css("width","80%"),$(a).css("max-width","720px")),c=$(a).width();else if(c=d.match(/%/)){if(d.match(/%\/max=/)){var e=d.split("=");$(a).css("width",d.substr(0,c.index+1));$(a).css("max-width",
6155e[1].substr(0,e[0].length)+"px")}else $(a).css("width",d);c=$(a).width()}else c=d;e=!!a[0].dataset.bigcoords;$("#aboveDiag"+b).width(c);$("#belowDiag"+b).width(c);c>.9*window.innerWidth&&"auto"!=d&&(c=.9*window.innerWidth,$(a).width(c));d=c;a=.92*d;LOG("Resize Diag:"+c+"/"+c,"","resize");$("#diagarea"+b).width(d);$("#diagarea"+b).height(a);this.modules[b]&&!this.modules[b].boardArea.canvas&&(this.modules[b].boardArea.createCanvas(this.modules[b].getKernel(),{topDist:1,bottomDist:1,marginDistDivisor:36,
6156shiftXPercent:-1.65,minWForCoordinates:this.coordinates?280:9999,transparent:!0,bigCoords:e,mixin:this.getDiagramMixin()}),this.modules[b].getKernel().boardWin.onReadyHandlers.add(this.modules[b].onBoardReady.bind(this.modules[b])));$("#diagarea"+b)[0]&&this.modules[b]&&this.modules[b].boardArea&&this.resizeBoard(b,d-1,a-1);this.setButtonImages("d",this.diagramBtns[b],this.getButtonConfig().getBtnHDiagram(a),this.getButtonConfig().getCssDiagrams(a),b,"Reader");a=$("#diagButtons"+b);d=$("#diagText"+
6157b);a&&a.height();d&&d.height();$("#diaEng"+b).width(c);a=$("#diaNota"+b);a.length&&(a.width(c),a[0].notaOpen&&this.resizeNotaMobile(b))}}getDiagramMixin(){return{addCheckMark:function(){this.addSideIcon({url:getCommonPath()+"Media/Ribbons/Reader/Check48.png",cssClass:"cbBoardCheckMark",boardFract:12})}}}getDiagHeight(a,b){return this.isPureNota(b)?(b=System.isMobile()?240:280,Math.min(b,Math.max(120,.52*a))):System.isMobile()?130:190}resizeTable(a,b){var c=this.modules[b].ranking;c&&(a=$(a),a.html(""),
6158b=a.width(),c=c.toHtml(b),a.append(c),$(a.children()[0]),750>b?a.css("font-size",1-(750-b)/1050+"em"):a.css("font-size","1em"))}resizePairings(a,b){var c=this.modules[b].pairing;if(c){a=$(a);a.html("");b=a.width();c=c.RoundToHtml(c.round,b);a.append(c);750>b?a.css("font-size",1-(750-b)/1200+"em"):a.css("font-size",1+(b-750)/4200+"em");a=$(c).find("td").has(".playerImageContainer");a.css("width","0px");a.hide();c=$(c).width();var d=$(a[0]).width();
6158a.css("width",(b-c+2*d)/2+"px");a.show()}}resizeActivePlugin(){this.resizePlugin($($(this.allPluginClasses)[this.nActivePlugin]),
6159this.nActivePlugin)}createBoardButtons(a,b){var c={title:lm.START_RADIO,id:"LiveNew",handler:this.fnStart.bind(this)};let d=this;var e={title:lm.TAKE_BACK,id:"Retract",handler:this.fnRetract.bind(this),dclickhandler:this.fnGotoStart.bind(this)};let f={title:lm.MAKE_MOVE,id:"Exec",handler:this.fnExec.bind(this),dclickhandler:this.fnGotoEnd.bind(this)},g={title:lm.AUTOPLAY,id:"Autoplay",handler:this.fnAutoplay.bind(this)},h={title:lm.GOTO_BEGIN,id:"GoBegin",handler:this.fnGotoStart.bind(this)},k={title:lm.GOTO_END,
6160id:"GoEnd",handler:this.fnGotoEnd.bind(this)},l={title:lm.PREV_GAME,id:"LoadPrev",handler:this.loadPrevGame.bind(this)},m={title:lm.NEXT_GAME,id:"LoadNext",handler:this.loadNextGame.bind(this)},n={title:lm.MAXIMIZE,id:"FullScreen",handler:this.fnFullWindow.bind(this)},r={title:lm.ANALYSIS_ENGINE,id:"Engine",handler:function(){this.fnToggleAnalysis(b)}.bind(this)},t={title:lm.FLIP_BOARD,id:"Rotate",handler:this.fnFlipBoard.bind(this)};this.fnSound.bind(this);let u={title:lm.PIECES,id:"Settings",handler:this.fnSettings.bind(this),
6161css:"btnPieces"},x={title:lm.DOWNLOAD,id:"Download",handler:function(ha,z){d.saveBtnHdl(ha,z)}},B={title:lm.TRAINING_SOLUTION,id:"Solution",handler:function(ha,z){d.showSolutionBtnHdl(ha,z)}},y={title:"Layout",id:"Layout",handler:this.fnDeskLayout.bind(this),css:"btnPieces"},A={separator:!0,id:"Sep"},aa=[];aa=this.isAnyVideo(b)?aa.concat([B,A,t]):aa.concat([r,A,l,h,g,e,f,k,m,A,t]);1==this.getGameCount(b)&&(aa=aa.filter(ha=>"LoadNext"!=ha.id&&"LoadPrev"!=ha.id));this.isMobileLayout()||aa.push(n);aa=
6162aa.concat([A,t]);this.isMobileLayout()||System.isElectron()||System.isCordova()||(aa=aa.concat([A,x]));aa.push(u);this.isRecorder(b)&&(aa=[c].concat(aa));this.isMobileLayout()||aa.push(y);c=$(a).width();e=this.getButtonConfig().getTotalBtnWBoard();c=Math.floor(c/e);2>c&&(c=2);aa=this.removeButtonsInOrderOf(aa,c,"Sep SoundOn Settings Layout Autoplay Rotate LoadPrev GoEnd Download Engine LoadNext GoBegin".split(" "));this.boardBtns[b]=aa;c=this.getButtonConfig().getCssBoard();try{this.instantiateButtons("button",
6163a,"b",aa,c,b)}catch(ha){}this.soundBtnSelector[b]="#b-btnSoundOn-"+b}recreateBoardButtons(a){this.buttonGate[a]||(this.buttonGate[a]=new V10);this.buttonGate[a].exec(function(){var b=$("#buttons"+a);this.createBoardButtons(b[0],a);var c=$(this.modules[a].pluginDiv);b=c.width();c=c.height();this.checkShowFullBtn(b,c,a);b=this.getButtonConfig();this.setButtonImages("b",this.boardBtns[a],b.getBtnHBoard(),b.getCssBoard(),a,"Reader")}.bind(this),400)}createFloatButtons(a,b){var c={separator:!0,id:"Sep"};
6164let d=this,e={title:lm.TAKE_BACK,id:"Retract",handler:this.fnRetract.bind(this),dclickhandler:this.fnGotoStart.bind(this)},f={title:lm.MAKE_MOVE,id:"Exec",handler:this.fnExec.bind(this),dclickhandler:this.fnGotoEnd.bind(this)},g={title:lm.AUTOPLAY,id:"Autoplay",handler:this.fnAutoplay.bind(this)},h={title:lm.GOTO_BEGIN,id:"GoBegin",handler:this.fnGotoStart.bind(this)},k={title:lm.GOTO_END,id:"GoEnd",handler:this.fnGotoEnd.bind(this)},l={title:lm.FLIP_BOARD,id:"Rotate",handler:this.fnFlipBoard.bind(this)};
6165var m={title:lm.DOWNLOAD,id:"Download",handler:function(A,aa){d.saveBtnHdl(A,aa)}};let n={title:lm.LOAD_PREV,id:"LoadPrev",handler:this.loadPrevGame.bind(this)},r={title:lm.LOAD_NEXT,id:"LoadNext",handler:this.loadNextGame.bind(this)};var t={title:"Fold/Unfold",id:"UnFoldAll",handler:function(){this.modules[b]&&this.modules[b].nota&&this.modules[b].nota.unfoldAll()}.bind(this)};let u={title:"Layout",id:"Layout",handler:function(){this.fnNotaToDesk(b)}.bind(this)},x={title:lm.ANALYSIS_ENGINE,id:"Engine",
6166handler:function(){this.fnToggleAnalysis(b)}.bind(this)},B={title:lm.PIECES,id:"Settings",handler:this.fnSettings.bind(this),css:"btnPieces"},y={title:lm.MAXIMIZE,id:"FullScreen",handler:this.fnFloatMaximize.bind(this)};c=[n,h,g,e,f,k,r,c,l,c,y,u,x];this.getKernel()&&200<this.getKernel().game.countAllMoves()&&c.unshift(t);c.push(B);System.isElectron()||System.isCordova()||(c=c.concat([m]));1==this.getGameCount(b)&&(c=c.filter(A=>"LoadNext"!=A.id&&"LoadPrev"!=A.id));m=$(a).width();t=this.getButtonConfig().getTotalBtnWBoard();
6167m=Math.floor(m/t);2>m&&(m=2);c=this.removeButtonsInOrderOf(c,m,"Sep Layout FullScreen UnFoldAll Settings LoadPrev Autoplay LoadNext Analysis Download GoEnd GoBegin".split(" "));m=this.getButtonConfig().getCssBoard();try{this.instantiateButtons("button",a,"b",c,m,b)}catch(A){}a=this.getButtonConfig();this.setButtonImages("b",c,a.getBtnHBoard(),a.getCssBoard(),b,"Reader")}createDiagramEng(a){let b=$("#diaEng"+a);if(this.showExtraDiv(a,b,130,!0))return b[0].engOpen=!0,this.createEngineDivsMobile(b[0],
6168a)}hideDiagramEng(a){let b=$("#diaEng"+a);this.hideExtraDiv(a,b);b[0].engOpen=!1}showDiagramNota(a){let b=$("#diaNota"+a);if(this.showExtraDiv(a,b,100,!1)){b[0].notaOpen=!0;let c=this.modules[a].getKernel();this.modules[a].nota=this.createNotaDivs(b[0],a,c,!0);this.resizeNotaMobile(a)}}hideDiagramNota(a){let b=$("#diaNota"+a);this.hideExtraDiv(a,b);b[0].notaOpen=!1}toggleDiagramNota(a){let b=$("#diaNota"+a);b.length&&b[0].notaOpen?this.hideDiagramNota(a):this.showDiagramNota(a)}showExtraDiv(a,b,c,
6169d){if(b.length)return b[0].engOpen=!0,b.show(),d&&b.css("transition","height 0.2s"),b.height(c),!0}hideExtraDiv(a,b){if(b.length)return b.css("transition","0"),b.hide(),b.height(0),b.html(""),!0}createFloatBoardEng(a){if(this.floatBoard[a]){let b=this.floatBoard[a].toggleEngine();if(b)return this.createEngineDivsMobile(b,a)}}hideFloatBoardEng(a){this.floatBoard[a]&&this.floatBoard[a].toggleEngine()}shakeFullWinBtn(a){$("#b-btnFullScreen-"+a).addClass("shakeShort")}stopShakeFullWinBtn(a){$("#b-btnFullScreen-"+
6170a).removeClass("shakeShort")}removeButtonsInOrderOf(a,b,c){let d=0;for(;a.length>b&&d<c.length;){for(let e=0;e<c.length;e++){let f=a.length;a=a.filter(g=>g.id!=c[e]);if(f>a.length)break}
6170d++}return a}createDiagramReplayButtons(a,b,c){var d=[],e=glApp.config.diaStyleSuffix;d=d.concat([{title:"Restart",id:"Repeat",pic:(b.dataset.play||b.dataset.choice?"Repeat":"GoBegin")+e,handler:this.fnRestart.bind(this)}]);d=d.concat([{title:lm.TAKE_BACK,id:"Retract",pic:"Retract"+e,handler:this.fnRetract.bind(this)},
6171{title:lm.MAKE_MOVE,id:"Exec",pic:"Exec"+e,handler:this.fnExec.bind(this)}]);360<=$(b).width()&&"replayonly"!=b.dataset.buttons&&(d=d.concat([{}]),d.push({title:lm.FLIP_BOARD,id:"Rotate",handler:this.fnFlipBoard.bind(this)}));let f=!1;b.dataset.hint?(f=!0,d=d.concat([{}]),d.push({title:"Hint",id:"Hint",pic:"Hint"+e,handler:function(g){this.fnHint(b.dataset.hint,g)}.bind(this)})):b.dataset.help&&(f=!0,d=d.concat([{}]),d.push({title:"Help",id:"Hint",pic:"Hint"+e,handler:function(g){this.fnHelp(b.dataset.help,
6172g)}.bind(this)}));b.dataset.solution&&(f=!0,d.push({title:"Solution",id:"Solution",handler:function(g){this.fnSolution(b.dataset.solution,g)}.bind(this)}));f||(d=d.concat([{}]),d.push({title:lm.NOTATION,id:"Notation",handler:function(g,h){this.toggleDiagramNota(g)}.bind(this)}));f||b.dataset.play||b.dataset.noengine||d.push({title:lm.ANALYSIS_ENGINE,id:"Engine",handler:function(g,h){this.fnToggleAnalysis(g,h)}.bind(this)});"replayonly"!=b.dataset.buttons&&(d=d.concat([{}]),d.push({title:lm.DOWNLOAD,
6173id:"Download",handler:function(g,h){this.saveBtnHdl(g,h)}.bind(this)}));this.diagramBtns[c]=d;e=this.getButtonConfig().getCssDiagrams();try{this.instantiateButtons("button",a,"d",d,e,c),this.showDiaReplayButtons(c,!1)}catch(g){}}showDiaReplayButtons(a,b){["Repeat","Retract","Exec"].forEach(function(c){c=$(`#d-btn${c}-${a}`);b?c.show():c.hide()})}createDiagramAnimButtons(a,b,c){b=[];var d=glApp.config.diaStyleSuffix;b=b.concat([{title:"Rewind",id:"ActionRewind",pic:"ActionRewind"+d,handler:this.fnAnimRewind.bind(this)},
6174{title:"Back",id:"ActionGotoPrev",pic:"ActionGotoPrev"+d,handler:this.fnAnimBack.bind(this)},{title:"Play",id:"ActionPlay",pic:"ActionPlay"+d,handler:this.fnAnimPlay.bind(this)},{title:"Step",id:"ActionGotoNext",pic:"ActionGotoNext"+d,handler:this.fnAnimStep.bind(this)},{title:"Pause",id:"ActionPause",pic:"ActionPause"+d,handler:this.fnAnimPause.bind(this)}]);this.diagramBtns[c]=b;d=this.getButtonConfig().getCssDiagrams();this.instantiateButtons("button",a,"d",b,d,c)}fn3D(a){this.toggle3DBoard(a)}setAutoplayBtnImg(a,
6175b){b=$(String.f("#b-btnAutoplay-{0}",b));var c='url( "'+getCommonPath()+'Media/Ribbons/Reader/{0}{1}.png" )';a?b.css("background-image",String.f(c,"Stop",this.getButtonConfig().getBtnHBoard())):b.css("background-image",String.f(c,"Autoplay",this.getButtonConfig().getBtnHBoard()))}canUseEngine(){return EngineInstance.isAjax||-1!=document.URL.search(/chessbase.com/i)||-1!=document.URL.search(/localhost/i)}createNotaButtons(a,b){var c=[];!this.socialMedia||System.isElectron()||System.isCordova()||c.push({title:"Share game",
6176id:"ShareGame",handler:function(){$("#n-btnShareGame-0").attr("disabled",!0);this.shareGame(this.modules[b].getKernel().game);$("#n-btnShareGame-0").removeAttr("disabled")}.bind(this)});System.isElectron()||System.isCordova()||c.push({title:lm.SAVE+" (Ctrl-S)",id:"Save",handler:this.fnSave.bind(this)});c.push({title:"Toggle Variation Folding",id:"UnFoldAll",handler:function(){this.modules[b]&&this.modules[b].nota&&this.modules[b].nota.unfoldAll()}.bind(this)});c.push({title:lm.PROMOTE_LINE+" (Alt-up)",
6177id:"PromoteLine",handler:this.fnPromoteLine.bind(this)});c.push({title:lm.DELETE_LINE+" (Del)",id:"DeleteLine",handler:this.fnDeleteLine.bind(this)});c.push({title:lm.CUT_LINE+" ([)",id:"CutLine",handler:this.fnDeletePrevious.bind(this)});c.push({title:"Zap Rest (])",id:"ZapRest",handler:this.fnZapRest.bind(this)});c.push({title:lm.UNANNOTATE+" (Ctrl-Shift-Y)",id:"Unannotate",handler:this.fnUnannotate.bind(this)});c.push({title:"Undo (Ctrl-Z)",id:"Undo",handler:this.fnUndo.bind(this)});c.push({title:"Redo (Ctrl-Y)",
6178id:"Redo",handler:this.fnRedo.bind(this)});c.push({title:"Symbols",id:"SymbolMenu",handler:function(e,f){this.symbolBtnHdl(e,f)}.bind(this)});System.isElectron()||System.isCordova()||(c.push({title:"Copy FEN to clipboard",id:"Fen",handler:this.fnSaveNotaFEN.bind(this)}),c.push({title:"Check Database",id:"OnlineDB",handler:this.fnOnlineDB.bind(this)}));!System.isElectron()&&!System.isCordova()&&1600<window.innerWidth&&(c.push({title:"-> MyGames",id:"MyGames",handler:this.fnMyGames.bind(this)}),c.push({title:"-> Fritz",
6179id:"FritzOnline",handler:this.fnFritz.bind(this)}));this.notaBtns=c;var d=this.getButtonConfig().getCssNota();try{this.instantiateButtons("button",a,"n",c,d,b)}catch(e){}}setFullWinBtnImage(a,b){this.buttonImages[a].FullScreen=b?"FullScreen":"Restore"}tryAgainBtnHdl(a,b){this.modules[a].getKernel()}playSolution(a,b){b=this.baseurl+"Replay/GetSolution?id="+encodeURIComponent(b);$.get(b,function(c){if(c){var d=c.ID;c=c.MSG;2<c.length?this.showMessage(c):this.loadNewVideo(a,d,!0)}}.bind(this))}showSolutionBtnHdl(a,
6180b){this.modules[a].getKernel().Interactive&&(b=this.modules[a].getKernel().Vp.videoid,this.playSolution(a,b))}saveBtnHdl(a,b){var c=$(`#b-btnDownload-${a}`);0==c.length&&(c=$(`#d-btnDownload-${a}`));if(0!=c.length){var d=b.clientX-40;a=this.createSaveMenu(c[0],a);c=$(a).height();b=b.clientY+window.pageYOffset-c;b+c>window.innerHeight+window.pageYOffset&&(b=Math.max(0,window.innerHeight-c+window.pageYOffset));$(a).jqxMenu({mode:"popup",theme:"chessbase"});$(a).jqxMenu("open",d,b)}}fnSaveDB(a){this.fnSave(a,
6181!1)}fnSave(a,b,c){var d="Download",e=".fen"===c;e&&(d+="-fen");if(b){var f=this.modules[a].getKernel().game;b=e?PGNWriter.toFEN(f):PGNWriter.toPGN(f);0<f.hdr.getStrPlayers(!1,0).length&&(d=f.hdr.getStrPlayers(!1,0)+(c||".pgn"));c=f.requiresPremiumForDownload()&&!e}else{b=this.modules[a].toPgn(a);if(!b)return;this.modules[a].pgnTitle&&(d=this.modules[a].pgnTitle);c=this.modules[a].getKernel().game.requiresPremiumForDownload()}this.modules[a].pluginDiv.dataset.allowdownload&&(c=!1);System.copyToClipboard(b);
6182e?this.showMessage("FEN downloaded and copied to clipboard",5E3):this.showMessage("PGN downloaded and copied to clipboard",5E3);a=System.runsOnChessBaseCom()&&-1==document.URL.search(/view.chessbase.com/i)&&-1==document.URL.search(/cloudserver.chessbase.com/i);if(c&&!glApp.isPremium()&&a)window.location="https://live.chessbase.com/Premium?returnurl="+encodeURIComponent(document.location);else{if(window.Blob){a=new Blob([b],{type:"text/plain;charset=utf-8"});c=d.split(".")[0]+".pgn";e=new File([a],
6183c,{type:"text/plain"});f=!0;try{System.isMobile()&&navigator.canShare&&navigator.canShare({files:[e]})&&navigator.share({files:[e],title:c}),System.runsOnLocalHost()&&(f=!0)}catch(g){console.log(g)}f&&window.saveAs(a,d)}System.copyToClipboard(b);LogStats("PGN")}}saveShareAndCopyUrl(a,b){var c=a.join("\n");
6183c=new Blob([c],{type:"text/plain;charset=utf-8"});try{System.isMobile()&&navigator.canShare&&navigator.canShare({url:a[0]})&&navigator.share({url:a[0],title:b})}catch(d){console.log(d)}window.saveAs(c,
6184b+".txt");System.copyToClipboard(a[0]);return a[0]}shareLiveChessLink(a){let b=this.getLiveChessUrl(a);b?(console.log(b),a=this.modules[a].getKernel().game.hdr,this.saveShareAndCopyUrl([b],"Link-"+a.getStrPlayers(!1,0))):console.log("no url")}createQRCode(a,b,c){function d(){let g=f.modules[a].getKernel().game;f.doCreateQR(g,a,!0)}function e(){let g=f.modules[a].pgnDatabase;for(let h=1;h<=g.getGameCount();h++){let k=g.getGame(h);(new Timer(function(){f.showMessage(k.hdr.toCompactString());f.doCreateQR(k,
6185a,!1)}.bind(f))).runOnce(600*h)}}let f=this;!c&&f.modules[a].pgnDatabase&&1<f.modules[a].pgnDatabase.getGameCount()?RadioChoice(this.modules[a].pluginDiv,"QR Codes",["This Game","All Games"],0,function(g){switch(g){case 0:d();break;case 1:e()}}.bind(this),b):d()}doCreateQR(a,b,c){var d=new DataBuffer;a.write2(d);b=new Uint8Array(d.buffer,0,d.nSize);b=UZIP.deflateRaw(b);b=DataBuffer.arrToBase64(b);b="https://replay.chessbase.com?c64="+b;2E3<b.length&&(b=new Game,b.assign(a),b.unAnnotate(),d.rewind(),
6186b.write2(d),b=new Uint8Array(d.buffer,0,d.nSize),b=UZIP.deflateRaw(b),b=DataBuffer.arrToBase64(b),b="https://replay.chessbase.com?c64="+b);if(2E3>b.length){d=document.body;var e=document.createElement("canvas");e.id="qrCanvas";e.width=1200;e.height=1200;d.appendChild(e);new QRious({element:e,size:1200,value:b});System.copyToClipboard(b);let f=e.getContext("2d").getImageData(0,0,1200,1200);d.removeChild(e);if(d=CanvasTools.imgToBlob(f,1200,1200))e=a.hdr.getStrPlayers(!1,0),a="QR-"+a.hdr.toCompactString()+
6187".png",c?this.shareImage(d,a,e,!0):window.saveAs(d,a)}return b}shareImage(a,b,c,d){var e=[new File([a],b,{type:"image/png"})];if(navigator.canShare&&navigator.canShare({files:e}))try{navigator.share({files:e,title:c})}catch(f){console.log(f)}d&&window.saveAs(a,b)}getLiveChessUrl(a){let b=this.modules[a].getKernel().game.hdr,c=b.white.last,d=b.black.last,e="";if(a=$(this.modules[a].pluginDiv).data("link")){let f=a.match(/\?id=(.+?)&/i);f||=a.match(/\?id=(.+)/i);f&&2==f.length&&(e=f[1])}else e=EventData.normalizeQueryString(b.event.event);
6188if(e)return`https://live.chessbase.com/search?tourn=${e}&player=${c}&other=${d}&round=${b.getRoundStr()}`}runsOnChessBaseNews(){return System.runsOnChessBaseNews()||-1!=document.URL.search(/localhost/i)}fnSaveFEN(a){this.fnSave(a,!0,".fen")}fnSaveNotaFEN(a){this.fnSave(a,!0,".fen")}moduleGamesToPgn(a){let b="";this.modules[a].list?this.modules[a].list.forEach(function(c){(c=this.modules[a].gameMap[c.id])&&(b+=PGNWriter.toPGN(c))}.bind(this)):this.modules[a].kernel.forEach(function(c){c.game&&c.game.hdr.isValid()&&
6189(b+=PGNWriter.toPGN(c.game))}.bind(this));return b}fnNewGame(a){this.modules[a].getKernel().newGame();this.fnSelectNota(a,400)}fnGotoStart(a){this.stopAutoplay(a);this.modules[a].getKernel().game.gotoStart()}fnRestart(a){this.fnAnimRewind(a);this.modules[a].getKernel().Vp.restart()}fnGotoEnd(a){this.stopAutoplay(a);this.modules[a].getKernel().game.gotoEnd()}fnRetract(a){this.stopAutoplay(a);this.modules[a].getKernel().game.gotoPrev()}fnExec(a){if(this.modules[a]&&!this.stopAutoplay(a)){var b=this.modules[a].getKernel().game.getAnno(AnnoType.TRAINING);
6190b&&!b.solved||this.modules[a].getKernel().game.gotoNext()}}fnAnimPlay(a){for(var b=0;b<this.modules.length;b++)b!=a&&this.modules[b].animationController&&this.modules[b].animationController.pause();this.modules[a].animationController&&this.modules[a].animationController.play()}fnAnimStep(a){this.modules[a].animationController&&this.modules[a].animationController.step()}fnAnimBack(a){this.modules[a].animationController&&this.modules[a].animationController.stepBack()}fnAnimFastForward(a){this.modules[a].animationController&&
6191this.modules[a].animationController.fastForward()}fnAnimPause(a){this.modules[a].animationController&&this.modules[a].animationController.pause()}fnAnimRewind(a){this.modules[a].animationController&&(this.modules[a].getKernel().Vp.restart(),this.modules[a].animationController.rewind(!0))}setMark(a,b){this.modules[a].getKernel().execCommand(b)}clearMark(a){this.modules[a].getKernel().deleteAnno(AnnoType.SYMBOL,!0)}stopAutoplay(a){return this.modules[a]&&(this.modules[a].runAutoplayTimer&&this.modules[a].runAutoplayTimer.stop(),
6192this.modules[a].timerAutoplay)?!this.fnAutoplay(a):!1}fnAutoplay(a,b,c){if(this.modules[a].timerAutoplay)return this.modules[a].timerAutoplay.stop(),delete this.modules[a].timerAutoplay,this.modules[a].getKernel().boardWin.prepareFullRedraw(),this.modules[a].animSteps&&(this.modules[a].getKernel().boardWin.animSteps=this.modules[a].animSteps),this.modules[a].getKernel().Vp.setIsAutoplay(!1),this.setAutoplayBtnImg(!1,a),!1;let d=this.modules[a].getKernel();d.boardWin&&d.boardWin.animSteps&&(this.modules[a].animSteps=
6193d.boardWin.animSteps,System.isMobile()?d.boardWin.animSteps.forMove=.3:d.boardWin.animSteps.forMove=3);d.game.getMoveNo()==d.game.getMainLine().length&&this.fnGotoStart(a);this.setAutoplayBtnImg(!0,a);var e=c||2500,f=7777;System.isMobile()&&(e=1600);
6193b&&!c&&(b.ctrlKey?(e=1300,b.altKey&&(e=b.shiftKey?200:700),f=3E3):b.shiftKey?(e=5E3,b.altKey&&(e=1E4),f=1E4):b.altKey&&(e=1E3,f=2E4));d.boardWin&&d.boardWin.destroyMessage();this.showMessage(String.f("Max Time in autoplay: {0}s",f/1E3),3E3);d.Vp.setIsAutoplay(!0);
6194d.game.gotoNext();let g=new Analyser(d);b=g.getGifDelays(500,f,d.getMoveNo(),!0);this.modules[a].timerAutoplay=new Timer(function(){d.game.isOnLastMove()?this.modules[a].timerAutoplay&&(this.modules[a].timerAutoplay.stop(),(new Timer(function(){if(this.modules[a].timerAutoplay){this.loadNextGame(a);d.game.gotoIndex(0);let h=g.getGifDelays(500,f,0,!0);this.modules[a].timerAutoplay.runArray(h)}}.bind(this))).runOnce(4*e)):d.game.gotoNext()}.bind(this));this.modules[a].timerAutoplay.runArray(b);return!0}fnCursorUp(a){this.modules[a].nota&&
6195this.modules[a].nota.handleCursorUp()}fnCursorDown(a){this.modules[a].nota&&this.modules[a].nota.handleCursorDown()}fnStartAnalysis(a){-1==this.nActivePlugin&&(this.nActivePlugin=a);this.modules[a]&&this.modules[a].getKernel()&&this.modules[a].getKernel().Vp.startEngine(a)}stopEngine(a){this.modules[a].getKernel()&&this.modules[a].getKernel().Vp.stopEngine(a)}stopAllEngines(a){this.modules[a].kernel.forEach(function(b){b.Vp.stopEngine(a)})}fnToggleAnalysis(a){if(this.modules[a])if(this.canUseEngine()){this.nActivePlugin=
6196a;let b=this.modules[a].getKernel().Vp;b.toggleEngine&&(b.toggleEngine(a)||this.closeEnginePanel())}else this.modules[this.nActivePlugin].engineOpen?this.closeEnginePanel():(LogStats("Engine"),this.openEnginePanel(this.nActivePlugin),this.modules[this.nActivePlugin].enginePanel.displayInfo("Sorry, you cannot run an engine in this browser yet. On Mac, please try Chrome. Thank you.","cbEngineWarnBrowser"))}fnIncMultiVars(a,b){this.modules[a].getKernel().Vp.incNMultiVars(b);this.multiVarGate.exec(function(){this.stopHints(a);
6197this.modules[a].getKernel().Vp.goAll()}.bind(this),300)}stopHints(a){this.modules[a].getKernel().Vp.stopHints&&this.modules[a].getKernel().Vp.stopHints();(a=this.getEngineElement())&&a.setHintMode(!1)}fnToggleThreat(a){this.threatGate.exec(function(){this.stopHints(a);this.modules[a].getKernel().Vp.toggleThreat()}.bind(this),300)}fnToggleHints(a){this.hintGate.exec(function(){if(this.modules[a].getKernel().Vp.toggleHints){let b=this.modules[a].getKernel().Vp.toggleHints(),c=this.getEngineElement();
6198c&&c.setHintMode(b)}}.bind(this),300)}fnFlipBoard(a){let b=this.modules[a].getKernel().boardWin;if(b){let c=$(b.cbcanvas.canvas);c.addClass("flip");(new Timer(function(){c.removeClass("flip");b.flipBoard()})).runOnce(400)}}fnDeskLayout(a){switch(this.layout){default:case ReaderLayout.DESK_SPLITTED:this.switchDeskLayout(ReaderLayout.DESK_SWIPED,a);break;case ReaderLayout.DESK_SWIPED:this.switchDeskLayout(ReaderLayout.DESK_SPLITTED,a)}}fnNotaToDesk(a){this.floatBoard[a]&&this.floatBoard[a]._fnClose();
6199this.recreateTournament("pgn",!1)}fnDeskToNota(a){this.recreateTournament("nota",!1)}fnSettings(a,b){if(this.modules[a]){let c=this.engBelowNota;this.createSettingsForm(this.modules[a].pluginDiv,function(d){this.sound=d.idSound;glApp.chessAudio&&glApp.chessAudio.enable(this.sound);let e=[CommandIds.PIECES2D_FRITZ,CommandIds.PIECES2D_CRYSTALS_WOOD,CommandIds.PIECES2D_USCF,CommandIds.PIECES2D_OLDSTYLE,CommandIds.PIECES2D_WORLDCHESS][d["idPieces-inx"]];this.biggerFonts=d.idFonts;this.engBelowNota=d.idEngBelowNota;
6200let f=d.idLayBoards;f&&(this.nUserBoardsDesk=f,this.boardsSameSize=d.idBoardsSame);c!=this.engBelowNota?this.checkRecreateOrientation(!0):(e&&glSettings.changeBoardStyle(e),f&&this.configBoards(a),this.isPureNota(a)?this.resizePureNota(a):this.resizeNotaMobile(a))}.bind(this),b)}}fnFloatMaximize(a){this.floatBoard[a]&&this.floatBoard[a].toggleMaxi()}fnUserLayout(a,b){this.createUserLayoutForm(this.modules[a]?.pluginDiv,function(c){this.nUserBoards=c.idLayBoards;this.nUserNota=c.idLayNota;c=ReaderLayout.USER_LAYOUT;
62014==this.nUserBoards&&(c=ReaderLayout.MULTI_BOARD_4);this.switchLayout(c,a)}.bind(this),b)}hasEngBelowNota(a){return this.engBelowNota&&!this.isVideo(a)}configDesktopLayout(a,b){this.createDesktopLayoutForm(this.modules[a]?.pluginDiv,function(c){this.boardsSameSize=c.idBoardsSame;this.nUserBoardsDesk=c.idLayBoards;this.configBoards(a)}.bind(this),b)}configBoards(a){let b=this.modules[a]?.multiBoard;if(b){let c=$("#boardHolder"+a).width(),d=$("#boardHolder"+a).height();this.adaptMaxKernels(a,c,d);b.setBoardsSameSize(this.boardsSameSize)}}fnSound(a){if(glApp.chessAudio)for(glApp.chessAudio.enable(!glApp.chessAudio.isEnabled()),
6202this.sound=glApp.chessAudio.isEnabled(),a=0;a<this.soundBtnSelector.length;a++)this.buttonImages[a].SoundOn=glApp.chessAudio.isEnabled()?"SoundOn":"SoundMute",this.setButtonImages("b",this.boardBtns[a],this.getButtonConfig().getBtnHBoard(),this.getButtonConfig().getCssBoard(),a,"Reader")}fnStart(a){this.recorder[0].start()}fnLike(a){var b=this.modules[a].getKernel().Vp.videoid;if(b){var c="";glApp.isLoggedIn()&&glApp.Vn.userName&&(c=glApp.Vn.userName);b=this.baseurl+"Replay/ToggleLike?id="+encodeURIComponent(b)+
6203"&user="+c;$.get(b,function(d){d&&(this.fnHint(d,a),this.setLike(a))}.bind(this)).fail(function(d){alert("Liked")}.bind(this))}}setLike(a){var b=this.modules[a].getKernel().Vp.videoid;if(b){var c="";glApp.isLoggedIn()&&glApp.Vn.userName&&(c=glApp.Vn.userName);b=this.baseurl+"Replay/GetMetaData?id="+encodeURIComponent(b)+"&user="+c;$.get(b,function(d){this.buttonImages[a]&&(this.buttonImages[a].Like=0<d.Like.length?"Liked":"Like",this.setButtonImages("b",this.boardBtns[a],this.getButtonConfig().getBtnHBoard(),
6204this.getButtonConfig().getCssBoard(),a,"Reader"))}.bind(this)).fail(function(d){alert("Liked")}.bind(this))}}
6204fnShareBoard(a){let b=this.getStrToMove(a);this.doShareBoard(a,{players:!0,toMove:b,share:!0})}getStrToMove(a){return this.modules[a].getKernel().getCurPos().getBTM()?lm.BLACKS_MOVE:lm.WHITES_MOVE}fnShareBoardUser(a,b){if(this.modules[a]){let c=this.getStrToMove(a);this.createShareForm(a,this.modules[a].pluginDiv,function(d){this.doShareBoard(a,{players:d.idPlayers,photos:d.idPhotos,save:d.idSave,
6205text:d.idText,toMove:c,share:!0})}.bind(this),b)}}doShareBoard(a,b){if(window.Blob){var c=this.modules[a].getKernel();let e=this.createTempCanvas(700,c.game,c.boardWin.blackIsBottom);var d=e.control.boards[0];if(d){function f(g,h){var k=c.game.hdr.getStrPlayers(!1,0),l=k+".png";if(g=CanvasTools.imgToBlob(g,h.w,h.h)){h=[new File([g],l,{type:"image/png"})];let m=!0;if(b.share&&navigator.canShare&&navigator.canShare({files:h}))try{if(navigator.share({files:h,title:k,text:b.text}),m=!1,!System.isMobile()||
6206System.runsOnLocalHost())m=!0}catch(n){console.log(n)}(m||b.save)&&window.saveAs(g,l);k=c.game.getCurPos().toDescriptiveString();k=String.f("https://dia.chessbase.com?pos='{0}'",k)+"&buttons=true&engine=true";System.copyToClipboard(k);document.body.removeChild(e.canvas);e.destroyDOM()}}if(b.players||b.text)d.redrawWithPlayers(f,function(g){return this.getFlagAndPic(g,a)}.bind(this),b);else{let g=d.getOuterRect();d=d.cbcanvas.bufferCtx.getImageData(g.left,g.top,g.w-1,g.h-1);f(d,g)}}}}shareDiaLinkUser(a,
6207b){let c=this;this.modules[a]&&this.createShareDiaForm(a,this.modules[a].pluginDiv,function(d){d=this.shareDiaLink(a,{title:d.idTitle,description:d.idDescription,engine:d.idEngine});c.closeFloatBoard(a);window.open(d,"_blank").blur();window.focus()}.bind(this),b)}shareDiaLink(a,b){if(window.Blob&&(a=this.modules[a].getKernel(),a.boardWin)){var c=a.game.getCurPos().toDescriptiveString();a=a.game.hdr.getStrPlayers(!1,0);c=String.f("https://dia.chessbase.com?pos='{0}'",c);let d=a.replace(" ","_");b.title&&
6208(d=b.title);d&&(c+="&title64="+StrUtil.base64.encode(d));b.description&&(c+="&descr64="+StrUtil.base64.encode(b.description));a||="Diagramlink";c=b.engine?c+"&engine=true":c+"&engine=false";return this.saveShareAndCopyUrl([c],"Dia-"+a,"")}}fnShareGifUser(a,b,c){if(this.modules[a]){let d=new Analyser(this.modules[a].getKernel());this.createGifForm(a,this.modules[a].pluginDiv,function(e){let f={players:e.idPlayers,hgt:100*e.idPixels,black:e.idBlack,share:c,analyser:d,firstMove:0,useThinkTimes:e.idThinkTimes,
6209grey:e.idGrey};switch(e.idSpeed){case 0:f.minTime=700;f.maxTime=3E3;break;default:case 1:f.minTime=1E3;f.maxTime=6E3;break;case 2:f.minTime=1E3,f.maxTime=12E3}f.toMove=d.game.hdr.getCBResult().toString();this.shareGif(a,f)}.bind(this),b,d.hasThinkTimes(0))}}createTempCanvas(a,b,c){var d=document.createElement("canvas");d.id="gifCanvas";d.width=a;d.height=a;document.body.appendChild(d);let e=new Game,f=new GameKernel(null,e),g=this.createReaderMode(f);f.setPlayingMode(g);d=new CBCanvas2D(d.id,f,{topDist:2,
6210bottomDist:2,marginDistDivisor:50,bigCoords:!1,shiftXPercent:0,minWForCoordinates:280,boardShadow:!1,noToMoveBulge:!0});d.resizeTimer.stop();d.resizeHdl(a,a);e.assign(b);b=d.control.boards[0];b.setPosSize(new CBPoint(0,0),new CBSize(a,a));b.resizeTimer.stop();$(d.canvas).hide();f.boardWin.setBlackIsBottom(c);return d}shareGif(a,b){if(window.Blob){let e=this;var c=this.modules[a].getKernel();let f=this.createTempCanvas(b.hgt+20,c.game);var d=f.control.boards[0];if(d){b.black&&d.flipBoard();let g=glSettings.boardTextureId;
6211$(e.modules[a].pluginDiv).css("cursor","wait");function h(k,l){l=b.analyser.getGifDelays(b.minTime,b.maxTime,b.firstMove,b.useThinkTimes);b.analyser.destructor();var m=imagesToGif(k,l,b.firstMove);$(e.modules[a].pluginDiv).css("cursor","auto");k=c.game.hdr.getStrPlayers(!1,0);l=k+".gif";m=new Blob([m],{type:"image/gif"});var n=[new File([m],l,{type:"image/gif"})];if(b.share&&navigator.canShare&&navigator.canShare({files:n}))try{navigator.share({files:n,title:k})}catch(r){console.log(r)}window.saveAs(m,
6212l);(k=e.getLiveChessUrl(a))?System.copyToClipboard(k):(k=PGNWriter.toPGN(c.game),System.copyToClipboard(k));glApp.setBoardTextures(g);e.resizePlugin($(e.modules[a].pluginDiv),a);document.body.removeChild(f.canvas);f.destroyDOM()}glSettings.boardTextureId=null;glApp.setBoardTextures(b.grey?CommandIds.BOARD2D_GRAY:CommandIds.BOARD2D_BLUE);glApp.Vh.callOnSquaresLoaded=function(){d.replayToImages(h,function(k){return e.getFlagAndPic(k,a)}.bind(e),b)}}}}getFlagAndPic(a,b){return this.modules[b].nota?this.modules[b].nota.notaHeaderElement.getFlagAndPic(a):
6213{}}fnHint(a,b){this.modules[b].getKernel().boardWin&&(this.modules[b].getKernel().boardWin.addMessage(a,!0),(new Timer(function(){this.modules[b].getKernel().boardWin.destroyMessage()}.bind(this))).runOnce(4E3))}fnHelp(a,b){this.modules[b].getKernel().Vp.showDiagramHelp(a)}fnSolution(a,b){if(this.modules[b].getKernel().boardWin&&4==a.length){var c=CBSquare.fromString(a.substring(0,2));a=CBSquare.fromString(a.substring(2,4));this.modules[b].getKernel().boardWin.drawArrow(c,a,"hsla( 120, 70%, 50%, 0.9 )")}}loadPrevGame(a){if(this.modules[a].pgnDatabase){var b=
6214this.modules[a].getKernel().game.gameNo-1;if(!b||1>b)b=this.modules[a].pgnDatabase.getGameCount();var c=this.modules[a].pgnDatabase.getGame(b);this.loadGame(c,a,b,!0)}else if(b=this.modules[a].getKernel().idGame)if(c=this.modules[a].list,1<c.length){for(var d=!1,e=1;!d&&e<c.length;e++)c[e].id==b&&(b=c[e-1].id,this.fnLoadLiveGame(b,a),d=!0);d||c[c.length-1].id==b||this.fnLoadLiveGame(c[c.length-1].id,a)}}loadNextGame(a){if(this.modules[a].pgnDatabase){var b=this.modules[a].getKernel().game.gameNo+
62151;if(!b||b>this.modules[a].pgnDatabase.getGameCount())b=1;var c=this.modules[a].pgnDatabase.getGame(b);this.loadGame(c,a,b,!0)}else if(b=this.modules[a].getKernel().idGame){c=this.modules[a].list;for(var d=!1,e=0;!d&&e<c.length-1;e++)c[e].id==b&&(b=c[e+1].id,this.fnLoadLiveGame(b,a),d=!0);d||c[0].id==b||this.fnLoadLiveGame(c[0].id,a)}}onWindowResize(){if(this.modules&&null!=this.modules[0]&&this.isOfflineVideo(0)){var a=$(this.allPluginClasses);$(a[0]).offset({top:0,left:0});$(a[0]).css("top",0);
6216$(a[0]).css("left",0)}}
6216fnFullWindow(a){if(!this.isMobileLayout()){this.stopShakeFullWinBtn(a);var b=$(this.allPluginClasses);if(b&&b[a]){var c=0,d=0;this.maximized!=a&&0<=this.maximized&&this.fnFullWindow(this.maximized);if(this.maximized==a)this.setFullWinBtnImage(a,!0),this.maximized=-1,$(b[a]).css("max-width",this.storeMaxWidth),$(b[a]).css("max-height",this.storeMaxHeight),$(b[a]).css("box-shadow",this.storeShadow),$(b[a]).width(this.storeWidth),$(b[a]).height(this.storeHeight),$(b[a]).offset({top:this.storeOffset.top,
6217left:this.storeOffset.left}),$(b[a]).css("z-index","1"),c=this.storeWidth,d=this.storeHeight,System.isElectron()?($(b[0]).offset({top:0,left:0}),$(b[0]).css("top",0),$(b[0]).css("left",0)):$("#root"+a).jqxSplitter({panels:this.storePanels});else{this.setFullWinBtnImage(a,!1);this.storeWidth=$(b[a]).width();this.storeHeight=$(b[a]).height();this.storeOffset=$(b[a]).offset();this.storeMaxWidth=$(b[a]).css("max-width");this.storeShadow=$(b[a]).css("box-shadow");this.storePanels=$("#root"+a).jqxSplitter("panels");
6218this.maximized=a;c=Math.min(1900,window.innerWidth-2*Math.min(30,Math.round(.05*window.innerWidth)));d=window.innerHeight-10;let e=$(".navbar-header").height();d-=e;$(b[a]).css("max-width",c);$(b[a]).css("max-height",d);$(b[a]).css("box-shadow","1px 1px 12px 2px hsla( 0, 0%, 0%, 0.35 )");$(b[a]).width(c);$(b[a]).height(d);$(b[a]).offset({top:window.pageYOffset+2+e,left:4+(window.innerWidth-c)/2});$(b[a]).css("z-index","100");System.isElectron()&&($(b[a]).css("max-width",screen.availWidth),$(b[a]).css("max-height",
6219screen.availHeight-64),$(b[a]).width(screen.availWidth),$(b[a]).height(screen.availHeight-64),$(b[a]).offset({top:0,left:0}),d=screen.availHeight-64,c=screen.availWidth);System.isIPad()&&($(b[a]).css("max-width",screen.availWidth),$(b[a]).css("max-height",screen.availHeight-64)-128,$(b[a]).width(screen.availWidth),$(b[a]).height(screen.availHeight-64-128),$(b[a]).offset({top:0,left:0}),d=screen.availHeight-64-128,c=screen.availWidth);this.nActivePlugin=a;this.shouldDoBigMultiBoard(a,c,d)&&($("#root"+
6220a).jqxSplitter({panels:[{size:"68%",collapsible:!1},{size:"32%",collapsible:!1}]}),700>d&&$("#westNest"+a).length&&$("#westNest"+a).jqxSplitter({panels:[{size:"60%",collapsible:!1},{size:"40%",collapsible:!1}]}));LogStats("FullWin")}$("#root"+a).jqxSplitter({width:c+"px",height:d+"px"});this.resizePlugin($(b[a]),a);this.splitterGateRoot.exec(function(){return function(){this.onSplitterResize(a,this.isLive(a))}.bind(this)}.call(this,a),300);$("#root"+a).jqxSplitter("refresh");$("westNest"+a).length&&
6221($("#westNest"+a).jqxSplitter("refresh"),$("#eastNest"+a).jqxSplitter("refresh"),$("#eastUpDownNest"+a).jqxSplitter("refresh"))}}}shouldDoBigMultiBoard(a,b,c){return!this.isMobileLayout()&&this.isLive(a)&&1200<b&&700<c&&3<=this.modules[a].list.length}fnSelectNota(a,b){(new Timer(function(){this.notaSwiper[a]&&this.notaSwiper[a].slideTo(this.swpNota[a],b||300)}.bind(this))).runOnce(10)}
6221fnSelectEngine(a,b){(new Timer(function(){this.notaSwiper[a]&&(this.layout==ReaderLayout.MULTI_BOARD_2?this.showEngineFlex(a):
62220<=this.swpEng[a]&&this.notaSwiper[a].slideTo(this.swpEng[a],b||200))}.bind(this))).runOnce(10)}fnSelectList(a){this.notaSwiper[a]&&0<=this.swpList[a]&&this.notaSwiper[a].slideTo(this.swpList[a],200)}fnSelectVideo(a){(new Timer(function(){this.notaSwiper[a]&&this.notaSwiper[a].slideTo(this.swpVideo[a],200)}.bind(this))).runOnce(10)}fnSelectBack(a){document.exitFullScreen&&document.exitFullScreen();document.location="https://live.chessbase.com"}onOrientationChange(a){0<=this.maximized&&this.fnFullWindow(this.maximized);
6223this.checkRecreateOrientation()}fnNotaSave(a){this.fnSave(a,!0)}fnOnlineDB(a){var b=$(this.allPluginClasses);b&&b[a]&&(System.isElectron()||glApp.saveGameToLocalStorage(),window.location="https://database.chessbase.com?ref=pgn")}fnMyGames(a){this.modules[a].getKernel().Vp.saveToCloud(!0)||5;var b=$(this.allPluginClasses);b&&b[a]&&(glApp.saveGameToLocalStorage(),window.location="http://mygames.chessbase.com?ref=pgn")}fnFritz(a){var b=$(this.allPluginClasses);b&&b[a]&&glApp.passToFritzOnline(this.modules[a].getKernel().game)}checkGAs(a){if(System.isElectron()){var b=
6224a,c=a.lastIndexOf("/");-1!=c&&(b=a.substr(c+1));this.readerHelper.readGameActionFileList(function(){this.readerHelper.isFileAvailable(b,this.onGaAvailable.bind(this))}.bind(this))}else try{var d=new XMLHttpRequest;d.open("GET",a,!1);d.onreadystatechange=function(){if(4===d.readyState&&(200===d.status||0==d.status)){this.gameactions=[];for(var e=d.responseText.split("\r\n"),f=0;f<(e.length-1)/2;f++){var g=e[2*f],h=e[2*f+1],k=new ScriptCommand;k.fromString(g,h);this.gameactions.push(k)}}}.bind(this);
6225d.send(null)}catch(e){LogException("RM:checkGAs",e)}}fnPromoteLine(a){this.modules[a].undo.push(ObjUtil.clone(this.modules[a].getKernel().game));this.modules[a].getKernel().Vp.onPromoteLine()&&this.modules[a].getKernel().game.promoteLine()}fnDeletePrevious(a){this.modules[a].undo.push(ObjUtil.clone(this.modules[a].getKernel().game));this.modules[a].getKernel().Vp.onDeletePrevious()&&this.modules[a].getKernel().game.deletePrevious()}fnZapRest(a){this.modules[a].undo.push(ObjUtil.clone(this.modules[a].getKernel().game));
6226this.modules[a].getKernel().Vp.onCutLine()&&this.modules[a].getKernel().game.deleteRemaining()}fnDeleteLine(a){this.modules[a].undo.push(ObjUtil.clone(this.modules[a].getKernel().game));this.modules[a].getKernel().Vp.onDeleteLine()&&this.modules[a].getKernel().game.deleteLine()}fnUndo(a){if(this.modules[a].undo.length){var b=this.modules[a].undo.pop();this.modules[a].redo.push(ObjUtil.clone(this.modules[a].getKernel().game));this.modules[a].getKernel().game.assign(b)}}fnRedo(a){if(this.modules[a].redo.length){var b=
6227this.modules[a].redo.pop();this.modules[a].undo.push(ObjUtil.clone(this.modules[a].getKernel().game));this.modules[a].getKernel().game.assign(b)}}fnUnannotate(a){this.modules[a].undo.push(ObjUtil.clone(this.modules[a].getKernel().game));this.modules[a].getKernel().Vp.saved=!1;this.modules[a].getKernel().game.unAnnotate()}fnEmbed(a){this.isLive(a)?window.open("https://docu.chessbase.com/reader/cblive.html"):window.open("https://docu.chessbase.com/reader/cbreplay.html")}fnLivePlaychess(a){window.open("http://live.playchess.com")}onNotaClickListener(a,
6228b){this.nActivePlugin=a;this.stopAutoplay(-1==this.nActivePlugin?0:this.nActivePlugin);if(this.closeHamburger[this.nActivePlugin])this.closeHamburger[this.nActivePlugin]();if(this.isPureNota(a)){let c=this.calcFloatBoardW(b.l,b.w);if(this.floatBoard[a])this.floatBoard[a].checkPosition(b);else{let d=this.modules[a].getKernel().game.hdr.getStrPlayers(!1,300>c?1:99);for(let e=0;e<this.floatBoard.length;e++)this.floatBoard[e]&&this.floatBoard[e]._fnClose();this.floatBoard[a]=this.createFloatBoard(a,this.modules[a].getKernel(),
6229d,c,c,b,function(e){this.stopEngine(e);this.closeEnginePanel();this.floatBoard[e]=null}.bind(this))}this.modules[a].nota.focus()}}calcFloatBoardW(a,b){var c=.6;System.isMobile()&&950>screen.width&&(c=.7);c=Math.min(Math.min(b,600),Math.max(260,b*c));return c=Math.max(c,Math.min(.5*window.innerHeight,window.innerWidth-(a+b)-20))}isFinished(a,b){if(a=this.modules[a].list)for(var c=0;c<a.length;c++)if(a[c].id===b)return 3>a[c].result}onGameEval(a,b,c){0<=a&&(this.isFinished(a,c)||this.setResultStat(a,
6230c,Evaluation.getListIcon(b.value)))}onLiveGameStatus(a,b){var c=this.modules[a].getKernelOfIdGame(b.idGame);if(c){var d={value:b.eval};c.boardWin&&(c.boardWin.displayEvaluation(!0,d),c.game.hasTBEval=!0,c.game.fireOnEval(1,b.eval,b.idGame));c=c.game.getMoves().length;this.onGameEval(a,{value:b.eval},b.idGame);b.isBlunder()?this.setGameStat(a,b.idGame,"blunder"):b.isTactics()?this.setGameStat(a,b.idGame,"tactics"):b.isMate(
6230)?this.setGameStat(a,b.idGame,"mate"):b.isAttack(0,c)?this.setGameStat(a,b.idGame,
6231"wAttacks"):b.isAttack(1,c)?this.setGameStat(a,b.idGame,"bAttacks"):b.isSharp()?this.setGameStat(a,b.idGame,"fire"):b.isOutpost(0,c)?this.setGameStat(a,b.idGame,"wKnights"):b.isOutpost(1,c)?this.setGameStat(a,b.idGame,"bKnights"):b.isActivity(0)?this.setGameStat(a,b.idGame,"wActivity"):b.isActivity(1)?this.setGameStat(a,b.idGame,"bActivity"):b.isEndgame()?this.setGameStat(a,b.idGame,"endgame"):this.setGameStat(a,b.idGame,void 0)}}handleKeyDown(a,b){if(this.instantiated&&-1!=this.nActivePlugin&&this.enableShortcuts){var c=
6232!0;switch(a.key){default:c=!1;break;case "[":this.fnDeletePrevious(b);break;case "]":this.fnZapRest(b)}if(!c)switch(c=!0,a.which){default:c=!1;break;case 13:c=!1;break;case 27:this.maximized==b&&this.fnFullWindow(b);this.modules[b].timerAutoplay&&this.fnAutoplay(b,a);break;case 37:this.fnRetract(b);break;case 39:this.fnExec(b);break;case 38:a.altKey?this.fnPromoteLine(b):this.fnCursorUp(b);break;case 40:this.fnCursorDown(b);break;case 46:this.fnDeleteLine(b);break;case 91:this.fnDeletePrevious(b);
6233break;case 93:this.fnZapRest(b);break;case 65:a.ctrlKey||(c=!1);break;case 66:a.ctrlKey?this.fnFlipBoard(b):c=!1;break;case 81:a.ctrlKey&&this.createQRCode(b,null,!0);break;case 83:a.ctrlKey?this.fnSave(b,!0):c=!1;break;case 89:a.ctrlKey?a.shiftKey?this.fnUnannotate(b):this.fnRedo(b):c=!1;break;case 90:a.ctrlKey?this.fnUndo(b):c=!1;break;case 113:a.altKey?this.fnToggleAnalysis(b):c=!1;break;case 122:a.ctrlKey||a.shiftKey?this.loadPrevGame(b):this.loadNextGame(b);break;case 187:this.fnIncMultiVars(b,
62341);break;case 189:this.fnIncMultiVars(b,-1);break;case 120:this.test(b)}c&&a.preventDefault();return c}}deleteRoot(a){$("#cbcaption"+a).remove();$("#rootParent"+a).remove()}test(a){}isMaximized(){return this.maximized==this.nActivePlugin}getFnKernelInitGame(a,b){return function(c){if(this.modules&&this.modules.length){var d=this.modules[b].pgnDatabase;d&&c.assign(d.getGame(1),!0)}}}getFnKernelInitDiagram(a,b,c,d){return function(e){e.reset();if(a){var f=a.dataset.fen;if(f)f=new Position(f),f=new Game(f),
6235c.addColoredAnnos(a,f),e.assign(f);else{var g=a.dataset.pos;g?(f=new Position,f.initString(g),f=new Game(f),c.addColoredAnnos(a,f),e.assign(f)):(f=a.dataset.moves)?(e.assign(PGN.parseGame(f)),e.gotoIndex(e.getMainLine().length)):d&&(e=new PgnDatabase(d),c.modules[b].pgnDatabase=d,f=e.getGame(1),c.modules[b].pgnTitle=f.hdr.getStrPlayers(!1,0)+".pgn",c.modules[b].getKernel())}}}}modifyPlayingModeForTraining(a,b,c){if((a=a.dataset.solution)&&4==a.length){var d=CBSquare.fromString(a.substring(0,2)),e=
6236CBSquare.fromString(a.substring(2,4)),f=new Timer(function(){c.boardWin.destroyMessage()});c.Vp.fnAcceptMove=function(g){if(0<c.game.getMoveIndex())return!0;f.runOnce(2E3);if(g.from!=d||g.to!=e)return c.boardWin.addMessage("Wrong Move, sorry",!0),!1;c.boardWin.addMessage("Correct!",!0);return!0}.bind(this)}}addColoredAnnos(a,b){var c=a.dataset.arrows;a=a.dataset.squares;if(c){c=c.split(",");for(var d=new ColArrowAnno,e=0;e<c.length;e++){var f=c[e];if(4==f.length){var g=CBSquare.fromString(f.substring(0,
62372));f=CBSquare.fromString(f.substring(2,4));g=new ColArrow(g,f,BoardColor.BLUE);d.push(g)}}d.length&&b.setAnnoBeforeFirstMove(AnnoType.ARROW_LIST,d,!0)}if(a){a=a.split(",");e=new ColSqAnno;for(c=0;c<a.length;++c)d=a[c],2==d.length&&(d=CBSquare.fromString(d),d=new ColSq(d,BoardColor.GREEN),e.push(d));e.length&&b.setAnnoBeforeFirstMove(AnnoType.SQUARE_LIST,e,!0)}}textToPgn(a,b,c,d,e){if(c){var f=new PgnDatabase(c);this.pluginDivPgn[b]=c;this.modules[b].pgnDatabase=f;this.modules[b].pgnTitle=d;a.dataset.downloadtitle&&
6238(this.modules[b].pgnTitle=a.dataset.downloadtitle);d=c=!1;1<f.getGameCount()||this.isSwipedLayout()?(c=e(f,b,this.loadGame.bind(this)),d=!0):this.resizePlugin($(a),b);c||("no"!=a.dataset.autoplay&&1<f.getGameCount()&&!d?this.modules[b].getKernel().Vp.loadGame(this.modules[b].pgnDatabase.getGame(0)):d||(this.modules[b].getKernel().Vp.loadGame(this.modules[b].pgnDatabase.getGame(1)),0<a.dataset.move&&this.modules[b].getKernel().game.gotoIndex(a.dataset.move)));this.setSingleGameCaption(this.modules[b].getKernel().game,
6239b)}}createPgnDatabase(a,b,c,d){if(a){var e=a.dataset.url;e||=StrUtil.getURLParam("url");e?$.get(e,f=>{this.textToPgn(a,c,f,e,b)}).fail(function(f){this.resizePlugin($(a),c)}.bind(this)):d&&(d=new PgnDatabase(d),this.modules[c].pgnDatabase=d,1<d.getGameCount()||this.isSwipedLayout()?b(d,c,this.loadGame.bind(this)):(this.resizePlugin($(a),c),System.isElectron()&&"undefined"!==typeof electronBridge&&electronBridge.setReplayTouchBar(glApp,"Replay")),d=this.modules[c].pgnDatabase.getGame(1),this.modules[c].pgnTitle=
6240d.hdr.getStrPlayers(!1,0)+".pgn",this.modules[c].getKernel().Vp.loadGame(d),this.setSingleGameCaption(d,c),this.pgnStartMoveIndex&&this.modules[c].getKernel().game.gotoIndex(this.pgnStartMoveIndex),!this.modules[c].getKernel().hasTraining()&&0<parseInt(a.dataset.autoplay)&&(this.modules[c].runAutoplayTimer=new Timer(function(){this.fnAutoplay(c,null,a.dataset.autoplay)}.bind(this)),this.modules[c].runAutoplayTimer.runOnce(1E4)))}}createVideoDatabase(a,b,c,d){if(a){this.baseurl=glApp.config.getVideoPortalUris()[0];
6241d=a.dataset.id;var e="";d&&(e=this.baseurl+"public/video?id="+encodeURIComponent(d));var f=a.dataset.show;f&&(e=this.baseurl+"public/GetVideosFromShow?id="+f,this.show=f);$.get(e,function(g){if(g)try{this.modules[c].videoDatabase=g,"Training PositionVideo"===g.Category&&(this.modules[c].getKernel().PositionMode=!0),b(g,c,this.loadVideoGame.bind(this)),this.resizePlugin($(a),c),f&&this.checkShowIsLive
6241(c)}catch(h){alert(h.message)}}.bind(this))}}createOfflineVideoDatabase(a,b,c,d){if(a){var e=a.dataset.id,
6242f={},g=[];if(e.endsWith(".txt")){e.split("/");this.modules[c].getKernel().OfflineInteractive=!0;var h=new XMLHttpRequest;h.open("GET",e,!0);h.onreadystatechange=function(){if(4===h.readyState&&(200===h.status||0==h.status)){this.modules[c].cmsiManager=new CMSIManager;for(var k=h.responseText.split("\r\n"),l=0;l<k.length;l++){var m=k[l];if(-1!=m.indexOf(".mp4")||-1!=m.indexOf(".mp3")){var n=m.indexOf("<"),r=m.indexOf(">");if(0<r&&(n=m.substr(n+1,r-n-1),0<n.length)){n=e.replace("FileNameToTitle.txt",
6243n);r="";var t=n.lastIndexOf("/");-1!=t&&(r=n.substr(t+1));t=r;var u=e.lastIndexOf("/");this.modules[c].baseDir=e.substr(0,u)+"/";this.modules[c].cmsiManager.addFile(t);0==this.modules[c].cmsiManager.extractStateFromFileName(r)&&(r={},r.Name=n,t=m.indexOf("["),u=m.indexOf("]"),0<u&&(r.Name=m.substr(t+1,u-t-1)),r.Id=n,r.url=n,r.gameId=n,g.push(r))}}}f.results=g;this.modules[c].offlinevideoDatabase=f;b(f,c,this.loadOfflineVideoGame.bind(this));this.resizePlugin($(a),c)}}.bind(this);h.send(null)}else this.modules[c].getKernel().OfflineInteractive=
6244!1,d={},d.Name=e,d.Id=e,d.url=e,d.gameId=e,g.push(d),f.results=g,this.modules[c].offlinevideoDatabase=f,b(f,c,this.loadOfflineVideoGame.bind(this)),this.resizePlugin($(a),c)}(new Timer(function(){var k='<div class="cbreplayInfo" id="replayinfo{0}">'+lm.CLICK_ENGINE_TO_ANALYSE;$("#engineEl0").html(k)}.bind(this))).runOnce(1E3)}getVideoShow(){}loadTableData(a,b){if(a){$(a).html('<div style= "font-size:large;margin-left:auto;margin-right:auto;margin-top:20px;margin-bottom:20px">Loading Table...</div>');
6245var c=a.dataset.url,d=a.dataset.name,e=parseInt(a.dataset.top),f=a.dataset.round||1E5,g=a.dataset.tbs,h=a.dataset.caption,k=a.dataset.pic,l=a.dataset.pw||1,m=a.dataset.pd||.5,n=a.dataset.pl||0;c||=String.f("{0}/results/{1}/all",glApp.config.getLiveResult(),d);var r={caption:h,withPic:k};c&&$.get(c,function(t){if(t){var u={round:f,top:e,tbs:g,pointsWin:parseFloat(l),pointsDraw:parseFloat(m),pointsLoss:parseFloat(n)};this.createCrossTable(a,b,t,u,r)}}.bind(this))}}loadPairingData(a,b){if(a){var c=a.dataset.name,
6246d=parseInt(a.dataset.top),e=a.dataset.round||3E4,f=a.dataset.pw||1,g=a.dataset.pd||.5,h=a.dataset.pl||0;(c=String.f("{0}/results/{1}/all",glApp.config.getLiveResult(),c))&&$.get(c,function(k){if(k)var l={round:e,top:d,pointsWin:parseFloat(f),pointsDraw:parseFloat(g),pointsLoss:parseFloat(h)};this.createPairings(a,b,k,l,{})}.bind(this))}}selectOrAddBoard(a,b,c){if(this.modules[a].useFirstBoard)return this.modules[a].useFirstBoard=!1,this.modules[a].kernel[0].setIdGame(b),this.modules[a].kernel[0].idKernel;
6247if(this.modules[a].kernel.length<this.modules[a].maxKernels){c=this.modules[a].addKernel(this);c.idGame=b;var d=this.modules[a].boardArea.canvas,e=this.createBoardWin(d,this.getMultiBoardOptions(),a);e.animateBoard=!1;c.setBoardWin(e);c.Vp.createGUIElements(e);d.control.addBoard(e,b);1==this.modules[a].kernel.length&&this.modules[a].nota.setGame(c.game);b=$("#boardHolder"+a).width();d=$("#boardHolder"+a).height();this.launchResizeBoard(a,b,d,300);return c.idKernel}return-1}fnGetVisibleKernel(a,b,
6248c){a=this.modules[a];if(b)for(var d=0;d<a.kernel.length;d++)if(a.kernel[d].idGame==b)return a.kernel[d];for(d=0;d<a.kernel.length;d++)if(a.kernel[d].idKernel==c)return a.kernel[d]}fnLoadLiveGame(a,b,c,d,e){var f=glApp.panelMgr;if(!e){f.modules[b].nGotoMoveIndex=d;if(f.trySwapWithBigBoard(a,b)){d&&f.fnGetVisibleKernel(b,a,f.modules[b].kernel[f.modules[b].nCurrKernel].idKernel).game.gotoIndex(d);return}for(var g=0;g<f.modules[b].kernel.length;g++)if(f.modules[b].kernel[g].idGame==a){f.changeSelectedGameKernel(a);
6249f.onWatch(b,a);d&&f.fnGetVisibleKernel(b,a,f.modules[b].kernel[f.modules[b].nCurrKernel].idKernel).game.gotoIndex(d);return}}var h=f.selectOrAddBoard(b,a,e);d=0;!c&&0>h&&(d=f.modules[b].getKernel().idGame,f.modules[b].getKernel().setIdGame(a),h=f.modules[b].kernel[f.modules[b].nCurrKernel].idKernel);glApp.lobby.initKibitzingById(a,f.modules[b].ticket,0<=h?function(k){return f.fnGetVisibleKernel(b,k,h)}:null,function(k,l){glApp.panelMgr.onMove(b,k,l)},d,function(k){glApp.panelMgr.onAnno(b,k)},function(k){k.game.idGame=
6250a;let l=f.modules[b];l.gameMap[a]=k.game;if(l.nGotoMoveIndex){var m=f.fnGetVisibleKernel(b,a,h);m&&(m.boardWin&&(m.boardWin.lastGameStat=""),m.game.gotoIndex(glApp.panelMgr.modules[b].nGotoMoveIndex),(new Timer(function(){f.modules[b].nGotoMoveIndex=0})).runOnce(1E3))}f.chat[b]&&!f.modules[b].chatRequested&&(l.chatRequested=!0,glApp.lobby.requestChatLog(l.ticket,a));m=f.isMobileLayout()?"":"Live: ";l.getKernel()&&(f.setCaptionText(m+l.getKernel().game.hdr.event.event,b),f.tbRequest
6250(k.game))});if(0<=
6251h)f.onWatch(b,a)}addGameById(a,b,c){this.fnLoadLiveGame(b,a,!1,c);this.isSelectingLiveGames&&this.showSelectedLiveGames(!0,a)}trySwapWithBigBoard(a,b,c){var d=this.modules[b];if(0==d.nCurrKernel||c)if(c=d.getKernelIndexOf(a),0<c){var e=ObjUtil.clone(d.kernel[0].game),f=d.kernel[0].idGame;d.kernel[0].game.assign(d.kernel[c].game);d.kernel[0].setIdGame(a);d.kernel[c].setIdGame(f);d.kernel[c].game.assign(e);this.changeSelectedGameKernel(a);glApp.lobby.notifySessionSwap(d.ticket,f,a);this.hasChat(b)&&
6252this.guessing[b]&&(this.guessing[b].showGuessMoveElements(),this.guessing[b].requestMoveList(b));return!0}}kibitzSelectedLiveGames(a){if(this.selectedLiveGames){var b=[];this.selectedLiveGames.forEach(function(c){0<c&&b.push(c)}.bind(this));if(b.length){let c=this.modules[a];c.closeAllBoards();this.nUserBoardsDesk=c.maxKernels=b.length;let d=0;b.forEach(function(e){24>=d++&&this.fnLoadLiveGame(e,a)}.bind(this))}}}initAbstractModule(a,b,c){a={pluginDiv:a,ticket:++ReaderPM.staticTicket};a.n=b;a.kernel=
6253[];a.gameMap={};a.nCurrKernel=0;a.useFirstBoard=!0;a.maxKernels=1;a.getKernel=function(d){if("undefined"!=typeof d)for(let e=0;e<this.kernel.length;e++)if(this.kernel[e].idKernel==d)return this.kernel[e];return 0<=this.nCurrKernel&&this.nCurrKernel<this.kernel.length?this.kernel[this.nCurrKernel]:this.kernel[0]};a.addKernel=function(d,e){var f=new GameKernel(d);f.ticket=this.ticket;f.setPlayingMode(c(f));f.pluginCnt=e;f.game.addOnClickInNotationListener(d.onNotaClickListener.bind(d));var g=function(){if(d.getKernel())return d.getKernel().Vp};
6254f.fnBoardFactory=function(h,k,l,m,n){return new ReplayHandlerBoardControl(h,k,l,m,n,g)};f.idKernel=++ReaderPM.staticIdKernel;this.kernel.push(f);return f};a.selectKernelByIdGame=function(d){for(var e=0;e<this.kernel.length;e++)if(this.kernel[e].idGame==d){this.nCurrKernel=e;break}};a.getKernelIndexOf=function(d){for(var e=0;e<this.kernel.length;e++)if(this.kernel[e].idGame==d)return e;return-1};a.getKernelOfIdGame=function(d){for(var e=0;e<this.kernel.length;e++)if(this.kernel[e].idGame==d)return this.kernel[e]};
6255a.removeKernelOfIdGame=function(d){let e=-1;for(var f=0;-1==e&&f<this.kernel.length;f++)this.kernel[f].idGame==d&&(e=f);-1!=e&&this.kernel.splice(e,1)};a.changeNKernels=function(d,e){var f=this.maxKernels;if(d<this.kernel.length){for(var g=d;g<this.kernel.length;g++){var h=this.multiBoard.getBoardByGameId(this.kernel[g].idGame);this.multiBoard.removeBoard(h);glApp.lobby.setSessionToBackground(this.ticket,this.kernel[g].idGame)}e.changeSelectedGameKernel(this.kernel[0].idGame);this.kernel.length=d}this.maxKernels=
6256d;return f};a.closeAllBoards=function(){for(var d=0;d<this.kernel.length;d++){var e=this.multiBoard.getBoardByGameId(this.kernel[d].idGame);this.multiBoard.removeBoard(e);glApp.lobby.setSessionToBackground(this.ticket,this.kernel[d].idGame)}this.kernel=[]};return a}createRequestData(a,b,c,d,e){e={};a.dataset.mymoves?e.myMoves=!0:(e.event=a.dataset.event,e.round=a.dataset.round,e.round2=a.dataset.round2,e.player=a.dataset.player,e.white=a.dataset.white,e.black=a.dataset.black,e.date=a.dataset.date,
6257e.team=a.dataset.team,e.other=a.dataset.other,e.roundstr=a.dataset.roundstr,e.kibitzRank=b,"highest"==e.round||"max"==e.round?(e.round="",e.highestRoundOnly=!0):e.highestRoundOnly=!1,e.sharp=a.dataset.sharp||!1,e.endgame=a.dataset.endgame||!1,e.minElo=a.dataset.minelo||0);e.isList=function(){return!0};e.onList=function(f){if(d.isLive(c)){var g=f();d.modules[c].list=g.games;700<g.games.length&&g.games.splice(700);d.createLiveListGrid.call(d,f,c,d.fnLoadLiveGame.bind(d));d.shakeFullWinBtn(c);let k=
6258g.games.length;for(f=0;f<k;f++){var h=g.games[f];let l=d.getResIcon(h.result);!l&&h.hasLiveGameStatus()&&(h=g.games[f].getEval(),l=Evaluation.getListIcon(h));d.setResultStat(c,g.games[f].id,l);d.setGameStat(c,g.games[f].id,d.getStatIcon(g.games[f].getLiveStatus()))}(new Timer(function(){let l=1;d.modules[c].multiBoard&&(l=d.modules[c].multiBoard.count());(4<g.games.length||1<l&&g.games.length>l)&&d.fnSelectList(c)})).runOnce(1E3)}};return e}loadGame(a,b,c,d,e){b=b||0;d||this.stopAutoplay(b);this.modules[b].getKernel().Vp.loadGame(a);
6259!e&&a&&(System.runsOnBooks()||System.runsOnLocalHost())&&(e=a.detStartMoveFromTraining());e&&(new Timer(function(){this.modules[b].getKernel().game.gotoIndex(e);this.modules[b].nota&&this.modules[b].nota.emphasizeMove()}.bind(this))).runOnce(50);this.modules[b].getKernel().game.gameNo=c;this.setSingleGameCaption(a,b)}loadOfflineVideoGame(a,b){this.gameactions=[];for(b=0;b<a.length;b++){var c=a[b],d=new ScriptCommand;d.time=c.Time;d.type=c.GameActionType;d.action=c.GameActionContent;this.gameactions.push(d)}}loadVideoGame(a,
6260b){if(this.video[b]){this.video[b].gameactions=[];for(var c=0,d=0;d<a.length;d++){var e=a[d],f=new ScriptCommand;f.time=e.Time;f.type=e.GameActionType;var g=new DataBuffer,h=!0;"TEXT"==f.type&&(h=!1);g.constructFromString(e.GameActionContent,h);g.rewind();f.aGA=new GameAction;f.aGA.fromDataBuf(g);e.GameActionContent.length>c&&(c=e.GameActionContent.length);this.video[b].gameactions.push(f)}this.getCMSIFenPositions(b)}}getCMSIFenPositions(a){var b=this.modules[a].getKernel().Vp.videoid;b&&(b=this.baseurl+
6261"Replay/GetCSMIFenPositions?id="+encodeURIComponent(b),$.get(b,function(c){c&&0<c.length&&this.suppressNotationForCMSI(a)}.bind(this)))}suppressNotationForCMSI(a,b){a=this.modules[a].nota;null!=a&&a.suppressNotationForCMSI()}onWatch(a,b){this.modules[a].getKernel()&&(b=this.isMobileLayout()?"":"Live: ",this.setCaptionText(b+this.modules[a].getKernel().game.hdr.event.event,a))}onMove(a,b,c){var d=this.modules[a].getKernelOfIdGame(b);if(d){var e=d.game.hdr.result;2>=e?this.setResultStat(a,b,this.getResIcon(e)):
6262(e=null,c&&c.gameAction.type==GameActionEnum.SETANNOTATION&&c.gameAction.anno&&(e=c.gameAction.anno[AnnoType.SYMBOL]),!e&&d.game.getLastMove()&&(c=d.game.getLastMove().getAnno())&&(e=c[AnnoType.SYMBOL]),e&&e.getEval&&((c=this.getSymAnnoIcon(e.getEval()))||(c=this.getSymAnnoIcon(e.getMark())),this.setResultStat(a,b,c)),this.guessing[a]&&this.guessing[a].requestMoveList(a))}}onAnno(a,b){this.setGameStat(a,b,"anno")}setGameStat(a,b,c){var d=this.modules[a].list;if(d)for(var e=0;e<d.length;e++)if(d[e].id==
6263b){d[e].stat=c;break}if(this.gridCreated[a]&&(d=$('*[data-statIcon="'+b+'"]'),c?d.html(this.getImgTag(c)):d.html(""),this.modules[a].data))for(d=this.modules[a].data,e=0;e<d.length;e++)d[e].id==b&&(d[e].St=c);this.flashBoardStat(a,b,c)}flashBoardStat(a,b,c){let d=this.modules[a].getKernelOfIdGame(b);
6263d&&d.boardWin&&0<=["fire","blunder","mate","tactics","endgame"].indexOf(c)&&(System.isMobile()||d.lastGameStat==c||(d.boardWin.destroySideIcon(),d.boardWin.addSideIcon({url:glApp.config.getExternalCommonPath()+
6264`Media/Ribbons/Reader/Status/${c}${48}.png`,cssClass:null,desiredWidth:0,transition:"left 0.3s, top 0.3s, width 0.2s, height 0.2s",width:48,boardFract:10}),d.lastGameStat=c),(new Timer(function(){d.boardWin.destroySideIcon()})).runOnce(5E3))}setResultStat(a,b,c){var d=this.modules[a].list;if(d)for(var e=0;e<d.length;e++)if(d[e].id===b){d[e].res=c;break}if(this.gridCreated[a]&&(d=$('*[data-resIcon="'+b+'"]'),c?(e=this.getImgTag(c),d.html(e)):d.html(""),this.modules[a].data))for(a=this.modules[a].data,
6265d=0;d<a.length;d++)if(a[d].id==b){a[d].Res=c;break}}setFlags(a,b,c){try{var d=this.modules[a].list||this.modules[a].gridItems;if(d)for(a=0;a<d.length;a++)d[a].reqPBW&&d[a].reqPBW.str===c.str?(d[a].flagw=d[a].FlgW=b,d[a].item&&(d[a].item.FlgW=b)):d[a].reqPBB&&d[a].reqPBB.str===c.str&&(d[a].flagb=d[a].FlgB=b,d[a].item&&(d[a].item.FlgB=b))}catch(e){console.log(e)}}refreshGridIcons(a){}getImgTag(a){return'<img src="'+(glApp.config.getExternalCommonPath()+"Media/Ribbons/Reader/Status/"+a+'16.png" height="16px">')}openEnginePanel(a){var b=
6266document.getElementById("engineEl"+a);if(!b)if(this.isDiagram(a))b=this.createDiagramEng(a);else if(this.isPureNota(a))b=this.createFloatBoardEng(a);else return;if(!this.modules[a].enginePanel){var c=new EngineLinesElement(a,!1,this);this.modules[a].enginePanel=c}this.modules[a].engineOpen||(this.modules[a].enginePanel.initElem(b,{scrollLines:!1}),this.modules[a].engineOpen=!0);if(this.isPureNota(a)||this.isDiagram(a))this.resizeEngineMobile(a);else if(this.isSwipedLayout())this.fnSelectEngine(a,
6267300);else{b=this.getGameCount(a);c=$("#west"+a).width();var d=$("#westSouth"+a).height();d=this.getEngineH(a,d,b);this.resizeEngineAndListHori(a,1<b,d,b,c)}return this.modules[a].enginePanel}closeEnginePanel(){let a=this.nActivePlugin;-1==a&&(a=0);this.modules[a].engineOpen=!1;$("#engineEl"+a).css("width","100%");this.isDiagram(a)?(this.hideDiagramEng(a),this.modules[a].enginePanel=null):this.isPureNota(a)?(this.hideFloatBoardEng(a),this.modules[a].enginePanel=null):this.isMobileLayout()?(this.hasEngineInSwipe()?
6268this.fnSelectNota(a):this.layout==ReaderLayout.MULTI_BOARD_2&&this.hideEngineFlex(a),this.recreateHelp(a)):(this.hasEngBelowNota(a)&&this.recreateHelp(a),this.resizeActivePlugin())}hideEngineFlex(a){$(`#engNotaNota-${a}`).css("height","100%");$(`#engNotaEng-${a}`).css("height","0%");$(`#engNotaEng-${a}`).hide();this.resizeNotaMobile(a)}showEngineFlex(a){$(`#engNotaNota-${a}`).css("height","80%");$(`#engNotaEng-${a}`).css("height","20%");$(`#engNotaEng-${a}`).show();this.resizeNotaMobile(a)}getEngineElement(){let a=
6269this.nActivePlugin;if(this.modules[a]){let b=this.modules[a].enginePanel;if(b&&this.modules[a].engineOpen)return b}}setAutoShowEngine(){}setIsGuest(a){}useMatBalanceDefault(){return!0}onPluginExit(a){this.modules[a].getKernel().Vp.onExit()}saveParams(){glApp.Vn.save("BoardsSameSize",this.boardsSameSize);glApp.Vn.save("Sound",this.sound);glApp.Vn.save("Fonts",this.biggerFonts);this.layout!=ReaderLayout.HORIZONTAL&&(glApp.Vn.save("ReaderLayout",this.layout),glApp.Vn.save("UserBoards",this.nUserBoards),
6270glApp.Vn.save("UserNota",this.nUserNota),glApp.Vn.save("EngBelowNota",this.engBelowNota))}onPluginEntry(a){if(this.modules[a]?.getKernel())this.modules[a].getKernel().Vp.onEntry()}onBlur(){if(0<=this.nActivePlugin&&this.modules[this.nActivePlugin]&&this.modules[this.nActivePlugin].getKernel())this.modules[this.nActivePlugin].getKernel().Vp.onExit()}onLogOff(){this.onBlur();this.loggedOffLive=!0;this.isLive(this.nActivePlugin)&&this.modules[this.nActivePlugin]&&this.modules[this.nActivePlugin].getKernel()&&
6271(this.liveGameId[this.nActivePlugin]=this.modules[this.nActivePlugin].getKernel().idGame);this.saveParams()}createDiagramPlayingMode(a){a=new ReaderPlayingMode(a,0,this);a.blockLiveBook=!0;return a}initLiveGames(){this.liveGames=[];this.liveLists=[];for(var a=0;a<this.modules.length;a++)if(this.modules[a].mode==ReaderMode.LIVE){var b=function(){var d=a,e=this;return function(){return e.modules[d].getKernel()}}.call(this),c={};c.requestData=this.modules[a].requestData;c.ticket=this.modules[a].ticket;
6272c.fnGetKernel=b;this.liveLists.push(c)}}onPlayerLobbyConnect(){for(var a=0;a<this.modules.length;a++)this.modules[a].nota&&this.modules[a].nota.notaHeaderElement.resetPlayerCache()}onLoggedIn(){this.loggedOffLive&&(this.requestLists&&this.requestLiveLists(this.requestLists),this.loggedOffLive=!1)}onLogInListener(a){var b=this.createHelpText(a);this.setHelpHtmlToAll(b);if(a&&!this.wasLoggedIn){for(b=0;b<this.chat.length;b++)this.chat[b]&&this.chat[b].outLoginOk(glApp.Vn.userName);this.wasLoggedIn=
6273a}this.modules&&this.modules[0]&&this.modules[0].isMyMovesLive&&!this.liveListsRequested&&($("#listParent0").html("<strong>If your game list is empty, please manage your <a href='https://mymoves.chessbase.com'>'My Moves'</a>
6273 first.</strong>"),glApp.lobby.requestLiveLists(this.liveLists),this.liveListsRequested=!0)}onTeraBrainConnect(){this.modules[0]&&this.modules[0].getKernel()&&this.modules[0].getKernel().Vp.checkLiveBook();glApp.aTBLobby&&this.modules[0]&&this.isLive(0)&&(this.tbTimer=new Timer(this.tbTimerHdl.bind(this)),
6274this.tbFirstTimer=new Timer(this.tbTimerHdl.bind(this)),this.tbTimer.runPeriodic(3E4))}tbTimerHdl(){if(glApp.aTBLobby)if(!glApp.aTBLobby.isConnected()&&!glApp.aTBLobby.isConnecting()&&50>glApp.aTBLobby.connectCount)glApp.aTBLobby.connect(null,this),this.tbFirstTimer.runOnce(5E3);else for(let b=0;b<this.modules.length;b++){var a=this.modules[b];if(a.mode==ReaderMode.LIVE)for(let c in a.gameMap)parseInt(c)&&this.tbRequest(a.gameMap[parseInt(c)])}}tbRequest(a){a.hdr.getCBResult().isFinished()||glApp.aTBLobby.requestWithTicket(a.idGame,
6275a.getCurPos(),function(b,c){this.tbTableHandler(b,c,0)}.bind(this))}tbTableHandler(a,b,c){var d=this.modules[0].getKernelOfIdGame(a);if(d&&0<b.move[0].m_aLine[0]){var e=HashTableData.generateLine(b.pos.getPosition(),b.move[0],d).lineNota,f=b.move[0].m_nEval/100,g=b.move[0].m_nDepth;f=Evaluation.getEvalString(b.move[0].m_nEval)+" ("+f+"/"+g+")";b={value:b.move[0].m_nEval,depth:b.move[0].m_nDepth,strLine:e,strEval:f};d.tbTableEvaluation=b;d.boardWin&&(d.boardWin.displayEvaluation(!0,b),d.game.hasTBEval=
6276!0,d.game.fireOnEval(b.depth,b.value,d.game.idGame));if(!d.game.hdr.getCBResult().isFinished())this.onGameEval(c,b,a)}}initDiagramAnimations(){$(this.allPluginClasses).each(function(a,b){if($(b).hasClass("cbdiagram")&&this.modules[a]&&this.modules[a].diagramAnimations&&(this.modules[a].animationController=new DiagramAnimationController(this.modules[a].diagramAnimations,this.modules[a].getKernel().getCurPos(),this.modules[a].getKernel().boardWin,b),this.modules[a].animationController.drawInvariants(),
6277this.hasAutoStartDiaAnimation(this.modules[a].diagramAnimations))){var c=this.modules[a].animationController;(new Timer(function(){c.play()})).runOnce(500)}}.bind(this))}onUserMove(a){if(this.modules[a].animationController)this.modules[a].animationController.onUserMove()}activateTrainer(){this.createHelper();this.readerHelper.readGameActionFileList(function(){this.autostartVideo=!0;this.readerHelper&&this.readerHelper.showActivateDialog(this.onActivatedVideoDownload.bind(this))}.bind(this))}deactivateTrainer(){this.createHelper();
6278this.readerHelper.readGameActionFileList(function(){this.readerHelper&&this.readerHelper.showDeactivateDialog()}.bind(this))}checkHardware(){this.createHelper();this.readerHelper.checkHardware(function(a,b){this.readerHelper.onCheckHardware(a,b)||(new Timer(function(){this.modules[0].offlineVideo.videoManager.stop()})).runOnce(500)}.bind(this))}feedbackProduct(){this.createHelper();this.readerHelper.feedbackProduct()}recreate(){this.destroyAll();this.inDestroy=!1;glApp.panelMgr.init();glApp.panelMgr.createPanels();
6279(new Timer(function(){0<$("#westNest0").length&&$("#westNest0").jqxSplitter("refresh")}.bind(this))).runOnce(1500)}destroyAll(){System.isElectron()&&"undefined"!==typeof electronBridge&&electronBridge.setTitleTouchBar(glApp,"");this.inDestroy=!0;this.modules&&this.modules[0]&&this.modules[0].getKernel()&&(this.engineOpen=this.maximized=this.recorder=this.offlinevideo=this.video=this.book=this.chat=this.diagrams=null,this.gridCreated=[],this.soundBtnSelector=this.notaResized=this.listResized=this.tabNavSwitchDivs=
6280this.buttonImages=this.tabNavBtns=this.diagramBtns=this.boardBtns=null,this.modules[0].getKernel()&&this.modules[0].getKernel().destroy(),this.modules[0].getKernel().boardWin&&this.modules[0].getKernel().boardWin.destroyMessage());this.deleteRoot(0)}onOpenExternalURL(a){System.isElectron()?"undefined"!==typeof electronBridge&&electronBridge.showExternalURL(glApp,a):window.open(a,"_system")}onTouchBarButton(a){if(0==a.indexOf("slider")){var b=a.substr(6);b=parseInt(b,10);var c=this.offlinevideo[0].videoManager.getDuration();
6281this.offlinevideo[0].videoManager.setCurrentTime(b/100*c)}switch(a){case "back":window.history.back();break;case "play":this.modules[0].offlineVideo.videoManager.play();break;case "stop":this.modules[0].offlineVideo.videoManager.stop();break;case "pause":this.modules[0].offlineVideo.videoManager.pause();break;case "solution":this.modules[0].getKernel().VpplaySolution();break;case "flip":this.modules[0].getKernel().boardWin&&this.modules[0].getKernel().boardWin.flipBoard();break;case "start":this.stopAutoplay(0);
6282this.modules[0].getKernel().game.gotoStart();break;case "end":this.stopAutoplay(0);this.modules[0].getKernel().game.gotoEnd();break;case "retract":this.stopAutoplay(0);this.modules[0].getKernel().game.gotoPrev();break;case "activate":this.activateTrainer();break;case "deactivate":this.deactivateTrainer();break;case "senduserfeedback":this.feedbackProduct();break;case "exec":this.stopAutoplay(0)||(a=this.modules[0].getKernel().game.getAnno(AnnoType.TRAINING))&&!a.solved||this.modules[0].getKernel().game.gotoNext()}}startEngOnClick(){let a=
6283this.nActivePlugin;0<=a&&this.fnToggleAnalysis(a)}createHelpText(a){var b='<div class="cbreplayInfo" id="replayinfo{0}">';if(this.isOfflineVideo(0)||System.isElectron()||System.isCordova())b+="<span>"+lm.CLICK_ENGINE_TO_ANALYSE+"</span>";else if(System.getIEVersion()&&11>System.getIEVersion())b+='<span class="browserWarning">
6283Please update your browser. Thank you!</span>';else{switch(Language.getStrUserLanguage().slice(0,2)){default:a&&(b+='<div>Hello <span class="cbHelloUser">'+glApp.Vn.userName+
6284"</span>,</div>");b+="<ul>";System.isElectron()||System.isCordova()||(b+=this.getStartEngineHint("Start an analysis engine:"),this.isMobileLayout()||(b+='<li class="cbMaximizeHint">Try maximizing the board:<div class="cbImgFullScreen"></div></li>'),this.isMobileLayout()?b+="<li>Swipe between notation and other displays.</li><li>Swipe left on board loads next game.</li>":(b+='<li>Use the four cursor keys to replay the game. Make moves to analyse yourself.</li><li>Press Ctrl-B to rotate the board.</li><li>Drag the split bars between window panes.</li><li class="cbDownloadHint">Download&Clip PGN/GIF/FEN/QR Codes. Share the game.<div class="cbImgDownload"></div></li><li>Games viewed here will automatically be stored in your <a href=\'http://mygames.chessbase.com?ref=pgn\'>cloud clipboard</a> (if you are logged in). Use the cloud clipboard also in ChessBase.</li>',
6285a||(b+="<li><a href='https://account.chessbase.com/en/create-account?ref=pgn'>Create an account</a> to access the games cloud.</li>")));break;case "de":a&&(b+='<div>Hallo <span class="cbHelloUser">'+glApp.Vn.userName+"</span>,</div>");b+="<ul>";System.isElectron()||System.isCordova()||(b+=this.getStartEngineHint("Starten Sie eine Analyse-Engine:"),this.isMobileLayout()?b+="<li>Wische die Notation oder Brett nach links oder rechts.</li>":(b+='<li>Spielen Sie die Partie mit den vier Pfeiltasten nach. Geben Sie Z\u00fcge ein, um zu analysieren.</li><li class="cbMaximizeHint">Maximieren Sie das Brett:<div class="cbImgFullScreen"></div></li><li>Strg-B dreht das Brett.</li><li>Alle nachgespielten Partien werden im Clipboard von <a href=\'http://mygames.chessbase.com?ref=pgn\'>MyGames</a> gespeichert (falls eingeloggt).</li>',
6286a||(b+="<li><a href='https://account.chessbase.com/en/create-account?ref=pgn'>Registrieren Sie sich</a>, um MyGames zu benutzen.</li>")));break;case "es":a&&(b+='<div>Hola <span class="cbHelloUser">'+glApp.Vn.userName+"</span>,</div>"),b=b+"<ul>"+this.getStartEngineHint("Utilizar un motor de an\u00e1lisis:"),System.isElectron()||System.isCordova()||this.isMobileLayout()||(b+='<li>Use las 4 teclas de flecha para reproducir la partida. Ejecute jugadas para analizar.</li><li class="cbMaximizeHint">Pruebe a maximizar el tablero:<div class="cbImgFullScreen"></div></li><li>Haga clic en el indicador de turno de juego en la esquina inferior para darle la vuelta.</li><li>Haga clic en el logo de \'MyGames\' para guardar sus an\u00e1lisis.</li>',
6287a||(b+="<li><a href='https://account.chessbase.com/en/create-account?ref=pgn'>Create an account</a> to use cloud functions</li>"))}b+='</ul><div class="cbTinyLog"></div></div>'}return b}getStartEngineHint(a){return`<li class=\"cbEngineHint\"><a href='#'>${a}</a><div class=\"cbImgEngine\"></div></li>`}recreateHelp(a){this.setHelpHtml(a,this.createHelpText(!1))}setHelpHtml(a,b){$("#engineEl"+a).html(String.f(b,a));$("#engineEl"+a).css("font-family","Roboto Condensed");$("#engineEl"+a).css("font-size",
6288"12px");$("#engineEl"+a).find(".cbEngineHint").on("click",this.startEngOnClick.bind(this))}setHelpHtmlToAll(a){$(this.allPluginClasses).each(function(b){this.setHelpHtml(b,a)}.bind(this))}displayHints(a){let b=null;var c=this.nActivePlugin;if(this.modules[c]){if(c=this.modules[c].nota)c.onHints(a);(c=this.getEngineElement())&&(b=[c.onHints(a)])}return b}initGestures(a,b){a.initGestures(function(c){let d=$(a.cbcanvas.canvas);c==Hammer.DIRECTION_LEFT&&d.addClass("shiftLeft");c==Hammer.DIRECTION_RIGHT&&
6289d.addClass("shiftRight");this.onBoardSwipe(c,b);(new Timer(function(){d.removeClass("shiftLeft shiftRight")})).runOnce(600)}.bind(this),null)}onBoardSwipe(a,b){switch(a){case Hammer.DIRECTION_LEFT:this.loadNextGame(b);this.fnSelectNota(b);break;case Hammer.DIRECTION_RIGHT:this.loadPrevGame(b),this.fnSelectNota(b)}}onBoardPinch(a,b){}createSettingsForm(a,b,c){b={id:"settingsForm",title:lm.SETTINGS,width:350,height:280,modal:!1,okHandler:b,fields:[{caption:lm.PIECES,type:"select",id:"idPieces",val:0,
6290options:[{text:lm.BOARD_FRITZ,value:0},{text:lm.BOARD_CRYSTALS,value:1},{text:lm.BOARD_USCF,value:2},{text:lm.BOARD_HABSBURG,value:3}]},{caption:"Sound",type:"checkbox",id:"idSound",checked:glApp.chessAudio&&!!glApp.chessAudio.isEnabled()}]};if(this.isSwipedLayout()||this.isPureNota(this.nActivePlugin)&&!System.runsOnChessBaseNews())b.fields.push({caption:lm.FONT_SIZE,type:"number",id:"idFonts",min:6,max:24,val:this.biggerFonts.toString(),spin:!0}),b.height+=12;this.isSwipedLayout()&&(b.fields.push({caption:lm.ENG_BELOW_NOTA,
6291id:"idEngBelowNota",type:"checkbox",checked:!!this.engBelowNota}),b.height+=12);if(this.isLive(this.nActivePlugin)&&!this.isMobileLayout()){let d=this.nUserBoardsDesk;0==d&&(d=this.modules[this.nActivePlugin].kernel.length);b.fields.push({caption:lm.BOARDS,type:"number",id:"idLayBoards",min:1,max:24,val:d.toString(),spin:!0});
6291b.fields.push({caption:lm.BOARDS_SAME_SIZE,id:"idBoardsSame",type:"checkbox",checked:!!this.boardsSameSize});b.height+=30;b.width+=20}(new CBForm(b)).create(a,null,c)}createUserLayoutForm(a,
6292b,c){if(a){var d=[{id:"idLayNotaSmall",text:"Small"},{id:"idLayNotaBig",text:"Big"}];d.forEach(function(e){e.checked=!1});d[this.nUserNota].checked=!0;(new CBForm({id:"userForm",title:"Layout",width:370,height:260,modal:!1,okHandler:b,fields:[{caption:lm.BOARDS,type:"number",id:"idLayBoards",min:1,max:12,val:this.nUserBoards.toString(),spin:!0},{type:"radio",caption:"Notation",id:"idLayNota",buttons:d}]})).create(a,null,c)}}createDesktopLayoutForm(a,b,c){a&&(new CBForm({id:"userForm",title:"Layout",
6293width:370,height:200,modal:!1,okHandler:b,fields:[{caption:lm.BOARDS,type:"number",id:"idLayBoards",min:1,max:12,val:Math.max(2,this.nUserBoardsDesk.toString()),spin:!0},{caption:lm.BOARDS_SAME_SIZE,id:"idBoardsSame",type:"checkbox",checked:!!this.boardsSameSize}]})).create(a,null,c)}createShareForm(a,b,c,d){(new CBForm({id:"shareForm",title:lm.SHARE_BOARD,width:370,height:270,modal:!0,okHandler:c,fields:[{caption:"Players",type:"checkbox",id:"idPlayers",checked:!0},{caption:"Photos",type:"checkbox",
6294id:"idPhotos",checked:!1},{caption:"Text",type:"string",id:"idText",val:""}]})).create(b,null,d)}createGifForm(a,b,c,d,e){a=[{id:"idSpeedFast",text:"Fast"},{id:"idSpeedNormal",text:"Normal"},{id:"idSpeedSlow",text:"Slow"}];a.forEach(function(f){f.checked=!1});a[1].checked=!0;c={id:"gifForm",title:lm.SHARE_GIF,width:440,height:360,modal:!0,okHandler:c,fields:[{caption:lm.PLAYERS,type:"checkbox",id:"idPlayers",checked:!0},{caption:lm.SIZE+" [1..9 * 100px]",type:"number",min:1,max:9,val:6,id:"idPixels",
6295spin:!0},{caption:lm.FLIP_BOARD,type:"checkbox",id:"idBlack",checked:!1},{type:"radio",caption:"Speed",id:"idSpeed",buttons:a},{caption:lm.GREY,type:"checkbox",id:"idGrey",checked:!0}]};e&&c.fields.push({caption:lm.USE_THINK_TIMES,type:"checkbox",id:"idThinkTimes",checked:!0});(new CBForm(c)).create(b,null,d)}createShareDiaForm(a,b,c,d){(new CBForm({id:"shareDiaForm",title:lm.SHARE_PLAYABLE,width:370,height:270,modal:!0,okHandler:c,fields:[{caption:lm.ENGINE,type:"checkbox",id:"idEngine",checked:!0},
6296{caption:lm.TITLE,type:"string",id:"idTitle",val:""},{caption:lm.DESCRIPTION,type:"string",id:"idDescription",val:""}]})).create(b,null,d)}addPgnFileInput(){function a(){glApp.panelMgr.onFileSelect(ReaderCommandIds.UPLOAD_PGN,this.files)}var b=$("#pgnFileInput");b.length||($(document.body).append($('<input id="pgnFileInput" type="file" style="display:none;" />')),b=$("#pgnFileInput"));if(b.length)b.on("change",a)}onFileSelect(a,b){LOG(b);if(a==ReaderCommandIds.UPLOAD_PGN){if(b.length)if(-1!=b[0].name.search(".fen")){let d=
6297new FileReader;d.readAsText(b[0]);d.onloadend=function(e){e=new Position(d.result);e=new Game(e);this.getKernel().Vp.loadGame(e)}.bind(this)}else var c=new PgnDatabase(b[0],function(){c.getGameCount()?this.setDatabase(c):this.showMessage("Not a valid PGN");var d=document.getElementById("pgnFileInput");d&&(d.value=null)}.bind(this));return!0}return!1}setDatabase(a){a&&0<a.getGameCount()&&($("#listParent"+this.nActivePlugin).length&&this.isReplay(this.nActivePlugin)?this.createDatabaseGrid(a,this.nActivePlugin,
6298this.loadGame.bind(this)):(a=a.getGame(1),this.getKernel().Vp.loadGame(a)))}showAreaMsg(a){let b=this.nActivePlugin;0>b&&(b=0);this.modules[b]&&this.modules[b].boardArea&&this.modules[b].boardArea.showText(a,"48px Roboto","black")}setupPosition=function(){let a=this.getKernel(),b=a.Vp;b.engineStop&&b.engineStop();a.togglePosInputMode(b.posLegalChecker)};static InitListeners(){ReaderPM.prototype.fireEvent||(Vk.initForListeners(ReaderPM),Vk.addEvent(ReaderPM,"NextHint"))}}"use strict";
6299class ReaderPlayingMode extends EngineHostMode{constructor(a,b,c){super(a,b,c);this.kernel=a;this.nMultiVars=2;this.cntPosViews=0;this.saved=this.statsSent=!1;this.nBookTimeouts=0;this.lastCMSIPos="";this.fnCheckLiveBook=this.checkLiveBook.bind(this);this.hintMeter=null;this.calcHints=!1}onBestMove(){}destroy(){glApp.analysisEngine&&(glApp.analysisEngine.engineStop(),glApp.analysisEngine.unlinkPlayingMode(this));super.destroy();glApp.commands.fireChecked(CommandIds.TOGGLE_ANALYSIS_ENGINE,!1);this.onDestroy()}onExit(){super.onExit();
6300glApp.analysisEngine&&(glApp.analysisEngine.engineStop(),glApp.analysisEngine.clearLines());this.saveAndReset()}createGUIElements(a){super.createGUIElements(a);a.shouldAnimatePosChange=this.shouldAnimatePosChange.bind(this);System.isMobile()&&(a.animSteps={forMove:.1,forPosition:.1});this.onCreateGUIElements()}shouldAnimatePosChange(){return System.V3()||!System.isNonCrossDomainIE()}static gateUpdate=new V10;getMoveEnterType(){return this.kernel.game.isLineEnd()||!glApp.allowMoveEntryDialog()?MoveEnterType.NEWLINE:
6301MoveEnterType.QUERY}onResetGame(){this.nBookTimeouts=0}playSolution(a){a=this.kernel.game.getCurPos();this.cmsiPos=a.toFEN();this.orgVideoId=this.videoid;a=this.panelMgr.modules[0].cmsiManager.collectFiles(a);for(var b=0;b<a.length;b++)if(2==this.panelMgr.modules[0].cmsiManager.extractStateFromFileName(a[b])){this.panelMgr.loadNewOfflineVideo(0,a[b]);break}}onEnteredMove(a){if(this.posAskBestmove&&this.posAskBestmove.equals(this.kernel.game.getCurPos())){var b=CBSquare.getStr(a.from),c=CBSquare.getStr(a.to);
6302this.panelMgr.fnSendChat(0,"ABM:"+b+"-"+c)}b=this.kernel.game.getCurPos();this.saved=!1;if("undefined"===typeof this.videoid&&this.kernel.game.getAnno(AnnoType.TRAINING)&&!this.checkIfCorrectTrainingMove(a,b))return!1;if(this.kernel.OfflineInteractive){b=this.kernel.game.getCurPos();this.cmsiPos=b.toFEN();this.orgVideoId=this.videoid;b=this.panelMgr.modules[0].cmsiManager.collectFiles(b);c=-1;for(var d=!1,e=0;e<b.length;e++){var f=this.panelMgr.modules[0].cmsiManager.extractStateFromFileName(b[e]),
6303g=this.panelMgr.modules[0].cmsiManager.extractMoveFromFileName(b[e]);if(g.from==a.from&&g.to==a.to){d=!0;2!=f&&3!=f||this.panelMgr.loadNewOfflineVideo(0,b[e]);break}else 4==f&&0==g.from&&0==g.to&&(c=e)}if(!d)if(-1!=c&&this.lastCMSIPos!=this.cmsiPos)this.lastCMSIPos=this.cmsiPos,this.panelMgr.loadNewOfflineVideo(0,b[c]);else return this.ShowMessage("Please try again"),this.restoreMoveEnterPosition(),this.videoid=this.orgVideoId,!1}this.kernel.Interactive&&(c=this.kernel.game.getCurPos(),this.cmsiPos=
6304c.toFEN(),this.orgVideoId=this.videoid,b="",glApp.isLoggedIn()&&glApp.Vn.userName&&(b=glApp.Vn.userName),this.baseurl=glApp.config.getVideoPortalUris()[0],a=this.baseurl+"Replay/GetNextIdWithMove?id="+encodeURIComponent(this.videoid)+"&from="+a.from+"&to="+a.to+"&user="+encodeURIComponent(b)+"&fen="+encodeURIComponent(c.toFEN()),$.get(a,function(h){if(h){var k=h.ID,l=h.MSG;2<l.length?(this.ShowMessage(l),"4"==h.STATE&&(this.restoreMoveEnterPosition(),this.videoid=this.orgVideoId)):this.panelMgr.loadNewVideo(this.panelMgr.nActivePlugin,
6305k,!0)}}.bind(this)));"undefined"!==typeof this.kernel.pluginCnt&&this.panelMgr.stopAutoplay(this.kernel.pluginCnt);return!0}checkIfCorrectTrainingMove(a,b){if(b=this.kernel.game.getAnno(AnnoType.TRAINING)){const c=this.kernel.game.getNextMove();c&&c.from==a.from&&c.to==a.to?(b.solved=!0,this.kernel.game.fireOnChanged(),this.ShowMessage(lm.CORRECT)):(this.ShowMessage(lm.TRY_AGAIN),(new Timer).runOnce(1E3,function(){this.kernel.retractAndAnimCurrMove()}.bind(this)));return!0}}onAfterMoveEntry(a){this.kernel.PositionMode&&
6306(a=this.kernel.game.getCurPos(),this.baseurl=glApp.config.getVideoPortalUris()[0],a=this.baseurl+"Public/GetVideoSnippets?fen="+encodeURIComponent(a.toNormalizedFEN()),$.get(a,function(b){b&&(b=b.Snippets,b.length&&this.panelMgr.loadNewVideo(0,b[0].Lecture))}.bind(this)))}restoreMoveEnterPosition(){var a=new Position(this.cmsiPos);a=new Game(a);this.kernel.game.assign(a);this.kernel.game.updateFromExtern()}ShowMessage(a){this.panelMgr.showMessage(a);this.kernel.boardWin.addMessage(a,!0);(new Timer(function(){this.kernel.boardWin.destroyMessage()}.bind(this))).runOnce(3E3)}canAnnotateLoadedGames(){return!0}isAnalysis(){return!0}fireHints(a){a.moveNo=
6307this.kernel.getMoveNo();if(this.panelMgr.displayHints){let b=this.panelMgr.displayHints(a);b&&b.forEach(function(c){c.displayed&&(this.lastHintTypeFired=a.hints[a.index].type)}.bind(this))}}engineGiveHint(){this.kernel.boardWin.undoAttributes();this.showNextGeneratedHint()}beforeGameLoad(){this.saveAndReset();this.saved=!1}afterGameLoad(){this.kernel.gotoFirstTrainingPosition()}saveAndReset(){16<this.cntPosViews&&!this.statsSent&&!this.isAutoplay&&(this.statsSent=!0,LogReplayed(this.kernel.game.hdr.getStrPlayers(!1,
63080),this.cntPosViews));this.saveToCloud(!0);this.cntPosViews=0;this.statsSent=!1}engineStop(){glApp.analysisEngine&&(glApp.analysisEngine.engineStop(),glApp.analysisEngine.clearLines());this.stopAll()}updateGamePos(){this.isAutoplay||this.cntPosViews++;this.engineStop();ReaderPlayingMode.gateUpdate.exec(function(){this.kernel.game.getCurPos().hasLegals()&&(this.isAutoplay||this.fnCheckLiveBook(),this.calcStaticEval(),this.calcHints?(this.initAnalysisEngine(),this.goAnalysis(2)):this.goAll())}.bind(this),
6309500);if($("#txtGameId")[0]){var a=this.panelMgr.socialMediaUrl+"/TextBoxValues/",b={Id:$("#txtGameId").val(),moveIndex:this.kernel.game.getMoveIndex()};$.ajax({url:a,method:"POST",dataType:"json",contentType:"application/json; charset=UTF-8",async:!1,data:JSON.stringify(b),success:function(c){c&&($("#txtEmbedCodeExample").val(c.EmbedGameCode),$("#txtEmbedCode").val(c.EmbedGameCode),$("#txtGameUrlExample").val(c.GameUrl),$("#txtCopyUrl").val(c.GameUrl))},error:function(c,d,e){this.panelMgr.showAlert("Error updating GameUrl.",
6310300,130)}})}}calcStaticEval(){if("undefined"!=typeof Evaluation){let a=new PositionEvaluation(this.kernel.getCurPos());0<this.engines.length&&this.engines[0]&&this.engines[0].fireOnStaticEval(a.evaluate())}}tbDataListener(){}initAnalysisEngine(a){super.initAnalysisEngine(a);glApp.analysisEngine&&!this.idOnLineListener&&glApp.analysisEngine.linkPlayingMode(this)}onAnalysisLine(a,b,c,d,e){if(!this.kernel.game.hasTBEval){var f=b;this.kernel.getCurPos().getBTM()&&(f=-f);this.kernel.game.fireOnEval(a,
6311f,c);f=!1;(6<=a||2E4<b)&&this.calcHints&&(this.genHints(a,b,c,d,e),f=!0);!f&&24<a&&glApp.analysisEngine&&glApp.analysisEngine.engineStop()}}getMarkedSquaresOnButtonDown(a,b){return b?(this.initAnalysisEngine(),this.getTargetSquareHints(a)
6311):this.genLegalSquareHints(a)}saveToCloud(a){return glApp.cloudMgr&&glApp.cloudMgr.isLoggedIn()&&!this.saved&&(1<this.cntPosViews||a)?(this.kernel.game.getMainLine().length&&this.kernel.game.isNormalInit()&&(glApp.cloudMgr.saveGameToClipboard(this.kernel.game),this.saved=
6312!0),!0):!1}}SimpleEngineModeMixin&&mixin(ReaderPlayingMode,SimpleEngineModeMixin);HintsMixin&&mixin(ReaderPlayingMode,HintsMixin);"NOMINIFY=glApp,panelMgr";
6313let ReaderCommandIds={TEST:4E3,UPLOAD_PGN:4001},V16=function(){var a=function(b){this.Vn=new ClientParams("Reader");this.versionCode=new VersionCode(VersionCodeEnum.JSREADER,31,5,0);console.log(this.versionCode.toString());this.appName="reader.chessbase.com";this.appUrl="https://reader.chessbase.com";this.shortAppName="reader";this.appTitle="ChessBase PGN Reader";this.gameKernel={};this.setExternalCommonPath({pics:(-1==document.URL.search(/chessbase.com/i)||-1!=document.URL.search(/cloudserver/i))&&
6314-1==document.URL.search(/localhost/i),engine:!0});this.initConfig()};inherit(a,V1d);mixin(a,AccountAppMixin);mixin(a,CloudAppMixin);a.prototype.initInstance=function(){this.superClass.initInstance.call(this);this.panelMgr=new ReaderPM;this.commandHandlerId=this.commands.registerCommandHandler(this);this.resultPostBack=new ResultPostBack;System.runsInIFrame()||(window.addEventListener("blur",onBlur),window.addEventListener("focus",onFocus),window.addEventListener("resize",onResize),window.addEventListener("beforeunload",
6315onBeforeUnload),window.addEventListener("unload",onBeforeUnload),document.addEventListener("visibilitychange",onVisibilityChange))};a.prototype.createLiveManager=function(b){glApp.Vn.loginToken=DOM.getCookie("AccountToken")||glApp.Vn.loginToken;glApp.Vn.userName=DOM.getAccountNameCookie(!0)||glApp.Vn.userName;glApp.hasUserName()&&(glApp.Vn.loginToken||glApp.Vn.password)&&!System.runsInIFrame()?glApp.Vn.loginMode=LoginMode.NORMAL:(glApp.Vn.userName="guest",glApp.Vn.loginMode=LoginMode.GUEST);glApp.lobby||
6316(glApp.lobby=new ServerLiveManager,glApp.lobby.createLobby(glApp.config.getLiveUris(),"guest","",LoginMode.GUEST,glApp.Vn.loginToken,b));glApp.lobby.isConnected()||glApp.lobby.isConnecting()||glApp.lobby.connect()};a.prototype.onLogin=function(b){this.setLoggedIn(1==b.ResultType)};a.prototype.exitInstance=function(){this.superClass.exitInstance.call(this)};a.prototype.isExtJS=function(){return!1};a.prototype.isBoardOnlyApp=function(){return!1};a.prototype.getAppSpecificCommandIds=function(){return ReaderCommandIds};
6317a.prototype.execCommand=function(b){return this.superClass.execCommand.apply(this,arguments)};a.prototype.initConfig=function(){this.config.liveBookIsPremium=!0;this.config.board2DBottomOffset=this.config.board2DTopOffset=Math.min(16,Math.max(4,window.innerHeight/50));this.config.silentCloud=!0;this.config.silentServers=!0;this.config.noPlayingAudios=!0;this.config.delayAudioInit=!0;this.config.jqxTheme="chessbase";this.config.diaStyleSuffix="";this.isSchachDe()?(this.config.diaStyleSuffix="-blue",
6318this.config.defaultBoardTextureId=this.config.forceBoardTextureId=CommandIds.BOARD2D_BLUE,this.config.forcePieceStyleId=CommandIds.PIECES2D_FRITZ):this.isNftChessBaseCom()&&(this.config.defaultBoardTextureId=this.config.forceBoardTextureId=CommandIds.BOARD2D_RED,this.config.forcePieceStyleId=CommandIds.PIECES2D_FRITZ,this.config.jqxTheme="chessbasered")};a.prototype.isSchachDe=function(){return 0<=window.location.href.search("schach.de")||0<=window.location.href.search("playchess.com")};a.prototype.isNftChessBaseCom=
6319function(){return 0<=window.location.href.search("nft.chessbase.com")};a.prototype.getAvailableLanguages=function(){return[Language.DEU,Language.ESP]};a.prototype.isPlugin=function(){return!0};a.prototype.getLocalizationArr=function(b){var c=this.superClass.getLocalizationArr.call(this,b);Loc.Reader&&(Loc.Reader[b]?c.push(Loc.Reader[b]):c.push(Loc.Reader.ENG));Loc.Training[b]?c.push(Loc.Training[b]):c.push(Loc.Training.ENG);return c};return a}();
6320function onBeforeUnload(a){glApp.lobby&&(glApp.lobby.logOff(),Timer.busyWait(700));glApp.exitInstance()}function onResize(){glApp.panelMgr.onWindowResize()}function onFocusOut(){}function onBlur(){glApp.saveGameToLocalStorage();glApp.lobby&&System.isMobile()&&(glApp.blurLogOffTimer&&glApp.blurLogOffTimer.stop(),glApp.blurLogOffTimer=new Timer(function(){glApp.lobby&&(glApp.lobby.logOff(),glAp
6320p.panelMgr.onLogOff());glApp.logOffPlayerLobby()}),glApp.blurLogOffTimer.runOnce(5E3))}
6321function onFocus(){glApp.lobby&&(System.isMobile()&&!glApp.lobby.isConnected()&&glApp.lobby.wasLoggedIn()&&(glApp.isLive&&glApp.lobby.reconnectUser(),glApp.playerLobby&&!glApp.playerLobby.isConnected()&&glApp.playerLobby.wasLoggedIn()&&glApp.playerLobby.reconnectUser()),glApp.blurLogOffTimer&&glApp.blurLogOffTimer.stop())}function onVisibilityChange(){glApp.lobby&&document.visibilityState&&("hidden"==document.visibilityState?onBlur():"visible"==document.visibilityState&&onFocus())}
6322function activateProduct(){this.glApp.panelMgr.activateTrainer()}function deactivateProduct(){this.glApp.panelMgr.deactivateTrainer()}function checkHardware(){this.glApp.panelMgr.checkHardware()}function senduserfeedback(){this.glApp.panelMgr.feedbackProduct()}function onChangePage(){alert("OnChangePage")}function onShowExternalURL(a){this.glApp.panelMgr.onOpenExternalURL(a)}function onRecreate(){this.glApp.panelMgr.recreate()}function onDestroy(){this.glApp.panelMgr.destroyAll()}"use strict";
6323(function(a){function b(){glApp.exitInstance();glApp.logOffPlayerLobby();glApp.logOffTeraBrainLobby();glApp.logOffOnlineLobby();glApp.panelMgr.onLogOff();glApp.saveGameToLocalStorage()}$(function(){var c=document.getElementById("bodytext");c&&document.body.removeChild(c);setGlobalApp(new V16);glApp.initInstance();glApp.panelMgr.hasPlugins&&(glApp.connectTeraBrainLobby(),glApp.connectOnlineDBLobby(!1),glApp.connectPlayerLobby(!1));glApp.panelMgr.createPanels();window.addEventListener("beforeunload",
6324b);LOG("User="+glApp.Vn.userName,"","acc");glApp.isLive&&glApp.createLiveManager();glApp.tryLogin(glApp.tokenLoginHandler.bind(glApp))||glApp.setLoggedIn(!1);glApp.panelMgr.onReady();glApp.aTBLobby&&(glApp.aTBLobby.callOnConnect=function(){glApp.panelMgr.onTeraBrainConnect()})})})(window);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.