e-virt-table 0.1.16 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(":root{--e-virt-table-color-white: #fff;--e-virt-table-color-black: #000000;--e-virt-table-color-primary: rgb(82, 146, 247);--e-virt-table-text-color-primary: #333;--e-virt-table-text-color-regular: #666;--e-virt-table-text-color-secondary: #999;--e-virt-table-box-shadow: 0 2px 12px 0 #0000001a;--e-virt-table-editor-bg-color: #fff;--e-virt-table-border-color: #e1e6eb}.e-virt-table-container{position:relative;outline:none}.e-virt-table-stage{position:relative;overflow:hidden;outline:none;z-index:10;border-radius:8px;border:1px solid var(--e-virt-table-border-color)}.e-virt-table-canvas{position:absolute;left:0;top:0;box-sizing:border-box;border:none;outline:none;z-index:10}.e-virt-table-editor{position:absolute;top:-10000px;left:-10000px;text-align:left;height:auto;line-height:0;z-index:100;overflow:hidden;background-color:var(--e-virt-table-editor-bg-color);border:2px solid var(--e-virt-table-color-primary);box-sizing:border-box;box-shadow:var(--e-virt-table-box-shadow);display:flex;align-items:center}.e-virt-table-overlayer{position:absolute;left:0;top:0;overflow:hidden;z-index:100;pointer-events:none}.e-virt-table-editor-textarea{width:100%;box-sizing:border-box;outline:none;font-weight:400;padding:8px;font-size:12px;color:inherit;white-space:pre-wrap;word-wrap:break-word;word-break:break-all;line-height:1.5;margin:0;border:none;vertical-align:middle;background:var(--e-virt-table-color-white);overflow-y:auto;resize:none}.e-virt-table-context-menu{position:absolute;font-size:14px;color:var(--e-virt-table-text-color-regular);background-color:var(--e-virt-table-color-white);border-radius:4px;border:1px solid #e4e7ed;box-shadow:var(--e-virt-table-box-shadow);width:fit-content;padding:6px 0;z-index:9999;left:-99999px;top:-99999px}.e-virt-table-context-menu-item{cursor:pointer;padding:8px 24px;color:var(--e-virt-table-text-color-regular)}.e-virt-table-context-menu-item:hover{color:var(--e-virt-table-color-primary);background-color:#f5f7fa}")),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
- (function(I,M){typeof exports=="object"&&typeof module<"u"?module.exports=M():typeof define=="function"&&define.amd?define(M):(I=typeof globalThis<"u"?globalThis:I||self,I.EVirtTable=M())})(this,function(){"use strict";var Ui=Object.defineProperty;var Zi=(I,M,P)=>M in I?Ui(I,M,{enumerable:!0,configurable:!0,writable:!0,value:P}):I[M]=P;var h=(I,M,P)=>Zi(I,typeof M!="symbol"?M+"":M,P);function I(){return I=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},I.apply(this,arguments)}function M(n,t){n.prototype=Object.create(t.prototype),n.prototype.constructor=n,st(n,t)}function P(n){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},P(n)}function st(n,t){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,s){return i.__proto__=s,i},st(n,t)}function me(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ft(n,t,e){return me()?ft=Reflect.construct.bind():ft=function(s,r,o){var a=[null];a.push.apply(a,r);var l=Function.bind.apply(s,a),c=new l;return o&&st(c,o.prototype),c},ft.apply(null,arguments)}function Ee(n){return Function.toString.call(n).indexOf("[native code]")!==-1}function Et(n){var t=typeof Map=="function"?new Map:void 0;return Et=function(i){if(i===null||!Ee(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(i))return t.get(i);t.set(i,s)}function s(){return ft(i,arguments,P(this).constructor)}return s.prototype=Object.create(i.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),st(s,i)},Et(n)}var be=/%[sdj%]/g,Xt=function(){};typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"&&typeof window<"u"&&typeof document<"u"&&(Xt=function(t,e){typeof console<"u"&&console.warn&&typeof ASYNC_VALIDATOR_NO_WARNING>"u"&&e.every(function(i){return typeof i=="string"})&&console.warn(t,e)});function bt(n){if(!n||!n.length)return null;var t={};return n.forEach(function(e){var i=e.field;t[i]=t[i]||[],t[i].push(e)}),t}function H(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];var s=0,r=e.length;if(typeof n=="function")return n.apply(null,e);if(typeof n=="string"){var o=n.replace(be,function(a){if(a==="%%")return"%";if(s>=r)return a;switch(a){case"%s":return String(e[s++]);case"%d":return Number(e[s++]);case"%j":try{return JSON.stringify(e[s++])}catch{return"[Circular]"}break;default:return a}});return o}return n}function Ce(n){return n==="string"||n==="url"||n==="hex"||n==="email"||n==="date"||n==="pattern"}function _(n,t){return!!(n==null||t==="array"&&Array.isArray(n)&&!n.length||Ce(t)&&typeof n=="string"&&!n)}function ve(n,t,e){var i=[],s=0,r=n.length;function o(a){i.push.apply(i,a||[]),s++,s===r&&e(i)}n.forEach(function(a){t(a,o)})}function kt(n,t,e){var i=0,s=n.length;function r(o){if(o&&o.length){e(o);return}var a=i;i=i+1,a<s?t(n[a],r):e([])}r([])}function Re(n){var t=[];return Object.keys(n).forEach(function(e){t.push.apply(t,n[e]||[])}),t}var Nt=function(n){M(t,n);function t(e,i){var s;return s=n.call(this,"Async Validation Error")||this,s.errors=e,s.fields=i,s}return t}(Et(Error));function _e(n,t,e,i,s){if(t.first){var r=new Promise(function(x,u){var g=function(y){return i(y),y.length?u(new Nt(y,bt(y))):x(s)},w=Re(n);kt(w,e,g)});return r.catch(function(x){return x}),r}var o=t.firstFields===!0?Object.keys(n):t.firstFields||[],a=Object.keys(n),l=a.length,c=0,f=[],d=new Promise(function(x,u){var g=function(p){if(f.push.apply(f,p),c++,c===l)return i(f),f.length?u(new Nt(f,bt(f))):x(s)};a.length||(i(f),x(s)),a.forEach(function(w){var p=n[w];o.indexOf(w)!==-1?kt(p,e,g):ve(p,e,g)})});return d.catch(function(x){return x}),d}function Ie(n){return!!(n&&n.message!==void 0)}function Oe(n,t){for(var e=n,i=0;i<t.length;i++){if(e==null)return e;e=e[t[i]]}return e}function Yt(n,t){return function(e){var i;return n.fullFields?i=Oe(t,n.fullFields):i=t[e.field||n.fullField],Ie(e)?(e.field=e.field||n.fullField,e.fieldValue=i,e):{message:typeof e=="function"?e():e,fieldValue:i,field:e.field||n.fullField}}}function Kt(n,t){if(t){for(var e in t)if(t.hasOwnProperty(e)){var i=t[e];typeof i=="object"&&typeof n[e]=="object"?n[e]=I({},n[e],i):n[e]=i}}return n}var Bt=function(t,e,i,s,r,o){t.required&&(!i.hasOwnProperty(t.field)||_(e,o||t.type))&&s.push(H(r.messages.required,t.fullField))},Te=function(t,e,i,s,r){(/^\s+$/.test(e)||e==="")&&s.push(H(r.messages.whitespace,t.fullField))},xt,Se=function(){if(xt)return xt;var n="[a-fA-F\\d:]",t=function(E){return E&&E.includeBoundaries?"(?:(?<=\\s|^)(?="+n+")|(?<="+n+")(?=\\s|$))":""},e="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",i="[a-fA-F\\d]{1,4}",s=(`
2
+ (function(I,M){typeof exports=="object"&&typeof module<"u"?module.exports=M():typeof define=="function"&&define.amd?define(M):(I=typeof globalThis<"u"?globalThis:I||self,I.EVirtTable=M())})(this,function(){"use strict";var Ui=Object.defineProperty;var Zi=(I,M,P)=>M in I?Ui(I,M,{enumerable:!0,configurable:!0,writable:!0,value:P}):I[M]=P;var l=(I,M,P)=>Zi(I,typeof M!="symbol"?M+"":M,P);function I(){return I=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},I.apply(this,arguments)}function M(n,t){n.prototype=Object.create(t.prototype),n.prototype.constructor=n,st(n,t)}function P(n){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},P(n)}function st(n,t){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,s){return i.__proto__=s,i},st(n,t)}function me(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function ft(n,t,e){return me()?ft=Reflect.construct.bind():ft=function(s,r,o){var a=[null];a.push.apply(a,r);var h=Function.bind.apply(s,a),c=new h;return o&&st(c,o.prototype),c},ft.apply(null,arguments)}function Ee(n){return Function.toString.call(n).indexOf("[native code]")!==-1}function Et(n){var t=typeof Map=="function"?new Map:void 0;return Et=function(i){if(i===null||!Ee(i))return i;if(typeof i!="function")throw new TypeError("Super expression must either be null or a function");if(typeof t<"u"){if(t.has(i))return t.get(i);t.set(i,s)}function s(){return ft(i,arguments,P(this).constructor)}return s.prototype=Object.create(i.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),st(s,i)},Et(n)}var be=/%[sdj%]/g,Xt=function(){};typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"&&typeof window<"u"&&typeof document<"u"&&(Xt=function(t,e){typeof console<"u"&&console.warn&&typeof ASYNC_VALIDATOR_NO_WARNING>"u"&&e.every(function(i){return typeof i=="string"})&&console.warn(t,e)});function bt(n){if(!n||!n.length)return null;var t={};return n.forEach(function(e){var i=e.field;t[i]=t[i]||[],t[i].push(e)}),t}function H(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];var s=0,r=e.length;if(typeof n=="function")return n.apply(null,e);if(typeof n=="string"){var o=n.replace(be,function(a){if(a==="%%")return"%";if(s>=r)return a;switch(a){case"%s":return String(e[s++]);case"%d":return Number(e[s++]);case"%j":try{return JSON.stringify(e[s++])}catch{return"[Circular]"}break;default:return a}});return o}return n}function Ce(n){return n==="string"||n==="url"||n==="hex"||n==="email"||n==="date"||n==="pattern"}function _(n,t){return!!(n==null||t==="array"&&Array.isArray(n)&&!n.length||Ce(t)&&typeof n=="string"&&!n)}function ve(n,t,e){var i=[],s=0,r=n.length;function o(a){i.push.apply(i,a||[]),s++,s===r&&e(i)}n.forEach(function(a){t(a,o)})}function kt(n,t,e){var i=0,s=n.length;function r(o){if(o&&o.length){e(o);return}var a=i;i=i+1,a<s?t(n[a],r):e([])}r([])}function Re(n){var t=[];return Object.keys(n).forEach(function(e){t.push.apply(t,n[e]||[])}),t}var Nt=function(n){M(t,n);function t(e,i){var s;return s=n.call(this,"Async Validation Error")||this,s.errors=e,s.fields=i,s}return t}(Et(Error));function _e(n,t,e,i,s){if(t.first){var r=new Promise(function(x,u){var g=function(y){return i(y),y.length?u(new Nt(y,bt(y))):x(s)},w=Re(n);kt(w,e,g)});return r.catch(function(x){return x}),r}var o=t.firstFields===!0?Object.keys(n):t.firstFields||[],a=Object.keys(n),h=a.length,c=0,f=[],d=new Promise(function(x,u){var g=function(p){if(f.push.apply(f,p),c++,c===h)return i(f),f.length?u(new Nt(f,bt(f))):x(s)};a.length||(i(f),x(s)),a.forEach(function(w){var p=n[w];o.indexOf(w)!==-1?kt(p,e,g):ve(p,e,g)})});return d.catch(function(x){return x}),d}function Ie(n){return!!(n&&n.message!==void 0)}function Oe(n,t){for(var e=n,i=0;i<t.length;i++){if(e==null)return e;e=e[t[i]]}return e}function Kt(n,t){return function(e){var i;return n.fullFields?i=Oe(t,n.fullFields):i=t[e.field||n.fullField],Ie(e)?(e.field=e.field||n.fullField,e.fieldValue=i,e):{message:typeof e=="function"?e():e,fieldValue:i,field:e.field||n.fullField}}}function Yt(n,t){if(t){for(var e in t)if(t.hasOwnProperty(e)){var i=t[e];typeof i=="object"&&typeof n[e]=="object"?n[e]=I({},n[e],i):n[e]=i}}return n}var Bt=function(t,e,i,s,r,o){t.required&&(!i.hasOwnProperty(t.field)||_(e,o||t.type))&&s.push(H(r.messages.required,t.fullField))},Te=function(t,e,i,s,r){(/^\s+$/.test(e)||e==="")&&s.push(H(r.messages.whitespace,t.fullField))},xt,Se=function(){if(xt)return xt;var n="[a-fA-F\\d:]",t=function(E){return E&&E.includeBoundaries?"(?:(?<=\\s|^)(?="+n+")|(?<="+n+")(?=\\s|$))":""},e="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",i="[a-fA-F\\d]{1,4}",s=(`
3
3
  (?:
4
4
  (?:`+i+":){7}(?:"+i+`|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
5
5
  (?:`+i+":){6}(?:"+e+"|:"+i+`|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
@@ -10,8 +10,8 @@
10
10
  (?:`+i+":){1}(?:(?::"+i+"){0,4}:"+e+"|(?::"+i+`){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
11
11
  (?::(?:(?::`+i+"){0,5}:"+e+"|(?::"+i+`){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
12
12
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
13
- `).replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),r=new RegExp("(?:^"+e+"$)|(?:^"+s+"$)"),o=new RegExp("^"+e+"$"),a=new RegExp("^"+s+"$"),l=function(E){return E&&E.exact?r:new RegExp("(?:"+t(E)+e+t(E)+")|(?:"+t(E)+s+t(E)+")","g")};l.v4=function(m){return m&&m.exact?o:new RegExp(""+t(m)+e+t(m),"g")},l.v6=function(m){return m&&m.exact?a:new RegExp(""+t(m)+s+t(m),"g")};var c="(?:(?:[a-z]+:)?//)",f="(?:\\S+(?::\\S*)?@)?",d=l.v4().source,x=l.v6().source,u="(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)",g="(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*",w="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))",p="(?::\\d{2,5})?",y='(?:[/?#][^\\s"]*)?',b="(?:"+c+"|www\\.)"+f+"(?:localhost|"+d+"|"+x+"|"+u+g+w+")"+p+y;return xt=new RegExp("(?:^"+b+"$)","i"),xt},Wt={email:/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,hex:/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i},rt={integer:function(t){return rt.number(t)&&parseInt(t,10)===t},float:function(t){return rt.number(t)&&!rt.integer(t)},array:function(t){return Array.isArray(t)},regexp:function(t){if(t instanceof RegExp)return!0;try{return!!new RegExp(t)}catch{return!1}},date:function(t){return typeof t.getTime=="function"&&typeof t.getMonth=="function"&&typeof t.getYear=="function"&&!isNaN(t.getTime())},number:function(t){return isNaN(t)?!1:typeof t=="number"},object:function(t){return typeof t=="object"&&!rt.array(t)},method:function(t){return typeof t=="function"},email:function(t){return typeof t=="string"&&t.length<=320&&!!t.match(Wt.email)},url:function(t){return typeof t=="string"&&t.length<=2048&&!!t.match(Se())},hex:function(t){return typeof t=="string"&&!!t.match(Wt.hex)}},Ae=function(t,e,i,s,r){if(t.required&&e===void 0){Bt(t,e,i,s,r);return}var o=["integer","float","array","regexp","object","method","email","number","date","url","hex"],a=t.type;o.indexOf(a)>-1?rt[a](e)||s.push(H(r.messages.types[a],t.fullField,t.type)):a&&typeof e!==t.type&&s.push(H(r.messages.types[a],t.fullField,t.type))},Le=function(t,e,i,s,r){var o=typeof t.len=="number",a=typeof t.min=="number",l=typeof t.max=="number",c=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,f=e,d=null,x=typeof e=="number",u=typeof e=="string",g=Array.isArray(e);if(x?d="number":u?d="string":g&&(d="array"),!d)return!1;g&&(f=e.length),u&&(f=e.replace(c,"_").length),o?f!==t.len&&s.push(H(r.messages[d].len,t.fullField,t.len)):a&&!l&&f<t.min?s.push(H(r.messages[d].min,t.fullField,t.min)):l&&!a&&f>t.max?s.push(H(r.messages[d].max,t.fullField,t.max)):a&&l&&(f<t.min||f>t.max)&&s.push(H(r.messages[d].range,t.fullField,t.min,t.max))},U="enum",Me=function(t,e,i,s,r){t[U]=Array.isArray(t[U])?t[U]:[],t[U].indexOf(e)===-1&&s.push(H(r.messages[U],t.fullField,t[U].join(", ")))},He=function(t,e,i,s,r){if(t.pattern){if(t.pattern instanceof RegExp)t.pattern.lastIndex=0,t.pattern.test(e)||s.push(H(r.messages.pattern.mismatch,t.fullField,e,t.pattern));else if(typeof t.pattern=="string"){var o=new RegExp(t.pattern);o.test(e)||s.push(H(r.messages.pattern.mismatch,t.fullField,e,t.pattern))}}},v={required:Bt,whitespace:Te,type:Ae,range:Le,enum:Me,pattern:He},De=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e,"string")&&!t.required)return i();v.required(t,e,s,o,r,"string"),_(e,"string")||(v.type(t,e,s,o,r),v.range(t,e,s,o,r),v.pattern(t,e,s,o,r),t.whitespace===!0&&v.whitespace(t,e,s,o,r))}i(o)},Fe=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&v.type(t,e,s,o,r)}i(o)},Xe=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(e===""&&(e=void 0),_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&(v.type(t,e,s,o,r),v.range(t,e,s,o,r))}i(o)},ke=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&v.type(t,e,s,o,r)}i(o)},Ne=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),_(e)||v.type(t,e,s,o,r)}i(o)},Ye=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&(v.type(t,e,s,o,r),v.range(t,e,s,o,r))}i(o)},Ke=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&(v.type(t,e,s,o,r),v.range(t,e,s,o,r))}i(o)},Be=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(e==null&&!t.required)return i();v.required(t,e,s,o,r,"array"),e!=null&&(v.type(t,e,s,o,r),v.range(t,e,s,o,r))}i(o)},We=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&v.type(t,e,s,o,r)}i(o)},Pe="enum",Ve=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&v[Pe](t,e,s,o,r)}i(o)},ze=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e,"string")&&!t.required)return i();v.required(t,e,s,o,r),_(e,"string")||v.pattern(t,e,s,o,r)}i(o)},$e=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e,"date")&&!t.required)return i();if(v.required(t,e,s,o,r),!_(e,"date")){var l;e instanceof Date?l=e:l=new Date(e),v.type(t,l,s,o,r),l&&v.range(t,l.getTime(),s,o,r)}}i(o)},qe=function(t,e,i,s,r){var o=[],a=Array.isArray(e)?"array":typeof e;v.required(t,e,s,o,r,a),i(o)},Ct=function(t,e,i,s,r){var o=t.type,a=[],l=t.required||!t.required&&s.hasOwnProperty(t.field);if(l){if(_(e,o)&&!t.required)return i();v.required(t,e,s,a,r,o),_(e,o)||v.type(t,e,s,a,r)}i(a)},Ge=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r)}i(o)},ot={string:De,method:Fe,number:Xe,boolean:ke,regexp:Ne,integer:Ye,float:Ke,array:Be,object:We,enum:Ve,pattern:ze,date:$e,url:Ct,hex:Ct,email:Ct,required:qe,any:Ge};function vt(){return{default:"Validation error on field %s",required:"%s is required",enum:"%s must be one of %s",whitespace:"%s cannot be empty",date:{format:"%s date %s is invalid for format %s",parse:"%s date could not be parsed, %s is invalid ",invalid:"%s date %s is invalid"},types:{string:"%s is not a %s",method:"%s is not a %s (function)",array:"%s is not an %s",object:"%s is not an %s",number:"%s is not a %s",date:"%s is not a %s",boolean:"%s is not a %s",integer:"%s is not an %s",float:"%s is not a %s",regexp:"%s is not a valid %s",email:"%s is not a valid %s",url:"%s is not a valid %s",hex:"%s is not a valid %s"},string:{len:"%s must be exactly %s characters",min:"%s must be at least %s characters",max:"%s cannot be longer than %s characters",range:"%s must be between %s and %s characters"},number:{len:"%s must equal %s",min:"%s cannot be less than %s",max:"%s cannot be greater than %s",range:"%s must be between %s and %s"},array:{len:"%s must be exactly %s in length",min:"%s cannot be less than %s in length",max:"%s cannot be greater than %s in length",range:"%s must be between %s and %s in length"},pattern:{mismatch:"%s value %s does not match pattern %s"},clone:function(){var t=JSON.parse(JSON.stringify(this));return t.clone=this.clone,t}}}var Rt=vt(),nt=function(){function n(e){this.rules=null,this._messages=Rt,this.define(e)}var t=n.prototype;return t.define=function(i){var s=this;if(!i)throw new Error("Cannot configure a schema with no rules");if(typeof i!="object"||Array.isArray(i))throw new Error("Rules must be an object");this.rules={},Object.keys(i).forEach(function(r){var o=i[r];s.rules[r]=Array.isArray(o)?o:[o]})},t.messages=function(i){return i&&(this._messages=Kt(vt(),i)),this._messages},t.validate=function(i,s,r){var o=this;s===void 0&&(s={}),r===void 0&&(r=function(){});var a=i,l=s,c=r;if(typeof l=="function"&&(c=l,l={}),!this.rules||Object.keys(this.rules).length===0)return c&&c(null,a),Promise.resolve(a);function f(w){var p=[],y={};function b(E){if(Array.isArray(E)){var C;p=(C=p).concat.apply(C,E)}else p.push(E)}for(var m=0;m<w.length;m++)b(w[m]);p.length?(y=bt(p),c(p,y)):c(null,a)}if(l.messages){var d=this.messages();d===Rt&&(d=vt()),Kt(d,l.messages),l.messages=d}else l.messages=this.messages();var x={},u=l.keys||Object.keys(this.rules);u.forEach(function(w){var p=o.rules[w],y=a[w];p.forEach(function(b){var m=b;typeof m.transform=="function"&&(a===i&&(a=I({},a)),y=a[w]=m.transform(y)),typeof m=="function"?m={validator:m}:m=I({},m),m.validator=o.getValidationMethod(m),m.validator&&(m.field=w,m.fullField=m.fullField||w,m.type=o.getType(m),x[w]=x[w]||[],x[w].push({rule:m,value:y,source:a,field:w}))})});var g={};return _e(x,l,function(w,p){var y=w.rule,b=(y.type==="object"||y.type==="array")&&(typeof y.fields=="object"||typeof y.defaultField=="object");b=b&&(y.required||!y.required&&w.value),y.field=w.field;function m(R,S){return I({},S,{fullField:y.fullField+"."+R,fullFields:y.fullFields?[].concat(y.fullFields,[R]):[R]})}function E(R){R===void 0&&(R=[]);var S=Array.isArray(R)?R:[R];!l.suppressWarning&&S.length&&n.warning("async-validator:",S),S.length&&y.message!==void 0&&(S=[].concat(y.message));var L=S.map(Yt(y,a));if(l.first&&L.length)return g[y.field]=1,p(L);if(!b)p(L);else{if(y.required&&!w.value)return y.message!==void 0?L=[].concat(y.message).map(Yt(y,a)):l.error&&(L=[l.error(y,H(l.messages.required,y.field))]),p(L);var F={};y.defaultField&&Object.keys(w.value).map(function(O){F[O]=y.defaultField}),F=I({},F,w.rule.fields);var N={};Object.keys(F).forEach(function(O){var A=F[O],T=Array.isArray(A)?A:[A];N[O]=T.map(m.bind(null,O))});var $=new n(N);$.messages(l.messages),w.rule.options&&(w.rule.options.messages=l.messages,w.rule.options.error=l.error),$.validate(w.value,w.rule.options||l,function(O){var A=[];L&&L.length&&A.push.apply(A,L),O&&O.length&&A.push.apply(A,O),p(A.length?A:null)})}}var C;if(y.asyncValidator)C=y.asyncValidator(y,w.value,E,w.source,l);else if(y.validator){try{C=y.validator(y,w.value,E,w.source,l)}catch(R){console.error==null||console.error(R),l.suppressValidatorError||setTimeout(function(){throw R},0),E(R.message)}C===!0?E():C===!1?E(typeof y.message=="function"?y.message(y.fullField||y.field):y.message||(y.fullField||y.field)+" fails"):C instanceof Array?E(C):C instanceof Error&&E(C.message)}C&&C.then&&C.then(function(){return E()},function(R){return E(R)})},function(w){f(w)},a)},t.getType=function(i){if(i.type===void 0&&i.pattern instanceof RegExp&&(i.type="pattern"),typeof i.validator!="function"&&i.type&&!ot.hasOwnProperty(i.type))throw new Error(H("Unknown rule type %s",i.type));return i.type||"string"},t.getValidationMethod=function(i){if(typeof i.validator=="function")return i.validator;var s=Object.keys(i),r=s.indexOf("message");return r!==-1&&s.splice(r,1),s.length===1&&s[0]==="required"?ot.required:ot[this.getType(i)]||void 0},n}();nt.register=function(t,e){if(typeof e!="function")throw new Error("Cannot register a validator by type, validator is not a function");ot[t]=e},nt.warning=Xt,nt.messages=Rt,nt.validators=ot;function Pt(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(n){const t=Math.random()*16|0;return(n==="x"?t:t&3|8).toString(16)})}function Vt(n,t){let e=0,i;return function(...s){const r=new Date().getTime(),o=r-e;!e||o>=t?(n.apply(this,s),e=r):i||(i=setTimeout(()=>{n.apply(this,s),e=new Date().getTime(),i=void 0},t-o))}}function zt(n){return n?n.map(t=>zt(t.children)+1).sort((t,e)=>e-t)[0]:0}function je(n=[]){let t=[],e=[],i=[];return n.forEach(s=>{s.fixed==="left"?t.push(s):s.fixed==="right"?i.push(s):e.push(s)}),[...t.sort((s,r)=>s.sort-r.sort),...e.sort((s,r)=>s.sort-r.sort),...i.sort((s,r)=>s.sort-r.sort)]}function $t(n=[],t=1,e=0){return n.map(i=>{if(i.children){let s=0,r=i.fixed;i.children.forEach(a=>{a.fixed=r});const o=$t(i.children,t-1,e+1);return o&&o.forEach(a=>{s+=a.colspan}),{...i,width:i.width,level:e,rowspan:1,colspan:s,children:o}}return{...i,level:e,rowspan:t,colspan:1}})}function _t(n=[]){let t=[];return n.forEach(e=>{e.children?t=t.concat(_t(e.children)):t.push(e)}),t}const qt=/^(\r\n|\n\r|\r|\n)/,Ue=/^[^\t\r\n]+/,Gt=/^\t/;function Ze(n){let t=[[""]];if(n.length===0)return t;let e=0,i=0,s;for(;n.length>0&&s!==n.length;)if(s=n.length,n.match(Gt))n=n.replace(Gt,""),e+=1,t[i][e]="";else if(n.match(qt))n=n.replace(qt,""),e=0,i+=1,t[i]=[""];else{let r="";if(n.startsWith('"')){let o=0,a=!0;for(;a;){const l=n.slice(0,1);l==='"'&&(o+=1),r+=l,n=n.slice(1),(n.length===0||n.match(/^[\t\r\n]/)&&o%2===0)&&(a=!1)}r=r.replace(/^"/,"").replace(/"$/,"").replace(/["]*/g,l=>new Array(Math.floor(l.length/2)).fill('"').join(""))}else{const o=n.match(Ue);r=o?o[0]:"",n=n.slice(r.length)}t[i][e]=r}return Array.isArray(t)&&t.length>1&&t[t.length-1].length===1&&t[t.length-1][0]===""&&(t=t.slice(0,t.length-1)),t}function Je(n){let t,e,i,s,r="",o;for(t=0,e=n.length;t<e;t+=1){for(s=n[t].length,i=0;i<s;i+=1)i>0&&(r+=" "),o=n[t][i],typeof o=="string"?o.indexOf(`
13
+ `).replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),r=new RegExp("(?:^"+e+"$)|(?:^"+s+"$)"),o=new RegExp("^"+e+"$"),a=new RegExp("^"+s+"$"),h=function(E){return E&&E.exact?r:new RegExp("(?:"+t(E)+e+t(E)+")|(?:"+t(E)+s+t(E)+")","g")};h.v4=function(m){return m&&m.exact?o:new RegExp(""+t(m)+e+t(m),"g")},h.v6=function(m){return m&&m.exact?a:new RegExp(""+t(m)+s+t(m),"g")};var c="(?:(?:[a-z]+:)?//)",f="(?:\\S+(?::\\S*)?@)?",d=h.v4().source,x=h.v6().source,u="(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)",g="(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*",w="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))",p="(?::\\d{2,5})?",y='(?:[/?#][^\\s"]*)?',b="(?:"+c+"|www\\.)"+f+"(?:localhost|"+d+"|"+x+"|"+u+g+w+")"+p+y;return xt=new RegExp("(?:^"+b+"$)","i"),xt},Wt={email:/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,hex:/^#?([a-f0-9]{6}|[a-f0-9]{3})$/i},rt={integer:function(t){return rt.number(t)&&parseInt(t,10)===t},float:function(t){return rt.number(t)&&!rt.integer(t)},array:function(t){return Array.isArray(t)},regexp:function(t){if(t instanceof RegExp)return!0;try{return!!new RegExp(t)}catch{return!1}},date:function(t){return typeof t.getTime=="function"&&typeof t.getMonth=="function"&&typeof t.getYear=="function"&&!isNaN(t.getTime())},number:function(t){return isNaN(t)?!1:typeof t=="number"},object:function(t){return typeof t=="object"&&!rt.array(t)},method:function(t){return typeof t=="function"},email:function(t){return typeof t=="string"&&t.length<=320&&!!t.match(Wt.email)},url:function(t){return typeof t=="string"&&t.length<=2048&&!!t.match(Se())},hex:function(t){return typeof t=="string"&&!!t.match(Wt.hex)}},Ae=function(t,e,i,s,r){if(t.required&&e===void 0){Bt(t,e,i,s,r);return}var o=["integer","float","array","regexp","object","method","email","number","date","url","hex"],a=t.type;o.indexOf(a)>-1?rt[a](e)||s.push(H(r.messages.types[a],t.fullField,t.type)):a&&typeof e!==t.type&&s.push(H(r.messages.types[a],t.fullField,t.type))},Le=function(t,e,i,s,r){var o=typeof t.len=="number",a=typeof t.min=="number",h=typeof t.max=="number",c=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,f=e,d=null,x=typeof e=="number",u=typeof e=="string",g=Array.isArray(e);if(x?d="number":u?d="string":g&&(d="array"),!d)return!1;g&&(f=e.length),u&&(f=e.replace(c,"_").length),o?f!==t.len&&s.push(H(r.messages[d].len,t.fullField,t.len)):a&&!h&&f<t.min?s.push(H(r.messages[d].min,t.fullField,t.min)):h&&!a&&f>t.max?s.push(H(r.messages[d].max,t.fullField,t.max)):a&&h&&(f<t.min||f>t.max)&&s.push(H(r.messages[d].range,t.fullField,t.min,t.max))},U="enum",Me=function(t,e,i,s,r){t[U]=Array.isArray(t[U])?t[U]:[],t[U].indexOf(e)===-1&&s.push(H(r.messages[U],t.fullField,t[U].join(", ")))},He=function(t,e,i,s,r){if(t.pattern){if(t.pattern instanceof RegExp)t.pattern.lastIndex=0,t.pattern.test(e)||s.push(H(r.messages.pattern.mismatch,t.fullField,e,t.pattern));else if(typeof t.pattern=="string"){var o=new RegExp(t.pattern);o.test(e)||s.push(H(r.messages.pattern.mismatch,t.fullField,e,t.pattern))}}},v={required:Bt,whitespace:Te,type:Ae,range:Le,enum:Me,pattern:He},De=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e,"string")&&!t.required)return i();v.required(t,e,s,o,r,"string"),_(e,"string")||(v.type(t,e,s,o,r),v.range(t,e,s,o,r),v.pattern(t,e,s,o,r),t.whitespace===!0&&v.whitespace(t,e,s,o,r))}i(o)},Fe=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&v.type(t,e,s,o,r)}i(o)},Xe=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(e===""&&(e=void 0),_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&(v.type(t,e,s,o,r),v.range(t,e,s,o,r))}i(o)},ke=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&v.type(t,e,s,o,r)}i(o)},Ne=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),_(e)||v.type(t,e,s,o,r)}i(o)},Ke=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&(v.type(t,e,s,o,r),v.range(t,e,s,o,r))}i(o)},Ye=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&(v.type(t,e,s,o,r),v.range(t,e,s,o,r))}i(o)},Be=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(e==null&&!t.required)return i();v.required(t,e,s,o,r,"array"),e!=null&&(v.type(t,e,s,o,r),v.range(t,e,s,o,r))}i(o)},We=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&v.type(t,e,s,o,r)}i(o)},Pe="enum",Ve=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r),e!==void 0&&v[Pe](t,e,s,o,r)}i(o)},ze=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e,"string")&&!t.required)return i();v.required(t,e,s,o,r),_(e,"string")||v.pattern(t,e,s,o,r)}i(o)},$e=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e,"date")&&!t.required)return i();if(v.required(t,e,s,o,r),!_(e,"date")){var h;e instanceof Date?h=e:h=new Date(e),v.type(t,h,s,o,r),h&&v.range(t,h.getTime(),s,o,r)}}i(o)},qe=function(t,e,i,s,r){var o=[],a=Array.isArray(e)?"array":typeof e;v.required(t,e,s,o,r,a),i(o)},Ct=function(t,e,i,s,r){var o=t.type,a=[],h=t.required||!t.required&&s.hasOwnProperty(t.field);if(h){if(_(e,o)&&!t.required)return i();v.required(t,e,s,a,r,o),_(e,o)||v.type(t,e,s,a,r)}i(a)},Ge=function(t,e,i,s,r){var o=[],a=t.required||!t.required&&s.hasOwnProperty(t.field);if(a){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r)}i(o)},ot={string:De,method:Fe,number:Xe,boolean:ke,regexp:Ne,integer:Ke,float:Ye,array:Be,object:We,enum:Ve,pattern:ze,date:$e,url:Ct,hex:Ct,email:Ct,required:qe,any:Ge};function vt(){return{default:"Validation error on field %s",required:"%s is required",enum:"%s must be one of %s",whitespace:"%s cannot be empty",date:{format:"%s date %s is invalid for format %s",parse:"%s date could not be parsed, %s is invalid ",invalid:"%s date %s is invalid"},types:{string:"%s is not a %s",method:"%s is not a %s (function)",array:"%s is not an %s",object:"%s is not an %s",number:"%s is not a %s",date:"%s is not a %s",boolean:"%s is not a %s",integer:"%s is not an %s",float:"%s is not a %s",regexp:"%s is not a valid %s",email:"%s is not a valid %s",url:"%s is not a valid %s",hex:"%s is not a valid %s"},string:{len:"%s must be exactly %s characters",min:"%s must be at least %s characters",max:"%s cannot be longer than %s characters",range:"%s must be between %s and %s characters"},number:{len:"%s must equal %s",min:"%s cannot be less than %s",max:"%s cannot be greater than %s",range:"%s must be between %s and %s"},array:{len:"%s must be exactly %s in length",min:"%s cannot be less than %s in length",max:"%s cannot be greater than %s in length",range:"%s must be between %s and %s in length"},pattern:{mismatch:"%s value %s does not match pattern %s"},clone:function(){var t=JSON.parse(JSON.stringify(this));return t.clone=this.clone,t}}}var Rt=vt(),nt=function(){function n(e){this.rules=null,this._messages=Rt,this.define(e)}var t=n.prototype;return t.define=function(i){var s=this;if(!i)throw new Error("Cannot configure a schema with no rules");if(typeof i!="object"||Array.isArray(i))throw new Error("Rules must be an object");this.rules={},Object.keys(i).forEach(function(r){var o=i[r];s.rules[r]=Array.isArray(o)?o:[o]})},t.messages=function(i){return i&&(this._messages=Yt(vt(),i)),this._messages},t.validate=function(i,s,r){var o=this;s===void 0&&(s={}),r===void 0&&(r=function(){});var a=i,h=s,c=r;if(typeof h=="function"&&(c=h,h={}),!this.rules||Object.keys(this.rules).length===0)return c&&c(null,a),Promise.resolve(a);function f(w){var p=[],y={};function b(E){if(Array.isArray(E)){var C;p=(C=p).concat.apply(C,E)}else p.push(E)}for(var m=0;m<w.length;m++)b(w[m]);p.length?(y=bt(p),c(p,y)):c(null,a)}if(h.messages){var d=this.messages();d===Rt&&(d=vt()),Yt(d,h.messages),h.messages=d}else h.messages=this.messages();var x={},u=h.keys||Object.keys(this.rules);u.forEach(function(w){var p=o.rules[w],y=a[w];p.forEach(function(b){var m=b;typeof m.transform=="function"&&(a===i&&(a=I({},a)),y=a[w]=m.transform(y)),typeof m=="function"?m={validator:m}:m=I({},m),m.validator=o.getValidationMethod(m),m.validator&&(m.field=w,m.fullField=m.fullField||w,m.type=o.getType(m),x[w]=x[w]||[],x[w].push({rule:m,value:y,source:a,field:w}))})});var g={};return _e(x,h,function(w,p){var y=w.rule,b=(y.type==="object"||y.type==="array")&&(typeof y.fields=="object"||typeof y.defaultField=="object");b=b&&(y.required||!y.required&&w.value),y.field=w.field;function m(R,S){return I({},S,{fullField:y.fullField+"."+R,fullFields:y.fullFields?[].concat(y.fullFields,[R]):[R]})}function E(R){R===void 0&&(R=[]);var S=Array.isArray(R)?R:[R];!h.suppressWarning&&S.length&&n.warning("async-validator:",S),S.length&&y.message!==void 0&&(S=[].concat(y.message));var L=S.map(Kt(y,a));if(h.first&&L.length)return g[y.field]=1,p(L);if(!b)p(L);else{if(y.required&&!w.value)return y.message!==void 0?L=[].concat(y.message).map(Kt(y,a)):h.error&&(L=[h.error(y,H(h.messages.required,y.field))]),p(L);var F={};y.defaultField&&Object.keys(w.value).map(function(O){F[O]=y.defaultField}),F=I({},F,w.rule.fields);var N={};Object.keys(F).forEach(function(O){var A=F[O],T=Array.isArray(A)?A:[A];N[O]=T.map(m.bind(null,O))});var $=new n(N);$.messages(h.messages),w.rule.options&&(w.rule.options.messages=h.messages,w.rule.options.error=h.error),$.validate(w.value,w.rule.options||h,function(O){var A=[];L&&L.length&&A.push.apply(A,L),O&&O.length&&A.push.apply(A,O),p(A.length?A:null)})}}var C;if(y.asyncValidator)C=y.asyncValidator(y,w.value,E,w.source,h);else if(y.validator){try{C=y.validator(y,w.value,E,w.source,h)}catch(R){console.error==null||console.error(R),h.suppressValidatorError||setTimeout(function(){throw R},0),E(R.message)}C===!0?E():C===!1?E(typeof y.message=="function"?y.message(y.fullField||y.field):y.message||(y.fullField||y.field)+" fails"):C instanceof Array?E(C):C instanceof Error&&E(C.message)}C&&C.then&&C.then(function(){return E()},function(R){return E(R)})},function(w){f(w)},a)},t.getType=function(i){if(i.type===void 0&&i.pattern instanceof RegExp&&(i.type="pattern"),typeof i.validator!="function"&&i.type&&!ot.hasOwnProperty(i.type))throw new Error(H("Unknown rule type %s",i.type));return i.type||"string"},t.getValidationMethod=function(i){if(typeof i.validator=="function")return i.validator;var s=Object.keys(i),r=s.indexOf("message");return r!==-1&&s.splice(r,1),s.length===1&&s[0]==="required"?ot.required:ot[this.getType(i)]||void 0},n}();nt.register=function(t,e){if(typeof e!="function")throw new Error("Cannot register a validator by type, validator is not a function");ot[t]=e},nt.warning=Xt,nt.messages=Rt,nt.validators=ot;function Pt(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(n){const t=Math.random()*16|0;return(n==="x"?t:t&3|8).toString(16)})}function Vt(n,t){let e=0,i;return function(...s){const r=new Date().getTime(),o=r-e;!e||o>=t?(n.apply(this,s),e=r):i||(i=setTimeout(()=>{n.apply(this,s),e=new Date().getTime(),i=void 0},t-o))}}function zt(n){return n?n.map(t=>zt(t.children)+1).sort((t,e)=>e-t)[0]:0}function je(n=[]){let t=[],e=[],i=[];return n.forEach(s=>{s.fixed==="left"?t.push(s):s.fixed==="right"?i.push(s):e.push(s)}),[...t.sort((s,r)=>s.sort-r.sort),...e.sort((s,r)=>s.sort-r.sort),...i.sort((s,r)=>s.sort-r.sort)]}function $t(n=[],t=1,e=0){return n.map(i=>{if(i.children){let s=0,r=i.fixed;i.children.forEach(a=>{a.fixed=r});const o=$t(i.children,t-1,e+1);return o&&o.forEach(a=>{s+=a.colspan}),{...i,width:i.width,level:e,rowspan:1,colspan:s,children:o}}return{...i,level:e,rowspan:t,colspan:1}})}function _t(n=[]){let t=[];return n.forEach(e=>{e.children?t=t.concat(_t(e.children)):t.push(e)}),t}const qt=/^(\r\n|\n\r|\r|\n)/,Ue=/^[^\t\r\n]+/,Gt=/^\t/;function Ze(n){let t=[[""]];if(n.length===0)return t;let e=0,i=0,s;for(;n.length>0&&s!==n.length;)if(s=n.length,n.match(Gt))n=n.replace(Gt,""),e+=1,t[i][e]="";else if(n.match(qt))n=n.replace(qt,""),e=0,i+=1,t[i]=[""];else{let r="";if(n.startsWith('"')){let o=0,a=!0;for(;a;){const h=n.slice(0,1);h==='"'&&(o+=1),r+=h,n=n.slice(1),(n.length===0||n.match(/^[\t\r\n]/)&&o%2===0)&&(a=!1)}r=r.replace(/^"/,"").replace(/"$/,"").replace(/["]*/g,h=>new Array(Math.floor(h.length/2)).fill('"').join(""))}else{const o=n.match(Ue);r=o?o[0]:"",n=n.slice(r.length)}t[i][e]=r}return Array.isArray(t)&&t.length>1&&t[t.length-1].length===1&&t[t.length-1][0]===""&&(t=t.slice(0,t.length-1)),t}function Je(n){let t,e,i,s,r="",o;for(t=0,e=n.length;t<e;t+=1){for(s=n[t].length,i=0;i<s;i+=1)i>0&&(r+=" "),o=n[t][i],typeof o=="string"?o.indexOf(`
14
14
  `)>-1?r+=`"${o.replace(/"/g,'""')}"`:r+=o:o==null?r+="":r+=o;t!==e-1&&(r+=`
15
- `)}return r}class Qe{constructor(t,e){h(this,"loading",!1);h(this,"ctx");h(this,"data");h(this,"columns");h(this,"footerData",[]);h(this,"rowKeyMap",new Map);h(this,"colIndexKeyMap",new Map);h(this,"headerMap",new Map);h(this,"rowIndexRowKeyMap",new Map);h(this,"checkboxKeyMap",new Map);h(this,"originalDataMap",new Map);h(this,"changedDataMap",new Map);h(this,"validationErrorMap",new Map);h(this,"itemRowKeyMap",new WeakMap);h(this,"bufferData",[]);h(this,"sumHeight",0);h(this,"filterMethod");h(this,"positions",[]);this.ctx=t;const{data:i=[],columns:s=[],footerData:r=[]}=e;this.data=i,this.footerData=r,this.columns=s,this.setLoading(!0),this.init()}init(){this.clearBufferData(),this.rowKeyMap.clear(),this.checkboxKeyMap.clear(),this.colIndexKeyMap.clear(),this.rowIndexRowKeyMap.clear(),this.originalDataMap.clear(),this.changedDataMap.clear(),this.validationErrorMap.clear(),this.itemRowKeyMap=new WeakMap,this.initData(this.data)}clearBufferData(){this.bufferData=[]}initData(t,e=0){t.forEach((i,s)=>{let r=i._hasChildren||!1;Array.isArray(i.children)&&i.children.length&&(r=!0,this.initData(i.children,e+1));const{ROW_KEY:o="",DEFAULT_EXPAND_ALL:a,CELL_HEIGHT:l,SELECTABLE_METHOD:c,CHECKBOX_KEY:f}=this.ctx.config,d=i[o],x=d!=null?`${d}`:Pt();this.itemRowKeyMap.set(i,x);const u=i._height||l,g=i._readonly;let w=!0;if(typeof c=="function"&&(w=c),f){const p=i[f];if(this.checkboxKeyMap.has(p)){const y=this.checkboxKeyMap.get(p);y.push(x),this.checkboxKeyMap.set(p,y)}else this.checkboxKeyMap.set(p,[x])}this.rowKeyMap.set(x,{readonly:g,index:s,rowIndex:s,level:e,height:u,check:!1,selectable:w,expand:a,expandLazy:!1,hasChildren:r,expandLoading:!1,item:i})})}setRowHeight(t,e){const i=this.rowIndexRowKeyMap.get(t),s=this.rowKeyMap.get(i);s.height=e,s.item._height=e,this.clearBufferData()}getAllRowsData(){let t=[];const e=i=>{i.forEach(s=>{t.push(s),Array.isArray(s.children)&&e(s.children)})};return e(this.data),t}filterColumns(t){return t.reduce((e,i)=>{if(!(typeof i.hide=="function"?i.hide():i.hide)){const r={...i};r.children&&Array.isArray(r.children)&&(r.children=this.filterColumns(r.children)),e.push(r)}return e},[])}getColumns(){return this.filterColumns(this.columns)}setColumns(t){this.columns=t,this.clearBufferData()}setData(t){this.data=t,this.columns.length&&this.init()}getData(){if(this.bufferData.length>0)return{data:this.bufferData,sumHeight:this.sumHeight,positions:this.positions};let t=[],e=0;this.sumHeight=0,this.positions=[];const i=r=>{r.forEach(o=>{t.push(o);const a=this.itemRowKeyMap.get(o),{expand:l,hasChildren:c,height:f}=this.rowKeyMap.get(a),d=this.sumHeight;this.sumHeight+=f,this.rowIndexRowKeyMap.set(e,a),this.positions.push({top:d,height:f,bottom:this.sumHeight}),e+=1,l&&c&&i(o.children)})};this.rowIndexRowKeyMap.clear();let s=this.data;return typeof this.filterMethod=="function"&&(s=this.filterMethod(s)),i(s),this.bufferData=t,{data:t,sumHeight:this.sumHeight,positions:this.positions}}setFooterData(t){this.footerData=t}getFooterData(){return this.footerData}setFilterMethod(t){this.filterMethod=t}clearFilterMethod(){this.filterMethod=void 0}expandItem(t,e=!1){const i=this.rowKeyMap.get(t);i.expand=e,this.clearBufferData(),this.ctx.emit("draw")}setExpandRowKeys(t,e=!0){t.forEach(i=>{const s=this.rowKeyMap.get(i);s.expand=e}),this.clearBufferData(),this.ctx.emit("draw")}getExpandRowKeys(){let t=[];return this.rowKeyMap.forEach((e,i)=>{e.expand&&t.push(i)}),t}expandAll(t){this.rowKeyMap.forEach(e=>{e.expand=t}),this.clearBufferData(),this.ctx.emit("draw")}expandLoading(t,e=!1){const i=this.rowKeyMap.get(t);i.expandLoading=e,this.clearBufferData(),this.ctx.emit("draw")}setExpandChildren(t,e){const i=this.rowKeyMap.get(t);i.expand=!0,i.expandLazy=!0,i.item.children=e,this.initData(i.item.children,i.level+1),this.clearBufferData()}getIsExpandLoading(t){return this.rowKeyMap.get(t).expandLoading}getIsExpandLazy(t){return this.rowKeyMap.get(t).expandLazy}getIsExpand(t){return this.rowKeyMap.get(t).expand}getRowForRowKey(t){return this.rowKeyMap.get(t)}getRowKeyForRowIndex(t){return this.rowIndexRowKeyMap.get(t)}getRowKeyByItem(t){return this.itemRowKeyMap.get(t)}getRowIndexForRowKey(t){return this.rowKeyMap.get(t).index}getItemValueForRowIndexAndColIndex(t,e){if(!(this.rowIndexRowKeyMap.has(t)&&this.colIndexKeyMap.get(e)))return null;const s=this.rowIndexRowKeyMap.get(t),r=this.colIndexKeyMap.get(e);return{rowKey:s,key:r,value:this.getItemValue(s,r)}}getItemValue(t,e){const i=this.rowKeyMap.get(t);return i&&i.item?i.item[e]===void 0?null:i.item[e]:null}async batchSetItemValue(t,e=!1){let i=[];const s=new Set;let r=t;const{BEFORE_VALUE_CHANGE_METHOD:o}=this.ctx.config;if(typeof o=="function"){const f=o,d=t.map(u=>({rowKey:u.rowKey,key:u.key,value:u.value,oldValue:this.getItemValue(u.rowKey,u.key),row:this.ctx.database.getRowDataItemForRowKey(u.rowKey)}));r=await f(d)}r.forEach(f=>{const{value:d,rowKey:x,key:u}=f,g=this.getItemValue(x,u);this.setItemValue(x,u,d),s.add(x),i.push({rowKey:x,key:u,oldValue:g,newValue:d})});let a=[];const l=i.map(f=>{const d=this.ctx.database.getRowDataItemForRowKey(f.rowKey);return{rowKey:f.rowKey,key:f.key,value:f.newValue,row:d}});s.forEach(f=>{a.push(this.ctx.database.getRowDataItemForRowKey(f))});const c=l.map(({rowKey:f,key:d})=>this.getValidator(f,d));Promise.all(c).then(()=>{this.validationErrorMap.size===0&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData())}),this.ctx.emit("change",l,a),e&&this.ctx.history.pushState({changeList:i,scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,type:"multiple"}),this.ctx.emit("draw")}async setItemValue(t,e,i,s=!1,r=!1,o=!1){if(!this.rowKeyMap.has(t))return{};const{item:a}=this.rowKeyMap.get(t);let l=a[e];if(this.ctx.database.getReadonly(t,e))return{oldValue:l,newValue:l};a[e]!==null&&typeof a[e]=="object"&&(l=JSON.parse(JSON.stringify(a[e])));const c=`${t}​_${e}`;this.originalDataMap.has(c)||this.originalDataMap.set(c,l);const f=this.originalDataMap.get(c);let d=i;if(o){const{BEFORE_VALUE_CHANGE_METHOD:x}=this.ctx.config;if(typeof x=="function"){const p=await x([{rowKey:t,key:e,value:i,oldValue:a[e],row:this.ctx.database.getRowDataItemForRowKey(t)}]);p&&p.length&&(d=p[0].value)}this.changedDataMap.set(c,d),a[e]=d;const u=this.ctx.database.getRowDataItemForRowKey(t),g={rowKey:t,key:e,value:d,row:u};this.getValidator(t,e).then(()=>{this.validationErrorMap.size===0&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData())}),this.ctx.emit("change",[g],[u]),this.ctx.emit("editChange",{rowKey:t,key:e,oldValue:l,value:d,originalValue:f,row:u})}else this.changedDataMap.set(c,d),a[e]=d;return this.ctx.hasEvent("iterationChange")&&this.ctx.emit("iterationChange",{rowKey:t,key:e,oldValue:l,value:d,originalValue:this.originalDataMap.get(c),row:this.ctx.database.getRowDataItemForRowKey(t)}),s&&this.ctx.history.pushState({type:"single",scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,changeList:[{rowKey:t,key:e,oldValue:l,newValue:d}]}),r&&this.ctx.emit("draw"),{oldValue:l,newValue:d}}getRowDataItemForRowKey(t){if(!this.rowKeyMap.has(t))return{};const{item:e}=this.rowKeyMap.get(t);return e}setRowSelectionByCheckboxKey(t,e){const{CHECKBOX_KEY:i}=this.ctx.config;if(i){if(!this.rowKeyMap.has(t))return!1;const{item:s}=this.rowKeyMap.get(t),r=s[i];this.checkboxKeyMap.has(r)&&this.checkboxKeyMap.get(r).forEach(a=>{const l=this.rowKeyMap.get(a);l.check=e})}}toggleRowSelection(t){const e=this.rowKeyMap.get(t);e.check=!e.check,this.setRowSelectionByCheckboxKey(t,e.check),this.ctx.emit("toggleRowSelection",e);const i=this.getSelectionRows();this.ctx.emit("selectionChange",i),this.ctx.emit("draw")}setRowSelection(t,e){const i=this.rowKeyMap.get(t);i.check=e,this.setRowSelectionByCheckboxKey(t,i.check);const s=this.getSelectionRows();this.ctx.emit("setRowSelection",s),this.ctx.emit("draw")}getSelectionRows(){let t=[];return this.rowKeyMap.forEach(e=>{e.check&&t.push(e.item)}),t}getRowSelection(t){const{check:e}=this.rowKeyMap.get(t);return e}getRowSelectable(t){const{selectable:e,item:i,rowIndex:s}=this.rowKeyMap.get(t);return typeof e=="function"?e({row:i,rowIndex:s}):e}toggleAllSelection(){this.rowKeyMap.forEach(e=>{const i=e.selectable;typeof i=="function"?i({row:e.item,rowIndex:e.rowIndex})&&(e.check=!0):i&&(e.check=!0)});const t=this.getSelectionRows();this.ctx.emit("toggleAllSelection",t),this.ctx.emit("selectionChange",t),this.ctx.emit("draw")}clearSelection(){this.rowKeyMap.forEach(e=>{const i=e.selectable;typeof i=="function"?i({row:e.item,rowIndex:e.rowIndex})&&(e.check=!1):i&&(e.check=!1)});const t=this.getSelectionRows();this.ctx.emit("clearSelection"),this.ctx.emit("selectionChange",t),this.ctx.emit("draw")}getCheckedState(){let t=0,e=0;this.rowKeyMap.forEach(o=>{o.check&&(t+=1);const a=o.selectable;typeof a=="function"?a({row:o.item,rowIndex:o.rowIndex})&&(e+=1):a&&(e+=1)});const i=e&&e>t&&t>0;return{check:e&&e===t,indeterminate:i,selectable:e!==0}}updateColIndexKeyMap(t=[]){this.colIndexKeyMap.clear(),t.forEach(e=>{this.colIndexKeyMap.set(e.colIndex,e.key)})}getChangedData(){let t=[];return this.changedDataMap.forEach((e,i)=>{const s=this.originalDataMap.get(i),r=i.split("​_")[0],o=i.split("​_")[1];s!==e&&t.push({rowKey:r,colKey:o,originalValue:s,row:this.ctx.database.getRowDataItemForRowKey(r),value:e})}),t}getChangedRows(){const t=new Set;this.changedDataMap.forEach((i,s)=>{const r=this.originalDataMap.get(s),o=s.split("​_")[0];r!==i&&t.add(o)});let e=[];return t.forEach(i=>{e.push(this.ctx.database.getRowDataItemForRowKey(i))}),e}isHasChangedData(t,e){const i=`${t}​_${e}`;if(!this.changedDataMap.has(i))return!1;const s=this.originalDataMap.get(i),r=this.changedDataMap.get(i);return s!==r}getPositionForRowIndex(t){return t<this.positions.length?this.positions[t]:{height:0,top:0,bottom:0}}setHeader(t,e){return t?(this.headerMap.set(t,e),!0):!1}getReadonly(t,e){const i=this.rowKeyMap.get(t),s=this.headerMap.get(e),r=i==null?void 0:i.readonly,o=s==null?void 0:s.readonly,{BODY_CELL_READONLY_METHOD:a}=this.ctx.config;if(typeof a=="function"){const c=a({row:i.item,rowIndex:i.rowIndex,colIndex:s.colIndex,column:s.column,value:this.getItemValue(t,e)});if(c!==void 0)return c}return o||r}clearValidate(){this.validationErrorMap.clear()}hasValidationError(){return this.validationErrorMap.size!==0}getValidator(t,e){return new Promise(i=>{const s=this.rowKeyMap.get(t),r=this.headerMap.get(e),{BODY_CELL_RULES_METHOD:o}=this.ctx.config,a=r.column;let l=a.rules;if(typeof o=="function"){const f=o({row:s.item,rowIndex:s.rowIndex,colIndex:r.colIndex,column:a,value:this.getItemValue(t,e)});f&&(l=f)}if(l){let c={},f={};if(f[e]=this.getItemValue(t,e),Array.isArray(l)&&l.length){const x=l.map(u=>({...u,row:s.item,column:a,rowIndex:s.rowIndex,colIndex:r.colIndex}));c[e]=x}else c[e]={...l,row:s.item,column:a,rowIndex:s.rowIndex,colIndex:r.colIndex};new nt(c).validate(f).then(()=>{this.clearValidationError(t,e),i([])}).catch(({errors:x})=>{const u=x.map(g=>({...g,column:a,key:e,row:s.item,rowKey:t}));this.setValidationError(t,e,u),i(u)})}else i([])})}getHeightByRowIndexRowSpan(t,e){let i=0;for(let s=0;s<e;s++){const r=this.positions[t+s];r&&(i+=r.height)}return i}setLoading(t){this.loading=t,this.ctx.emit("loadingChange",t)}getLoading(){return this.loading}setValidationErrorByRowIndex(t,e,i){const r=`${this.rowIndexRowKeyMap.get(t)}​_${e}`,o=[{message:i}];this.validationErrorMap.set(r,o)}setValidationError(t,e,i){const s=`${t}​_${e}`;this.validationErrorMap.set(s,i)}clearValidationError(t,e){const i=`${t}​_${e}`;this.validationErrorMap.has(i)&&this.validationErrorMap.delete(i)}getValidationError(t,e){const i=`${t}​_${e}`;return this.validationErrorMap.get(i)||[]}}class ti{constructor(t){h(this,"ctx");h(this,"history",[]);h(this,"historyIndex",-1);this.ctx=t,this.init()}init(){this.ctx.on("keydown",t=>{if(t.ctrlKey&&!t.shiftKey&&t.code==="KeyZ"||t.metaKey&&!t.shiftKey&&t.code==="KeyZ"){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.backState();return}if(t.ctrlKey&&t.code==="KeyY"||t.ctrlKey&&t.shiftKey&&t.code==="KeyZ"||t.metaKey&&t.shiftKey&&t.code==="KeyZ"){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.forwardState();return}})}pushState(t){const{HISTORY_NUM:e=0,ENABLE_HISTORY:i}=this.ctx.config;i&&(this.history.push(t),this.history.length>e&&this.history.splice(0,1),this.historyIndex=this.history.length-1)}backState(){if(this.historyIndex>=0){const{changeList:t,scrollX:e,scrollY:i}=this.history[this.historyIndex],s=t.map(r=>({rowKey:r.rowKey,key:r.key,value:r.oldValue,row:{}}));this.ctx.setScroll(e,i),this.ctx.database.batchSetItemValue(s,!1),this.historyIndex-=1}}forwardState(){if(this.historyIndex<this.history.length-1){this.historyIndex+=1;const{changeList:t}=this.history[this.historyIndex],e=t.map(i=>({rowKey:i.rowKey,key:i.key,value:i.newValue,row:{}}));this.ctx.database.batchSetItemValue(e,!1)}}clear(){this.history=[],this.historyIndex=-1}}class ei{constructor(t){h(this,"eventTasks",new Map);h(this,"ctx");this.ctx=t,this.init()}init(){this.bind(window,"resize",this.handleResize.bind(this)),this.bind(window,"mouseup",this.handleMouseUp.bind(this)),this.bind(window,"mousemove",this.handleMousemove.bind(this)),this.bind(this.ctx.stageElement,"click",this.handleClick.bind(this)),this.bind(window,"keydown",this.handleKeydown.bind(this)),this.bind(this.ctx.stageElement,"wheel",this.handleWheel.bind(this)),this.bind(this.ctx.stageElement,"contextmenu",this.handleContextMenu.bind(this)),this.bind(this.ctx.stageElement,"mousedown",this.handleMouseDown.bind(this)),this.bind(this.ctx.stageElement,"mouseenter",this.handleMouseEnter.bind(this)),this.bind(this.ctx.stageElement,"mouseleave",this.handleMouseLeave.bind(this)),this.bind(this.ctx.stageElement,"dblclick",this.handleDblclick.bind(this))}destroy(){this.eventTasks.forEach((t,e)=>{this.unbind(window,e,t)}),this.eventTasks.clear()}handleResize(t){this.ctx.emit("resetHeader",t),this.ctx.emit("resize",t)}handleMouseDown(t){t.button===0&&(this.ctx.mousedown=!0),this.ctx.emit("mousedown",t)}handleMousemove(t){this.ctx.emit("mousemove",t)}handleMouseUp(t){t.button===0&&(this.ctx.mousedown=!1),this.ctx.emit("mouseup",t)}handleClick(t){this.ctx.emit("click",t)}handleKeydown(t){const{ENABLE_KEYBOARD:e}=this.ctx.config;e&&this.ctx.isTarget()&&this.ctx.emit("keydown",t)}handleWheel(t){this.ctx.emit("wheel",t)}handleContextMenu(t){this.ctx.emit("contextMenu",t)}handleMouseEnter(t){this.ctx.isInsideTargetContainer=!0,this.ctx.emit("mouseenter",t)}handleMouseLeave(t){this.ctx.editing||(this.ctx.isInsideTargetContainer=!1,this.ctx.emit("mouseleave",t))}handleDblclick(t){this.ctx.emit("dblclick",t)}bind(t,e,i,s){t.addEventListener(e,i,s),this.eventTasks.set(e,i)}unbind(t,e,i){t.removeEventListener(e,i),this.eventTasks.delete(e)}}class ii{constructor(){h(this,"events",new Map)}has(t){return this.events.has(t)}on(t,e){const i=this.events.get(t)||[];i.push(e),this.events.set(t,i)}once(t,e){const i=(...s)=>{e(...s),this.off(t,i)};return this.on(t,i),this}off(t,e){const i=this.events.get(t);if(i){const s=i.indexOf(e);s>=0&&(i.splice(s,1),i.length===0?this.events.delete(t):this.events.set(t,i))}}emit(t,...e){const i=this.events.get(t);i&&i.forEach(s=>{s(...e)})}destroy(){this.events.clear()}}class si{constructor(t){h(this,"ctx");const e=t.getContext("2d");if(!e)throw new Error("canvas context not found");this.ctx=e}scale(t){this.ctx.scale(t,t)}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(t,e){this.ctx.translate(t,e)}setCursor(t="default"){this.ctx.canvas.style.cursor=t}clear(t=0,e=0,i,s){this.ctx.clearRect(t,e,i||this.ctx.canvas.width,s||this.ctx.canvas.height)}drawShadow(t,e,i,s,r){const{fillColor:o,side:a,shadowWidth:l,colorStart:c,colorEnd:f}=r;this.ctx.save(),o&&(this.ctx.fillStyle=o,this.ctx.fillRect(t,e,i,s));let d;switch(a){case"left":d=this.ctx.createLinearGradient(t-l,e,t,e),d.addColorStop(0,c),d.addColorStop(1,f),this.ctx.fillStyle=d,this.ctx.fillRect(t-l,e,l,s);break;case"right":d=this.ctx.createLinearGradient(t+i,e,t+i+l,e),d.addColorStop(0,c),d.addColorStop(1,f),this.ctx.fillStyle=d,this.ctx.fillRect(t+i,e,l,s);break;case"top":d=this.ctx.createLinearGradient(t,e-l,t,e),d.addColorStop(0,c),d.addColorStop(1,f),this.ctx.fillStyle=d,this.ctx.fillRect(t,e-l,i,l);break;case"bottom":d=this.ctx.createLinearGradient(t,e+s,t,e+s+l),d.addColorStop(0,c),d.addColorStop(1,f),this.ctx.fillStyle=d,this.ctx.fillRect(t,e+s,i,l);break;default:console.error("Invalid side specified for shadow");break}}drawLine(t,e){if(t.length<4||t.length%2!==0)throw new Error("A valid array of points is required to draw a line");this.ctx.save();const{borderColor:i="black",borderWidth:s=1}=e;this.ctx.beginPath(),this.ctx.moveTo(t[0]-.5,t[1]-.5);for(let r=2;r<t.length;r+=2)this.ctx.lineTo(t[r]-.5,t[r+1]-.5);this.ctx.strokeStyle=i,this.ctx.lineWidth=s,e.lineDash&&(this.ctx.lineDashOffset=4,this.ctx.setLineDash(e.lineDash)),e.fillColor&&(this.ctx.fillStyle=e.fillColor,this.ctx.fill()),e.borderColor&&(this.ctx.strokeStyle=e.borderColor),this.ctx.stroke(),this.ctx.closePath(),this.ctx.restore()}drawImage(t,e,i,s,r){this.ctx.save(),this.ctx.drawImage(t,e,i,s,r),this.ctx.restore()}drawRect(t,e,i,s,{borderWidth:r=1,borderColor:o,fillColor:a,radius:l=0}={}){if(this.ctx.save(),this.ctx.beginPath(),a!==void 0&&(this.ctx.fillStyle=a),o!==void 0&&(this.ctx.lineWidth=r,this.ctx.strokeStyle=o),l===0)this.ctx.rect(t-.5,e-.5,i,s);else{const[c,f,d,x]=typeof l=="number"?[l,l,l,l]:l;this.ctx.moveTo(t+c,e),this.ctx.arcTo(t+i,e,t+i,e+f,f),this.ctx.arcTo(t+i,e+s,t+i-d,e+s,d),this.ctx.arcTo(t,e+s,t,e+s-x,x),this.ctx.arcTo(t,e,t+c,e,c)}a!==void 0&&this.ctx.fill(),o!==void 0&&this.ctx.stroke(),this.ctx.restore()}drawText(t="",e,i,s,r,o={}){this.ctx.save();const{font:a="12px Arial",align:l="center",color:c="#495060",padding:f=0,verticalAlign:d="middle"}=o;this.ctx.font=a,this.ctx.fillStyle=c,this.ctx.textBaseline=d,this.ctx.textAlign=l;let x=0;d==="top"?x=i+f:d==="bottom"?x=i+r-f:x=i+(r+1)/2;let u=0;l==="left"?u=e+f:l==="right"?u=e+s-f:u=e+s/2;const{_text:g,ellipsis:w}=this.handleEllipsis(t,s,f,a);return this.ctx.fillText(g,u,x),this.ctx.restore(),w}handleEllipsis(t,e,i=0,s="12px Arial"){let r=!1,o=t;if(this.ctx.font=s,t==null||t==="")return{_text:"",ellipsis:r};const a=this.ctx.measureText("...").width,l=this.ctx.measureText(t).width;if(l&&l+a>=e-i*2){r=!0;let c=0;for(let f=0;f<t.length;f++)if(c+=this.ctx.measureText(t[f]).width,c>=e-i*2-a){o=t.slice(0,f)+"...";break}}return{_text:o,ellipsis:r}}}class jt{constructor(t){h(this,"PROCESSOR_NUM",50);h(this,"CSS_PREFIX","e-virt-table");h(this,"ICONS",[]);h(this,"ROW_KEY","");h(this,"HEADER_FONT","12px normal Arial");h(this,"BODY_FONT","12px normal Arial");h(this,"BORDER_COLOR","#e1e6eb");h(this,"WIDTH",0);h(this,"RESIZE_MIN_WIDTH",40);h(this,"HEIGHT",0);h(this,"EMPTY_BODY_HEIGHT",120);h(this,"EMPTY_CUSTOM",!1);h(this,"EMPTY_CUSTOM_STYLE",{});h(this,"EMPTY_TEXT","暂无数据");h(this,"MAX_HEIGHT",1e3);h(this,"BORDER_RADIUS",8);h(this,"ENABLE_OFFSET_HEIGHT",!1);h(this,"OFFSET_HEIGHT",0);h(this,"HEADER_HEIGHT",36);h(this,"ENABLE_HEADER_STICKY",!1);h(this,"HEADER_BG_COLOR","#F8FAFF");h(this,"BODY_BG_COLOR","#FFF");h(this,"HEADER_TEXT_COLOR","#1D2129");h(this,"LOADING_ICON_SVG","");h(this,"LOADING_ICON_COLOR","#4E5969");h(this,"EXPAND_ICON_SVG","");h(this,"SHRINK_ICON_SVG","");h(this,"EXPAND_ICON_COLOR","#4E5969");h(this,"SHRINK_ICON_COLOR","#4E5969");h(this,"ERROR_TIP_ICON_COLOR","red");h(this,"ERROR_TIP_ICON_SIZE",6);h(this,"EXPAND_LAZY",!0);h(this,"DEFAULT_EXPAND_ALL",!1);h(this,"CELL_WIDTH",100);h(this,"CELL_HEIGHT",36);h(this,"CELL_PADDING",8);h(this,"CELL_HOVER_ICON_SIZE",20);h(this,"SCROLLER_TRACK_SIZE",14);h(this,"SCROLLER_SIZE",8);h(this,"SCROLLER_COLOR","#dee0e3");h(this,"SCROLLER_TRACK_COLOR","#fff");h(this,"SCROLLER_FOCUS_COLOR","#bbbec4");h(this,"SELECT_BORDER_COLOR","rgb(82,146,247)");h(this,"SELECT_AREA_COLOR","rgba(82,146,247,0.1)");h(this,"SELECT_BG_COLOR","rgba(82,146,247,0.1)");h(this,"EDIT_BG_COLOR","#fcf6ed");h(this,"CHECKBOX_KEY","");h(this,"CHECKBOX_COLOR","rgb(82,146,247)");h(this,"CHECKBOX_SIZE",20);h(this,"CHECKBOX_DISABLED_SVG","");h(this,"CHECKBOX_CHECK_SVG","");h(this,"CHECKBOX_UNCHECK_SVG","");h(this,"CHECKBOX_INDETERMINATE_SVG","");h(this,"READONLY_COLOR","#fff");h(this,"READONLY_TEXT_COLOR","#4E5969");h(this,"ERROR_TIP_COLOR","#ED3F14");h(this,"FOOTER_BG_COLOR","#fafafa");h(this,"FOOTER_FIXED",!0);h(this,"CELL_FOOTER_HEIGHT",36);h(this,"ENABLE_SELECTOR",!1);h(this,"ENABLE_EDIT_SINGLE_CLICK",!1);h(this,"ENABLE_EDIT_CLICK_SELECTOR",!0);h(this,"SELECTOR_AREA_MIN_X",0);h(this,"SELECTOR_AREA_MAX_X_OFFSET",0);h(this,"SELECTOR_AREA_MAX_X",0);h(this,"SELECTOR_AREA_MIN_Y",0);h(this,"SELECTOR_AREA_MAX_Y",0);h(this,"SELECTOR_AREA_MAX_Y_OFFSET",0);h(this,"ENABLE_SELECTOR_SINGLE",!1);h(this,"ENABLE_SELECTOR_SPAN_COL",!0);h(this,"ENABLE_SELECTOR_SPAN_ROW",!0);h(this,"ENABLE_SELECTOR_ALL_ROWS",!0);h(this,"ENABLE_SELECTOR_ALL_COLS",!0);h(this,"ENABLE_AUTOFILL",!1);h(this,"ENABLE_CONTEXT_MENU",!1);h(this,"ENABLE_COPY",!0);h(this,"ENABLE_PASTER",!0);h(this,"ENABLE_RESIZE_ROW",!0);h(this,"ENABLE_RESIZE_COLUMN",!0);h(this,"RESIZE_ROW_LINE_COLOR","#e1e6eb");h(this,"RESIZE_COLUMN_LINE_COLOR","#e1e6eb");h(this,"RESIZE_ROW_MIN_HEIGHT",36);h(this,"RESIZE_COLUMN_MIN_WIDTH",40);h(this,"ENABLE_KEYBOARD",!0);h(this,"ENABLE_HISTORY",!1);h(this,"ENABLE_VALIDATOR_IMMEDIATE",!0);h(this,"HISTORY_NUM",50);h(this,"HIGHLIGHT_HOVER_ROW",!1);h(this,"HIGHLIGHT_HOVER_ROW_COLOR","rgba(186,203,231,0.1)");h(this,"HIGHLIGHT_SELECTED_ROW",!1);h(this,"HIGHLIGHT_SELECTED_ROW_COLOR","rgba(82,146,247,0.1)");h(this,"TOOLTIP_BG_COLOR","#303133");h(this,"TOOLTIP_TEXT_COLOR","#fff");h(this,"TOOLTIP_ZINDEX",3e3);h(this,"TOOLTIP_CUSTOM_STYLE",{});h(this,"CONTEXT_MENU",[{label:"复制",value:"copy"},{label:"剪切",value:"cut"},{label:"粘贴",value:"paste"},{label:"清空选中内容",value:"clearSelected"}]);h(this,"HEADER_CELL_STYLE_METHOD");h(this,"BODY_CELL_STYLE_METHOD");h(this,"FOOTER_CELL_STYLE_METHOD");h(this,"BODY_CELL_READONLY_METHOD");h(this,"BODY_CELL_FORMATTER_METHOD");h(this,"BODY_CELL_RULES_METHOD");h(this,"BODY_CELL_TYPE_METHOD");h(this,"BODY_CELL_EDITOR_TYPE_METHOD");h(this,"BODY_CELL_RENDER_METHOD");h(this,"BODY_CELL_HOVER_ICON_METHOD");h(this,"SPAN_METHOD");h(this,"SELECTABLE_METHOD");h(this,"EXPAND_LAZY_METHOD");h(this,"BEFORE_VALUE_CHANGE_METHOD");h(this,"BEFORE_PASTE_CHANGE_METHOD");h(this,"BEFORE_AUTOFILL_CHANGE_METHOD");Object.assign(this,t)}init(t){Object.assign(this,t)}}class ri{constructor(t){h(this,"ctx");h(this,"list",[{name:"loading",configName:"LOADING_ICON_SVG",configColorName:"LOADING_ICON_COLOR",svg:'<svg t="1724133395728" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2893" width="32" height="32"><path d="M512 226.8476541a19.82487759 19.82487759 0 0 1 14.66497778 5.70304692c3.80203107 3.82918865 5.70304692 8.71751457 5.70304693 14.66497779v122.20814825a19.82487759 19.82487759 0 0 1-5.70304693 14.66497778 19.82487759 19.82487759 0 0 1-14.66497778 5.70304691 19.82487759 19.82487759 0 0 1-14.66497778-5.70304691 19.82487759 19.82487759 0 0 1-5.70304693-14.66497778v-122.20814825a19.82487759 19.82487759 0 0 1 5.70304693-14.66497779 19.82487759 19.82487759 0 0 1 14.66497778-5.70304692z m0 407.36049415a19.82487759 19.82487759 0 0 1 14.66497778 5.70304691c3.80203107 3.82918865 5.70304692 8.71751457 5.70304693 14.66497778v122.20814827a19.82487759 19.82487759 0 0 1-5.70304693 14.66497776 19.82487759 19.82487759 0 0 1-14.66497778 5.70304693 19.82487759 19.82487759 0 0 1-14.66497778-5.70304693 19.82487759 19.82487759 0 0 1-5.70304693-14.66497776v-122.20814827a19.82487759 19.82487759 0 0 1 5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 14.66497778-5.70304691zM797.1523459 512a19.82487759 19.82487759 0 0 1-5.70304692 14.66497778 19.82487759 19.82487759 0 0 1-14.66497779 5.70304693h-122.20814825a19.82487759 19.82487759 0 0 1-14.66497778-5.70304693 19.82487759 19.82487759 0 0 1-5.70304691-14.66497778 19.82487759 19.82487759 0 0 1 5.70304691-14.66497778 19.82487759 19.82487759 0 0 1 14.66497778-5.70304693h122.20814825a19.82487759 19.82487759 0 0 1 14.66497779 5.70304693c3.80203107 3.82918865 5.70304692 8.71751457 5.70304692 14.66497778z m-407.36049415 0a19.82487759 19.82487759 0 0 1-5.70304691 14.66497778 19.82487759 19.82487759 0 0 1-14.66497778 5.70304693h-122.20814827a19.82487759 19.82487759 0 0 1-14.66497776-5.70304693 19.82487759 19.82487759 0 0 1-5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 14.66497776-5.70304693h122.20814827a19.82487759 19.82487759 0 0 1 14.66497778 5.70304693c3.80203107 3.82918865 5.70304692 8.71751457 5.70304691 14.66497778zM310.22076878 310.22076878a21.29137537 21.29137537 0 0 1 14.66497779-5.70304693c5.51294514 0 10.18401235 1.90101585 14.01320099 5.70304693l86.55052591 86.57768347a20.91117183 20.91117183 0 0 1 5.73020449 14.31193182 19.28172983 19.28172983 0 0 1-6.05609289 14.013201 19.11878565 19.11878565 0 0 1-14.013201 6.05609289 20.96548698 20.96548698 0 0 1-14.31193182-5.70304692L310.22076878 338.87178998a19.06447114 19.06447114 0 0 1-5.70304693-14.01320099c0-5.54010272 1.90101585-10.42842865 5.70304693-14.66497778z m288.32975775 288.32975775a19.79772001 19.79772001 0 0 1 14.3390894-6.35482371c5.29568642 0 10.04822572 2.11827457 14.31193182 6.38198066l86.57768347 86.55052651c3.80203107 3.80203107 5.70304692 8.47309828 5.70304691 14.01320102a19.55330372 19.55330372 0 0 1-6.05609225 14.31193182 19.66193339 19.66193339 0 0 1-14.31193245 6.05609288 19.01015661 19.01015661 0 0 1-14.01320099-5.70304692l-86.55052591-86.57768347a19.79772001 19.79772001 0 0 1-6.38198129-14.31193245c0-5.29568642 2.11827457-10.07538268 6.38198129-14.33908939zM713.77923122 310.22076878c3.80203107 4.26370672 5.70304692 9.15203265 5.70304693 14.66497779s-1.90101585 10.18401235-5.70304693 14.01320099l-86.57768347 86.55052591a20.91117183 20.91117183 0 0 1-14.31193182 5.73020449 19.28172983 19.28172983 0 0 1-14.013201-6.05609289 19.11878565 19.11878565 0 0 1-6.05609289-14.013201c0-5.29568642 1.90101585-10.07538268 5.70304692-14.31193182l86.57768348-86.57768347c3.80203107-3.80203107 8.50025585-5.70304692 14.01320099-5.70304693 5.54010272 0 10.40127108 1.90101585 14.66497779 5.70304693zM425.44947347 598.57768347a19.79772001 19.79772001 0 0 1 6.35482371 14.33908939c0 5.29568642-2.11827457 10.04822572-6.38198066 14.31193245L338.89894756 713.77923122a19.06447114 19.06447114 0 0 1-14.01320099 5.70304693 19.55330372 19.55330372 0 0 1-14.31193245-6.05609227 19.68909035 19.68909035 0 0 1-6.05609227-14.31193245 19.01015661 19.01015661 0 0 1 5.70304693-14.01320099l86.57768347-86.55052591a19.79772001 19.79772001 0 0 1 14.31193182-6.38198129c5.29568642 0 10.07538268 2.11827457 14.3390894 6.38198129z" fill="#000000" fill-opacity=".65" p-id="2894"></path></svg>',color:"#4E5969"},{name:"expand",configName:"EXPAND_ICON_SVG",configColorName:"EXPAND_ICON_COLOR",svg:'<svg t="1724122015492" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4237" width="32" height="32"><path d="M401.472 316.992l159.04 217.664L591.488 512l-30.976-22.656-159.04 217.728q-2.24 3.008-3.84 6.464-1.6 3.456-2.496 7.104-0.896 3.648-1.024 7.424-0.192 3.84 0.384 7.552 0.64 3.712 1.92 7.296 1.28 3.52 3.2 6.784 1.984 3.2 4.544 6.016 2.56 2.752 5.632 4.992 3.072 2.24 6.464 3.84 3.456 1.6 7.168 2.496 3.648 0.896 7.424 1.024 3.776 0.192 7.488-0.448 3.776-0.576 7.296-1.856 3.584-1.28 6.784-3.264 3.2-1.92 6.016-4.48 2.816-2.56 5.056-5.632l159.04-217.728q3.584-4.928 5.504-10.752 1.92-5.76 1.92-11.904 0-6.08-1.92-11.904-1.92-5.76-5.504-10.752L463.488 271.68q-2.24-3.072-5.056-5.632-2.752-2.56-6.016-4.48-3.2-1.984-6.784-3.328-3.52-1.28-7.296-1.856-3.712-0.576-7.488-0.448-3.84 0.192-7.424 1.088-3.712 0.896-7.168 2.496-3.392 1.6-6.4 3.84-3.136 2.176-5.696 4.992-2.56 2.752-4.48 6.016-1.984 3.2-3.264 6.784-1.28 3.52-1.92 7.296-0.576 3.712-0.384 7.488 0.128 3.84 1.024 7.488 0.896 3.648 2.496 7.04 1.6 3.456 3.84 6.528z m30.976-61.056q-3.776 0-7.488 0.704-3.712 0.768-7.168 2.24-3.52 1.408-6.656 3.52-3.2 2.112-5.824 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.52 6.656-1.472 3.52-2.176 7.232-0.768 3.712-0.768 7.488 0 3.776 0.768 7.488 0.704 3.712 2.176 7.232 1.408 3.456 3.52 6.592 2.112 3.2 4.8 5.824 2.688 2.688 5.76 4.8 3.2 2.112 6.72 3.52 3.456 1.472 7.168 2.176 3.712 0.768 7.488 0.768 3.84 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.408 6.592-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.112-3.2 3.52-6.656 1.472-3.52 2.24-7.232 0.704-3.712 0.704-7.488 0-3.84-0.704-7.488-0.768-3.712-2.24-7.232-1.408-3.456-3.52-6.592-2.112-3.2-4.8-5.824-2.624-2.688-5.76-4.8-3.2-2.112-6.656-3.52-3.52-1.472-7.232-2.24Q436.224 256 432.448 256z m0 435.392q-3.776 0-7.488 0.704-3.712 0.768-7.168 2.176-3.52 1.472-6.656 3.584-3.2 2.112-5.824 4.736-2.688 2.688-4.8 5.824-2.112 3.2-3.52 6.656-1.472 3.52-2.176 7.232-0.768 3.712-0.768 7.488 0 3.776 0.768 7.488 0.704 3.712 2.176 7.168 1.408 3.52 3.52 6.656 2.112 3.2 4.8 5.76 2.688 2.752 5.76 4.8 3.2 2.112 6.72 3.584 3.456 1.472 7.168 2.176 3.712 0.768 7.488 0.768 3.84 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.472 6.592-3.584 3.2-2.048 5.824-4.736 2.688-2.688 4.8-5.824 2.112-3.2 3.52-6.656 1.472-3.456 2.24-7.168 0.704-3.712 0.704-7.488 0-3.84-0.704-7.488-0.768-3.712-2.24-7.232-1.408-3.52-3.52-6.656-2.112-3.136-4.8-5.76-2.624-2.688-5.76-4.8-3.2-2.112-6.656-3.584-3.52-1.408-7.232-2.176-3.712-0.704-7.488-0.704z" p-id="4238"></path></svg>',color:"#4E5969"},{name:"shrink",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"SHRINK_ICON_COLOR",svg:'<svg t="1724122044148" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M707.648 401.28L489.28 560.704l22.656 30.976 22.656-30.976L316.16 401.216q-3.072-2.24-6.464-3.84-3.456-1.536-7.104-2.432-3.712-0.896-7.488-1.088-3.776-0.128-7.488 0.448-3.776 0.64-7.296 1.92-3.584 1.28-6.784 3.2-3.2 1.984-6.016 4.544-2.816 2.56-5.056 5.632-2.176 3.072-3.84 6.464-1.536 3.456-2.432 7.104-0.896 3.712-1.088 7.488-0.128 3.776 0.448 7.488 0.64 3.776 1.92 7.296 1.28 3.584 3.2 6.784 1.984 3.2 4.544 6.016 2.56 2.752 5.632 4.992l218.368 159.552q4.928 3.584 10.752 5.504 5.76 1.92 11.904 1.92 6.08 0 11.904-1.92 5.76-1.92 10.752-5.504l218.368-159.552q3.008-2.24 5.568-4.992 2.56-2.816 4.544-6.016 1.92-3.2 3.264-6.784 1.28-3.52 1.92-7.296 0.576-3.712 0.384-7.488-0.128-3.84-1.024-7.488-0.896-3.648-2.496-7.04-1.6-3.456-3.84-6.528-2.24-3.072-4.992-5.632-2.816-2.56-6.016-4.48-3.2-1.984-6.784-3.328-3.584-1.28-7.296-1.856-3.712-0.64-7.488-0.448-3.84 0.192-7.488 1.088-3.648 0.896-7.04 2.496-3.456 1.536-6.528 3.84z m61.056 30.976q0-3.84-0.768-7.488-0.704-3.712-2.176-7.232-1.472-3.456-3.52-6.656-2.112-3.136-4.8-5.76-2.688-2.688-5.76-4.8-3.2-2.112-6.72-3.584-3.456-1.408-7.168-2.176-3.712-0.704-7.488-0.704-3.84 0-7.488 0.704-3.712 0.768-7.232 2.176-3.456 1.472-6.656 3.584-3.136 2.112-5.76 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.584 6.656-1.408 3.52-2.176 7.232-0.704 3.712-0.704 7.488 0 3.776 0.704 7.488 0.768 3.712 2.176 7.168 1.472 3.52 3.584 6.656 2.112 3.2 4.8 5.824 2.624 2.688 5.76 4.8 3.2 2.112 6.656 3.52 3.52 1.472 7.232 2.176 3.712 0.768 7.488 0.768 3.776 0 7.488-0.768 3.712-0.704 7.168-2.176 3.52-1.408 6.656-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.048-3.2 3.52-6.72 1.472-3.456 2.176-7.168 0.768-3.712 0.768-7.488z m-436.736 0q0-3.84-0.768-7.488-0.704-3.712-2.176-7.232-1.408-3.456-3.52-6.656-2.112-3.136-4.8-5.76-2.688-2.688-5.76-4.8-3.2-2.112-6.656-3.584-3.52-1.408-7.232-2.176-3.712-0.704-7.488-0.704-3.84 0-7.488 0.704-3.712 0.768-7.232 2.176-3.456 1.472-6.592 3.584-3.2 2.112-5.824 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.52 6.656-1.472 3.52-2.24 7.232-0.704 3.712-0.704 7.488 0 3.776 0.704 7.488 0.768 3.712 2.24 7.168 1.408 3.52 3.52 6.656 2.112 3.2 4.8 5.824 2.624 2.688 5.76 4.8 3.2 2.112 6.656 3.52 3.52 1.472 7.232 2.176 3.712 0.768 7.488 0.768 3.776 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.408 6.592-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.112-3.2 3.52-6.72 1.472-3.456 2.176-7.168 0.768-3.712 0.768-7.488z" p-id="4552"></path></svg>',color:"#4E5969"},{name:"checkbox-uncheck",configName:"CHECKBOX_UNCHECK_SVG",svg:'<svg t="1722595639920" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4708" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4709"></path></svg>',color:""},{name:"checkbox-check",configName:"CHECKBOX_CHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595535853" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M640 128H384c-170.496 0-256 85.504-256 256v256c0 170.496 85.504 256 256 256h256c170.496 0 256-85.504 256-256V384c0-170.496-85.504-256-256-256z m67.584 302.592c-2.048 4.608-4.608 8.704-8.192 12.288L506.88 634.88c-3.584 3.584-7.68 6.144-12.288 8.192-4.608 2.048-9.728 3.072-14.848 3.072s-10.24-1.024-14.848-3.072c-4.608-2.048-8.704-4.608-12.288-8.192l-96.256-96.256c-3.584-3.584-6.144-7.68-8.192-12.288-2.048-4.608-3.072-9.728-3.072-14.848 0-2.56 0-5.12 1.024-7.68 0.512-2.56 1.024-5.12 2.048-7.168 1.024-2.56 2.048-4.608 3.584-6.656 1.536-2.048 3.072-4.096 4.608-5.632 1.536-2.048 3.584-3.584 5.632-4.608 2.048-1.536 4.096-2.56 6.656-3.584 2.56-1.024 4.608-1.536 7.168-2.048 2.56-0.512 5.12-0.512 7.68-0.512 5.12 0 10.24 1.024 14.848 3.072 4.608 2.048 8.704 4.608 12.288 8.192l69.12 68.608L645.12 389.12c3.584-3.584 7.68-6.144 12.288-8.192 4.608-2.048 9.728-3.072 14.848-3.072 2.56 0 5.12 0 7.68 0.512s5.12 1.024 7.168 2.048c2.56 1.024 4.608 2.048 6.656 3.584 2.048 1.536 4.096 3.072 5.632 4.608 1.536 1.536 3.584 3.584 4.608 5.632 1.536 2.048 2.56 4.096 3.584 6.656 1.024 2.56 1.536 4.608 2.048 7.168 0.512 2.56 1.024 5.12 1.024 7.68 0 5.12-1.024 10.24-3.072 14.848z" p-id="4552"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-hover",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595639920" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4708" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4709"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-indeterminate",configName:"CHECKBOX_INDETERMINATE_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595280953" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4394" width="32" height="32"><path d="M128 384v256q0 12.608 1.28 25.088 1.216 12.544 3.648 24.832 2.432 12.352 6.08 24.384t8.448 23.68q4.864 11.584 10.752 22.72 5.952 11.072 12.928 21.504 7.04 10.496 14.976 20.224 8 9.728 16.896 18.56 8.896 8.96 18.56 16.896 9.728 8 20.224 14.976 10.432 7.04 21.504 12.928 11.136 5.888 22.72 10.688 11.648 4.864 23.68 8.512 12.032 3.648 24.32 6.08 12.352 2.432 24.896 3.712Q371.392 896 384 896h256q12.608 0 25.088-1.28 12.544-1.216 24.832-3.648 12.352-2.432 24.384-6.08t23.68-8.512q11.584-4.8 22.72-10.688 11.072-5.952 21.504-12.928 10.496-7.04 20.224-14.976 9.728-8 18.56-16.896 8.96-8.832 16.896-18.56 8-9.728 14.976-20.224 7.04-10.432 12.928-21.504 5.888-11.136 10.688-22.72 4.864-11.648 8.512-23.68 3.648-12.032 6.08-24.32 2.432-12.352 3.712-24.896Q896 652.608 896 640V384q0-12.608-1.28-25.088-1.216-12.544-3.648-24.832-2.432-12.352-6.08-24.384t-8.512-23.68q-4.8-11.584-10.688-22.72-5.952-11.072-12.928-21.504-7.04-10.496-14.976-20.224-8-9.664-16.896-18.56-8.832-8.96-18.56-16.896-9.728-8-20.224-14.976-10.432-7.04-21.504-12.928-11.136-5.888-22.72-10.752-11.648-4.8-23.68-8.448-12.032-3.648-24.32-6.08-12.352-2.432-24.896-3.712Q652.608 128 640 128H384q-12.608 0-25.088 1.28-12.544 1.216-24.832 3.648-12.352 2.432-24.384 6.08t-23.68 8.448q-11.584 4.864-22.72 10.752-11.072 5.952-21.504 12.928-10.496 7.04-20.224 14.976-9.664 8-18.56 16.896-8.96 8.896-16.896 18.56-8 9.728-14.976 20.224-7.04 10.432-12.928 21.504-5.888 11.136-10.752 22.72-4.8 11.648-8.448 23.68-3.648 12.032-6.08 24.32-2.432 12.352-3.712 24.896Q128 371.392 128 384z m566.016 166.336H330.112a38.4 38.4 0 0 1 0-76.8h363.904a38.4 38.4 0 0 1 0 76.8z" p-id="4395"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-check-disabled",configName:"CHECKBOX_CHECK_SVG",svg:'<svg t="1722595535853" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M640 128H384c-170.496 0-256 85.504-256 256v256c0 170.496 85.504 256 256 256h256c170.496 0 256-85.504 256-256V384c0-170.496-85.504-256-256-256z m67.584 302.592c-2.048 4.608-4.608 8.704-8.192 12.288L506.88 634.88c-3.584 3.584-7.68 6.144-12.288 8.192-4.608 2.048-9.728 3.072-14.848 3.072s-10.24-1.024-14.848-3.072c-4.608-2.048-8.704-4.608-12.288-8.192l-96.256-96.256c-3.584-3.584-6.144-7.68-8.192-12.288-2.048-4.608-3.072-9.728-3.072-14.848 0-2.56 0-5.12 1.024-7.68 0.512-2.56 1.024-5.12 2.048-7.168 1.024-2.56 2.048-4.608 3.584-6.656 1.536-2.048 3.072-4.096 4.608-5.632 1.536-2.048 3.584-3.584 5.632-4.608 2.048-1.536 4.096-2.56 6.656-3.584 2.56-1.024 4.608-1.536 7.168-2.048 2.56-0.512 5.12-0.512 7.68-0.512 5.12 0 10.24 1.024 14.848 3.072 4.608 2.048 8.704 4.608 12.288 8.192l69.12 68.608L645.12 389.12c3.584-3.584 7.68-6.144 12.288-8.192 4.608-2.048 9.728-3.072 14.848-3.072 2.56 0 5.12 0 7.68 0.512s5.12 1.024 7.168 2.048c2.56 1.024 4.608 2.048 6.656 3.584 2.048 1.536 4.096 3.072 5.632 4.608 1.536 1.536 3.584 3.584 4.608 5.632 1.536 2.048 2.56 4.096 3.584 6.656 1.024 2.56 1.536 4.608 2.048 7.168 0.512 2.56 1.024 5.12 1.024 7.68 0 5.12-1.024 10.24-3.072 14.848z" p-id="4552"></path></svg>',color:"#DDE0EA"},{name:"checkbox-disabled",configName:"CHECKBOX_DISABLED_SVG",svg:'<svg t="1722595946663" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4865" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z" fill="#F1F2F4" p-id="4866"></path><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4867"></path></svg>',color:""}]);h(this,"icons",new Map);this.ctx=t,this.init()}async init(){const t=[];for(let e=0;e<this.list.length;e++){const i=this.list[e];let s=i.color;if(i.configColorName){const o=this.ctx.config[i.configColorName];o&&(s=o)}const r=this.createImageFromSVG(i.svg,s).then(o=>{this.icons.set(i.name,o)});t.push(r)}for(let e=0;e<this.ctx.config.ICONS.length;e++){const i=this.ctx.config.ICONS[e];let s=i.color;const r=this.createImageFromSVG(i.svg,s).then(o=>{this.icons.set(i.name,o)});t.push(r)}await Promise.all(t),this.ctx.emit("draw")}async createImageFromSVG(t,e){const r=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;e&&r.querySelectorAll("*").forEach(c=>{c.setAttribute("fill",e)});const o=new Image,a=new Blob([new XMLSerializer().serializeToString(r)],{type:"image/svg+xml"}),l=URL.createObjectURL(a);return o.src=l,new Promise((c,f)=>{o.onerror=()=>f(new Error("Failed to load image")),o.onload=()=>{c(o)}})}get(t){return this.icons.get(t)}}class Ut{constructor(t,e,i,s,r,o,a){h(this,"ctx");h(this,"x",0);h(this,"y",0);h(this,"width",0);h(this,"height",0);h(this,"fixed");h(this,"cellType");this.ctx=t,this.x=e,this.y=i,this.width=s,this.height=r,this.fixed=o,this.cellType=a}isHorizontalVisible(){if(this.fixed)return!0;const{stageWidth:t,fixedLeftWidth:e,scrollX:i,fixedRightWidth:s}=this.ctx,r=t;return!(this.x+this.width-e-i<=0||this.x-i>=r-s)}isVerticalVisible(){const{stageHeight:t,scrollY:e}=this.ctx,i=t;return!(this.y+this.height-e<=0||this.y-e>=i)}getDrawX(){if(this.fixed==="left")return this.x;if(this.fixed==="right"){const{stageWidth:t,config:{SCROLLER_TRACK_SIZE:e}}=this.ctx;return t-(this.ctx.header.width-this.x)-e+1}return this.x-this.ctx.scrollX}getDrawY(){return this.cellType==="header"?this.y:this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED?this.y:this.y-this.ctx.scrollY}getLeftFixedX(){return this.x-this.ctx.scrollX}getRightFixedX(){}}class Zt extends Ut{constructor(e,i,s,r,o,a,l,c,f,d="body"){super(e,r,o,a,l,c.fixed,d);h(this,"formatter");h(this,"formatterFooter");h(this,"hoverIconName","");h(this,"operation",!1);h(this,"align");h(this,"verticalAlign");h(this,"fixed");h(this,"type");h(this,"editorType");h(this,"cellType");h(this,"level");h(this,"colspan",1);h(this,"rowspan",1);h(this,"key");h(this,"column");h(this,"rowIndex");h(this,"colIndex");h(this,"rowKey");h(this,"row");h(this,"value");h(this,"render");h(this,"renderFooter");h(this,"style",{});h(this,"rules",{});h(this,"message","");h(this,"text","");h(this,"displayText","");h(this,"visibleWidth",0);h(this,"visibleHeight",0);h(this,"isHasChanged",!1);h(this,"drawX",0);h(this,"drawY",0);h(this,"drawCellBgColor","");h(this,"drawCellSkyBgColor","");h(this,"drawTextColor","");h(this,"drawTextX",0);h(this,"drawTextY",0);h(this,"drawImageX",0);h(this,"drawImageY",0);h(this,"drawImageWidth",0);h(this,"drawImageHeight",0);h(this,"drawImageName","");h(this,"drawImageSource");h(this,"ellipsis",!1);h(this,"rowExpand",!1);h(this,"rowHasChildren",!1);h(this,"overflowTooltipShow",!0);h(this,"overflowTooltipMaxWidth",500);h(this,"overflowTooltipPlacement","top");this.visibleWidth=this.width,this.visibleHeight=this.height,this.colIndex=s,this.rowIndex=i,this.key=c.key,this.type=c.type||"text",this.editorType=c.editorType||"text",this.cellType=d,this.align=c.align||"center",this.verticalAlign=c.verticalAlign||"middle",this.fixed=c.fixed,this.level=c.level,this.operation=c.operation||!1,this.column=c,this.rules=c.rules,this.row=f,this.rowKey=this.cellType==="body"?this.ctx.database.getRowKeyForRowIndex(i):`${this.cellType}_${this.rowIndex}`,this.value=this.getValue(),this.render=c.render,this.overflowTooltipShow=c.overflowTooltipShow!==!1,this.overflowTooltipMaxWidth=c.overflowTooltipMaxWidth||500,this.overflowTooltipPlacement=c.overflowTooltipPlacement||"top",this.renderFooter=c.renderFooter,this.hoverIconName=c.hoverIconName,this.formatter=c.formatter,this.formatterFooter=c.formatterFooter,this.update()}getValidationMessage(){const e=this.ctx.database.getValidationError(this.rowKey,this.key);if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message}return this.message}update(){this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawTextX=this.drawX,this.drawTextY=this.drawY,this.isHasChanged=this.ctx.database.isHasChangedData(this.rowKey,this.key),this.updateSpan(),this.updateStyle(),this.updateType(),this.updateHoverIcon(),this.updateSelection(),this.updateTree(),this.updateEditorType(),this.updateRender(),this.getValidationMessage(),this.updateContainer(),this.text=this.getText(),this.displayText=this.getDisplayText()}updateSpan(){if(this.cellType==="footer")return;const{SPAN_METHOD:e}=this.ctx.config;if(typeof e=="function"){const i=e,{colspan:s=1,rowspan:r=1}=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue(),headIndex:this.ctx.body.headIndex,headPosition:this.ctx.database.getPositionForRowIndex(this.ctx.body.headIndex),visibleRows:this.ctx.body.visibleRows,visibleLeafColumns:this.ctx.header.visibleLeafColumns,rows:this.ctx.body.data})||{};this.colspan=s,this.rowspan=r,this.visibleWidth=this.getWidthByColIndexColSpan(this.colIndex,this.colspan),this.visibleHeight=this.ctx.database.getHeightByRowIndexRowSpan(this.rowIndex,this.rowspan)}}updateType(){const{BODY_CELL_TYPE_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.type=s)}}updateEditorType(){const{BODY_CELL_EDITOR_TYPE_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.editorType=s)}}updateRender(){const{BODY_CELL_RENDER_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.render=s)}}validate(){this.ctx.database.getValidator(this.rowKey,this.key).then(()=>{this.ctx.database.setValidationError(this.rowKey,this.key,[]),this.message=""}).catch(e=>{if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message,this.ctx.database.setValidationError(this.rowKey,this.key,e)}}).finally(()=>{this.ctx.emit("draw")})}updateStyle(){this.style=this.getOverlayerViewsStyle()}updateTree(){const{CELL_PADDING:e=0}=this.ctx.config,{rowKey:i,cellType:s}=this;let r,o=0,a="";if(this.type==="tree"&&s==="body"){const l=this.ctx.database.getRowForRowKey(i),{expand:c=!1,hasChildren:f=!1,expandLoading:d=!1,level:x=0}=l||{};if(this.rowExpand=c,this.rowHasChildren=f,d){const u=this.ctx.icons.get("loading");a="loading",r=u,o=x*8}else if(f){const u=this.ctx.icons.get("expand"),g=this.ctx.icons.get("shrink");r=c?g:u,a=c?"shrink":"expand",o=x*8}else o=x*8;if(r){let u=20,g=20,w=this.drawX+o+e,p=this.drawY+(this.visibleHeight-g)/2;this.ctx.paint.drawImage(r,w,p,u,g),this.drawImageX=w,this.drawImageY=p,this.drawImageWidth=u,this.drawImageHeight=g,this.drawImageName=a,this.drawImageSource=r,this.align="left",this.drawTextX=o+this.drawX+u-.5}}}updateContainer(){const{BODY_BG_COLOR:e,EDIT_BG_COLOR:i,BODY_CELL_STYLE_METHOD:s,FOOTER_CELL_STYLE_METHOD:r,READONLY_TEXT_COLOR:o,FOOTER_BG_COLOR:a,HIGHLIGHT_SELECTED_ROW:l,HIGHLIGHT_SELECTED_ROW_COLOR:c,HIGHLIGHT_HOVER_ROW:f,HIGHLIGHT_HOVER_ROW_COLOR:d}=this.ctx.config;if(this.cellType==="footer"){let y=a,b=o;if(typeof r=="function"){const m=r,{backgroundColor:E,color:C}=m({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};E&&(y=E),C&&(b=C)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=y,this.drawTextColor=b;return}let x="transparent";const u=this.ctx.focusCell,g=this.ctx.hoverCell;f&&(g==null?void 0:g.rowKey)===this.rowKey&&(x=d),l&&(u==null?void 0:u.rowKey)===this.rowKey&&(x=c),this.drawCellSkyBgColor=x;let w=e,p=o;if(["index","index-selection","selection"].includes(this.type)){this.drawCellBgColor=e,this.drawTextColor=o;return}if(this.ctx.database.getReadonly(this.rowKey,this.key)||(w=i,p=o),typeof s=="function"){const y=s,{backgroundColor:b,color:m}=y({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,isHasChanged:this.isHasChanged,value:this.getValue()})||{};b&&(w=b),m&&(p=m)}this.drawCellBgColor=w,this.drawTextColor=p}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:r,cellType:o,type:a,rowIndex:l,rowKey:c}=this;if(!(s===0||r===0)&&o!=="footer"&&["index-selection","selection"].includes(a)){const f=this.ctx.database.getRowSelection(c),d=this.ctx.database.getRowSelectable(c),{CHECKBOX_SIZE:x=0}=this.ctx.config,u=this.drawX+(e-x)/2,g=this.drawY+(i-x)/2;let w=this.ctx.icons.get("checkbox-uncheck"),p="checkbox-uncheck";f&&d?(w=this.ctx.icons.get("checkbox-check"),p="checkbox-check"):f&&d?(w=this.ctx.icons.get("checkbox-check-disabled"),p="checkbox-check-disabled"):!f&&d?(w=this.ctx.icons.get("checkbox-uncheck"),p="checkbox-uncheck"):(w=this.ctx.icons.get("checkbox-disabled"),p="checkbox-disabled"),w&&a=="index-selection"?(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===l||["checkbox-disabled","checkbox-check"].includes(p))&&(this.drawImageX=u,this.drawImageY=g,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=p,this.drawImageSource=w):w&&a==="selection"&&(this.drawImageX=u,this.drawImageY=g,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=p,this.drawImageSource=w)}}updateHoverIcon(){const{BODY_CELL_HOVER_ICON_METHOD:e,CELL_HOVER_ICON_SIZE:i,CELL_PADDING:s}=this.ctx.config;if(typeof e=="function"){const l=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});l!==void 0&&(this.hoverIconName=l)}const r=this.drawX+this.width-i-s,o=this.drawY+(this.height-i)/2;if(this.hoverIconName&&this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===this.rowIndex){const a=this.ctx.icons.get(this.hoverIconName);this.drawImageX=r,this.drawImageY=o,this.drawImageWidth=i,this.drawImageHeight=i,this.drawImageName=this.hoverIconName,this.drawImageSource=a}}getDisplayText(){return this.cellType==="footer"?this.renderFooter||this.text===null||this.text===void 0?"":this.text:this.rowspan===0||this.colspan===0||this.render||this.type==="index-selection"&&(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===this.rowIndex||["checkbox-disabled","checkbox-check"].includes(this.drawImageName))||this.text===null||this.text===void 0?"":`${this.text}`}getText(){if(this.cellType==="footer")return typeof this.formatterFooter=="function"?this.formatterFooter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.row[this.key]}):this.row[this.key];if(typeof this.formatter=="function")return this.formatter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});const{BODY_CELL_FORMATTER_METHOD:e}=this.ctx.config;return typeof e=="function"?e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()}):["index-selection","index"].includes(this.type)?`${this.rowIndex+1}`:(this.value=this.ctx.database.getItemValue(this.rowKey,this.key),this.value)}getValue(){return this.ctx.database.getItemValue(this.rowKey,this.key)}getOverlayerViewsStyle(){let e=`${this.drawX-this.ctx.fixedLeftWidth}px`,i=`${this.drawY-this.ctx.body.y}px`;return this.fixed==="left"?e=`${this.drawX}px`:this.fixed==="right"&&(e=`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`),this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED&&(i=`${this.drawY-this.ctx.footer.y}px`),{position:"absolute",overflow:"hidden",left:e,top:i,width:`${this.visibleWidth}px`,height:`${this.visibleHeight}px`,pointerEvents:"initial",userSelect:"none"}}draw(){const{paint:e,config:{BORDER_COLOR:i}}=this.ctx,{drawX:s,drawY:r}=this;e.drawRect(s,r,this.visibleWidth,this.visibleHeight,{borderColor:i,fillColor:this.drawCellBgColor}),e.drawRect(s,r,this.width,this.height,{borderColor:"transparent",borderWidth:1,fillColor:this.drawCellSkyBgColor}),this.drawText(),this.drawImage(),this.drawSelector(),this.drawAutofillPiont(),this.drawErrorTip()}getWidthByColIndexColSpan(e,i){if(i===0)return 0;let s=0;for(let r=e;r<e+i;r++){const o=this.ctx.header.leafCellHeaders[r];s+=o.width}return s}drawText(){const{CELL_PADDING:e,BODY_FONT:i}=this.ctx.config,{ellipsis:s}=this.ctx.paint.handleEllipsis(this.text,this.width,e,i);return this.ellipsis=s,this.ctx.paint.drawText(this.displayText,this.drawTextX,this.drawTextY,this.visibleWidth,this.visibleHeight,{font:i,padding:e,align:this.align,verticalAlign:this.verticalAlign,color:this.drawTextColor})}drawImage(){this.drawImageSource&&this.ctx.paint.drawImage(this.drawImageSource,this.drawImageX,this.drawImageY,this.drawImageWidth,this.drawImageHeight)}drawAutofillPiont(){if(this.cellType==="footer")return;const{SELECT_BORDER_COLOR:e,ENABLE_AUTOFILL:i,ENABLE_SELECTOR:s}=this.ctx.config;if(!s||!i)return;const{xArr:r,yArr:o}=this.ctx.selector,a=r[1],l=o[1],{colIndex:c,rowIndex:f,drawX:d,drawY:x}=this;c===a&&f===l&&this.ctx.paint.drawRect(d+this.width-6,x+this.height-6,6,6,{borderColor:"#fff",fillColor:e})}drawSelector(){if(this.cellType==="footer")return;const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i,yArr:s,xArrCopy:r,yArrCopy:o}=this.ctx.selector;this.drawBorder({xArr:r,yArr:o,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:this.ctx.config.SELECT_AREA_COLOR||"rgba(82,146,247,0.1)",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:this.ctx.autofill.xArr,yArr:this.ctx.autofill.yArr,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:this.ctx.config.SELECT_AREA_COLOR||"rgba(82,146,247,0.1)",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:i,yArr:s,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:this.ctx.config.SELECT_AREA_COLOR||"rgba(82,146,247,0.1)",borderWidth:1})}drawErrorTip(){if(this.cellType==="footer"||!this.message)return;const{ERROR_TIP_ICON_SIZE:e,ERROR_TIP_COLOR:i}=this.ctx.config,{width:s}=this,r=this.drawX,o=this.drawY,a=[r+s-e-.5,o,r+s-.5,o,r+s-.5,o+e];this.ctx.paint.drawLine(a,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,width:r,rowIndex:o,colIndex:a}=this;let l=i+.5,c=s+.5,f=this.height;o===0&&(c=this.y+1,f=f-1),a===this.ctx.maxColIndex&&(l=l-1);const{xArr:d,yArr:x,lineDash:u=[],borderWidth:g=1,borderColor:w,fillColor:p}=e,y=d[0],b=d[1],m=x[0],E=x[1];a>=y&&a<=b&&o===m&&this.ctx.paint.drawLine([l,c,l+r-2,c],{borderColor:w,fillColor:p,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:u}),a>=y&&a<=b&&o===E&&this.ctx.paint.drawLine([l,c+f-1.5,l+r,c+f-1.5],{borderColor:w,fillColor:p,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:u}),a===y&&o>=m&&o<=E&&this.ctx.paint.drawLine([l,c,l,c+f-1],{borderColor:w,fillColor:p,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:u}),a===b&&o>=m&&o<=E&&this.ctx.paint.drawLine([l+r-1.5,c,l+r-1.5,c+f-1.5],{borderColor:w,fillColor:p,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:u})}}class Jt extends Ut{constructor(e,i,s,r,o,a,l){super(e,s,r,o,a,l.fixed,"header");h(this,"align");h(this,"verticalAlign","middle");h(this,"fixed");h(this,"widthFillDisable");h(this,"type");h(this,"operation",!1);h(this,"editorType");h(this,"level");h(this,"text");h(this,"displayText","");h(this,"colspan");h(this,"rowspan");h(this,"key");h(this,"required",!1);h(this,"readonly",!1);h(this,"children",[]);h(this,"column");h(this,"colIndex");h(this,"rowKey");h(this,"rules");h(this,"hasChildren");h(this,"render");h(this,"style",{});h(this,"drawX",0);h(this,"drawY",0);h(this,"drawCellBgColor","");h(this,"drawTextColor","");h(this,"drawImageX",0);h(this,"drawImageY",0);h(this,"drawImageWidth",0);h(this,"drawImageHeight",0);h(this,"drawImageName","");h(this,"drawImageSource");this.ctx=e,this.x=s,this.y=r,this.width=o,this.height=a,this.colIndex=i,this.key=l.key,this.type=l.type,this.editorType=l.editorType||"text",this.align=l.align||"center",this.verticalAlign=l.verticalAlign||"middle",this.fixed=l.fixed,this.level=l.level,this.operation=l.operation||!1,this.text=l.title,this.column=l,this.colspan=l.colspan,this.widthFillDisable=l.widthFillDisable,this.rowspan=l.rowspan,this.rules=l.rules,this.readonly=l.readonly,this.required=l.required,this.rowKey=Pt(),this.hasChildren=l.children&&l.children.length>0||!1,this.render=l.renderHeader}isVerticalVisible(){const{stageHeight:e}=this.ctx,i=e;return!(this.y+this.height<=0||this.y>=i)}updateStyle(){this.style=this.getOverlayerViewsStyle()}updateContainer(){const{HEADER_CELL_STYLE_METHOD:e,HEADER_BG_COLOR:i,HEADER_TEXT_COLOR:s}=this.ctx.config;let r=i,o=s;if(typeof e=="function"){const a=e,{backgroundColor:l,color:c}=a({colIndex:this.colIndex,column:this.column})||{};l&&(r=l),c&&(o=c)}this.drawCellBgColor=r,this.drawTextColor=o}update(){this.updateContainer(),this.displayText=this.getText(),this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.updateStyle()}draw(){const{paint:e,config:{BORDER_COLOR:i,CELL_PADDING:s,HEADER_FONT:r}}=this.ctx,{drawX:o,drawY:a,displayText:l}=this;e.drawRect(o,a,this.width,this.height,{borderColor:i,fillColor:this.drawCellBgColor}),e.drawText(l,o,a,this.width,this.height,{font:r,padding:s,color:this.drawTextColor,align:this.align,verticalAlign:this.verticalAlign}),this.drawSelection()}drawSelection(){const{width:e,height:i,type:s}=this;if(["index-selection","selection"].includes(s)){const{indeterminate:r,check:o,selectable:a}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:l=0}=this.ctx.config,c=this.drawX+(e-l)/2,f=this.drawY+(i-l)/2;let d=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck";r?(d=this.ctx.icons.get("checkbox-indeterminate"),x="checkbox-indeterminate"):o&&a?(d=this.ctx.icons.get("checkbox-check"),x="checkbox-check"):o&&a?(d=this.ctx.icons.get("checkbox-check-disabled"),x="checkbox-check-disabled"):!o&&a?(d=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck"):(d=this.ctx.icons.get("checkbox-disabled"),x="checkbox-disabled"),d&&(this.drawImageX=c,this.drawImageY=f,this.drawImageWidth=l,this.drawImageHeight=l,this.drawImageName=x,this.drawImageSource=d,this.ctx.paint.drawImage(this.drawImageSource,this.drawImageX,this.drawImageY,this.drawImageWidth,this.drawImageHeight))}}getText(){return this.render?"":this.text}getOverlayerViewsStyle(){let e="";return this.fixed==="left"?e=`${this.drawX}px`:this.fixed==="right"?e=`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`:e=`${this.drawX-this.ctx.fixedLeftWidth}px`,{position:"absolute",overflow:"hidden",left:e,top:`${this.drawY+1}px`,width:`${this.width}px`,height:`${this.height-2}px`,pointerEvents:"initial",userSelect:"none"}}}class oi{constructor(t){h(this,"ctx");h(this,"visibleHoverCell");h(this,"resizeObserver");this.ctx=t,this.init()}init(){this.resizeObserver=new ResizeObserver(()=>{this.ctx.emit("resetHeader"),this.ctx.emit("resizeObserver")}),this.resizeObserver.observe(this.ctx.stageElement),this.ctx.on("mousedown",t=>{if(t.button!==0||this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,r=i;this.handleHeaderEvent(r,s,this.ctx.header.renderCellHeaders,o=>{this.ctx.focusCellHeader=o,this.ctx.emit("cellHeaderMousedown",o,t)}),this.handleBodyEvent(r,s,this.ctx.body.renderRows,o=>{this.ctx.setFocusCell(o),this.ctx.emit("cellMousedown",o,t)})}),this.ctx.on("click",t=>{if(t.button!==0||this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.clickCellHeader=s,this.ctx.emit("cellHeaderClick",s,t),this.selectionClick(s)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellClick",s,t),this.selectionClick(s),this.treeClick(s)})}),this.ctx.on("dblclick",t=>{if(t.button!==0||this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.emit("cellHeaderDblclick",s,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellDblclick",s,t)})}),this.ctx.on("contextMenu",t=>{if(this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,r=i;this.handleHeaderEvent(r,s,this.ctx.header.renderCellHeaders,o=>{this.ctx.emit("cellHeaderContextMenuClick",o,t)}),this.handleBodyEvent(r,s,this.ctx.body.renderRows,o=>{this.ctx.emit("cellContextMenuClick",o,t)})}),this.ctx.on("mousemove",t=>{if(this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.emit("cellHeaderMouseenter",s,t),this.ctx.hoverCellHeader&&this.ctx.hoverCellHeader!==s&&this.ctx.emit("cellHeaderMouseleave",this.ctx.hoverCellHeader,t),this.imageEnterAndLeave(s,t),this.ctx.hoverCellHeader!==s&&(this.ctx.hoverCellHeader=s,this.ctx.emit("cellHeaderHoverChange",s))}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.imageEnterAndLeave(s,t),this.visibleHoverCell!==s&&(this.ctx.emit("visibleCellMouseleave",s,t),this.visibleHoverCell=s,this.ctx.emit("visibleCellHoverChange",s,t))},!0),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{var r;this.ctx.emit("cellMouseenter",s,t),this.ctx.hoverCell&&this.ctx.hoverCell!==s&&this.ctx.emit("cellMouseleave",this.ctx.hoverCell,t),this.ctx.hoverCell!==s&&(((r=this.ctx.hoverCell)==null?void 0:r.rowKey)!==s.rowKey&&(this.ctx.hoverCell=s,this.ctx.hoverRow=this.ctx.body.renderRows.find(o=>o.rowKey===s.rowKey),this.ctx.emit("rowHoverChange",this.ctx.hoverRow,s,t),this.ctx.emit("drawView")),this.ctx.hoverCell=s,this.ctx.emit("cellHoverChange",s,t))})})}selectionClick(t){if(["selection","index-selection"].includes(t.type)&&this.ctx.isPointer)if(t instanceof Jt)t.drawImageName==="checkbox-uncheck"||t.drawImageName==="checkbox-indeterminate"?this.ctx.database.toggleAllSelection():t.drawImageName==="checkbox-check"&&this.ctx.database.clearSelection();else{if(!this.ctx.database.getRowSelectable(t.rowKey))return;this.ctx.database.toggleRowSelection(t.rowKey)}}treeClick(t){if(t.type==="tree"&&this.ctx.isPointer){const e=this.ctx.database.getRowForRowKey(t.rowKey),{expand:i=!1,expandLazy:s=!1}=e||{},{EXPAND_LAZY:r,EXPAND_LAZY_METHOD:o}=this.ctx.config;if(r&&o&&!i&&!s)typeof o=="function"&&(this.ctx.database.expandLoading(t.rowKey,!0),o({row:t.row,rowIndex:t.rowIndex,colIndex:t.colIndex,column:t.column,value:t.getValue()}).then(l=>{this.ctx.database.setExpandChildren(t.rowKey,l),this.ctx.database.expandLoading(t.rowKey,!1),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}).catch(l=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(l)}));else{const a=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!a),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}}}imageEnterAndLeave(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),r=i,o=s;o>t.drawImageX&&o<t.drawImageX+t.drawImageWidth&&r>t.drawImageY&&r<t.drawImageY+t.drawImageHeight?(this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0,t instanceof Zt&&["selection","index-selection"].includes(t.type)&&(this.ctx.database.getRowSelectable(t.rowKey)||(this.ctx.stageElement.style.cursor="not-allowed"))):(this.ctx.isPointer=!1,this.ctx.stageElement.style.cursor==="pointer"&&(this.ctx.stageElement.style.cursor="default"))}isBusy(t){const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,r=i;if(!this.ctx.isTarget()||this.ctx.stageElement.style.cursor==="row-resize"||this.ctx.stageElement.style.cursor==="col-resize"||this.ctx.columnResizing||this.ctx.rowResizing)return!0;const{SCROLLER_TRACK_SIZE:o}=this.ctx.config;return!!(this.ctx.scrollerMove||this.ctx.scrollerFocus||s>this.ctx.stageHeight-o||r>this.ctx.stageWidth-o)}handleBodyEvent(t,e,i,s,r=!1){for(const o of i){const a=o.fixedCells.concat(o.noFixedCells);for(const l of a){const c=l.getDrawX(),f=l.getDrawY();if(r){if(t>c&&t<c+l.visibleWidth&&e>f&&e<f+l.visibleHeight){s(l);return}}else if(t>c&&t<c+l.width&&e>f&&e<f+l.height){s(l);return}}}}handleHeaderEvent(t,e,i,s){for(const r of i){const o=r.getDrawX(),a=r.getDrawY();if(t>o&&t<o+r.width&&e>a&&e<a+r.height){s(r);return}}}destroy(){this.resizeObserver.unobserve(this.ctx.stageElement)}}class ni{constructor(t,e){h(this,"eventBus");h(this,"eventBrowser");h(this,"eventTable");h(this,"containerElement");h(this,"stageElement");h(this,"canvasElement");h(this,"overlayerElement");h(this,"editorElement");h(this,"stageWidth",0);h(this,"stageHeight",0);h(this,"paint");h(this,"icons");h(this,"isInsideTargetContainer",!1);h(this,"mousedown",!1);h(this,"isPointer",!1);h(this,"rowResizing",!1);h(this,"columnResizing",!1);h(this,"scrollerMove",!1);h(this,"scrollerFocus",!1);h(this,"autofillMove",!1);h(this,"selectorMove",!1);h(this,"adjustPositioning",!1);h(this,"editing",!1);h(this,"scrollY",0);h(this,"scrollX",0);h(this,"fixedLeftWidth",0);h(this,"fixedRightWidth",0);h(this,"maxColIndex",0);h(this,"maxRowIndex",0);h(this,"hoverRow");h(this,"clickCell");h(this,"focusCell");h(this,"hoverCell");h(this,"clickCellHeader");h(this,"focusCellHeader");h(this,"hoverCellHeader");h(this,"body",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,headIndex:0,tailIndex:0,visibleRows:[],renderRows:[],data:[]});h(this,"footer",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,renderRows:[]});h(this,"header",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,visibleLeafColumns:[],leafCellHeaders:[],renderLeafCellHeaders:[],renderCellHeaders:[],fixedLeftCellHeaders:[],fixedRightCellHeaders:[],renderCenterCellHeaders:[]});h(this,"selector",{enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]});h(this,"autofill",{enable:!1,xArr:[-1,-1],yArr:[-1,-1]});h(this,"database");h(this,"history");h(this,"config");const{containerElement:i,stageElement:s,canvasElement:r,overlayerElement:o,editorElement:a}=t;this.containerElement=i,s.tabIndex=0,this.stageElement=s,this.canvasElement=r,this.overlayerElement=o,this.editorElement=a,this.config=new jt(e.config||{}),this.eventBus=new ii,this.eventBrowser=new ei(this),this.eventTable=new oi(this),this.paint=new si(this.canvasElement),this.database=new Qe(this,e),this.history=new ti(this),this.icons=new ri(this)}setConfig(t){this.config=new jt(t)}setFocusCell(t){var e;this.focusCell!==t&&(((e=this.focusCell)==null?void 0:e.rowKey)!==t.rowKey&&(this.focusCell=t,this.emit("rowFocusChange",t)),this.focusCell=t,this.emit("cellFocusChange",t))}clearSelector(){this.selector={enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]}}clearAutofill(){this.autofill={enable:!1,xArr:[-1,-1],yArr:[-1,-1]}}getSelectedData(){const t=[],e=this.selector.yArr,i=this.selector.xArr;let s="";for(let r=0;r<=e[1]-e[0];r++){const o=[];for(let a=0;a<=i[1]-i[0];a++){const l=r+e[0],c=a+i[0],f=this.database.getItemValueForRowIndexAndColIndex(l,c);f&&o.push(f.value)}s+=`${o.join(" ")}\r`,t.push(o)}return s=s?s.replace(/\r$/,""):" ",{xArr:i,yArr:e,text:s,value:t}}setScroll(t,e){let i=Math.floor(t);const s=this.body.width-this.body.visibleWidth;i<0?i=0:i>s&&(i=s);let r=Math.floor(e);const o=this.body.height-this.body.visibleHeight-this.footer.height;r<0?r=0:r>o&&(r=o),this.emit("setScroll",i,r)}setScrollX(t){let e=Math.floor(t);const i=this.body.width-this.body.visibleWidth;e<0?e=0:e>i&&(e=i),this.emit("setScrollX",e)}setScrollY(t){let e=Math.floor(t),i=0;this.config.FOOTER_FIXED||(i=this.footer.height);const s=this.body.height-this.body.visibleHeight+i;e<0?e=0:e>s&&(e=s),this.emit("setScrollY",e)}isTarget(){return this.isInsideTargetContainer}getOffset(t){const{left:e,top:i}=this.containerElement.getBoundingClientRect();return{offsetX:t.clientX-e,offsetY:t.clientY-i}}hasEvent(t){return this.eventBus.has(t)}on(t,e){this.eventBus.on(t,e)}once(t,e){this.eventBus.once(t,e)}off(t,e){this.eventBus.off(t,e)}emit(t,...e){this.eventBus.emit(t,...e)}destroy(){this.eventTable.destroy(),this.eventBrowser.destroy(),this.eventBus.destroy()}}class Qt{constructor(t,e){h(this,"ctx");h(this,"type");h(this,"isFocus",!1);h(this,"trackX",0);h(this,"trackY",0);h(this,"trackWidth",0);h(this,"trackHeight",0);h(this,"splitPoints",[]);h(this,"barX",0);h(this,"barY",0);h(this,"barWidth",0);h(this,"barHeight",0);h(this,"distance",0);h(this,"visibleDistance",0);h(this,"clientX",0);h(this,"clientY",0);h(this,"dragStart",0);h(this,"isDragging",!1);h(this,"scroll",0);this.ctx=t,this.type=e,this.type==="vertical"?this.scroll=this.ctx.scrollY:this.scroll=this.ctx.scrollX}onWheel(t){this.updateScroll(t)}onMouseDown(t){if(!(t.target instanceof Element)||!this.ctx.isTarget())return;if(this.ctx.stageElement.style.cursor==="row-resize"||this.ctx.stageElement.style.cursor==="col-resize")return!0;const{offsetX:e,offsetY:i,clientX:s,clientY:r}=t;if(!(s==this.clientX&&r==this.clientY)){if(this.isOnScrollbar(e,i))this.clientX=s,this.clientY=r,this.isDragging=!0,this.ctx.scrollerMove=!0,this.isFocus=!0,this.dragStart=this.scroll;else if(this.isOnTrack(e,i)){let o=0;this.type==="vertical"?o=(i-this.ctx.header.height-this.barHeight/2)/(this.visibleDistance-this.barHeight)*this.distance:o=(e-this.barWidth/2)/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(o,this.distance))}}}onMouseUp(){this.isDragging=!1,this.isFocus=!1,this.clientX=0,this.clientY=0}onMouseMove(t){const{offsetX:e,offsetY:i,clientX:s,clientY:r}=t;if(this.isOnScrollbar(e,i)&&t.target===this.ctx.canvasElement?this.isFocus=!0:this.isFocus=!1,s==this.clientX&&r==this.clientY)return;let o=0;if(this.type==="horizontal"?o=s-this.clientX:o=r-this.clientY,this.isDragging&&o!==0){let a=0;this.type==="vertical"?a=this.dragStart+o/(this.visibleDistance-this.barHeight)*this.distance:a=this.dragStart+o/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(a,this.distance))}}isPointInElement(t,e,i,s,r,o){return t>=i&&t<=i+r&&e>=s&&e<=s+o}hasScrollbar(){return this.type==="vertical"?this.barHeight>0:this.type==="horizontal"?this.barWidth>0:!1}isOnScrollbar(t,e){return this.isPointInElement(t,e,this.barX,this.barY,this.barWidth,this.barHeight)}isOnTrack(t,e){return this.isPointInElement(t,e,this.trackX,this.trackY,this.trackWidth,this.trackHeight)}updateScroll(t){const e=t.deltaX,i=t.deltaY;this.type==="vertical"&&t.shiftKey===!1?(this.hasScrollbar()&&!(this.scroll===0&&i<0||this.scroll===this.distance&&i>0)&&t.preventDefault(),this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance))):this.type==="horizontal"&&(t.shiftKey?this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance)):this.scroll=Math.max(0,Math.min(this.scroll+e,this.distance)))}updatedSize(){const{body:t,header:e,stageHeight:i,stageWidth:s,config:{SCROLLER_TRACK_SIZE:r=0,SCROLLER_SIZE:o=0}}=this.ctx,a=s,l=i,c=e.height,f=e.width,d=t.height,x=this.ctx.footer.height;if(this.type==="vertical"){this.visibleDistance=l-r-c,this.distance=d-this.visibleDistance+x,this.trackX=a-r,this.trackY=0,this.splitPoints=[this.trackX,c,this.trackX+r,c],this.trackWidth=r,this.trackHeight=l,this.barX=this.trackX-.5+(r-o)/2,this.barWidth=o;const u=this.distance?this.visibleDistance/d:0;let g=Math.floor(u*this.visibleDistance);g<30?g=30:g>this.visibleDistance&&(g=0),this.barHeight=g,this.barY=c+this.scroll/this.distance*(this.visibleDistance-this.barHeight),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}else{this.visibleDistance=a-r,this.distance=f-this.visibleDistance,this.splitPoints=[a-r,l-r,a-r,l],this.trackX=0,this.trackY=l-r,this.trackWidth=a,this.trackHeight=r;const u=this.distance?this.visibleDistance/f:0;let g=Math.floor(u*this.visibleDistance);this.barY=this.trackY-.5+(r-o)/2,g<30?g=30:g>=this.visibleDistance&&(g=0),this.barWidth=g,this.barHeight=o,this.barX=this.scroll/this.distance*(this.visibleDistance-this.barWidth),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}}draw(){const{config:{SCROLLER_FOCUS_COLOR:t,SCROLLER_COLOR:e,BORDER_COLOR:i,SCROLLER_TRACK_COLOR:s}}=this.ctx;this.updatedSize(),this.ctx.paint.drawRect(this.trackX,this.trackY,this.trackWidth,this.trackHeight,{borderColor:i,fillColor:s}),this.ctx.paint.drawRect(this.barX,this.barY,this.barWidth,this.barHeight,{fillColor:this.isFocus||this.isDragging?t:e,radius:4}),this.splitPoints.length>0&&this.ctx.paint.drawLine(this.splitPoints,{borderColor:i,borderWidth:1}),this.ctx.scrollerFocus=this.isFocus}}class ai{constructor(t){h(this,"ctx");h(this,"verticalScrollbar");h(this,"horizontalScrollbar");this.ctx=t,this.verticalScrollbar=new Qt(t,"vertical"),this.horizontalScrollbar=new Qt(t,"horizontal"),this.ctx.on("wheel",e=>this.onWheel(e)),this.ctx.on("mousedown",e=>this.onMouseDown(e)),this.ctx.on("mousemove",e=>this.onMouseMove(e)),this.ctx.on("mouseup",()=>this.onMouseUp()),this.ctx.on("setScroll",(e,i)=>{this.setScroll(e,i)}),this.ctx.on("setScrollX",e=>{this.setScrollX(e)}),this.ctx.on("setScrollY",e=>{this.setScrollY(e)})}onWheel(t){this.verticalScrollbar.onWheel(t),this.horizontalScrollbar.onWheel(t),this.draw()}onMouseDown(t){this.verticalScrollbar.onMouseDown(t),this.horizontalScrollbar.onMouseDown(t),this.draw()}onMouseMove(t){this.verticalScrollbar.onMouseMove(t),this.horizontalScrollbar.onMouseMove(t),this.draw()}onMouseUp(){this.verticalScrollbar.onMouseUp(),this.horizontalScrollbar.onMouseUp(),this.ctx.scrollerMove=!1}draw(){this.verticalScrollbar.draw(),this.horizontalScrollbar.draw();const t=Math.floor(this.horizontalScrollbar.scroll),e=Math.floor(this.verticalScrollbar.scroll);(t!==this.ctx.scrollX||e!==this.ctx.scrollY)&&(this.ctx.emit("onScroll",t,e),t!==this.ctx.scrollX&&this.ctx.emit("onScrollX",t),e!==this.ctx.scrollY&&this.ctx.emit("onScrollY",e),this.ctx.scrollX=t,this.ctx.scrollY=e,this.ctx.emit("draw"))}setScroll(t,e){this.horizontalScrollbar.scroll=t,this.verticalScrollbar.scroll=e,this.ctx.emit("draw")}setScrollX(t){this.horizontalScrollbar.scroll=t,this.ctx.emit("draw")}setScrollY(t){this.verticalScrollbar.scroll=t,this.ctx.emit("draw")}scrollToColkey(t){const{header:e}=this.ctx,i=e.leafCellHeaders.find(s=>s.key===t);i&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToColIndex(t){const{header:e}=this.ctx,i=e.leafCellHeaders.find(s=>s.colIndex===t);i&&i.x>e.visibleWidth/2&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToRowIndex(t){const{body:e,database:i}=this.ctx,{top:s}=i.getPositionForRowIndex(t);s>e.visibleHeight&&this.setScrollY(s-e.visibleHeight/2)}scrollToRowKey(t){const{body:e,database:i}=this.ctx,s=i.getRowIndexForRowKey(t),{top:r}=i.getPositionForRowIndex(s);this.setScrollY(r-e.visibleHeight/2)}}class hi{constructor(t){h(this,"ctx");h(this,"x",0);h(this,"y",0);h(this,"width",0);h(this,"height",0);h(this,"resizeTarget",null);h(this,"resizeNum",0);h(this,"isResizing",!1);h(this,"clientX",0);h(this,"resizeDiff",0);h(this,"columnIndex",0);h(this,"isMouseDown",!1);h(this,"columns");h(this,"visibleLeafColumns",[]);h(this,"visibleHeight",0);h(this,"visibleWidth",0);h(this,"allCellHeaders",[]);h(this,"leafCellHeaders",[]);h(this,"renderLeafCellHeaders",[]);h(this,"fixedLeftCellHeaders",[]);h(this,"centerCellHeaders",[]);h(this,"fixedRightCellHeaders",[]);h(this,"renderCenterCellHeaders",[]);h(this,"renderFixedCellHeaders",[]);this.ctx=t,this.ctx.on("resetHeader",Vt(()=>{this.init(),this.ctx.emit("draw")},100)),this.init(),this.initResizeColumn()}init(){const{config:{HEADER_HEIGHT:t,SCROLLER_TRACK_SIZE:e}}=this.ctx,i=this.ctx.database.getColumns();this.columns=i,this.allCellHeaders=[],this.leafCellHeaders=[],this.fixedLeftCellHeaders=[],this.fixedRightCellHeaders=[],this.centerCellHeaders=[];const s=zt(i),r=_t(i);this.height=t*s,this.width=r.reduce((d,x)=>d+((x==null?void 0:x.width)||100),0),this.visibleHeight=this.height;const o=je($t(i,s));this.columnIndex=0,this.resizeNum=0,this.render(o,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);const a=this.ctx.containerElement.getBoundingClientRect();this.resizeNum>0?this.ctx.stageWidth=Math.floor(a.width):this.ctx.stageWidth=Math.floor(this.width+e),this.ctx.stageElement.style.width=this.ctx.stageWidth-.5+"px",this.visibleWidth=this.ctx.stageWidth-e;const l=this.visibleWidth-this.width;if(this.resizeNum&&l>0){const d=Math.floor(l/this.resizeNum*100)/100;this.resizeAllColumn(d)}const c=this.fixedLeftCellHeaders.filter(d=>!d.hasChildren);this.ctx.fixedLeftWidth=c.reduce((d,x)=>d+x.width,0);const f=this.fixedRightCellHeaders.filter(d=>!d.hasChildren);this.ctx.fixedRightWidth=f.reduce((d,x)=>d+x.width,e),this.ctx.maxColIndex=this.leafCellHeaders.length-1,this.ctx.header.x=this.x,this.ctx.header.y=this.y,this.ctx.header.width=this.width,this.ctx.header.height=this.height,this.ctx.header.visibleWidth=this.visibleWidth,this.ctx.header.visibleHeight=this.visibleHeight}initResizeColumn(){const{config:{ENABLE_RESIZE_COLUMN:t}}=this.ctx;t&&(this.ctx.on("mousedown",e=>{this.ctx.isTarget()&&(this.clientX=e.clientX,this.resizeTarget?(this.isResizing=!0,this.ctx.columnResizing=!0):this.isResizing=!1,this.isMouseDown=!0)}),this.ctx.on("mouseup",()=>{this.isMouseDown=!1,this.resizeDiff!==0&&this.resizeTarget&&this.resizeColumn(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.isResizing=!1,this.ctx.columnResizing=!1,this.clientX=0}),this.ctx.on("mousemove",e=>{if(this.ctx.editing)return;const{stageWidth:i,config:{RESIZE_COLUMN_MIN_WIDTH:s}}=this.ctx;if(this.isResizing&&this.resizeTarget){const r=this.resizeTarget.width;let o=e.clientX-this.clientX;o+r<s&&(o=-(r-s)),this.resizeDiff=o,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;this.ctx.stageElement.style.cursor==="col-resize"&&(this.ctx.stageElement.style.cursor="default");const r=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(const o of r){const{offsetX:a,offsetY:l}=this.ctx.getOffset(e),c=a,f=o.getDrawX();c>f+o.width-5&&c<f+o.width+4&&c<i-4&&o.colspan<=1&&this.ctx.isTarget()&&l<=this.height&&(this.ctx.stageElement.style.cursor="col-resize",this.resizeTarget=o)}}}))}resizeColumn(t,e){const i=r=>{r.forEach(o=>{if(o.children&&o.children.length>0&&i(o.children),o.key===t.key){const a=o.width||100;o.width=a+e}})};i(this.columns),this.ctx.database.setColumns(this.columns),this.init(),this.ctx.emit("draw");let s=0;if(this.width<this.visibleWidth){const r=this.visibleWidth-this.width;s=Math.floor(r/this.resizeNum*100)/100,this.resizeAllColumn(s),this.ctx.emit("draw")}this.ctx.emit("resizeColumnChange",{colIndex:t.colIndex,key:t.key,oldWidth:t.width,width:t.width+e+s,column:t.column,columns:this.columns})}resizeAllColumn(t){if(t===0)return;const e=new Map;let i=!0;for(const r of this.allCellHeaders)if(r.widthFillDisable)e.set(r.key,r.width);else{const o=r.width+t*r.colspan;e.set(r.key,o),o<this.ctx.config.RESIZE_COLUMN_MIN_WIDTH&&(i=!1)}if(!i)return;const s=r=>{r.forEach(o=>{e.has(o.key)&&(o.width=e.get(o.key)),o.children&&o.children.length>0&&s(o.children)})};s(this.columns),this.ctx.database.setColumns(this.columns),this.init()}render(t,e){const i=t.length;let s=e;const{HEADER_HEIGHT:r=0}=this.ctx.config;for(let o=0;o<i;o++){const a=t[o],l=r*(a.rowspan||1),c=r*a.level;let f=a.width||100;a.children&&(f=_t(a.children).reduce((u,g)=>u+((g==null?void 0:g.width)||100),0));const d=new Jt(this.ctx,this.columnIndex,s,c,f,l,a);this.ctx.database.setHeader(a.key,d),this.allCellHeaders.push(d),a.children||(this.leafCellHeaders.push(d),d.column.widthFillDisable||this.resizeNum++),a.fixed==="left"?this.fixedLeftCellHeaders.push(d):a.fixed==="right"?this.fixedRightCellHeaders.push(d):this.centerCellHeaders.push(d),!a.children&&this.columnIndex++,a.children&&this.render(a.children,s),s+=f}}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageHeight:t,config:{RESIZE_COLUMN_LINE_COLOR:e}}=this.ctx,i=this.resizeTarget.getDrawX(),s=this.resizeTarget.width,r=i+s+this.resizeDiff-.5,o=[r-.5,0,r-.5,t];this.ctx.paint.drawLine(o,{borderColor:e,borderWidth:1})}}drawFiexShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:a}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:o,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==a){const l=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(l+1,this.y,e,this.height,{fillColor:o,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){const t=[],e=[],i=[];this.centerCellHeaders.forEach(s=>{s.isHorizontalVisible()&&s.isVerticalVisible()&&(e.push(s),s.hasChildren||t.push(s))}),this.fixedLeftCellHeaders.forEach(s=>{i.push(s),s.hasChildren||t.push(s)}),this.fixedRightCellHeaders.forEach(s=>{i.push(s),s.hasChildren||t.push(s)}),this.renderCenterCellHeaders=e,this.renderFixedCellHeaders=i,this.renderLeafCellHeaders=t.sort((s,r)=>s.x-r.x),this.visibleLeafColumns=this.renderLeafCellHeaders.map(s=>s.column),this.ctx.header.visibleLeafColumns=this.visibleLeafColumns,this.ctx.header.leafCellHeaders=this.leafCellHeaders,this.ctx.header.renderLeafCellHeaders=this.renderLeafCellHeaders,this.ctx.header.renderCellHeaders=this.renderFixedCellHeaders.concat(this.renderCenterCellHeaders)}draw(){this.renderCenterCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawFiexShadow(),this.renderFixedCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawTipLine()}}class te{constructor(t,e,i=0,s=0,r=0,o=0,a,l="body"){h(this,"ctx");h(this,"x",0);h(this,"y",0);h(this,"width",0);h(this,"height");h(this,"cells",[]);h(this,"fixedCells",[]);h(this,"noFixedCells",[]);h(this,"rowIndex",0);h(this,"rowKey","");h(this,"rowType","body");h(this,"data");this.ctx=t,this.x=i,this.y=s,this.width=r,this.height=o,this.rowIndex=e,this.rowKey=t.database.getRowKeyForRowIndex(e),this.rowType=l,this.data=a,this.update()}update(){const{header:t}=this.ctx,e=[],i=[],s=[];t.renderLeafCellHeaders.forEach(r=>{const o=new Zt(this.ctx,this.rowIndex,r.colIndex,r.x,this.y,r.width,this.height,r.column,this.data,this.rowType);o.fixed?i.push(o):s.push(o),e.push(o)}),this.cells=e,this.fixedCells=i,this.noFixedCells=s}drawCenter(){this.noFixedCells.forEach(t=>{t.draw()})}drawFixed(){this.fixedCells.forEach(t=>{t.draw()})}draw(){this.noFixedCells.forEach(t=>{t.draw()}),this.fixedCells.forEach(t=>{t.draw()})}}class li{constructor(t){h(this,"resizeTarget",null);h(this,"isMouseDown",!1);h(this,"resizeDiff",0);h(this,"clientY",0);h(this,"ctx");h(this,"x",0);h(this,"y",0);h(this,"width",0);h(this,"height",0);h(this,"headIndex",0);h(this,"tailIndex",0);h(this,"isResizing",!1);h(this,"renderRows",[]);h(this,"visibleRows",[]);h(this,"visibleHeight",0);h(this,"visibleWidth",0);h(this,"data",[]);this.ctx=t,this.init(),this.initResizeRow()}init(){const{canvasElement:t,header:e,database:i,config:{FOOTER_FIXED:s,SCROLLER_TRACK_SIZE:r=0,HEIGHT:o,EMPTY_BODY_HEIGHT:a=0,MAX_HEIGHT:l=0,ENABLE_OFFSET_HEIGHT:c=0,OFFSET_HEIGHT:f=0}}=this.ctx;if(!e.width)return;this.x=0,this.y=e.height;const{data:d,sumHeight:x}=i.getData();this.height=x,this.data=d;const{top:u}=t.getBoundingClientRect();this.width=e.width,this.visibleWidth=this.ctx.stageWidth-r;const g=this.ctx.footer.height;this.data.length||(this.height=a);const w=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:w,type:w,headerHeight:e.height,bodyHeight:this.height,footerHeight:g,width:this.width,height:this.data.length?0:a+g});let p=this.height+e.height+r;p+=g;let y=0;this.data.length&&c?(y=window.innerHeight-u-f,y<0&&(y=32,console.error("There is an error in the height calculation ENABLE_OFFSET_HEIGHT and OFFSET_HEIGHT are invalid"))):this.data.length&&o?y=o:this.data.length&&l&&p>l?y=l:y=p,y>0&&(this.ctx.stageHeight=Math.floor(y),this.ctx.stageElement.style.height=`${this.ctx.stageHeight-.5}px`);let b=this.ctx.stageHeight-e.height-r;s?this.visibleHeight=b-g:this.visibleHeight=b,this.ctx.body.x=this.x,this.ctx.body.y=this.y,this.ctx.body.width=this.width,this.ctx.body.height=this.height,this.ctx.body.visibleWidth=this.visibleWidth,this.ctx.body.visibleHeight=this.visibleHeight,this.ctx.body.data=d;const m=window.devicePixelRatio||1,E=this.ctx.stageWidth*m,C=this.ctx.stageHeight*m;t.width=Math.floor(E),t.height=Math.floor(C),this.ctx.canvasElement.setAttribute("style",` height:${this.ctx.stageHeight}px;width:${this.ctx.stageWidth}px;`),this.ctx.paint.scale(m)}initResizeRow(){const{config:{ENABLE_RESIZE_ROW:t}}=this.ctx;t&&(this.ctx.on("mouseup",()=>{this.isMouseDown=!1,this.resizeDiff!==0&&this.resizeTarget&&this.resizeRow(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.resizeDiff=0,this.isResizing=!1,setTimeout(()=>{this.ctx.rowResizing=!1},0),this.clientY=0}),this.ctx.on("mousedown",e=>{this.ctx.isTarget()&&(this.clientY=e.clientY,this.resizeTarget?(this.isResizing=!0,this.ctx.rowResizing=!0):(this.isResizing=!1,this.ctx.rowResizing=!1),this.isMouseDown=!0)}),this.ctx.on("mousemove",e=>{if(this.ctx.editing)return;const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),r=i,o=s,a=e.clientY,{stageHeight:l,scrollY:c,config:{RESIZE_ROW_MIN_HEIGHT:f=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){const d=this.resizeTarget.height;let x=a-this.clientY;x+d<f&&(x=-(d-f)),this.resizeDiff=x,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown||this.ctx.stageElement.style.cursor==="crosshair")return;this.ctx.stageElement.style.cursor==="row-resize"&&(this.ctx.stageElement.style.cursor="default");for(let d=0;d<this.renderRows.length;d++){const x=this.renderRows[d];if(r>x.y-c+x.height-1.5&&r<x.y-c+x.height+1.5&&r<l-4)for(let g=0;g<x.cells.length;g++){const w=x.cells[g];o>w.drawX+10&&o<w.drawX+w.width-10&&w.rowspan===1&&(this.ctx.stageElement.style.cursor="row-resize",this.resizeTarget=x)}}}}))}resizeRow(t,e){const{rowIndex:i,height:s,rowKey:r,data:o}=t;this.ctx.database.setRowHeight(i,s+e),this.init(),this.ctx.emit("draw"),this.ctx.emit("resizeRowChange",{rowIndex:i,oldHeight:s,height:s+e,rowKey:r,row:o,data:this.data})}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageWidth:t,scrollY:e,config:{RESIZE_ROW_LINE_COLOR:i}}=this.ctx,s=this.resizeTarget.y-e,r=this.resizeTarget.height,o=s+r+this.resizeDiff-.5,a=[0,o-.5,t,o-.5];this.ctx.paint.drawLine(a,{borderColor:i,borderWidth:1})}}drawFiexShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:a}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:o,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==a){const l=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(l+1,this.y,e,this.height,{fillColor:o,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}binarySearch(t,e){let i=0,s=t.length-1,r=-1;for(;i<=s;){let o=Math.floor((i+s)/2),a=t[o].bottom;if(a===e)return o;a<e?i=o+1:(r=o,s=o-1)}return r}update(){this.init();const{header:t,database:e,scrollY:i}=this.ctx,s=i,{data:r,positions:o}=e.getData();this.ctx.maxRowIndex=r.length-1;const a=this.binarySearch(o,s);let l=this.binarySearch(o,s+this.visibleHeight);l===-1&&(l=r.length),this.headIndex=Math.max(0,a),this.tailIndex=Math.min(this.ctx.maxRowIndex,l+1),this.visibleRows=r.slice(this.headIndex,this.tailIndex+1),this.ctx.body.headIndex=this.headIndex,this.ctx.body.tailIndex=this.tailIndex,this.ctx.body.visibleRows=this.visibleRows;const c=[];for(let f=0;f<this.visibleRows.length;f++){const d=this.headIndex+f,x=this.visibleRows[f],{height:u,top:g}=this.ctx.database.getPositionForRowIndex(d),w=new te(this.ctx,d,0,g+this.y,t.width,u,x);c.push(w)}this.renderRows=c,this.ctx.body.renderRows=c}draw(){this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFiexShadow(),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTipLine()}}class ci{constructor(t){h(this,"ctx");h(this,"renderRows",[]);h(this,"data",[]);h(this,"x",0);h(this,"y",0);h(this,"width",0);h(this,"height",0);h(this,"visibleWidth",0);h(this,"visibleHeight",0);this.ctx=t,this.init()}init(){this.data=this.ctx.database.getFooterData();const{header:t,body:e,config:{CELL_FOOTER_HEIGHT:i,FOOTER_FIXED:s,SCROLLER_TRACK_SIZE:r}}=this.ctx;this.width=t.width,this.visibleWidth=t.visibleWidth,this.height=this.data.reduce(o=>o+i,0),this.visibleHeight=this.height,s?this.y=this.ctx.stageHeight-this.height-r:this.y=e.y+e.height,this.ctx.footer.x=this.x,this.ctx.footer.y=this.y,this.ctx.footer.height=this.height,this.ctx.footer.width=this.width,this.ctx.footer.visibleWidth=this.visibleWidth,this.ctx.footer.visibleHeight=this.visibleHeight}drawFiexShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:a}}=this.ctx;let l=this.y;if(this.ctx.config.FOOTER_FIXED||(l=this.y-this.ctx.scrollY),i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,l,t,this.height,{fillColor:o,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==a){const c=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(c+1,l,e,this.height,{fillColor:o,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){this.init();const{CELL_FOOTER_HEIGHT:t}=this.ctx.config;let e=this.y;const i=[];this.data.forEach((s,r)=>{const o=new te(this.ctx,r,0,e,this.width,t,s,"footer");e+=t,i.push(o)}),this.renderRows=i,this.ctx.footer.renderRows=this.renderRows}draw(){this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFiexShadow(),this.renderRows.forEach(t=>{t.drawFixed()})}}class di{constructor(t){h(this,"isCut",!1);h(this,"isMultipleRow",!1);h(this,"mousedownHeader",!1);h(this,"ctx");h(this,"adjustPositionX","");h(this,"adjustPositionY","");h(this,"timerX",0);h(this,"timerY",0);this.ctx=t,this.init()}init(){this.ctx.on("mousemove",Vt(t=>{const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=this.ctx.isTarget()&&i>0&&i<this.ctx.body.visibleWidth&&e>this.ctx.header.visibleHeight&&e<this.ctx.header.visibleHeight+this.ctx.body.visibleHeight;(this.ctx.selectorMove||this.ctx.autofillMove)&&(!s&&!this.mousedownHeader?this.startAdjustPosition(t):this.stopAdjustPosition())},100)),this.ctx.on("cellHoverChange",t=>{if(!this.ctx.autofillMove){if(t.operation){this.selectRows(t,!1);return}this.isMultipleRow||this.mouseenter()}}),this.ctx.on("cellMousedown",(t,e)=>{if(this.ctx.isTarget()&&this.ctx.stageElement.style.cursor!=="pointer"&&!this.ctx.isPointer&&this.ctx.stageElement.style.cursor!=="crosshair"){if(t.operation){this.isMultipleRow=!0,this.selectRows(t);return}this.isMultipleRow=!1,this.click(e.shiftKey)}}),this.ctx.on("mouseup",()=>{this.mousedownHeader=!1;const t=setTimeout(()=>{this.ctx.adjustPositioning=!1,clearTimeout(t)},0)}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHeaderMousedown",t=>{this.ctx.stageElement.style.cursor!=="pointer"&&(this.ctx.isPointer||(this.mousedownHeader=!0,this.selectCols(t)))}),this.ctx.on("keydown",t=>{if(t.ctrlKey&&t.code==="KeyV"||t.metaKey&&t.code==="KeyV"){t.preventDefault(),this.paste();return}if(t.ctrlKey&&t.code==="KeyC"||t.metaKey&&t.code==="KeyC"){t.preventDefault(),this.copy(),this.isCut=!1;return}if(t.ctrlKey&&t.code==="KeyX"||t.metaKey&&t.code==="KeyX"){t.preventDefault(),this.isCut=!0,this.copy();return}if((t.ctrlKey&&t.code==="KeyA"||t.metaKey&&t.code==="KeyA")&&(t.preventDefault(),this.selectAll()),t.code==="ArrowLeft"){t.preventDefault(),this.moveFocus("LEFT");return}if(t.code==="ArrowUp"){t.preventDefault(),this.moveFocus("TOP");return}if(t.code==="ArrowRight"||t.code==="Tab"){t.preventDefault(),this.moveFocus("RIGHT");return}if(t.code==="ArrowDown"){t.preventDefault(),this.moveFocus("BOTTOM");return}if(t.code==="Delete"||t.code==="Backspace"){t.preventDefault();const{xArr:e,yArr:i}=this.ctx.selector;this.clearSelectedData(e,i);return}}),this.ctx.on("contextMenuClearSelected",()=>{const{xArr:t,yArr:e}=this.ctx.selector;this.clearSelectedData(t,e)}),this.ctx.on("contextMenuCopy",()=>{this.copy()}),this.ctx.on("contextMenuPaste",()=>{this.paste()}),this.ctx.on("contextMenuCut",()=>{this.isCut=!0,this.copy()}),this.ctx.on("setSelectorCell",t=>{this.ctx.setFocusCell(t),this.click()}),this.ctx.on("mouseup",()=>{this.ctx.selectorMove=!1,this.stopAdjustPosition()})}setSelector(t,e){const{ENABLE_SELECTOR_SPAN_COL:i,ENABLE_SELECTOR_SPAN_ROW:s}=this.ctx.config;let r=t,o=e;if(!s){const[a]=o;o=[a,a]}if(!i){const[a]=r;r=[a,a]}if(JSON.stringify(this.ctx.selector.xArr)!==JSON.stringify(r)||JSON.stringify(this.ctx.selector.yArr)!==JSON.stringify(o)){this.ctx.mousedown&&(this.ctx.selectorMove=!0),this.ctx.selector.enable=!0;const{SELECTOR_AREA_MIN_X:a,SELECTOR_AREA_MAX_X:l,SELECTOR_AREA_MIN_Y:c,SELECTOR_AREA_MAX_Y:f,SELECTOR_AREA_MAX_X_OFFSET:d,SELECTOR_AREA_MAX_Y_OFFSET:x}=this.ctx.config,u=a,g=l||this.ctx.maxColIndex-d,w=c,p=f||this.ctx.maxRowIndex-x;let[y,b]=r,[m,E]=o;if(y<u||b>g||m<w||E>p)return;this.ctx.selector.xArr=[Math.max(u,y),Math.min(g,b)],this.ctx.selector.yArr=[Math.max(w,m),Math.min(p,E)],this.ctx.emit("setSelector",this.ctx.selector),this.ctx.emit("drawView")}}selectCols(t){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_ROWS||this.ctx.autofillMove||this.ctx.columnResizing||this.ctx.editing)return;if(t.operation){this.selectAll();return}const{SELECTOR_AREA_MIN_Y:e,SELECTOR_AREA_MAX_Y:i,SELECTOR_AREA_MAX_Y_OFFSET:s}=this.ctx.config,r=e,o=i||this.ctx.maxRowIndex-s;if(this.ctx.mousedown&&this.ctx.focusCellHeader){const{colIndex:a}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),t.colIndex>=a){const l=[a,t.colIndex+t.colspan-1],c=[r,o];this.setSelector(l,c)}else{const l=[t.colIndex,a],c=[r,o];this.setSelector(l,c)}}else{const a=[t.colIndex,t.colIndex+t.colspan-1],l=[r,o];this.setSelector(a,l)}}selectAll(){if(this.ctx.autofillMove||this.ctx.editing)return;const{ENABLE_SELECTOR_ALL_ROWS:t,ENABLE_SELECTOR_ALL_COLS:e}=this.ctx.config;if(t&&e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:r,SELECTOR_AREA_MAX_Y:o,SELECTOR_AREA_MAX_X_OFFSET:a,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,c=i,f=s||this.ctx.maxColIndex-a,d=r,x=o||this.ctx.maxRowIndex-l,u=[c,f],g=[d,x];this.setSelector(u,g)}}selectRows(t,e=!0){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_COLS||this.ctx.autofillMove||this.ctx.editing)return;const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MAX_X_OFFSET:r}=this.ctx.config,o=s||this.ctx.maxColIndex-r,a=i;if(e){this.ctx.setFocusCell(t);const l=[a,o],c=[t.rowIndex,t.rowIndex];this.setSelector(l,c)}if(this.ctx.focusCell&&this.ctx.mousedown){const{rowIndex:l}=this.ctx.focusCell;if(t.rowIndex>=l){const c=[a,o],f=[l,t.rowIndex];this.setSelector(c,f)}else{const c=[a,o],f=[t.rowIndex,l];this.setSelector(c,f)}}}mouseenter(){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||this.ctx.editing)return;const{mousedown:t,focusCell:e,hoverCell:i}=this.ctx;if(t&&e&&i){const{rowIndex:s,colIndex:r}=e,o=Math.min(i.colIndex,r),a=Math.max(i.colIndex,r),l=Math.min(i.rowIndex,s),c=Math.max(i.rowIndex,s),f=[o,a],d=[l,c];this.setSelector(f,d)}}click(t=!1){const{focusCell:e,clickCell:i}=this.ctx;if(e&&this.isInSettingRange(e.rowIndex,e.colIndex))if(this.ctx.selector.enable=!0,i&&t){const{colIndex:s,rowIndex:r}=i,{colIndex:o,rowIndex:a}=e,l=Math.min(o,s),c=Math.max(o,s),f=Math.min(a,r),d=Math.max(a,r),x=[l,c],u=[f,d];this.setSelector(x,u)}else{this.ctx.emit("cellSelectedClick",e);const s=[e.colIndex,e.colIndex],r=[e.rowIndex,e.rowIndex];this.setSelector(s,r),this.adjustBoundaryPosition()}}clearCopyLine(){this.ctx.selector.xArrCopy=[-1,-1],this.ctx.selector.yArrCopy=[-1,-1]}getCell(t,e){const i=this.ctx.body.renderRows.find(r=>r.rowIndex===t);return i==null?void 0:i.cells.find(r=>r.colIndex===e)}copy(){if(!this.ctx.config.ENABLE_COPY)return;const{value:t}=this.ctx.getSelectedData(),e=Je(t);navigator.clipboard?navigator.clipboard.writeText(e).then(()=>{this.ctx.selector.xArrCopy=this.ctx.selector.xArr.slice(),this.ctx.selector.yArrCopy=this.ctx.selector.yArr.slice(),this.ctx.emit("copyChange",{xArr:this.ctx.selector.xArrCopy,yArr:this.ctx.selector.yArrCopy,data:t}),this.ctx.emit("draw")}).catch(i=>console.error("复制失败:",i)):console.error("当前浏览器不支持Clipboard API")}clearSelectedData(t,e,i=!1){let s=[];const r=new Set;for(let a=0;a<=e[1]-e[0];a++)for(let l=0;l<=t[1]-t[0];l++){const c=a+e[0],f=l+t[0],d=this.ctx.database.getItemValueForRowIndexAndColIndex(c,f);if(d){const{rowKey:x,key:u}=d;this.ctx.database.getReadonly(x,u)||(r.add(x),s.push({rowKey:x,key:u,value:null,row:{}}))}}if(!s.length)return[];if(i)return s;this.ctx.database.batchSetItemValue(s,!0);let o=[];return r.forEach(a=>{o.push(this.ctx.database.getRowDataItemForRowKey(a))}),this.ctx.emit("clearSelectedDataChange",s,o),s}paste(){if(!navigator.clipboard){console.error("当前浏览器不支持Clipboard API");return}const{ENABLE_PASTER:t}=this.ctx.config;if(this.ctx.selector.enable&&t){const e=this.ctx.selector.yArr[0],i=this.ctx.selector.xArr[0],s=new Set;navigator.clipboard.readText().then(async r=>{let o=Ze(r),a=[];for(let f=0;f<=o.length-1;f++){const d=o[f].length;for(let x=0;x<=d-1;x++){const u=f+e,g=x+i,w=o[f][x],p=this.ctx.database.getItemValueForRowIndexAndColIndex(u,g);if(p){const{rowKey:y,key:b}=p;this.ctx.database.getReadonly(y,b)||(s.add(y),a.push({rowKey:y,key:b,value:w,row:{}}))}}}if(this.isCut){const f=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),d=a.map(x=>`${x.rowKey}-${x.key}`);f.forEach(x=>{d.includes(`${x.rowKey}-${x.key}`)||a.unshift(x)}),this.isCut=!1}if(!a.length)return;const{BEFORE_PASTE_CHANGE_METHOD:l}=this.ctx.config;if(typeof l=="function"){const f=l,d=a.map(x=>({rowKey:x.rowKey,key:x.key,value:x.value,oldValue:this.ctx.database.getItemValue(x.rowKey,x.key),row:this.ctx.database.getRowDataItemForRowKey(x.rowKey)}));a=await f(d)}this.clearCopyLine(),this.ctx.database.batchSetItemValue(a,!0);let c=[];s.forEach(f=>{c.push(this.ctx.database.getRowDataItemForRowKey(f))}),this.ctx.emit("pasteChange",a,c)}).catch(r=>{console.error("获取剪贴板内容失败:",r)})}}moveFocus(t){if(this.ctx.editing)return;const{focusCell:e}=this.ctx;if(!e)return;let{colIndex:i=0,rowIndex:s=0}=e;const r=0,o=0,a=this.ctx.maxColIndex,l=this.ctx.maxRowIndex;switch(t){case"LEFT":i>r&&i--;break;case"TOP":s>o&&s--;break;case"RIGHT":i<a&&i++;break;case"BOTTOM":s<l&&s++;break}const c=[i,i],f=[s,s],d=this.getCell(s,i);d&&(d.operation||this.isInSettingRange(d.rowIndex,d.colIndex)&&(this.ctx.setFocusCell(d),this.setSelector(c,f),this.adjustBoundaryPosition(),this.ctx.emit("draw")))}stopAdjustPosition(){this.adjustPositionX="",this.adjustPositionY="",this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerY&&(clearInterval(this.timerY),this.timerY=0)}isInSettingRange(t,e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:r,SELECTOR_AREA_MAX_Y:o,SELECTOR_AREA_MAX_X_OFFSET:a,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,c=i,f=s||this.ctx.maxColIndex-a,d=r,x=o||this.ctx.maxRowIndex-l;return!(e<c||e>f||t<d||t>x)}startAdjustPosition(t){const{offsetX:e,offsetY:i}=this.ctx.getOffset(t);let s="",r="";if(e<0?s="left":e>this.ctx.body.visibleWidth&&(s="right"),i<this.ctx.header.visibleHeight?r="top":i>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight&&(r="bottom"),s&&this.adjustPositionX!==s){this.adjustPositionX=s;let a=10*(s==="left"?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{a*=1.5;const{scrollX:l}=this.ctx,c=l+a;(c<0||c>this.ctx.body.width)&&(clearInterval(this.timerX),this.timerX=0),this.ctx.setScrollX(c)},100)}if(r&&this.adjustPositionY!==r){this.adjustPositionY=r;let a=10*(r==="top"?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{a*=1.5;const{scrollY:l}=this.ctx,c=l+a;(c<0||c>this.ctx.body.height)&&(clearInterval(this.timerY),this.timerY=0),this.ctx.setScrollY(c)},100)}}adjustBoundaryPosition(){const{stageHeight:t,stageWidth:e,focusCell:i,fixedRightWidth:s,fixedLeftWidth:r,header:o,footer:a,body:l,scrollX:c,scrollY:f,config:{SCROLLER_TRACK_SIZE:d,FOOTER_FIXED:x}}=this.ctx;if(!i)return;const u=r-i.drawX+1,g=i.drawX+i.width-(e-s)+1,w=o.height-i.drawY;let p=i.height;p>l.visibleHeight&&(p=l.visibleHeight);let y=0;x&&(y=a.visibleHeight);const b=i.drawY+p-(t-y-d);let m=c,E=f;g>0&&!i.fixed?m=Math.floor(c+g):u>0&&!i.fixed&&(m=Math.floor(c-u)),w>0?E=Math.floor(f-w):b>0&&(E=Math.floor(f+b)),(Math.abs(c-m)>2||Math.abs(f-E)>2)&&(this.ctx.adjustPositioning=!0,this.ctx.setScroll(m,E),this.ctx.emit("adjustBoundaryPosition",i))}destroy(){this.timerX&&(clearTimeout(this.timerX),this.timerX=0),this.timerY&&(clearTimeout(this.timerY),this.timerY=0)}}class fi{constructor(t){h(this,"ctx");this.ctx=t,this.init()}init(){this.ctx.on("cellMouseenter",(t,e)=>{this.ctx.stageElement.style.cursor==="crosshair"&&(this.ctx.stageElement.style.cursor="default");const{offsetX:i,offsetY:s}=this.ctx.getOffset(e),{xArr:r,yArr:o}=this.ctx.selector,a=r[1],l=o[1],{colIndex:c,rowIndex:f,drawX:d,drawY:x,width:u,height:g}=t;if(this.ctx.config.ENABLE_AUTOFILL&&c===a&&f===l){const p=d+u-6,y=x+g-6;i>p&&s>y&&(this.ctx.stageElement.style.cursor="crosshair")}this.mouseenter(t)}),this.ctx.on("cellMousedown",()=>{this.ctx.stageElement.style.cursor==="crosshair"&&this.setMousedown()}),this.ctx.on("mouseup",()=>{this.setMouseUp()})}isAutofillIng(){const{xArr:t,yArr:e}=this.ctx.selector;return!(JSON.stringify(this.ctx.autofill.xArr)===JSON.stringify(t)&&JSON.stringify(this.ctx.autofill.yArr)===JSON.stringify(e))}setMousedown(){this.ctx.autofill.enable=!0,this.ctx.autofillMove=!0}setMouseUp(){if(!this.ctx.autofill.enable)return;this.isAutofillIng()&&this.autofillData(),this.ctx.autofill.enable=!1,this.ctx.autofillMove=!1,this.ctx.autofill.xArr=[-1,-1],this.ctx.autofill.yArr=[-1,-1]}setAutofill(t,e){const{ENABLE_AUTOFILL:i,ENABLE_SELECTOR_SPAN_COL:s,ENABLE_SELECTOR_SPAN_ROW:r}=this.ctx.config;if(!i)return;let o=t,a=e;if(!r){const[l]=a;a=[l,l]}if(!s){const[l]=o;o=[l,l]}if(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(o)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(a)){const{SELECTOR_AREA_MIN_X:l,SELECTOR_AREA_MAX_X:c,SELECTOR_AREA_MIN_Y:f,SELECTOR_AREA_MAX_Y:d,SELECTOR_AREA_MAX_X_OFFSET:x,SELECTOR_AREA_MAX_Y_OFFSET:u}=this.ctx.config,g=l,w=c||this.ctx.maxColIndex-x,p=f,y=d||this.ctx.maxRowIndex-u;let[b,m]=o,[E,C]=a;if(b<g||E<p)return;this.ctx.autofill.xArr=[Math.max(g,b),Math.min(w,m)],this.ctx.autofill.yArr=[Math.max(p,E),Math.min(y,C)],this.ctx.emit("setAutofill",this.ctx.autofill),this.ctx.emit("draw")}}async autofillData(){const t=new Set,e=this.ctx.getSelectedData(),i=new Map;for(let x=0;x<=e.yArr[1]-e.yArr[0];x++)for(let u=0;u<=e.xArr[1]-e.xArr[0];u++){const g=x+e.yArr[0],w=u+e.xArr[0];i.set(`${g}-${w}`,!0)}const{value:s}=e,r=s[0].length,o=s.length,a=this.ctx.autofill.xArr,l=this.ctx.autofill.yArr;let c=[];for(let x=0;x<=l[1]-l[0];x++)for(let u=0;u<=a[1]-a[0];u++){const g=u+a[0],w=x+l[0],p=s[x%o][u%r],y=this.ctx.database.getItemValueForRowIndexAndColIndex(w,g),b=`${w}-${g}`;if(y&&!i.has(b)){const{rowKey:m,key:E}=y;this.ctx.database.getReadonly(m,E)||(t.add(m),c.push({rowKey:m,key:E,value:p,row:{}}))}}if(!c.length)return;const{BEFORE_AUTOFILL_CHANGE_METHOD:f}=this.ctx.config;if(typeof f=="function"){const x=f,u=c.map(g=>({rowKey:g.rowKey,key:g.key,value:g.value,oldValue:this.ctx.database.getItemValue(g.rowKey,g.key),row:this.ctx.database.getRowDataItemForRowKey(g.rowKey)}));c=await x(u)}this.ctx.selector.xArr=this.ctx.autofill.xArr,this.ctx.selector.yArr=this.ctx.autofill.yArr,this.ctx.database.batchSetItemValue(c,!0);let d=[];t.forEach(x=>{d.push(this.ctx.database.getRowDataItemForRowKey(x))}),this.ctx.emit("autofillChange",c,d)}mouseenter(t){if(["index","selection","index-selection"].includes(t.type))return;const{selector:e,autofill:i}=this.ctx;if(this.ctx.mousedown&&e.enable&&i.enable){const{rowIndex:s,colIndex:r}=t,o=e.xArr.slice(),a=e.yArr.slice();s>=e.yArr[0]&&s<=e.yArr[1]?r>e.xArr[1]?o.splice(1,1,r):r<e.xArr[0]&&o.splice(0,1,r):s>e.yArr[1]?a.splice(1,1,s):s<e.yArr[0]&&a.splice(0,1,s),this.setAutofill(o,a)}}destroy(){}}const at=Math.min,Z=Math.max,ut=Math.round,V=n=>({x:n,y:n}),xi={left:"right",right:"left",bottom:"top",top:"bottom"},ui={start:"end",end:"start"};function It(n,t,e){return Z(n,at(t,e))}function ht(n,t){return typeof n=="function"?n(t):n}function j(n){return n.split("-")[0]}function lt(n){return n.split("-")[1]}function ee(n){return n==="x"?"y":"x"}function Ot(n){return n==="y"?"height":"width"}function J(n){return["top","bottom"].includes(j(n))?"y":"x"}function Tt(n){return ee(J(n))}function gi(n,t,e){e===void 0&&(e=!1);const i=lt(n),s=Tt(n),r=Ot(s);let o=s==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(o=gt(o)),[o,gt(o)]}function wi(n){const t=gt(n);return[St(n),t,St(t)]}function St(n){return n.replace(/start|end/g,t=>ui[t])}function pi(n,t,e){const i=["left","right"],s=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(n){case"top":case"bottom":return e?t?s:i:t?i:s;case"left":case"right":return t?r:o;default:return[]}}function yi(n,t,e,i){const s=lt(n);let r=pi(j(n),e==="start",i);return s&&(r=r.map(o=>o+"-"+s),t&&(r=r.concat(r.map(St)))),r}function gt(n){return n.replace(/left|right|bottom|top/g,t=>xi[t])}function mi(n){return{top:0,right:0,bottom:0,left:0,...n}}function ie(n){return typeof n!="number"?mi(n):{top:n,right:n,bottom:n,left:n}}function wt(n){const{x:t,y:e,width:i,height:s}=n;return{width:i,height:s,top:e,left:t,right:t+i,bottom:e+s,x:t,y:e}}function se(n,t,e){let{reference:i,floating:s}=n;const r=J(t),o=Tt(t),a=Ot(o),l=j(t),c=r==="y",f=i.x+i.width/2-s.width/2,d=i.y+i.height/2-s.height/2,x=i[a]/2-s[a]/2;let u;switch(l){case"top":u={x:f,y:i.y-s.height};break;case"bottom":u={x:f,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:d};break;case"left":u={x:i.x-s.width,y:d};break;default:u={x:i.x,y:i.y}}switch(lt(t)){case"start":u[o]-=x*(e&&c?-1:1);break;case"end":u[o]+=x*(e&&c?-1:1);break}return u}const Ei=async(n,t,e)=>{const{placement:i="bottom",strategy:s="absolute",middleware:r=[],platform:o}=e,a=r.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:n,floating:t,strategy:s}),{x:f,y:d}=se(c,i,l),x=i,u={},g=0;for(let w=0;w<a.length;w++){const{name:p,fn:y}=a[w],{x:b,y:m,data:E,reset:C}=await y({x:f,y:d,initialPlacement:i,placement:x,strategy:s,middlewareData:u,rects:c,platform:o,elements:{reference:n,floating:t}});f=b??f,d=m??d,u={...u,[p]:{...u[p],...E}},C&&g<=50&&(g++,typeof C=="object"&&(C.placement&&(x=C.placement),C.rects&&(c=C.rects===!0?await o.getElementRects({reference:n,floating:t,strategy:s}):C.rects),{x:f,y:d}=se(c,x,l)),w=-1)}return{x:f,y:d,placement:x,strategy:s,middlewareData:u}};async function re(n,t){var e;t===void 0&&(t={});const{x:i,y:s,platform:r,rects:o,elements:a,strategy:l}=n,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:x=!1,padding:u=0}=ht(t,n),g=ie(u),p=a[x?d==="floating"?"reference":"floating":d],y=wt(await r.getClippingRect({element:(e=await(r.isElement==null?void 0:r.isElement(p)))==null||e?p:p.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:c,rootBoundary:f,strategy:l})),b=d==="floating"?{x:i,y:s,width:o.floating.width,height:o.floating.height}:o.reference,m=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),E=await(r.isElement==null?void 0:r.isElement(m))?await(r.getScale==null?void 0:r.getScale(m))||{x:1,y:1}:{x:1,y:1},C=wt(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:m,strategy:l}):b);return{top:(y.top-C.top+g.top)/E.y,bottom:(C.bottom-y.bottom+g.bottom)/E.y,left:(y.left-C.left+g.left)/E.x,right:(C.right-y.right+g.right)/E.x}}const bi=n=>({name:"arrow",options:n,async fn(t){const{x:e,y:i,placement:s,rects:r,platform:o,elements:a,middlewareData:l}=t,{element:c,padding:f=0}=ht(n,t)||{};if(c==null)return{};const d=ie(f),x={x:e,y:i},u=Tt(s),g=Ot(u),w=await o.getDimensions(c),p=u==="y",y=p?"top":"left",b=p?"bottom":"right",m=p?"clientHeight":"clientWidth",E=r.reference[g]+r.reference[u]-x[u]-r.floating[g],C=x[u]-r.reference[u],R=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let S=R?R[m]:0;(!S||!await(o.isElement==null?void 0:o.isElement(R)))&&(S=a.floating[m]||r.floating[g]);const L=E/2-C/2,F=S/2-w[g]/2-1,N=at(d[y],F),$=at(d[b],F),O=N,A=S-w[g]-$,T=S/2-w[g]/2+L,it=It(O,T,A),W=!l.arrow&&lt(s)!=null&&T!==it&&r.reference[g]/2-(T<O?N:$)-w[g]/2<0,K=W?T<O?T-O:T-A:0;return{[u]:x[u]+K,data:{[u]:it,centerOffset:T-it-K,...W&&{alignmentOffset:K}},reset:W}}}),Ci=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(t){var e,i;const{placement:s,middlewareData:r,rects:o,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:x,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:w=!0,...p}=ht(n,t);if((e=r.arrow)!=null&&e.alignmentOffset)return{};const y=j(s),b=J(a),m=j(a)===a,E=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=x||(m||!w?[gt(a)]:wi(a)),R=g!=="none";!x&&R&&C.push(...yi(a,w,g,E));const S=[a,...C],L=await re(t,p),F=[];let N=((i=r.flip)==null?void 0:i.overflows)||[];if(f&&F.push(L[y]),d){const T=gi(s,o,E);F.push(L[T[0]],L[T[1]])}if(N=[...N,{placement:s,overflows:F}],!F.every(T=>T<=0)){var $,O;const T=((($=r.flip)==null?void 0:$.index)||0)+1,it=S[T];if(it)return{data:{index:T,overflows:N},reset:{placement:it}};let W=(O=N.filter(K=>K.overflows[0]<=0).sort((K,q)=>K.overflows[1]-q.overflows[1])[0])==null?void 0:O.placement;if(!W)switch(u){case"bestFit":{var A;const K=(A=N.filter(q=>{if(R){const G=J(q.placement);return G===b||G==="y"}return!0}).map(q=>[q.placement,q.overflows.filter(G=>G>0).reduce((G,ji)=>G+ji,0)]).sort((q,G)=>q[1]-G[1])[0])==null?void 0:A[0];K&&(W=K);break}case"initialPlacement":W=a;break}if(s!==W)return{reset:{placement:W}}}return{}}}};async function vi(n,t){const{placement:e,platform:i,elements:s}=n,r=await(i.isRTL==null?void 0:i.isRTL(s.floating)),o=j(e),a=lt(e),l=J(e)==="y",c=["left","top"].includes(o)?-1:1,f=r&&l?-1:1,d=ht(t,n);let{mainAxis:x,crossAxis:u,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof g=="number"&&(u=a==="end"?g*-1:g),l?{x:u*f,y:x*c}:{x:x*c,y:u*f}}const Ri=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(t){var e,i;const{x:s,y:r,placement:o,middlewareData:a}=t,l=await vi(t,n);return o===((e=a.offset)==null?void 0:e.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:s+l.x,y:r+l.y,data:{...l,placement:o}}}}},_i=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(t){const{x:e,y:i,placement:s}=t,{mainAxis:r=!0,crossAxis:o=!1,limiter:a={fn:p=>{let{x:y,y:b}=p;return{x:y,y:b}}},...l}=ht(n,t),c={x:e,y:i},f=await re(t,l),d=J(j(s)),x=ee(d);let u=c[x],g=c[d];if(r){const p=x==="y"?"top":"left",y=x==="y"?"bottom":"right",b=u+f[p],m=u-f[y];u=It(b,u,m)}if(o){const p=d==="y"?"top":"left",y=d==="y"?"bottom":"right",b=g+f[p],m=g-f[y];g=It(b,g,m)}const w=a.fn({...t,[x]:u,[d]:g});return{...w,data:{x:w.x-e,y:w.y-i,enabled:{[x]:r,[d]:o}}}}}};function pt(){return typeof window<"u"}function Q(n){return oe(n)?(n.nodeName||"").toLowerCase():"#document"}function D(n){var t;return(n==null||(t=n.ownerDocument)==null?void 0:t.defaultView)||window}function B(n){var t;return(t=(oe(n)?n.ownerDocument:n.document)||window.document)==null?void 0:t.documentElement}function oe(n){return pt()?n instanceof Node||n instanceof D(n).Node:!1}function X(n){return pt()?n instanceof Element||n instanceof D(n).Element:!1}function Y(n){return pt()?n instanceof HTMLElement||n instanceof D(n).HTMLElement:!1}function ne(n){return!pt()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof D(n).ShadowRoot}function ct(n){const{overflow:t,overflowX:e,overflowY:i,display:s}=k(n);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&!["inline","contents"].includes(s)}function Ii(n){return["table","td","th"].includes(Q(n))}function yt(n){return[":popover-open",":modal"].some(t=>{try{return n.matches(t)}catch{return!1}})}function At(n){const t=Lt(),e=X(n)?k(n):n;return e.transform!=="none"||e.perspective!=="none"||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||["transform","perspective","filter"].some(i=>(e.willChange||"").includes(i))||["paint","layout","strict","content"].some(i=>(e.contain||"").includes(i))}function Oi(n){let t=z(n);for(;Y(t)&&!tt(t);){if(At(t))return t;if(yt(t))return null;t=z(t)}return null}function Lt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function tt(n){return["html","body","#document"].includes(Q(n))}function k(n){return D(n).getComputedStyle(n)}function mt(n){return X(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function z(n){if(Q(n)==="html")return n;const t=n.assignedSlot||n.parentNode||ne(n)&&n.host||B(n);return ne(t)?t.host:t}function ae(n){const t=z(n);return tt(t)?n.ownerDocument?n.ownerDocument.body:n.body:Y(t)&&ct(t)?t:ae(t)}function Mt(n,t,e){var i;t===void 0&&(t=[]),e===void 0&&(e=!0);const s=ae(n),r=s===((i=n.ownerDocument)==null?void 0:i.body),o=D(s);if(r){const a=Ht(o);return t.concat(o,o.visualViewport||[],ct(s)?s:[],a&&e?Mt(a):[])}return t.concat(s,Mt(s,[],e))}function Ht(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function he(n){const t=k(n);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=Y(n),r=s?n.offsetWidth:e,o=s?n.offsetHeight:i,a=ut(e)!==r||ut(i)!==o;return a&&(e=r,i=o),{width:e,height:i,$:a}}function le(n){return X(n)?n:n.contextElement}function et(n){const t=le(n);if(!Y(t))return V(1);const e=t.getBoundingClientRect(),{width:i,height:s,$:r}=he(t);let o=(r?ut(e.width):e.width)/i,a=(r?ut(e.height):e.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const Ti=V(0);function ce(n){const t=D(n);return!Lt()||!t.visualViewport?Ti:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Si(n,t,e){return t===void 0&&(t=!1),!e||t&&e!==D(n)?!1:t}function dt(n,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const s=n.getBoundingClientRect(),r=le(n);let o=V(1);t&&(i?X(i)&&(o=et(i)):o=et(n));const a=Si(r,e,i)?ce(r):V(0);let l=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,f=s.width/o.x,d=s.height/o.y;if(r){const x=D(r),u=i&&X(i)?D(i):i;let g=x,w=Ht(g);for(;w&&i&&u!==g;){const p=et(w),y=w.getBoundingClientRect(),b=k(w),m=y.left+(w.clientLeft+parseFloat(b.paddingLeft))*p.x,E=y.top+(w.clientTop+parseFloat(b.paddingTop))*p.y;l*=p.x,c*=p.y,f*=p.x,d*=p.y,l+=m,c+=E,g=D(w),w=Ht(g)}}return wt({width:f,height:d,x:l,y:c})}function Ai(n){let{elements:t,rect:e,offsetParent:i,strategy:s}=n;const r=s==="fixed",o=B(i),a=t?yt(t.floating):!1;if(i===o||a&&r)return e;let l={scrollLeft:0,scrollTop:0},c=V(1);const f=V(0),d=Y(i);if((d||!d&&!r)&&((Q(i)!=="body"||ct(o))&&(l=mt(i)),Y(i))){const x=dt(i);c=et(i),f.x=x.x+i.clientLeft,f.y=x.y+i.clientTop}return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-l.scrollLeft*c.x+f.x,y:e.y*c.y-l.scrollTop*c.y+f.y}}function Li(n){return Array.from(n.getClientRects())}function Dt(n,t){const e=mt(n).scrollLeft;return t?t.left+e:dt(B(n)).left+e}function Mi(n){const t=B(n),e=mt(n),i=n.ownerDocument.body,s=Z(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),r=Z(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let o=-e.scrollLeft+Dt(n);const a=-e.scrollTop;return k(i).direction==="rtl"&&(o+=Z(t.clientWidth,i.clientWidth)-s),{width:s,height:r,x:o,y:a}}function Hi(n,t){const e=D(n),i=B(n),s=e.visualViewport;let r=i.clientWidth,o=i.clientHeight,a=0,l=0;if(s){r=s.width,o=s.height;const c=Lt();(!c||c&&t==="fixed")&&(a=s.offsetLeft,l=s.offsetTop)}return{width:r,height:o,x:a,y:l}}function Di(n,t){const e=dt(n,!0,t==="fixed"),i=e.top+n.clientTop,s=e.left+n.clientLeft,r=Y(n)?et(n):V(1),o=n.clientWidth*r.x,a=n.clientHeight*r.y,l=s*r.x,c=i*r.y;return{width:o,height:a,x:l,y:c}}function de(n,t,e){let i;if(t==="viewport")i=Hi(n,e);else if(t==="document")i=Mi(B(n));else if(X(t))i=Di(t,e);else{const s=ce(n);i={...t,x:t.x-s.x,y:t.y-s.y}}return wt(i)}function fe(n,t){const e=z(n);return e===t||!X(e)||tt(e)?!1:k(e).position==="fixed"||fe(e,t)}function Fi(n,t){const e=t.get(n);if(e)return e;let i=Mt(n,[],!1).filter(a=>X(a)&&Q(a)!=="body"),s=null;const r=k(n).position==="fixed";let o=r?z(n):n;for(;X(o)&&!tt(o);){const a=k(o),l=At(o);!l&&a.position==="fixed"&&(s=null),(r?!l&&!s:!l&&a.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||ct(o)&&!l&&fe(n,o))?i=i.filter(f=>f!==o):s=a,o=z(o)}return t.set(n,i),i}function Xi(n){let{element:t,boundary:e,rootBoundary:i,strategy:s}=n;const o=[...e==="clippingAncestors"?yt(t)?[]:Fi(t,this._c):[].concat(e),i],a=o[0],l=o.reduce((c,f)=>{const d=de(t,f,s);return c.top=Z(d.top,c.top),c.right=at(d.right,c.right),c.bottom=at(d.bottom,c.bottom),c.left=Z(d.left,c.left),c},de(t,a,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function ki(n){const{width:t,height:e}=he(n);return{width:t,height:e}}function Ni(n,t,e){const i=Y(t),s=B(t),r=e==="fixed",o=dt(n,!0,r,t);let a={scrollLeft:0,scrollTop:0};const l=V(0);if(i||!i&&!r)if((Q(t)!=="body"||ct(s))&&(a=mt(t)),i){const u=dt(t,!0,r,t);l.x=u.x+t.clientLeft,l.y=u.y+t.clientTop}else s&&(l.x=Dt(s));let c=0,f=0;if(s&&!i&&!r){const u=s.getBoundingClientRect();f=u.top+a.scrollTop,c=u.left+a.scrollLeft-Dt(s,u)}const d=o.left+a.scrollLeft-l.x-c,x=o.top+a.scrollTop-l.y-f;return{x:d,y:x,width:o.width,height:o.height}}function Ft(n){return k(n).position==="static"}function xe(n,t){if(!Y(n)||k(n).position==="fixed")return null;if(t)return t(n);let e=n.offsetParent;return B(n)===e&&(e=e.ownerDocument.body),e}function ue(n,t){const e=D(n);if(yt(n))return e;if(!Y(n)){let s=z(n);for(;s&&!tt(s);){if(X(s)&&!Ft(s))return s;s=z(s)}return e}let i=xe(n,t);for(;i&&Ii(i)&&Ft(i);)i=xe(i,t);return i&&tt(i)&&Ft(i)&&!At(i)?e:i||Oi(n)||e}const Yi=async function(n){const t=this.getOffsetParent||ue,e=this.getDimensions,i=await e(n.floating);return{reference:Ni(n.reference,await t(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Ki(n){return k(n).direction==="rtl"}const Bi={convertOffsetParentRelativeRectToViewportRelativeRect:Ai,getDocumentElement:B,getClippingRect:Xi,getOffsetParent:ue,getElementRects:Yi,getClientRects:Li,getDimensions:ki,getScale:et,isElement:X,isRTL:Ki},ge=Ri,we=_i,pe=Ci,Wi=bi,ye=(n,t,e)=>{const i=new Map,s={platform:Bi,...e},r={...s.platform,_c:i};return Ei(n,t,{...s,platform:r})};let Pi=class{constructor(t){h(this,"ctx");h(this,"enable",!1);h(this,"contentEl");h(this,"floatingEl");h(this,"arrowEl");this.ctx=t;const{TOOLTIP_BG_COLOR:e,TOOLTIP_TEXT_COLOR:i,TOOLTIP_ZINDEX:s,TOOLTIP_CUSTOM_STYLE:r,CSS_PREFIX:o}=this.ctx.config;this.contentEl=document.createElement("div"),this.arrowEl=document.createElement("div"),this.floatingEl=document.createElement("div"),this.floatingEl.className=`${o}-tooltip`,this.contentEl.className=`${o}-tooltip-content`,this.arrowEl.className=`${o}-tooltip-arrow`;const a={display:"none",position:"absolute",background:e,color:i,boxSizing:"border-box",zIndex:s,padding:"8px",borderRadius:"4px",fontSize:"12px",...r},l={position:"absolute",width:"10px",height:"10px",background:a.background,backgroundColor:a.backgroundColor,transform:"rotate(45deg)",zIndex:a.zIndex};Object.assign(this.arrowEl.style,l),Object.assign(this.floatingEl.style,a),this.floatingEl.appendChild(this.contentEl),this.floatingEl.appendChild(this.arrowEl),this.ctx.containerElement.appendChild(this.floatingEl),this.init()}init(){this.ctx.on("mousemove",t=>{if(!this.ctx.isTarget())return;const e=this.ctx.containerElement.getBoundingClientRect();e&&(t.clientX<e.x||t.clientX>e.x+e.width||t.clientY<e.y||t.clientY>e.y+e.height)&&this.hide()}),this.ctx.on("startEdit",()=>{this.hide()}),this.ctx.on("visibleCellHoverChange",t=>{(t.ellipsis||t.message)&&this.show(t)}),this.ctx.on("visibleCellMouseleave",()=>{this.hide()})}show(t){if(!t.overflowTooltipShow||this.ctx.mousedown)return;this.floatingEl.style.display="block";let e=t.getText();t.message&&(e=t.message);const i=this.ctx.containerElement.getBoundingClientRect();if(!i)return;this.enable=!0,this.contentEl.style.maxWidth=`${t.overflowTooltipMaxWidth||500}px`,this.contentEl.style.width="100%",this.contentEl.style.display="inline-block",this.contentEl.style.wordBreak="break-all",this.contentEl.style.lineHeight="1.5",this.contentEl.innerText=e;const s=t.drawX+i.x,r=t.drawY+i.y;ye({getBoundingClientRect(){return{width:t.visibleWidth,height:t.visibleHeight,x:s,y:r,left:s,right:s+t.visibleWidth,top:r,bottom:r+t.visibleHeight}}},this.floatingEl,{placement:t.overflowTooltipPlacement,middleware:[we(),pe(),ge(6),Wi({element:this.arrowEl})]}).then(a=>{const{x:l,y:c,placement:f,middlewareData:d}=a;if(Object.assign(this.floatingEl.style,{top:`${c}px`,left:`${l}px`}),d.arrow){const x=d.arrow;["left","left-start","left-end"].includes(f)?Object.assign(this.arrowEl.style,{top:`${x.y}px`,bottom:"",left:"",right:"-5px"}):["right","right-start","right-end"].includes(f)?Object.assign(this.arrowEl.style,{top:`${x.y}px`,bottom:"",left:"-5px",right:""}):["bottom","bottom-start","bottom-end"].includes(f)?Object.assign(this.arrowEl.style,{top:"-5px",bottom:"",left:`${x.x}px`,right:""}):["top","top-start","top-end"].includes(f)&&Object.assign(this.arrowEl.style,{top:"",bottom:"-5px",left:`${x.x}px`,right:""})}})}hide(){this.enable&&(this.enable=!1,this.floatingEl.style.display="none")}destroy(){this.contentEl.remove(),this.arrowEl.remove(),this.floatingEl.remove()}};class Vi{constructor(t){h(this,"editorEl");h(this,"inputEl");h(this,"enable",!1);h(this,"cellTarget",null);h(this,"ctx");h(this,"drawY",0);h(this,"drawX",0);this.ctx=t,this.initTextEditor(),this.init()}init(){this.ctx.on("onScroll",()=>{this.enable&&this.doneEdit()}),this.ctx.on("cellHeaderMousedown",()=>{this.enable&&this.doneEdit(),this.cellTarget=null}),this.ctx.on("keydown",t=>{const e=t.key,i=t.ctrlKey,s=t.altKey,r=t.shiftKey,o=t.metaKey;if(!(i||s||r||o||["Escape","Tab","Backspace","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown","Insert","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"].includes(e))){if(t.code==="Enter"&&!this.enable){t.preventDefault(),this.startEdit();return}this.startEdit()}}),this.ctx.on("adjustBoundaryPosition",t=>{this.cellTarget=t}),this.ctx.on("cellClick",t=>{var e,i;this.ctx.adjustPositioning||(t.rowKey===((e=this.cellTarget)==null?void 0:e.rowKey)&&t.key===((i=this.cellTarget)==null?void 0:i.key)?this.startEdit():(this.doneEdit(),this.cellTarget=t,this.ctx.config.ENABLE_EDIT_SINGLE_CLICK&&this.startEdit()))})}initTextEditor(){this.inputEl=document.createElement("textarea"),this.inputEl.setAttribute("rows","1"),this.inputEl.addEventListener("keydown",t=>{if(!t.isComposing&&this.enable){if(t.stopPropagation(),(t.altKey||t.metaKey)&&t.code==="Enter"){t.preventDefault();const e=this.inputEl.selectionStart,i=this.inputEl.value.substring(0,e),s=this.inputEl.value.substring(e);this.inputEl.value=i+`
16
- `+s,this.inputEl.selectionStart=this.inputEl.selectionEnd=e+1,this.autoSize();return}(t.code==="Escape"||t.code==="Enter")&&(t.preventDefault(),this.inputEl.blur())}}),this.inputEl.addEventListener("input",this.autoSize.bind(this)),this.inputEl.addEventListener("blur",()=>{this.doneEdit()}),this.editorEl=this.ctx.editorElement,this.inputEl.className="e-virt-table-editor-textarea",this.editorEl.appendChild(this.inputEl),this.ctx.containerElement.appendChild(this.editorEl)}autoSize(){this.inputEl.style.height="auto";let t=this.inputEl.scrollHeight,e=this.ctx.body.visibleHeight;t>e&&(t=e);const{stageHeight:i,footer:s,header:r,config:{SCROLLER_TRACK_SIZE:o}}=this.ctx,a=i-s.height-o;this.editorEl.style.bottom="auto",(this.drawY+t>a||this.drawY<r.height)&&(this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top="auto",this.editorEl.style.bottom=`${i-a}px`),this.inputEl.style.height=`${t}px`}startEditByInput(t){const e=t.getValue(),{width:i,editorType:s}=t,r=t.getDrawX();let o=t.getDrawY();this.drawX=r,this.drawY=o;let{height:a}=t;const{config:{CELL_PADDING:l},header:c}=this.ctx;let f=this.ctx.body.visibleHeight;if(a>f&&(a=f),this.editorEl.style.left=`${r-1}px`,this.editorEl.style.top=`${o-1}px`,this.editorEl.style.bottom="auto",this.editorEl.style.maxHeight=`${f}px`,s==="text"){this.inputEl.style.display="block",this.inputEl.style.minWidth=`${i-1}px`,this.inputEl.style.minHeight=`${a-1}px`,this.inputEl.style.maxHeight=`${f}px`,this.inputEl.style.width=`${i-1}px`,this.inputEl.style.height="auto",this.inputEl.style.padding=`${l}px`,e!==null&&(this.inputEl.value=e),this.inputEl.focus();const d=this.inputEl.value.length;this.inputEl.setSelectionRange(d,d)}else this.inputEl.style.display="none";(this.inputEl.scrollHeight>a||o<c.height)&&this.autoSize()}doneEditByInput(){if(this.cellTarget&&(this.editorEl.style.left="-10000px",this.editorEl.style.top="-10000px",this.editorEl.style.bottom="atuo",this.cellTarget.editorType==="text")){const{rowKey:t,key:e}=this.cellTarget,i=this.cellTarget.getValue(),s=this.inputEl.value;s!==i&&!(s===""&&i===null)&&this.ctx.database.setItemValue(t,e,s,!0,!0,!0),this.inputEl.value=""}}startEdit(){const{ENABLE_EDIT_CLICK_SELECTOR:t}=this.ctx.config;if(!t)return;const e=this.ctx.focusCell;if(!e||["index","index-selection","selection"].includes(e.type)||this.enable)return;const{rowKey:i,key:s}=e,r=this.ctx.database.getReadonly(i,s);e&&!r&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=e,this.startEditByInput(this.cellTarget),this.ctx.emit("startEdit",this.cellTarget))}editCell(t,e){const i=this.ctx.body.renderRows.find(c=>c.rowIndex===t);if(!i)return;const s=i.cells.find(c=>c.colIndex===e);if(!s)return;this.ctx.emit("setSelectorCell",s);const r=this.ctx.focusCell;if(!r||["index","index-selection","selection"].includes(r.type)||this.enable)return;const{rowKey:o,key:a}=r,l=this.ctx.database.getReadonly(o,a);r&&!l&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=r,this.startEditByInput(this.cellTarget),this.ctx.emit("startEdit",this.cellTarget))}doneEdit(){this.enable&&(this.doneEditByInput(),this.ctx.emit("doneEdit",this.cellTarget),this.enable=!1,this.ctx.stageElement.focus(),this.ctx.editing=!1,this.ctx.emit("draw"))}destroy(){var t;(t=this.editorEl)==null||t.remove()}}class zi{constructor(t){h(this,"ctx");h(this,"emptyEl");this.ctx=t;const{EMPTY_TEXT:e,EMPTY_CUSTOM:i,EMPTY_CUSTOM_STYLE:s,CSS_PREFIX:r}=this.ctx.config;this.emptyEl=document.createElement("div"),this.emptyEl.className=`${r}-empty`,this.emptyEl.style.display="none",this.emptyEl.innerText=e,this.ctx.containerElement.appendChild(this.emptyEl),this.ctx.on("emptyChange",({type:o,headerHeight:a,bodyHeight:l,footerHeight:c})=>{if(i)return;const f=a+(l+c)/2,d={display:o==="empty"?"block":"none",position:"absolute",fontSize:"14px",color:"#666",left:"50%",top:`${f}px`,transform:"translate(-50%, -50%)",...s};Object.assign(this.emptyEl.style,d)})}destroy(){this.emptyEl.remove()}}class $i{constructor(t){h(this,"ctx");this.ctx=t}draw(){const t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){this.ctx.emit("overlayerChange",{style:{},views:[]})}getContainer(){const t=this.getHeader(),e=this.getBody(),i=this.getFooter();let s=[t,e,i];const{FOOTER_FIXED:r}=this.ctx.config;return r||(s=[t,e]),{views:s}}getHeader(){const{fixedLeftWidth:t,fixedRightWidth:e,config:{SCROLLER_TRACK_SIZE:i,CSS_PREFIX:s}}=this.ctx,{visibleWidth:r,visibleHeight:o,renderCellHeaders:a}=this.ctx.header;let l=[],c=[],f=[];a.forEach(p=>{p.render&&(p.fixed==="left"?c.push(p):p.fixed==="right"?f.push(p):l.push(p))});const d=e-i,x={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${o}px`},cells:c},u={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${r-t-d+1}px`,height:`${o}px`},cells:l},g={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${d+1}px`,height:`${o}px`},cells:f};return{type:"header",class:`${s}-overlayer-header`,style:{position:"relative",overflow:"hidden",width:`${r}px`,height:`${o}px`},views:[x,u,g]}}getBody(){const t=[],e=[],i=[];let s=this.ctx.body.renderRows;this.ctx.config.FOOTER_FIXED||(s=s.concat(this.ctx.footer.renderRows)),s.forEach(p=>{p.cells.forEach(y=>{y.cellType==="footer"&&(y.render=y.renderFooter),y.render&&(y.fixed==="left"?e.push(y):y.fixed==="right"?i.push(y):t.push(y))})});const{fixedLeftWidth:r,fixedRightWidth:o,config:{SCROLLER_TRACK_SIZE:a,CSS_PREFIX:l}}=this.ctx,{visibleWidth:c,visibleHeight:f}=this.ctx.body,d=o-a,x={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${r}px`,height:`${f}px`},cells:e},u={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${r-.5}px`,overflow:"hidden",width:`${c-r-d}px`,height:`${f}px`},cells:t},g={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${d}px`,height:`${f}px`},cells:i};return{type:"body",class:`${l}-overlayer-body`,style:{position:"relative",overflow:"hidden",width:`${c}px`,height:`${f}px`},views:[x,u,g]}}getFooter(){const t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(w=>{w.cells.forEach(p=>{p.cellType==="footer"&&p.renderFooter&&(p.render=p.renderFooter,p.fixed==="left"?e.push(p):p.fixed==="right"?i.push(p):t.push(p))})});const{fixedLeftWidth:s,fixedRightWidth:r,config:{SCROLLER_TRACK_SIZE:o,CSS_PREFIX:a}}=this.ctx,{visibleWidth:l,visibleHeight:c}=this.ctx.footer,f=r-o,d={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${s}px`,height:`${c}px`},cells:e},x={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${s-.5}px`,overflow:"hidden",width:`${l-s-f}px`,height:`${c}px`},cells:t},u={key:"right",style:{position:"absolute",top:`${.5}px`,right:`${.5}px`,overflow:"hidden",width:`${f}px`,height:`${c}px`},cells:i};return{type:"footer",class:`${a}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${l}px`,height:`${c}px`},views:[d,x,u]}}}class qi{constructor(t){h(this,"ctx");h(this,"contextMenuEl");this.ctx=t,this.contextMenuEl=document.createElement("div"),this.createContextMenu(),this.init()}init(){this.ctx.on("cellContextMenuClick",(t,e)=>{if(!this.ctx.config.ENABLE_CONTEXT_MENU)return;e.preventDefault();const{xArr:i,yArr:s}=this.ctx.selector,[r,o]=i,[a,l]=s,{rowIndex:c,colIndex:f}=t;c>=a&&c<=l&&f>=r&&f<=o||this.ctx.emit("setSelectorCell",t,e);const x={getBoundingClientRect:()=>({width:0,height:0,top:e.clientY,left:e.clientX,right:e.clientX,bottom:e.clientY,x:e.clientX,y:e.clientY}),contextElement:document.body};ye(x,this.contextMenuEl,{placement:"right-start",middleware:[ge(),we(),pe()]}).then(({x:u,y:g})=>{this.show(u,g)})}),this.ctx.on("click",this.hide.bind(this)),this.ctx.on("onScroll",this.hide.bind(this)),this.ctx.on("resize",this.hide.bind(this))}createContextMenu(){this.contextMenuEl.replaceChildren(),this.contextMenuEl.className="e-virt-table-context-menu",this.ctx.containerElement.appendChild(this.contextMenuEl);const{CONTEXT_MENU:t}=this.ctx.config;this.createContextMenuItems(t,e=>{switch(e.value){case"copy":this.ctx.emit("contextMenuCopy");break;case"paste":this.ctx.emit("contextMenuPaste");break;case"cut":this.ctx.emit("contextMenuCut");break;case"clearSelected":this.ctx.emit("contextMenuClearSelected");break}this.hide()})}createContextMenuItems(t,e){t.forEach(i=>{const s=document.createElement("div");s.className="e-virt-table-context-menu-item",s.innerText=i.label,i.event?s.onclick=()=>{i.event&&i.event(),e(i)}:s.onclick=()=>e(i),this.contextMenuEl.appendChild(s)})}show(t,e){Object.assign(this.contextMenuEl.style,{left:`${t}px`,top:`${e}px`})}hide(){Object.assign(this.contextMenuEl.style,{left:"-99999px",top:"-99999px"})}updated(){this.createContextMenu()}destroy(){this.contextMenuEl.remove()}}class Gi{constructor(t,e){h(this,"options");h(this,"scroller");h(this,"header");h(this,"body");h(this,"footer");h(this,"selector");h(this,"autofill");h(this,"tooltip");h(this,"editor");h(this,"empty");h(this,"overlayer");h(this,"contextMenu");h(this,"ctx");this.options=e;const{overlayerElement:i,editorElement:s}=e,r=this.createContainer(t,i,s);this.ctx=new ni(r,this.options),this.header=new hi(this.ctx),this.body=new li(this.ctx),this.footer=new ci(this.ctx),this.scroller=new ai(this.ctx),this.selector=new di(this.ctx),this.autofill=new fi(this.ctx),this.tooltip=new Pi(this.ctx),this.empty=new zi(this.ctx),this.editor=new Vi(this.ctx),this.overlayer=new $i(this.ctx),this.contextMenu=new qi(this.ctx),this.ctx.on("draw",()=>{this.draw()}),this.ctx.on("drawView",()=>{this.draw(!0)}),this.draw()}createContainer(t,e,i){t.className="e-virt-table-container";const s=document.createElement("div"),r=document.createElement("canvas"),o=e||document.createElement("div");s.className="e-virt-table-stage",r.className="e-virt-table-canvas",o.className="e-virt-table-overlayer";const a=i||document.createElement("div");return a.className="e-virt-table-editor",s.appendChild(r),s.appendChild(o),t.appendChild(s),{containerElement:t,stageElement:s,canvasElement:r,overlayerElement:o,editorElement:a}}draw(t=!1){requestAnimationFrame(()=>{this.header.update(),this.footer.update(),this.body.update(),this.ctx.paint.clear(),this.body.draw(),this.footer.draw(),this.header.draw(),this.scroller.draw(),t||this.overlayer.draw()})}loadConfig(t){this.ctx.config.init(t),this.ctx.database.init(),this.header.init(),this.contextMenu.updated(),this.ctx.emit("draw")}loadColumns(t){this.editor.doneEdit(),this.ctx.database.setColumns(t),this.header.init(),this.ctx.emit("draw")}loadData(t){this.editor.doneEdit(),this.ctx.database.setData(t),this.header.init(),this.ctx.emit("draw")}loadFooterData(t){this.ctx.database.setFooterData(t),this.ctx.emit("draw")}setLoading(t){this.ctx.database.setLoading(t)}on(t,e){this.ctx.on(t,e)}off(t,e){this.ctx.off(t,e)}filterMethod(t){this.ctx.setScrollY(0),this.ctx.setScrollX(0),this.ctx.database.init(),this.ctx.database.setFilterMethod(t),this.ctx.emit("draw")}editCell(t,e){this.editor.editCell(t,e)}setItemValue(t,e,i,s=!0,r=!0,o=!1){this.ctx.database.setItemValue(t,e,i,s,r,o)}batchSetItemValue(t,e=!0){this.ctx.database.batchSetItemValue(t,e)}setItemValueByEditor(t,e,i,s=!0,r=!0){this.ctx.database.setItemValue(t,e,i,s,r,!0),this.editor.doneEdit()}doLayout(){this.ctx.emit("draw")}getChangedData(){return this.ctx.database.getChangedData()}getChangedRows(){return this.ctx.database.getChangedRows()}clearValidate(){this.ctx.database.clearValidate(),this.ctx.emit("draw")}async validate(t=!0){return this.editor.doneEdit(),new Promise(async(e,i)=>{try{const s=await this.getValidations();e(s)}catch(s){if(t&&Array.isArray(s)&&s.length){const[r]=s;if(Array.isArray(r)&&r.length){const[o]=r,{rowKey:a,key:l}=o;this.scrollToRowkey(a),this.scrollToColkey(l)}}i(s)}})}setValidations(t){if(t.forEach(e=>{const{rowIndex:i,key:s,message:r}=e;this.ctx.database.setValidationErrorByRowIndex(i,s,r)}),t&&Array.isArray(t)&&t.length){const[e]=t;if(e&&e.rowIndex>=0&&e.key){const{rowIndex:i,key:s}=e;this.scrollToRowIndex(i),this.scrollToColkey(s)}}}getValidations(){return new Promise(async(t,e)=>{const i=this.ctx.database.getAllRowsData(),s=this.ctx.header.leafCellHeaders;let r=[];for(let o=0;o<i.length;o++)for(let a=0;a<s.length;a++){const l=this.ctx.database.getRowKeyByItem(i[o]),f=s[a].key,d=await this.ctx.database.getValidator(l,f);Array.isArray(d)&&d.length&&r.push(d)}r.length?(e(r),this.ctx.emit("draw")):(t([]),this.ctx.emit("draw"))})}hasValidationError(){return this.ctx.database.hasValidationError()}scrollTo(t,e){this.scrollXTo(t),this.scrollYTo(e)}scrollXTo(t){this.ctx.setScrollX(t)}scrollToColkey(t){this.scroller.scrollToColkey(t)}scrollToRowkey(t){this.scroller.scrollToRowKey(t)}scrollToColIndex(t){this.scroller.scrollToColIndex(t)}scrollToRowIndex(t){this.scroller.scrollToRowIndex(t)}scrollYTo(t){this.ctx.setScrollY(t)}setExpandRowKeys(t,e=!0){this.ctx.database.setExpandRowKeys(t,e)}clearSelection(){this.ctx.database.clearSelection(),this.ctx.emit("draw")}toggleRowSelection(t){const e=this.ctx.database.getRowKeyByItem(t);this.ctx.database.toggleRowSelection(e),this.ctx.emit("draw")}setSelectionByRows(t,e=!0){t.forEach(i=>{const s=this.ctx.database.getRowKeyByItem(i);this.ctx.database.setRowSelection(s,e)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}setSelectionByRowKeys(t,e=!0){t.forEach(i=>{this.ctx.database.setRowSelection(i,e)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}toggleAllSelection(){this.ctx.database.toggleAllSelection(),this.ctx.emit("draw")}toggleRowExpand(t,e){this.ctx.database.expandItem(t,e),this.ctx.emit("draw")}toggleExpandAll(t){this.ctx.database.expandAll(t),this.ctx.emit("draw")}getSelectionRows(){return this.ctx.database.getSelectionRows()}getPositionForRowIndex(t){return this.ctx.database.getPositionForRowIndex(t)}getCellValue(t,e){return this.ctx.database.getItemValue(t,e)}getCellValueByIndex(t,e){return this.ctx.database.getItemValueForRowIndexAndColIndex(t,e)}destroy(){this.overlayer.destroy(),this.empty.destroy(),this.editor.destroy(),this.tooltip.destroy(),this.selector.destroy(),this.autofill.destroy(),this.contextMenu.destroy(),this.ctx.destroy(),this.ctx.containerElement.remove()}}return Gi});
15
+ `)}return r}class Qe{constructor(t,e){l(this,"loading",!1);l(this,"ctx");l(this,"data");l(this,"columns");l(this,"footerData",[]);l(this,"rowKeyMap",new Map);l(this,"colIndexKeyMap",new Map);l(this,"headerMap",new Map);l(this,"rowIndexRowKeyMap",new Map);l(this,"checkboxKeyMap",new Map);l(this,"originalDataMap",new Map);l(this,"changedDataMap",new Map);l(this,"validationErrorMap",new Map);l(this,"itemRowKeyMap",new WeakMap);l(this,"bufferData",[]);l(this,"sumHeight",0);l(this,"filterMethod");l(this,"positions",[]);this.ctx=t;const{data:i=[],columns:s=[],footerData:r=[]}=e;this.data=i,this.footerData=r,this.columns=s,this.setLoading(!0),this.init()}init(){this.clearBufferData(),this.rowKeyMap.clear(),this.checkboxKeyMap.clear(),this.colIndexKeyMap.clear(),this.rowIndexRowKeyMap.clear(),this.originalDataMap.clear(),this.changedDataMap.clear(),this.validationErrorMap.clear(),this.itemRowKeyMap=new WeakMap,this.initData(this.data)}clearBufferData(){this.bufferData=[]}initData(t,e=0){t.forEach((i,s)=>{let r=i._hasChildren||!1;Array.isArray(i.children)&&i.children.length&&(r=!0,this.initData(i.children,e+1));const{ROW_KEY:o="",DEFAULT_EXPAND_ALL:a,CELL_HEIGHT:h,SELECTABLE_METHOD:c,CHECKBOX_KEY:f}=this.ctx.config,d=i[o],x=d!=null?`${d}`:Pt();this.itemRowKeyMap.set(i,x);const u=i._height||h,g=i._readonly;let w=!0;if(typeof c=="function"&&(w=c),f){const p=i[f];if(this.checkboxKeyMap.has(p)){const y=this.checkboxKeyMap.get(p);y.push(x),this.checkboxKeyMap.set(p,y)}else this.checkboxKeyMap.set(p,[x])}this.rowKeyMap.set(x,{readonly:g,index:s,rowIndex:s,level:e,height:u,check:!1,selectable:w,expand:a,expandLazy:!1,hasChildren:r,expandLoading:!1,item:i})})}setRowHeight(t,e){const i=this.rowIndexRowKeyMap.get(t),s=this.rowKeyMap.get(i);s.height=e,s.item._height=e,this.clearBufferData()}getAllRowsData(){let t=[];const e=i=>{i.forEach(s=>{t.push(s),Array.isArray(s.children)&&e(s.children)})};return e(this.data),t}filterColumns(t){return t.reduce((e,i)=>{if(!(typeof i.hide=="function"?i.hide():i.hide)){const r={...i};r.children&&Array.isArray(r.children)&&(r.children=this.filterColumns(r.children)),e.push(r)}return e},[])}getColumns(){return this.filterColumns(this.columns)}setColumns(t){this.columns=t,this.clearBufferData()}setData(t){this.data=t,this.columns.length&&this.init()}getData(){if(this.bufferData.length>0)return{data:this.bufferData,sumHeight:this.sumHeight,positions:this.positions};let t=[],e=0;this.sumHeight=0,this.positions=[];const i=r=>{r.forEach(o=>{t.push(o);const a=this.itemRowKeyMap.get(o),{expand:h,hasChildren:c,height:f}=this.rowKeyMap.get(a),d=this.sumHeight;this.sumHeight+=f,this.rowIndexRowKeyMap.set(e,a),this.positions.push({top:d,height:f,bottom:this.sumHeight}),e+=1,h&&c&&i(o.children)})};this.rowIndexRowKeyMap.clear();let s=this.data;return typeof this.filterMethod=="function"&&(s=this.filterMethod(s)),i(s),this.bufferData=t,{data:t,sumHeight:this.sumHeight,positions:this.positions}}setFooterData(t){this.footerData=t}getFooterData(){return this.footerData}setFilterMethod(t){this.filterMethod=t}clearFilterMethod(){this.filterMethod=void 0}expandItem(t,e=!1){const i=this.rowKeyMap.get(t);i.expand=e,this.clearBufferData(),this.ctx.emit("draw")}setExpandRowKeys(t,e=!0){t.forEach(i=>{const s=this.rowKeyMap.get(i);s.expand=e}),this.clearBufferData(),this.ctx.emit("draw")}getExpandRowKeys(){let t=[];return this.rowKeyMap.forEach((e,i)=>{e.expand&&t.push(i)}),t}expandAll(t){this.rowKeyMap.forEach(e=>{e.expand=t}),this.clearBufferData(),this.ctx.emit("draw")}expandLoading(t,e=!1){const i=this.rowKeyMap.get(t);i.expandLoading=e,this.clearBufferData(),this.ctx.emit("draw")}setExpandChildren(t,e){const i=this.rowKeyMap.get(t);i.expand=!0,i.expandLazy=!0,i.item.children=e,this.initData(i.item.children,i.level+1),this.clearBufferData()}getIsExpandLoading(t){return this.rowKeyMap.get(t).expandLoading}getIsExpandLazy(t){return this.rowKeyMap.get(t).expandLazy}getIsExpand(t){return this.rowKeyMap.get(t).expand}getRowForRowKey(t){return this.rowKeyMap.get(t)}getRowKeyForRowIndex(t){return this.rowIndexRowKeyMap.get(t)}getRowKeyByItem(t){return this.itemRowKeyMap.get(t)}getRowIndexForRowKey(t){return this.rowKeyMap.get(t).index}getItemValueForRowIndexAndColIndex(t,e){if(!(this.rowIndexRowKeyMap.has(t)&&this.colIndexKeyMap.get(e)))return null;const s=this.rowIndexRowKeyMap.get(t),r=this.colIndexKeyMap.get(e);return{rowKey:s,key:r,value:this.getItemValue(s,r)}}getItemValue(t,e){const i=this.rowKeyMap.get(t);return i&&i.item?i.item[e]===void 0?null:i.item[e]:null}async batchSetItemValue(t,e=!1){let i=[];const s=new Set;let r=t;const{BEFORE_VALUE_CHANGE_METHOD:o}=this.ctx.config;if(typeof o=="function"){const f=o,d=t.map(u=>({rowKey:u.rowKey,key:u.key,value:u.value,oldValue:this.getItemValue(u.rowKey,u.key),row:this.ctx.database.getRowDataItemForRowKey(u.rowKey)}));r=await f(d)}r.forEach(f=>{const{value:d,rowKey:x,key:u}=f,g=this.getItemValue(x,u);this.setItemValue(x,u,d),s.add(x),i.push({rowKey:x,key:u,oldValue:g,newValue:d})});let a=[];const h=i.map(f=>{const d=this.ctx.database.getRowDataItemForRowKey(f.rowKey);return{rowKey:f.rowKey,key:f.key,value:f.newValue,row:d}});s.forEach(f=>{a.push(this.ctx.database.getRowDataItemForRowKey(f))});const c=h.map(({rowKey:f,key:d})=>this.getValidator(f,d));Promise.all(c).then(()=>{this.validationErrorMap.size===0&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData())}),this.ctx.emit("change",h,a),e&&this.ctx.history.pushState({changeList:i,scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,type:"multiple"}),this.ctx.emit("draw")}async setItemValue(t,e,i,s=!1,r=!1,o=!1){if(!this.rowKeyMap.has(t))return{};const{item:a}=this.rowKeyMap.get(t);let h=a[e];if(this.ctx.database.getReadonly(t,e))return{oldValue:h,newValue:h};a[e]!==null&&typeof a[e]=="object"&&(h=JSON.parse(JSON.stringify(a[e])));const c=`${t}​_${e}`;this.originalDataMap.has(c)||this.originalDataMap.set(c,h);const f=this.originalDataMap.get(c);let d=i;if(o){const{BEFORE_VALUE_CHANGE_METHOD:x}=this.ctx.config;if(typeof x=="function"){const p=await x([{rowKey:t,key:e,value:i,oldValue:a[e],row:this.ctx.database.getRowDataItemForRowKey(t)}]);p&&p.length&&(d=p[0].value)}this.changedDataMap.set(c,d),a[e]=d;const u=this.ctx.database.getRowDataItemForRowKey(t),g={rowKey:t,key:e,value:d,row:u};this.getValidator(t,e).then(()=>{this.validationErrorMap.size===0&&this.changedDataMap.size>0&&this.ctx.emit("validateChangedData",this.getChangedData())}),this.ctx.emit("change",[g],[u]),this.ctx.emit("editChange",{rowKey:t,key:e,oldValue:h,value:d,originalValue:f,row:u})}else this.changedDataMap.set(c,d),a[e]=d;return this.ctx.hasEvent("iterationChange")&&this.ctx.emit("iterationChange",{rowKey:t,key:e,oldValue:h,value:d,originalValue:this.originalDataMap.get(c),row:this.ctx.database.getRowDataItemForRowKey(t)}),s&&this.ctx.history.pushState({type:"single",scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,changeList:[{rowKey:t,key:e,oldValue:h,newValue:d}]}),r&&this.ctx.emit("draw"),{oldValue:h,newValue:d}}getRowDataItemForRowKey(t){if(!this.rowKeyMap.has(t))return{};const{item:e}=this.rowKeyMap.get(t);return e}setRowSelectionByCheckboxKey(t,e){const{CHECKBOX_KEY:i}=this.ctx.config;if(i){if(!this.rowKeyMap.has(t))return!1;const{item:s}=this.rowKeyMap.get(t),r=s[i];this.checkboxKeyMap.has(r)&&this.checkboxKeyMap.get(r).forEach(a=>{const h=this.rowKeyMap.get(a);h.check=e})}}toggleRowSelection(t){const e=this.rowKeyMap.get(t);e.check=!e.check,this.setRowSelectionByCheckboxKey(t,e.check),this.ctx.emit("toggleRowSelection",e);const i=this.getSelectionRows();this.ctx.emit("selectionChange",i),this.ctx.emit("draw")}setRowSelection(t,e){const i=this.rowKeyMap.get(t);i.check=e,this.setRowSelectionByCheckboxKey(t,i.check);const s=this.getSelectionRows();this.ctx.emit("setRowSelection",s),this.ctx.emit("draw")}getSelectionRows(){let t=[];return this.rowKeyMap.forEach(e=>{e.check&&t.push(e.item)}),t}getRowSelection(t){const{check:e}=this.rowKeyMap.get(t);return e}getRowSelectable(t){const{selectable:e,item:i,rowIndex:s}=this.rowKeyMap.get(t);return typeof e=="function"?e({row:i,rowIndex:s}):e}toggleAllSelection(){this.rowKeyMap.forEach(e=>{const i=e.selectable;typeof i=="function"?i({row:e.item,rowIndex:e.rowIndex})&&(e.check=!0):i&&(e.check=!0)});const t=this.getSelectionRows();this.ctx.emit("toggleAllSelection",t),this.ctx.emit("selectionChange",t),this.ctx.emit("draw")}clearSelection(){this.rowKeyMap.forEach(e=>{const i=e.selectable;typeof i=="function"?i({row:e.item,rowIndex:e.rowIndex})&&(e.check=!1):i&&(e.check=!1)});const t=this.getSelectionRows();this.ctx.emit("clearSelection"),this.ctx.emit("selectionChange",t),this.ctx.emit("draw")}getCheckedState(){let t=0,e=0;this.rowKeyMap.forEach(o=>{o.check&&(t+=1);const a=o.selectable;typeof a=="function"?a({row:o.item,rowIndex:o.rowIndex})&&(e+=1):a&&(e+=1)});const i=e&&e>t&&t>0;return{check:e&&e===t,indeterminate:i,selectable:e!==0}}updateColIndexKeyMap(t=[]){this.colIndexKeyMap.clear(),t.forEach(e=>{this.colIndexKeyMap.set(e.colIndex,e.key)})}getChangedData(){let t=[];return this.changedDataMap.forEach((e,i)=>{const s=this.originalDataMap.get(i),r=i.split("​_")[0],o=i.split("​_")[1];s!==e&&t.push({rowKey:r,colKey:o,originalValue:s,row:this.ctx.database.getRowDataItemForRowKey(r),value:e})}),t}getChangedRows(){const t=new Set;this.changedDataMap.forEach((i,s)=>{const r=this.originalDataMap.get(s),o=s.split("​_")[0];r!==i&&t.add(o)});let e=[];return t.forEach(i=>{e.push(this.ctx.database.getRowDataItemForRowKey(i))}),e}isHasChangedData(t,e){const i=`${t}​_${e}`;if(!this.changedDataMap.has(i))return!1;const s=this.originalDataMap.get(i),r=this.changedDataMap.get(i);return s!==r}getPositionForRowIndex(t){return t<this.positions.length?this.positions[t]:{height:0,top:0,bottom:0}}setHeader(t,e){return t?(this.headerMap.set(t,e),!0):!1}getReadonly(t,e){const i=this.rowKeyMap.get(t),s=this.headerMap.get(e),r=i==null?void 0:i.readonly,o=s==null?void 0:s.readonly,{BODY_CELL_READONLY_METHOD:a}=this.ctx.config;if(typeof a=="function"){const c=a({row:i.item,rowIndex:i.rowIndex,colIndex:s.colIndex,column:s.column,value:this.getItemValue(t,e)});if(c!==void 0)return c}return o||r}clearValidate(){this.validationErrorMap.clear()}hasValidationError(){return this.validationErrorMap.size!==0}getValidator(t,e){return new Promise(i=>{const s=this.rowKeyMap.get(t),r=this.headerMap.get(e),{BODY_CELL_RULES_METHOD:o}=this.ctx.config,a=r.column;let h=a.rules;if(typeof o=="function"){const f=o({row:s.item,rowIndex:s.rowIndex,colIndex:r.colIndex,column:a,value:this.getItemValue(t,e)});f&&(h=f)}if(h){let c={},f={};if(f[e]=this.getItemValue(t,e),Array.isArray(h)&&h.length){const x=h.map(u=>({...u,row:s.item,column:a,rowIndex:s.rowIndex,colIndex:r.colIndex}));c[e]=x}else c[e]={...h,row:s.item,column:a,rowIndex:s.rowIndex,colIndex:r.colIndex};new nt(c).validate(f).then(()=>{this.clearValidationError(t,e),i([])}).catch(({errors:x})=>{const u=x.map(g=>({...g,column:a,key:e,row:s.item,rowKey:t}));this.setValidationError(t,e,u),i(u)})}else i([])})}getHeightByRowIndexRowSpan(t,e){let i=0;for(let s=0;s<e;s++){const r=this.positions[t+s];r&&(i+=r.height)}return i}setLoading(t){this.loading=t,this.ctx.emit("loadingChange",t)}getLoading(){return this.loading}setValidationErrorByRowIndex(t,e,i){const r=`${this.rowIndexRowKeyMap.get(t)}​_${e}`,o=[{message:i}];this.validationErrorMap.set(r,o)}setValidationError(t,e,i){const s=`${t}​_${e}`;this.validationErrorMap.set(s,i)}clearValidationError(t,e){const i=`${t}​_${e}`;this.validationErrorMap.has(i)&&this.validationErrorMap.delete(i)}getValidationError(t,e){const i=`${t}​_${e}`;return this.validationErrorMap.get(i)||[]}}class ti{constructor(t){l(this,"ctx");l(this,"history",[]);l(this,"historyIndex",-1);this.ctx=t,this.init()}init(){this.ctx.on("keydown",t=>{if(t.ctrlKey&&!t.shiftKey&&t.code==="KeyZ"||t.metaKey&&!t.shiftKey&&t.code==="KeyZ"){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.backState();return}if(t.ctrlKey&&t.code==="KeyY"||t.ctrlKey&&t.shiftKey&&t.code==="KeyZ"||t.metaKey&&t.shiftKey&&t.code==="KeyZ"){t.preventDefault(),this.ctx.clearSelector(),this.ctx.clearAutofill(),this.forwardState();return}})}pushState(t){const{HISTORY_NUM:e=0,ENABLE_HISTORY:i}=this.ctx.config;i&&(this.history.push(t),this.history.length>e&&this.history.splice(0,1),this.historyIndex=this.history.length-1)}backState(){if(this.historyIndex>=0){const{changeList:t,scrollX:e,scrollY:i}=this.history[this.historyIndex],s=t.map(r=>({rowKey:r.rowKey,key:r.key,value:r.oldValue,row:{}}));this.ctx.setScroll(e,i),this.ctx.database.batchSetItemValue(s,!1),this.historyIndex-=1}}forwardState(){if(this.historyIndex<this.history.length-1){this.historyIndex+=1;const{changeList:t}=this.history[this.historyIndex],e=t.map(i=>({rowKey:i.rowKey,key:i.key,value:i.newValue,row:{}}));this.ctx.database.batchSetItemValue(e,!1)}}clear(){this.history=[],this.historyIndex=-1}}class ei{constructor(t){l(this,"eventTasks",new Map);l(this,"ctx");this.ctx=t,this.init()}init(){this.bind(window,"resize",this.handleResize.bind(this)),this.bind(window,"mouseup",this.handleMouseUp.bind(this)),this.bind(window,"mousemove",this.handleMousemove.bind(this)),this.bind(this.ctx.stageElement,"click",this.handleClick.bind(this)),this.bind(window,"keydown",this.handleKeydown.bind(this)),this.bind(this.ctx.stageElement,"wheel",this.handleWheel.bind(this)),this.bind(this.ctx.stageElement,"contextmenu",this.handleContextMenu.bind(this)),this.bind(this.ctx.stageElement,"mousedown",this.handleMouseDown.bind(this)),this.bind(this.ctx.stageElement,"mouseenter",this.handleMouseEnter.bind(this)),this.bind(this.ctx.stageElement,"mouseleave",this.handleMouseLeave.bind(this)),this.bind(this.ctx.stageElement,"dblclick",this.handleDblclick.bind(this))}destroy(){this.eventTasks.forEach((t,e)=>{this.unbind(window,e,t)}),this.eventTasks.clear()}handleResize(t){this.ctx.emit("resetHeader",t),this.ctx.emit("resize",t)}handleMouseDown(t){t.button===0&&(this.ctx.mousedown=!0),this.ctx.emit("mousedown",t)}handleMousemove(t){this.ctx.emit("mousemove",t)}handleMouseUp(t){t.button===0&&(this.ctx.mousedown=!1),this.ctx.emit("mouseup",t)}handleClick(t){this.ctx.emit("click",t)}handleKeydown(t){const{ENABLE_KEYBOARD:e}=this.ctx.config;e&&this.ctx.isTarget()&&this.ctx.emit("keydown",t)}handleWheel(t){this.ctx.emit("wheel",t)}handleContextMenu(t){this.ctx.emit("contextMenu",t)}handleMouseEnter(t){this.ctx.isInsideTargetContainer=!0,this.ctx.emit("mouseenter",t)}handleMouseLeave(t){this.ctx.editing||(this.ctx.isInsideTargetContainer=!1,this.ctx.emit("mouseleave",t))}handleDblclick(t){this.ctx.emit("dblclick",t)}bind(t,e,i,s){t.addEventListener(e,i,s),this.eventTasks.set(e,i)}unbind(t,e,i){t.removeEventListener(e,i),this.eventTasks.delete(e)}}class ii{constructor(){l(this,"events",new Map)}has(t){return this.events.has(t)}on(t,e){const i=this.events.get(t)||[];i.push(e),this.events.set(t,i)}once(t,e){const i=(...s)=>{e(...s),this.off(t,i)};return this.on(t,i),this}off(t,e){const i=this.events.get(t);if(i){const s=i.indexOf(e);s>=0&&(i.splice(s,1),i.length===0?this.events.delete(t):this.events.set(t,i))}}emit(t,...e){const i=this.events.get(t);i&&i.forEach(s=>{s(...e)})}destroy(){this.events.clear()}}class si{constructor(t){l(this,"ctx");const e=t.getContext("2d");if(!e)throw new Error("canvas context not found");this.ctx=e}scale(t){this.ctx.scale(t,t)}save(){this.ctx.save()}restore(){this.ctx.restore()}translate(t,e){this.ctx.translate(t,e)}setCursor(t="default"){this.ctx.canvas.style.cursor=t}clear(t=0,e=0,i,s){this.ctx.clearRect(t,e,i||this.ctx.canvas.width,s||this.ctx.canvas.height)}drawShadow(t,e,i,s,r){const{fillColor:o,side:a,shadowWidth:h,colorStart:c,colorEnd:f}=r;this.ctx.save(),o&&(this.ctx.fillStyle=o,this.ctx.fillRect(t,e,i,s));let d;switch(a){case"left":d=this.ctx.createLinearGradient(t-h,e,t,e),d.addColorStop(0,c),d.addColorStop(1,f),this.ctx.fillStyle=d,this.ctx.fillRect(t-h,e,h,s);break;case"right":d=this.ctx.createLinearGradient(t+i,e,t+i+h,e),d.addColorStop(0,c),d.addColorStop(1,f),this.ctx.fillStyle=d,this.ctx.fillRect(t+i,e,h,s);break;case"top":d=this.ctx.createLinearGradient(t,e-h,t,e),d.addColorStop(0,c),d.addColorStop(1,f),this.ctx.fillStyle=d,this.ctx.fillRect(t,e-h,i,h);break;case"bottom":d=this.ctx.createLinearGradient(t,e+s,t,e+s+h),d.addColorStop(0,c),d.addColorStop(1,f),this.ctx.fillStyle=d,this.ctx.fillRect(t,e+s,i,h);break;default:console.error("Invalid side specified for shadow");break}}drawLine(t,e){if(t.length<4||t.length%2!==0)throw new Error("A valid array of points is required to draw a line");this.ctx.save();const{borderColor:i="black",borderWidth:s=1}=e;this.ctx.beginPath(),this.ctx.moveTo(t[0]-.5,t[1]-.5);for(let r=2;r<t.length;r+=2)this.ctx.lineTo(t[r]-.5,t[r+1]-.5);this.ctx.strokeStyle=i,this.ctx.lineWidth=s,e.lineDash&&(this.ctx.lineDashOffset=4,this.ctx.setLineDash(e.lineDash)),e.fillColor&&(this.ctx.fillStyle=e.fillColor,this.ctx.fill()),e.borderColor&&(this.ctx.strokeStyle=e.borderColor),this.ctx.stroke(),this.ctx.closePath(),this.ctx.restore()}drawImage(t,e,i,s,r){this.ctx.save(),this.ctx.drawImage(t,e,i,s,r),this.ctx.restore()}drawRect(t,e,i,s,{borderWidth:r=1,borderColor:o,fillColor:a,radius:h=0}={}){if(this.ctx.save(),this.ctx.beginPath(),a!==void 0&&(this.ctx.fillStyle=a),o!==void 0&&(this.ctx.lineWidth=r,this.ctx.strokeStyle=o),h===0)this.ctx.rect(t-.5,e-.5,i,s);else{const[c,f,d,x]=typeof h=="number"?[h,h,h,h]:h;this.ctx.moveTo(t+c,e),this.ctx.arcTo(t+i,e,t+i,e+f,f),this.ctx.arcTo(t+i,e+s,t+i-d,e+s,d),this.ctx.arcTo(t,e+s,t,e+s-x,x),this.ctx.arcTo(t,e,t+c,e,c)}a!==void 0&&this.ctx.fill(),o!==void 0&&this.ctx.stroke(),this.ctx.restore()}drawText(t="",e,i,s,r,o={}){this.ctx.save();const{font:a="12px Arial",align:h="center",color:c="#495060",padding:f=0,verticalAlign:d="middle"}=o;this.ctx.font=a,this.ctx.fillStyle=c,this.ctx.textBaseline=d,this.ctx.textAlign=h;let x=0;d==="top"?x=i+f:d==="bottom"?x=i+r-f:x=i+(r+1)/2;let u=0;h==="left"?u=e+f:h==="right"?u=e+s-f:u=e+s/2;const{_text:g,ellipsis:w}=this.handleEllipsis(t,s,f,a);return this.ctx.fillText(g,u,x),this.ctx.restore(),w}handleEllipsis(t,e,i=0,s="12px Arial"){let r=!1,o=t;if(this.ctx.font=s,t==null||t==="")return{_text:"",ellipsis:r};const a=this.ctx.measureText("...").width,h=this.ctx.measureText(t).width;if(h&&h+a>=e-i*2){r=!0;let c=0;for(let f=0;f<t.length;f++)if(c+=this.ctx.measureText(t[f]).width,c>=e-i*2-a){o=t.slice(0,f)+"...";break}}return{_text:o,ellipsis:r}}}class jt{constructor(t){l(this,"PROCESSOR_NUM",50);l(this,"CSS_PREFIX","e-virt-table");l(this,"ICONS",[]);l(this,"ROW_KEY","");l(this,"HEADER_FONT","12px normal Arial");l(this,"BODY_FONT","12px normal Arial");l(this,"BORDER_COLOR","#e1e6eb");l(this,"WIDTH",0);l(this,"RESIZE_MIN_WIDTH",40);l(this,"HEIGHT",0);l(this,"EMPTY_BODY_HEIGHT",120);l(this,"EMPTY_CUSTOM_STYLE",{});l(this,"EMPTY_TEXT","暂无数据");l(this,"MAX_HEIGHT",1e3);l(this,"BORDER_RADIUS",8);l(this,"ENABLE_OFFSET_HEIGHT",!1);l(this,"OFFSET_HEIGHT",0);l(this,"HEADER_HEIGHT",36);l(this,"ENABLE_HEADER_STICKY",!1);l(this,"HEADER_BG_COLOR","#F8FAFF");l(this,"BODY_BG_COLOR","#FFF");l(this,"HEADER_TEXT_COLOR","#1D2129");l(this,"LOADING_ICON_SVG","");l(this,"LOADING_ICON_COLOR","#4E5969");l(this,"EXPAND_ICON_SVG","");l(this,"SHRINK_ICON_SVG","");l(this,"EXPAND_ICON_COLOR","#4E5969");l(this,"SHRINK_ICON_COLOR","#4E5969");l(this,"ERROR_TIP_ICON_COLOR","red");l(this,"ERROR_TIP_ICON_SIZE",6);l(this,"EXPAND_LAZY",!0);l(this,"DEFAULT_EXPAND_ALL",!1);l(this,"CELL_WIDTH",100);l(this,"CELL_HEIGHT",36);l(this,"CELL_PADDING",8);l(this,"CELL_HOVER_ICON_SIZE",20);l(this,"SCROLLER_TRACK_SIZE",14);l(this,"SCROLLER_SIZE",8);l(this,"SCROLLER_COLOR","#dee0e3");l(this,"SCROLLER_TRACK_COLOR","#fff");l(this,"SCROLLER_FOCUS_COLOR","#bbbec4");l(this,"SELECT_BORDER_COLOR","rgb(82,146,247)");l(this,"SELECT_AREA_COLOR","rgba(82,146,247,0.1)");l(this,"SELECT_BG_COLOR","rgba(82,146,247,0.1)");l(this,"EDIT_BG_COLOR","#fcf6ed");l(this,"CHECKBOX_KEY","");l(this,"CHECKBOX_COLOR","rgb(82,146,247)");l(this,"CHECKBOX_SIZE",20);l(this,"CHECKBOX_DISABLED_SVG","");l(this,"CHECKBOX_CHECK_SVG","");l(this,"CHECKBOX_UNCHECK_SVG","");l(this,"CHECKBOX_INDETERMINATE_SVG","");l(this,"READONLY_COLOR","#fff");l(this,"READONLY_TEXT_COLOR","#4E5969");l(this,"ERROR_TIP_COLOR","#ED3F14");l(this,"FOOTER_BG_COLOR","#fafafa");l(this,"FOOTER_FIXED",!0);l(this,"CELL_FOOTER_HEIGHT",36);l(this,"ENABLE_SELECTOR",!1);l(this,"ENABLE_EDIT_SINGLE_CLICK",!1);l(this,"ENABLE_EDIT_CLICK_SELECTOR",!0);l(this,"SELECTOR_AREA_MIN_X",0);l(this,"SELECTOR_AREA_MAX_X_OFFSET",0);l(this,"SELECTOR_AREA_MAX_X",0);l(this,"SELECTOR_AREA_MIN_Y",0);l(this,"SELECTOR_AREA_MAX_Y",0);l(this,"SELECTOR_AREA_MAX_Y_OFFSET",0);l(this,"ENABLE_SELECTOR_SINGLE",!1);l(this,"ENABLE_SELECTOR_SPAN_COL",!0);l(this,"ENABLE_SELECTOR_SPAN_ROW",!0);l(this,"ENABLE_SELECTOR_ALL_ROWS",!0);l(this,"ENABLE_SELECTOR_ALL_COLS",!0);l(this,"ENABLE_AUTOFILL",!1);l(this,"ENABLE_CONTEXT_MENU",!1);l(this,"ENABLE_COPY",!0);l(this,"ENABLE_PASTER",!0);l(this,"ENABLE_RESIZE_ROW",!0);l(this,"ENABLE_RESIZE_COLUMN",!0);l(this,"RESIZE_ROW_LINE_COLOR","#e1e6eb");l(this,"RESIZE_COLUMN_LINE_COLOR","#e1e6eb");l(this,"RESIZE_ROW_MIN_HEIGHT",36);l(this,"RESIZE_COLUMN_MIN_WIDTH",40);l(this,"ENABLE_KEYBOARD",!0);l(this,"ENABLE_HISTORY",!1);l(this,"ENABLE_VALIDATOR_IMMEDIATE",!0);l(this,"HISTORY_NUM",50);l(this,"HIGHLIGHT_HOVER_ROW",!1);l(this,"HIGHLIGHT_HOVER_ROW_COLOR","rgba(186,203,231,0.1)");l(this,"HIGHLIGHT_SELECTED_ROW",!1);l(this,"HIGHLIGHT_SELECTED_ROW_COLOR","rgba(82,146,247,0.1)");l(this,"TOOLTIP_BG_COLOR","#303133");l(this,"TOOLTIP_TEXT_COLOR","#fff");l(this,"TOOLTIP_ZINDEX",3e3);l(this,"TOOLTIP_CUSTOM_STYLE",{});l(this,"CONTEXT_MENU",[{label:"复制",value:"copy"},{label:"剪切",value:"cut"},{label:"粘贴",value:"paste"},{label:"清空选中内容",value:"clearSelected"}]);l(this,"HEADER_CELL_STYLE_METHOD");l(this,"BODY_CELL_STYLE_METHOD");l(this,"FOOTER_CELL_STYLE_METHOD");l(this,"BODY_CELL_READONLY_METHOD");l(this,"BODY_CELL_FORMATTER_METHOD");l(this,"BODY_CELL_RULES_METHOD");l(this,"BODY_CELL_TYPE_METHOD");l(this,"BODY_CELL_EDITOR_TYPE_METHOD");l(this,"BODY_CELL_RENDER_METHOD");l(this,"BODY_CELL_HOVER_ICON_METHOD");l(this,"SPAN_METHOD");l(this,"SELECTABLE_METHOD");l(this,"EXPAND_LAZY_METHOD");l(this,"BEFORE_VALUE_CHANGE_METHOD");l(this,"BEFORE_PASTE_CHANGE_METHOD");l(this,"BEFORE_AUTOFILL_CHANGE_METHOD");Object.assign(this,t)}init(t){Object.assign(this,t)}}class ri{constructor(t){l(this,"ctx");l(this,"list",[{name:"loading",configName:"LOADING_ICON_SVG",configColorName:"LOADING_ICON_COLOR",svg:'<svg t="1724133395728" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2893" width="32" height="32"><path d="M512 226.8476541a19.82487759 19.82487759 0 0 1 14.66497778 5.70304692c3.80203107 3.82918865 5.70304692 8.71751457 5.70304693 14.66497779v122.20814825a19.82487759 19.82487759 0 0 1-5.70304693 14.66497778 19.82487759 19.82487759 0 0 1-14.66497778 5.70304691 19.82487759 19.82487759 0 0 1-14.66497778-5.70304691 19.82487759 19.82487759 0 0 1-5.70304693-14.66497778v-122.20814825a19.82487759 19.82487759 0 0 1 5.70304693-14.66497779 19.82487759 19.82487759 0 0 1 14.66497778-5.70304692z m0 407.36049415a19.82487759 19.82487759 0 0 1 14.66497778 5.70304691c3.80203107 3.82918865 5.70304692 8.71751457 5.70304693 14.66497778v122.20814827a19.82487759 19.82487759 0 0 1-5.70304693 14.66497776 19.82487759 19.82487759 0 0 1-14.66497778 5.70304693 19.82487759 19.82487759 0 0 1-14.66497778-5.70304693 19.82487759 19.82487759 0 0 1-5.70304693-14.66497776v-122.20814827a19.82487759 19.82487759 0 0 1 5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 14.66497778-5.70304691zM797.1523459 512a19.82487759 19.82487759 0 0 1-5.70304692 14.66497778 19.82487759 19.82487759 0 0 1-14.66497779 5.70304693h-122.20814825a19.82487759 19.82487759 0 0 1-14.66497778-5.70304693 19.82487759 19.82487759 0 0 1-5.70304691-14.66497778 19.82487759 19.82487759 0 0 1 5.70304691-14.66497778 19.82487759 19.82487759 0 0 1 14.66497778-5.70304693h122.20814825a19.82487759 19.82487759 0 0 1 14.66497779 5.70304693c3.80203107 3.82918865 5.70304692 8.71751457 5.70304692 14.66497778z m-407.36049415 0a19.82487759 19.82487759 0 0 1-5.70304691 14.66497778 19.82487759 19.82487759 0 0 1-14.66497778 5.70304693h-122.20814827a19.82487759 19.82487759 0 0 1-14.66497776-5.70304693 19.82487759 19.82487759 0 0 1-5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 5.70304693-14.66497778 19.82487759 19.82487759 0 0 1 14.66497776-5.70304693h122.20814827a19.82487759 19.82487759 0 0 1 14.66497778 5.70304693c3.80203107 3.82918865 5.70304692 8.71751457 5.70304691 14.66497778zM310.22076878 310.22076878a21.29137537 21.29137537 0 0 1 14.66497779-5.70304693c5.51294514 0 10.18401235 1.90101585 14.01320099 5.70304693l86.55052591 86.57768347a20.91117183 20.91117183 0 0 1 5.73020449 14.31193182 19.28172983 19.28172983 0 0 1-6.05609289 14.013201 19.11878565 19.11878565 0 0 1-14.013201 6.05609289 20.96548698 20.96548698 0 0 1-14.31193182-5.70304692L310.22076878 338.87178998a19.06447114 19.06447114 0 0 1-5.70304693-14.01320099c0-5.54010272 1.90101585-10.42842865 5.70304693-14.66497778z m288.32975775 288.32975775a19.79772001 19.79772001 0 0 1 14.3390894-6.35482371c5.29568642 0 10.04822572 2.11827457 14.31193182 6.38198066l86.57768347 86.55052651c3.80203107 3.80203107 5.70304692 8.47309828 5.70304691 14.01320102a19.55330372 19.55330372 0 0 1-6.05609225 14.31193182 19.66193339 19.66193339 0 0 1-14.31193245 6.05609288 19.01015661 19.01015661 0 0 1-14.01320099-5.70304692l-86.55052591-86.57768347a19.79772001 19.79772001 0 0 1-6.38198129-14.31193245c0-5.29568642 2.11827457-10.07538268 6.38198129-14.33908939zM713.77923122 310.22076878c3.80203107 4.26370672 5.70304692 9.15203265 5.70304693 14.66497779s-1.90101585 10.18401235-5.70304693 14.01320099l-86.57768347 86.55052591a20.91117183 20.91117183 0 0 1-14.31193182 5.73020449 19.28172983 19.28172983 0 0 1-14.013201-6.05609289 19.11878565 19.11878565 0 0 1-6.05609289-14.013201c0-5.29568642 1.90101585-10.07538268 5.70304692-14.31193182l86.57768348-86.57768347c3.80203107-3.80203107 8.50025585-5.70304692 14.01320099-5.70304693 5.54010272 0 10.40127108 1.90101585 14.66497779 5.70304693zM425.44947347 598.57768347a19.79772001 19.79772001 0 0 1 6.35482371 14.33908939c0 5.29568642-2.11827457 10.04822572-6.38198066 14.31193245L338.89894756 713.77923122a19.06447114 19.06447114 0 0 1-14.01320099 5.70304693 19.55330372 19.55330372 0 0 1-14.31193245-6.05609227 19.68909035 19.68909035 0 0 1-6.05609227-14.31193245 19.01015661 19.01015661 0 0 1 5.70304693-14.01320099l86.57768347-86.55052591a19.79772001 19.79772001 0 0 1 14.31193182-6.38198129c5.29568642 0 10.07538268 2.11827457 14.3390894 6.38198129z" fill="#000000" fill-opacity=".65" p-id="2894"></path></svg>',color:"#4E5969"},{name:"expand",configName:"EXPAND_ICON_SVG",configColorName:"EXPAND_ICON_COLOR",svg:'<svg t="1724122015492" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4237" width="32" height="32"><path d="M401.472 316.992l159.04 217.664L591.488 512l-30.976-22.656-159.04 217.728q-2.24 3.008-3.84 6.464-1.6 3.456-2.496 7.104-0.896 3.648-1.024 7.424-0.192 3.84 0.384 7.552 0.64 3.712 1.92 7.296 1.28 3.52 3.2 6.784 1.984 3.2 4.544 6.016 2.56 2.752 5.632 4.992 3.072 2.24 6.464 3.84 3.456 1.6 7.168 2.496 3.648 0.896 7.424 1.024 3.776 0.192 7.488-0.448 3.776-0.576 7.296-1.856 3.584-1.28 6.784-3.264 3.2-1.92 6.016-4.48 2.816-2.56 5.056-5.632l159.04-217.728q3.584-4.928 5.504-10.752 1.92-5.76 1.92-11.904 0-6.08-1.92-11.904-1.92-5.76-5.504-10.752L463.488 271.68q-2.24-3.072-5.056-5.632-2.752-2.56-6.016-4.48-3.2-1.984-6.784-3.328-3.52-1.28-7.296-1.856-3.712-0.576-7.488-0.448-3.84 0.192-7.424 1.088-3.712 0.896-7.168 2.496-3.392 1.6-6.4 3.84-3.136 2.176-5.696 4.992-2.56 2.752-4.48 6.016-1.984 3.2-3.264 6.784-1.28 3.52-1.92 7.296-0.576 3.712-0.384 7.488 0.128 3.84 1.024 7.488 0.896 3.648 2.496 7.04 1.6 3.456 3.84 6.528z m30.976-61.056q-3.776 0-7.488 0.704-3.712 0.768-7.168 2.24-3.52 1.408-6.656 3.52-3.2 2.112-5.824 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.52 6.656-1.472 3.52-2.176 7.232-0.768 3.712-0.768 7.488 0 3.776 0.768 7.488 0.704 3.712 2.176 7.232 1.408 3.456 3.52 6.592 2.112 3.2 4.8 5.824 2.688 2.688 5.76 4.8 3.2 2.112 6.72 3.52 3.456 1.472 7.168 2.176 3.712 0.768 7.488 0.768 3.84 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.408 6.592-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.112-3.2 3.52-6.656 1.472-3.52 2.24-7.232 0.704-3.712 0.704-7.488 0-3.84-0.704-7.488-0.768-3.712-2.24-7.232-1.408-3.456-3.52-6.592-2.112-3.2-4.8-5.824-2.624-2.688-5.76-4.8-3.2-2.112-6.656-3.52-3.52-1.472-7.232-2.24Q436.224 256 432.448 256z m0 435.392q-3.776 0-7.488 0.704-3.712 0.768-7.168 2.176-3.52 1.472-6.656 3.584-3.2 2.112-5.824 4.736-2.688 2.688-4.8 5.824-2.112 3.2-3.52 6.656-1.472 3.52-2.176 7.232-0.768 3.712-0.768 7.488 0 3.776 0.768 7.488 0.704 3.712 2.176 7.168 1.408 3.52 3.52 6.656 2.112 3.2 4.8 5.76 2.688 2.752 5.76 4.8 3.2 2.112 6.72 3.584 3.456 1.472 7.168 2.176 3.712 0.768 7.488 0.768 3.84 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.472 6.592-3.584 3.2-2.048 5.824-4.736 2.688-2.688 4.8-5.824 2.112-3.2 3.52-6.656 1.472-3.456 2.24-7.168 0.704-3.712 0.704-7.488 0-3.84-0.704-7.488-0.768-3.712-2.24-7.232-1.408-3.52-3.52-6.656-2.112-3.136-4.8-5.76-2.624-2.688-5.76-4.8-3.2-2.112-6.656-3.584-3.52-1.408-7.232-2.176-3.712-0.704-7.488-0.704z" p-id="4238"></path></svg>',color:"#4E5969"},{name:"shrink",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"SHRINK_ICON_COLOR",svg:'<svg t="1724122044148" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M707.648 401.28L489.28 560.704l22.656 30.976 22.656-30.976L316.16 401.216q-3.072-2.24-6.464-3.84-3.456-1.536-7.104-2.432-3.712-0.896-7.488-1.088-3.776-0.128-7.488 0.448-3.776 0.64-7.296 1.92-3.584 1.28-6.784 3.2-3.2 1.984-6.016 4.544-2.816 2.56-5.056 5.632-2.176 3.072-3.84 6.464-1.536 3.456-2.432 7.104-0.896 3.712-1.088 7.488-0.128 3.776 0.448 7.488 0.64 3.776 1.92 7.296 1.28 3.584 3.2 6.784 1.984 3.2 4.544 6.016 2.56 2.752 5.632 4.992l218.368 159.552q4.928 3.584 10.752 5.504 5.76 1.92 11.904 1.92 6.08 0 11.904-1.92 5.76-1.92 10.752-5.504l218.368-159.552q3.008-2.24 5.568-4.992 2.56-2.816 4.544-6.016 1.92-3.2 3.264-6.784 1.28-3.52 1.92-7.296 0.576-3.712 0.384-7.488-0.128-3.84-1.024-7.488-0.896-3.648-2.496-7.04-1.6-3.456-3.84-6.528-2.24-3.072-4.992-5.632-2.816-2.56-6.016-4.48-3.2-1.984-6.784-3.328-3.584-1.28-7.296-1.856-3.712-0.64-7.488-0.448-3.84 0.192-7.488 1.088-3.648 0.896-7.04 2.496-3.456 1.536-6.528 3.84z m61.056 30.976q0-3.84-0.768-7.488-0.704-3.712-2.176-7.232-1.472-3.456-3.52-6.656-2.112-3.136-4.8-5.76-2.688-2.688-5.76-4.8-3.2-2.112-6.72-3.584-3.456-1.408-7.168-2.176-3.712-0.704-7.488-0.704-3.84 0-7.488 0.704-3.712 0.768-7.232 2.176-3.456 1.472-6.656 3.584-3.136 2.112-5.76 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.584 6.656-1.408 3.52-2.176 7.232-0.704 3.712-0.704 7.488 0 3.776 0.704 7.488 0.768 3.712 2.176 7.168 1.472 3.52 3.584 6.656 2.112 3.2 4.8 5.824 2.624 2.688 5.76 4.8 3.2 2.112 6.656 3.52 3.52 1.472 7.232 2.176 3.712 0.768 7.488 0.768 3.776 0 7.488-0.768 3.712-0.704 7.168-2.176 3.52-1.408 6.656-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.048-3.2 3.52-6.72 1.472-3.456 2.176-7.168 0.768-3.712 0.768-7.488z m-436.736 0q0-3.84-0.768-7.488-0.704-3.712-2.176-7.232-1.408-3.456-3.52-6.656-2.112-3.136-4.8-5.76-2.688-2.688-5.76-4.8-3.2-2.112-6.656-3.584-3.52-1.408-7.232-2.176-3.712-0.704-7.488-0.704-3.84 0-7.488 0.704-3.712 0.768-7.232 2.176-3.456 1.472-6.592 3.584-3.2 2.112-5.824 4.8-2.688 2.624-4.8 5.76-2.112 3.2-3.52 6.656-1.472 3.52-2.24 7.232-0.704 3.712-0.704 7.488 0 3.776 0.704 7.488 0.768 3.712 2.24 7.168 1.408 3.52 3.52 6.656 2.112 3.2 4.8 5.824 2.624 2.688 5.76 4.8 3.2 2.112 6.656 3.52 3.52 1.472 7.232 2.176 3.712 0.768 7.488 0.768 3.776 0 7.488-0.768 3.712-0.704 7.232-2.176 3.456-1.408 6.592-3.52 3.2-2.112 5.824-4.8 2.688-2.688 4.8-5.76 2.112-3.2 3.52-6.72 1.472-3.456 2.176-7.168 0.768-3.712 0.768-7.488z" p-id="4552"></path></svg>',color:"#4E5969"},{name:"checkbox-uncheck",configName:"CHECKBOX_UNCHECK_SVG",svg:'<svg t="1722595639920" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4708" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4709"></path></svg>',color:""},{name:"checkbox-check",configName:"CHECKBOX_CHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595535853" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M640 128H384c-170.496 0-256 85.504-256 256v256c0 170.496 85.504 256 256 256h256c170.496 0 256-85.504 256-256V384c0-170.496-85.504-256-256-256z m67.584 302.592c-2.048 4.608-4.608 8.704-8.192 12.288L506.88 634.88c-3.584 3.584-7.68 6.144-12.288 8.192-4.608 2.048-9.728 3.072-14.848 3.072s-10.24-1.024-14.848-3.072c-4.608-2.048-8.704-4.608-12.288-8.192l-96.256-96.256c-3.584-3.584-6.144-7.68-8.192-12.288-2.048-4.608-3.072-9.728-3.072-14.848 0-2.56 0-5.12 1.024-7.68 0.512-2.56 1.024-5.12 2.048-7.168 1.024-2.56 2.048-4.608 3.584-6.656 1.536-2.048 3.072-4.096 4.608-5.632 1.536-2.048 3.584-3.584 5.632-4.608 2.048-1.536 4.096-2.56 6.656-3.584 2.56-1.024 4.608-1.536 7.168-2.048 2.56-0.512 5.12-0.512 7.68-0.512 5.12 0 10.24 1.024 14.848 3.072 4.608 2.048 8.704 4.608 12.288 8.192l69.12 68.608L645.12 389.12c3.584-3.584 7.68-6.144 12.288-8.192 4.608-2.048 9.728-3.072 14.848-3.072 2.56 0 5.12 0 7.68 0.512s5.12 1.024 7.168 2.048c2.56 1.024 4.608 2.048 6.656 3.584 2.048 1.536 4.096 3.072 5.632 4.608 1.536 1.536 3.584 3.584 4.608 5.632 1.536 2.048 2.56 4.096 3.584 6.656 1.024 2.56 1.536 4.608 2.048 7.168 0.512 2.56 1.024 5.12 1.024 7.68 0 5.12-1.024 10.24-3.072 14.848z" p-id="4552"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-hover",configName:"CHECKBOX_UNCHECK_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595639920" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4708" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4709"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-indeterminate",configName:"CHECKBOX_INDETERMINATE_SVG",configColorName:"CHECKBOX_COLOR",svg:'<svg t="1722595280953" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4394" width="32" height="32"><path d="M128 384v256q0 12.608 1.28 25.088 1.216 12.544 3.648 24.832 2.432 12.352 6.08 24.384t8.448 23.68q4.864 11.584 10.752 22.72 5.952 11.072 12.928 21.504 7.04 10.496 14.976 20.224 8 9.728 16.896 18.56 8.896 8.96 18.56 16.896 9.728 8 20.224 14.976 10.432 7.04 21.504 12.928 11.136 5.888 22.72 10.688 11.648 4.864 23.68 8.512 12.032 3.648 24.32 6.08 12.352 2.432 24.896 3.712Q371.392 896 384 896h256q12.608 0 25.088-1.28 12.544-1.216 24.832-3.648 12.352-2.432 24.384-6.08t23.68-8.512q11.584-4.8 22.72-10.688 11.072-5.952 21.504-12.928 10.496-7.04 20.224-14.976 9.728-8 18.56-16.896 8.96-8.832 16.896-18.56 8-9.728 14.976-20.224 7.04-10.432 12.928-21.504 5.888-11.136 10.688-22.72 4.864-11.648 8.512-23.68 3.648-12.032 6.08-24.32 2.432-12.352 3.712-24.896Q896 652.608 896 640V384q0-12.608-1.28-25.088-1.216-12.544-3.648-24.832-2.432-12.352-6.08-24.384t-8.512-23.68q-4.8-11.584-10.688-22.72-5.952-11.072-12.928-21.504-7.04-10.496-14.976-20.224-8-9.664-16.896-18.56-8.832-8.96-18.56-16.896-9.728-8-20.224-14.976-10.432-7.04-21.504-12.928-11.136-5.888-22.72-10.752-11.648-4.8-23.68-8.448-12.032-3.648-24.32-6.08-12.352-2.432-24.896-3.712Q652.608 128 640 128H384q-12.608 0-25.088 1.28-12.544 1.216-24.832 3.648-12.352 2.432-24.384 6.08t-23.68 8.448q-11.584 4.864-22.72 10.752-11.072 5.952-21.504 12.928-10.496 7.04-20.224 14.976-9.664 8-18.56 16.896-8.96 8.896-16.896 18.56-8 9.728-14.976 20.224-7.04 10.432-12.928 21.504-5.888 11.136-10.752 22.72-4.8 11.648-8.448 23.68-3.648 12.032-6.08 24.32-2.432 12.352-3.712 24.896Q128 371.392 128 384z m566.016 166.336H330.112a38.4 38.4 0 0 1 0-76.8h363.904a38.4 38.4 0 0 1 0 76.8z" p-id="4395"></path></svg>',color:"rgb(82,146,247)"},{name:"checkbox-check-disabled",configName:"CHECKBOX_CHECK_SVG",svg:'<svg t="1722595535853" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4551" width="32" height="32"><path d="M640 128H384c-170.496 0-256 85.504-256 256v256c0 170.496 85.504 256 256 256h256c170.496 0 256-85.504 256-256V384c0-170.496-85.504-256-256-256z m67.584 302.592c-2.048 4.608-4.608 8.704-8.192 12.288L506.88 634.88c-3.584 3.584-7.68 6.144-12.288 8.192-4.608 2.048-9.728 3.072-14.848 3.072s-10.24-1.024-14.848-3.072c-4.608-2.048-8.704-4.608-12.288-8.192l-96.256-96.256c-3.584-3.584-6.144-7.68-8.192-12.288-2.048-4.608-3.072-9.728-3.072-14.848 0-2.56 0-5.12 1.024-7.68 0.512-2.56 1.024-5.12 2.048-7.168 1.024-2.56 2.048-4.608 3.584-6.656 1.536-2.048 3.072-4.096 4.608-5.632 1.536-2.048 3.584-3.584 5.632-4.608 2.048-1.536 4.096-2.56 6.656-3.584 2.56-1.024 4.608-1.536 7.168-2.048 2.56-0.512 5.12-0.512 7.68-0.512 5.12 0 10.24 1.024 14.848 3.072 4.608 2.048 8.704 4.608 12.288 8.192l69.12 68.608L645.12 389.12c3.584-3.584 7.68-6.144 12.288-8.192 4.608-2.048 9.728-3.072 14.848-3.072 2.56 0 5.12 0 7.68 0.512s5.12 1.024 7.168 2.048c2.56 1.024 4.608 2.048 6.656 3.584 2.048 1.536 4.096 3.072 5.632 4.608 1.536 1.536 3.584 3.584 4.608 5.632 1.536 2.048 2.56 4.096 3.584 6.656 1.024 2.56 1.536 4.608 2.048 7.168 0.512 2.56 1.024 5.12 1.024 7.68 0 5.12-1.024 10.24-3.072 14.848z" p-id="4552"></path></svg>',color:"#DDE0EA"},{name:"checkbox-disabled",configName:"CHECKBOX_DISABLED_SVG",svg:'<svg t="1722595946663" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4865" width="32" height="32"><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z" fill="#F1F2F4" p-id="4866"></path><path d="M128 640V384a256 256 0 0 1 256-256h256a256 256 0 0 1 256 256v256a256 256 0 0 1-256 256H384a256 256 0 0 1-256-256z m64 0q0 79.552 56.256 135.744Q304.448 832 384 832h256q79.552 0 135.744-56.256Q832 719.552 832 640V384q0-79.552-56.256-135.744Q719.552 192 640 192H384q-79.552 0-135.744 56.256Q192 304.448 192 384v256z" fill="#DDE0EA" p-id="4867"></path></svg>',color:""}]);l(this,"icons",new Map);this.ctx=t,this.init()}async init(){const t=[];for(let e=0;e<this.list.length;e++){const i=this.list[e];let s=i.color;if(i.configColorName){const o=this.ctx.config[i.configColorName];o&&(s=o)}const r=this.createImageFromSVG(i.svg,s).then(o=>{this.icons.set(i.name,o)});t.push(r)}for(let e=0;e<this.ctx.config.ICONS.length;e++){const i=this.ctx.config.ICONS[e];let s=i.color;const r=this.createImageFromSVG(i.svg,s).then(o=>{this.icons.set(i.name,o)});t.push(r)}await Promise.all(t),this.ctx.emit("draw")}async createImageFromSVG(t,e){const r=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;e&&r.querySelectorAll("*").forEach(c=>{c.setAttribute("fill",e)});const o=new Image,a=new Blob([new XMLSerializer().serializeToString(r)],{type:"image/svg+xml"}),h=URL.createObjectURL(a);return o.src=h,new Promise((c,f)=>{o.onerror=()=>f(new Error("Failed to load image")),o.onload=()=>{c(o)}})}get(t){return this.icons.get(t)}}class Ut{constructor(t,e,i,s,r,o,a){l(this,"ctx");l(this,"x",0);l(this,"y",0);l(this,"width",0);l(this,"height",0);l(this,"fixed");l(this,"cellType");this.ctx=t,this.x=e,this.y=i,this.width=s,this.height=r,this.fixed=o,this.cellType=a}isHorizontalVisible(){if(this.fixed)return!0;const{stageWidth:t,fixedLeftWidth:e,scrollX:i,fixedRightWidth:s}=this.ctx,r=t;return!(this.x+this.width-e-i<=0||this.x-i>=r-s)}isVerticalVisible(){const{stageHeight:t,scrollY:e}=this.ctx,i=t;return!(this.y+this.height-e<=0||this.y-e>=i)}getDrawX(){if(this.fixed==="left")return this.x;if(this.fixed==="right"){const{stageWidth:t,config:{SCROLLER_TRACK_SIZE:e}}=this.ctx;return t-(this.ctx.header.width-this.x)-e+1}return this.x-this.ctx.scrollX}getDrawY(){return this.cellType==="header"?this.y:this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED?this.y:this.y-this.ctx.scrollY}getLeftFixedX(){return this.x-this.ctx.scrollX}getRightFixedX(){}}class Zt extends Ut{constructor(e,i,s,r,o,a,h,c,f,d="body"){super(e,r,o,a,h,c.fixed,d);l(this,"formatter");l(this,"formatterFooter");l(this,"hoverIconName","");l(this,"operation",!1);l(this,"align");l(this,"verticalAlign");l(this,"fixed");l(this,"type");l(this,"editorType");l(this,"cellType");l(this,"level");l(this,"colspan",1);l(this,"rowspan",1);l(this,"key");l(this,"column");l(this,"rowIndex");l(this,"colIndex");l(this,"rowKey");l(this,"row");l(this,"value");l(this,"render");l(this,"renderFooter");l(this,"style",{});l(this,"rules",{});l(this,"message","");l(this,"text","");l(this,"displayText","");l(this,"visibleWidth",0);l(this,"visibleHeight",0);l(this,"isHasChanged",!1);l(this,"drawX",0);l(this,"drawY",0);l(this,"drawCellBgColor","");l(this,"drawCellSkyBgColor","");l(this,"drawTextColor","");l(this,"drawTextX",0);l(this,"drawTextY",0);l(this,"drawImageX",0);l(this,"drawImageY",0);l(this,"drawImageWidth",0);l(this,"drawImageHeight",0);l(this,"drawImageName","");l(this,"drawImageSource");l(this,"ellipsis",!1);l(this,"rowExpand",!1);l(this,"rowHasChildren",!1);l(this,"overflowTooltipShow",!0);l(this,"overflowTooltipMaxWidth",500);l(this,"overflowTooltipPlacement","top");this.visibleWidth=this.width,this.visibleHeight=this.height,this.colIndex=s,this.rowIndex=i,this.key=c.key,this.type=c.type||"text",this.editorType=c.editorType||"text",this.cellType=d,this.align=c.align||"center",this.verticalAlign=c.verticalAlign||"middle",this.fixed=c.fixed,this.level=c.level,this.operation=c.operation||!1,this.column=c,this.rules=c.rules,this.row=f,this.rowKey=this.cellType==="body"?this.ctx.database.getRowKeyForRowIndex(i):`${this.cellType}_${this.rowIndex}`,this.value=this.getValue(),this.render=c.render,this.overflowTooltipShow=c.overflowTooltipShow!==!1,this.overflowTooltipMaxWidth=c.overflowTooltipMaxWidth||500,this.overflowTooltipPlacement=c.overflowTooltipPlacement||"top",this.renderFooter=c.renderFooter,this.hoverIconName=c.hoverIconName,this.formatter=c.formatter,this.formatterFooter=c.formatterFooter,this.update()}getValidationMessage(){const e=this.ctx.database.getValidationError(this.rowKey,this.key);if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message}return this.message}update(){this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.drawTextX=this.drawX,this.drawTextY=this.drawY,this.isHasChanged=this.ctx.database.isHasChangedData(this.rowKey,this.key),this.updateSpan(),this.updateStyle(),this.updateType(),this.updateHoverIcon(),this.updateSelection(),this.updateTree(),this.updateEditorType(),this.updateRender(),this.getValidationMessage(),this.updateContainer(),this.text=this.getText(),this.displayText=this.getDisplayText()}updateSpan(){if(this.cellType==="footer")return;const{SPAN_METHOD:e}=this.ctx.config;if(typeof e=="function"){const i=e,{colspan:s=1,rowspan:r=1}=i({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue(),headIndex:this.ctx.body.headIndex,headPosition:this.ctx.database.getPositionForRowIndex(this.ctx.body.headIndex),visibleRows:this.ctx.body.visibleRows,visibleLeafColumns:this.ctx.header.visibleLeafColumns,rows:this.ctx.body.data})||{};this.colspan=s,this.rowspan=r,this.visibleWidth=this.getWidthByColIndexColSpan(this.colIndex,this.colspan),this.visibleHeight=this.ctx.database.getHeightByRowIndexRowSpan(this.rowIndex,this.rowspan)}}updateType(){const{BODY_CELL_TYPE_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.type=s)}}updateEditorType(){const{BODY_CELL_EDITOR_TYPE_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.editorType=s)}}updateRender(){const{BODY_CELL_RENDER_METHOD:e}=this.ctx.config;if(typeof e=="function"){const s=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});s!==void 0&&(this.render=s)}}validate(){this.ctx.database.getValidator(this.rowKey,this.key).then(()=>{this.ctx.database.setValidationError(this.rowKey,this.key,[]),this.message=""}).catch(e=>{if(Array.isArray(e)&&e.length){const[i]=e;this.message=i.message,this.ctx.database.setValidationError(this.rowKey,this.key,e)}}).finally(()=>{this.ctx.emit("draw")})}updateStyle(){this.style=this.getOverlayerViewsStyle()}updateTree(){const{CELL_PADDING:e=0}=this.ctx.config,{rowKey:i,cellType:s}=this;let r,o=0,a="";if(this.type==="tree"&&s==="body"){const h=this.ctx.database.getRowForRowKey(i),{expand:c=!1,hasChildren:f=!1,expandLoading:d=!1,level:x=0}=h||{};if(this.rowExpand=c,this.rowHasChildren=f,d){const u=this.ctx.icons.get("loading");a="loading",r=u,o=x*8}else if(f){const u=this.ctx.icons.get("expand"),g=this.ctx.icons.get("shrink");r=c?g:u,a=c?"shrink":"expand",o=x*8}else o=x*8;if(r){let u=20,g=20,w=this.drawX+o+e,p=this.drawY+(this.visibleHeight-g)/2;this.ctx.paint.drawImage(r,w,p,u,g),this.drawImageX=w,this.drawImageY=p,this.drawImageWidth=u,this.drawImageHeight=g,this.drawImageName=a,this.drawImageSource=r,this.align="left",this.drawTextX=o+this.drawX+u-.5}}}updateContainer(){const{BODY_BG_COLOR:e,EDIT_BG_COLOR:i,BODY_CELL_STYLE_METHOD:s,FOOTER_CELL_STYLE_METHOD:r,READONLY_TEXT_COLOR:o,FOOTER_BG_COLOR:a,HIGHLIGHT_SELECTED_ROW:h,HIGHLIGHT_SELECTED_ROW_COLOR:c,HIGHLIGHT_HOVER_ROW:f,HIGHLIGHT_HOVER_ROW_COLOR:d}=this.ctx.config;if(this.cellType==="footer"){let y=a,b=o;if(typeof r=="function"){const m=r,{backgroundColor:E,color:C}=m({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};E&&(y=E),C&&(b=C)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=y,this.drawTextColor=b;return}let x="transparent";const u=this.ctx.focusCell,g=this.ctx.hoverCell;f&&(g==null?void 0:g.rowKey)===this.rowKey&&(x=d),h&&(u==null?void 0:u.rowKey)===this.rowKey&&(x=c),this.drawCellSkyBgColor=x;let w=e,p=o;if(["index","index-selection","selection"].includes(this.type)){this.drawCellBgColor=e,this.drawTextColor=o;return}if(this.ctx.database.getReadonly(this.rowKey,this.key)||(w=i,p=o),typeof s=="function"){const y=s,{backgroundColor:b,color:m}=y({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,isHasChanged:this.isHasChanged,value:this.getValue()})||{};b&&(w=b),m&&(p=m)}this.drawCellBgColor=w,this.drawTextColor=p}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:r,cellType:o,type:a,rowIndex:h,rowKey:c}=this;if(!(s===0||r===0)&&o!=="footer"&&["index-selection","selection"].includes(a)){const f=this.ctx.database.getRowSelection(c),d=this.ctx.database.getRowSelectable(c),{CHECKBOX_SIZE:x=0}=this.ctx.config,u=this.drawX+(e-x)/2,g=this.drawY+(i-x)/2;let w=this.ctx.icons.get("checkbox-uncheck"),p="checkbox-uncheck";f&&d?(w=this.ctx.icons.get("checkbox-check"),p="checkbox-check"):f&&d?(w=this.ctx.icons.get("checkbox-check-disabled"),p="checkbox-check-disabled"):!f&&d?(w=this.ctx.icons.get("checkbox-uncheck"),p="checkbox-uncheck"):(w=this.ctx.icons.get("checkbox-disabled"),p="checkbox-disabled"),w&&a=="index-selection"?(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===h||["checkbox-disabled","checkbox-check"].includes(p))&&(this.drawImageX=u,this.drawImageY=g,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=p,this.drawImageSource=w):w&&a==="selection"&&(this.drawImageX=u,this.drawImageY=g,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=p,this.drawImageSource=w)}}updateHoverIcon(){const{BODY_CELL_HOVER_ICON_METHOD:e,CELL_HOVER_ICON_SIZE:i,CELL_PADDING:s}=this.ctx.config;if(typeof e=="function"){const h=e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});h!==void 0&&(this.hoverIconName=h)}const r=this.drawX+this.width-i-s,o=this.drawY+(this.height-i)/2;if(this.hoverIconName&&this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===this.rowIndex){const a=this.ctx.icons.get(this.hoverIconName);this.drawImageX=r,this.drawImageY=o,this.drawImageWidth=i,this.drawImageHeight=i,this.drawImageName=this.hoverIconName,this.drawImageSource=a}}getDisplayText(){return this.cellType==="footer"?this.renderFooter||this.text===null||this.text===void 0?"":this.text:this.rowspan===0||this.colspan===0||this.render||this.type==="index-selection"&&(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===this.rowIndex||["checkbox-disabled","checkbox-check"].includes(this.drawImageName))||this.text===null||this.text===void 0?"":`${this.text}`}getText(){if(this.cellType==="footer")return typeof this.formatterFooter=="function"?this.formatterFooter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.row[this.key]}):this.row[this.key];if(typeof this.formatter=="function")return this.formatter({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()});const{BODY_CELL_FORMATTER_METHOD:e}=this.ctx.config;return typeof e=="function"?e({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()}):["index-selection","index"].includes(this.type)?`${this.rowIndex+1}`:(this.value=this.ctx.database.getItemValue(this.rowKey,this.key),this.value)}getValue(){return this.ctx.database.getItemValue(this.rowKey,this.key)}getOverlayerViewsStyle(){let e=`${this.drawX-this.ctx.fixedLeftWidth}px`,i=`${this.drawY-this.ctx.body.y}px`;return this.fixed==="left"?e=`${this.drawX}px`:this.fixed==="right"&&(e=`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`),this.cellType==="footer"&&this.ctx.config.FOOTER_FIXED&&(i=`${this.drawY-this.ctx.footer.y}px`),{position:"absolute",overflow:"hidden",left:e,top:i,width:`${this.visibleWidth}px`,height:`${this.visibleHeight}px`,pointerEvents:"initial",userSelect:"none"}}draw(){const{paint:e,config:{BORDER_COLOR:i}}=this.ctx,{drawX:s,drawY:r}=this;e.drawRect(s,r,this.visibleWidth,this.visibleHeight,{borderColor:i,fillColor:this.drawCellBgColor}),e.drawRect(s,r,this.width,this.height,{borderColor:"transparent",borderWidth:1,fillColor:this.drawCellSkyBgColor}),this.drawText(),this.drawImage(),this.drawSelector(),this.drawAutofillPiont(),this.drawErrorTip()}getWidthByColIndexColSpan(e,i){if(i===0)return 0;let s=0;for(let r=e;r<e+i;r++){const o=this.ctx.header.leafCellHeaders[r];s+=o.width}return s}drawText(){const{CELL_PADDING:e,BODY_FONT:i}=this.ctx.config,{ellipsis:s}=this.ctx.paint.handleEllipsis(this.text,this.width,e,i);return this.ellipsis=s,this.ctx.paint.drawText(this.displayText,this.drawTextX,this.drawTextY,this.visibleWidth,this.visibleHeight,{font:i,padding:e,align:this.align,verticalAlign:this.verticalAlign,color:this.drawTextColor})}drawImage(){this.drawImageSource&&this.ctx.paint.drawImage(this.drawImageSource,this.drawImageX,this.drawImageY,this.drawImageWidth,this.drawImageHeight)}drawAutofillPiont(){if(this.cellType==="footer")return;const{SELECT_BORDER_COLOR:e,ENABLE_AUTOFILL:i,ENABLE_SELECTOR:s}=this.ctx.config;if(!s||!i)return;const{xArr:r,yArr:o}=this.ctx.selector,a=r[1],h=o[1],{colIndex:c,rowIndex:f,drawX:d,drawY:x}=this;c===a&&f===h&&this.ctx.paint.drawRect(d+this.width-6,x+this.height-6,6,6,{borderColor:"#fff",fillColor:e})}drawSelector(){if(this.cellType==="footer")return;const{ENABLE_SELECTOR:e}=this.ctx.config;if(!e)return;const{xArr:i,yArr:s,xArrCopy:r,yArrCopy:o}=this.ctx.selector;this.drawBorder({xArr:r,yArr:o,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:this.ctx.config.SELECT_AREA_COLOR||"rgba(82,146,247,0.1)",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:this.ctx.autofill.xArr,yArr:this.ctx.autofill.yArr,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:this.ctx.config.SELECT_AREA_COLOR||"rgba(82,146,247,0.1)",borderWidth:1,lineDash:[4,4]}),this.drawBorder({xArr:i,yArr:s,borderColor:this.ctx.config.SELECT_BORDER_COLOR||"rgb(82,146,247)",fillColor:this.ctx.config.SELECT_AREA_COLOR||"rgba(82,146,247,0.1)",borderWidth:1})}drawErrorTip(){if(this.cellType==="footer"||!this.message)return;const{ERROR_TIP_ICON_SIZE:e,ERROR_TIP_COLOR:i}=this.ctx.config,{width:s}=this,r=this.drawX,o=this.drawY,a=[r+s-e-.5,o,r+s-.5,o,r+s-.5,o+e];this.ctx.paint.drawLine(a,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,width:r,rowIndex:o,colIndex:a}=this;let h=i+.5,c=s+.5,f=this.height;o===0&&(c=this.y+1,f=f-1),a===this.ctx.maxColIndex&&(h=h-1);const{xArr:d,yArr:x,lineDash:u=[],borderWidth:g=1,borderColor:w,fillColor:p}=e,y=d[0],b=d[1],m=x[0],E=x[1];a>=y&&a<=b&&o===m&&this.ctx.paint.drawLine([h,c,h+r-2,c],{borderColor:w,fillColor:p,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:u}),a>=y&&a<=b&&o===E&&this.ctx.paint.drawLine([h,c+f-1.5,h+r,c+f-1.5],{borderColor:w,fillColor:p,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:u}),a===y&&o>=m&&o<=E&&this.ctx.paint.drawLine([h,c,h,c+f-1],{borderColor:w,fillColor:p,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:u}),a===b&&o>=m&&o<=E&&this.ctx.paint.drawLine([h+r-1.5,c,h+r-1.5,c+f-1.5],{borderColor:w,fillColor:p,borderWidth:g,lineCap:"round",lineJoin:"round",lineDash:u})}}class Jt extends Ut{constructor(e,i,s,r,o,a,h){super(e,s,r,o,a,h.fixed,"header");l(this,"align");l(this,"verticalAlign","middle");l(this,"fixed");l(this,"widthFillDisable");l(this,"type");l(this,"operation",!1);l(this,"editorType");l(this,"level");l(this,"text");l(this,"displayText","");l(this,"colspan");l(this,"rowspan");l(this,"key");l(this,"required",!1);l(this,"readonly",!1);l(this,"children",[]);l(this,"column");l(this,"colIndex");l(this,"rowKey");l(this,"rules");l(this,"hasChildren");l(this,"render");l(this,"style",{});l(this,"drawX",0);l(this,"drawY",0);l(this,"drawCellBgColor","");l(this,"drawTextColor","");l(this,"drawImageX",0);l(this,"drawImageY",0);l(this,"drawImageWidth",0);l(this,"drawImageHeight",0);l(this,"drawImageName","");l(this,"drawImageSource");this.ctx=e,this.x=s,this.y=r,this.width=o,this.height=a,this.colIndex=i,this.key=h.key,this.type=h.type,this.editorType=h.editorType||"text",this.align=h.align||"center",this.verticalAlign=h.verticalAlign||"middle",this.fixed=h.fixed,this.level=h.level,this.operation=h.operation||!1,this.text=h.title,this.column=h,this.colspan=h.colspan,this.widthFillDisable=h.widthFillDisable,this.rowspan=h.rowspan,this.rules=h.rules,this.readonly=h.readonly,this.required=h.required,this.rowKey=Pt(),this.hasChildren=h.children&&h.children.length>0||!1,this.render=h.renderHeader}isVerticalVisible(){const{stageHeight:e}=this.ctx,i=e;return!(this.y+this.height<=0||this.y>=i)}updateStyle(){this.style=this.getOverlayerViewsStyle()}updateContainer(){const{HEADER_CELL_STYLE_METHOD:e,HEADER_BG_COLOR:i,HEADER_TEXT_COLOR:s}=this.ctx.config;let r=i,o=s;if(typeof e=="function"){const a=e,{backgroundColor:h,color:c}=a({colIndex:this.colIndex,column:this.column})||{};h&&(r=h),c&&(o=c)}this.drawCellBgColor=r,this.drawTextColor=o}update(){this.updateContainer(),this.displayText=this.getText(),this.drawX=this.getDrawX(),this.drawY=this.getDrawY(),this.updateStyle()}draw(){const{paint:e,config:{BORDER_COLOR:i,CELL_PADDING:s,HEADER_FONT:r}}=this.ctx,{drawX:o,drawY:a,displayText:h}=this;e.drawRect(o,a,this.width,this.height,{borderColor:i,fillColor:this.drawCellBgColor}),e.drawText(h,o,a,this.width,this.height,{font:r,padding:s,color:this.drawTextColor,align:this.align,verticalAlign:this.verticalAlign}),this.drawSelection()}drawSelection(){const{width:e,height:i,type:s}=this;if(["index-selection","selection"].includes(s)){const{indeterminate:r,check:o,selectable:a}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:h=0}=this.ctx.config,c=this.drawX+(e-h)/2,f=this.drawY+(i-h)/2;let d=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck";r?(d=this.ctx.icons.get("checkbox-indeterminate"),x="checkbox-indeterminate"):o&&a?(d=this.ctx.icons.get("checkbox-check"),x="checkbox-check"):o&&a?(d=this.ctx.icons.get("checkbox-check-disabled"),x="checkbox-check-disabled"):!o&&a?(d=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck"):(d=this.ctx.icons.get("checkbox-disabled"),x="checkbox-disabled"),d&&(this.drawImageX=c,this.drawImageY=f,this.drawImageWidth=h,this.drawImageHeight=h,this.drawImageName=x,this.drawImageSource=d,this.ctx.paint.drawImage(this.drawImageSource,this.drawImageX,this.drawImageY,this.drawImageWidth,this.drawImageHeight))}}getText(){return this.render?"":this.text}getOverlayerViewsStyle(){let e="";return this.fixed==="left"?e=`${this.drawX}px`:this.fixed==="right"?e=`${this.drawX-(this.ctx.stageWidth-this.ctx.fixedRightWidth)}px`:e=`${this.drawX-this.ctx.fixedLeftWidth}px`,{position:"absolute",overflow:"hidden",left:e,top:`${this.drawY+1}px`,width:`${this.width}px`,height:`${this.height-2}px`,pointerEvents:"initial",userSelect:"none"}}}class oi{constructor(t){l(this,"ctx");l(this,"visibleHoverCell");l(this,"resizeObserver");this.ctx=t,this.init()}init(){this.resizeObserver=new ResizeObserver(()=>{this.ctx.emit("resetHeader"),this.ctx.emit("resizeObserver")}),this.resizeObserver.observe(this.ctx.stageElement),this.ctx.on("mousedown",t=>{if(t.button!==0||this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,r=i;this.handleHeaderEvent(r,s,this.ctx.header.renderCellHeaders,o=>{this.ctx.focusCellHeader=o,this.ctx.emit("cellHeaderMousedown",o,t)}),this.handleBodyEvent(r,s,this.ctx.body.renderRows,o=>{this.ctx.setFocusCell(o),this.ctx.emit("cellMousedown",o,t)})}),this.ctx.on("click",t=>{if(t.button!==0||this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.clickCellHeader=s,this.ctx.emit("cellHeaderClick",s,t),this.selectionClick(s)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellClick",s,t),this.selectionClick(s),this.treeClick(s)})}),this.ctx.on("dblclick",t=>{if(t.button!==0||this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.emit("cellHeaderDblclick",s,t)}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.ctx.clickCell=s,this.ctx.emit("cellDblclick",s,t)})}),this.ctx.on("contextMenu",t=>{if(this.isBusy(t))return;const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,r=i;this.handleHeaderEvent(r,s,this.ctx.header.renderCellHeaders,o=>{this.ctx.emit("cellHeaderContextMenuClick",o,t)}),this.handleBodyEvent(r,s,this.ctx.body.renderRows,o=>{this.ctx.emit("cellContextMenuClick",o,t)})}),this.ctx.on("mousemove",t=>{if(this.isBusy(t))return;const e=this.ctx.getOffset(t).offsetY,i=this.ctx.getOffset(t).offsetX;this.handleHeaderEvent(i,e,this.ctx.header.renderCellHeaders,s=>{this.ctx.emit("cellHeaderMouseenter",s,t),this.ctx.hoverCellHeader&&this.ctx.hoverCellHeader!==s&&this.ctx.emit("cellHeaderMouseleave",this.ctx.hoverCellHeader,t),this.imageEnterAndLeave(s,t),this.ctx.hoverCellHeader!==s&&(this.ctx.hoverCellHeader=s,this.ctx.emit("cellHeaderHoverChange",s))}),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{this.imageEnterAndLeave(s,t),this.visibleHoverCell!==s&&(this.ctx.emit("visibleCellMouseleave",s,t),this.visibleHoverCell=s,this.ctx.emit("visibleCellHoverChange",s,t))},!0),this.handleBodyEvent(i,e,this.ctx.body.renderRows,s=>{var r;this.ctx.emit("cellMouseenter",s,t),this.ctx.hoverCell&&this.ctx.hoverCell!==s&&this.ctx.emit("cellMouseleave",this.ctx.hoverCell,t),this.ctx.hoverCell!==s&&(((r=this.ctx.hoverCell)==null?void 0:r.rowKey)!==s.rowKey&&(this.ctx.hoverCell=s,this.ctx.hoverRow=this.ctx.body.renderRows.find(o=>o.rowKey===s.rowKey),this.ctx.emit("rowHoverChange",this.ctx.hoverRow,s,t),this.ctx.emit("drawView")),this.ctx.hoverCell=s,this.ctx.emit("cellHoverChange",s,t))})})}selectionClick(t){if(["selection","index-selection"].includes(t.type)&&this.ctx.isPointer)if(t instanceof Jt)t.drawImageName==="checkbox-uncheck"||t.drawImageName==="checkbox-indeterminate"?this.ctx.database.toggleAllSelection():t.drawImageName==="checkbox-check"&&this.ctx.database.clearSelection();else{if(!this.ctx.database.getRowSelectable(t.rowKey))return;this.ctx.database.toggleRowSelection(t.rowKey)}}treeClick(t){if(t.type==="tree"&&this.ctx.isPointer){const e=this.ctx.database.getRowForRowKey(t.rowKey),{expand:i=!1,expandLazy:s=!1}=e||{},{EXPAND_LAZY:r,EXPAND_LAZY_METHOD:o}=this.ctx.config;if(r&&o&&!i&&!s)typeof o=="function"&&(this.ctx.database.expandLoading(t.rowKey,!0),o({row:t.row,rowIndex:t.rowIndex,colIndex:t.colIndex,column:t.column,value:t.getValue()}).then(h=>{this.ctx.database.setExpandChildren(t.rowKey,h),this.ctx.database.expandLoading(t.rowKey,!1),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}).catch(h=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(h)}));else{const a=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!a),this.ctx.emit("expandChange",this.ctx.database.getExpandRowKeys())}}}imageEnterAndLeave(t,e){const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),r=i,o=s;o>t.drawImageX&&o<t.drawImageX+t.drawImageWidth&&r>t.drawImageY&&r<t.drawImageY+t.drawImageHeight?(this.ctx.stageElement.style.cursor="pointer",this.ctx.isPointer=!0,t instanceof Zt&&["selection","index-selection"].includes(t.type)&&(this.ctx.database.getRowSelectable(t.rowKey)||(this.ctx.stageElement.style.cursor="not-allowed"))):(this.ctx.isPointer=!1,this.ctx.stageElement.style.cursor==="pointer"&&(this.ctx.stageElement.style.cursor="default"))}isBusy(t){const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=e,r=i;if(!this.ctx.isTarget()||this.ctx.stageElement.style.cursor==="row-resize"||this.ctx.stageElement.style.cursor==="col-resize"||this.ctx.columnResizing||this.ctx.rowResizing)return!0;const{SCROLLER_TRACK_SIZE:o}=this.ctx.config;return!!(this.ctx.scrollerMove||this.ctx.scrollerFocus||s>this.ctx.stageHeight-o||r>this.ctx.stageWidth-o)}handleBodyEvent(t,e,i,s,r=!1){for(const o of i){const a=o.fixedCells.concat(o.noFixedCells);for(const h of a){const c=h.getDrawX(),f=h.getDrawY();if(r){if(t>c&&t<c+h.visibleWidth&&e>f&&e<f+h.visibleHeight){s(h);return}}else if(t>c&&t<c+h.width&&e>f&&e<f+h.height){s(h);return}}}}handleHeaderEvent(t,e,i,s){for(const r of i){const o=r.getDrawX(),a=r.getDrawY();if(t>o&&t<o+r.width&&e>a&&e<a+r.height){s(r);return}}}destroy(){this.resizeObserver.unobserve(this.ctx.stageElement)}}class ni{constructor(t,e){l(this,"eventBus");l(this,"eventBrowser");l(this,"eventTable");l(this,"containerElement");l(this,"stageElement");l(this,"canvasElement");l(this,"overlayerElement");l(this,"editorElement");l(this,"emptyElement");l(this,"contextMenuElement");l(this,"stageWidth",0);l(this,"stageHeight",0);l(this,"paint");l(this,"icons");l(this,"isInsideTargetContainer",!1);l(this,"mousedown",!1);l(this,"isPointer",!1);l(this,"rowResizing",!1);l(this,"columnResizing",!1);l(this,"scrollerMove",!1);l(this,"scrollerFocus",!1);l(this,"autofillMove",!1);l(this,"selectorMove",!1);l(this,"adjustPositioning",!1);l(this,"editing",!1);l(this,"scrollY",0);l(this,"scrollX",0);l(this,"fixedLeftWidth",0);l(this,"fixedRightWidth",0);l(this,"maxColIndex",0);l(this,"maxRowIndex",0);l(this,"hoverRow");l(this,"clickCell");l(this,"focusCell");l(this,"hoverCell");l(this,"clickCellHeader");l(this,"focusCellHeader");l(this,"hoverCellHeader");l(this,"body",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,headIndex:0,tailIndex:0,visibleRows:[],renderRows:[],data:[]});l(this,"footer",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,renderRows:[]});l(this,"header",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,visibleLeafColumns:[],leafCellHeaders:[],renderLeafCellHeaders:[],renderCellHeaders:[],fixedLeftCellHeaders:[],fixedRightCellHeaders:[],renderCenterCellHeaders:[]});l(this,"selector",{enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]});l(this,"autofill",{enable:!1,xArr:[-1,-1],yArr:[-1,-1]});l(this,"database");l(this,"history");l(this,"config");const{containerElement:i,stageElement:s,canvasElement:r,overlayerElement:o,editorElement:a,emptyElement:h,contextMenuElement:c}=t;this.containerElement=i,s.tabIndex=0,this.stageElement=s,this.canvasElement=r,this.overlayerElement=o,this.editorElement=a,this.emptyElement=h,this.contextMenuElement=c,this.config=new jt(e.config||{}),this.eventBus=new ii,this.eventBrowser=new ei(this),this.eventTable=new oi(this),this.paint=new si(this.canvasElement),this.database=new Qe(this,e),this.history=new ti(this),this.icons=new ri(this)}setConfig(t){this.config=new jt(t)}setFocusCell(t){var e;this.focusCell!==t&&(((e=this.focusCell)==null?void 0:e.rowKey)!==t.rowKey&&(this.focusCell=t,this.emit("rowFocusChange",t)),this.focusCell=t,this.emit("cellFocusChange",t))}clearSelector(){this.selector={enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]}}clearAutofill(){this.autofill={enable:!1,xArr:[-1,-1],yArr:[-1,-1]}}getSelectedData(){const t=[],e=this.selector.yArr,i=this.selector.xArr;let s="";for(let r=0;r<=e[1]-e[0];r++){const o=[];for(let a=0;a<=i[1]-i[0];a++){const h=r+e[0],c=a+i[0],f=this.database.getItemValueForRowIndexAndColIndex(h,c);f&&o.push(f.value)}s+=`${o.join(" ")}\r`,t.push(o)}return s=s?s.replace(/\r$/,""):" ",{xArr:i,yArr:e,text:s,value:t}}setScroll(t,e){let i=Math.floor(t);const s=this.body.width-this.body.visibleWidth;i<0?i=0:i>s&&(i=s);let r=Math.floor(e);const o=this.body.height-this.body.visibleHeight-this.footer.height;r<0?r=0:r>o&&(r=o),this.emit("setScroll",i,r)}setScrollX(t){let e=Math.floor(t);const i=this.body.width-this.body.visibleWidth;e<0?e=0:e>i&&(e=i),this.emit("setScrollX",e)}setScrollY(t){let e=Math.floor(t),i=0;this.config.FOOTER_FIXED||(i=this.footer.height);const s=this.body.height-this.body.visibleHeight+i;e<0?e=0:e>s&&(e=s),this.emit("setScrollY",e)}isTarget(){return this.isInsideTargetContainer}getOffset(t){const{left:e,top:i}=this.containerElement.getBoundingClientRect();return{offsetX:t.clientX-e,offsetY:t.clientY-i}}hasEvent(t){return this.eventBus.has(t)}on(t,e){this.eventBus.on(t,e)}once(t,e){this.eventBus.once(t,e)}off(t,e){this.eventBus.off(t,e)}emit(t,...e){this.eventBus.emit(t,...e)}destroy(){this.eventTable.destroy(),this.eventBrowser.destroy(),this.eventBus.destroy()}}class Qt{constructor(t,e){l(this,"ctx");l(this,"type");l(this,"isFocus",!1);l(this,"trackX",0);l(this,"trackY",0);l(this,"trackWidth",0);l(this,"trackHeight",0);l(this,"splitPoints",[]);l(this,"barX",0);l(this,"barY",0);l(this,"barWidth",0);l(this,"barHeight",0);l(this,"distance",0);l(this,"visibleDistance",0);l(this,"clientX",0);l(this,"clientY",0);l(this,"dragStart",0);l(this,"isDragging",!1);l(this,"scroll",0);this.ctx=t,this.type=e,this.type==="vertical"?this.scroll=this.ctx.scrollY:this.scroll=this.ctx.scrollX}onWheel(t){this.updateScroll(t)}onMouseDown(t){if(!(t.target instanceof Element)||!this.ctx.isTarget())return;if(this.ctx.stageElement.style.cursor==="row-resize"||this.ctx.stageElement.style.cursor==="col-resize")return!0;const{offsetX:e,offsetY:i,clientX:s,clientY:r}=t;if(!(s==this.clientX&&r==this.clientY)){if(this.isOnScrollbar(e,i))this.clientX=s,this.clientY=r,this.isDragging=!0,this.ctx.scrollerMove=!0,this.isFocus=!0,this.dragStart=this.scroll;else if(this.isOnTrack(e,i)){let o=0;this.type==="vertical"?o=(i-this.ctx.header.height-this.barHeight/2)/(this.visibleDistance-this.barHeight)*this.distance:o=(e-this.barWidth/2)/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(o,this.distance))}}}onMouseUp(){this.isDragging=!1,this.isFocus=!1,this.clientX=0,this.clientY=0}onMouseMove(t){const{offsetX:e,offsetY:i,clientX:s,clientY:r}=t;if(this.isOnScrollbar(e,i)&&t.target===this.ctx.canvasElement?this.isFocus=!0:this.isFocus=!1,s==this.clientX&&r==this.clientY)return;let o=0;if(this.type==="horizontal"?o=s-this.clientX:o=r-this.clientY,this.isDragging&&o!==0){let a=0;this.type==="vertical"?a=this.dragStart+o/(this.visibleDistance-this.barHeight)*this.distance:a=this.dragStart+o/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(a,this.distance))}}isPointInElement(t,e,i,s,r,o){return t>=i&&t<=i+r&&e>=s&&e<=s+o}hasScrollbar(){return this.type==="vertical"?this.barHeight>0:this.type==="horizontal"?this.barWidth>0:!1}isOnScrollbar(t,e){return this.isPointInElement(t,e,this.barX,this.barY,this.barWidth,this.barHeight)}isOnTrack(t,e){return this.isPointInElement(t,e,this.trackX,this.trackY,this.trackWidth,this.trackHeight)}updateScroll(t){const e=t.deltaX,i=t.deltaY;this.type==="vertical"&&t.shiftKey===!1?(this.hasScrollbar()&&!(this.scroll===0&&i<0||this.scroll===this.distance&&i>0)&&t.preventDefault(),this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance))):this.type==="horizontal"&&(t.shiftKey?this.scroll=Math.max(0,Math.min(this.scroll+i,this.distance)):this.scroll=Math.max(0,Math.min(this.scroll+e,this.distance)))}updatedSize(){const{body:t,header:e,stageHeight:i,stageWidth:s,config:{SCROLLER_TRACK_SIZE:r=0,SCROLLER_SIZE:o=0}}=this.ctx,a=s,h=i,c=e.height,f=e.width,d=t.height,x=this.ctx.footer.height;if(this.type==="vertical"){this.visibleDistance=h-r-c,this.distance=d-this.visibleDistance+x,this.trackX=a-r,this.trackY=0,this.splitPoints=[this.trackX,c,this.trackX+r,c],this.trackWidth=r,this.trackHeight=h,this.barX=this.trackX-.5+(r-o)/2,this.barWidth=o;const u=this.distance?this.visibleDistance/d:0;let g=Math.floor(u*this.visibleDistance);g<30?g=30:g>this.visibleDistance&&(g=0),this.barHeight=g,this.barY=c+this.scroll/this.distance*(this.visibleDistance-this.barHeight),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}else{this.visibleDistance=a-r,this.distance=f-this.visibleDistance,this.splitPoints=[a-r,h-r,a-r,h],this.trackX=0,this.trackY=h-r,this.trackWidth=a,this.trackHeight=r;const u=this.distance?this.visibleDistance/f:0;let g=Math.floor(u*this.visibleDistance);this.barY=this.trackY-.5+(r-o)/2,g<30?g=30:g>=this.visibleDistance&&(g=0),this.barWidth=g,this.barHeight=o,this.barX=this.scroll/this.distance*(this.visibleDistance-this.barWidth),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}}draw(){const{config:{SCROLLER_FOCUS_COLOR:t,SCROLLER_COLOR:e,BORDER_COLOR:i,SCROLLER_TRACK_COLOR:s}}=this.ctx;this.updatedSize(),this.ctx.paint.drawRect(this.trackX,this.trackY,this.trackWidth,this.trackHeight,{borderColor:i,fillColor:s}),this.ctx.paint.drawRect(this.barX,this.barY,this.barWidth,this.barHeight,{fillColor:this.isFocus||this.isDragging?t:e,radius:4}),this.splitPoints.length>0&&this.ctx.paint.drawLine(this.splitPoints,{borderColor:i,borderWidth:1}),this.ctx.scrollerFocus=this.isFocus}}class ai{constructor(t){l(this,"ctx");l(this,"verticalScrollbar");l(this,"horizontalScrollbar");this.ctx=t,this.verticalScrollbar=new Qt(t,"vertical"),this.horizontalScrollbar=new Qt(t,"horizontal"),this.ctx.on("wheel",e=>this.onWheel(e)),this.ctx.on("mousedown",e=>this.onMouseDown(e)),this.ctx.on("mousemove",e=>this.onMouseMove(e)),this.ctx.on("mouseup",()=>this.onMouseUp()),this.ctx.on("setScroll",(e,i)=>{this.setScroll(e,i)}),this.ctx.on("setScrollX",e=>{this.setScrollX(e)}),this.ctx.on("setScrollY",e=>{this.setScrollY(e)})}onWheel(t){this.verticalScrollbar.onWheel(t),this.horizontalScrollbar.onWheel(t),this.draw()}onMouseDown(t){this.verticalScrollbar.onMouseDown(t),this.horizontalScrollbar.onMouseDown(t),this.draw()}onMouseMove(t){this.verticalScrollbar.onMouseMove(t),this.horizontalScrollbar.onMouseMove(t),this.draw()}onMouseUp(){this.verticalScrollbar.onMouseUp(),this.horizontalScrollbar.onMouseUp(),this.ctx.scrollerMove=!1}draw(){this.verticalScrollbar.draw(),this.horizontalScrollbar.draw();const t=Math.floor(this.horizontalScrollbar.scroll),e=Math.floor(this.verticalScrollbar.scroll);(t!==this.ctx.scrollX||e!==this.ctx.scrollY)&&(this.ctx.emit("onScroll",t,e),t!==this.ctx.scrollX&&this.ctx.emit("onScrollX",t),e!==this.ctx.scrollY&&this.ctx.emit("onScrollY",e),this.ctx.scrollX=t,this.ctx.scrollY=e,this.ctx.emit("draw"))}setScroll(t,e){this.horizontalScrollbar.scroll=t,this.verticalScrollbar.scroll=e,this.ctx.emit("draw")}setScrollX(t){this.horizontalScrollbar.scroll=t,this.ctx.emit("draw")}setScrollY(t){this.verticalScrollbar.scroll=t,this.ctx.emit("draw")}scrollToColkey(t){const{header:e}=this.ctx,i=e.leafCellHeaders.find(s=>s.key===t);i&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToColIndex(t){const{header:e}=this.ctx,i=e.leafCellHeaders.find(s=>s.colIndex===t);i&&i.x>e.visibleWidth/2&&this.setScrollX(i.x-e.visibleWidth/2)}scrollToRowIndex(t){const{body:e,database:i}=this.ctx,{top:s}=i.getPositionForRowIndex(t);s>e.visibleHeight&&this.setScrollY(s-e.visibleHeight/2)}scrollToRowKey(t){const{body:e,database:i}=this.ctx,s=i.getRowIndexForRowKey(t),{top:r}=i.getPositionForRowIndex(s);this.setScrollY(r-e.visibleHeight/2)}}class li{constructor(t){l(this,"ctx");l(this,"x",0);l(this,"y",0);l(this,"width",0);l(this,"height",0);l(this,"resizeTarget",null);l(this,"resizeNum",0);l(this,"isResizing",!1);l(this,"clientX",0);l(this,"resizeDiff",0);l(this,"columnIndex",0);l(this,"isMouseDown",!1);l(this,"columns");l(this,"visibleLeafColumns",[]);l(this,"visibleHeight",0);l(this,"visibleWidth",0);l(this,"allCellHeaders",[]);l(this,"leafCellHeaders",[]);l(this,"renderLeafCellHeaders",[]);l(this,"fixedLeftCellHeaders",[]);l(this,"centerCellHeaders",[]);l(this,"fixedRightCellHeaders",[]);l(this,"renderCenterCellHeaders",[]);l(this,"renderFixedCellHeaders",[]);this.ctx=t,this.ctx.on("resetHeader",Vt(()=>{this.init(),this.ctx.emit("draw")},100)),this.init(),this.initResizeColumn()}init(){const{config:{HEADER_HEIGHT:t,SCROLLER_TRACK_SIZE:e}}=this.ctx,i=this.ctx.database.getColumns();this.columns=i,this.allCellHeaders=[],this.leafCellHeaders=[],this.fixedLeftCellHeaders=[],this.fixedRightCellHeaders=[],this.centerCellHeaders=[];const s=zt(i),r=_t(i);this.height=t*s,this.width=r.reduce((d,x)=>d+((x==null?void 0:x.width)||100),0),this.visibleHeight=this.height;const o=je($t(i,s));this.columnIndex=0,this.resizeNum=0,this.render(o,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);const a=this.ctx.containerElement.getBoundingClientRect();this.resizeNum>0?this.ctx.stageWidth=Math.floor(a.width):this.ctx.stageWidth=Math.floor(this.width+e),this.ctx.stageElement.style.width=this.ctx.stageWidth-.5+"px",this.visibleWidth=this.ctx.stageWidth-e;const h=this.visibleWidth-this.width;if(this.resizeNum&&h>0){const d=Math.floor(h/this.resizeNum*100)/100;this.resizeAllColumn(d)}const c=this.fixedLeftCellHeaders.filter(d=>!d.hasChildren);this.ctx.fixedLeftWidth=c.reduce((d,x)=>d+x.width,0);const f=this.fixedRightCellHeaders.filter(d=>!d.hasChildren);this.ctx.fixedRightWidth=f.reduce((d,x)=>d+x.width,e),this.ctx.maxColIndex=this.leafCellHeaders.length-1,this.ctx.header.x=this.x,this.ctx.header.y=this.y,this.ctx.header.width=this.width,this.ctx.header.height=this.height,this.ctx.header.visibleWidth=this.visibleWidth,this.ctx.header.visibleHeight=this.visibleHeight}initResizeColumn(){const{config:{ENABLE_RESIZE_COLUMN:t}}=this.ctx;t&&(this.ctx.on("mousedown",e=>{this.ctx.isTarget()&&(this.clientX=e.clientX,this.resizeTarget?(this.isResizing=!0,this.ctx.columnResizing=!0):this.isResizing=!1,this.isMouseDown=!0)}),this.ctx.on("mouseup",()=>{this.isMouseDown=!1,this.resizeDiff!==0&&this.resizeTarget&&this.resizeColumn(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.isResizing=!1,this.ctx.columnResizing=!1,this.clientX=0}),this.ctx.on("mousemove",e=>{if(this.ctx.editing)return;const{stageWidth:i,config:{RESIZE_COLUMN_MIN_WIDTH:s}}=this.ctx;if(this.isResizing&&this.resizeTarget){const r=this.resizeTarget.width;let o=e.clientX-this.clientX;o+r<s&&(o=-(r-s)),this.resizeDiff=o,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;this.ctx.stageElement.style.cursor==="col-resize"&&(this.ctx.stageElement.style.cursor="default");const r=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(const o of r){const{offsetX:a,offsetY:h}=this.ctx.getOffset(e),c=a,f=o.getDrawX();c>f+o.width-5&&c<f+o.width+4&&c<i-4&&o.colspan<=1&&this.ctx.isTarget()&&h<=this.height&&(this.ctx.stageElement.style.cursor="col-resize",this.resizeTarget=o)}}}))}resizeColumn(t,e){const i=r=>{r.forEach(o=>{if(o.children&&o.children.length>0&&i(o.children),o.key===t.key){const a=o.width||100;o.width=a+e}})};i(this.columns),this.ctx.database.setColumns(this.columns),this.init(),this.ctx.emit("draw");let s=0;if(this.width<this.visibleWidth){const r=this.visibleWidth-this.width;s=Math.floor(r/this.resizeNum*100)/100,this.resizeAllColumn(s),this.ctx.emit("draw")}this.ctx.emit("resizeColumnChange",{colIndex:t.colIndex,key:t.key,oldWidth:t.width,width:t.width+e+s,column:t.column,columns:this.columns})}resizeAllColumn(t){if(t===0)return;const e=new Map;let i=!0;for(const r of this.allCellHeaders)if(r.widthFillDisable)e.set(r.key,r.width);else{const o=r.width+t*r.colspan;e.set(r.key,o),o<this.ctx.config.RESIZE_COLUMN_MIN_WIDTH&&(i=!1)}if(!i)return;const s=r=>{r.forEach(o=>{e.has(o.key)&&(o.width=e.get(o.key)),o.children&&o.children.length>0&&s(o.children)})};s(this.columns),this.ctx.database.setColumns(this.columns),this.init()}render(t,e){const i=t.length;let s=e;const{HEADER_HEIGHT:r=0}=this.ctx.config;for(let o=0;o<i;o++){const a=t[o],h=r*(a.rowspan||1),c=r*a.level;let f=a.width||100;a.children&&(f=_t(a.children).reduce((u,g)=>u+((g==null?void 0:g.width)||100),0));const d=new Jt(this.ctx,this.columnIndex,s,c,f,h,a);this.ctx.database.setHeader(a.key,d),this.allCellHeaders.push(d),a.children||(this.leafCellHeaders.push(d),d.column.widthFillDisable||this.resizeNum++),a.fixed==="left"?this.fixedLeftCellHeaders.push(d):a.fixed==="right"?this.fixedRightCellHeaders.push(d):this.centerCellHeaders.push(d),!a.children&&this.columnIndex++,a.children&&this.render(a.children,s),s+=f}}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageHeight:t,config:{RESIZE_COLUMN_LINE_COLOR:e}}=this.ctx,i=this.resizeTarget.getDrawX(),s=this.resizeTarget.width,r=i+s+this.resizeDiff-.5,o=[r-.5,0,r-.5,t];this.ctx.paint.drawLine(o,{borderColor:e,borderWidth:1})}}drawFiexShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:a}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:o,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==a){const h=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(h+1,this.y,e,this.height,{fillColor:o,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){const t=[],e=[],i=[];this.centerCellHeaders.forEach(s=>{s.isHorizontalVisible()&&s.isVerticalVisible()&&(e.push(s),s.hasChildren||t.push(s))}),this.fixedLeftCellHeaders.forEach(s=>{i.push(s),s.hasChildren||t.push(s)}),this.fixedRightCellHeaders.forEach(s=>{i.push(s),s.hasChildren||t.push(s)}),this.renderCenterCellHeaders=e,this.renderFixedCellHeaders=i,this.renderLeafCellHeaders=t.sort((s,r)=>s.x-r.x),this.visibleLeafColumns=this.renderLeafCellHeaders.map(s=>s.column),this.ctx.header.visibleLeafColumns=this.visibleLeafColumns,this.ctx.header.leafCellHeaders=this.leafCellHeaders,this.ctx.header.renderLeafCellHeaders=this.renderLeafCellHeaders,this.ctx.header.renderCellHeaders=this.renderFixedCellHeaders.concat(this.renderCenterCellHeaders)}draw(){this.renderCenterCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawFiexShadow(),this.renderFixedCellHeaders.forEach(t=>{t.update(),t.draw()}),this.drawTipLine()}}class te{constructor(t,e,i=0,s=0,r=0,o=0,a,h="body"){l(this,"ctx");l(this,"x",0);l(this,"y",0);l(this,"width",0);l(this,"height");l(this,"cells",[]);l(this,"fixedCells",[]);l(this,"noFixedCells",[]);l(this,"rowIndex",0);l(this,"rowKey","");l(this,"rowType","body");l(this,"data");this.ctx=t,this.x=i,this.y=s,this.width=r,this.height=o,this.rowIndex=e,this.rowKey=t.database.getRowKeyForRowIndex(e),this.rowType=h,this.data=a,this.update()}update(){const{header:t}=this.ctx,e=[],i=[],s=[];t.renderLeafCellHeaders.forEach(r=>{const o=new Zt(this.ctx,this.rowIndex,r.colIndex,r.x,this.y,r.width,this.height,r.column,this.data,this.rowType);o.fixed?i.push(o):s.push(o),e.push(o)}),this.cells=e,this.fixedCells=i,this.noFixedCells=s}drawCenter(){this.noFixedCells.forEach(t=>{t.draw()})}drawFixed(){this.fixedCells.forEach(t=>{t.draw()})}draw(){this.noFixedCells.forEach(t=>{t.draw()}),this.fixedCells.forEach(t=>{t.draw()})}}class hi{constructor(t){l(this,"resizeTarget",null);l(this,"isMouseDown",!1);l(this,"resizeDiff",0);l(this,"clientY",0);l(this,"ctx");l(this,"x",0);l(this,"y",0);l(this,"width",0);l(this,"height",0);l(this,"headIndex",0);l(this,"tailIndex",0);l(this,"isResizing",!1);l(this,"renderRows",[]);l(this,"visibleRows",[]);l(this,"visibleHeight",0);l(this,"visibleWidth",0);l(this,"data",[]);this.ctx=t,this.init(),this.initResizeRow()}init(){const{canvasElement:t,header:e,database:i,config:{FOOTER_FIXED:s,SCROLLER_TRACK_SIZE:r=0,HEIGHT:o,EMPTY_BODY_HEIGHT:a=0,MAX_HEIGHT:h=0,ENABLE_OFFSET_HEIGHT:c=0,OFFSET_HEIGHT:f=0}}=this.ctx;if(!e.width)return;this.x=0,this.y=e.height;const{data:d,sumHeight:x}=i.getData();this.height=x,this.data=d;const{top:u}=t.getBoundingClientRect();this.width=e.width,this.visibleWidth=this.ctx.stageWidth-r;const g=this.ctx.footer.height;this.data.length||(this.height=a);const w=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:w,type:w,headerHeight:e.height,bodyHeight:this.height,footerHeight:g,width:this.width,height:this.data.length?0:a+g});let p=this.height+e.height+r;p+=g;let y=0;this.data.length&&c?(y=window.innerHeight-u-f,y<0&&(y=32,console.error("There is an error in the height calculation ENABLE_OFFSET_HEIGHT and OFFSET_HEIGHT are invalid"))):this.data.length&&o?y=o:this.data.length&&h&&p>h?y=h:y=p,y>0&&(this.ctx.stageHeight=Math.floor(y),this.ctx.stageElement.style.height=`${this.ctx.stageHeight-.5}px`);let b=this.ctx.stageHeight-e.height-r;s?this.visibleHeight=b-g:this.visibleHeight=b,this.ctx.body.x=this.x,this.ctx.body.y=this.y,this.ctx.body.width=this.width,this.ctx.body.height=this.height,this.ctx.body.visibleWidth=this.visibleWidth,this.ctx.body.visibleHeight=this.visibleHeight,this.ctx.body.data=d;const m=window.devicePixelRatio||1,E=this.ctx.stageWidth*m,C=this.ctx.stageHeight*m;t.width=Math.floor(E),t.height=Math.floor(C),this.ctx.canvasElement.setAttribute("style",` height:${this.ctx.stageHeight}px;width:${this.ctx.stageWidth}px;`),this.ctx.paint.scale(m)}initResizeRow(){const{config:{ENABLE_RESIZE_ROW:t}}=this.ctx;t&&(this.ctx.on("mouseup",()=>{this.isMouseDown=!1,this.resizeDiff!==0&&this.resizeTarget&&this.resizeRow(this.resizeTarget,this.resizeDiff),this.resizeTarget=null,this.resizeDiff=0,this.isResizing=!1,setTimeout(()=>{this.ctx.rowResizing=!1},0),this.clientY=0}),this.ctx.on("mousedown",e=>{this.ctx.isTarget()&&(this.clientY=e.clientY,this.resizeTarget?(this.isResizing=!0,this.ctx.rowResizing=!0):(this.isResizing=!1,this.ctx.rowResizing=!1),this.isMouseDown=!0)}),this.ctx.on("mousemove",e=>{if(this.ctx.editing)return;const{offsetY:i,offsetX:s}=this.ctx.getOffset(e),r=i,o=s,a=e.clientY,{stageHeight:h,scrollY:c,config:{RESIZE_ROW_MIN_HEIGHT:f=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){const d=this.resizeTarget.height;let x=a-this.clientY;x+d<f&&(x=-(d-f)),this.resizeDiff=x,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown||this.ctx.stageElement.style.cursor==="crosshair")return;this.ctx.stageElement.style.cursor==="row-resize"&&(this.ctx.stageElement.style.cursor="default");for(let d=0;d<this.renderRows.length;d++){const x=this.renderRows[d];if(r>x.y-c+x.height-1.5&&r<x.y-c+x.height+1.5&&r<h-4)for(let g=0;g<x.cells.length;g++){const w=x.cells[g];o>w.drawX+10&&o<w.drawX+w.width-10&&w.rowspan===1&&(this.ctx.stageElement.style.cursor="row-resize",this.resizeTarget=x)}}}}))}resizeRow(t,e){const{rowIndex:i,height:s,rowKey:r,data:o}=t;this.ctx.database.setRowHeight(i,s+e),this.init(),this.ctx.emit("draw"),this.ctx.emit("resizeRowChange",{rowIndex:i,oldHeight:s,height:s+e,rowKey:r,row:o,data:this.data})}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{stageWidth:t,scrollY:e,config:{RESIZE_ROW_LINE_COLOR:i}}=this.ctx,s=this.resizeTarget.y-e,r=this.resizeTarget.height,o=s+r+this.resizeDiff-.5,a=[0,o-.5,t,o-.5];this.ctx.paint.drawLine(a,{borderColor:i,borderWidth:1})}}drawFiexShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:a}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:o,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==a){const h=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(h+1,this.y,e,this.height,{fillColor:o,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}binarySearch(t,e){let i=0,s=t.length-1,r=-1;for(;i<=s;){let o=Math.floor((i+s)/2),a=t[o].bottom;if(a===e)return o;a<e?i=o+1:(r=o,s=o-1)}return r}update(){this.init();const{header:t,database:e,scrollY:i}=this.ctx,s=i,{data:r,positions:o}=e.getData();this.ctx.maxRowIndex=r.length-1;const a=this.binarySearch(o,s);let h=this.binarySearch(o,s+this.visibleHeight);h===-1&&(h=r.length),this.headIndex=Math.max(0,a),this.tailIndex=Math.min(this.ctx.maxRowIndex,h+1),this.visibleRows=r.slice(this.headIndex,this.tailIndex+1),this.ctx.body.headIndex=this.headIndex,this.ctx.body.tailIndex=this.tailIndex,this.ctx.body.visibleRows=this.visibleRows;const c=[];for(let f=0;f<this.visibleRows.length;f++){const d=this.headIndex+f,x=this.visibleRows[f],{height:u,top:g}=this.ctx.database.getPositionForRowIndex(d),w=new te(this.ctx,d,0,g+this.y,t.width,u,x);c.push(w)}this.renderRows=c,this.ctx.body.renderRows=c}draw(){this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFiexShadow(),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTipLine()}}class ci{constructor(t){l(this,"ctx");l(this,"renderRows",[]);l(this,"data",[]);l(this,"x",0);l(this,"y",0);l(this,"width",0);l(this,"height",0);l(this,"visibleWidth",0);l(this,"visibleHeight",0);this.ctx=t,this.init()}init(){this.data=this.ctx.database.getFooterData();const{header:t,body:e,config:{CELL_FOOTER_HEIGHT:i,FOOTER_FIXED:s,SCROLLER_TRACK_SIZE:r}}=this.ctx;this.width=t.width,this.visibleWidth=t.visibleWidth,this.height=this.data.reduce(o=>o+i,0),this.visibleHeight=this.height,s?this.y=this.ctx.stageHeight-this.height-r:this.y=e.y+e.height,this.ctx.footer.x=this.x,this.ctx.footer.y=this.y,this.ctx.footer.height=this.height,this.ctx.footer.width=this.width,this.ctx.footer.visibleWidth=this.visibleWidth,this.ctx.footer.visibleHeight=this.visibleHeight}drawFiexShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,stageWidth:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:a}}=this.ctx;let h=this.y;if(this.ctx.config.FOOTER_FIXED||(h=this.y-this.ctx.scrollY),i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,h,t,this.height,{fillColor:o,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-r-1)&&e!==a){const c=s.width-(this.x+this.width)+r-e;this.ctx.paint.drawShadow(c+1,h,e,this.height,{fillColor:o,side:"left",shadowWidth:4,colorStart:"rgba(0,0,0,0)",colorEnd:"rgba(0,0,0,0.1)"})}}update(){this.init();const{CELL_FOOTER_HEIGHT:t}=this.ctx.config;let e=this.y;const i=[];this.data.forEach((s,r)=>{const o=new te(this.ctx,r,0,e,this.width,t,s,"footer");e+=t,i.push(o)}),this.renderRows=i,this.ctx.footer.renderRows=this.renderRows}draw(){this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFiexShadow(),this.renderRows.forEach(t=>{t.drawFixed()})}}class di{constructor(t){l(this,"isCut",!1);l(this,"isMultipleRow",!1);l(this,"mousedownHeader",!1);l(this,"ctx");l(this,"adjustPositionX","");l(this,"adjustPositionY","");l(this,"timerX",0);l(this,"timerY",0);this.ctx=t,this.init()}init(){this.ctx.on("mousemove",Vt(t=>{const{offsetY:e,offsetX:i}=this.ctx.getOffset(t),s=this.ctx.isTarget()&&i>0&&i<this.ctx.body.visibleWidth&&e>this.ctx.header.visibleHeight&&e<this.ctx.header.visibleHeight+this.ctx.body.visibleHeight;(this.ctx.selectorMove||this.ctx.autofillMove)&&(!s&&!this.mousedownHeader?this.startAdjustPosition(t):this.stopAdjustPosition())},100)),this.ctx.on("cellHoverChange",t=>{if(!this.ctx.autofillMove){if(t.operation){this.selectRows(t,!1);return}this.isMultipleRow||this.mouseenter()}}),this.ctx.on("cellMousedown",(t,e)=>{if(this.ctx.isTarget()&&this.ctx.stageElement.style.cursor!=="pointer"&&!this.ctx.isPointer&&this.ctx.stageElement.style.cursor!=="crosshair"){if(t.operation){this.isMultipleRow=!0,this.selectRows(t);return}this.isMultipleRow=!1,this.click(e.shiftKey)}}),this.ctx.on("mouseup",()=>{this.mousedownHeader=!1;const t=setTimeout(()=>{this.ctx.adjustPositioning=!1,clearTimeout(t)},0)}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHeaderMousedown",t=>{this.ctx.stageElement.style.cursor!=="pointer"&&(this.ctx.isPointer||(this.mousedownHeader=!0,this.selectCols(t)))}),this.ctx.on("keydown",t=>{if(t.ctrlKey&&t.code==="KeyV"||t.metaKey&&t.code==="KeyV"){t.preventDefault(),this.paste();return}if(t.ctrlKey&&t.code==="KeyC"||t.metaKey&&t.code==="KeyC"){t.preventDefault(),this.copy(),this.isCut=!1;return}if(t.ctrlKey&&t.code==="KeyX"||t.metaKey&&t.code==="KeyX"){t.preventDefault(),this.isCut=!0,this.copy();return}if((t.ctrlKey&&t.code==="KeyA"||t.metaKey&&t.code==="KeyA")&&(t.preventDefault(),this.selectAll()),t.code==="ArrowLeft"){t.preventDefault(),this.moveFocus("LEFT");return}if(t.code==="ArrowUp"){t.preventDefault(),this.moveFocus("TOP");return}if(t.code==="ArrowRight"||t.code==="Tab"){t.preventDefault(),this.moveFocus("RIGHT");return}if(t.code==="ArrowDown"){t.preventDefault(),this.moveFocus("BOTTOM");return}if(t.code==="Delete"||t.code==="Backspace"){t.preventDefault();const{xArr:e,yArr:i}=this.ctx.selector;this.clearSelectedData(e,i);return}}),this.ctx.on("contextMenuClearSelected",()=>{const{xArr:t,yArr:e}=this.ctx.selector;this.clearSelectedData(t,e)}),this.ctx.on("contextMenuCopy",()=>{this.copy()}),this.ctx.on("contextMenuPaste",()=>{this.paste()}),this.ctx.on("contextMenuCut",()=>{this.isCut=!0,this.copy()}),this.ctx.on("setSelectorCell",t=>{this.ctx.setFocusCell(t),this.click()}),this.ctx.on("mouseup",()=>{this.ctx.selectorMove=!1,this.stopAdjustPosition()})}setSelector(t,e){const{ENABLE_SELECTOR_SPAN_COL:i,ENABLE_SELECTOR_SPAN_ROW:s}=this.ctx.config;let r=t,o=e;if(!s){const[a]=o;o=[a,a]}if(!i){const[a]=r;r=[a,a]}if(JSON.stringify(this.ctx.selector.xArr)!==JSON.stringify(r)||JSON.stringify(this.ctx.selector.yArr)!==JSON.stringify(o)){this.ctx.mousedown&&(this.ctx.selectorMove=!0),this.ctx.selector.enable=!0;const{SELECTOR_AREA_MIN_X:a,SELECTOR_AREA_MAX_X:h,SELECTOR_AREA_MIN_Y:c,SELECTOR_AREA_MAX_Y:f,SELECTOR_AREA_MAX_X_OFFSET:d,SELECTOR_AREA_MAX_Y_OFFSET:x}=this.ctx.config,u=a,g=h||this.ctx.maxColIndex-d,w=c,p=f||this.ctx.maxRowIndex-x;let[y,b]=r,[m,E]=o;if(y<u||b>g||m<w||E>p)return;this.ctx.selector.xArr=[Math.max(u,y),Math.min(g,b)],this.ctx.selector.yArr=[Math.max(w,m),Math.min(p,E)],this.ctx.emit("setSelector",this.ctx.selector),this.ctx.emit("drawView")}}selectCols(t){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_ROWS||this.ctx.autofillMove||this.ctx.columnResizing||this.ctx.editing)return;if(t.operation){this.selectAll();return}const{SELECTOR_AREA_MIN_Y:e,SELECTOR_AREA_MAX_Y:i,SELECTOR_AREA_MAX_Y_OFFSET:s}=this.ctx.config,r=e,o=i||this.ctx.maxRowIndex-s;if(this.ctx.mousedown&&this.ctx.focusCellHeader){const{colIndex:a}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),t.colIndex>=a){const h=[a,t.colIndex+t.colspan-1],c=[r,o];this.setSelector(h,c)}else{const h=[t.colIndex,a],c=[r,o];this.setSelector(h,c)}}else{const a=[t.colIndex,t.colIndex+t.colspan-1],h=[r,o];this.setSelector(a,h)}}selectAll(){if(this.ctx.autofillMove||this.ctx.editing)return;const{ENABLE_SELECTOR_ALL_ROWS:t,ENABLE_SELECTOR_ALL_COLS:e}=this.ctx.config;if(t&&e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:r,SELECTOR_AREA_MAX_Y:o,SELECTOR_AREA_MAX_X_OFFSET:a,SELECTOR_AREA_MAX_Y_OFFSET:h}=this.ctx.config,c=i,f=s||this.ctx.maxColIndex-a,d=r,x=o||this.ctx.maxRowIndex-h,u=[c,f],g=[d,x];this.setSelector(u,g)}}selectRows(t,e=!0){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||!this.ctx.config.ENABLE_SELECTOR_ALL_COLS||this.ctx.autofillMove||this.ctx.editing)return;const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MAX_X_OFFSET:r}=this.ctx.config,o=s||this.ctx.maxColIndex-r,a=i;if(e){this.ctx.setFocusCell(t);const h=[a,o],c=[t.rowIndex,t.rowIndex];this.setSelector(h,c)}if(this.ctx.focusCell&&this.ctx.mousedown){const{rowIndex:h}=this.ctx.focusCell;if(t.rowIndex>=h){const c=[a,o],f=[h,t.rowIndex];this.setSelector(c,f)}else{const c=[a,o],f=[t.rowIndex,h];this.setSelector(c,f)}}}mouseenter(){if(this.ctx.config.ENABLE_SELECTOR_SINGLE||this.ctx.editing)return;const{mousedown:t,focusCell:e,hoverCell:i}=this.ctx;if(t&&e&&i){const{rowIndex:s,colIndex:r}=e,o=Math.min(i.colIndex,r),a=Math.max(i.colIndex,r),h=Math.min(i.rowIndex,s),c=Math.max(i.rowIndex,s),f=[o,a],d=[h,c];this.setSelector(f,d)}}click(t=!1){const{focusCell:e,clickCell:i}=this.ctx;if(e&&this.isInSettingRange(e.rowIndex,e.colIndex))if(this.ctx.selector.enable=!0,i&&t){const{colIndex:s,rowIndex:r}=i,{colIndex:o,rowIndex:a}=e,h=Math.min(o,s),c=Math.max(o,s),f=Math.min(a,r),d=Math.max(a,r),x=[h,c],u=[f,d];this.setSelector(x,u)}else{this.ctx.emit("cellSelectedClick",e);const s=[e.colIndex,e.colIndex],r=[e.rowIndex,e.rowIndex];this.setSelector(s,r),this.adjustBoundaryPosition()}}clearCopyLine(){this.ctx.selector.xArrCopy=[-1,-1],this.ctx.selector.yArrCopy=[-1,-1]}getCell(t,e){const i=this.ctx.body.renderRows.find(r=>r.rowIndex===t);return i==null?void 0:i.cells.find(r=>r.colIndex===e)}copy(){if(!this.ctx.config.ENABLE_COPY)return;const{value:t}=this.ctx.getSelectedData(),e=Je(t);navigator.clipboard?navigator.clipboard.writeText(e).then(()=>{this.ctx.selector.xArrCopy=this.ctx.selector.xArr.slice(),this.ctx.selector.yArrCopy=this.ctx.selector.yArr.slice(),this.ctx.emit("copyChange",{xArr:this.ctx.selector.xArrCopy,yArr:this.ctx.selector.yArrCopy,data:t}),this.ctx.emit("draw")}).catch(i=>console.error("复制失败:",i)):console.error("当前浏览器不支持Clipboard API")}clearSelectedData(t,e,i=!1){let s=[];const r=new Set;for(let a=0;a<=e[1]-e[0];a++)for(let h=0;h<=t[1]-t[0];h++){const c=a+e[0],f=h+t[0],d=this.ctx.database.getItemValueForRowIndexAndColIndex(c,f);if(d){const{rowKey:x,key:u}=d;this.ctx.database.getReadonly(x,u)||(r.add(x),s.push({rowKey:x,key:u,value:null,row:{}}))}}if(!s.length)return[];if(i)return s;this.ctx.database.batchSetItemValue(s,!0);let o=[];return r.forEach(a=>{o.push(this.ctx.database.getRowDataItemForRowKey(a))}),this.ctx.emit("clearSelectedDataChange",s,o),s}paste(){if(!navigator.clipboard){console.error("当前浏览器不支持Clipboard API");return}const{ENABLE_PASTER:t}=this.ctx.config;if(this.ctx.selector.enable&&t){const e=this.ctx.selector.yArr[0],i=this.ctx.selector.xArr[0],s=new Set;navigator.clipboard.readText().then(async r=>{let o=Ze(r),a=[];for(let f=0;f<=o.length-1;f++){const d=o[f].length;for(let x=0;x<=d-1;x++){const u=f+e,g=x+i,w=o[f][x],p=this.ctx.database.getItemValueForRowIndexAndColIndex(u,g);if(p){const{rowKey:y,key:b}=p;this.ctx.database.getReadonly(y,b)||(s.add(y),a.push({rowKey:y,key:b,value:w,row:{}}))}}}if(this.isCut){const f=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),d=a.map(x=>`${x.rowKey}-${x.key}`);f.forEach(x=>{d.includes(`${x.rowKey}-${x.key}`)||a.unshift(x)}),this.isCut=!1}if(!a.length)return;const{BEFORE_PASTE_CHANGE_METHOD:h}=this.ctx.config;if(typeof h=="function"){const f=h,d=a.map(x=>({rowKey:x.rowKey,key:x.key,value:x.value,oldValue:this.ctx.database.getItemValue(x.rowKey,x.key),row:this.ctx.database.getRowDataItemForRowKey(x.rowKey)}));a=await f(d)}this.clearCopyLine(),this.ctx.database.batchSetItemValue(a,!0);let c=[];s.forEach(f=>{c.push(this.ctx.database.getRowDataItemForRowKey(f))}),this.ctx.emit("pasteChange",a,c)}).catch(r=>{console.error("获取剪贴板内容失败:",r)})}}moveFocus(t){if(this.ctx.editing)return;const{focusCell:e}=this.ctx;if(!e)return;let{colIndex:i=0,rowIndex:s=0}=e;const r=0,o=0,a=this.ctx.maxColIndex,h=this.ctx.maxRowIndex;switch(t){case"LEFT":i>r&&i--;break;case"TOP":s>o&&s--;break;case"RIGHT":i<a&&i++;break;case"BOTTOM":s<h&&s++;break}const c=[i,i],f=[s,s],d=this.getCell(s,i);d&&(d.operation||this.isInSettingRange(d.rowIndex,d.colIndex)&&(this.ctx.setFocusCell(d),this.setSelector(c,f),this.adjustBoundaryPosition(),this.ctx.emit("draw")))}stopAdjustPosition(){this.adjustPositionX="",this.adjustPositionY="",this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerY&&(clearInterval(this.timerY),this.timerY=0)}isInSettingRange(t,e){const{SELECTOR_AREA_MIN_X:i,SELECTOR_AREA_MAX_X:s,SELECTOR_AREA_MIN_Y:r,SELECTOR_AREA_MAX_Y:o,SELECTOR_AREA_MAX_X_OFFSET:a,SELECTOR_AREA_MAX_Y_OFFSET:h}=this.ctx.config,c=i,f=s||this.ctx.maxColIndex-a,d=r,x=o||this.ctx.maxRowIndex-h;return!(e<c||e>f||t<d||t>x)}startAdjustPosition(t){const{offsetX:e,offsetY:i}=this.ctx.getOffset(t);let s="",r="";if(e<0?s="left":e>this.ctx.body.visibleWidth&&(s="right"),i<this.ctx.header.visibleHeight?r="top":i>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight&&(r="bottom"),s&&this.adjustPositionX!==s){this.adjustPositionX=s;let a=10*(s==="left"?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{a*=1.5;const{scrollX:h}=this.ctx,c=h+a;(c<0||c>this.ctx.body.width)&&(clearInterval(this.timerX),this.timerX=0),this.ctx.setScrollX(c)},100)}if(r&&this.adjustPositionY!==r){this.adjustPositionY=r;let a=10*(r==="top"?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{a*=1.5;const{scrollY:h}=this.ctx,c=h+a;(c<0||c>this.ctx.body.height)&&(clearInterval(this.timerY),this.timerY=0),this.ctx.setScrollY(c)},100)}}adjustBoundaryPosition(){const{stageHeight:t,stageWidth:e,focusCell:i,fixedRightWidth:s,fixedLeftWidth:r,header:o,footer:a,body:h,scrollX:c,scrollY:f,config:{SCROLLER_TRACK_SIZE:d,FOOTER_FIXED:x}}=this.ctx;if(!i)return;const u=r-i.drawX+1,g=i.drawX+i.width-(e-s)+1,w=o.height-i.drawY;let p=i.height;p>h.visibleHeight&&(p=h.visibleHeight);let y=0;x&&(y=a.visibleHeight);const b=i.drawY+p-(t-y-d);let m=c,E=f;g>0&&!i.fixed?m=Math.floor(c+g):u>0&&!i.fixed&&(m=Math.floor(c-u)),w>0?E=Math.floor(f-w):b>0&&(E=Math.floor(f+b)),(Math.abs(c-m)>2||Math.abs(f-E)>2)&&(this.ctx.adjustPositioning=!0,this.ctx.setScroll(m,E),this.ctx.emit("adjustBoundaryPosition",i))}destroy(){this.timerX&&(clearTimeout(this.timerX),this.timerX=0),this.timerY&&(clearTimeout(this.timerY),this.timerY=0)}}class fi{constructor(t){l(this,"ctx");this.ctx=t,this.init()}init(){this.ctx.on("cellMouseenter",(t,e)=>{this.ctx.stageElement.style.cursor==="crosshair"&&(this.ctx.stageElement.style.cursor="default");const{offsetX:i,offsetY:s}=this.ctx.getOffset(e),{xArr:r,yArr:o}=this.ctx.selector,a=r[1],h=o[1],{colIndex:c,rowIndex:f,drawX:d,drawY:x,width:u,height:g}=t;if(this.ctx.config.ENABLE_AUTOFILL&&c===a&&f===h){const p=d+u-6,y=x+g-6;i>p&&s>y&&(this.ctx.stageElement.style.cursor="crosshair")}this.mouseenter(t)}),this.ctx.on("cellMousedown",()=>{this.ctx.stageElement.style.cursor==="crosshair"&&this.setMousedown()}),this.ctx.on("mouseup",()=>{this.setMouseUp()})}isAutofillIng(){const{xArr:t,yArr:e}=this.ctx.selector;return!(JSON.stringify(this.ctx.autofill.xArr)===JSON.stringify(t)&&JSON.stringify(this.ctx.autofill.yArr)===JSON.stringify(e))}setMousedown(){this.ctx.autofill.enable=!0,this.ctx.autofillMove=!0}setMouseUp(){if(!this.ctx.autofill.enable)return;this.isAutofillIng()&&this.autofillData(),this.ctx.autofill.enable=!1,this.ctx.autofillMove=!1,this.ctx.autofill.xArr=[-1,-1],this.ctx.autofill.yArr=[-1,-1]}setAutofill(t,e){const{ENABLE_AUTOFILL:i,ENABLE_SELECTOR_SPAN_COL:s,ENABLE_SELECTOR_SPAN_ROW:r}=this.ctx.config;if(!i)return;let o=t,a=e;if(!r){const[h]=a;a=[h,h]}if(!s){const[h]=o;o=[h,h]}if(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(o)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(a)){const{SELECTOR_AREA_MIN_X:h,SELECTOR_AREA_MAX_X:c,SELECTOR_AREA_MIN_Y:f,SELECTOR_AREA_MAX_Y:d,SELECTOR_AREA_MAX_X_OFFSET:x,SELECTOR_AREA_MAX_Y_OFFSET:u}=this.ctx.config,g=h,w=c||this.ctx.maxColIndex-x,p=f,y=d||this.ctx.maxRowIndex-u;let[b,m]=o,[E,C]=a;if(b<g||E<p)return;this.ctx.autofill.xArr=[Math.max(g,b),Math.min(w,m)],this.ctx.autofill.yArr=[Math.max(p,E),Math.min(y,C)],this.ctx.emit("setAutofill",this.ctx.autofill),this.ctx.emit("draw")}}async autofillData(){const t=new Set,e=this.ctx.getSelectedData(),i=new Map;for(let x=0;x<=e.yArr[1]-e.yArr[0];x++)for(let u=0;u<=e.xArr[1]-e.xArr[0];u++){const g=x+e.yArr[0],w=u+e.xArr[0];i.set(`${g}-${w}`,!0)}const{value:s}=e,r=s[0].length,o=s.length,a=this.ctx.autofill.xArr,h=this.ctx.autofill.yArr;let c=[];for(let x=0;x<=h[1]-h[0];x++)for(let u=0;u<=a[1]-a[0];u++){const g=u+a[0],w=x+h[0],p=s[x%o][u%r],y=this.ctx.database.getItemValueForRowIndexAndColIndex(w,g),b=`${w}-${g}`;if(y&&!i.has(b)){const{rowKey:m,key:E}=y;this.ctx.database.getReadonly(m,E)||(t.add(m),c.push({rowKey:m,key:E,value:p,row:{}}))}}if(!c.length)return;const{BEFORE_AUTOFILL_CHANGE_METHOD:f}=this.ctx.config;if(typeof f=="function"){const x=f,u=c.map(g=>({rowKey:g.rowKey,key:g.key,value:g.value,oldValue:this.ctx.database.getItemValue(g.rowKey,g.key),row:this.ctx.database.getRowDataItemForRowKey(g.rowKey)}));c=await x(u)}this.ctx.selector.xArr=this.ctx.autofill.xArr,this.ctx.selector.yArr=this.ctx.autofill.yArr,this.ctx.database.batchSetItemValue(c,!0);let d=[];t.forEach(x=>{d.push(this.ctx.database.getRowDataItemForRowKey(x))}),this.ctx.emit("autofillChange",c,d)}mouseenter(t){if(["index","selection","index-selection"].includes(t.type))return;const{selector:e,autofill:i}=this.ctx;if(this.ctx.mousedown&&e.enable&&i.enable){const{rowIndex:s,colIndex:r}=t,o=e.xArr.slice(),a=e.yArr.slice();s>=e.yArr[0]&&s<=e.yArr[1]?r>e.xArr[1]?o.splice(1,1,r):r<e.xArr[0]&&o.splice(0,1,r):s>e.yArr[1]?a.splice(1,1,s):s<e.yArr[0]&&a.splice(0,1,s),this.setAutofill(o,a)}}destroy(){}}const at=Math.min,Z=Math.max,ut=Math.round,V=n=>({x:n,y:n}),xi={left:"right",right:"left",bottom:"top",top:"bottom"},ui={start:"end",end:"start"};function It(n,t,e){return Z(n,at(t,e))}function lt(n,t){return typeof n=="function"?n(t):n}function j(n){return n.split("-")[0]}function ht(n){return n.split("-")[1]}function ee(n){return n==="x"?"y":"x"}function Ot(n){return n==="y"?"height":"width"}function J(n){return["top","bottom"].includes(j(n))?"y":"x"}function Tt(n){return ee(J(n))}function gi(n,t,e){e===void 0&&(e=!1);const i=ht(n),s=Tt(n),r=Ot(s);let o=s==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(o=gt(o)),[o,gt(o)]}function wi(n){const t=gt(n);return[St(n),t,St(t)]}function St(n){return n.replace(/start|end/g,t=>ui[t])}function pi(n,t,e){const i=["left","right"],s=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(n){case"top":case"bottom":return e?t?s:i:t?i:s;case"left":case"right":return t?r:o;default:return[]}}function yi(n,t,e,i){const s=ht(n);let r=pi(j(n),e==="start",i);return s&&(r=r.map(o=>o+"-"+s),t&&(r=r.concat(r.map(St)))),r}function gt(n){return n.replace(/left|right|bottom|top/g,t=>xi[t])}function mi(n){return{top:0,right:0,bottom:0,left:0,...n}}function ie(n){return typeof n!="number"?mi(n):{top:n,right:n,bottom:n,left:n}}function wt(n){const{x:t,y:e,width:i,height:s}=n;return{width:i,height:s,top:e,left:t,right:t+i,bottom:e+s,x:t,y:e}}function se(n,t,e){let{reference:i,floating:s}=n;const r=J(t),o=Tt(t),a=Ot(o),h=j(t),c=r==="y",f=i.x+i.width/2-s.width/2,d=i.y+i.height/2-s.height/2,x=i[a]/2-s[a]/2;let u;switch(h){case"top":u={x:f,y:i.y-s.height};break;case"bottom":u={x:f,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:d};break;case"left":u={x:i.x-s.width,y:d};break;default:u={x:i.x,y:i.y}}switch(ht(t)){case"start":u[o]-=x*(e&&c?-1:1);break;case"end":u[o]+=x*(e&&c?-1:1);break}return u}const Ei=async(n,t,e)=>{const{placement:i="bottom",strategy:s="absolute",middleware:r=[],platform:o}=e,a=r.filter(Boolean),h=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:n,floating:t,strategy:s}),{x:f,y:d}=se(c,i,h),x=i,u={},g=0;for(let w=0;w<a.length;w++){const{name:p,fn:y}=a[w],{x:b,y:m,data:E,reset:C}=await y({x:f,y:d,initialPlacement:i,placement:x,strategy:s,middlewareData:u,rects:c,platform:o,elements:{reference:n,floating:t}});f=b??f,d=m??d,u={...u,[p]:{...u[p],...E}},C&&g<=50&&(g++,typeof C=="object"&&(C.placement&&(x=C.placement),C.rects&&(c=C.rects===!0?await o.getElementRects({reference:n,floating:t,strategy:s}):C.rects),{x:f,y:d}=se(c,x,h)),w=-1)}return{x:f,y:d,placement:x,strategy:s,middlewareData:u}};async function re(n,t){var e;t===void 0&&(t={});const{x:i,y:s,platform:r,rects:o,elements:a,strategy:h}=n,{boundary:c="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:x=!1,padding:u=0}=lt(t,n),g=ie(u),p=a[x?d==="floating"?"reference":"floating":d],y=wt(await r.getClippingRect({element:(e=await(r.isElement==null?void 0:r.isElement(p)))==null||e?p:p.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:c,rootBoundary:f,strategy:h})),b=d==="floating"?{x:i,y:s,width:o.floating.width,height:o.floating.height}:o.reference,m=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),E=await(r.isElement==null?void 0:r.isElement(m))?await(r.getScale==null?void 0:r.getScale(m))||{x:1,y:1}:{x:1,y:1},C=wt(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:m,strategy:h}):b);return{top:(y.top-C.top+g.top)/E.y,bottom:(C.bottom-y.bottom+g.bottom)/E.y,left:(y.left-C.left+g.left)/E.x,right:(C.right-y.right+g.right)/E.x}}const bi=n=>({name:"arrow",options:n,async fn(t){const{x:e,y:i,placement:s,rects:r,platform:o,elements:a,middlewareData:h}=t,{element:c,padding:f=0}=lt(n,t)||{};if(c==null)return{};const d=ie(f),x={x:e,y:i},u=Tt(s),g=Ot(u),w=await o.getDimensions(c),p=u==="y",y=p?"top":"left",b=p?"bottom":"right",m=p?"clientHeight":"clientWidth",E=r.reference[g]+r.reference[u]-x[u]-r.floating[g],C=x[u]-r.reference[u],R=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let S=R?R[m]:0;(!S||!await(o.isElement==null?void 0:o.isElement(R)))&&(S=a.floating[m]||r.floating[g]);const L=E/2-C/2,F=S/2-w[g]/2-1,N=at(d[y],F),$=at(d[b],F),O=N,A=S-w[g]-$,T=S/2-w[g]/2+L,it=It(O,T,A),W=!h.arrow&&ht(s)!=null&&T!==it&&r.reference[g]/2-(T<O?N:$)-w[g]/2<0,Y=W?T<O?T-O:T-A:0;return{[u]:x[u]+Y,data:{[u]:it,centerOffset:T-it-Y,...W&&{alignmentOffset:Y}},reset:W}}}),Ci=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(t){var e,i;const{placement:s,middlewareData:r,rects:o,initialPlacement:a,platform:h,elements:c}=t,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:x,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:w=!0,...p}=lt(n,t);if((e=r.arrow)!=null&&e.alignmentOffset)return{};const y=j(s),b=J(a),m=j(a)===a,E=await(h.isRTL==null?void 0:h.isRTL(c.floating)),C=x||(m||!w?[gt(a)]:wi(a)),R=g!=="none";!x&&R&&C.push(...yi(a,w,g,E));const S=[a,...C],L=await re(t,p),F=[];let N=((i=r.flip)==null?void 0:i.overflows)||[];if(f&&F.push(L[y]),d){const T=gi(s,o,E);F.push(L[T[0]],L[T[1]])}if(N=[...N,{placement:s,overflows:F}],!F.every(T=>T<=0)){var $,O;const T=((($=r.flip)==null?void 0:$.index)||0)+1,it=S[T];if(it)return{data:{index:T,overflows:N},reset:{placement:it}};let W=(O=N.filter(Y=>Y.overflows[0]<=0).sort((Y,q)=>Y.overflows[1]-q.overflows[1])[0])==null?void 0:O.placement;if(!W)switch(u){case"bestFit":{var A;const Y=(A=N.filter(q=>{if(R){const G=J(q.placement);return G===b||G==="y"}return!0}).map(q=>[q.placement,q.overflows.filter(G=>G>0).reduce((G,ji)=>G+ji,0)]).sort((q,G)=>q[1]-G[1])[0])==null?void 0:A[0];Y&&(W=Y);break}case"initialPlacement":W=a;break}if(s!==W)return{reset:{placement:W}}}return{}}}};async function vi(n,t){const{placement:e,platform:i,elements:s}=n,r=await(i.isRTL==null?void 0:i.isRTL(s.floating)),o=j(e),a=ht(e),h=J(e)==="y",c=["left","top"].includes(o)?-1:1,f=r&&h?-1:1,d=lt(t,n);let{mainAxis:x,crossAxis:u,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof g=="number"&&(u=a==="end"?g*-1:g),h?{x:u*f,y:x*c}:{x:x*c,y:u*f}}const Ri=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(t){var e,i;const{x:s,y:r,placement:o,middlewareData:a}=t,h=await vi(t,n);return o===((e=a.offset)==null?void 0:e.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:s+h.x,y:r+h.y,data:{...h,placement:o}}}}},_i=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(t){const{x:e,y:i,placement:s}=t,{mainAxis:r=!0,crossAxis:o=!1,limiter:a={fn:p=>{let{x:y,y:b}=p;return{x:y,y:b}}},...h}=lt(n,t),c={x:e,y:i},f=await re(t,h),d=J(j(s)),x=ee(d);let u=c[x],g=c[d];if(r){const p=x==="y"?"top":"left",y=x==="y"?"bottom":"right",b=u+f[p],m=u-f[y];u=It(b,u,m)}if(o){const p=d==="y"?"top":"left",y=d==="y"?"bottom":"right",b=g+f[p],m=g-f[y];g=It(b,g,m)}const w=a.fn({...t,[x]:u,[d]:g});return{...w,data:{x:w.x-e,y:w.y-i,enabled:{[x]:r,[d]:o}}}}}};function pt(){return typeof window<"u"}function Q(n){return oe(n)?(n.nodeName||"").toLowerCase():"#document"}function D(n){var t;return(n==null||(t=n.ownerDocument)==null?void 0:t.defaultView)||window}function B(n){var t;return(t=(oe(n)?n.ownerDocument:n.document)||window.document)==null?void 0:t.documentElement}function oe(n){return pt()?n instanceof Node||n instanceof D(n).Node:!1}function X(n){return pt()?n instanceof Element||n instanceof D(n).Element:!1}function K(n){return pt()?n instanceof HTMLElement||n instanceof D(n).HTMLElement:!1}function ne(n){return!pt()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof D(n).ShadowRoot}function ct(n){const{overflow:t,overflowX:e,overflowY:i,display:s}=k(n);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&!["inline","contents"].includes(s)}function Ii(n){return["table","td","th"].includes(Q(n))}function yt(n){return[":popover-open",":modal"].some(t=>{try{return n.matches(t)}catch{return!1}})}function At(n){const t=Lt(),e=X(n)?k(n):n;return e.transform!=="none"||e.perspective!=="none"||(e.containerType?e.containerType!=="normal":!1)||!t&&(e.backdropFilter?e.backdropFilter!=="none":!1)||!t&&(e.filter?e.filter!=="none":!1)||["transform","perspective","filter"].some(i=>(e.willChange||"").includes(i))||["paint","layout","strict","content"].some(i=>(e.contain||"").includes(i))}function Oi(n){let t=z(n);for(;K(t)&&!tt(t);){if(At(t))return t;if(yt(t))return null;t=z(t)}return null}function Lt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function tt(n){return["html","body","#document"].includes(Q(n))}function k(n){return D(n).getComputedStyle(n)}function mt(n){return X(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function z(n){if(Q(n)==="html")return n;const t=n.assignedSlot||n.parentNode||ne(n)&&n.host||B(n);return ne(t)?t.host:t}function ae(n){const t=z(n);return tt(t)?n.ownerDocument?n.ownerDocument.body:n.body:K(t)&&ct(t)?t:ae(t)}function Mt(n,t,e){var i;t===void 0&&(t=[]),e===void 0&&(e=!0);const s=ae(n),r=s===((i=n.ownerDocument)==null?void 0:i.body),o=D(s);if(r){const a=Ht(o);return t.concat(o,o.visualViewport||[],ct(s)?s:[],a&&e?Mt(a):[])}return t.concat(s,Mt(s,[],e))}function Ht(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}function le(n){const t=k(n);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=K(n),r=s?n.offsetWidth:e,o=s?n.offsetHeight:i,a=ut(e)!==r||ut(i)!==o;return a&&(e=r,i=o),{width:e,height:i,$:a}}function he(n){return X(n)?n:n.contextElement}function et(n){const t=he(n);if(!K(t))return V(1);const e=t.getBoundingClientRect(),{width:i,height:s,$:r}=le(t);let o=(r?ut(e.width):e.width)/i,a=(r?ut(e.height):e.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const Ti=V(0);function ce(n){const t=D(n);return!Lt()||!t.visualViewport?Ti:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Si(n,t,e){return t===void 0&&(t=!1),!e||t&&e!==D(n)?!1:t}function dt(n,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const s=n.getBoundingClientRect(),r=he(n);let o=V(1);t&&(i?X(i)&&(o=et(i)):o=et(n));const a=Si(r,e,i)?ce(r):V(0);let h=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,f=s.width/o.x,d=s.height/o.y;if(r){const x=D(r),u=i&&X(i)?D(i):i;let g=x,w=Ht(g);for(;w&&i&&u!==g;){const p=et(w),y=w.getBoundingClientRect(),b=k(w),m=y.left+(w.clientLeft+parseFloat(b.paddingLeft))*p.x,E=y.top+(w.clientTop+parseFloat(b.paddingTop))*p.y;h*=p.x,c*=p.y,f*=p.x,d*=p.y,h+=m,c+=E,g=D(w),w=Ht(g)}}return wt({width:f,height:d,x:h,y:c})}function Ai(n){let{elements:t,rect:e,offsetParent:i,strategy:s}=n;const r=s==="fixed",o=B(i),a=t?yt(t.floating):!1;if(i===o||a&&r)return e;let h={scrollLeft:0,scrollTop:0},c=V(1);const f=V(0),d=K(i);if((d||!d&&!r)&&((Q(i)!=="body"||ct(o))&&(h=mt(i)),K(i))){const x=dt(i);c=et(i),f.x=x.x+i.clientLeft,f.y=x.y+i.clientTop}return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-h.scrollLeft*c.x+f.x,y:e.y*c.y-h.scrollTop*c.y+f.y}}function Li(n){return Array.from(n.getClientRects())}function Dt(n,t){const e=mt(n).scrollLeft;return t?t.left+e:dt(B(n)).left+e}function Mi(n){const t=B(n),e=mt(n),i=n.ownerDocument.body,s=Z(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),r=Z(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let o=-e.scrollLeft+Dt(n);const a=-e.scrollTop;return k(i).direction==="rtl"&&(o+=Z(t.clientWidth,i.clientWidth)-s),{width:s,height:r,x:o,y:a}}function Hi(n,t){const e=D(n),i=B(n),s=e.visualViewport;let r=i.clientWidth,o=i.clientHeight,a=0,h=0;if(s){r=s.width,o=s.height;const c=Lt();(!c||c&&t==="fixed")&&(a=s.offsetLeft,h=s.offsetTop)}return{width:r,height:o,x:a,y:h}}function Di(n,t){const e=dt(n,!0,t==="fixed"),i=e.top+n.clientTop,s=e.left+n.clientLeft,r=K(n)?et(n):V(1),o=n.clientWidth*r.x,a=n.clientHeight*r.y,h=s*r.x,c=i*r.y;return{width:o,height:a,x:h,y:c}}function de(n,t,e){let i;if(t==="viewport")i=Hi(n,e);else if(t==="document")i=Mi(B(n));else if(X(t))i=Di(t,e);else{const s=ce(n);i={...t,x:t.x-s.x,y:t.y-s.y}}return wt(i)}function fe(n,t){const e=z(n);return e===t||!X(e)||tt(e)?!1:k(e).position==="fixed"||fe(e,t)}function Fi(n,t){const e=t.get(n);if(e)return e;let i=Mt(n,[],!1).filter(a=>X(a)&&Q(a)!=="body"),s=null;const r=k(n).position==="fixed";let o=r?z(n):n;for(;X(o)&&!tt(o);){const a=k(o),h=At(o);!h&&a.position==="fixed"&&(s=null),(r?!h&&!s:!h&&a.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||ct(o)&&!h&&fe(n,o))?i=i.filter(f=>f!==o):s=a,o=z(o)}return t.set(n,i),i}function Xi(n){let{element:t,boundary:e,rootBoundary:i,strategy:s}=n;const o=[...e==="clippingAncestors"?yt(t)?[]:Fi(t,this._c):[].concat(e),i],a=o[0],h=o.reduce((c,f)=>{const d=de(t,f,s);return c.top=Z(d.top,c.top),c.right=at(d.right,c.right),c.bottom=at(d.bottom,c.bottom),c.left=Z(d.left,c.left),c},de(t,a,s));return{width:h.right-h.left,height:h.bottom-h.top,x:h.left,y:h.top}}function ki(n){const{width:t,height:e}=le(n);return{width:t,height:e}}function Ni(n,t,e){const i=K(t),s=B(t),r=e==="fixed",o=dt(n,!0,r,t);let a={scrollLeft:0,scrollTop:0};const h=V(0);if(i||!i&&!r)if((Q(t)!=="body"||ct(s))&&(a=mt(t)),i){const u=dt(t,!0,r,t);h.x=u.x+t.clientLeft,h.y=u.y+t.clientTop}else s&&(h.x=Dt(s));let c=0,f=0;if(s&&!i&&!r){const u=s.getBoundingClientRect();f=u.top+a.scrollTop,c=u.left+a.scrollLeft-Dt(s,u)}const d=o.left+a.scrollLeft-h.x-c,x=o.top+a.scrollTop-h.y-f;return{x:d,y:x,width:o.width,height:o.height}}function Ft(n){return k(n).position==="static"}function xe(n,t){if(!K(n)||k(n).position==="fixed")return null;if(t)return t(n);let e=n.offsetParent;return B(n)===e&&(e=e.ownerDocument.body),e}function ue(n,t){const e=D(n);if(yt(n))return e;if(!K(n)){let s=z(n);for(;s&&!tt(s);){if(X(s)&&!Ft(s))return s;s=z(s)}return e}let i=xe(n,t);for(;i&&Ii(i)&&Ft(i);)i=xe(i,t);return i&&tt(i)&&Ft(i)&&!At(i)?e:i||Oi(n)||e}const Ki=async function(n){const t=this.getOffsetParent||ue,e=this.getDimensions,i=await e(n.floating);return{reference:Ni(n.reference,await t(n.floating),n.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Yi(n){return k(n).direction==="rtl"}const Bi={convertOffsetParentRelativeRectToViewportRelativeRect:Ai,getDocumentElement:B,getClippingRect:Xi,getOffsetParent:ue,getElementRects:Ki,getClientRects:Li,getDimensions:ki,getScale:et,isElement:X,isRTL:Yi},ge=Ri,we=_i,pe=Ci,Wi=bi,ye=(n,t,e)=>{const i=new Map,s={platform:Bi,...e},r={...s.platform,_c:i};return Ei(n,t,{...s,platform:r})};let Pi=class{constructor(t){l(this,"ctx");l(this,"enable",!1);l(this,"contentEl");l(this,"floatingEl");l(this,"arrowEl");this.ctx=t;const{TOOLTIP_BG_COLOR:e,TOOLTIP_TEXT_COLOR:i,TOOLTIP_ZINDEX:s,TOOLTIP_CUSTOM_STYLE:r,CSS_PREFIX:o}=this.ctx.config;this.contentEl=document.createElement("div"),this.arrowEl=document.createElement("div"),this.floatingEl=document.createElement("div"),this.floatingEl.className=`${o}-tooltip`,this.contentEl.className=`${o}-tooltip-content`,this.arrowEl.className=`${o}-tooltip-arrow`;const a={display:"none",position:"absolute",background:e,color:i,boxSizing:"border-box",zIndex:s,padding:"8px",borderRadius:"4px",fontSize:"12px",...r},h={position:"absolute",width:"10px",height:"10px",background:a.background,backgroundColor:a.backgroundColor,transform:"rotate(45deg)",zIndex:a.zIndex};Object.assign(this.arrowEl.style,h),Object.assign(this.floatingEl.style,a),this.floatingEl.appendChild(this.contentEl),this.floatingEl.appendChild(this.arrowEl),this.ctx.containerElement.appendChild(this.floatingEl),this.init()}init(){this.ctx.on("mousemove",t=>{if(!this.ctx.isTarget())return;const e=this.ctx.containerElement.getBoundingClientRect();e&&(t.clientX<e.x||t.clientX>e.x+e.width||t.clientY<e.y||t.clientY>e.y+e.height)&&this.hide()}),this.ctx.on("startEdit",()=>{this.hide()}),this.ctx.on("visibleCellHoverChange",t=>{(t.ellipsis||t.message)&&this.show(t)}),this.ctx.on("visibleCellMouseleave",()=>{this.hide()})}show(t){if(!t.overflowTooltipShow||this.ctx.mousedown)return;this.floatingEl.style.display="block";let e=t.getText();t.message&&(e=t.message);const i=this.ctx.containerElement.getBoundingClientRect();if(!i)return;this.enable=!0,this.contentEl.style.maxWidth=`${t.overflowTooltipMaxWidth||500}px`,this.contentEl.style.width="100%",this.contentEl.style.display="inline-block",this.contentEl.style.wordBreak="break-all",this.contentEl.style.lineHeight="1.5",this.contentEl.innerText=e;const s=t.drawX+i.x,r=t.drawY+i.y;ye({getBoundingClientRect(){return{width:t.visibleWidth,height:t.visibleHeight,x:s,y:r,left:s,right:s+t.visibleWidth,top:r,bottom:r+t.visibleHeight}}},this.floatingEl,{placement:t.overflowTooltipPlacement,middleware:[we(),pe(),ge(6),Wi({element:this.arrowEl})]}).then(a=>{const{x:h,y:c,placement:f,middlewareData:d}=a;if(Object.assign(this.floatingEl.style,{top:`${c}px`,left:`${h}px`}),d.arrow){const x=d.arrow;["left","left-start","left-end"].includes(f)?Object.assign(this.arrowEl.style,{top:`${x.y}px`,bottom:"",left:"",right:"-5px"}):["right","right-start","right-end"].includes(f)?Object.assign(this.arrowEl.style,{top:`${x.y}px`,bottom:"",left:"-5px",right:""}):["bottom","bottom-start","bottom-end"].includes(f)?Object.assign(this.arrowEl.style,{top:"-5px",bottom:"",left:`${x.x}px`,right:""}):["top","top-start","top-end"].includes(f)&&Object.assign(this.arrowEl.style,{top:"",bottom:"-5px",left:`${x.x}px`,right:""})}})}hide(){this.enable&&(this.enable=!1,this.floatingEl.style.display="none")}destroy(){this.contentEl.remove(),this.arrowEl.remove(),this.floatingEl.remove()}};class Vi{constructor(t){l(this,"editorEl");l(this,"inputEl");l(this,"enable",!1);l(this,"cellTarget",null);l(this,"ctx");l(this,"drawY",0);l(this,"drawX",0);this.ctx=t,this.initTextEditor(),this.init()}init(){this.ctx.on("onScroll",()=>{this.enable&&this.doneEdit()}),this.ctx.on("cellHeaderMousedown",()=>{this.enable&&this.doneEdit(),this.cellTarget=null}),this.ctx.on("keydown",t=>{const e=t.key,i=t.ctrlKey,s=t.altKey,r=t.shiftKey,o=t.metaKey;if(!(i||s||r||o||["Escape","Tab","Backspace","Delete","ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown","Insert","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"].includes(e))){if(t.code==="Enter"&&!this.enable){t.preventDefault(),this.startEdit();return}this.startEdit()}}),this.ctx.on("adjustBoundaryPosition",t=>{this.cellTarget=t}),this.ctx.on("cellClick",t=>{var e,i;this.ctx.adjustPositioning||(t.rowKey===((e=this.cellTarget)==null?void 0:e.rowKey)&&t.key===((i=this.cellTarget)==null?void 0:i.key)?this.startEdit():(this.doneEdit(),this.cellTarget=t,this.ctx.config.ENABLE_EDIT_SINGLE_CLICK&&this.startEdit()))})}initTextEditor(){this.inputEl=document.createElement("textarea"),this.inputEl.setAttribute("rows","1"),this.inputEl.addEventListener("keydown",t=>{if(!t.isComposing&&this.enable){if(t.stopPropagation(),(t.altKey||t.metaKey)&&t.code==="Enter"){t.preventDefault();const e=this.inputEl.selectionStart,i=this.inputEl.value.substring(0,e),s=this.inputEl.value.substring(e);this.inputEl.value=i+`
16
+ `+s,this.inputEl.selectionStart=this.inputEl.selectionEnd=e+1,this.autoSize();return}(t.code==="Escape"||t.code==="Enter")&&(t.preventDefault(),this.inputEl.blur())}}),this.inputEl.addEventListener("input",this.autoSize.bind(this)),this.inputEl.addEventListener("blur",()=>{this.doneEdit()}),this.editorEl=this.ctx.editorElement,this.inputEl.className="e-virt-table-editor-textarea",this.editorEl.appendChild(this.inputEl),this.ctx.containerElement.appendChild(this.editorEl)}autoSize(){this.inputEl.style.height="auto";let t=this.inputEl.scrollHeight,e=this.ctx.body.visibleHeight;t>e&&(t=e);const{stageHeight:i,footer:s,header:r,config:{SCROLLER_TRACK_SIZE:o}}=this.ctx,a=i-s.height-o;this.editorEl.style.bottom="auto",(this.drawY+t>a||this.drawY<r.height)&&(this.editorEl.style.left=`${this.drawX-1}px`,this.editorEl.style.top="auto",this.editorEl.style.bottom=`${i-a}px`),this.inputEl.style.height=`${t}px`}startEditByInput(t){const e=t.getValue(),{width:i,editorType:s}=t,r=t.getDrawX();let o=t.getDrawY();this.drawX=r,this.drawY=o;let{height:a}=t;const{config:{CELL_PADDING:h},header:c}=this.ctx;let f=this.ctx.body.visibleHeight;if(a>f&&(a=f),this.editorEl.style.left=`${r-1}px`,this.editorEl.style.top=`${o-1}px`,this.editorEl.style.bottom="auto",this.editorEl.style.maxHeight=`${f}px`,s==="text"){this.inputEl.style.display="block",this.inputEl.style.minWidth=`${i-1}px`,this.inputEl.style.minHeight=`${a-1}px`,this.inputEl.style.maxHeight=`${f}px`,this.inputEl.style.width=`${i-1}px`,this.inputEl.style.height="auto",this.inputEl.style.padding=`${h}px`,e!==null&&(this.inputEl.value=e),this.inputEl.focus();const d=this.inputEl.value.length;this.inputEl.setSelectionRange(d,d)}else this.inputEl.style.display="none";(this.inputEl.scrollHeight>a||o<c.height)&&this.autoSize()}doneEditByInput(){if(this.cellTarget&&(this.editorEl.style.left="-10000px",this.editorEl.style.top="-10000px",this.editorEl.style.bottom="atuo",this.cellTarget.editorType==="text")){const{rowKey:t,key:e}=this.cellTarget,i=this.cellTarget.getValue(),s=this.inputEl.value;s!==i&&!(s===""&&i===null)&&this.ctx.database.setItemValue(t,e,s,!0,!0,!0),this.inputEl.value=""}}startEdit(){const{ENABLE_EDIT_CLICK_SELECTOR:t}=this.ctx.config;if(!t)return;const e=this.ctx.focusCell;if(!e||["index","index-selection","selection"].includes(e.type)||this.enable)return;const{rowKey:i,key:s}=e,r=this.ctx.database.getReadonly(i,s);e&&!r&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=e,this.startEditByInput(this.cellTarget),this.ctx.emit("startEdit",this.cellTarget))}editCell(t,e){const i=this.ctx.body.renderRows.find(c=>c.rowIndex===t);if(!i)return;const s=i.cells.find(c=>c.colIndex===e);if(!s)return;this.ctx.emit("setSelectorCell",s);const r=this.ctx.focusCell;if(!r||["index","index-selection","selection"].includes(r.type)||this.enable)return;const{rowKey:o,key:a}=r,h=this.ctx.database.getReadonly(o,a);r&&!h&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=r,this.startEditByInput(this.cellTarget),this.ctx.emit("startEdit",this.cellTarget))}doneEdit(){this.enable&&(this.doneEditByInput(),this.ctx.emit("doneEdit",this.cellTarget),this.enable=!1,this.ctx.stageElement.focus(),this.ctx.editing=!1,this.ctx.emit("draw"))}destroy(){var t;(t=this.editorEl)==null||t.remove()}}class zi{constructor(t){l(this,"ctx");l(this,"emptyEl");this.ctx=t;const{EMPTY_TEXT:e,EMPTY_CUSTOM_STYLE:i}=this.ctx.config;this.ctx.emptyElement?this.emptyEl=this.ctx.emptyElement:(this.emptyEl=document.createElement("div"),this.emptyEl.innerText=e),this.emptyEl.className="e-virt-table-empty",this.emptyEl.style.display="none",this.ctx.containerElement.appendChild(this.emptyEl),this.ctx.on("emptyChange",({type:s,headerHeight:r,bodyHeight:o,footerHeight:a})=>{const h=r+(o+a)/2,c={display:s==="empty"?"block":"none",position:"absolute",fontSize:"14px",color:"#666",left:"50%",top:`${h}px`,transform:"translate(-50%, -50%)",...i};Object.assign(this.emptyEl.style,c)})}destroy(){this.emptyEl.remove()}}class $i{constructor(t){l(this,"ctx");this.ctx=t}draw(){const t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){this.ctx.emit("overlayerChange",{style:{},views:[]})}getContainer(){const t=this.getHeader(),e=this.getBody(),i=this.getFooter();let s=[t,e,i];const{FOOTER_FIXED:r}=this.ctx.config;return r||(s=[t,e]),{views:s}}getHeader(){const{fixedLeftWidth:t,fixedRightWidth:e,config:{SCROLLER_TRACK_SIZE:i,CSS_PREFIX:s}}=this.ctx,{visibleWidth:r,visibleHeight:o,renderCellHeaders:a}=this.ctx.header;let h=[],c=[],f=[];a.forEach(p=>{p.render&&(p.fixed==="left"?c.push(p):p.fixed==="right"?f.push(p):h.push(p))});const d=e-i,x={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${o}px`},cells:c},u={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${r-t-d+1}px`,height:`${o}px`},cells:h},g={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${d+1}px`,height:`${o}px`},cells:f};return{type:"header",class:`${s}-overlayer-header`,style:{position:"relative",overflow:"hidden",width:`${r}px`,height:`${o}px`},views:[x,u,g]}}getBody(){const t=[],e=[],i=[];let s=this.ctx.body.renderRows;this.ctx.config.FOOTER_FIXED||(s=s.concat(this.ctx.footer.renderRows)),s.forEach(p=>{p.cells.forEach(y=>{y.cellType==="footer"&&(y.render=y.renderFooter),y.render&&(y.fixed==="left"?e.push(y):y.fixed==="right"?i.push(y):t.push(y))})});const{fixedLeftWidth:r,fixedRightWidth:o,config:{SCROLLER_TRACK_SIZE:a,CSS_PREFIX:h}}=this.ctx,{visibleWidth:c,visibleHeight:f}=this.ctx.body,d=o-a,x={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${r}px`,height:`${f}px`},cells:e},u={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${r-.5}px`,overflow:"hidden",width:`${c-r-d}px`,height:`${f}px`},cells:t},g={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${d}px`,height:`${f}px`},cells:i};return{type:"body",class:`${h}-overlayer-body`,style:{position:"relative",overflow:"hidden",width:`${c}px`,height:`${f}px`},views:[x,u,g]}}getFooter(){const t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(w=>{w.cells.forEach(p=>{p.cellType==="footer"&&p.renderFooter&&(p.render=p.renderFooter,p.fixed==="left"?e.push(p):p.fixed==="right"?i.push(p):t.push(p))})});const{fixedLeftWidth:s,fixedRightWidth:r,config:{SCROLLER_TRACK_SIZE:o,CSS_PREFIX:a}}=this.ctx,{visibleWidth:h,visibleHeight:c}=this.ctx.footer,f=r-o,d={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${s}px`,height:`${c}px`},cells:e},x={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${s-.5}px`,overflow:"hidden",width:`${h-s-f}px`,height:`${c}px`},cells:t},u={key:"right",style:{position:"absolute",top:`${.5}px`,right:`${.5}px`,overflow:"hidden",width:`${f}px`,height:`${c}px`},cells:i};return{type:"footer",class:`${a}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${h}px`,height:`${c}px`},views:[d,x,u]}}}class qi{constructor(t){l(this,"ctx");l(this,"contextMenuEl");l(this,"custom",!1);this.ctx=t,this.ctx.contextMenuElement?(this.custom=!0,this.contextMenuEl=this.ctx.contextMenuElement):(this.custom=!1,this.contextMenuEl=document.createElement("div")),this.createContextMenu(),this.init()}init(){this.ctx.on("cellContextMenuClick",(t,e)=>{if(!this.ctx.config.ENABLE_CONTEXT_MENU)return;e.preventDefault();const{xArr:i,yArr:s}=this.ctx.selector,[r,o]=i,[a,h]=s,{rowIndex:c,colIndex:f}=t;c>=a&&c<=h&&f>=r&&f<=o||this.ctx.emit("setSelectorCell",t,e);const x={getBoundingClientRect:()=>({width:0,height:0,top:e.clientY,left:e.clientX,right:e.clientX,bottom:e.clientY,x:e.clientX,y:e.clientY}),contextElement:document.body};ye(x,this.contextMenuEl,{placement:"right-start",middleware:[ge(),we(),pe()]}).then(({x:u,y:g})=>{this.show(u,g)})}),this.ctx.on("click",this.hide.bind(this)),this.ctx.on("onScroll",this.hide.bind(this)),this.ctx.on("resize",this.hide.bind(this))}createContextMenu(){if(this.contextMenuEl.className="e-virt-table-context-menu",this.ctx.containerElement.appendChild(this.contextMenuEl),this.custom)return;const{CONTEXT_MENU:t}=this.ctx.config;this.createContextMenuItems(t,e=>{switch(e.value){case"copy":this.ctx.emit("contextMenuCopy");break;case"paste":this.ctx.emit("contextMenuPaste");break;case"cut":this.ctx.emit("contextMenuCut");break;case"clearSelected":this.ctx.emit("contextMenuClearSelected");break}this.hide()})}createContextMenuItems(t,e){this.contextMenuEl.replaceChildren(),t.forEach(i=>{const s=document.createElement("div");s.className="e-virt-table-context-menu-item",s.innerText=i.label,i.event?s.onclick=()=>{i.event&&i.event(),e(i)}:s.onclick=()=>e(i),this.contextMenuEl.appendChild(s)})}show(t,e){Object.assign(this.contextMenuEl.style,{left:`${t}px`,top:`${e}px`})}hide(){Object.assign(this.contextMenuEl.style,{left:"-99999px",top:"-99999px"})}updated(){this.createContextMenu()}destroy(){this.contextMenuEl.remove()}}class Gi{constructor(t,e){l(this,"options");l(this,"scroller");l(this,"header");l(this,"body");l(this,"footer");l(this,"selector");l(this,"autofill");l(this,"tooltip");l(this,"editor");l(this,"empty");l(this,"overlayer");l(this,"contextMenu");l(this,"ctx");this.options=e;const{overlayerElement:i,editorElement:s,emptyElement:r,contextMenuElement:o}=e,a=this.createContainer(t,i,s,r,o);this.ctx=new ni(a,this.options),this.header=new li(this.ctx),this.body=new hi(this.ctx),this.footer=new ci(this.ctx),this.scroller=new ai(this.ctx),this.selector=new di(this.ctx),this.autofill=new fi(this.ctx),this.tooltip=new Pi(this.ctx),this.empty=new zi(this.ctx),this.editor=new Vi(this.ctx),this.overlayer=new $i(this.ctx),this.contextMenu=new qi(this.ctx),this.ctx.on("draw",()=>{this.draw()}),this.ctx.on("drawView",()=>{this.draw(!0)}),this.draw()}createContainer(t,e,i,s,r){t.className="e-virt-table-container";const o=document.createElement("div"),a=document.createElement("canvas"),h=e||document.createElement("div");o.className="e-virt-table-stage",a.className="e-virt-table-canvas",h.className="e-virt-table-overlayer";const c=i||document.createElement("div");c.className="e-virt-table-editor";const f=s,d=r;return o.appendChild(a),o.appendChild(h),t.appendChild(o),{containerElement:t,stageElement:o,canvasElement:a,overlayerElement:h,editorElement:c,emptyElement:f,contextMenuElement:d}}draw(t=!1){requestAnimationFrame(()=>{this.header.update(),this.footer.update(),this.body.update(),this.ctx.paint.clear(),this.body.draw(),this.footer.draw(),this.header.draw(),this.scroller.draw(),t||this.overlayer.draw()})}loadConfig(t){this.ctx.config.init(t),this.ctx.database.init(),this.header.init(),this.contextMenu.updated(),this.ctx.emit("draw")}loadColumns(t){this.editor.doneEdit(),this.ctx.database.setColumns(t),this.header.init(),this.ctx.emit("draw")}loadData(t){this.editor.doneEdit(),this.ctx.database.setData(t),this.header.init(),this.ctx.emit("draw")}loadFooterData(t){this.ctx.database.setFooterData(t),this.ctx.emit("draw")}setLoading(t){this.ctx.database.setLoading(t)}on(t,e){this.ctx.on(t,e)}emit(t,...e){this.ctx.emit(t,...e)}off(t,e){this.ctx.off(t,e)}filterMethod(t){this.ctx.setScrollY(0),this.ctx.setScrollX(0),this.ctx.database.init(),this.ctx.database.setFilterMethod(t),this.ctx.emit("draw")}editCell(t,e){this.editor.editCell(t,e)}setItemValue(t,e,i,s=!0,r=!0,o=!1){this.ctx.database.setItemValue(t,e,i,s,r,o)}batchSetItemValue(t,e=!0){this.ctx.database.batchSetItemValue(t,e)}setItemValueByEditor(t,e,i,s=!0,r=!0){this.ctx.database.setItemValue(t,e,i,s,r,!0),this.editor.doneEdit()}doLayout(){this.ctx.emit("draw")}getChangedData(){return this.ctx.database.getChangedData()}getChangedRows(){return this.ctx.database.getChangedRows()}clearValidate(){this.ctx.database.clearValidate(),this.ctx.emit("draw")}async validate(t=!0){return this.editor.doneEdit(),new Promise(async(e,i)=>{try{const s=await this.getValidations();e(s)}catch(s){if(t&&Array.isArray(s)&&s.length){const[r]=s;if(Array.isArray(r)&&r.length){const[o]=r,{rowKey:a,key:h}=o;this.scrollToRowkey(a),this.scrollToColkey(h)}}i(s)}})}setValidations(t){if(t.forEach(e=>{const{rowIndex:i,key:s,message:r}=e;this.ctx.database.setValidationErrorByRowIndex(i,s,r)}),t&&Array.isArray(t)&&t.length){const[e]=t;if(e&&e.rowIndex>=0&&e.key){const{rowIndex:i,key:s}=e;this.scrollToRowIndex(i),this.scrollToColkey(s)}}}getValidations(){return new Promise(async(t,e)=>{const i=this.ctx.database.getAllRowsData(),s=this.ctx.header.leafCellHeaders;let r=[];for(let o=0;o<i.length;o++)for(let a=0;a<s.length;a++){const h=this.ctx.database.getRowKeyByItem(i[o]),f=s[a].key,d=await this.ctx.database.getValidator(h,f);Array.isArray(d)&&d.length&&r.push(d)}r.length?(e(r),this.ctx.emit("draw")):(t([]),this.ctx.emit("draw"))})}hasValidationError(){return this.ctx.database.hasValidationError()}scrollTo(t,e){this.scrollXTo(t),this.scrollYTo(e)}scrollXTo(t){this.ctx.setScrollX(t)}scrollToColkey(t){this.scroller.scrollToColkey(t)}scrollToRowkey(t){this.scroller.scrollToRowKey(t)}scrollToColIndex(t){this.scroller.scrollToColIndex(t)}scrollToRowIndex(t){this.scroller.scrollToRowIndex(t)}scrollYTo(t){this.ctx.setScrollY(t)}setExpandRowKeys(t,e=!0){this.ctx.database.setExpandRowKeys(t,e)}clearSelection(){this.ctx.database.clearSelection(),this.ctx.emit("draw")}toggleRowSelection(t){const e=this.ctx.database.getRowKeyByItem(t);this.ctx.database.toggleRowSelection(e),this.ctx.emit("draw")}setSelectionByRows(t,e=!0){t.forEach(i=>{const s=this.ctx.database.getRowKeyByItem(i);this.ctx.database.setRowSelection(s,e)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}setSelectionByRowKeys(t,e=!0){t.forEach(i=>{this.ctx.database.setRowSelection(i,e)}),this.ctx.emit("selectionChange",this.getSelectionRows()),this.ctx.emit("draw")}toggleAllSelection(){this.ctx.database.toggleAllSelection(),this.ctx.emit("draw")}toggleRowExpand(t,e){this.ctx.database.expandItem(t,e),this.ctx.emit("draw")}toggleExpandAll(t){this.ctx.database.expandAll(t),this.ctx.emit("draw")}getSelectionRows(){return this.ctx.database.getSelectionRows()}getPositionForRowIndex(t){return this.ctx.database.getPositionForRowIndex(t)}getCellValue(t,e){return this.ctx.database.getItemValue(t,e)}getCellValueByIndex(t,e){return this.ctx.database.getItemValueForRowIndexAndColIndex(t,e)}contextMenuHide(){this.contextMenu.hide()}destroy(){this.overlayer.destroy(),this.empty.destroy(),this.editor.destroy(),this.tooltip.destroy(),this.selector.destroy(),this.autofill.destroy(),this.contextMenu.destroy(),this.ctx.destroy(),this.ctx.containerElement.remove()}}return Gi});
17
17
  //# sourceMappingURL=index.umd.js.map