e-virt-table 0.0.18 → 0.0.20

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
- (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-editor{position:absolute;top:-10000px;left:-10000px;text-align:left;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);pointer-events:auto;display:flex;align-items:center}.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}.e-virt-table-context-menu-item:hover{color:var(--e-virt-table-color-primary);background-color:#f5f7fa}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
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 c=(I,M,P)=>Zi(I,typeof M!="symbol"?M+"":M,P);function I(){return I=Object.assign?Object.assign.bind():function(a){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(a[i]=e[i])}return a},I.apply(this,arguments)}function M(a,t){a.prototype=Object.create(t.prototype),a.prototype.constructor=a,st(a,t)}function P(a){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},P(a)}function st(a,t){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,s){return i.__proto__=s,i},st(a,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(a,t,e){return me()?ft=Reflect.construct.bind():ft=function(s,o,r){var n=[null];n.push.apply(n,o);var l=Function.bind.apply(s,n),h=new l;return r&&st(h,r.prototype),h},ft.apply(null,arguments)}function Ee(a){return Function.toString.call(a).indexOf("[native code]")!==-1}function Et(a){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(a)}var Ce=/%[sdj%]/g,kt=function(){};typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"&&typeof window<"u"&&typeof document<"u"&&(kt=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 Ct(a){if(!a||!a.length)return null;var t={};return a.forEach(function(e){var i=e.field;t[i]=t[i]||[],t[i].push(e)}),t}function H(a){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,o=e.length;if(typeof a=="function")return a.apply(null,e);if(typeof a=="string"){var r=a.replace(Ce,function(n){if(n==="%%")return"%";if(s>=o)return n;switch(n){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 n}});return r}return a}function be(a){return a==="string"||a==="url"||a==="hex"||a==="email"||a==="date"||a==="pattern"}function _(a,t){return!!(a==null||t==="array"&&Array.isArray(a)&&!a.length||be(t)&&typeof a=="string"&&!a)}function ve(a,t,e){var i=[],s=0,o=a.length;function r(n){i.push.apply(i,n||[]),s++,s===o&&e(i)}a.forEach(function(n){t(n,r)})}function Nt(a,t,e){var i=0,s=a.length;function o(r){if(r&&r.length){e(r);return}var n=i;i=i+1,n<s?t(a[n],o):e([])}o([])}function Re(a){var t=[];return Object.keys(a).forEach(function(e){t.push.apply(t,a[e]||[])}),t}var Yt=function(a){M(t,a);function t(e,i){var s;return s=a.call(this,"Async Validation Error")||this,s.errors=e,s.fields=i,s}return t}(Et(Error));function _e(a,t,e,i,s){if(t.first){var o=new Promise(function(x,u){var p=function(y){return i(y),y.length?u(new Yt(y,Ct(y))):x(s)},g=Re(a);Nt(g,e,p)});return o.catch(function(x){return x}),o}var r=t.firstFields===!0?Object.keys(a):t.firstFields||[],n=Object.keys(a),l=n.length,h=0,f=[],d=new Promise(function(x,u){var p=function(w){if(f.push.apply(f,w),h++,h===l)return i(f),f.length?u(new Yt(f,Ct(f))):x(s)};n.length||(i(f),x(s)),n.forEach(function(g){var w=a[g];r.indexOf(g)!==-1?Nt(w,e,p):ve(w,e,p)})});return d.catch(function(x){return x}),d}function Ie(a){return!!(a&&a.message!==void 0)}function Oe(a,t){for(var e=a,i=0;i<t.length;i++){if(e==null)return e;e=e[t[i]]}return e}function Kt(a,t){return function(e){var i;return a.fullFields?i=Oe(t,a.fullFields):i=t[e.field||a.fullField],Ie(e)?(e.field=e.field||a.fullField,e.fieldValue=i,e):{message:typeof e=="function"?e():e,fieldValue:i,field:e.field||a.fullField}}}function Bt(a,t){if(t){for(var e in t)if(t.hasOwnProperty(e)){var i=t[e];typeof i=="object"&&typeof a[e]=="object"?a[e]=I({},a[e],i):a[e]=i}}return a}var Wt=function(t,e,i,s,o,r){t.required&&(!i.hasOwnProperty(t.field)||_(e,r||t.type))&&s.push(H(o.messages.required,t.fullField))},Se=function(t,e,i,s,o){(/^\s+$/.test(e)||e==="")&&s.push(H(o.messages.whitespace,t.fullField))},xt,Te=function(){if(xt)return xt;var a="[a-fA-F\\d:]",t=function(E){return E&&E.includeBoundaries?"(?:(?<=\\s|^)(?="+a+")|(?<="+a+")(?=\\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=(`
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-editor{position:absolute;top:-10000px;left:-10000px;text-align:left;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);pointer-events:auto;display:flex;align-items:center}.e-virt-table-editor-textarea{width:100%;box-sizing:border-box;padding:8px;outline:none;font-weight:400;font-size:12px;color:inherit;white-space:normal;word-wrap:break-word;word-break:break-all;line-height:18px;margin:0;border:none;background:var(--e-virt-table-color-white);overflow:hidden;cursor:text}.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}.e-virt-table-context-menu-item:hover{color:var(--e-virt-table-color-primary);background-color:#f5f7fa}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
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 c=(I,M,P)=>Zi(I,typeof M!="symbol"?M+"":M,P);function I(){return I=Object.assign?Object.assign.bind():function(a){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(a[i]=e[i])}return a},I.apply(this,arguments)}function M(a,t){a.prototype=Object.create(t.prototype),a.prototype.constructor=a,st(a,t)}function P(a){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},P(a)}function st(a,t){return st=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,s){return i.__proto__=s,i},st(a,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(a,t,e){return me()?ft=Reflect.construct.bind():ft=function(s,r,o){var n=[null];n.push.apply(n,r);var l=Function.bind.apply(s,n),h=new l;return o&&st(h,o.prototype),h},ft.apply(null,arguments)}function Ee(a){return Function.toString.call(a).indexOf("[native code]")!==-1}function Et(a){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(a)}var Ce=/%[sdj%]/g,kt=function(){};typeof process<"u"&&process.env&&process.env.NODE_ENV!=="production"&&typeof window<"u"&&typeof document<"u"&&(kt=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 Ct(a){if(!a||!a.length)return null;var t={};return a.forEach(function(e){var i=e.field;t[i]=t[i]||[],t[i].push(e)}),t}function H(a){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 a=="function")return a.apply(null,e);if(typeof a=="string"){var o=a.replace(Ce,function(n){if(n==="%%")return"%";if(s>=r)return n;switch(n){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 n}});return o}return a}function be(a){return a==="string"||a==="url"||a==="hex"||a==="email"||a==="date"||a==="pattern"}function _(a,t){return!!(a==null||t==="array"&&Array.isArray(a)&&!a.length||be(t)&&typeof a=="string"&&!a)}function ve(a,t,e){var i=[],s=0,r=a.length;function o(n){i.push.apply(i,n||[]),s++,s===r&&e(i)}a.forEach(function(n){t(n,o)})}function Nt(a,t,e){var i=0,s=a.length;function r(o){if(o&&o.length){e(o);return}var n=i;i=i+1,n<s?t(a[n],r):e([])}r([])}function Re(a){var t=[];return Object.keys(a).forEach(function(e){t.push.apply(t,a[e]||[])}),t}var Yt=function(a){M(t,a);function t(e,i){var s;return s=a.call(this,"Async Validation Error")||this,s.errors=e,s.fields=i,s}return t}(Et(Error));function _e(a,t,e,i,s){if(t.first){var r=new Promise(function(x,u){var p=function(y){return i(y),y.length?u(new Yt(y,Ct(y))):x(s)},g=Re(a);Nt(g,e,p)});return r.catch(function(x){return x}),r}var o=t.firstFields===!0?Object.keys(a):t.firstFields||[],n=Object.keys(a),l=n.length,h=0,f=[],d=new Promise(function(x,u){var p=function(w){if(f.push.apply(f,w),h++,h===l)return i(f),f.length?u(new Yt(f,Ct(f))):x(s)};n.length||(i(f),x(s)),n.forEach(function(g){var w=a[g];o.indexOf(g)!==-1?Nt(w,e,p):ve(w,e,p)})});return d.catch(function(x){return x}),d}function Ie(a){return!!(a&&a.message!==void 0)}function Oe(a,t){for(var e=a,i=0;i<t.length;i++){if(e==null)return e;e=e[t[i]]}return e}function Kt(a,t){return function(e){var i;return a.fullFields?i=Oe(t,a.fullFields):i=t[e.field||a.fullField],Ie(e)?(e.field=e.field||a.fullField,e.fieldValue=i,e):{message:typeof e=="function"?e():e,fieldValue:i,field:e.field||a.fullField}}}function Bt(a,t){if(t){for(var e in t)if(t.hasOwnProperty(e)){var i=t[e];typeof i=="object"&&typeof a[e]=="object"?a[e]=I({},a[e],i):a[e]=i}}return a}var Wt=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))},Se=function(t,e,i,s,r){(/^\s+$/.test(e)||e==="")&&s.push(H(r.messages.whitespace,t.fullField))},xt,Te=function(){if(xt)return xt;var a="[a-fA-F\\d:]",t=function(E){return E&&E.includeBoundaries?"(?:(?<=\\s|^)(?="+a+")|(?<="+a+")(?=\\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,9 +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(),o=new RegExp("(?:^"+e+"$)|(?:^"+s+"$)"),r=new RegExp("^"+e+"$"),n=new RegExp("^"+s+"$"),l=function(E){return E&&E.exact?o:new RegExp("(?:"+t(E)+e+t(E)+")|(?:"+t(E)+s+t(E)+")","g")};l.v4=function(m){return m&&m.exact?r:new RegExp(""+t(m)+e+t(m),"g")},l.v6=function(m){return m&&m.exact?n:new RegExp(""+t(m)+s+t(m),"g")};var h="(?:(?:[a-z]+:)?//)",f="(?:\\S+(?::\\S*)?@)?",d=l.v4().source,x=l.v6().source,u="(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)",p="(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*",g="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))",w="(?::\\d{2,5})?",y='(?:[/?#][^\\s"]*)?',C="(?:"+h+"|www\\.)"+f+"(?:localhost|"+d+"|"+x+"|"+u+p+g+")"+w+y;return xt=new RegExp("(?:^"+C+"$)","i"),xt},Pt={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(Pt.email)},url:function(t){return typeof t=="string"&&t.length<=2048&&!!t.match(Te())},hex:function(t){return typeof t=="string"&&!!t.match(Pt.hex)}},Ae=function(t,e,i,s,o){if(t.required&&e===void 0){Wt(t,e,i,s,o);return}var r=["integer","float","array","regexp","object","method","email","number","date","url","hex"],n=t.type;r.indexOf(n)>-1?rt[n](e)||s.push(H(o.messages.types[n],t.fullField,t.type)):n&&typeof e!==t.type&&s.push(H(o.messages.types[n],t.fullField,t.type))},Le=function(t,e,i,s,o){var r=typeof t.len=="number",n=typeof t.min=="number",l=typeof t.max=="number",h=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,f=e,d=null,x=typeof e=="number",u=typeof e=="string",p=Array.isArray(e);if(x?d="number":u?d="string":p&&(d="array"),!d)return!1;p&&(f=e.length),u&&(f=e.replace(h,"_").length),r?f!==t.len&&s.push(H(o.messages[d].len,t.fullField,t.len)):n&&!l&&f<t.min?s.push(H(o.messages[d].min,t.fullField,t.min)):l&&!n&&f>t.max?s.push(H(o.messages[d].max,t.fullField,t.max)):n&&l&&(f<t.min||f>t.max)&&s.push(H(o.messages[d].range,t.fullField,t.min,t.max))},U="enum",Me=function(t,e,i,s,o){t[U]=Array.isArray(t[U])?t[U]:[],t[U].indexOf(e)===-1&&s.push(H(o.messages[U],t.fullField,t[U].join(", ")))},He=function(t,e,i,s,o){if(t.pattern){if(t.pattern instanceof RegExp)t.pattern.lastIndex=0,t.pattern.test(e)||s.push(H(o.messages.pattern.mismatch,t.fullField,e,t.pattern));else if(typeof t.pattern=="string"){var r=new RegExp(t.pattern);r.test(e)||s.push(H(o.messages.pattern.mismatch,t.fullField,e,t.pattern))}}},v={required:Wt,whitespace:Se,type:Ae,range:Le,enum:Me,pattern:He},De=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(_(e,"string")&&!t.required)return i();v.required(t,e,s,r,o,"string"),_(e,"string")||(v.type(t,e,s,r,o),v.range(t,e,s,r,o),v.pattern(t,e,s,r,o),t.whitespace===!0&&v.whitespace(t,e,s,r,o))}i(r)},Xe=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(_(e)&&!t.required)return i();v.required(t,e,s,r,o),e!==void 0&&v.type(t,e,s,r,o)}i(r)},Fe=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(e===""&&(e=void 0),_(e)&&!t.required)return i();v.required(t,e,s,r,o),e!==void 0&&(v.type(t,e,s,r,o),v.range(t,e,s,r,o))}i(r)},ke=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(_(e)&&!t.required)return i();v.required(t,e,s,r,o),e!==void 0&&v.type(t,e,s,r,o)}i(r)},Ne=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(_(e)&&!t.required)return i();v.required(t,e,s,r,o),_(e)||v.type(t,e,s,r,o)}i(r)},Ye=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(_(e)&&!t.required)return i();v.required(t,e,s,r,o),e!==void 0&&(v.type(t,e,s,r,o),v.range(t,e,s,r,o))}i(r)},Ke=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(_(e)&&!t.required)return i();v.required(t,e,s,r,o),e!==void 0&&(v.type(t,e,s,r,o),v.range(t,e,s,r,o))}i(r)},Be=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(e==null&&!t.required)return i();v.required(t,e,s,r,o,"array"),e!=null&&(v.type(t,e,s,r,o),v.range(t,e,s,r,o))}i(r)},We=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(_(e)&&!t.required)return i();v.required(t,e,s,r,o),e!==void 0&&v.type(t,e,s,r,o)}i(r)},Pe="enum",ze=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(_(e)&&!t.required)return i();v.required(t,e,s,r,o),e!==void 0&&v[Pe](t,e,s,r,o)}i(r)},Ve=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(_(e,"string")&&!t.required)return i();v.required(t,e,s,r,o),_(e,"string")||v.pattern(t,e,s,r,o)}i(r)},$e=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(_(e,"date")&&!t.required)return i();if(v.required(t,e,s,r,o),!_(e,"date")){var l;e instanceof Date?l=e:l=new Date(e),v.type(t,l,s,r,o),l&&v.range(t,l.getTime(),s,r,o)}}i(r)},qe=function(t,e,i,s,o){var r=[],n=Array.isArray(e)?"array":typeof e;v.required(t,e,s,r,o,n),i(r)},bt=function(t,e,i,s,o){var r=t.type,n=[],l=t.required||!t.required&&s.hasOwnProperty(t.field);if(l){if(_(e,r)&&!t.required)return i();v.required(t,e,s,n,o,r),_(e,r)||v.type(t,e,s,n,o)}i(n)},Ge=function(t,e,i,s,o){var r=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(_(e)&&!t.required)return i();v.required(t,e,s,r,o)}i(r)},ot={string:De,method:Xe,number:Fe,boolean:ke,regexp:Ne,integer:Ye,float:Ke,array:Be,object:We,enum:ze,pattern:Ve,date:$e,url:bt,hex:bt,email:bt,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 a(e){this.rules=null,this._messages=Rt,this.define(e)}var t=a.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(o){var r=i[o];s.rules[o]=Array.isArray(r)?r:[r]})},t.messages=function(i){return i&&(this._messages=Bt(vt(),i)),this._messages},t.validate=function(i,s,o){var r=this;s===void 0&&(s={}),o===void 0&&(o=function(){});var n=i,l=s,h=o;if(typeof l=="function"&&(h=l,l={}),!this.rules||Object.keys(this.rules).length===0)return h&&h(null,n),Promise.resolve(n);function f(g){var w=[],y={};function C(E){if(Array.isArray(E)){var b;w=(b=w).concat.apply(b,E)}else w.push(E)}for(var m=0;m<g.length;m++)C(g[m]);w.length?(y=Ct(w),h(w,y)):h(null,n)}if(l.messages){var d=this.messages();d===Rt&&(d=vt()),Bt(d,l.messages),l.messages=d}else l.messages=this.messages();var x={},u=l.keys||Object.keys(this.rules);u.forEach(function(g){var w=r.rules[g],y=n[g];w.forEach(function(C){var m=C;typeof m.transform=="function"&&(n===i&&(n=I({},n)),y=n[g]=m.transform(y)),typeof m=="function"?m={validator:m}:m=I({},m),m.validator=r.getValidationMethod(m),m.validator&&(m.field=g,m.fullField=m.fullField||g,m.type=r.getType(m),x[g]=x[g]||[],x[g].push({rule:m,value:y,source:n,field:g}))})});var p={};return _e(x,l,function(g,w){var y=g.rule,C=(y.type==="object"||y.type==="array")&&(typeof y.fields=="object"||typeof y.defaultField=="object");C=C&&(y.required||!y.required&&g.value),y.field=g.field;function m(R,A){return I({},A,{fullField:y.fullField+"."+R,fullFields:y.fullFields?[].concat(y.fullFields,[R]):[R]})}function E(R){R===void 0&&(R=[]);var A=Array.isArray(R)?R:[R];!l.suppressWarning&&A.length&&a.warning("async-validator:",A),A.length&&y.message!==void 0&&(A=[].concat(y.message));var L=A.map(Kt(y,n));if(l.first&&L.length)return p[y.field]=1,w(L);if(!C)w(L);else{if(y.required&&!g.value)return y.message!==void 0?L=[].concat(y.message).map(Kt(y,n)):l.error&&(L=[l.error(y,H(l.messages.required,y.field))]),w(L);var X={};y.defaultField&&Object.keys(g.value).map(function(O){X[O]=y.defaultField}),X=I({},X,g.rule.fields);var N={};Object.keys(X).forEach(function(O){var T=X[O],S=Array.isArray(T)?T:[T];N[O]=S.map(m.bind(null,O))});var $=new a(N);$.messages(l.messages),g.rule.options&&(g.rule.options.messages=l.messages,g.rule.options.error=l.error),$.validate(g.value,g.rule.options||l,function(O){var T=[];L&&L.length&&T.push.apply(T,L),O&&O.length&&T.push.apply(T,O),w(T.length?T:null)})}}var b;if(y.asyncValidator)b=y.asyncValidator(y,g.value,E,g.source,l);else if(y.validator){try{b=y.validator(y,g.value,E,g.source,l)}catch(R){console.error==null||console.error(R),l.suppressValidatorError||setTimeout(function(){throw R},0),E(R.message)}b===!0?E():b===!1?E(typeof y.message=="function"?y.message(y.fullField||y.field):y.message||(y.fullField||y.field)+" fails"):b instanceof Array?E(b):b instanceof Error&&E(b.message)}b&&b.then&&b.then(function(){return E()},function(R){return E(R)})},function(g){f(g)},n)},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),o=s.indexOf("message");return o!==-1&&s.splice(o,1),s.length===1&&s[0]==="required"?ot.required:ot[this.getType(i)]||void 0},a}();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=kt,nt.messages=Rt,nt.validators=ot;function _t(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(a){const t=Math.random()*16|0;return(a==="x"?t:t&3|8).toString(16)})}function zt(a,t){let e=0,i;return function(...s){const o=new Date().getTime(),r=o-e;!e||r>=t?(a.apply(this,s),e=o):i||(i=setTimeout(()=>{a.apply(this,s),e=new Date().getTime(),i=void 0},t-r))}}function Vt(a){return a?a.map(t=>Vt(t.children)+1).sort((t,e)=>e-t)[0]:0}function je(a=[]){let t=[],e=[],i=[];return a.forEach(s=>{s.fixed==="left"?t.push(s):s.fixed==="right"?i.push(s):e.push(s)}),[...t.sort((s,o)=>s.sort-o.sort),...e.sort((s,o)=>s.sort-o.sort),...i.sort((s,o)=>s.sort-o.sort)]}function $t(a=[],t=1,e=0){return a.map(i=>{if(i.children){let s=0,o=i.fixed;i.children.forEach(n=>{n.fixed=o});const r=$t(i.children,t-1,e+1);return r&&r.forEach(n=>{s+=n.colspan}),{...i,width:i.width,level:e,rowspan:1,colspan:s,children:r}}return{...i,level:e,rowspan:t,colspan:1}})}function It(a=[]){let t=[];return a.forEach(e=>{e.children?t=t.concat(It(e.children)):t.push(e)}),t}const qt=/^(\r\n|\n\r|\r|\n)/,Ue=/^[^\t\r\n]+/,Gt=/^\t/;function Ze(a){let t=[[""]];if(a.length===0)return t;let e=0,i=0,s;for(;a.length>0&&s!==a.length;)if(s=a.length,a.match(Gt))a=a.replace(Gt,""),e+=1,t[i][e]="";else if(a.match(qt))a=a.replace(qt,""),e=0,i+=1,t[i]=[""];else{let o="";if(a.startsWith('"')){let r=0,n=!0;for(;n;){const l=a.slice(0,1);l==='"'&&(r+=1),o+=l,a=a.slice(1),(a.length===0||a.match(/^[\t\r\n]/)&&r%2===0)&&(n=!1)}o=o.replace(/^"/,"").replace(/"$/,"").replace(/["]*/g,l=>new Array(Math.floor(l.length/2)).fill('"').join(""))}else{const r=a.match(Ue);o=r?r[0]:"",a=a.slice(o.length)}t[i][e]=o}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(a){let t,e,i,s,o="",r;for(t=0,e=a.length;t<e;t+=1){for(s=a[t].length,i=0;i<s;i+=1)i>0&&(o+=" "),r=a[t][i],typeof r=="string"?r.indexOf(`
14
- `)>-1?o+=`"${r.replace(/"/g,'""')}"`:o+=r:r==null?o+="":o+=r;t!==e-1&&(o+=`
15
- `)}return o}class Qe{constructor(t,e){c(this,"loading",!1);c(this,"ctx");c(this,"data");c(this,"columns");c(this,"footerData",[]);c(this,"rowKeyMap",new Map);c(this,"colIndexKeyMap",new Map);c(this,"headerMap",new Map);c(this,"rowIndexRowKeyMap",new Map);c(this,"checkboxKeyMap",new Map);c(this,"originalDataMap",new Map);c(this,"changedDataMap",new Map);c(this,"validationErrorMap",new Map);c(this,"itemRowKeyMap",new WeakMap);c(this,"bufferData",[]);c(this,"sumHeight",0);c(this,"filterMethod");c(this,"positions",[]);this.ctx=t;const{data:i=[],columns:s=[],footerData:o=[]}=e;this.data=i,this.footerData=o,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 o=!1;Array.isArray(i.children)&&(o=!0,this.initData(i.children,e+1));const{ROW_KEY:r="",DEFAULT_EXPAND_ALL:n,CELL_HEIGHT:l,SELECTABLE_METHOD:h,CHECKBOX_KEY:f}=this.ctx.config,d=i[r],x=d??_t();this.itemRowKeyMap.set(i,x);const u=i._height||l,p=i._readonly;let g=!0;if(typeof h=="function"&&(g=h),f){const w=i[f];if(this.checkboxKeyMap.has(w)){const y=this.checkboxKeyMap.get(w);y.push(x),this.checkboxKeyMap.set(w,y)}else this.checkboxKeyMap.set(w,[x])}this.rowKeyMap.set(x,{readonly:p,index:s,rowIndex:s,level:e,height:u,check:!1,selectable:g,expand:n,expandLazy:!1,hasChildren:o,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 o={...i};o.children&&Array.isArray(o.children)&&(o.children=this.filterColumns(o.children)),e.push(o)}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=o=>{o.forEach(r=>{t.push(r);const n=this.itemRowKeyMap.get(r),{expand:l,hasChildren:h,height:f}=this.rowKeyMap.get(n),d=this.sumHeight;this.sumHeight+=f,this.rowIndexRowKeyMap.set(e,n),this.positions.push({top:d,height:f,bottom:this.sumHeight}),e+=1,l&&h&&i(r.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")}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),o=this.colIndexKeyMap.get(e);return{rowKey:s,key:o,value:this.getItemValue(s,o)}}getItemValue(t,e){const i=this.rowKeyMap.get(t);return i&&i.item?i.item[e]===void 0?null:i.item[e]:null}batchSetItemValue(t,e=!1){let i=[];const s=new Set;t.forEach(n=>{const{value:l,rowKey:h,key:f}=n,{oldValue:d,newValue:x}=this.setItemValue(h,f,l);s.add(h),i.push({rowKey:h,key:f,oldValue:d,newValue:x})});let o=[];const r=i.map(n=>{const l=this.ctx.database.getRowDataItemForRowKey(n.rowKey);return{rowKey:n.rowKey,key:n.key,value:n.newValue,row:l}});return s.forEach(n=>{o.push(this.ctx.database.getRowDataItemForRowKey(n))}),this.ctx.emit("change",r,o),e&&this.ctx.history.pushState({changeList:i,scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,type:"multiple"}),i}setItemValue(t,e,i,s=!1,o=!1,r=!1){if(!this.rowKeyMap.has(t))return{};const{item:n}=this.rowKeyMap.get(t);let l=n[e];if(this.ctx.database.getReadonly(t,e))return{oldValue:l,newValue:l};n[e]!==null&&typeof n[e]=="object"&&(l=JSON.parse(JSON.stringify(n[e])));const h=`${t}_${e}`;if(this.originalDataMap.has(h)||this.originalDataMap.set(h,l),this.changedDataMap.set(h,i),n[e]=i,r){const f=this.ctx.database.getRowDataItemForRowKey(t),d={rowKey:t,key:e,value:i,row:f};this.ctx.emit("change",[d],[f]),this.ctx.emit("editChange",{rowKey:t,key:e,oldValue:l,value:i,originalValue:this.originalDataMap.get(h),row:f})}return this.ctx.hasEvent("iterationChange")&&this.ctx.emit("iterationChange",{rowKey:t,key:e,oldValue:l,value:i,originalValue:this.originalDataMap.get(h),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:i}]}),o&&this.ctx.emit("draw"),{oldValue:l,newValue:i}}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),o=s[i];this.checkboxKeyMap.has(o)&&this.checkboxKeyMap.get(o).forEach(n=>{const l=this.rowKeyMap.get(n);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(r=>{r.check&&(t+=1);const n=r.selectable;typeof n=="function"?n({row:r.item,rowIndex:r.rowIndex})&&(e+=1):n&&(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),o=i.split("_")[0],r=i.split("_")[1];s!==e&&t.push({rowKey:o,colKey:r,originalValue:s,row:this.rowKeyMap.get(o),value:e})}),t}getChangedRows(){const t=new Set;this.changedDataMap.forEach((i,s)=>{const o=this.originalDataMap.get(s),r=s.split("_")[0];o!==i&&t.add(r)});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),o=this.changedDataMap.get(i);return s!==o}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),o=i==null?void 0:i.readonly,r=s==null?void 0:s.readonly,{CELL_READONLY_METHOD:n}=this.ctx.config;if(typeof n=="function"){const h=n({row:i.item,rowIndex:i.rowIndex,colIndex:s.colIndex,column:s.column,value:this.getItemValue(t,e)});if(h!==void 0)return h}return r||o}clearValidate(){this.validationErrorMap.clear()}getValidator(t,e){return new Promise(i=>{const s=this.rowKeyMap.get(t),o=this.headerMap.get(e),{CELL_RULES_METHOD:r}=this.ctx.config,n=o.column;let l=n.rules;if(typeof r=="function"){const f=r({row:s.item,rowIndex:s.rowIndex,colIndex:o.colIndex,column:n,value:this.getItemValue(t,e)});f&&(l=f)}if(l){let h={},f={};if(f[e]=this.getItemValue(t,e),Array.isArray(l)&&l.length){const x=l.map(u=>({...u,row:s.item,column:n,rowIndex:s.rowIndex,colIndex:o.colIndex}));h[e]=x}else h[e]={...l,row:s.item,column:n,rowIndex:s.rowIndex,colIndex:o.colIndex};new nt(h).validate(f).then(()=>{this.setValidationError(t,e,[]),i([])}).catch(({errors:x})=>{const u=x.map(p=>({...p,column:n,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 o=this.positions[t+s];o&&(i+=o.height)}return i}setLoading(t){this.loading=t,this.ctx.emit("loadingChange",t)}getLoading(){return this.loading}setValidationErrorByRowIndex(t,e,i){const o=`${this.rowIndexRowKeyMap.get(t)}_${e}`,r=[{message:i}];this.validationErrorMap.set(o,r)}setValidationError(t,e,i){const s=`${t}_${e}`;this.validationErrorMap.set(s,i)}getValidationError(t,e){const i=`${t}_${e}`;return this.validationErrorMap.get(i)||[]}}class ti{constructor(t){c(this,"ctx");c(this,"history",[]);c(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(o=>({rowKey:o.rowKey,key:o.key,value:o.oldValue,row:{}}));this.ctx.setScroll(e,i),this.ctx.database.batchSetItemValue(s,!1),this.historyIndex-=1,this.ctx.emit("draw")}}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),this.ctx.emit("draw")}}clear(){this.history=[],this.historyIndex=-1}}class ei{constructor(t){c(this,"eventTasks",new Map);c(this,"ctx");this.ctx=t,this.init()}init(){this.bind(window,"resize",this.handleResize.bind(this)),this.bind(window,"mousedown",this.handleMouseDown.bind(this)),this.bind(window,"mouseup",this.handleMouseUp.bind(this)),this.bind(window,"mousemove",this.handleMousemove.bind(this)),this.bind(window,"scroll",this.handleScroll.bind(this)),this.bind(this.ctx.target,"click",this.handleClick.bind(this)),this.bind(this.ctx.target,"keydown",this.handleKeydown.bind(this)),this.bind(this.ctx.target,"wheel",this.handleWheel.bind(this)),this.bind(this.ctx.target,"contextmenu",this.handleContextMenu.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.emit("keydown",t)}handleWheel(t){this.ctx.emit("wheel",t)}handleContextMenu(t){this.ctx.emit("contextMenu",t)}handleScroll(t){this.ctx.emit("scroll",t)}bind(t,e,i){t instanceof HTMLCanvasElement&&e==="keydown"&&(t.tabIndex=0),t.addEventListener(e,i),this.eventTasks.set(e,i)}unbind(t,e,i){t.removeEventListener(e,i),this.eventTasks.delete(e)}}class ii{constructor(){c(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){c(this,"ctx");const e=t.getContext("2d");if(!e)throw new Error("canvas context not found");this.ctx=e}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,o){const{fillColor:r,side:n,shadowWidth:l,colorStart:h,colorEnd:f}=o;this.ctx.save(),r&&(this.ctx.fillStyle=r,this.ctx.fillRect(t,e,i,s));let d;switch(n){case"left":d=this.ctx.createLinearGradient(t-l,e,t,e),d.addColorStop(0,h),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,h),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,h),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,h),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 o=2;o<t.length;o+=2)this.ctx.lineTo(t[o]+.5,t[o+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,o){this.ctx.save(),this.ctx.drawImage(t,e,i,s,o),this.ctx.restore()}drawRect(t,e,i,s,{borderWidth:o=1,borderColor:r,fillColor:n,radius:l=0}={}){if(this.ctx.save(),this.ctx.beginPath(),n!==void 0&&(this.ctx.fillStyle=n),r!==void 0&&(this.ctx.lineWidth=o,this.ctx.strokeStyle=r),l===0)this.ctx.rect(t+.5,e+.5,i,s);else{const[h,f,d,x]=typeof l=="number"?[l,l,l,l]:l;this.ctx.moveTo(t+h,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+h,e,h)}n!==void 0&&this.ctx.fill(),r!==void 0&&this.ctx.stroke(),this.ctx.restore()}drawText(t="",e,i,s,o,r={}){this.ctx.save();const{font:n="12px Arial",align:l="center",color:h="#495060",padding:f=0,verticalAlign:d="middle"}=r;this.ctx.font=n,this.ctx.fillStyle=h,this.ctx.textBaseline=d,this.ctx.textAlign=l;let x=0;d==="top"?x=i+f:d==="bottom"?x=i+o-f:x=i+(o+f)/2;let u=0;l==="left"?u=e+f:l==="right"?u=e+s-f:u=e+s/2;const{_text:p,ellipsis:g}=this.handleEllipsis(t,s,f);return this.ctx.fillText(p,u,x),this.ctx.restore(),g}handleEllipsis(t,e,i=0){let s=!1,o=t;if(t==null||t==="")return{_text:"",ellipsis:s};const r=this.ctx.measureText("...").width,n=this.ctx.measureText(t).width;if(n&&n+r>=e-i*2){s=!0;let l=0;for(let h=0;h<t.length;h++)if(l+=this.ctx.measureText(t[h]).width,l>=e-i*2-r){o=t.slice(0,h)+"...";break}}return{_text:o,ellipsis:s}}}class jt{constructor(t){c(this,"PROCESSOR_NUM",50);c(this,"CSS_PREFIX","e-virt-table");c(this,"ICONS",[]);c(this,"ROW_KEY","");c(this,"HEADER_FONT","12px normal Arial");c(this,"BODY_FONT","12px normal Arial");c(this,"BORDER_COLOR","#e1e6eb");c(this,"WIDTH",0);c(this,"RESIZE_MIN_WIDTH",40);c(this,"HEIGHT",0);c(this,"EMPTY_BODY_HEIGHT",120);c(this,"EMPTY_CUSTOM",!1);c(this,"EMPTY_CUSTOM_STYLE",{});c(this,"EMPTY_TEXT","暂无数据");c(this,"MAX_HEIGHT",1e3);c(this,"BORDER_RADIUS",8);c(this,"ENABLE_OFFSET_HEIGHT",!1);c(this,"OFFSET_HEIGHT",0);c(this,"HEADER_HEIGHT",36);c(this,"ENABLE_HEADER_STICKY",!1);c(this,"HEADER_BG_COLOR","#F8FAFF");c(this,"BODY_BG_COLOR","#FFF");c(this,"HEADER_TEXT_COLOR","#1D2129");c(this,"LOADING_ICON_SVG","");c(this,"LOADING_ICON_COLOR","#4E5969");c(this,"EXPAND_ICON_SVG","");c(this,"SHRINK_ICON_SVG","");c(this,"EXPAND_ICON_COLOR","#4E5969");c(this,"SHRINK_ICON_COLOR","#4E5969");c(this,"ERROR_TIP_ICON_COLOR","red");c(this,"ERROR_TIP_ICON_SIZE",6);c(this,"EXPAND_LAZY",!0);c(this,"DEFAULT_EXPAND_ALL",!1);c(this,"CELL_WIDTH",100);c(this,"CELL_HEIGHT",36);c(this,"CELL_PADDING",8);c(this,"CELL_HOVER_ICON_SIZE",20);c(this,"SCROLLER_TRACK_SIZE",14);c(this,"SCROLLER_SIZE",8);c(this,"SCROLLER_COLOR","#dee0e3");c(this,"SCROLLER_TRACK_COLOR","#fff");c(this,"SCROLLER_FOCUS_COLOR","#bbbec4");c(this,"SELECT_BORDER_COLOR","rgb(82,146,247)");c(this,"SELECT_AREA_COLOR","rgba(82,146,247,0.1)");c(this,"SELECT_BG_COLOR","rgba(82,146,247,0.1)");c(this,"EDIT_BG_COLOR","#fcf6ed");c(this,"CHECKBOX_KEY","");c(this,"CHECKBOX_COLOR","rgb(82,146,247)");c(this,"CHECKBOX_SIZE",20);c(this,"CHECKBOX_DISABLED_SVG","");c(this,"CHECKBOX_CHECK_SVG","");c(this,"CHECKBOX_UNCHECK_SVG","");c(this,"CHECKBOX_INDETERMINATE_SVG","");c(this,"READONLY_COLOR","#fff");c(this,"READONLY_TEXT_COLOR","#4E5969");c(this,"ERROR_TIP_COLOR","#ED3F14");c(this,"FOOTER_BG_COLOR","#fafafa");c(this,"FOOTER_FIXED",!0);c(this,"CELL_FOOTER_HEIGHT",36);c(this,"ENABLE_SELECTOR",!1);c(this,"ENABLE_EDIT_SINGLE_CLICK",!1);c(this,"ENABLE_EDIT_CLICK_SELECTOR",!0);c(this,"SELECTOR_AREA_MIN_X",0);c(this,"SELECTOR_AREA_MAX_X_OFFSET",0);c(this,"SELECTOR_AREA_MAX_X",0);c(this,"SELECTOR_AREA_MIN_Y",0);c(this,"SELECTOR_AREA_MAX_Y",0);c(this,"SELECTOR_AREA_MAX_Y_OFFSET",0);c(this,"ENABLE_SELECTOR_SINGLE",!1);c(this,"ENABLE_SELECTOR_SPAN_COL",!0);c(this,"ENABLE_SELECTOR_SPAN_ROW",!0);c(this,"ENABLE_SELECTOR_ALL_ROWS",!0);c(this,"ENABLE_SELECTOR_ALL_COLS",!0);c(this,"ENABLE_AUTOFILL",!1);c(this,"ENABLE_CONTEXT_MENU",!1);c(this,"ENABLE_COPY",!0);c(this,"ENABLE_PASTER",!0);c(this,"ENABLE_RESIZE_ROW",!0);c(this,"ENABLE_RESIZE_COLUMN",!0);c(this,"RESIZE_ROW_LINE_COLOR","#e1e6eb");c(this,"RESIZE_COLUMN_LINE_COLOR","#e1e6eb");c(this,"RESIZE_ROW_MIN_HEIGHT",36);c(this,"RESIZE_COLUMN_MIN_WIDTH",40);c(this,"ENABLE_KEYBOARD",!0);c(this,"ENABLE_HISTORY",!1);c(this,"ENABLE_VALIDATOR_IMMEDIATE",!0);c(this,"HISTORY_NUM",50);c(this,"HIGHLIGHT_HOVER_ROW",!1);c(this,"HIGHLIGHT_HOVER_ROW_COLOR","rgba(186,203,231,0.1)");c(this,"HIGHLIGHT_SELECTED_ROW",!1);c(this,"HIGHLIGHT_SELECTED_ROW_COLOR","rgba(82,146,247,0.1)");c(this,"TOOLTIP_BG_COLOR","#303133");c(this,"TOOLTIP_TEXT_COLOR","#fff");c(this,"TOOLTIP_ZINDEX",3e3);c(this,"TOOLTIP_CUSTOM_STYLE",{});c(this,"CONTEXT_MENU",[{label:"复制",value:"copy"},{label:"剪切",value:"cut"},{label:"粘贴",value:"paste"},{label:"清空选中内容",value:"clearSelected"}]);c(this,"HEADER_CELL_STYLE_METHOD");c(this,"BODY_CELL_STYLE_METHOD");c(this,"FOOTER_CELL_STYLE_METHOD");c(this,"CELL_READONLY_METHOD");c(this,"CELL_FORMATTER_METHOD");c(this,"CELL_RULES_METHOD");c(this,"CELL_TYPE_METHOD");c(this,"CELL_EDITOR_TYPE_METHOD");c(this,"CELL_RENDER_METHOD");c(this,"CELL_HOVER_ICON_METHOD");c(this,"SPAN_METHOD");c(this,"SELECTABLE_METHOD");c(this,"EXPAND_LAZY_METHOD");Object.assign(this,t)}init(t){Object.assign(this,t)}}class ri{constructor(t){c(this,"ctx");c(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:""}]);c(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 r=this.ctx.config[i.configColorName];r&&(s=r)}const o=this.createImageFromSVG(i.svg,s).then(r=>{this.icons.set(i.name,r)});t.push(o)}for(let e=0;e<this.ctx.config.ICONS.length;e++){const i=this.ctx.config.ICONS[e];let s=i.color;const o=this.createImageFromSVG(i.svg,s).then(r=>{this.icons.set(i.name,r)});t.push(o)}await Promise.all(t),this.ctx.emit("draw")}async createImageFromSVG(t,e){const o=new DOMParser().parseFromString(t,"image/svg+xml").documentElement;e&&o.querySelectorAll("*").forEach(h=>{h.setAttribute("fill",e)});const r=new Image,n=new Blob([new XMLSerializer().serializeToString(o)],{type:"image/svg+xml"}),l=URL.createObjectURL(n);return r.src=l,new Promise((h,f)=>{r.onerror=()=>f(new Error("Failed to load image")),r.onload=()=>{h(r)}})}get(t){return this.icons.get(t)}}class Ut{constructor(t,e,i,s,o,r,n){c(this,"ctx");c(this,"x",0);c(this,"y",0);c(this,"width",0);c(this,"height",0);c(this,"fixed");c(this,"cellType");this.ctx=t,this.x=e,this.y=i,this.width=s,this.height=o,this.fixed=r,this.cellType=n}isHorizontalVisible(){if(this.fixed)return!0;const{target:t,fixedLeftWidth:e,scrollX:i,fixedRightWidth:s}=this.ctx,o=t.width;return!(this.x+this.width-e-i<=0||this.x-i>=o-s)}isVerticalVisible(){const{target:t,scrollY:e}=this.ctx,i=t.height;return!(this.y+this.height-e<=0||this.y-e>=i)}getDrawX(){return this.fixed==="left"?this.x:this.fixed==="right"?this.ctx.header.visibleWidth-(this.ctx.header.width-this.x)+1: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,o,r,n,l,h,f,d="body"){super(e,o,r,n,l,h.fixed,d);c(this,"formatter");c(this,"hoverIconName","");c(this,"operation",!1);c(this,"align");c(this,"verticalAlign");c(this,"fixed");c(this,"type");c(this,"editorType");c(this,"cellType");c(this,"level");c(this,"colspan",1);c(this,"rowspan",1);c(this,"key");c(this,"column");c(this,"rowIndex");c(this,"colIndex");c(this,"rowKey");c(this,"row");c(this,"value");c(this,"render");c(this,"renderFooter");c(this,"style",{});c(this,"rules",{});c(this,"message","");c(this,"text","");c(this,"displayText","");c(this,"visibleWidth",0);c(this,"visibleHeight",0);c(this,"drawX",0);c(this,"drawY",0);c(this,"drawCellBgColor","");c(this,"drawCellSkyBgColor","");c(this,"drawTextColor","");c(this,"drawTextX",0);c(this,"drawTextY",0);c(this,"drawImageX",0);c(this,"drawImageY",0);c(this,"drawImageWidth",0);c(this,"drawImageHeight",0);c(this,"drawImageName","");c(this,"drawImageSource");c(this,"ellipsis",!1);c(this,"overflowTooltipShow",!0);c(this,"overflowTooltipMaxWidth",500);c(this,"overflowTooltipPlacement","top");this.visibleWidth=this.width,this.visibleHeight=this.height,this.colIndex=s,this.rowIndex=i,this.key=h.key,this.type=h.type||"text",this.editorType=h.editorType||"text",this.cellType=d,this.align=h.align||"center",this.verticalAlign=h.verticalAlign||"middle",this.fixed=h.fixed,this.level=h.level,this.operation=h.operation||!1,this.column=h,this.rules=h.rules,this.row=f,this.rowKey=this.cellType==="body"?this.ctx.database.getRowKeyForRowIndex(i):`${this.cellType}_${this.rowIndex}`,this.value=this.getValue(),this.render=h.render,this.overflowTooltipShow=h.overflowTooltipShow!==!1,this.overflowTooltipMaxWidth=h.overflowTooltipMaxWidth||500,this.overflowTooltipPlacement=h.overflowTooltipPlacement||"top",this.renderFooter=h.renderFooter,this.hoverIconName=h.hoverIconName,this.formatter=h.formatter,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.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:o=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=o,this.visibleWidth=this.getWidthByColIndexColSpan(this.colIndex,this.colspan),this.visibleHeight=this.ctx.database.getHeightByRowIndexRowSpan(this.rowIndex,this.rowspan)}}updateType(){const{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{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{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 o,r=0,n="";if(this.type==="tree"&&s==="body"){const l=this.ctx.database.getRowForRowKey(i),{expand:h=!1,hasChildren:f=!1,expandLoading:d=!1,level:x=0}=l||{};if(d){const u=this.ctx.icons.get("loading");n="loading",o=u,r=x*8}else if(f){const u=this.ctx.icons.get("expand"),p=this.ctx.icons.get("shrink");o=h?p:u,n=h?"shrink":"expand",r=x*8}else r=x*8;if(o){let u=20,p=20,g=this.drawX+r+e,w=this.drawY+(this.visibleHeight-p)/2+2;this.ctx.paint.drawImage(o,g,w,u,p),this.drawImageX=g,this.drawImageY=w,this.drawImageWidth=u,this.drawImageHeight=p,this.drawImageName=n,this.drawImageSource=o,this.align="left",this.drawTextX=r+this.drawX+u+.5}}}updateContainer(){const{BODY_BG_COLOR:e,EDIT_BG_COLOR:i,BODY_CELL_STYLE_METHOD:s,FOOTER_CELL_STYLE_METHOD:o,READONLY_TEXT_COLOR:r,FOOTER_BG_COLOR:n,HIGHLIGHT_SELECTED_ROW:l,HIGHLIGHT_SELECTED_ROW_COLOR:h,HIGHLIGHT_HOVER_ROW:f,HIGHLIGHT_HOVER_ROW_COLOR:d}=this.ctx.config;if(this.cellType==="footer"){let y=n,C=r;if(typeof o=="function"){const m=o,{backgroundColor:E,color:b}=m({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};E&&(y=E),b&&(C=b)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=y,this.drawTextColor=C;return}let x="transparent";const u=this.ctx.focusCell,p=this.ctx.hoverCell;f&&(p==null?void 0:p.rowKey)===this.rowKey&&(x=d),l&&(u==null?void 0:u.rowKey)===this.rowKey&&(x=h),this.drawCellSkyBgColor=x;let g=e,w=r;if(["index","index-selection","selection"].includes(this.type)){this.drawCellBgColor=e,this.drawTextColor=r;return}if(this.ctx.database.getReadonly(this.rowKey,this.key)||(g=i,w=r),typeof s=="function"){const y=s,{backgroundColor:C,color:m}=y({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};C&&(g=C),m&&(w=m)}this.drawCellBgColor=g,this.drawTextColor=w}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:o,cellType:r,type:n,rowIndex:l,rowKey:h}=this;if(!(s===0||o===0)&&r!=="footer"&&["index-selection","selection"].includes(n)){const f=this.ctx.database.getRowSelection(h),d=this.ctx.database.getRowSelectable(h),{CHECKBOX_SIZE:x=0}=this.ctx.config,u=this.drawX+(e-x)/2,p=this.drawY+(i-x)/2;let g=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck";f&&d?(g=this.ctx.icons.get("checkbox-check"),w="checkbox-check"):f&&d?(g=this.ctx.icons.get("checkbox-check-disabled"),w="checkbox-check-disabled"):!f&&d?(g=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck"):(g=this.ctx.icons.get("checkbox-disabled"),w="checkbox-disabled"),g&&n=="index-selection"?(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===l||["checkbox-disabled","checkbox-check"].includes(w))&&(this.drawImageX=u,this.drawImageY=p,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=w,this.drawImageSource=g):g&&n==="selection"&&(this.drawImageX=u,this.drawImageY=p,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=w,this.drawImageSource=g)}}updateHoverIcon(){const{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 o=this.drawX+this.width-i-s,r=this.drawY+(this.height-i)/2;if(this.hoverIconName&&this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===this.rowIndex){const n=this.ctx.icons.get(this.hoverIconName);this.drawImageX=o,this.drawImageY=r,this.drawImageWidth=i,this.drawImageHeight=i,this.drawImageName=this.hoverIconName,this.drawImageSource=n}}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 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{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.target.width-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:"none"}}draw(){const{paint:e,config:{BORDER_COLOR:i}}=this.ctx,{drawX:s,drawY:o}=this;e.drawRect(s,o,this.visibleWidth,this.visibleHeight,{borderColor:i,fillColor:this.drawCellBgColor}),e.drawRect(s,o,this.width,this.height,{borderColor:"transparent",borderWidth:1,fillColor:this.drawCellSkyBgColor}),this.ellipsis=this.drawText(),this.drawImage(),this.drawSelector(),this.drawAutofillPiont(),this.drawErrorTip()}getWidthByColIndexColSpan(e,i){if(i===0)return 0;let s=0;for(let o=e;o<e+i;o++){const r=this.ctx.header.leafCellHeaders[o];s+=r.width}return s}drawText(){const{CELL_PADDING:e,BODY_FONT:i}=this.ctx.config;return 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:o,yArr:r}=this.ctx.selector,n=o[1],l=r[1],{colIndex:h,rowIndex:f,drawX:d,drawY:x}=this;h===n&&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:o,yArrCopy:r}=this.ctx.selector;this.drawBorder({xArr:o,yArr:r,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,o=this.drawX,r=this.drawY,n=[o+s-e-.5,r,o+s-.5,r,o+s-.5,r+e];this.ctx.paint.drawLine(n,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,width:o,rowIndex:r,colIndex:n}=this,l=i+.5;let h=s+.5,f=this.height;r===0&&(h=this.y+1,f=f-1);const{xArr:d,yArr:x,lineDash:u=[],borderWidth:p=1,borderColor:g,fillColor:w}=e,y=d[0],C=d[1],m=x[0],E=x[1];n>=y&&n<=C&&r===m&&this.ctx.paint.drawLine([l,h,l+o-2,h],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u}),n>=y&&n<=C&&r===E&&this.ctx.paint.drawLine([l,h+f-1.5,l+o,h+f-1.5],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u}),n===y&&r>=m&&r<=E&&this.ctx.paint.drawLine([l,h,l,h+f-1],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u}),n===C&&r>=m&&r<=E&&this.ctx.paint.drawLine([l+o-1,h,l+o-1,h+f-1],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u})}}class Jt extends Ut{constructor(e,i,s,o,r,n,l){super(e,s,o,r,n,l.fixed,"header");c(this,"align");c(this,"verticalAlign","middle");c(this,"fixed");c(this,"widthFillDisable");c(this,"type");c(this,"operation",!1);c(this,"editorType");c(this,"level");c(this,"text");c(this,"displayText","");c(this,"colspan");c(this,"rowspan");c(this,"key");c(this,"required",!1);c(this,"readonly",!1);c(this,"children",[]);c(this,"column");c(this,"colIndex");c(this,"rowKey");c(this,"rules");c(this,"hasChildren");c(this,"render");c(this,"style",{});c(this,"drawX",0);c(this,"drawY",0);c(this,"drawCellBgColor","");c(this,"drawTextColor","");c(this,"drawImageX",0);c(this,"drawImageY",0);c(this,"drawImageWidth",0);c(this,"drawImageHeight",0);c(this,"drawImageName","");c(this,"drawImageSource");this.ctx=e,this.x=s,this.y=o,this.width=r,this.height=n,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=_t(),this.hasChildren=l.children&&l.children.length>0||!1,this.render=l.renderHeader}isVerticalVisible(){const{target:e}=this.ctx,i=e.height;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 o=i,r=s;if(typeof e=="function"){const n=e,{backgroundColor:l,color:h}=n({colIndex:this.colIndex,column:this.column})||{};l&&(o=l),h&&(r=h)}this.drawCellBgColor=o,this.drawTextColor=r}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:o}}=this.ctx,{drawX:r,drawY:n,displayText:l}=this;e.drawRect(r,n,this.width,this.height,{borderColor:i,fillColor:this.drawCellBgColor}),e.drawText(l,r,n,this.width,this.height,{font:o,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:o,check:r,selectable:n}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:l=0}=this.ctx.config,h=this.drawX+(e-l)/2,f=this.drawY+(i-l)/2;let d=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck";o?(d=this.ctx.icons.get("checkbox-indeterminate"),x="checkbox-indeterminate"):r&&n?(d=this.ctx.icons.get("checkbox-check"),x="checkbox-check"):r&&n?(d=this.ctx.icons.get("checkbox-check-disabled"),x="checkbox-check-disabled"):!r&&n?(d=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck"):(d=this.ctx.icons.get("checkbox-disabled"),x="checkbox-disabled"),d&&(this.drawImageX=h,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.target.width-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:"none"}}}class oi{constructor(t){c(this,"ctx");c(this,"visibleHoverCell");c(this,"resizeObserver");this.ctx=t,this.init()}init(){this.resizeObserver=new ResizeObserver(()=>{this.ctx.emit("resetHeader"),this.ctx.emit("resizeObserver")}),this.ctx.target.parentElement&&this.resizeObserver.observe(this.ctx.target),this.ctx.on("mousedown",t=>{if(t.button!==0||this.isBusy(t))return;const e=t.offsetY,i=t.offsetX,s=this.ctx.header.renderCellHeaders;for(const r of s){const n=r.getDrawX(),l=r.getDrawY();if(i>n&&i<n+r.width&&e>l&&e<l+r.height){this.ctx.focusCellHeader=r,this.ctx.emit("cellHeaderMousedown",r,t);return}}const o=this.ctx.body.renderRows;for(const r of o){const n=r.fixedCells.concat(r.noFixedCells);for(const l of n){const h=l.getDrawX(),f=l.getDrawY();if(i>h&&i<h+l.width&&e>f&&e<f+l.height){this.ctx.setFocusCell(l),this.ctx.emit("cellMousedown",l,t);return}}}}),this.ctx.on("click",t=>{if(t.button!==0||this.isBusy(t))return;const e=t.offsetY,i=t.offsetX,s=this.ctx.header.renderCellHeaders;for(const r of s){const n=r.getDrawX(),l=r.getDrawY();if(i>n&&i<n+r.width&&e>l&&e<l+r.height){this.ctx.clickCellHeader=r,this.ctx.emit("cellHeaderClick",r,t),this.selectionClick(r);return}}const o=this.ctx.body.renderRows;for(const r of o){const n=r.fixedCells.concat(r.noFixedCells);for(const l of n){const h=l.getDrawX(),f=l.getDrawY();if(i>h&&i<h+l.width&&e>f&&e<f+l.height){this.ctx.clickCell=l,this.ctx.emit("cellClick",l,t),this.selectionClick(l),this.treeClick(l);return}}}}),this.ctx.on("contextMenu",t=>{if(this.isBusy(t))return;const e=t.offsetY,i=t.offsetX,s=this.ctx.header.renderCellHeaders;for(const r of s){const n=r.getDrawX(),l=r.getDrawY();if(i>n&&i<n+r.width&&e>l&&e<l+r.height){this.ctx.emit("cellHeaderContextMenuClick",r,t);return}}const o=this.ctx.body.renderRows;for(const r of o){const n=r.fixedCells.concat(r.noFixedCells);for(const l of n){const h=l.getDrawX(),f=l.getDrawY();if(i>h&&i<h+l.width&&e>f&&e<f+l.height){this.ctx.emit("cellContextMenuClick",l,t);return}}}}),this.ctx.on("mousemove",t=>{var r;if(this.isBusy(t))return;const e=t.offsetY,i=t.offsetX,s=this.ctx.header.renderCellHeaders;for(const n of s){const l=n.getDrawX(),h=n.getDrawY();if(i>l&&i<l+n.width&&e>h&&e<h+n.height){if(this.ctx.emit("cellHeaderMouseenter",n,t),this.ctx.hoverCellHeader&&this.ctx.hoverCellHeader!==n&&this.ctx.emit("cellHeaderMouseleave",this.ctx.hoverCellHeader,t),this.imageEnterAndLeave(n,t),this.ctx.hoverCellHeader===n)return;this.ctx.hoverCellHeader=n,this.ctx.emit("cellHeaderHoverChange",n);return}}const o=this.ctx.body.renderRows;for(const n of o){const l=n.fixedCells.concat(n.noFixedCells);for(const h of l){const f=h.getDrawX(),d=h.getDrawY();if(i>f&&i<f+h.visibleWidth&&e>d&&e<d+h.visibleHeight&&(this.imageEnterAndLeave(h,t),this.visibleHoverCell!==h&&(this.ctx.emit("visibleCellMouseleave",h,t),this.visibleHoverCell=h,this.ctx.emit("visibleCellHoverChange",h,t))),i>f&&i<f+h.width&&e>d&&e<d+h.height){if(this.ctx.emit("cellMouseenter",h,t),this.ctx.hoverCell&&this.ctx.hoverCell!==h&&this.ctx.emit("cellMouseleave",this.ctx.hoverCell,t),this.ctx.hoverCell===h)return;((r=this.ctx.hoverCell)==null?void 0:r.rowKey)!==h.rowKey&&(this.ctx.hoverCell=h,this.ctx.hoverRow=this.ctx.body.renderRows.find(x=>x.rowKey===h.rowKey),this.ctx.emit("rowHoverChange",this.ctx.hoverRow,h,t),this.ctx.emit("draw")),this.ctx.hoverCell=h,this.ctx.emit("cellHoverChange",h,t);return}}}})}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:o,EXPAND_LAZY_METHOD:r}=this.ctx.config;if(o&&r&&!i&&!s)typeof r=="function"&&(this.ctx.database.expandLoading(t.rowKey,!0),r({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)}).catch(l=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(l)}));else{const n=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!n),this.ctx.emit("expandChange")}}}imageEnterAndLeave(t,e){const i=e.offsetY,s=e.offsetX;s>t.drawImageX&&s<t.drawImageX+t.drawImageWidth&&i>t.drawImageY&&i<t.drawImageY+t.drawImageHeight?(this.ctx.target.style.cursor="pointer",this.ctx.isPointer=!0,t instanceof Zt&&["selection","index-selection"].includes(t.type)&&(this.ctx.database.getRowSelectable(t.rowKey)||(this.ctx.target.style.cursor="not-allowed"))):(this.ctx.isPointer=!1,this.ctx.target.style.cursor==="pointer"&&(this.ctx.target.style.cursor="default"))}isBusy(t){const e=t.offsetY,i=t.offsetX;if(!(t.target instanceof HTMLCanvasElement)||!this.ctx.isTarget(t.target)||this.ctx.target.style.cursor==="row-resize"||this.ctx.target.style.cursor==="col-resize"||this.ctx.columnResizing||this.ctx.rowResizing)return!0;const{SCROLLER_TRACK_SIZE:s}=this.ctx.config;return!!(this.ctx.scrollerMove||this.ctx.scrollerFocus||e>this.ctx.target.height-s||i>this.ctx.target.width-s)}destroy(){this.resizeObserver.unobserve(this.ctx.target)}}class ni{constructor(t,e,i){c(this,"eventBus");c(this,"eventBrowser");c(this,"eventTable");c(this,"uuid",_t());c(this,"targetContainer");c(this,"target");c(this,"paint");c(this,"icons");c(this,"mousedown",!1);c(this,"isPointer",!1);c(this,"rowResizing",!1);c(this,"columnResizing",!1);c(this,"scrollerMove",!1);c(this,"scrollerFocus",!1);c(this,"autofillMove",!1);c(this,"selectorMove",!1);c(this,"editing",!1);c(this,"scrollY",0);c(this,"scrollX",0);c(this,"fixedLeftWidth",0);c(this,"fixedRightWidth",0);c(this,"maxColIndex",0);c(this,"maxRowIndex",0);c(this,"hoverRow");c(this,"clickCell");c(this,"focusCell");c(this,"hoverCell");c(this,"clickCellHeader");c(this,"focusCellHeader");c(this,"hoverCellHeader");c(this,"body",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,headIndex:0,tailIndex:0,visibleRows:[],renderRows:[],data:[]});c(this,"footer",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,renderRows:[]});c(this,"header",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,visibleLeafColumns:[],leafCellHeaders:[],renderLeafCellHeaders:[],renderCellHeaders:[],fixedLeftCellHeaders:[],fixedRightCellHeaders:[],renderCenterCellHeaders:[]});c(this,"selector",{enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]});c(this,"autofill",{enable:!1,xArr:[-1,-1],yArr:[-1,-1]});c(this,"database");c(this,"history");c(this,"config");this.target=e,this.targetContainer=t,this.target.setAttribute("uuid",this.uuid),this.config=new jt(i.config||{}),this.eventBus=new ii,this.eventBrowser=new ei(this),this.eventTable=new oi(this),this.paint=new si(e),this.database=new Qe(this,i),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 o=0;o<=e[1]-e[0];o++){const r=[];for(let n=0;n<=i[1]-i[0];n++){const l=o+e[0],h=n+i[0],f=this.database.getItemValueForRowIndexAndColIndex(l,h);f&&r.push(f.value)}s+=`${r.join(" ")}\r`,t.push(r)}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 o=Math.floor(e);const r=this.body.height-this.body.visibleHeight-this.footer.height;o<0?o=0:o>r&&(o=r),this.emit("setScroll",i,o)}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);const i=this.body.height-this.body.visibleHeight-this.footer.height;e<0?e=0:e>i&&(e=i),this.emit("setScrollY",e)}isTarget(t){if(t===null)return!1;const e=t.getAttribute("uuid");return this.uuid===e}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){c(this,"ctx");c(this,"type");c(this,"isFocus",!1);c(this,"trackX",0);c(this,"trackY",0);c(this,"trackWidth",0);c(this,"trackHeight",0);c(this,"splitPoints",[]);c(this,"barX",0);c(this,"barY",0);c(this,"barWidth",0);c(this,"barHeight",0);c(this,"distance",0);c(this,"visibleDistance",0);c(this,"clientX",0);c(this,"clientY",0);c(this,"dragStart",0);c(this,"isDragging",!1);c(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 HTMLCanvasElement)||!this.ctx.isTarget(t.target))return;if(this.ctx.target.style.cursor==="row-resize"||this.ctx.target.style.cursor==="col-resize")return!0;const{offsetX:e,offsetY:i,clientX:s,clientY:o}=t;if(!(s==this.clientX&&o==this.clientY)){if(this.isOnScrollbar(e,i))this.clientX=s,this.clientY=o,this.isDragging=!0,this.ctx.scrollerMove=!0,this.isFocus=!0,this.dragStart=this.scroll;else if(this.isOnTrack(e,i)){let r=0;this.type==="vertical"?r=(i-this.ctx.header.height-this.barHeight/2)/(this.visibleDistance-this.barHeight)*this.distance:r=(e-this.barWidth/2)/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(r,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:o}=t;if(this.isOnScrollbar(e,i)&&t.target===this.ctx.target?this.isFocus=!0:this.isFocus=!1,s==this.clientX&&o==this.clientY)return;let r=0;if(this.type==="horizontal"?r=s-this.clientX:r=o-this.clientY,this.isDragging&&r!==0){let n=0;this.type==="vertical"?n=this.dragStart+r/(this.visibleDistance-this.barHeight)*this.distance:n=this.dragStart+r/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(n,this.distance))}}isPointInElement(t,e,i,s,o,r){return t>=i&&t<=i+o&&e>=s&&e<=s+r}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.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,config:{SCROLLER_TRACK_SIZE:i=0,SCROLLER_SIZE:s=0}}=this.ctx,o=this.ctx.target.width+1,r=this.ctx.target.height,n=e.height,l=e.width,h=t.height,f=this.ctx.footer.height;if(this.type==="vertical"){this.visibleDistance=r-i-n,this.distance=h-this.visibleDistance+f,this.trackX=o-i,this.trackY=0,this.splitPoints=[this.trackX,n,this.trackX+i,n],this.trackWidth=i,this.trackHeight=r,this.barX=this.trackX+(i-s)/2,this.barWidth=s;const d=this.distance?this.visibleDistance/h:0;let x=Math.floor(d*this.visibleDistance);x<30?x=30:x>this.visibleDistance&&(x=0),this.barHeight=x,this.barY=n+this.scroll/this.distance*(this.visibleDistance-this.barHeight),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}else{this.visibleDistance=o-i,this.distance=l-this.visibleDistance,this.splitPoints=[o-i,r-i,o-i,r],this.trackX=0,this.trackY=r-i,this.trackWidth=o,this.trackHeight=i;const d=this.distance?this.visibleDistance/l:0;let x=Math.floor(d*this.visibleDistance);this.barY=this.trackY+.5+(i-s)/2,x<30?x=30:x>=this.visibleDistance&&(x=0),this.barWidth=x,this.barHeight=s,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){c(this,"ctx");c(this,"verticalScrollbar");c(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:o}=i.getPositionForRowIndex(s);this.setScrollY(o-e.visibleHeight/2)}}class ci{constructor(t){c(this,"ctx");c(this,"x",0);c(this,"y",0);c(this,"width",0);c(this,"height",0);c(this,"resizeTarget",null);c(this,"resizeNum",0);c(this,"isResizing",!1);c(this,"clientX",0);c(this,"resizeDiff",0);c(this,"columnIndex",0);c(this,"isMouseDown",!1);c(this,"columns");c(this,"visibleLeafColumns",[]);c(this,"visibleHeight",0);c(this,"visibleWidth",0);c(this,"allCellHeaders",[]);c(this,"leafCellHeaders",[]);c(this,"renderLeafCellHeaders",[]);c(this,"fixedLeftCellHeaders",[]);c(this,"centerCellHeaders",[]);c(this,"fixedRightCellHeaders",[]);c(this,"renderCenterCellHeaders",[]);c(this,"renderFixedCellHeaders",[]);this.ctx=t,this.ctx.on("resetHeader",zt(()=>{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=Vt(i),o=It(i);this.height=t*s,this.width=o.reduce((d,x)=>d+((x==null?void 0:x.width)||100),0),this.visibleHeight=this.height;const r=je($t(i,s));this.columnIndex=0,this.resizeNum=0,this.render(r,0),this.ctx.database.updateColIndexKeyMap(this.leafCellHeaders);const n=this.ctx.targetContainer.getBoundingClientRect();this.resizeNum>0?this.ctx.target.width=n.width:this.ctx.target.width=this.width+e-1,this.visibleWidth=this.ctx.target.width-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 h=this.fixedLeftCellHeaders.filter(d=>!d.hasChildren);this.ctx.fixedLeftWidth=h.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(e.target)&&(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{target:i,config:{RESIZE_COLUMN_MIN_WIDTH:s}}=this.ctx;if(this.isResizing&&this.resizeTarget){const o=this.resizeTarget.width;let r=e.clientX-this.clientX;r+o<s&&(r=-(o-s)),this.resizeDiff=r,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown)return;this.ctx.target.style.cursor==="col-resize"&&(this.ctx.target.style.cursor="default");const o=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(const r of o){const n=e.layerX,l=r.getDrawX();n>l+r.width-5&&n<l+r.width+4&&n<i.width-4&&r.colspan<=1&&e.target instanceof HTMLCanvasElement&&this.ctx.isTarget(e.target)&&e.layerY<=this.height&&(this.ctx.target.style.cursor="col-resize",this.resizeTarget=r)}}}))}resizeColumn(t,e){const i=o=>{o.forEach(r=>{if(r.children&&r.children.length>0&&i(r.children),r.key===t.key){const n=r.width||100;r.width=n+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 o=this.visibleWidth-this.width;s=Math.floor(o/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 o of this.allCellHeaders)if(o.widthFillDisable)e.set(o.key,o.width);else{const r=o.width+t*o.colspan;e.set(o.key,r),r<this.ctx.config.RESIZE_COLUMN_MIN_WIDTH&&(i=!1)}if(!i)return;const s=o=>{o.forEach(r=>{e.has(r.key)&&(r.width=e.get(r.key)),r.children&&r.children.length>0&&s(r.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:o=0}=this.ctx.config;for(let r=0;r<i;r++){const n=t[r],l=o*(n.rowspan||1),h=o*n.level;let f=n.width||100;n.children&&(f=It(n.children).reduce((u,p)=>u+((p==null?void 0:p.width)||100),0));const d=new Jt(this.ctx,this.columnIndex,s,h,f,l,n);this.ctx.database.setHeader(n.key,d),this.allCellHeaders.push(d),n.children||(this.leafCellHeaders.push(d),d.column.widthFillDisable||this.resizeNum++),n.fixed==="left"?this.fixedLeftCellHeaders.push(d):n.fixed==="right"?this.fixedRightCellHeaders.push(d):this.centerCellHeaders.push(d),!n.children&&this.columnIndex++,n.children&&this.render(n.children,s),s+=f}}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{target:t,config:{RESIZE_COLUMN_LINE_COLOR:e}}=this.ctx,i=this.resizeTarget.getDrawX(),s=this.resizeTarget.width,o=i+s+this.resizeDiff-.5,r=[o+.5,0,o+.5,t.height];this.ctx.paint.drawLine(r,{borderColor:e,borderWidth:1})}}drawFiexShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,target:o,config:{HEADER_BG_COLOR:r,SCROLLER_TRACK_SIZE:n}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:r,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-s.visibleWidth-1)&&e!==n){const l=s.width-(this.x+this.width)+o.width-e;this.ctx.paint.drawShadow(l+1,this.y,e,this.height,{fillColor:r,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,o)=>s.x-o.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,o=0,r=0,n,l="body"){c(this,"ctx");c(this,"x",0);c(this,"y",0);c(this,"width",0);c(this,"height");c(this,"cells",[]);c(this,"fixedCells",[]);c(this,"noFixedCells",[]);c(this,"rowIndex",0);c(this,"rowKey","");c(this,"rowType","body");c(this,"data");this.ctx=t,this.x=i,this.y=s,this.width=o,this.height=r,this.rowIndex=e,this.rowKey=t.database.getRowKeyForRowIndex(e),this.rowType=l,this.data=n,this.update()}update(){const{header:t}=this.ctx,e=[],i=[],s=[];t.renderLeafCellHeaders.forEach(o=>{const r=new Zt(this.ctx,this.rowIndex,o.colIndex,o.x,this.y,o.width,this.height,o.column,this.data,this.rowType);r.fixed?i.push(r):s.push(r),e.push(r)}),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){c(this,"resizeTarget",null);c(this,"isMouseDown",!1);c(this,"resizeDiff",0);c(this,"clientY",0);c(this,"ctx");c(this,"x",0);c(this,"y",0);c(this,"width",0);c(this,"height",0);c(this,"headIndex",0);c(this,"tailIndex",0);c(this,"isResizing",!1);c(this,"renderRows",[]);c(this,"visibleRows",[]);c(this,"visibleHeight",0);c(this,"visibleWidth",0);c(this,"data",[]);this.ctx=t,this.init(),this.initResizeRow()}init(){const{target:t,header:e,database:i,config:{FOOTER_FIXED:s,SCROLLER_TRACK_SIZE:o=0,BORDER_COLOR:r,BORDER_RADIUS:n,HEIGHT:l,EMPTY_BODY_HEIGHT:h=0,MAX_HEIGHT:f=0,ENABLE_OFFSET_HEIGHT:d=0,OFFSET_HEIGHT:x=0}}=this.ctx;if(!e.width)return;this.x=0,this.y=e.height;const{data:u,sumHeight:p}=i.getData();this.height=p,this.data=u;const{top:g}=t.getBoundingClientRect();this.width=e.width,this.visibleWidth=t.width-o;const w=this.ctx.footer.height;this.data.length||(this.height=h);const y=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:y,type:y,headerHeight:e.height,bodyHeight:this.height,footerHeight:w,width:this.width,height:this.data.length?0:h+w});let C=this.height+e.height+o;C+=w;let m=0;this.data.length&&d?(m=window.innerHeight-g-x,m<0&&(m=32,console.error("There is an error in the height calculation ENABLE_OFFSET_HEIGHT and OFFSET_HEIGHT are invalid"))):this.data.length&&l?m=l:this.data.length&&f&&C>f?m=f:m=C,m>0&&(this.ctx.target.height=m);let E=t.height-e.height-o;s?this.visibleHeight=E-w:this.visibleHeight=E,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=u,this.ctx.target.setAttribute("style",`outline: none; position: relative; border-radius: ${n}px; border: 1px solid ${r}; height:${this.ctx.target.height}px;width:${this.ctx.target.width-1}px;`)}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(e.target)&&(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 i=e.offsetY,s=e.offsetX,o=e.clientY,{target:r,scrollY:n,config:{RESIZE_ROW_MIN_HEIGHT:l=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){const h=this.resizeTarget.height;let f=o-this.clientY;f+h<l&&(f=-(h-l)),this.resizeDiff=f,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown||this.ctx.target.style.cursor==="crosshair")return;this.ctx.target.style.cursor==="row-resize"&&(this.ctx.target.style.cursor="default");for(let h=0;h<this.renderRows.length;h++){const f=this.renderRows[h];if(i>f.y-n+f.height-1.5&&i<f.y-n+f.height+1.5&&i<r.height-4)for(let x=0;x<f.cells.length;x++){const u=f.cells[x];s>u.drawX+10&&s<u.drawX+u.width-10&&u.rowspan===1&&(this.ctx.target.style.cursor="row-resize",this.resizeTarget=f)}}}}))}resizeRow(t,e){const{rowIndex:i,height:s,rowKey:o,data:r}=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:o,row:r,data:this.data})}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{target:t,scrollY:e,config:{RESIZE_ROW_LINE_COLOR:i}}=this.ctx,s=this.resizeTarget.y-e,o=this.resizeTarget.height,r=s+o+this.resizeDiff-.5,n=[0,r+.5,t.width,r+.5];this.ctx.paint.drawLine(n,{borderColor:i,borderWidth:1})}}drawFiexShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,target:o,config:{HEADER_BG_COLOR:r,SCROLLER_TRACK_SIZE:n}}=this.ctx;if(i>0&&t!==0&&this.ctx.paint.drawShadow(this.x,this.y,t,this.height,{fillColor:r,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-s.visibleWidth-1)&&e!==n){const l=s.width-(this.x+this.width)+o.width-e;this.ctx.paint.drawShadow(l+1,this.y,e,this.height,{fillColor:r,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,o=-1;for(;i<=s;){let r=Math.floor((i+s)/2),n=t[r].bottom;if(n===e)return r;n<e?i=r+1:(o=r,s=r-1)}return o}update(){this.init();const{header:t,database:e,scrollY:i}=this.ctx,s=i,{data:o,positions:r}=e.getData();this.ctx.maxRowIndex=o.length-1;const n=this.binarySearch(r,s);let l=this.binarySearch(r,s+this.visibleHeight);l===-1&&(l=o.length),this.headIndex=Math.max(0,n),this.tailIndex=Math.min(this.ctx.maxRowIndex,l+1),this.visibleRows=o.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 h=[];for(let f=0;f<this.visibleRows.length;f++){const d=this.headIndex+f,x=this.visibleRows[f],{height:u,top:p}=this.ctx.database.getPositionForRowIndex(d),g=new te(this.ctx,d,0,p+this.y,t.width,u,x);h.push(g)}this.renderRows=h,this.ctx.body.renderRows=h}draw(){this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFiexShadow(),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTipLine()}}class hi{constructor(t){c(this,"ctx");c(this,"renderRows",[]);c(this,"data",[]);c(this,"x",0);c(this,"y",0);c(this,"width",0);c(this,"height",0);c(this,"visibleWidth",0);c(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:o}}=this.ctx;this.width=t.width,this.visibleWidth=t.visibleWidth,this.height=this.data.reduce(r=>r+i,0),this.visibleHeight=this.height,s?this.y=this.ctx.target.height-this.height-o: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,target:o,config:{HEADER_BG_COLOR:r,SCROLLER_TRACK_SIZE:n}}=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:r,side:"right",shadowWidth:4,colorStart:"rgba(0,0,0,0.1)",colorEnd:"rgba(0,0,0,0)"}),i<Math.floor(s.width-s.visibleWidth-1)&&e!==n){const h=s.width-(this.x+this.width)+o.width-e;this.ctx.paint.drawShadow(h+1,l,e,this.height,{fillColor:r,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,o)=>{const r=new te(this.ctx,o,0,e,this.width,t,s,"footer");e+=t,i.push(r)}),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){c(this,"isCut",!1);c(this,"isMultipleRow",!1);c(this,"ctx");c(this,"adjustPositionX","");c(this,"adjustPositionY","");c(this,"timerX",0);c(this,"timerY",0);this.ctx=t,this.init()}init(){this.ctx.on("mousemove",zt(t=>{const{offsetX:e,offsetY:i}=t,s=this.ctx.isTarget(t.target)&&e>0&&e<this.ctx.body.visibleWidth&&i>this.ctx.header.visibleHeight&&i<this.ctx.header.visibleHeight+this.ctx.body.visibleHeight;(this.ctx.selectorMove||this.ctx.autofillMove)&&(s?this.stopAdjustPosition():this.startAdjustPosition(t))},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(e.target)&&this.ctx.target.style.cursor!=="pointer"&&!this.ctx.isPointer&&this.ctx.target.style.cursor!=="crosshair"){if(t.operation){this.isMultipleRow=!0,this.selectRows(t);return}this.isMultipleRow=!1,this.click(e.shiftKey)}}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHeaderMousedown",t=>{this.ctx.target.style.cursor!=="pointer"&&(this.ctx.isPointer||this.selectCols(t))}),this.ctx.on("keydown",t=>{if(t.ctrlKey&&t.code==="KeyV"||t.metaKey&&t.code==="KeyV"){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 o=t,r=e;if(!s){const[n]=r;r=[n,n]}if(!i){const[n]=o;o=[n,n]}if(JSON.stringify(this.ctx.selector.xArr)!==JSON.stringify(o)||JSON.stringify(this.ctx.selector.yArr)!==JSON.stringify(r)){this.ctx.mousedown&&(this.ctx.selectorMove=!0),this.ctx.selector.enable=!0;const{SELECTOR_AREA_MIN_X:n,SELECTOR_AREA_MAX_X:l,SELECTOR_AREA_MIN_Y:h,SELECTOR_AREA_MAX_Y:f,SELECTOR_AREA_MAX_X_OFFSET:d,SELECTOR_AREA_MAX_Y_OFFSET:x}=this.ctx.config,u=n,p=l||this.ctx.maxColIndex-d,g=h,w=f||this.ctx.maxRowIndex-x;let[y,C]=o,[m,E]=r;if(y<u||C>p||m<g||E>w)return;this.ctx.selector.xArr=[Math.max(u,y),Math.min(p,C)],this.ctx.selector.yArr=[Math.max(g,m),Math.min(w,E)],this.ctx.emit("setSelector",this.ctx.selector),this.ctx.emit("draw")}}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,o=e,r=i||this.ctx.maxRowIndex-s;if(this.ctx.mousedown&&this.ctx.focusCellHeader){const{colIndex:n}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),t.colIndex>=n){const l=[n,t.colIndex+t.colspan-1],h=[o,r];this.setSelector(l,h)}else{const l=[t.colIndex,n],h=[o,r];this.setSelector(l,h)}}else{const n=[t.colIndex,t.colIndex+t.colspan-1],l=[o,r];this.setSelector(n,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:o,SELECTOR_AREA_MAX_Y:r,SELECTOR_AREA_MAX_X_OFFSET:n,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,h=i,f=s||this.ctx.maxColIndex-n,d=o,x=r||this.ctx.maxRowIndex-l,u=[h,f],p=[d,x];this.setSelector(u,p)}}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:o}=this.ctx.config,r=s||this.ctx.maxColIndex-o,n=i;if(e){this.ctx.setFocusCell(t);const l=[n,r],h=[t.rowIndex,t.rowIndex];this.setSelector(l,h)}if(this.ctx.focusCell&&this.ctx.mousedown){const{rowIndex:l}=this.ctx.focusCell;if(t.rowIndex>=l){const h=[n,r],f=[l,t.rowIndex];this.setSelector(h,f)}else{const h=[n,r],f=[t.rowIndex,l];this.setSelector(h,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:o}=e,r=Math.min(i.colIndex,o),n=Math.max(i.colIndex,o),l=Math.min(i.rowIndex,s),h=Math.max(i.rowIndex,s),f=[r,n],d=[l,h];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:o}=i,{colIndex:r,rowIndex:n}=e,l=Math.min(r,s),h=Math.max(r,s),f=Math.min(n,o),d=Math.max(n,o),x=[l,h],u=[f,d];this.setSelector(x,u)}else{this.ctx.emit("cellSelectedClick",e);const s=[e.colIndex,e.colIndex],o=[e.rowIndex,e.rowIndex];this.setSelector(s,o),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(o=>o.rowIndex===t);return i==null?void 0:i.cells.find(o=>o.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("setCopy",this.ctx.selector),this.ctx.emit("draw")}).catch(i=>console.error("复制失败:",i)):console.error("当前浏览器不支持Clipboard API")}clearSelectedData(t,e,i=!1){let s=[];const o=new Set;for(let n=0;n<=e[1]-e[0];n++)for(let l=0;l<=t[1]-t[0];l++){const h=n+e[0],f=l+t[0],d=this.ctx.database.getItemValueForRowIndexAndColIndex(h,f);if(d){const{rowKey:x,key:u}=d;this.ctx.database.getReadonly(x,u)||(o.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 r=[];return o.forEach(n=>{r.push(this.ctx.database.getRowDataItemForRowKey(n))}),this.ctx.emit("clearSelectedDataChange",s,r),this.ctx.emit("draw"),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(o=>{let r=Ze(o),n=[];for(let h=0;h<=r.length-1;h++){const f=r[h].length;for(let d=0;d<=f-1;d++){const x=h+e,u=d+i,p=r[h][d],g=this.ctx.database.getItemValueForRowIndexAndColIndex(x,u);if(g){const{rowKey:w,key:y}=g;this.ctx.database.getReadonly(w,y)||(s.add(w),n.push({rowKey:w,key:y,value:p,row:{}}))}}}if(this.isCut){const h=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),f=n.map(d=>`${d.rowKey}-${d.key}`);h.forEach(d=>{f.includes(`${d.rowKey}-${d.key}`)||n.unshift(d)}),this.isCut=!1}if(!n.length)return;this.ctx.database.batchSetItemValue(n,!0);let l=[];s.forEach(h=>{l.push(this.ctx.database.getRowDataItemForRowKey(h))}),this.ctx.emit("pasteChange",n,l),this.clearCopyLine(),this.ctx.emit("draw")}).catch(o=>{console.error("获取剪贴板内容失败:",o)})}}moveFocus(t){if(this.ctx.editing)return;const{focusCell:e}=this.ctx;if(!e)return;let{colIndex:i=0,rowIndex:s=0}=e;const o=0,r=0,n=this.ctx.maxColIndex,l=this.ctx.maxRowIndex;switch(t){case"LEFT":i>o&&i--;break;case"TOP":s>r&&s--;break;case"RIGHT":i<n&&i++;break;case"BOTTOM":s<l&&s++;break}const h=[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(h,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:o,SELECTOR_AREA_MAX_Y:r,SELECTOR_AREA_MAX_X_OFFSET:n,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,h=i,f=s||this.ctx.maxColIndex-n,d=o,x=r||this.ctx.maxRowIndex-l;return!(e<h||e>f||t<d||t>x)}startAdjustPosition(t){const{offsetX:e,offsetY:i}=t;let s="",o="";if(e<0?s="left":e>this.ctx.body.visibleWidth&&(s="right"),i<this.ctx.header.visibleHeight?o="top":i>this.ctx.header.visibleHeight+this.ctx.body.visibleHeight&&(o="bottom"),s&&this.adjustPositionX!==s){this.adjustPositionX=s;let n=10*(s==="left"?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{n*=1.5;const{scrollX:l}=this.ctx,h=l+n;(h<0||h>this.ctx.body.width)&&(clearInterval(this.timerX),this.timerX=0),this.ctx.setScrollX(h)},100)}if(o&&this.adjustPositionY!==o){this.adjustPositionY=o;let n=10*(o==="top"?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{n*=1.5;const{scrollY:l}=this.ctx,h=l+n;(h<0||h>this.ctx.body.height)&&(clearInterval(this.timerY),this.timerY=0),this.ctx.setScrollY(h)},100)}}adjustBoundaryPosition(){const{target:t,focusCell:e,fixedRightWidth:i,fixedLeftWidth:s,header:o,footer:r,scrollX:n,scrollY:l}=this.ctx;if(!e)return;const{SCROLLER_TRACK_SIZE:h=0,FOOTER_FIXED:f}=this.ctx.config;let d=0;f&&(d=r.visibleHeight);const x=s-e.drawX+1,u=e.drawX+e.width-(t.width-i)+1,p=o.height-e.drawY,g=e.drawY+e.height-(t.height-d-h);u>0&&!e.fixed?this.ctx.setScrollX(n+u):x>0&&!e.fixed&&this.ctx.setScrollX(n-x),p>0?this.ctx.setScrollY(l-p):g>0&&this.ctx.setScrollY(l+g)}destroy(){this.timerX&&(clearTimeout(this.timerX),this.timerX=0),this.timerY&&(clearTimeout(this.timerY),this.timerY=0)}}class fi{constructor(t){c(this,"ctx");this.ctx=t,this.init()}init(){this.ctx.on("cellMouseenter",(t,e)=>{this.ctx.target.style.cursor==="crosshair"&&(this.ctx.target.style.cursor="default");const{xArr:i,yArr:s}=this.ctx.selector,o=i[1],r=s[1],{colIndex:n,rowIndex:l,drawX:h,drawY:f,width:d,height:x}=t;if(this.ctx.config.ENABLE_AUTOFILL&&n===o&&l===r){const p=h+d-6,g=f+x-6;e.offsetX>p&&e.offsetY>g&&(this.ctx.target.style.cursor="crosshair")}this.mouseenter(t)}),this.ctx.on("cellMousedown",()=>{this.ctx.target.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:o}=this.ctx.config;if(!i)return;let r=t,n=e;if(!o){const[l]=n;n=[l,l]}if(!s){const[l]=r;r=[l,l]}if(JSON.stringify(this.ctx.autofill.xArr)!==JSON.stringify(r)||JSON.stringify(this.ctx.autofill.yArr)!==JSON.stringify(n)){const{SELECTOR_AREA_MIN_X:l,SELECTOR_AREA_MAX_X:h,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,p=l,g=h||this.ctx.maxColIndex-x,w=f,y=d||this.ctx.maxRowIndex-u;let[C,m]=r,[E,b]=n;if(C<p||E<w)return;this.ctx.autofill.xArr=[Math.max(p,C),Math.min(g,m)],this.ctx.autofill.yArr=[Math.max(w,E),Math.min(y,b)],this.ctx.emit("setAutofill",this.ctx.autofill),this.ctx.emit("draw")}}autofillData(){const t=new Set,e=this.ctx.getSelectedData(),i=new Map;for(let d=0;d<=e.yArr[1]-e.yArr[0];d++)for(let x=0;x<=e.xArr[1]-e.xArr[0];x++){const u=d+e.yArr[0],p=x+e.xArr[0];i.set(`${u}-${p}`,!0)}const{value:s}=e,o=s[0].length,r=s.length,n=this.ctx.autofill.xArr,l=this.ctx.autofill.yArr;let h=[];for(let d=0;d<=l[1]-l[0];d++)for(let x=0;x<=n[1]-n[0];x++){const u=x+n[0],p=d+l[0],g=s[d%r][x%o],w=this.ctx.database.getItemValueForRowIndexAndColIndex(p,u),y=`${p}-${u}`;if(w&&!i.has(y)){const{rowKey:C,key:m}=w;this.ctx.database.getReadonly(C,m)||(t.add(C),h.push({rowKey:C,key:m,value:g,row:{}}))}}if(!h.length)return;this.ctx.database.batchSetItemValue(h,!0);let f=[];t.forEach(d=>{f.push(this.ctx.database.getRowDataItemForRowKey(d))}),this.ctx.emit("autofillChange",h,f),this.ctx.selector.xArr=this.ctx.autofill.xArr,this.ctx.selector.yArr=this.ctx.autofill.yArr,this.ctx.emit("draw")}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:o}=t,r=e.xArr.slice(),n=e.yArr.slice();s>=e.yArr[0]&&s<=e.yArr[1]?o>e.xArr[1]?r.splice(1,1,o):o<e.xArr[0]&&r.splice(0,1,o):s>e.yArr[1]?n.splice(1,1,s):s<e.yArr[0]&&n.splice(0,1,s),this.setAutofill(r,n)}}destroy(){}}const at=Math.min,Z=Math.max,ut=Math.round,z=a=>({x:a,y:a}),xi={left:"right",right:"left",bottom:"top",top:"bottom"},ui={start:"end",end:"start"};function Ot(a,t,e){return Z(a,at(t,e))}function ct(a,t){return typeof a=="function"?a(t):a}function j(a){return a.split("-")[0]}function lt(a){return a.split("-")[1]}function ee(a){return a==="x"?"y":"x"}function St(a){return a==="y"?"height":"width"}function J(a){return["top","bottom"].includes(j(a))?"y":"x"}function Tt(a){return ee(J(a))}function gi(a,t,e){e===void 0&&(e=!1);const i=lt(a),s=Tt(a),o=St(s);let r=s==="x"?i===(e?"end":"start")?"right":"left":i==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(r=gt(r)),[r,gt(r)]}function wi(a){const t=gt(a);return[At(a),t,At(t)]}function At(a){return a.replace(/start|end/g,t=>ui[t])}function pi(a,t,e){const i=["left","right"],s=["right","left"],o=["top","bottom"],r=["bottom","top"];switch(a){case"top":case"bottom":return e?t?s:i:t?i:s;case"left":case"right":return t?o:r;default:return[]}}function yi(a,t,e,i){const s=lt(a);let o=pi(j(a),e==="start",i);return s&&(o=o.map(r=>r+"-"+s),t&&(o=o.concat(o.map(At)))),o}function gt(a){return a.replace(/left|right|bottom|top/g,t=>xi[t])}function mi(a){return{top:0,right:0,bottom:0,left:0,...a}}function ie(a){return typeof a!="number"?mi(a):{top:a,right:a,bottom:a,left:a}}function wt(a){const{x:t,y:e,width:i,height:s}=a;return{width:i,height:s,top:e,left:t,right:t+i,bottom:e+s,x:t,y:e}}function se(a,t,e){let{reference:i,floating:s}=a;const o=J(t),r=Tt(t),n=St(r),l=j(t),h=o==="y",f=i.x+i.width/2-s.width/2,d=i.y+i.height/2-s.height/2,x=i[n]/2-s[n]/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[r]-=x*(e&&h?-1:1);break;case"end":u[r]+=x*(e&&h?-1:1);break}return u}const Ei=async(a,t,e)=>{const{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:r}=e,n=o.filter(Boolean),l=await(r.isRTL==null?void 0:r.isRTL(t));let h=await r.getElementRects({reference:a,floating:t,strategy:s}),{x:f,y:d}=se(h,i,l),x=i,u={},p=0;for(let g=0;g<n.length;g++){const{name:w,fn:y}=n[g],{x:C,y:m,data:E,reset:b}=await y({x:f,y:d,initialPlacement:i,placement:x,strategy:s,middlewareData:u,rects:h,platform:r,elements:{reference:a,floating:t}});f=C??f,d=m??d,u={...u,[w]:{...u[w],...E}},b&&p<=50&&(p++,typeof b=="object"&&(b.placement&&(x=b.placement),b.rects&&(h=b.rects===!0?await r.getElementRects({reference:a,floating:t,strategy:s}):b.rects),{x:f,y:d}=se(h,x,l)),g=-1)}return{x:f,y:d,placement:x,strategy:s,middlewareData:u}};async function re(a,t){var e;t===void 0&&(t={});const{x:i,y:s,platform:o,rects:r,elements:n,strategy:l}=a,{boundary:h="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:x=!1,padding:u=0}=ct(t,a),p=ie(u),w=n[x?d==="floating"?"reference":"floating":d],y=wt(await o.getClippingRect({element:(e=await(o.isElement==null?void 0:o.isElement(w)))==null||e?w:w.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(n.floating)),boundary:h,rootBoundary:f,strategy:l})),C=d==="floating"?{x:i,y:s,width:r.floating.width,height:r.floating.height}:r.reference,m=await(o.getOffsetParent==null?void 0:o.getOffsetParent(n.floating)),E=await(o.isElement==null?void 0:o.isElement(m))?await(o.getScale==null?void 0:o.getScale(m))||{x:1,y:1}:{x:1,y:1},b=wt(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:n,rect:C,offsetParent:m,strategy:l}):C);return{top:(y.top-b.top+p.top)/E.y,bottom:(b.bottom-y.bottom+p.bottom)/E.y,left:(y.left-b.left+p.left)/E.x,right:(b.right-y.right+p.right)/E.x}}const Ci=a=>({name:"arrow",options:a,async fn(t){const{x:e,y:i,placement:s,rects:o,platform:r,elements:n,middlewareData:l}=t,{element:h,padding:f=0}=ct(a,t)||{};if(h==null)return{};const d=ie(f),x={x:e,y:i},u=Tt(s),p=St(u),g=await r.getDimensions(h),w=u==="y",y=w?"top":"left",C=w?"bottom":"right",m=w?"clientHeight":"clientWidth",E=o.reference[p]+o.reference[u]-x[u]-o.floating[p],b=x[u]-o.reference[u],R=await(r.getOffsetParent==null?void 0:r.getOffsetParent(h));let A=R?R[m]:0;(!A||!await(r.isElement==null?void 0:r.isElement(R)))&&(A=n.floating[m]||o.floating[p]);const L=E/2-b/2,X=A/2-g[p]/2-1,N=at(d[y],X),$=at(d[C],X),O=N,T=A-g[p]-$,S=A/2-g[p]/2+L,it=Ot(O,S,T),W=!l.arrow&&lt(s)!=null&&S!==it&&o.reference[p]/2-(S<O?N:$)-g[p]/2<0,K=W?S<O?S-O:S-T:0;return{[u]:x[u]+K,data:{[u]:it,centerOffset:S-it-K,...W&&{alignmentOffset:K}},reset:W}}}),bi=function(a){return a===void 0&&(a={}),{name:"flip",options:a,async fn(t){var e,i;const{placement:s,middlewareData:o,rects:r,initialPlacement:n,platform:l,elements:h}=t,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:x,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...w}=ct(a,t);if((e=o.arrow)!=null&&e.alignmentOffset)return{};const y=j(s),C=J(n),m=j(n)===n,E=await(l.isRTL==null?void 0:l.isRTL(h.floating)),b=x||(m||!g?[gt(n)]:wi(n)),R=p!=="none";!x&&R&&b.push(...yi(n,g,p,E));const A=[n,...b],L=await re(t,w),X=[];let N=((i=o.flip)==null?void 0:i.overflows)||[];if(f&&X.push(L[y]),d){const S=gi(s,r,E);X.push(L[S[0]],L[S[1]])}if(N=[...N,{placement:s,overflows:X}],!X.every(S=>S<=0)){var $,O;const S=((($=o.flip)==null?void 0:$.index)||0)+1,it=A[S];if(it)return{data:{index:S,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 T;const K=(T=N.filter(q=>{if(R){const G=J(q.placement);return G===C||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:T[0];K&&(W=K);break}case"initialPlacement":W=n;break}if(s!==W)return{reset:{placement:W}}}return{}}}};async function vi(a,t){const{placement:e,platform:i,elements:s}=a,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),r=j(e),n=lt(e),l=J(e)==="y",h=["left","top"].includes(r)?-1:1,f=o&&l?-1:1,d=ct(t,a);let{mainAxis:x,crossAxis:u,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return n&&typeof p=="number"&&(u=n==="end"?p*-1:p),l?{x:u*f,y:x*h}:{x:x*h,y:u*f}}const Ri=function(a){return a===void 0&&(a=0),{name:"offset",options:a,async fn(t){var e,i;const{x:s,y:o,placement:r,middlewareData:n}=t,l=await vi(t,a);return r===((e=n.offset)==null?void 0:e.placement)&&(i=n.arrow)!=null&&i.alignmentOffset?{}:{x:s+l.x,y:o+l.y,data:{...l,placement:r}}}}},_i=function(a){return a===void 0&&(a={}),{name:"shift",options:a,async fn(t){const{x:e,y:i,placement:s}=t,{mainAxis:o=!0,crossAxis:r=!1,limiter:n={fn:w=>{let{x:y,y:C}=w;return{x:y,y:C}}},...l}=ct(a,t),h={x:e,y:i},f=await re(t,l),d=J(j(s)),x=ee(d);let u=h[x],p=h[d];if(o){const w=x==="y"?"top":"left",y=x==="y"?"bottom":"right",C=u+f[w],m=u-f[y];u=Ot(C,u,m)}if(r){const w=d==="y"?"top":"left",y=d==="y"?"bottom":"right",C=p+f[w],m=p-f[y];p=Ot(C,p,m)}const g=n.fn({...t,[x]:u,[d]:p});return{...g,data:{x:g.x-e,y:g.y-i,enabled:{[x]:o,[d]:r}}}}}};function pt(){return typeof window<"u"}function Q(a){return oe(a)?(a.nodeName||"").toLowerCase():"#document"}function D(a){var t;return(a==null||(t=a.ownerDocument)==null?void 0:t.defaultView)||window}function B(a){var t;return(t=(oe(a)?a.ownerDocument:a.document)||window.document)==null?void 0:t.documentElement}function oe(a){return pt()?a instanceof Node||a instanceof D(a).Node:!1}function F(a){return pt()?a instanceof Element||a instanceof D(a).Element:!1}function Y(a){return pt()?a instanceof HTMLElement||a instanceof D(a).HTMLElement:!1}function ne(a){return!pt()||typeof ShadowRoot>"u"?!1:a instanceof ShadowRoot||a instanceof D(a).ShadowRoot}function ht(a){const{overflow:t,overflowX:e,overflowY:i,display:s}=k(a);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&!["inline","contents"].includes(s)}function Ii(a){return["table","td","th"].includes(Q(a))}function yt(a){return[":popover-open",":modal"].some(t=>{try{return a.matches(t)}catch{return!1}})}function Lt(a){const t=Mt(),e=F(a)?k(a):a;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(a){let t=V(a);for(;Y(t)&&!tt(t);){if(Lt(t))return t;if(yt(t))return null;t=V(t)}return null}function Mt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function tt(a){return["html","body","#document"].includes(Q(a))}function k(a){return D(a).getComputedStyle(a)}function mt(a){return F(a)?{scrollLeft:a.scrollLeft,scrollTop:a.scrollTop}:{scrollLeft:a.scrollX,scrollTop:a.scrollY}}function V(a){if(Q(a)==="html")return a;const t=a.assignedSlot||a.parentNode||ne(a)&&a.host||B(a);return ne(t)?t.host:t}function ae(a){const t=V(a);return tt(t)?a.ownerDocument?a.ownerDocument.body:a.body:Y(t)&&ht(t)?t:ae(t)}function Ht(a,t,e){var i;t===void 0&&(t=[]),e===void 0&&(e=!0);const s=ae(a),o=s===((i=a.ownerDocument)==null?void 0:i.body),r=D(s);if(o){const n=Dt(r);return t.concat(r,r.visualViewport||[],ht(s)?s:[],n&&e?Ht(n):[])}return t.concat(s,Ht(s,[],e))}function Dt(a){return a.parent&&Object.getPrototypeOf(a.parent)?a.frameElement:null}function ce(a){const t=k(a);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=Y(a),o=s?a.offsetWidth:e,r=s?a.offsetHeight:i,n=ut(e)!==o||ut(i)!==r;return n&&(e=o,i=r),{width:e,height:i,$:n}}function le(a){return F(a)?a:a.contextElement}function et(a){const t=le(a);if(!Y(t))return z(1);const e=t.getBoundingClientRect(),{width:i,height:s,$:o}=ce(t);let r=(o?ut(e.width):e.width)/i,n=(o?ut(e.height):e.height)/s;return(!r||!Number.isFinite(r))&&(r=1),(!n||!Number.isFinite(n))&&(n=1),{x:r,y:n}}const Si=z(0);function he(a){const t=D(a);return!Mt()||!t.visualViewport?Si:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ti(a,t,e){return t===void 0&&(t=!1),!e||t&&e!==D(a)?!1:t}function dt(a,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const s=a.getBoundingClientRect(),o=le(a);let r=z(1);t&&(i?F(i)&&(r=et(i)):r=et(a));const n=Ti(o,e,i)?he(o):z(0);let l=(s.left+n.x)/r.x,h=(s.top+n.y)/r.y,f=s.width/r.x,d=s.height/r.y;if(o){const x=D(o),u=i&&F(i)?D(i):i;let p=x,g=Dt(p);for(;g&&i&&u!==p;){const w=et(g),y=g.getBoundingClientRect(),C=k(g),m=y.left+(g.clientLeft+parseFloat(C.paddingLeft))*w.x,E=y.top+(g.clientTop+parseFloat(C.paddingTop))*w.y;l*=w.x,h*=w.y,f*=w.x,d*=w.y,l+=m,h+=E,p=D(g),g=Dt(p)}}return wt({width:f,height:d,x:l,y:h})}function Ai(a){let{elements:t,rect:e,offsetParent:i,strategy:s}=a;const o=s==="fixed",r=B(i),n=t?yt(t.floating):!1;if(i===r||n&&o)return e;let l={scrollLeft:0,scrollTop:0},h=z(1);const f=z(0),d=Y(i);if((d||!d&&!o)&&((Q(i)!=="body"||ht(r))&&(l=mt(i)),Y(i))){const x=dt(i);h=et(i),f.x=x.x+i.clientLeft,f.y=x.y+i.clientTop}return{width:e.width*h.x,height:e.height*h.y,x:e.x*h.x-l.scrollLeft*h.x+f.x,y:e.y*h.y-l.scrollTop*h.y+f.y}}function Li(a){return Array.from(a.getClientRects())}function Xt(a,t){const e=mt(a).scrollLeft;return t?t.left+e:dt(B(a)).left+e}function Mi(a){const t=B(a),e=mt(a),i=a.ownerDocument.body,s=Z(t.scrollWidth,t.clientWidth,i.scrollWidth,i.clientWidth),o=Z(t.scrollHeight,t.clientHeight,i.scrollHeight,i.clientHeight);let r=-e.scrollLeft+Xt(a);const n=-e.scrollTop;return k(i).direction==="rtl"&&(r+=Z(t.clientWidth,i.clientWidth)-s),{width:s,height:o,x:r,y:n}}function Hi(a,t){const e=D(a),i=B(a),s=e.visualViewport;let o=i.clientWidth,r=i.clientHeight,n=0,l=0;if(s){o=s.width,r=s.height;const h=Mt();(!h||h&&t==="fixed")&&(n=s.offsetLeft,l=s.offsetTop)}return{width:o,height:r,x:n,y:l}}function Di(a,t){const e=dt(a,!0,t==="fixed"),i=e.top+a.clientTop,s=e.left+a.clientLeft,o=Y(a)?et(a):z(1),r=a.clientWidth*o.x,n=a.clientHeight*o.y,l=s*o.x,h=i*o.y;return{width:r,height:n,x:l,y:h}}function de(a,t,e){let i;if(t==="viewport")i=Hi(a,e);else if(t==="document")i=Mi(B(a));else if(F(t))i=Di(t,e);else{const s=he(a);i={...t,x:t.x-s.x,y:t.y-s.y}}return wt(i)}function fe(a,t){const e=V(a);return e===t||!F(e)||tt(e)?!1:k(e).position==="fixed"||fe(e,t)}function Xi(a,t){const e=t.get(a);if(e)return e;let i=Ht(a,[],!1).filter(n=>F(n)&&Q(n)!=="body"),s=null;const o=k(a).position==="fixed";let r=o?V(a):a;for(;F(r)&&!tt(r);){const n=k(r),l=Lt(r);!l&&n.position==="fixed"&&(s=null),(o?!l&&!s:!l&&n.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||ht(r)&&!l&&fe(a,r))?i=i.filter(f=>f!==r):s=n,r=V(r)}return t.set(a,i),i}function Fi(a){let{element:t,boundary:e,rootBoundary:i,strategy:s}=a;const r=[...e==="clippingAncestors"?yt(t)?[]:Xi(t,this._c):[].concat(e),i],n=r[0],l=r.reduce((h,f)=>{const d=de(t,f,s);return h.top=Z(d.top,h.top),h.right=at(d.right,h.right),h.bottom=at(d.bottom,h.bottom),h.left=Z(d.left,h.left),h},de(t,n,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function ki(a){const{width:t,height:e}=ce(a);return{width:t,height:e}}function Ni(a,t,e){const i=Y(t),s=B(t),o=e==="fixed",r=dt(a,!0,o,t);let n={scrollLeft:0,scrollTop:0};const l=z(0);if(i||!i&&!o)if((Q(t)!=="body"||ht(s))&&(n=mt(t)),i){const u=dt(t,!0,o,t);l.x=u.x+t.clientLeft,l.y=u.y+t.clientTop}else s&&(l.x=Xt(s));let h=0,f=0;if(s&&!i&&!o){const u=s.getBoundingClientRect();f=u.top+n.scrollTop,h=u.left+n.scrollLeft-Xt(s,u)}const d=r.left+n.scrollLeft-l.x-h,x=r.top+n.scrollTop-l.y-f;return{x:d,y:x,width:r.width,height:r.height}}function Ft(a){return k(a).position==="static"}function xe(a,t){if(!Y(a)||k(a).position==="fixed")return null;if(t)return t(a);let e=a.offsetParent;return B(a)===e&&(e=e.ownerDocument.body),e}function ue(a,t){const e=D(a);if(yt(a))return e;if(!Y(a)){let s=V(a);for(;s&&!tt(s);){if(F(s)&&!Ft(s))return s;s=V(s)}return e}let i=xe(a,t);for(;i&&Ii(i)&&Ft(i);)i=xe(i,t);return i&&tt(i)&&Ft(i)&&!Lt(i)?e:i||Oi(a)||e}const Yi=async function(a){const t=this.getOffsetParent||ue,e=this.getDimensions,i=await e(a.floating);return{reference:Ni(a.reference,await t(a.floating),a.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Ki(a){return k(a).direction==="rtl"}const Bi={convertOffsetParentRelativeRectToViewportRelativeRect:Ai,getDocumentElement:B,getClippingRect:Fi,getOffsetParent:ue,getElementRects:Yi,getClientRects:Li,getDimensions:ki,getScale:et,isElement:F,isRTL:Ki},ge=Ri,we=_i,pe=bi,Wi=Ci,ye=(a,t,e)=>{const i=new Map,s={platform:Bi,...e},o={...s.platform,_c:i};return Ei(a,t,{...s,platform:o})};let Pi=class{constructor(t){c(this,"ctx");c(this,"enable",!1);c(this,"contentEl");c(this,"floatingEl");c(this,"arrowEl");this.ctx=t;const{TOOLTIP_BG_COLOR:e,TOOLTIP_TEXT_COLOR:i,TOOLTIP_ZINDEX:s,TOOLTIP_CUSTOM_STYLE:o,CSS_PREFIX:r}=this.ctx.config;this.contentEl=document.createElement("div"),this.arrowEl=document.createElement("div"),this.floatingEl=document.createElement("div"),this.floatingEl.className=`${r}-tooltip`,this.contentEl.className=`${r}-tooltip-content`,this.arrowEl.className=`${r}-tooltip-arrow`;const n={display:"none",position:"absolute",background:e,color:i,boxSizing:"border-box",zIndex:s,padding:"8px",borderRadius:"4px",fontSize:"12px",...o},l={position:"absolute",width:"10px",height:"10px",background:n.background,backgroundColor:n.backgroundColor,transform:"rotate(45deg)",zIndex:n.zIndex};Object.assign(this.arrowEl.style,l),Object.assign(this.floatingEl.style,n),this.floatingEl.appendChild(this.contentEl),this.floatingEl.appendChild(this.arrowEl),this.ctx.targetContainer.appendChild(this.floatingEl),this.init()}init(){this.ctx.on("mousemove",t=>{const e=this.ctx.target.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.target.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,o=t.drawY+i.y;ye({getBoundingClientRect(){return{width:t.visibleWidth,height:t.visibleHeight,x:s,y:o,left:s,right:s+t.visibleWidth,top:o,bottom:o+t.visibleHeight}}},this.floatingEl,{placement:t.overflowTooltipPlacement,middleware:[we(),pe(),ge(6),Wi({element:this.arrowEl})]}).then(n=>{const{x:l,y:h,placement:f,middlewareData:d}=n;if(Object.assign(this.floatingEl.style,{top:`${h}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 zi{constructor(t){c(this,"editorEl");c(this,"inputEl");c(this,"enable",!1);c(this,"cellTarget",null);c(this,"ctx");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,o=t.shiftKey,r=t.metaKey;if(!(i||s||o||r||["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("cellClick",t=>{var e,i;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(){const{CSS_PREFIX:t,SELECT_BORDER_COLOR:e}=this.ctx.config;this.inputEl=document.createElement("div"),this.inputEl.addEventListener("keydown",r=>{if(this.enable){if((r.altKey||r.metaKey)&&r.code==="Enter"){r.preventDefault();const n=this.inputEl.textContent;this.inputEl.textContent=`${n}
16
-
17
- `;const l=window.getSelection();l==null||l.selectAllChildren(this.inputEl),l==null||l.collapseToEnd();return}(r.code==="Escape"||r.code==="Enter")&&(r.preventDefault(),this.inputEl.blur())}}),this.inputEl.addEventListener("blur",()=>{this.doneEdit()}),this.editorEl=document.createElement("div"),this.editorEl.className=`${t}-self-editor`,this.inputEl.className=`${t}-self-editor-input`;const i={position:"absolute",top:"-10000px",left:"-10000px",textAlign:"left",lineHeight:"0",zIndex:100,overflow:"hidden",backgroundColor:"#fff",border:`2px solid ${e}`,boxSizing:"border-box",boxShadow:"rgba(0, 0, 0, 0.2) 0px 6px 16px",pointerEvents:"auto",display:"flex",alignItems:"center"};Object.assign(this.editorEl.style,i);const s={width:"100%",boxSizing:"border-box",padding:"8px",outline:"none",fontWeight:"400",fontSize:"12px",color:"inherit",whiteSpace:"normal",wordWrap:"break-word",wordBreak:"break-all",lineHeight:"18px",margin:"0",background:"#fff",cursor:"text"};Object.assign(this.inputEl.style,s);const o=navigator.userAgent.toLowerCase().includes("firefox");this.inputEl.contentEditable=o?"true":"plaintext-only",this.editorEl.appendChild(this.inputEl),this.ctx.targetContainer.appendChild(this.editorEl)}startEditByInput(t){if(t.editorType!=="text")return;const e=t.getValue(),{width:i}=t,s=t.getDrawX();let o=t.getDrawY(),{height:r}=t;t.height>this.ctx.body.visibleHeight&&(r=this.ctx.body.visibleHeight,o=this.ctx.header.visibleHeight);const{CELL_PADDING:n}=this.ctx.config;this.editorEl.style.left=`${s}px`,this.editorEl.style.top=`${o}px`,this.inputEl.style.minWidth=`${i-1}px`,this.inputEl.style.minHeight=`${r-1}px`,this.inputEl.style.padding=`${n}px`,e!==null&&(this.inputEl.textContent=e),this.inputEl.focus();const l=window.getSelection();l==null||l.selectAllChildren(this.inputEl),l==null||l.collapseToEnd()}doneEditByInput(){if(!this.cellTarget||this.cellTarget.editorType!=="text")return;const{rowKey:t,key:e}=this.cellTarget,i=this.cellTarget.getValue(),s=this.inputEl.textContent;s!==i&&!(s===""&&i===null)&&this.ctx.database.setItemValue(t,e,s,!0,!0,!0),this.inputEl.textContent=null,this.editorEl.style.left="-10000px",this.editorEl.style.top="-10000px"}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,o=this.ctx.database.getReadonly(i,s);e&&!o&&(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(h=>h.rowIndex===t);if(!i)return;const s=i.cells.find(h=>h.colIndex===e);if(!s)return;this.ctx.emit("setSelectorCell",s);const o=this.ctx.focusCell;if(!o||["index","index-selection","selection"].includes(o.type)||this.enable)return;const{rowKey:r,key:n}=o,l=this.ctx.database.getReadonly(r,n);o&&!l&&(this.enable=!0,this.ctx.editing=!0,this.cellTarget=o,this.startEditByInput(this.cellTarget),this.ctx.emit("startEdit",this.cellTarget))}doneEdit(){this.enable&&this.cellTarget&&(this.ctx.emit("doneEdit",this.cellTarget),this.doneEditByInput(),this.enable=!1,this.ctx.target.focus(),this.ctx.editing=!1,this.cellTarget=null,this.ctx.emit("draw"))}destroy(){}}class Vi{constructor(t){c(this,"ctx");c(this,"emptyEl");this.ctx=t;const{EMPTY_TEXT:e,EMPTY_CUSTOM:i,EMPTY_CUSTOM_STYLE:s,CSS_PREFIX:o}=this.ctx.config;this.emptyEl=document.createElement("div"),this.emptyEl.className=`${o}-empty`,this.emptyEl.style.display="none",this.emptyEl.innerText=e,this.ctx.targetContainer.appendChild(this.emptyEl),this.ctx.on("emptyChange",({type:r,headerHeight:n,bodyHeight:l,footerHeight:h})=>{if(i)return;const f=n+(l+h)/2,d={display:r==="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){c(this,"ctx");this.ctx=t,this.ctx.on("scroll",()=>{if(!this.ctx.config.ENABLE_HEADER_STICKY)return;const e=this.ctx.targetContainer.getBoundingClientRect();let i=!1,s=this.getHeader();e.top<0&&e.top<-this.ctx.header.visibleHeight&&e.top>-this.ctx.body.visibleHeight?i=!0:i=!1;const{config:{CSS_PREFIX:o}}=this.ctx,{visibleWidth:r}=this.ctx.body,n={type:"header-sticky",class:`${o}-overlayer-header-sticky`,style:{position:"sticky",top:"0px","z-index":10,width:`${r}px`,display:i?"block":"none"},views:s.views};this.ctx.emit("headerStickyChange",n)})}draw(){const t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){this.ctx.emit("overlayerChange",{style:{},views:[]})}getContainer(){const{target:t,config:{SCROLLER_TRACK_SIZE:e}}=this.ctx,i=t.width-e,s=t.height-e,o=this.getHeader(),r=this.getBody(),n=this.getFooter();let l=[o,r,n];const{FOOTER_FIXED:h}=this.ctx.config;return h||(l=[o,r]),{style:{position:"absolute",left:"0px",top:"0px",pointerEvents:"none",overflow:"hidden",width:`${i}px`,height:`${s}px`},views:l}}getHeader(){const{fixedLeftWidth:t,fixedRightWidth:e,config:{SCROLLER_TRACK_SIZE:i,CSS_PREFIX:s}}=this.ctx,{visibleWidth:o,visibleHeight:r,renderCellHeaders:n}=this.ctx.header;let l=[],h=[],f=[];n.forEach(w=>{w.render&&(w.fixed==="left"?h.push(w):w.fixed==="right"?f.push(w):l.push(w))});const d=e-i,x={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${r}px`},cells:h},u={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${o-t-d+1}px`,height:`${r}px`},cells:l},p={key:"right",style:{position:"absolute",top:"0px",right:"0px",overflow:"hidden",width:`${d+1}px`,height:`${r}px`},cells:f};return{type:"header",class:`${s}-overlayer-header`,style:{position:"relative",overflow:"hidden",width:`${o}px`,height:`${r}px`},views:[x,u,p]}}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(w=>{w.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:o,fixedRightWidth:r,config:{SCROLLER_TRACK_SIZE:n,CSS_PREFIX:l}}=this.ctx,{visibleWidth:h,visibleHeight:f}=this.ctx.body,d=r-n,x={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${o}px`,height:`${f}px`},cells:e},u={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${o+.5}px`,overflow:"hidden",width:`${h-o-d}px`,height:`${f}px`},cells:t},p={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:`${h}px`,height:`${f}px`},views:[x,u,p]}}getFooter(){const t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(g=>{g.cells.forEach(w=>{w.cellType==="footer"&&w.renderFooter&&(w.render=w.renderFooter,w.fixed==="left"?e.push(w):w.fixed==="right"?i.push(w):t.push(w))})});const{fixedLeftWidth:s,fixedRightWidth:o,config:{SCROLLER_TRACK_SIZE:r,CSS_PREFIX:n}}=this.ctx,{visibleWidth:l,visibleHeight:h}=this.ctx.footer,f=o-r,d={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${s}px`,height:`${h}px`},cells:e},x={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${s+.5}px`,overflow:"hidden",width:`${l-s-f}px`,height:`${h}px`},cells:t},u={key:"right",style:{position:"absolute",top:`${.5}px`,right:`${.5}px`,overflow:"hidden",width:`${f}px`,height:`${h}px`},cells:i};return{type:"footer",class:`${n}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${l}px`,height:`${h}px`},views:[d,x,u]}}}class qi{constructor(t){c(this,"ctx");c(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,[o,r]=i,[n,l]=s,{rowIndex:h,colIndex:f}=t;h>=n&&h<=l&&f>=o&&f<=r||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:p})=>{this.show(u,p)})}),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.targetContainer.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){c(this,"targetContainer");c(this,"target");c(this,"options");c(this,"scroller");c(this,"header");c(this,"body");c(this,"footer");c(this,"selector");c(this,"autofill");c(this,"tooltip");c(this,"editor");c(this,"empty");c(this,"overlayer");c(this,"contextMenu");c(this,"ctx");this.target=document.createElement("canvas"),this.targetContainer=t,this.targetContainer.style.position="relative",this.targetContainer.appendChild(this.target),this.options=e,this.ctx=new ni(this.targetContainer,this.target,this.options),this.header=new ci(this.ctx),this.body=new li(this.ctx),this.footer=new hi(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 Vi(this.ctx),this.editor=new zi(this.ctx),this.overlayer=new $i(this.ctx),this.contextMenu=new qi(this.ctx),this.ctx.on("draw",this.draw.bind(this)),this.draw()}draw(){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(),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,o=!0,r=!1){this.ctx.database.setItemValue(t,e,i,s,o,r)}batchSetItemValue(t,e=!0,i=!0){this.ctx.database.batchSetItemValue(t,e),i&&this.ctx.emit("draw")}setItemValueByEditor(t,e,i,s=!0,o=!0){this.ctx.database.setItemValue(t,e,i,s,o,!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[o]=s;if(Array.isArray(o)&&o.length){const[r]=o,{rowKey:n,key:l}=r;this.scrollToRowkey(n),this.scrollToColkey(l)}}i(s)}})}setValidations(t){if(t.forEach(e=>{const{rowIndex:i,key:s,message:o}=e;this.ctx.database.setValidationErrorByRowIndex(i,s,o)}),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 o=[];for(let r=0;r<i.length;r++)for(let n=0;n<s.length;n++){const l=this.ctx.database.getRowKeyByItem(i[r]),f=s[n].key,d=await this.ctx.database.getValidator(l,f);Array.isArray(d)&&d.length&&o.push(d)}o.length?(e(o),this.ctx.emit("draw")):(t([]),this.ctx.emit("draw"))})}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)}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")}getSelectionRows(){return this.ctx.database.getSelectionRows()}getPositionForRowIndex(t){return this.ctx.database.getPositionForRowIndex(t)}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.target.remove()}}return Gi});
13
+ `).replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),r=new RegExp("(?:^"+e+"$)|(?:^"+s+"$)"),o=new RegExp("^"+e+"$"),n=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?n:new RegExp(""+t(m)+s+t(m),"g")};var h="(?:(?:[a-z]+:)?//)",f="(?:\\S+(?::\\S*)?@)?",d=l.v4().source,x=l.v6().source,u="(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)",p="(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*",g="(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))",w="(?::\\d{2,5})?",y='(?:[/?#][^\\s"]*)?',C="(?:"+h+"|www\\.)"+f+"(?:localhost|"+d+"|"+x+"|"+u+p+g+")"+w+y;return xt=new RegExp("(?:^"+C+"$)","i"),xt},Pt={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(Pt.email)},url:function(t){return typeof t=="string"&&t.length<=2048&&!!t.match(Te())},hex:function(t){return typeof t=="string"&&!!t.match(Pt.hex)}},Ae=function(t,e,i,s,r){if(t.required&&e===void 0){Wt(t,e,i,s,r);return}var o=["integer","float","array","regexp","object","method","email","number","date","url","hex"],n=t.type;o.indexOf(n)>-1?rt[n](e)||s.push(H(r.messages.types[n],t.fullField,t.type)):n&&typeof e!==t.type&&s.push(H(r.messages.types[n],t.fullField,t.type))},Le=function(t,e,i,s,r){var o=typeof t.len=="number",n=typeof t.min=="number",l=typeof t.max=="number",h=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,f=e,d=null,x=typeof e=="number",u=typeof e=="string",p=Array.isArray(e);if(x?d="number":u?d="string":p&&(d="array"),!d)return!1;p&&(f=e.length),u&&(f=e.replace(h,"_").length),o?f!==t.len&&s.push(H(r.messages[d].len,t.fullField,t.len)):n&&!l&&f<t.min?s.push(H(r.messages[d].min,t.fullField,t.min)):l&&!n&&f>t.max?s.push(H(r.messages[d].max,t.fullField,t.max)):n&&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:Wt,whitespace:Se,type:Ae,range:Le,enum:Me,pattern:He},De=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){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)},Xe=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){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)},Fe=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){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=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){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=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){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=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){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=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){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=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){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=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){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=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){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=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){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=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){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=[],n=Array.isArray(e)?"array":typeof e;v.required(t,e,s,o,r,n),i(o)},bt=function(t,e,i,s,r){var o=t.type,n=[],l=t.required||!t.required&&s.hasOwnProperty(t.field);if(l){if(_(e,o)&&!t.required)return i();v.required(t,e,s,n,r,o),_(e,o)||v.type(t,e,s,n,r)}i(n)},Ge=function(t,e,i,s,r){var o=[],n=t.required||!t.required&&s.hasOwnProperty(t.field);if(n){if(_(e)&&!t.required)return i();v.required(t,e,s,o,r)}i(o)},ot={string:De,method:Xe,number:Fe,boolean:ke,regexp:Ne,integer:Ye,float:Ke,array:Be,object:We,enum:Ve,pattern:ze,date:$e,url:bt,hex:bt,email:bt,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 a(e){this.rules=null,this._messages=Rt,this.define(e)}var t=a.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=Bt(vt(),i)),this._messages},t.validate=function(i,s,r){var o=this;s===void 0&&(s={}),r===void 0&&(r=function(){});var n=i,l=s,h=r;if(typeof l=="function"&&(h=l,l={}),!this.rules||Object.keys(this.rules).length===0)return h&&h(null,n),Promise.resolve(n);function f(g){var w=[],y={};function C(E){if(Array.isArray(E)){var b;w=(b=w).concat.apply(b,E)}else w.push(E)}for(var m=0;m<g.length;m++)C(g[m]);w.length?(y=Ct(w),h(w,y)):h(null,n)}if(l.messages){var d=this.messages();d===Rt&&(d=vt()),Bt(d,l.messages),l.messages=d}else l.messages=this.messages();var x={},u=l.keys||Object.keys(this.rules);u.forEach(function(g){var w=o.rules[g],y=n[g];w.forEach(function(C){var m=C;typeof m.transform=="function"&&(n===i&&(n=I({},n)),y=n[g]=m.transform(y)),typeof m=="function"?m={validator:m}:m=I({},m),m.validator=o.getValidationMethod(m),m.validator&&(m.field=g,m.fullField=m.fullField||g,m.type=o.getType(m),x[g]=x[g]||[],x[g].push({rule:m,value:y,source:n,field:g}))})});var p={};return _e(x,l,function(g,w){var y=g.rule,C=(y.type==="object"||y.type==="array")&&(typeof y.fields=="object"||typeof y.defaultField=="object");C=C&&(y.required||!y.required&&g.value),y.field=g.field;function m(R,A){return I({},A,{fullField:y.fullField+"."+R,fullFields:y.fullFields?[].concat(y.fullFields,[R]):[R]})}function E(R){R===void 0&&(R=[]);var A=Array.isArray(R)?R:[R];!l.suppressWarning&&A.length&&a.warning("async-validator:",A),A.length&&y.message!==void 0&&(A=[].concat(y.message));var L=A.map(Kt(y,n));if(l.first&&L.length)return p[y.field]=1,w(L);if(!C)w(L);else{if(y.required&&!g.value)return y.message!==void 0?L=[].concat(y.message).map(Kt(y,n)):l.error&&(L=[l.error(y,H(l.messages.required,y.field))]),w(L);var X={};y.defaultField&&Object.keys(g.value).map(function(O){X[O]=y.defaultField}),X=I({},X,g.rule.fields);var N={};Object.keys(X).forEach(function(O){var T=X[O],S=Array.isArray(T)?T:[T];N[O]=S.map(m.bind(null,O))});var $=new a(N);$.messages(l.messages),g.rule.options&&(g.rule.options.messages=l.messages,g.rule.options.error=l.error),$.validate(g.value,g.rule.options||l,function(O){var T=[];L&&L.length&&T.push.apply(T,L),O&&O.length&&T.push.apply(T,O),w(T.length?T:null)})}}var b;if(y.asyncValidator)b=y.asyncValidator(y,g.value,E,g.source,l);else if(y.validator){try{b=y.validator(y,g.value,E,g.source,l)}catch(R){console.error==null||console.error(R),l.suppressValidatorError||setTimeout(function(){throw R},0),E(R.message)}b===!0?E():b===!1?E(typeof y.message=="function"?y.message(y.fullField||y.field):y.message||(y.fullField||y.field)+" fails"):b instanceof Array?E(b):b instanceof Error&&E(b.message)}b&&b.then&&b.then(function(){return E()},function(R){return E(R)})},function(g){f(g)},n)},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},a}();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=kt,nt.messages=Rt,nt.validators=ot;function _t(){return"xxxxxxxxxxxxxxxxxx".replace(/[x]/g,function(a){const t=Math.random()*16|0;return(a==="x"?t:t&3|8).toString(16)})}function Vt(a,t){let e=0,i;return function(...s){const r=new Date().getTime(),o=r-e;!e||o>=t?(a.apply(this,s),e=r):i||(i=setTimeout(()=>{a.apply(this,s),e=new Date().getTime(),i=void 0},t-o))}}function zt(a){return a?a.map(t=>zt(t.children)+1).sort((t,e)=>e-t)[0]:0}function je(a=[]){let t=[],e=[],i=[];return a.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(a=[],t=1,e=0){return a.map(i=>{if(i.children){let s=0,r=i.fixed;i.children.forEach(n=>{n.fixed=r});const o=$t(i.children,t-1,e+1);return o&&o.forEach(n=>{s+=n.colspan}),{...i,width:i.width,level:e,rowspan:1,colspan:s,children:o}}return{...i,level:e,rowspan:t,colspan:1}})}function It(a=[]){let t=[];return a.forEach(e=>{e.children?t=t.concat(It(e.children)):t.push(e)}),t}const qt=/^(\r\n|\n\r|\r|\n)/,Ue=/^[^\t\r\n]+/,Gt=/^\t/;function Ze(a){let t=[[""]];if(a.length===0)return t;let e=0,i=0,s;for(;a.length>0&&s!==a.length;)if(s=a.length,a.match(Gt))a=a.replace(Gt,""),e+=1,t[i][e]="";else if(a.match(qt))a=a.replace(qt,""),e=0,i+=1,t[i]=[""];else{let r="";if(a.startsWith('"')){let o=0,n=!0;for(;n;){const l=a.slice(0,1);l==='"'&&(o+=1),r+=l,a=a.slice(1),(a.length===0||a.match(/^[\t\r\n]/)&&o%2===0)&&(n=!1)}r=r.replace(/^"/,"").replace(/"$/,"").replace(/["]*/g,l=>new Array(Math.floor(l.length/2)).fill('"').join(""))}else{const o=a.match(Ue);r=o?o[0]:"",a=a.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(a){let t,e,i,s,r="",o;for(t=0,e=a.length;t<e;t+=1){for(s=a[t].length,i=0;i<s;i+=1)i>0&&(r+=" "),o=a[t][i],typeof o=="string"?o.indexOf(`
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){c(this,"loading",!1);c(this,"ctx");c(this,"data");c(this,"columns");c(this,"footerData",[]);c(this,"rowKeyMap",new Map);c(this,"colIndexKeyMap",new Map);c(this,"headerMap",new Map);c(this,"rowIndexRowKeyMap",new Map);c(this,"checkboxKeyMap",new Map);c(this,"originalDataMap",new Map);c(this,"changedDataMap",new Map);c(this,"validationErrorMap",new Map);c(this,"itemRowKeyMap",new WeakMap);c(this,"bufferData",[]);c(this,"sumHeight",0);c(this,"filterMethod");c(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=!1;Array.isArray(i.children)&&(r=!0,this.initData(i.children,e+1));const{ROW_KEY:o="",DEFAULT_EXPAND_ALL:n,CELL_HEIGHT:l,SELECTABLE_METHOD:h,CHECKBOX_KEY:f}=this.ctx.config,d=i[o],x=d??_t();this.itemRowKeyMap.set(i,x);const u=i._height||l,p=i._readonly;let g=!0;if(typeof h=="function"&&(g=h),f){const w=i[f];if(this.checkboxKeyMap.has(w)){const y=this.checkboxKeyMap.get(w);y.push(x),this.checkboxKeyMap.set(w,y)}else this.checkboxKeyMap.set(w,[x])}this.rowKeyMap.set(x,{readonly:p,index:s,rowIndex:s,level:e,height:u,check:!1,selectable:g,expand:n,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 n=this.itemRowKeyMap.get(o),{expand:l,hasChildren:h,height:f}=this.rowKeyMap.get(n),d=this.sumHeight;this.sumHeight+=f,this.rowIndexRowKeyMap.set(e,n),this.positions.push({top:d,height:f,bottom:this.sumHeight}),e+=1,l&&h&&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")}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}batchSetItemValue(t,e=!1){let i=[];const s=new Set;t.forEach(n=>{const{value:l,rowKey:h,key:f}=n,{oldValue:d,newValue:x}=this.setItemValue(h,f,l);s.add(h),i.push({rowKey:h,key:f,oldValue:d,newValue:x})});let r=[];const o=i.map(n=>{const l=this.ctx.database.getRowDataItemForRowKey(n.rowKey);return{rowKey:n.rowKey,key:n.key,value:n.newValue,row:l}});return s.forEach(n=>{r.push(this.ctx.database.getRowDataItemForRowKey(n))}),this.ctx.emit("change",o,r),e&&this.ctx.history.pushState({changeList:i,scrollX:this.ctx.scrollX,scrollY:this.ctx.scrollY,type:"multiple"}),i}setItemValue(t,e,i,s=!1,r=!1,o=!1){if(!this.rowKeyMap.has(t))return{};const{item:n}=this.rowKeyMap.get(t);let l=n[e];if(this.ctx.database.getReadonly(t,e))return{oldValue:l,newValue:l};n[e]!==null&&typeof n[e]=="object"&&(l=JSON.parse(JSON.stringify(n[e])));const h=`${t}_${e}`;if(this.originalDataMap.has(h)||this.originalDataMap.set(h,l),this.changedDataMap.set(h,i),n[e]=i,o){const f=this.ctx.database.getRowDataItemForRowKey(t),d={rowKey:t,key:e,value:i,row:f};this.ctx.emit("change",[d],[f]),this.ctx.emit("editChange",{rowKey:t,key:e,oldValue:l,value:i,originalValue:this.originalDataMap.get(h),row:f})}return this.ctx.hasEvent("iterationChange")&&this.ctx.emit("iterationChange",{rowKey:t,key:e,oldValue:l,value:i,originalValue:this.originalDataMap.get(h),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:i}]}),r&&this.ctx.emit("draw"),{oldValue:l,newValue:i}}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(n=>{const l=this.rowKeyMap.get(n);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 n=o.selectable;typeof n=="function"?n({row:o.item,rowIndex:o.rowIndex})&&(e+=1):n&&(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.rowKeyMap.get(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,{CELL_READONLY_METHOD:n}=this.ctx.config;if(typeof n=="function"){const h=n({row:i.item,rowIndex:i.rowIndex,colIndex:s.colIndex,column:s.column,value:this.getItemValue(t,e)});if(h!==void 0)return h}return o||r}clearValidate(){this.validationErrorMap.clear()}getValidator(t,e){return new Promise(i=>{const s=this.rowKeyMap.get(t),r=this.headerMap.get(e),{CELL_RULES_METHOD:o}=this.ctx.config,n=r.column;let l=n.rules;if(typeof o=="function"){const f=o({row:s.item,rowIndex:s.rowIndex,colIndex:r.colIndex,column:n,value:this.getItemValue(t,e)});f&&(l=f)}if(l){let h={},f={};if(f[e]=this.getItemValue(t,e),Array.isArray(l)&&l.length){const x=l.map(u=>({...u,row:s.item,column:n,rowIndex:s.rowIndex,colIndex:r.colIndex}));h[e]=x}else h[e]={...l,row:s.item,column:n,rowIndex:s.rowIndex,colIndex:r.colIndex};new nt(h).validate(f).then(()=>{this.setValidationError(t,e,[]),i([])}).catch(({errors:x})=>{const u=x.map(p=>({...p,column:n,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)}getValidationError(t,e){const i=`${t}_${e}`;return this.validationErrorMap.get(i)||[]}}class ti{constructor(t){c(this,"ctx");c(this,"history",[]);c(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,this.ctx.emit("draw")}}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),this.ctx.emit("draw")}}clear(){this.history=[],this.historyIndex=-1}}class ei{constructor(t){c(this,"eventTasks",new Map);c(this,"ctx");this.ctx=t,this.init()}init(){this.bind(window,"resize",this.handleResize.bind(this)),this.bind(window,"mousedown",this.handleMouseDown.bind(this)),this.bind(window,"mouseup",this.handleMouseUp.bind(this)),this.bind(window,"mousemove",this.handleMousemove.bind(this)),this.bind(window,"scroll",this.handleScroll.bind(this)),this.bind(this.ctx.target,"click",this.handleClick.bind(this)),this.bind(this.ctx.target,"keydown",this.handleKeydown.bind(this)),this.bind(this.ctx.target,"wheel",this.handleWheel.bind(this)),this.bind(this.ctx.target,"contextmenu",this.handleContextMenu.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.emit("keydown",t)}handleWheel(t){this.ctx.emit("wheel",t)}handleContextMenu(t){this.ctx.emit("contextMenu",t)}handleScroll(t){this.ctx.emit("scroll",t)}bind(t,e,i){t instanceof HTMLCanvasElement&&e==="keydown"&&(t.tabIndex=0),t.addEventListener(e,i),this.eventTasks.set(e,i)}unbind(t,e,i){t.removeEventListener(e,i),this.eventTasks.delete(e)}}class ii{constructor(){c(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){c(this,"ctx");const e=t.getContext("2d");if(!e)throw new Error("canvas context not found");this.ctx=e}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:n,shadowWidth:l,colorStart:h,colorEnd:f}=r;this.ctx.save(),o&&(this.ctx.fillStyle=o,this.ctx.fillRect(t,e,i,s));let d;switch(n){case"left":d=this.ctx.createLinearGradient(t-l,e,t,e),d.addColorStop(0,h),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,h),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,h),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,h),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:n,radius:l=0}={}){if(this.ctx.save(),this.ctx.beginPath(),n!==void 0&&(this.ctx.fillStyle=n),o!==void 0&&(this.ctx.lineWidth=r,this.ctx.strokeStyle=o),l===0)this.ctx.rect(t+.5,e+.5,i,s);else{const[h,f,d,x]=typeof l=="number"?[l,l,l,l]:l;this.ctx.moveTo(t+h,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+h,e,h)}n!==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:n="12px Arial",align:l="center",color:h="#495060",padding:f=0,verticalAlign:d="middle"}=o;this.ctx.font=n,this.ctx.fillStyle=h,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+f)/2;let u=0;l==="left"?u=e+f:l==="right"?u=e+s-f:u=e+s/2;const{_text:p,ellipsis:g}=this.handleEllipsis(t,s,f);return this.ctx.fillText(p,u,x),this.ctx.restore(),g}handleEllipsis(t,e,i=0){let s=!1,r=t;if(t==null||t==="")return{_text:"",ellipsis:s};const o=this.ctx.measureText("...").width,n=this.ctx.measureText(t).width;if(n&&n+o>=e-i*2){s=!0;let l=0;for(let h=0;h<t.length;h++)if(l+=this.ctx.measureText(t[h]).width,l>=e-i*2-o){r=t.slice(0,h)+"...";break}}return{_text:r,ellipsis:s}}}class jt{constructor(t){c(this,"PROCESSOR_NUM",50);c(this,"CSS_PREFIX","e-virt-table");c(this,"ICONS",[]);c(this,"ROW_KEY","");c(this,"HEADER_FONT","12px normal Arial");c(this,"BODY_FONT","12px normal Arial");c(this,"BORDER_COLOR","#e1e6eb");c(this,"WIDTH",0);c(this,"RESIZE_MIN_WIDTH",40);c(this,"HEIGHT",0);c(this,"EMPTY_BODY_HEIGHT",120);c(this,"EMPTY_CUSTOM",!1);c(this,"EMPTY_CUSTOM_STYLE",{});c(this,"EMPTY_TEXT","暂无数据");c(this,"MAX_HEIGHT",1e3);c(this,"BORDER_RADIUS",8);c(this,"ENABLE_OFFSET_HEIGHT",!1);c(this,"OFFSET_HEIGHT",0);c(this,"HEADER_HEIGHT",36);c(this,"ENABLE_HEADER_STICKY",!1);c(this,"HEADER_BG_COLOR","#F8FAFF");c(this,"BODY_BG_COLOR","#FFF");c(this,"HEADER_TEXT_COLOR","#1D2129");c(this,"LOADING_ICON_SVG","");c(this,"LOADING_ICON_COLOR","#4E5969");c(this,"EXPAND_ICON_SVG","");c(this,"SHRINK_ICON_SVG","");c(this,"EXPAND_ICON_COLOR","#4E5969");c(this,"SHRINK_ICON_COLOR","#4E5969");c(this,"ERROR_TIP_ICON_COLOR","red");c(this,"ERROR_TIP_ICON_SIZE",6);c(this,"EXPAND_LAZY",!0);c(this,"DEFAULT_EXPAND_ALL",!1);c(this,"CELL_WIDTH",100);c(this,"CELL_HEIGHT",36);c(this,"CELL_PADDING",8);c(this,"CELL_HOVER_ICON_SIZE",20);c(this,"SCROLLER_TRACK_SIZE",14);c(this,"SCROLLER_SIZE",8);c(this,"SCROLLER_COLOR","#dee0e3");c(this,"SCROLLER_TRACK_COLOR","#fff");c(this,"SCROLLER_FOCUS_COLOR","#bbbec4");c(this,"SELECT_BORDER_COLOR","rgb(82,146,247)");c(this,"SELECT_AREA_COLOR","rgba(82,146,247,0.1)");c(this,"SELECT_BG_COLOR","rgba(82,146,247,0.1)");c(this,"EDIT_BG_COLOR","#fcf6ed");c(this,"CHECKBOX_KEY","");c(this,"CHECKBOX_COLOR","rgb(82,146,247)");c(this,"CHECKBOX_SIZE",20);c(this,"CHECKBOX_DISABLED_SVG","");c(this,"CHECKBOX_CHECK_SVG","");c(this,"CHECKBOX_UNCHECK_SVG","");c(this,"CHECKBOX_INDETERMINATE_SVG","");c(this,"READONLY_COLOR","#fff");c(this,"READONLY_TEXT_COLOR","#4E5969");c(this,"ERROR_TIP_COLOR","#ED3F14");c(this,"FOOTER_BG_COLOR","#fafafa");c(this,"FOOTER_FIXED",!0);c(this,"CELL_FOOTER_HEIGHT",36);c(this,"ENABLE_SELECTOR",!1);c(this,"ENABLE_EDIT_SINGLE_CLICK",!1);c(this,"ENABLE_EDIT_CLICK_SELECTOR",!0);c(this,"SELECTOR_AREA_MIN_X",0);c(this,"SELECTOR_AREA_MAX_X_OFFSET",0);c(this,"SELECTOR_AREA_MAX_X",0);c(this,"SELECTOR_AREA_MIN_Y",0);c(this,"SELECTOR_AREA_MAX_Y",0);c(this,"SELECTOR_AREA_MAX_Y_OFFSET",0);c(this,"ENABLE_SELECTOR_SINGLE",!1);c(this,"ENABLE_SELECTOR_SPAN_COL",!0);c(this,"ENABLE_SELECTOR_SPAN_ROW",!0);c(this,"ENABLE_SELECTOR_ALL_ROWS",!0);c(this,"ENABLE_SELECTOR_ALL_COLS",!0);c(this,"ENABLE_AUTOFILL",!1);c(this,"ENABLE_CONTEXT_MENU",!1);c(this,"ENABLE_COPY",!0);c(this,"ENABLE_PASTER",!0);c(this,"ENABLE_RESIZE_ROW",!0);c(this,"ENABLE_RESIZE_COLUMN",!0);c(this,"RESIZE_ROW_LINE_COLOR","#e1e6eb");c(this,"RESIZE_COLUMN_LINE_COLOR","#e1e6eb");c(this,"RESIZE_ROW_MIN_HEIGHT",36);c(this,"RESIZE_COLUMN_MIN_WIDTH",40);c(this,"ENABLE_KEYBOARD",!0);c(this,"ENABLE_HISTORY",!1);c(this,"ENABLE_VALIDATOR_IMMEDIATE",!0);c(this,"HISTORY_NUM",50);c(this,"HIGHLIGHT_HOVER_ROW",!1);c(this,"HIGHLIGHT_HOVER_ROW_COLOR","rgba(186,203,231,0.1)");c(this,"HIGHLIGHT_SELECTED_ROW",!1);c(this,"HIGHLIGHT_SELECTED_ROW_COLOR","rgba(82,146,247,0.1)");c(this,"TOOLTIP_BG_COLOR","#303133");c(this,"TOOLTIP_TEXT_COLOR","#fff");c(this,"TOOLTIP_ZINDEX",3e3);c(this,"TOOLTIP_CUSTOM_STYLE",{});c(this,"CONTEXT_MENU",[{label:"复制",value:"copy"},{label:"剪切",value:"cut"},{label:"粘贴",value:"paste"},{label:"清空选中内容",value:"clearSelected"}]);c(this,"HEADER_CELL_STYLE_METHOD");c(this,"BODY_CELL_STYLE_METHOD");c(this,"FOOTER_CELL_STYLE_METHOD");c(this,"CELL_READONLY_METHOD");c(this,"CELL_FORMATTER_METHOD");c(this,"CELL_RULES_METHOD");c(this,"CELL_TYPE_METHOD");c(this,"CELL_EDITOR_TYPE_METHOD");c(this,"CELL_RENDER_METHOD");c(this,"CELL_HOVER_ICON_METHOD");c(this,"SPAN_METHOD");c(this,"SELECTABLE_METHOD");c(this,"EXPAND_LAZY_METHOD");Object.assign(this,t)}init(t){Object.assign(this,t)}}class ri{constructor(t){c(this,"ctx");c(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:""}]);c(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(h=>{h.setAttribute("fill",e)});const o=new Image,n=new Blob([new XMLSerializer().serializeToString(r)],{type:"image/svg+xml"}),l=URL.createObjectURL(n);return o.src=l,new Promise((h,f)=>{o.onerror=()=>f(new Error("Failed to load image")),o.onload=()=>{h(o)}})}get(t){return this.icons.get(t)}}class Ut{constructor(t,e,i,s,r,o,n){c(this,"ctx");c(this,"x",0);c(this,"y",0);c(this,"width",0);c(this,"height",0);c(this,"fixed");c(this,"cellType");this.ctx=t,this.x=e,this.y=i,this.width=s,this.height=r,this.fixed=o,this.cellType=n}isHorizontalVisible(){if(this.fixed)return!0;const{target:t,fixedLeftWidth:e,scrollX:i,fixedRightWidth:s}=this.ctx,r=t.width;return!(this.x+this.width-e-i<=0||this.x-i>=r-s)}isVerticalVisible(){const{target:t,scrollY:e}=this.ctx,i=t.height;return!(this.y+this.height-e<=0||this.y-e>=i)}getDrawX(){return this.fixed==="left"?this.x:this.fixed==="right"?this.ctx.header.visibleWidth-(this.ctx.header.width-this.x)+1: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,n,l,h,f,d="body"){super(e,r,o,n,l,h.fixed,d);c(this,"formatter");c(this,"hoverIconName","");c(this,"operation",!1);c(this,"align");c(this,"verticalAlign");c(this,"fixed");c(this,"type");c(this,"editorType");c(this,"cellType");c(this,"level");c(this,"colspan",1);c(this,"rowspan",1);c(this,"key");c(this,"column");c(this,"rowIndex");c(this,"colIndex");c(this,"rowKey");c(this,"row");c(this,"value");c(this,"render");c(this,"renderFooter");c(this,"style",{});c(this,"rules",{});c(this,"message","");c(this,"text","");c(this,"displayText","");c(this,"visibleWidth",0);c(this,"visibleHeight",0);c(this,"drawX",0);c(this,"drawY",0);c(this,"drawCellBgColor","");c(this,"drawCellSkyBgColor","");c(this,"drawTextColor","");c(this,"drawTextX",0);c(this,"drawTextY",0);c(this,"drawImageX",0);c(this,"drawImageY",0);c(this,"drawImageWidth",0);c(this,"drawImageHeight",0);c(this,"drawImageName","");c(this,"drawImageSource");c(this,"ellipsis",!1);c(this,"overflowTooltipShow",!0);c(this,"overflowTooltipMaxWidth",500);c(this,"overflowTooltipPlacement","top");this.visibleWidth=this.width,this.visibleHeight=this.height,this.colIndex=s,this.rowIndex=i,this.key=h.key,this.type=h.type||"text",this.editorType=h.editorType||"text",this.cellType=d,this.align=h.align||"center",this.verticalAlign=h.verticalAlign||"middle",this.fixed=h.fixed,this.level=h.level,this.operation=h.operation||!1,this.column=h,this.rules=h.rules,this.row=f,this.rowKey=this.cellType==="body"?this.ctx.database.getRowKeyForRowIndex(i):`${this.cellType}_${this.rowIndex}`,this.value=this.getValue(),this.render=h.render,this.overflowTooltipShow=h.overflowTooltipShow!==!1,this.overflowTooltipMaxWidth=h.overflowTooltipMaxWidth||500,this.overflowTooltipPlacement=h.overflowTooltipPlacement||"top",this.renderFooter=h.renderFooter,this.hoverIconName=h.hoverIconName,this.formatter=h.formatter,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.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{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{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{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,n="";if(this.type==="tree"&&s==="body"){const l=this.ctx.database.getRowForRowKey(i),{expand:h=!1,hasChildren:f=!1,expandLoading:d=!1,level:x=0}=l||{};if(d){const u=this.ctx.icons.get("loading");n="loading",r=u,o=x*8}else if(f){const u=this.ctx.icons.get("expand"),p=this.ctx.icons.get("shrink");r=h?p:u,n=h?"shrink":"expand",o=x*8}else o=x*8;if(r){let u=20,p=20,g=this.drawX+o+e,w=this.drawY+(this.visibleHeight-p)/2+2;this.ctx.paint.drawImage(r,g,w,u,p),this.drawImageX=g,this.drawImageY=w,this.drawImageWidth=u,this.drawImageHeight=p,this.drawImageName=n,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:n,HIGHLIGHT_SELECTED_ROW:l,HIGHLIGHT_SELECTED_ROW_COLOR:h,HIGHLIGHT_HOVER_ROW:f,HIGHLIGHT_HOVER_ROW_COLOR:d}=this.ctx.config;if(this.cellType==="footer"){let y=n,C=o;if(typeof r=="function"){const m=r,{backgroundColor:E,color:b}=m({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};E&&(y=E),b&&(C=b)}this.drawCellSkyBgColor="transparent",this.drawCellBgColor=y,this.drawTextColor=C;return}let x="transparent";const u=this.ctx.focusCell,p=this.ctx.hoverCell;f&&(p==null?void 0:p.rowKey)===this.rowKey&&(x=d),l&&(u==null?void 0:u.rowKey)===this.rowKey&&(x=h),this.drawCellSkyBgColor=x;let g=e,w=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)||(g=i,w=o),typeof s=="function"){const y=s,{backgroundColor:C,color:m}=y({row:this.row,rowIndex:this.rowIndex,colIndex:this.colIndex,column:this.column,value:this.getValue()})||{};C&&(g=C),m&&(w=m)}this.drawCellBgColor=g,this.drawTextColor=w}updateSelection(){const{visibleWidth:e,visibleHeight:i,rowspan:s,colspan:r,cellType:o,type:n,rowIndex:l,rowKey:h}=this;if(!(s===0||r===0)&&o!=="footer"&&["index-selection","selection"].includes(n)){const f=this.ctx.database.getRowSelection(h),d=this.ctx.database.getRowSelectable(h),{CHECKBOX_SIZE:x=0}=this.ctx.config,u=this.drawX+(e-x)/2,p=this.drawY+(i-x)/2;let g=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck";f&&d?(g=this.ctx.icons.get("checkbox-check"),w="checkbox-check"):f&&d?(g=this.ctx.icons.get("checkbox-check-disabled"),w="checkbox-check-disabled"):!f&&d?(g=this.ctx.icons.get("checkbox-uncheck"),w="checkbox-uncheck"):(g=this.ctx.icons.get("checkbox-disabled"),w="checkbox-disabled"),g&&n=="index-selection"?(this.ctx.hoverCell&&this.ctx.hoverCell.rowIndex===l||["checkbox-disabled","checkbox-check"].includes(w))&&(this.drawImageX=u,this.drawImageY=p,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=w,this.drawImageSource=g):g&&n==="selection"&&(this.drawImageX=u,this.drawImageY=p,this.drawImageWidth=x,this.drawImageHeight=x,this.drawImageName=w,this.drawImageSource=g)}}updateHoverIcon(){const{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 n=this.ctx.icons.get(this.hoverIconName);this.drawImageX=r,this.drawImageY=o,this.drawImageWidth=i,this.drawImageHeight=i,this.drawImageName=this.hoverIconName,this.drawImageSource=n}}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 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{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.target.width-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:"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.ellipsis=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;return 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,n=r[1],l=o[1],{colIndex:h,rowIndex:f,drawX:d,drawY:x}=this;h===n&&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,n=[r+s-e-.5,o,r+s-.5,o,r+s-.5,o+e];this.ctx.paint.drawLine(n,{borderColor:i,fillColor:i,borderWidth:1,lineCap:"round",lineJoin:"round"})}drawBorder(e){const{drawX:i,drawY:s,width:r,rowIndex:o,colIndex:n}=this,l=i+.5;let h=s+.5,f=this.height;o===0&&(h=this.y+1,f=f-1);const{xArr:d,yArr:x,lineDash:u=[],borderWidth:p=1,borderColor:g,fillColor:w}=e,y=d[0],C=d[1],m=x[0],E=x[1];n>=y&&n<=C&&o===m&&this.ctx.paint.drawLine([l,h,l+r-2,h],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u}),n>=y&&n<=C&&o===E&&this.ctx.paint.drawLine([l,h+f-1.5,l+r,h+f-1.5],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u}),n===y&&o>=m&&o<=E&&this.ctx.paint.drawLine([l,h,l,h+f-1],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u}),n===C&&o>=m&&o<=E&&this.ctx.paint.drawLine([l+r-1,h,l+r-1,h+f-1],{borderColor:g,fillColor:w,borderWidth:p,lineCap:"round",lineJoin:"round",lineDash:u})}}class Jt extends Ut{constructor(e,i,s,r,o,n,l){super(e,s,r,o,n,l.fixed,"header");c(this,"align");c(this,"verticalAlign","middle");c(this,"fixed");c(this,"widthFillDisable");c(this,"type");c(this,"operation",!1);c(this,"editorType");c(this,"level");c(this,"text");c(this,"displayText","");c(this,"colspan");c(this,"rowspan");c(this,"key");c(this,"required",!1);c(this,"readonly",!1);c(this,"children",[]);c(this,"column");c(this,"colIndex");c(this,"rowKey");c(this,"rules");c(this,"hasChildren");c(this,"render");c(this,"style",{});c(this,"drawX",0);c(this,"drawY",0);c(this,"drawCellBgColor","");c(this,"drawTextColor","");c(this,"drawImageX",0);c(this,"drawImageY",0);c(this,"drawImageWidth",0);c(this,"drawImageHeight",0);c(this,"drawImageName","");c(this,"drawImageSource");this.ctx=e,this.x=s,this.y=r,this.width=o,this.height=n,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=_t(),this.hasChildren=l.children&&l.children.length>0||!1,this.render=l.renderHeader}isVerticalVisible(){const{target:e}=this.ctx,i=e.height;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 n=e,{backgroundColor:l,color:h}=n({colIndex:this.colIndex,column:this.column})||{};l&&(r=l),h&&(o=h)}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:n,displayText:l}=this;e.drawRect(o,n,this.width,this.height,{borderColor:i,fillColor:this.drawCellBgColor}),e.drawText(l,o,n,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:n}=this.ctx.database.getCheckedState(),{CHECKBOX_SIZE:l=0}=this.ctx.config,h=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&&n?(d=this.ctx.icons.get("checkbox-check"),x="checkbox-check"):o&&n?(d=this.ctx.icons.get("checkbox-check-disabled"),x="checkbox-check-disabled"):!o&&n?(d=this.ctx.icons.get("checkbox-uncheck"),x="checkbox-uncheck"):(d=this.ctx.icons.get("checkbox-disabled"),x="checkbox-disabled"),d&&(this.drawImageX=h,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.target.width-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:"none"}}}class oi{constructor(t){c(this,"ctx");c(this,"visibleHoverCell");c(this,"resizeObserver");this.ctx=t,this.init()}init(){this.resizeObserver=new ResizeObserver(()=>{this.ctx.emit("resetHeader"),this.ctx.emit("resizeObserver")}),this.ctx.target.parentElement&&this.resizeObserver.observe(this.ctx.target),this.ctx.on("mousedown",t=>{if(t.button!==0||this.isBusy(t))return;const e=t.offsetY,i=t.offsetX,s=this.ctx.header.renderCellHeaders;for(const o of s){const n=o.getDrawX(),l=o.getDrawY();if(i>n&&i<n+o.width&&e>l&&e<l+o.height){this.ctx.focusCellHeader=o,this.ctx.emit("cellHeaderMousedown",o,t);return}}const r=this.ctx.body.renderRows;for(const o of r){const n=o.fixedCells.concat(o.noFixedCells);for(const l of n){const h=l.getDrawX(),f=l.getDrawY();if(i>h&&i<h+l.width&&e>f&&e<f+l.height){this.ctx.setFocusCell(l),this.ctx.emit("cellMousedown",l,t);return}}}}),this.ctx.on("click",t=>{if(t.button!==0||this.isBusy(t))return;const e=t.offsetY,i=t.offsetX,s=this.ctx.header.renderCellHeaders;for(const o of s){const n=o.getDrawX(),l=o.getDrawY();if(i>n&&i<n+o.width&&e>l&&e<l+o.height){this.ctx.clickCellHeader=o,this.ctx.emit("cellHeaderClick",o,t),this.selectionClick(o);return}}const r=this.ctx.body.renderRows;for(const o of r){const n=o.fixedCells.concat(o.noFixedCells);for(const l of n){const h=l.getDrawX(),f=l.getDrawY();if(i>h&&i<h+l.width&&e>f&&e<f+l.height){this.ctx.clickCell=l,this.ctx.emit("cellClick",l,t),this.selectionClick(l),this.treeClick(l);return}}}}),this.ctx.on("contextMenu",t=>{if(this.isBusy(t))return;const e=t.offsetY,i=t.offsetX,s=this.ctx.header.renderCellHeaders;for(const o of s){const n=o.getDrawX(),l=o.getDrawY();if(i>n&&i<n+o.width&&e>l&&e<l+o.height){this.ctx.emit("cellHeaderContextMenuClick",o,t);return}}const r=this.ctx.body.renderRows;for(const o of r){const n=o.fixedCells.concat(o.noFixedCells);for(const l of n){const h=l.getDrawX(),f=l.getDrawY();if(i>h&&i<h+l.width&&e>f&&e<f+l.height){this.ctx.emit("cellContextMenuClick",l,t);return}}}}),this.ctx.on("mousemove",t=>{var o;if(this.isBusy(t))return;const e=t.offsetY,i=t.offsetX,s=this.ctx.header.renderCellHeaders;for(const n of s){const l=n.getDrawX(),h=n.getDrawY();if(i>l&&i<l+n.width&&e>h&&e<h+n.height){if(this.ctx.emit("cellHeaderMouseenter",n,t),this.ctx.hoverCellHeader&&this.ctx.hoverCellHeader!==n&&this.ctx.emit("cellHeaderMouseleave",this.ctx.hoverCellHeader,t),this.imageEnterAndLeave(n,t),this.ctx.hoverCellHeader===n)return;this.ctx.hoverCellHeader=n,this.ctx.emit("cellHeaderHoverChange",n);return}}const r=this.ctx.body.renderRows;for(const n of r){const l=n.fixedCells.concat(n.noFixedCells);for(const h of l){const f=h.getDrawX(),d=h.getDrawY();if(i>f&&i<f+h.visibleWidth&&e>d&&e<d+h.visibleHeight&&(this.imageEnterAndLeave(h,t),this.visibleHoverCell!==h&&(this.ctx.emit("visibleCellMouseleave",h,t),this.visibleHoverCell=h,this.ctx.emit("visibleCellHoverChange",h,t))),i>f&&i<f+h.width&&e>d&&e<d+h.height){if(this.ctx.emit("cellMouseenter",h,t),this.ctx.hoverCell&&this.ctx.hoverCell!==h&&this.ctx.emit("cellMouseleave",this.ctx.hoverCell,t),this.ctx.hoverCell===h)return;((o=this.ctx.hoverCell)==null?void 0:o.rowKey)!==h.rowKey&&(this.ctx.hoverCell=h,this.ctx.hoverRow=this.ctx.body.renderRows.find(x=>x.rowKey===h.rowKey),this.ctx.emit("rowHoverChange",this.ctx.hoverRow,h,t),this.ctx.emit("draw")),this.ctx.hoverCell=h,this.ctx.emit("cellHoverChange",h,t);return}}}})}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)}).catch(l=>{this.ctx.database.expandLoading(t.rowKey,!1),console.error(l)}));else{const n=this.ctx.database.getIsExpand(t.rowKey);this.ctx.database.expandItem(t.rowKey,!n),this.ctx.emit("expandChange")}}}imageEnterAndLeave(t,e){const i=e.offsetY,s=e.offsetX;s>t.drawImageX&&s<t.drawImageX+t.drawImageWidth&&i>t.drawImageY&&i<t.drawImageY+t.drawImageHeight?(this.ctx.target.style.cursor="pointer",this.ctx.isPointer=!0,t instanceof Zt&&["selection","index-selection"].includes(t.type)&&(this.ctx.database.getRowSelectable(t.rowKey)||(this.ctx.target.style.cursor="not-allowed"))):(this.ctx.isPointer=!1,this.ctx.target.style.cursor==="pointer"&&(this.ctx.target.style.cursor="default"))}isBusy(t){const e=t.offsetY,i=t.offsetX;if(!(t.target instanceof HTMLCanvasElement)||!this.ctx.isTarget(t.target)||this.ctx.target.style.cursor==="row-resize"||this.ctx.target.style.cursor==="col-resize"||this.ctx.columnResizing||this.ctx.rowResizing)return!0;const{SCROLLER_TRACK_SIZE:s}=this.ctx.config;return!!(this.ctx.scrollerMove||this.ctx.scrollerFocus||e>this.ctx.target.height-s||i>this.ctx.target.width-s)}destroy(){this.resizeObserver.unobserve(this.ctx.target)}}class ni{constructor(t,e,i){c(this,"eventBus");c(this,"eventBrowser");c(this,"eventTable");c(this,"uuid",_t());c(this,"targetContainer");c(this,"target");c(this,"paint");c(this,"icons");c(this,"mousedown",!1);c(this,"isPointer",!1);c(this,"rowResizing",!1);c(this,"columnResizing",!1);c(this,"scrollerMove",!1);c(this,"scrollerFocus",!1);c(this,"autofillMove",!1);c(this,"selectorMove",!1);c(this,"editing",!1);c(this,"scrollY",0);c(this,"scrollX",0);c(this,"fixedLeftWidth",0);c(this,"fixedRightWidth",0);c(this,"maxColIndex",0);c(this,"maxRowIndex",0);c(this,"hoverRow");c(this,"clickCell");c(this,"focusCell");c(this,"hoverCell");c(this,"clickCellHeader");c(this,"focusCellHeader");c(this,"hoverCellHeader");c(this,"body",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,headIndex:0,tailIndex:0,visibleRows:[],renderRows:[],data:[]});c(this,"footer",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,renderRows:[]});c(this,"header",{x:0,y:0,width:0,height:0,visibleHeight:0,visibleWidth:0,visibleLeafColumns:[],leafCellHeaders:[],renderLeafCellHeaders:[],renderCellHeaders:[],fixedLeftCellHeaders:[],fixedRightCellHeaders:[],renderCenterCellHeaders:[]});c(this,"selector",{enable:!1,xArr:[-1,-1],yArr:[-1,-1],xArrCopy:[-1,-1],yArrCopy:[-1,-1]});c(this,"autofill",{enable:!1,xArr:[-1,-1],yArr:[-1,-1]});c(this,"database");c(this,"history");c(this,"config");this.target=e,this.targetContainer=t,this.target.setAttribute("uuid",this.uuid),this.config=new jt(i.config||{}),this.eventBus=new ii,this.eventBrowser=new ei(this),this.eventTable=new oi(this),this.paint=new si(e),this.database=new Qe(this,i),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 n=0;n<=i[1]-i[0];n++){const l=r+e[0],h=n+i[0],f=this.database.getItemValueForRowIndexAndColIndex(l,h);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);const i=this.body.height-this.body.visibleHeight-this.footer.height;e<0?e=0:e>i&&(e=i),this.emit("setScrollY",e)}isTarget(t){if(t===null)return!1;const e=t.getAttribute("uuid");return this.uuid===e}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){c(this,"ctx");c(this,"type");c(this,"isFocus",!1);c(this,"trackX",0);c(this,"trackY",0);c(this,"trackWidth",0);c(this,"trackHeight",0);c(this,"splitPoints",[]);c(this,"barX",0);c(this,"barY",0);c(this,"barWidth",0);c(this,"barHeight",0);c(this,"distance",0);c(this,"visibleDistance",0);c(this,"clientX",0);c(this,"clientY",0);c(this,"dragStart",0);c(this,"isDragging",!1);c(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 HTMLCanvasElement)||!this.ctx.isTarget(t.target))return;if(this.ctx.target.style.cursor==="row-resize"||this.ctx.target.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.target?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 n=0;this.type==="vertical"?n=this.dragStart+o/(this.visibleDistance-this.barHeight)*this.distance:n=this.dragStart+o/(this.visibleDistance-this.barWidth)*this.distance,this.scroll=Math.max(0,Math.min(n,this.distance))}}isPointInElement(t,e,i,s,r,o){return t>=i&&t<=i+r&&e>=s&&e<=s+o}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.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,config:{SCROLLER_TRACK_SIZE:i=0,SCROLLER_SIZE:s=0}}=this.ctx,r=this.ctx.target.width+1,o=this.ctx.target.height,n=e.height,l=e.width,h=t.height,f=this.ctx.footer.height;if(this.type==="vertical"){this.visibleDistance=o-i-n,this.distance=h-this.visibleDistance+f,this.trackX=r-i,this.trackY=0,this.splitPoints=[this.trackX,n,this.trackX+i,n],this.trackWidth=i,this.trackHeight=o,this.barX=this.trackX+(i-s)/2,this.barWidth=s;const d=this.distance?this.visibleDistance/h:0;let x=Math.floor(d*this.visibleDistance);x<30?x=30:x>this.visibleDistance&&(x=0),this.barHeight=x,this.barY=n+this.scroll/this.distance*(this.visibleDistance-this.barHeight),this.scroll=Math.max(0,Math.min(this.scroll,this.distance))}else{this.visibleDistance=r-i,this.distance=l-this.visibleDistance,this.splitPoints=[r-i,o-i,r-i,o],this.trackX=0,this.trackY=o-i,this.trackWidth=r,this.trackHeight=i;const d=this.distance?this.visibleDistance/l:0;let x=Math.floor(d*this.visibleDistance);this.barY=this.trackY+.5+(i-s)/2,x<30?x=30:x>=this.visibleDistance&&(x=0),this.barWidth=x,this.barHeight=s,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){c(this,"ctx");c(this,"verticalScrollbar");c(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 ci{constructor(t){c(this,"ctx");c(this,"x",0);c(this,"y",0);c(this,"width",0);c(this,"height",0);c(this,"resizeTarget",null);c(this,"resizeNum",0);c(this,"isResizing",!1);c(this,"clientX",0);c(this,"resizeDiff",0);c(this,"columnIndex",0);c(this,"isMouseDown",!1);c(this,"columns");c(this,"visibleLeafColumns",[]);c(this,"visibleHeight",0);c(this,"visibleWidth",0);c(this,"allCellHeaders",[]);c(this,"leafCellHeaders",[]);c(this,"renderLeafCellHeaders",[]);c(this,"fixedLeftCellHeaders",[]);c(this,"centerCellHeaders",[]);c(this,"fixedRightCellHeaders",[]);c(this,"renderCenterCellHeaders",[]);c(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=It(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 n=this.ctx.targetContainer.getBoundingClientRect();this.resizeNum>0?this.ctx.target.width=n.width:this.ctx.target.width=this.width+e-1,this.visibleWidth=this.ctx.target.width-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 h=this.fixedLeftCellHeaders.filter(d=>!d.hasChildren);this.ctx.fixedLeftWidth=h.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(e.target)&&(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{target: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.target.style.cursor==="col-resize"&&(this.ctx.target.style.cursor="default");const r=[...this.renderFixedCellHeaders,...this.renderCenterCellHeaders];for(const o of r){const n=e.layerX,l=o.getDrawX();n>l+o.width-5&&n<l+o.width+4&&n<i.width-4&&o.colspan<=1&&e.target instanceof HTMLCanvasElement&&this.ctx.isTarget(e.target)&&e.layerY<=this.height&&(this.ctx.target.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 n=o.width||100;o.width=n+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 n=t[o],l=r*(n.rowspan||1),h=r*n.level;let f=n.width||100;n.children&&(f=It(n.children).reduce((u,p)=>u+((p==null?void 0:p.width)||100),0));const d=new Jt(this.ctx,this.columnIndex,s,h,f,l,n);this.ctx.database.setHeader(n.key,d),this.allCellHeaders.push(d),n.children||(this.leafCellHeaders.push(d),d.column.widthFillDisable||this.resizeNum++),n.fixed==="left"?this.fixedLeftCellHeaders.push(d):n.fixed==="right"?this.fixedRightCellHeaders.push(d):this.centerCellHeaders.push(d),!n.children&&this.columnIndex++,n.children&&this.render(n.children,s),s+=f}}drawTipLine(){if(this.isResizing&&this.resizeTarget){const{target: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.height];this.ctx.paint.drawLine(o,{borderColor:e,borderWidth:1})}}drawFiexShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,target:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:n}}=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-s.visibleWidth-1)&&e!==n){const l=s.width-(this.x+this.width)+r.width-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,n,l="body"){c(this,"ctx");c(this,"x",0);c(this,"y",0);c(this,"width",0);c(this,"height");c(this,"cells",[]);c(this,"fixedCells",[]);c(this,"noFixedCells",[]);c(this,"rowIndex",0);c(this,"rowKey","");c(this,"rowType","body");c(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=n,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){c(this,"resizeTarget",null);c(this,"isMouseDown",!1);c(this,"resizeDiff",0);c(this,"clientY",0);c(this,"ctx");c(this,"x",0);c(this,"y",0);c(this,"width",0);c(this,"height",0);c(this,"headIndex",0);c(this,"tailIndex",0);c(this,"isResizing",!1);c(this,"renderRows",[]);c(this,"visibleRows",[]);c(this,"visibleHeight",0);c(this,"visibleWidth",0);c(this,"data",[]);this.ctx=t,this.init(),this.initResizeRow()}init(){const{target:t,header:e,database:i,config:{FOOTER_FIXED:s,SCROLLER_TRACK_SIZE:r=0,BORDER_COLOR:o,BORDER_RADIUS:n,HEIGHT:l,EMPTY_BODY_HEIGHT:h=0,MAX_HEIGHT:f=0,ENABLE_OFFSET_HEIGHT:d=0,OFFSET_HEIGHT:x=0}}=this.ctx;if(!e.width)return;this.x=0,this.y=e.height;const{data:u,sumHeight:p}=i.getData();this.height=p,this.data=u;const{top:g}=t.getBoundingClientRect();this.width=e.width,this.visibleWidth=t.width-r;const w=this.ctx.footer.height;this.data.length||(this.height=h);const y=this.data.length?"not-empty":"empty";this.ctx.emit("emptyChange",{isEmpty:y,type:y,headerHeight:e.height,bodyHeight:this.height,footerHeight:w,width:this.width,height:this.data.length?0:h+w});let C=this.height+e.height+r;C+=w;let m=0;this.data.length&&d?(m=window.innerHeight-g-x,m<0&&(m=32,console.error("There is an error in the height calculation ENABLE_OFFSET_HEIGHT and OFFSET_HEIGHT are invalid"))):this.data.length&&l?m=l:this.data.length&&f&&C>f?m=f:m=C,m>0&&(this.ctx.target.height=m);let E=t.height-e.height-r;s?this.visibleHeight=E-w:this.visibleHeight=E,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=u,this.ctx.target.setAttribute("style",`outline: none; position: relative; border-radius: ${n}px; border: 1px solid ${o}; height:${this.ctx.target.height}px;width:${this.ctx.target.width-1}px;`)}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(e.target)&&(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 i=e.offsetY,s=e.offsetX,r=e.clientY,{target:o,scrollY:n,config:{RESIZE_ROW_MIN_HEIGHT:l=0}}=this.ctx;if(this.isResizing&&this.resizeTarget){const h=this.resizeTarget.height;let f=r-this.clientY;f+h<l&&(f=-(h-l)),this.resizeDiff=f,this.ctx.emit("draw")}else{if(this.resizeTarget=null,this.isMouseDown||this.ctx.target.style.cursor==="crosshair")return;this.ctx.target.style.cursor==="row-resize"&&(this.ctx.target.style.cursor="default");for(let h=0;h<this.renderRows.length;h++){const f=this.renderRows[h];if(i>f.y-n+f.height-1.5&&i<f.y-n+f.height+1.5&&i<o.height-4)for(let x=0;x<f.cells.length;x++){const u=f.cells[x];s>u.drawX+10&&s<u.drawX+u.width-10&&u.rowspan===1&&(this.ctx.target.style.cursor="row-resize",this.resizeTarget=f)}}}}))}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{target: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,n=[0,o+.5,t.width,o+.5];this.ctx.paint.drawLine(n,{borderColor:i,borderWidth:1})}}drawFiexShadow(){const{fixedLeftWidth:t,fixedRightWidth:e,scrollX:i,header:s,target:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:n}}=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-s.visibleWidth-1)&&e!==n){const l=s.width-(this.x+this.width)+r.width-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),n=t[o].bottom;if(n===e)return o;n<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 n=this.binarySearch(o,s);let l=this.binarySearch(o,s+this.visibleHeight);l===-1&&(l=r.length),this.headIndex=Math.max(0,n),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 h=[];for(let f=0;f<this.visibleRows.length;f++){const d=this.headIndex+f,x=this.visibleRows[f],{height:u,top:p}=this.ctx.database.getPositionForRowIndex(d),g=new te(this.ctx,d,0,p+this.y,t.width,u,x);h.push(g)}this.renderRows=h,this.ctx.body.renderRows=h}draw(){this.renderRows.forEach(t=>{t.drawCenter()}),this.drawFiexShadow(),this.renderRows.forEach(t=>{t.drawFixed()}),this.drawTipLine()}}class hi{constructor(t){c(this,"ctx");c(this,"renderRows",[]);c(this,"data",[]);c(this,"x",0);c(this,"y",0);c(this,"width",0);c(this,"height",0);c(this,"visibleWidth",0);c(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.target.height-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,target:r,config:{HEADER_BG_COLOR:o,SCROLLER_TRACK_SIZE:n}}=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-s.visibleWidth-1)&&e!==n){const h=s.width-(this.x+this.width)+r.width-e;this.ctx.paint.drawShadow(h+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){c(this,"isCut",!1);c(this,"isMultipleRow",!1);c(this,"ctx");c(this,"adjustPositionX","");c(this,"adjustPositionY","");c(this,"timerX",0);c(this,"timerY",0);this.ctx=t,this.init()}init(){this.ctx.on("mousemove",Vt(t=>{const{offsetX:e,offsetY:i}=t,s=this.ctx.isTarget(t.target)&&e>0&&e<this.ctx.body.visibleWidth&&i>this.ctx.header.visibleHeight&&i<this.ctx.header.visibleHeight+this.ctx.body.visibleHeight;(this.ctx.selectorMove||this.ctx.autofillMove)&&(s?this.stopAdjustPosition():this.startAdjustPosition(t))},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(e.target)&&this.ctx.target.style.cursor!=="pointer"&&!this.ctx.isPointer&&this.ctx.target.style.cursor!=="crosshair"){if(t.operation){this.isMultipleRow=!0,this.selectRows(t);return}this.isMultipleRow=!1,this.click(e.shiftKey)}}),this.ctx.on("cellHeaderHoverChange",t=>{this.ctx.mousedown&&this.selectCols(t)}),this.ctx.on("cellHeaderMousedown",t=>{this.ctx.target.style.cursor!=="pointer"&&(this.ctx.isPointer||this.selectCols(t))}),this.ctx.on("keydown",t=>{if(t.ctrlKey&&t.code==="KeyV"||t.metaKey&&t.code==="KeyV"){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[n]=o;o=[n,n]}if(!i){const[n]=r;r=[n,n]}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:n,SELECTOR_AREA_MAX_X:l,SELECTOR_AREA_MIN_Y:h,SELECTOR_AREA_MAX_Y:f,SELECTOR_AREA_MAX_X_OFFSET:d,SELECTOR_AREA_MAX_Y_OFFSET:x}=this.ctx.config,u=n,p=l||this.ctx.maxColIndex-d,g=h,w=f||this.ctx.maxRowIndex-x;let[y,C]=r,[m,E]=o;if(y<u||C>p||m<g||E>w)return;this.ctx.selector.xArr=[Math.max(u,y),Math.min(p,C)],this.ctx.selector.yArr=[Math.max(g,m),Math.min(w,E)],this.ctx.emit("setSelector",this.ctx.selector),this.ctx.emit("draw")}}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:n}=this.ctx.focusCellHeader;if(this.ctx.clearSelector(),t.colIndex>=n){const l=[n,t.colIndex+t.colspan-1],h=[r,o];this.setSelector(l,h)}else{const l=[t.colIndex,n],h=[r,o];this.setSelector(l,h)}}else{const n=[t.colIndex,t.colIndex+t.colspan-1],l=[r,o];this.setSelector(n,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:n,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,h=i,f=s||this.ctx.maxColIndex-n,d=r,x=o||this.ctx.maxRowIndex-l,u=[h,f],p=[d,x];this.setSelector(u,p)}}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,n=i;if(e){this.ctx.setFocusCell(t);const l=[n,o],h=[t.rowIndex,t.rowIndex];this.setSelector(l,h)}if(this.ctx.focusCell&&this.ctx.mousedown){const{rowIndex:l}=this.ctx.focusCell;if(t.rowIndex>=l){const h=[n,o],f=[l,t.rowIndex];this.setSelector(h,f)}else{const h=[n,o],f=[t.rowIndex,l];this.setSelector(h,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),n=Math.max(i.colIndex,r),l=Math.min(i.rowIndex,s),h=Math.max(i.rowIndex,s),f=[o,n],d=[l,h];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:n}=e,l=Math.min(o,s),h=Math.max(o,s),f=Math.min(n,r),d=Math.max(n,r),x=[l,h],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("setCopy",this.ctx.selector),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 n=0;n<=e[1]-e[0];n++)for(let l=0;l<=t[1]-t[0];l++){const h=n+e[0],f=l+t[0],d=this.ctx.database.getItemValueForRowIndexAndColIndex(h,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(n=>{o.push(this.ctx.database.getRowDataItemForRowKey(n))}),this.ctx.emit("clearSelectedDataChange",s,o),this.ctx.emit("draw"),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(r=>{let o=Ze(r),n=[];for(let h=0;h<=o.length-1;h++){const f=o[h].length;for(let d=0;d<=f-1;d++){const x=h+e,u=d+i,p=o[h][d],g=this.ctx.database.getItemValueForRowIndexAndColIndex(x,u);if(g){const{rowKey:w,key:y}=g;this.ctx.database.getReadonly(w,y)||(s.add(w),n.push({rowKey:w,key:y,value:p,row:{}}))}}}if(this.isCut){const h=this.clearSelectedData(this.ctx.selector.xArrCopy,this.ctx.selector.yArrCopy,!0),f=n.map(d=>`${d.rowKey}-${d.key}`);h.forEach(d=>{f.includes(`${d.rowKey}-${d.key}`)||n.unshift(d)}),this.isCut=!1}if(!n.length)return;this.ctx.database.batchSetItemValue(n,!0);let l=[];s.forEach(h=>{l.push(this.ctx.database.getRowDataItemForRowKey(h))}),this.ctx.emit("pasteChange",n,l),this.clearCopyLine(),this.ctx.emit("draw")}).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,n=this.ctx.maxColIndex,l=this.ctx.maxRowIndex;switch(t){case"LEFT":i>r&&i--;break;case"TOP":s>o&&s--;break;case"RIGHT":i<n&&i++;break;case"BOTTOM":s<l&&s++;break}const h=[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(h,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:n,SELECTOR_AREA_MAX_Y_OFFSET:l}=this.ctx.config,h=i,f=s||this.ctx.maxColIndex-n,d=r,x=o||this.ctx.maxRowIndex-l;return!(e<h||e>f||t<d||t>x)}startAdjustPosition(t){const{offsetX:e,offsetY:i}=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 n=10*(s==="left"?-1:1);this.timerX&&(clearInterval(this.timerX),this.timerX=0),this.timerX=setInterval(()=>{n*=1.5;const{scrollX:l}=this.ctx,h=l+n;(h<0||h>this.ctx.body.width)&&(clearInterval(this.timerX),this.timerX=0),this.ctx.setScrollX(h)},100)}if(r&&this.adjustPositionY!==r){this.adjustPositionY=r;let n=10*(r==="top"?-1:1);this.timerY&&(clearInterval(this.timerY),this.timerY=0),this.timerY=setInterval(()=>{n*=1.5;const{scrollY:l}=this.ctx,h=l+n;(h<0||h>this.ctx.body.height)&&(clearInterval(this.timerY),this.timerY=0),this.ctx.setScrollY(h)},100)}}adjustBoundaryPosition(){const{target:t,focusCell:e,fixedRightWidth:i,fixedLeftWidth:s,header:r,footer:o,scrollX:n,scrollY:l}=this.ctx;if(!e)return;const{SCROLLER_TRACK_SIZE:h=0,FOOTER_FIXED:f}=this.ctx.config;let d=0;f&&(d=o.visibleHeight);const x=s-e.drawX+1,u=e.drawX+e.width-(t.width-i)+1,p=r.height-e.drawY,g=e.drawY+e.height-(t.height-d-h);u>0&&!e.fixed?this.ctx.setScrollX(n+u):x>0&&!e.fixed&&this.ctx.setScrollX(n-x),p>0?this.ctx.setScrollY(l-p):g>0&&this.ctx.setScrollY(l+g)}destroy(){this.timerX&&(clearTimeout(this.timerX),this.timerX=0),this.timerY&&(clearTimeout(this.timerY),this.timerY=0)}}class fi{constructor(t){c(this,"ctx");this.ctx=t,this.init()}init(){this.ctx.on("cellMouseenter",(t,e)=>{this.ctx.target.style.cursor==="crosshair"&&(this.ctx.target.style.cursor="default");const{xArr:i,yArr:s}=this.ctx.selector,r=i[1],o=s[1],{colIndex:n,rowIndex:l,drawX:h,drawY:f,width:d,height:x}=t;if(this.ctx.config.ENABLE_AUTOFILL&&n===r&&l===o){const p=h+d-6,g=f+x-6;e.offsetX>p&&e.offsetY>g&&(this.ctx.target.style.cursor="crosshair")}this.mouseenter(t)}),this.ctx.on("cellMousedown",()=>{this.ctx.target.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,n=e;if(!r){const[l]=n;n=[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(n)){const{SELECTOR_AREA_MIN_X:l,SELECTOR_AREA_MAX_X:h,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,p=l,g=h||this.ctx.maxColIndex-x,w=f,y=d||this.ctx.maxRowIndex-u;let[C,m]=o,[E,b]=n;if(C<p||E<w)return;this.ctx.autofill.xArr=[Math.max(p,C),Math.min(g,m)],this.ctx.autofill.yArr=[Math.max(w,E),Math.min(y,b)],this.ctx.emit("setAutofill",this.ctx.autofill),this.ctx.emit("draw")}}autofillData(){const t=new Set,e=this.ctx.getSelectedData(),i=new Map;for(let d=0;d<=e.yArr[1]-e.yArr[0];d++)for(let x=0;x<=e.xArr[1]-e.xArr[0];x++){const u=d+e.yArr[0],p=x+e.xArr[0];i.set(`${u}-${p}`,!0)}const{value:s}=e,r=s[0].length,o=s.length,n=this.ctx.autofill.xArr,l=this.ctx.autofill.yArr;let h=[];for(let d=0;d<=l[1]-l[0];d++)for(let x=0;x<=n[1]-n[0];x++){const u=x+n[0],p=d+l[0],g=s[d%o][x%r],w=this.ctx.database.getItemValueForRowIndexAndColIndex(p,u),y=`${p}-${u}`;if(w&&!i.has(y)){const{rowKey:C,key:m}=w;this.ctx.database.getReadonly(C,m)||(t.add(C),h.push({rowKey:C,key:m,value:g,row:{}}))}}if(!h.length)return;this.ctx.database.batchSetItemValue(h,!0);let f=[];t.forEach(d=>{f.push(this.ctx.database.getRowDataItemForRowKey(d))}),this.ctx.emit("autofillChange",h,f),this.ctx.selector.xArr=this.ctx.autofill.xArr,this.ctx.selector.yArr=this.ctx.autofill.yArr,this.ctx.emit("draw")}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(),n=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]?n.splice(1,1,s):s<e.yArr[0]&&n.splice(0,1,s),this.setAutofill(o,n)}}destroy(){}}const at=Math.min,Z=Math.max,ut=Math.round,V=a=>({x:a,y:a}),xi={left:"right",right:"left",bottom:"top",top:"bottom"},ui={start:"end",end:"start"};function Ot(a,t,e){return Z(a,at(t,e))}function ct(a,t){return typeof a=="function"?a(t):a}function j(a){return a.split("-")[0]}function lt(a){return a.split("-")[1]}function ee(a){return a==="x"?"y":"x"}function St(a){return a==="y"?"height":"width"}function J(a){return["top","bottom"].includes(j(a))?"y":"x"}function Tt(a){return ee(J(a))}function gi(a,t,e){e===void 0&&(e=!1);const i=lt(a),s=Tt(a),r=St(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(a){const t=gt(a);return[At(a),t,At(t)]}function At(a){return a.replace(/start|end/g,t=>ui[t])}function pi(a,t,e){const i=["left","right"],s=["right","left"],r=["top","bottom"],o=["bottom","top"];switch(a){case"top":case"bottom":return e?t?s:i:t?i:s;case"left":case"right":return t?r:o;default:return[]}}function yi(a,t,e,i){const s=lt(a);let r=pi(j(a),e==="start",i);return s&&(r=r.map(o=>o+"-"+s),t&&(r=r.concat(r.map(At)))),r}function gt(a){return a.replace(/left|right|bottom|top/g,t=>xi[t])}function mi(a){return{top:0,right:0,bottom:0,left:0,...a}}function ie(a){return typeof a!="number"?mi(a):{top:a,right:a,bottom:a,left:a}}function wt(a){const{x:t,y:e,width:i,height:s}=a;return{width:i,height:s,top:e,left:t,right:t+i,bottom:e+s,x:t,y:e}}function se(a,t,e){let{reference:i,floating:s}=a;const r=J(t),o=Tt(t),n=St(o),l=j(t),h=r==="y",f=i.x+i.width/2-s.width/2,d=i.y+i.height/2-s.height/2,x=i[n]/2-s[n]/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&&h?-1:1);break;case"end":u[o]+=x*(e&&h?-1:1);break}return u}const Ei=async(a,t,e)=>{const{placement:i="bottom",strategy:s="absolute",middleware:r=[],platform:o}=e,n=r.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(t));let h=await o.getElementRects({reference:a,floating:t,strategy:s}),{x:f,y:d}=se(h,i,l),x=i,u={},p=0;for(let g=0;g<n.length;g++){const{name:w,fn:y}=n[g],{x:C,y:m,data:E,reset:b}=await y({x:f,y:d,initialPlacement:i,placement:x,strategy:s,middlewareData:u,rects:h,platform:o,elements:{reference:a,floating:t}});f=C??f,d=m??d,u={...u,[w]:{...u[w],...E}},b&&p<=50&&(p++,typeof b=="object"&&(b.placement&&(x=b.placement),b.rects&&(h=b.rects===!0?await o.getElementRects({reference:a,floating:t,strategy:s}):b.rects),{x:f,y:d}=se(h,x,l)),g=-1)}return{x:f,y:d,placement:x,strategy:s,middlewareData:u}};async function re(a,t){var e;t===void 0&&(t={});const{x:i,y:s,platform:r,rects:o,elements:n,strategy:l}=a,{boundary:h="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:x=!1,padding:u=0}=ct(t,a),p=ie(u),w=n[x?d==="floating"?"reference":"floating":d],y=wt(await r.getClippingRect({element:(e=await(r.isElement==null?void 0:r.isElement(w)))==null||e?w:w.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(n.floating)),boundary:h,rootBoundary:f,strategy:l})),C=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(n.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},b=wt(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:n,rect:C,offsetParent:m,strategy:l}):C);return{top:(y.top-b.top+p.top)/E.y,bottom:(b.bottom-y.bottom+p.bottom)/E.y,left:(y.left-b.left+p.left)/E.x,right:(b.right-y.right+p.right)/E.x}}const Ci=a=>({name:"arrow",options:a,async fn(t){const{x:e,y:i,placement:s,rects:r,platform:o,elements:n,middlewareData:l}=t,{element:h,padding:f=0}=ct(a,t)||{};if(h==null)return{};const d=ie(f),x={x:e,y:i},u=Tt(s),p=St(u),g=await o.getDimensions(h),w=u==="y",y=w?"top":"left",C=w?"bottom":"right",m=w?"clientHeight":"clientWidth",E=r.reference[p]+r.reference[u]-x[u]-r.floating[p],b=x[u]-r.reference[u],R=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let A=R?R[m]:0;(!A||!await(o.isElement==null?void 0:o.isElement(R)))&&(A=n.floating[m]||r.floating[p]);const L=E/2-b/2,X=A/2-g[p]/2-1,N=at(d[y],X),$=at(d[C],X),O=N,T=A-g[p]-$,S=A/2-g[p]/2+L,it=Ot(O,S,T),W=!l.arrow&&lt(s)!=null&&S!==it&&r.reference[p]/2-(S<O?N:$)-g[p]/2<0,K=W?S<O?S-O:S-T:0;return{[u]:x[u]+K,data:{[u]:it,centerOffset:S-it-K,...W&&{alignmentOffset:K}},reset:W}}}),bi=function(a){return a===void 0&&(a={}),{name:"flip",options:a,async fn(t){var e,i;const{placement:s,middlewareData:r,rects:o,initialPlacement:n,platform:l,elements:h}=t,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:x,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...w}=ct(a,t);if((e=r.arrow)!=null&&e.alignmentOffset)return{};const y=j(s),C=J(n),m=j(n)===n,E=await(l.isRTL==null?void 0:l.isRTL(h.floating)),b=x||(m||!g?[gt(n)]:wi(n)),R=p!=="none";!x&&R&&b.push(...yi(n,g,p,E));const A=[n,...b],L=await re(t,w),X=[];let N=((i=r.flip)==null?void 0:i.overflows)||[];if(f&&X.push(L[y]),d){const S=gi(s,o,E);X.push(L[S[0]],L[S[1]])}if(N=[...N,{placement:s,overflows:X}],!X.every(S=>S<=0)){var $,O;const S=((($=r.flip)==null?void 0:$.index)||0)+1,it=A[S];if(it)return{data:{index:S,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 T;const K=(T=N.filter(q=>{if(R){const G=J(q.placement);return G===C||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:T[0];K&&(W=K);break}case"initialPlacement":W=n;break}if(s!==W)return{reset:{placement:W}}}return{}}}};async function vi(a,t){const{placement:e,platform:i,elements:s}=a,r=await(i.isRTL==null?void 0:i.isRTL(s.floating)),o=j(e),n=lt(e),l=J(e)==="y",h=["left","top"].includes(o)?-1:1,f=r&&l?-1:1,d=ct(t,a);let{mainAxis:x,crossAxis:u,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return n&&typeof p=="number"&&(u=n==="end"?p*-1:p),l?{x:u*f,y:x*h}:{x:x*h,y:u*f}}const Ri=function(a){return a===void 0&&(a=0),{name:"offset",options:a,async fn(t){var e,i;const{x:s,y:r,placement:o,middlewareData:n}=t,l=await vi(t,a);return o===((e=n.offset)==null?void 0:e.placement)&&(i=n.arrow)!=null&&i.alignmentOffset?{}:{x:s+l.x,y:r+l.y,data:{...l,placement:o}}}}},_i=function(a){return a===void 0&&(a={}),{name:"shift",options:a,async fn(t){const{x:e,y:i,placement:s}=t,{mainAxis:r=!0,crossAxis:o=!1,limiter:n={fn:w=>{let{x:y,y:C}=w;return{x:y,y:C}}},...l}=ct(a,t),h={x:e,y:i},f=await re(t,l),d=J(j(s)),x=ee(d);let u=h[x],p=h[d];if(r){const w=x==="y"?"top":"left",y=x==="y"?"bottom":"right",C=u+f[w],m=u-f[y];u=Ot(C,u,m)}if(o){const w=d==="y"?"top":"left",y=d==="y"?"bottom":"right",C=p+f[w],m=p-f[y];p=Ot(C,p,m)}const g=n.fn({...t,[x]:u,[d]:p});return{...g,data:{x:g.x-e,y:g.y-i,enabled:{[x]:r,[d]:o}}}}}};function pt(){return typeof window<"u"}function Q(a){return oe(a)?(a.nodeName||"").toLowerCase():"#document"}function D(a){var t;return(a==null||(t=a.ownerDocument)==null?void 0:t.defaultView)||window}function B(a){var t;return(t=(oe(a)?a.ownerDocument:a.document)||window.document)==null?void 0:t.documentElement}function oe(a){return pt()?a instanceof Node||a instanceof D(a).Node:!1}function F(a){return pt()?a instanceof Element||a instanceof D(a).Element:!1}function Y(a){return pt()?a instanceof HTMLElement||a instanceof D(a).HTMLElement:!1}function ne(a){return!pt()||typeof ShadowRoot>"u"?!1:a instanceof ShadowRoot||a instanceof D(a).ShadowRoot}function ht(a){const{overflow:t,overflowX:e,overflowY:i,display:s}=k(a);return/auto|scroll|overlay|hidden|clip/.test(t+i+e)&&!["inline","contents"].includes(s)}function Ii(a){return["table","td","th"].includes(Q(a))}function yt(a){return[":popover-open",":modal"].some(t=>{try{return a.matches(t)}catch{return!1}})}function Lt(a){const t=Mt(),e=F(a)?k(a):a;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(a){let t=z(a);for(;Y(t)&&!tt(t);){if(Lt(t))return t;if(yt(t))return null;t=z(t)}return null}function Mt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function tt(a){return["html","body","#document"].includes(Q(a))}function k(a){return D(a).getComputedStyle(a)}function mt(a){return F(a)?{scrollLeft:a.scrollLeft,scrollTop:a.scrollTop}:{scrollLeft:a.scrollX,scrollTop:a.scrollY}}function z(a){if(Q(a)==="html")return a;const t=a.assignedSlot||a.parentNode||ne(a)&&a.host||B(a);return ne(t)?t.host:t}function ae(a){const t=z(a);return tt(t)?a.ownerDocument?a.ownerDocument.body:a.body:Y(t)&&ht(t)?t:ae(t)}function Ht(a,t,e){var i;t===void 0&&(t=[]),e===void 0&&(e=!0);const s=ae(a),r=s===((i=a.ownerDocument)==null?void 0:i.body),o=D(s);if(r){const n=Dt(o);return t.concat(o,o.visualViewport||[],ht(s)?s:[],n&&e?Ht(n):[])}return t.concat(s,Ht(s,[],e))}function Dt(a){return a.parent&&Object.getPrototypeOf(a.parent)?a.frameElement:null}function ce(a){const t=k(a);let e=parseFloat(t.width)||0,i=parseFloat(t.height)||0;const s=Y(a),r=s?a.offsetWidth:e,o=s?a.offsetHeight:i,n=ut(e)!==r||ut(i)!==o;return n&&(e=r,i=o),{width:e,height:i,$:n}}function le(a){return F(a)?a:a.contextElement}function et(a){const t=le(a);if(!Y(t))return V(1);const e=t.getBoundingClientRect(),{width:i,height:s,$:r}=ce(t);let o=(r?ut(e.width):e.width)/i,n=(r?ut(e.height):e.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!n||!Number.isFinite(n))&&(n=1),{x:o,y:n}}const Si=V(0);function he(a){const t=D(a);return!Mt()||!t.visualViewport?Si:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ti(a,t,e){return t===void 0&&(t=!1),!e||t&&e!==D(a)?!1:t}function dt(a,t,e,i){t===void 0&&(t=!1),e===void 0&&(e=!1);const s=a.getBoundingClientRect(),r=le(a);let o=V(1);t&&(i?F(i)&&(o=et(i)):o=et(a));const n=Ti(r,e,i)?he(r):V(0);let l=(s.left+n.x)/o.x,h=(s.top+n.y)/o.y,f=s.width/o.x,d=s.height/o.y;if(r){const x=D(r),u=i&&F(i)?D(i):i;let p=x,g=Dt(p);for(;g&&i&&u!==p;){const w=et(g),y=g.getBoundingClientRect(),C=k(g),m=y.left+(g.clientLeft+parseFloat(C.paddingLeft))*w.x,E=y.top+(g.clientTop+parseFloat(C.paddingTop))*w.y;l*=w.x,h*=w.y,f*=w.x,d*=w.y,l+=m,h+=E,p=D(g),g=Dt(p)}}return wt({width:f,height:d,x:l,y:h})}function Ai(a){let{elements:t,rect:e,offsetParent:i,strategy:s}=a;const r=s==="fixed",o=B(i),n=t?yt(t.floating):!1;if(i===o||n&&r)return e;let l={scrollLeft:0,scrollTop:0},h=V(1);const f=V(0),d=Y(i);if((d||!d&&!r)&&((Q(i)!=="body"||ht(o))&&(l=mt(i)),Y(i))){const x=dt(i);h=et(i),f.x=x.x+i.clientLeft,f.y=x.y+i.clientTop}return{width:e.width*h.x,height:e.height*h.y,x:e.x*h.x-l.scrollLeft*h.x+f.x,y:e.y*h.y-l.scrollTop*h.y+f.y}}function Li(a){return Array.from(a.getClientRects())}function Xt(a,t){const e=mt(a).scrollLeft;return t?t.left+e:dt(B(a)).left+e}function Mi(a){const t=B(a),e=mt(a),i=a.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+Xt(a);const n=-e.scrollTop;return k(i).direction==="rtl"&&(o+=Z(t.clientWidth,i.clientWidth)-s),{width:s,height:r,x:o,y:n}}function Hi(a,t){const e=D(a),i=B(a),s=e.visualViewport;let r=i.clientWidth,o=i.clientHeight,n=0,l=0;if(s){r=s.width,o=s.height;const h=Mt();(!h||h&&t==="fixed")&&(n=s.offsetLeft,l=s.offsetTop)}return{width:r,height:o,x:n,y:l}}function Di(a,t){const e=dt(a,!0,t==="fixed"),i=e.top+a.clientTop,s=e.left+a.clientLeft,r=Y(a)?et(a):V(1),o=a.clientWidth*r.x,n=a.clientHeight*r.y,l=s*r.x,h=i*r.y;return{width:o,height:n,x:l,y:h}}function de(a,t,e){let i;if(t==="viewport")i=Hi(a,e);else if(t==="document")i=Mi(B(a));else if(F(t))i=Di(t,e);else{const s=he(a);i={...t,x:t.x-s.x,y:t.y-s.y}}return wt(i)}function fe(a,t){const e=z(a);return e===t||!F(e)||tt(e)?!1:k(e).position==="fixed"||fe(e,t)}function Xi(a,t){const e=t.get(a);if(e)return e;let i=Ht(a,[],!1).filter(n=>F(n)&&Q(n)!=="body"),s=null;const r=k(a).position==="fixed";let o=r?z(a):a;for(;F(o)&&!tt(o);){const n=k(o),l=Lt(o);!l&&n.position==="fixed"&&(s=null),(r?!l&&!s:!l&&n.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||ht(o)&&!l&&fe(a,o))?i=i.filter(f=>f!==o):s=n,o=z(o)}return t.set(a,i),i}function Fi(a){let{element:t,boundary:e,rootBoundary:i,strategy:s}=a;const o=[...e==="clippingAncestors"?yt(t)?[]:Xi(t,this._c):[].concat(e),i],n=o[0],l=o.reduce((h,f)=>{const d=de(t,f,s);return h.top=Z(d.top,h.top),h.right=at(d.right,h.right),h.bottom=at(d.bottom,h.bottom),h.left=Z(d.left,h.left),h},de(t,n,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function ki(a){const{width:t,height:e}=ce(a);return{width:t,height:e}}function Ni(a,t,e){const i=Y(t),s=B(t),r=e==="fixed",o=dt(a,!0,r,t);let n={scrollLeft:0,scrollTop:0};const l=V(0);if(i||!i&&!r)if((Q(t)!=="body"||ht(s))&&(n=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=Xt(s));let h=0,f=0;if(s&&!i&&!r){const u=s.getBoundingClientRect();f=u.top+n.scrollTop,h=u.left+n.scrollLeft-Xt(s,u)}const d=o.left+n.scrollLeft-l.x-h,x=o.top+n.scrollTop-l.y-f;return{x:d,y:x,width:o.width,height:o.height}}function Ft(a){return k(a).position==="static"}function xe(a,t){if(!Y(a)||k(a).position==="fixed")return null;if(t)return t(a);let e=a.offsetParent;return B(a)===e&&(e=e.ownerDocument.body),e}function ue(a,t){const e=D(a);if(yt(a))return e;if(!Y(a)){let s=z(a);for(;s&&!tt(s);){if(F(s)&&!Ft(s))return s;s=z(s)}return e}let i=xe(a,t);for(;i&&Ii(i)&&Ft(i);)i=xe(i,t);return i&&tt(i)&&Ft(i)&&!Lt(i)?e:i||Oi(a)||e}const Yi=async function(a){const t=this.getOffsetParent||ue,e=this.getDimensions,i=await e(a.floating);return{reference:Ni(a.reference,await t(a.floating),a.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function Ki(a){return k(a).direction==="rtl"}const Bi={convertOffsetParentRelativeRectToViewportRelativeRect:Ai,getDocumentElement:B,getClippingRect:Fi,getOffsetParent:ue,getElementRects:Yi,getClientRects:Li,getDimensions:ki,getScale:et,isElement:F,isRTL:Ki},ge=Ri,we=_i,pe=bi,Wi=Ci,ye=(a,t,e)=>{const i=new Map,s={platform:Bi,...e},r={...s.platform,_c:i};return Ei(a,t,{...s,platform:r})};let Pi=class{constructor(t){c(this,"ctx");c(this,"enable",!1);c(this,"contentEl");c(this,"floatingEl");c(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 n={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:n.background,backgroundColor:n.backgroundColor,transform:"rotate(45deg)",zIndex:n.zIndex};Object.assign(this.arrowEl.style,l),Object.assign(this.floatingEl.style,n),this.floatingEl.appendChild(this.contentEl),this.floatingEl.appendChild(this.arrowEl),this.ctx.targetContainer.appendChild(this.floatingEl),this.init()}init(){this.ctx.on("mousemove",t=>{const e=this.ctx.target.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.target.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(n=>{const{x:l,y:h,placement:f,middlewareData:d}=n;if(Object.assign(this.floatingEl.style,{top:`${h}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){c(this,"editorEl");c(this,"inputEl");c(this,"enable",!1);c(this,"cellTarget",null);c(this,"ctx");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("cellClick",t=>{var e,i;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.addEventListener("keydown",t=>{if(this.enable){if((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;return}(t.code==="Escape"||t.code==="Enter")&&(t.preventDefault(),this.inputEl.blur())}}),this.inputEl.addEventListener("blur",()=>{this.doneEdit()}),this.editorEl=document.createElement("div"),this.editorEl.className="e-virt-table-editor",this.inputEl.className="e-virt-table-editor-textarea",this.editorEl.appendChild(this.inputEl),this.ctx.targetContainer.appendChild(this.editorEl)}startEditByInput(t){if(t.editorType!=="text")return;const e=t.getValue(),{width:i}=t,s=t.getDrawX();let r=t.getDrawY(),{height:o}=t;t.height>this.ctx.body.visibleHeight&&(o=this.ctx.body.visibleHeight,r=this.ctx.header.visibleHeight);const{CELL_PADDING:n}=this.ctx.config;this.editorEl.style.left=`${s}px`,this.editorEl.style.top=`${r}px`,this.inputEl.style.minWidth=`${i-1}px`,this.inputEl.style.minHeight=`${o-1}px`,this.inputEl.style.width=`${i-1}px`,this.inputEl.style.height=`${o-1}px`,this.inputEl.style.padding=`${n}px`,e!==null&&(this.inputEl.value=e);const l=window.getSelection();l==null||l.selectAllChildren(this.inputEl),l==null||l.collapseToEnd(),this.inputEl.focus()}doneEditByInput(){if(!this.cellTarget||this.cellTarget.editorType!=="text")return;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="",this.editorEl.style.left="-10000px",this.editorEl.style.top="-10000px"}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(h=>h.rowIndex===t);if(!i)return;const s=i.cells.find(h=>h.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:n}=r,l=this.ctx.database.getReadonly(o,n);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.cellTarget&&(this.ctx.emit("doneEdit",this.cellTarget),this.doneEditByInput(),this.enable=!1,this.ctx.target.focus(),this.ctx.editing=!1,this.cellTarget=null,this.ctx.emit("draw"))}destroy(){}}class zi{constructor(t){c(this,"ctx");c(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.targetContainer.appendChild(this.emptyEl),this.ctx.on("emptyChange",({type:o,headerHeight:n,bodyHeight:l,footerHeight:h})=>{if(i)return;const f=n+(l+h)/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){c(this,"ctx");this.ctx=t,this.ctx.on("scroll",()=>{if(!this.ctx.config.ENABLE_HEADER_STICKY)return;const e=this.ctx.targetContainer.getBoundingClientRect();let i=!1,s=this.getHeader();e.top<0&&e.top<-this.ctx.header.visibleHeight&&e.top>-this.ctx.body.visibleHeight?i=!0:i=!1;const{config:{CSS_PREFIX:r}}=this.ctx,{visibleWidth:o}=this.ctx.body,n={type:"header-sticky",class:`${r}-overlayer-header-sticky`,style:{position:"sticky",top:"0px","z-index":10,width:`${o}px`,display:i?"block":"none"},views:s.views};this.ctx.emit("headerStickyChange",n)})}draw(){const t=this.getContainer();this.ctx.emit("overlayerChange",t)}destroy(){this.ctx.emit("overlayerChange",{style:{},views:[]})}getContainer(){const{target:t,config:{SCROLLER_TRACK_SIZE:e}}=this.ctx,i=t.width-e,s=t.height-e,r=this.getHeader(),o=this.getBody(),n=this.getFooter();let l=[r,o,n];const{FOOTER_FIXED:h}=this.ctx.config;return h||(l=[r,o]),{style:{position:"absolute",left:"0px",top:"0px",pointerEvents:"none",overflow:"hidden",width:`${i}px`,height:`${s}px`},views:l}}getHeader(){const{fixedLeftWidth:t,fixedRightWidth:e,config:{SCROLLER_TRACK_SIZE:i,CSS_PREFIX:s}}=this.ctx,{visibleWidth:r,visibleHeight:o,renderCellHeaders:n}=this.ctx.header;let l=[],h=[],f=[];n.forEach(w=>{w.render&&(w.fixed==="left"?h.push(w):w.fixed==="right"?f.push(w):l.push(w))});const d=e-i,x={key:"left",style:{position:"absolute",top:"0px",left:"0px",overflow:"hidden",width:`${t}px`,height:`${o}px`},cells:h},u={key:"center",style:{position:"absolute",top:"0px",left:`${t}px`,overflow:"hidden",width:`${r-t-d+1}px`,height:`${o}px`},cells:l},p={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,p]}}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(w=>{w.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:n,CSS_PREFIX:l}}=this.ctx,{visibleWidth:h,visibleHeight:f}=this.ctx.body,d=o-n,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:`${h-r-d}px`,height:`${f}px`},cells:t},p={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:`${h}px`,height:`${f}px`},views:[x,u,p]}}getFooter(){const t=[],e=[],i=[];this.ctx.footer.renderRows.forEach(g=>{g.cells.forEach(w=>{w.cellType==="footer"&&w.renderFooter&&(w.render=w.renderFooter,w.fixed==="left"?e.push(w):w.fixed==="right"?i.push(w):t.push(w))})});const{fixedLeftWidth:s,fixedRightWidth:r,config:{SCROLLER_TRACK_SIZE:o,CSS_PREFIX:n}}=this.ctx,{visibleWidth:l,visibleHeight:h}=this.ctx.footer,f=r-o,d={key:"left",style:{position:"absolute",top:`${.5}px`,left:`${.5}px`,overflow:"hidden",width:`${s}px`,height:`${h}px`},cells:e},x={key:"center",style:{position:"absolute",top:`${.5}px`,left:`${s+.5}px`,overflow:"hidden",width:`${l-s-f}px`,height:`${h}px`},cells:t},u={key:"right",style:{position:"absolute",top:`${.5}px`,right:`${.5}px`,overflow:"hidden",width:`${f}px`,height:`${h}px`},cells:i};return{type:"footer",class:`${n}-overlayer-footer`,style:{position:"relative",overflow:"hidden",width:`${l}px`,height:`${h}px`},views:[d,x,u]}}}class qi{constructor(t){c(this,"ctx");c(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,[n,l]=s,{rowIndex:h,colIndex:f}=t;h>=n&&h<=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:p})=>{this.show(u,p)})}),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.targetContainer.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){c(this,"targetContainer");c(this,"target");c(this,"options");c(this,"scroller");c(this,"header");c(this,"body");c(this,"footer");c(this,"selector");c(this,"autofill");c(this,"tooltip");c(this,"editor");c(this,"empty");c(this,"overlayer");c(this,"contextMenu");c(this,"ctx");this.target=document.createElement("canvas"),this.targetContainer=t,this.targetContainer.style.position="relative",this.targetContainer.appendChild(this.target),this.options=e,this.ctx=new ni(this.targetContainer,this.target,this.options),this.header=new ci(this.ctx),this.body=new li(this.ctx),this.footer=new hi(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.bind(this)),this.draw()}draw(){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(),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,i=!0){this.ctx.database.batchSetItemValue(t,e),i&&this.ctx.emit("draw")}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:n,key:l}=o;this.scrollToRowkey(n),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 n=0;n<s.length;n++){const l=this.ctx.database.getRowKeyByItem(i[o]),f=s[n].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"))})}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)}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")}getSelectionRows(){return this.ctx.database.getSelectionRows()}getPositionForRowIndex(t){return this.ctx.database.getPositionForRowIndex(t)}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.target.remove()}}return Gi});
18
17
  //# sourceMappingURL=index.umd.js.map