@jh-grid/jhgrid-js 0.1.0

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.
@@ -0,0 +1,149 @@
1
+ var JHGrid=(()=>{var de=Object.defineProperty;var ns=Object.getOwnPropertyDescriptor;var rs=Object.getOwnPropertyNames;var ls=Object.prototype.hasOwnProperty;var as=(r,t)=>{for(var e in t)de(r,e,{get:t[e],enumerable:!0})},cs=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of rs(t))!ls.call(r,i)&&i!==e&&de(r,i,{get:()=>t[i],enumerable:!(s=ns(t,i))||s.enumerable});return r};var hs=r=>cs(de({},"__esModule",{value:!0}),r);var Vs={};as(Vs,{BuiltinRenderers:()=>pt,CellEditors:()=>Ht,CellRenderers:()=>pt,DEFAULT_THEME:()=>Ut,DataManager:()=>Yt,GRID_CLASSES:()=>L,JA_I18N:()=>Jt,JHGrid:()=>Qt,KO_I18N:()=>qt,Renderer:()=>Gt,SUPPORTED_BROWSERS:()=>Ks,VERSION:()=>Gs,ZH_I18N:()=>Zt,computeHeaderCells:()=>Wt,registerCellEditor:()=>be,registerCellRenderer:()=>we});var Yt=class{#t;#e;#i;#o=new Map;#s=new Set;#n=new Set;#a=new Set;#l=0;#r=new Map;#c;#h;#d=!1;onChunkLoaded=null;onChunkError=null;constructor({fetchData:t,chunkSize:e=300,maxChunks:s=50,maxInFlight:i=2,maxQueued:o=4}){this.#t=t,this.#e=e,this.#i=s,this.#c=Math.max(1,i),this.#h=Math.max(1,o)}getRow(t){let e=Math.floor(t/this.#e);if(this.#o.has(e)){let s=this.#o.get(e);return this.#o.delete(e),this.#o.set(e,s),s[t%this.#e]??null}return this.#u(e),null}setRow(t,e){let s=Math.floor(t/this.#e),i=this.#o.get(s);i&&(i[t%this.#e]=e)}insertAt(t,e){let s=e,i=t;for(;s!==void 0;){let o=Math.floor(i/this.#e),n=this.#o.get(o);if(!n)break;let l=i%this.#e;if(l>n.length)break;let a=l<n.length?n[n.length-1]:void 0;for(let c=n.length-1;c>l;c--)n[c]=n[c-1];n[l]=s,s=a,i=(o+1)*this.#e}}prefetch(t,e){let s=Math.floor(t/this.#e),i=Math.floor(e/this.#e);for(let o=s;o<=i+1;o++)this.#u(o)}async loadAll(t,e){let s=Math.floor(t/this.#e),i=Math.floor(e/this.#e),o=[];for(let a=s;a<=i;a++)o.push(a);let n=0,l=async()=>{for(;n<o.length;)await this.#p(o[n++])};await Promise.all(Array.from({length:this.#c},l))}#u(t){if(!(this.#o.has(t)||this.#s.has(t)||this.#n.has(t))){for(this.#r.delete(t),this.#r.set(t,!0);this.#r.size>this.#h;)this.#r.delete(this.#r.keys().next().value);this.#_()}}setHold(t){let e=this.#d;this.#d=!!t,!(!e||this.#d)&&(this.#r.clear(),this.#_())}#_(){if(!this.#d)for(;this.#s.size<this.#c&&this.#r.size>0;){let t;for(let e of this.#r.keys())t=e;this.#r.delete(t),this.#p(t)}}setFetch(t){this.#t=t,this.#l++,this.clear()}async#p(t){if(this.#o.has(t)||this.#s.has(t)||this.#n.has(t))return;this.#s.add(t);let e=this.#l;try{let s;for(let i=0;i<3;i++){if(e!==this.#l)return;try{let{rows:o}=await this.#t(t,this.#e);if(e!==this.#l)return;if(!Array.isArray(o))throw new TypeError("fetchData must resolve { rows: [] }");this.#o.set(t,o),this.#g(),this.onChunkLoaded?.();return}catch(o){if(s=o,o instanceof TypeError)break;i<2&&await new Promise(n=>setTimeout(n,500*2**i))}}if(e===this.#l){console.error(`[DataManager] chunk ${t} failed after retries:`,s),this.onChunkError?.(s,t),this.#n.add(t);let i=setTimeout(()=>{this.#n.delete(t),this.#a.delete(i)},5e3);this.#a.add(i)}}finally{this.#s.delete(t),this.#_()}}#g(){for(;this.#o.size>this.#i;){let t=this.#o.keys().next().value;this.#o.delete(t)}}forEachLoaded(t){for(let[e,s]of[...this.#o]){let i=e*this.#e;for(let o=0;o<s.length;o++)if(t(s[o],i+o)===!1)return}}clear(){this.#o.clear(),this.#s.clear(),this.#r.clear(),this.#n.clear(),this.#a.forEach(clearTimeout),this.#a.clear()}};function ue(r){return r==null?[]:Array.isArray(r)?r:[r]}function Me(r,t,e,s){if(t===e)return;let i=0;for(;i<r.length;){let o=r[i],n=o._path[t];if(n===void 0){s[t].push({label:o.label??o.field,fields:[o.field],rowspan:e+1-t}),i++;continue}let l=i+1;for(;l<r.length&&r[l]._path[t]===n;)l++;let a=r.slice(i,l);s[t].push({label:n,fields:a.map(c=>c.field)}),Me(a,t+1,e,s),i=l}}function Te(r){let t=(r??[]).map(i=>({field:i.field,label:i.label,_path:ue(i.group)})),e=Math.max(0,...t.map(i=>i._path.length));if(e===0)return null;let s=Array.from({length:e},()=>[]);return Me(t,0,e,s),s}function ds(r){let t="";for(let e=r+1;e>0;){let s=(e-1)%26;t=String.fromCharCode(65+s)+t,e=Math.floor((e-1)/26)}return t}function Wt(r,t,e=!1){let s=t.length,i=r?.length??0,o=e?1:0,n=i+1+o,l=Array.from({length:n},()=>new Array(s).fill(!1)),a=[];if(e)for(let h=0;h<s;h++)a.push({row:0,col:h,colspan:1,rowspan:1,label:ds(h),align:"center",isLeaf:!1,isColLetter:!0});for(let h=0;h<i;h++){let _=h+o,f=0;for(let d of r[h]??[]){let{label:u="",fields:p,colspan:w,rowspan:m=1,align:C="center"}=d,S=Math.min(m,n-_),y;if(p){let v=p.map(x=>t.indexOf(x)).filter(x=>x>=0).sort((x,B)=>x-B);y=[];for(let x of v){let B=y[y.length-1];B&&B.start+B.length===x?B.length++:y.push({start:x,length:1})}}else{for(;f<s&&l[_][f];)f++;if(f>=s)continue;y=[{start:f,length:Math.min(w??1,s-f)}],f+=y[0].length}for(let{start:v,length:x}of y){let B=x;for(let W=0;W<S;W++)for(let M=0;M<B;M++)_+W<n&&(l[_+W][v+M]=!0);a.push({row:_,col:v,colspan:B,rowspan:S,label:u,align:C,isLeaf:_+S>=n})}}}let c=i+o;for(let h=0;h<s;h++)l[c][h]||a.push({row:c,col:h,colspan:1,rowspan:1,label:null,align:null,isLeaf:!0});return a}function ee(r,t,e){let{frozenCount:s,frozenWidth:i,frozenRightCount:o=0,rightX:n,colPositions:l}=t;if(r<s)return l[r];let a=l.length-1;if(o>0&&r>=a-o){let c=a-o;return n+l[r]-l[c]}return i+l[r]-l[s]-e}var Pt=new Map,_e=[],fe=0,pe=new Set;function us(){for(let r of pe)try{r()}catch(t){console.error("[JHGrid] image cache load listener error:",t)}}function _s(r){return r.width*r.height*4}function fs(){let r=0;for(let t of Pt.values())r+=t.bytes;if(!(r<=52428800))for(let[t,e]of Pt){if(r<=52428800)break;e.status!=="loading"&&(Pt.delete(t),r-=e.bytes)}}function ps(r){let t=Pt.get(r);return t&&(Pt.delete(r),Pt.set(r,t)),t}function gs(r,t,e){return new Promise((s,i)=>{let o=new Image;o.crossOrigin="anonymous",o.onload=()=>createImageBitmap(o,{resizeWidth:t,resizeHeight:e,resizeQuality:"medium"}).then(s,i),o.onerror=()=>i(new Error(`[JHGrid] image cache: failed to load ${r}`)),o.src=r})}async function ms(r,t,e){let s=typeof window<"u"&&window.devicePixelRatio||1,i=Math.max(24,Math.min(256,Math.round(t*s))),o=Math.max(24,Math.min(256,Math.round(e*s)));try{let n;try{let l=await fetch(r);if(!l.ok)throw new Error(`HTTP ${l.status}`);let a=await l.blob();n=await createImageBitmap(a,{resizeWidth:i,resizeHeight:o,resizeQuality:"medium"})}catch{n=await gs(r,i,o)}Pt.set(r,{status:"loaded",bitmap:n,bytes:_s(n)}),fs()}catch(n){console.error("[JHGrid] image cache decode error:",n),Pt.set(r,{status:"error",bitmap:null,bytes:0})}finally{fe--,us(),ke()}}function ke(){for(;fe<6&&_e.length>0;){let{url:r,w:t,h:e}=_e.shift(),s=Pt.get(r);!s||s.status!=="loading"||(fe++,ms(r,t,e))}}function De(r,t,e){if(!r)return null;let s=ps(r);if(s)return s;let i={status:"loading",bitmap:null,bytes:0};return Pt.set(r,i),_e.push({url:r,w:t,h:e}),ke(),i}function $e(r){pe.add(r)}function Le(r){pe.delete(r)}var Bt=20,ie=18,me=16,se=20,Ut={headerBg:"#E8E8E8",headerText:"#3D3D3D",headerBorder:"#C0C0C0",rowEven:"#FFFFFF",rowOdd:"#FFFFFF",cellBorder:"#D9D9D9",cellText:"#212121",loadingText:"#BFBFBF",skeletonBar:"#E4E7EB",skeletonSheen:"rgba(255,255,255,0.65)",cellPadding:10,selectionColor:"#2E75B6",selectionFill:"rgba(46,117,182,0.10)",selRowBg:"rgba(46,117,182,0.12)",hoverRowBg:"rgba(0,0,0,0.045)",scrollbarBg:"#F0F0F0",scrollbarThumb:"#C0C0C0",scrollbarRadius:4,frozenBorder:"#B0B0B0",hiddenColIndicator:"#94A3B8",groupHeaderBg:"#EEF2F7",groupHeaderText:"#1E293B",footerBg:"#F2F2F2",footerText:"#1E293B",filterIconBg:"rgba(245,158,11,0.18)",sortIconBg:"rgba(46,117,182,0.12)",filterIconColor:"#C87B00",sortIconColor:"#2E75B6",headerIconColor:"rgba(0,0,0,0.28)",dragIndicatorFill:"rgba(59,130,246,0.12)",dragIndicatorLine:"#3b82f6",dragGhostShadow:"rgba(15,23,42,0.30)",deletedRowFill:"rgba(239,68,68,0.10)",deletedRowStrike:"rgba(239,68,68,0.55)",invalidCellBorder:"#dc2626",fontSize:13,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',locale:"en-US",overlayBg:"#FFFFFF",overlayBorder:"#D0D0D0",overlayHeaderBg:"#F5F5F5",overlayDivider:"#E0E0E0",overlayText:"#212121",overlayMutedText:"#595959",overlayHintText:"#909090",overlayHoverBg:"#F5F5F5",overlayItemHoverBg:"#F0F0F0",overlayShadow:"0 4px 16px rgba(0,0,0,0.15)",overlayMenuShadow:"0 4px 12px rgba(0,0,0,0.15)",overlayAccentText:"#FFFFFF",pagerBg:"#f8fafc",pagerBorder:"#e2e8f0",pagerText:"#1e293b",pagerButtonBg:"#ffffff",pagerButtonBorder:"#cbd5e1",readonlyCellBg:"#F5F5F5",editableCellBg:void 0,imagePlaceholderBg:"#F1F5F9",imageErrorBg:"#FEE2E2",imageErrorIcon:"#DC2626"},pt={richtext(){return(r,{x:t,y:e,w:s,h:i,value:o,theme:n,padding:l})=>{if(o==null||o==="")return;let a=ys(String(o));if(!a.length)return;r.textAlign="left",r.textBaseline="middle",r.fillStyle=n.cellText,r.save(),r.beginPath(),r.rect(t,e,s,i),r.clip();let c=t+l,h=e+i/2;for(let _ of a){r.font=`${_.italic?"italic ":""}${_.bold?"bold ":""}${n.fontSize}px ${n.fontFamily}`,r.fillText(_.text,c,h);let f=r.measureText(_.text).width;if(_.underline||_.strike){r.strokeStyle=n.cellText,r.lineWidth=1;let d=_.underline?h+n.fontSize/2-1:h;r.beginPath(),r.moveTo(c,d),r.lineTo(c+f,d),r.stroke()}c+=f}r.restore()}},tree({indentPx:r=ie,inner:t}={}){let e=(s,{x:i,y:o,w:n,h:l,value:a,theme:c,padding:h})=>{s.fillStyle=a!=null?c.cellText:c.loadingText,s.textAlign="left",s.textBaseline="middle",s.save(),s.beginPath(),s.rect(i,o,n,l),s.clip(),s.fillText(a!=null?String(a):"",i+h,o+l/2),s.restore()};return(s,i)=>{let{x:o,y:n,w:l,h:a,rowData:c,theme:h}=i;if(!c?.__tree__){(t??e)(s,i);return}let _=(c.__treeLevel??0)*r,f=o+_+me;c.__treeHasChildren&&(s.fillStyle=h.cellText,s.font=`${h.fontSize}px ${h.fontFamily}`,s.textAlign="left",s.textBaseline="middle",s.fillText(c.__treeExpanded?"\u25BE":"\u25B8",o+_,n+a/2)),(t??e)(s,{...i,x:f,w:o+l-f})}},progressBar({max:r=100,showLabel:t=!0}={}){return(e,{x:s,y:i,w:o,h:n,value:l,theme:a,padding:c})=>{let h=Number(l);if(isNaN(h))return;let _=Math.max(0,Math.min(1,h/r)),f=t?36:0,d=s+c,u=Math.max(0,o-c*2-f),p=6,w=i+(n-p)/2,m=3;if(e.fillStyle="#e2e8f0",e.beginPath(),e.roundRect?e.roundRect(d,w,u,p,m):e.rect(d,w,u,p),e.fill(),_>0){e.fillStyle=_>=.8?"#16a34a":_>=.5?"#f59e0b":"#ef4444",e.beginPath();let C=Math.max(m*2,u*_);e.roundRect?e.roundRect(d,w,C,p,m):e.rect(d,w,C,p),e.fill()}t&&(e.fillStyle=a.cellText,e.font=`${a.fontSize}px ${a.fontFamily}`,e.textAlign="right",e.textBaseline="middle",e.fillText(`${Math.round(_*100)}%`,s+o-c,i+n/2))}},badge({colorMap:r={}}={}){return(t,{x:e,y:s,w:i,h:o,value:n,theme:l})=>{if(n==null||n==="")return;let a=String(n),{bg:c="#f1f5f9",fg:h="#475569"}=r[a]??{},_=8;t.font=`${l.fontSize-1}px ${l.fontFamily}`;let f=t.measureText(a).width,d=Math.min(f+_*2,i-8),u=o-10,p=e+(i-d)/2,w=s+5,m=u/2;t.fillStyle=c,t.beginPath(),t.roundRect?t.roundRect(p,w,d,u,m):t.rect(p,w,d,u),t.fill(),t.fillStyle=h,t.textAlign="center",t.textBaseline="middle",t.fillText(a,e+i/2,s+o/2)}},checkmark({trueColor:r="#16a34a",falseColor:t="#94a3b8",showFalse:e=!0}={}){return(s,{x:i,y:o,w:n,h:l,value:a,theme:c})=>{let h=a===!0||a===1||a==="Y"||a==="\uC608"||a==="true";!h&&!e||(s.fillStyle=h?r:t,s.font=`bold ${c.fontSize+1}px ${c.fontFamily}`,s.textAlign="center",s.textBaseline="middle",s.fillText(h?"\u2713":"\u2717",i+n/2,o+l/2))}},image({fit:r="cover",radius:t=0}={}){return(e,{x:s,y:i,w:o,h:n,value:l,theme:a,padding:c})=>{if(!l)return;let h=s+c,_=i+c,f=o-c*2,d=n-c*2;if(f<=0||d<=0)return;let u=De(String(l),f,d);if(e.save(),e.beginPath(),t>0&&e.roundRect?e.roundRect(h,_,f,d,t):e.rect(h,_,f,d),e.clip(),u?.status==="loaded"&&u.bitmap){let p=u.bitmap,w=r==="contain"?Math.min(f/p.width,d/p.height):Math.max(f/p.width,d/p.height),m=p.width*w,C=p.height*w;e.drawImage(p,h+(f-m)/2,_+(d-C)/2,m,C)}else u?.status==="error"?(e.fillStyle=a.imageErrorBg,e.fillRect(h,_,f,d),e.strokeStyle=a.imageErrorIcon,e.lineWidth=1.5,e.beginPath(),e.moveTo(h+f*.3,_+d*.3),e.lineTo(h+f*.7,_+d*.7),e.moveTo(h+f*.7,_+d*.3),e.lineTo(h+f*.3,_+d*.7),e.stroke()):(e.fillStyle=a.imagePlaceholderBg,e.fillRect(h,_,f,d));e.restore()}},number({locale:r,decimals:t=0}={}){let e,s;return(i,{x:o,y:n,w:l,h:a,value:c,theme:h,padding:_})=>{let f=r??h.locale;(e===void 0||s!==f)&&(e=new Intl.NumberFormat(f,{minimumFractionDigits:t,maximumFractionDigits:t}),s=f);let d=Number(c);if(c==null||c===""||isNaN(d))return;let u=e.format(d);i.fillStyle=h.cellText,i.font=`${h.fontSize}px ${h.fontFamily}`,i.textAlign="right",i.textBaseline="middle",i.save(),i.beginPath(),i.rect(o,n,l,a),i.clip(),i.fillText(u,o+l-_,n+a/2),i.restore()}},date({format:r="YYYY-MM-DD",locale:t,dateStyle:e,align:s="left"}={}){let i,o;return(n,{x:l,y:a,w:c,h,value:_,theme:f,padding:d})=>{if(_==null||_==="")return;let u=_ instanceof Date?_:typeof _=="number"?new Date(_):new Date(String(_)),p=String(_);if(!isNaN(u.getTime()))if(r==="locale"){let m=t??f.locale;(i===void 0||o!==m)&&(i=new Intl.DateTimeFormat(m,e?{dateStyle:e}:void 0),o=m),p=i.format(u)}else{let m=String(u.getFullYear()).padStart(4,"0"),C=String(u.getMonth()+1).padStart(2,"0"),S=String(u.getDate()).padStart(2,"0"),y=String(u.getHours()).padStart(2,"0"),v=String(u.getMinutes()).padStart(2,"0"),x=String(u.getSeconds()).padStart(2,"0"),B=m.slice(-2);p=r.replace("YYYY",m).replace("YY",B).replace("MM",C).replace("DD",S).replace("HH",y).replace("mm",v).replace("ss",x)}let w=s==="right"?l+c-d:s==="center"?l+c/2:l+d;n.fillStyle=f.cellText,n.font=`${f.fontSize}px ${f.fontFamily}`,n.textAlign=s,n.textBaseline="middle",n.save(),n.beginPath(),n.rect(l,a,c,h),n.clip(),n.fillText(p,w,a+h/2),n.restore()}},currency({locale:r,currency:t="KRW"}={}){let e,s;return(i,{x:o,y:n,w:l,h:a,value:c,theme:h,padding:_})=>{let f=r??h.locale;(e===void 0||s!==f)&&(e=new Intl.NumberFormat(f,{style:"currency",currency:t}),s=f);let d=Number(c);if(c==null||c===""||isNaN(d))return;let u=e.format(d);i.fillStyle=h.cellText,i.font=`${h.fontSize}px ${h.fontFamily}`,i.textAlign="right",i.textBaseline="middle",i.save(),i.beginPath(),i.rect(o,n,l,a),i.clip(),i.fillText(u,o+l-_,n+a/2),i.restore()}},dropdown({placeholder:r=""}={}){let t=se;return(e,{x:s,y:i,w:o,h:n,value:l,theme:a,padding:c})=>{let h=l!=null&&l!==""?String(l):r;e.font=`${a.fontSize}px ${a.fontFamily}`,e.textBaseline="middle",e.fillStyle=l!=null&&l!==""?a.cellText:a.loadingText,e.textAlign="left",e.save(),e.beginPath(),e.rect(s,i,o-t,n),e.clip(),e.fillText(h,s+c,i+n/2),e.restore(),e.fillStyle="rgba(0,0,0,0.06)",e.fillRect(s+o-t,i+1,t-1,n-2),e.fillStyle=a.headerText??a.cellText,e.font=`11px ${a.fontFamily}`,e.textAlign="center",e.fillText("\u25BE",s+o-t/2,i+n/2)}},multiselect({placeholder:r=""}={}){let t=se;return(e,{x:s,y:i,w:o,h:n,value:l,theme:a,padding:c})=>{let h=l!=null&&l!==""?String(l):r;e.font=`${a.fontSize}px ${a.fontFamily}`,e.textBaseline="middle",e.fillStyle=l!=null&&l!==""?a.cellText:a.loadingText,e.textAlign="left",e.save(),e.beginPath(),e.rect(s,i,o-t,n),e.clip(),e.fillText(h,s+c,i+n/2),e.restore(),e.fillStyle="rgba(0,0,0,0.06)",e.fillRect(s+o-t,i+1,t-1,n-2),e.fillStyle=a.headerText??a.cellText,e.font=`11px ${a.fontFamily}`,e.textAlign="center",e.fillText("\u25BE",s+o-t/2,i+n/2)}},checkbox({checkedColor:r="#2563eb",size:t=14}={}){return(e,{x:s,y:i,w:o,h:n,value:l})=>{let a=l===!0||l===1||l==="true"||l==="1"||l==="Y"||l==="yes",c=s+(o-t)/2,h=i+(n-t)/2,_=3;e.beginPath(),e.roundRect?e.roundRect(c,h,t,t,_):e.rect(c,h,t,t),a?(e.fillStyle=r,e.fill(),e.strokeStyle="#fff",e.lineWidth=1.8,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(c+3,h+t/2),e.lineTo(c+t/2-1,h+t-4),e.lineTo(c+t-3,h+3.5),e.stroke()):(e.fillStyle="#fff",e.fill(),e.strokeStyle="#C0C0C0",e.lineWidth=1.5,e.stroke())}},button({label:r="Button",disabled:t=!1,variant:e="primary"}={}){let s={primary:"#2563eb",success:"#16a34a",danger:"#dc2626",neutral:"#64748b"};return(i,{x:o,y:n,w:l,h:a,theme:c,rowData:h,rowIndex:_})=>{let f=typeof r=="function"?r(h,_):r;if(f==null||f==="")return;let d=typeof t=="function"?!!t(h,_):!!t,u=typeof e=="function"?e(h,_):e;i.font=`${c.fontSize-1}px ${c.fontFamily}`;let p=i.measureText(f).width,w=Math.min(a-8,24),m=Math.min(l-8,p+24);if(m<=0||w<=0)return;let C=o+(l-m)/2,S=n+(a-w)/2;i.beginPath(),i.roundRect?i.roundRect(C,S,m,w,w/2):i.rect(C,S,m,w),i.fillStyle=d?"#cbd5e1":s[u]??s.primary,i.fill(),i.fillStyle="#ffffff",i.textAlign="center",i.textBaseline="middle",i.fillText(f,C+m/2,S+w/2)}}},ws=new Set(Object.keys(pt));function we(r,t){ws.has(r)&&console.warn(`[JHGrid] registerCellRenderer: "${r}" is a built-in renderer name and will be overwritten`),pt[r]=t}var ge=/<\/?(b|i|u|s)>/g;function ys(r){let t=[],e={bold:!1,italic:!1,underline:!1,strike:!1},s=l=>l.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),i=l=>{l&&t.push({text:s(l),...e})};ge.lastIndex=0;let o=0,n;for(;n=ge.exec(r);){i(r.slice(o,n.index)),o=ge.lastIndex;let l=n[0][1]==="/",a={b:"bold",i:"italic",u:"underline",s:"strike"}[n[1]];e[a]=!l}return i(r.slice(o)),t}var Gt=class r{#t;#e;constructor(t,e){this.#t=t.getContext("2d"),this.#e=e}render({scrollTop:t,scrollLeft:e,totalRows:s,columns:i,columnLabels:o,columnAligns:n,columnHeaderAligns:l,getRow:a,geo:c,rowLayout:h,sel:_,editing:f,headerFocusCol:d,rowFocus:u,colDrag:p,rowDrag:w,sorts:m,filters:C,columnRenderers:S,invalidCells:y,selectedRows:v,fillPreview:x,deletedRows:B,skeletonPhase:W,rowNumberLabel:M,grouping:U,groupFooter:z,hiddenNeighbors:K,editableColumns:H,i18n:I,headerCheckboxCols:E,hoverRow:R=null,selAnim:F=null,colSlide:Q=null,remoteSelections:A=null}){let{headerHeight:O,theme:D}=this.#e,{headerRows:T}=this.#e,{width:k,height:P}=this.#e,g=this.#t,{vpH:V,vpW:J,SB:lt,vSB:nt=lt,hSB:et=lt,frozenCount:q=0,frozenWidth:N=0,frozenRightCount:j=0,frozenRightWidth:ft=0,rightX:it=0,colPositions:X,headerH:G,footerH:Ct=0,maxRow:At,rowNumW:Mt=0}=c,yt=o??i,$=i.length,st=_,ot=F?.prev?{prev:F.prev,t:F.t}:null;g.fillStyle=D.rowEven,g.fillRect(0,0,k,P);let ct=At??s-1,ht=Math.max(0,h.rowAt(t,ct)),ut=h.rowAt(t+V,ct),wt=ut<0?ct:Math.min(ct,ut+1),Et=$-1-j,$t=X[q],Tt=q;for(;Tt<Et&&X[Tt+1]-$t<=e;)Tt++;let Rt=Tt;for(;Rt<Et&&X[Rt]-$t<e+J;)Rt++;if(Rt=Math.min(Et,Rt+1),g.save(),g.beginPath(),g.rect(N,G,J,V),g.clip(),this.#l(ht,wt,Tt,Rt,t,e,i,n,a,h,G,D,q,N,j,it,X,S,y,v,B,H,R,W),g.restore(),q>0&&(g.save(),g.beginPath(),g.rect(0,G,N,V),g.clip(),this.#l(ht,wt,0,q-1,t,e,i,n,a,h,G,D,q,N,j,it,X,S,y,v,B,H,R,W),g.restore()),j>0&&(g.save(),g.beginPath(),g.rect(it,G,ft,V),g.clip(),this.#l(ht,wt,$-j,$-1,t,e,i,n,a,h,G,D,q,N,j,it,X,S,y,v,B,H,R,W),g.restore()),st){let Y=gt=>gt.type==="single"?gt.col:gt.c1,tt=gt=>gt.type==="single"?gt.col:gt.c2,rt=ot?.prev,Z=rt?Math.min(Y(st),Y(rt)):Y(st),_t=rt?Math.max(tt(st),tt(rt)):tt(st);q>0&&Z<q&&(g.save(),g.beginPath(),g.rect(0,G,N,V),g.clip(),this.#c(st,f,t,e,h,G,D,q,N,j,it,X,ot),g.restore()),_t>=q&&Z<$-j&&(g.save(),g.beginPath(),g.rect(N,G,J,V),g.clip(),this.#c(st,f,t,e,h,G,D,q,N,j,it,X,ot),g.restore()),j>0&&_t>=$-j&&(g.save(),g.beginPath(),g.rect(it,G,ft,V),g.clip(),this.#c(st,f,t,e,h,G,D,q,N,j,it,X,ot),g.restore())}if(A&&A.length)for(let Y of A){let tt=Y.sel;if(!tt)continue;let rt=tt.type==="single"?tt.col:tt.c1,Z=tt.type==="single"?tt.col:tt.c2;q>0&&rt<q&&(g.save(),g.beginPath(),g.rect(0,G,N,V),g.clip(),this.#h(tt,Y.color,Y.label,t,e,h,G,q,N,j,it,X),g.restore()),Z>=q&&rt<$-j&&(g.save(),g.beginPath(),g.rect(N,G,J,V),g.clip(),this.#h(tt,Y.color,Y.label,t,e,h,G,q,N,j,it,X),g.restore()),j>0&&Z>=$-j&&(g.save(),g.beginPath(),g.rect(it,G,ft,V),g.clip(),this.#h(tt,Y.color,Y.label,t,e,h,G,q,N,j,it,X),g.restore())}if(v&&v.size>0){let Y=k-nt,tt=Math.max(0,X[$-j]-N-e),rt=Math.min(Y,N+Math.min(J,tt)+ft);g.save(),g.beginPath(),g.rect(0,G,rt,V),g.clip(),g.strokeStyle=D.selectionColor,g.lineWidth=2;for(let Z=ht;Z<=wt;Z++){if(!v.has(Z)||Z>ht&&v.has(Z-1))continue;let _t=Z;for(;_t<wt&&v.has(_t+1);)_t++;let gt=v.has(Z-1)?G-4:h.yOf(Z)-t+G,Dt=v.has(_t+1)?G+V+4:h.yOf(_t)-t+G+h.heightOf(_t);g.strokeRect(1,gt+1,rt-2,Dt-gt-2),Z=_t}g.restore()}if(g.save(),g.beginPath(),g.rect(N,0,J,G),g.clip(),this.#a(yt,l??n,i,m,C,Tt,Rt,e,G,O,T,D,q,N,j,it,X,K,E,_),g.restore(),q>0&&(g.save(),g.beginPath(),g.rect(0,0,N,G),g.clip(),this.#a(yt,l??n,i,m,C,0,q-1,e,G,O,T,D,q,N,j,it,X,K,E,_),g.restore()),j>0&&(g.save(),g.beginPath(),g.rect(it,0,ft,G),g.clip(),this.#a(yt,l??n,i,m,C,$-j,$-1,e,G,O,T,D,q,N,j,it,X,K,E,_),g.restore()),q>0){g.strokeStyle=D.frozenBorder,g.lineWidth=2,g.beginPath();let Y=Math.round(N)+.5;g.moveTo(Y,0),g.lineTo(Y,P-et),g.stroke()}if(j>0){g.strokeStyle=D.frozenBorder,g.lineWidth=2,g.beginPath();let Y=Math.round(it)+.5;g.moveTo(Y,0),g.lineTo(Y,P-et),g.stroke()}if(d!=null&&d>=0&&d<i.length){let Y=d<q,tt=j>0&&d>=$-j,rt=this.#n(d,q,N,j,it,e,X),Z=X[d+1]-X[d];g.save(),g.beginPath(),Y?g.rect(0,0,N,G):tt?g.rect(it,0,ft,G):g.rect(N,0,J,G),g.clip(),g.strokeStyle=D.selectionColor,g.lineWidth=2,g.strokeRect(rt+1,1,Math.max(0,Z-2),Math.max(0,G-2)),g.restore()}if(u!=null&&Mt>0){let Y=h.yOf(u)-t+G,tt=h.heightOf(u);Y+tt>G&&Y<P-et&&(g.save(),g.beginPath(),g.rect(0,G,Mt,V),g.clip(),g.strokeStyle=D.selectionColor,g.lineWidth=2,g.strokeRect(1,Y+1,Math.max(0,Mt-2),Math.max(0,tt-2)),g.restore())}if(_&&!f){let tt=_.type==="single"?_.row:_.r2,rt=_.type==="single"?_.col:_.c2,Z=this.#n(rt,q,N,j,it,e,X)+(X[rt+1]-X[rt]),_t=h.yOf(tt+1)-t+G;Z>=N-7&&Z<=k-nt+7&&_t>=G&&_t<=P-et+7&&(g.fillStyle=D.selectionColor,g.fillRect(Math.round(Z)-7/2,Math.round(_t)-7/2,7,7))}if(x){let{r1:Y,c1:tt,r2:rt,c2:Z}=x,_t=this.#n(tt,q,N,j,it,e,X),gt=h.yOf(Y)-t+G,Dt=this.#n(Z,q,N,j,it,e,X)+(X[Z+1]-X[Z])-_t,bt=h.yOf(rt+1)-h.yOf(Y);g.fillStyle=D.selectionFill,g.fillRect(_t,gt,Dt,bt),g.setLineDash([4,3]),g.strokeStyle=D.selectionColor,g.lineWidth=2,g.strokeRect(_t+1,gt+1,Dt-2,bt-2),g.setLineDash([])}if(Q&&Q.c1>=0&&Q.c2<$&&Q.dragCol>=0&&Q.dragCol<$&&Q.dx!==0){let{c1:Y,c2:tt,dx:rt,dragCol:Z}=Q,_t=Math.min(Y,Z),gt=Math.max(tt,Z),Dt=It=>this.#n(It,q,N,j,it,e,X),bt=Math.max(0,Dt(_t)),Ft=Math.min(k-nt,Dt(gt)+(X[gt+1]-X[gt])),zt=(It,te,Vt)=>{g.save(),g.translate(Vt,0),this.#l(ht,wt,It,te,t,e,i,n,a,h,G,D,q,N,j,it,X,S,y,v,B,H,R,W),this.#a(yt,l??n,i,m,C,It,te,e,G,O,T,D,q,N,j,it,X,K,E,_),g.restore()};Ft>bt&&(g.save(),g.beginPath(),g.rect(bt,0,Ft-bt,P-et),g.clip(),g.fillStyle=D.headerBg,g.fillRect(bt,0,Ft-bt,G),g.fillStyle=D.rowEven,g.fillRect(bt,G,Ft-bt,P-et-G),zt(Y,tt,rt),zt(Z,Z,0),g.restore())}if(p?.active){let{col:Y,insertBefore:tt}=p,rt=this.#n(Y,q,N,j,it,e,X),Z=X[Y+1]-X[Y];g.fillStyle=D.dragIndicatorFill,g.fillRect(rt,0,Z,P-et);let _t=i.length,gt=tt<_t?this.#n(tt,q,N,j,it,e,X):this.#n(_t-1,q,N,j,it,e,X)+(X[_t]-X[_t-1]);if(g.strokeStyle=D.dragIndicatorLine,g.lineWidth=3,g.beginPath(),g.moveTo(gt,0),g.lineTo(gt,P-et),g.stroke(),p.x!==void 0){let Dt=O,bt=G-O,Ft=Math.max(0,Math.min(k-nt-Z,p.x-p.grabDX));g.save(),g.globalAlpha=.92,g.shadowColor=D.dragGhostShadow,g.shadowBlur=8,g.shadowOffsetY=2,g.fillStyle=D.headerBg,g.fillRect(Ft,bt,Z,Dt),g.restore(),g.save(),g.beginPath(),g.rect(Ft,bt,Z,Dt),g.clip(),g.globalAlpha=.92,g.strokeStyle=D.dragIndicatorLine,g.lineWidth=1,g.strokeRect(Ft+.5,bt+.5,Z-1,Dt-1),g.font=`bold ${D.headerFontSize??D.fontSize}px ${D.fontFamily}`,g.fillStyle=D.headerText,g.textAlign="left",g.textBaseline="middle",g.fillText(this.#f(String(yt[Y]??i[Y]??""),Z-D.cellPadding*2),Ft+D.cellPadding,bt+Dt/2),g.restore()}}if(w?.active){let{row:Y,insertBefore:tt}=w,rt=h.yOf(Y)-t+G;g.fillStyle=D.dragIndicatorFill,g.fillRect(0,rt,k-nt,h.heightOf(Y));let Z=h.yOf(tt)-t+G;g.strokeStyle=D.dragIndicatorLine,g.lineWidth=3,g.beginPath(),g.moveTo(0,Z),g.lineTo(k-nt,Z),g.stroke()}if(U){let{rowNumW:Y}=c;this.#o(ht,wt,t,h,G,D,k,nt,Y,a,i,o??i,I)}let{rowNumW:kt}=c;if(kt>0&&this.#i(ht,wt,t,h,kt,P,G,et,D,M,v,R),z&&Ct>0){let Y=P-et-Ct;g.save(),g.beginPath(),g.rect(N,Y,J,Ct),g.clip(),this.#s(z,i,n,Tt,Rt,e,Y,Ct,D,q,N,j,it,X,I),g.restore(),q>0&&(g.save(),g.beginPath(),g.rect(0,Y,N,Ct),g.clip(),this.#s(z,i,n,0,q-1,e,Y,Ct,D,q,N,j,it,X,I),g.restore()),j>0&&(g.save(),g.beginPath(),g.rect(it,Y,ft,Ct),g.clip(),this.#s(z,i,n,$-j,$-1,e,Y,Ct,D,q,N,j,it,X,I),g.restore())}this.#d(c,D,k,P)}#i(t,e,s,i,o,n,l,a,c,h,_,f){let d=this.#t;d.save(),d.beginPath(),d.rect(0,0,o,n-a),d.clip(),d.fillStyle=c.headerBg,d.fillRect(0,0,o,l),d.font=`bold ${c.headerFontSize??c.fontSize}px ${c.fontFamily}`,d.fillStyle=c.headerText,d.textAlign="center",d.textBaseline="middle",d.fillText(h??"No.",o/2,l/2),d.textAlign="center",d.textBaseline="middle",d.save(),d.beginPath(),d.rect(0,l,o,Math.max(0,n-a-l)),d.clip();for(let u=t;u<=e;u++){let p=i.yOf(u)-s+l,w=i.heightOf(u),m=_?.has(u);d.fillStyle=c.headerBg,d.fillRect(0,p,o,w),m&&(d.fillStyle=c.selectionColor,d.globalAlpha=.28,d.fillRect(0,p,o,w),d.globalAlpha=1),f&&f.row===u&&f.alpha>0&&c.hoverRowBg&&(d.globalAlpha=Math.min(1,f.alpha),d.fillStyle=c.hoverRowBg,d.fillRect(0,p,o,w),d.globalAlpha=1),d.font=m?`bold ${c.fontSize-1}px ${c.fontFamily}`:`${c.fontSize-1}px ${c.fontFamily}`,d.fillStyle=m?c.sortIconColor??c.selectionColor:c.headerText,d.fillText(String(u+1),o/2,p+w/2),d.strokeStyle=c.headerBorder,d.lineWidth=1,d.beginPath(),d.moveTo(0,Math.round(p+w)-.5),d.lineTo(o,Math.round(p+w)-.5),d.stroke()}d.restore(),d.strokeStyle=c.headerBorder,d.lineWidth=1,d.beginPath(),d.moveTo(0,l-.5),d.lineTo(o,l-.5),d.stroke(),d.strokeStyle=c.frozenBorder??c.headerBorder,d.lineWidth=1.5,d.beginPath(),d.moveTo(o-.5,0),d.lineTo(o-.5,n-a),d.stroke(),d.restore()}#o(t,e,s,i,o,n,l,a,c,h,_,f,d){let u=this.#t,p=c,w=l-a-c;if(w<=0)return;let m=n.cellPadding,C=d?.groupLabel??((S,y,v)=>`${S}: ${y} (${v})`);for(let S=t;S<=e;S++){let y=h(S);if(!y?.__group__)continue;let v=i.yOf(S)-s+o,x=i.heightOf(S),B=(y.level??0)*ie;u.fillStyle=n.groupHeaderBg,u.fillRect(p,v,w,x),u.strokeStyle=n.cellBorder,u.lineWidth=1,u.strokeRect(Math.round(p)+.5,Math.round(v)+.5,w-1,x-1),u.fillStyle=n.groupHeaderText,u.font=`bold ${n.fontSize}px ${n.fontFamily}`,u.textAlign="left",u.textBaseline="middle";let W=y.collapsed?"\u25B8":"\u25BE";u.fillText(`${W} ${C(y.field,y.key,y.count)}`,p+m+B,v+x/2);let M=Object.entries(y.aggregates??{});if(M.length){u.font=`${n.fontSize-1}px ${n.fontFamily}`,u.textAlign="right";let U=M.map(([z,K])=>`${f[_.indexOf(z)]??z} ${K}`).join(" ");u.fillText(U,p+w-m,v+x/2)}}}#s(t,e,s,i,o,n,l,a,c,h,_,f,d,u,p){if(i>o)return;let w=this.#t,m=c.cellPadding,C=u.length-1,S=i<h?0:f>0&&i>=C-f?d-u[C-f]:_-u[h]-n;w.fillStyle=c.footerBg,w.fillRect(u[i]+S,l,u[o+1]-u[i],a),w.font=`bold ${c.fontSize}px ${c.fontFamily}`,w.textBaseline="middle";let y=l+a/2;i===0&&(w.fillStyle=c.footerText,w.textAlign="left",w.font=`bold ${c.fontSize-1}px ${c.fontFamily}`,w.fillText(p?.groupFooterLabel??"Total",u[i]+S+m,y),w.font=`bold ${c.fontSize}px ${c.fontFamily}`);for(let x=i;x<=o;x++){let B=t[e[x]];if(B==null)continue;let W=u[x]+S,M=u[x+1]-u[x];w.fillStyle=c.footerText;let U=s?.[x]??"left";w.textAlign=U;let z=U==="right"?W+M-m:U==="center"?W+M/2:W+m;w.fillText(this.#f(String(B),M-m*2),z,y)}w.strokeStyle=c.headerBorder,w.lineWidth=1,w.beginPath();let v=Math.round(l)+.5;w.moveTo(u[i]+S,v),w.lineTo(u[o+1]+S,v),w.stroke()}#n(t,e,s,i,o,n,l){return ee(t,{frozenCount:e,frozenWidth:s,frozenRightCount:i,rightX:o,colPositions:l},n)}#a(t,e,s,i,o,n,l,a,c,h,_,f,d,u,p,w,m,C,S,y){if(n>l)return;let v=this.#t,x=f.cellPadding,B=y?y.type==="single"?y.col:y.c1:null,W=y?y.type==="single"?y.col:y.c2:null,M=m.length-1,U=A=>p>0&&A>=M-p,z=n<d?0:U(n)?w-m[M-p]:u-m[d]-a,K=m[n]+z,H=m[l+1]-m[n];v.fillStyle=f.headerBg,v.fillRect(K,0,H,c);let E=Wt(_,s,this.#e.columnLetterHeader).filter(A=>A.col+A.colspan-1>=n&&A.col<=l);v.strokeStyle=f.headerBorder,v.lineWidth=1,v.beginPath();for(let A of E){let O=m[A.col]+z,D=m[A.col+A.colspan]-m[A.col],T=A.row*h,k=A.rowspan*h,P=Math.round(O+D)+.5,g=T+k+.5;v.moveTo(P,T),v.lineTo(P,T+k),v.moveTo(O,g),v.lineTo(O+D,g)}v.stroke();let R=A=>A<d?0:U(A)?2:1,F=R(n);v.textBaseline="middle",v.fillStyle=f.headerText;let Q="";for(let A of E){let O=m[A.col]+z,D=m[A.col+A.colspan]-m[A.col],T=A.row*h,k=A.rowspan*h,P=T+k/2;A.isLeaf&&B!==null&&A.col>=B&&A.col<=W&&(v.fillStyle=f.selectionColor,v.globalAlpha=.28,v.fillRect(O,T,D,k),v.globalAlpha=1,v.fillStyle=f.headerText);let g=A.isLeaf?s[A.col]:null,V=A.isLeaf&&!!o?.[g],J=A.isLeaf&&i?.length?i.findIndex(st=>st.field===g):-1,lt=J>=0?i[J]:null,nt=i?.length>1,et=O+D-Bt;if(A.isLeaf&&V?(v.fillStyle=f.filterIconBg??"rgba(245,158,11,0.18)",v.fillRect(et+1,T+3,Bt-2,k-6),v.fillStyle=f.headerText):A.isLeaf&&lt&&(v.fillStyle=f.sortIconBg??"rgba(46,117,182,0.12)",v.fillRect(et+1,T+3,Bt-2,k-6),v.fillStyle=f.headerText),!(A.isLeaf||R(A.col)===F))continue;let N=O,j=D;if(!A.isLeaf){let st=Math.max(A.col,n),ot=Math.min(A.col+A.colspan-1,l);N=m[st]+z,j=m[ot+1]-m[st]}let ft=A.isLeaf?e?.[A.col]??"left":A.align??"center",it=A.isLeaf?Bt+4:0,X=A.isLeaf&&S?.has(g),G=X?20:0,Ct=j-x*2-it-G,At=f.headerFontSize??f.fontSize;v.font=`bold ${At}px ${f.fontFamily}`;let Mt=X?"left":ft;Mt!==Q&&(v.textAlign=Mt,Q=Mt);let yt=ft==="right"?N+j-x-it:X?N+x+G:ft==="center"?N+j/2:N+x,$=A.isLeaf?t[A.col]??"":A.label??"";if(this.#e.wrapHeader&&$){let st=this.#p($,Ct),ot=At*1.4,ct=P-(st.length-1)*ot/2;for(let ht of st)v.fillText(ht,yt,ct),ct+=ot}else v.fillText(this.#f($,Ct),yt,P);if(A.isLeaf){v.font=`bold ${At-1}px ${f.fontFamily}`,v.textAlign="center",Q="center",v.fillStyle=V?f.filterIconColor??"#C87B00":lt?f.sortIconColor??"#2E75B6":f.headerIconColor??"rgba(0,0,0,0.28)";let st=lt?lt.dir==="asc"?"\u2191":"\u2193":"\u25BE",ot=lt&&nt?`${J+1}${st}`:st;v.fillText(ot,et+Bt/2,P),v.fillStyle=f.headerText}}if(C){v.fillStyle=f.hiddenColIndicator??"#94A3B8";for(let A of E){if(!A.isLeaf)continue;let O=C[A.col];if(!O?.left&&!O?.right)continue;let D=m[A.col]+z,T=m[A.col+A.colspan]-m[A.col],k=A.row*h,P=A.rowspan*h;O.right&&v.fillRect(D+T-1,k,1,P),O.left&&v.fillRect(D,k,1,P)}}}#l(t,e,s,i,o,n,l,a,c,h,_,f,d,u,p,w,m,C,S,y,v,x,B,W){if(t>e||s>i)return;let M=this.#t,U=f.cellPadding,z=m.length-1,K=s<d?0:p>0&&s>=z-p?w-m[z-p]:u-m[d]-n,H=m[s]+K,I=m[i+1]-m[s];M.font=`${f.fontSize}px ${f.fontFamily}`,M.textBaseline="middle";let E=M.measureText("\u2026").width;for(let T=t;T<=e;T++)M.fillStyle=T%2===0?f.rowEven:f.rowOdd,M.fillRect(H,h.yOf(T)-o+_,I,h.heightOf(T));if(x){let T=f.editableCellBg,k=f.readonlyCellBg;if(T||k)for(let P=s;P<=i;P++){let g=x[P]?T:k;if(!g)continue;let V=m[P]+K,J=m[P+1]-m[P];M.fillStyle=g;for(let lt=t;lt<=e;lt++)M.fillRect(V,h.yOf(lt)-o+_,J,h.heightOf(lt))}}for(let T=t;T<=e;T++){let k=h.yOf(T)-o+_,P=h.heightOf(T);y?.has(T)&&(M.fillStyle=f.selRowBg,M.fillRect(H,k,I,P));let g=this.#e.rowHighlighter?.(c(T),T);g&&(M.fillStyle=g,M.fillRect(H,k,I,P)),v?.has(T)&&(M.fillStyle=f.deletedRowFill,M.fillRect(H,k,I,P))}let R=this.#e.cellBackground;if(R)for(let T=t;T<=e;T++){let k=h.yOf(T)-o+_,P=h.heightOf(T),g=c(T);for(let V=s;V<=i;V++){let J;try{J=R(g,T,l[V],V)}catch(et){console.error("[JHGrid] cellBackground error at row",T,"col",V,":",et);continue}if(!J)continue;let lt=m[V]+K,nt=m[V+1]-m[V];M.fillStyle=J,M.fillRect(lt,k,nt,P)}}if(B&&B.alpha>0&&B.row>=t&&B.row<=e&&f.hoverRowBg){let T=h.yOf(B.row)-o+_;M.globalAlpha=Math.min(1,B.alpha),M.fillStyle=f.hoverRowBg,M.fillRect(H,T,I,h.heightOf(B.row)),M.globalAlpha=1}let F=Math.round(h.yOf(t)-o+_),Q=Math.round(h.yOf(e+1)-o+_);M.strokeStyle=f.cellBorder,M.lineWidth=1,M.beginPath();for(let T=s;T<=i+1;T++){let k=Math.round(m[T]+K)+.5;M.moveTo(k,F),M.lineTo(k,Q)}for(let T=t;T<=e+1;T++){if(y?.has(T)&&y.has(T-1))continue;let k=Math.round(h.yOf(T)-o+_)+.5;M.moveTo(H,k),M.lineTo(H+I,k)}M.stroke();let A="",O="";for(let T=t;T<=e;T++){let k=c(T),P=h.yOf(T)-o+_;for(let g=s;g<=i;g++){let V=k?k[l[g]]:null,J=m[g]+K,lt=m[g+1]-m[g],nt=h.heightOf(T),et=P+nt/2,q=C?.[g];if(q&&k){M.save();try{q(M,{x:J,y:P,w:lt,h:nt,value:V,rowData:k,rowIndex:T,colIndex:g,theme:f,padding:U})}catch(Ct){console.error("[JHGrid] Custom renderer error at row",T,"col",g,":",Ct)}M.restore();continue}if(k==null){let At=(lt-U*2)*this.#_(T,g);if(At>2){let Mt=Math.min(9,nt-12);M.fillStyle=f.skeletonBar,this.#u(J+U,et-Mt/2,At,Mt,3),O=null}continue}let N=V!=null?f.cellText:f.loadingText,j=a?.[g]??"left";N!==O&&(M.fillStyle=N,O=N),j!==A&&(M.textAlign=j,A=j);let ft=j==="right"?J+lt-U:j==="center"?J+lt/2:J+U,it=lt-U*2,X=V!=null?String(V):"";if(X.indexOf(`
2
+ `)!==-1){let Ct=X.split(`
3
+ `),At=f.fontSize*1.4,Mt=et-(Ct.length-1)*At/2;M.save(),M.beginPath(),M.rect(J,P,lt,nt),M.clip();for(let yt of Ct)M.fillText(this.#m(yt,it,E),ft,Mt),Mt+=At;M.restore();continue}let G=Math.floor(it/(f.fontSize*.5));M.fillText(X.length<=G&&!r.#w(X)?X:this.#m(X,it,E),ft,et)}}if(W!=null){let T=I*.28,k=H-T+(I+T*2)*W;for(let P=t;P<=e;P++){if(c(P)!=null)continue;let g=h.yOf(P)-o+_;M.save(),M.beginPath(),M.rect(H,g,I,h.heightOf(P)),M.clip(),M.fillStyle=f.skeletonSheen,M.fillRect(k,g,T,h.heightOf(P)),M.restore()}}if(v){M.strokeStyle=f.deletedRowStrike,M.lineWidth=1;for(let T=t;T<=e;T++){if(!v.has(T))continue;let k=Math.round(h.yOf(T)-o+_+h.heightOf(T)/2)+.5;M.beginPath(),M.moveTo(H,k),M.lineTo(H+I,k),M.stroke()}}if(S&&S.size){M.strokeStyle=f.invalidCellBorder,M.lineWidth=1.5;for(let T=t;T<=e;T++){let k=h.yOf(T)-o+_;for(let P=s;P<=i;P++){if(!S.has(`${T}_${l[P]}`))continue;let g=m[P]+K,V=m[P+1]-m[P],J=h.heightOf(T);M.strokeRect(Math.round(g)+1,Math.round(k)+1,V-2,J-2)}}}let D=this.#e.cellDecorator;if(D)for(let T=t;T<=e;T++){let k=c(T);if(k==null)continue;let P=h.yOf(T)-o+_,g=h.heightOf(T);for(let V=s;V<=i;V++){let J=m[V]+K,lt=m[V+1]-m[V],nt=l[V];M.save();try{D(M,{x:J,y:P,w:lt,h:g,value:k[nt],rowData:k,field:nt,rowIndex:T,colIndex:V,theme:f,padding:U})}catch(et){console.error("[JHGrid] cellDecorator error at row",T,"col",V,":",et)}M.restore()}}}#r(t,e,s,i,o,n,l,a,c,h){if(!t)return null;let _=C=>this.#n(C,n,l,a,c,s,h),f=C=>i.yOf(C)-e+o;if(t.type==="single")return{x:_(t.col),y:f(t.row),w:h[t.col+1]-h[t.col],h:i.heightOf(t.row)};let{r1:d,c1:u,r2:p,c2:w}=t,m=_(u);return{x:m,y:f(d),w:_(w)+(h[w+1]-h[w])-m,h:i.yOf(p+1)-i.yOf(d)}}#c(t,e,s,i,o,n,l,a,c,h,_,f,d){let u=this.#t;if(t.type==="single"&&e?.row===t.row&&e?.col===t.col)return;let p=[s,i,o,n,a,c,h,_,f],{x:w,y:m,w:C,h:S}=this.#r(t,...p);if(d?.prev&&d.t<1){let y=this.#r(d.prev,...p);if(y){let v=d.t;w=y.x+(w-y.x)*v,m=y.y+(m-y.y)*v,C=y.w+(C-y.w)*v,S=y.h+(S-y.h)*v}}t.type==="range"&&(u.fillStyle=l.selectionFill,u.fillRect(w,m,C,S)),u.strokeStyle=l.selectionColor,u.lineWidth=2,u.strokeRect(w+1,m+1,C-2,S-2)}#h(t,e,s,i,o,n,l,a,c,h,_,f){let d=this.#t,{x:u,y:p,w,h:m}=this.#r(t,i,o,n,l,a,c,h,_,f);if(d.save(),d.strokeStyle=e,d.lineWidth=2,d.strokeRect(u+1,p+1,w-2,m-2),s){d.font=`bold 11px ${this.#e.theme.fontFamily}`;let C=this.#f(s,100),S=d.measureText(C).width+8,y=14,v=p-y>=l?p-y:p+m;d.fillStyle=e,d.fillRect(u,v,S,y),d.fillStyle="#fff",d.textAlign="left",d.textBaseline="middle",d.fillText(C,u+4,v+y/2)}d.restore()}#d({v:t,h:e,SB:s,vSB:i=s,hSB:o=s,frozenWidth:n=0,frozenRightWidth:l=0,rightX:a=0},c,h,_){if(!i&&!o)return;let f=this.#t,d=c.scrollbarRadius;f.fillStyle=c.scrollbarBg,i>0&&o>0&&f.fillRect(h-i,_-o,i,o),o>0&&n>0&&f.fillRect(0,_-o,n,o),o>0&&l>0&&f.fillRect(a,_-o,l,o),f.fillRect(t.x,t.y,t.w,t.h),f.fillStyle=c.scrollbarThumb,this.#u(t.x+2,t.thumbY+2,t.w-4,t.thumbH-4,d),f.fillStyle=c.scrollbarBg,f.fillRect(e.x,e.y,e.w,e.h),f.fillStyle=c.scrollbarThumb,this.#u(e.thumbX+2,e.y+2,e.thumbW-4,e.h-4,d)}#u(t,e,s,i,o){if(s<=0||i<=0)return;let n=this.#t;n.beginPath(),n.roundRect?n.roundRect(t,e,s,i,o):n.rect(t,e,s,i),n.fill()}#_(t,e){return .45+(t*73+e*151)%100/100*.4}#p(t,e){let s=this.#t,i=t.split(" "),o=[],n="";for(let l of i){let a=n?n+" "+l:l;s.measureText(a).width<=e?n=a:(n&&o.push(n),n=s.measureText(l).width>e?this.#f(l,e):l)}return n&&o.push(n),o.length?o:[t]}static#g=/[\u{1100}-\u{FFEF}\u{1F000}-\u{1FFFF}]/u;static#w(t){return r.#g.test(t)}#f(t,e){let s=this.#t;if(!t||s.measureText(t).width<=e)return t;let i=s.measureText("\u2026").width;return this.#m(t,e,i)}#m(t,e,s){let i=this.#t;if(i.measureText(t).width<=e)return t;let o=0,n=t.length;for(;o<n;){let l=o+n+1>>1;i.measureText(t.slice(0,l)).width+s<=e?o=l:n=l-1}return o>0?t.slice(0,o)+"\u2026":"\u2026"}};var L={root:"jhg-root",loading:"jhg-loading",empty:"jhg-empty",tooltip:"jhg-tooltip",overlay:"jhg-overlay",panel:"jhg-panel",dialog:"jhg-dialog",menu:"jhg-menu",menuItem:"jhg-menu-item",chip:"jhg-chip",chipContains:"jhg-chip-contains",treeGroup:"jhg-tree-group",treeToggle:"jhg-tree-toggle",btn:"jhg-btn",swatch:"jhg-swatch",pager:"jhg-pager",pagerBtn:"jhg-pager-btn",editor:"jhg-editor"},Pe={overlayBg:"--jhg-overlay-bg",overlayBorder:"--jhg-overlay-border",overlayHeaderBg:"--jhg-overlay-header-bg",overlayDivider:"--jhg-overlay-divider",overlayText:"--jhg-overlay-text",overlayMutedText:"--jhg-overlay-muted-text",overlayHintText:"--jhg-overlay-hint-text",overlayHoverBg:"--jhg-overlay-hover-bg",overlayItemHoverBg:"--jhg-overlay-item-hover-bg",overlayShadow:"--jhg-overlay-shadow",overlayMenuShadow:"--jhg-overlay-menu-shadow",overlayAccentText:"--jhg-overlay-accent-text",selectionColor:"--jhg-accent",pagerBg:"--jhg-pager-bg",pagerText:"--jhg-pager-text",pagerBorder:"--jhg-pager-border",pagerButtonBg:"--jhg-pager-button-bg",pagerButtonBorder:"--jhg-pager-button-border",fontFamily:"--jhg-font-family"};function b(r,t){let e=r?.[t],s=Pe[t];return s?`var(${s}, ${e})`:e}var ii=Object.freeze({...Pe}),Fe="jhgrid-styles",bs=`
4
+ .${L.root} {
5
+ --jhg-motion-fast: 140ms;
6
+ --jhg-motion-slow: 180ms;
7
+ --jhg-ease: cubic-bezier(0.2, 0, 0.2, 1);
8
+ --jhg-focus-ring: var(--jhg-accent, #2E75B6);
9
+ }
10
+
11
+ @keyframes jhg-overlay-in {
12
+ from { opacity: 0; transform: translateY(-4px) scale(0.985); }
13
+ to { opacity: 1; transform: none; }
14
+ }
15
+ @keyframes jhg-fade-in {
16
+ from { opacity: 0; }
17
+ to { opacity: 1; }
18
+ }
19
+
20
+ /* Entrance only. Every close path removes its element synchronously (and callers/tests observe
21
+ that immediately), so an exit animation would mean deferring removal \u2014 a behavioral change,
22
+ not a cosmetic one. Hover/focus transitions below still animate in both directions. */
23
+ .${L.overlay} {
24
+ animation: jhg-overlay-in var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out) both;
25
+ transform-origin: top center;
26
+ }
27
+
28
+ .${L.menuItem} {
29
+ transition: background-color var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out);
30
+ }
31
+
32
+ /* The builders assign background/border/color inline; declaring the transition here is what makes
33
+ those assignments animate instead of snapping. */
34
+ .${L.btn}, .${L.pagerBtn} {
35
+ transition: background-color var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out),
36
+ border-color var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out),
37
+ color var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out),
38
+ transform 90ms var(--jhg-ease, ease-out);
39
+ }
40
+ .${L.btn}:active:not(:disabled), .${L.pagerBtn}:active:not(:disabled) {
41
+ transform: translateY(1px);
42
+ }
43
+ .${L.pagerBtn}:disabled {
44
+ opacity: 0.45;
45
+ cursor: default;
46
+ }
47
+
48
+ .${L.swatch} {
49
+ transition: transform var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out),
50
+ box-shadow var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out);
51
+ }
52
+ .${L.swatch}:hover { transform: scale(1.12); }
53
+
54
+ /* The chooser sets \`transform\` inline to turn the arrow; this is what makes it turn rather than
55
+ flip. Same split as everywhere else here \u2014 the value is the builder's, the timing is ours. */
56
+ .${L.treeToggle} {
57
+ transition: transform var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out),
58
+ color var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out);
59
+ }
60
+ .${L.treeGroup} {
61
+ transition: background-color var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out);
62
+ }
63
+
64
+ /* These three are shown and hidden by flipping display, which no transition can observe \u2014 a
65
+ transition on opacity here would be dead code, since opacity itself never changes. An animation
66
+ works instead: a display:none element runs none, and starting to display it replays it. */
67
+ .${L.tooltip}, .${L.empty} {
68
+ animation: jhg-fade-in var(--jhg-motion-fast, 140ms) var(--jhg-ease, ease-out) both;
69
+ }
70
+ .${L.loading} {
71
+ animation: jhg-fade-in var(--jhg-motion-slow, 180ms) var(--jhg-ease, ease-out) both;
72
+ }
73
+
74
+ /* Editors mount over the cell and take focus immediately, so this stays short enough not to read
75
+ as lag while typing. Kept to opacity only \u2014 moving a text caret around would be worse, not
76
+ better. */
77
+ @keyframes jhg-editor-in {
78
+ from { opacity: 0; }
79
+ to { opacity: 1; }
80
+ }
81
+ .${L.editor} {
82
+ animation: jhg-editor-in 90ms var(--jhg-ease, ease-out) both;
83
+ }
84
+
85
+ /* A visible focus target for keyboard users. :focus-visible keeps it off mouse interactions, and
86
+ the grid wrapper is excluded because it is focused programmatically on nearly every
87
+ interaction \u2014 a ring there would flash constantly rather than indicate anything.
88
+ Menu items are also excluded: a context menu focuses its first item with a plain
89
+ \`.focus()\` call as soon as it opens \u2014 including on a mouse right-click, since focus-visible
90
+ can't tell that script-driven focus apart from a keyboard interaction \u2014 so this outline would
91
+ flash on every open. A full-width single-row item makes the outline's top/bottom edges read as
92
+ two stray horizontal lines rather than a ring, which is the actual bug this excludes. Menu
93
+ items get their own focus indicator instead (same highlight as mouse hover \u2014 see each menu
94
+ builder's \`mkItem\`). */
95
+ .${L.root} :focus-visible:not([role="menuitem"]),
96
+ .${L.pager} :focus-visible {
97
+ outline: 2px solid var(--jhg-focus-ring, #2E75B6);
98
+ outline-offset: 1px;
99
+ }
100
+ /* ...and the browser's own default focus outline (not our rule above) needs suppressing too,
101
+ since excluding [role="menuitem"] from the rule above only stops *our* outline \u2014 without this
102
+ it's replaced by the UA's native one instead of by mkItem's background highlight. */
103
+ .${L.menuItem}:focus {
104
+ outline: none;
105
+ }
106
+
107
+ @media (prefers-reduced-motion: reduce) {
108
+ .${L.root}, .${L.pager} {
109
+ --jhg-motion-fast: 1ms;
110
+ --jhg-motion-slow: 1ms;
111
+ }
112
+ .${L.overlay}, .${L.loading}, .${L.tooltip}, .${L.empty}, .${L.editor} { animation: none; }
113
+ .${L.swatch}:hover { transform: none; }
114
+ .${L.btn}:active:not(:disabled), .${L.pagerBtn}:active:not(:disabled) { transform: none; }
115
+ /* Stated outright rather than left to the retimed variables: the chooser is a floating surface
116
+ and may be mounted outside .${L.root}, where those variables never reach it. */
117
+ .${L.treeToggle}, .${L.treeGroup} { transition: none; }
118
+ }
119
+ `;function Be(r=typeof document<"u"?document:null){if(!(!r?.head||r.getElementById(Fe)))try{let t=r.createElement("style");t.id=Fe,t.textContent=bs,r.head.appendChild(t)}catch{}}var oe=(r,t,e,s,i)=>({position:"absolute",left:t+"px",top:e+"px",width:s+"px",height:i+"px",border:`2px solid ${b(r,"selectionColor")}`,outline:"none",padding:`0 ${r.cellPadding}px`,fontSize:r.fontSize+"px",fontFamily:b(r,"fontFamily"),background:b(r,"overlayBg"),color:r.cellText,zIndex:"10",boxSizing:"border-box"});function ye({el:r,wrapper:t,x:e,y:s,offsetY:i=0}){let o=()=>{let n=t.getBoundingClientRect();r.style.left=n.left+e+"px",r.style.top=n.top+s+i+"px"};return o(),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o),()=>{window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o)}}function He(r,{wrapper:t,x:e,y:s,colW:i,rowH:o}){let n=t.getBoundingClientRect(),l=n.left+e,a=n.top+s;return r.clientX>=l&&r.clientX<l+i&&r.clientY>=a&&r.clientY<a+o}var Ht={text(){return r=>{let{theme:t,x:e,y:s,colW:i,rowH:o,wrapper:n,kbProxy:l,i18n:a,columnLabel:c,row:h,initialValue:_,keepInputValue:f}=r,d=l;if(d._jhEditorBlur&&d.removeEventListener("blur",d._jhEditorBlur),d._jhEditorKeydown&&d.removeEventListener("keydown",d._jhEditorKeydown),f||(d.value=_),d.setAttribute("aria-label",a.editAriaLabel(c,h+1)),d.className=L.editor,d.style.cssText="",Object.assign(d.style,oe(t,e,s,i,o)),d.parentElement!==n&&n.appendChild(d),!f){d.focus();let w=d.value.length;d.setSelectionRange(w,w)}let u=()=>r.commit(),p=w=>{if(w.key==="Enter"&&w.altKey)w.preventDefault(),w.stopPropagation(),r.insertLineBreak();else if(w.key==="Enter"){if(w.isComposing||w.keyCode===229)return;w.preventDefault(),w.stopPropagation(),r.commit(),r.moveSel(1,0),r.focusWrapper()}else w.key==="Tab"?(w.preventDefault(),w.stopPropagation(),r.commit(),r.moveSel(0,w.shiftKey?-1:1),r.focusWrapper()):w.key==="Escape"&&(w.preventDefault(),w.stopPropagation(),r.cancel(),r.focusWrapper())};return d._jhEditorBlur=u,d._jhEditorKeydown=p,d.addEventListener("blur",u),d.addEventListener("keydown",p),d}},textMultiline(){return r=>{let{theme:t,x:e,y:s,colW:i,rowH:o,wrapper:n,i18n:l,columnLabel:a,row:c,initialValue:h}=r,_=document.createElement("textarea");_.value=h??"",_.setAttribute("aria-label",l.editAriaLabel(a,c+1)),_.className=L.editor,Object.assign(_.style,oe(t,e,s,i,o),{resize:"none",overflow:"auto",whiteSpace:"pre"}),n.appendChild(_),_.focus(),_.setSelectionRange(_.value.length,_.value.length);let f=()=>r.commit(),d=u=>{if(u.key==="Enter"&&u.altKey){u.preventDefault(),u.stopPropagation();let p=_.selectionStart??_.value.length,w=_.selectionEnd??_.value.length;_.value=_.value.slice(0,p)+`
120
+ `+_.value.slice(w),_.setSelectionRange(p+1,p+1);return}if(u.key==="Enter"){if(u.isComposing||u.keyCode===229)return;u.preventDefault(),u.stopPropagation(),r.commit(),r.moveSel(1,0),r.focusWrapper()}else if(u.key==="Tab")u.preventDefault(),u.stopPropagation(),r.commit(),r.moveSel(0,u.shiftKey?-1:1),r.focusWrapper();else if(u.key==="Escape")u.preventDefault(),u.stopPropagation(),r.cancel(),r.focusWrapper();else{let p=u.key.toLowerCase();(u.ctrlKey||u.metaKey)&&!["c","v","x","a"].includes(p)&&u.stopPropagation()}};return _.addEventListener("blur",f),_.addEventListener("keydown",d),_}},date({mode:r="date",min:t,max:e,format:s}={}){if(s){let o=s.match(/[^A-Za-z0-9]/)?.[0]??"/",n=s.split(/[^A-Za-z0-9]+/).map(u=>u.length),l=n.reduce((u,p)=>u+p,0),a=s.match(/YYYY|YY|MM|DD|HH|mm|ss/g)??[],c=a.includes("HH")||a.includes("mm")||a.includes("ss"),h=c?"datetime-local":"date",_=u=>{let p="",w=0;for(let m=0;m<n.length;m++){let C=u.slice(w,w+n[m]);if(!C)break;p&&(p+=o),p+=C,w+=n[m]}return p},f=u=>{let p={},w=0;for(let m of a){let C=u.slice(w,w+m.length);if(w+=m.length,C.length<m.length)return null;m==="YYYY"?p.Y=C:m==="YY"?p.Y="20"+C:m==="MM"?p.M=C:m==="DD"?p.D=C:m==="HH"?p.H=C:m==="mm"&&(p.Mi=C)}return!p.Y||!p.M||!p.D?null:c?`${p.Y}-${p.M}-${p.D}T${p.H??"00"}:${p.Mi??"00"}`:`${p.Y}-${p.M}-${p.D}`},d=u=>{let p=/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2}))?/.exec(u);if(!p)return"";let[,w,m,C,S,y]=p,v="";for(let x of a)x==="YYYY"?v+=w:x==="YY"?v+=w.slice(-2):x==="MM"?v+=m:x==="DD"?v+=C:x==="HH"?v+=S??"00":x==="mm"&&(v+=y??"00");return _(v)};return u=>{let{theme:p,x:w,y:m,colW:C,rowH:S,wrapper:y,i18n:v,columnLabel:x,row:B,initialValue:W}=u,M=a.length&&C>40?22:0,U=C-M,z=document.createElement("input");z.type="text",z.value=String(W??""),z.setAttribute("aria-label",v.editAriaLabel(x,B+1)),Object.assign(z.style,oe(p,w,m,U,S)),y.appendChild(z);let K=null,H=null;if(M>0){K=document.createElement("input"),K.type=h,t!=null&&(K.min=t),e!=null&&(K.max=e),K.tabIndex=-1,K.setAttribute("aria-label",v.editAriaLabel(x,B+1)+" calendar"),Object.assign(K.style,{position:"absolute",left:w+U+"px",top:m+"px",width:M+"px",height:S+"px",opacity:"0",border:"none",padding:"0",margin:"0",zIndex:"9"}),y.appendChild(K),H=document.createElement("div"),H.textContent=String.fromCodePoint(128197),H.setAttribute("aria-hidden","true"),Object.assign(H.style,{position:"absolute",left:w+U+"px",top:m+"px",width:M+"px",height:S+"px",display:"flex",alignItems:"center",justifyContent:"center",fontSize:Math.min(p.fontSize,14)+"px",pointerEvents:"none",zIndex:"10"}),y.appendChild(H);let I=f(z.value.replace(/\D/g,"").slice(0,l));I!=null&&(K.value=I),K.addEventListener("click",()=>{if(typeof K.showPicker=="function")try{K.showPicker()}catch{}}),K.addEventListener("change",()=>{z.value=d(K.value),u.commit(),u.focusWrapper()}),K.addEventListener("blur",E=>{E.relatedTarget!==z&&u.commit()})}return z.focus(),z.select(),z.addEventListener("input",()=>{let I=z.selectionStart,E=z.value.slice(0,I).replace(/\D/g,"").length,R=z.value.replace(/\D/g,"").slice(0,l),F=_(R);if(z.value=F,K){let O=f(R);O!=null&&(K.value=O)}let Q=F.length,A=0;for(let O=0;O<F.length;O++)if(/\d/.test(F[O])&&(A++,A===E)){Q=O+1;break}z.setSelectionRange(Q,Q)}),z.addEventListener("blur",I=>{K&&I.relatedTarget===K||u.commit()}),z.addEventListener("keydown",I=>{I.key==="Enter"?(I.preventDefault(),I.stopPropagation(),u.commit(),u.moveSel(1,0),u.focusWrapper()):I.key==="Tab"?(I.preventDefault(),I.stopPropagation(),u.commit(),u.moveSel(0,I.shiftKey?-1:1),u.focusWrapper()):I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),u.cancel(),u.focusWrapper())}),{get value(){return z.value},remove(){z.remove(),K&&K.remove(),H&&H.remove()}}}}let i=r==="datetime-local"?16:10;return o=>{let{theme:n,x:l,y:a,colW:c,rowH:h,wrapper:_,i18n:f,columnLabel:d,row:u,initialValue:p}=o,w=document.createElement("input");return w.type=r==="datetime-local"?"datetime-local":"date",t!=null&&(w.min=t),e!=null&&(w.max=e),w.value=String(p??"").slice(0,i),w.setAttribute("aria-label",f.editAriaLabel(d,u+1)),w.className=L.editor,Object.assign(w.style,oe(n,l,a,c,h)),_.appendChild(w),w.focus(),w.addEventListener("blur",()=>o.commit()),w.addEventListener("keydown",m=>{m.key==="Enter"?(m.preventDefault(),m.stopPropagation(),o.commit(),o.moveSel(1,0),o.focusWrapper()):m.key==="Tab"?(m.preventDefault(),m.stopPropagation(),o.commit(),o.moveSel(0,m.shiftKey?-1:1),o.focusWrapper()):m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),o.cancel(),o.focusWrapper())}),w}},dropdown({options:r}={}){return t=>{let{theme:e,x:s,y:i,colW:o,rowH:n,wrapper:l,i18n:a,columnLabel:c,row:h,rowData:_,initialValue:f}=t,d=typeof r=="function"?r(_??{}):r??[];if(!d.length)return null;let u=f,p=document.createElement("div");Object.assign(p.style,{position:"absolute",left:s+"px",top:i+"px",width:o+"px",height:n+"px",border:`2px solid ${e.selectionColor}`,boxSizing:"border-box",zIndex:"10",pointerEvents:"none"}),l.appendChild(p);let w=l.getBoundingClientRect(),m=w.left+s,C=w.top+i+n,S=document.createElement("div");S.setAttribute("role","listbox"),S.setAttribute("aria-label",a.editAriaLabel(c,h+1)),Object.assign(S.style,{position:"fixed",left:m+"px",top:C+"px",minWidth:o+"px",maxHeight:"240px",overflowY:"auto",background:e.overlayBg,border:`1px solid ${e.overlayBorder}`,borderRadius:"4px",boxShadow:e.overlayMenuShadow,zIndex:"99999",fontSize:e.fontSize+"px",fontFamily:e.fontFamily,color:e.cellText});let y=-1,v=[],x=E=>{v.forEach((R,F)=>{R.style.background=F===E?e.selectionColor:R.dataset.val===u?e.selectionFill:e.overlayBg,R.style.color=F===E?e.overlayAccentText:e.cellText}),y=E,E>=0&&v[E].scrollIntoView({block:"nearest"})};for(let E=0;E<d.length;E++){let R=d[E],F=typeof R=="string"?R:R.value,Q=typeof R=="string"?R:R.label??R.value,A=document.createElement("div");A.setAttribute("role","option"),A.dataset.val=F,A.textContent=Q,Object.assign(A.style,{padding:"6px 10px",cursor:"pointer",background:F===u?e.selectionFill:e.overlayBg,whiteSpace:"nowrap"}),A.addEventListener("mouseenter",()=>x(E)),A.addEventListener("mouseleave",()=>x(-1)),A.addEventListener("mousedown",O=>{O.preventDefault(),O.stopPropagation(),u=F,z()}),S.appendChild(A),v.push(A)}document.body.appendChild(S);let B=ye({el:S,wrapper:l,x:s,y:i,offsetY:n}),W=!0,M={get value(){return u},remove(){U(),p.remove(),S.remove()}},U=()=>{B(),document.removeEventListener("mousedown",H,!0),document.removeEventListener("keydown",I,!0)},z=()=>{W&&(W=!1,U(),t.commit(),t.focusWrapper())},K=()=>{W&&(W=!1,U(),t.cancel(),t.focusWrapper())},H=E=>{S.contains(E.target)||(He(E,{wrapper:l,x:s,y:i,colW:o,rowH:n})&&t.suppressReopen?.(),K())},I=E=>{E.key==="Escape"?(E.preventDefault(),E.stopPropagation(),K()):E.key==="ArrowDown"?(E.preventDefault(),E.stopPropagation(),x(Math.min(y+1,v.length-1))):E.key==="ArrowUp"?(E.preventDefault(),E.stopPropagation(),x(Math.max(y-1,0))):E.key==="Enter"?(E.preventDefault(),E.stopPropagation(),y>=0&&(u=v[y].dataset.val),z()):E.key==="Tab"&&(E.preventDefault(),E.stopPropagation(),y>=0&&(u=v[y].dataset.val),z(),t.moveSel(0,E.shiftKey?-1:1))};return document.addEventListener("mousedown",H,!0),document.addEventListener("keydown",I,!0),M}},multiselect({options:r=[],delimiter:t=","}={}){return e=>{let{theme:s,x:i,y:o,colW:n,rowH:l,wrapper:a,i18n:c,columnLabel:h,row:_,rowData:f,initialValue:d}=e,u=typeof r=="function"?r(f??{}):r;if(!u.length)return null;let p=new Set(String(d??"").split(t).map(H=>H.trim()).filter(Boolean)),w=document.createElement("div");Object.assign(w.style,{position:"absolute",left:i+"px",top:o+"px",width:n+"px",height:l+"px",border:`2px solid ${s.selectionColor}`,boxSizing:"border-box",zIndex:"10",pointerEvents:"none"}),a.appendChild(w);let m=a.getBoundingClientRect(),C=m.left+i,S=m.top+o+l,y=document.createElement("div");y.setAttribute("role","listbox"),y.setAttribute("aria-multiselectable","true"),y.setAttribute("aria-label",c.editAriaLabel(h,_+1)),Object.assign(y.style,{position:"fixed",left:C+"px",top:S+"px",minWidth:n+"px",maxHeight:"240px",overflowY:"auto",background:s.overlayBg,border:`1px solid ${s.overlayBorder}`,borderRadius:"4px",boxShadow:s.overlayMenuShadow,zIndex:"99999",fontSize:s.fontSize+"px",fontFamily:s.fontFamily,color:s.cellText}),u.forEach(H=>{let I=typeof H=="string"?H:H.value,E=typeof H=="string"?H:H.label??H.value,R=p.has(I),F=document.createElement("div");F.setAttribute("role","option"),F.setAttribute("aria-selected",String(R)),Object.assign(F.style,{display:"flex",alignItems:"center",gap:"8px",padding:"6px 10px",cursor:"pointer",background:R?s.selectionFill:s.overlayBg,userSelect:"none",whiteSpace:"nowrap"});let Q=document.createElement("input");Q.type="checkbox",Q.checked=R,Q.tabIndex=-1,Q.style.pointerEvents="none";let A=document.createElement("span");A.textContent=E,F.appendChild(Q),F.appendChild(A),F.addEventListener("mouseenter",()=>{F.style.background=s.selectionColor,F.style.color=s.overlayAccentText}),F.addEventListener("mouseleave",()=>{F.style.background=p.has(I)?s.selectionFill:s.overlayBg,F.style.color=s.cellText}),F.addEventListener("mousedown",O=>{O.preventDefault(),O.stopPropagation(),Q.checked=!Q.checked,F.setAttribute("aria-selected",String(Q.checked)),Q.checked?p.add(I):p.delete(I),F.style.background=p.has(I)?s.selectionFill:s.overlayBg,F.style.color=s.cellText}),y.appendChild(F)}),document.body.appendChild(y);let v=ye({el:y,wrapper:a,x:i,y:o,offsetY:l}),x=!0,B={get value(){return[...p].join(t)},remove(){w.remove(),y.remove(),W()}},W=()=>{v(),document.removeEventListener("mousedown",z,!0),document.removeEventListener("keydown",K,!0)},M=()=>{x&&(x=!1,W(),e.commit(),e.focusWrapper())},U=()=>{x&&(x=!1,W(),e.cancel(),e.focusWrapper())},z=H=>{y.contains(H.target)||(He(H,{wrapper:a,x:i,y:o,colW:n,rowH:l})&&e.suppressReopen?.(),M())},K=H=>{H.key==="Escape"?(H.preventDefault(),H.stopPropagation(),U()):H.key==="Enter"?(H.preventDefault(),H.stopPropagation(),M()):H.key==="Tab"&&(H.preventDefault(),H.stopPropagation(),M(),e.moveSel(0,H.shiftKey?-1:1))};return document.addEventListener("mousedown",z,!0),document.addEventListener("keydown",K,!0),B}},richtext({marks:r=["bold","italic","underline","strike"]}={}){let t={bold:"bold",italic:"italic",underline:"underline",strike:"strikeThrough"},e={bold:"B",italic:"I",underline:"U",strike:"S"};return s=>{let{theme:i,x:o,y:n,colW:l,rowH:a,wrapper:c,i18n:h,columnLabel:_,row:f,initialValue:d}=s,u=document.createElement("div");Object.assign(u.style,{position:"absolute",left:o+"px",top:n+"px",width:l+"px",height:a+"px",border:`2px solid ${i.selectionColor}`,boxSizing:"border-box",zIndex:"10",pointerEvents:"none"}),c.appendChild(u);let p=c.getBoundingClientRect(),w=p.left+o,m=p.top+n,C=document.createElement("div");C.setAttribute("role","toolbar"),C.setAttribute("aria-label",h.richtextToolbarLabel??"Formatting"),Object.assign(C.style,{position:"fixed",left:w+"px",top:m-30+"px",display:"flex",gap:"2px",padding:"2px",background:i.overlayBg,border:`1px solid ${i.overlayBorder}`,borderRadius:"4px",boxShadow:i.overlayMenuShadow,zIndex:"99999"});let S={},y=()=>{for(let E of r){let R=!1;try{R=document.queryCommandState(t[E])}catch{}S[E].setAttribute("aria-pressed",String(R)),S[E].style.background=R?i.selectionFill:i.overlayBg}};for(let E of r){let R=document.createElement("button");R.type="button",R.textContent=e[E]??E[0].toUpperCase(),R.setAttribute("aria-label",E),R.setAttribute("aria-pressed","false"),Object.assign(R.style,{width:"24px",height:"24px",border:"none",background:i.overlayBg,cursor:"pointer",fontSize:i.fontSize+"px",fontFamily:i.fontFamily,fontWeight:E==="bold"?"bold":"normal",fontStyle:E==="italic"?"italic":"normal",textDecoration:E==="underline"?"underline":E==="strike"?"line-through":"none"}),R.addEventListener("mousedown",F=>{F.preventDefault();try{document.execCommand(t[E],!1,null)}catch{}y(),x.focus()}),C.appendChild(R),S[E]=R}document.body.appendChild(C);let v=ye({el:C,wrapper:c,x:o,y:n,offsetY:-30}),x=document.createElement("div");x.contentEditable="true",x.setAttribute("role","textbox"),x.setAttribute("aria-multiline","false"),x.setAttribute("aria-label",h.editAriaLabel(_,f+1)),x.innerHTML=Oe(String(d??"")),Object.assign(x.style,{position:"absolute",left:o+"px",top:n+"px",width:l+"px",height:a+"px",border:`2px solid ${i.selectionColor}`,outline:"none",boxSizing:"border-box",padding:`0 ${i.cellPadding}px`,lineHeight:a+"px",whiteSpace:"nowrap",overflow:"hidden",fontSize:i.fontSize+"px",fontFamily:i.fontFamily,background:i.overlayBg,color:i.cellText,zIndex:"10"}),c.appendChild(x),x.focus();let B=document.createRange();B.selectNodeContents(x),B.collapse(!1);let W=window.getSelection();W.removeAllRanges(),W.addRange(B);let M=!0,U={get value(){return Oe(x.innerHTML)},remove(){z(),u.remove(),C.remove(),x.remove()}},z=()=>{document.removeEventListener("mousedown",I,!0),v(),document.removeEventListener("selectionchange",y)},K=()=>{M&&(M=!1,z(),s.commit(),s.focusWrapper())},H=()=>{M&&(M=!1,z(),s.cancel(),s.focusWrapper())},I=E=>{!x.contains(E.target)&&!C.contains(E.target)&&K()};return x.addEventListener("keydown",E=>{if(E.key==="Enter"){if(E.isComposing||E.keyCode===229)return;E.preventDefault(),E.stopPropagation(),K(),s.moveSel(1,0)}else if(E.key==="Tab")E.preventDefault(),E.stopPropagation(),K(),s.moveSel(0,E.shiftKey?-1:1);else if(E.key==="Escape")E.preventDefault(),E.stopPropagation(),H();else{let R=E.key.toLowerCase();(E.ctrlKey||E.metaKey)&&!["c","v","x","a"].includes(R)&&E.stopPropagation()}}),x.addEventListener("input",y),document.addEventListener("mousedown",I,!0),y(),U}}},vs=new Set(Object.keys(Ht));function be(r,t){vs.has(r)&&console.warn(`[JHGrid] registerCellEditor: "${r}" is a built-in editor name and will be overwritten`),Ht[r]=t}var xs=new Set(["B","STRONG","I","EM","U","S","STRIKE","DEL"]),Cs={STRONG:"B",EM:"I",STRIKE:"S",DEL:"S"},Ss=new Set(["SCRIPT","STYLE","TEMPLATE","NOSCRIPT","IFRAME","OBJECT","EMBED"]);function Es(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Oe(r){let t=document.createElement("template");t.innerHTML=r;let e=t.content,s=[],i=1,o=3,n=l=>{for(let a of Array.from(l.childNodes))if(a.nodeType===o)s.push(Es(a.textContent.replace(/[\r\n]+/g," ")));else if(a.nodeType===i){let c=a.tagName;if(Ss.has(c))continue;if(c==="BR"){s.push(" ");continue}if(c==="DIV"||c==="P"){n(a),s.push(" ");continue}let h=Cs[c]??(xs.has(c)?c:null);if(h){let _=h.toLowerCase();s.push(`<${_}>`),n(a),s.push(`</${_}>`)}else n(a)}};return n(e),s.join("").trim()}var ne=class{#t=[];#e=[];#i;constructor(t=100){this.#i=t}push(t){this.#t.push(t),this.#t.length>this.#i&&this.#t.shift(),this.#e.length=0}undo(){let t=this.#t.pop();t&&(t.undo(),this.#e.push(t))}redo(){let t=this.#e.pop();t&&(t.redo(),this.#t.push(t))}canUndo(){return this.#t.length>0}canRedo(){return this.#e.length>0}clear(){this.#t.length=0,this.#e.length=0}};var re=class{#t=new Map;#e;#i;#o;#s;#n;constructor({getColumnDef:t,getColumnLabel:e,getI18n:s,getRowData:i,onError:o}){this.#e=t,this.#i=e,this.#o=s,this.#s=i,this.#n=o}compute(t,e,s){let i=this.#e(e),o=i?.validation,n=this.#o(),l=this.#i(e)??e,a=s??"";if(o?.required&&a.trim()==="")return o.message??n.validationRequired(l);if(a==="")return null;if(!o)return this.#a(i,t,a,l,n);if(o.pattern){let c=o.pattern instanceof RegExp?o.pattern:new RegExp(o.pattern);if(c.lastIndex=0,!c.test(a))return o.message??n.validationPattern(l)}if(o.min!=null||o.max!=null){let c=i?.type==="date",h=c?Date.parse(a):Number(a);if(o.min!=null&&(isNaN(h)||h<(c?Date.parse(o.min):o.min)))return o.message??n.validationMin(l,o.min);if(o.max!=null&&(isNaN(h)||h>(c?Date.parse(o.max):o.max)))return o.message??n.validationMax(l,o.max)}if(o.minLength!=null&&a.length<o.minLength)return o.message??n.validationMinLength(l,o.minLength);if(o.maxLength!=null&&a.length>o.maxLength)return o.message??n.validationMaxLength(l,o.maxLength);if(o.validator){let c;try{c=o.validator(a,this.#s(t)??{})}catch(h){return console.error("[JHGrid] validator error at row",t,"field",e,":",h),null}if(typeof c=="string")return c;if(c===!1)return o.message??n.validationInvalid(l)}return this.#a(i,t,a,l,n)}#a(t,e,s,i,o){if(!t)return null;if(t.type==="dropdown"){let n=this.#r(t,e);if(n&&!n.includes(s))return o.validationInvalid(i)}else if(t.type==="multiselect"){let n=this.#r(t,e);if(n){let l=t.editorOptions?.delimiter??",";if(s.split(l).map(c=>c.trim()).filter(Boolean).some(c=>!n.includes(c)))return o.validationInvalid(i)}}else if(t.type==="date"&&!this.#l(s,t.format))return o.validationInvalid(i);return null}#l(t,e){let s=e?.match(/YYYY|YY|MM|DD|HH|mm|ss/g);if(!s?.length)return!isNaN(new Date(t).getTime());let i=e.match(/[^A-Za-z0-9]/)?.[0]??"/",o=t.split(i);if(o.length!==s.length)return!1;let n,l;for(let a=0;a<s.length;a++){if(!/^\d+$/.test(o[a]))return!1;s[a]==="MM"?n=Number(o[a]):s[a]==="DD"&&(l=Number(o[a]))}return!(n!=null&&(n<1||n>12)||l!=null&&(l<1||l>31))}#r(t,e){let s=typeof t.options=="function"?t.options(this.#s(e)??{}):t.options;return Array.isArray(s)?s.map(i=>typeof i=="string"?i:i.value):null}revalidate(t,e,s){let i=this.#e(e);if(!i?.validation&&!this.#c(i?.type))return null;let o=`${t}_${e}`,n=this.compute(t,e,s);return n?this.#t.set(o,n):this.#t.delete(o),this.#n?.(t,e,n??null),n}#c(t){return t==="dropdown"||t==="multiselect"||t==="date"}isValid(){return this.#t.size===0}getInvalidCells(){let t={};return this.#t.forEach((e,s)=>{let i=s.indexOf("_"),o=Number(s.slice(0,i)),n=s.slice(i+1);(t[o]??={})[n]=e}),t}get map(){return this.#t}clear(){this.#t.clear()}};var Rs=/^-?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function ze(r,t=","){let e=String(r??"");return/^[=+\-@\t\r]/.test(e)&&!Rs.test(e)&&(e="'"+e),e.includes(t)||e.includes('"')||e.includes(`
121
+ `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function Ie(r,t=" "){let e=String(r??"");return e.includes(t)||e.includes('"')||e.includes(`
122
+ `)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function We(r,t=" "){let e=r.replace(/\r\n/g,`
123
+ `).replace(/\r/g,`
124
+ `),s=[],i=[],o="",n=!1;for(let l=0;l<e.length;l++){let a=e[l];if(n){a==='"'?e[l+1]==='"'?(o+='"',l++):n=!1:o+=a;continue}if(a==='"'&&o===""){n=!0;continue}if(a===t){i.push(o),o="";continue}if(a===`
125
+ `){i.push(o),s.push(i),i=[],o="";continue}o+=a}return i.push(o),s.push(i),s}function Kt(r,t,e){if(r==null||r==="")return r;if(t?.type==="date"){let s=r instanceof Date?r:new Date(String(r));if(isNaN(s.getTime()))return r;let i=t.format??"YYYY-MM-DD";if(i==="locale")return new Intl.DateTimeFormat(e).format(s);let o=String(s.getFullYear()).padStart(4,"0"),n=String(s.getMonth()+1).padStart(2,"0"),l=String(s.getDate()).padStart(2,"0"),a=String(s.getHours()).padStart(2,"0"),c=String(s.getMinutes()).padStart(2,"0"),h=String(s.getSeconds()).padStart(2,"0"),_=o.slice(-2);return i.replace("YYYY",o).replace("YY",_).replace("MM",n).replace("DD",l).replace("HH",a).replace("mm",c).replace("ss",h)}return t?.type==="richtext"&&typeof r=="string"?r.replace(/<\/?(b|i|u|s)>/g,"").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"):r}function ve(r,t,e=1){if(r.length===0)return"";let s=r.map(Number),i=r.every(a=>a.trim()!==""&&!isNaN(Number(a))),o=e<0;if(i){if(r.length===1)return String(s[0]+(o?-t:t));let a=s.slice(1).map((h,_)=>h-s[_]),c=a[0];if(a.every(h=>Math.abs(h-c)<1e-9)){let h=o?s[0]-c*t:s[s.length-1]+c*t;return Number.isInteger(h)?String(h):String(parseFloat(h.toFixed(10)))}}let n=r.length,l=o?(n-t%n)%n:(t-1)%n;return r[l]}var le=class{#t=[];get size(){return this.#t.length}values(){return[...this.#t]}clear(){this.#t.length=0}#e(t){let e=0,s=this.#t.length;for(;e<s;){let i=e+s>>1;this.#t[i]<t?e=i+1:s=i}return e}has(t){let e=this.#e(t);return e<this.#t.length&&this.#t[e]===t}add(t){let e=this.#e(t);return e<this.#t.length&&this.#t[e]===t?!1:(this.#t.splice(e,0,t),!0)}delete(t){let e=this.#e(t);return e>=this.#t.length||this.#t[e]!==t?!1:(this.#t.splice(e,1),!0)}countBefore(t){return this.#e(t)}toServer(t){if(this.#t.length===0)return t;let e=0,s=this.#t.length;for(;e<s;){let i=e+s>>1;this.#t[i]-i<=t?e=i+1:s=i}return t+e}toVisual(t){return this.has(t)?-1:t-this.countBefore(t)}dropFrom(t){let e=this.#e(t);e<this.#t.length&&(this.#t.length=e)}shiftFrom(t){let e=this.#e(t);for(let s=e;s<this.#t.length;s++)this.#t[s]++}};var ae=class{removed=new le;serverTotal=0;anchors=[];get localCount(){return this.anchors.length}get serverVisible(){return this.serverTotal-this.removed.size}get totalRows(){return this.serverVisible+this.anchors.length}reset(t=0){this.serverTotal=t,this.removed.clear(),this.anchors.length=0}#t(t){let e=Math.min(t,this.serverTotal);return e-this.removed.countBefore(e)}visualOfLocal(t){return this.#t(this.anchors[t])+t}#e(t){let e=0,s=this.anchors.length;for(;e<s;){let i=e+s>>1;this.visualOfLocal(i)<=t?e=i+1:s=i}return e}sourceAt(t){if(t<0||t>=this.totalRows)return null;let e=this.#e(t);return e>0&&this.visualOfLocal(e-1)===t?{local:e-1,server:-1}:{local:-1,server:this.removed.toServer(t-e)}}visualOfServer(t){return this.removed.has(t)?-1:this.#t(t)+this.#i(t)}#i(t){let e=0,s=this.anchors.length;for(;e<s;){let i=e+s>>1;this.anchors[i]<=t?e=i+1:s=i}return e}planInsert(t){let e=Math.max(0,Math.min(t,this.totalRows));if(e>=this.totalRows)return{anchor:this.serverTotal,at:this.anchors.length};let s=this.sourceAt(e);return s.local>=0?{anchor:this.anchors[s.local],at:s.local}:{anchor:s.server,at:this.#i(s.server)}}insertLocal(t){let{anchor:e,at:s}=this.planInsert(t);return this.anchors.splice(s,0,e),s}removeLocal(t){this.anchors.splice(t,1)}clampAnchors(t){this.serverTotal=t;for(let e=0;e<this.anchors.length;e++)this.anchors[e]>t&&(this.anchors[e]=t)}detachAnchors(){for(let t=0;t<this.anchors.length;t++)this.anchors[t]=Number.MAX_SAFE_INTEGER}};var As=50,Ms=2;function Ts(r,t){let e=[],s=new Map;for(let i of r){let o=t(i)??[],n=e,l="";for(let a of o){l+=" "+a;let c=s.get(l);c||(c={type:"group",label:a,children:[]},s.set(l,c),n.push(c)),n=c.children}n.push({type:"field",field:i})}return e}function xe(r){return r.type==="field"?[r.field]:r.children.flatMap(xe)}function Ne({x:r,y:t,width:e,height:s,fields:i,isHidden:o,labelFor:n,groupPathFor:l=()=>[],i18n:a,theme:c,onApply:h,onCancel:_}){if(i.length===0)return null;let f=Ts(i,l),d=k=>k.reduce((P,g)=>P+1+(g.type==="group"?d(g.children):0),0),u=d(f),p=(...k)=>k.join(";"),w=220,m=document.createElement("div");m.setAttribute("role","dialog"),m.setAttribute("aria-modal","true"),m.setAttribute("aria-label",a.colChooserTitle),m.className=`${L.overlay} ${L.dialog}`,m.style.cssText=p("position:absolute",`left:${Math.max(0,Math.min(r,e-w-4))}px`,`top:${Math.max(0,Math.min(t,s-40-u*32))}px`,`width:${w}px`,`background:${b(c,"overlayBg")}`,`border:1px solid ${b(c,"overlayBorder")}`,"border-radius:6px",`box-shadow:${b(c,"overlayShadow")}`,`font-family:${b(c,"fontFamily")}`,`font-size:${c.fontSize}px`,`color:${b(c,"overlayText")}`,"z-index:300","overflow:hidden","user-select:none");let C=document.createElement("div");C.style.cssText=p("display:flex","align-items:center","justify-content:space-between","padding:9px 12px",`background:${b(c,"overlayHeaderBg")}`,`border-bottom:1px solid ${b(c,"overlayDivider")}`);let S=document.createElement("span");S.textContent=a.colChooserTitle,S.style.fontWeight="600";let y=document.createElement("button");y.type="button",y.textContent="\xD7",y.setAttribute("aria-label",a.colChooserCancel),y.style.cssText=p("background:none","border:none",`color:${b(c,"overlayMutedText")}`,"cursor:pointer","font-size:17px","line-height:1","padding:0 2px"),y.addEventListener("click",()=>_()),C.append(S,y);let v=document.createElement("div");v.style.cssText="padding:0 0 6px;max-height:280px;overflow-y:auto;";let x=new Map(i.map(k=>[k,!o(k)])),B=document.createElement("label");B.style.cssText=p("display:flex","align-items:center","gap:8px","padding:6px 14px","cursor:pointer",`border-bottom:1px solid ${b(c,"overlayDivider")}`,"margin-bottom:2px"),B.addEventListener("mouseover",()=>{B.style.background=b(c,"overlayHoverBg")}),B.addEventListener("mouseout",()=>{B.style.background=""});let W=document.createElement("input");W.type="checkbox",W.style.cssText="width:14px;height:14px;cursor:pointer;flex-shrink:0;";let M=document.createElement("span");M.textContent=a.colChooserSelectAll??"\uC804\uCCB4 \uC120\uD0DD",M.style.cssText="flex:1;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",B.append(W,M),v.appendChild(B);let U=[],z=[],K=()=>{let k=U.filter(P=>P.checked).length;W.checked=k===U.length,W.indeterminate=k>0&&k<U.length},H=new Map,I=()=>{for(let{node:k,cb:P}of z){let g=xe(k),V=g.filter(J=>H.get(J).checked).length;P.checked=V===g.length,P.indeterminate=V>0&&V<g.length}K()};W.addEventListener("change",()=>{W.indeterminate=!1,U.forEach(k=>{k.checked=W.checked,x.set(k.dataset.field,W.checked)}),I()});let E=18,R=32;function F(k,P,g){let V=n(k),J=document.createElement("label");J.style.cssText=p("display:flex","align-items:center","gap:6px","padding:6px 14px","cursor:pointer","border-radius:3px"),J.addEventListener("mouseover",()=>{J.style.background=b(c,"overlayHoverBg")}),J.addEventListener("mouseout",()=>{J.style.background=""});let lt=document.createElement("span");lt.style.cssText="width:18px;height:18px;flex-shrink:0;";let nt=document.createElement("input");nt.type="checkbox",nt.checked=x.get(k),nt.dataset.field=k,nt.style.cssText="width:14px;height:14px;cursor:pointer;flex-shrink:0;",nt.addEventListener("change",()=>{x.set(k,nt.checked),I()});let et=document.createElement("span");et.textContent=V,et.style.cssText="flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",J.append(lt,nt,et),g.appendChild(J),U.push(nt),H.set(k,nt)}function Q(k,P,g){let V=xe(k),J=document.createElement("div");J.className=L.treeGroup,J.style.cssText=p("display:flex","align-items:center","gap:6px","padding:7px 14px 7px 10px","cursor:pointer",`background:${b(c,"overlayHeaderBg")}`,`border-bottom:1px solid ${b(c,"overlayDivider")}`,`border-left:3px solid ${b(c,"selectionColor")}`,"position:sticky",`top:${P*R}px`,`z-index:${10-P}`),J.addEventListener("mouseover",()=>{J.style.background=b(c,"overlayHoverBg")}),J.addEventListener("mouseout",()=>{J.style.background=b(c,"overlayHeaderBg")});let lt=document.createElement("div");lt.style.cssText=p(`margin-left:${E}px`,"padding-left:6px",`border-left:1px solid ${b(c,"overlayDivider")}`);let nt=!0,et=document.createElement("button");et.type="button",et.className=L.treeToggle,et.textContent="\u25BE",et.setAttribute("aria-expanded","true"),et.setAttribute("aria-label",k.label),et.style.cssText=p("width:18px","height:18px","flex-shrink:0","display:flex","align-items:center","justify-content:center","background:none","border:none","padding:0","cursor:pointer","font-size:13px","line-height:1",`color:${b(c,"overlayText")}`),et.addEventListener("click",ft=>{ft.preventDefault(),ft.stopPropagation(),nt=!nt,et.style.transform=nt?"":"rotate(-90deg)",et.setAttribute("aria-expanded",String(nt)),lt.style.display=nt?"":"none"});let q=document.createElement("label");q.style.cssText="display:flex;align-items:center;gap:8px;flex:1;cursor:pointer;min-width:0;";let N=document.createElement("input");N.type="checkbox",N.style.cssText="width:14px;height:14px;cursor:pointer;flex-shrink:0;",N.addEventListener("change",()=>{N.indeterminate=!1,V.forEach(ft=>{H.get(ft).checked=N.checked,x.set(ft,N.checked)}),I()});let j=document.createElement("span");j.textContent=k.label,j.style.cssText="flex:1;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",q.append(N,j),J.append(et,q),g.appendChild(J),g.appendChild(lt),z.push({node:k,cb:N}),A(k.children,P+1,lt)}function A(k,P,g){for(let V of k)V.type==="group"?Q(V,P,g):F(V.field,P,g)}A(f,0,v),I();let O=document.createElement("div");O.style.cssText=p("display:flex","gap:6px","padding:10px 12px",`border-top:1px solid ${b(c,"overlayDivider")}`);let D=document.createElement("button");D.type="button",D.textContent=a.colChooserApply,D.style.cssText=p("flex:1","padding:7px 0",`background:${b(c,"selectionColor")}`,`color:${b(c,"overlayAccentText")}`,"border:none","border-radius:4px","cursor:pointer","font-size:13px","font-weight:600"),D.addEventListener("click",()=>h(x));let T=document.createElement("button");return T.type="button",T.textContent=a.colChooserCancel,T.style.cssText=p("flex:1","padding:7px 0",`background:${b(c,"overlayHeaderBg")}`,`color:${b(c,"overlayText")}`,`border:1px solid ${b(c,"overlayBorder")}`,"border-radius:4px","cursor:pointer","font-size:13px"),T.addEventListener("click",()=>_()),O.append(D,T),m.append(C,v,O),m.addEventListener("mousedown",k=>k.stopPropagation()),m.addEventListener("keydown",k=>{k.key==="Escape"&&_(),k.stopPropagation()}),m}function je({colLeft:r,headerH:t,width:e,maxPanelHeight:s,label:i,curVal:o,sortPriority:n,asc:l,desc:a,filterId:c,swatchColors:h,activeColor:_,multiSortEnabled:f,i18n:d,theme:u,distinctValues:p,selectedValues:w,suggest:m,suggestScope:C,tagValues:S,containsValue:y,minQueryChars:v,onClose:x,onSort:B,onApply:W,onApplyValues:M,onColorFilter:U,onResetCol:z,onResetAll:K}){let I=Math.max(0,Math.min(r,e-220)),E=t,R=(...$)=>$.join(";"),F=($,st,ot)=>{let ct=document.createElement("button");return ct.type="button",ct.textContent=$,ct.dataset.action=st,ct.className=L.btn,ct.style.cssText=ot,ct},Q=document.createElement("div");Q.setAttribute("role","dialog"),Q.setAttribute("aria-modal","true"),Q.setAttribute("aria-label",d.filterDialog(i)),Q.className=`${L.overlay} ${L.panel}`,Q.style.cssText=R("position:absolute",`left:${I}px`,`top:${E}px`,"width:220px",`background:${b(u,"overlayBg")}`,`border:1px solid ${b(u,"overlayBorder")}`,"border-radius:6px",`box-shadow:${b(u,"overlayShadow")}`,`font-family:${b(u,"fontFamily")}`,`font-size:${u.fontSize}px`,`color:${b(u,"overlayText")}`,"z-index:100","overflow:hidden","user-select:none","display:flex","flex-direction:column",...s?[`max-height:${Math.max(120,s)}px`]:[]);let A=document.createElement("div");A.style.cssText=R("display:flex","align-items:center","justify-content:space-between","padding:9px 12px",`background:${b(u,"overlayHeaderBg")}`,`border-bottom:1px solid ${b(u,"overlayDivider")}`);let O=document.createElement("span");O.textContent=i,O.style.fontWeight="600";let D=F("\xD7","close",R("background:none","border:none",`color:${b(u,"overlayMutedText")}`,"cursor:pointer","font-size:17px","line-height:1","padding:0 2px"));D.setAttribute("aria-label",d.filterClose),A.append(O,D);let T=document.createElement("div");T.style.cssText=R("padding:10px 12px",`border-bottom:1px solid ${b(u,"overlayDivider")}`);let k=document.createElement("div");k.style.cssText=R("display:flex","gap:6px");let P=R("flex:1","padding:6px 0","border-radius:4px","cursor:pointer","font-size:12px"),g=F(d.sortAsc,"asc",R(P,`background:${l?b(u,"selectionColor"):b(u,"overlayHeaderBg")}`,`color:${l?b(u,"overlayAccentText"):b(u,"overlayText")}`,`border:1px solid ${l?b(u,"selectionColor"):b(u,"overlayBorder")}`));g.setAttribute("aria-pressed",String(l));let V=F(d.sortDesc,"desc",R(P,`background:${a?b(u,"selectionColor"):b(u,"overlayHeaderBg")}`,`color:${a?b(u,"overlayAccentText"):b(u,"overlayText")}`,`border:1px solid ${a?b(u,"selectionColor"):b(u,"overlayBorder")}`));if(V.setAttribute("aria-pressed",String(a)),k.append(g,V),n>0){let $=document.createElement("span");$.textContent=`#${n}`,$.title="Sort priority",$.style.cssText=R("align-self:center","font-size:11px","font-weight:700",`color:${b(u,"selectionColor")}`,"min-width:20px","text-align:center"),k.appendChild($)}if(T.appendChild(k),f){let $=document.createElement("div");$.textContent=d.sortShiftHint??"Shift+click: add to multi-sort",$.style.cssText=R("font-size:10px",`color:${b(u,"overlayHintText")}`,"margin-top:5px"),T.appendChild($)}let J=null;if(h?.length){J=document.createElement("div"),J.style.cssText=R("padding:10px 12px",`border-bottom:1px solid ${b(u,"overlayDivider")}`);let $=document.createElement("div");$.textContent=d.filterColorLabel??"Filter by color",$.style.cssText=R("font-size:11px",`color:${b(u,"overlayMutedText")}`,"margin-bottom:6px");let st=document.createElement("div");st.style.cssText=R("display:flex","flex-wrap:wrap","gap:6px"),h.forEach(ot=>{let ct=_===ot,ht=document.createElement("button");ht.type="button",ht.dataset.action="color-filter",ht.dataset.value=ot,ht.title=ot,ht.setAttribute("aria-pressed",String(ct)),ht.className=L.swatch,ht.style.cssText=R("width:22px","height:22px","border-radius:50%","cursor:pointer","padding:0","border:none",`background:${ot}`,`box-shadow:${ct?`0 0 0 2px ${b(u,"overlayBg")}, 0 0 0 4px ${b(u,"selectionColor")}`:"0 0 0 1px rgba(0,0,0,0.15)"}`),st.appendChild(ht)}),J.append($,st)}let lt=document.createElement("div");lt.style.cssText=R("padding:10px 12px",`border-bottom:1px solid ${b(u,"overlayDivider")}`);let nt=document.createElement("label");nt.textContent=d.filterLabel,nt.htmlFor=c,nt.style.cssText=R("font-size:11px",`color:${b(u,"overlayMutedText")}`,"display:block","margin-bottom:6px");let et=document.createElement("input");et.type="text",et.id=c,et.value=o,et.placeholder=d.filterPlaceholder,et.className=L.editor,et.style.cssText=R("width:100%","padding:6px 8px",`background:${b(u,"overlayBg")}`,`border:1px solid ${b(u,"overlayBorder")}`,"border-radius:4px",`color:${b(u,"overlayText")}`,`font-size:${u.fontSize}px`,"box-sizing:border-box"),lt.append(nt,et);let q=null,N=null;if(!Array.isArray(p)&&typeof m=="function"){let Ft=function(){if(Et.replaceChildren(),_t){Et.appendChild(bt(d.filterTagMinChars(Dt),!1)),$t.replaceChildren(Y(d.filterTagContains(tt),d.filterTagContains(tt),()=>kt(tt),!0)),wt.style.display="flex",ut.setAttribute("aria-expanded","true"),Z=-1;return}let at=new Set($.tags),mt=rt.filter(xt=>!at.has(xt));if(C==="local"&&mt.length>0){let xt=bt(d.filterTagLocalScope,!0);xt.style.borderBottom=`1px solid ${b(u,"overlayDivider")}`,Et.appendChild(xt)}let vt=mt.slice(0,As);for(let xt of vt){let St=xt===""?d.emptyCell:xt;Et.appendChild(Y(St,St,()=>dt(xt),!1))}if(mt.length>vt.length){let xt=bt(d.filterTagMore(mt.length-vt.length),!0);xt.style.borderTop=`1px solid ${b(u,"overlayDivider")}`,Et.appendChild(xt)}mt.length===0&&Et.appendChild(bt(rt.length?d.filterTagAllSelected:d.filterTagNoMatch,!1)),$t.replaceChildren(Y(d.filterTagContains(tt),d.filterTagContains(tt),()=>kt(tt),!0)),wt.style.display="flex",ut.setAttribute("aria-expanded","true"),Z=-1},$={tags:Array.isArray(S)?[...S]:[],contains:typeof y=="string"&&y?y:null};q=document.createElement("div"),q.style.cssText=R("padding:10px 12px",`border-bottom:1px solid ${b(u,"overlayDivider")}`);let st=document.createElement("div");st.textContent=d.filterLabel,st.style.cssText=R("font-size:11px",`color:${b(u,"overlayMutedText")}`,"margin-bottom:6px");let ot=document.createElement("div");ot.style.cssText=R("display:none","flex-direction:column","flex:0 1 auto","min-height:0","margin-top:8px");let ct=document.createElement("div");ct.style.cssText=R("font-size:11px",`color:${b(u,"overlayMutedText")}`,"margin-bottom:4px");let ht=document.createElement("div");ht.style.cssText=R("display:flex","flex-wrap:wrap","gap:4px","flex:1 1 auto","min-height:30px","max-height:64px","overflow-y:auto","padding:6px","border-radius:4px",`border:1px solid ${b(u,"overlayBorder")}`,`background:${b(u,"overlayHeaderBg")}`),ot.append(ct,ht);let ut=document.createElement("input");ut.type="text",ut.id=c,ut.placeholder=d.filterTagPlaceholder,ut.className=L.editor,ut.setAttribute("role","combobox"),ut.setAttribute("aria-expanded","false"),ut.setAttribute("aria-autocomplete","list"),ut.style.cssText=R("width:100%","padding:6px 8px",`background:${b(u,"overlayBg")}`,`border:1px solid ${b(u,"overlayBorder")}`,"border-radius:4px",`color:${b(u,"overlayText")}`,`font-size:${u.fontSize}px`,"box-sizing:border-box");let wt=document.createElement("div");wt.style.cssText=R("display:none","flex-direction:column","flex:0 0 auto","margin-top:4px",`border:1px solid ${b(u,"overlayBorder")}`,"border-radius:4px","overflow:hidden");let Et=document.createElement("div");Et.setAttribute("role","listbox"),Et.style.cssText=R("flex:0 0 auto","max-height:132px","overflow-y:auto");let $t=document.createElement("div");$t.style.cssText=R("flex:0 0 auto",`border-top:1px solid ${b(u,"overlayDivider")}`,`background:${b(u,"overlayHeaderBg")}`),wt.append(Et,$t);let Tt=()=>{ht.replaceChildren();let at=(vt,xt,St,Ae)=>{let Xt=document.createElement("span");Xt.className=L.chip+(Ae?` ${L.chipContains}`:""),Xt.style.cssText=R("display:inline-flex","align-items:center","gap:4px","max-width:100%","padding:2px 4px 2px 7px","border-radius:10px","font-size:11px","box-sizing:border-box",Ae?`background:${b(u,"overlayHeaderBg")};border:1px dashed ${b(u,"overlayBorder")};color:${b(u,"overlayMutedText")}`:`background:${b(u,"sortIconBg")};border:1px solid ${b(u,"overlayBorder")};color:${b(u,"overlayText")}`);let he=document.createElement("span");he.textContent=vt,Xt.title=xt,he.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;";let Nt=document.createElement("button");Nt.type="button",Nt.className=L.btn,Nt.textContent="\xD7",Nt.setAttribute("aria-label",d.filterTagRemove(xt)),Nt.style.cssText=R("border:none","background:none","cursor:pointer","padding:0 2px","line-height:1","font-size:13px",`color:${b(u,"overlayMutedText")}`),Nt.addEventListener("click",()=>{St(),Tt(),ut.focus()}),Xt.append(he,Nt),ht.appendChild(Xt)};$.contains!==null?at(d.filterTagContains($.contains),d.filterTagContains($.contains),()=>{$.contains=null},!0):$.tags.forEach((vt,xt)=>{let St=vt===""?d.emptyCell:vt;at(St,St,()=>{$.tags.splice(xt,1)})});let mt=ht.childElementCount;ot.style.display=mt?"flex":"none",ct.textContent=d.filterTagSelected(mt)},Rt=()=>{wt.style.display="none",Et.replaceChildren(),$t.replaceChildren(),ut.setAttribute("aria-expanded","false")},dt=at=>{$.contains=null,$.tags.includes(at)||$.tags.push(at),ut.value="",Rt(),Tt(),ut.focus()},kt=at=>{$.tags=[],$.contains=at,ut.value="",Rt(),Tt(),ut.focus()},Y=(at,mt,vt,xt)=>{let St=document.createElement("div");return St.setAttribute("role","option"),St.className=L.menuItem,St.title=mt,St.textContent=at,St.style.cssText=R("padding:5px 8px","font-size:12px","cursor:pointer","overflow:hidden","text-overflow:ellipsis","white-space:nowrap",xt?`color:${b(u,"overlayMutedText")}`:`color:${b(u,"overlayText")}`),St.addEventListener("mouseenter",()=>{St.style.background=b(u,"overlayItemHoverBg")}),St.addEventListener("mouseleave",()=>{St.style.background="none"}),St.addEventListener("click",vt),St},tt="",rt=[],Z=-1,_t=!1,gt=Math.floor(Number(v)),Dt=Number.isFinite(gt)&&gt>0?gt:Ms,bt=(at,mt)=>{let vt=document.createElement("div");return vt.textContent=at,vt.style.cssText=R("padding:5px 8px",`font-size:${mt?11:12}px`,mt?"font-style:italic":"",`color:${b(u,"overlayMutedText")}`),vt},zt=0,It=0,te=async at=>{let mt=++zt,vt=[];try{vt=await m(at)??[]}catch{vt=[]}mt!==zt||ut.value.trim()!==at||(tt=at,rt=vt,_t=!1,Ft())};ut.addEventListener("input",()=>{clearTimeout(It);let at=ut.value.trim();if(!at){zt++,Rt();return}if(at.length<Dt){zt++,tt=at,rt=[],_t=!0,Ft();return}It=setTimeout(()=>te(at),180)});let Vt=()=>[...wt.querySelectorAll('[role="option"]')],Re=at=>{let mt=Vt();mt.forEach((vt,xt)=>{vt.style.background=xt===at?b(u,"overlayItemHoverBg"):"none"}),Z=at,mt[at]?.scrollIntoView({block:"nearest"})};ut.addEventListener("keydown",at=>{let mt=wt.style.display!=="none";at.key==="ArrowDown"&&mt?(at.preventDefault(),Re(Math.min(Z+1,Vt().length-1))):at.key==="ArrowUp"&&mt?(at.preventDefault(),Re(Math.max(Z-1,0))):at.key==="Enter"?(at.preventDefault(),mt?Vt()[Z>=0?Z:0]?.click():G.click()):at.key==="Escape"&&(mt?(Rt(),Z=-1):x()),at.stopPropagation()}),ut.addEventListener("input",()=>{Z=-1}),q.append(st,ut,wt,ot),Tt(),Q.addEventListener("jhg-dispose",()=>{clearTimeout(It),zt++}),N=()=>$.contains!==null?{contains:$.contains}:{values:[...$.tags]}}let j=null,ft=[];if(Array.isArray(p)&&p.length>0){j=document.createElement("div"),j.style.cssText=R("padding:10px 12px",`border-bottom:1px solid ${b(u,"overlayDivider")}`);let $=document.createElement("div");$.textContent=d.filterValuesLabel,$.style.cssText=R("font-size:11px",`color:${b(u,"overlayMutedText")}`,"margin-bottom:6px");let st=Array.isArray(w)?new Set(w):null,ot=(dt,kt,Y)=>{let tt=document.createElement("label");tt.style.cssText=R("display:flex","align-items:center","gap:6px","font-size:12px","cursor:pointer","padding:2px 0");let rt=document.createElement("input");rt.type="checkbox",rt.checked=Y,rt.dataset.value=dt;let Z=document.createElement("span");return Z.textContent=kt,Z.style.cssText="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",tt.append(rt,Z),{row:tt,cb:rt}},ct=document.createElement("input");ct.type="text",ct.placeholder=d.filterTagPlaceholder,ct.setAttribute("aria-label",d.filterTagPlaceholder),ct.className=L.editor,ct.style.cssText=R("width:100%","padding:6px 8px",`background:${b(u,"overlayBg")}`,`border:1px solid ${b(u,"overlayBorder")}`,"border-radius:4px",`color:${b(u,"overlayText")}`,`font-size:${u.fontSize}px`,"box-sizing:border-box","margin-bottom:6px");let ht=document.createElement("div");ht.style.cssText=R("max-height:140px","overflow-y:auto","display:flex","flex-direction:column");let ut=[];p.forEach(dt=>{let kt=st===null?!0:st.has(dt),Y=dt===""?d.emptyCell:dt,{row:tt,cb:rt}=ot(dt,Y,kt);ft.push(rt),ut.push({row:tt,cb:rt,text:Y}),ht.appendChild(tt)});let wt=document.createElement("div");wt.textContent=d.filterTagNoMatch,wt.style.cssText=R("padding:5px 8px","font-size:12px",`color:${b(u,"overlayMutedText")}`,"display:none"),ht.appendChild(wt);let{row:Et,cb:$t}=ot("",d.filterSelectAll,ft.every(dt=>dt.checked));delete $t.dataset.value,$t.dataset.selectAll="true",Et.style.cssText+=`;font-weight:600;border-bottom:1px solid ${b(u,"overlayDivider")};padding-bottom:6px;margin-bottom:4px;`;let Tt=()=>ut.filter(dt=>dt.row.style.display!=="none").map(dt=>dt.cb),Rt=()=>{let dt=Tt();$t.checked=dt.length>0&&dt.every(kt=>kt.checked)};$t.addEventListener("change",()=>{Tt().forEach(dt=>{dt.checked=$t.checked})}),ft.forEach(dt=>dt.addEventListener("change",Rt)),ct.addEventListener("input",()=>{let dt=ct.value.trim().toLowerCase(),kt=!1;for(let Y of ut){let tt=!dt||Y.text.toLowerCase().includes(dt);Y.row.style.display=tt?"flex":"none",kt=kt||tt}wt.style.display=kt?"none":"block",Rt()}),ct.addEventListener("keydown",dt=>{dt.key==="Enter"?(dt.preventDefault(),G.click()):dt.key==="Escape"&&x(),dt.stopPropagation()}),j.append($,ct,Et,ht)}let it=document.createElement("div");it.style.cssText=R("padding:10px 12px",`border-bottom:1px solid ${b(u,"overlayDivider")}`);let X=document.createElement("div");X.style.cssText=R("display:flex","gap:6px");let G=F(d.filterApply,"apply",R("flex:1","padding:7px 0",`background:${b(u,"selectionColor")}`,`color:${b(u,"overlayAccentText")}`,"border:none","border-radius:4px","cursor:pointer","font-size:13px","font-weight:600")),Ct=F(d.filterReset,"reset-col",R("flex:1","padding:7px 0",`background:${b(u,"overlayHeaderBg")}`,`color:${b(u,"overlayText")}`,`border:1px solid ${b(u,"overlayBorder")}`,"border-radius:4px","cursor:pointer","font-size:13px"));X.append(G,Ct),it.appendChild(X);let At=document.createElement("div");At.style.cssText=R("padding:8px 12px","text-align:center");let Mt=F(d.filterResetAll,"reset-all",R("background:none","border:none",`color:${b(u,"overlayMutedText")}`,"cursor:pointer","font-size:12px","text-decoration:underline"));At.appendChild(Mt);let yt=j??q??lt;Q.append(A,T,...J?[J]:[],yt,it,At);for(let $ of Q.children)$.style.flex="0 0 auto";return yt.style.flex="1 1 auto",yt.style.minHeight="0",yt===q&&(yt.style.display="flex",yt.style.flexDirection="column",yt.style.overflowY="auto"),yt===j&&(yt.style.overflowY="auto"),Q.addEventListener("mousedown",$=>$.stopPropagation()),Q.addEventListener("keydown",$=>{if($.key!=="Tab")return;let st=[...Q.querySelectorAll("button:not([disabled]), input")];if(st.length===0)return;let ot=st[0],ct=st[st.length-1];$.shiftKey?document.activeElement===ot&&($.preventDefault(),ct.focus()):document.activeElement===ct&&($.preventDefault(),ot.focus())},!0),Q.addEventListener("click",$=>{let st=$.target.closest("[data-action]")?.dataset?.action;if(st)if(st==="close")x();else if(st==="asc"||st==="desc")B(st,$.shiftKey);else if(st==="apply")if(j)M(ft.filter(ot=>ot.checked).map(ot=>ot.dataset.value));else if(N){let ot=N();ot.contains!==void 0?W(ot.contains):ot.values.length?M(ot.values):W("")}else W(et.value.trim());else if(st==="color-filter"){let ot=$.target.closest('[data-action="color-filter"]')?.dataset?.value;if(ot==null)return;U(ot)}else st==="reset-col"?z():st==="reset-all"&&K()}),et.addEventListener("keydown",$=>{$.key==="Enter"?($.preventDefault(),G.click()):$.key==="Escape"&&x(),$.stopPropagation()}),Q.addEventListener("keydown",$=>{$.key==="Escape"&&x()}),Q}function Ye({x:r,y:t,width:e,isFrozen:s,isFrozenRight:i,isDeleted:o,i18n:n,theme:l,allowedItems:a={},onFreeze:c,onFreezeRight:h,onVisibility:_,onInsertLeft:f,onInsertRight:d,onDelete:u,onUndelete:p,onEscape:w}){let{freeze:m=!0,freezeRight:C=!0,visibility:S=!0,insertLeft:y=!0,insertRight:v=!0,delete:x=!0}=a;if(!m&&!C&&!S&&!y&&!v&&!x)return null;let B=170,W=(...A)=>A.join(";"),M=W("padding:8px 14px","cursor:pointer"),U=document.createElement("div");U.setAttribute("role","menu"),U.className=`${L.overlay} ${L.menu}`,U.style.cssText=W("position:absolute",`left:${Math.min(r,e-B-2)}px`,`top:${t}px`,`width:${B}px`,`background:${b(l,"overlayBg")}`,`border:1px solid ${b(l,"overlayBorder")}`,"border-radius:6px",`box-shadow:${b(l,"overlayMenuShadow")}`,`font-family:${b(l,"fontFamily")}`,`font-size:${l.fontSize}px`,`color:${b(l,"overlayText")}`,"z-index:200","overflow:hidden","user-select:none","padding:4px 0");let z=(A,O)=>{let D=document.createElement("div");return D.setAttribute("role","menuitem"),D.setAttribute("tabindex","0"),D.textContent=A,D.dataset.action=O,D.className=L.menuItem,D.style.cssText=M,D.addEventListener("mouseover",()=>{D.style.background=b(l,"overlayItemHoverBg")}),D.addEventListener("mouseout",()=>{D.style.background=""}),D.addEventListener("focus",()=>{D.style.background=b(l,"overlayItemHoverBg")}),D.addEventListener("blur",()=>{D.style.background=""}),D},K=()=>{let A=document.createElement("div");return A.style.cssText=`height:1px;background:${b(l,"overlayDivider")};margin:4px 0;`,A},H=[];m&&H.push(z(s?n.colUnfreeze:n.colFreeze,s?"unfreeze":"freeze")),C&&H.push(z(i?n.colUnfreezeRight:n.colFreezeRight,i?"unfreeze-right":"freeze-right"));let I=S?[z(n.colVisibility,"col-visibility")]:[],E=[];y&&E.push(z(n.colInsertLeft,"col-insert-left")),v&&E.push(z(n.colInsertRight,"col-insert-right"));let R=x?[z(o?n.colUndelete:n.colDelete,o?"col-undelete":"col-delete")]:[],Q=[H,I,E,R].filter(A=>A.length>0).flatMap((A,O)=>O===0?A:[K(),...A]);return U.addEventListener("mousedown",A=>A.stopPropagation()),U.addEventListener("click",A=>{let O=A.target.closest("[data-action]")?.dataset?.action;if(O)if(O==="freeze"||O==="unfreeze")c();else if(O==="freeze-right"||O==="unfreeze-right")h();else if(O==="col-visibility"){_();return}else if(O==="col-insert-left"){f();return}else if(O==="col-insert-right"){d();return}else O==="col-delete"?u():O==="col-undelete"&&p()}),U.addEventListener("keydown",A=>{if(A.key==="Escape")w();else if(A.key==="Enter"||A.key===" ")A.preventDefault(),document.activeElement?.click?.();else if(A.key==="ArrowDown"||A.key==="ArrowUp"){A.preventDefault();let O=[...U.querySelectorAll('[role="menuitem"]')],D=O.indexOf(document.activeElement),T=A.key==="ArrowDown"?(D+1)%O.length:(D-1+O.length)%O.length;O[T]?.focus()}A.stopPropagation()}),U.append(...Q),U}function Ce(r,t,e,s){let i=new Map;return r((o,n)=>{let l=e(n);l>=0&&i.set(l,o)}),t.forEach((o,n)=>i.set(s(n),o)),[...i.entries()].sort(([o],[n])=>o-n)}function Ge({cols:r,labels:t,rows:e,title:s,includeHeaders:i,i18n:o,lang:n}){let l=h=>String(h??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),a=i?`<thead><tr>${t.map(h=>`<th>${l(h)}</th>`).join("")}</tr></thead>`:"",c=e.map(h=>`<tr>${r.map(_=>`<td>${l(h[_])}</td>`).join("")}</tr>`).join("");return`<!DOCTYPE html><html lang="${l(n)}"><head>
126
+ <meta charset="utf-8">
127
+ <title>${l(s||"Grid Print")}</title>
128
+ <style>
129
+ body{font-family:sans-serif;font-size:11px;margin:12px}
130
+ h2{font-size:14px;margin:0 0 8px}
131
+ table{border-collapse:collapse;width:100%}
132
+ th,td{border:1px solid #bbb;padding:3px 6px;text-align:left;white-space:nowrap}
133
+ th{background:#e8e8e8;font-weight:600}
134
+ tr:nth-child(even){background:#f7f7f7}
135
+ @media print{body{margin:0}button{display:none}}
136
+ </style>
137
+ </head><body>
138
+ ${s?`<h2>${l(s)}</h2>`:""}
139
+ <button onclick="window.print()" style="margin-bottom:8px;padding:4px 12px;cursor:pointer">\u{1F5A8} ${l(o.printButton)}</button>
140
+ <table>${a}<tbody>${c}</tbody></table>
141
+ </body></html>`}var ce=class{#t;#e=new Map;#i=[];#o=[0];#s=!1;constructor(t){this.#t=t}get defaultHeight(){return this.#t}set defaultHeight(t){t!==this.#t&&(this.#t=t,this.#s=!0)}#n(){this.#i=[...this.#e.keys()].sort((t,e)=>t-e),this.#o=new Array(this.#i.length+1),this.#o[0]=0;for(let t=0;t<this.#i.length;t++){let e=this.#e.get(this.#i[t]);this.#o[t+1]=this.#o[t]+(e-this.#t)}this.#s=!1}#a(){this.#s&&this.#n()}#l(t){let e=0,s=this.#i.length;for(;e<s;){let i=e+s>>1;this.#i[i]<t?e=i+1:s=i}return e}heightOf(t){return this.#e.get(t)??this.#t}hasOverride(t){return this.#e.has(t)}setHeight(t,e){let s=Math.max(1,Math.round(e));if(s===this.#t){this.#e.delete(t)&&(this.#s=!0);return}this.#e.get(t)!==s&&(this.#e.set(t,s),this.#s=!0)}snapshotOverrides(){return new Map(this.#e)}restoreOverrides(t){this.#e=new Map(t),this.#s=!0}clear(){this.#e.size&&(this.#e.clear(),this.#s=!0)}yOf(t){return t<=0?0:(this.#a(),t*this.#t+this.#o[this.#l(t)])}rowAt(t,e){if(t<0||e<0||this.yOf(e)+this.heightOf(e)<=t)return-1;let s=0,i=e;for(;s<i;){let o=s+i+1>>1;this.yOf(o)<=t?s=o:i=o-1}return s}shiftRows(t){if(this.#e.size===0)return;let e=new Map;for(let[s,i]of this.#e)e.set(t(s),i);this.#e=e,this.#s=!0}deleteRow(t){if(this.#e.size===0)return;let e=new Map;for(let[s,i]of this.#e)s!==t&&e.set(s>t?s-1:s,i);this.#e=e,this.#s=!0}};var ks=new Intl.Collator(void 0,{numeric:!0});function Ke(r){return r==null||typeof r=="string"&&r.trim()===""?NaN:Number(r)}function Ds(r){return(t,e)=>{let s=t[r],i=e[r],o=Ke(s),n=Ke(i);return!Number.isNaN(o)&&!Number.isNaN(n)?o-n:ks.compare(String(s??""),String(i??""))}}function Ve(r,t){if(!Array.isArray(r))throw new Error("[JHGrid] opts.data must be an array");let e=t?.length?t.map(i=>i.field):Object.keys(r[0]??{});if(!e.length)throw new Error("[JHGrid] opts.data: could not resolve columns from an empty array \u2014 pass opts.columnDefs");function s(i){let{filters:o={},sorts:n=[],quickFilter:l=""}=i??{},a=r;for(let[c,h]of Object.entries(o))if(Array.isArray(h)){if(h.length===0)continue;let _=new Set(h.map(String));a=a.filter(f=>_.has(String(f[c]??"")))}else if(h){let _=String(h).toLowerCase();a=a.filter(f=>String(f[c]??"").toLowerCase().includes(_))}if(l){let c=l.toLowerCase();a=a.filter(h=>Object.values(h).some(_=>String(_??"").toLowerCase().includes(c)))}for(let{field:c,dir:h}of[...n].reverse()){let _=h==="desc"?-1:1,f=Ds(c);a=[...a].sort((d,u)=>_*f(d,u))}return a}return{fetchMeta(i){let o=s(i);return Promise.resolve({totalRows:o.length,columns:e})},fetchData(i,o,n){let l=s(n);return Promise.resolve({rows:l.slice(i*o,i*o+o)})}}}var Xe=new WeakMap;function Lt(r){let t=Xe.get(r);return t||(t={selectedRows:new Set,lastSelRow:null},Xe.set(r,t)),t}function Ue(r){return r._opts.rowSelection??"none"}var qe={resetScope:["rowIndexState","full"],clear(r){this.rowSelection.clear(r)},snapshotStructural(r,t){let e=Lt(r);t.selectedRows=new Set(e.selectedRows),t.lastSelRow=e.lastSelRow},restoreStructural(r,t){let e=Lt(r);e.selectedRows=new Set(t.selectedRows??[]),e.lastSelRow=t.lastSelRow??null},exportState(r,t){t.selectedRows=[...Lt(r).selectedRows]},importState(r,t){if(!Array.isArray(t.selectedRows))return;let e=Lt(r);e.selectedRows=new Set(t.selectedRows),e.lastSelRow=t.selectedRows.at(-1)??null,r._draw()},install(r){Object.assign(r.prototype,{getSelectedRows(){return[...Lt(this).selectedRows]},clearRowSelection(){let t=Lt(this);t.selectedRows.clear(),t.lastSelRow=null,this._draw()}})},rowSelection:{modeFor:Ue,has(r,t){return Lt(r).selectedRows.has(t)},getRenderSet(r){let t=Lt(r);return t.selectedRows.size>0?t.selectedRows:null},getSorted(r){return[...Lt(r).selectedRows].sort((t,e)=>t-e)},clear(r){let t=Lt(r);t.selectedRows.clear(),t.lastSelRow=null},shiftRows(r,t,e=-1){let s=Lt(r);if(s.selectedRows.size>0){let i=new Set;for(let o of s.selectedRows)o!==e&&i.add(t(o));s.selectedRows=i}s.lastSelRow!=null&&(s.lastSelRow=s.lastSelRow===e?null:t(s.lastSelRow))},update(r,t,e,s){let i=Ue(r);if(i==="none")return;let o=Lt(r);if(i==="single")o.selectedRows.has(t)?o.selectedRows.clear():(o.selectedRows.clear(),o.selectedRows.add(t)),o.lastSelRow=t;else if(s&&o.lastSelRow!==null){let n=Math.min(o.lastSelRow,t),l=Math.max(o.lastSelRow,t);e||o.selectedRows.clear();for(let a=n;a<=l;a++)o.selectedRows.add(a)}else e?(o.selectedRows.has(t)?o.selectedRows.delete(t):o.selectedRows.add(t),o.lastSelRow=t):(o.selectedRows.clear(),o.selectedRows.add(t),o.lastSelRow=t);r._opts.onRowSelect?.([...o.selectedRows].sort((n,l)=>n-l)),r._announce(r._i18n.rowsSelectedAnnounce(o.selectedRows.size))},clearOnCellClick(r,t){if(!r._opts.showRowNumbers||t.ctrlKey||t.metaKey||t.shiftKey)return;let e=Lt(r);e.selectedRows.size!==0&&(e.selectedRows.clear(),e.lastSelRow=null,r._opts.onRowSelect?.([]))}}};var Je=typeof requestAnimationFrame=="function",$s=typeof performance<"u"&&typeof performance.now=="function"?()=>performance.now():()=>Date.now(),Ls=r=>r*(2-r),jt=class{#t;#e;#i;#o=0;#s=0;#n=0;#a;#l;#r;#c;constructor({value:t=0,onFrame:e=null,requestFrame:s,cancelFrame:i,now:o}={}){this.#t=t,this.#e=t,this.#i=t,this.#a=e,this.#c=o??$s,this.#l=s!==void 0?s:Je?n=>requestAnimationFrame(n):null,this.#r=i!==void 0?i:Je?n=>cancelAnimationFrame(n):null}get value(){if(this.#s===0)return this.#i;let t=(this.#c()-this.#o)/this.#s;return t>=1?(this.#s=0,this.#t=this.#i,this.#i):this.#e+(this.#i-this.#e)*Ls(Math.max(0,t))}get animating(){return this.#s!==0&&this.#c()-this.#o<this.#s}set(t){this.#d(),this.#s=0,this.#t=this.#e=this.#i=t}to(t,e){if(t!==this.#i){if(!(e>0)||!this.#l){this.set(t);return}this.#e=this.value,this.#i=t,this.#o=this.#c(),this.#s=e,this.#h()}}stop(){this.#d(),this.#s=0,this.#t=this.#e=this.#i=this.value}#h(){if(this.#n||!this.#l)return;let t=()=>{this.#n=0;let e=this.animating;this.#a?.(),e&&this.#h()};this.#n=this.#l(t)}#d(){this.#n&&this.#r&&this.#r(this.#n),this.#n=0}};function Ze(r=typeof window<"u"?window:null){try{return!!r?.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches}catch{return!1}}var qt={loading:"Loading\u2026",loadError:"\u26A0 \uB370\uC774\uD130\uB97C \uBD88\uB7EC\uC624\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.",pasteTruncated:r=>`${r}\uAC1C \uAC12\uC774 \uBC94\uC704\uB97C \uBC97\uC5B4\uB098 \uBD99\uC5EC\uB123\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`,copyIncomplete:r=>`${r}\uAC1C \uD589\uC774 \uC544\uC9C1 \uBD88\uB7EC\uC624\uC9C0 \uC54A\uC544 \uBCF5\uC0AC\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4`,noData:"\uD45C\uC2DC\uD560 \uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.",emptyCell:"\uBE48 \uC140",ariaGrid:"\uB370\uC774\uD130 \uADF8\uB9AC\uB4DC",sortAsc:"\u2191 \uC624\uB984\uCC28\uC21C",sortDesc:"\u2193 \uB0B4\uB9BC\uCC28\uC21C",sortShiftHint:"Shift+\uD074\uB9AD: \uB2E4\uC911 \uC815\uB82C \uCD94\uAC00",rowNumberLabel:"\uBC88\uD638",filterLabel:"\uAC80\uC0C9",filterPlaceholder:"\uAC80\uC0C9\uC5B4 \uC785\uB825\u2026",filterApply:"\uC801\uC6A9",filterReset:"\uCD08\uAE30\uD654",filterResetAll:"\uBAA8\uB4E0 \uD544\uD130 \uCD08\uAE30\uD654",filterClose:"\uB2EB\uAE30",filterDialog:r=>`${r} \uD544\uD130`,filterColorLabel:"\uC0C9\uC0C1\uC73C\uB85C \uD544\uD130",filterValuesLabel:"\uAC12\uC73C\uB85C \uD544\uD130",filterSelectAll:"(\uC804\uCCB4 \uC120\uD0DD)",filterTagPlaceholder:"\uAC12 \uAC80\uC0C9\u2026",filterTagLocalScope:"\uB85C\uB4DC\uB41C \uBC94\uC704\uC5D0\uC11C",filterTagNoMatch:"\uC77C\uCE58\uD558\uB294 \uAC12 \uC5C6\uC74C",filterTagMinChars:r=>`${r}\uAE00\uC790 \uC774\uC0C1 \uC785\uB825\uD558\uC138\uC694`,filterTagAllSelected:"\uC77C\uCE58\uD558\uB294 \uAC12\uC744 \uBAA8\uB450 \uC120\uD0DD\uD568",filterTagMore:r=>`\uC678 ${r}\uAC1C \u2014 \uAC80\uC0C9\uC5B4\uB97C \uC881\uD600\uBCF4\uC138\uC694`,filterTagSelected:r=>`\uC120\uD0DD\uD55C \uAC12 (${r})`,filterTagContains:r=>`"${r}" \uD3EC\uD568`,filterTagRemove:r=>`${r} \uC81C\uAC70`,colFreeze:"\uC5F4 \uACE0\uC815",colUnfreeze:"\uC5F4 \uACE0\uC815 \uD574\uC81C",colFreezeRight:"\uC624\uB978\uCABD \uC5F4 \uACE0\uC815",colUnfreezeRight:"\uC624\uB978\uCABD \uC5F4 \uACE0\uC815 \uD574\uC81C",colVisibility:"\uC5F4 \uD45C\uC2DC/\uC228\uAE30\uAE30\u2026",colChooserTitle:"\uC5F4 \uD45C\uC2DC/\uC228\uAE30\uAE30",colChooserApply:"\uC801\uC6A9",colChooserCancel:"\uCDE8\uC18C",colChooserSelectAll:"\uC804\uCCB4 \uC120\uD0DD",colInsertLeft:"\uC67C\uCABD\uC5D0 \uC5F4 \uC0BD\uC785",colInsertRight:"\uC624\uB978\uCABD\uC5D0 \uC5F4 \uC0BD\uC785",colInsertTitle:"\uC5F4 \uCD94\uAC00",colInsertPlaceholder:"\uC5F4 \uC774\uB984 \uC785\uB825",colInsertConfirm:"\uCD94\uAC00",colInsertCancel:"\uCDE8\uC18C",colDelete:"\uC774 \uC5F4 \uC0AD\uC81C",colUndelete:"\uC0AD\uC81C \uCDE8\uC18C",rowInsertTop:"\uB9E8 \uC704\uC5D0 \uD589 \uC0BD\uC785",rowInsertBottom:"\uB9E8 \uC544\uB798\uC5D0 \uD589 \uC0BD\uC785",rowInsertAbove:"\uC704\uC5D0 \uD589 \uC0BD\uC785",rowInsertBelow:"\uC544\uB798\uC5D0 \uD589 \uC0BD\uC785",rowAddEnd:"\uD589 \uCD94\uAC00",rowDelete:"\uC774 \uD589 \uC0AD\uC81C",rowDeleteMark:"\uC774 \uD589 \uC0AD\uC81C \uD45C\uC2DC",rowDeletePermanent:"\uC774 \uD589 \uC644\uC804 \uC0AD\uC81C",rowUndelete:"\uC0AD\uC81C \uCDE8\uC18C",editAriaLabel:(r,t)=>`${r} \uD3B8\uC9D1, ${t}\uD589`,announceCell:(r,t,e)=>`${r}\uD589 ${t}: ${e}`,columnHeaderAnnounce:r=>`${r} \uC5F4 \uBA38\uB9AC\uAE00. Enter: \uC815\uB82C/\uD544\uD130 \uBA54\uB274. \uBA54\uB274 \uD0A4: \uC5F4 \uC635\uC158.`,rowHeaderAnnounce:r=>`${r}\uD589. \uBA54\uB274 \uD0A4: \uD589 \uC635\uC158.`,rowReorderAnnounce:(r,t)=>`${r}\uD589\uC744 ${t}\uD589 \uC704\uCE58\uB85C \uC774\uB3D9\uD588\uC2B5\uB2C8\uB2E4.`,sortAppliedAnnounce:(r,t)=>`${r} ${t==="asc"?"\uC624\uB984\uCC28\uC21C":"\uB0B4\uB9BC\uCC28\uC21C"} \uC815\uB82C \uC801\uC6A9\uB428.`,filterAppliedAnnounce:r=>`${r}\uC5D0 \uD544\uD130\uAC00 \uC801\uC6A9\uB418\uC5C8\uC2B5\uB2C8\uB2E4.`,filterClearedAnnounce:r=>`${r} \uD544\uD130\uAC00 \uCD08\uAE30\uD654\uB418\uC5C8\uC2B5\uB2C8\uB2E4.`,allFiltersClearedAnnounce:"\uBAA8\uB4E0 \uD544\uD130\uC640 \uC815\uB82C\uC774 \uCD08\uAE30\uD654\uB418\uC5C8\uC2B5\uB2C8\uB2E4.",rowsSelectedAnnounce:r=>r===0?"\uC120\uD0DD\uC774 \uD574\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4.":`${r}\uAC1C \uD589\uC774 \uC120\uD0DD\uB418\uC5C8\uC2B5\uB2C8\uB2E4.`,unsavedEditsWarning:"\uC800\uC7A5\uD558\uC9C0 \uC54A\uC740 \uD3B8\uC9D1\uC774 \uC788\uC2B5\uB2C8\uB2E4. \uC774 \uBCC0\uACBD\uC744 \uC801\uC6A9\uD558\uBA74 \uD3B8\uC9D1\uC774 \uC0AD\uC81C\uB429\uB2C8\uB2E4. \uACC4\uC18D\uD558\uC2DC\uACA0\uC2B5\uB2C8\uAE4C?",exportCsvFilename:"export.csv",exportExcelFilename:"export.xlsx",exportSheetName:"Sheet1",printButton:"\uC778\uC1C4",validationRequired:r=>`${r}\uC740(\uB294) \uD544\uC218 \uC785\uB825 \uD56D\uBAA9\uC785\uB2C8\uB2E4.`,validationPattern:r=>`${r} \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.`,validationMin:(r,t)=>`${r}\uC740(\uB294) ${t} \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4.`,validationMax:(r,t)=>`${r}\uC740(\uB294) ${t} \uC774\uD558\uC5EC\uC57C \uD569\uB2C8\uB2E4.`,validationMinLength:(r,t)=>`${r}\uC740(\uB294) \uCD5C\uC18C ${t}\uC790 \uC774\uC0C1\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4.`,validationMaxLength:(r,t)=>`${r}\uC740(\uB294) \uCD5C\uB300 ${t}\uC790\uAE4C\uC9C0 \uC785\uB825\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.`,validationInvalid:r=>`${r} \uAC12\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.`,pagerFirst:"\uCCAB \uD398\uC774\uC9C0",pagerPrev:"\uC774\uC804 \uD398\uC774\uC9C0",pagerNext:"\uB2E4\uC74C \uD398\uC774\uC9C0",pagerLast:"\uB9C8\uC9C0\uB9C9 \uD398\uC774\uC9C0",pagerPageLabel:(r,t)=>`${r} / ${t} \uD398\uC774\uC9C0`,aggSum:"\uD569\uACC4:",aggAvg:"\uD3C9\uADE0:",aggCount:"\uAC1C\uC218:",aggMin:"\uCD5C\uC18C:",aggMax:"\uCD5C\uB300:",groupLabel:(r,t,e)=>`${r}: ${t} (${e})`,groupFooterLabel:"\uD569\uACC4"};var Jt={loading:"\u8AAD\u307F\u8FBC\u307F\u4E2D\u2026",loadError:"\u26A0 \u30C7\u30FC\u30BF\u306E\u8AAD\u307F\u8FBC\u307F\u306B\u5931\u6557\u3057\u307E\u3057\u305F\u3002",pasteTruncated:r=>`${r}\u4EF6\u304C\u7BC4\u56F2\u5916\u306E\u305F\u3081\u8CBC\u308A\u4ED8\u3051\u3089\u308C\u307E\u305B\u3093\u3067\u3057\u305F`,copyIncomplete:r=>`${r}\u884C\u304C\u672A\u8AAD\u307F\u8FBC\u307F\u306E\u305F\u3081\u30B3\u30D4\u30FC\u3055\u308C\u307E\u305B\u3093\u3067\u3057\u305F`,noData:"\u8868\u793A\u3059\u308B\u30C7\u30FC\u30BF\u304C\u3042\u308A\u307E\u305B\u3093\u3002",emptyCell:"\u7A7A\u30BB\u30EB",ariaGrid:"\u30C7\u30FC\u30BF\u30B0\u30EA\u30C3\u30C9",sortAsc:"\u2191 \u6607\u9806",sortDesc:"\u2193 \u964D\u9806",sortShiftHint:"Shift+\u30AF\u30EA\u30C3\u30AF: \u8907\u6570\u30BD\u30FC\u30C8\u306B\u8FFD\u52A0",rowNumberLabel:"No.",filterLabel:"\u691C\u7D22",filterPlaceholder:"\u691C\u7D22\u8A9E\u3092\u5165\u529B\u2026",filterApply:"\u9069\u7528",filterReset:"\u30EA\u30BB\u30C3\u30C8",filterResetAll:"\u3059\u3079\u3066\u306E\u30D5\u30A3\u30EB\u30BF\u30FC\u3092\u30EA\u30BB\u30C3\u30C8",filterClose:"\u9589\u3058\u308B",filterDialog:r=>`${r} \u30D5\u30A3\u30EB\u30BF\u30FC`,filterColorLabel:"\u8272\u3067\u30D5\u30A3\u30EB\u30BF\u30FC",filterValuesLabel:"\u5024\u3067\u30D5\u30A3\u30EB\u30BF\u30FC",filterSelectAll:"(\u3059\u3079\u3066\u9078\u629E)",filterTagPlaceholder:"\u5024\u3092\u691C\u7D22\u2026",filterTagLocalScope:"\u8AAD\u307F\u8FBC\u307F\u6E08\u307F\u306E\u7BC4\u56F2\u304B\u3089",filterTagNoMatch:"\u4E00\u81F4\u3059\u308B\u5024\u304C\u3042\u308A\u307E\u305B\u3093",filterTagMinChars:r=>`${r}\u6587\u5B57\u4EE5\u4E0A\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044`,filterTagAllSelected:"\u4E00\u81F4\u3059\u308B\u5024\u3092\u3059\u3079\u3066\u9078\u629E\u6E08\u307F",filterTagMore:r=>`\u4ED6 ${r}\u4EF6 \u2014 \u691C\u7D22\u8A9E\u3092\u7D5E\u3063\u3066\u304F\u3060\u3055\u3044`,filterTagSelected:r=>`\u9078\u629E\u3057\u305F\u5024 (${r})`,filterTagContains:r=>`"${r}" \u3092\u542B\u3080`,filterTagRemove:r=>`${r} \u3092\u524A\u9664`,colFreeze:"\u5217\u3092\u56FA\u5B9A",colUnfreeze:"\u5217\u306E\u56FA\u5B9A\u3092\u89E3\u9664",colFreezeRight:"\u53F3\u5074\u306E\u5217\u3092\u56FA\u5B9A",colUnfreezeRight:"\u53F3\u5074\u306E\u5217\u306E\u56FA\u5B9A\u3092\u89E3\u9664",colVisibility:"\u5217\u306E\u8868\u793A/\u975E\u8868\u793A\u2026",colChooserTitle:"\u5217\u306E\u8868\u793A/\u975E\u8868\u793A",colChooserApply:"\u9069\u7528",colChooserCancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",colChooserSelectAll:"\u3059\u3079\u3066\u9078\u629E",colInsertLeft:"\u5DE6\u306B\u5217\u3092\u633F\u5165",colInsertRight:"\u53F3\u306B\u5217\u3092\u633F\u5165",colInsertTitle:"\u5217\u3092\u8FFD\u52A0",colInsertPlaceholder:"\u5217\u540D\u3092\u5165\u529B",colInsertConfirm:"\u8FFD\u52A0",colInsertCancel:"\u30AD\u30E3\u30F3\u30BB\u30EB",colDelete:"\u3053\u306E\u5217\u3092\u524A\u9664",colUndelete:"\u524A\u9664\u3092\u5143\u306B\u623B\u3059",rowInsertTop:"\u5148\u982D\u306B\u884C\u3092\u633F\u5165",rowInsertBottom:"\u672B\u5C3E\u306B\u884C\u3092\u633F\u5165",rowInsertAbove:"\u4E0A\u306B\u884C\u3092\u633F\u5165",rowInsertBelow:"\u4E0B\u306B\u884C\u3092\u633F\u5165",rowAddEnd:"\u884C\u3092\u8FFD\u52A0",rowDelete:"\u3053\u306E\u884C\u3092\u524A\u9664",rowDeleteMark:"\u3053\u306E\u884C\u306B\u524A\u9664\u30DE\u30FC\u30AF",rowDeletePermanent:"\u3053\u306E\u884C\u3092\u5B8C\u5168\u306B\u524A\u9664",rowUndelete:"\u524A\u9664\u3092\u5143\u306B\u623B\u3059",editAriaLabel:(r,t)=>`${r} \u3092\u7DE8\u96C6, ${t} \u884C\u76EE`,announceCell:(r,t,e)=>`${r} \u884C\u76EE ${t}: ${e}`,columnHeaderAnnounce:r=>`${r} \u5217\u30D8\u30C3\u30C0\u30FC\u3002Enter: \u30BD\u30FC\u30C8/\u30D5\u30A3\u30EB\u30BF\u30FC\u30E1\u30CB\u30E5\u30FC\u3002\u30E1\u30CB\u30E5\u30FC\u30AD\u30FC: \u5217\u30AA\u30D7\u30B7\u30E7\u30F3\u3002`,rowHeaderAnnounce:r=>`${r} \u884C\u76EE\u3002\u30E1\u30CB\u30E5\u30FC\u30AD\u30FC: \u884C\u30AA\u30D7\u30B7\u30E7\u30F3\u3002`,rowReorderAnnounce:(r,t)=>`${r} \u884C\u76EE\u3092 ${t} \u884C\u76EE\u306B\u79FB\u52D5\u3057\u307E\u3057\u305F\u3002`,sortAppliedAnnounce:(r,t)=>`${r} \u3092${t==="asc"?"\u6607\u9806":"\u964D\u9806"}\u306B\u4E26\u3079\u66FF\u3048\u307E\u3057\u305F\u3002`,filterAppliedAnnounce:r=>`${r} \u306B\u30D5\u30A3\u30EB\u30BF\u30FC\u304C\u9069\u7528\u3055\u308C\u307E\u3057\u305F\u3002`,filterClearedAnnounce:r=>`${r} \u306E\u30D5\u30A3\u30EB\u30BF\u30FC\u304C\u89E3\u9664\u3055\u308C\u307E\u3057\u305F\u3002`,allFiltersClearedAnnounce:"\u3059\u3079\u3066\u306E\u30D5\u30A3\u30EB\u30BF\u30FC\u3068\u30BD\u30FC\u30C8\u304C\u89E3\u9664\u3055\u308C\u307E\u3057\u305F\u3002",rowsSelectedAnnounce:r=>r===0?"\u9078\u629E\u304C\u89E3\u9664\u3055\u308C\u307E\u3057\u305F\u3002":`${r} \u884C\u304C\u9078\u629E\u3055\u308C\u307E\u3057\u305F\u3002`,unsavedEditsWarning:"\u4FDD\u5B58\u3055\u308C\u3066\u3044\u306A\u3044\u7DE8\u96C6\u5185\u5BB9\u304C\u3042\u308A\u307E\u3059\u3002\u3053\u306E\u5909\u66F4\u3092\u9069\u7528\u3059\u308B\u3068\u7834\u68C4\u3055\u308C\u307E\u3059\u3002\u7D9A\u884C\u3057\u307E\u3059\u304B?",exportCsvFilename:"export.csv",exportExcelFilename:"export.xlsx",exportSheetName:"Sheet1",printButton:"\u5370\u5237",validationRequired:r=>`${r} \u306F\u5FC5\u9808\u9805\u76EE\u3067\u3059\u3002`,validationPattern:r=>`${r} \u306E\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002`,validationMin:(r,t)=>`${r} \u306F ${t} \u4EE5\u4E0A\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002`,validationMax:(r,t)=>`${r} \u306F ${t} \u4EE5\u4E0B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002`,validationMinLength:(r,t)=>`${r} \u306F ${t} \u6587\u5B57\u4EE5\u4E0A\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,validationMaxLength:(r,t)=>`${r} \u306F ${t} \u6587\u5B57\u4EE5\u5185\u3067\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,validationInvalid:r=>`${r} \u306E\u5024\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002`,pagerFirst:"\u6700\u521D\u306E\u30DA\u30FC\u30B8",pagerPrev:"\u524D\u306E\u30DA\u30FC\u30B8",pagerNext:"\u6B21\u306E\u30DA\u30FC\u30B8",pagerLast:"\u6700\u5F8C\u306E\u30DA\u30FC\u30B8",pagerPageLabel:(r,t)=>`${t} \u30DA\u30FC\u30B8\u4E2D ${r} \u30DA\u30FC\u30B8\u76EE`,aggSum:"\u5408\u8A08:",aggAvg:"\u5E73\u5747:",aggCount:"\u4EF6\u6570:",aggMin:"\u6700\u5C0F:",aggMax:"\u6700\u5927:",groupLabel:(r,t,e)=>`${r}: ${t} (${e})`,groupFooterLabel:"\u5408\u8A08"};var Zt={loading:"\u52A0\u8F7D\u4E2D\u2026",loadError:"\u26A0 \u6570\u636E\u52A0\u8F7D\u5931\u8D25\u3002",pasteTruncated:r=>`${r} \u4E2A\u503C\u8D85\u51FA\u8303\u56F4\uFF0C\u672A\u88AB\u7C98\u8D34`,copyIncomplete:r=>`${r} \u884C\u5C1A\u672A\u52A0\u8F7D\uFF0C\u672A\u88AB\u590D\u5236`,noData:"\u6682\u65E0\u6570\u636E\u3002",emptyCell:"\u7A7A\u5355\u5143\u683C",ariaGrid:"\u6570\u636E\u8868\u683C",sortAsc:"\u2191 \u5347\u5E8F",sortDesc:"\u2193 \u964D\u5E8F",sortShiftHint:"Shift+\u70B9\u51FB\uFF1A\u6DFB\u52A0\u591A\u91CD\u6392\u5E8F",rowNumberLabel:"\u5E8F\u53F7",filterLabel:"\u641C\u7D22",filterPlaceholder:"\u8BF7\u8F93\u5165\u641C\u7D22\u5185\u5BB9\u2026",filterApply:"\u5E94\u7528",filterReset:"\u91CD\u7F6E",filterResetAll:"\u91CD\u7F6E\u6240\u6709\u7B5B\u9009",filterClose:"\u5173\u95ED",filterDialog:r=>`${r} \u7B5B\u9009`,filterColorLabel:"\u6309\u989C\u8272\u7B5B\u9009",filterValuesLabel:"\u6309\u503C\u7B5B\u9009",filterSelectAll:"(\u5168\u9009)",filterTagPlaceholder:"\u641C\u7D22\u503C\u2026",filterTagLocalScope:"\u4EC5\u6765\u81EA\u5DF2\u52A0\u8F7D\u7684\u884C",filterTagNoMatch:"\u6CA1\u6709\u5339\u914D\u7684\u503C",filterTagMinChars:r=>`\u8BF7\u8F93\u5165\u81F3\u5C11 ${r} \u4E2A\u5B57\u7B26`,filterTagAllSelected:"\u5339\u914D\u7684\u503C\u5DF2\u5168\u90E8\u9009\u62E9",filterTagMore:r=>`\u53E6\u6709 ${r} \u4E2A \u2014 \u8BF7\u7F29\u5C0F\u641C\u7D22\u8303\u56F4`,filterTagSelected:r=>`\u5DF2\u9009\u503C (${r})`,filterTagContains:r=>`\u5305\u542B "${r}"`,filterTagRemove:r=>`\u79FB\u9664 ${r}`,colFreeze:"\u51BB\u7ED3\u5217",colUnfreeze:"\u53D6\u6D88\u51BB\u7ED3\u5217",colFreezeRight:"\u51BB\u7ED3\u53F3\u4FA7\u5217",colUnfreezeRight:"\u53D6\u6D88\u51BB\u7ED3\u53F3\u4FA7\u5217",colVisibility:"\u5217\u7684\u663E\u793A/\u9690\u85CF\u2026",colChooserTitle:"\u5217\u7684\u663E\u793A/\u9690\u85CF",colChooserApply:"\u5E94\u7528",colChooserCancel:"\u53D6\u6D88",colChooserSelectAll:"\u5168\u9009",colInsertLeft:"\u5728\u5DE6\u4FA7\u63D2\u5165\u5217",colInsertRight:"\u5728\u53F3\u4FA7\u63D2\u5165\u5217",colInsertTitle:"\u6DFB\u52A0\u5217",colInsertPlaceholder:"\u8BF7\u8F93\u5165\u5217\u540D",colInsertConfirm:"\u6DFB\u52A0",colInsertCancel:"\u53D6\u6D88",colDelete:"\u5220\u9664\u6B64\u5217",colUndelete:"\u64A4\u9500\u5220\u9664",rowInsertTop:"\u5728\u9876\u90E8\u63D2\u5165\u884C",rowInsertBottom:"\u5728\u5E95\u90E8\u63D2\u5165\u884C",rowInsertAbove:"\u5728\u4E0A\u65B9\u63D2\u5165\u884C",rowInsertBelow:"\u5728\u4E0B\u65B9\u63D2\u5165\u884C",rowAddEnd:"\u6DFB\u52A0\u884C",rowDelete:"\u5220\u9664\u6B64\u884C",rowDeleteMark:"\u6807\u8BB0\u6B64\u884C\u4E3A\u5220\u9664",rowDeletePermanent:"\u5F7B\u5E95\u5220\u9664\u6B64\u884C",rowUndelete:"\u64A4\u9500\u5220\u9664",editAriaLabel:(r,t)=>`\u7F16\u8F91 ${r}\uFF0C\u7B2C ${t} \u884C`,announceCell:(r,t,e)=>`\u7B2C ${r} \u884C ${t}\uFF1A${e}`,columnHeaderAnnounce:r=>`${r} \u5217\u6807\u9898\u3002Enter\uFF1A\u6392\u5E8F/\u7B5B\u9009\u83DC\u5355\u3002\u83DC\u5355\u952E\uFF1A\u5217\u9009\u9879\u3002`,rowHeaderAnnounce:r=>`\u7B2C ${r} \u884C\u3002\u83DC\u5355\u952E\uFF1A\u884C\u9009\u9879\u3002`,rowReorderAnnounce:(r,t)=>`\u5DF2\u5C06\u7B2C ${r} \u884C\u79FB\u52A8\u5230\u7B2C ${t} \u884C\u3002`,sortAppliedAnnounce:(r,t)=>`${r} \u5DF2\u6309${t==="asc"?"\u5347\u5E8F":"\u964D\u5E8F"}\u6392\u5E8F\u3002`,filterAppliedAnnounce:r=>`\u5DF2\u5BF9 ${r} \u5E94\u7528\u7B5B\u9009\u3002`,filterClearedAnnounce:r=>`\u5DF2\u6E05\u9664 ${r} \u7684\u7B5B\u9009\u3002`,allFiltersClearedAnnounce:"\u5DF2\u6E05\u9664\u6240\u6709\u7B5B\u9009\u548C\u6392\u5E8F\u3002",rowsSelectedAnnounce:r=>r===0?"\u5DF2\u53D6\u6D88\u9009\u62E9\u3002":`\u5DF2\u9009\u62E9 ${r} \u884C\u3002`,unsavedEditsWarning:"\u60A8\u6709\u5C1A\u672A\u4FDD\u5B58\u7684\u7F16\u8F91\u5185\u5BB9\uFF0C\u6B64\u66F4\u6539\u5C06\u4E22\u5F03\u8FD9\u4E9B\u5185\u5BB9\u3002\u662F\u5426\u7EE7\u7EED\uFF1F",exportCsvFilename:"export.csv",exportExcelFilename:"export.xlsx",exportSheetName:"Sheet1",printButton:"\u6253\u5370",validationRequired:r=>`${r} \u4E3A\u5FC5\u586B\u9879\u3002`,validationPattern:r=>`${r} \u683C\u5F0F\u4E0D\u6B63\u786E\u3002`,validationMin:(r,t)=>`${r} \u4E0D\u80FD\u5C0F\u4E8E ${t}\u3002`,validationMax:(r,t)=>`${r} \u4E0D\u80FD\u5927\u4E8E ${t}\u3002`,validationMinLength:(r,t)=>`${r} \u81F3\u5C11\u9700\u8981 ${t} \u4E2A\u5B57\u7B26\u3002`,validationMaxLength:(r,t)=>`${r} \u6700\u591A\u5141\u8BB8 ${t} \u4E2A\u5B57\u7B26\u3002`,validationInvalid:r=>`${r} \u7684\u503C\u65E0\u6548\u3002`,pagerFirst:"\u9996\u9875",pagerPrev:"\u4E0A\u4E00\u9875",pagerNext:"\u4E0B\u4E00\u9875",pagerLast:"\u672B\u9875",pagerPageLabel:(r,t)=>`\u7B2C ${r} / ${t} \u9875`,aggSum:"\u603B\u8BA1\uFF1A",aggAvg:"\u5E73\u5747\u503C\uFF1A",aggCount:"\u8BA1\u6570\uFF1A",aggMin:"\u6700\u5C0F\u503C\uFF1A",aggMax:"\u6700\u5927\u503C\uFF1A",groupLabel:(r,t,e)=>`${r}\uFF1A${t}\uFF08${e}\uFF09`,groupFooterLabel:"\u5408\u8BA1"};var Se={loading:"Loading\u2026",loadError:"\u26A0 Failed to load data.",pasteTruncated:r=>`${r} value(s) did not fit and were not pasted`,copyIncomplete:r=>`${r} row(s) hadn't loaded yet and were not copied`,noData:"No data to display.",emptyCell:"Empty cell",ariaGrid:"Data grid",sortAsc:"\u2191 Ascending",sortDesc:"\u2193 Descending",sortShiftHint:"Shift+click: add to multi-sort",rowNumberLabel:"No.",filterLabel:"Search",filterPlaceholder:"Enter search term\u2026",filterApply:"Apply",filterReset:"Reset",filterResetAll:"Reset all filters",filterClose:"Close",filterDialog:r=>`${r} Filter`,filterColorLabel:"Filter by color",filterValuesLabel:"Filter by value",filterSelectAll:"(Select all)",filterTagPlaceholder:"Search values\u2026",filterTagLocalScope:"From loaded rows only",filterTagNoMatch:"No matching values",filterTagMinChars:r=>`Type at least ${r} characters`,filterTagAllSelected:"All matches already selected",filterTagMore:r=>`+${r} more \u2014 narrow the search`,filterTagSelected:r=>`Selected (${r})`,filterTagContains:r=>`Contains "${r}"`,filterTagRemove:r=>`Remove ${r}`,colFreeze:"Freeze column",colUnfreeze:"Unfreeze column",colFreezeRight:"Freeze columns to the right",colUnfreezeRight:"Unfreeze columns to the right",colVisibility:"Column visibility\u2026",colChooserTitle:"Column Visibility",colChooserApply:"Apply",colChooserCancel:"Cancel",colChooserSelectAll:"Select all",colInsertLeft:"Insert column left",colInsertRight:"Insert column right",colInsertTitle:"Add column",colInsertPlaceholder:"Column name",colInsertConfirm:"Add",colInsertCancel:"Cancel",colDelete:"Delete column",colUndelete:"Undo delete",rowInsertTop:"Insert row at top",rowInsertBottom:"Insert row at bottom",rowInsertAbove:"Insert row above",rowInsertBelow:"Insert row below",rowAddEnd:"Add row",rowDelete:"Delete row",rowDeleteMark:"Mark row for deletion",rowDeletePermanent:"Delete row permanently",rowUndelete:"Undo delete",editAriaLabel:(r,t)=>`Edit ${r}, row ${t}`,announceCell:(r,t,e)=>`Row ${r}, ${t}: ${e}`,columnHeaderAnnounce:r=>`${r} column header. Enter: sort/filter menu. Context menu key: column options.`,rowHeaderAnnounce:r=>`Row ${r}. Context menu key: row options.`,rowReorderAnnounce:(r,t)=>`Moved row ${r} to position ${t}.`,sortAppliedAnnounce:(r,t)=>`${r} sorted ${t==="asc"?"ascending":"descending"}.`,filterAppliedAnnounce:r=>`Filter applied to ${r}.`,filterClearedAnnounce:r=>`Filter cleared for ${r}.`,allFiltersClearedAnnounce:"All filters and sorts cleared.",rowsSelectedAnnounce:r=>r===0?"Selection cleared.":r===1?"1 row selected.":`${r} rows selected.`,unsavedEditsWarning:"You have unsaved edits. This change will discard them. Continue?",exportCsvFilename:"export.csv",exportExcelFilename:"export.xlsx",exportSheetName:"Sheet1",printButton:"Print",validationRequired:r=>`${r} is required.`,validationPattern:r=>`${r} format is invalid.`,validationMin:(r,t)=>`${r} must be at least ${t}.`,validationMax:(r,t)=>`${r} must be at most ${t}.`,validationMinLength:(r,t)=>`${r} must be at least ${t} characters.`,validationMaxLength:(r,t)=>`${r} must be at most ${t} characters.`,validationInvalid:r=>`${r} is invalid.`,pagerFirst:"First page",pagerPrev:"Previous page",pagerNext:"Next page",pagerLast:"Last page",pagerPageLabel:(r,t)=>`Page ${r} of ${t}`,aggSum:"Sum:",aggAvg:"Avg:",aggCount:"Count:",aggMin:"Min:",aggMax:"Max:",groupLabel:(r,t,e)=>`${r}: ${t} (${e})`,groupFooterLabel:"Total"};var Fs={en:Se,ko:qt,ja:Jt,zh:Zt},Ps=r=>String(r??"").toLowerCase().split("-")[0];function Qe(r){return Fs[Ps(r)]??Se}function ts(r){return r||"en-US"}var Bs={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]},Ot=5,es=30,ss=16,Hs=500,Os=40,zs=120,Is=220,Ws=110,Ns=90,is=1200,Ee="position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;",os="position:absolute;opacity:0;pointer-events:none;border:0;margin:0;padding:0;background:transparent;outline:none;",js={width:1200,height:700,rowHeight:28,colWidth:130,headerHeight:30,columnLetterHeader:!1,scrollbarSize:12,chunkSize:300,maxCachedChunks:50,editableCols:[],deleteMode:"mark",frozenCols:0,frozenColsRight:0,rowReorder:!1,responsive:!1,rowSelection:"none",showRowNumbers:!0};function Ys(r,t,e){let s=null,i=null;return{fetchMeta:function(o){let n=Promise.resolve(r(0,t,o));return s=n,i=o,n.then(function(l){let a=l.columns??e?.map(function(c){return c.field});if(!a)throw new Error("[JHGrid] opts.fetchPage: resolve { columns } or pass opts.columnDefs");return{totalRows:l.totalRows,columns:a}})},fetchData:function(o,n,l){let c=o===0&&n===t&&s&&i===l?s:Promise.resolve(r(o,n,l));return s=null,i=null,c.then(function(h){return{rows:h.rows}})}}}var Qt=class r{static _plugins=[];static use(t){r._plugins.includes(t)||(r._plugins.push(t),t.install?.(r))}static _plugin(t){return r._plugins.find(e=>e[t])?.[t]??null}_clearPlugins(t){for(let e of r._plugins)e.resetScope?.includes(t)&&e.clear?.(this)}_opts;_canvas;_container;_wrapper;_loadingEl;_liveRegion;_a11yHead;_a11yBody;_a11yActiveRow;_a11yActiveCell;_dm;_renderer;_scrollTop=0;_scrollLeft=0;_ticking=!1;_drag=null;_totalRows=0;_columns=[];_columnLabels=[];_columnAligns=[];_columnHeaderAligns=[];_colDefMap=new Map;_edits=new Map;_editedRows=new Set;_validator;_undoMgr=new ne(100);_editTxn=null;_sel=null;_selAnchor=null;_selDragging=!1;_selDragStart=null;_dragScrollDir={dx:0,dy:0};_dragScrollPos=null;_dragScrollTimer=null;_lastCopyMissingRows=0;_isLocalData=!1;_pastedImageUrls=new Set;_headerFocusCol=null;_rowFocus=null;_colDrag=null;_colResize=null;_colContextMenu=null;_rowContextMenu=null;_cellContextMenu=null;_columnWidths=[];_columnRenderers=[];_headerCheckboxState=new Map;_editing=null;_editableCols=null;_filters=new Map;_trivialSetFilters=new Set;_searchModeCols=new Set;_sorts=[];_filterPanel=null;_quickFilter="";_rowDrag=null;_rowOrderData=null;_rowOrderGen=0;_rowOrderScanPending=!1;_rowResize=null;_uid=Math.random().toString(36).slice(2,9);_destroyed=!1;_booting=!1;_bootPromise=null;_readyResolve;_readyPromise=new Promise(t=>{this._readyResolve=t});_announceRaf=0;_schedRaf=0;_scrolling=!1;_scrollEndTimer=null;_skeletonRaf=0;_hcMq=null;_hcMqHandler=null;_dprMq=null;_dprMqHandler=null;_i18n={};_emptyEl=null;_resizeObserver=null;_ev={};_touch=null;_lastTap={time:0,row:-1,col:-1};_rowTap=null;_longPressTimer=null;_columnOriginalOrder=[];_hiddenColumns=new Map;_columnWidthMap=new Map;_colChooser=null;_newColDialog=null;_fillDrag=null;_fillPreview=null;_localRows=[];_pendingLocalState=null;_deletedRows=new Set;_serverTotal=0;_rowPlan=new ae;_localColumns=new Map;_deletedColumns=new Set;_newColSeq=1;_cellTooltip=null;_tooltipTimer=null;_errorBannerEl=null;_errorBannerTimer=null;_pagination=null;_page=0;_pagerBar=null;constructor(t){if(typeof window>"u")throw new Error("[JHGrid] JHGrid requires a browser environment. For SSR frameworks (Next.js, Nuxt, SvelteKit), import and instantiate only on the client side (e.g. inside useEffect / onMounted).");if(!t?.container)throw new Error("[JHGrid] opts.container is required");if(this._opts={...js,...t,theme:{...Ut,locale:ts(t.locale),...t.theme??{}}},t.responsive){let s=["width","height"].filter(i=>t[i]!=null);s.length&&console.warn(`[JHGrid] opts.${s.join(" and opts.")} ${s.length>1?"are":"is"} ignored while opts.responsive is true \u2014 the container element's CSS size determines the grid size instead. Set width/height (or max-width) via CSS on the container element, not via opts.${s[0]}.`)}if(!this._opts.headerRows?.length){let s=Te(t.columnDefs);s&&(this._opts.headerRows=s)}if(this._i18n={...Qe(t.locale),...t.i18n??{}},t.pagination?.enabled){let s=typeof t.pagination.pageSize=="number"&&t.pagination.pageSize>0?Math.floor(t.pagination.pageSize):50;this._pagination={enabled:!0,pageSize:s},this._opts.chunkSize=s}if(t.fetchPage&&!t.fetchMeta&&!t.fetchData){let s=Ys(t.fetchPage,this._opts.chunkSize,t.columnDefs);this._opts.fetchMeta=s.fetchMeta,this._opts.fetchData=s.fetchData}if(t.data&&!t.fetchMeta&&!t.fetchData&&!t.fetchPage){let s=Ve(t.data,t.columnDefs);this._opts.fetchMeta=s.fetchMeta,this._opts.fetchData=s.fetchData,this._isLocalData=!0}if(!this._opts.fetchMeta)throw new Error("[JHGrid] opts.fetchMeta is required (or provide opts.data / opts.fetchPage instead)");if(!this._opts.fetchData)throw new Error("[JHGrid] opts.fetchData is required (or provide opts.data / opts.fetchPage instead)");this._rowLayout=new ce(this._opts.rowHeight),this._editableCols=t.editableCols==="*"?null:new Set(t.editableCols??[]),(t.columnDefs??[]).forEach(({field:s,label:i,align:o,headerAlign:n,width:l,renderer:a,editor:c,editorOptions:h,editable:_,type:f,format:d,options:u,validation:p,button:w,aggregate:m,treeColumn:C,group:S,headerCheckbox:y})=>this._colDefMap.set(s,{label:i,align:o,headerAlign:n,width:l,renderer:a,editor:c,editorOptions:h,editable:_,type:f,format:d,options:u,validation:p,button:w,aggregate:m,treeColumn:C,group:S,headerCheckbox:y})),t.hiddenColumns?.length&&t.hiddenColumns.forEach(s=>this._hiddenColumns.set(s,null)),this._validator=new re({getColumnDef:s=>this._colDefMap.get(s),getColumnLabel:s=>this._columnLabels[this._columns.indexOf(s)]??s,getI18n:()=>this._i18n,getRowData:s=>this._getRow(s),onError:(s,i,o)=>this._opts.onValidationError?.(s,i,o)}),this._mount(),this._dm=new Yt({fetchData:(s,i)=>this._opts.fetchData(s,i,null),chunkSize:this._opts.chunkSize,maxChunks:this._opts.maxCachedChunks}),this._dm.onChunkLoaded=()=>{this._scrolling||this._schedDraw()},this._dm.onChunkError=s=>{this._opts.onChunkError?.(s),this._showErrorBanner(this._i18n.loadError)},this._imageLoadListener=()=>{this._scrolling||this._schedDraw()},$e(this._imageLoadListener),this._renderer=new Gt(this._canvas,this._opts),this._remoteSelections=[],this._hoverRow=null,this._hoverTarget=0,this._hoverFade=new jt({onFrame:()=>this._schedDraw()});let e=Ze();this._reducedMotion=e,this._hoverFadeMs=e?0:this._opts.hoverFadeMs??Ws,this._selKey=null,this._selLast=null,this._selPrev=null,this._selMove=new jt({value:1,onFrame:()=>this._schedDraw()}),this._selMoveMs=e?0:this._opts.selectionMoveMs??Ns,this._scrollFrom={y:0,x:0},this._scrollAim={y:0,x:0},this._scrollWrote={y:0,x:0},this._scrollEase=new jt({value:1,onFrame:()=>this._onScrollFrame()}),this._scrollEaseMs=e?0:this._opts.scrollEaseMs??zs,this._colSlide=null,this._colSlideTween=new jt({value:1,onFrame:()=>this._schedDraw()}),this._colSlideMs=e?0:this._opts.columnSlideMs??Is,this._bind(),this._initResizeObserver(),this._initHighContrast(),this._watchDpr(),this._boot()}_mount(){let{container:t,width:e,height:s}=this._opts,i=typeof t=="string"?document.querySelector(t):t;if(!i)throw new Error(`[JHGrid] container "${t}" not found`);this._container=i,Be(i.ownerDocument??document),this._wrapper=document.createElement("div"),this._wrapper.className=L.root,Object.assign(this._wrapper.style,{position:"relative",overflow:"hidden",width:e+"px",height:s+"px",outline:"none"}),this._wrapper.setAttribute("role","grid"),this._wrapper.setAttribute("aria-label",this._opts.ariaLabel??this._i18n.ariaGrid),this._wrapper.setAttribute("aria-rowcount","0"),this._wrapper.setAttribute("aria-colcount","0"),this._wrapper.setAttribute("aria-busy","true");let o=r._plugin("rowSelection")?.modeFor(this)??"none";o!=="none"&&this._wrapper.setAttribute("aria-multiselectable",String(o==="multi")),this._wrapper.tabIndex=-1,i.appendChild(this._wrapper),this._kbProxy=document.createElement("input"),this._kbProxy.type="text",this._kbProxy.setAttribute("aria-label",this._opts.ariaLabel??this._i18n.ariaGrid),this._kbProxy.tabIndex=0,this._kbProxy.style.cssText=os,this._kbProxy.remove=()=>this._resetKbProxy(),this._wrapper.appendChild(this._kbProxy);let n=window.devicePixelRatio||1;this._canvas=document.createElement("canvas"),this._canvas.width=Math.round(e*n),this._canvas.height=Math.round(s*n),this._canvas.style.cssText=`display:block;width:${e}px;height:${s}px;outline:none;`,this._canvas.setAttribute("aria-hidden","true"),this._canvas.tabIndex=-1,this._canvas.getContext("2d").scale(n,n),this._wrapper.appendChild(this._canvas),this._loadingEl=Object.assign(document.createElement("div"),{textContent:this._i18n.loading}),this._loadingEl.className=L.loading,Object.assign(this._loadingEl.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255,255,255,0.9)",fontSize:"14px",color:b(this._opts.theme,"overlayMutedText"),fontFamily:b(this._opts.theme,"fontFamily")}),this._wrapper.appendChild(this._loadingEl),this._liveRegion=document.createElement("div"),this._liveRegion.setAttribute("aria-live","polite"),this._liveRegion.setAttribute("aria-atomic","true"),this._liveRegion.style.cssText=Ee,this._wrapper.appendChild(this._liveRegion),this._a11yHead=document.createElement("div"),this._a11yHead.setAttribute("role","rowgroup"),this._a11yHead.style.cssText=Ee,this._wrapper.appendChild(this._a11yHead),this._a11yBody=document.createElement("div"),this._a11yBody.setAttribute("role","rowgroup"),this._a11yBody.style.cssText=Ee,this._a11yActiveRow=document.createElement("div"),this._a11yActiveRow.setAttribute("role","row"),this._a11yActiveRow.setAttribute("aria-rowindex","2"),this._a11yActiveCell=document.createElement("div"),this._a11yActiveCell.setAttribute("role","gridcell"),this._a11yActiveCell.setAttribute("aria-colindex","1"),this._a11yActiveCell.setAttribute("aria-selected","false"),this._a11yActiveCell.id=`jhgrid-${this._uid}-cell`,this._a11yActiveRow.appendChild(this._a11yActiveCell),this._a11yBody.appendChild(this._a11yActiveRow),this._wrapper.appendChild(this._a11yBody);for(let l of r._plugins)l.onMount?.(this);this._emptyEl=document.createElement("div"),this._emptyEl.className=L.empty,Object.assign(this._emptyEl.style,{position:"absolute",inset:"0",display:"none",alignItems:"center",justifyContent:"center",fontSize:"14px",pointerEvents:"none",color:b(this._opts.theme,"overlayHintText"),fontFamily:b(this._opts.theme,"fontFamily")}),this._emptyEl.textContent=this._i18n.noData,this._wrapper.appendChild(this._emptyEl),this._cellTooltip=document.createElement("div"),this._cellTooltip.className=L.tooltip,this._cellTooltip.style.cssText=["position:absolute","background:#212121","color:#FFFFFF","border-radius:4px","padding:5px 9px","font-size:12px","pointer-events:none","z-index:160","max-width:320px","white-space:pre-wrap","word-break:break-all","display:none","box-shadow:0 4px 12px rgba(0,0,0,0.22)",`font-family:${b(this._opts.theme,"fontFamily")}`].join(";"),this._wrapper.appendChild(this._cellTooltip),this._pagination&&this._buildPagerBar()}_buildPagerBar(){let t=this._opts.theme,e=(...h)=>h.join(";"),s=document.createElement("nav");s.setAttribute("aria-label","Pagination"),s.className=L.pager,s.style.cssText=e("display:flex","align-items:center","justify-content:center","gap:4px","padding:8px 12px",`border-top:1px solid ${b(t,"pagerBorder")}`,`background:${b(t,"pagerBg")}`,`font-size:${t.fontSize}px`,`color:${b(t,"pagerText")}`,`font-family:${b(t,"fontFamily")}`,`width:${this._opts.width}px`,"box-sizing:border-box","user-select:none");let i=(h,_,f)=>{let d=document.createElement("button");return d.type="button",d.textContent=h,d.setAttribute("aria-label",_),d.className=L.pagerBtn,d.style.cssText=e("padding:4px 10px",`border:1px solid ${b(t,"pagerButtonBorder")}`,"border-radius:4px",`background:${b(t,"pagerButtonBg")}`,"cursor:pointer",`font-size:${t.fontSize}px`,`color:${b(t,"pagerText")}`,"min-width:28px"),d.addEventListener("click",f),d},o=i("\xAB",this._i18n.pagerFirst,()=>this.goToPage(0)),n=i("\u2039",this._i18n.pagerPrev,()=>this.prevPage()),l=document.createElement("span");l.style.cssText="display:flex;align-items:center;gap:4px;margin:0 4px;";let a=i("\u203A",this._i18n.pagerNext,()=>this.nextPage()),c=i("\xBB",this._i18n.pagerLast,()=>this.goToPage(this._pageCount()-1));s.append(o,n,l,a,c),this._container.appendChild(s),this._pagerBar={el:s,firstBtn:o,prevBtn:n,numbers:l,nextBtn:a,lastBtn:c},this._updatePagerBar()}_pagerPageWindow(){let t=this._pageCount(),e=this._page,s=Math.max(0,e-2),i=Math.min(t-1,e+2),o=Math.min(4,t-1);for(;i-s<o;)if(s>0)s--;else if(i<t-1)i++;else break;return Array.from({length:i-s+1},(n,l)=>s+l)}_updatePagerBar(){if(!this._pagerBar)return;let{firstBtn:t,prevBtn:e,numbers:s,nextBtn:i,lastBtn:o}=this._pagerBar,n=this._pageCount(),l=this._page,a=this._opts.theme,c=(...h)=>h.join(";");t.disabled=e.disabled=l<=0,o.disabled=i.disabled=l>=n-1,this._pagerBar.el.setAttribute("aria-label",this._i18n.pagerPageLabel(l+1,n)),s.replaceChildren(),this._pagerPageWindow().forEach(h=>{let _=h===l,f=document.createElement("button");f.type="button",f.textContent=String(h+1),f.className=L.pagerBtn,f.style.cssText=c("padding:4px 9px","border-radius:4px","cursor:pointer",`font-size:${a.fontSize}px`,`border:1px solid ${_?b(a,"selectionColor"):b(a,"pagerButtonBorder")}`,`background:${_?b(a,"selectionColor"):b(a,"pagerButtonBg")}`,`color:${_?b(a,"overlayAccentText"):b(a,"pagerText")}`,`font-weight:${_?"600":"400"}`),_&&f.setAttribute("aria-current","page"),f.addEventListener("click",()=>this.goToPage(h)),s.appendChild(f)})}_showErrorBanner(t,e=4e3){this._errorBannerEl||(this._errorBannerEl=document.createElement("div"),this._errorBannerEl.setAttribute("role","alert"),this._errorBannerEl.setAttribute("aria-live","assertive"),this._errorBannerEl.setAttribute("aria-atomic","true"),Object.assign(this._errorBannerEl.style,{position:"absolute",top:"4px",left:"50%",transform:"translateX(-50%)",background:"#fee2e2",color:"#991b1b",border:"1px solid #fca5a5",borderRadius:"4px",padding:"6px 14px",fontSize:"12px",fontFamily:Ut.fontFamily,zIndex:"10",whiteSpace:"nowrap",pointerEvents:"none"}),this._wrapper.appendChild(this._errorBannerEl)),this._errorBannerEl.textContent=t,this._errorBannerEl.style.display="block",clearTimeout(this._errorBannerTimer),this._errorBannerTimer=setTimeout(()=>{this._errorBannerEl&&(this._errorBannerEl.style.display="none")},e)}_initResizeObserver(){if(!this._opts.responsive||!window.ResizeObserver)return;let t=this._container.getBoundingClientRect();t.width>0&&t.height>0&&this._setSize(Math.floor(t.width),Math.floor(t.height)),this._resizeObserver=new ResizeObserver(e=>{let{width:s,height:i}=e[0].contentRect;s>0&&i>0&&this._setSize(Math.floor(s),Math.floor(i))}),this._resizeObserver.observe(this._container)}_setSize(t,e){if(this._destroyed)return;let s=this._pagerBar?this._pagerBar.el.offsetHeight:0,i=Math.max(0,e-s);this._opts.width=t,this._opts.height=i,this._wrapper.style.width=t+"px",this._wrapper.style.height=i+"px",this._canvas.style.cssText=`display:block;width:${t}px;height:${i}px;outline:none;`;let o=window.devicePixelRatio||1;this._canvas.width=Math.round(t*o),this._canvas.height=Math.round(i*o),this._canvas.getContext("2d").setTransform(o,0,0,o,0,0),this._pagerBar&&(this._pagerBar.el.style.width=t+"px"),this._clamp(this._geo()),this._draw()}_announce(t){cancelAnimationFrame(this._announceRaf),this._liveRegion.textContent="",this._announceRaf=requestAnimationFrame(()=>{this._liveRegion.textContent=t})}_updateA11yHeader(){this._a11yHead.replaceChildren(),this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._wrapper.setAttribute("aria-colcount",String(this._columns.length));let t=document.createElement("div");t.setAttribute("role","row"),t.setAttribute("aria-rowindex","1"),this._columnLabels.forEach((e,s)=>{let i=document.createElement("div");i.setAttribute("role","columnheader"),i.setAttribute("aria-colindex",String(s+1)),i.id=`jhgrid-${this._uid}-header-${s}`;let o=this._columns[s],n=this._sorts.find(l=>l.field===o);n&&i.setAttribute("aria-sort",n.dir==="asc"?"ascending":"descending"),i.textContent=e,t.appendChild(i)}),this._a11yHead.appendChild(t),this._headerFocusCol!==null&&(this._a11yActiveCell.setAttribute("aria-selected","false"),this._wrapper.setAttribute("aria-activedescendant",`jhgrid-${this._uid}-header-${this._headerFocusCol}`))}_updateA11yCell(){if(this._headerFocusCol!==null||this._rowFocus!==null)return;if(!this._sel){this._wrapper.removeAttribute("aria-activedescendant"),this._a11yActiveRow.setAttribute("aria-selected","false"),this._a11yActiveCell.setAttribute("aria-selected","false"),this._a11yActiveCell.removeAttribute("aria-invalid"),this._a11yActiveCell.textContent="";return}let t=this._sel.type==="single"?this._sel.row:this._sel.r1,e=this._sel.type==="single"?this._sel.col:this._sel.c1,s=this._columns[e],i=this._columnLabels[e]??s??"",o=this._cellVal(t,e),n=this._validator.map.get(`${t}_${s}`);this._a11yActiveRow.setAttribute("aria-rowindex",String(t+2)),this._a11yActiveRow.setAttribute("aria-selected",String(!!r._plugin("rowSelection")?.has(this,t))),this._a11yActiveCell.setAttribute("aria-colindex",String(e+1)),this._a11yActiveCell.setAttribute("aria-selected","true"),n?(this._a11yActiveCell.setAttribute("aria-invalid","true"),this._a11yActiveCell.setAttribute("aria-label",`${i}: ${o||this._i18n.emptyCell}. ${n}`)):(this._a11yActiveCell.removeAttribute("aria-invalid"),this._a11yActiveCell.setAttribute("aria-label",`${i}: ${o||this._i18n.emptyCell}`)),this._a11yActiveCell.textContent=o,this._wrapper.setAttribute("aria-activedescendant",`jhgrid-${this._uid}-cell`)}_enterHeaderFocus(t){this._headerFocusCol=t,this._updateA11yHeader();let e=this._sel?.type==="single"?this._sel.row:this._sel?.r1??0;this._ensureVisible(e,t),this._announce(this._i18n.columnHeaderAnnounce(this._columnLabels[t]??this._columns[t])),this._draw()}_exitHeaderFocus(){let t=this._headerFocusCol;this._headerFocusCol=null,this._updateA11yHeader();let e=this._sel?.type==="single"?this._sel.row:this._sel?.r1??0;this._setSel({type:"single",row:e,col:t}),this._selAnchor=null,this._updateA11yCell(),this._announce(this._i18n.announceCell(e+1,this._columnLabels[t]??this._columns[t],this._cellVal(e,t)||this._i18n.emptyCell)),this._draw()}_handleHeaderFocusKey(t){let e=this._headerFocusCol;if(t.key==="ArrowLeft"){t.preventDefault(),e>0&&this._enterHeaderFocus(e-1);return}if(t.key==="ArrowRight"){t.preventDefault(),e<this._columns.length-1&&this._enterHeaderFocus(e+1);return}if(t.key==="ArrowDown"||t.key==="Escape"){t.preventDefault(),this._exitHeaderFocus();return}if(t.key==="Enter"||t.key==="F2"||t.key===" "){t.preventDefault(),this._openFilterPanel(e);return}if(t.key==="ContextMenu"||t.shiftKey&&t.key==="F10"){t.preventDefault();let s=this._geo();this._openColContextMenu(e,this._colLeft(e,s),s.headerH)}}_enterRowFocus(t){this._rowFocus=t,this._ensureVisible(t,0),this._announce(this._i18n.rowHeaderAnnounce(t+1)),this._draw()}_exitRowFocus(){let t=this._rowFocus;this._rowFocus=null,this._setSel({type:"single",row:t,col:0}),this._selAnchor=null,this._updateA11yCell(),this._announce(this._i18n.announceCell(t+1,this._columnLabels[0]??this._columns[0],this._cellVal(t,0)||this._i18n.emptyCell)),this._draw()}_handleRowFocusKey(t){let e=this._rowFocus;if(t.key==="ArrowUp"){t.preventDefault(),e>0&&this._enterRowFocus(e-1);return}if(t.key==="ArrowDown"){t.preventDefault(),e<this._totalRows-1&&this._enterRowFocus(e+1);return}if(t.key==="ArrowRight"||t.key==="Escape"){t.preventDefault(),this._exitRowFocus();return}if((t.key==="Enter"||t.key===" ")&&(r._plugin("rowSelection")?.modeFor(this)??"none")!=="none"){t.preventDefault(),this._updateRowSel(e,t.ctrlKey||t.metaKey,t.shiftKey),this._draw();return}if(t.key==="ContextMenu"||t.shiftKey&&t.key==="F10"){t.preventDefault();let s=this._geo();this._closeFilterPanel(),this._closeColContextMenu(),this._closeCellContextMenu(),this._openRowContextMenu(e,0,this._rowLayout.yOf(e)-this._scrollTop+s.headerH)}}_focusDefaultCell(){this._setSel({type:"single",row:0,col:0}),this._selAnchor=null,this._ensureVisible(0,0),this._updateA11yCell(),this._announce(this._i18n.announceCell(1,this._columnLabels[0]??this._columns[0],this._cellVal(0,0)||this._i18n.emptyCell)),this._draw()}_watchDpr(){if(!window.matchMedia)return;this._dprMq?.removeEventListener("change",this._dprMqHandler);let t=window.devicePixelRatio||1;this._dprMq=window.matchMedia(`(resolution: ${t}dppx)`),this._dprMqHandler=()=>{this._resizeCanvas(),this._watchDpr()},this._dprMq.addEventListener("change",this._dprMqHandler)}_resizeCanvas(){this._setSize(this._opts.width,this._opts.height)}_initHighContrast(){if(!window.matchMedia)return;this._hcMq=window.matchMedia("(forced-colors: active)");let t={...this._opts.theme};this._hcMqHandler=e=>{e.matches?Object.assign(this._opts.theme,{headerBg:"ButtonFace",headerText:"ButtonText",headerBorder:"ButtonBorder",rowEven:"Canvas",rowOdd:"Canvas",cellBorder:"ButtonBorder",cellText:"CanvasText",loadingText:"GrayText",selectionColor:"Highlight",selectionFill:"rgba(0,0,0,0)",scrollbarBg:"Canvas",scrollbarThumb:"ButtonText",frozenBorder:"ButtonBorder",dragIndicatorFill:"ButtonFace",dragIndicatorLine:"Highlight",deletedRowFill:"ButtonFace",deletedRowStrike:"GrayText",invalidCellBorder:"Mark"}):Object.assign(this._opts.theme,t),this._draw()},this._hcMq.addEventListener("change",this._hcMqHandler),this._hcMqHandler(this._hcMq)}_pageBounds(){if(!this._pagination)return{start:0,rows:this._totalRows};let t=this._page*this._pagination.pageSize,e=Math.max(0,Math.min(this._pagination.pageSize,this._totalRows-t));return{start:t,rows:e}}_pageCount(){return this._pagination?Math.max(1,Math.ceil(this._totalRows/this._pagination.pageSize)):1}_switchToPage(t){if(!this._pagination||this._destroyed)return;let e=this._pageCount(),s=Math.max(0,Math.min(e-1,Math.trunc(t))),i=s!==this._page;this._editing&&this._commitEdit(),this._page=s,this._sel=null,this._selAnchor=null,this._scrollTop=this._rowLayout.yOf(s*this._pagination.pageSize),this._clamp(this._geo()),this._updateA11yHeader(),this._updateA11yCell(),this._updatePagerBar(),i&&(this._opts.onPageChange?.(this._page,e),this._announce(this._i18n.pagerPageLabel(this._page+1,e))),this._draw()}get _headerH(){return this._opts.headerHeight*((this._opts.headerRows?.length??0)+1+(this._opts.columnLetterHeader?1:0))}_geo(){let{colWidth:t,scrollbarSize:e,width:s,height:i}=this._opts,o=this._headerH,n=Math.max(0,Math.min(this._opts.frozenCols??0,this._columns.length)),l=this._columns.length,a=this._opts.showRowNumbers?this._opts.rowNumberWidth??50:0,c=new Array(l+1);c[0]=a;for(let k=0;k<l;k++)c[k+1]=c[k]+(this._columnWidths[k]??t);let h=c[n],_=Math.min(t,s);for(;n>0&&h>s-_;)n--,h=c[n];let f=Math.max(0,Math.min(this._opts.frozenColsRight??0,l-n)),d=c[l]-c[l-f];for(;f>0&&h+d>s-_;)f--,d=c[l]-c[l-f];let u=c[l-f]-h,p=r._plugins.reduce((k,P)=>k+(P.footerBandHeight?.(this)??0),0),w=i-o-p,m=Math.max(0,s-h-d),{start:C,rows:S}=this._pageBounds(),y=this._rowLayout.yOf(C),v=this._rowLayout.yOf(C+S)-y,x=v>w,B=u>m;x&&!B&&(B=u>Math.max(0,m-e)),B&&!x&&(x=v>w-e);let W=x?e:0,M=B?e:0,U=w-M,z=Math.max(0,m-W),K=s-W-d,H=y,I=H+Math.max(0,v-U),E=Math.max(0,u-z),R=U,F=v>0?Math.max(24,R*(U/v)):R,Q=I-H,A=o+(Q>0?(this._scrollTop-H)/Q*(R-F):0),O=z,D=u>0?Math.max(24,O*(z/u)):O,T=h+(E>0?this._scrollLeft/E*(O-D):0);return{SB:e,vSB:W,hSB:M,vpH:U,vpW:z,frozenCount:n,frozenWidth:h,frozenRightCount:f,frozenRightWidth:d,rightX:K,minScrollY:H,maxScrollY:I,maxScrollX:E,colPositions:c,headerH:o,footerH:p,rowNumW:a,maxRow:C+S-1,v:{x:s-W,y:o,w:x?e:0,h:x?R:0,thumbY:A,thumbH:F},h:{x:h,y:i-M,w:B?O:0,h:B?e:0,thumbX:T,thumbW:D}}}_colAtX(t,e){let{frozenCount:s,frozenWidth:i,frozenRightCount:o,rightX:n,colPositions:l,rowNumW:a}=e,c=this._columns.length;if(c===0||t<a)return null;if(t<i){for(let f=0;f<s;f++)if(t<l[f+1])return f;return null}if(o>0&&t>=n){let f=c-o,d=t-n+l[f];for(let u=f;u<c;u++)if(d<l[u+1])return u;return null}let h=c-o,_=t-i+this._scrollLeft+l[s];for(let f=s;f<h;f++)if(_<l[f+1])return f;return null}_hitCell(t,e,s=this._geo()){let{width:i,height:o}=this._opts,{headerH:n,hSB:l,vSB:a}=s;if(e<n||e>o-l||t<0||t>i-a)return null;let c=this._rowLayout.rowAt(e-n+this._scrollTop,this._totalRows-1);if(c<0)return null;let h=this._colAtX(t,s);return h===null?null:{row:c,col:h}}_hitCellClamped(t,e,s=this._geo()){let{width:i,height:o}=this._opts,{headerH:n,hSB:l,vSB:a,rowNumW:c}=s;if(this._totalRows===0||this._columns.length===0)return null;let h=Math.max(n,Math.min(o-l-1,e)),_=Math.max(c,Math.min(i-a-1,t)),f=this._rowLayout.rowAt(h-n+this._scrollTop,this._totalRows-1);if(f<0)return null;let d=this._colAtX(_,s);return d===null?null:{row:f,col:d}}_hitHeader(t,e=this._geo()){let{width:s}=this._opts;return t<0||t>s-e.vSB||t<e.rowNumW?null:this._colAtX(t,e)}_hitRowNumber(t,e,s=this._geo()){let{height:i}=this._opts;if(s.rowNumW===0||t<0||t>=s.rowNumW||e<s.headerH||e>=i-s.hSB)return null;let o=this._rowLayout.rowAt(e-s.headerH+this._scrollTop,this._totalRows-1);return o<0?null:o}_hitRowBoundary(t,e=this._geo()){let{height:s}=this._opts;if(t<e.headerH||t>=s-e.hSB)return null;let i=t-e.headerH+this._scrollTop,o=this._rowLayout.rowAt(i,this._totalRows-1);if(o<0)return null;let n=this._rowLayout.yOf(o+1)-this._scrollTop+e.headerH;if(Math.abs(t-n)<=Ot)return o;if(o>0){let l=this._rowLayout.yOf(o)-this._scrollTop+e.headerH;if(Math.abs(t-l)<=Ot)return o-1}return null}_hitFillHandle(t,e,s=this._geo()){if(!this._sel)return!1;let{headerH:i,colPositions:o}=s,n=this._sel.type==="single"?this._sel.row:this._sel.r2,l=this._sel.type==="single"?this._sel.col:this._sel.c2,a=this._colLeft(l,s)+(o[l+1]-o[l]),c=this._rowLayout.yOf(n+1)-this._scrollTop+i,h=5;return Math.abs(t-a)<=h&&Math.abs(e-c)<=h}_colLeft(t,e){return ee(t,e,this._scrollLeft)}_autoFitCol(t){let e=this._canvas.getContext("2d"),{theme:s}=this._opts,i=s.cellPadding,o=this._columns[t],n=this._columnLabels[t]??o;e.font=`bold ${s.fontSize}px ${s.fontFamily}`;let l=this._colDefMap.get(o)?.headerCheckbox?20:0,a=e.measureText(n).width+i*2+Bt+4+l,c=this._colDefMap.get(o),h=c?.type,_=h==="dropdown"||h==="multiselect"?se:0,f=s.locale;e.font=`${s.fontSize}px ${s.fontFamily}`,this._dm.forEachLoaded(u=>{let p=u?.[o];if(p==null)return;let w=Kt(p,c,f),m=e.measureText(String(w)).width+i*2+_;m>a&&(a=m)}),this._edits.forEach((u,p)=>{let w=p.indexOf("_");if(w===-1||p.slice(w+1)!==o)return;let m=Kt(u,c,f),C=e.measureText(String(m)).width+i*2+_;C>a&&(a=C)});let d=Math.max(es,Math.ceil(a));this._columnWidths[t]=d,this._columnWidthMap.set(o,d)}_selectedColsForAutoFit(){if(this._sel&&this._sel.type==="range"){let t=new Set;for(let e=this._sel.c1;e<=this._sel.c2;e++)t.add(e);return t}return null}_calcInsertBefore(t,e=this._geo()){let{width:s}=this._opts,{colPositions:i}=e,o=this._columns.length;if(t<=0)return 0;if(t>=s-e.vSB)return o;let n=this._colAtX(t,e)??0,l=this._colLeft(n,e),a=i[n+1]-i[n];return t>l+a/2?n+1:n}_startColSlide(t,e,s){if(this._colSlideMs===0){this._colSlide=null;return}let[i,o,n]=e>t?[t,e-1,t+1]:[e+1,t,e],l=this._geo().colPositions,a=s[n]-l[i];if(!a){this._colSlide=null;return}this._colSlide={c1:i,c2:o,dx:a,dragCol:e},this._colSlideTween.set(0),this._colSlideTween.to(1,this._colSlideMs)}_reorderCol(t,e,{silent:s=!1}={}){if(e===t||e===t+1)return t;this._commitEdit();let i=e>t?e-1:e,o=a=>{let c=[...a];return c.splice(i,0,c.splice(t,1)[0]),c},n=this._columns.length;this._columns=o(this._columns),this._columnLabels=o(this._columnLabels),this._columnAligns=o(this._columnAligns),this._columnHeaderAligns=o(this._columnHeaderAligns),this._columnWidths=o(this._columnWidths),this._columnRenderers=o(this._columnRenderers);let l=new Map;for(let a=0;a<n;a++)a===t?l.set(a,i):e>t&&a>t&&a<=i?l.set(a,a-1):e<t&&a>=i&&a<t?l.set(a,a+1):l.set(a,a);if(this._sel){let a=c=>l.get(c)??c;if(this._sel.type==="single")this._sel={...this._sel,col:a(this._sel.col)};else{let{r1:c,c1:h,r2:_,c2:f}=this._sel;this._sel={type:"range",...this._normRange(c,a(h),_,a(f))}}}return this._updateA11yHeader(),this._updateA11yCell(),s||this._opts.onColumnReorder?.([...this._columns]),i}_rowReorderReady(){return!!this._opts.rowReorder&&Array.isArray(this._rowOrderData)&&!r._plugins.some(t=>t.altRowSource?.(this))}async _materializeRowOrder(){if(this._rowOrderScanPending)return;this._rowOrderScanPending=!0;let t=this._rowOrderGen;try{let e=await this._scanAllRows();if(this._destroyed||e===null||t!==this._rowOrderGen||!this._opts.rowReorder||r._plugins.some(s=>s.altRowSource?.(this)))return;this._rowOrderData=e,this._applyDisplayFetch(e),this._draw()}finally{this._rowOrderScanPending=!1}}_calcRowInsertBefore(t,e=this._geo()){let s=t-e.headerH+this._scrollTop,i=this._rowPlan.serverVisible-1;if(i<0||s<=0)return 0;let o=this._rowLayout.rowAt(s,i);if(o<0)return this._rowPlan.serverVisible;let n=this._rowLayout.yOf(o),l=this._rowLayout.heightOf(o);return s-n<l/2?o:o+1}_reorderRow(t,e){if(!this._rowOrderData||e===t||e===t+1)return;let s=e>t?e-1:e,i;this._rebuildDisplayFetch(()=>([i]=this._rowOrderData.splice(t,1),this._rowOrderData.splice(s,0,i),this._rowOrderData))&&(this._opts.onRowReorder?.(t,s,i),this._announce(this._i18n.rowReorderAnnounce(t+1,s+1)))}_filterState(){return{sorts:[...this._sorts],filters:Object.fromEntries(this._filters),quickFilter:this._quickFilter}}_snapshotLocalRowState(){if(this._localRows.length===0)return null;let t=s=>{let i=[];return s.forEach((o,n)=>{let l=n.indexOf("_"),a=this._localIndexAt(Number(n.slice(0,l)));a>=0&&i.push([a,n.slice(l+1),o])}),i},e=[];return this._rowLayout.snapshotOverrides().forEach((s,i)=>{let o=this._localIndexAt(i);o>=0&&e.push([o,s])}),{edits:t(this._edits),invalid:t(this._validator.map),heights:e}}_restoreLocalRowState(){let t=this._pendingLocalState;if(this._pendingLocalState=null,!t)return;let e=s=>this._rowPlan.visualOfLocal(s);for(let[s,i,o]of t.edits)this._edits.set(`${e(s)}_${i}`,o),this._editedRows.add(e(s));for(let[s,i,o]of t.invalid)this._validator.map.set(`${e(s)}_${i}`,o);if(t.heights.length>0){let s=this._rowLayout.snapshotOverrides();for(let[i,o]of t.heights)s.set(e(i),o);this._rowLayout.restoreOverrides(s)}}_reloadFiltered({confirmUnsaved:t=!0,carryRows:e=!0}={}){if(t){let o=0;if(this._edits.forEach((n,l)=>{this._localIndexAt(Number(l.slice(0,l.indexOf("_"))))<0&&o++}),o>0&&!window.confirm(this._i18n.unsavedEditsWarning))return null}this._pendingLocalState=e?this._snapshotLocalRowState():null,e||(this._localRows.length=0,this._rowPlan.anchors.length=0);let s=this._filterState();this._cancelEdit(),this._closeRowContextMenu(),this._closeCellContextMenu();for(let o of r._plugins)o.hideTooltip?.(this);return this._cellTooltip.style.display="none",this._clearPlugins("rowIndexState"),this._clearPlugins("altView"),this._edits.clear(),this._editedRows.clear(),this._validator.clear(),this._rowLayout.clear(),this._sel=null,this._fillDrag=null,this._fillPreview=null,this._deletedRows.clear(),this._rowPlan.removed.clear(),this._rowPlan.detachAnchors(),this._undoMgr.clear(),this._editTxn=null,this._scrollTop=0,this._page=0,this._emptyEl.style.display="none",this._loadingEl.style.display="flex",this._wrapper.setAttribute("aria-busy","true"),this._updateA11yCell(),this._opts.onSort?.(this._sorts.length>0?[...this._sorts]:null),this._opts.onFilter?.(Object.fromEntries(this._filters)),r._plugins.some(o=>o.bootOverride?.(this,s))?(this._pendingLocalState=null,Promise.resolve()):(this._dm.setFetch((o,n)=>this._opts.fetchData(o,n,s)),this._boot(s))}_skeletonPhase(){if(this._reducedMotion)return null;let t=this._geo(),e=Math.max(0,this._rowLayout.rowAt(this._scrollTop,this._totalRows-1)),s=Math.min(this._totalRows-1,this._rowLayout.rowAt(this._scrollTop+t.vpH,this._totalRows-1)),i=!1;for(let o=e;o<=s;o++)if(this._rowSource(o)==null){i=!0;break}return i?(this._skeletonRaf||(this._skeletonRaf=requestAnimationFrame(()=>{this._skeletonRaf=0,this._draw()})),performance.now()%is/is):(this._skeletonRaf&&(cancelAnimationFrame(this._skeletonRaf),this._skeletonRaf=0),null)}_colorScanConcurrency(){let t=this._opts.colorFilterConcurrency;if(t>0)return t;let e=typeof navigator<"u"&&navigator.hardwareConcurrency||4;return Math.max(2,Math.min(8,e))}async _forEachFilteredRow(t,e){for(let o of r._plugins)if(await o.forEachFilteredRowOverride?.(this,t,e))return;let s=this._opts.chunkSize,i=0;for(;;){let{rows:o}=await this._opts.fetchData(i,s,t);if(!o?.length||(e(o,i*s),o.length<s))break;i++}}async _scanAllRows(){let t=this._filterState();this._loadingEl.textContent=this._i18n.loading;let e=await this._opts.fetchMeta(t);if(this._destroyed)return null;let s=e.totalRows,i=Math.max(1,this._opts.colorFilterPageSize||this._opts.chunkSize),o=Math.max(1,Math.ceil(s/i)),n=new Array(o),l=0,a=0,c=async()=>{for(;;){if(this._destroyed)return;let _=l++;if(_>=o)return;let{rows:f}=await this._opts.fetchData(_,i,t);if(this._destroyed)return;n[_]=f??[],a++,this._loadingEl.textContent=`${this._i18n.loading} ${Math.round(a/o*100)}%`}};if(await Promise.all(Array.from({length:Math.min(this._colorScanConcurrency(),o)},c)),this._destroyed)return null;let h=[];for(let _ of n)if(_)for(let f of _)h.push(f);return h}_applyDisplayFetch(t){this._dm.setFetch((e,s)=>Promise.resolve({rows:t.slice(e*s,(e+1)*s)})),this._serverTotal=t.length,this._rowPlan.clampAnchors(t.length),this._totalRows=t.length+this._localRows.length,this._dm.prefetch(0,Math.min(this._opts.chunkSize-1,this._totalRows-1))}_isGroupRow(t){return!!this._dm.getRow(t)?.__group__}_hitTreeChevron(t,e,s){let i=this._dm.getRow(e.row);if(!i?.__treeHasChildren)return!1;let o=this._columns[e.col];if(!this._colDefMap.get(o)?.treeColumn)return!1;let n=this._colLeft(e.col,s),l=(i.__treeLevel??0)*ie;return t>=n+l&&t<=n+l+me}_rebuildDisplayFetch(t){if(this._edits.size>0&&!window.confirm(this._i18n.unsavedEditsWarning))return!1;this._commitEdit(),this._setSel(null),this._edits.clear(),this._editedRows.clear(),this._validator.clear(),this._clearPlugins("rowIndexState"),this._rowLayout.clear(),this._undoMgr.clear();let e=t();return this._applyDisplayFetch(e),this._clamp(this._geo()),this._updateA11yHeader(),this._draw(),!0}_suggestFilterValuesLocal(t,e,s=50){let i=String(e??"").toLowerCase(),o=new Set,n=l=>{let a=l==null?"":String(l);return a===""||o.has(a)||!a.toLowerCase().includes(i)?!0:(o.add(a),o.size<s)};if(this._dm.forEachLoaded(l=>n(l?.[t])),o.size<s){for(let l of this._localRows)if(n(l?.[t])===!1)break}return[...o].sort((l,a)=>l.localeCompare(a,void 0,{numeric:!0}))}_discoverFilterValues(t,e=200){if(this._searchModeCols.has(t))return null;let s=new Set,i=!1,o=n=>{let l=n==null?"":String(n);return!s.has(l)&&(s.add(l),s.size>e)?(i=!0,!1):!0};if(this._dm.forEachLoaded(n=>o(n?.[t])),!i){for(let n of this._localRows)if(o(n?.[t])===!1)break}return i?null:[...s].sort((n,l)=>n.localeCompare(l,void 0,{numeric:!0}))}_openFilterPanel(t){this._closeFilterPanel();let e=this._geo(),s=this._columns[t],i=this._columnLabels[t]??s,o=this._filters.get(s),n=typeof o=="string"?o:"",l=this._discoverFilterValues(s);l===null?this._searchModeCols.add(s):this._searchModeCols.has(s)&&(l=null);let a=Array.isArray(o)?o:null,c=this._sorts.find(y=>y.field===s),h=c?this._sorts.indexOf(c)+1:0,_={};for(let y of r._plugins)Object.assign(_,y.filterPanelOptions?.(this,s,t));let{swatchColors:f=[],activeColor:d}=_,u=r._plugins.some(y=>y.extraSortSlots),p=()=>{this._closeFilterPanel(),this._kbProxy.focus()};this._wrapper.style.overflow="visible";let w=this._wrapper.getBoundingClientRect().top,C=(window.innerHeight||document.documentElement.clientHeight)-w-e.headerH-8,S=je({colLeft:this._colLeft(t,e),headerH:e.headerH,width:this._opts.width,maxPanelHeight:C,label:i,curVal:n,sortPriority:h,asc:c?.dir==="asc",desc:c?.dir==="desc",filterId:`jhgrid-${this._uid}-filter`,multiSortEnabled:u,swatchColors:f,activeColor:d,distinctValues:l,selectedValues:a,suggest:this._opts.fetchFilterValues?async y=>{let v=await this._opts.fetchFilterValues(s,y);return Array.isArray(v)?v.map(x=>x==null?"":String(x)):[]}:y=>this._suggestFilterValuesLocal(s,y),suggestScope:this._opts.fetchFilterValues?"remote":"local",tagValues:a,containsValue:n,minQueryChars:this._opts.filterValueMinChars,i18n:this._i18n,theme:this._opts.theme,onClose:p,onSort:(y,v)=>{let x=this._sorts.findIndex(B=>B.field===s);v&&u?x>=0?this._sorts[x]={field:s,dir:y}:this._sorts.push({field:s,dir:y}):this._sorts=[{field:s,dir:y}],this._reloadFiltered(),p(),this._announce(this._i18n.sortAppliedAnnounce(i,y))},onApply:y=>{this._trivialSetFilters.delete(s),y?this._filters.set(s,y):this._filters.delete(s),this._reloadFiltered(),p(),this._announce(y?this._i18n.filterAppliedAnnounce(i):this._i18n.filterClearedAnnounce(i))},onApplyValues:y=>{this._filters.set(s,y),l&&y.length===l.length?this._trivialSetFilters.add(s):this._trivialSetFilters.delete(s),this._reloadFiltered(),p(),this._announce(this._i18n.filterAppliedAnnounce(i))},onColorFilter:y=>{let v=r._plugins.find(x=>x.toggleFilterValue)?.toggleFilterValue(this,s,y);this._reloadFiltered(),p(),this._announce(v?this._i18n.filterClearedAnnounce(i):this._i18n.filterAppliedAnnounce(i))},onResetCol:()=>{this._filters.delete(s),this._trivialSetFilters.delete(s),r._plugins.find(y=>y.clearFilterField)?.clearFilterField(this,s),this._sorts=this._sorts.filter(y=>y.field!==s),this._reloadFiltered(),p(),this._announce(this._i18n.filterClearedAnnounce(i))},onResetAll:()=>{this._filters.clear(),this._trivialSetFilters.clear(),this._clearPlugins("filterState"),this._sorts=[],this._reloadFiltered(),p(),this._announce(this._i18n.allFiltersClearedAnnounce)}});this._wrapper.appendChild(S),this._filterPanel={col:t,el:S},(S.querySelector('input[type="text"]')??S.querySelector("input")).focus()}_closeFilterPanel(){this._filterPanel&&(this._filterPanel.el.dispatchEvent(new Event("jhg-dispose")),this._filterPanel.el.remove(),this._filterPanel=null,this._wrapper.style.overflow="hidden")}_colMenuItemAllowed(t){let e=this._opts.colContextMenuItems;return!Array.isArray(e)||e.includes(t)}_openColContextMenu(t,e,s){if(this._opts.colContextMenuItems===!1)return;this._closeColContextMenu();let i=this._geo(),o=this._columns.length,n=t<i.frozenCount,l=t>=o-i.frozenRightCount,a=this._columns[t],c=this._deletedColumns.has(a),h=Ye({x:e,y:s,width:this._opts.width,isFrozen:n,isFrozenRight:l,isDeleted:c,i18n:this._i18n,theme:this._opts.theme,allowedItems:{freeze:this._colMenuItemAllowed("freeze"),freezeRight:this._colMenuItemAllowed("freeze-right"),visibility:this._colMenuItemAllowed("visibility"),insertLeft:this._colMenuItemAllowed("insert-left"),insertRight:this._colMenuItemAllowed("insert-right"),delete:this._colMenuItemAllowed("delete")},onFreeze:()=>{this._closeColContextMenu(),this._opts.frozenCols=n?0:t+1,this._scrollLeft=0,this._clamp(this._geo()),this._draw(),this._kbProxy.focus()},onFreezeRight:()=>{this._closeColContextMenu(),this._opts.frozenColsRight=l?0:o-t,this._scrollLeft=0,this._clamp(this._geo()),this._draw(),this._kbProxy.focus()},onVisibility:()=>{this._closeColContextMenu(),this._openColChooser(e,s)},onInsertLeft:()=>{this._closeColContextMenu(),this._openNewColumnDialog(t,e,s)},onInsertRight:()=>{this._closeColContextMenu(),this._openNewColumnDialog(t+1,e,s)},onDelete:()=>{this._closeColContextMenu(),this.deleteColumn(a),this._kbProxy.focus()},onUndelete:()=>{this._closeColContextMenu(),this.undeleteColumn(a),this._kbProxy.focus()},onEscape:()=>{this._closeColContextMenu(),this._kbProxy.focus()}});h&&(this._wrapper.appendChild(h),this._colContextMenu={col:t,el:h},h.querySelector('[role="menuitem"]').focus())}_closeColContextMenu(){this._colContextMenu&&(this._colContextMenu.el.remove(),this._colContextMenu=null)}_openNewColumnDialog(t,e,s){this._closeNewColumnDialog();let{width:i,height:o,theme:n}=this._opts,l=(...x)=>x.join(";"),a=220,c=122,h=Math.max(0,Math.min(e,i-a-4)),_=Math.max(0,Math.min(s,o-c-4)),f=document.createElement("div");f.setAttribute("role","dialog"),f.setAttribute("aria-modal","true"),f.setAttribute("aria-label",this._i18n.colInsertTitle),f.className=`${L.overlay} ${L.dialog}`,f.style.cssText=l("position:absolute",`left:${h}px`,`top:${_}px`,`width:${a}px`,`background:${b(n,"overlayBg")}`,`border:1px solid ${b(n,"overlayBorder")}`,"border-radius:6px",`box-shadow:${b(n,"overlayShadow")}`,`font-family:${b(n,"fontFamily")}`,`font-size:${n.fontSize}px`,`color:${b(n,"overlayText")}`,"z-index:300","overflow:hidden","user-select:none");let d=document.createElement("div");d.style.cssText=l("display:flex","align-items:center","justify-content:space-between","padding:8px 12px",`background:${b(n,"overlayHeaderBg")}`,`border-bottom:1px solid ${b(n,"overlayDivider")}`);let u=document.createElement("span");u.textContent=this._i18n.colInsertTitle,u.style.cssText=`font-weight:600;font-size:12px;color:${b(n,"overlayMutedText")};`;let p=document.createElement("button");p.type="button",p.textContent="\xD7",p.setAttribute("aria-label",this._i18n.colInsertCancel),p.style.cssText=l("background:none","border:none",`color:${b(n,"overlayMutedText")}`,"cursor:pointer","font-size:17px","line-height:1","padding:0 2px"),p.addEventListener("click",()=>{this._closeNewColumnDialog(),this._kbProxy.focus()}),d.append(u,p);let w=document.createElement("div");w.style.cssText="padding:10px 12px 0;";let m=document.createElement("input");m.type="text",m.placeholder=this._i18n.colInsertPlaceholder,m.className=L.editor,m.style.cssText=l("width:100%",`background:${b(n,"overlayBg")}`,`border:1px solid ${b(n,"overlayBorder")}`,"border-radius:4px",`color:${b(n,"overlayText")}`,`font-size:${n.fontSize}px`,"padding:6px 8px","box-sizing:border-box",`font-family:${b(n,"fontFamily")}`),w.appendChild(m);let C=document.createElement("div");C.style.cssText="display:flex;gap:6px;padding:10px 12px;";let S=document.createElement("button");S.type="button",S.textContent=this._i18n.colInsertConfirm,S.className=L.btn,S.style.cssText=l("flex:1","padding:6px 0",`background:${b(n,"selectionColor")}`,`color:${b(n,"overlayAccentText")}`,"border:none","border-radius:4px","cursor:pointer","font-size:13px","font-weight:600");let y=()=>{let x=m.value.trim();if(!x){m.focus();return}let B=`NEW_COL_${this._newColSeq++}`;this.addColumn(B,{label:x},{index:t}),this._closeNewColumnDialog(),this._kbProxy.focus()};S.addEventListener("click",y);let v=document.createElement("button");v.type="button",v.textContent=this._i18n.colInsertCancel,v.className=L.btn,v.style.cssText=l("flex:1","padding:6px 0",`background:${b(n,"overlayHeaderBg")}`,`color:${b(n,"overlayText")}`,`border:1px solid ${b(n,"overlayBorder")}`,"border-radius:4px","cursor:pointer","font-size:13px"),v.addEventListener("click",()=>{this._closeNewColumnDialog(),this._kbProxy.focus()}),C.append(S,v),f.append(d,w,C),f.addEventListener("mousedown",x=>x.stopPropagation()),m.addEventListener("keydown",x=>{x.key==="Enter"?(x.preventDefault(),y()):x.key==="Escape"&&(this._closeNewColumnDialog(),this._kbProxy.focus()),x.stopPropagation()}),this._wrapper.appendChild(f),this._newColDialog={el:f},m.focus()}_closeNewColumnDialog(){this._newColDialog&&(this._newColDialog.el.remove(),this._newColDialog=null)}_rowMenuItemAllowed(t){let e=this._opts.rowContextMenuItems;return!Array.isArray(e)||e.includes(t)}_openRowContextMenu(t,e,s){if(this._opts.rowContextMenuItems===!1)return;this._closeRowContextMenu();let i=this._localIndexAt(t)>=0,o=this._deletedRows.has(t),n=this._opts.theme,l=170,a=(...y)=>y.join(";"),c=a("padding:8px 14px","cursor:pointer"),h=(y,v)=>{let x=document.createElement("div");return x.setAttribute("role","menuitem"),x.setAttribute("tabindex","0"),x.textContent=y,x.dataset.action=v,x.className=L.menuItem,x.style.cssText=c,x.addEventListener("mouseover",()=>{x.style.background=b(n,"overlayItemHoverBg")}),x.addEventListener("mouseout",()=>{x.style.background=""}),x.addEventListener("focus",()=>{x.style.background=b(n,"overlayItemHoverBg")}),x.addEventListener("blur",()=>{x.style.background=""}),x},_=()=>{let y=document.createElement("div");return y.style.cssText=`height:1px;background:${b(n,"overlayDivider")};margin:4px 0;`,y},f=[];this._rowMenuItemAllowed("row-insert-above")&&f.push(h(this._i18n.rowInsertAbove,"row-insert-above")),this._rowMenuItemAllowed("row-insert-below")&&f.push(h(this._i18n.rowInsertBelow,"row-insert-below")),this._rowMenuItemAllowed("row-insert-top")&&f.push(h(this._i18n.rowInsertTop,"row-insert-top")),this._rowMenuItemAllowed("row-insert-bottom")&&f.push(h(this._i18n.rowInsertBottom,"row-insert-bottom"));let d=[];if(this._rowMenuItemAllowed("row-delete")&&(o?d.push(h(this._i18n.rowUndelete,"row-undelete")):i?d.push(h(this._i18n.rowDelete,"row-delete")):(d.push(h(this._i18n.rowDeleteMark,"row-delete-mark")),d.push(h(this._i18n.rowDeletePermanent,"row-delete-permanent")))),f.length===0&&d.length===0)return;let u=f.length>0&&d.length>0?[...f,_(),...d]:[...f,...d],m=(u.length-(f.length>0&&d.length>0?1:0))*36+(f.length>0&&d.length>0?9:0)+8,C=s+m<=this._opts.height?s:Math.max(0,s-m),S=document.createElement("div");S.setAttribute("role","menu"),S.className=`${L.overlay} ${L.menu}`,S.style.cssText=a("position:absolute",`left:${e}px`,`top:${C}px`,`width:${l}px`,`background:${b(n,"overlayBg")}`,`border:1px solid ${b(n,"overlayBorder")}`,"border-radius:6px",`box-shadow:${b(n,"overlayMenuShadow")}`,`font-family:${b(n,"fontFamily")}`,`font-size:${n.fontSize}px`,`color:${b(n,"overlayText")}`,"z-index:200","overflow:hidden","user-select:none","padding:4px 0"),S.addEventListener("mousedown",y=>y.stopPropagation()),S.addEventListener("click",y=>{let v=y.target.closest("[data-action]")?.dataset?.action;v&&(this._closeRowContextMenu(),v==="row-insert-above"?this.addRow({},{index:t}):v==="row-insert-below"?this.addRow({},{index:t+1}):v==="row-insert-top"?this.addRow({},{index:0}):v==="row-insert-bottom"?this.addRow({}):v==="row-delete-mark"?this.deleteRow(t,{permanent:!1}):v==="row-delete-permanent"?this.deleteRow(t,{permanent:!0}):v==="row-delete"?this.deleteRow(t):v==="row-undelete"&&this.undeleteRow(t),this._kbProxy.focus())}),S.addEventListener("keydown",y=>{if(y.key==="Escape")this._closeRowContextMenu(),this._kbProxy.focus();else if(y.key==="Enter"||y.key===" ")y.preventDefault(),document.activeElement?.click?.();else if(y.key==="ArrowDown"||y.key==="ArrowUp"){y.preventDefault();let v=[...S.querySelectorAll('[role="menuitem"]')],x=v.indexOf(document.activeElement),B=y.key==="ArrowDown"?(x+1)%v.length:(x-1+v.length)%v.length;v[B]?.focus()}y.stopPropagation()}),S.append(...u),this._wrapper.appendChild(S),this._rowContextMenu={row:t,el:S},u[0].focus()}_closeRowContextMenu(){this._rowContextMenu&&(this._rowContextMenu.el.remove(),this._rowContextMenu=null)}_cellMenuItemAllowed(t){let e=this._opts.cellContextMenuItems;return!Array.isArray(e)||e.includes(t)}_openCellContextMenu(t,e,s,i){if(this._opts.cellContextMenuItems===!1)return;this._closeCellContextMenu();let o=this._columns[e],n=this._opts.theme,l=170,a=(...E)=>E.join(";"),c=a("padding:8px 14px","cursor:pointer"),h=(E,R)=>{let F=document.createElement("div");return F.setAttribute("role","menuitem"),F.setAttribute("tabindex","0"),F.textContent=E,F.dataset.action=R,F.className=L.menuItem,F.style.cssText=c,F.addEventListener("mouseover",()=>{F.style.background=b(n,"overlayItemHoverBg")}),F.addEventListener("mouseout",()=>{F.style.background=""}),F.addEventListener("focus",()=>{F.style.background=b(n,"overlayItemHoverBg")}),F.addEventListener("blur",()=>{F.style.background=""}),F},_=()=>{let E=document.createElement("div");return E.style.cssText=`height:1px;background:${b(n,"overlayDivider")};margin:4px 0;`,E},f=[];this._cellMenuItemAllowed("col-insert-left")&&f.push(h(this._i18n.colInsertLeft,"col-insert-left")),this._cellMenuItemAllowed("col-insert-right")&&f.push(h(this._i18n.colInsertRight,"col-insert-right"));let d=this._cellMenuItemAllowed("col-delete")?[h(this._i18n.colDelete,"col-delete")]:[],u=[];this._cellMenuItemAllowed("row-insert-below")&&u.push(h(this._i18n.rowInsertBelow,"row-insert-below")),this._cellMenuItemAllowed("row-delete")&&u.push(h(this._i18n.rowDelete,"row-delete"));let p=this.getRowData(t),w=this._canvas.getBoundingClientRect(),m=w.left+s,C=w.top+i,S=typeof this._opts.cellContextMenuExtraItems=="function"?this._opts.cellContextMenuExtraItems({row:t,col:e,field:o,rowData:p,clientX:m,clientY:C})||[]:[],y=S.map((E,R)=>{let F=h(E.label,`extra:${R}`);return E.disabled&&(F.setAttribute("aria-disabled","true"),F.style.opacity="0.5",F.style.pointerEvents="none"),F}),v=[f,d,u,y].filter(E=>E.length>0);if(v.length===0)return;let x=v.flatMap((E,R)=>R===0?E:[_(),...E]),B=36,W=9,M=v.reduce((E,R)=>E+R.length,0),U=v.length-1,z=M*B+U*W+8,K=i+z<=this._opts.height?i:Math.max(0,i-z),H=Math.min(s,this._opts.width-l-2),I=document.createElement("div");I.setAttribute("role","menu"),I.className=`${L.overlay} ${L.menu}`,I.style.cssText=a("position:absolute",`left:${H}px`,`top:${K}px`,`width:${l}px`,`background:${b(n,"overlayBg")}`,`border:1px solid ${b(n,"overlayBorder")}`,"border-radius:6px",`box-shadow:${b(n,"overlayMenuShadow")}`,`font-family:${b(n,"fontFamily")}`,`font-size:${n.fontSize}px`,`color:${b(n,"overlayText")}`,"z-index:200","overflow:hidden","user-select:none","padding:4px 0"),I.addEventListener("mousedown",E=>E.stopPropagation()),I.addEventListener("click",E=>{let R=E.target.closest("[data-action]")?.dataset?.action;if(R){if(R==="col-insert-left"){this._closeCellContextMenu(),this._openNewColumnDialog(e,s,i);return}if(R==="col-insert-right"){this._closeCellContextMenu(),this._openNewColumnDialog(e+1,s,i);return}if(R.startsWith("extra:")){this._closeCellContextMenu(),S[Number(R.slice(6))]?.onClick?.({row:t,col:e,field:o,rowData:p,clientX:m,clientY:C}),this._kbProxy.focus();return}this._closeCellContextMenu(),R==="col-delete"?this.deleteColumn(o):R==="row-insert-below"?this.addRow({},{index:t+1}):R==="row-delete"&&this.deleteRow(t),this._kbProxy.focus()}}),I.addEventListener("keydown",E=>{if(E.key==="Escape")this._closeCellContextMenu(),this._kbProxy.focus();else if(E.key==="Enter"||E.key===" ")E.preventDefault(),document.activeElement?.click?.();else if(E.key==="ArrowDown"||E.key==="ArrowUp"){E.preventDefault();let R=[...I.querySelectorAll('[role="menuitem"]')],F=R.indexOf(document.activeElement),Q=E.key==="ArrowDown"?(F+1)%R.length:(F-1+R.length)%R.length;R[Q]?.focus()}E.stopPropagation()}),I.append(...x),this._wrapper.appendChild(I),this._cellContextMenu={row:t,col:e,el:I},I.querySelector('[role="menuitem"]').focus()}_closeCellContextMenu(){this._cellContextMenu&&(this._cellContextMenu.el.remove(),this._cellContextMenu=null)}_openColChooser(t,e){this._closeColChooser();let s=Ne({x:t,y:e,width:this._opts.width,height:this._opts.height,fields:this._columnOriginalOrder,isHidden:i=>this._hiddenColumns.has(i),labelFor:i=>this._colDefMap.get(i)?.label??i,groupPathFor:i=>ue(this._colDefMap.get(i)?.group),i18n:this._i18n,theme:this._opts.theme,onApply:i=>{this._withStructuralUndo(()=>{this._columnOriginalOrder.forEach(o=>{let n=i.get(o),l=!this._hiddenColumns.has(o);n&&!l?(this._deletedColumns.delete(o),this._showColumnInternal(o)):!n&&l&&this._hideColumnInternal(o)}),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()}),this._closeColChooser(),this._kbProxy.focus()},onCancel:()=>{this._closeColChooser(),this._kbProxy.focus()}});s&&(this._wrapper.appendChild(s),this._colChooser={el:s},s.querySelector("button").focus())}_closeColChooser(){this._colChooser&&(this._colChooser.el.remove(),this._colChooser=null)}_remapSelForColRemoval(t){if(!this._sel)return;let e=s=>s>t?s-1:s===t?-1:s;if(this._sel.type==="single"){let s=e(this._sel.col);this._sel=s<0?null:{...this._sel,col:s}}else{let s=e(this._sel.c1),i=e(this._sel.c2);s<0||i<0?this._sel=null:s===i?this._sel={type:"single",row:this._sel.r1,col:s}:this._sel={type:"range",...this._normRange(this._sel.r1,s,this._sel.r2,i)}}}_purgeFieldEdits(t){[...this._edits.keys()].forEach(e=>{let s=e.indexOf("_");e.slice(s+1)===t&&this._edits.delete(e)});for(let e of r._plugins)e.purgeField?.(this,t)}_hideColumnInternal(t){let e=this._columns.indexOf(t);if(e===-1)return;this._hiddenColumns.set(t,{label:this._columnLabels[e],align:this._columnAligns[e],headerAlign:this._columnHeaderAligns[e],width:this._columnWidths[e],renderer:this._columnRenderers[e]});let s=(i,o)=>o!==e;this._columns=this._columns.filter(s),this._columnLabels=this._columnLabels.filter(s),this._columnAligns=this._columnAligns.filter(s),this._columnHeaderAligns=this._columnHeaderAligns.filter(s),this._columnWidths=this._columnWidths.filter(s),this._columnRenderers=this._columnRenderers.filter(s),this._remapSelForColRemoval(e)}_showColumnInternal(t){let e=this._hiddenColumns.get(t);if(!e)return;this._hiddenColumns.delete(t);let s=this._columnOriginalOrder.indexOf(t),i=this._columns.length;for(let n=s+1;n<this._columnOriginalOrder.length;n++){let l=this._columns.indexOf(this._columnOriginalOrder[n]);if(l!==-1){i=l;break}}let o=(n,l)=>{let a=[...n];return a.splice(i,0,l),a};this._columns=o(this._columns,t),this._columnLabels=o(this._columnLabels,e.label),this._columnAligns=o(this._columnAligns,e.align),this._columnHeaderAligns=o(this._columnHeaderAligns,e.headerAlign),this._columnWidths=o(this._columnWidths,e.width),this._columnRenderers=o(this._columnRenderers,e.renderer)}_normRange(t,e,s,i){return{r1:Math.min(t,s),c1:Math.min(e,i),r2:Math.max(t,s),c2:Math.max(e,i)}}_dragEdgeDir(t,e,s=this._geo()){let{width:i,height:o}=this._opts,n=24,l=0,a=0;return t<s.frozenWidth+n?l=-1:t>s.rightX-n&&(l=1),e<s.headerH+n?a=-1:e>o-s.hSB-n&&(a=1),{dx:l,dy:a}}_extendDragSelection(t,e,s=this._geo()){let i=this._hitCellClamped(t,e,s);if(!i)return;let o=this._normRange(this._selDragStart.row,this._selDragStart.col,i.row,i.col),n=o.r1===o.r2&&o.c1===o.c2;this._sel=n?{type:"single",row:o.r1,col:o.c1}:{type:"range",...o},this._schedDraw()}_startDragAutoScroll(){this._dragScrollTimer||(this._dragScrollTimer=setInterval(()=>this._dragAutoScrollTick(),50))}_stopDragAutoScroll(){this._dragScrollTimer&&(clearInterval(this._dragScrollTimer),this._dragScrollTimer=null),this._dragScrollDir={dx:0,dy:0}}_dragAutoScrollTick(){let{dx:t,dy:e}=this._dragScrollDir;if(!t&&!e||!this._selDragging&&!this._fillDrag||!this._dragScrollPos){this._stopDragAutoScroll();return}let s=40,i=this._geo();t&&(this._scrollLeft+=t*s),e&&(this._scrollTop+=e*s),this._clamp(i),this._selDragging?this._extendDragSelection(this._dragScrollPos.x,this._dragScrollPos.y,this._geo()):this._extendFillDrag(this._dragScrollPos.x,this._dragScrollPos.y,this._geo())}_isEditable(t){if(t<0||t>=this._columns.length)return!1;let e=this._columns[t],s=this._colDefMap.get(e)?.editable;return s!==void 0?s:this._editableCols===null||this._editableCols.has(e)}_localIndexAt(t){return this._rowPlan.sourceAt(t)?.local??-1}_rowSource(t){let e=this._rowPlan.sourceAt(t);return e?e.local>=0?this._localRows[e.local]??null:this._dm.getRow(e.server):null}_cellVal(t,e){let s=this._columns[e],i=`${t}_${s}`;if(this._edits.has(i))return this._edits.get(i);let o=this._rowSource(t);if(!o)return"";let n=o[s];return n!=null?String(n):""}_getRow(t){let e=this._rowSource(t);if(!this._editedRows.has(t))return e;let s=e?{...e}:{};return this._columns.forEach(i=>{let o=`${t}_${i}`;this._edits.has(o)&&(s[i]=this._edits.get(o))}),s}_isPlainTextEditor(t){let e=this._colDefMap.get(this._columns[t]);return!e?.editor&&(e?.type??"text")==="text"}_startEdit(t,e,s=void 0,{keepInputValue:i=!1}={}){if(!this._isEditable(e))return;this._editing&&this._commitEdit();let o=this._columns[e],n=this._colDefMap.get(o),l=n?.type??"text";if(l==="checkbox"||l==="button")return;let a=this._buildEditorCtx(t,e,s);a.keepInputValue=i;let c=n?.editor,h;if(typeof c=="function")h=c(a);else{let _=c??l,d=_==="text"&&!i&&String(a.initialValue??"").includes(`
142
+ `)?Ht.textMultiline:Ht[_]??Ht.text,u=_==="dropdown"||_==="multiselect"?{options:n?.options??[],...n?.editorOptions??{}}:_==="date"?{format:n?.format,...n?.editorOptions??{}}:n?.editorOptions??{};h=d(u)(a)}h&&(this._editing={row:t,col:e,el:h})}_buildEditorCtx(t,e,s){let{theme:i}=this._opts,o=this._geo(),{colPositions:n,headerH:l}=o,a=n[e+1]-n[e],c=this._rowLayout.yOf(t+1)-this._rowLayout.yOf(t),h=this._colLeft(e,o),_=this._rowLayout.yOf(t)-this._scrollTop+l;return{row:t,col:e,field:this._columns[e],rowData:this._getRow(t),x:h,y:_,colW:a,rowH:c,wrapper:this._wrapper,kbProxy:this._kbProxy,theme:i,i18n:this._i18n,columnLabel:this._columnLabels[e]??this._columns[e],initialValue:s!==void 0?s:this._cellVal(t,e),commit:()=>this._commitEdit(),cancel:()=>this._cancelEdit(),insertLineBreak:()=>this._insertLineBreakInEdit(),moveSel:(f,d)=>this._moveSel(f,d),focusWrapper:()=>this._kbProxy.focus(),suppressReopen:()=>{this._suppressReopenCell={row:t,col:e}}}}_toggleCheckbox(t,e){let s=this._columns[e],i=this._cellVal(t,e),n=i==="true"||i==="1"||i==="Y"||i==="yes"?"false":"true";this._editTxnBegin(),this._setEdit(t,s,n),this._editTxnCommit(),this._updateA11yCell(),this._draw()}_fireButtonClick(t,e){let s=this._columns[e],i=this._colDefMap.get(s)?.button;if(!i?.onClick)return;let o=this._getRow(t);if(!(typeof i.disabled=="function"?i.disabled(o,t):i.disabled))try{i.onClick(t,o,s)}catch(l){console.error("[JHGrid] button onClick error at row",t,"field",s,":",l)}}_isButtonCell(t){return!t||t.type!=="single"?!1:this._colDefMap.get(this._columns[t.col])?.type==="button"}_startDropdownEdit(t,e,s){let i=Ht[s?.type]??Ht.dropdown,o={options:s?.options??[],...s?.editorOptions??{}},n=this._buildEditorCtx(t,e),l=i(o)(n);l&&(this._editing={row:t,col:e,el:l})}_resetKbProxy(){let t=this._kbProxy;t._jhEditorBlur&&(t.removeEventListener("blur",t._jhEditorBlur),t._jhEditorBlur=null),t._jhEditorKeydown&&(t.removeEventListener("keydown",t._jhEditorKeydown),t._jhEditorKeydown=null),t.value="",t.setAttribute("aria-label",this._opts.ariaLabel??this._i18n.ariaGrid),t.className="",t.style.cssText=os,this._syncKbProxyPosition()}_syncKbProxyPosition(){if(this._editing||!this._sel||this._sel.type!=="single")return;let{row:t,col:e}=this._sel,s=this._geo(),i=s.colPositions[e+1]-s.colPositions[e],o=this._rowLayout.yOf(t+1)-this._rowLayout.yOf(t),n=this._colLeft(e,s),l=this._rowLayout.yOf(t)-this._scrollTop+s.headerH;Object.assign(this._kbProxy.style,{left:n+"px",top:l+"px",width:i+"px",height:o+"px"})}_commitEdit(){if(!this._editing)return;let{row:t,col:e,el:s}=this._editing,i=s.value,o=this._columns[e];this._editTxnBegin(),this._setEdit(t,o,i),this._editTxnCommit(),this._editing=null,s.remove(),this._updateA11yCell();let n=this._validator.map.get(`${t}_${o}`);n&&this._announce(n),this._draw()}_cancelEdit(){if(!this._editing)return;let t=this._editing.el;this._editing=null,t.remove(),this._draw()}_insertLineBreakInEdit(){if(!this._editing)return;let{row:t,col:e,el:s}=this._editing,i=s.selectionStart??s.value.length,o=s.selectionEnd??s.value.length,n=s.value.slice(0,i)+`
143
+ `+s.value.slice(o);this._editing=null,s.remove(),this._startEdit(t,e,n),this._editing?.el.setSelectionRange(i+1,i+1)}_setSel(t){this._sel=t,this._opts.onSelectionChange?.(t)}_moveSel(t,e){let s=this._sel;if(!s)return;let i=(s.type==="single"?s.row:s.r1)+t,o=(s.type==="single"?s.col:s.c1)+e,{start:n,rows:l}=this._pageBounds(),a=Math.max(n,Math.min(n+l-1,i)),c=Math.max(0,Math.min(this._columns.length-1,o));this._setSel({type:"single",row:a,col:c}),this._ensureVisible(a,c),this._updateA11yCell(),this._announce(this._i18n.announceCell(a+1,this._columnLabels[c]??this._columns[c],this._cellVal(a,c)||this._i18n.emptyCell)),this._draw()}_updateRowSel(t,e,s){r._plugin("rowSelection")?.update(this,t,e,s)}_clearRowSelOnCellClick(t){r._plugin("rowSelection")?.clearOnCellClick(this,t)}_updateColSel(t,e){if(this._totalRows===0)return;let s=this._totalRows-1,i=e&&this._selAnchor?this._selAnchor.col:t;(!e||!this._selAnchor)&&(this._selAnchor={row:0,col:t}),r._plugin("rowSelection")?.clear(this);let o=this._normRange(0,i,s,t);this._setSel(o.r1===o.r2&&o.c1===o.c2?{type:"single",row:o.r1,col:o.c1}:{type:"range",...o}),this._ensureColVisible(t),this._updateA11yCell()}_ensureColVisible(t){let e=this._geo(),{frozenCount:s,frozenRightCount:i,colPositions:o}=e,n=this._columns.length;if(t>=s&&t<n-i){let l=o[t]-o[s],a=o[t+1]-o[t];l<this._scrollLeft&&(this._scrollLeft=l),l+a>this._scrollLeft+e.vpW&&(this._scrollLeft=l+a-e.vpW)}this._clamp(e)}_extendSel(t,e){if(!this._sel)return;this._selAnchor||(this._selAnchor=this._sel.type==="single"?{row:this._sel.row,col:this._sel.col}:{row:this._sel.r1,col:this._sel.c1});let s=this._selAnchor,i,o;this._sel.type==="single"?(i=this._sel.row,o=this._sel.col):(i=s.row===this._sel.r1?this._sel.r2:this._sel.r1,o=s.col===this._sel.c1?this._sel.c2:this._sel.c1),i=Math.max(0,Math.min(this._totalRows-1,i+t)),o=Math.max(0,Math.min(this._columns.length-1,o+e));let n=this._normRange(s.row,s.col,i,o);this._setSel(n.r1===n.r2&&n.c1===n.c2?{type:"single",row:n.r1,col:n.c1}:{type:"range",...n}),this._ensureVisible(i,o),this._updateA11yCell(),this._draw()}_clearSelection(){if(!this._sel)return;let t=this._sel.type==="single"?[[this._sel.row,this._sel.col]]:Array.from({length:this._sel.r2-this._sel.r1+1},(e,s)=>Array.from({length:this._sel.c2-this._sel.c1+1},(i,o)=>[this._sel.r1+s,this._sel.c1+o])).flat();this._editTxnBegin(),t.forEach(([e,s])=>{if(!this._isEditable(s))return;let i=this._columns[s];this._setEdit(e,i,"")}),this._editTxnCommit(),this._draw()}_usedRange(t=0,e=0){let s=this._totalRows,i=this._columns.length;if(s===0||i===0)return{r1:0,r2:s-1,c1:0,c2:i-1};let o=w=>w==null||w==="",n=s-1;for(;n>0;){let w=this._getRow(n);if(w==null||!this._columns.every(m=>o(w[m])))break;n--}let l=new Array(i).fill(!1),a=0,c=-1,h=1/0,_=w=>{if(w==null||w<0||w>n)return;let m=this._getRow(w);if(m==null)return;a++;let C=!0;for(let S=0;S<i;S++)o(m[this._columns[S]])||(C=!1,l[S]||(l[S]=!0));C&&w!==t&&(w<t&&w>c&&(c=w),w>t&&w<h&&(h=w))};this._dm.forEachLoaded((w,m)=>_(this._rowPlan.visualOfServer(m))),this._localRows.forEach((w,m)=>_(this._rowPlan.visualOfLocal(m)));let f=0,d=n,u=0,p=i-1;if(a>0&&(h<1/0&&(d=Math.min(d,h-1)),c>-1&&(f=c+1),u=p=e,i>1)){for(;p+1<i&&l[p+1];)p++;for(;u-1>=0&&l[u-1];)u--}return{r1:f,r2:d,c1:u,c2:p}}_ensureVisible(t,e){let s=this._geo(),{frozenCount:i,frozenRightCount:o,colPositions:n}=s,l=this._columns.length,a=this._rowLayout.yOf(t),c=this._rowLayout.heightOf(t);if(a<this._scrollTop&&(this._scrollTop=a),a+c>this._scrollTop+s.vpH&&(this._scrollTop=a+c-s.vpH),e>=i&&e<l-o){let h=n[e]-n[i],_=n[e+1]-n[e];h<this._scrollLeft&&(this._scrollLeft=h),h+_>this._scrollLeft+s.vpW&&(this._scrollLeft=h+_-s.vpW)}this._clamp(s)}_pushUndoCmd(t){this._undoMgr.push(t)}_snapshotStructural(){let t={totalRows:this._totalRows,serverTotal:this._serverTotal,localRows:this._localRows.map(e=>({...e})),deletedRows:new Set(this._deletedRows),removedServer:this._rowPlan.removed.values(),localAnchors:[...this._rowPlan.anchors],edits:new Map(this._edits),editedRows:new Set(this._editedRows),sel:this._sel?{...this._sel}:null,selAnchor:this._selAnchor?{...this._selAnchor}:null,columns:[...this._columns],columnLabels:[...this._columnLabels],columnAligns:[...this._columnAligns],columnHeaderAligns:[...this._columnHeaderAligns],columnWidths:[...this._columnWidths],columnRenderers:[...this._columnRenderers],rowHeight:this._opts.rowHeight,rowHeightOverrides:this._rowLayout.snapshotOverrides(),localColumns:new Map(this._localColumns),deletedColumns:new Set(this._deletedColumns),colDefMap:new Map(this._colDefMap),columnWidthMap:new Map(this._columnWidthMap),columnOriginalOrder:[...this._columnOriginalOrder],hiddenColumns:new Map(this._hiddenColumns)};for(let e of r._plugins)e.snapshotStructural?.(this,t);return t}_restoreStructural(t){this._totalRows=t.totalRows,this._serverTotal=t.serverTotal,this._localRows=t.localRows.map(e=>({...e})),this._deletedRows=new Set(t.deletedRows),this._rowPlan.removed.clear(),this._rowPlan.detachAnchors();for(let e of t.removedServer)this._rowPlan.removed.add(e);this._rowPlan.anchors=[...t.localAnchors],this._rowPlan.serverTotal=t.serverTotal,this._edits=new Map(t.edits),this._editedRows=new Set(t.editedRows),this._sel=t.sel?{...t.sel}:null,this._selAnchor=t.selAnchor?{...t.selAnchor}:null,this._columns=[...t.columns],this._columnLabels=[...t.columnLabels],this._columnAligns=[...t.columnAligns],this._columnHeaderAligns=[...t.columnHeaderAligns],this._columnWidths=[...t.columnWidths],this._columnRenderers=[...t.columnRenderers],this._opts.rowHeight=t.rowHeight,this._rowLayout.defaultHeight=t.rowHeight,this._rowLayout.restoreOverrides(t.rowHeightOverrides),this._localColumns=new Map(t.localColumns),this._deletedColumns=new Set(t.deletedColumns),this._colDefMap=new Map(t.colDefMap),this._columnWidthMap=new Map(t.columnWidthMap),this._columnOriginalOrder=[...t.columnOriginalOrder],this._hiddenColumns=new Map(t.hiddenColumns);for(let e of r._plugins)e.restoreStructural?.(this,t);this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._wrapper.setAttribute("aria-colcount",String(this._columns.length)),this._emptyEl.style.display=this._totalRows===0?"flex":"none",this._clamp(this._geo()),this._updateA11yHeader(),this._updateA11yCell(),this._opts.onSelectionChange?.(this._sel),this._opts.onRowSelect?.(r._plugin("rowSelection")?.getSorted(this)??[]),this._revalidateAllFromEdits(),this._draw()}_withStructuralUndo(t){let e=this._snapshotStructural(),s=t();this._revalidateAllFromEdits(),this._draw();let i=this._snapshotStructural();return this._pushUndoCmd({undo:()=>this._restoreStructural(e),redo:()=>this._restoreStructural(i)}),s}_resolveCellStringValue(t,e){let s=`${t}_${e}`;if(this._edits.has(s))return this._edits.get(s);let i=this._rowSource(t);if(!i)return"";let o=i[e];return o!=null?String(o):""}_revalidateKey(t){let e=t.indexOf("_"),s=Number(t.slice(0,e)),i=t.slice(e+1);this._validator.revalidate(s,i,this._resolveCellStringValue(s,i))}_revalidateAllFromEdits(){let t=new Set(this._validator.map.keys());this._validator.clear(),this._edits.forEach((e,s)=>this._revalidateKey(s)),t.forEach(e=>{if(this._validator.map.has(e))return;let s=e.indexOf("_");this._opts.onValidationError?.(Number(e.slice(0,s)),e.slice(s+1),null)})}isValid(){return this._validator.isValid()}getInvalidCells(){return this._validator.getInvalidCells()}validateAll(){if(this._destroyed)return this.getInvalidCells();this._validator.clear();let t=this._columns.filter(e=>this._colDefMap.get(e)?.validation);return t.length>0&&(this._dm.forEachLoaded((e,s)=>{t.forEach(i=>this._revalidateKey(`${s}_${i}`))}),this._localRows.forEach((e,s)=>{let i=this._rowPlan.visualOfLocal(s);t.forEach(o=>this._revalidateKey(`${i}_${o}`))})),this._draw(),this.getInvalidCells()}_editTxnBegin(){this._editTxn=new Map}_setEdit(t,e,s){let i=`${t}_${e}`,o;if(this._edits.has(i))o=this._edits.get(i);else{let n=this._rowSource(t)?.[e];o=n!=null?String(n):""}this._editTxn&&!this._editTxn.has(i)&&this._editTxn.set(i,this._edits.has(i)?{had:!0,value:this._edits.get(i)}:{had:!1,value:void 0}),this._edits.set(i,s),this._editedRows.add(t),this._opts.onCellChange?.({row:t,field:e,newValue:s,oldValue:o}),this._revalidateKey(i),this._growRowForMultilineValue(t,s)}_growRowForMultilineValue(t,e){if(typeof e!="string"||e.indexOf(`
144
+ `)===-1)return;let{fontSize:s,cellPadding:i}=this._opts.theme,o=Math.ceil(e.split(`
145
+ `).length*s*1.4+i*2);o>this._rowLayout.heightOf(t)&&this._rowLayout.setHeight(t,o)}_autoFitRow(t){let{fontSize:e,cellPadding:s}=this._opts.theme,i=this._getRow(t),o=1;i&&this._columns.forEach(l=>{let a=i[l];if(a==null)return;let c=String(a).split(`
146
+ `).length;c>o&&(o=c)});let n=o<=1?this._rowLayout.defaultHeight:Math.max(ss,Math.ceil(o*e*1.4+s*2));this._rowLayout.setHeight(t,n)}_selectedRowsForAutoFit(){let t=r._plugin("rowSelection")?.getSorted(this);if(t&&t.length>1)return new Set(t);if(this._sel&&this._sel.type==="range"){let e=new Set;for(let s=this._sel.r1;s<=this._sel.r2;s++)e.add(s);return e}return null}_restoreEditSnap(t,e){e.had?this._edits.set(t,e.value):this._edits.delete(t);let s=t.indexOf("_");this._editedRows.add(Number(t.slice(0,s))),this._revalidateKey(t)}_editTxnCommit(){let t=this._editTxn;if(this._editTxn=null,!t||t.size===0)return;let e=new Map;t.forEach((s,i)=>{e.set(i,this._edits.has(i)?{had:!0,value:this._edits.get(i)}:{had:!1,value:void 0})}),this._pushUndoCmd({undo:()=>{t.forEach((s,i)=>this._restoreEditSnap(i,s)),this._draw()},redo:()=>{e.forEach((s,i)=>this._restoreEditSnap(i,s)),this._draw()}})}undo(){this._undoMgr.undo()}redo(){this._undoMgr.redo()}canUndo(){return this._undoMgr.canUndo()}canRedo(){return this._undoMgr.canRedo()}_selectedRowsSorted(){return r._plugin("rowSelection")?.getSorted(this)??[]}_buildCopyText(){let t=this._sel?null:this._selectedRowsSorted();if(!this._sel&&(!t||t.length===0))return"";this._lastCopyMissingRows=0;let e=(l,a)=>{let c=this._cellVal(l,a),h=this._colDefMap.get(this._columns[a]);return Ie(Kt(c,h,this._opts.theme.locale))};if(t)return t.map(l=>(this._rowSource(l)==null&&this._lastCopyMissingRows++,this._columns.map((a,c)=>e(l,c)).join(" "))).join(`
147
+ `);if(this._sel.type==="single")return this._rowSource(this._sel.row)==null&&(this._lastCopyMissingRows=1),e(this._sel.row,this._sel.col);let{r1:s,c1:i,r2:o,c2:n}=this._sel;return Array.from({length:o-s+1},(l,a)=>{let c=s+a;return this._rowSource(c)==null&&this._lastCopyMissingRows++,Array.from({length:n-i+1},(h,_)=>e(c,i+_)).join(" ")}).join(`
148
+ `)}_pasteImageBlob(t){if(!this._sel)return!1;let e=this._sel.type==="single"?this._sel.row:this._sel.r1,s=this._sel.type==="single"?this._sel.col:this._sel.c1,i=this._columns[s];if(this._colDefMap.get(i)?.type!=="image"||!this._isEditable(s))return!1;let o=this._cellVal(e,s);this._pastedImageUrls.has(o)&&(URL.revokeObjectURL(o),this._pastedImageUrls.delete(o));let n=URL.createObjectURL(t);return this._pastedImageUrls.add(n),this._editTxnBegin(),this._setEdit(e,i,n),this._editTxnCommit(),this._draw(),!0}async _pasteFromClipboardAsync(){if(navigator.clipboard?.read)try{let e=await navigator.clipboard.read();for(let s of e){let i=s.types.find(n=>n.startsWith("image/"));if(!i)continue;let o=await s.getType(i);if(this._pasteImageBlob(o))return}}catch{}if(!navigator.clipboard?.readText)return;let t=await navigator.clipboard.readText().catch(()=>"");t&&this._applyPaste(t)}_applyPaste(t){if(!this._sel||!t)return;let e=We(t.trimEnd()),s=e.length,i=Math.max(...e.map(c=>c.length)),o=this._sel.type==="single"?this._sel.row:this._sel.r1,n=this._sel.type==="single"?this._sel.col:this._sel.c1,l=0,a=(c,h,_)=>{if(c>=this._totalRows||h>=this._columns.length){l++;return}if(!this._isEditable(h)){l++;return}if(this._isGroupRow(c))return;let f=this._columns[h];this._setEdit(c,f,_)};if(this._editTxnBegin(),s===1&&i===1&&this._sel.type==="range"){let c=e[0][0];for(let h=this._sel.r1;h<=this._sel.r2;h++)for(let _=this._sel.c1;_<=this._sel.c2;_++)a(h,_,c)}else e.forEach((c,h)=>c.forEach((_,f)=>a(o+h,n+f,_)));this._editTxnCommit(),this._draw(),l>0&&(this._showErrorBanner(this._i18n.pasteTruncated(l)),this._announce(this._i18n.pasteTruncated(l)))}_applyFill(t,e){let s=t.type==="single"?t.row:t.r1,i=t.type==="single"?t.row:t.r2,o=t.type==="single"?t.col:t.c1,n=t.type==="single"?t.col:t.c2,{r1:l,c1:a,r2:c,c2:h}=e,_=l>i||c<s,f=(_?l>i:a>n)?1:-1,d=_?f>0?l:c:f>0?a:h,u=p=>Math.abs(p-d)+1;if(this._editTxnBegin(),_)for(let p=o;p<=n;p++){if(!this._isEditable(p))continue;let w=[];for(let C=s;C<=i;C++)w.push(this._cellVal(C,p));let m=this._columns[p];for(let C=d;(f>0?C<=c:C>=l)&&!(C>=this._totalRows||C<0);C+=f)this._isGroupRow(C)||this._setEdit(C,m,ve(w,u(C),f))}else for(let p=s;p<=i;p++){if(this._isGroupRow(p))continue;let w=[];for(let m=o;m<=n;m++)w.push(this._cellVal(p,m));for(let m=d;f>0?m<=h:m>=a;m+=f){if(!this._isEditable(m))continue;let C=this._columns[m];this._setEdit(p,C,ve(w,u(m),f))}}this._editTxnCommit(),this._draw()}_xy(t){let e=this._canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}_clamp(t){this._scrollTop=Math.max(t.minScrollY,Math.min(t.maxScrollY,this._scrollTop)),this._scrollLeft=Math.max(0,Math.min(t.maxScrollX,this._scrollLeft))}_wheelPixels(t,e){return t.deltaMode===1?{dx:t.deltaX*Os,dy:t.deltaY*this._opts.rowHeight}:t.deltaMode===2?{dx:t.deltaX*e.vpW,dy:t.deltaY*e.vpH}:{dx:t.deltaX,dy:t.deltaY}}_easeWheel(t,e,s){if(this._scrollEaseMs===0||Math.abs(e)<this._opts.rowHeight&&Math.abs(t)<this._opts.rowHeight)return!1;let i=this._scrollEase.animating,o=(i?this._scrollAim.y:this._scrollTop)+e,n=(i?this._scrollAim.x:this._scrollLeft)+t;return this._scrollAim={y:Math.max(s.minScrollY,Math.min(s.maxScrollY,o)),x:Math.max(0,Math.min(s.maxScrollX,n))},this._scrollFrom={y:this._scrollTop,x:this._scrollLeft},this._scrollWrote={y:this._scrollTop,x:this._scrollLeft},this._scrollEase.set(0),this._scrollEase.to(1,this._scrollEaseMs),!0}_onScrollFrame(){if(this._scrollTop!==this._scrollWrote.y||this._scrollLeft!==this._scrollWrote.x){this._scrollEase.stop();return}let t=this._scrollEase.value;this._scrollTop=this._scrollFrom.y+(this._scrollAim.y-this._scrollFrom.y)*t,this._scrollLeft=this._scrollFrom.x+(this._scrollAim.x-this._scrollFrom.x)*t,this._clamp(this._geo()),this._scrollWrote={y:this._scrollTop,x:this._scrollLeft},this._schedDraw()}_cancelScrollEase(){this._scrollEase.stop()}_schedDraw(){this._ticking||(this._ticking=!0,this._schedRaf=requestAnimationFrame(()=>{this._ticking=!1,this._draw()}))}_anyOverlayOpen(){return!!(this._filterPanel||this._colContextMenu||this._rowContextMenu||this._cellContextMenu||this._colChooser||this._newColDialog)}_setHoverRow(t){if(!this._opts.theme.hoverRowBg)return;let e=t===null?0:1,s=t!==null&&t!==this._hoverRow;!s&&e===this._hoverTarget||(s&&(this._hoverRow=t),this._hoverTarget=e,this._hoverFade.to(e,this._hoverFadeMs),this._schedDraw())}_openContextMenuAt(t,e,s){let{headerH:i}=s;if(e>=0&&e<i){let n=this._hitHeader(t,s);return n===null?!1:(this._closeFilterPanel(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._openColContextMenu(n,t,e),!0)}if(s.rowNumW>0&&t<s.rowNumW){let n=this._hitRowNumber(t,e,s);return n===null?!1:(this._closeFilterPanel(),this._closeColContextMenu(),this._closeCellContextMenu(),this._openRowContextMenu(n,t,e),!0)}let o=this._hitCell(t,e,s);return o?(this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._openCellContextMenu(o.row,o.col,t,e),!0):!1}_updateStructuralGesture(t,e){if(this._colResize){let s=Math.max(es,this._colResize.startWidth+t-this._colResize.startX);return this._columnWidths[this._colResize.col]=s,this._canvas.style.cursor="col-resize",this._clamp(this._geo()),this._schedDraw(),!0}if(this._rowResize){let s=Math.max(ss,this._rowResize.startHeight+e-this._rowResize.startY);return this._rowLayout.setHeight(this._rowResize.row,s),this._canvas.style.cursor="row-resize",this._clamp(this._geo()),this._schedDraw(),!0}if(this._colDrag){if(!this._colDrag.active&&Math.abs(t-this._colDrag.startX)>5&&(this._colDrag.active=!0),this._colDrag.active){this._colDrag.x=t;let s=this._calcInsertBefore(t);this._colDrag.insertBefore=s;let i=this._colDrag.col;if(s!==i&&s!==i+1){this._colDrag.undoBefore??=this._snapshotStructural();let o=this._geo().colPositions;this._colDrag.col=this._reorderCol(i,s,{silent:!0}),this._startColSlide(i,this._colDrag.col,o)}this._canvas.style.cursor="grabbing",this._schedDraw()}return!0}return this._rowDrag?(!this._rowDrag.active&&Math.abs(e-this._rowDrag.startY)>5&&(this._rowDrag.active=!0),this._rowDrag.active&&(this._rowDrag.insertBefore=this._calcRowInsertBefore(e),this._canvas.style.cursor="grabbing",this._schedDraw()),!0):this._fillDrag?(this._dragScrollPos={x:t,y:e},this._dragScrollDir=this._dragEdgeDir(t,e),this._dragScrollDir.dx||this._dragScrollDir.dy?this._startDragAutoScroll():this._stopDragAutoScroll(),this._extendFillDrag(t,e),this._canvas.style.cursor="crosshair",this._schedDraw(),!0):!1}_extendFillDrag(t,e,s=this._geo()){let i=this._hitCellClamped(t,e,s);if(!i){this._fillPreview=null;return}let o=this._fillDrag.sel,n=o.type==="single"?o.row:o.r1,l=o.type==="single"?o.row:o.r2,a=o.type==="single"?o.col:o.c1,c=o.type==="single"?o.col:o.c2;i.row>l?this._fillPreview={r1:l+1,c1:a,r2:i.row,c2:c}:i.row<n?this._fillPreview={r1:i.row,c1:a,r2:n-1,c2:c}:i.col>c?this._fillPreview={r1:n,c1:c+1,r2:l,c2:i.col}:i.col<a?this._fillPreview={r1:n,c1:i.col,r2:l,c2:a-1}:this._fillPreview=null}_finalizeStructuralGesture(){if(this._colResize){let{col:t,startWidth:e,undoBefore:s}=this._colResize,i=this._columnWidths[t];if(this._colResize=null,i!==e){let o=this._columns[t];this._columnWidthMap.set(o,i),this._canvas.style.cursor="";let n=this._snapshotStructural();this._pushUndoCmd({undo:()=>this._restoreStructural(s),redo:()=>this._restoreStructural(n)}),this._opts.onColumnResize?.(o,i),this._draw()}return!0}if(this._rowResize){let{row:t,startHeight:e,undoBefore:s}=this._rowResize,i=this._rowLayout.heightOf(t);if(this._rowResize=null,i!==e){this._canvas.style.cursor="";let o=this._snapshotStructural();this._pushUndoCmd({undo:()=>this._restoreStructural(s),redo:()=>this._restoreStructural(o)}),this._opts.onRowHeightResize?.(t,i),this._draw()}return!0}if(this._colDrag){let{active:t,startCol:e,col:s,undoBefore:i,shiftKey:o}=this._colDrag;if(this._colDrag=null,t&&s!==e&&i){this._revalidateAllFromEdits();let n=this._snapshotStructural();this._pushUndoCmd({undo:()=>this._restoreStructural(i),redo:()=>this._restoreStructural(n)}),this._opts.onColumnReorder?.([...this._columns])}else t||(this._updateColSel(e,o),this._kbProxy.focus());return this._canvas.style.cursor="",this._draw(),!0}if(this._rowDrag){let{row:t,insertBefore:e,active:s,ctrlKey:i,shiftKey:o}=this._rowDrag;return this._rowDrag=null,this._canvas.style.cursor="",s?this._reorderRow(t,e):((r._plugin("rowSelection")?.modeFor(this)??"none")!=="none"&&(this._sel=null),this._updateRowSel(t,i,o),this._draw(),this._kbProxy.focus()),!0}if(this._fillDrag){if(this._stopDragAutoScroll(),this._fillPreview){let t=this._fillDrag.sel,e=t.type==="single"?t.row:t.r1,s=t.type==="single"?t.row:t.r2,i=t.type==="single"?t.col:t.c1,o=t.type==="single"?t.col:t.c2,{r1:n,c1:l,r2:a,c2:c}=this._fillPreview;this._applyFill(t,this._fillPreview),this._sel={type:"range",r1:Math.min(e,n),c1:Math.min(i,l),r2:Math.max(s,a),c2:Math.max(o,c)},this._opts.onSelectionChange?.(this._sel)}return this._fillDrag=null,this._fillPreview=null,this._canvas.style.cursor="",this._draw(),!0}return!1}_armLongPress(t,e){clearTimeout(this._longPressTimer),this._longPressTimer=setTimeout(()=>{this._longPressTimer=null,this._colDrag=null,this._rowDrag=null,this._rowTap=null,this._touch=null,navigator.vibrate?.(10),this._openContextMenuAt(t,e,this._geo())},Hs)}_cancelLongPress(){clearTimeout(this._longPressTimer),this._longPressTimer=null}_bind(){let t=this._ev;t.wheel=e=>{let s=this._geo(),{dx:i,dy:o}=this._wheelPixels(e,s),n=this._scrollEase.animating,l=n?this._scrollAim.y:this._scrollTop,a=n?this._scrollAim.x:this._scrollLeft,c=l<=s.minScrollY,h=l>=s.maxScrollY,_=a<=0,f=a>=s.maxScrollX,d=o!==0&&!(o>0&&h||o<0&&c),u=i!==0&&!(i>0&&f||i<0&&_);!d&&!u||(e.preventDefault(),this._editing&&this._commitEdit(),this._easeWheel(i,o,s)||(this._cancelScrollEase(),this._scrollTop+=o,this._scrollLeft+=i,this._clamp(s)),this._scrolling=!0,this._dm.setHold(!0),clearTimeout(this._scrollEndTimer),this._scrollEndTimer=setTimeout(()=>{this._scrolling=!1,this._dm.setHold(!1),this._schedDraw()},150),this._schedDraw())},t.contextmenu=e=>{let{x:s,y:i}=this._xy(e),o=this._geo();this._openContextMenuAt(s,i,o)&&e.preventDefault()},t.mousedown=e=>{let{x:s,y:i}=this._xy(e),o=this._geo(),{v:n,h:l}=o,a=this._suppressReopenCell;this._suppressReopenCell=null,this._editing&&this._commitEdit(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu();let c=this._filterPanel?.col??-1;if(this._closeFilterPanel(),e.button===2&&this._sel){let u=this._hitCell(s,i,o);if(u&&(this._sel.type==="single"?this._sel.row===u.row&&this._sel.col===u.col:u.row>=this._sel.r1&&u.row<=this._sel.r2&&u.col>=this._sel.c1&&u.col<=this._sel.c2))return}if(s>=n.x){if(i>=n.thumbY&&i<=n.thumbY+n.thumbH)this._drag={axis:"v",startMouse:i,startScroll:this._scrollTop};else if(i>=n.y&&i<=n.y+n.h){let u=Math.max(0,Math.min(1,(i-n.y-n.thumbH/2)/(n.h-n.thumbH)));this._scrollTop=o.minScrollY+u*(o.maxScrollY-o.minScrollY),this._clamp(o),this._draw()}e.preventDefault();return}if(i>=l.y){if(s>=l.thumbX&&s<=l.thumbX+l.thumbW)this._drag={axis:"h",startMouse:s,startScroll:this._scrollLeft};else if(s>=l.x&&s<=l.x+l.w){let u=Math.max(0,Math.min(1,(s-l.x-l.thumbW/2)/(l.w-l.thumbW)));this._scrollLeft=u*o.maxScrollX,this._clamp(o),this._draw()}e.preventDefault();return}let{headerH:h}=o;if(i>=0&&i<h){let u=this._hitHeader(s,o);if(u!==null){let p=o.colPositions[u+1]-o.colPositions[u],w=this._colLeft(u,o)+p,m=w-Bt;if(Math.abs(s-w)<=Ot){this._colResize={col:u,startX:s,startWidth:p,undoBefore:this._snapshotStructural()},e.preventDefault();return}let C=this._colLeft(u,o);if(u>0&&Math.abs(s-C)<=Ot){let y=o.colPositions[u]-o.colPositions[u-1];this._colResize={col:u-1,startX:s,startWidth:y,undoBefore:this._snapshotStructural()},e.preventDefault();return}let S=this._columns[u];if(this._colDefMap.get(S)?.headerCheckbox){let y=this._opts.theme?.cellPadding??4,v=this._colLeft(u,o)+y+6,x=Wt(this._opts.headerRows,this._columns,this._opts.columnLetterHeader).find(W=>W.isLeaf&&W.col===u),B=x?x.row*this._opts.headerHeight+x.rowspan*this._opts.headerHeight/2:h-this._opts.headerHeight/2;if(Math.abs(s-v)<=9&&Math.abs(i-B)<=9){let W=!(this._headerCheckboxState.get(S)??!1);this._headerCheckboxState.set(S,W),this._draw(),this._opts.onHeaderCheckboxChange?.(S,W),e.preventDefault();return}}if(s>=m&&i>=h-this._opts.headerHeight){u!==c&&this._openFilterPanel(u),e.preventDefault();return}this._colDrag={col:u,startX:s,insertBefore:u,active:!1,x:s,grabDX:s-this._colLeft(u,this._geo()),startCol:u,undoBefore:null,shiftKey:e.shiftKey},e.preventDefault();return}}let _=o.rowNumW>0&&s<o.rowNumW&&i>=o.headerH?this._hitRowBoundary(i,o):null;if(_!==null){this._rowResize={row:_,startY:i,startHeight:this._rowLayout.heightOf(_),undoBefore:this._snapshotStructural()},e.preventDefault();return}if(o.rowNumW>0&&s<o.rowNumW&&i>=o.headerH){let u=this._hitRowNumber(s,i,o);if(u!==null){if(e.preventDefault(),this._rowReorderReady()&&this._localIndexAt(u)<0&&!this._isGroupRow(u)){this._rowDrag={row:u,startY:i,insertBefore:u,active:!1,ctrlKey:e.ctrlKey||e.metaKey,shiftKey:e.shiftKey};return}this._opts.rowReorder&&this._rowOrderData===null&&!r._plugins.some(p=>p.altRowSource?.(this))&&this._materializeRowOrder(),(r._plugin("rowSelection")?.modeFor(this)??"none")!=="none"&&(this._sel=null),this._updateRowSel(u,e.ctrlKey||e.metaKey,e.shiftKey),this._draw(),this._kbProxy.focus()}return}if(this._sel&&this._hitFillHandle(s,i,o)){this._fillDrag={sel:this._sel},this._fillPreview=null,e.preventDefault();return}let d=this._hitCell(s,i,o);if(d&&e.preventDefault(),d&&this._hitTreeChevron(s,d,o)){this._commitEdit(),this.toggleTreeNode(this._dm.getRow(d.row).__treePath),this._kbProxy.focus();return}if(d&&this._isGroupRow(d.row)){this._commitEdit(),this.toggleGroup(this._dm.getRow(d.row).path),this._kbProxy.focus();return}if(d){if(this._commitEdit(),!e.shiftKey&&!e.ctrlKey&&!e.metaKey){let w=this._columns[d.col];if(this._colDefMap.get(w)?.type==="button"){this._sel={type:"single",row:d.row,col:d.col},this._selAnchor=null,this._selDragging=!0,this._selDragStart=d,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(d.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell(),this._fireButtonClick(d.row,d.col),this._draw();return}}if(!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._isEditable(d.col)){let w=this._columns[d.col];if(this._colDefMap.get(w)?.type==="checkbox"){this._sel={type:"single",row:d.row,col:d.col},this._selAnchor=null,this._selDragging=!0,this._selDragStart=d,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(d.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell(),this._announce(this._i18n.announceCell(d.row+1,this._columnLabels[d.col]??this._columns[d.col],this._cellVal(d.row,d.col)||this._i18n.emptyCell)),this._toggleCheckbox(d.row,d.col);return}}let u=!e.shiftKey&&!e.ctrlKey&&!e.metaKey&&this._sel?.type==="single"&&this._sel.row===d.row&&this._sel.col===d.col;if(e.shiftKey&&this._sel){this._selAnchor||(this._selAnchor=this._sel.type==="single"?{row:this._sel.row,col:this._sel.col}:{row:this._sel.r1,col:this._sel.c1});let w=this._selAnchor,m=this._normRange(w.row,w.col,d.row,d.col);this._sel=m.r1===m.r2&&m.c1===m.c2?{type:"single",row:m.r1,col:m.c1}:{type:"range",...m}}else this._sel={type:"single",row:d.row,col:d.col},this._selAnchor=null;this._selDragging=!0,this._selDragStart=d,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(d.row,e.ctrlKey||e.metaKey,e.shiftKey),this._kbProxy.focus(),this._updateA11yCell(),this._announce(this._i18n.announceCell(d.row+1,this._columnLabels[d.col]??this._columns[d.col],this._cellVal(d.row,d.col)||this._i18n.emptyCell));let p=a&&a.row===d.row&&a.col===d.col;if(u&&!p&&this._isEditable(d.col)){let w=this._columns[d.col],m=this._colDefMap.get(w);if(m?.type==="dropdown"||m?.type==="multiselect"){this._draw(),this._startDropdownEdit(d.row,d.col,m);return}}this._draw()}},t.mousemove=e=>{let{x:s,y:i}=this._xy(e);if(this._colResize||this._rowResize||this._colDrag||this._rowDrag||this._fillDrag||this._drag||this._selDragging||this._anyOverlayOpen())this._setHoverRow(null);else{let l=this._geo();this._setHoverRow(this._hitCell(s,i,l)?.row??this._hitRowNumber(s,i,l))}if(this._updateStructuralGesture(s,i))return;let n=this._headerH;if(i>=0&&i<n){let l=this._geo(),a=this._hitHeader(s,l);if(a!==null){let c=l.colPositions[a+1]-l.colPositions[a],h=this._colLeft(a,l)+c,_=this._colLeft(a,l);if(Math.abs(s-h)<=Ot||a>0&&Math.abs(s-_)<=Ot)this._canvas.style.cursor="col-resize";else{let f=i>=n-this._opts.headerHeight;this._canvas.style.cursor=s>=h-Bt&&f?"pointer":"grab"}}else!this._drag&&!this._selDragging&&(this._canvas.style.cursor="")}else if(!this._drag&&!this._selDragging){let l=this._geo();if(l.rowNumW>0&&s>=0&&s<l.rowNumW&&this._hitRowBoundary(i,l)!==null)this._canvas.style.cursor="row-resize";else if(this._sel&&this._hitFillHandle(s,i))this._canvas.style.cursor="crosshair";else{let a=this._hitCell(s,i),c=a?this._columns[a.col]:null;this._canvas.style.cursor=c&&this._colDefMap.get(c)?.type==="button"?"pointer":""}}if(this._drag){let l=this._geo(),{v:a,h:c}=l;if(this._drag.axis==="v"){let h=(i-this._drag.startMouse)/(a.h-a.thumbH);this._scrollTop=this._drag.startScroll+h*(l.maxScrollY-l.minScrollY)}else{let h=(s-this._drag.startMouse)/(c.w-c.thumbW);this._scrollLeft=this._drag.startScroll+h*l.maxScrollX}this._clamp(l),this._scrolling=!0,this._dm.setHold(!0),clearTimeout(this._scrollEndTimer),this._scrollEndTimer=setTimeout(()=>{this._scrolling=!1,this._dm.setHold(!1),this._schedDraw()},150),this._schedDraw();return}if(this._selDragging&&(this._dragScrollPos={x:s,y:i},this._dragScrollDir=this._dragEdgeDir(s,i),this._dragScrollDir.dx||this._dragScrollDir.dy?this._startDragAutoScroll():this._stopDragAutoScroll(),this._extendDragSelection(s,i)),!this._drag&&!this._selDragging&&!this._colDrag&&!this._colResize&&!this._rowDrag){let l=this._geo(),a=this._hitCell(s,i,l),c=a&&!this._validator.isValid()?this._validator.map.get(`${a.row}_${this._columns[a.col]}`):null,h=null;if(!c&&a&&this._opts.cellTooltip)try{h=this._opts.cellTooltip(this.getRowData(a.row),a.row,this._columns[a.col],a.col)||null}catch(f){console.error("[JHGrid] cellTooltip error at row",a.row,"col",a.col,":",f)}let _=null;if(!c&&!h&&a)for(let f of r._plugins){let d=f.cellTooltip?.(this,a.row,this._columns[a.col]);if(d){_=d;break}}if(_)for(let f of r._plugins)f.showTooltip?.(this,_,s,i);else for(let f of r._plugins)f.hideTooltip?.(this);if(clearTimeout(this._tooltipTimer),c||h){let{width:f}=this._opts;this._cellTooltip.textContent=c||h,this._cellTooltip.style.display="block",this._cellTooltip.style.left=`${Math.min(s+12,f-330)}px`,this._cellTooltip.style.top=`${Math.max(0,i-36)}px`}else a&&!_&&!this._columnRenderers[a.col]?this._tooltipTimer=setTimeout(()=>{let f=this._cellVal(a.row,a.col);if(!f){this._cellTooltip.style.display="none";return}let{theme:d}=this._opts,u=this._canvas.getContext("2d");u.font=`${d.fontSize}px ${d.fontFamily}`;let w=l.colPositions[a.col+1]-l.colPositions[a.col]-d.cellPadding*2;if(u.measureText(f).width>w){let{width:C}=this._opts;this._cellTooltip.textContent=f,this._cellTooltip.style.display="block",this._cellTooltip.style.left=`${Math.min(s+12,C-330)}px`,this._cellTooltip.style.top=`${Math.max(0,i-36)}px`}else this._cellTooltip.style.display="none"},600):this._cellTooltip.style.display="none"}else{for(let l of r._plugins)l.hideTooltip?.(this);this._cellTooltip.style.display="none",clearTimeout(this._tooltipTimer)}},t.mouseup=()=>{if(this._finalizeStructuralGesture())return;this._drag=null;let e=this._selDragging;this._selDragging=!1,this._stopDragAutoScroll(),e&&this._opts.onSelectionChange?.(this._sel)},t.dblclick=e=>{let{x:s,y:i}=this._xy(e),o=this._headerH;if(i>=0&&i<o){let a=this._geo(),c=this._hitHeader(s,a);if(c!==null){let h=a.colPositions[c+1]-a.colPositions[c],_=this._colLeft(c,a)+h,f=this._colLeft(c,a),d=u=>{let p=this._selectedColsForAutoFit();p&&p.size>1&&(p.has(u)||p.has(u+1))?p.forEach(w=>this._autoFitCol(w)):this._autoFitCol(u)};if(Math.abs(s-_)<=Ot){d(c),this._clamp(this._geo()),this._draw();return}if(c>0&&Math.abs(s-f)<=Ot){d(c-1),this._clamp(this._geo()),this._draw();return}}return}let n=this._geo();if(n.rowNumW>0&&s<n.rowNumW&&i>=o){let a=this._hitRowBoundary(i,n);if(a!==null){let c=this._selectedRowsForAutoFit();c&&c.size>1&&(c.has(a)||c.has(a+1))?c.forEach(h=>this._autoFitRow(h)):this._autoFitRow(a),this._clamp(this._geo()),this._draw();return}}let l=this._hitCell(s,i);l&&this._isGroupRow(l.row)||l&&this._hitTreeChevron(s,l,this._geo())||l&&(this._sel={type:"single",row:l.row,col:l.col},this._startEdit(l.row,l.col),this._draw())},t.keydown=e=>{if(this._editing)return;if(this._headerFocusCol!==null){this._handleHeaderFocusKey(e);return}if(this._rowFocus!==null){this._handleRowFocusKey(e);return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="z"){e.preventDefault(),e.shiftKey?this.redo():this.undo();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="y"){e.preventDefault(),this.redo();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="c"&&(this._sel||this._selectedRowsSorted().length>0)&&navigator.clipboard?.writeText){e.preventDefault();let i=this._buildCopyText();navigator.clipboard.writeText(i).catch(()=>{}),this._lastCopyMissingRows>0&&(this._showErrorBanner(this._i18n.copyIncomplete(this._lastCopyMissingRows)),this._announce(this._i18n.copyIncomplete(this._lastCopyMissingRows)));return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="v"&&this._sel&&(navigator.clipboard?.readText||navigator.clipboard?.read)){e.preventDefault(),this._pasteFromClipboardAsync();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="a"&&this._sel){e.preventDefault(),this._selAnchor=null;let i=this._sel.type==="single"?this._sel.row:this._sel.r1,o=this._sel.type==="single"?this._sel.col:this._sel.c1,{r1:n,c1:l,r2:a,c2:c}=this._usedRange(i,o);this._setSel(n===a&&l===c?{type:"single",row:n,col:l}:{type:"range",r1:n,c1:l,r2:a,c2:c}),this._ensureVisible(a,c),this._updateA11yCell(),this._draw();return}if(e.key==="Tab"){e.preventDefault(),this._sel&&(this._selAnchor=null,this._moveSel(0,e.shiftKey?-1:1));return}if(e.key==="ArrowUp"&&(e.ctrlKey||e.metaKey)&&this._sel){e.preventDefault(),this._enterHeaderFocus(this._sel.type==="single"?this._sel.col:this._sel.c1);return}if(e.key==="ArrowLeft"&&!e.shiftKey&&this._opts.showRowNumbers&&this._sel&&(this._sel.type==="single"?this._sel.col:this._sel.c1)===0){e.preventDefault(),this._enterRowFocus(this._sel.type==="single"?this._sel.row:this._sel.r1);return}let s=Bs[e.key];if(s){if(e.preventDefault(),!this._sel&&this._totalRows>0){this._focusDefaultCell();return}e.shiftKey?this._extendSel(...s):(this._selAnchor=null,this._moveSel(...s));return}if(e.key==="Escape"){if(this._colDrag){let{active:i,undoBefore:o}=this._colDrag;this._colDrag=null,this._colSlide=null,this._colSlideTween.stop(),i&&o&&this._restoreStructural(o),this._canvas.style.cursor="",this._draw();return}if(this._fillDrag){this._fillDrag=null,this._fillPreview=null,this._canvas.style.cursor="",this._draw();return}this._filterPanel?this._closeFilterPanel():this._colContextMenu?this._closeColContextMenu():this._rowContextMenu?this._closeRowContextMenu():this._cellContextMenu?this._closeCellContextMenu():(this._setSel(null),this._selAnchor=null,this._updateA11yCell(),this._draw());return}if(this._sel){if(e.key==="Delete"||e.key==="Backspace"){e.preventDefault(),this._clearSelection();return}if(e.key==="Home"){e.preventDefault();let i=this._sel.type==="single"?this._sel.row:this._sel.r1,o=e.ctrlKey?0:i,n=0;this._setSel({type:"single",row:o,col:n}),this._selAnchor=null,this._ensureVisible(o,n),this._updateA11yCell(),this._announce(this._i18n.announceCell(o+1,this._columnLabels[n]??this._columns[n],this._cellVal(o,n)||this._i18n.emptyCell)),this._draw()}else if(e.key==="End"){e.preventDefault();let i=this._sel.type==="single"?this._sel.row:this._sel.r1,o=e.ctrlKey?this._totalRows-1:i,n=this._columns.length-1;this._setSel({type:"single",row:o,col:n}),this._selAnchor=null,this._ensureVisible(o,n),this._updateA11yCell(),this._announce(this._i18n.announceCell(o+1,this._columnLabels[n]??this._columns[n],this._cellVal(o,n)||this._i18n.emptyCell)),this._draw()}else if(e.key==="PageDown"){e.preventDefault(),this._selAnchor=null;let i=Math.max(1,Math.floor(this._geo().vpH/this._rowLayout.defaultHeight));this._moveSel(i,0)}else if(e.key==="PageUp"){e.preventDefault(),this._selAnchor=null;let i=Math.max(1,Math.floor(this._geo().vpH/this._rowLayout.defaultHeight));this._moveSel(-i,0)}else if(e.key===" "||e.key==="F2"||e.key==="Enter"){let i=this._sel.type==="single"?this._dm.getRow(this._sel.row):null,o=!!i?.__treeHasChildren&&this._colDefMap.get(this._columns[this._sel.col])?.treeColumn;if(this._sel.type==="single"&&this._isGroupRow(this._sel.row))e.preventDefault(),this.toggleGroup(this._dm.getRow(this._sel.row).path);else if(o)e.preventDefault(),this.toggleTreeNode(i.__treePath);else if(this._sel.type==="single"){e.preventDefault();let n=this._columns[this._sel.col],l=this._colDefMap.get(n);l?.type==="button"?(this._fireButtonClick(this._sel.row,this._sel.col),this._draw()):l?.type==="checkbox"&&this._isEditable(this._sel.col)?this._toggleCheckbox(this._sel.row,this._sel.col):e.key===" "?this._startEdit(this._sel.row,this._sel.col," "):this._startEdit(this._sel.row,this._sel.col)}}else e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this._sel.type==="single"&&!this._isPlainTextEditor(this._sel.col)&&(e.preventDefault(),this._startEdit(this._sel.row,this._sel.col,e.key))}},t.copy=e=>{if(!this._sel&&this._selectedRowsSorted().length===0||e.target!==this._kbProxy)return;e.preventDefault();let s=this._buildCopyText();e.clipboardData.setData("text/plain",s),this._lastCopyMissingRows>0&&(this._showErrorBanner(this._i18n.copyIncomplete(this._lastCopyMissingRows)),this._announce(this._i18n.copyIncomplete(this._lastCopyMissingRows)))},t.paste=e=>{if(!this._sel||e.target!==this._kbProxy)return;let i=Array.from(e.clipboardData?.items??[]).find(o=>o.type?.startsWith("image/"))?.getAsFile();if(i&&this._pasteImageBlob(i)){e.preventDefault();return}e.preventDefault(),this._applyPaste(e.clipboardData.getData("text/plain"))},t.focus=()=>{this._sel||this._totalRows===0||r._plugin("rowSelection")?.getRenderSet(this)||this._focusDefaultCell()},t.kbProxyInput=()=>{if(this._editing)return;let e=this._sel;if(!(e?.type==="single"&&this._isEditable(e.col)&&this._isPlainTextEditor(e.col))){this._kbProxy.value="";return}this._startEdit(e.row,e.col,void 0,{keepInputValue:!0})},t.docMousedown=e=>{this._anyOverlayOpen()&&(this._wrapper.contains(e.target)||(this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._closeColChooser(),this._closeNewColumnDialog()))},t.touchstart=e=>{if(e.touches.length===1){let s=e.touches[0],i=this._canvas.getBoundingClientRect(),o=s.clientX-i.left,n=s.clientY-i.top;this._editing&&this._commitEdit(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu();let l=this._filterPanel?.col??-1;this._closeFilterPanel(),this._rowTap=null;let a=this._geo(),c=a.headerH;if(n>=0&&n<c){let _=this._hitHeader(o,a);if(_!==null){let f=a.colPositions[_+1]-a.colPositions[_],d=this._colLeft(_,a)+f,u=d-Bt;if(Math.abs(o-d)<=Ot){this._colResize={col:_,startX:o,startWidth:f,undoBefore:this._snapshotStructural()},e.preventDefault();return}let p=this._colLeft(_,a);if(_>0&&Math.abs(o-p)<=Ot){let m=a.colPositions[_]-a.colPositions[_-1];this._colResize={col:_-1,startX:o,startWidth:m,undoBefore:this._snapshotStructural()},e.preventDefault();return}let w=this._columns[_];if(this._colDefMap.get(w)?.headerCheckbox){let m=this._opts.theme?.cellPadding??4,C=this._colLeft(_,a)+m+6,S=Wt(this._opts.headerRows,this._columns,this._opts.columnLetterHeader).find(v=>v.isLeaf&&v.col===_),y=S?S.row*this._opts.headerHeight+S.rowspan*this._opts.headerHeight/2:c-this._opts.headerHeight/2;if(Math.abs(o-C)<=9&&Math.abs(n-y)<=9){let v=!(this._headerCheckboxState.get(w)??!1);this._headerCheckboxState.set(w,v),this._draw(),this._opts.onHeaderCheckboxChange?.(w,v),e.preventDefault();return}}if(o>=u&&n>=c-this._opts.headerHeight){_!==l&&this._openFilterPanel(_),e.preventDefault();return}this._colDrag={col:_,startX:o,insertBefore:_,active:!1,x:o,grabDX:o-this._colLeft(_,a),startCol:_,undoBefore:null,shiftKey:!1},this._armLongPress(o,n),e.preventDefault();return}}let h=a.rowNumW>0&&o<a.rowNumW&&n>=a.headerH?this._hitRowBoundary(n,a):null;if(h!==null){this._rowResize={row:h,startY:n,startHeight:this._rowLayout.heightOf(h),undoBefore:this._snapshotStructural()},e.preventDefault();return}if(a.rowNumW>0&&o<a.rowNumW&&n>=a.headerH){let _=this._hitRowNumber(o,n,a);_!==null&&(this._rowReorderReady()&&this._localIndexAt(_)<0&&!this._isGroupRow(_)?this._rowDrag={row:_,startY:n,insertBefore:_,active:!1,ctrlKey:e.ctrlKey||e.metaKey,shiftKey:e.shiftKey}:(this._opts.rowReorder&&this._rowOrderData===null&&!r._plugins.some(f=>f.altRowSource?.(this))&&this._materializeRowOrder(),this._rowTap={row:_,startY:n,ctrlKey:e.ctrlKey||e.metaKey,shiftKey:e.shiftKey}),this._armLongPress(o,n),e.preventDefault());return}if(this._sel&&this._hitFillHandle(o,n,a)){this._fillDrag={sel:this._sel},this._fillPreview=null,e.preventDefault();return}this._touch={startX:o,startY:n,scrollTopStart:this._scrollTop,scrollLeftStart:this._scrollLeft,moved:!1},this._armLongPress(o,n)}else if(e.touches.length===2){this._cancelLongPress();let s=e.touches[0],i=e.touches[1],o=this._canvas.getBoundingClientRect();this._touch={twoFinger:!0,midX:(s.clientX+i.clientX)/2-o.left,midY:(s.clientY+i.clientY)/2-o.top,scrollTopStart:this._scrollTop,scrollLeftStart:this._scrollLeft},e.preventDefault()}},t.touchmove=e=>{if(this._colResize||this._rowResize||this._colDrag||this._rowDrag||this._fillDrag){if(!e.touches.length)return;let i=e.touches[0],o=this._canvas.getBoundingClientRect();this._updateStructuralGesture(i.clientX-o.left,i.clientY-o.top),(this._colDrag?.active||this._rowDrag?.active)&&this._cancelLongPress(),e.preventDefault();return}if(!this._touch)return;let s=this._canvas.getBoundingClientRect();if(e.touches.length>=2&&this._touch.twoFinger){e.preventDefault();let i=e.touches[0],o=e.touches[1],n=(i.clientX+o.clientX)/2-s.left,l=(i.clientY+o.clientY)/2-s.top,a=this._geo();this._scrollTop=Math.max(a.minScrollY,Math.min(a.maxScrollY,this._touch.scrollTopStart-(l-this._touch.midY))),this._scrollLeft=Math.max(0,Math.min(a.maxScrollX,this._touch.scrollLeftStart-(n-this._touch.midX))),this._schedDraw()}else if(e.touches.length===1&&!this._touch.twoFinger){let i=e.touches[0],o=i.clientX-s.left,n=i.clientY-s.top,l=o-this._touch.startX,a=n-this._touch.startY;if(!this._touch.moved&&(Math.abs(l)>5||Math.abs(a)>5)&&(this._touch.moved=!0,this._cancelLongPress()),this._touch.moved){e.preventDefault();let c=this._geo();this._scrollTop=Math.max(c.minScrollY,Math.min(c.maxScrollY,this._touch.scrollTopStart-a)),this._scrollLeft=Math.max(0,Math.min(c.maxScrollX,this._touch.scrollLeftStart-l)),this._schedDraw()}}else if(this._rowTap){let i=e.touches[0];(Math.abs(i.clientX-s.left-this._rowTap.startX)>5||Math.abs(i.clientY-s.top-this._rowTap.startY)>5)&&this._cancelLongPress()}},t.touchend=e=>{if(this._cancelLongPress(),this._finalizeStructuralGesture())return;if(this._rowTap){let{row:h,ctrlKey:_,shiftKey:f}=this._rowTap;this._rowTap=null,(r._plugin("rowSelection")?.modeFor(this)??"none")!=="none"&&(this._sel=null),this._updateRowSel(h,_,f),this._draw(),this._kbProxy.focus();return}if(!this._touch)return;let s=this._touch;if(this._touch=null,s.twoFinger||s.moved||e.changedTouches.length!==1)return;e.preventDefault();let{startX:i,startY:o}=s,n=this._geo(),l=this._hitCell(i,o,n);if(!l)return;let a=Date.now();if(a-this._lastTap.time<350&&this._lastTap.row===l.row&&this._lastTap.col===l.col)this._lastTap={time:0,row:-1,col:-1},this._sel={type:"single",row:l.row,col:l.col},this._startEdit(l.row,l.col),this._draw();else{this._lastTap={time:a,row:l.row,col:l.col},this._editing&&this._commitEdit(),this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._setSel({type:"single",row:l.row,col:l.col}),this._selAnchor=null,this._opts.showRowNumbers?this._clearRowSelOnCellClick(e):this._updateRowSel(l.row,!1,!1),this._kbProxy.focus(),this._updateA11yCell(),this._announce(this._i18n.announceCell(l.row+1,this._columnLabels[l.col]??this._columns[l.col],this._cellVal(l.row,l.col)||this._i18n.emptyCell));let h=this._columns[l.col],_=this._colDefMap.get(h);_?.type==="button"?(this._fireButtonClick(l.row,l.col),this._draw()):_?.type==="checkbox"&&this._isEditable(l.col)?this._toggleCheckbox(l.row,l.col):(_?.type==="dropdown"||_?.type==="multiselect")&&this._isEditable(l.col)?(this._draw(),this._startDropdownEdit(l.row,l.col,_)):this._draw()}},this._canvas.addEventListener("wheel",t.wheel,{passive:!1}),this._canvas.addEventListener("mousedown",t.mousedown),this._canvas.addEventListener("dblclick",t.dblclick),this._canvas.addEventListener("contextmenu",t.contextmenu),this._canvas.addEventListener("touchstart",t.touchstart,{passive:!1}),this._canvas.addEventListener("touchmove",t.touchmove,{passive:!1}),this._canvas.addEventListener("touchend",t.touchend),this._canvas.addEventListener("touchcancel",t.touchend),this._kbProxy.addEventListener("keydown",t.keydown),this._kbProxy.addEventListener("copy",t.copy),this._kbProxy.addEventListener("paste",t.paste),this._kbProxy.addEventListener("focus",t.focus),this._kbProxy.addEventListener("input",t.kbProxyInput),window.addEventListener("mousemove",t.mousemove),window.addEventListener("mouseup",t.mouseup),document.addEventListener("mousedown",t.docMousedown),document.addEventListener("touchstart",t.docMousedown,{passive:!0})}async _boot(t=null){if(this._booting)return this._bootPromise;this._booting=!0;let e;this._bootPromise=new Promise(s=>{e=s});try{let s=await this._opts.fetchMeta(t);if(this._destroyed)return;this._serverTotal=s.totalRows,this._rowPlan.removed.dropFrom(s.totalRows),this._rowPlan.clampAnchors(s.totalRows),this._totalRows=this._rowPlan.totalRows,this._restoreLocalRowState(),this._columns.forEach((a,c)=>{this._columnWidths[c]!=null&&this._columnWidthMap.set(a,this._columnWidths[c])});let i=new Set(s.columns),o=this._opts.columnDefs?.map(a=>a.field)??[],n=o.length>0?[...o.filter(a=>i.has(a)),...s.columns.filter(a=>!o.includes(a))]:[...s.columns];if(this._localColumns.size>0){let a=new Set([...n,...this._localColumns.keys()]);n=this._columnOriginalOrder.length>0?[...this._columnOriginalOrder.filter(c=>a.has(c)),...[...a].filter(c=>!this._columnOriginalOrder.includes(c))]:[...n,...this._localColumns.keys()]}this._columnOriginalOrder.length===0&&(this._columnOriginalOrder=[...n]);let l=n.filter(a=>!this._hiddenColumns.has(a)&&!this._deletedColumns.has(a));this._columns=l,this._columnLabels=l.map(a=>this._colDefMap.get(a)?.label??a),this._columnAligns=l.map(a=>this._colDefMap.get(a)?.align??"left"),this._columnHeaderAligns=l.map(a=>this._colDefMap.get(a)?.headerAlign??this._colDefMap.get(a)?.align??"left"),this._columnWidths=l.map(a=>this._columnWidthMap.get(a)??this._colDefMap.get(a)?.width??this._opts.colWidth),this._columnRenderers=l.map(a=>{let c=this._colDefMap.get(a),h=c?.renderer,_=h?typeof h=="function"?h:pt[h]?.()??null:c?.type==="checkbox"?pt.checkbox():c?.type==="dropdown"?pt.dropdown():c?.type==="button"?pt.button(c.button??{}):c?.type==="date"?pt.date({format:c.format,align:c.align}):c?.type==="multiselect"?pt.multiselect():c?.type==="richtext"?pt.richtext():c?.type==="image"?pt.image():null;return c?.treeColumn?pt.tree({inner:_}):_}),this._hiddenColumns.forEach((a,c)=>{if(a!==null)return;if(n.indexOf(c)===-1){this._hiddenColumns.delete(c);return}this._hiddenColumns.set(c,{label:this._colDefMap.get(c)?.label??c,align:this._colDefMap.get(c)?.align??"left",headerAlign:this._colDefMap.get(c)?.headerAlign??this._colDefMap.get(c)?.align??"left",width:this._columnWidthMap.get(c)??this._colDefMap.get(c)?.width??this._opts.colWidth,renderer:(()=>{let _=this._colDefMap.get(c)?.renderer;return _?typeof _=="function"?_:pt[_]?.()??null:null})()})}),this._loadingEl.style.display="none",this._emptyEl.style.display=this._totalRows===0?"flex":"none",this._wrapper.removeAttribute("aria-busy"),this._updateA11yHeader(),this._pagination&&(this._page=Math.min(this._page,this._pageCount()-1),this._updatePagerBar()),this._isLocalData?this._dm.loadAll(0,this._totalRows-1):this._dm.prefetch(0,Math.min(this._opts.chunkSize-1,this._totalRows-1)),this._draw(),this._opts.rowReorder&&(this._rowOrderData=null,this._rowOrderGen++)}catch(s){console.error("[JHGrid] fetchMeta failed:",s),this._loadingEl.textContent=this._i18n.loadError,this._wrapper.removeAttribute("aria-busy")}finally{this._booting=!1,this._bootPromise=null,e(),this._readyResolve&&(this._readyResolve(),this._readyResolve=null)}}static _selKeyOf(t){return t?t.type==="single"?`s${t.row},${t.col}`:`r${t.r1},${t.c1},${t.r2},${t.c2}`:null}_syncSelAnim(t){let e=r._selKeyOf(t);if(e===this._selKey)return;this._selMoveMs===0||this._selDragging||this._fillDrag||!t||!this._selLast||this._selMove.animating?(this._selPrev=null,this._selMove.set(1)):(this._selPrev=this._selLast,this._selMove.set(0),this._selMove.to(1,this._selMoveMs)),this._selKey=e,this._selLast=t}_draw(){if(this._destroyed)return;let t={filters:null,grouping:null,groupFooter:null};for(let s of r._plugins)s.renderParams?.(this,t);if(this._filters.size>0){let s={};for(let[i,o]of this._filters)this._trivialSetFilters.has(i)||(s[i]=o);t.filters={...s,...t.filters}}let e=this._isButtonCell(this._sel)?null:this._sel;this._syncSelAnim(e),this._renderer.render({scrollTop:this._scrollTop,scrollLeft:this._scrollLeft,totalRows:this._totalRows,columns:this._columns,columnLabels:this._columnLabels,columnAligns:this._columnAligns,columnHeaderAligns:this._columnHeaderAligns,getRow:s=>this._getRow(s),geo:this._geo(),rowLayout:this._rowLayout,sel:e,editing:this._editing?{row:this._editing.row,col:this._editing.col}:null,headerFocusCol:this._headerFocusCol,rowFocus:this._rowFocus,colDrag:this._colDrag,rowDrag:this._rowDrag,sorts:this._sorts,filters:t.filters,columnRenderers:this._columnRenderers,invalidCells:this._validator.isValid()?null:this._validator.map,selectedRows:r._plugin("rowSelection")?.getRenderSet(this)??null,fillPreview:this._fillPreview,deletedRows:this._deletedRows.size>0?this._deletedRows:null,skeletonPhase:this._skeletonPhase(),rowNumberLabel:this._i18n.rowNumberLabel??"No.",grouping:t.grouping,groupFooter:t.groupFooter,hiddenNeighbors:this._computeHiddenNeighbors(),editableColumns:(()=>{let s=this._columns.map((i,o)=>this._isEditable(o));return s.every(Boolean)?null:s})(),i18n:this._i18n,hoverRow:this._hoverRow===null?null:{row:this._hoverRow,alpha:this._hoverFade.value},selAnim:this._selPrev&&this._selMove.value<1?{prev:this._selPrev,t:this._selMove.value}:null,colSlide:this._colSlide&&this._colSlideTween.value<1?{...this._colSlide,dx:this._colSlide.dx*(1-this._colSlideTween.value)}:null,remoteSelections:this._remoteSelections??null,headerCheckboxCols:this._columns.some(s=>this._colDefMap.get(s)?.headerCheckbox)?new Set(this._columns.filter(s=>this._colDefMap.get(s)?.headerCheckbox)):null}),this._drawHeaderCheckboxes(),this._syncKbProxyPosition(),this._opts.onRender?.()}_drawHeaderCheckboxes(){let t=this._geo(),{headerH:e,colPositions:s}=t,i=this._opts.headerHeight,o=12,n=window.devicePixelRatio||1,l=this._canvas.getContext("2d"),a=this._canvas.width/n,c=new Map;for(let h of Wt(this._opts.headerRows,this._columns,this._opts.columnLetterHeader))h.isLeaf&&c.set(h.col,h.row*i+h.rowspan*i/2);l.save(),l.setTransform(n,0,0,n,0,0);for(let h=0;h<this._columns.length;h++){let _=this._columns[h];if(!this._colDefMap.get(_)?.headerCheckbox)continue;let f=this._colLeft(h,t),d=(s[h+1]??s[h])-s[h];if(f+d<0||f>a)continue;let u=s.length-1,p=h<t.frozenCount,w=t.frozenRightCount>0&&h>=u-t.frozenRightCount;if(!p&&!w&&f<t.frozenWidth||!p&&!w&&t.frozenRightCount>0&&f>=t.rightX)continue;let m=this._opts.theme?.cellPadding??4,C=f+m+o/2,S=c.get(h)??e-i/2,y=this._headerCheckboxState.get(_)??!1;l.fillStyle=y?"#2563eb":"#ffffff",l.strokeStyle=y?"#2563eb":"#9ca3af",l.lineWidth=1,l.beginPath(),l.rect(C-o/2,S-o/2,o,o),l.fill(),l.stroke(),y&&(l.strokeStyle="#ffffff",l.lineWidth=1.5,l.lineCap="round",l.lineJoin="round",l.beginPath(),l.moveTo(C-3,S),l.lineTo(C-.5,S+2.5),l.lineTo(C+3.5,S-2.5),l.stroke())}l.restore()}_computeHiddenNeighbors(){if(this._hiddenColumns.size===0||this._columnOriginalOrder.length===0)return null;let t=this._columnOriginalOrder,e=this._hiddenColumns,s=new Set(this._columns);return this._columns.map(i=>{let o=t.indexOf(i);if(o<0)return{left:!1,right:!1};let n=!1,l=!1;for(let a=o-1;a>=0;a--){if(e.has(t[a])){n=!0;break}if(s.has(t[a]))break}for(let a=o+1;a<t.length;a++){if(e.has(t[a])){l=!0;break}if(s.has(t[a]))break}return{left:n,right:l}})}ready(){return this._readyPromise}setHeaderCheckbox(t,e){this._headerCheckboxState.set(t,e),this._draw()}getHeaderCheckbox(t){return this._headerCheckboxState.get(t)??!1}repaint(){this._schedDraw()}refresh(){this._closeFilterPanel(),this._cancelEdit();for(let t of r._plugins)t.hideTooltip?.(this);this._setSel(null),this._scrollTop=0,this._scrollLeft=0,this._page=0,this._edits.clear(),this._editedRows.clear(),this._validator.clear(),this._undoMgr.clear(),this._editTxn=null,this._filters.clear(),this._trivialSetFilters.clear(),this._sorts=[],this._clearPlugins("full"),this._rowLayout.clear(),this._fillDrag=null,this._fillPreview=null,this._localRows.length=0,this._deletedRows.clear(),this._serverTotal=0,this._rowPlan.reset(0),this._localColumns.clear(),this._deletedColumns.clear(),this._dm.setFetch((t,e)=>this._opts.fetchData(t,e,null)),this._columnWidths=[],this._columnWidthMap.clear(),this._columnOriginalOrder=[],this._emptyEl.style.display="none",this._loadingEl.style.display="flex",this._wrapper.setAttribute("aria-busy","true"),this._updateA11yCell(),this._boot()}scrollTo(t){if(typeof t!="number"||!isFinite(t))throw new TypeError("[JHGrid] scrollTo: rowIndex must be a finite number");if(this._pagination){let i=Math.floor(Math.max(0,t)/this._pagination.pageSize);i!==this._page&&this._switchToPage(i)}let{minScrollY:e,maxScrollY:s}=this._geo();this._scrollTop=Math.min(s,Math.max(e,this._rowLayout.yOf(t))),this._draw()}goToPage(t){typeof t!="number"||!isFinite(t)||this._switchToPage(t)}nextPage(){this._pagination&&this._switchToPage(this._page+1)}prevPage(){this._pagination&&this._switchToPage(this._page-1)}getCurrentPage(){return this._pagination?this._page:0}getPageCount(){return this._pageCount()}getEdits(){let t={};return this._edits.forEach((e,s)=>{let i=s.indexOf("_"),o=Number(s.slice(0,i)),n=s.slice(i+1);(t[o]??={})[n]=e}),t}clearEdits(){this._edits.clear(),this._editedRows.clear(),this._validator.clear(),this._fillDrag=null,this._fillPreview=null,this._undoMgr.clear(),this._editTxn=null,this._draw()}setRemoteSelections(t){if(!Array.isArray(t))throw new TypeError("[JHGrid] setRemoteSelections: list must be an array");this._remoteSelections=t,this._schedDraw()}setCellValue(t,e,s){if(!Number.isInteger(t)||t<0)throw new TypeError("[JHGrid] setCellValue: row must be a non-negative integer");if(typeof e!="string")throw new TypeError("[JHGrid] setCellValue: field must be a string");if(typeof s!="string")throw new TypeError("[JHGrid] setCellValue: value must be a string");if(this._columns.length>0&&!this._columns.includes(e))throw new RangeError(`[JHGrid] setCellValue: unknown field "${e}"`);this._isGroupRow(t)||(this._editTxnBegin(),this._setEdit(t,e,s),this._editTxnCommit(),this._updateA11yCell(),this._draw())}setCellValues(t){if(!Array.isArray(t))throw new TypeError("[JHGrid] setCellValues: entries must be an array");for(let e of t){let{row:s,field:i,value:o}=e??{};if(!Number.isInteger(s)||s<0)throw new TypeError("[JHGrid] setCellValues: row must be a non-negative integer");if(typeof i!="string")throw new TypeError("[JHGrid] setCellValues: field must be a string");if(typeof o!="string")throw new TypeError("[JHGrid] setCellValues: value must be a string");if(this._columns.length>0&&!this._columns.includes(i))throw new RangeError(`[JHGrid] setCellValues: unknown field "${i}"`)}this._editTxnBegin();for(let{row:e,field:s,value:i}of t)this._isGroupRow(e)||this._setEdit(e,s,i);this._editTxnCommit(),this._updateA11yCell(),this._draw()}addRow(t={},{index:e}={}){return this._withStructuralUndo(()=>{let s=e==null?this._totalRows:Math.max(0,Math.min(e,this._totalRows)),i=this._rowPlan.insertLocal(s);return this._localRows.splice(i,0,{...t}),this._totalRows=this._rowPlan.totalRows,this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._emptyEl.style.display="none",s<this._totalRows-1&&this._shiftRowKeyedState(o=>o>=s?o+1:o,{grow:!0}),this._draw(),s})}deleteRow(t,{permanent:e=this._opts.deleteMode==="permanent"}={}){t<0||t>=this._totalRows||this._withStructuralUndo(()=>{let s=this._localIndexAt(t);s>=0?(this._localRows.splice(s,1),this._rowPlan.removeLocal(s),this._totalRows=this._rowPlan.totalRows,this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._totalRows===0&&(this._emptyEl.style.display="flex"),this._shiftAfterRemoval(t)):e?this._rowPlan.removed.add(this._rowPlan.sourceAt(t).server)&&(this._totalRows--,this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._totalRows===0&&(this._emptyEl.style.display="flex"),this._shiftAfterRemoval(t)):this._deletedRows.add(t),this._sel&&(this._sel.type==="single"?this._sel.row===t:this._sel.r1===t||this._sel.r2===t)&&this._setSel(null),this._draw()})}_shiftRowKeyedState(t,{drop:e=-1,grow:s=!1}={}){let i=(o,n)=>{let l=new Map(o);o.clear(),l.forEach((a,c)=>{let h=c.indexOf("_"),_=Number(c.slice(0,h));if(_===e)return;let f=t(_);o.set(`${f}_${c.slice(h+1)}`,a),n?.(f)})};if(this._editedRows.clear(),i(this._edits,o=>this._editedRows.add(o)),i(this._validator.map),this._deletedRows.size>0){let o=[...this._deletedRows];this._deletedRows.clear();for(let n of o)n!==e&&this._deletedRows.add(t(n))}this._sel&&(this._sel=this._sel.type==="single"?{...this._sel,row:t(this._sel.row)}:{...this._sel,r1:t(this._sel.r1),r2:t(this._sel.r2)}),r._plugin("rowSelection")?.shiftRows(this,t,e),s?this._rowLayout.shiftRows(t):e>=0?this._rowLayout.deleteRow(e):this._rowLayout.shiftRows(t)}_shiftAfterRemoval(t){this._shiftRowKeyedState(e=>e>t?e-1:e,{drop:t})}undeleteRow(t){if(this._deletedRows.has(t)){this._withStructuralUndo(()=>{this._deletedRows.delete(t),this._draw()});return}this._rowPlan.removed.has(t)&&this._withStructuralUndo(()=>{this._rowPlan.removed.delete(t);let e=this._rowPlan.visualOfServer(t);this._totalRows++,this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._emptyEl.style.display="none",this._shiftAfterRestore(e),this._draw()})}_shiftAfterRestore(t){this._shiftRowKeyedState(e=>e>=t?e+1:e,{grow:!0})}getNewRows(){return this._localRows.map(t=>({...t}))}getDeletedRows(){return[...this._deletedRows].map(t=>this._rowPlan.sourceAt(t)?.server??-1).filter(t=>t>=0).sort((t,e)=>t-e)}getRemovedRows(){return this._rowPlan.removed.values()}clearFilters(){this._filters.clear(),this._trivialSetFilters.clear(),this._quickFilter="",this._clearPlugins("filterState"),this._sorts=[],this._cancelEdit(),this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._closeColChooser(),this._closeNewColumnDialog(),this._cellTooltip&&(this._cellTooltip.style.display="none");for(let t of r._plugins)t.hideTooltip?.(this);this._dm.setFetch((t,e)=>this._opts.fetchData(t,e,null)),this._scrollTop=0,this._scrollLeft=0,this._setSel(null),this._undoMgr.clear(),this._editTxn=null,this._emptyEl.style.display="none",this._loadingEl.style.display="flex",this._wrapper.setAttribute("aria-busy","true"),this._updateA11yCell(),this._boot()}getState(){let t={selectedRows:[],grouping:null,treeData:null,colorFilters:null};for(let e of r._plugins)e.exportState?.(this,t);return{columns:[...this._columns],columnWidths:Object.fromEntries(this._columns.map((e,s)=>[e,this._columnWidths[s]])),hiddenColumns:[...this._hiddenColumns.keys()],frozenCols:this._opts.frozenCols??0,frozenColsRight:this._opts.frozenColsRight??0,sorts:this._sorts.map(e=>({...e})),filters:Object.fromEntries(this._filters),quickFilter:this._quickFilter,headerCheckboxState:Object.fromEntries(this._headerCheckboxState),localColumns:this.getNewColumns(),deletedColumns:this.getDeletedColumns(),rowChanges:this._exportRowChanges(),...t}}_exportRowChanges(){let t=i=>{let o={},n=`${i}_`;return this._edits.forEach((l,a)=>{a.startsWith(n)&&(o[a.slice(n.length)]=l)}),o},e=this._localRows.map((i,o)=>({anchor:this._rowPlan.anchors[o],data:{...i},edits:t(this._rowPlan.visualOfLocal(o))})),s={};return this._edits.forEach((i,o)=>{let n=o.indexOf("_"),l=Number(o.slice(0,n)),a=this._rowPlan.sourceAt(l);!a||a.local>=0||((s[a.server]??={})[o.slice(n+1)]=i)}),{added:e,removed:this.getRemovedRows(),marked:this.getDeletedRows(),edits:s}}_importRowChanges(t){if(!t||typeof t!="object")return;this._localRows.length=0,this._rowPlan.anchors.length=0,this._rowPlan.removed.clear(),this._deletedRows.clear(),this._edits.clear(),this._editedRows.clear();for(let i of t.removed??[])this._rowPlan.removed.add(i);let e=[...t.added??[]].sort((i,o)=>(i.anchor??0)-(o.anchor??0));for(let i of e)this._localRows.push({...i.data??{}}),this._rowPlan.anchors.push(i.anchor??this._rowPlan.serverTotal);this._rowPlan.clampAnchors(this._serverTotal),this._totalRows=this._rowPlan.totalRows;let s=(i,o)=>{if(!(i<0||!o))for(let[n,l]of Object.entries(o))this._edits.set(`${i}_${n}`,l),this._editedRows.add(i)};e.forEach((i,o)=>s(this._rowPlan.visualOfLocal(o),i.edits));for(let[i,o]of Object.entries(t.edits??{}))s(this._rowPlan.visualOfServer(Number(i)),o);for(let i of t.marked??[]){let o=this._rowPlan.visualOfServer(i);o>=0&&this._deletedRows.add(o)}this._wrapper.setAttribute("aria-rowcount",String(this._totalRows+1)),this._emptyEl.style.display=this._totalRows===0?"flex":"none"}setState(t){if(!t)return;this._withStructuralUndo(()=>{if(Array.isArray(t.localColumns))for(let{field:o,...n}of t.localColumns)this._columns.includes(o)||this._hiddenColumns.has(o)||this._deletedColumns.has(o)||this._addColumnImpl(o,n);if(Array.isArray(t.deletedColumns))for(let o of t.deletedColumns)!this._columns.includes(o)||this._localColumns.has(o)||this._deletedColumns.has(o)||(this._hideColumnInternal(o),this._deletedColumns.add(o),this._purgeFieldEdits(o));if(Array.isArray(t.columns)){let o=new Set(t.hiddenColumns??[]);[...this._hiddenColumns.keys()].forEach(h=>this._showColumnInternal(h)),o.forEach(h=>this._hideColumnInternal(h));let n=t.columns.filter(h=>this._columns.includes(h)),l=this._columns.filter(h=>!n.includes(h)),a=[...n,...l],c=h=>a.map(_=>h[this._columns.indexOf(_)]);this._columnLabels=c(this._columnLabels),this._columnAligns=c(this._columnAligns),this._columnHeaderAligns=c(this._columnHeaderAligns),this._columnWidths=c(this._columnWidths),this._columnRenderers=c(this._columnRenderers),this._columns=a}if(t.columnWidths&&Object.entries(t.columnWidths).forEach(([o,n])=>{let l=this._columns.indexOf(o);l!==-1&&(this._columnWidths[l]=n),this._columnWidthMap.set(o,n)}),t.frozenCols!=null&&(this._opts.frozenCols=t.frozenCols),t.frozenColsRight!=null&&(this._opts.frozenColsRight=t.frozenColsRight),Array.isArray(t.sorts)){let o=r._plugins.some(n=>n.extraSortSlots);this._sorts=(o?t.sorts:t.sorts.slice(0,1)).map(n=>({...n}))}else t.sort&&(this._sorts=[{...t.sort}]);t.filters&&(this._filters.clear(),this._trivialSetFilters.clear(),Object.entries(t.filters).forEach(([o,n])=>this._filters.set(o,n))),typeof t.quickFilter=="string"&&(this._quickFilter=t.quickFilter),t.headerCheckboxState&&(this._headerCheckboxState.clear(),Object.entries(t.headerCheckboxState).forEach(([o,n])=>this._headerCheckboxState.set(o,n))),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()});for(let o of r._plugins)o.importState?.(this,t);let e=t.sorts!==void 0||t.filters!==void 0||t.quickFilter!==void 0,s=()=>{t.rowChanges&&this._importRowChanges(t.rowChanges),this._draw()};if(!e)return s(),Promise.resolve();let i=this._reloadFiltered({confirmUnsaved:!1,carryRows:!1});return Promise.resolve(i).then(s)}setFilter(t,e){if(typeof t!="string")throw new TypeError("[JHGrid] setFilter: field must be a string");if(e!=null&&e!==""&&typeof e!="string")throw new TypeError("[JHGrid] setFilter: value must be a string, null, or undefined");if(typeof e=="string"&&e.length>1e3)throw new RangeError("[JHGrid] setFilter: value exceeds maximum length of 1000 characters");if(this._columns.length>0&&!this._columns.includes(t))throw new RangeError(`[JHGrid] setFilter: unknown field "${t}"`);this._trivialSetFilters.delete(t),e==null||e===""?this._filters.delete(t):this._filters.set(t,e),this._reloadFiltered()}removeFilter(t){if(typeof t!="string")throw new TypeError("[JHGrid] removeFilter: field must be a string");this._filters.has(t)&&(this._filters.delete(t),this._trivialSetFilters.delete(t),this._reloadFiltered())}setFilterValues(t,e){if(typeof t!="string")throw new TypeError("[JHGrid] setFilterValues: field must be a string");if(e!=null&&!Array.isArray(e))throw new TypeError("[JHGrid] setFilterValues: values must be an array, null, or undefined");if(this._columns.length>0&&!this._columns.includes(t))throw new RangeError(`[JHGrid] setFilterValues: unknown field "${t}"`);this._trivialSetFilters.delete(t),e==null?this._filters.delete(t):this._filters.set(t,e.map(String)),this._reloadFiltered()}setQuickFilter(t){if(t!=null&&typeof t!="string")throw new TypeError("[JHGrid] setQuickFilter: value must be a string, null, or undefined");if(typeof t=="string"&&t.length>1e3)throw new RangeError("[JHGrid] setQuickFilter: value exceeds maximum length of 1000 characters");let e=t??"";e!==this._quickFilter&&(this._quickFilter=e,this._reloadFiltered())}getQuickFilter(){return this._quickFilter}clearQuickFilter(){this.setQuickFilter("")}setSort(t,e="asc"){if(typeof t!="string")throw new TypeError("[JHGrid] setSort: field must be a string");if(e!=="asc"&&e!=="desc")throw new RangeError('[JHGrid] setSort: dir must be "asc" or "desc"');if(this._columns.length>0&&!this._columns.includes(t))throw new RangeError(`[JHGrid] setSort: unknown field "${t}"`);this._sorts=[{field:t,dir:e}],this._reloadFiltered()}removeSort(t){if(typeof t!="string")throw new TypeError("[JHGrid] removeSort: field must be a string");let e=this._sorts.length;this._sorts=this._sorts.filter(s=>s.field!==t),this._sorts.length!==e&&this._reloadFiltered()}clearSort(){this._sorts.length!==0&&(this._sorts=[],this._reloadFiltered())}getRowData(t){return this._getRow(t)}getOriginalRowData(t){let e=this._rowSource(t);return e?{...e}:null}isNewRow(t){return this._localIndexAt(t)>=0}acknowledgeSave(t,e){let s=this._rowPlan.sourceAt(t);!s||s.local>=0||(this._dm.setRow(s.server,{...e}),this._columns.forEach(i=>this._edits.delete(`${t}_${i}`)),this._editedRows.delete(t),this._updateA11yCell(),this._draw())}acknowledgeInsert(t,e){let s=this._rowPlan.sourceAt(t);if(!s||s.local<0)return!1;let i=this._rowPlan,o=i.anchors[s.local];i.serverTotal++,i.anchors.splice(s.local,1);for(let n=0;n<i.anchors.length;n++)i.anchors[n]>=o&&i.anchors[n]++;return i.removed.shiftFrom(o),this._localRows.splice(s.local,1),this._dm.insertAt(o,{...e}),this._columns.forEach(n=>this._edits.delete(`${t}_${n}`)),this._editedRows.delete(t),this._updateA11yCell(),this._draw(),!0}autoFitColumns(...t){this._destroyed||this._withStructuralUndo(()=>{let e=t.length?t.map(s=>this._columns.indexOf(s)).filter(s=>s!==-1):this._columns.map((s,i)=>i);e.forEach(s=>this._autoFitCol(s)),this._clamp(this._geo()),this._draw(),this._opts.onColumnResize&&e.forEach(s=>this._opts.onColumnResize(this._columns[s],this._columnWidths[s]))})}setRowHeight(t,e){if(this._destroyed)return;if(e===void 0){if(typeof t!="number"||!isFinite(t)||t<=0)throw new TypeError("[JHGrid] setRowHeight: height must be a positive finite number");this._commitEdit(),this._opts.rowHeight=t,this._rowLayout.defaultHeight=t,this._clamp(this._geo()),this._draw();return}let s=t;if(typeof s!="number"||!Number.isInteger(s)||s<0||s>=this._totalRows)throw new RangeError("[JHGrid] setRowHeight: rowIndex out of range");if(typeof e!="number"||!isFinite(e)||e<=0)throw new TypeError("[JHGrid] setRowHeight: height must be a positive finite number");this._commitEdit(),this._rowLayout.setHeight(s,e),this._clamp(this._geo()),this._draw()}getRowHeight(t){return this._rowLayout.heightOf(t)}resetRowHeight(t){this._destroyed||!this._rowLayout.hasOverride(t)||(this._commitEdit(),this._rowLayout.setHeight(t,this._rowLayout.defaultHeight),this._clamp(this._geo()),this._draw())}hideColumn(t){this._hiddenColumns.has(t)||this._withStructuralUndo(()=>{this._hideColumnInternal(t),this._clamp(this._geo()),this._updateA11yHeader(),this._updateA11yCell(),this._draw()})}showColumn(t){this._hiddenColumns.has(t)&&this._withStructuralUndo(()=>{this._showColumnInternal(t),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()})}isColumnVisible(t){return!this._hiddenColumns.has(t)}getHiddenColumns(){return[...this._hiddenColumns.keys()]}_foldColumnIntoAdjacentGroups(t,e){let s=this._opts.headerRows;if(!s?.length)return;let i=e>0?this._columns[e-1]:null,o=e<this._columns.length-1?this._columns[e+1]:null;if(!(!i||!o))for(let n of s)for(let l of n??[])l.fields?.includes(i)&&l.fields?.includes(o)&&!l.fields.includes(t)&&l.fields.push(t)}addColumn(t,e={},{index:s}={}){return typeof t!="string"||!t||this._columns.includes(t)||this._hiddenColumns.has(t)||this._deletedColumns.has(t)?!1:this._withStructuralUndo(()=>this._addColumnImpl(t,e,s))}_addColumnImpl(t,e,s){this._colDefMap.set(t,{label:e.label,align:e.align,headerAlign:e.headerAlign,width:e.width,renderer:e.renderer,editable:e.editable,type:e.type,options:e.options,validation:e.validation,button:e.button,editor:e.editor,editorOptions:e.editorOptions,treeColumn:e.treeColumn,group:e.group}),this._localColumns.set(t,{...e});let i=s==null?this._columns.length:Math.max(0,Math.min(s,this._columns.length)),o=e.label??t,n=e.align??"left",l=e.headerAlign??n,a=e.width??this._opts.colWidth,c=e.renderer?typeof e.renderer=="function"?e.renderer:pt[e.renderer]?.()??null:e.type==="checkbox"?pt.checkbox():e.type==="dropdown"?pt.dropdown():e.type==="button"?pt.button(e.button??{}):e.type==="date"?pt.date({format:e.format,align:e.align}):e.type==="multiselect"?pt.multiselect():e.type==="richtext"?pt.richtext():e.type==="image"?pt.image():null,h=e.treeColumn?pt.tree({inner:c}):c,_=(u,p)=>{let w=[...u];return w.splice(i,0,p),w};this._columns=_(this._columns,t),this._columnLabels=_(this._columnLabels,o),this._columnAligns=_(this._columnAligns,n),this._columnHeaderAligns=_(this._columnHeaderAligns,l),this._columnWidths=_(this._columnWidths,a),this._columnRenderers=_(this._columnRenderers,h),this._columnWidthMap.set(t,a),this._foldColumnIntoAdjacentGroups(t,i);let f=this._columns[i+1]??null,d=f?this._columnOriginalOrder.indexOf(f):-1;if(d===-1?this._columnOriginalOrder.push(t):this._columnOriginalOrder.splice(d,0,t),this._sel){let u=p=>p>=i?p+1:p;this._sel=this._sel.type==="single"?{...this._sel,col:u(this._sel.col)}:{...this._sel,c1:u(this._sel.c1),c2:u(this._sel.c2)}}return this._clamp(this._geo()),this._updateA11yHeader(),this._draw(),!0}deleteColumn(t){return this._columns.includes(t)?(this._withStructuralUndo(()=>{if(this._localColumns.has(t)){let e=this._columns.indexOf(t),s=(o,n)=>n!==e;this._columns=this._columns.filter(s),this._columnLabels=this._columnLabels.filter(s),this._columnAligns=this._columnAligns.filter(s),this._columnHeaderAligns=this._columnHeaderAligns.filter(s),this._columnWidths=this._columnWidths.filter(s),this._columnRenderers=this._columnRenderers.filter(s),this._remapSelForColRemoval(e),this._localColumns.delete(t),this._colDefMap.delete(t),this._columnWidthMap.delete(t);let i=this._columnOriginalOrder.indexOf(t);i!==-1&&this._columnOriginalOrder.splice(i,1)}else this._hideColumnInternal(t),this._deletedColumns.add(t);this._purgeFieldEdits(t),this._clamp(this._geo()),this._updateA11yHeader(),this._updateA11yCell(),this._draw()}),!0):!1}undeleteColumn(t){this._deletedColumns.has(t)&&this._withStructuralUndo(()=>{this._deletedColumns.delete(t),this._showColumnInternal(t),this._clamp(this._geo()),this._updateA11yHeader(),this._draw()})}getNewColumns(){return[...this._localColumns].map(([t,e])=>({field:t,...e}))}getDeletedColumns(){return[...this._deletedColumns]}commitColumns(t){let e=t==null?[...this._localColumns.keys(),...this._deletedColumns]:Array.isArray(t)?t:[t];for(let s of e)this._localColumns.delete(s),this._deletedColumns.delete(s)}printGrid({title:t="",includeHeaders:e=!0}={}){let s=this._columns.filter(c=>!this._hiddenColumns.has(c)),i=s.map(c=>this._colDefMap.get(c)?.label??c),o=Ce(c=>this._dm.forEachLoaded(c),this._localRows,c=>this._rowPlan.visualOfServer(c),c=>this._rowPlan.visualOfLocal(c)).map(([c,h])=>{let _={};for(let f of s){let d=`${c}_${f}`,u=this._edits.has(d)?this._edits.get(d):h?.[f];_[f]=Kt(u,this._colDefMap.get(f),this._opts.theme.locale)}return _}),n=document.documentElement.lang||navigator.language||"en",l=Ge({cols:s,labels:i,rows:o,title:t,includeHeaders:e,i18n:this._i18n,lang:n}),a=window.open("","_blank","width=1000,height=720");if(!a){console.error("[JHGrid] printGrid: popup blocked");return}a.document.write(l),a.document.close(),a.focus()}async exportCsv({filename:t,delimiter:e=",",includeHeaders:s=!0,bom:i=!0,full:o=!1}={}){let n=d=>ze(d,e),l=[];s&&l.push(this._columnLabels.map(n).join(e));let a=(d,u)=>Kt(u,this._colDefMap.get(d),this._opts.theme.locale);if(o){let d=this._filterState();await this._forEachFilteredRow(d,(u,p)=>{u.forEach((w,m)=>{let C=this._columns.map(S=>{let y=p!=null&&this._edits.has(`${p+m}_${S}`)?this._edits.get(`${p+m}_${S}`):w?.[S];return n(a(S,y))});l.push(C.join(e))})})}else{let d=Ce(p=>this._dm.forEachLoaded(p),this._localRows,p=>this._rowPlan.visualOfServer(p),p=>this._rowPlan.visualOfLocal(p));for(let[p,w]of d){let m=this._columns.map(C=>{let S=`${p}_${C}`,y=this._edits.has(S)?this._edits.get(S):w?.[C];return n(a(C,y))});l.push(m.join(e))}let u=d.length-this._localRows.length;this._serverTotal>u&&console.warn(`[JHGrid] exportCsv: ${u} of ${this._serverTotal} server rows exported (only loaded chunks). Pass { full: true } to export all server rows.`)}let c=(i?"\uFEFF":"")+l.join(`\r
149
+ `),h=new Blob([c],{type:"text/csv;charset=utf-8;"}),_=URL.createObjectURL(h),f=document.createElement("a");f.href=_,f.download=t??this._i18n.exportCsvFilename,document.body.appendChild(f),f.click(),document.body.removeChild(f),URL.revokeObjectURL(_)}destroy(){this._destroyed=!0,this._clearPlugins("filterState"),cancelAnimationFrame(this._announceRaf),cancelAnimationFrame(this._schedRaf),this._hoverFade.stop(),this._selMove.stop(),this._scrollEase.stop(),this._colSlideTween.stop(),this._dm.onChunkLoaded=null,Le(this._imageLoadListener);for(let e of this._pastedImageUrls)URL.revokeObjectURL(e);this._pastedImageUrls.clear(),this._hcMq?.removeEventListener("change",this._hcMqHandler),this._dprMq?.removeEventListener("change",this._dprMqHandler),this._resizeObserver?.disconnect(),this._pagerBar=null;let t=this._ev;clearTimeout(this._tooltipTimer),clearTimeout(this._errorBannerTimer),this._stopDragAutoScroll(),this._cancelEdit(),this._closeFilterPanel(),this._closeColContextMenu(),this._closeRowContextMenu(),this._closeCellContextMenu(),this._closeColChooser(),this._closeNewColumnDialog(),this._canvas.removeEventListener("wheel",t.wheel),this._canvas.removeEventListener("mousedown",t.mousedown),this._canvas.removeEventListener("dblclick",t.dblclick),this._canvas.removeEventListener("contextmenu",t.contextmenu),this._canvas.removeEventListener("touchstart",t.touchstart),this._canvas.removeEventListener("touchmove",t.touchmove),this._canvas.removeEventListener("touchend",t.touchend),this._canvas.removeEventListener("touchcancel",t.touchend),this._kbProxy.removeEventListener("keydown",t.keydown),this._kbProxy.removeEventListener("copy",t.copy),this._kbProxy.removeEventListener("paste",t.paste),this._kbProxy.removeEventListener("focus",t.focus),this._kbProxy.removeEventListener("input",t.kbProxyInput),window.removeEventListener("mousemove",t.mousemove),window.removeEventListener("mouseup",t.mouseup),document.removeEventListener("mousedown",t.docMousedown),document.removeEventListener("touchstart",t.docMousedown),this._cancelLongPress(),this._container.replaceChildren()}};Qt.use(qe);var Gs="0.1.0",Ks={chrome:99,edge:99,firefox:112,safari:15.4};return hs(Vs);})();