var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(b,a,k){b instanceof String&&(b=String(b));for(var c=b.length,g=0;g<c;g++){var h=b[g];if(a.call(k,h,g,b))return{i:g,v:h}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(b,a,k){if(b==Array.prototype||b==Object.prototype)return b;b[a]=k.value;return b};$jscomp.getGlobal=function(b){b=["object"==typeof globalThis&&globalThis,b,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var a=0;a<b.length;++a){var k=b[a];if(k&&k.Math==Math)return k}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(b,a){var k=$jscomp.propertyToPolyfillSymbol[a];if(null==k)return b[a];k=b[k];return void 0!==k?k:b[a]};
$jscomp.polyfill=function(b,a,k,c){a&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(b,a,k,c):$jscomp.polyfillUnisolated(b,a,k,c))};$jscomp.polyfillUnisolated=function(b,a,k,c){k=$jscomp.global;b=b.split(".");for(c=0;c<b.length-1;c++){var g=b[c];if(!(g in k))return;k=k[g]}b=b[b.length-1];c=k[b];a=a(c);a!=c&&null!=a&&$jscomp.defineProperty(k,b,{configurable:!0,writable:!0,value:a})};
$jscomp.polyfillIsolated=function(b,a,k,c){var g=b.split(".");b=1===g.length;c=g[0];c=!b&&c in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var h=0;h<g.length-1;h++){var f=g[h];if(!(f in c))return;c=c[f]}g=g[g.length-1];k=$jscomp.IS_SYMBOL_NATIVE&&"es6"===k?c[g]:null;a=a(k);null!=a&&(b?$jscomp.defineProperty($jscomp.polyfills,g,{configurable:!0,writable:!0,value:a}):a!==k&&(void 0===$jscomp.propertyToPolyfillSymbol[g]&&(k=1E9*Math.random()>>>0,$jscomp.propertyToPolyfillSymbol[g]=$jscomp.IS_SYMBOL_NATIVE?
$jscomp.global.Symbol(g):$jscomp.POLYFILL_PREFIX+k+"$"+g),$jscomp.defineProperty(c,$jscomp.propertyToPolyfillSymbol[g],{configurable:!0,writable:!0,value:a})))};$jscomp.polyfill("Array.prototype.find",function(b){return b?b:function(a,k){return $jscomp.findInternal(this,a,k).v}},"es6","es3");
function KTColumn(b,a){var k=this,c=b,g=a?a:"col"+ ++KTColumn.iFlowId,h=72,f,n,l=!1,v;this.setKey=function(r){g=r};this.getKey=function(){return g};this.setWidth=function(r){if(h!=r){var C=h;h=r;c(this,KTColumn.WIDTH,h,C)}};this.getWidth=function(){return h};this.$innerDestroy=function(){this.setStyle(null);this.setBorder(null);c=null};this.setStyle=function(r){r!=f&&(null!=f&&f.removeChangeListener(z),f=r,null!=f&&f.addChangeListener(z))};this.getStyle=function(){return f};this.setBorder=function(r){r!=
n&&(null!=n&&n.removeChangeListener(z),n=r,null!=n&&n.addChangeListener(z))};this.getBorder=function(){return n};var z=function(r,C,x,u){c(k,C,x,u)};this.setHide=function(r){l!=r&&(l=r,c(k,KTColumn.HIDE,l,!l))};this.isHide=function(){return l};this.setUserObject=function(r){v=r};this.getUserObject=function(){return v}}KTColumn.WIDTH="width";KTColumn.HIDE="columnHide";KTColumn.iFlowId=100;
function KTRow(b,a){var k=this,c=a,g="row"+ ++KTRow.iFlowId,h=20,f=[],n,l,v=!1,z,r=!1;this.getKey=function(){return g};this.setHeight=function(u){h!=u&&(h=u,c(this,KTRow.HEIGHT,h,u))};this.getHeight=function(){return h};this.getCell=function(u,A){var q=f[u];A||q||(q=new KTCell(C),f[u]=q);return q};this.getCellForDraw=function(u){return f[u]};this.setStyle=function(u){u!=n&&(null!=n&&n.removeChangeListener(x),n=u,null!=n&&n.addChangeListener(x))};this.getStyle=function(){return n};this.setBorder=function(u){u!=
l&&(null!=l&&l.removeChangeListener(x),l=u,null!=l&&l.addChangeListener(x))};this.getBorder=function(){return l};this.$innerDestroy=function(){this.setStyle(null);this.setBorder(null);c=null;for(var u=0;u<f.length;u++){var A=f[u];A&&A.$innerDestroy()}f=null};this.$innerInsertCell=function(u){f.splice(u,0,null)};this.$innerRemoveCell=function(u){var A=f[u];A&&A.$innerDestroy();f.splice(u,1)};var C=function(u,A,q,F){var L;for(L=0;L<f.length&&f[L]!=u;L++);u=new KTCell.Path(k,L,u);c(u,A,q,F)},x=function(u,
A,q,F){c(k,A,q,F)};this.setHide=function(u){v!=u&&(v=u,c(k,KTRow.HIDE,v,!v))};this.isHide=function(){return v};this.setUserObject=function(u){z=u};this.getUserObject=function(){return z};this.clearAsSkeleton=function(){for(var u=0;u<f.length;u++){var A=f[u];A&&A.$innerDestroy()}f=[];r=!0};this.isSkeleton=function(){return r};this.rescueSkeleton=function(){r=!1}}KTRow.HEIGHT="height";KTRow.HIDE="rowHide";KTRow.iFlowId=0;
function KTCell(b){var a=this,k=b,c,g,h,f,n;this.setValue=function(z){if(c!=z){var r=c;c=z;"undefined"!=typeof r&&k(this,KTCell.VALUE,c,r)}};this.getValue=function(){return c};this.setUserObject=function(z){n=z};this.getUserObject=function(){return n};this.$innerDestroy=function(){this.setStyle(null);this.setBorder(null);k=null};this.setStyle=function(z){z!=g&&(null!=g&&g.removeChangeListener(l),g=z,null!=g&&g.addChangeListener(l))};this.getStyle=function(){return g};this.setBorder=function(z){z!=
h&&(null!=h&&h.removeChangeListener(l),h=z,null!=h&&h.addChangeListener(l))};this.getBorder=function(){return h};var l=function(z,r,C,x){k(a,r,C,x)};this.setTreeModel=function(z){f&&f.$innerBindChangeListener(null);if(f=z)f.$innerBindChangeListener(v),k(a,KTCell.TREE_EXPANDING)};this.getTreeModel=function(){return f};var v=function(z){z==KTCellTreeModel.EXPANDED&&k(a,KTCell.TREE_EXPANDING)}}KTCell.VALUE="value";KTCell.TREE_EXPANDING="treeExpanding";
KTCell.Path=function(b,a,k){var c,g;this.$innerSetInfo=function(h,f){c=h;g=f};this.getRowIndex=function(){return c};this.getColIndex=function(){return a};this.getRow=function(){return b};this.getCol=function(){return g};this.getCell=function(){return k}};
function KTAbstractStyle(){var b=null,a=[],k=!0;this.setChangeListenerSilence=function(g){k=g};this.$innerDirty=function(g,h,f,n){b=null;if(!k)for(var l=0;l<a.length;l++)a[l](g,h,f,n)};this.addChangeListener=function(g){k||0>c(g)&&a.push(g)};this.removeChangeListener=function(g){g=c(g);0<=g&&a.splice(g,1)};var c=function(g){for(var h=0;h<a.length;h++)if(a[h]==g)return h;return-1};this.copy=function(){throw Error("Override me.");};this.toCssString=function(){null==b&&(b=this.protectedCreateCssString());
return b};this.protectedCreateCssString=function(){throw Error("Override me.");};KTAbstractStyle.createCssItem=function(g,h,f){var n=typeof h;return"undefined"==n||null==h?"":"string"==n&&0<h.indexOf(" ")?g+':"'+h+'";':g+":"+h+(f?f:"")+";"};this.toString=function(){return this.toCssString()}}
function KTStyle(){KTAbstractStyle.call(this);var b=this,a,k,c,g,h,f,n,l,v,z,r,C,x,u,A=function(q){b.$innerDirty(b,q?q:KTStyle.STYLE_COMMON)};this.setFontName=function(q){a=q;A()};this.getFontName=function(){return a};this.setFontSize=function(q){k=q;A()};this.getFontSize=function(){return k};this.setBold=function(q){c=q;A()};this.isBold=function(){return c};this.setItalic=function(q){g=q;A()};this.getItalic=function(){return g};this.setUnderLine=function(q){h=q;A()};this.isUnderLine=function(){return h};
this.setLineThrough=function(q){f=q;A()};this.isLineThrough=function(){return f};this.setColor=function(q){n=q;A()};this.getColor=function(){return n};this.setBackgroundColor=function(q){l=q;A()};this.getBackgroundColor=function(){return l};this.setTextAlign=function(q){v=q;A()};this.getTextAlign=function(){return v};this.setVerticalAlign=function(q){z=q;A(KTStyle.STYLE_TEXT_SPECIAL)};this.getVerticalAlign=function(){return z};this.setWrapText=function(q){r=q;A(KTStyle.STYLE_TEXT_SPECIAL)};this.isWrapText=
function(){return r};this.setIndent=function(q){C=q;A()};this.getIndent=function(){return C};this.setCursor=function(q){x=q};this.getCursor=function(){return x};this.setFontUnit=function(q){u=q};this.getFontUnit=function(){return u};this.getFontSizeWithUnit=function(){return k||0==k?k+(u?u:KTStyle.DEFAULT_FONT_UNIT):k};this.copy=function(){var q=new KTStyle;q.setFontName(a);q.setFontSize(k);q.setBold(c);q.setItalic(g);q.setUnderLine(h);q.setLineThrough(f);q.setColor(n);q.setBackgroundColor(l);q.setTextAlign(v);
q.setVerticalAlign(z);q.setWrapText(r);q.setCursor(x);q.setFontUnit(u);return q};this.protectedCreateCssString=function(){var q=""+KTAbstractStyle.createCssItem("font-family",a);q+=KTAbstractStyle.createCssItem("font-size",k,u?u:KTStyle.DEFAULT_FONT_UNIT);1==c?q+=KTAbstractStyle.createCssItem("font-weight","bold"):0==c&&(q+=KTAbstractStyle.createCssItem("font-weight","normal"));1==g?q+=KTAbstractStyle.createCssItem("font-style","italic"):0==g&&(q+=KTAbstractStyle.createCssItem("font-style","normal"));
f&&h?q+=KTAbstractStyle.createCssItem("text-decoration","underline line-through"):h?q+=KTAbstractStyle.createCssItem("text-decoration","underline"):f&&(q+=KTAbstractStyle.createCssItem("text-decoration","line-through"));q+=KTAbstractStyle.createCssItem("color",n);q+=KTAbstractStyle.createCssItem("background-color",l);q+=KTAbstractStyle.createCssItem("text-align",v);q+=KTAbstractStyle.createCssItem("vertical-align",z);!0===r?(q+=KTAbstractStyle.createCssItem("white-space","pre-wrap"),q+=KTAbstractStyle.createCssItem("*white-space",
"pre"),q+=KTAbstractStyle.createCssItem("*word-wrap","break-word")):!1===r&&(q+=KTAbstractStyle.createCssItem("white-space","nowrap"));return q}}KTStyle.CSS_ID_PREFIXE="style";KTStyle.STYLE_COMMON="styleCommon";KTStyle.STYLE_TEXT_SPECIAL="styleTextSpecial";KTStyle.DEFAULT_FONT_UNIT="pt";
function KTBorderStyle(){KTAbstractStyle.call(this);var b=this,a=Array(4),k=Array(4),c=Array(4),g=function(h){b.$innerDirty(b,h?h:KTBorderStyle.BORDER_COMMON)};this.setTopBorderPen=function(h){a[0]=h;g()};this.getTopBorderPen=function(){return a[0]};this.setRightBorderPen=function(h){a[1]=h;g()};this.getRightBorderPen=function(){return a[1]};this.setBottomBorderPen=function(h){a[2]=h;g()};this.getBottomBorderPen=function(){return a[2]};this.setLeftBorderPen=function(h){a[3]=h;g()};this.getLeftBorderPen=
function(){return a[3]};this.setBorderPen=function(h){for(var f=0;4>f;f++)a[f]=h;g()};this.getBorderPen=function(){return a[0]==a[1]&&a[0]==a[2]&&a[0]==a[3]?a[0]:null};this.setTopBorderWidth=function(h){k[0]=h;g(KTBorderStyle.BORDER_WIDTH)};this.getTopBorderWidth=function(){return k[0]};this.setRightBorderWidth=function(h){k[1]=h;g(KTBorderStyle.BORDER_WIDTH)};this.getRightBorderWidth=function(){return k[1]};this.setBottomBorderWidth=function(h){k[2]=h;g(KTBorderStyle.BORDER_WIDTH)};this.getBottomBorderWidth=
function(){return k[2]};this.setLeftBorderWidth=function(h){k[3]=h;g(KTBorderStyle.BORDER_WIDTH)};this.getLeftBorderWidth=function(){return k[3]};this.setBorderWidth=function(h){for(var f=0;4>f;f++)k[f]=h;g(KTBorderStyle.BORDER_WIDTH)};this.getBorderWidth=function(){return k[0]==k[1]&&k[0]==k[2]&&k[0]==k[3]?k[0]:null};this.setTopBorderColor=function(h){c[0]=h;g()};this.getTopBorderColor=function(){return c[0]};this.setRightBorderColor=function(h){c[1]=h;g()};this.getRightBorderColor=function(){return c[1]};
this.setBottomBorderColor=function(h){c[2]=h;g()};this.getBottomBorderColor=function(){return c[2]};this.setLeftBorderColor=function(h){c[3]=h;g()};this.getLeftBorderColor=function(){return c[3]};this.setBorderColor=function(h){for(var f=0;4>f;f++)c[f]=h;g()};this.getBorderColor=function(){return c[0]==c[1]&&c[0]==c[2]&&c[0]==c[3]?c[0]:null};this.copy=function(){var h=new KTBorderStyle;h.setTopBorderPen(this.getTopBorderPen());h.setRightBorderPen(this.getRightBorderPen());h.setBottomBorderPen(this.getBottomBorderPen());
h.setLeftBorderPen(this.getLeftBorderPen());h.setTopBorderWidth(this.getTopBorderWidth());h.setRightBorderWidth(this.getRightBorderWidth());h.setBottomBorderWidth(this.getBottomBorderWidth());h.setLeftBorderWidth(this.getLeftBorderWidth());h.setTopBorderColor(this.getTopBorderColor());h.setRightBorderColor(this.getRightBorderColor());h.setBottomBorderColor(this.getBottomBorderColor());h.setLeftBorderColor(this.getLeftBorderColor());return h};this.protectedCreateCssString=function(){var h="",f=this.getBorderPen();
null==f?(h+=KTAbstractStyle.createCssItem("border-top-style",this.getTopBorderPen()),h+=KTAbstractStyle.createCssItem("border-right-style",this.getRightBorderPen()),h+=KTAbstractStyle.createCssItem("border-bottom-style",this.getBottomBorderPen()),h+=KTAbstractStyle.createCssItem("border-left-style",this.getLeftBorderPen())):h+=KTAbstractStyle.createCssItem("border-style",f);f=this.getBorderWidth();null==f?(h+=KTAbstractStyle.createCssItem("border-top-width",this.getTopBorderWidth(),"px"),h+=KTAbstractStyle.createCssItem("border-right-width",
this.getRightBorderWidth(),"px"),h+=KTAbstractStyle.createCssItem("border-bottom-width",this.getBottomBorderWidth(),"px"),h+=KTAbstractStyle.createCssItem("border-left-width",this.getLeftBorderWidth(),"px")):h+=KTAbstractStyle.createCssItem("border-width",f,"px");f=this.getBorderColor();null==f?(h+=KTAbstractStyle.createCssItem("border-top-color",this.getTopBorderColor()),h+=KTAbstractStyle.createCssItem("border-right-color",this.getRightBorderColor()),h+=KTAbstractStyle.createCssItem("border-bottom-color",
this.getBottomBorderColor()),h+=KTAbstractStyle.createCssItem("border-left-color",this.getLeftBorderColor())):h+=KTAbstractStyle.createCssItem("border-color",f);return h}}KTBorderStyle.CSS_ID_PREFIXE="border";KTBorderStyle.BORDER_COMMON="borderCommon";KTBorderStyle.BORDER_WIDTH="borderWidth";
function KTStyleManager(){var b=new KTStyleManager.MultiMaps,a=function(k,c){c=b.getMap(c);var g=c[k];if(!g){if(k instanceof KTStyle)g=KTStyle.CSS_ID_PREFIXE;else if(k instanceof KTBorderStyle)g=KTBorderStyle.CSS_ID_PREFIXE;else throw Error("New type, modify here.");g+=++KTStyleManager.iStyleFlowId;g=[k,g];c[k]=g}return g};this.getShareStyle=function(k,c){return a(k,c)[0]};this.getShareStyleId=function(k,c){return a(k,c)[1]}}KTStyleManager.iStyleFlowId=0;KTStyleManager.PRIORITY_TABLE=0;
KTStyleManager.PRIORITY_ROW=1;KTStyleManager.PRIORITY_COLUMN=2;KTStyleManager.PRIORITY_CELL=3;KTStyleManager.MultiMaps=function(){var b=[];this.getMap=function(a){var k=b[a];k||(k={},b[a]=k);return k}};
function KTSelectionModel(b){var a=this,k=KTSelectionModel.MODE_NONE,c=KTSelectionModel.POLICY_CELL,g=[],h=new KTListenerProxy;this.setMode=function(f){k=f};this.getMode=function(){return k};this.setPolicy=function(f){c=f};this.getPolicy=function(){return c};this.isPolicySetting=function(f){return(c&f)==f};this.addChangeListener=function(f){h.addListener(KTSelectionModel.CHANGE_ADD,f);h.addListener(KTSelectionModel.CHANGE_REMOVE,f)};this.removeChangeListener=function(f){h.removeListener(KTSelectionModel.CHANGE_ADD,
f);h.removeListener(KTSelectionModel.CHANGE_REMOVE,f)};this.addSelected=function(f){if(!(f instanceof KTSelectionModel.Target))throw Error("Illegal argument.");g.push(f);h.fireListener(KTSelectionModel.CHANGE_ADD,[f])};this.appendSelected=function(f){if(!(f instanceof KTSelectionModel.Target))throw Error("Illegal argument.");if(this.hasSelected()){var n=this.getSelected(),l=a.parseBlockRange(f),v=a.parseBlockRange(n),z=Math.min(Math.min(Math.min(l[0],l[2]),v[0]),v[2]),r=Math.min(Math.min(Math.min(l[1],
l[3]),v[1]),v[3]),C=Math.max(Math.max(Math.max(l[0],l[2]),v[0]),v[2]);l=Math.max(Math.max(Math.max(l[1],l[3]),v[1]),v[3]);if(f.isSingleRow())r=z==C?a.createRowTarget(z):new KTSelectionModel.Target(Math.min(z,C),-1,Math.max(z,C));else if(f.isSingleColumn())r=r==l?a.createColumnTarget(r):new KTSelectionModel.Target(-1,Math.min(r,l),null,Math.max(r,l));else if(a.isPolicySetting(KTSelectionModel.POLICY_BLOCK))r=a.createBlockTarget(z,r,C,l);else{for(n=z;n<=C;n++)for(f=r;f<=l;f++)z=a.createCellTarget(n,
f),a.isContains(z)||a.addSelected(z);return}a.removeSelected(n);a.addSelected(r)}else a.addSelected(f)};this.removeSelected=function(f){for(var n=g.length-1;0<=n;n--){var l=g[n];if(l.equals(f))return g.splice(n,1),h.fireListener(KTSelectionModel.CHANGE_REMOVE,[l]),!0}return!1};this.removeAllSelecteds=function(){var f=g.slice(0);g=[];h.fireListener(KTSelectionModel.CHANGE_REMOVE,f)};this.setSelected=function(f){this.hasSelected()&&this.removeAllSelecteds();this.addSelected(f)};this.getSelecteds=function(){return g.concat()};
this.getSelected=function(){return this.hasSelected()?g[g.length-1]:null};this.hasSelected=function(){return 0<g.length};this.isSingleSelected=function(){return 1==g.length};this.isContains=function(f){for(var n=0;n<g.length;n++)if(g[n].equals(f))return!0;return!1};this.createCellTarget=function(f,n){var l=b.searchMergeBlock(f,n);return l?new KTSelectionModel.Target(l.getRowIdxFrom(),l.getColIdxFrom(),l.getRowIdxTo(),l.getColIdxTo()):new KTSelectionModel.Target(f,n)};this.createRowTarget=function(f){return KTSelectionModel.Target.createRow(f,
-1)};this.createColumnTarget=function(f){return KTSelectionModel.Target.createColumn(-1,f)};this.createBlockTarget=function(f,n,l,v){return f==l&&n==v?a.createCellTarget(f,n):new KTSelectionModel.Target(Math.min(f,l),Math.min(n,v),Math.max(f,l),Math.max(n,v))};this.parseBlockRange=function(f){var n=f.getRowIdx(),l=f.getColIdx(),v=f.getEndRowIdx(),z=f.getEndColIdx();if(f.isSingleCell())v=n,z=l;else if(f.isSingleRow()||f.isRows())f.isSingleRow()&&(v=n),l=0,z=b.getColumnsCount()-1;else if(f.isSingleColumn()||
f.isColumns())f.isSingleColumn()&&(z=l),n=0,v=b.getRowsCount()-1;return[n,l,v,z]}}KTSelectionModel.MODE_NONE="selection_mode_none";KTSelectionModel.MODE_SINGLE="selection_mode_single";KTSelectionModel.MODE_MULTI="selection_mode_multi";KTSelectionModel.POLICY_CELL=1;KTSelectionModel.POLICY_BLOCK=2;KTSelectionModel.POLICY_ROW=4;KTSelectionModel.POLICY_COLUMN=8;KTSelectionModel.CHANGE_ADD="selectionChange-add";KTSelectionModel.CHANGE_REMOVE="selectionChange-remove";
KTSelectionModel.Target=function(b,a,k,c){var g=k||0==k?k:null,h=c||0==c?c:null;this.getRowIdx=function(){return b};this.getColIdx=function(){return a};this.getEndRowIdx=function(){return g};this.getEndColIdx=function(){return h};this.equals=function(f){return this.getRowIdx()==f.getRowIdx()&&this.getColIdx()==f.getColIdx()&&this.getEndRowIdx()==f.getEndRowIdx()&&this.getEndColIdx()==f.getEndColIdx()};this.toString=function(){return b+","+a+"~"+g+","+h};this.isSingleCell=function(){return null==g&&
null==h&&-1!=b&&-1!=a};this.isSingleRow=function(){return null==g&&-1==a};this.isSingleColumn=function(){return-1==b&&null==h};this.isBlock=function(){return null!=g&&-1!=b&&null!=h&&-1!=a};this.isRows=function(){return null!=g&&g!=b&&-1==a};this.isColumns=function(){return-1==b&&null!=h&&h!=a}};KTSelectionModel.Target.createRow=function(b){return new KTSelectionModel.Target(b,-1)};KTSelectionModel.Target.createColumn=function(b){return new KTSelectionModel.Target(-1,b)};
function KTMergeBlock(b,a,k,c){var g=b,h=a,f=k,n=c;this.setRowIdxFrom=function(l){g=l};this.getRowIdxFrom=function(){return g};this.setRowIdxTo=function(l){h=l};this.getRowIdxTo=function(){return h};this.setColIdxFrom=function(l){f=l};this.getColIdxFrom=function(){return f};this.setColIdxTo=function(l){n=l};this.getColIdxTo=function(){return n};this.isInvalid=function(){return g>a||k>c||g==a&&f==c};this.equals=function(l){return l instanceof KTMergeBlock?l.getRowIdxFrom()==g&&l.getRowIdxTo()==h&&
l.getColIdxFrom()==f&&l.getColIdxTo()==n:!1};this.isContainCell=function(l,v){return l>=g&&l<=h&&v>=f&&v<=n}}
function KTMergeBlockSet(){function b(){var l=[],v=[],z=[],r=[];this.getStartFromMe=function(){return l};this.getAcrossFromHorizontal=function(){return v};this.getAcrossFromVertical=function(){return z};this.getAcrossFromBoth=function(){return r}}var a=[],k=null,c;this.clear=function(){a=[];k=null};this.remove=function(l){for(var v=0;v<a.length;v++)if(l.equals(a[v]))return a.splice(v,1),k=null,!0;return!1};this.append=function(l){var v=f(a,l.getRowIdxFrom(),l.getColIdxFrom());return l.equals(v)?!1:
(a.push(l),k=null,!0)};this.appendArray=function(l){a=a.concat(l);k=null};this.requestBucketing=function(){k=null};this.bucketing=function(l,v,z,r){if(null==k)for(k={},c=1E6<l?1E4:1E4<l?1E3:100,l=0;l<a.length;l++){v=a[l];for(var C=g(v.getRowIdxFrom(),z),x=g(v.getRowIdxTo(),z),u=C;u<=x;u+=c){var A=k[u];A||(A={},k[u]=A);for(var q=h(v.getColIdxFrom(),r),F=h(v.getColIdxTo(),r),L=q;L<=F;L+=100){var V=A[L];V||(V=new b,A[L]=V);(u==C?L==q?V.getStartFromMe():V.getAcrossFromHorizontal():L==q?V.getAcrossFromVertical():
V.getAcrossFromBoth()).push(v)}}}};var g=function(l,v){l<v?v=0:(l=parseInt((l-v)/c),v+=l*c);return v},h=function(l,v){l<v?v=0:(l=parseInt((l-v)/100),v+=100*l);return v};this.search=function(l,v,z,r){var C=null;if(0<a.length)if(k){if(z=g(l,z),z=k[z])if(r=h(v,r),r=z[r])C=f(r.getStartFromMe(),l,v),!C&&(C=f(r.getAcrossFromVertical(),l,v)),!C&&(C=f(r.getAcrossFromHorizontal(),l,v)),!C&&(C=f(r.getAcrossFromBoth(),l,v))}else C=f(a,l,v);return C};var f=function(l,v,z){for(var r=0;r<l.length;r++){var C=l[r];
if(C.isContainCell(v,z))return C}return null};this.visit=function(l,v,z,r,C,x,u){if(0!=a.length)if(k){var A=[v,z,r,C];v=g(v,x);z=g(z,x);for(x=v;x<=z;x+=c){var q=k[x];if(q)for(var F=h(r,u),L=h(C,u),V=F;V<=L;V+=100){var ha=q[V];if(ha){if(x==v&&V==F){if(n(l,A,ha.getAcrossFromBoth())||n(l,A,ha.getAcrossFromVertical())||n(l,A,ha.getAcrossFromHorizontal()))return}else if(x==v){if(n(l,A,ha.getAcrossFromVertical()))return}else if(V==F&&n(l,A,ha.getAcrossFromHorizontal()))return;if(n(l,A,ha.getStartFromMe()))return}}}}else for(u=
0;u<a.length&&(A=a[u],A.getRowIdxTo()<v||z<A.getRowIdxFrom()||A.getColIdxTo()<r||C<A.getColIdxFrom()||!l(A));u++);};this.visitAll=function(l){for(var v=0;v<a.length&&!l(a[v]);v++);};var n=function(l,v,z){var r=v[0],C=v[1],x=v[2];v=v[3];for(var u=0;u<z.length;u++){var A=z[u];if(!(A.getRowIdxTo()<r||C<A.getRowIdxFrom()||A.getColIdxTo()<x||v<A.getColIdxFrom())&&l(A))return!0}return!1};this.syncMergeBlocks=function(l,v,z){if(l){l="setRowIdxFrom";var r="getRowIdxFrom";var C="setRowIdxTo";var x="getRowIdxTo"}else l=
"setColIdxFrom",r="getColIdxFrom",C="setColIdxTo",x="getColIdxTo";for(var u=a.length-1;0<=u;u--){var A=a[u];if(z)v<=A[r]()?(A[l](A[r]()+1),A[C](A[x]()+1),k=null):v<=A[x]()&&(A[C](A[x]()+1),k=null);else{var q=!1;v<A[r]()?(A[l](A[r]()-1),A[C](A[x]()-1),q=!0,k=null):v<=A[x]()&&(A[C](A[x]()-1),q=!0,k=null);q&&A.isInvalid()&&a.splice(u,1)}}}}
function KTListenerProxy(){var b={};this.addListener=function(a,k){var c=b[a];c||(c=[],b[a]=c);for(a=0;a<c.length;a++)if(c[a]==k)return;c.push(k)};this.removeListener=function(a,k){if(a=b[a])for(var c=a.length-1;0<=c;c--)if(a[c]==k){a.splice(c,1);break}};this.fireListener=function(a,k){var c=b[a];if(c)for(var g=c.length-1;0<=g;g--)c[g](a,k)}}
function KTEmbedObject(b,a,k,c,g){var h=this,f,n=b,l=a,v=k,z=c,r=g,C,x;this.$innerBindChangeListener=function(u){f=u};this.setId=function(u){n=u};this.getId=function(){return n};this.setX=function(u){l!=u&&(l=u,f&&f(h,KTEmbedObject.BOUND,void 0,void 0))};this.getX=function(){return l};this.setY=function(u){v!=u&&(v=u,f&&f(h,KTEmbedObject.BOUND,void 0,void 0))};this.getY=function(){return v};this.setWidth=function(u){z!=u&&(z=u,f&&f(h,KTEmbedObject.BOUND,void 0,void 0))};this.getWidth=function(){return z};
this.setHeight=function(u){r!=u&&(r=u,f&&f(h,KTEmbedObject.BOUND,void 0,void 0))};this.getHeight=function(){return r};this.setType=function(u){C=u};this.getType=function(){return C};this.setUserObject=function(u){var A=x;x=u;f&&f(h,KTEmbedObject.DATA,x,A)};this.getUserObject=function(){return x}}KTEmbedObject.BOUND="embedObjectXYWH";KTEmbedObject.DATA="embedObjectData";
function KTCellTreeModel(b,a){var k,c=a?!0:!1,g=-1,h=!1,f=!0,n;this.$innerBindChangeListener=function(l){k=l};this.isHorizontal=function(){return c};this.getLevel=function(){return b};this.setHaveHandlerAlways=function(l){h=l};this.isHaveHandlerAlways=function(){return h};this.setExpanded=function(l){f!=l&&(f=l,k&&k(KTCellTreeModel.EXPANDED))};this.isExpanded=function(){return f};this.setLazyLoaded=function(l){n=l};this.isLazyLoaded=function(){return n};this.setLastChildLevel=function(l){g=l};this.getLastChildLevel=
function(){return g}}KTCellTreeModel.EXPANDED="expanded";
function KTDiagonalModel(){var b=KTDiagonalModel.BASE_LEFT_UP,a=1,k=1,c=[],g=[],h=[];this.setBasePoint=function(n){b=n};this.getBasePoint=function(){return b};this.setCrossRows=function(n){a=n};this.getCrossRows=function(){return a};this.setCrossColumns=function(n){k=n};this.getCrossColumns=function(){return k};this.setLinkToRows=function(n){c=n};this.getLinkToRows=function(){return c};this.setLinkToColumns=function(n){g=n};this.getLinkToColumns=function(){return g};this.getTriangleSize=function(){return c.length+
g.length+2};var f=function(n){var l=h[n];l||(l={text:"",lean:!0},h[n]=l);return l};this.setText=function(n,l){f(l).text=n};this.getText=function(n){return f(n).text};this.setLean=function(n,l){f(l).lean=n};this.isLean=function(n){return f(n).lean}}KTDiagonalModel.BASE_LEFT_UP="left-up";KTDiagonalModel.BASE_RIGHT_UP="right-up";KTDiagonalModel.BASE_LEFT_DOWN="left-down";KTDiagonalModel.BASE_RIGHT_DOWN="right-down";function KTableUI(b){function a(){this.fireEvent=function(e,p){F.fireListener(e,p)};this.isScrollDynamicRepaint=function(){return k.isScrollDynamicRepaint()};this.isDynamicRepaintWithCache=function(){return k.isDynamicRepaintWithCache()};this.isDynamicUpdateModel=function(){return A?!0:!1};this.getDynamicUpdateModelAliveDeltaRows=function(){return q};this.fireDynamicUpdateModelEvent=function(e,p,G){O(e,p,G)};this.buildStyle=function(e,p,G){return ca(e,p,G)};this.buildBorder=function(e,p,G){var H=
"";G&&(H+=ja(G.getBorder(),KTStyleManager.PRIORITY_CELL));H+=ja(p.getBorder(),KTStyleManager.PRIORITY_COLUMN);H+=ja(e.getBorder(),KTStyleManager.PRIORITY_ROW);return H+=ja(c.getBorder(),KTStyleManager.PRIORITY_TABLE)};this.searchRowIdx=function(e){e=!L||1>=L.length?-1:I(L,e);return e};this.searchCell=function(e,p){return P(e,p)};this.getRowY=function(e){return ra(e)};this.getColX=function(e){return V[e]}}KTableUI.INSERT_COL="insertColumn";KTableUI.REMOVE_COL="removeColumn";KTableUI.INSERT_ROW="insertRow";
KTableUI.REMOVE_ROW="removeRow";KTableUI.ADD_MERGEBLOCK="addMergeBlock";KTableUI.REMOVE_MERGEBLOCK="removeMergeBlock";KTableUI.FROZEN_ROW="frozenRow";KTableUI.FROZEN_COL="frozenCol";var k=this,c=b,g=$("<div>"),h,f,n,l,v=new KTableUIDraggableAdjustingHandler,z,r,C=!0,x=!1,u=!0,A,q,F=new KTListenerProxy,L=[],V=[],ha=!1;this.getHtmlElement=function(){if(!(0<g.children().length)){g.css("overflow","hidden");g.css("white-space","nowrap");var e=T().getUI();e.attr("id",c.getId()+T().getName());m(e);e.css("position",
"absolute");e.css("left",0);e.css("top",0);e.width("100%");e.height("100%");e.css("z-index",0);e.appendTo(g);M()}return g[0]};this.setScrollerVisible=function(e,p,G){var H=T().getUI();H.css("overflow-x",e?e:"hidden");H.css("overflow-y",p?p:"auto");G&&G(H)};var T=function(){h||(h=new KTableUIMainView(c,new a),k.addListener("scroll",Q),k.addListener("scroll",aa),k.addListener("mousedown",aa),k.addListener("mousedown",J),k.addListener("mousemove",J),k.addListener("mouseup",J),k.addListener("mousemove",
ka),g.on("mouseleave",fa),k.addListener("mousedown",v.mouseEventHandler),k.addListener("mousemove",v.mouseEventHandler),v.setContext(c,g,{getRowY:ra,getColX:pa,getScrollLeft:la,getScrollTop:na}));return h};this.setSyncUIWhenModelChanged=function(e){C=e};this.isSyncUIWhenModelChanged=function(){return C};this.setScrollDynamicRepaint=function(e,p){x=e?!0:!1;u=p||"undefined"==typeof p?!0:!1;0<g.children().length&&k.updateUI()};this.isScrollDynamicRepaint=function(){return x};this.isDynamicRepaintWithCache=
function(){return u};this.setScrollDynamicUpdateModelListener=function(e,p){q=e;A=p};var O=function(e,p,G){A&&!ha&&A(e,p,function(){G();n&&n.repaint();K()})};this.updateUI=function(e,p){c.getCellRender().reset();c.bucketingMergeBlocks();if(c.isColumnFitVisibleWidth()){for(var G=0,H=0,W=c.getColumnsCount();H<W;H++){var da=c.getColumn(H);da.isHide()||(G+=da.getWidth())}var ia=g.prop("clientWidth")-1,ea=c.isSyncUIWhenModelChanged();c.setSyncUIWhenModelChanged(!1);G=ia/G;H=0;for(W=c.getColumnsCount();H<
W;H++)if(da=c.getColumn(H),!da.isHide()){var oa=parseInt(da.getWidth()*G);da.setWidth(oa);ia-=oa}if(0<ia)for(H=c.getColumnsCount()-1;0<=H;H--)if(da=c.getColumn(H),!da.isHide()){da.setWidth(da.getWidth()+ia);break}c.setSyncUIWhenModelChanged(ea)}N(-1);X(-1);var ma;e&&(ma=p?p:k.keepScrollStatus());ha=!0;T().updateUI();B();f&&f.updateUI();n&&n.updateUI();l&&l.updateUI();U();K();ha=!1;e&&k.restoreScrollStatus(ma)};this.keepScrollStatus=function(){var e=T().getUI().prop("scrollTop"),p=T().getUI().prop("scrollLeft");
return{v:e,h:p}};this.restoreScrollStatus=function(e){var p=e.v;e=e.h;T().getUI().prop("scrollTop",p);T().getUI().prop("scrollLeft",e)};this.scrollCellVisible=function(e,p,G){var H=c.getFrozenColumns(),W=c.getFrozenRows();H=V[H];W=L[W];var da=V[p];p=da+c.getColumn(p).getWidth();var ia=L[e];e=ia+c.getRow(e).getHeight();var ea=T().getUI().prop("scrollLeft"),oa=T().getUI().prop("scrollTop"),ma=T().getUI().prop("clientWidth"),ta=T().getUI().prop("clientHeight"),ua=ea+ma,va=oa+ta,sa=!1;da<ea+H?(sa=!0,
ea=da-H):p>ua&&(sa=!0,ea=p-ma);ia<oa+W?(sa=!0,oa=ia-W):e>va&&(sa=!0,oa=e-ta);sa&&(G?T().getUI().animate({scrollTop:oa,scrollLeft:ea}):T().getUI().prop({scrollTop:oa,scrollLeft:ea}))};this.showPromptForLazyAppendData=function(e){e?(r||(r=$('<div style="position:absolute; left:0; right:0; top:0; bottom:0">'),r.css("z-index",128),e=$('<div style="position:absolute; left:0; right:0; top:0; bottom:0">'),e.css("background-color","#CCCCCC"),e.css("opacity",.5),e.appendTo(r),e=$("<div>"),e.css("position",
"absolute"),e.width(120),e.height(20),e.css("padding",10),e.css("background-color","#D0E3F6"),e.css("border","1px solid #97B3CB"),e.text("\u6570\u636e\u52a0\u8f7d\u4e2d..."),e.appendTo(r)),r.appendTo(g),e=r.find(":last-child"),e.css("left",(g.width()-e.width())/2),e.css("top",(g.height()-e.height())/2)):r&&r.remove()};this.repaintAfterLazyAppendData=function(e){c.getCellRender().reset();X(e);T().reset();T().repaint();T().adjustFootPlaceholder();n&&(n.reset(),n.repaint(),n.adjustFootPlaceholder());
K()};var X=function(e){var p=c.getRowsCount();L.length>p+1&&(L.length=p+1);for(var G=0<=e?L[e]:0,H=e=0<=e?e:0;H<p;H++){L[H]=G;var W=c.getRow(H);W.isHide()||(W=W.getHeight(),G+=W)}L[p]=G;p=e;if(b.isAutoAdjustRowHeight())for(e=0,p=0<=p?p:0,G=L.length-1;p<G;p++){W=c.getRow(p);if(!W.isHide()){for(var da=H=0,ia=c.getColumnsCount();da<=ia;da++){var ea=W.getCellForDraw(da);if(ea){var oa=c.getColumn(da);if(c.getStyleValue(ea,oa,W,"getStyle","isWrapText",!1)){var ma=p;var ta=da,ua=W,va=ea;ea=c.searchMergeBlock(ma,
ta);if(!ea||ma==ea.getRowIdxFrom()&&ta==ea.getColIdxFrom()){var sa=(ea?V[ea.getColIdxTo()+1]-V[ea.getColIdxFrom()]:oa.getWidth())-4;if(0>sa)ma=0;else{var xa=ca(ua,oa,va),wa=c.getCellRender();wa.setContext(ua,oa,va,ma,ta,NaN,NaN,sa,NaN);ma=wa.calculateCellHeight(xa);ea&&(ma-=L[ea.getRowIdxTo()+1]-L[ea.getRowIdxFrom()+1],ma=0>ma?0:ma);ma+=4}}else ma=0;H=ma>H?ma:H}}}W=W.getHeight();H>W&&(e+=H-W)}L[p+1]+=e}},N=function(e){var p=c.getColumnsCount();V.length>p+1&&(V.length=p+1);var G=0<=e?V[e]:0;for(e=
0<=e?e:0;e<p;e++){V[e]=G;var H=c.getColumn(e);H.isHide()||(H=H.getWidth(),G+=H)}V[p]=G},P=function(e,p){if(!V||1>=V.length||!L||1>=L.length||e>=V[V.length-1]||p>=L[L.length-1])return null;e=I(V,e,!0);return[I(L,p,!0),e]},I=function(e,p,G){for(var H,W=[0,e.length-2];W;){var da=W[0],ia=W[1];if(da==ia){H=da;break}var ea=da+ia>>1;if(e[ea]==p){H=ea;break}else if(e[ea]<p)W[0]=ea+1,W[1]=ia;else if(e[ea]>p){if(ea-1<da){H=ea;break}W[0]=da;W[1]=ea-1}else throw Error("Prevent endless loop.");}if(G){for(;e[H]>
p&&0<H;)--H;for(;e[H+1]<=p&&H<e.length-2;)H+=1}return H};this.modelChangeHandler=function(e,p){if(C&&0<g.children().length){var G=T().modelChangeHandler(e,p);f&&(G=G||f.modelChangeHandler(e,p));n&&(G=G||n.modelChangeHandler(e,p));l&&(G=G||l.modelChangeHandler(e,p));G&&k.updateUI(!0)}};this.propertyChangeHandler=function(e,p,G,H){if(C&&0<g.children().length)switch(p){case KTColumn.WIDTH:N(c.getColumnIndex(e));R(e,p,G,H);B();E();break;case KTRow.HEIGHT:X(c.getRowIndex(e));R(e,p,G,H);D();break;case KTableUI.FROZEN_ROW:case KTableUI.FROZEN_COL:M();
k.updateUI();break;case KTRow.HIDE:var W=c.getRowIndex(e);X(W);R(e,p,G,H);B();E();D();break;case KTColumn.HIDE:W=c.getColumnIndex(e);N(W);R(e,p,G,H);B();E();D();break;case KTEmbedObject.DATA:T().propertyChangeHandler(e,p,G,H);break;default:R(e,p,G,H)}};var R=function(e,p,G,H){var W=T().propertyChangeHandler(e,p,G,H);f&&(W=W||f.propertyChangeHandler(e,p,G,H));n&&(W=W||n.propertyChangeHandler(e,p,G,H));l&&(W=W||l.propertyChangeHandler(e,p,G,H));W&&k.updateUI(!0)};this.addListener=function(e,p){F.addListener(e,
p)};this.removeListener=function(e,p){F.removeListener(e,p)};var M=function(){var e=c.getFrozenRows(),p=c.getFrozenColumns();e=0<e;p=0<p;var G=e&&p;e&&!f?(f=new KTableUITopFrozenView(c,new a),w(f,1)):!e&&f&&(y(f),f=null);p&&!n?(n=new KTableUILeftFrozenView(c,new a),w(n,1)):!p&&n&&(y(n),n=null);G&&!l?(l=new KTableUICornerFrozenView(c,new a),w(l,2)):!G&&l&&(y(l),l=null)},m=function(e){var p=c.getUICustomStyleMap();p=p?p["background-color"]:null;e.css("background-color",p?p:"#fff")},w=function(e,p){e=
e.getUI();e.appendTo(g);e.css("z-index",p);e.css("top",0);e.css("left",0);m(e)},y=function(e){e.getUI().remove();e.destroy()};this.relayoutViews=function(){T().repaint();B();E();D();U();K()};var B=function(){if(f){var e=T().getUI().prop("clientWidth");f.getUI().width(e)}n&&(e=T().getUI().prop("clientHeight"),n.getUI().height(e))},Q=function(e,p){p.isHorizontalScroll()&&(E(),U());p.isVerticalScroll()&&(D(),K())},E=function(){if(f){var e=la();f.getUI().prop("scrollLeft",e)}},D=function(){if(n){var e=
na();n.getUI().prop("scrollTop",e);k.isScrollDynamicRepaint()&&(n.setBlankFirstImmediately(h.isBlankFirstImmediately()),n.repaint(),n.setBlankFirstImmediately(!1))}},U=function(){if(c.isMergeBlockTextVisibleAlways()&&1<V.length){var e=la(),p=e+T().getUI().prop("clientWidth");e+=n?n.getUI().prop("offsetWidth"):0;var G=I(V,e,!0),H=I(V,p,!0);(f?f:T()).adjustHorizontalFrontierCell(e,p,G,H)}},K=function(){if(c.isMergeBlockTextVisibleAlways()&&1<L.length){var e=na(),p=e+T().getUI().prop("clientHeight");
e+=f?f.getUI().prop("offsetHeight"):0;var G=I(L,e,!0),H=I(L,p,!0);(n?n:T()).adjustVerticalFrontierCell(e,p,G,H)}};this.popupMenu=function(e,p,G,H,W){aa();if(G&&0!=G.length){if(W){var da=W["background-color"];var ia=W["border-color"];var ea=W["font-size"];var oa=W["selection-color"]}da=da?da:"#D0E3F6";ia=ia?ia:"#97B3CB";ea=ea?ea:12;oa=oa?oa:"#FFE358";z=$("<div>");z.css("z-index",64);z.css("position","absolute");z.css("cursor","pointer");z.css("border","1px solid");z.css("border-color",ia);z.css("background-color",
da);z.css("font-size",ea);for(W=0;W<G.length;W++)da=G[W],ia=$("<div>"),ia.text(da.getText()),ia.css("padding",2),ia.click(Z(H,da)),ia.mouseover(function(ma){$(ma.target).css("background-color",oa)}),ia.mouseout(function(ma){$(ma.target).css("background-color","")}),z.append(ia);g.append(z);e+z.width()>g.width()&&(z.width(z.width()+2),e=g.width()-z.width()-5,e=0>e?0:e);p+z.height()>g.height()&&(p=g.height()-z.height()-5,p=0>p?0:p);z.css("left",e);z.css("top",p)}};var Z=function(e,p){return function(G){aa();
e&&e(p)}},aa=function(){z&&z.remove()},ba=!1,d=!1,t=null,J=function(e,p){p.isStopped()||c.getSelectionModel().getMode()==KTSelectionModel.MODE_NONE||null===c.getSelectionRender()||("mousedown"==e?p.isLeftButton()&&(e=p.getMouseTargetModel(),e instanceof KTCell.Path&&(ba=!0,t=c.getSelectionModel().createCellTarget(e.getRowIndex(),e.getColIndex()))):"mouseup"==e?(d&&(S(null),e=p.getMouseTargetModel(),e instanceof KTCell.Path&&(e=c.getSelectionModel().createCellTarget(e.getRowIndex(),e.getColIndex()),
e.equals(t)||c.getSelectionModel().appendSelected(e))),ba=d=!1,t=null):"mousemove"==e&&c.getSelectionModel().isPolicySetting(KTSelectionModel.POLICY_BLOCK)&&(ba&&!d&&(d=!0),d&&(e=p.getMouseTargetModel(),S(e))))},S=function(e){var p=null;if(e instanceof KTCell.Path){p=c.getSelectionModel();e=p.createCellTarget(e.getRowIndex(),e.getColIndex());e=p.parseBlockRange(e);var G=p.parseBlockRange(t);p=p.createBlockTarget(Math.min(Math.min(Math.min(e[0],e[2]),G[0]),G[2]),Math.min(Math.min(Math.min(e[1],e[3]),
G[1]),G[3]),Math.max(Math.max(Math.max(e[0],e[2]),G[0]),G[2]),Math.max(Math.max(Math.max(e[1],e[3]),G[1]),G[3]))}h.showDragingMarkBundle(p);l&&l.showDragingMarkBundle(p);n&&n.showDragingMarkBundle(p);f&&f.showDragingMarkBundle(p)},Y=function(e,p){e==KTSelectionModel.CHANGE_ADD&&(e=c.getSelectionModel().parseBlockRange(p[0]),F.fireListener("new-select",[V[e[1]],L[e[0]],V[e[3]+1],L[e[2]+1]]))},ca=function(e,p,G){var H="";G&&(H+=ja(G.getStyle(),KTStyleManager.PRIORITY_CELL));H+=ja(p.getStyle(),KTStyleManager.PRIORITY_COLUMN);
H+=ja(e.getStyle(),KTStyleManager.PRIORITY_ROW);return H+=ja(c.getStyle(),KTStyleManager.PRIORITY_TABLE)},ja=function(e,p){if(!e)return"";var G=c.getStyleManager().getShareStyleId(e,p),H=KTableUI.oMapsCssName.getMap(p);if(!H[G]){H[G]=!0;H="."+G;e=e.toCssString();p=KTableUI.sStyleNodeIdPrefix+p;for(var W,da=document.styleSheets.length-1;0<=da;da--){var ia=document.styleSheets[da];if((ia.id||""==ia.id?ia.id:ia.ownerNode.id)==p){W=ia;break}}W.addRule?W.addRule(H,e):W.insertRule(H+"{"+e+"}",W.cssRules.length)}return" "+
G};this.selectByPoint=function(e,p){p=P(e,p);if(!p)return!1;e=c.getSelectionModel();p=e.isPolicySetting(KTSelectionModel.POLICY_ROW)?e.createRowTarget(p[0]):e.isPolicySetting(KTSelectionModel.POLICY_COLUMN)?e.createColumnTarget(p[1]):e.createCellTarget(p[0],p[1]);e.removeAllSelecteds();e.addSelected(p);return!0};var ka=function(e,p){if(e=c.getCellAcrossListener())if(p.isCellPointed()){var G=p.getMouseTargetModel(),H=c.getSelectionModel().createCellTarget(G.getRowIndex(),G.getColIndex());G=H.getRowIdx();
H=H.getColIdx();p=$(p.getOriginalEvent().currentTarget);var W=KTableUIAbstractView.createCellId(c.getRow(G),c.getColumn(H));p=p.find("#"+W);e(p,G,H,qa)}else e(null,-1,-1,qa)},fa=function(e){(e=c.getCellAcrossListener())&&e(null,-1,-1,qa)},qa=function(e,p){if(void 0===p){var G="*[id*='"+KTableUIAbstractView.createCellId(c.getRow(e))+"']";return g.find(G)}G="#"+KTableUIAbstractView.createCellId(c.getRow(e),c.getColumn(p));e=function(H){return(H=H?H.getCellsContainer().find(G):null)&&0<H.length?H:null};
return e(l)||e(n)||e(f)||e(h)},la=function(){return T().getUI().prop("scrollLeft")},na=function(){return T().getUI().prop("scrollTop")},ra=function(e){return e>=L.length?L[L.length-1]:L[e]},pa=function(e){return V[e]};(function(){if(!KTableUI.sStyleNodeIdPrefix){KTableUI.sStyleNodeIdPrefix="_ktable_style_";var e=$("head"),p=KTableUI.sStyleNodeIdPrefix+KTStyleManager.PRIORITY_TABLE;e.append($('<style type="text/css" id="'+p+'">'));p=KTableUI.sStyleNodeIdPrefix+KTStyleManager.PRIORITY_ROW;e.append($('<style type="text/css" id="'+
p+'">'));p=KTableUI.sStyleNodeIdPrefix+KTStyleManager.PRIORITY_COLUMN;e.append($('<style type="text/css" id="'+p+'">'));p=KTableUI.sStyleNodeIdPrefix+KTStyleManager.PRIORITY_CELL;e.append($('<style type="text/css" id="'+p+'">'))}c.getSelectionModel().addChangeListener(Y)})()}KTableUI.sStyleNodeIdPrefix=null;KTableUI.oMapsCssName=new KTStyleManager.MultiMaps;
function KTableUIAbstractView(b,a){function k(m,w,y,B,Q,E,D,U){KTAbstractMouseEvent.call(this,m,w,y,B,Q);var K;this.getOriginalEvent=function(){return m};this.isCellPointed=function(){return E instanceof KTCell.Path};this.getMouseTargetModel=function(){return E};this.isPointTreeHandler=function(){return D};this.isPointScrollBar=function(){return U};this.setXYCellAtTable=function(Z,aa){K=[Z,aa]};this.getXYCellAtTable=function(){return K}}function c(){KTableSelectionRender.call(this);var m=$("<div>"),
w=$("<div>"),y=$("<div>"),B=$("<div>");this.show=function(D,U,K,Z,aa){--U;--K;--Z;--aa;var ba=Z-U,d=aa-K;Q(m,U,K,ba,0);Q(y,U,aa,ba,0);Q(B,U,K,0,d);Q(w,Z,K,0,d);D.append(m);D.append(w);D.append(y);D.append(B)};this.remove=function(){m.remove();w.remove();y.remove();B.remove()};this.current=function(){E(m);E(y);E(B);E(w)};var Q=function(D,U,K,Z,aa){D.attr("ktableUiMark","selectionBundle");D.css("z-index",64);D.css("position","absolute");D.css("left",U);D.css("top",K);D.width(Z);D.height(aa);D.css("overflow",
"hidden");D.css("border-width","1px");D.css("border-style","solid");E(D)};this.letOthersOld=function(D){D.children("div[ktableUiMark='selectionBundle']").css("border-color","#ffcc33")};var E=function(D){D.css("border-color","#aa6600")}}var g=this,h=$("<div>"),f,n={};this.getName=function(){throw Error("Override me.");};this.getViewTag=function(){throw Error("Override me.");};this.destroy=function(){};this.getUI=function(){return h};this.getCellsContainer=function(){f||(f=$("<div>"),f.attr("ktableUiMark",
"allCellLayer"),f.css("z-index",1),f.css("position","absolute"),f.css("left",0),f.css("top",0),h.append(f));return f};this.updateUI=function(){g.protectedBeforeUpdateUI();h.children(":not([ktableUiMark='allCellLayer'])").remove();g.getCellsContainer().empty();g.repaint();g.adjustFootPlaceholder();g.adjustRightPlaceholder()};this.protectedBeforeUpdateUI=function(){};this.adjustFootPlaceholder=function(){var m=a.getRowY(b.getRowsCount())+1;g.getCellsContainer().css("height",m)};this.adjustRightPlaceholder=
function(){var m=b.getDraggableAdjusting(),w=0;m&&(w=(w=m?m[2]:null)?w.getTailBlankForDragging():60);m=a.getColX(b.getColumnsCount())+1;m+=w;g.getCellsContainer().css("width",m)};this.protectedBeforeRepaint=function(m){throw Error("Override me.");};this.protectedIsNeedCreatingRow=function(m,w,y,B){return!0};this.protectedAfterRepaint=function(m,w,y){};this.protectedGetPaintRect=function(){throw Error("Override me.");};this.repaint=function(){l();var m=b.getEmbedObjects(),w=g.protectedGetPaintRect(),
y=w[0],B=w[1],Q=w[2];w=w[3];for(var E=0;E<m.length;E++){var D=m[E];if(!(D.getY()+D.getHeight()<y||D.getY()>B||D.getX()+D.getWidth()<Q||D.getX()>w)){var U=q(D);if(0==($.parseHTML?h.find($.parseHTML("#"+U)):h.find("#"+U)).length){var K=z("div",D.getX(),D.getY(),D.getWidth(),D.getHeight());K.id=U;K.style.zIndex=128;U=$(K);U.appendTo(h);K=b.getEmbedObjectRender();K.setViewTag(g.getViewTag());K.paintEmbedObject(D,U)}}}};this.adjustVerticalFrontierCell=function(m,w,y,B){var Q=g.protectedBeforeRepaint();
b.visitMergeBlocks(y,B,Q[2],Q[3],function(E){if(E.getRowIdxFrom()!=E.getRowIdxTo()){var D=V(E);if(D.length){var U=D[D.length-1];D=$(U);var K=a.getRowY(E.getRowIdxFrom()),Z=a.getRowY(E.getRowIdxTo()+1),aa=Math.max(m,K),ba=Math.min(w,Z)-aa-(Z-K);Z=D.width();ba=D.height()+ba;if(!(20>ba)||y<E.getRowIdxFrom()&&E.getRowIdxTo()<B)if(K=aa-K,a.isDynamicUpdateModel())$(U).children().css({top:K,height:ba,"line-height":ba+"px"});else{aa=E.getRowIdxFrom();var d=E.getColIdxFrom(),t=b.getRow(aa),J=b.getColumn(d),
S=t.getCell(d);0==aa&&0==d&&S&&S.getValue()instanceof KTDiagonalModel||(D.empty(),v(U,aa,d,t,J,S,E,0,K,Z,ba))}}}})};this.adjustHorizontalFrontierCell=function(m,w,y,B){var Q=g.protectedBeforeRepaint();b.visitMergeBlocks(Q[0],Q[1],y,B,function(E){if(E.getColIdxFrom()!=E.getColIdxTo()){var D=V(E);if(D.length){var U=D[D.length-1];D=$(U);var K=a.getColX(E.getColIdxFrom()),Z=a.getColX(E.getColIdxTo()+1),aa=Math.max(m,K),ba=Math.min(w,Z)-aa-(Z-K);Z=E.getRowIdxFrom();var d=E.getColIdxFrom(),t=b.getRow(Z),
J=b.getColumn(d),S=t.getCell(d);if(!(0==Z&&0==d&&S&&S.getValue()instanceof KTDiagonalModel)){ba=D.width()+ba;var Y=D.height();K=aa-K;D.empty();v(U,Z,d,t,J,S,E,K,0,ba,Y)}}}})};this.createVisibleRect=function(){var m=g.getUI().prop("clientWidth");!m&&(m=window.screen.width);var w=g.getUI().prop("clientHeight");!w&&(w=window.screen.height);var y=g.getUI().prop("scrollLeft");return[y,iY1,y+m,iY1+w]};var l=function(m){g.protectedBeforeRepaint(function(w,y,B,Q,E){m?g.getCellsContainer().empty():a.isScrollDynamicRepaint()?
(g.getUI().find("*[isProxyFirstCell='true']").remove(),a.isDynamicUpdateModel()&&g.getUI().find("*[isBlankFirst=true]").remove()):g.getCellsContainer().empty();if(!(-1==w&&-1==y||-1==B&&-1==Q)){for(var D=w,U=[],K=!0,Z=document.createDocumentFragment(),aa=w;aa<=y;aa++){var ba=b.getRow(aa);K&&(ba.isHide()?D++:K=!1);if(!ba.isHide()&&g.protectedIsNeedCreatingRow(aa,D,F,E))for(var d=a.getRowY(aa),t=B;t<=Q;t++){var J=b.getColumn(t);if(!J.isHide()){var S=ba.getCellForDraw(t),Y=a.getColX(t);a:{var ca=aa;
var ja=t,ka=ba,fa=Y,qa=d,la=U;Y=r(ca,ja,D);var na=ka,ra=!1;if(!1===Y){var pa=a.getColX(ja+1)-a.getColX(ja);var e=a.getRowY(ca+1)-a.getRowY(ca);Y=null}else if(Y){Y instanceof Array&&(ra=Y[1],Y=Y[0]);if(Y.getRowIdxFrom()!=ca||Y.getColIdxFrom()!=ja)ca=Y.getRowIdxFrom(),ka=b.getRow(ca),ja=Y.getColIdxFrom(),J=b.getColumn(ja),a.isDynamicUpdateModel()&&S?(pa=S.getValue(),S=ka.getCell(ja),S.setValue(pa)):S=ka.getCellForDraw(ja),qa=a.getRowY(ca),fa=a.getColX(ja);pa=Y.getColIdxTo()+1;e=Y.getRowIdxTo()+1;pa=
pa>b.getColumnsCount()?b.getColumnsCount():pa;e=e>b.getRowsCount()?b.getRowsCount():e;pa=a.getColX(pa)-a.getColX(Y.getColIdxFrom());e=a.getRowY(e)-a.getRowY(Y.getRowIdxFrom())}else{ca=null;break a}A(pa,e,S,J,ka,la);var p=la[0],G=la[1],H=la[2];la=la[3];na=F(na,J);fa=z("div",fa+p,qa+G,H,la);fa.id=na;fa.style.zIndex=S&&S.getValue()?2:1;Y&&$(fa).attr("mergeBlock",L(Y));qa=a.buildStyle(ka,J,S);qa+=a.buildBorder(ka,J,S);fa.className=qa;ra&&$(fa).attr("isProxyFirstCell","true");if(S&&S.getValue()instanceof
KTDiagonalModel){if(ca=b.getDiagonalRender().create(b,S.getValue(),ca,ja,pa,e))fa.appendChild(ca),ca.style.position="absolute",ca.style.left=p+"px",ca.style.top=G+"px",ca.style.width=pa+"px",ca.style.height=e+"px"}else v(fa,ca,ja,ka,J,S,Y,0,0,H,la);ca=fa}ca&&(E&&$(ca).attr("isBlankFirst",!0),Z.appendChild(ca))}}}g.getCellsContainer()[0].appendChild(Z);E||g.protectedAfterRepaint(w,y,F)}})},v=function(m,w,y,B,Q,E,D,U,K,Z,aa){var ba=Z,d=aa;if(E&&E.getTreeModel()){var t=b.getTreeHandlerRender();t.setUiDependence(a);
t.setMergeBlock(D);U=t.create(E.getTreeModel(),w,y,U,K,Z,aa);if(K=U[0])K.ktableUiMark="treeHandler",K.style.zIndex=2,m.appendChild(K);(K=U[2])&&m.appendChild(K);if(t=U[1])t.ktableUiMark="textSpan",t.style.zIndex=1,m.appendChild(t),ba=parseInt(t.style.width),d=parseInt(t.style.height);K=U=0}D=b.getCellRender();D.setContext(B,Q,E,w,y,Z,aa,ba,d);D.setTextOffset(U,K);D.paintCellUI(m,t)},z=function(m,w,y,B,Q){m=document.createElement(m);m.style.overflow="hidden";m.style.position="absolute";m.style.left=
w+"px";m.style.top=y+"px";m.style.width=B+"px";m.style.height=Q+"px";return m},r=function(m,w,y){var B=b.searchMergeBlock(m,w);if(B){if(m==B.getRowIdxFrom()&&w==B.getColIdxFrom())return B;if(m==y&&B.getRowIdxFrom()<y&&w==B.getColIdxFrom())return[B,!0];y=B.getRowIdxFrom()-1;for(var Q=null;y<m&&(null==Q||Q.isHide());)Q=b.getRow(++y);if(y==m){m=B.getColIdxFrom()-1;for(y=null;m<w&&(null==y||y.isHide());)y=b.getColumn(++m);if(m==w)return[B,!1]}return null}return!1},C=function(m,w,y,B){B.removeClass(function(){return u($(this),
KTStyle.CSS_ID_PREFIXE)});B.addClass(a.buildStyle(m,w,y))},x=function(m,w,y,B){B.removeClass(function(){return u($(this),KTBorderStyle.CSS_ID_PREFIXE)});B.addClass(a.buildBorder(m,w,y,B))},u=function(m,w){if(m=m.attr("class")){var y=m.split(" ");m="";for(var B=0;B<y.length;B++)0==y[B].indexOf(w)&&(0<m.length&&(m+=" "),m+=y[B])}return m},A=function(m,w,y,B,Q,E){var D=b.getStyleValue(y,B,Q,"getBorder","getRightBorderWidth",0),U=b.getStyleValue(y,B,Q,"getBorder","getLeftBorderWidth",0),K=b.getStyleValue(y,
B,Q,"getBorder","getTopBorderWidth",0);B=b.getStyleValue(y,B,Q,"getBorder","getBottomBorderWidth",0);y=U>>1;m=m-(U-y)-(D>>1);D=K>>1;w=w-(K-D)-(B>>1);E[0]=-y;E[1]=-D;E[2]=0>m?0:m;E[3]=0>w?0:w},q=function(m){return b.getId()+g.getName()+"_Embed_"+m.getId()},F=function(m,w){return KTableUIAbstractView.createCellId(m,w)},L=function(m){return[m.getRowIdxFrom(),m.getRowIdxTo(),m.getColIdxFrom(),m.getColIdxTo()].join()},V=function(m){return g.getUI().find("[mergeBlock='"+L(m)+"']")};this.propertyChangeHandler=
function(m,w,y,B){switch(w){case KTColumn.WIDTH:this.protectedUpdateColumnWidth();break;case KTRow.HEIGHT:return!0;case KTCell.VALUE:T(m);break;case KTStyle.STYLE_COMMON:case KTStyle.STYLE_TEXT_SPECIAL:case KTBorderStyle.BORDER_COMMON:case KTBorderStyle.BORDER_WIDTH:if(m instanceof KTable)return!0;if(m instanceof KTCell.Path)y=w==KTBorderStyle.BORDER_WIDTH?a.getColX(m.getColIndex()):0,B=w==KTBorderStyle.BORDER_WIDTH?a.getRowY(m.getRowIndex()):0,ha(m.getRow(),m.getCol(),m.getCell(),w,y,B),T(m);else if(m instanceof
KTRow){var Q=b.getRowIndex(m);B=w==KTBorderStyle.BORDER_WIDTH?a.getRowY(b.getRowIndex(m)):0;for(var E=0,D=b.getColumnsCount();E<D;E++){var U=b.getColumn(E),K=m.getCellForDraw(E);y=a.getColX(Z);ha(m,U,K,w,y,B);K=new KTCell.Path(m,E,K);K.$innerSetInfo(Q,U);T(K)}}else if(m instanceof KTColumn){y=w==KTBorderStyle.BORDER_WIDTH?a.getColX(b.getColumnIndex(m)):0;Q=b.getColumnIndex(m);var Z=0;for(E=b.getRowsCount();Z<E;Z++)D=b.getRow(Z),K=D.getCellForDraw(Q),B=a.getRowY(Z),ha(D,m,K,w,y,B),K=new KTCell.Path(D,
Q,K),K.$innerSetInfo(Z,m),T(K)}break;case KTRow.HIDE:this.protectedUpdateByRowHide();break;case KTColumn.HIDE:this.protectedUpdateByColumnHide();break;case KTEmbedObject.DATA:w=q(m),w=h.find("#"+w),0<w.length&&(Z=b.getEmbedObjectRender(),Z.setViewTag(g.getViewTag()),Z.paintEmbedObject(m,w))}return!1};this.modelChangeHandler=function(m,w){switch(w){case KTableUI.INSERT_COL:case KTableUI.REMOVE_COL:return!0;case KTableUI.INSERT_ROW:case KTableUI.REMOVE_ROW:return!0;case KTableUI.ADD_MERGEBLOCK:case KTableUI.REMOVE_MERGEBLOCK:return!0}return!1};
this.protectedUpdateColumnWidth=function(){l(!0);g.adjustRightPlaceholder()};this.protectedUpdateByRowHide=function(){l();g.adjustFootPlaceholder()};this.protectedUpdateByColumnHide=function(){l();g.adjustRightPlaceholder()};var ha=function(m,w,y,B,Q,E){var D=F(m,w);D=h.find("#"+D);if(0!=D.length)if(B==KTStyle.STYLE_COMMON||B==KTStyle.STYLE_TEXT_SPECIAL)C(m,w,y,D);else if(B==KTBorderStyle.BORDER_COMMON)x(m,w,y,D);else if(B==KTBorderStyle.BORDER_WIDTH){x(m,w,y,D);B=[];var U=b.getRowIndex(m);U=a.getRowY(U+
1)-a.getRowY(U);var K=b.getColumnIndex(w);K=a.getColX(K+1)-a.getColX(K);A(K,U,y,w,m,B);D.css("left",Q+B[0]);D.css("top",E+B[1]);D.width(B[2]);D.height(B[3])}},T=function(m){var w=F(m.getRow(),m.getCol());w=h.find("#"+w);if(0!=w.length){for(var y=null,B=w.width(),Q=w.height(),E=w.find("span"),D=0;D<E.length;D++)if("textSpan"==E[D].ktableUiMark){y=E[D];Q=$(y);B=Q.width();Q=Q.height();break}E=b.getCellRender();E.setContext(m.getRow(),m.getCol(),m.getCell(),m.getRowIndex(),m.getColIndex(),w.width(),w.height(),
B,Q);E.paintCellUI(w[0],y)}},O=[-65535,-65535],X=0,N=function(m){var w=m.type;"click"!=w&&("mouseup"==w?5>Math.abs(O[0]-m.screenX)&&5>Math.abs(O[1]-m.screenY)&&P(m,"click"):"mousedown"==w&&(300>(new Date).getTime()-X&&(P(m,"dblclick"),X=0),X=(new Date).getTime(),O=[m.screenX,m.screenY]),P(m,w))},P=function(m,w){var y=h[0],B=0,Q=0,E=m.target;E==y&&(B=y.scrollLeft,Q=y.scrollTop);for(;E&&E!=y;)B+=E.offsetLeft,Q+=E.offsetTop,E=E.parentNode;var D=B+(void 0==m.offsetX?m.originalEvent.layerX:m.offsetX),
U=Q+(void 0==m.offsetY?m.originalEvent.layerY:m.offsetY),K=D-y.scrollLeft,Z=U-y.scrollTop,aa=!1;if(K>=y.clientWidth||Z>=y.clientHeight)if("mousemove"==w)aa=!0;else return;E=m.target;for(var ba,d=!1;E&&E!=y&&(!d||!(ba=KTableUIAbstractView.searchCellModelById(b,E.id)));)d||"treeHandler"!=E.ktableUiMark||(d=!0),E=E.parentNode;if(!ba)if(E=a.searchCell(D,U),null==E)ba=null;else{y=E[0];ba=E[1];var t=b.getRow(y);E=b.getColumn(ba);var J=t.getCellForDraw(ba);ba=new KTCell.Path(t,ba,J);ba.$innerSetInfo(y,E)}m=
new k(m,D,U,K,Z,ba,d,aa);m.setXYCellAtTable(B,Q);a.fireEvent(w,m)},I=function(m,w,y,B){w=a.getColX(w);m=a.getRowY(m);B=a.getColX(B+1);y=a.getRowY(y+1);return[w,m,B,y]},R=function(){var m=b.getSelectionRender();m=m?m:c;m=new m;m.setTable(b);return m},M=null;this.showDragingMarkBundle=function(m){M&&(M.remove(),M=null);if(m){var w=b.getSelectionModel().getSelected(),y=n[w];y&&y.remove();m=b.getSelectionModel().parseBlockRange(m);m=I(m[0],m[1],m[2],m[3]);M=R();M.show(h,m[0],m[1],m[2],m[3])}else if(w=
b.getSelectionModel().getSelected(),y=n[w])m=b.getSelectionModel().parseBlockRange(w),m=I(m[0],m[1],m[2],m[3]),y.show(h,m[0],m[1],m[2],m[3])};this.getMaxFrozenRowIdx=function(){return Math.min(b.getFrozenRows()-1,b.getRowsCount()-1)};this.getMaxFrozenColumnIdx=function(){return Math.min(b.getFrozenColumns()-1,b.getColumnsCount()-1)};h.css("position","absolute");h.mouseup(N);h.mousedown(N);h.mousemove(N);h.dblclick(N);b.getSelectionModel().addChangeListener(function(m,w){if(null!==b.getSelectionRender())for(var y=
0;y<w.length;y++){var B=w[y];if(m==KTSelectionModel.CHANGE_ADD){var Q=b.getSelectionModel().parseBlockRange(B);Q=I(Q[0],Q[1],Q[2],Q[3]);var E=R();n[B]=E;E.letOthersOld(h);E.show(h,Q[0],Q[1],Q[2],Q[3])}else m==KTSelectionModel.CHANGE_REMOVE&&n[B]&&(n[B].remove(),delete n[B],B=b.getSelectionModel().getSelected(),(B=n[B])&&B.current())}})}KTableUIAbstractView.createCellId=function(b,a){var k="cell_I_";b&&(k+=b.getKey()+"_I_",a&&(k+=a.getKey()));return k};
KTableUIAbstractView.searchCellModelById=function(b,a){if(!a||0!=a.indexOf("cell_I_"))return null;a=a.split("_I_");if(3!=a.length)return null;var k=a[1],c=a[2];a=-1;for(var g=0,h=b.getRowsCount();g<h;g++){var f=b.getRow(g);if(f.getKey()==k){a=g;break}}if(-1==a)return null;k=b.getColumn(c);b=b.getColumnIndex(k);c=f.getCellForDraw(b);f=new KTCell.Path(f,b,c);f.$innerSetInfo(a,k);return f};
function KTableSelectionRender(){var b;this.setTable=function(a){b=a};this.getTable=function(){return b};this.show=function(a,k,c,g,h){};this.remove=function(){};this.current=function(){};this.letOthersOld=function(a){}}
function KTableUIManyRowsView(b,a){KTableUIAbstractView.call(this,b,a);var k=this,c,g,h,f,n=!1;this.setBlankFirstImmediately=function(x){n=x?!0:!1};this.isBlankFirstImmediately=function(){return n};this.reset=function(){c=[]};var l=function(){var x=k.getUI().prop("clientHeight");x||(x=window.screen.height);return x};this.getScrollRepaintDelta=function(){return h};this.protectedBeforeUpdateUI=function(){c=[];var x=l();a.isDynamicUpdateModel()?(h=0,f=.5*x):(h=.5*x,f=1*x)};this.createPaintSection=function(){if(a.isScrollDynamicRepaint()){var x=
k.getUI().prop("scrollTop");var u=l();var A=x-f;x=x+u+f}else A=0,x=2147483647;return[A,x]};this.createRowsRange=function(){if(a.isScrollDynamicRepaint()){var x=this.createPaintSection();var u=x[1];x=a.searchRowIdx(x[0]);u=a.searchRowIdx(u)}else x=0,u=b.getRowsCount()-1;return[x,u]};this.protectedIsNeedCreatingRow=function(x,u,A,q){if(a.isScrollDynamicRepaint()){var F=c[x];if(F)if(x==u)!0===F&&(F=v(x,A)),F.remove();else return!0!==F&&k.getCellsContainer().append(F),!1;q||(c[x]=!0)}return!0};this.protectedAfterRepaint=
function(x,u,A){a.isScrollDynamicRepaint()&&setTimeout(function(){for(var q=g?g[0]:-1,F=g?g[1]:-2,L=a.isDynamicRepaintWithCache();q<=F;q++)if(q<x||q>u){var V=c[q];V&&(!0===V&&(V=v(q,A),L?c[q]=V:delete c[q]),V.remove())}g=[x,u]},10)};var v=function(x,u){x=b.getRow(x);return k.getUI().find("*[id*='"+u(x)+"']")},z=this.protectedUpdateByRowHide;this.protectedUpdateByRowHide=function(){a.isScrollDynamicRepaint()&&(c=[]);z()};var r=this.protectedUpdateByColumnHide;this.protectedUpdateByColumnHide=function(){a.isScrollDynamicRepaint()&&
(c=[]);r()};var C=this.protectedUpdateColumnWidth;this.protectedUpdateColumnWidth=function(){a.isScrollDynamicRepaint()&&(c=[]);C()}}
function KTableUIMainView(b,a){function k(r){this.isHorizontalScroll=function(){var C=c.getUI().prop("scrollLeft");return h!=C};this.isVerticalScroll=function(){var C=c.getUI().prop("scrollTop");return g!=C};this.isScrollToBottom=function(){var C=c.getUI().prop("scrollTop"),x=c.getUI().prop("clientHeight"),u=c.getUI().prop("scrollHeight");return C+x>=u-2}}KTableUIManyRowsView.call(this,b,a);var c=this,g=0,h=0,f,n=0;this.getName=function(){return"MainView"};this.getViewTag=function(){return KTableViewTag.MAIN};
var l=this.protectedBeforeUpdateUI;this.protectedBeforeUpdateUI=function(){l();h=g=n=0};this.protectedBeforeRepaint=function(r){var C=this.createRowsRange(),x=C[0],u=C[1],A=0,q=b.getColumnsCount()-1;b.getCrossFrozenRenderMode()==KTCrossFrozenRenderMode.STUPID_LIGHT&&(x=Math.max(c.getMaxFrozenRowIdx()+1,x),A=c.getMaxFrozenColumnIdx()+1);if(r)(new Date).getTime(),c.setBlankFirstImmediately(!1),v(x,u,function(F){c.setBlankFirstImmediately(F);r(x,u,A,q,F)});else return[x,u,A,q]};var v=function(r,C,x){if(a.isDynamicUpdateModel()){for(var u=
r,A=C,q=!1;r<=C;r++)if(b.getRow(r).isSkeleton())q||(q=!0,u=r),A=r;else if(q)break;q?(x(!0),C=b.getFrozenRows(),a.fireDynamicUpdateModelEvent(u-C,A-C,x)):x()}else x()};this.protectedGetPaintRect=function(){var r=this.createPaintSection(),C=r[0];r=r[1];var x=a.getColX(c.getMaxFrozenColumnIdx()+1);return[C,r,x,2147483647]};var z=this.protectedAfterRepaint;this.protectedAfterRepaint=function(r,C,x){z(r,C,x);if(a.isScrollDynamicRepaint()&&a.isDynamicUpdateModel()){r-=.5*a.getDynamicUpdateModelAliveDeltaRows();
C+=a.getDynamicUpdateModelAliveDeltaRows();x=b.getFrozenRows();for(var u=b.getRowsCount();x<u;x++)x>r&&x<C||b.getRow(x).clearAsSkeleton()}};c.getUI().css("overflow","auto");c.getUI().scroll(function(r){a.isScrollDynamicRepaint()?(clearTimeout(f),f=setTimeout(function(){var C=c.getUI().prop("scrollTop");c.getUI().prop("clientHeight");if(C<n-c.getScrollRepaintDelta()||C>n+c.getScrollRepaintDelta())c.repaint(),n=C;a.fireEvent("scroll",new k(r));g=c.getUI().prop("scrollTop");h=c.getUI().prop("scrollLeft")},
50)):(a.fireEvent("scroll",new k(r)),g=c.getUI().prop("scrollTop"),h=c.getUI().prop("scrollLeft"))})}
function KTableUILeftFrozenView(b,a){KTableUIManyRowsView.call(this,b,a);var k=this;this.getName=function(){return"LeftView"};this.getViewTag=function(){return KTableViewTag.LEFT};var c=this.protectedBeforeUpdateUI;this.protectedBeforeUpdateUI=function(){c();h()};this.protectedBeforeRepaint=function(f){var n=this.createRowsRange(),l=n[0];n=n[1];var v=k.getMaxFrozenColumnIdx();b.getCrossFrozenRenderMode()==KTCrossFrozenRenderMode.STUPID_LIGHT&&(l=Math.max(k.getMaxFrozenRowIdx()+1,l));if(f)f(l,n,0,
v,k.isBlankFirstImmediately());else return[l,n,0,v]};this.protectedGetPaintRect=function(){var f=this.createPaintSection(),n=f[0];f=f[1];var l=k.getUI().width();return[n,f,0,l]};var g=this.protectedUpdateColumnWidth;this.protectedUpdateColumnWidth=function(){h();g()};var h=function(){var f=k.getMaxFrozenColumnIdx();f=a.getColX(f+1);k.getUI().width(f+1)};k.getUI().css("overflow","hidden")}
function KTableUITopFrozenView(b,a){KTableUIAbstractView.call(this,b,a);var k=this;this.getName=function(){return"TopView"};this.getViewTag=function(){return KTableViewTag.TOP};this.protectedBeforeUpdateUI=function(){var c=k.getMaxFrozenRowIdx();c=a.getRowY(c+1);k.getUI().height(c+1)};this.protectedBeforeRepaint=function(c){var g=k.getMaxFrozenRowIdx(),h=0,f=b.getColumnsCount()-1;b.getCrossFrozenRenderMode()==KTCrossFrozenRenderMode.STUPID_LIGHT&&(h=k.getMaxFrozenColumnIdx()+1);if(c)c(0,g,h,f);else return[0,
g,h,f]};this.protectedGetPaintRect=function(){var c=k.getUI().height(),g=a.getColX(k.getMaxFrozenColumnIdx()+1);return[0,c,g,2147483647]};k.getUI().css("overflow","hidden")}
function KTableUICornerFrozenView(b,a){KTableUIAbstractView.call(this,b,a);var k=this;this.getName=function(){return"CornerView"};this.getViewTag=function(){return KTableViewTag.LEFT&KTableViewTag.TOP};this.protectedBeforeUpdateUI=function(){var h=k.getMaxFrozenRowIdx();h=a.getRowY(h+1);k.getUI().height(h+1);g()};this.protectedBeforeRepaint=function(h){var f=k.getMaxFrozenRowIdx(),n=k.getMaxFrozenColumnIdx();if(h)h(0,f,0,n);else return[0,f,0,n]};this.protectedGetPaintRect=function(){return[0,k.getUI().height(),
0,k.getUI().width()]};var c=this.protectedUpdateColumnWidth;this.protectedUpdateColumnWidth=function(){g();c()};var g=function(){var h=k.getMaxFrozenColumnIdx();h=a.getColX(h+1);k.getUI().width(h+1)};k.getUI().css("overflow","hidden")}
function KTDefaultCellRender(b){var a=this,k,c,g,h,f,n,l,v,z,r,C,x,u,A=!0,q=2,F=1,L=!1;this.setOutsideVisible=function(O){A=O};this.setPaddingHV=function(O,X){q=O;F=X};this.setEllipsis=function(O){L=O};this.reset=function(){x=null};this.setContext=function(O,X,N,P,I,R,M,m,w){k=O;c=X;g=N;h=P;f=I;n=R;l=M;v=m;z=w;C=r=0};this.setTextOffset=function(O,X){r=O;C=X};this.calculateCellHeight=function(O){if(!g||!g.getValue())return 0;var X=ha();X.className=O;return T(X)};this.paintCellUI=function(O,X){if(g&&
void 0!=g.getValue()){var N=ha(O),P=a.getStyleValue("isWrapText"),I=a.getStyleValue("getVerticalAlign");"middle"==I?P?(I=T(N,O),N.style.left=r+"px",N.style.top=C+(z-I>>1)+"px",N.style.height=I+"px"):(I=z-2*F,I=(0>I?0:I)+"px",N.style.lineHeight=I,N.style.height=I,N.style.top=C+F+"px"):"bottom"==I?N.style.bottom=parseInt(O.style.height)-C-z+F+"px":N.style.top=C+F+"px";I=X?X:O;var R=I.firstChild;R&&I.removeChild(R);I.appendChild(N);R=a.getStyleValue("isLineThrough");var M=a.getStyleValue("isUnderLine");
R&&M?N.style.textDecoration="line-through underline":R?N.style.textDecoration="line-through":M&&(N.style.textDecoration="underline");if(A&&(x&&x[0]==h||(x=[h,V(h)]),M=x[1],!P&&!M[f])){R=a.getStyleValue("getTextAlign");var m=P=-1;if("left"==R||"center"==R||null==R){P=0;for(var w=b.getColumnsCount(),y=f+1;y<w;y++){var B=M[y]?M[y]:k.getCellForDraw(y);if(B&&void 0!==B.getValue())break;b.getColumn(y).isHide()||(P+=b.getColumn(y).getWidth())}}if("right"==R||"center"==R)if(m=0,!g.getTreeModel()||g.getTreeModel().isHorizontal())for(y=
f-1;0<=y&&(!(B=M[y]?M[y]:k.getCellForDraw(y))||void 0===B.getValue());y--)b.getColumn(y).isHide()||(m+=b.getColumn(y).getWidth());M=v;0<=P&&(M+=P,w=M-u-q,N.style.width=(0>w?0:w)+"px");0<=m&&(w=document.createElement("span"),w.style.overflow="hidden",w.style.position="absolute",w.style.left=-m+"px",w.style.width=M+m+"px",0>z&&(z=0),w.style.height=z+"px",N.style.width="","center"==R?(N.style.whiteSpace="nowrap",R=T(N,O,"offsetWidth"),N.style.left=(v-R>>1)+m+"px"):(N.style.right=0,N.style.left=""),w.appendChild(N),
I.appendChild(w));m=0<P||0<m}O.style.overflow=m?"visible":"hidden";X&&(X.style.overflow=m?"visible":"hidden");g.getStyle()&&g.getStyle().getCursor()&&"auto"!=g.getStyle().getCursor()&&(O=document.createElement("div"),O.style.position="absolute",O.style.height=I.style.height,O.style.width=I.style.width,O.style.cursor=g.getStyle().getCursor(),O.style.backgroundImage="url(data:;base64,AAABAYA=)",I.appendChild(O))}};var V=function(O){var X=[];b.visitMergeBlocks(O,O,-1,-1,function(N){for(var P=b.getRow(N.getRowIdxFrom()).getCellForDraw(N.getColIdxFrom()),
I=N.getColIdxFrom();I<=N.getColIdxTo();I++)X[I]=P});return X},ha=function(O){u=q;var X=a.getStyleValue("getIndent");if(0<X){var N=a.getStyleValue("getTextAlign");if("left"==N||null==N)N=document.createElement("span"),"undefined"!=typeof N.textContent?N.textContent="A":N.innerText="A",O=T(N,O,"offsetWidth"),u+=O*X}N=document.createElement("span");N.style.paddingLeft=u+"px";N.style.paddingRight=q+"px";N.style.overflow="hidden";L&&(N.style.textOverflow="ellipsis");N.style.position="absolute";N.style.left=
r+"px";X=v-u-q;N.style.width=(0>X?0:X)+"px";"undefined"!=typeof N.textContent?N.textContent=g.getValue():N.innerText=g.getValue();return N},T=function(O,X,N){var P=O.style.left,I=O.style.top;O.style.left="-32768px";O.style.top="-32768px";if(X){if(X=X.className){var R=X.split(" ");X="";for(var M=0;M<R.length;M++)0!=R[M].indexOf(KTBorderStyle.CSS_ID_PREFIXE)&&(0<X.length&&(X+=" "),X+=R[M])}else X="";O.className=X}document.body.appendChild(O);N=O[N?N:"offsetHeight"];document.body.removeChild(O);O.className=
"";O.style.left=P;O.style.top=I;return N};this.getStyleValue=function(O){return b.getStyleValue(g,c,k,"getStyle",O,null)};this.getCurrentRow=function(){return k};this.getCurrentCol=function(){return c};this.getCell=function(){return g};this.getCurrentRowIdx=function(){return h};this.getCurrentColIdx=function(){return f};this.getCellWidth=function(){return n};this.getCellHeight=function(){return l};this.getTextAreaWidth=function(){return v};this.getTextAreaHeight=function(){return z};this.protectedMethod=
new function(){this.setTextAreaHeight=function(O){z=O}}}function KTDefaultEmbedObjectRender(){var b;this.setViewTag=function(a){b=a};this.getViewTag=function(){return b};this.paintEmbedObject=function(a,k){}}
function KTDefaultTreeHandlerRender(b){var a=9,k,c;this.setHandlerSize=function(n){a=n};this.setUiDependence=function(n){k=n};this.setMergeBlock=function(n){c=n};this.create=function(n,l,v,z,r,C,x){if(n.isHorizontal()){var u=z;var A=11*n.getLevel();var q=C;var F=2+a+2+1;var L=z;var V=A+F}else u=17*n.getLevel(),A=r,q=2+a+2+3,F=x,L=u+q,V=r;if(n.isHorizontal()){var ha=C-a-2>>1;var T=2}else{ha=2;var O=b.getRow(l);T=b.getColumn(v);var X=O.getCell(v);"top"==b.getStyleValue(X,T,O,"getStyle","getVerticalAlign",
"top")?(O=b.getStyleValue(X,T,O,"getStyle","getFontSize",20),T=Math.max(2,O-a-2>>1)):T=x-a-2>>1}v=(O=h(n,l,v))||n.isHaveHandlerAlways();l=null;v&&(l=f("div",u,A,q,F),l.style.cursor="pointer",u=f("div",ha,T,a,a),u.style.border="1px solid #8A9EBF","undefined"!=typeof u.style.borderRadius&&(u.style.borderRadius="3px"),u.style.backgroundColor="#FFFFFF",l.appendChild(u),n.isExpanded()?(A=a-2,A=f("div",1,1,A,A>>1),A.style.borderBottom="1px solid black",u.appendChild(A)):(q=a-2>>1,A=f("div",1,1,q,q),A.style.borderBottom=
"1px solid black",A.style.borderRight="1px solid black",q=f("div",1+q,1+q,q,q),q.style.borderTop="1px solid black",q.style.borderLeft="1px solid black",u.appendChild(A),u.appendChild(q)));u=null;if(b.isMultiTreeSupported()){v=!v;ha=z+ha+(a>>1);u=r+T+(a>>1);T=document.createDocumentFragment();A=n.isHorizontal();q=n.getLevel();F=n.getLastChildLevel();n=O&&n.isExpanded();O=0<=F?n?0:q-F:0;var N=q-O;if(A){q=z;F=u;X=C;var P=0}else q=ha,F=r,X=0,P=x;for(var I=0;I<N;I++)g(T,A,q,F,X,P),q+=A?0:17,F+=A?11:0;
for(I=0;I<O;I++){N=T;var R=A,M=X,m=P;M+=R?-4:a>>1;m+=R?a>>1:-4;M=f("div",q,F,M,m);N.appendChild(M);R?(M.style.borderTop="1px dotted #8A9EBF",M.style.borderRight="1px dotted #8A9EBF"):(M.style.borderLeft="1px dotted #8A9EBF",M.style.borderBottom="1px dotted #8A9EBF");q+=A?0:17;F+=A?11:0}q=A?ha:q;F=A?F:u;n&&g(T,A,q,F,X,P);v&&(n=f("div",q,F,0,0),T.appendChild(n),n.style.border="1px solid #8A9EBF");u=T}n=[l,L,V,u];L=n[0];V=n[1];l=n[2];n=n[3];z=f("span",V,l,z+C-V,r+x-l);return[L,z,n]};var g=function(n,
l,v,z,r,C){v=f("div",v,z,r,C);n.appendChild(v);l?v.style.borderTop="1px dotted #8A9EBF":v.style.borderLeft="1px dotted #8A9EBF"},h=function(n,l,v){if(n.isHorizontal())for(var z=b.getColumnsCount()-1;v<z&&(v++,c&&c.isContainCell(l,v)););else for(z=b.getRowsCount()-1;l<z&&(l++,c&&c.isContainCell(l,v)););return(l=b.getRow(l).getCellForDraw(v))&&l.getTreeModel()&&l.getTreeModel().getLevel()>n.getLevel()},f=function(n,l,v,z,r){n=document.createElement(n);n.style.overflow="hidden";n.style.position="absolute";
n.style.left=l+"px";n.style.top=v+"px";n.style.width=(0>z?0:z)+"px";n.style.height=(0>r?0:r)+"px";return n};this.protectedMethod={getTable:function(){return b},getUiDependence:function(){return k},isTreeNodeHasChildren:h,createAbsoluteHtmlElement:f}}
function KTableUIDraggableAdjustingHandler(){var b,a,k,c=-1,g=-1,h=-1,f=-1,n=-1,l=-1,v=!0,z=!0,r,C=-1,x=-1,u=!1,A,q,F;this.setContext=function(P,I,R){b=P;k=I;a=R;k.on("mouseenter",V);k.on("mouseleave",X)};this.mouseEventHandler=function(P,I){if(b.getDraggableAdjusting())if("mousemove"==P)a:{x=C=-1;var R=I.getXAtTable();P=I.getYAtTable();var M=R>n-6,m=P>l-6,w=M||m,y=I.isCellPointed()&&!I.isPointTreeHandler();if((y||w)&&!I.isPointScrollBar()&&R<n&&P<l&&(R<c||P<g)){I=I.getMouseTargetModel();if(z&&(y||
M)){M=I?I.getColIndex():-1;w=-1;if(-1==M)w=b.getColumnsCount();else if(R>a.getColX(M+1)-3)w=M+1;else for(;0<M&&R<a.getColX(M)+3&&(w=M,M--,b.getColumn(M).isHide()););if(0<w&&r.isColumnDraggable(b,w-1)){x=w;k.css("cursor","col-resize");break a}}if(v&&(y||m)){I=I?I.getRowIndex():-1;R=-1;if(-1==I)R=b.getRowsCount();else if(P>a.getRowY(I+1)-3)R=I+1;else for(;0<I&&P<a.getRowY(I)+3&&(R=I,I--,b.getRow(I).isHide()););if(0<R&&r.isRowDraggable(b,R-1)){C=R;k.css("cursor","row-resize");break a}}}k.css("cursor",
"")}else"mousedown"==P&&(P=0<x,R=0<C,P||R)&&(I.stop(),M=$("<div>"),M.css("z-index",65535),M.css("position","absolute"),M.css("top",0),M.css("left",0),M.css("width","100%"),M.css("height","100%"),M.css("background-color","rgba(255, 255, 255, 0.1)"),F=M,F.on("mousemove",ha),F.on("mouseup",T),F.appendTo(k),M=$("<div>"),M.css("z-index",65534),M.css("position","absolute"),M.css("top",0),M.css("left",0),M.css("width",0),M.css("height",0),M.css("border-style","dashed"),M.css("border-width","0"),M.css("border-color",
"#000"),M.css("background-color","rgba(0, 0, 0, 0.2)"),q=M,q.appendTo(k),P?(m=a.getColX(x-1),y=m-(m<h?0:a.getScrollLeft()),A=b.getColumn(x-1).getWidth(),M=a.getRowY(b.getRowsCount())-a.getScrollTop(),m=I.getOriginalEvent().screenX,q.css("border-right-width","1px"),q.css("left",y),q.css("width",A),q.css("height",M),I=x-1,y=-Math.max(0,b.getColumn(I).getWidth()-r.getMinColumnWidthLimited(b,I))):R&&(m=a.getRowY(C-1),y=m-(m<f?0:a.getScrollTop()),A=b.getRow(C-1).getHeight(),M=a.getColX(b.getColumnsCount())-
a.getScrollLeft(),m=I.getOriginalEvent().screenY,q.css("border-bottom-width","1px"),q.css("top",y),q.css("height",A),q.css("width",M),I=C-1,y=-Math.max(0,b.getRow(I).getHeight()-r.getMinRowHeightLimited(b,I))),P||R)&&(q.data("kt_startMouse",m),q.data("kt_minDelta",y))};var L=function(){var P=b.getDraggableAdjusting(),I=P[0],R=P[1];r=(r=P[2])?r:new KTableUIDraggableAdjustingHandler.CustomExpendor;v=0!==R;z=0!==I;I=I?0<I?I:b.getRowsCount():0===I?0:b.getFrozenRows();R=R?0<R?R:b.getColumnsCount():0===
R?0:b.getFrozenColumns();g=a.getRowY(I)+3;c=a.getColX(R)+3;f=a.getRowY(b.getFrozenRows());h=a.getColX(b.getFrozenColumns());l=a.getRowY(b.getRowsCount())+3;n=a.getColX(b.getColumnsCount())+3},V=function(P){b.getDraggableAdjusting()&&L()},ha=function(P){u=!0;P=O(P);P=A+P;0<x?q.css("width",P):q.css("height",P)},T=function(P){u&&(P=O(P),0<x?r.columnDraggedAction(b,x-1,P):r.rowDraggedAction(b,C-1,P));N();L()},O=function(P){P=(0<x?P.screenX:P.screenY)-q.data("kt_startMouse");var I=q.data("kt_minDelta");
P<I&&(P=I);return P},X=function(P){N()},N=function(){u=!1;x=-1;q&&q.remove();F&&F.remove()}}
KTableUIDraggableAdjustingHandler.CustomExpendor=function(){this.isRowDraggable=function(b,a){return!0};this.isColumnDraggable=function(b,a){return!0};this.getMinRowHeightLimited=function(b,a){return 3};this.getMinColumnWidthLimited=function(b,a){return 4};this.rowDraggedAction=function(b,a,k){var c=b.isSyncUIWhenModelChanged();b.setSyncUIWhenModelChanged(!0);a=b.getRow(a);a.setHeight(a.getHeight()+k);b.setSyncUIWhenModelChanged(c)};this.columnDraggedAction=function(b,a,k){var c=b.isSyncUIWhenModelChanged();
b.setSyncUIWhenModelChanged(!0);a=b.getColumn(a);a.setWidth(a.getWidth()+k);b.setSyncUIWhenModelChanged(c)};this.getTailBlankForDragging=function(){return 60}};function KTDiagonalRender(){this.create=function(c,g,h,f,n,l){try{var v=document.createElement("canvas");v.width=n;v.height=l;var z=h,r=g.getLinkToRows(),C=0,x=Array(r.length+2);x[0]=C;for(var u=0;u<r.length;u++){for(var A=0;A<r[u];A++)C+=c.getRow(z++).getHeight();x[u+1]=C}x[r.length+1]=l;l=f;var q=g.getLinkToColumns();z=0;var F=Array(q.length+2);F[0]=z;for(r=0;r<q.length;r++){for(C=0;C<q[r];C++)z+=c.getColumn(l++).getWidth();F[r+1]=z}F[q.length+1]=n;var L=v.getContext("2d"),V=c.getRow(h),ha=c.getColumn(f),
T=V.getCell(f),O=c.getStyleValue(T,ha,V,"getBorder","getRightBorderColor","#aaaaaa");L.save();L.strokeStyle=O;L.lineWidth=.8;var X=F[F.length-1],N=x[x.length-1];for(n=1;n<x.length;n++)L.moveTo(0,0),L.lineTo(X,x[n]);for(n=1;n<F.length;n++)L.moveTo(0,0),L.lineTo(F[n],N);L.stroke();L.restore();var P=c.getRow(h),I=c.getColumn(f),R=P.getCell(f),M=c.getStyleValue(R,I,P,"getStyle","getFontSizeWithUnit"),m=c.getStyleValue(R,I,P,"getStyle","getFontName");M&&m&&(L.font=M+" "+m);c=[];var w=F[F.length-1],y=x[x.length-
1];h=[0,0];for(f=0;f<x.length-1;f++){var B=[w,x[f]],Q=[w,x[f+1]];c.push([h,B,Q])}for(f=F.length-1;0<f;f--)B=[F[f],y],Q=[F[f-1],y],c.push([h,B,Q]);for(x=0;x<c.length;x++){var E=c[x];var D=[Math.floor((E[0][0]+E[1][0]+E[2][0])/3+.5),Math.floor((E[0][1]+E[1][1]+E[2][1])/3+.5)];F=[0,0];var U=D[0]-F[0];var K=0==U?PI/2:Math.atan((D[1]-F[1])/U);var Z=g.getText(x);L.save();if(g.isLean(x)){F=L;w=Z;Q=D;y=K;h=!0;for(B=0;B<w.length;B++)if(127<w.charCodeAt(B)){h=!1;break}F.translate(Q[0],Q[1]);F.rotate(y);var aa=
k(F,w,!0,y);F.translate(aa[0],aa[1]);if(h)F.fillText(w,0,0);else for(B=Q=0;B<w.length;B++){var ba=w.charAt(B);F.translate(Q,0);F.rotate(-y);F.fillText(ba,0,0);F.rotate(y);Q=F.measureText(ba).width}}else{F=L;w=Z;y=D;var d=k(F,w,!1,K);F.fillText(w,y[0]+d[0],y[1]+d[1])}L.restore()}return v}catch(t){return null}};var b=[[Math.PI/18,.1],[Math.PI/12,.2],[Math.PI/9,.3],[Math.PI/6,.4],[Math.PI/2,.5]],a=[[Math.PI/9,.2],[Math.PI/6,.3],[Math.PI/5,.4],[Math.PI/4,.6],[Math.PI/2,.7]],k=function(c,g,h,f){h=h?a:
b;var n=Math.abs(f);f=.5;for(var l=0;l<h.length;l++)if(n<=h[l][0]){f=h[l][1];break}g=c.measureText(g);h=-g.width*f;g=c.measureText("\u58f9");return[h,.5*g.width]}};function KTable(){var b=this,a="table"+ ++KTable.iFlowId,k=new KTListenerProxy,c=[],g=[],h=new KTMergeBlockSet,f,n,l=[],v=new KTStyleManager,z=new KTSelectionModel(b),r,C,x,u,A,q,F=0,L=0,V=KTCrossFrozenRenderMode.STUPID_HEAVY,ha,T=!0,O=!1,X=!1,N=!0,P,I,R,M=!1;this.getId=function(){return a};var m=function(){r||(r=new KTableUI(b),r.addListener("scroll",D),r.addListener("mousedown",Z),r.addListener("click",Z),r.addListener("click",E));return r};this.setUICustomStyleMap=function(d){C=d};this.getUICustomStyleMap=
function(){return C};this.getUI=function(){return m().getHtmlElement()};this.addColumn=function(d){return b.insertColumn(c.length,d)};this.addColumns=function(d){for(var t=0;t<d;t++)b.addColumn()};this.insertColumn=function(d,t){if(0>d||d>c.length)throw Error("Illegal argument.");t=new KTColumn(U,t);c.splice(d,0,t);for(var J=0;J<g.length;J++)g[J].$innerInsertCell(d);N&&h.syncMergeBlocks(!1,d,!0);K(t,KTableUI.INSERT_COL);return t};this.removeColumn=function(d){if(0>d||d>c.length)throw Error("Illegal argument.");
var t=c[d];t.$innerDestroy();c.splice(d,1);for(var J=0;J<g.length;J++)g[J].$innerRemoveCell(d);N&&h.syncMergeBlocks(!1,d,!1);K(t,KTableUI.REMOVE_COL)};this.removeAllColumns=function(){for(var d=c.length-1;0<=d;d--)c[d].$innerDestroy();c.length=0;h.clear();K(null,KTableUI.REMOVE_COL)};this.getColumnsCount=function(){return c.length};this.getColumn=function(d){var t=typeof d;if("number"==t){if(0>d||d>c.length)throw Error("Illegal argument.");return c[d]}if("string"==t){for(t=0;t<c.length;t++)if(c[t].getKey()==
d)return c[t];return null}throw Error("Unknown argument.");};this.getColumnIndex=function(d){var t=!1;if(d instanceof KTColumn)t=!0;else if("string"!=typeof d)throw Error("Unknown argument.");for(var J=0;J<c.length;J++)if(t){if(c[J]==d)return J}else if(c[J].getKey()==d)return J;return-1};this.addRow=function(){return b.insertRow(g.length)};this.addRows=function(d){for(var t=0;t<d;t++)b.addRow()};this.insertRow=function(d){if(0>d||d>g.length)throw Error("Illegal argument.");var t=new KTRow(b.getColumnsCount(),
U);g.splice(d,0,t);N&&h.syncMergeBlocks(!0,d,!0);K(t,KTableUI.INSERT_ROW);return t};this.removeRow=function(d){if(0>d||d>g.length)throw Error("Illegal argument.");var t=g[d];t.$innerDestroy();g.splice(d,1);N&&h.syncMergeBlocks(!0,d,!1);K(t,KTableUI.REMOVE_ROW)};this.removeAllRows=function(){for(var d=g.length-1;0<=d;d--)g[d].$innerDestroy();g.length=0;h.clear();K(null,KTableUI.REMOVE_ROW)};this.getRowsCount=function(){return g.length};this.getRow=function(d){return g[d]};this.getRowIndex=function(d){for(var t=
0;t<g.length;t++)if(g[t]==d)return t;return-1};this.updateUI=function(d,t){m().updateUI(d,t)};var w,y;this.lazyAppendData=function(d){d?(y=b.getRowsCount(),w=b.isSyncUIWhenModelChanged(),b.setSyncUIWhenModelChanged(!1)):(m().repaintAfterLazyAppendData(y),b.setSyncUIWhenModelChanged(w))};this.lazyAppendDataByTree=function(d,t){d?(w=b.isSyncUIWhenModelChanged(),b.setSyncUIWhenModelChanged(!1),m().showPromptForLazyAppendData(!0)):(m().showPromptForLazyAppendData(!1),t.setExpanded(!1),b.setSyncUIWhenModelChanged(!0),
t.setExpanded(!0),b.setSyncUIWhenModelChanged(w))};this.setLargeDataMode=function(d,t){m().setScrollDynamicRepaint(d,t)};this.isLargeDataMode=function(){return m().isScrollDynamicRepaint()};this.setHugeModelUpdateListener=function(d,t){m().setScrollDynamicUpdateModelListener(d,t)};this.setSyncUIWhenModelChanged=function(d){m().setSyncUIWhenModelChanged(d)};this.isSyncUIWhenModelChanged=function(){return m().isSyncUIWhenModelChanged()};this.setSyncMergeBlockWhenModelChanged=function(d){N=d};this.isSyncMergeBlockWhenModelChanged=
function(){return N};this.setCellRender=function(d){x=d};this.getCellRender=function(){x||(x=new KTDefaultCellRender(b));return x};this.setDiagonalRender=function(d){u=d};this.getDiagonalRender=function(){u||(u=new KTDiagonalRender);return u};this.setEmbedObjectRender=function(d){A=d};this.getEmbedObjectRender=function(){A||(A=new KTDefaultEmbedObjectRender);return A};this.setTreeHandlerRender=function(d){q=d};this.getTreeHandlerRender=function(){q||(q=new KTDefaultTreeHandlerRender(b));return q};
this.getStyleManager=function(){return v};this.addMergeBlock=function(d){h.append(d)&&K(d,KTableUI.ADD_MERGEBLOCK)};this.addMergeBlocks=function(d){h.appendArray(d)};this.removeMergeBlock=function(d){h.remove(d)&&K(d,KTableUI.REMOVE_MERGEBLOCK)};this.clearMergeBlocks=function(){h.clear();K(null,KTableUI.REMOVE_MERGEBLOCK)};this.bucketingMergeBlocks=function(d){d&&h.requestBucketing();h.bucketing(b.getRowsCount(),b.getColumnsCount(),F,L)};this.searchMergeBlock=function(d,t){return h.search(d,t,F,L)};
this.visitMergeBlocks=function(d,t,J,S,Y){d=0>d?0:d;t=0>t?b.getRowsCount()-1:t;J=0>J?0:J;S=0>S?b.getColumnsCount()-1:S;h.visit(Y,d,t,J,S,F,L)};this.visitAllMergeBlocks=function(d){h.visitAll(d)};this.setMergeBlockTextVisibleAlways=function(d){M=d};this.isMergeBlockTextVisibleAlways=function(){return M};this.setStyle=function(d){f=d};this.getStyle=function(){return f};this.setBorder=function(d){n=d};this.getBorder=function(){return n};this.getStyleValue=function(d,t,J,S,Y,ca){if(d&&(d=d[S]())&&((d=
d[Y]())||0===d||!1===d))return d;if(d=t[S]())if((d=d[Y]())||0===d||!1===d)return d;if(d=J[S]())if((d=d[Y]())||0===d||!1===d)return d;if(d=b[S]())if((d=d[Y]())||0===d||!1===d)return d;return ca};this.addEmbedObject=function(d){if(0<=B(d))throw Error("EmbedObjcet ID already exist.");d.$innerBindChangeListener(Q);l.push(d)};this.removeEmbedObject=function(d){var t=B(d);0<=t&&(d=l[t],d.$innerBindChangeListener(null),l.splice(t,1))};this.getEmbedObject=function(d){d=B(new KTEmbedObject(d));return 0<=d?
l[d]:null};var B=function(d){for(var t=0;t<l.length;t++)if(d.getId()==l[t].getId())return t;return-1};this.getEmbedObjects=function(){return l};var Q=function(d,t,J,S){U(d,t,J,S)};this.addCellClickListener=function(d){k.addListener("cell-click",d)};this.removeCellClickListener=function(d){k.removeListener("cell-click",d)};this.addTreeExpandListener=function(d){k.addListener("tree-expand",d)};this.removeTreeExpandListener=function(d){k.removeListener("tree-expand",d)};var E=function(d,t){if(t.isCellPointed()){d=
t.getMouseTargetModel();var J=d.getCell();if(t.isPointTreeHandler()&&t.isLeftButton()){t=b.isSyncUIWhenModelChanged();b.setSyncUIWhenModelChanged(!0);var S=J.getTreeModel();S.setExpanded(!S.isExpanded());b.setSyncUIWhenModelChanged(t);d=new KTTreeExpandEvent(J,d.getRowIndex(),d.getColIndex());k.fireListener("tree-expand",d)}else{S=t.getOriginalEvent();a:{var Y=d.getRowIndex();var ca=d.getColIndex();if(Y=b.searchMergeBlock(Y,ca))for(ca=Y.getRowIdxFrom();ca<=Y.getRowIdxTo();ca++)for(var ja=b.getRow(ca),
ka=Y.getColIdxFrom();ka<=Y.getColIdxTo();ka++){var fa=ja.getCell(ka,!0);if(fa){Y=fa;break a}}Y=null}d=new KTCellClickEvent(S,Y?Y:J,d,t);k.fireListener("cell-click",d)}}};this.addScrollToBottomListener=function(d){k.addListener("scroll-to-bottom",d)};this.removeScrollToBottomListener=function(d){k.removeListener("scroll-to-bottom",d)};var D=function(d,t){t.isVerticalScroll()&&t.isScrollToBottom()&&k.fireListener("scroll-to-bottom",t)};this.addUIListener=function(d,t){m().addListener(d,t)};this.removeUIListener=
function(d,t){m().removeListener(d,t)};var U=function(d,t,J,S){if(r&&r.isSyncUIWhenModelChanged()){if(d instanceof KTCell.Path){var Y=b.getColumn(d.getColIndex()),ca=b.getRowIndex(d.getRow());d.$innerSetInfo(ca,Y);if(t==KTCell.TREE_EXPANDING){t=new KTTreeStateChangedEvent(b,d);k.fireListener("tree-state-changed",t);if(!t.isPreventDefault()){if(r){var ja=r.isSyncUIWhenModelChanged();r.setSyncUIWhenModelChanged(!1)}Y=d.getCell().getTreeModel();t=Y.isHorizontal();ca=Y.isExpanded();J=d.getRowIndex();
d=d.getColIndex();var ka=t?J:d,fa=d=t?ba(J,d):aa(J,d),qa=t?b.getColumnsCount():b.getRowsCount();J=[];for(var la=32767;fa<qa;){var na=t?ka:fa,ra=t?fa:ka;S=fa;fa=t?ba(ka,fa):aa(fa,ka);var pa=fa-1;na=b.getRow(na).getCell(ra,!0);if(!na||!na.getTreeModel())break;ra=na.getTreeModel();var e=ra.getLevel();if(e<=Y.getLevel()||t!=ra.isHorizontal())break;if(ca)for(na=!1,e<=la&&(la=ra.isExpanded()?32767:e,na=!0);S<=pa;S++)J.push(na);else for(;S<=pa;S++)(t?b.getColumn(S):b.getRow(S)).setHide(!0)}if(ca){if(R)for(Y=
t?Math.min(R[0],b.getRowsCount()):Math.min(R[1],b.getColumnsCount()),S=ka+1;S<Y;S++)for(ca=J,ka=d,fa=S,qa=t,la=ka,pa=ka+ca.length,na=32767;la<pa;){var p=qa?fa:la,G=qa?la:fa;e=la;la=qa?ba(fa,la):aa(la,fa);ra=la-1;if((p=b.getRow(p).getCell(G,!0))&&p.getTreeModel()&&(p=p.getTreeModel(),qa==p.isHorizontal()))if(G=p.getLevel(),G<=na)na=p.isExpanded()?32767:G;else for(;e<=ra;e++)ca[e-ka]=!1}for(S=0;S<J.length;S++)fa=S+d,(t?b.getColumn(fa):b.getRow(fa)).setHide(!J[S])}r&&(r.setSyncUIWhenModelChanged(ja),
r.updateUI(!0))}return}}r.propertyChangeHandler(d,t,J,S)}},K=function(d,t){r&&r.isSyncUIWhenModelChanged()&&r.modelChangeHandler(d,t)};this.getSelectionModel=function(){return z};this.setSelectionRender=function(d){ha=d};this.getSelectionRender=function(){return ha};this.setMouseDownSelectingMode=function(d){T=d};this.isMouseDownSelectingMode=function(){return T};var Z=function(d,t){if(!(T&&"mousedown"!=d||!T&&"mousedown"==d||t.isStopped())&&t.isCellPointed()&&(d=b.getSelectionModel(),d.getMode()!=
KTSelectionModel.MODE_NONE)){var J=t.getMouseTargetModel();if(J instanceof KTCell.Path){if(d.isPolicySetting(KTSelectionModel.POLICY_ROW)){if(J.getRowIndex()<b.getFrozenRows())return;J=d.createRowTarget(J.getRowIndex())}else if(d.isPolicySetting(KTSelectionModel.POLICY_COLUMN)){if(J.getColIndex()<b.getFrozenColumns())return;J=d.createColumnTarget(J.getColIndex())}else J=d.createCellTarget(J.getRowIndex(),J.getColIndex());t.isCtrlDown()&&d.getMode()==KTSelectionModel.MODE_MULTI?d.isContains(J)?d.removeSelected(J):
d.addSelected(J):t.isShiftDown()&&d.getMode()==KTSelectionModel.MODE_MULTI?(d.isContains(J)&&d.removeSelected(J),d.appendSelected(J)):d.hasSelected()?d.isSingleSelected()&&d.isContains(J)||(d.removeAllSelecteds(),d.addSelected(J)):d.addSelected(J)}}};this.setFrozenRows=function(d){if(F!=d){var t=F;F=d;h.requestBucketing();U(b,KTableUI.FROZEN_ROW,F,t)}};this.getFrozenRows=function(){return F};this.setFrozenColumns=function(d){if(L!=d){var t=L;L=d;h.requestBucketing();U(b,KTableUI.FROZEN_COL,L,t)}};
this.getFrozenColumns=function(){return L};this.setCrossFrozenRenderMode=function(d){V=d};this.getCrossFrozenRenderMode=function(){return V};this.popupMenu=function(d,t,J,S,Y){m().popupMenu(d,t,J,S,Y)};this.setMultiTreeSupported=function(d,t,J){R=d?[t,J]:null};this.isMultiTreeSupported=function(){return R?!0:!1};var aa=function(d,t){return(t=b.searchMergeBlock(d,t))?t.getRowIdxTo()+1:d+1},ba=function(d,t){return(d=b.searchMergeBlock(d,t))?d.getColIdxTo()+1:t+1};this.isColumnFitVisibleWidth=function(){return O};
this.setColumnFitVisibleWidth=function(d){O=d};this.isAutoAdjustRowHeight=function(){return X};this.setAutoAdjustRowHeight=function(d){X=d};this.selectByPoint=function(d,t){return m().selectByPoint(d,t)};this.setScrollerVisible=function(d,t,J){m().setScrollerVisible(d,t,J)};this.keepScrollStatus=function(){return m().keepScrollStatus()};this.restoreScrollStatus=function(d){m().restoreScrollStatus(d)};this.scrollCellVisible=function(d,t,J){m().scrollCellVisible(d,t,J)};this.setDraggableAdjusting=function(d,
t,J,S){P=d?[t,J,S]:null};this.getDraggableAdjusting=function(){return P};this.relayoutViews=function(){m().relayoutViews()};this.addTreeStateChangedListener=function(d){k.addListener("tree-state-changed",d)};this.removeTreeStateChangedListener=function(d){k.removeListener("tree-state-changed",d)};this.setCellAcrossListener=function(d){I=d};this.getCellAcrossListener=function(){return I};this.searchJqCell=function(d,t){var J=$(b.getUI());d=KTableUIAbstractView.createCellId(b.getRow(d),b.getColumn(t));
return J.find("#"+d)}}KTable.iFlowId=0;var KTableViewTag=new function(){this.MAIN=0;this.LEFT=4096;this.TOP=256},KTCrossFrozenRenderMode=new function(){this.STUPID_HEAVY=0;this.STUPID_LIGHT=1};function KTPopupMenuItem(b){var a=b,k;this.setText=function(c){a=c};this.getText=function(){return a};this.setUserObject=function(c){k=c};this.getUserObject=function(){return k}}
function KTAbstractMouseEvent(b,a,k,c,g){var h=!1;this.stop=function(){h=!0};this.isStopped=function(){return h};this.getX=function(){return c};this.getY=function(){return g};this.getXAtTable=function(){return a};this.getYAtTable=function(){return k};this.isCtrlDown=function(){return b.ctrlKey};this.isShiftDown=function(){return b.shiftKey};this.isLeftButton=function(){return 1==b.which};this.isRightButton=function(){return 3==b.which}}
function KTCellClickEvent(b,a,k,c){KTAbstractMouseEvent.call(this,b,c.getXAtTable(),c.getYAtTable(),c.getX(),c.getY());this.getCell=function(){return a};this.getCol=function(){return k.getCol()};this.getRow=function(){return k.getRow()};this.getColIdx=function(){return k.getColIndex()};this.getRowIdx=function(){return k.getRowIndex()};this.getXCellAtTable=function(){return c.getXYCellAtTable()[0]};this.getYCellAtTable=function(){return c.getXYCellAtTable()[1]}}
function KTTreeExpandEvent(b,a,k){this.isExpanded=function(){return b.getTreeModel().isExpanded()};this.getCell=function(){return b};this.getRowIdx=function(){return a};this.getColIdx=function(){return k}}
function KTTreeStateChangedEvent(b,a){var k=!1;this.preventDefault=function(){k=!0};this.isPreventDefault=function(){return k};this.getTable=function(){return b};this.getRowIndex=function(){return a.getRowIndex()};this.getColIndex=function(){return a.getColIndex()};this.getRow=function(){return a.getRow()};this.getCol=function(){return a.getCol()};this.getCell=function(){return a.getCell()};this.createCellId=function(c,g){c=c||a.getRow();g=g||a.getCol();return KTableUIAbstractView.createCellId(c,
g)}};
//qingVersionTag: 20250415