@freegridjs/core 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +5 -4
- package/README.md +2 -2
- package/dist/cdn/freegrid.esm.js +1 -1
- package/dist/cdn/freegrid.min.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -3
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -21,8 +21,9 @@ This license covers the FreeGrid software, including the packages @freegridjs/co
|
|
|
21
21
|
Company License. A Company may evaluate the Software for up to 30 days without a license.
|
|
22
22
|
|
|
23
23
|
- A Company License is issued for one domain (for example example.com) and covers that
|
|
24
|
-
domain and its
|
|
25
|
-
|
|
24
|
+
domain and its www host (www.example.com). Each other subdomain (for example
|
|
25
|
+
erp.example.com) needs its own Company License. Applications without a domain (desktop
|
|
26
|
+
apps, intranets reached by address) count as one domain per installation site.
|
|
26
27
|
- The fee is KRW 200,000 per domain per year. The license is valid for one year from the
|
|
27
28
|
date it is issued and may be renewed.
|
|
28
29
|
- A license key is provided with each Company License. Setting the key removes the
|
|
@@ -58,8 +59,8 @@ FreeGrid 라이선스 (요약, 한국어)
|
|
|
58
59
|
- 개인: 개인적·교육·연구 등 비상업적 용도로 무료로 사용, 복제, 수정할 수 있습니다.
|
|
59
60
|
- 회사: 회사, 단체, 공공기관 등 업무용으로 쓰려면 판매용·내부용·고객 제공용 모두 유료
|
|
60
61
|
회사 라이선스가 필요합니다. 30일 동안은 평가 목적으로 라이선스 없이 써 볼 수 있습니다.
|
|
61
|
-
- 도메인 1개(
|
|
62
|
-
갱신할 수 있습니다.
|
|
62
|
+
- 도메인 1개(www 포함) 기준 연 200,000원이며, 발급일로부터 1년간 유효하고
|
|
63
|
+
갱신할 수 있습니다. 서브도메인(예: erp.example.com)은 별도로 요금이 책정됩니다.
|
|
63
64
|
- 라이선스마다 키를 발급하며, 키를 설정하면 콘솔 안내가 사라집니다.
|
|
64
65
|
- 모든 사용자: 저작권과 이 라이선스 문구를 유지해야 하며, 소프트웨어 자체를 판매하거나
|
|
65
66
|
별도 그리드 라이브러리로 재배포할 수 없고, 라이선스 확인을 제거하거나 키를 다른
|
package/README.md
CHANGED
|
@@ -47,9 +47,9 @@ The container needs a height. Languages: `import ko from '@freegridjs/core/local
|
|
|
47
47
|
## License
|
|
48
48
|
|
|
49
49
|
Free for personal use. Company use needs a domain license: KRW 200,000 per domain per year
|
|
50
|
-
(
|
|
50
|
+
(each subdomain is licensed separately). See https://freegrid.app/pricing/ and the LICENSE file.
|
|
51
51
|
|
|
52
|
-
개인은 무료, 회사는 도메인당 연 20만
|
|
52
|
+
개인은 무료, 회사는 도메인당 연 20만 원이며, 서브도메인은 별도로 요금이 책정됩니다. 자세한 내용은 https://freegrid.app/pricing/
|
|
53
53
|
|
|
54
54
|
```js
|
|
55
55
|
import { setLicenseKey } from '@freegridjs/core';
|
package/dist/cdn/freegrid.esm.js
CHANGED
|
@@ -3,6 +3,6 @@ var Jn={code:"en",noRows:"No rows to show",filter:"Filter",apply:"Apply",reset:"
|
|
|
3
3
|
`){n.push(r),t.push(n),n=[],r="",a=!0,o+=l==="\r"&&s[o+1]===`
|
|
4
4
|
`?2:1;continue}r+=l,a=!1,o++}return(r!==""||n.length||!a)&&(n.push(r),t.push(n)),t}function Ze(s,e,t){if(F(e))return"";switch(s.type){case"number":{let n=typeof e=="number"?e:Number(e);return Number.isNaN(n)?String(e):String(n)}case"date":return _(e)??String(e);case"boolean":return e===!0?"TRUE":e===!1?"FALSE":String(e);default:return G(s,t)(e)}}var Ir=new Set(["true","1","y","yes","\uC608","o","on"]),Dr=new Set(["false","0","n","no","\uC544\uB2C8\uC624","x","off"]);function Tr(s){let e=s.trim();if(!e)return{ok:!0,value:null};let t=!1;/^\(.*\)$/.test(e)&&(t=!0,e=e.slice(1,-1));let n=e.endsWith("%");if(n&&(e=e.slice(0,-1)),e=e.replace(/[\s,₩$€£¥원]/g,""),!/^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i.test(e))return{ok:!1};let r=Number(e);return n&&(r/=100),t&&(r=-r),{ok:!0,value:Math.round(r*1e12)/1e12}}function vn(s,e,t){let n=new Date(s,e-1,t);return n.getFullYear()===s&&n.getMonth()===e-1&&n.getDate()===t?n:null}function $r(s,e){let t=s.trim();if(!t)return{ok:!0,value:null};let n=null,r=/^(\d{4})\s*[-./년]\s*(\d{1,2})\s*[-./월]\s*(\d{1,2})\s*[.일]?$/.exec(t);return r?n=vn(+r[1],+r[2],+r[3]):(r=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(t))?n=vn(+r[3],+r[1],+r[2]):/^\d{4}-\d{2}-\d{2}T/.test(t)&&(n=Z(t)),n?{ok:!0,value:e instanceof Date?n:_(n)}:{ok:!1}}function Je(s,e,t){switch(s.type){case"number":return Tr(e);case"date":return $r(e,t);case"boolean":{let n=e.trim().toLowerCase();return n?Ir.has(n)?{ok:!0,value:!0}:Dr.has(n)?{ok:!0,value:!1}:{ok:!1}:{ok:!0,value:null}}default:return{ok:!0,value:e}}}var Pr=s=>s.map(e=>e!==null&&typeof e=="object"&&"value"in e?e:{value:e,label:String(e),disabled:!1}),de=s=>String(s).padStart(2,"0");function Ar(s){let e=s instanceof Date?s:typeof s=="string"&&s?new Date(s):null;return!e||Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${de(e.getMonth()+1)}-${de(e.getDate())}T${de(e.getHours())}:${de(e.getMinutes())}`}function Nr(s){if(s instanceof Date)return`${de(s.getHours())}:${de(s.getMinutes())}`;let e=typeof s=="string"?/(\d{1,2}):(\d{2})/.exec(s):null;return e?`${de(Number(e[1]))}:${e[2]}`:""}var Qe=class{constructor(e){this.grid=e;this.cur=null}get active(){return this.cur&&{rowIndex:this.cur.rowIndex,colId:this.cur.colId}}canEdit(e,t){if(I(t))return!1;let n=this.grid.columns.getColumn(t);if(!n?.def.field||e<0||e>=this.grid.rowModel.getRowCount())return!1;let r=this.grid.rowModel.getRow(e);return!r.kind&&te(n.def,r.data,e)}start(e,t,n){if(this.cur&&this.commit(null),!this.canEdit(e,t))return!1;let{grid:r}=this;if(r.veto("beforeEdit",{row:r.rowModel.getRow(e).data,rowIndex:e,colId:t}))return!1;let{renderer:o}=r,i=r.columns.getColumn(t),a=i.def,l=r.rowModel.getRow(e).data,d=l[a.field];r.setFocus(e,t),o.ensureVisible(e,t),o.render();let c=o.root.querySelector(`.fg-row[data-row="${e}"] .fg-cell[data-col="${CSS.escape(t)}"]`),u=o.root.getBoundingClientRect(),v=c?.getBoundingClientRect(),p=b("div","fg-editor");p.style.left=`${(v?.left??u.left)-u.left}px`,p.style.top=`${(v?.top??u.top)-u.top}px`,p.style.width=`${v?.width||i.width}px`,p.style.height=`${v?.height||o.opts.rowHeight}px`;let R,w,m=()=>{},h=a.editor;if(typeof h=="function"){let x=h({value:d,row:l,column:a,initialText:n});R=x.el,w=()=>({value:x.getValue()}),m=()=>x.destroy?.(),p.append(R),queueMicrotask(()=>x.focus?.())}else if(h?.type==="select"){let x=Pr(typeof h.options=="function"?h.options(l):h.options),g=b("select","fg-editor-control");x.forEach((k,E)=>{let M=b("option");M.value=String(E),M.textContent=k.label??String(k.value),M.disabled=!!k.disabled,g.append(M)}),g.selectedIndex=Math.max(0,x.findIndex(k=>Object.is(k.value,d))),R=g,w=()=>({value:x[g.selectedIndex]?.value??null}),p.append(g)}else if(h?.type==="time"||h?.type==="datetime"||!h&&a.type==="date"&&a.format==="datetime"){let x=h?.type==="time",g=b("input","fg-editor-control",{type:x?"time":"datetime-local"});g.value=x?Nr(d):Ar(d),R=g,w=()=>g.value?x?{value:g.value}:{value:d instanceof Date?new Date(g.value):g.value}:{value:null},p.append(g)}else{let g=h?.type==="textarea"?b("textarea","fg-editor-control"):b("input","fg-editor-control");g instanceof HTMLInputElement&&(g.type=a.type==="date"&&n===void 0?"date":"text",a.type==="number"&&(g.inputMode="decimal"));let k=a.type==="date"?_(d)??"":F(d)?"":String(d);g.value=n??k,R=g,w=()=>({text:g.value}),p.append(g)}R.setAttribute("aria-label",a.header??a.field??t);let f=b("div","fg-editor-msg",{role:"alert"});p.append(f);let C=x=>{if(x.stopPropagation(),x.key==="Escape")x.preventDefault(),this.cancel();else if(x.key==="Enter"){if(R instanceof HTMLTextAreaElement&&!(x.ctrlKey||x.metaKey))return;x.preventDefault(),this.commit(x.shiftKey?"up":"down")}else x.key==="Tab"&&(x.preventDefault(),this.commit(x.shiftKey?"left":"right"))},y=x=>{this.cur?.wrap===p&&!p.contains(x.relatedTarget)&&this.commit(null)},S=()=>this.commit(null);return p.addEventListener("keydown",C),p.addEventListener("focusout",y),o.scroller.addEventListener("scroll",S,{passive:!0}),o.root.append(p),this.cur={rowIndex:e,colId:t,row:l,def:a,wrap:p,read:w,dispose:()=>{p.removeEventListener("keydown",C),p.removeEventListener("focusout",y),o.scroller.removeEventListener("scroll",S),m(),p.remove()}},typeof h!="function"&&(R.focus(),n===void 0&&R instanceof HTMLInputElement&&R.type==="text"&&R.select()),r.events.emit("editStart",{rowIndex:e,colId:t}),!0}commit(e){let t=this.cur;if(!t)return!1;let{grid:n}=this,r=n.store.state.locale,o=t.def.field,i=t.row[o],a=t.read(),l;if("text"in a&&t.def.formulas&&fe(a.text.trim()))l=a.text.trim();else if("text"in a){let c=Je(t.def,a.text,i);if(!c.ok)return this.fail(a.text,r.invalidValue);l=c.value}else l=a.value;let d=n.cellError(t.def,t.row,l);return d!==null?this.fail(l,d):(this.close(!0),n.applyEdit(t.rowIndex,t.colId,l),this.move(t.rowIndex,t.colId,e),!0)}cancel(){this.close(!1)}fail(e,t){let n=this.cur;return n.wrap.classList.add("fg-editor-invalid"),n.wrap.querySelector(".fg-editor-msg").textContent=t,this.grid.events.emit("validationFailed",{rowIndex:n.rowIndex,colId:n.colId,value:e,message:t}),!1}close(e){let t=this.cur;t&&(this.cur=null,t.dispose(),this.grid.renderer.gridEl.focus({preventScroll:!0}),this.grid.events.emit("editStop",{rowIndex:t.rowIndex,colId:t.colId,committed:e}))}move(e,t,n){if(!n)return;let{grid:r}=this,o=r.rowModel.getRowCount();if(n==="down"||n==="up"){let c=Math.max(0,Math.min(o-1,e+(n==="down"?1:-1)));r.setFocus(c,t),r.renderer.ensureVisible(c,t);return}let i=r.columns.displayed().filter(c=>this.canEdit(e,c.id)||c.def.editable);if(!i.length)return;let a=n==="right"?1:-1,l=e,d=i.findIndex(c=>c.id===t)+a;d>=i.length&&(d=0,l++),d<0&&(d=i.length-1,l--),!(l<0||l>=o)&&this.start(l,i[d].id)}};var et=class{constructor(e=200){this.limit=e;this.entries=[];this.index=0}push(e){this.entries.splice(this.index),this.entries.push(e),this.entries.length>this.limit&&this.entries.shift(),this.index=this.entries.length}canUndo(){return this.index>0}canRedo(){return this.index<this.entries.length}undo(){return this.canUndo()?(this.entries[--this.index].undo(),!0):!1}redo(){return this.canRedo()?(this.entries[this.index++].redo(),!0):!1}clear(){this.entries=[],this.index=0}};var bn=(s,e)=>s instanceof Date&&e instanceof Date?s.getTime()===e.getTime():Object.is(s,e),tt=class{constructor(){this.originals=new Map;this.created=new Set;this.deleted=new Map}beforeChange(e){!this.created.has(e)&&!this.originals.has(e)&&this.originals.set(e,{...e})}isDirty(e,t){if(!t||this.created.has(e))return!1;let n=this.originals.get(e);return!!n&&!bn(n[t],e[t])}diff(e,t){let n=this.originals.get(e);return n?t.filter(r=>!bn(n[r],e[r])):[]}get size(){return this.originals.size+this.created.size+this.deleted.size}reset(){this.originals.clear(),this.created.clear(),this.deleted.clear()}};function Se(s){return{r1:Math.min(s.start.rowIndex,s.end.rowIndex),r2:Math.max(s.start.rowIndex,s.end.rowIndex),c1:Math.min(s.start.colIndex,s.end.colIndex),c2:Math.max(s.start.colIndex,s.end.colIndex)}}function xn(s,e,t){return e>=s.r1&&e<=s.r2&&t>=s.c1&&t<=s.c2}var Fr=5;function Cn(s,e){let t=r=>s(r),n=r=>{window.removeEventListener("pointermove",t),window.removeEventListener("pointerup",n),window.removeEventListener("pointercancel",n),e(r)};window.addEventListener("pointermove",t),window.addEventListener("pointerup",n),window.addEventListener("pointercancel",n)}function Hr(s,e,t){let n=s.columns.getColumn(t);if(!n)return;let r=e.clientX,o=n.width;s.renderer.root.classList.add("fg-resizing"),Cn(i=>{s.columns.setWidth(t,o+(i.clientX-r)*(s.renderer.rtl?-1:1)),s.layoutChanged()},()=>{s.renderer.root.classList.remove("fg-resizing");let i=s.columns.getColumn(t)?.width??o;i!==o&&s.events.emit("columnResize",{colId:t,width:i})})}function Br(s,e){let t=s.columns.getNode(e);return!!s.groupPanel&&!!t&&!t.children&&!s.options.treeData&&!s.getGroupBy().includes(e)}function Or(s,e,t,n){let r=new Set(s.columns.siblings(e).map(l=>l.id).filter(l=>l!==e&&!I(l))),o=[...n.querySelectorAll(".fg-header-cell")].filter(l=>r.has(l.dataset.col)).map(l=>({id:l.dataset.col,el:l})),i=b("div",`fg-drag-ghost fg-theme-${s.store.state.theme}`);i.textContent=t.querySelector(".fg-header-label")?.textContent??"",s.applyFontTo(i),se(s.renderer.root).append(i);let a=b("div","fg-drop-marker");return a.style.height=`${s.renderer.headerEl.offsetHeight}px`,s.renderer.root.append(a),t.classList.add("fg-dragging"),{ghost:i,marker:a,cell:t,sibs:o,target:-1,overPanel:!1}}function zr(s,e,t,n,r){t.ghost.style.transform=`translate(${n+12}px, ${r+8}px)`,t.overPanel=Br(s,e)&&!!s.groupPanel?.contains(n,r),s.groupPanel?.highlight(t.overPanel),t.marker.hidden=t.overPanel;let o=0;for(let c of t.sibs){let u=c.el.getBoundingClientRect();(s.renderer.rtl?n<u.left+u.width/2:n>u.left+u.width/2)&&o++}t.target=o;let i=s.renderer.root.getBoundingClientRect().left,a=c=>s.renderer.rtl?c.getBoundingClientRect().right:c.getBoundingClientRect().left,l=c=>s.renderer.rtl?c.getBoundingClientRect().left:c.getBoundingClientRect().right,d=o<t.sibs.length?a(t.sibs[o].el):t.sibs.length?l(t.sibs[t.sibs.length-1].el):a(t.cell);t.marker.style.left=`${d-i-1}px`}function Gr(s,e,t){if(t.ghost.remove(),t.marker.remove(),t.cell.classList.remove("fg-dragging"),t.overPanel){s.groupPanel?.highlight(!1),s.setGroupBy([...s.getGroupBy(),e]);return}if(t.target<0||!t.sibs.length)return;let n=s.columns.siblings(e),r=n.findIndex(a=>a.id===e),o=n.map(a=>a.id).filter(a=>a!==e),i=t.target<t.sibs.length?o.indexOf(t.sibs[t.target].id):o.indexOf(t.sibs[t.sibs.length-1].id)+1;i=Math.max(o.filter(I).length,i),i!==r&&(s.columns.move(e,i),s.layoutChanged(),s.events.emit("columnMove",{colId:e,toIndex:i}))}function Vr(s,e,t,n){let r=s.columns.getNode(t),o=n.closest(".fg-header-pane");if(!r||!o)return;let i=e.clientX,a=null;Cn(l=>{if(!a){if(Math.abs(l.clientX-i)<Fr)return;a=Or(s,t,n,o)}zr(s,t,a,l.clientX,l.clientY)},l=>{a?Gr(s,t,a):!r.children&&le(r.def)&&s.toggleSort(t,l.shiftKey||l.ctrlKey||l.metaKey)})}function Rn(s){let e=s.renderer.headerEl,t=r=>{if(r.button!==0)return;let o=r.target,i=o.closest(".fg-header-cell"),a=i?.dataset.col;!i||!a||I(a)||o.closest(".fg-menu-btn")||o.closest("button, a, input, select, textarea, [data-fg-no-sort]")&&o.closest(".fg-header-label")||(r.preventDefault(),o.closest(".fg-resize")?Hr(s,r,a):Vr(s,r,a,i))},n=r=>{let o=r.target,i=o.closest(".fg-menu-btn");if(i){let a=i.closest(".fg-header-cell")?.dataset.col;a&&s.menu.toggle(a,i);return}o.closest(".fg-select-all")&&s.toggleSelectAll()};return e.addEventListener("pointerdown",t),e.addEventListener("click",n),()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("click",n)}}var Ur=/^[=+\-@\t\r]/;function kn(s,e=","){let t=n=>{let r=n.value;return n.text&&Ur.test(r)&&(r=`'${r}`),r.includes(e)||/["\r\n]/.test(r)||/^\s|\s$/.test(r)?`"${r.replace(/"/g,'""')}"`:r};return s.map(n=>n.map(t).join(e)).join(`\r
|
|
5
5
|
`)}function St(s){let e=s.slice(0,s.search(/\r?\n|$/)),t=i=>e.split(i).length-1,n=t(" "),r=t(";"),o=t(",");return n&&n>=o&&n>=r?" ":r>o?";":","}function Mt(s,e=St(s)){return kt(s.replace(/^\uFEFF/,""),e)}var qr=(()=>{let s=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;s[e]=t>>>0}return s})();function Kr(s){let e=4294967295;for(let t=0;t<s.length;t++)e=qr[(e^s[t])&255]^e>>>8;return(e^4294967295)>>>0}var Sn=new TextEncoder;function Mn(s){let e=s.map(c=>{let u=Sn.encode(c.name),v=typeof c.data=="string"?Sn.encode(c.data):c.data;return{name:u,data:v,crc:Kr(v),offset:0}}),t=e.reduce((c,u)=>c+30+u.name.length+u.data.length,0),n=e.reduce((c,u)=>c+46+u.name.length,0),r=new Uint8Array(t+n+22),o=new DataView(r.buffer),i=0,a=0,l=33;for(let c of e)c.offset=i,o.setUint32(i,67324752,!0),o.setUint16(i+4,20,!0),o.setUint16(i+6,2048,!0),o.setUint16(i+8,0,!0),o.setUint16(i+10,a,!0),o.setUint16(i+12,l,!0),o.setUint32(i+14,c.crc,!0),o.setUint32(i+18,c.data.length,!0),o.setUint32(i+22,c.data.length,!0),o.setUint16(i+26,c.name.length,!0),o.setUint16(i+28,0,!0),r.set(c.name,i+30),r.set(c.data,i+30+c.name.length),i+=30+c.name.length+c.data.length;let d=i;for(let c of e)o.setUint32(i,33639248,!0),o.setUint16(i+4,20,!0),o.setUint16(i+6,20,!0),o.setUint16(i+8,2048,!0),o.setUint16(i+10,0,!0),o.setUint16(i+12,a,!0),o.setUint16(i+14,l,!0),o.setUint32(i+16,c.crc,!0),o.setUint32(i+20,c.data.length,!0),o.setUint32(i+24,c.data.length,!0),o.setUint16(i+28,c.name.length,!0),o.setUint16(i+30,0,!0),o.setUint16(i+32,0,!0),o.setUint16(i+34,0,!0),o.setUint16(i+36,0,!0),o.setUint32(i+38,0,!0),o.setUint32(i+42,c.offset,!0),r.set(c.name,i+46),i+=46+c.name.length;return o.setUint32(i,101010256,!0),o.setUint16(i+8,e.length,!0),o.setUint16(i+10,e.length,!0),o.setUint32(i+12,i-d,!0),o.setUint32(i+16,d,!0),r}var nt=s=>s.length>4&&s[0]===80&&s[1]===75&&s[2]===3&&s[3]===4;async function _r(s){if(typeof DecompressionStream>"u")throw new Error("This browser cannot read compressed xlsx files (no DecompressionStream)");let e=new Response(s).body.pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(e).arrayBuffer())}async function En(s){let e=new DataView(s.buffer,s.byteOffset,s.byteLength),t=-1;for(let a=s.length-22;a>=Math.max(0,s.length-65557);a--)if(e.getUint32(a,!0)===101010256){t=a;break}if(t<0)throw new Error("Not a zip file");let n=e.getUint16(t+10,!0),r=e.getUint32(t+16,!0),o=new TextDecoder,i=new Map;for(let a=0;a<n;a++){if(e.getUint32(r,!0)!==33639248)throw new Error("Broken zip directory");let l=e.getUint16(r+10,!0),d=e.getUint32(r+20,!0),c=e.getUint16(r+28,!0),u=e.getUint16(r+30,!0),v=e.getUint16(r+32,!0),p=e.getUint32(r+42,!0),R=o.decode(s.subarray(r+46,r+46+c)),w=e.getUint16(p+26,!0),m=e.getUint16(p+28,!0),h=p+30+w+m,f=s.subarray(h,h+d);if(l===0)i.set(R,f);else if(l===8)i.set(R,await _r(f));else throw new Error(`Unsupported zip compression ${l}`);r+=46+c+u+v}return i}function Et(s){let e="";for(let t=s+1;t>0;t=Math.floor((t-1)/26))e=String.fromCharCode(65+(t-1)%26)+e;return e}var Ln=Date.UTC(1899,11,30),In=864e5;function Wr(s){return(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds())-Ln)/In}function jr(s){let e=new Date(Math.round(s*In)+Ln);return new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds())}var Xr=/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g,rt=s=>s.replace(Xr,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),we=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
6
|
-
`,Lt="http://schemas.openxmlformats.org/spreadsheetml/2006/main",ve="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function Yr(s){let e=new Set;return s.map((t,n)=>{let r=(t.name??`Sheet${n+1}`).replace(/[[\]:*?/\\]/g," ").slice(0,31).trim()||`Sheet${n+1}`,o=r;for(let i=2;e.has(o.toLowerCase());i++)o=`${r.slice(0,28)} (${i})`;return e.add(o.toLowerCase()),o})}function It(s){let e=new Map([["General",0]]),t=[],n=['<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>'],r=new Map([["General||||",0]]),o=['<font><sz val="11"/><name val="Calibri"/></font>','<font><b/><sz val="11"/><name val="Calibri"/></font>'],i=new Map([["0|",0],["1|",1]]),a=['<fill><patternFill patternType="none"/></fill>','<fill><patternFill patternType="gray125"/></fill>','<fill><patternFill patternType="solid"><fgColor rgb="FFF2F4F7"/><bgColor indexed="64"/></patternFill></fill>'],l=new Map([["FFF2F4F7",2]]),d=h=>h&&/^[0-9a-f]{8}$/i.test(h)?h.toUpperCase():h&&/^[0-9a-f]{6}$/i.test(h)?`FF${h.toUpperCase()}`:"",c=(h,f)=>{let C=`${h?1:0}|${f}`,y=i.get(C);return y===void 0&&(y=o.length,o.push(`<font>${h?"<b/>":""}<sz val="11"/>${f?`<color rgb="${f}"/>`:""}<name val="Calibri"/></font>`),i.set(C,y)),y},u=h=>{if(!h)return 0;let f=l.get(h);return f===void 0&&(f=a.length,a.push(`<fill><patternFill patternType="solid"><fgColor rgb="${h}"/><bgColor indexed="64"/></patternFill></fill>`),l.set(h,f)),f},v=(h,f)=>{let C=d(f.color),y=f.header?"FFF2F4F7":d(f.fill),S=!!(f.bold||f.header),x=f.align==="left"||f.align==="center"||f.align==="right"?f.align:"",g=`${h}|${S?1:""}|${C}|${y}|${x}`,k=r.get(g);if(k!==void 0)return k;let E=e.get(h);E===void 0&&(E=164+t.length,t.push(h),e.set(h,E));let M=c(S,C),L=u(y),D=`numFmtId="${E}" fontId="${M}" fillId="${L}" borderId="0" xfId="0"`+(E?' applyNumberFormat="1"':"")+(M?' applyFont="1"':"")+(L?' applyFill="1"':"")+(x?' applyAlignment="1"':"");return k=n.length,n.push(x?`<xf ${D}><alignment horizontal="${x}"/></xf>`:`<xf ${D}/>`),r.set(g,k),k},p=Yr(s),R=s.map(h=>{let f=h.rows.map((E,M)=>{let L=E.map((D,P)=>{let T=D!==null&&typeof D=="object"&&!(D instanceof Date)?D:{v:D},A=`${Et(P)}${M+1}`,H=T.v,B=T.fmt??"General";H instanceof Date&&(Number.isNaN(H.getTime())?H=null:(B==="General"&&(B="yyyy-mm-dd"),H=Wr(H)));let O=v(B,T),V=O?` s="${O}"`:"";return H==null||H===""?V?`<c r="${A}"${V}/>`:"":typeof H=="number"?Number.isFinite(H)?`<c r="${A}"${V}><v>${H}</v></c>`:"":typeof H=="boolean"?`<c r="${A}"${V} t="b"><v>${H?1:0}</v></c>`:`<c r="${A}"${V} t="inlineStr"><is><t xml:space="preserve">${rt(String(H))}</t></is></c>`}).join("");return`<row r="${M+1}">${L}</row>`}).join(""),C=Math.max(0,...h.rows.map(E=>E.length)),y=h.freezeRows??0,S=y?`<sheetViews><sheetView workbookViewId="0"><pane ySplit="${y}" topLeftCell="A${y+1}" activePane="bottomLeft" state="frozen"/></sheetView></sheetViews>`:'<sheetViews><sheetView workbookViewId="0"/></sheetViews>',x=h.widths?.length?`<cols>${h.widths.map((E,M)=>`<col min="${M+1}" max="${M+1}" width="${Math.max(4,Math.min(120,E)).toFixed(1)}" customWidth="1"/>`).join("")}</cols>`:"",g=h.autoFilter&&C&&y&&h.rows.length>=y?`<autoFilter ref="A${y}:${Et(C-1)}${h.rows.length}"/>`:"",k=h.merges?.length?`<mergeCells count="${h.merges.length}">${h.merges.map(E=>`<mergeCell ref="${E}"/>`).join("")}</mergeCells>`:"";return`${we}<worksheet xmlns="${Lt}" xmlns:r="${ve}">${S}<sheetFormatPr defaultRowHeight="15"/>${x}<sheetData>${f}</sheetData>${g}${k}</worksheet>`}),w=`${we}<styleSheet xmlns="${Lt}">`+(t.length?`<numFmts count="${t.length}">${t.map((h,f)=>`<numFmt numFmtId="${164+f}" formatCode="${rt(h)}"/>`).join("")}</numFmts>`:"")+`<fonts count="${o.length}">${o.join("")}</fonts><fills count="${a.length}">${a.join("")}</fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="${n.length}">${n.join("")}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`,m=[{name:"[Content_Types].xml",data:`${we}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>`+s.map((h,f)=>`<Override PartName="/xl/worksheets/sheet${f+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join("")+"</Types>"},{name:"_rels/.rels",data:`${we}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${ve}/officeDocument" Target="xl/workbook.xml"/></Relationships>`},{name:"xl/workbook.xml",data:`${we}<workbook xmlns="${Lt}" xmlns:r="${ve}"><sheets>`+p.map((h,f)=>`<sheet name="${rt(h)}" sheetId="${f+1}" r:id="rId${f+1}"/>`).join("")+"</sheets>"+(s.some(h=>h.autoFilter&&h.freezeRows)?`<definedNames>${s.map((h,f)=>{let C=Math.max(0,...h.rows.map(y=>y.length));return h.autoFilter&&h.freezeRows&&C?`<definedName name="_xlnm._FilterDatabase" localSheetId="${f}" hidden="1">'${rt(p[f].replace(/'/g,"''"))}'!$A$${h.freezeRows}:$${Et(C-1)}$${h.rows.length}</definedName>`:""}).join("")}</definedNames>`:"")+"</workbook>"},{name:"xl/_rels/workbook.xml.rels",data:`${we}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`+s.map((h,f)=>`<Relationship Id="rId${f+1}" Type="${ve}/worksheet" Target="worksheets/sheet${f+1}.xml"/>`).join("")+`<Relationship Id="rId${s.length+1}" Type="${ve}/styles" Target="styles.xml"/></Relationships>`},{name:"xl/styles.xml",data:w},...R.map((h,f)=>({name:`xl/worksheets/sheet${f+1}.xml`,data:h}))];return Mn(m)}var Zr=new Set([14,15,16,17,18,19,20,21,22,27,30,36,45,46,47,50,57]);function Jr(s){let e=s.replace(/"[^"]*"/g,"").replace(/\[[^\]]*\]/g,"").replace(/\\./g,"");return/[dmyhs]/i.test(e)&&!/^[#0.,%\s]*$/.test(e)}function Me(s){return s?new DOMParser().parseFromString(new TextDecoder().decode(s),"application/xml"):null}var ne=(s,e)=>[...s.getElementsByTagNameNS("*",e)];function Qr(s){let e=0;for(let t of s){let n=t.charCodeAt(0);if(n<65||n>90)break;e=e*26+(n-64)}return e-1}async function Dt(s){let e=s instanceof Uint8Array?s:new Uint8Array(s);if(!nt(e))throw new Error("Not an xlsx file");let t=await En(e),n=Me(t.get("xl/workbook.xml"));if(!n)throw new Error("xlsx has no workbook");let r=Me(t.get("xl/_rels/workbook.xml.rels")),o=new Map(r?ne(r,"Relationship").map(p=>[p.getAttribute("Id")??"",p.getAttribute("Target")??""]):[]),i=Me(t.get("xl/sharedStrings.xml")),a=i?ne(i,"si").map(p=>ne(p,"t").map(R=>R.textContent??"").join("")):[],l=Me(t.get("xl/styles.xml")),d=new Map(l?ne(l,"numFmt").map(p=>[Number(p.getAttribute("numFmtId")),p.getAttribute("formatCode")??""]):[]),c=l?ne(l,"cellXfs")[0]:void 0,u=(c?[...c.children].filter(p=>p.localName==="xf"):[]).map(p=>{let R=Number(p.getAttribute("numFmtId")??0);return Zr.has(R)||d.has(R)&&Jr(d.get(R))}),v=[];for(let p of ne(n,"sheet")){let R=p.getAttribute("r:id")??p.getAttributeNS(ve,"id")??"",w=o.get(R)??"";w=w.startsWith("/")?w.slice(1):`xl/${w}`;let m=Me(t.get(w)),h=[];if(m){for(let f of ne(m,"row")){let C=Number(f.getAttribute("r")??h.length+1)-1,y=[],S=0;for(let x of[...f.children].filter(g=>g.localName==="c")){let g=x.getAttribute("r"),k=g?Qr(g):S;S=k+1;let E=x.getAttribute("t"),M=ne(x,"v")[0]?.textContent??null,L=null;if(E==="s")L=M===null?null:a[Number(M)]??"";else if(E==="inlineStr")L=ne(x,"t").map(D=>D.textContent??"").join("");else if(E==="b")L=M==="1";else if(E==="str"||E==="e")L=M;else if(M!==null&&M!==""){let D=Number(M);L=u[Number(x.getAttribute("s")??0)]?jr(D):D}y[k]=L}for(let x=0;x<y.length;x++)y[x]===void 0&&(y[x]=null);h[C]=y}for(let f=0;f<h.length;f++)h[f]||(h[f]=[])}v.push({name:p.getAttribute("name")??`Sheet${v.length+1}`,rows:h})}return v}function Dn(s,e){return Array.isArray(e)?e.flatMap(t=>{let n=s.columns.getNode(t);return!n||n.children||I(t)?($(`export: unknown column "${t}"`),[]):[{id:t,def:n.def,node:n,width:s.columns.getColumn(t)?.width??n.width}]}):s.columns.displayed().filter(t=>!I(t.id)).map(t=>({id:t.id,def:t.def,node:t.node,width:t.width}))}function Tn(s,e){return e==="selected"?s.selectedRows():e==="all"?s.rowModel.server?s.rowModel.dataRows().map(t=>t.data):s.viewRows():s.rowModel.dataRows().map(t=>t.data)}var Tt=(s,e)=>s.header??s.field??e;function $t(s,e={}){let t=Dn(s,e.columns),n=s.store.state.locale.code,r=typeof e.separator=="string"&&e.separator.length===1?e.separator:",",o=Tn(s,e.rows).map(i=>t.map(a=>{let l=N(a.def,i),d=a.def.type;return{value:Ze(a.def,l,n),text:!(d==="number"||d==="date"||d==="boolean")||typeof l=="string"}}));return e.headers!==!1&&o.unshift(t.map(i=>({value:Tt(i.def,i.id),text:!0}))),kn(o,r)}function eo(s){let e=s.format;if(s.type==="date")return e==="datetime"?"yyyy-mm-dd hh:mm":e==="time"?"hh:mm":"yyyy-mm-dd";if(s.type!=="number"||e==null)return null;if(typeof e=="string")return e==="integer"?"#,##0":e==="percent"?"0%":e.startsWith("currency:")?"#,##0.##":/^[#0,.%]+$/.test(e)?e:null;let t=e,n=t.maximumFractionDigits??t.minimumFractionDigits,r=n?`.${"0".repeat(Math.min(10,n))}`:"";return t.style==="percent"?`0${r}%`:`${t.useGrouping===!1?"0":"#,##0"}${r}`}function ot(s){let e=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(s.trim());if(e)return`FF${(e[1].length===3?[...e[1]].map(o=>o+o).join(""):e[1]).toUpperCase()}`;let t=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)(?:[\s,/]+([\d.]+%?))?\s*\)$/i.exec(s.trim());return!t||!((t[4]===void 0?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]))>0)?"":`FF${[t[1],t[2],t[3]].map(r=>Math.min(255,Number(r)).toString(16).padStart(2,"0")).join("").toUpperCase()}`}function to(s){let e=s.renderer.root;if(typeof getComputedStyle!="function"||!e.isConnected)return{of:()=>({}),dispose:()=>{}};let t=document.createElement("div");t.className="fg-row",t.style.cssText="position:absolute;left:-9999px;top:0;visibility:hidden;pointer-events:none";let n=document.createElement("div");t.append(n),e.append(t);let r=a=>{n.className=a?`fg-cell ${a}`:"fg-cell";let l=getComputedStyle(n),d=l.fontWeight;return{color:l.color,fill:l.backgroundColor,bold:d==="bold"||Number(d)>=600}},o=r(""),i=new Map;return{of(a){let l=i.get(a);if(!l){let d=r(a);l={},d.color!==o.color&&ot(d.color)&&(l.color=ot(d.color)),d.fill!==o.fill&&ot(d.fill)&&(l.fill=ot(d.fill)),d.bold&&!o.bold&&(l.bold=!0),i.set(a,l)}return l},dispose:()=>t.remove()}}function Pt(s,e={}){let t=Dn(s,e.columns),n=s.store.state.locale.code,r=[],o=[],i=0;if(e.headers!==!1){let m=t.map(f=>{let C=[];for(let y=f.node;y;y=y.parent)C.unshift(y);return C});i=Math.max(1,...m.map(f=>f.length));let h=f=>{let C="";for(let y=f+1;y>0;y=Math.floor((y-1)/26))C=String.fromCharCode(65+(y-1)%26)+C;return C};for(let f=0;f<i;f++){let C=[];for(let y=0;y<t.length;y++){let S=m[y],x=S.length-1;if(f<x){let g=S[f],k=y>0?m[y-1][f]:null;if(C.push({v:k===g?null:Tt(g.def,g.id),header:!0}),k!==g){let E=y;for(;E+1<t.length&&m[E+1][f]===g;)E++;E>y&&o.push(`${h(y)}${f+1}:${h(E)}${f+1}`)}}else f===x?(C.push({v:Tt(t[y].def,t[y].id),header:!0}),i-1>f&&o.push(`${h(y)}${f+1}:${h(y)}${i}`)):C.push({v:null,header:!0})}r.push(C)}}let a=t.map(m=>eo(m.def)),l=t.map(m=>G(m.def,n)),d=Tn(s,e.rows),c=e.styles!==!1,u=c&&t.some(m=>m.def.cellClass)?to(s):null,v=(m,h,f)=>{if(F(f))return null;let C=a[h]??void 0;switch(m.def.type){case"number":{let y=typeof f=="number"?f:Number(f);return Number.isFinite(y)?{v:y,fmt:C}:String(f)}case"date":{let y=Z(f);return y?{v:y,fmt:C}:String(f)}case"boolean":return typeof f=="boolean"?f:String(f);default:return l[h](f)}};try{d.forEach((m,h)=>{r.push(t.map((f,C)=>{let y=N(f.def,m),S=v(f,C,y);if(!c)return S;let x=f.def.align?{align:f.def.align}:{};if(u&&f.def.cellClass){let g;try{g=typeof f.def.cellClass=="function"?f.def.cellClass({value:y,formatted:l[C](y),row:m,rowIndex:h,column:f.def}):f.def.cellClass}catch{g=void 0}g&&(x={...x,...u.of(g)})}return Object.keys(x).length?S!==null&&typeof S=="object"&&!(S instanceof Date)?{...S,...x}:{v:S,...x}:S}))})}finally{u?.dispose()}let p=new Set,R=m=>{let h="";for(let f=m+1;f>0;f=Math.floor((f-1)/26))h=String.fromCharCode(65+(f-1)%26)+h;return h},w=(m,h,f,C)=>{for(let y=m;y<=f;y++)for(let S=h;S<=C;S++)if(p.has(`${y},${S}`))return;for(let y=m;y<=f;y++)for(let S=h;S<=C;S++)p.add(`${y},${S}`);o.push(`${R(h)}${i+m+1}:${R(C)}${i+f+1}`)};return d.forEach((m,h)=>t.forEach((f,C)=>{let y=f.def.colSpan?xe(f.def.colSpan,f.def,m,h,t.length-C):1;y>1&&w(h,C,h,C+y-1)})),t.forEach((m,h)=>{if(!m.def.merge&&!m.def.rowSpan)return;let f=He(d,m.def);for(let C=0;C<d.length;C++)f.start[C]===C&&f.end[C]>C&&w(C,h,f.end[C],h)}),It([{name:e.sheetName??"Sheet1",rows:r,widths:t.map(m=>Math.round(m.width/7)),merges:o,freezeRows:i,autoFilter:i>0}])}function At(s,e,t){if(typeof URL>"u"||typeof URL.createObjectURL!="function"||typeof document>"u"){$("downloads are not supported in this environment");return}let n=URL.createObjectURL(new Blob(e,{type:t})),r=document.createElement("a");r.href=n,r.download=s,r.style.display="none",document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}var st=s=>String(s??"").trim().toLowerCase();function no(s){return s==null?"":s instanceof Date?s.getHours()||s.getMinutes()||s.getSeconds()?s.toISOString():_(s)??"":String(s)}async function $n(s,e,t={}){let n=e instanceof Uint8Array?e:new Uint8Array(e instanceof ArrayBuffer?e:await e.arrayBuffer()),r;if(nt(n)){let w=await Dt(n),m=typeof t.sheet=="string"?w.find(h=>h.name===t.sheet):w[typeof t.sheet=="number"?t.sheet:0];if(!m)throw new Error(`Sheet ${String(t.sheet)} not found`);r=m.rows}else{let w=new TextDecoder().decode(n);r=Mt(w,St(w))}if(!r.length)return{rows:[],skipped:0};let o=[],i=w=>w.forEach(m=>m.children?i(m.children):!I(m.id)&&m.def.field&&o.push(m));i(s.columns.roots());let a=w=>{let m=st(w);return m?o.find(h=>st(h.def.header)===m)??o.find(h=>st(h.def.field)===m||st(h.id)===m)??null:null},l=1,d=new Set(r[0].map(a).filter(Boolean));for(;l<Math.min(r.length,5);){let m=(r[l]??[]).filter(f=>f!=null&&String(f).trim()!==""),h=m.map(a).filter(f=>f&&!d.has(f));if(!m.length||!m.every(f=>typeof f=="string")||!h.length)break;h.forEach(f=>d.add(f)),l++}let c=Math.max(...r.slice(0,l).map(w=>w?.length??0)),u=Array.from({length:c},(w,m)=>{for(let h=l-1;h>=0;h--){let f=r[h]?.[m];if(f!=null&&String(f).trim()!=="")return a(f)}return null}),v=s.store.state.data[0],p=0,R=[];for(let w of r.slice(l)){if(!w||w.every(h=>h==null||String(h).trim()===""))continue;let m={};u.forEach((h,f)=>{if(!h)return;let C=h.def,y=no(w[f]),S=s.acceptText(C,m,y,v?.[C.field]);S.ok?y===""&&(S.value===null||S.value==="")||(m[C.field]=S.value):p++}),R.push(m)}return t.mode==="replace"?s.setData(R):s.addRows(R),{rows:R,skipped:p}}var ro="http://www.w3.org/2000/svg";var Ft=["var(--fg-accent, #2563eb)","#f59e0b","#10b981","#ef4444","#8b5cf6","#06b6d4","#ec4899","#84cc16","#f97316","#64748b","#14b8a6","#a855f7"],ye=s=>Ft[s%Ft.length];function K(s,e={},t=""){let n=document.createElementNS(ro,s);t&&n.setAttribute("class",t);for(let[r,o]of Object.entries(e))n.setAttribute(r,String(o));return n}function Nt(s,e){let t=K("title");t.textContent=e,s.append(t)}function oo(s,e,t=5){let n=Math.min(0,s),r=Math.max(0,e);n===r&&(r=n+1);let o=(r-n)/t,i=10**Math.floor(Math.log10(o)),a=[1,2,5,10].map(d=>d*i).find(d=>d>=o);n=Math.floor(n/a)*a,r=Math.ceil(r/a)*a;let l=[];for(let d=n;d<=r+a/2;d+=a)l.push(Math.round(d/a)*a);return l}function Ht(s,e){let t=new Intl.NumberFormat(e.locale,{maximumFractionDigits:2}),n=new Intl.NumberFormat(e.locale,{notation:"compact",maximumFractionDigits:1}),r=K("svg",{viewBox:"0 0 640 360",role:"img",preserveAspectRatio:"xMidYMid meet"},`fg-chart fg-chart-is-${e.type}`);e.title&&r.setAttribute("aria-label",e.title);let o=e.series.slice(0,Ft.length),i=e.categories,a=16;if(e.title){let E=K("text",{x:320,y:22,"text-anchor":"middle"},"fg-chart-title");E.textContent=e.title,r.append(E),a=36}let l=K("g",{},"fg-chart-legend"),d=e.type==="pie"?i:o.map(E=>E.name),c=16;d.forEach((E,M)=>{let L=K("g",{transform:`translate(${c},350)`},"fg-chart-legend-item");L.append(K("rect",{x:0,y:-9,width:10,height:10,rx:2,fill:ye(M)}));let D=K("text",{x:14,y:0});D.textContent=E,L.append(D),l.append(L),c+=24+Math.min(140,E.length*7)});let u=308;if(e.type==="pie"){let E=(o[0]?.values??[]).map(A=>A!==null&&A>0?A:0),M=E.reduce((A,H)=>A+H,0),L=640/2,D=(a+u)/2,P=Math.max(10,(u-a)/2-6),T=-Math.PI/2;E.forEach((A,H)=>{if(!A||!M)return;let B=T+A/M*Math.PI*2,O=B-T>Math.PI?1:0,V=Q=>`${L+P*Math.cos(Q)},${D+P*Math.sin(Q)}`,J=A===M?`M${L-P},${D}a${P},${P} 0 1,0 ${2*P},0a${P},${P} 0 1,0 ${-2*P},0`:`M${L},${D}L${V(T)}A${P},${P} 0 ${O} 1 ${V(B)}Z`,q=K("path",{d:J,fill:ye(H)},"fg-chart-slice");Nt(q,`${i[H]}: ${t.format(A)} (${Math.round(A/M*1e3)/10}%)`),r.append(q),T=B}),r.append(l),s.replaceChildren(r);return}let v=e.type==="stackedBar",p=0,R=0;i.forEach((E,M)=>{let L=0,D=0;for(let P of o){let T=P.values[M];T==null||!Number.isFinite(T)||(v?T>=0?L+=T:D+=T:(R=Math.max(R,T),p=Math.min(p,T)))}v&&(R=Math.max(R,L),p=Math.min(p,D))});let w=oo(p,R),m=w[0],h=w[w.length-1],f=56,C=624,y=E=>u-(E-m)/(h-m)*(u-a),S=K("g",{},"fg-chart-axis");for(let E of w){S.append(K("line",{x1:f,x2:C,y1:y(E),y2:y(E)},E===0?"fg-chart-zero":"fg-chart-grid"));let M=K("text",{x:f-6,y:y(E)+4,"text-anchor":"end"});M.textContent=n.format(E),S.append(M)}let x=(C-f)/Math.max(1,i.length),g=Math.max(1,Math.ceil(i.length/Math.floor((C-f)/56)));i.forEach((E,M)=>{if(M%g)return;let L=K("text",{x:f+x*(M+.5),y:u+16,"text-anchor":"middle"});L.textContent=E.length>12?`${E.slice(0,11)}\u2026`:E,S.append(L)}),r.append(S);let k=K("g",{},"fg-chart-plot");if(e.type==="bar"||v){let E=x*.72,M=v?E:E/Math.max(1,o.length);i.forEach((L,D)=>{let P=0,T=0;o.forEach((A,H)=>{let B=A.values[D];if(B==null||!Number.isFinite(B))return;let O=0,V=B;v&&(O=B>=0?P:T,V=O+B,B>=0?P=V:T=V);let J=f+x*D+(x-E)/2+(v?0:M*H),q=K("rect",{x:J,y:Math.min(y(O),y(V)),width:Math.max(1,M-2),height:Math.max(.5,Math.abs(y(V)-y(O))),fill:ye(H),rx:2},"fg-chart-bar");Nt(q,`${A.name} \xB7 ${L}: ${t.format(B)}`),k.append(q)})})}else o.forEach((E,M)=>{let L=E.values.map((T,A)=>T==null||!Number.isFinite(T)?null:[f+x*(A+.5),y(T),T]),D="",P=!1;for(let T of L){if(!T){P=!1;continue}D+=`${P?"L":"M"}${T[0]},${T[1]}`,P=!0}if(e.type==="area"){let T=L.filter(A=>!!A);if(T.length){let A=`M${T[0][0]},${y(0)}${T.map(H=>`L${H[0]},${H[1]}`).join("")}L${T[T.length-1][0]},${y(0)}Z`;k.append(K("path",{d:A,fill:ye(M),"fill-opacity":.18},"fg-chart-area"))}}k.append(K("path",{d:D,fill:"none",stroke:ye(M),"stroke-width":2.2,"stroke-linejoin":"round"},"fg-chart-line")),L.forEach((T,A)=>{if(!T)return;let H=K("circle",{cx:T[0],cy:T[1],r:3.5,fill:ye(M)},"fg-chart-point");Nt(H,`${E.name} \xB7 ${i[A]}: ${t.format(T[2])}`),k.append(H)})});r.append(k,l),s.replaceChildren(r)}var so=12,Pn=500,Bt=["bar","stackedBar","line","area","pie"],it=class{constructor(e){this.grid=e;this.handles=new Set}create(e={}){let{grid:t}=this,n=Bt.includes(e.type)?e.type:"bar",r=()=>t.store.state.locale,o=e.range??t.store.state.range,i=null;if(o){let w=t.columns.getColumn(o.start.colId),m=t.columns.getColumn(o.end.colId);if(w&&m){let h=Se({start:{rowIndex:o.start.rowIndex,colIndex:w.index},end:{rowIndex:o.end.rowIndex,colIndex:m.index}}),f=[];for(let C=h.r1;C<=h.r2&&f.length<Pn;C++){let y=t.rowModel.getRow(C);y&&!y.kind&&f.push(y.data)}i={rows:f,colIds:t.columns.displayed().slice(h.c1,h.c2+1).filter(C=>!I(C.id)).map(C=>C.id)}}}let a=()=>{let w=i?i.rows:t.rowModel.dataRows().slice(0,Pn).map(x=>x.data),m=(i?i.colIds.map(x=>t.columns.getColumn(x)):t.columns.displayed().filter(x=>!I(x.id))).filter(x=>!!x),h=m[0]&&m[0].def.type!=="number"?m[0]:i?null:m.find(x=>x.def.type!=="number")??null,f=x=>!!x.node.parent&&x.node.parent.id==="pivotgroup|total",C=m.filter(x=>x!==h&&x.def.type==="number"&&(i||!f(x))).slice(0,so),y=x=>{let g=[];for(let k=x.node.parent;k;k=k.parent)g.unshift(k.def.header??k.id);return g.push(x.def.header??x.def.field??x.id),g.join(" \xB7 ")},S=h?G(h.def,r().code):null;return{categories:w.map((x,g)=>h&&S?S(N(h.def,x)):String(g+1)),series:C.map(x=>({name:y(x),values:w.map(g=>{let k=N(x.def,g),E=typeof k=="number"?k:k==null||k===""?NaN:Number(k);return Number.isFinite(E)?E:null})}))}},l=b("div","fg-chart-body"),d=null,c=()=>Ht(l,{type:n,title:e.title,locale:r().code,...a()}),u=w=>({bar:r().chartBar,stackedBar:r().chartStacked,line:r().chartLine,area:r().chartArea,pie:r().chartPie})[w],v=()=>d?.querySelectorAll(".fg-chart-type").forEach(w=>w.setAttribute("aria-pressed",String(w.dataset.type===n)));if(e.container)e.container.append(l);else{d=b("div","fg-chart-panel",{role:"dialog","aria-label":e.title??u(n)});let w=b("div","fg-chart-head");for(let h of Bt){let f=b("button","fg-chart-type",{type:"button",title:u(h)});f.dataset.type=h,f.textContent=u(h),f.addEventListener("click",()=>R.setType(h)),w.append(f)}let m=b("button","fg-chooser-close",{type:"button","aria-label":r().close});m.textContent="\xD7",m.addEventListener("click",()=>R.destroy()),w.append(b("span","fg-chart-spacer"),m),d.append(w,l),t.renderer.root.append(d)}let p=[t.events.on("cellValueChanged",()=>c()),t.events.on("rowsAdded",()=>c()),t.events.on("rowsRemoved",()=>c())];i||p.push(t.events.on("sortChange",()=>c()),t.events.on("filterChange",()=>c()));let R={el:l,setType:w=>{Bt.includes(w)&&(n=w,v(),c())},update:()=>c(),destroy:()=>{p.forEach(w=>w()),(d??l).remove(),this.handles.delete(R)}};return this.handles.add(R),v(),c(),R}destroy(){for(let e of[...this.handles])e.destroy()}};function An(s,e,t){return typeof s=="number"&&typeof e=="number"?s-e:s instanceof Date&&e instanceof Date?s.getTime()-e.getTime():typeof s=="boolean"&&typeof e=="boolean"?Number(s)-Number(e):t.compare(String(s),String(e))}function io(s,e){if(F(e))return null;if(s.type==="number"){let t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?null:t}return s.type==="date"?Z(e)?.getTime()??null:e}function ce(s,e,t){let n=F(s),r=F(e);return n||r?n===r?0:n?1:-1:An(s,e,t)}function Nn(s,e,t,n){let r=e.map(a=>({def:t(a.colId),mul:a.dir==="desc"?-1:1})).filter(a=>!!a.def);if(!r.length)return s;let o=r.map(a=>s.map(l=>{let d=N(a.def,l.data);return a.def.comparator?d:io(a.def,d)})),i=s.map((a,l)=>l);return i.sort((a,l)=>{for(let d=0;d<r.length;d++){let{def:c,mul:u}=r[d],v=o[d][a],p=o[d][l],R;if(c.comparator)try{R=(Number(c.comparator(v,p,s[a].data,s[l].data))||0)*u}catch{$(`comparator of column "${c.id??c.field}" threw; treating values as equal`),R=0}else{let w=F(v),m=F(p);R=w||m?w===m?0:w?1:-1:An(v,p,n)*u}if(R)return R}return a-l}),i.map(a=>s[a])}var Fn=new WeakMap,ao=s=>typeof s=="function"?"custom":s;function Ot(s,e){return{rows:(s.rows??[]).filter(e),columns:(s.columns??[]).filter(e),values:(s.values??[]).filter(t=>t&&e(t.colId)).map(t=>({colId:t.colId,aggFunc:t.aggFunc??"sum"})),totals:s.totals!==!1}}function Hn(s,e,t,n,r){let o=Ot(e,C=>!!t(C)),i=new Intl.Collator(r,{numeric:!0,sensitivity:"base"}),a=C=>t(C),l=(C,y)=>C.map(S=>W(N(a(S),y))).join(""),d=new Map;for(let C of s){let y=l(o.columns,C);d.has(y)||d.set(y,o.columns.map(S=>N(a(S),C)))}let c=[...d.entries()].sort((C,y)=>{for(let S=0;S<o.columns.length;S++){let x=ce(C[1][S],y[1][S],i);if(x)return x}return 0});o.columns.length||c.splice(0,c.length,["",[]]);let u=[],v=(C,y,S)=>{let x=o.values[y],g=a(x.colId),k=`pivot|${S}|${y}`;u.push({id:k,comboKey:C,valueIndex:y});let E=L=>C===null||l(o.columns,L)===C,M=x.aggFunc;return{id:k,field:k,header:`${g.header??g.field??x.colId} (${n.agg(ao(M))})`,type:"number",format:M==="count"?"integer":g.format,width:130,aggFunc:(L,D)=>{let P=D.flatMap(T=>Fn.get(T)??[]).filter(E);return P.length?pe(M,P.map(T=>N(g,T)),P):null}}},p=[],R=(C,y)=>{if(F(y))return n.blank;let S=a(C);return S.type==="number"&&!S.format?String(y):G(S,r)(y)};if(!o.columns.length)o.values.forEach((C,y)=>p.push(v("",y,0)));else{let C=(y,S,x)=>{let g=[],k=0;for(;k<y.length;){let E=y[k][1][S],M=W(E),L=k;for(;L<y.length&&W(y[L][1][S])===M;)L++;let D=y.slice(k,L),P=S===o.columns.length-1?o.values.map((T,A)=>v(D[0][0],A,x+k)):C(D,S+1,x+k);g.push({id:`pivotgroup|${S}|${x+k}`,header:R(o.columns[S],E),children:P}),k=L}return g};p.push(...C(c,0,0)),o.totals&&o.values.length&&p.push({id:"pivotgroup|total",header:n.total,children:o.values.map((y,S)=>v(null,S,"total"))})}let w=new Map;for(let C of s){let y=l(o.rows,C),S=w.get(y);S||w.set(y,S={values:o.rows.map(x=>N(a(x),C)),src:[]}),S.src.push(C)}let h=[...w.values()].sort((C,y)=>{for(let S=0;S<o.rows.length;S++){let x=ce(C.values[S],y.values[S],i);if(x)return x}return 0}).map(C=>{let y={};o.rows.forEach((x,g)=>{y[a(x).field??x]=C.values[g]});let S=new Map;if(o.columns.length)for(let x of C.src){let g=l(o.columns,x),k=S.get(g);k||S.set(g,k=[]),k.push(x)}for(let x of u){let g=o.values[x.valueIndex],k=x.comboKey===null||!o.columns.length?C.src:S.get(x.comboKey)??[],E=a(g.colId);y[x.id]=k.length?pe(g.aggFunc,k.map(M=>N(E,M)),k):null}return Fn.set(y,C.src),y});return{columns:[...o.rows.map(C=>{let y=a(C);return{id:C,field:y.field??C,header:y.header??y.field??C,type:y.type,format:y.format,width:y.width??140}}),...p],rows:h,groupBy:o.rows.slice(0,-1)}}var at="0.8.0";var lo={kty:"EC",crv:"P-256",x:"sUTKkglZmk-HMKPNub8p7AeLBKesHCU8irIkw9rJlbE",y:"j0U_aKRDR7iApY9UpaD3hUemhBLZJwDv9-QiT_hUyw8"},zt="https://freegrid.app/pricing/",Bn="https://freegrid.app/api/usage",co="https://freegrid.app/api/domain-status",On=s=>{let e=atob(s.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-s.length%4)%4));return Uint8Array.from(e,t=>t.charCodeAt(0))};function Vt(s){let e=s.toLowerCase().replace(/^\[|\]$/g,"");return!e||e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="0.0.0.0"||e.endsWith(".localhost")||e.endsWith(".test")||e.endsWith(".local")||/^(10|192\.168|172\.(1[6-9]|2\d|3[01]))\./.test(e)}function uo(s,e){let t=s.toLowerCase().replace(/\.$/,"");return e.some(n=>{let r=n.toLowerCase().replace(/^\*\./,"").replace(/\.$/,"");return!!r&&(t===r||t.endsWith(`.${r}`))})}var ho=s=>`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`;async function Un(s,e,t={}){let n=typeof s=="string"?s.trim().split("."):[];if(n.length!==3||n[0]!=="FG1")return{ok:!1,reason:"format"};let r;try{if(r=JSON.parse(new TextDecoder().decode(On(n[1]))),!Array.isArray(r.domains)||typeof r.expires!="string")return{ok:!1,reason:"format"}}catch{return{ok:!1,reason:"format"}}let o=typeof crypto<"u"?crypto.subtle:void 0;if(!o)return{ok:!1,reason:"unsupported",info:r};try{let i=await o.importKey("jwk",t.publicKey??lo,{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]),a=new TextEncoder().encode(`${n[0]}.${n[1]}`);if(!await o.verify({name:"ECDSA",hash:"SHA-256"},i,On(n[2]),a))return{ok:!1,reason:"signature",info:r}}catch{return{ok:!1,reason:"signature",info:r}}return ho(t.now??new Date)>r.expires?{ok:!1,reason:"expired",info:r}:uo(e,r.domains)?{ok:!0,info:r}:{ok:!1,reason:"domain",info:r}}var Gt,zn=new Map,Ee=null;function fo(s){Gt=s}var Gn={missing:`FreeGrid is free for personal use. Company use needs a domain license (\u20A9200,000 per domain per year): ${zt}
|
|
6
|
+
`,Lt="http://schemas.openxmlformats.org/spreadsheetml/2006/main",ve="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function Yr(s){let e=new Set;return s.map((t,n)=>{let r=(t.name??`Sheet${n+1}`).replace(/[[\]:*?/\\]/g," ").slice(0,31).trim()||`Sheet${n+1}`,o=r;for(let i=2;e.has(o.toLowerCase());i++)o=`${r.slice(0,28)} (${i})`;return e.add(o.toLowerCase()),o})}function It(s){let e=new Map([["General",0]]),t=[],n=['<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>'],r=new Map([["General||||",0]]),o=['<font><sz val="11"/><name val="Calibri"/></font>','<font><b/><sz val="11"/><name val="Calibri"/></font>'],i=new Map([["0|",0],["1|",1]]),a=['<fill><patternFill patternType="none"/></fill>','<fill><patternFill patternType="gray125"/></fill>','<fill><patternFill patternType="solid"><fgColor rgb="FFF2F4F7"/><bgColor indexed="64"/></patternFill></fill>'],l=new Map([["FFF2F4F7",2]]),d=h=>h&&/^[0-9a-f]{8}$/i.test(h)?h.toUpperCase():h&&/^[0-9a-f]{6}$/i.test(h)?`FF${h.toUpperCase()}`:"",c=(h,f)=>{let C=`${h?1:0}|${f}`,y=i.get(C);return y===void 0&&(y=o.length,o.push(`<font>${h?"<b/>":""}<sz val="11"/>${f?`<color rgb="${f}"/>`:""}<name val="Calibri"/></font>`),i.set(C,y)),y},u=h=>{if(!h)return 0;let f=l.get(h);return f===void 0&&(f=a.length,a.push(`<fill><patternFill patternType="solid"><fgColor rgb="${h}"/><bgColor indexed="64"/></patternFill></fill>`),l.set(h,f)),f},v=(h,f)=>{let C=d(f.color),y=f.header?"FFF2F4F7":d(f.fill),S=!!(f.bold||f.header),x=f.align==="left"||f.align==="center"||f.align==="right"?f.align:"",g=`${h}|${S?1:""}|${C}|${y}|${x}`,k=r.get(g);if(k!==void 0)return k;let E=e.get(h);E===void 0&&(E=164+t.length,t.push(h),e.set(h,E));let M=c(S,C),L=u(y),D=`numFmtId="${E}" fontId="${M}" fillId="${L}" borderId="0" xfId="0"`+(E?' applyNumberFormat="1"':"")+(M?' applyFont="1"':"")+(L?' applyFill="1"':"")+(x?' applyAlignment="1"':"");return k=n.length,n.push(x?`<xf ${D}><alignment horizontal="${x}"/></xf>`:`<xf ${D}/>`),r.set(g,k),k},p=Yr(s),R=s.map(h=>{let f=h.rows.map((E,M)=>{let L=E.map((D,P)=>{let T=D!==null&&typeof D=="object"&&!(D instanceof Date)?D:{v:D},A=`${Et(P)}${M+1}`,H=T.v,B=T.fmt??"General";H instanceof Date&&(Number.isNaN(H.getTime())?H=null:(B==="General"&&(B="yyyy-mm-dd"),H=Wr(H)));let O=v(B,T),V=O?` s="${O}"`:"";return H==null||H===""?V?`<c r="${A}"${V}/>`:"":typeof H=="number"?Number.isFinite(H)?`<c r="${A}"${V}><v>${H}</v></c>`:"":typeof H=="boolean"?`<c r="${A}"${V} t="b"><v>${H?1:0}</v></c>`:`<c r="${A}"${V} t="inlineStr"><is><t xml:space="preserve">${rt(String(H))}</t></is></c>`}).join("");return`<row r="${M+1}">${L}</row>`}).join(""),C=Math.max(0,...h.rows.map(E=>E.length)),y=h.freezeRows??0,S=y?`<sheetViews><sheetView workbookViewId="0"><pane ySplit="${y}" topLeftCell="A${y+1}" activePane="bottomLeft" state="frozen"/></sheetView></sheetViews>`:'<sheetViews><sheetView workbookViewId="0"/></sheetViews>',x=h.widths?.length?`<cols>${h.widths.map((E,M)=>`<col min="${M+1}" max="${M+1}" width="${Math.max(4,Math.min(120,E)).toFixed(1)}" customWidth="1"/>`).join("")}</cols>`:"",g=h.autoFilter&&C&&y&&h.rows.length>=y?`<autoFilter ref="A${y}:${Et(C-1)}${h.rows.length}"/>`:"",k=h.merges?.length?`<mergeCells count="${h.merges.length}">${h.merges.map(E=>`<mergeCell ref="${E}"/>`).join("")}</mergeCells>`:"";return`${we}<worksheet xmlns="${Lt}" xmlns:r="${ve}">${S}<sheetFormatPr defaultRowHeight="15"/>${x}<sheetData>${f}</sheetData>${g}${k}</worksheet>`}),w=`${we}<styleSheet xmlns="${Lt}">`+(t.length?`<numFmts count="${t.length}">${t.map((h,f)=>`<numFmt numFmtId="${164+f}" formatCode="${rt(h)}"/>`).join("")}</numFmts>`:"")+`<fonts count="${o.length}">${o.join("")}</fonts><fills count="${a.length}">${a.join("")}</fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="${n.length}">${n.join("")}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`,m=[{name:"[Content_Types].xml",data:`${we}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>`+s.map((h,f)=>`<Override PartName="/xl/worksheets/sheet${f+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join("")+"</Types>"},{name:"_rels/.rels",data:`${we}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${ve}/officeDocument" Target="xl/workbook.xml"/></Relationships>`},{name:"xl/workbook.xml",data:`${we}<workbook xmlns="${Lt}" xmlns:r="${ve}"><sheets>`+p.map((h,f)=>`<sheet name="${rt(h)}" sheetId="${f+1}" r:id="rId${f+1}"/>`).join("")+"</sheets>"+(s.some(h=>h.autoFilter&&h.freezeRows)?`<definedNames>${s.map((h,f)=>{let C=Math.max(0,...h.rows.map(y=>y.length));return h.autoFilter&&h.freezeRows&&C?`<definedName name="_xlnm._FilterDatabase" localSheetId="${f}" hidden="1">'${rt(p[f].replace(/'/g,"''"))}'!$A$${h.freezeRows}:$${Et(C-1)}$${h.rows.length}</definedName>`:""}).join("")}</definedNames>`:"")+"</workbook>"},{name:"xl/_rels/workbook.xml.rels",data:`${we}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`+s.map((h,f)=>`<Relationship Id="rId${f+1}" Type="${ve}/worksheet" Target="worksheets/sheet${f+1}.xml"/>`).join("")+`<Relationship Id="rId${s.length+1}" Type="${ve}/styles" Target="styles.xml"/></Relationships>`},{name:"xl/styles.xml",data:w},...R.map((h,f)=>({name:`xl/worksheets/sheet${f+1}.xml`,data:h}))];return Mn(m)}var Zr=new Set([14,15,16,17,18,19,20,21,22,27,30,36,45,46,47,50,57]);function Jr(s){let e=s.replace(/"[^"]*"/g,"").replace(/\[[^\]]*\]/g,"").replace(/\\./g,"");return/[dmyhs]/i.test(e)&&!/^[#0.,%\s]*$/.test(e)}function Me(s){return s?new DOMParser().parseFromString(new TextDecoder().decode(s),"application/xml"):null}var ne=(s,e)=>[...s.getElementsByTagNameNS("*",e)];function Qr(s){let e=0;for(let t of s){let n=t.charCodeAt(0);if(n<65||n>90)break;e=e*26+(n-64)}return e-1}async function Dt(s){let e=s instanceof Uint8Array?s:new Uint8Array(s);if(!nt(e))throw new Error("Not an xlsx file");let t=await En(e),n=Me(t.get("xl/workbook.xml"));if(!n)throw new Error("xlsx has no workbook");let r=Me(t.get("xl/_rels/workbook.xml.rels")),o=new Map(r?ne(r,"Relationship").map(p=>[p.getAttribute("Id")??"",p.getAttribute("Target")??""]):[]),i=Me(t.get("xl/sharedStrings.xml")),a=i?ne(i,"si").map(p=>ne(p,"t").map(R=>R.textContent??"").join("")):[],l=Me(t.get("xl/styles.xml")),d=new Map(l?ne(l,"numFmt").map(p=>[Number(p.getAttribute("numFmtId")),p.getAttribute("formatCode")??""]):[]),c=l?ne(l,"cellXfs")[0]:void 0,u=(c?[...c.children].filter(p=>p.localName==="xf"):[]).map(p=>{let R=Number(p.getAttribute("numFmtId")??0);return Zr.has(R)||d.has(R)&&Jr(d.get(R))}),v=[];for(let p of ne(n,"sheet")){let R=p.getAttribute("r:id")??p.getAttributeNS(ve,"id")??"",w=o.get(R)??"";w=w.startsWith("/")?w.slice(1):`xl/${w}`;let m=Me(t.get(w)),h=[];if(m){for(let f of ne(m,"row")){let C=Number(f.getAttribute("r")??h.length+1)-1,y=[],S=0;for(let x of[...f.children].filter(g=>g.localName==="c")){let g=x.getAttribute("r"),k=g?Qr(g):S;S=k+1;let E=x.getAttribute("t"),M=ne(x,"v")[0]?.textContent??null,L=null;if(E==="s")L=M===null?null:a[Number(M)]??"";else if(E==="inlineStr")L=ne(x,"t").map(D=>D.textContent??"").join("");else if(E==="b")L=M==="1";else if(E==="str"||E==="e")L=M;else if(M!==null&&M!==""){let D=Number(M);L=u[Number(x.getAttribute("s")??0)]?jr(D):D}y[k]=L}for(let x=0;x<y.length;x++)y[x]===void 0&&(y[x]=null);h[C]=y}for(let f=0;f<h.length;f++)h[f]||(h[f]=[])}v.push({name:p.getAttribute("name")??`Sheet${v.length+1}`,rows:h})}return v}function Dn(s,e){return Array.isArray(e)?e.flatMap(t=>{let n=s.columns.getNode(t);return!n||n.children||I(t)?($(`export: unknown column "${t}"`),[]):[{id:t,def:n.def,node:n,width:s.columns.getColumn(t)?.width??n.width}]}):s.columns.displayed().filter(t=>!I(t.id)).map(t=>({id:t.id,def:t.def,node:t.node,width:t.width}))}function Tn(s,e){return e==="selected"?s.selectedRows():e==="all"?s.rowModel.server?s.rowModel.dataRows().map(t=>t.data):s.viewRows():s.rowModel.dataRows().map(t=>t.data)}var Tt=(s,e)=>s.header??s.field??e;function $t(s,e={}){let t=Dn(s,e.columns),n=s.store.state.locale.code,r=typeof e.separator=="string"&&e.separator.length===1?e.separator:",",o=Tn(s,e.rows).map(i=>t.map(a=>{let l=N(a.def,i),d=a.def.type;return{value:Ze(a.def,l,n),text:!(d==="number"||d==="date"||d==="boolean")||typeof l=="string"}}));return e.headers!==!1&&o.unshift(t.map(i=>({value:Tt(i.def,i.id),text:!0}))),kn(o,r)}function eo(s){let e=s.format;if(s.type==="date")return e==="datetime"?"yyyy-mm-dd hh:mm":e==="time"?"hh:mm":"yyyy-mm-dd";if(s.type!=="number"||e==null)return null;if(typeof e=="string")return e==="integer"?"#,##0":e==="percent"?"0%":e.startsWith("currency:")?"#,##0.##":/^[#0,.%]+$/.test(e)?e:null;let t=e,n=t.maximumFractionDigits??t.minimumFractionDigits,r=n?`.${"0".repeat(Math.min(10,n))}`:"";return t.style==="percent"?`0${r}%`:`${t.useGrouping===!1?"0":"#,##0"}${r}`}function ot(s){let e=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(s.trim());if(e)return`FF${(e[1].length===3?[...e[1]].map(o=>o+o).join(""):e[1]).toUpperCase()}`;let t=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)(?:[\s,/]+([\d.]+%?))?\s*\)$/i.exec(s.trim());return!t||!((t[4]===void 0?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]))>0)?"":`FF${[t[1],t[2],t[3]].map(r=>Math.min(255,Number(r)).toString(16).padStart(2,"0")).join("").toUpperCase()}`}function to(s){let e=s.renderer.root;if(typeof getComputedStyle!="function"||!e.isConnected)return{of:()=>({}),dispose:()=>{}};let t=document.createElement("div");t.className="fg-row",t.style.cssText="position:absolute;left:-9999px;top:0;visibility:hidden;pointer-events:none";let n=document.createElement("div");t.append(n),e.append(t);let r=a=>{n.className=a?`fg-cell ${a}`:"fg-cell";let l=getComputedStyle(n),d=l.fontWeight;return{color:l.color,fill:l.backgroundColor,bold:d==="bold"||Number(d)>=600}},o=r(""),i=new Map;return{of(a){let l=i.get(a);if(!l){let d=r(a);l={},d.color!==o.color&&ot(d.color)&&(l.color=ot(d.color)),d.fill!==o.fill&&ot(d.fill)&&(l.fill=ot(d.fill)),d.bold&&!o.bold&&(l.bold=!0),i.set(a,l)}return l},dispose:()=>t.remove()}}function Pt(s,e={}){let t=Dn(s,e.columns),n=s.store.state.locale.code,r=[],o=[],i=0;if(e.headers!==!1){let m=t.map(f=>{let C=[];for(let y=f.node;y;y=y.parent)C.unshift(y);return C});i=Math.max(1,...m.map(f=>f.length));let h=f=>{let C="";for(let y=f+1;y>0;y=Math.floor((y-1)/26))C=String.fromCharCode(65+(y-1)%26)+C;return C};for(let f=0;f<i;f++){let C=[];for(let y=0;y<t.length;y++){let S=m[y],x=S.length-1;if(f<x){let g=S[f],k=y>0?m[y-1][f]:null;if(C.push({v:k===g?null:Tt(g.def,g.id),header:!0}),k!==g){let E=y;for(;E+1<t.length&&m[E+1][f]===g;)E++;E>y&&o.push(`${h(y)}${f+1}:${h(E)}${f+1}`)}}else f===x?(C.push({v:Tt(t[y].def,t[y].id),header:!0}),i-1>f&&o.push(`${h(y)}${f+1}:${h(y)}${i}`)):C.push({v:null,header:!0})}r.push(C)}}let a=t.map(m=>eo(m.def)),l=t.map(m=>G(m.def,n)),d=Tn(s,e.rows),c=e.styles!==!1,u=c&&t.some(m=>m.def.cellClass)?to(s):null,v=(m,h,f)=>{if(F(f))return null;let C=a[h]??void 0;switch(m.def.type){case"number":{let y=typeof f=="number"?f:Number(f);return Number.isFinite(y)?{v:y,fmt:C}:String(f)}case"date":{let y=Z(f);return y?{v:y,fmt:C}:String(f)}case"boolean":return typeof f=="boolean"?f:String(f);default:return l[h](f)}};try{d.forEach((m,h)=>{r.push(t.map((f,C)=>{let y=N(f.def,m),S=v(f,C,y);if(!c)return S;let x=f.def.align?{align:f.def.align}:{};if(u&&f.def.cellClass){let g;try{g=typeof f.def.cellClass=="function"?f.def.cellClass({value:y,formatted:l[C](y),row:m,rowIndex:h,column:f.def}):f.def.cellClass}catch{g=void 0}g&&(x={...x,...u.of(g)})}return Object.keys(x).length?S!==null&&typeof S=="object"&&!(S instanceof Date)?{...S,...x}:{v:S,...x}:S}))})}finally{u?.dispose()}let p=new Set,R=m=>{let h="";for(let f=m+1;f>0;f=Math.floor((f-1)/26))h=String.fromCharCode(65+(f-1)%26)+h;return h},w=(m,h,f,C)=>{for(let y=m;y<=f;y++)for(let S=h;S<=C;S++)if(p.has(`${y},${S}`))return;for(let y=m;y<=f;y++)for(let S=h;S<=C;S++)p.add(`${y},${S}`);o.push(`${R(h)}${i+m+1}:${R(C)}${i+f+1}`)};return d.forEach((m,h)=>t.forEach((f,C)=>{let y=f.def.colSpan?xe(f.def.colSpan,f.def,m,h,t.length-C):1;y>1&&w(h,C,h,C+y-1)})),t.forEach((m,h)=>{if(!m.def.merge&&!m.def.rowSpan)return;let f=He(d,m.def);for(let C=0;C<d.length;C++)f.start[C]===C&&f.end[C]>C&&w(C,h,f.end[C],h)}),It([{name:e.sheetName??"Sheet1",rows:r,widths:t.map(m=>Math.round(m.width/7)),merges:o,freezeRows:i,autoFilter:i>0}])}function At(s,e,t){if(typeof URL>"u"||typeof URL.createObjectURL!="function"||typeof document>"u"){$("downloads are not supported in this environment");return}let n=URL.createObjectURL(new Blob(e,{type:t})),r=document.createElement("a");r.href=n,r.download=s,r.style.display="none",document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}var st=s=>String(s??"").trim().toLowerCase();function no(s){return s==null?"":s instanceof Date?s.getHours()||s.getMinutes()||s.getSeconds()?s.toISOString():_(s)??"":String(s)}async function $n(s,e,t={}){let n=e instanceof Uint8Array?e:new Uint8Array(e instanceof ArrayBuffer?e:await e.arrayBuffer()),r;if(nt(n)){let w=await Dt(n),m=typeof t.sheet=="string"?w.find(h=>h.name===t.sheet):w[typeof t.sheet=="number"?t.sheet:0];if(!m)throw new Error(`Sheet ${String(t.sheet)} not found`);r=m.rows}else{let w=new TextDecoder().decode(n);r=Mt(w,St(w))}if(!r.length)return{rows:[],skipped:0};let o=[],i=w=>w.forEach(m=>m.children?i(m.children):!I(m.id)&&m.def.field&&o.push(m));i(s.columns.roots());let a=w=>{let m=st(w);return m?o.find(h=>st(h.def.header)===m)??o.find(h=>st(h.def.field)===m||st(h.id)===m)??null:null},l=1,d=new Set(r[0].map(a).filter(Boolean));for(;l<Math.min(r.length,5);){let m=(r[l]??[]).filter(f=>f!=null&&String(f).trim()!==""),h=m.map(a).filter(f=>f&&!d.has(f));if(!m.length||!m.every(f=>typeof f=="string")||!h.length)break;h.forEach(f=>d.add(f)),l++}let c=Math.max(...r.slice(0,l).map(w=>w?.length??0)),u=Array.from({length:c},(w,m)=>{for(let h=l-1;h>=0;h--){let f=r[h]?.[m];if(f!=null&&String(f).trim()!=="")return a(f)}return null}),v=s.store.state.data[0],p=0,R=[];for(let w of r.slice(l)){if(!w||w.every(h=>h==null||String(h).trim()===""))continue;let m={};u.forEach((h,f)=>{if(!h)return;let C=h.def,y=no(w[f]),S=s.acceptText(C,m,y,v?.[C.field]);S.ok?y===""&&(S.value===null||S.value==="")||(m[C.field]=S.value):p++}),R.push(m)}return t.mode==="replace"?s.setData(R):s.addRows(R),{rows:R,skipped:p}}var ro="http://www.w3.org/2000/svg";var Ft=["var(--fg-accent, #2563eb)","#f59e0b","#10b981","#ef4444","#8b5cf6","#06b6d4","#ec4899","#84cc16","#f97316","#64748b","#14b8a6","#a855f7"],ye=s=>Ft[s%Ft.length];function K(s,e={},t=""){let n=document.createElementNS(ro,s);t&&n.setAttribute("class",t);for(let[r,o]of Object.entries(e))n.setAttribute(r,String(o));return n}function Nt(s,e){let t=K("title");t.textContent=e,s.append(t)}function oo(s,e,t=5){let n=Math.min(0,s),r=Math.max(0,e);n===r&&(r=n+1);let o=(r-n)/t,i=10**Math.floor(Math.log10(o)),a=[1,2,5,10].map(d=>d*i).find(d=>d>=o);n=Math.floor(n/a)*a,r=Math.ceil(r/a)*a;let l=[];for(let d=n;d<=r+a/2;d+=a)l.push(Math.round(d/a)*a);return l}function Ht(s,e){let t=new Intl.NumberFormat(e.locale,{maximumFractionDigits:2}),n=new Intl.NumberFormat(e.locale,{notation:"compact",maximumFractionDigits:1}),r=K("svg",{viewBox:"0 0 640 360",role:"img",preserveAspectRatio:"xMidYMid meet"},`fg-chart fg-chart-is-${e.type}`);e.title&&r.setAttribute("aria-label",e.title);let o=e.series.slice(0,Ft.length),i=e.categories,a=16;if(e.title){let E=K("text",{x:320,y:22,"text-anchor":"middle"},"fg-chart-title");E.textContent=e.title,r.append(E),a=36}let l=K("g",{},"fg-chart-legend"),d=e.type==="pie"?i:o.map(E=>E.name),c=16;d.forEach((E,M)=>{let L=K("g",{transform:`translate(${c},350)`},"fg-chart-legend-item");L.append(K("rect",{x:0,y:-9,width:10,height:10,rx:2,fill:ye(M)}));let D=K("text",{x:14,y:0});D.textContent=E,L.append(D),l.append(L),c+=24+Math.min(140,E.length*7)});let u=308;if(e.type==="pie"){let E=(o[0]?.values??[]).map(A=>A!==null&&A>0?A:0),M=E.reduce((A,H)=>A+H,0),L=640/2,D=(a+u)/2,P=Math.max(10,(u-a)/2-6),T=-Math.PI/2;E.forEach((A,H)=>{if(!A||!M)return;let B=T+A/M*Math.PI*2,O=B-T>Math.PI?1:0,V=Q=>`${L+P*Math.cos(Q)},${D+P*Math.sin(Q)}`,J=A===M?`M${L-P},${D}a${P},${P} 0 1,0 ${2*P},0a${P},${P} 0 1,0 ${-2*P},0`:`M${L},${D}L${V(T)}A${P},${P} 0 ${O} 1 ${V(B)}Z`,q=K("path",{d:J,fill:ye(H)},"fg-chart-slice");Nt(q,`${i[H]}: ${t.format(A)} (${Math.round(A/M*1e3)/10}%)`),r.append(q),T=B}),r.append(l),s.replaceChildren(r);return}let v=e.type==="stackedBar",p=0,R=0;i.forEach((E,M)=>{let L=0,D=0;for(let P of o){let T=P.values[M];T==null||!Number.isFinite(T)||(v?T>=0?L+=T:D+=T:(R=Math.max(R,T),p=Math.min(p,T)))}v&&(R=Math.max(R,L),p=Math.min(p,D))});let w=oo(p,R),m=w[0],h=w[w.length-1],f=56,C=624,y=E=>u-(E-m)/(h-m)*(u-a),S=K("g",{},"fg-chart-axis");for(let E of w){S.append(K("line",{x1:f,x2:C,y1:y(E),y2:y(E)},E===0?"fg-chart-zero":"fg-chart-grid"));let M=K("text",{x:f-6,y:y(E)+4,"text-anchor":"end"});M.textContent=n.format(E),S.append(M)}let x=(C-f)/Math.max(1,i.length),g=Math.max(1,Math.ceil(i.length/Math.floor((C-f)/56)));i.forEach((E,M)=>{if(M%g)return;let L=K("text",{x:f+x*(M+.5),y:u+16,"text-anchor":"middle"});L.textContent=E.length>12?`${E.slice(0,11)}\u2026`:E,S.append(L)}),r.append(S);let k=K("g",{},"fg-chart-plot");if(e.type==="bar"||v){let E=x*.72,M=v?E:E/Math.max(1,o.length);i.forEach((L,D)=>{let P=0,T=0;o.forEach((A,H)=>{let B=A.values[D];if(B==null||!Number.isFinite(B))return;let O=0,V=B;v&&(O=B>=0?P:T,V=O+B,B>=0?P=V:T=V);let J=f+x*D+(x-E)/2+(v?0:M*H),q=K("rect",{x:J,y:Math.min(y(O),y(V)),width:Math.max(1,M-2),height:Math.max(.5,Math.abs(y(V)-y(O))),fill:ye(H),rx:2},"fg-chart-bar");Nt(q,`${A.name} \xB7 ${L}: ${t.format(B)}`),k.append(q)})})}else o.forEach((E,M)=>{let L=E.values.map((T,A)=>T==null||!Number.isFinite(T)?null:[f+x*(A+.5),y(T),T]),D="",P=!1;for(let T of L){if(!T){P=!1;continue}D+=`${P?"L":"M"}${T[0]},${T[1]}`,P=!0}if(e.type==="area"){let T=L.filter(A=>!!A);if(T.length){let A=`M${T[0][0]},${y(0)}${T.map(H=>`L${H[0]},${H[1]}`).join("")}L${T[T.length-1][0]},${y(0)}Z`;k.append(K("path",{d:A,fill:ye(M),"fill-opacity":.18},"fg-chart-area"))}}k.append(K("path",{d:D,fill:"none",stroke:ye(M),"stroke-width":2.2,"stroke-linejoin":"round"},"fg-chart-line")),L.forEach((T,A)=>{if(!T)return;let H=K("circle",{cx:T[0],cy:T[1],r:3.5,fill:ye(M)},"fg-chart-point");Nt(H,`${E.name} \xB7 ${i[A]}: ${t.format(T[2])}`),k.append(H)})});r.append(k,l),s.replaceChildren(r)}var so=12,Pn=500,Bt=["bar","stackedBar","line","area","pie"],it=class{constructor(e){this.grid=e;this.handles=new Set}create(e={}){let{grid:t}=this,n=Bt.includes(e.type)?e.type:"bar",r=()=>t.store.state.locale,o=e.range??t.store.state.range,i=null;if(o){let w=t.columns.getColumn(o.start.colId),m=t.columns.getColumn(o.end.colId);if(w&&m){let h=Se({start:{rowIndex:o.start.rowIndex,colIndex:w.index},end:{rowIndex:o.end.rowIndex,colIndex:m.index}}),f=[];for(let C=h.r1;C<=h.r2&&f.length<Pn;C++){let y=t.rowModel.getRow(C);y&&!y.kind&&f.push(y.data)}i={rows:f,colIds:t.columns.displayed().slice(h.c1,h.c2+1).filter(C=>!I(C.id)).map(C=>C.id)}}}let a=()=>{let w=i?i.rows:t.rowModel.dataRows().slice(0,Pn).map(x=>x.data),m=(i?i.colIds.map(x=>t.columns.getColumn(x)):t.columns.displayed().filter(x=>!I(x.id))).filter(x=>!!x),h=m[0]&&m[0].def.type!=="number"?m[0]:i?null:m.find(x=>x.def.type!=="number")??null,f=x=>!!x.node.parent&&x.node.parent.id==="pivotgroup|total",C=m.filter(x=>x!==h&&x.def.type==="number"&&(i||!f(x))).slice(0,so),y=x=>{let g=[];for(let k=x.node.parent;k;k=k.parent)g.unshift(k.def.header??k.id);return g.push(x.def.header??x.def.field??x.id),g.join(" \xB7 ")},S=h?G(h.def,r().code):null;return{categories:w.map((x,g)=>h&&S?S(N(h.def,x)):String(g+1)),series:C.map(x=>({name:y(x),values:w.map(g=>{let k=N(x.def,g),E=typeof k=="number"?k:k==null||k===""?NaN:Number(k);return Number.isFinite(E)?E:null})}))}},l=b("div","fg-chart-body"),d=null,c=()=>Ht(l,{type:n,title:e.title,locale:r().code,...a()}),u=w=>({bar:r().chartBar,stackedBar:r().chartStacked,line:r().chartLine,area:r().chartArea,pie:r().chartPie})[w],v=()=>d?.querySelectorAll(".fg-chart-type").forEach(w=>w.setAttribute("aria-pressed",String(w.dataset.type===n)));if(e.container)e.container.append(l);else{d=b("div","fg-chart-panel",{role:"dialog","aria-label":e.title??u(n)});let w=b("div","fg-chart-head");for(let h of Bt){let f=b("button","fg-chart-type",{type:"button",title:u(h)});f.dataset.type=h,f.textContent=u(h),f.addEventListener("click",()=>R.setType(h)),w.append(f)}let m=b("button","fg-chooser-close",{type:"button","aria-label":r().close});m.textContent="\xD7",m.addEventListener("click",()=>R.destroy()),w.append(b("span","fg-chart-spacer"),m),d.append(w,l),t.renderer.root.append(d)}let p=[t.events.on("cellValueChanged",()=>c()),t.events.on("rowsAdded",()=>c()),t.events.on("rowsRemoved",()=>c())];i||p.push(t.events.on("sortChange",()=>c()),t.events.on("filterChange",()=>c()));let R={el:l,setType:w=>{Bt.includes(w)&&(n=w,v(),c())},update:()=>c(),destroy:()=>{p.forEach(w=>w()),(d??l).remove(),this.handles.delete(R)}};return this.handles.add(R),v(),c(),R}destroy(){for(let e of[...this.handles])e.destroy()}};function An(s,e,t){return typeof s=="number"&&typeof e=="number"?s-e:s instanceof Date&&e instanceof Date?s.getTime()-e.getTime():typeof s=="boolean"&&typeof e=="boolean"?Number(s)-Number(e):t.compare(String(s),String(e))}function io(s,e){if(F(e))return null;if(s.type==="number"){let t=typeof e=="number"?e:Number(e);return Number.isNaN(t)?null:t}return s.type==="date"?Z(e)?.getTime()??null:e}function ce(s,e,t){let n=F(s),r=F(e);return n||r?n===r?0:n?1:-1:An(s,e,t)}function Nn(s,e,t,n){let r=e.map(a=>({def:t(a.colId),mul:a.dir==="desc"?-1:1})).filter(a=>!!a.def);if(!r.length)return s;let o=r.map(a=>s.map(l=>{let d=N(a.def,l.data);return a.def.comparator?d:io(a.def,d)})),i=s.map((a,l)=>l);return i.sort((a,l)=>{for(let d=0;d<r.length;d++){let{def:c,mul:u}=r[d],v=o[d][a],p=o[d][l],R;if(c.comparator)try{R=(Number(c.comparator(v,p,s[a].data,s[l].data))||0)*u}catch{$(`comparator of column "${c.id??c.field}" threw; treating values as equal`),R=0}else{let w=F(v),m=F(p);R=w||m?w===m?0:w?1:-1:An(v,p,n)*u}if(R)return R}return a-l}),i.map(a=>s[a])}var Fn=new WeakMap,ao=s=>typeof s=="function"?"custom":s;function Ot(s,e){return{rows:(s.rows??[]).filter(e),columns:(s.columns??[]).filter(e),values:(s.values??[]).filter(t=>t&&e(t.colId)).map(t=>({colId:t.colId,aggFunc:t.aggFunc??"sum"})),totals:s.totals!==!1}}function Hn(s,e,t,n,r){let o=Ot(e,C=>!!t(C)),i=new Intl.Collator(r,{numeric:!0,sensitivity:"base"}),a=C=>t(C),l=(C,y)=>C.map(S=>W(N(a(S),y))).join(""),d=new Map;for(let C of s){let y=l(o.columns,C);d.has(y)||d.set(y,o.columns.map(S=>N(a(S),C)))}let c=[...d.entries()].sort((C,y)=>{for(let S=0;S<o.columns.length;S++){let x=ce(C[1][S],y[1][S],i);if(x)return x}return 0});o.columns.length||c.splice(0,c.length,["",[]]);let u=[],v=(C,y,S)=>{let x=o.values[y],g=a(x.colId),k=`pivot|${S}|${y}`;u.push({id:k,comboKey:C,valueIndex:y});let E=L=>C===null||l(o.columns,L)===C,M=x.aggFunc;return{id:k,field:k,header:`${g.header??g.field??x.colId} (${n.agg(ao(M))})`,type:"number",format:M==="count"?"integer":g.format,width:130,aggFunc:(L,D)=>{let P=D.flatMap(T=>Fn.get(T)??[]).filter(E);return P.length?pe(M,P.map(T=>N(g,T)),P):null}}},p=[],R=(C,y)=>{if(F(y))return n.blank;let S=a(C);return S.type==="number"&&!S.format?String(y):G(S,r)(y)};if(!o.columns.length)o.values.forEach((C,y)=>p.push(v("",y,0)));else{let C=(y,S,x)=>{let g=[],k=0;for(;k<y.length;){let E=y[k][1][S],M=W(E),L=k;for(;L<y.length&&W(y[L][1][S])===M;)L++;let D=y.slice(k,L),P=S===o.columns.length-1?o.values.map((T,A)=>v(D[0][0],A,x+k)):C(D,S+1,x+k);g.push({id:`pivotgroup|${S}|${x+k}`,header:R(o.columns[S],E),children:P}),k=L}return g};p.push(...C(c,0,0)),o.totals&&o.values.length&&p.push({id:"pivotgroup|total",header:n.total,children:o.values.map((y,S)=>v(null,S,"total"))})}let w=new Map;for(let C of s){let y=l(o.rows,C),S=w.get(y);S||w.set(y,S={values:o.rows.map(x=>N(a(x),C)),src:[]}),S.src.push(C)}let h=[...w.values()].sort((C,y)=>{for(let S=0;S<o.rows.length;S++){let x=ce(C.values[S],y.values[S],i);if(x)return x}return 0}).map(C=>{let y={};o.rows.forEach((x,g)=>{y[a(x).field??x]=C.values[g]});let S=new Map;if(o.columns.length)for(let x of C.src){let g=l(o.columns,x),k=S.get(g);k||S.set(g,k=[]),k.push(x)}for(let x of u){let g=o.values[x.valueIndex],k=x.comboKey===null||!o.columns.length?C.src:S.get(x.comboKey)??[],E=a(g.colId);y[x.id]=k.length?pe(g.aggFunc,k.map(M=>N(E,M)),k):null}return Fn.set(y,C.src),y});return{columns:[...o.rows.map(C=>{let y=a(C);return{id:C,field:y.field??C,header:y.header??y.field??C,type:y.type,format:y.format,width:y.width??140}}),...p],rows:h,groupBy:o.rows.slice(0,-1)}}var at="0.8.1";var lo={kty:"EC",crv:"P-256",x:"sUTKkglZmk-HMKPNub8p7AeLBKesHCU8irIkw9rJlbE",y:"j0U_aKRDR7iApY9UpaD3hUemhBLZJwDv9-QiT_hUyw8"},zt="https://freegrid.app/pricing/",Bn="https://freegrid.app/api/usage",co="https://freegrid.app/api/domain-status",On=s=>{let e=atob(s.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-s.length%4)%4));return Uint8Array.from(e,t=>t.charCodeAt(0))};function Vt(s){let e=s.toLowerCase().replace(/^\[|\]$/g,"");return!e||e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="0.0.0.0"||e.endsWith(".localhost")||e.endsWith(".test")||e.endsWith(".local")||/^(10|192\.168|172\.(1[6-9]|2\d|3[01]))\./.test(e)}function uo(s,e){let t=s.toLowerCase().replace(/\.$/,"");return e.some(n=>{let r=n.toLowerCase().replace(/\.$/,""),o=r.startsWith("*."),i=o?r.slice(2):r;return i?t===i||t===`www.${i}`?!0:o&&t.endsWith(`.${i}`):!1})}var ho=s=>`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`;async function Un(s,e,t={}){let n=typeof s=="string"?s.trim().split("."):[];if(n.length!==3||n[0]!=="FG1")return{ok:!1,reason:"format"};let r;try{if(r=JSON.parse(new TextDecoder().decode(On(n[1]))),!Array.isArray(r.domains)||typeof r.expires!="string")return{ok:!1,reason:"format"}}catch{return{ok:!1,reason:"format"}}let o=typeof crypto<"u"?crypto.subtle:void 0;if(!o)return{ok:!1,reason:"unsupported",info:r};try{let i=await o.importKey("jwk",t.publicKey??lo,{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]),a=new TextEncoder().encode(`${n[0]}.${n[1]}`);if(!await o.verify({name:"ECDSA",hash:"SHA-256"},i,On(n[2]),a))return{ok:!1,reason:"signature",info:r}}catch{return{ok:!1,reason:"signature",info:r}}return ho(t.now??new Date)>r.expires?{ok:!1,reason:"expired",info:r}:uo(e,r.domains)?{ok:!0,info:r}:{ok:!1,reason:"domain",info:r}}var Gt,zn=new Map,Ee=null;function fo(s){Gt=s}var Gn={missing:`FreeGrid is free for personal use. Company use needs a domain license (\u20A9200,000 per domain per year): ${zt}
|
|
7
7
|
FreeGrid\uB294 \uAC1C\uC778\uC5D0\uAC8C \uBB34\uB8CC\uC785\uB2C8\uB2E4. \uD68C\uC0AC\uC5D0\uC11C \uC4F0\uB824\uBA74 \uB3C4\uBA54\uC778 \uB77C\uC774\uC120\uC2A4(\uB3C4\uBA54\uC778\uB2F9 \uC5F0 20\uB9CC \uC6D0)\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4: ${zt}`,format:"FreeGrid: the license key is not in the right format. / \uB77C\uC774\uC120\uC2A4 \uD0A4 \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.",signature:"FreeGrid: the license key could not be verified. / \uB77C\uC774\uC120\uC2A4 \uD0A4\uB97C \uD655\uC778\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.",expired:"FreeGrid: the license key has expired. / \uB77C\uC774\uC120\uC2A4 \uAE30\uAC04\uC774 \uB05D\uB0AC\uC2B5\uB2C8\uB2E4.",domain:"FreeGrid: the license key is for a different domain. / \uB2E4\uB978 \uB3C4\uBA54\uC778\uC6A9 \uB77C\uC774\uC120\uC2A4 \uD0A4\uC785\uB2C8\uB2E4."};function Vn(s,e=typeof location<"u"?location.hostname:""){try{if(Vt(e)||typeof navigator>"u")return;let t=new Date().toISOString().slice(0,10),n=`${e}|${t}|${s.licensed?1:0}`,r=typeof localStorage<"u"?localStorage:null;if(r?.getItem("freegrid:usage")===n)return;r?.setItem("freegrid:usage",n);let o=JSON.stringify({version:s.version,licensed:s.licensed,company:s.company,url:`${location.origin}${location.pathname}`});typeof navigator.sendBeacon=="function"?navigator.sendBeacon(Bn,o):typeof fetch=="function"&&fetch(Bn,{method:"POST",body:o,mode:"no-cors",keepalive:!0}).catch(()=>{})}catch{}}function po(s=Gt,e=typeof location<"u"?location.hostname:""){if(Vt(e))return Promise.resolve(!0);let t=s??Gt,n=`${t??""}@${e}`,r=zn.get(n);return r||(t?r=Un(t,e).then(o=>{if(Vn({version:at,licensed:o.ok,company:o.ok?o.info.company:void 0},e),o.ok||o.reason==="unsupported")return o.ok||o.reason==="unsupported";let i=o.info?` (${o.info.domains.join(", ")}, ${o.info.expires})`:"";return console.warn(`${Gn[o.reason]}${i}
|
|
8
8
|
${zt}`),!1},()=>!1):(console.info(Gn.missing),Vn({version:at,licensed:!1},e),r=Promise.resolve(!1)),zn.set(n,r),r)}function go(s=typeof location<"u"?location.hostname:""){if(Vt(s)||typeof fetch!="function")return Promise.resolve(!1);if(Ee)return Ee;let e=new Date().toISOString().slice(0,10),t=null;try{t=typeof localStorage<"u"?localStorage:null;let n=JSON.parse(t?.getItem("freegrid:badge")??"null");if(n&&n.host===s&&n.day===e)return Ee=Promise.resolve(n.show)}catch{}return Ee=fetch(co,{mode:"cors",credentials:"omit"}).then(n=>n.ok?n.json():{badge:!1}).then(n=>{let r=n.badge===!0;try{t?.setItem("freegrid:badge",JSON.stringify({host:s,day:e,show:r}))}catch{}return r},()=>!1),Ee}async function qn(s,e=typeof location<"u"?location.hostname:""){return await po(s,e)?!1:go(e)}var Kn={text:["contains","equals","notEquals","startsWith","endsWith","blank","notBlank"],number:["eq","ne","lt","lte","gt","gte","between","blank","notBlank"],date:["equals","before","after","between","blank","notBlank"]},_n=["blank","notBlank"],Ut=500,lt=class{constructor(e){this.grid=e;this.popup=null;this.colId=null;this.off=[]}get openColumn(){return this.colId}toggle(e,t){this.colId===e?this.close():this.open(e,t)}open(e,t){this.close();let n=this.grid.columns.getNode(e);if(!n||n.children||I(e))return;let r=this.grid.store.state.locale,o=n.def,i=b("div",`fg-menu fg-theme-${this.grid.store.state.theme}`,{role:"dialog","aria-label":r.columnMenu});this.grid.applyFontTo(i),le(o)&&i.append(this.section([[r.sortAsc,()=>this.grid.setSort([{colId:e,dir:"asc"}])],[r.sortDesc,()=>this.grid.setSort([{colId:e,dir:"desc"}])],[r.clearSort,()=>this.grid.setSort(this.grid.store.state.sort.filter(w=>w.colId!==e))]])),i.append(this.section([[r.pinLeft,()=>this.grid.setPinned(e,"left")],[r.pinRight,()=>this.grid.setPinned(e,"right")],[r.unpin,()=>this.grid.setPinned(e,null)]]));let a=this.grid.getGroupBy();if(!this.grid.options.treeData&&(this.grid.options.groupPanel||a.length)){let w=a.includes(e)?[[r.ungroup,()=>this.grid.setGroupBy(a.filter(m=>m!==e))]]:[[r.groupByThis,()=>this.grid.setGroupBy([...a,e])]];a.length&&w.push([r.expandAll,()=>this.grid.expandAll(!0)],[r.collapseAll,()=>this.grid.expandAll(!1)]),i.append(this.section(w))}let l=[[r.autosizeThis,()=>this.grid.autoSize([e])],[r.autosizeAll,()=>this.grid.autoSize()]];o.lockVisible||l.push([r.hideColumn,()=>this.grid.setColumnsVisible([e],!1)]),l.push([r.chooseColumns,()=>this.grid.chooser.open()],[r.resetColumns,()=>this.grid.resetColumns()]),i.append(this.section(l));let d=this.filterSection(e,()=>this.close());d&&i.append(d),se(this.grid.renderer.root).append(i);let c=t.getBoundingClientRect(),u=i.offsetWidth||248;i.style.left=`${Math.max(4,Math.min(c.right-u,window.innerWidth-u-4))}px`;let v=Math.max(4,Math.min(c.bottom+4,window.innerHeight-240));i.style.top=`${v}px`,i.style.maxHeight=`${Math.max(160,window.innerHeight-v-8)}px`,this.popup=i,this.colId=e;let p=w=>{me(w,i,t)||this.close()},R=w=>{w.key==="Escape"&&(this.close(),this.grid.renderer.gridEl.focus())};document.addEventListener("pointerdown",p,!0),document.addEventListener("keydown",R,!0),this.off.push(()=>document.removeEventListener("pointerdown",p,!0),()=>document.removeEventListener("keydown",R,!0)),i.querySelector(".fg-filter-value:not([hidden]), .fg-set-search, .fg-menu-item")?.focus()}filterSection(e,t){let n=this.grid.columns.getNode(e);if(!n||n.children)return null;let r=this.grid.store.state.locale,o=he(n.def);return o==="set"?this.setFilter(e,r,t):o?this.conditionFilter(e,o,r,t):null}close(){for(let e of this.off)e();this.off=[],this.popup?.remove(),this.popup=null,this.colId=null}section(e){let t=b("div","fg-menu-section");for(let[n,r]of e){let o=b("button","fg-menu-item",{type:"button"});o.textContent=n,o.addEventListener("click",()=>{r(),this.close()}),t.append(o)}return t}actions(e,t,n,r){let o=b("div","fg-menu-actions"),i=b("button","fg-btn",{type:"button"});i.textContent=t.reset,i.addEventListener("click",()=>{this.grid.setFilter(e,null),r()});let a=b("button","fg-btn fg-btn-primary",{type:"button"});return a.textContent=t.apply,a.addEventListener("click",n),o.append(i,a),o}title(e){let t=b("div","fg-menu-title");return t.textContent=e.filter,t}conditionFilter(e,t,n,r){let o=this.grid.store.state.filters[e],i=o&&o.type===t?o:void 0,a=b("div","fg-menu-section fg-filter"),l=b("select","fg-filter-op",{"aria-label":n.filter});for(let R of Kn[t]){let w=b("option");w.value=R,w.textContent=n.ops[R],l.append(w)}l.value=i?.op??Kn[t][0];let d=t==="text"?"text":t,c=b("input","fg-input fg-filter-value",{type:d,placeholder:n.value,"aria-label":n.value}),u=b("input","fg-input fg-filter-value-to",{type:d,placeholder:n.valueTo,"aria-label":n.valueTo});i&&(c.value=i.value!=null?String(i.value):"",u.value="valueTo"in i&&i.valueTo!=null?String(i.valueTo):"");let v=()=>{c.hidden=_n.includes(l.value),u.hidden=l.value!=="between"};l.addEventListener("change",v),v();let p=()=>{let R=l.value,w=!_n.includes(R),m=null;if(t==="number"){let h=c.value===""?void 0:Number(c.value),f=u.value===""?void 0:Number(u.value);(!w||h!==void 0)&&(m={type:t,op:R,value:h,valueTo:f})}else t==="date"?(!w||c.value)&&(m={type:t,op:R,value:c.value||void 0,valueTo:u.value||void 0}):(!w||c.value)&&(m={type:t,op:R,value:c.value});this.grid.setFilter(e,m),r()};for(let R of[c,u])R.addEventListener("keydown",w=>w.key==="Enter"&&p());return a.append(this.title(n),l,c,u,this.actions(e,n,p,r)),a}setFilter(e,t,n){let{grid:r}=this,o=r.columns.getNode(e).def,i=G(o,t.code),a=r.collator(),l=new Map;for(let x of r.rowModel.allNodes()){let g=N(o,x.data),k=W(g);l.has(k)||l.set(k,g)}let d=[...l.entries()].sort((x,g)=>ce(x[1],g[1],a)),c=r.store.state.filters[e],u=new Set(c?.type==="set"?c.values.map(W).filter(x=>l.has(x)):l.keys()),v=(x,g)=>x===""?t.blanks:i(g),p=b("div","fg-menu-section fg-filter fg-set-filter"),R=b("input","fg-input fg-set-search",{type:"search",placeholder:t.search,"aria-label":t.search}),w=b("label","fg-set-item fg-set-all"),m=b("input","fg-checkbox",{type:"checkbox"});w.append(m,document.createTextNode(t.selectAll));let h=b("div","fg-set-list"),f=()=>{let x=R.value.trim().toLowerCase();return x?d.filter(([g,k])=>v(g,k).toLowerCase().includes(x)):d},C=()=>{let x=f(),g=x.filter(([k])=>u.has(k)).length;m.checked=g>0&&g===x.length,m.indeterminate=g>0&&g<x.length},y=()=>{let x=f();if(h.replaceChildren(...x.slice(0,Ut).map(([g,k])=>{let E=b("label","fg-set-item"),M=b("input","fg-checkbox",{type:"checkbox"});return M.checked=u.has(g),M.addEventListener("change",()=>{M.checked?u.add(g):u.delete(g),C()}),E.append(M,document.createTextNode(v(g,k))),E})),x.length>Ut){let g=b("div","fg-set-more");g.textContent=`\u2026 +${x.length-Ut}`,h.append(g)}C()};m.addEventListener("change",()=>{for(let[x]of f())m.checked?u.add(x):u.delete(x);y()}),R.addEventListener("input",y);let S=()=>{r.setFilter(e,u.size===l.size?null:{type:"set",values:d.filter(([x])=>u.has(x)).map(([,x])=>x)}),n()};return R.addEventListener("keydown",x=>x.key==="Enter"&&S()),y(),p.append(this.title(t),R,w,h,this.actions(e,t,S,n)),p}};var Wn=new WeakMap,mo=0;function Le(s){let e=Wn.get(s);return e||Wn.set(s,e=`r${++mo}`),e}var dt=class{constructor(e){this.deps=e;this.stats={filterRuns:0,sortRuns:0};this.server=!1;this.full=[];this.last={};this.nodes=[];this.filtered=[];this.sorted=[];this.display=[];this.indexById=null;this.layoutCache=null}update(e){let t=this.deps.collator(),n=e.display,r=!!n?.getParentId!=!!this.last.display?.getParentId,o=e.data!==this.last.data,i=o||r||e.filters!==this.last.filters||e.quickFilter!==this.last.quickFilter,a=i||e.sort!==this.last.sort||t!==this.last.collator,l=a||n?.version!==this.last.displayVersion||n?.groupBy!==this.last.display?.groupBy;if(o){let u=this.deps.getRowId;this.nodes=e.data.map((v,p)=>({id:u?String(u(v)):Le(v),data:v,sourceIndex:p}))}i&&(this.filtered=this.filter(e),this.stats.filterRuns++),a&&(this.sorted=Nn(this.filtered,e.sort,u=>this.deps.columnDef(u),t),this.stats.sortRuns++),l&&(this.full=n?this.buildDisplay(n,e.sort,t):this.sorted);let d=e.page??null,c=this.last.page??null;(l||d?.index!==c?.index||d?.size!==c?.size)&&(this.display=d?this.full.slice(d.index*d.size,(d.index+1)*d.size):this.full,this.indexById=null,this.layoutCache=null),this.last={...e,collator:t,displayVersion:n?.version}}invalidate(){this.last={}}fullCount(){return this.full.length}dataCount(){return this.sorted.length}loading(){return!1}getRowCount(){return this.display.length}getRow(e){return this.display[e]}rows(){return this.display}dataRows(){return this.sorted}allNodes(){return this.nodes}idOf(e){return this.deps.getRowId?String(this.deps.getRowId(e)):Le(e)}indexOfId(e){return this.indexById||(this.indexById=new Map(this.display.map((t,n)=>[t.id,n]))),this.indexById.get(e)??-1}layout(e,t,n,r=0){let o=this.layoutCache;if(o&&o.rows===this.display&&o.rh===e&&o.dh===t&&o.hv===r)return o;let i=this.display.length,a=new Float64Array(i+1),l=!0,d=n&&n.size?n:null;for(let c=0;c<i;c++){let u=this.display[c],v=e;u.kind==="detail"?v=t:d&&!u.kind&&(v=d.get(u.id)??e),v!==e&&(l=!1),a[c+1]=a[c]+v}return this.layoutCache={rows:this.display,rh:e,dh:t,hv:r,offsets:a,uniform:l},this.layoutCache}filter(e){let t=Object.entries(e.filters).map(([d,c])=>({def:this.deps.columnDef(d),pred:on(c)})).filter(d=>!!d.def),n=sn(e.quickFilter),r=n.length?this.deps.quickColumns():[];if(!t.length&&!n.length)return this.nodes;let o=this.nodes.filter(d=>{for(let c of t)if(!c.pred(N(c.def,d.data)))return!1;if(n.length){let c=r.map(u=>this.deps.format(u,N(u,d.data))).join("").toLowerCase();if(!an(n,c))return!1}return!0}),i=e.display?.getParentId;if(!i)return o;let a=new Map(this.nodes.map(d=>[d.id,d])),l=new Set(o);for(let d of o){let c=i(d.data),u=new Set;for(;c!=null&&!u.has(c);){u.add(c);let v=a.get(String(c));if(!v)break;l.add(v),c=i(v.data)}}return this.nodes.filter(d=>l.has(d))}isOpen(e,t,n){let r=e.expanded.get(t);return r!==void 0?r:e.defaultExpanded===-1||n<e.defaultExpanded}withDetails(e,t,n){for(let r of t)n.push(r),e.detailOpen.has(r.id)&&(!e.isMaster||e.isMaster(r.data))&&n.push({id:`detail:${r.id}`,data:{},sourceIndex:-1,kind:"detail",detailOf:r})}buildDisplay(e,t,n){let r=[];if(e.getParentId)return this.buildTree(e,r),r;let o=e.groupBy.filter(a=>this.deps.columnDef(a));if(!o.length)return e.detailOpen.size?(this.withDetails(e,this.sorted,r),r):this.sorted;let i=(a,l,d)=>{let c=o[l],u=this.deps.columnDef(c),v=new Map;for(let w of a){let m=N(u,w.data),h=F(m)?"":W(m),f=v.get(h);f||v.set(h,f={value:m,nodes:[]}),f.nodes.push(w)}let p=t.find(w=>w.colId===c)?.dir==="desc"?-1:1,R=[...v.entries()].sort((w,m)=>ce(w[1].value,m[1].value,n)*p);for(let[w,m]of R){let h=`${d}${c}:${w}`,f=this.isOpen(e,h,l);r.push({id:`group:${h}`,data:{},sourceIndex:-1,kind:"group",level:l,group:{key:h,colId:c,value:m.value,rows:m.nodes.map(C=>C.data),expanded:f}}),f&&(l+1<o.length?i(m.nodes,l+1,`${h}|`):this.withDetails(e,m.nodes.map(C=>({...C,level:l+1})),r))}};return i(this.sorted,0,""),r}buildTree(e,t){let n=new Set(this.sorted.map(a=>a.id)),r=new Map,o=[];for(let a of this.sorted){let l=e.getParentId(a.data),d=l==null?null:String(l);if(d!==null&&n.has(d)&&d!==a.id){let c=r.get(d);c||r.set(d,c=[]),c.push(a)}else o.push(a)}let i=(a,l,d)=>{for(let c of a){if(d.has(c.id))continue;let u=r.get(c.id)??[],v=!u.length&&!!e.lazyChildren?.(c.id,c.data),p=u.length>0&&this.isOpen(e,c.id,l),R={...c,level:l,hasChildren:u.length>0||v,expanded:p};v&&e.loading?.has(c.id)&&(R.loading=!0),this.withDetails(e,[R],t),p&&i(u,l+1,new Set([...d,c.id]))}};i(o,0,new Set)}};var wo=3e3,vo=new Float64Array(0),Ie=class{constructor(e){this.deps=e;this.stats={filterRuns:0,sortRuns:0};this.server=!0;this.blocks=new Map;this.total=null;this.loadedEnd=0;this.gen=0;this.query=null;this.page=null;this.lastBlock=0;this.version=0;this.cache=null}get bs(){return this.page?this.page.size:this.deps.blockSize}get base(){return this.page?this.page.index*this.page.size:0}update(e){let t=this.query,n=!t||t.sort!==e.sort||t.filters!==e.filters||t.quickFilter!==e.quickFilter,r=e.page??null,o=(r?.size??0)!==(this.page?.size??0);this.query={sort:e.sort,filters:e.filters,quickFilter:e.quickFilter},this.page=r?{...r}:null,(n||o)&&this.purge(),this.ensure(Math.floor(this.base/this.bs))}invalidate(){}purge(){this.gen++,this.blocks.clear(),this.total=null,this.loadedEnd=0,this.touch(),this.query&&this.ensure(Math.floor(this.base/this.bs))}touch(){this.version++,this.cache=null}fullCount(){if(this.total!==null)return this.total;if(!this.loadedEnd)return 0;let e=this.blocks.get(Math.floor((this.loadedEnd-1)/this.bs));return this.loadedEnd+(e&&e.nodes.length<this.bs?0:this.bs)}getRowCount(){let e=this.fullCount();return this.page?Math.max(0,Math.min(this.page.size,e-this.base)):e}dataCount(){return this.fullCount()}loading(){for(let e of this.blocks.values())if(e.state==="loading")return!0;return!1}placeholder(e){return{id:`loading:${e}`,data:{},sourceIndex:-1,kind:"loading"}}peek(e){let t=Math.floor(e/this.bs),n=this.blocks.get(t);return n?.state==="loaded"?n.nodes[e-t*this.bs]??null:null}getRow(e){let t=this.base+e,n=this.peek(t);return n||(e>=0&&e<this.getRowCount()&&this.ensure(Math.floor(t/this.bs)),this.placeholder(t))}ensure(e){let t=this.blocks.get(e);if(t&&(t.state!=="failed"||Date.now()<(t.retryAt??0))||this.total!==null&&e*this.bs>=this.total&&e>0)return;let n=e*this.bs,r=n+this.bs,o=this.gen;this.lastBlock=e,this.blocks.set(e,{state:"loading",nodes:[]});let i=this.query,a=d=>{o===this.gen&&(this.blocks.set(e,{state:"failed",nodes:[],retryAt:Date.now()+wo}),this.deps.onFailed(n,r,d))},l;try{l=Promise.resolve(this.deps.datasource.getRows({start:n,end:r,sort:[...i.sort],filters:{...i.filters},quickFilter:i.quickFilter}))}catch(d){l=Promise.reject(d)}l.then(d=>{if(o!==this.gen)return;let c=Array.isArray(d?.rows)?d.rows.filter(p=>p!==null&&typeof p=="object"):null;if(!c){$("datasource.getRows must resolve to { rows: Row[], total?: number }"),a(new Error("invalid datasource response"));return}let u=this.deps.getRowId,v=c.slice(0,this.bs).map((p,R)=>({id:u?String(u(p)):Le(p),data:p,sourceIndex:n+R}));this.blocks.set(e,{state:"loaded",nodes:v}),typeof d.total=="number"&&d.total>=0?this.total=d.total:v.length<this.bs&&(this.total=n+v.length),this.loadedEnd=Math.max(this.loadedEnd,n+v.length),this.evict(),this.touch(),this.deps.onLoaded(n,n+v.length,this.total)},a)}evict(){let e=Math.max(2,this.deps.maxBlocks);if(this.blocks.size<=e)return;let t=[...this.blocks.keys()].sort((n,r)=>Math.abs(r-this.lastBlock)-Math.abs(n-this.lastBlock));for(let n of t){if(this.blocks.size<=e)break;this.blocks.get(n).state!=="loading"&&this.blocks.delete(n)}}built(){if(this.cache?.ver===this.version)return this.cache;let e=[];for(let n of[...this.blocks.keys()].sort((r,o)=>r-o)){let r=this.blocks.get(n);r.state==="loaded"&&e.push(...r.nodes)}let t=new Map;for(let n of e)t.set(n.id,n.sourceIndex);return this.cache={ver:this.version,data:e,rows:null,ids:t},this.cache}rows(){let e=this.built();if(!e.rows){let t=this.getRowCount();e.rows=new Array(t);for(let n=0;n<t;n++)e.rows[n]=this.peek(this.base+n)??this.placeholder(this.base+n)}return e.rows}dataRows(){return this.built().data}allNodes(){return this.built().data}idOf(e){return this.deps.getRowId?String(this.deps.getRowId(e)):Le(e)}indexOfId(e){let t=this.built().ids.get(e);if(t===void 0)return-1;let n=t-this.base;return n>=0&&n<this.getRowCount()?n:-1}layout(){return{offsets:vo,uniform:!0}}};function jn(s){let e=s.idAt(s.index);if(s.mode==="single"){let t=new Set;return s.toggle&&s.selected.has(e)||t.add(e),{selected:t,anchorIndex:s.index}}if(s.range&&s.anchorIndex!=null){let t=s.toggle?new Set(s.selected):new Set,n=Math.min(s.anchorIndex,s.index),r=Math.max(s.anchorIndex,s.index);for(let o=n;o<=r;o++)t.add(s.idAt(o));return{selected:t,anchorIndex:s.anchorIndex}}if(s.toggle){let t=new Set(s.selected);return t.has(e)?t.delete(e):t.add(e),{selected:t,anchorIndex:s.index}}return{selected:new Set([e]),anchorIndex:s.index}}var ct=class{constructor(e){this.bus=new ge;this.current=e}get state(){return this.current}set(e){let t=Object.keys(e).filter(n=>e[n]!==this.current[n]);t.length&&(this.current={...this.current,...e},this.bus.emit("change",t))}};var Xn=s=>Math.round(s*2.75),Yn=s=>Math.round(s*3.1),Zn=13,yo=[],bo=100,xo=new Map;function ie(s){return s.every(e=>e!==null&&typeof e=="object")?s:($("data contains entries that are not objects; they were skipped"),s.filter(e=>e!==null&&typeof e=="object"))}var qt=class{constructor(e,t){this.options=t;this.events=new ge;this.pinnedRows={top:[],bottom:[]};this.spanCache=null;this.editVersion=0;this.tracker=new tt;this.history=new et;this.disposers=[];this.collatorCache=null;this.destroyed=!1;this.summaryOpts=null;this.summaryValues=[];this.groupBy=[];this.expanded=new Map;this.defaultExpanded=0;this.detailOpen=new Set;this.displayVersion=0;this.aggCache={ver:-1,map:new WeakMap};this.charts=new it(this);this.sourceDefs=[];this.pivotCfg=null;this.pivotData=null;this.savedGroup=null;this.page=0;this.pageSize=bo;this.treeLoaded=new Set;this.treeLoading=new Set;this.lazyChildren=(e,t)=>{if(this.treeLoaded.has(e))return!1;try{return!!this.options.treeData?.hasChildren?.(t)}catch{return!1}};Array.isArray(t.columns)||$("options.columns must be an array"),t.data!=null&&!Array.isArray(t.data)&&$("options.data must be an array"),this.store=new ct({data:Array.isArray(t.data)?ie(t.data):[],sort:[],filters:{},quickFilter:"",selected:new Set,anchorId:null,focus:null,range:null,extraRanges:[],locale:De(t.locale),theme:t.theme??"light"}),this.sourceDefs=Array.isArray(t.columns)?t.columns:[],this.columns=new $e(this.withSelect(this.sourceDefs));let n=t.pagination;n&&typeof n=="object"&&n.pageSize!==void 0&&(Number.isInteger(n.pageSize)&&n.pageSize>0?this.pageSize=n.pageSize:$("pagination.pageSize must be a positive integer")),t.datasource&&typeof t.datasource.getRows!="function"&&$("datasource.getRows must be a function"),this.rowModel=t.datasource&&typeof t.datasource.getRows=="function"?new Ie({datasource:t.datasource,blockSize:Number.isInteger(t.blockSize)&&t.blockSize>0?t.blockSize:100,maxBlocks:Number.isInteger(t.maxBlocks)&&t.maxBlocks>0?t.maxBlocks:100,getRowId:t.getRowId,onLoaded:(i,a,l)=>this.serverLoaded(i,a,l),onFailed:(i,a,l)=>this.serverFailed(i,a,l)}):new dt({getRowId:t.getRowId,columnDef:i=>this.columns.getNode(i)?.def,quickColumns:()=>this.columns.displayed().filter(i=>!I(i.id)).map(i=>i.def),format:(i,a)=>G(i,this.store.state.locale.code)(a),collator:()=>this.collator()}),this.groupBy=this.validGroupBy(t.groupBy??[]),this.defaultExpanded=t.groupDefaultExpanded??0,t.treeData&&!t.getRowId&&$("treeData needs getRowId so parent ids can be matched"),this.updateRows(),this.summaryOpts=t.summary??null,this.refreshSummary();let r=t.fontSize!=null&&t.fontSize>0?t.fontSize:null;t.fontSize!=null&&!(t.fontSize>0)&&$("fontSize must be a positive number"),this.font={size:r,family:t.fontFamily??null};let o=r??Zn;if(this.renderer=new Oe(e,this,{rowHeight:t.rowHeight??Xn(o),headerHeight:t.headerHeight??Yn(o)}),this.renderer.applyFont(this.font.size,this.font.family),this.menu=new lt(this),this.chooser=new _e(this),this.contextMenu=new je(this),this.editor=new Qe(this),this.finder=new Ye(this),this.fillHandle=new Xe(this),this.groupPanel=t.groupPanel?new ze(this):null,this.pinnedRows={top:ie(t.pinnedTopRows??[]),bottom:ie(t.pinnedBottomRows??[])},this.sideBar=t.sideBar?new We(this,typeof t.sideBar=="object"&&!!t.sideBar.open,(typeof t.sideBar=="object"?t.sideBar.panels:void 0)??(t.pivot||t.pivotPanel?["columns","filters","pivot"]:void 0)):null,this.disposers.push(this.store.bus.on("change",i=>this.onChange(i)),Rn(this),wn(this),()=>this.menu.close(),()=>this.chooser.close(),()=>this.contextMenu.destroy(),()=>this.editor.cancel(),()=>this.fillHandle.destroy(),()=>this.groupPanel?.destroy(),()=>this.charts.destroy()),typeof ResizeObserver<"u"){let i=new ResizeObserver(()=>this.renderer.schedule());i.observe(this.renderer.main),this.disposers.push(()=>i.disconnect())}t.pivot&&this.setPivot(t.pivot),qn(t.licenseKey).then(i=>{i&&!this.destroyed&&this.renderer.showFreeBadge()}),this.renderer.render(),this.api=this.createApi(),Ge.set(this.renderer.root,this)}collator(){let e=this.store.state.locale.code;return this.collatorCache?.code!==e&&(this.collatorCache={code:e,collator:new Intl.Collator(e,{numeric:!0,sensitivity:"base"})}),this.collatorCache.collator}layoutChanged(){this.renderer.invalidateHeights(),this.renderer.invalidate({header:!0,rows:!0}),this.refreshChoosers()}columnsChanged(){this.rowModel.invalidate(),this.updateRows(),this.refreshSummary(),this.renderer.invalidate({header:!0,rows:!0}),this.refreshChoosers()}display(){return{groupBy:this.options.treeData?yo:this.groupBy,getParentId:this.options.treeData?.getParentId,expanded:this.expanded,defaultExpanded:this.defaultExpanded,detailOpen:this.options.detailRenderer?this.detailOpen:new Set,isMaster:this.options.isRowMaster,lazyChildren:this.options.treeData?.hasChildren?this.lazyChildren:void 0,loading:this.treeLoading,version:this.displayVersion}}updateRows(){let e=!!this.options.pagination,t=this.pivotData??this.store.state.data;this.rowModel.update({...this.store.state,data:t,display:this.display(),page:e?{index:this.page,size:this.pageSize}:null}),e&&this.page>=this.getPageCount()&&(this.page=this.getPageCount()-1,this.rowModel.update({...this.store.state,data:t,display:this.display(),page:{index:this.page,size:this.pageSize}}))}viewRows(){return this.pivotData??this.store.state.data}sourceLeaves(){let e=[],t=n=>{for(let r of n)!r||typeof r!="object"||(Array.isArray(r.children)?t(r.children):(r.id??r.field)&&e.push({id:r.id??r.field,def:r}))};return t(this.sourceDefs),e}getPivot(){let e=this.pivotCfg;if(!e)return null;let t={rows:[...e.rows],columns:[...e.columns],values:e.values.map(n=>({...n}))};return e.totals||(t.totals=!1),t}setPivot(e){if(e&&this.clientOnly("pivot"))return;if(e&&(typeof e!="object"||!Array.isArray(e.rows)||!Array.isArray(e.values))){$("setPivot: expected { rows: string[], values: [...] }");return}if(this.editor.cancel(),!e){if(!this.pivotCfg)return;this.pivotCfg=null,this.pivotData=null,this.columns.setDefs(this.withSelect(this.sourceDefs)),this.savedGroup&&(this.groupBy=this.savedGroup.groupBy,this.expanded=this.savedGroup.expanded,this.defaultExpanded=this.savedGroup.defaultExpanded,this.savedGroup=null),this.afterPivotSwitch();return}let t=new Set(this.sourceLeaves().map(n=>n.id));this.pivotCfg||(this.savedGroup={groupBy:this.groupBy,expanded:this.expanded,defaultExpanded:this.defaultExpanded}),this.pivotCfg=Ot(e,n=>t.has(n)),this.expanded=new Map,this.defaultExpanded=-1,this.rebuildPivot(!1),this.afterPivotSwitch()}afterPivotSwitch(){this.page=0,this.store.set({sort:[],filters:{},range:null,focus:null}),this.rowModel.invalidate(),this.updateRows(),this.displayVersion++,this.updateRows(),this.groupPanel?.refresh(),this.renderer.invalidate({header:!0,rows:!0}),this.refreshChoosers(),this.events.emit("pivotChange",{pivot:this.getPivot()})}rebuildPivot(e=!0){let t=this.pivotCfg;if(!t)return;let n=this.store.state.locale,r=new Map(this.sourceLeaves().map(d=>[d.id,d.def])),o={sum:n.sum,avg:n.avg,min:n.min,max:n.max,count:n.count},i=Hn(this.store.state.data,t,d=>r.get(d),{total:n.total,blank:n.blanks,agg:d=>o[d]??d},n.code);if(this.pivotData=i.rows,this.columns.setDefs(this.withSelect(i.columns)),this.groupBy=i.groupBy,!e)return;let a=d=>!!this.columns.getNode(d),l=this.store.state;(l.sort.some(d=>!a(d.colId))||Object.keys(l.filters).some(d=>!a(d)))&&this.store.set({sort:l.sort.filter(d=>a(d.colId)),filters:Object.fromEntries(Object.entries(l.filters).filter(([d])=>a(d)))}),this.rowModel.invalidate(),this.displayVersion++,this.updateRows(),this.renderer.invalidate({header:!0,rows:!0}),this.refreshChoosers()}getPage(){return this.options.pagination?this.page:0}getPageSize(){return this.options.pagination?this.pageSize:this.rowModel.fullCount()}getPageCount(){return this.options.pagination?Math.max(1,Math.ceil(this.rowModel.fullCount()/this.pageSize)):1}setPage(e){if(!this.options.pagination||!Number.isFinite(e))return;let t=Math.max(0,Math.min(this.getPageCount()-1,Math.floor(e)));t!==this.page&&(this.veto("beforePageChange",{page:t,pageSize:this.pageSize})||(this.page=t,this.pageMoved()))}setPageSize(e){if(!this.options.pagination)return;if(!Number.isInteger(e)||e<=0){$("setPageSize: size must be a positive integer");return}if(e===this.pageSize)return;let t=this.page*this.pageSize;this.veto("beforePageChange",{page:Math.floor(t/e),pageSize:e})||(this.pageSize=e,this.page=Math.floor(t/e),this.pageMoved())}pageMoved(){this.editor.cancel(),this.updateRows(),this.store.state.range&&this.setRange(null);let e=this.rowModel.getRowCount(),t=this.store.state.focus;t&&t.rowIndex>=e&&this.store.set({focus:e?{...t,rowIndex:e-1}:null}),this.renderer.scroller.scrollTop=0,this.finder.refresh(),this.renderer.invalidate({header:!0,rows:!0}),this.emitPage()}emitPage(){this.events.emit("pageChange",{page:this.page,pageSize:this.pageSize,pageCount:this.getPageCount()})}refreshRows(){this.rowModel instanceof Ie&&(this.rowModel.purge(),this.renderer.invalidate({rows:!0}))}serverLoaded(e,t,n){this.destroyed||(this.renderer.invalidate({header:!0,rows:!0}),this.events.emit("rowsLoaded",n===null?{start:e,end:t}:{start:e,end:t,total:n}))}serverFailed(e,t,n){this.destroyed||($(`datasource.getRows failed for rows ${e}\u2013${t}`),this.toast(this.store.state.locale.loadFailed),this.renderer.invalidate({rows:!0}),this.events.emit("rowsLoadFailed",{start:e,end:t,error:n}))}syncScroll(e,t){if(!e||typeof e.setScrollPosition!="function"||e===this.api)return()=>{};let n=new Map,r=a=>`${a.top},${a.left}`,o=(a,l)=>a.on("scroll",d=>{if(n.get(a)===r(d)){n.delete(a);return}l.setScrollPosition(t==="vertical"?{top:d.top}:t==="horizontal"?{left:d.left}:d),n.set(l,r(l.getScrollPosition()))}),i=[o(this.api,e),o(e,this.api)];return()=>{for(let a of i)a()}}veto(e,t){let n=!1;return this.events.emit(e,{...t,cancel:()=>{n=!0}}),n}clientOnly(e){return this.rowModel.server?($(`${e} is not available with a datasource`),!0):!1}displayChanged(){this.displayVersion++,this.updateRows(),this.store.state.range&&this.setRange(null);let e=this.rowModel.getRowCount(),t=this.store.state.focus;t&&t.rowIndex>=e&&this.store.set({focus:e?{...t,rowIndex:e-1}:null}),this.finder.refresh(),this.renderer.invalidate({header:!0,rows:!0})}validGroupBy(e){return Array.isArray(e)?e.length&&this.clientOnly("grouping")?[]:[...new Set(e)].filter(t=>{let n=this.columns.getNode(t);return!n||n.children||I(t)?($(`groupBy: unknown column "${t}"`),!1):!0}):[]}getGroupBy(){return[...this.groupBy]}setGroupBy(e){let t=this.validGroupBy(e);t.join("")!==this.groupBy.join("")&&(this.groupBy=t,this.page=0,this.groupPanel?.refresh(),this.displayChanged(),this.events.emit("groupChange",{groupBy:[...t]}))}isExpandable(e){return!!e&&(e.kind==="group"||!!e.hasChildren)}expandKey(e){return e.group?e.group.key:e.id}loadChildren(e){let t=this.options.treeData,n=e.id;if(this.treeLoading.has(n))return;if(typeof t.loadChildren!="function"){$("treeData.hasChildren needs treeData.loadChildren");return}this.treeLoading.add(n),this.displayChanged();let r=()=>(this.treeLoading.delete(n),!this.destroyed&&this.store.state.data.includes(e.data));Promise.resolve().then(()=>t.loadChildren(e.data)).then(o=>{if(!r())return;let i=ie(Array.isArray(o)?o:[]);this.treeLoaded.add(n),this.expanded.set(n,!0),i.length&&this.replaceData([...this.store.state.data,...i]),this.displayChanged(),this.events.emit("childrenLoaded",{row:e.data,rows:i}),this.events.emit("groupToggle",{key:n,expanded:!0})},o=>{r()&&($(`treeData.loadChildren failed for row "${n}"`),this.displayChanged(),this.events.emit("childrenLoadFailed",{row:e.data,error:o}))})}setGroupExpanded(e,t){let n=this.rowModel.rows().find(o=>this.isExpandable(o)&&this.expandKey(o)===e);if((n?!!(n.group?.expanded??n.expanded):this.expanded.get(e))!==t){if(t&&n&&!n.group&&this.options.treeData&&this.lazyChildren(n.id,n.data)){this.loadChildren(n);return}this.expanded.set(e,t),this.displayChanged(),this.events.emit("groupToggle",{key:e,expanded:t})}}toggleRow(e){let t=this.rowModel.getRow(e);this.isExpandable(t)&&this.setGroupExpanded(this.expandKey(t),!(t.group?.expanded??t.expanded))}expandAll(e=!0){this.expanded.clear(),this.defaultExpanded=e?-1:0,this.displayChanged()}groupAggregate(e,t){let n=this.columns.getNode(t)?.def;if(!e.group||!n?.aggFunc)return;this.aggCache.ver!==this.editVersion&&(this.aggCache={ver:this.editVersion,map:new WeakMap});let r=this.aggCache.map.get(e.group);if(r||this.aggCache.map.set(e.group,r=new Map),!r.has(t)){let o=e.group.rows;try{r.set(t,pe(n.aggFunc,o.map(i=>N(n,i)),o))}catch{$(`aggFunc of column "${t}" threw`),r.set(t,null)}}return r.get(t)}canExpandDetail(e){if(!this.options.detailRenderer)return!1;try{return!this.options.isRowMaster||!!this.options.isRowMaster(e)}catch{return!1}}isDetailExpanded(e){return!!e&&typeof e=="object"&&this.detailOpen.has(this.rowModel.idOf(e))}setDetailExpanded(e,t){if(!e||typeof e!="object"||t&&!this.canExpandDetail(e))return;let n=this.rowModel.idOf(e);this.detailOpen.has(n)!==t&&(t?this.detailOpen.add(n):(this.detailOpen.delete(n),this.renderer.dropDetail(n)),this.displayChanged(),this.events.emit("detailToggle",{row:e,expanded:t}))}canMoveRows(){let e=this.store.state,t=this.options.treeData;return!this.rowModel.server&&!e.sort.length&&!Object.keys(e.filters).length&&!e.quickFilter.trim()&&!this.groupBy.length&&(!t||typeof t.setParentId=="function")}get dragOptions(){let e=this.options.rowDrag;return e&&typeof e=="object"?e:{}}parentOf(e){let t=null;try{t=this.options.treeData.getParentId(e)}catch{t=null}return t==null?null:String(t)}rawParent(e){try{return this.options.treeData.getParentId(e)??null}catch{return null}}idValue(e){let t=this.rowModel.idOf(e);for(let r of this.store.state.data){let o=this.rawParent(r);if(o!==null&&String(o)===t)return o}return this.store.state.data.some(r=>typeof this.rawParent(r)=="number")&&t.trim()!==""&&Number.isFinite(Number(t))?Number(t):t}canDropRow(e,t,n,r=this){if(!this.canMoveRows()||t===e)return!1;if(r===this&&this.options.treeData&&t){let i=this.rowModel.idOf(e),a=new Set;for(let l=this.rowModel.idOf(t);l!==null&&!a.has(l);){if(l===i)return!1;a.add(l);let d=this.rowModel.allNodes().find(c=>c.id===l);l=d?this.parentOf(d.data):null}}let o=this.dragOptions.canDrop;if(!o)return!0;try{return o({row:e,target:t,position:n,fromOtherGrid:r!==this})!==!1}catch{return $("rowDrag.canDrop threw; the drop was refused"),!1}}dropRow(e,t,n="after",r=this){if(this.clientOnly("dropRow")||!e||typeof e!="object")return!1;let o=this.options.treeData;!o&&n==="inside"&&(n="after");let i=this.store.state.data,a=r!==this,l=a?-1:i.indexOf(e);if(!a&&l<0||t&&!i.includes(t)||a&&(!r.canMoveRows()||i.includes(e))||!this.canDropRow(e,t,n,r))return!1;let d=o?this.rawParent(e):null,c=!o||!t?null:n==="inside"?t:this.store.state.data.find(h=>this.rowModel.idOf(h)===this.parentOf(t))??null,u=c?this.idValue(c):null,v=i.filter(h=>h!==e),p=!t||n==="inside"?v.length:v.indexOf(t)+(n==="after"?1:0);v.splice(p,0,e);let R=v.some((h,f)=>h!==i[f]);if(!a&&!R&&String(d??"")===String(u??""))return!1;let w=(h,f)=>{try{o.setParentId(e,h,f)}catch{$("treeData.setParentId threw")}},m=o?this.store.state.data.find(h=>this.rowModel.idOf(h)===this.parentOf(e))??null:null;return a?(r.removeRows([e]),o&&w(u,c),this.addRows([e],p)):(o&&w(u,c),this.replaceData(v),this.history.push({undo:()=>{o&&w(d,m),this.replaceData(i)},redo:()=>{o&&w(u,c),this.replaceData(v)}}),this.events.emit("rowDragEnd",{row:e,fromIndex:l,toIndex:p})),this.events.emit("rowDrop",{row:e,target:t,position:n,fromOtherGrid:a,fromGrid:a?r.api:null}),!0}moveRow(e,t,n=!0){if(this.clientOnly("moveRow")||!this.canMoveRows())return!1;let r=this.store.state.data,o=r.indexOf(e);if(o<0||!Number.isFinite(t))return!1;let i=Math.max(0,Math.min(r.length-1,Math.floor(t)));if(i===o)return!1;let a=[...r];return a.splice(o,1),a.splice(i,0,e),this.replaceData(a),n&&this.history.push({undo:()=>this.moveRow(e,o,!1),redo:()=>this.moveRow(e,i,!1)}),this.events.emit("rowDragEnd",{row:e,fromIndex:o,toIndex:i}),!0}setFont(e){let t=this.font.size;e.size!==void 0&&(typeof e.size=="number"&&e.size>0?t=e.size:$("setFont: size must be a positive number"));let n=e.family===void 0?this.font.family:e.family||null;this.font={size:t,family:n};let r=t??Zn;this.options.rowHeight==null&&(this.renderer.opts.rowHeight=Xn(r)),this.options.headerHeight==null&&(this.renderer.opts.headerHeight=Yn(r)),this.renderer.applyFont(t,n),this.renderer.invalidateHeights(),this.menu.close(),this.layoutChanged()}applyFontTo(e){this.font.size&&e.style.setProperty("--fg-font-size",`${this.font.size}px`),this.font.family&&e.style.setProperty("--fg-font",this.font.family)}summary(){return this.summaryOpts&&this.summaryOpts.rows?.length?{opts:this.summaryOpts,values:this.summaryValues}:null}setSummary(e){if(e&&!Array.isArray(e.rows)){$("setSummary: summary.rows must be an array");return}this.summaryOpts=e,this.refreshSummary(),this.renderer.invalidate({header:!0,rows:!0})}refreshSummary(){let e=this.summaryOpts;if(!e?.rows?.length){this.summaryValues=[];return}let t=e.scope??"filtered",n=t==="all"?this.rowModel.allNodes().map(r=>r.data):t==="selected"?this.selectedRows():this.rowModel.dataRows().map(r=>r.data);this.summaryValues=un(e.rows,n,r=>this.columns.getNode(r)?.def)}dataColumns(){return this.columns.displayed().filter(e=>!I(e.id))}validRange(e){if(!e||this.options.rangeSelection===!1)return null;let t=this.rowModel.getRowCount(),n=r=>!!r&&!I(r.colId)&&!!this.columns.getColumn(r.colId)&&r.rowIndex>=0&&r.rowIndex<t;return n(e.start)&&n(e.end)?{start:{...e.start},end:{...e.end}}:null}setRange(e,t=!1){let n=this.validRange(e),r=t||!this.store.state.extraRanges.length?this.store.state.extraRanges:[],o=this.store.state.range;JSON.stringify(o)===JSON.stringify(n)&&r===this.store.state.extraRanges||(this.store.set({range:n,extraRanges:r}),this.events.emit("rangeChange",{range:n&&{start:{...n.start},end:{...n.end}}}))}addRange(e){let{range:t,focus:n}=this.store.state,r=this.validRange(t??(n?{start:n,end:n}:null));r&&this.store.set({extraRanges:[...this.store.state.extraRanges,r]}),this.setRange(e,!0)}getRanges(){let e=[...this.store.state.extraRanges];return this.store.state.range&&e.push(this.store.state.range),e.map(t=>({start:{...t.start},end:{...t.end}}))}setRanges(e){let t=(Array.isArray(e)?e:[]).map(n=>this.validRange(n)).filter(n=>!!n);this.store.set({extraRanges:t.slice(0,-1)}),this.setRange(t[t.length-1]??null,!0)}boundsOf(e){if(!e)return null;let t=this.columns.getColumn(e.start.colId),n=this.columns.getColumn(e.end.colId);return!t||!n?null:Se({start:{rowIndex:e.start.rowIndex,colIndex:t.index},end:{rowIndex:e.end.rowIndex,colIndex:n.index}})}rangeBounds(){return this.boundsOf(this.store.state.range)}allRangeBounds(){return[...this.store.state.extraRanges,this.store.state.range].map(e=>this.boundsOf(e)).filter(e=>!!e)}rangeContains(e,t){let n=this.columns.getColumn(t);return!!n&&this.allRangeBounds().some(r=>xn(r,e,n.index))}selectAllCells(){let e=this.dataColumns(),t=this.rowModel.getRowCount();!e.length||!t||(this.store.state.focus||this.setFocus(0,e[0].id),this.setRange({start:{rowIndex:0,colId:e[0].id},end:{rowIndex:t-1,colId:e[e.length-1].id}}))}selectionTSV(e,t=!1){let n=this.store.state.locale.code,r=this.columns.displayed(),o=t?null:this.rangeBounds(),i=t,a,l,d=t?[]:this.allRangeBounds();if(d.length>1){let u=d.every(p=>p.c1===d[0].c1&&p.c2===d[0].c2),v=d.every(p=>p.r1===d[0].r1&&p.r2===d[0].r2);if(u||v){let p=[...d].sort((m,h)=>u?m.r1-h.r1:m.c1-h.c1),R=p.map(m=>this.rangeMatrix(m)),w=u?R.flat():R[0].map((m,h)=>R.flatMap(f=>f[h]??[]));return e&&w.unshift((u?p.slice(0,1):p).flatMap(m=>this.rangeHeaders(m))),Rt(w)}}if(o){a=[];for(let u=o.r1;u<=o.r2;u++){let v=this.rowModel.getRow(u);v.kind||a.push(v.data)}l=r.slice(o.c1,o.c2+1).filter(u=>!I(u.id))}else if(i){let u=this.store.state.selected;a=this.rowModel.dataRows().filter(v=>u.has(v.id)).map(v=>v.data),l=this.dataColumns()}else{let u=this.store.state.focus,v=u&&this.columns.getColumn(u.colId),p=u&&this.rowModel.getRow(u.rowIndex);if(!v||!p||p.kind||I(v.id))return"";a=[p.data],l=[v]}let c=a.map(u=>l.map(v=>this.copyCell(v.def,u,n)));return e&&c.unshift(l.map(u=>u.def.header??u.def.field??u.id)),Rt(c)}rangeHeaders(e){return this.columns.displayed().slice(e.c1,e.c2+1).filter(t=>!I(t.id)).map(t=>t.def.header??t.def.field??t.id)}rangeMatrix(e){let t=this.columns.displayed().slice(e.c1,e.c2+1).filter(o=>!I(o.id)),n=this.store.state.locale.code,r=[];for(let o=e.r1;o<=e.r2;o++){let i=this.rowModel.getRow(o);i&&!i.kind&&r.push(t.map(a=>this.copyCell(a.def,i.data,n)))}return r}copyCell(e,t,n){let r=N(e,t),o=e.copyable;if(o===!1)return"";if(typeof o=="function"){let i=!1;try{i=o({value:r,row:t,column:e})!==!1}catch{i=!1}if(!i)return""}return Ze(e,r,n)}copyToClipboard(e,t=!1){let n=this.selectionTSV(e,t);if(n&&typeof navigator<"u"&&navigator.clipboard?.writeText)try{navigator.clipboard.writeText(n)?.catch?.(()=>{})}catch{}return n}pasteText(e){let t=yn(e),n={changed:0,skipped:0};if(!t.length)return n;let r=this.columns.displayed(),o=this.rowModel.getRowCount(),i=this.rangeBounds(),a=this.store.state.focus,l=a&&this.columns.getColumn(a.colId),d,c;if(i)d=i.r1,c=i.c1;else if(a&&l&&!I(l.id))d=a.rowIndex,c=l.index;else return n;let u=[],v=t.length===1&&t[0].length===1,p=v&&i?i.r2-i.r1+1:t.length,R=v&&i?i.c2-i.c1+1:Math.max(...t.map(w=>w.length));for(let w=0;w<p;w++){let m=d+w;if(m>=o)break;let h=this.rowModel.getRow(m);if(!h.kind)for(let f=0;f<R;f++){let C=r[c+f];if(!C)break;if(I(C.id))continue;let y=v&&i?t[0][0]:t[w]?.[f];if(y===void 0)continue;let S=C.def;if(!S.field||!te(S,h.data,m)){n.skipped++;continue}let x=h.data[S.field],g=this.acceptText(S,h.data,y,x);if(!g.ok){n.skipped++;continue}this.writeCell(u,h.data,S.field,C.id,m,g.value)&&n.changed++}}return this.endCellTx(u),this.events.emit("paste",{...n}),n}acceptText(e,t,n,r){let o,i=e.editor;if(i&&typeof i=="object"&&i.type==="select"){let a=(typeof i.options=="function"?i.options(t):i.options)??[],l=n.trim().toLowerCase(),d=a.map(c=>c!==null&&typeof c=="object"&&"value"in c?c:{value:c,label:String(c),disabled:!1}).find(c=>String(c.value).toLowerCase()===l||(c.label??"").toLowerCase()===l);if(!d||d.disabled)return{ok:!1};o=d.value}else if(e.formulas&&fe(n.trim()))o=n.trim();else{let a=Je(e,n,r);if(!a.ok)return a;o=a.value}return this.cellError(e,t,o)!==null?{ok:!1}:{ok:!0,value:o}}cellError(e,t,n){let r=this.store.state.locale;if(e.required&&F(n))return r.required;if(e.unique&&e.field&&!F(n)){let o=n instanceof Date?n.getTime():String(n),i=e.field;if(this.store.state.data.some(a=>{if(a===t)return!1;let l=a[i];return!F(l)&&(l instanceof Date?l.getTime():String(l))===o}))return r.duplicate}if(e.validate){let o;try{o=e.validate(n,t)}catch{o=r.invalidValue}if(o!==!0)return typeof o=="string"&&o?o:r.invalidValue}return null}validateAll(){let e=[],t=this.columns.getState().map(n=>({id:n.colId,def:this.columns.getNode(n.colId).def})).filter(n=>n.def.field&&n.def.editable&&(n.def.required||n.def.unique||n.def.validate));return this.store.state.data.forEach((n,r)=>{let o=this.rowModel.idOf(n),i=this.rowModel.indexOfId(o);for(let a of t){if(!te(a.def,n,i<0?r:i))continue;let l=this.cellError(a.def,n,n[a.def.field]);l!==null&&e.push({row:n,rowIndex:i,colId:a.id,message:l})}}),e}mergeSpans(){if(this.rowModel.server||!this.columns.displayed().some(o=>o.def.merge||o.def.rowSpan))return xo;let e=this.rowModel.rows(),t=this.editVersion*1e6+this.columns.displayed().length;if(this.spanCache&&this.spanCache.rows===e&&this.spanCache.ver===t)return this.spanCache.spans;let n=new Map,r=this.columns.displayed().filter(o=>o.def.merge||o.def.rowSpan);if(r.length&&!e.some(o=>o.kind)){let o=e.map(i=>i.data);for(let i of r)n.set(i.id,He(o,i.def))}return this.spanCache={rows:e,ver:t,spans:n},n}rangeAggregates(){let e=this.allRangeBounds();if(!e.length)return null;let t=this.columns.displayed(),n={cells:0,count:0,numbers:0,sum:0,min:1/0,max:-1/0},r=e.length>1?new Set:null;for(let o of e)for(let i=o.r1;i<=o.r2;i++){let a=this.rowModel.getRow(i);if(!a||a.kind)continue;let l=a.data;for(let d of t.slice(o.c1,o.c2+1)){if(I(d.id))continue;if(r){let u=`${i},${d.index}`;if(r.has(u))continue;r.add(u)}n.cells++;let c=N(d.def,l);if(!F(c)&&(n.count++,typeof c=="number"||d.def.type==="number"&&!Number.isNaN(Number(c)))){let u=Number(c);n.numbers++,n.sum+=u,u<n.min&&(n.min=u),u>n.max&&(n.max=u)}}}return n}fillRange(e){let t=this.rangeBounds()??(()=>{let u=this.store.state.focus,v=u&&this.columns.getColumn(u.colId);return u&&v&&!I(v.id)?{r1:u.rowIndex,r2:u.rowIndex,c1:v.index,c2:v.index}:null})(),n=this.columns.getColumn(e.start.colId),r=this.columns.getColumn(e.end.colId);if(!t||!n||!r)return;let o=Se({start:{rowIndex:e.start.rowIndex,colIndex:n.index},end:{rowIndex:e.end.rowIndex,colIndex:r.index}}),i=this.rowModel.getRowCount();o.r1=Math.max(0,o.r1),o.r2=Math.min(i-1,o.r2);let a=this.columns.displayed(),l=[],d=(u,v,p)=>{let R=a[v],w=this.rowModel.getRow(u),m=R?.def;!w||w.kind||!m?.field||I(R.id)||!te(m,w.data,u)||this.cellError(m,w.data,p)===null&&this.writeCell(l,w.data,m.field,R.id,u,p)},c=(u,v)=>N(a[v].def,this.rowModel.getRow(u).data);if(o.r1<t.r1||o.r2>t.r2)for(let u=t.c1;u<=t.c2;u++){let v=[],p=[];for(let R=t.r1;R<=t.r2;R++)v.push(c(R,u));for(let R=t.r2;R>=t.r1;R--)p.push(c(R,u));ke(v,o.r2-t.r2).forEach((R,w)=>d(t.r2+1+w,u,R)),ke(p,t.r1-o.r1).forEach((R,w)=>d(t.r1-1-w,u,R))}else if(o.c1<t.c1||o.c2>t.c2)for(let u=t.r1;u<=t.r2;u++){let v=[],p=[];for(let R=t.c1;R<=t.c2;R++)v.push(c(u,R));for(let R=t.c2;R>=t.c1;R--)p.push(c(u,R));ke(v,o.c2-t.c2).forEach((R,w)=>d(u,t.c2+1+w,R)),ke(p,t.c1-o.c1).forEach((R,w)=>d(u,t.c1-1-w,R))}else return;this.endCellTx(l),this.setRange({start:{rowIndex:o.r1,colId:a[o.c1].id},end:{rowIndex:o.r2,colId:a[o.c2].id}})}setPinnedRows(e){e.top&&(this.pinnedRows.top=ie(e.top)),e.bottom&&(this.pinnedRows.bottom=ie(e.bottom)),this.renderer.invalidate({rows:!0})}writeCell(e,t,n,r,o,i){let a=t[n];return Object.is(a,i)||this.veto("beforeCellChange",{row:t,rowIndex:o,colId:r,oldValue:a,newValue:i})?!1:(this.tracker.beforeChange(t),t[n]=i,e.push({row:t,field:n,colId:r,oldValue:a,newValue:i}),this.events.emit("cellValueChanged",{row:t,rowIndex:o,colId:r,oldValue:a,newValue:i}),!0)}endCellTx(e){if(!e.length)return;let t=(n,r)=>{for(let o of n){let i=o.row[o.field];o.row[o.field]=o[r],this.events.emit("cellValueChanged",{row:o.row,rowIndex:this.rowModel.indexOfId(this.rowModel.idOf(o.row)),colId:o.colId,oldValue:i,newValue:o[r]})}this.afterDataEdit()};this.history.push({undo:()=>t([...e].reverse(),"oldValue"),redo:()=>t(e,"newValue")}),this.afterDataEdit()}afterDataEdit(){this.renderer.invalidateHeights(),this.editVersion++,this.refreshSummary(),this.renderer.invalidate({rows:!0})}applyEdit(e,t,n){let r=this.rowModel.getRow(e),o=this.columns.getColumn(t)?.def;if(!r||!o?.field)return;let i=[];this.writeCell(i,r.data,o.field,t,e,n),this.endCellTx(i)}clearCells(){let e=this.columns.displayed(),t=this.allRangeBounds(),n=this.store.state.focus,r=n?this.columns.getColumn(n.colId)?.index:void 0,o=t.length?t:n&&r!==void 0?[{r1:n.rowIndex,r2:n.rowIndex,c1:r,c2:r}]:[];if(!o.length)return;let i=[];for(let a of o)for(let l=a.r1;l<=a.r2;l++){let d=this.rowModel.getRow(l);for(let c=a.c1;c<=a.c2;c++){let u=e[c]?.def;d&&!d.kind&&u?.field&&te(u,d.data,l)&&this.writeCell(i,d.data,u.field,e[c].id,l,null)}}this.endCellTx(i)}replaceData(e){this.store.set({data:e});let t=new Set(this.rowModel.allNodes().map(i=>i.id)),n=this.store.state.selected;[...n].some(i=>!t.has(i))&&this.setSelected(new Set([...n].filter(i=>t.has(i))));let r=this.rowModel.getRowCount(),o=this.store.state.focus;o&&o.rowIndex>=r&&this.store.set({focus:r?{...o,rowIndex:r-1}:null})}addRows(e,t,n=!0){if(this.clientOnly("addRows"))return[];let r=ie(Array.isArray(e)?e:[]);if(!r.length)return[];let o=[...this.store.state.data],i=t===void 0?o.length:Math.max(0,Math.min(o.length,t));o.splice(i,0,...r);for(let a of r)this.tracker.created.add(a);return this.replaceData(o),n&&this.history.push({undo:()=>this.removeRows(r,!1),redo:()=>this.addRows(r,i,!1)}),this.events.emit("rowsAdded",{rows:[...r]}),r}removeRows(e,t=!0){if(this.clientOnly("removeRows"))return[];let n=this.store.state.data,r=typeof e=="function"?e:(l=>d=>l.has(d))(new Set(e)),o=[];if(n.forEach((l,d)=>{let c=!1;try{c=!!r(l)}catch{c=!1}c&&o.push({row:l,index:d})}),!o.length)return[];let i=new Set(o.map(l=>l.row)),a=new Set(o.filter(l=>this.tracker.created.has(l.row)).map(l=>l.row));for(let{row:l,index:d}of o)a.has(l)?this.tracker.created.delete(l):this.tracker.deleted.set(l,d);return this.replaceData(n.filter(l=>!i.has(l))),t&&this.history.push({undo:()=>{let l=[...this.store.state.data];for(let{row:d,index:c}of o)l.splice(Math.min(c,l.length),0,d),this.tracker.deleted.delete(d),a.has(d)&&this.tracker.created.add(d);this.replaceData(l)},redo:()=>this.removeRows([...i],!1)}),this.events.emit("rowsRemoved",{rows:o.map(l=>l.row)}),o.map(l=>l.row)}trackedFields(){let e=[],t=n=>{for(let r of n)r.children?t(r.children):r.def.field&&!I(r.id)&&e.push({field:r.def.field,colId:r.id})};return t(this.columns.roots()),e}getChanges(){let e=this.trackedFields(),t=[];for(let[n,r]of this.tracker.originals)if(!this.tracker.deleted.has(n))for(let o of this.tracker.diff(n,e.map(i=>i.field)))t.push({row:n,colId:e.find(i=>i.field===o).colId,oldValue:r[o],newValue:n[o]});return t}getModifiedRows(){let e=this.trackedFields().map(n=>n.field),t=this.store.state.data;return{created:t.filter(n=>this.tracker.created.has(n)),updated:t.filter(n=>this.tracker.originals.has(n)&&this.tracker.diff(n,e).length>0),deleted:[...this.tracker.deleted.keys()]}}hasChanges(){let e=this.getModifiedRows();return e.created.length+e.updated.length+e.deleted.length>0}commitChanges(){this.tracker.reset(),this.renderer.invalidate({rows:!0})}revertChanges(){this.editor.cancel();for(let[n,r]of this.tracker.originals)Object.assign(n,r);let e=this.store.state.data.filter(n=>!this.tracker.created.has(n)),t=[...this.tracker.deleted.entries()].sort((n,r)=>n[1]-r[1]);e=[...e];for(let[n,r]of t)e.splice(Math.min(r,e.length),0,n);this.tracker.reset(),this.history.clear(),this.replaceData(e),this.afterDataEdit()}undo(){this.editor.cancel(),this.history.undo()}redo(){this.editor.cancel(),this.history.redo()}toast(e){let t=b("div","fg-toast",{role:"status"});t.textContent=e,this.renderer.root.append(t),setTimeout(()=>t.remove(),3500)}refreshChoosers(){this.chooser.refresh(),this.sideBar?.refresh()}setColumnsVisible(e,t){let n=[];for(let r of e){let o=this.columns.getNode(r);!o||o.children||o.hide===!t||(this.columns.setHide(r,!t),n.push(r))}if(n.length){this.columnsChanged();for(let r of n)this.events.emit("columnVisible",{colId:r,visible:t})}}autoSize(e){let t=(e?e.map(l=>this.columns.getColumn(l)):this.columns.displayed()).filter(l=>!!l&&Pe(l.def)),{first:n,last:r}=this.renderer.renderedRange(),o=this.store.state.locale.code,i=66,a=24;for(let l of t){let d=this.renderer.measureText(l.def.header??l.def.field??"",!0)+i,c=G(l.def,o);for(let v=n;v<=r;v++){let p=this.rowModel.getRow(v);p&&(d=Math.max(d,this.renderer.measureText(c(N(l.def,p.data)),!1)+a))}let u=this.columns.setWidth(l.id,Math.ceil(d));this.events.emit("columnResize",{colId:l.id,width:u})}this.layoutChanged()}resetColumns(){this.columns.reset(),this.columnsChanged()}setSort(e){let t=e.filter(n=>{let r=this.columns.getNode(n.colId);return!r||r.children?($(`setSort: unknown column "${n.colId}"`),!1):n.dir==="asc"||n.dir==="desc"});this.veto("beforeSort",{sort:t.map(n=>({...n}))})||(this.store.set({sort:t}),this.events.emit("sortChange",{sort:[...t]}))}toggleSort(e,t){let n=this.store.state.sort,r=n.find(a=>a.colId===e),o=r?r.dir==="asc"?"desc":null:"asc",i;t?o?r?i=n.map(a=>a.colId===e?{colId:e,dir:o}:a):i=[...n,{colId:e,dir:o}]:i=n.filter(a=>a.colId!==e):i=o?[{colId:e,dir:o}]:[],this.setSort(i)}setFilter(e,t){let n=this.columns.getNode(e);if(!n||n.children){$(`setFilter: unknown column "${e}"`);return}if(this.veto("beforeFilter",{colId:e,model:t}))return;let r={...this.store.state.filters};t?r[e]=t:delete r[e],this.store.set({filters:r}),this.events.emit("filterChange",{filters:{...r}})}setPinned(e,t){this.columns.setPinned(e,t),this.layoutChanged()}setFocus(e,t){let n=this.store.state.focus;n&&n.rowIndex===e&&n.colId===t||(this.store.set({focus:{rowIndex:e,colId:t}}),this.events.emit("focusChange",{rowIndex:e,colId:t}))}setSelected(e,t=this.store.state.anchorId){this.store.set({selected:e,anchorId:t}),this.events.emit("selectionChange",{selected:this.selectedRows()})}rowSelectable(e){let t=this.options.isRowSelectable;if(!t)return!0;try{return!!t(e)}catch{return!1}}selectFromClick(e,t,n){let r=this.options.rowSelection;if(!r||e<0||e>=this.rowModel.getRowCount())return;let o=this.rowModel.getRow(e);if(o.kind||!this.rowSelectable(o.data))return;let i=jn({selected:this.store.state.selected,anchorIndex:this.anchorIndex(),mode:r,index:e,idAt:a=>this.rowModel.getRow(a).id,toggle:t,range:n});if(this.rowModel.rows()!==this.rowModel.dataRows()||this.options.isRowSelectable)for(let a of i.selected){if(this.store.state.selected.has(a))continue;let l=this.rowModel.indexOfId(a),d=l>=0?this.rowModel.getRow(l):null;d&&(d.kind||!this.rowSelectable(d.data))&&i.selected.delete(a)}this.setSelected(i.selected,this.rowModel.getRow(i.anchorIndex)?.id??null)}anchorIndex(){let e=this.store.state.anchorId;if(e==null)return null;let t=this.rowModel.indexOfId(e);return t<0?null:t}selectableRows(){let e=this.rowModel.dataRows();return this.options.isRowSelectable?e.filter(t=>this.rowSelectable(t.data)):e}toggleSelectAll(){let e=this.selectableRows(),t=this.store.state.selected,n=e.length>0&&e.every(o=>t.has(o.id)),r=new Set(t);for(let o of e)n?r.delete(o.id):r.add(o.id);this.setSelected(r)}selectedRows(){let e=this.store.state.selected;return e.size?this.rowModel.allNodes().filter(t=>e.has(t.id)).map(t=>t.data):[]}withSelect(e){let t=[];return this.options.rowDrag&&t.push(tn),this.options.rowSelection&&t.push(en),[...t,...e]}setData(e,t){if(this.clientOnly("setData"))return;if(!Array.isArray(e)){$("setData: rows must be an array");return}this.editor.cancel(),this.tracker.reset(),this.history.clear(),this.detailOpen.clear(),this.treeLoaded.clear(),this.treeLoading.clear(),this.renderer.dropDetail(),this.store.set({data:ie(e)}),t?.scrollToTop&&this.renderer.setScroll({top:0,left:0});let n=this.store.state.selected;if(n.size)if(this.options.getRowId){let i=new Set(this.rowModel.allNodes().map(l=>l.id)),a=new Set([...n].filter(l=>i.has(l)));a.size!==n.size&&this.setSelected(a)}else this.setSelected(new Set,null);let r=this.rowModel.getRowCount(),o=this.store.state.focus;o&&o.rowIndex>=r&&this.store.set({focus:r?{...o,rowIndex:r-1}:null})}setColumns(e){if(!Array.isArray(e)){$("setColumns: columns must be an array");return}if(this.menu.close(),this.sourceDefs=e,this.pivotCfg){this.rebuildPivot();return}this.columns.setDefs(this.withSelect(e));let t=r=>!!this.columns.getNode(r),n=this.groupBy.filter(t);n.length!==this.groupBy.length&&(this.groupBy=n,this.groupPanel?.refresh(),this.events.emit("groupChange",{groupBy:[...n]})),this.store.set({sort:this.store.state.sort.filter(r=>t(r.colId)),filters:Object.fromEntries(Object.entries(this.store.state.filters).filter(([r])=>t(r))),focus:null}),this.columnsChanged()}onChange(e){let t=(...r)=>r.some(o=>e.includes(o));this.pivotCfg&&t("data","locale")&&this.rebuildPivot(!1),t("locale")&&(this.menu.close(),this.chooser.close(),this.sideBar?.refresh(),this.rowModel.invalidate());let n=t("sort","filters","quickFilter")&&this.page!==0;n&&(this.page=0),t("data","sort","filters","quickFilter","locale")&&this.updateRows(),n&&this.emitPage(),t("data","sort","filters","quickFilter")&&this.store.state.range&&this.setRange(null),t("data","sort","filters","quickFilter","locale")&&this.finder.refresh(),(t("data","filters","quickFilter","locale")||t("selected")&&this.summaryOpts?.scope==="selected")&&this.refreshSummary(),t("locale")&&this.groupPanel?.refresh(),t("filters")&&this.sideBar?.refresh(),t("theme")&&this.renderer.applyTheme(),this.renderer.invalidate({header:t("sort","filters","quickFilter","locale","selected","data"),rows:t("data","sort","filters","quickFilter","locale")})}createApi(){let e=t=>((...n)=>{if(this.destroyed){$("API called after destroy()");return}return t(...n)});return{setData:e((t,n)=>this.setData(t,n)),getData:e(()=>this.store.state.data),setColumns:e(t=>this.setColumns(t)),getColumnState:e(()=>this.columns.getState()),applyColumnState:e(t=>{this.columns.applyState(t),this.columnsChanged()}),setSort:e(t=>this.setSort(t)),getSort:e(()=>[...this.store.state.sort]),setFilter:e((t,n)=>this.setFilter(t,n)),getFilterModel:e(()=>({...this.store.state.filters})),setQuickFilter:e(t=>this.store.set({quickFilter:t??""})),getSelectedRows:e(()=>this.selectedRows()),selectAll:e(()=>this.setSelected(new Set([...this.store.state.selected,...this.selectableRows().map(t=>t.id)]))),deselectAll:e(()=>this.setSelected(new Set,null)),getDisplayedRowCount:e(()=>this.rowModel.getRowCount()),scrollToRow:e(t=>this.renderer.scrollToRow(t)),validate:e(()=>this.validateAll()),getScrollPosition:e(()=>this.renderer.getScroll()),setScrollPosition:e(t=>this.renderer.setScroll(t??{})),syncScroll:e((t,n="both")=>this.syncScroll(t,n)),setTheme:e(t=>this.store.set({theme:t})),setLocale:e(t=>this.store.set({locale:De(t)})),setFont:e(t=>this.setFont(t)),setColumnVisible:e((t,n)=>this.setColumnsVisible([t],n)),autoSizeColumns:e(t=>this.autoSize(t)),resetColumnState:e(()=>this.resetColumns()),openColumnChooser:e(()=>this.chooser.open()),closeColumnChooser:e(()=>this.chooser.close()),toggleSideBar:e((t,n)=>this.sideBar?.toggle(t,n)),setSummary:e(t=>this.setSummary(t)),getSummaryValues:e(()=>this.summaryValues.map(t=>({...t}))),getRange:e(()=>{let t=this.store.state.range;return t&&{start:{...t.start},end:{...t.end}}}),setRange:e(t=>this.setRange(t)),getRanges:e(()=>this.getRanges()),setRanges:e(t=>this.setRanges(t)),copySelection:e(t=>this.copyToClipboard(!!t?.headers,!!t?.rows)),pasteText:e(t=>this.pasteText(t)),startEdit:e((t,n)=>this.editor.start(t,n)),stopEdit:e(t=>t?this.editor.cancel():void this.editor.commit(null)),addRows:e((t,n)=>this.addRows(t,n)),removeRows:e(t=>this.removeRows(t)),removeSelectedRows:e(()=>this.removeRows(this.selectedRows())),getModifiedRows:e(()=>this.getModifiedRows()),getChanges:e(()=>this.getChanges()),hasChanges:e(()=>this.hasChanges()),commitChanges:e(()=>this.commitChanges()),revertChanges:e(()=>this.revertChanges()),undo:e(()=>this.undo()),redo:e(()=>this.redo()),canUndo:e(()=>this.history.canUndo()),canRedo:e(()=>this.history.canRedo()),fillRange:e(t=>this.fillRange(t)),setPinnedRows:e(t=>this.setPinnedRows(t)),find:e(t=>this.finder.find(t)),findNext:e(()=>this.finder.next()),findPrevious:e(()=>this.finder.previous()),clearFind:e(()=>this.finder.clear()),setGroupBy:e(t=>this.setGroupBy(t)),getGroupBy:e(()=>this.getGroupBy()),setGroupExpanded:e((t,n)=>this.setGroupExpanded(t,n)),expandAll:e(()=>this.expandAll(!0)),collapseAll:e(()=>this.expandAll(!1)),setDetailExpanded:e((t,n)=>this.setDetailExpanded(t,n)),isDetailExpanded:e(t=>this.isDetailExpanded(t)),moveRow:e((t,n)=>this.moveRow(t,n)),dropRow:e((t,n,r)=>this.dropRow(t,n,r)),setPage:e(t=>this.setPage(t)),getPage:e(()=>this.getPage()),getPageCount:e(()=>this.getPageCount()),setPageSize:e(t=>this.setPageSize(t)),getPageSize:e(()=>this.getPageSize()),refreshRows:e(()=>this.refreshRows()),setPivot:e(t=>this.setPivot(t)),getPivot:e(()=>this.getPivot()),createChart:e(t=>this.charts.create(t)),getCsv:e(t=>$t(this,t)),exportCsv:e((t="export.csv",n)=>At(t,["\uFEFF",$t(this,n)],"text/csv;charset=utf-8")),getXlsx:e(t=>Pt(this,t)),exportXlsx:e((t="export.xlsx",n)=>At(t,[Pt(this,n)],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")),importFile:e((t,n)=>$n(this,t,n)),on:e((t,n)=>this.events.on(t,n)),destroy:()=>this.destroy()}}destroy(){if(!this.destroyed){this.destroyed=!0,Ge.delete(this.renderer.root);for(let e of this.disposers)e();this.renderer.destroy(),this.events.clear()}}};function Co(s,e){return new qt(s,e).api}var Ro={en:ee,ko:Jt,"zh-CN":Qt,ja:Zt,es:Xt,fr:Yt,de:jt};for(let s of Object.values(Ro))ht(s);export{Co as createGrid,ee as en,Ro as locales,Mt as parseCsv,Dt as readXlsx,ht as registerLocale,Ht as renderChart,De as resolveLocale,fo as setLicenseKey,Un as verifyLicense,at as version,It as writeXlsx};
|
package/dist/cdn/freegrid.min.js
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
`){n.push(r),t.push(n),n=[],r="",a=!0,o+=l==="\r"&&s[o+1]===`
|
|
4
4
|
`?2:1;continue}r+=l,a=!1,o++}return(r!==""||n.length||!a)&&(n.push(r),t.push(n)),t}function nt(s,e,t){var n;if(O(e))return"";switch(s.type){case"number":{let r=typeof e=="number"?e:Number(e);return Number.isNaN(r)?String(e):String(r)}case"date":return(n=Y(e))!=null?n:String(e);case"boolean":return e===!0?"TRUE":e===!1?"FALSE":String(e);default:return K(s,t)(e)}}var Vr=new Set(["true","1","y","yes","\uC608","o","on"]),Ur=new Set(["false","0","n","no","\uC544\uB2C8\uC624","x","off"]);function qr(s){let e=s.trim();if(!e)return{ok:!0,value:null};let t=!1;/^\(.*\)$/.test(e)&&(t=!0,e=e.slice(1,-1));let n=e.endsWith("%");if(n&&(e=e.slice(0,-1)),e=e.replace(/[\s,₩$€£¥원]/g,""),!/^[-+]?(\d+\.?\d*|\.\d+)(e[-+]?\d+)?$/i.test(e))return{ok:!1};let r=Number(e);return n&&(r/=100),t&&(r=-r),{ok:!0,value:Math.round(r*1e12)/1e12}}function Rn(s,e,t){let n=new Date(s,e-1,t);return n.getFullYear()===s&&n.getMonth()===e-1&&n.getDate()===t?n:null}function Kr(s,e){let t=s.trim();if(!t)return{ok:!0,value:null};let n=null,r=/^(\d{4})\s*[-./년]\s*(\d{1,2})\s*[-./월]\s*(\d{1,2})\s*[.일]?$/.exec(t);return r?n=Rn(+r[1],+r[2],+r[3]):(r=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(t))?n=Rn(+r[3],+r[1],+r[2]):/^\d{4}-\d{2}-\d{2}T/.test(t)&&(n=te(t)),n?{ok:!0,value:e instanceof Date?n:Y(n)}:{ok:!1}}function rt(s,e,t){switch(s.type){case"number":return qr(e);case"date":return Kr(e,t);case"boolean":{let n=e.trim().toLowerCase();return n?Vr.has(n)?{ok:!0,value:!0}:Ur.has(n)?{ok:!0,value:!1}:{ok:!1}:{ok:!0,value:null}}default:return{ok:!0,value:e}}}var _r=s=>s.map(e=>e!==null&&typeof e=="object"&&"value"in e?e:{value:e,label:String(e),disabled:!1}),ce=s=>String(s).padStart(2,"0");function Wr(s){let e=s instanceof Date?s:typeof s=="string"&&s?new Date(s):null;return!e||Number.isNaN(e.getTime())?"":`${e.getFullYear()}-${ce(e.getMonth()+1)}-${ce(e.getDate())}T${ce(e.getHours())}:${ce(e.getMinutes())}`}function jr(s){if(s instanceof Date)return`${ce(s.getHours())}:${ce(s.getMinutes())}`;let e=typeof s=="string"?/(\d{1,2}):(\d{2})/.exec(s):null;return e?`${ce(Number(e[1]))}:${e[2]}`:""}var ot=class{constructor(e){this.grid=e;this.cur=null}get active(){return this.cur&&{rowIndex:this.cur.rowIndex,colId:this.cur.colId}}canEdit(e,t){if(P(t))return!1;let n=this.grid.columns.getColumn(t);if(!(n!=null&&n.def.field)||e<0||e>=this.grid.rowModel.getRowCount())return!1;let r=this.grid.rowModel.getRow(e);return!r.kind&&ne(n.def,r.data,e)}start(e,t,n){var S,E,m,R,I;if(this.cur&&this.commit(null),!this.canEdit(e,t))return!1;let{grid:r}=this;if(r.veto("beforeEdit",{row:r.rowModel.getRow(e).data,rowIndex:e,colId:t}))return!1;let{renderer:o}=r,i=r.columns.getColumn(t),a=i.def,l=r.rowModel.getRow(e).data,d=l[a.field];r.setFocus(e,t),o.ensureVisible(e,t),o.render();let c=o.root.querySelector(`.fg-row[data-row="${e}"] .fg-cell[data-col="${CSS.escape(t)}"]`),u=o.root.getBoundingClientRect(),f=c==null?void 0:c.getBoundingClientRect(),p=k("div","fg-editor");p.style.left=`${((S=f==null?void 0:f.left)!=null?S:u.left)-u.left}px`,p.style.top=`${((E=f==null?void 0:f.top)!=null?E:u.top)-u.top}px`,p.style.width=`${(f==null?void 0:f.width)||i.width}px`,p.style.height=`${(f==null?void 0:f.height)||o.opts.rowHeight}px`;let x,M,v=()=>{},h=a.editor;if(typeof h=="function"){let b=h({value:d,row:l,column:a,initialText:n});x=b.el,M=()=>({value:b.getValue()}),v=()=>{var L;return(L=b.destroy)==null?void 0:L.call(b)},p.append(x),queueMicrotask(()=>{var L;return(L=b.focus)==null?void 0:L.call(b)})}else if((h==null?void 0:h.type)==="select"){let b=_r(typeof h.options=="function"?h.options(l):h.options),L=k("select","fg-editor-control");b.forEach((D,$)=>{var T;let A=k("option");A.value=String($),A.textContent=(T=D.label)!=null?T:String(D.value),A.disabled=!!D.disabled,L.append(A)}),L.selectedIndex=Math.max(0,b.findIndex(D=>Object.is(D.value,d))),x=L,M=()=>{var D,$;return{value:($=(D=b[L.selectedIndex])==null?void 0:D.value)!=null?$:null}},p.append(L)}else if((h==null?void 0:h.type)==="time"||(h==null?void 0:h.type)==="datetime"||!h&&a.type==="date"&&a.format==="datetime"){let b=(h==null?void 0:h.type)==="time",L=k("input","fg-editor-control",{type:b?"time":"datetime-local"});L.value=b?jr(d):Wr(d),x=L,M=()=>L.value?b?{value:L.value}:{value:d instanceof Date?new Date(L.value):L.value}:{value:null},p.append(L)}else{let L=(h==null?void 0:h.type)==="textarea"?k("textarea","fg-editor-control"):k("input","fg-editor-control");L instanceof HTMLInputElement&&(L.type=a.type==="date"&&n===void 0?"date":"text",a.type==="number"&&(L.inputMode="decimal"));let D=a.type==="date"?(m=Y(d))!=null?m:"":O(d)?"":String(d);L.value=n!=null?n:D,x=L,M=()=>({text:L.value}),p.append(L)}x.setAttribute("aria-label",(I=(R=a.header)!=null?R:a.field)!=null?I:t);let y=k("div","fg-editor-msg",{role:"alert"});p.append(y);let g=b=>{if(b.stopPropagation(),b.key==="Escape")b.preventDefault(),this.cancel();else if(b.key==="Enter"){if(x instanceof HTMLTextAreaElement&&!(b.ctrlKey||b.metaKey))return;b.preventDefault(),this.commit(b.shiftKey?"up":"down")}else b.key==="Tab"&&(b.preventDefault(),this.commit(b.shiftKey?"left":"right"))},w=b=>{var L;((L=this.cur)==null?void 0:L.wrap)===p&&!p.contains(b.relatedTarget)&&this.commit(null)},C=()=>this.commit(null);return p.addEventListener("keydown",g),p.addEventListener("focusout",w),o.scroller.addEventListener("scroll",C,{passive:!0}),o.root.append(p),this.cur={rowIndex:e,colId:t,row:l,def:a,wrap:p,read:M,dispose:()=>{p.removeEventListener("keydown",g),p.removeEventListener("focusout",w),o.scroller.removeEventListener("scroll",C),v(),p.remove()}},typeof h!="function"&&(x.focus(),n===void 0&&x instanceof HTMLInputElement&&x.type==="text"&&x.select()),r.events.emit("editStart",{rowIndex:e,colId:t}),!0}commit(e){let t=this.cur;if(!t)return!1;let{grid:n}=this,r=n.store.state.locale,o=t.def.field,i=t.row[o],a=t.read(),l;if("text"in a&&t.def.formulas&&ge(a.text.trim()))l=a.text.trim();else if("text"in a){let c=rt(t.def,a.text,i);if(!c.ok)return this.fail(a.text,r.invalidValue);l=c.value}else l=a.value;let d=n.cellError(t.def,t.row,l);return d!==null?this.fail(l,d):(this.close(!0),n.applyEdit(t.rowIndex,t.colId,l),this.move(t.rowIndex,t.colId,e),!0)}cancel(){this.close(!1)}fail(e,t){let n=this.cur;return n.wrap.classList.add("fg-editor-invalid"),n.wrap.querySelector(".fg-editor-msg").textContent=t,this.grid.events.emit("validationFailed",{rowIndex:n.rowIndex,colId:n.colId,value:e,message:t}),!1}close(e){let t=this.cur;t&&(this.cur=null,t.dispose(),this.grid.renderer.gridEl.focus({preventScroll:!0}),this.grid.events.emit("editStop",{rowIndex:t.rowIndex,colId:t.colId,committed:e}))}move(e,t,n){if(!n)return;let{grid:r}=this,o=r.rowModel.getRowCount();if(n==="down"||n==="up"){let c=Math.max(0,Math.min(o-1,e+(n==="down"?1:-1)));r.setFocus(c,t),r.renderer.ensureVisible(c,t);return}let i=r.columns.displayed().filter(c=>this.canEdit(e,c.id)||c.def.editable);if(!i.length)return;let a=n==="right"?1:-1,l=e,d=i.findIndex(c=>c.id===t)+a;d>=i.length&&(d=0,l++),d<0&&(d=i.length-1,l--),!(l<0||l>=o)&&this.start(l,i[d].id)}};var st=class{constructor(e=200){this.limit=e;this.entries=[];this.index=0}push(e){this.entries.splice(this.index),this.entries.push(e),this.entries.length>this.limit&&this.entries.shift(),this.index=this.entries.length}canUndo(){return this.index>0}canRedo(){return this.index<this.entries.length}undo(){return this.canUndo()?(this.entries[--this.index].undo(),!0):!1}redo(){return this.canRedo()?(this.entries[this.index++].redo(),!0):!1}clear(){this.entries=[],this.index=0}};var Sn=(s,e)=>s instanceof Date&&e instanceof Date?s.getTime()===e.getTime():Object.is(s,e),it=class{constructor(){this.originals=new Map;this.created=new Set;this.deleted=new Map}beforeChange(e){!this.created.has(e)&&!this.originals.has(e)&&this.originals.set(e,{...e})}isDirty(e,t){if(!t||this.created.has(e))return!1;let n=this.originals.get(e);return!!n&&!Sn(n[t],e[t])}diff(e,t){let n=this.originals.get(e);return n?t.filter(r=>!Sn(n[r],e[r])):[]}get size(){return this.originals.size+this.created.size+this.deleted.size}reset(){this.originals.clear(),this.created.clear(),this.deleted.clear()}};function Le(s){return{r1:Math.min(s.start.rowIndex,s.end.rowIndex),r2:Math.max(s.start.rowIndex,s.end.rowIndex),c1:Math.min(s.start.colIndex,s.end.colIndex),c2:Math.max(s.start.colIndex,s.end.colIndex)}}function Mn(s,e,t){return e>=s.r1&&e<=s.r2&&t>=s.c1&&t<=s.c2}var Xr=5;function En(s,e){let t=r=>s(r),n=r=>{window.removeEventListener("pointermove",t),window.removeEventListener("pointerup",n),window.removeEventListener("pointercancel",n),e(r)};window.addEventListener("pointermove",t),window.addEventListener("pointerup",n),window.addEventListener("pointercancel",n)}function Yr(s,e,t){let n=s.columns.getColumn(t);if(!n)return;let r=e.clientX,o=n.width;s.renderer.root.classList.add("fg-resizing"),En(i=>{s.columns.setWidth(t,o+(i.clientX-r)*(s.renderer.rtl?-1:1)),s.layoutChanged()},()=>{var a,l;s.renderer.root.classList.remove("fg-resizing");let i=(l=(a=s.columns.getColumn(t))==null?void 0:a.width)!=null?l:o;i!==o&&s.events.emit("columnResize",{colId:t,width:i})})}function Zr(s,e){let t=s.columns.getNode(e);return!!s.groupPanel&&!!t&&!t.children&&!s.options.treeData&&!s.getGroupBy().includes(e)}function Jr(s,e,t,n){var l,d;let r=new Set(s.columns.siblings(e).map(c=>c.id).filter(c=>c!==e&&!P(c))),o=[...n.querySelectorAll(".fg-header-cell")].filter(c=>r.has(c.dataset.col)).map(c=>({id:c.dataset.col,el:c})),i=k("div",`fg-drag-ghost fg-theme-${s.store.state.theme}`);i.textContent=(d=(l=t.querySelector(".fg-header-label"))==null?void 0:l.textContent)!=null?d:"",s.applyFontTo(i),ie(s.renderer.root).append(i);let a=k("div","fg-drop-marker");return a.style.height=`${s.renderer.headerEl.offsetHeight}px`,s.renderer.root.append(a),t.classList.add("fg-dragging"),{ghost:i,marker:a,cell:t,sibs:o,target:-1,overPanel:!1}}function Qr(s,e,t,n,r){var c,u;t.ghost.style.transform=`translate(${n+12}px, ${r+8}px)`,t.overPanel=Zr(s,e)&&!!((c=s.groupPanel)!=null&&c.contains(n,r)),(u=s.groupPanel)==null||u.highlight(t.overPanel),t.marker.hidden=t.overPanel;let o=0;for(let f of t.sibs){let p=f.el.getBoundingClientRect();(s.renderer.rtl?n<p.left+p.width/2:n>p.left+p.width/2)&&o++}t.target=o;let i=s.renderer.root.getBoundingClientRect().left,a=f=>s.renderer.rtl?f.getBoundingClientRect().right:f.getBoundingClientRect().left,l=f=>s.renderer.rtl?f.getBoundingClientRect().left:f.getBoundingClientRect().right,d=o<t.sibs.length?a(t.sibs[o].el):t.sibs.length?l(t.sibs[t.sibs.length-1].el):a(t.cell);t.marker.style.left=`${d-i-1}px`}function eo(s,e,t){var a;if(t.ghost.remove(),t.marker.remove(),t.cell.classList.remove("fg-dragging"),t.overPanel){(a=s.groupPanel)==null||a.highlight(!1),s.setGroupBy([...s.getGroupBy(),e]);return}if(t.target<0||!t.sibs.length)return;let n=s.columns.siblings(e),r=n.findIndex(l=>l.id===e),o=n.map(l=>l.id).filter(l=>l!==e),i=t.target<t.sibs.length?o.indexOf(t.sibs[t.target].id):o.indexOf(t.sibs[t.sibs.length-1].id)+1;i=Math.max(o.filter(P).length,i),i!==r&&(s.columns.move(e,i),s.layoutChanged(),s.events.emit("columnMove",{colId:e,toIndex:i}))}function to(s,e,t,n){let r=s.columns.getNode(t),o=n.closest(".fg-header-pane");if(!r||!o)return;let i=e.clientX,a=null;En(l=>{if(!a){if(Math.abs(l.clientX-i)<Xr)return;a=Jr(s,t,n,o)}Qr(s,t,a,l.clientX,l.clientY)},l=>{a?eo(s,t,a):!r.children&&de(r.def)&&s.toggleSort(t,l.shiftKey||l.ctrlKey||l.metaKey)})}function Ln(s){let e=s.renderer.headerEl,t=r=>{if(r.button!==0)return;let o=r.target,i=o.closest(".fg-header-cell"),a=i==null?void 0:i.dataset.col;!i||!a||P(a)||o.closest(".fg-menu-btn")||o.closest("button, a, input, select, textarea, [data-fg-no-sort]")&&o.closest(".fg-header-label")||(r.preventDefault(),o.closest(".fg-resize")?Yr(s,r,a):to(s,r,a,i))},n=r=>{var a;let o=r.target,i=o.closest(".fg-menu-btn");if(i){let l=(a=i.closest(".fg-header-cell"))==null?void 0:a.dataset.col;l&&s.menu.toggle(l,i);return}o.closest(".fg-select-all")&&s.toggleSelectAll()};return e.addEventListener("pointerdown",t),e.addEventListener("click",n),()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("click",n)}}var no=/^[=+\-@\t\r]/;function In(s,e=","){let t=n=>{let r=n.value;return n.text&&no.test(r)&&(r=`'${r}`),r.includes(e)||/["\r\n]/.test(r)||/^\s|\s$/.test(r)?`"${r.replace(/"/g,'""')}"`:r};return s.map(n=>n.map(t).join(e)).join(`\r
|
|
5
5
|
`)}function $t(s){let e=s.slice(0,s.search(/\r?\n|$/)),t=i=>e.split(i).length-1,n=t(" "),r=t(";"),o=t(",");return n&&n>=o&&n>=r?" ":r>o?";":","}function at(s,e=$t(s)){return Tt(s.replace(/^\uFEFF/,""),e)}var ro=(()=>{let s=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;s[e]=t>>>0}return s})();function oo(s){let e=4294967295;for(let t=0;t<s.length;t++)e=ro[(e^s[t])&255]^e>>>8;return(e^4294967295)>>>0}var Dn=new TextEncoder;function Tn(s){let e=s.map(c=>{let u=Dn.encode(c.name),f=typeof c.data=="string"?Dn.encode(c.data):c.data;return{name:u,data:f,crc:oo(f),offset:0}}),t=e.reduce((c,u)=>c+30+u.name.length+u.data.length,0),n=e.reduce((c,u)=>c+46+u.name.length,0),r=new Uint8Array(t+n+22),o=new DataView(r.buffer),i=0,a=0,l=33;for(let c of e)c.offset=i,o.setUint32(i,67324752,!0),o.setUint16(i+4,20,!0),o.setUint16(i+6,2048,!0),o.setUint16(i+8,0,!0),o.setUint16(i+10,a,!0),o.setUint16(i+12,l,!0),o.setUint32(i+14,c.crc,!0),o.setUint32(i+18,c.data.length,!0),o.setUint32(i+22,c.data.length,!0),o.setUint16(i+26,c.name.length,!0),o.setUint16(i+28,0,!0),r.set(c.name,i+30),r.set(c.data,i+30+c.name.length),i+=30+c.name.length+c.data.length;let d=i;for(let c of e)o.setUint32(i,33639248,!0),o.setUint16(i+4,20,!0),o.setUint16(i+6,20,!0),o.setUint16(i+8,2048,!0),o.setUint16(i+10,0,!0),o.setUint16(i+12,a,!0),o.setUint16(i+14,l,!0),o.setUint32(i+16,c.crc,!0),o.setUint32(i+20,c.data.length,!0),o.setUint32(i+24,c.data.length,!0),o.setUint16(i+28,c.name.length,!0),o.setUint16(i+30,0,!0),o.setUint16(i+32,0,!0),o.setUint16(i+34,0,!0),o.setUint16(i+36,0,!0),o.setUint32(i+38,0,!0),o.setUint32(i+42,c.offset,!0),r.set(c.name,i+46),i+=46+c.name.length;return o.setUint32(i,101010256,!0),o.setUint16(i+8,e.length,!0),o.setUint16(i+10,e.length,!0),o.setUint32(i+12,i-d,!0),o.setUint32(i+16,d,!0),r}var lt=s=>s.length>4&&s[0]===80&&s[1]===75&&s[2]===3&&s[3]===4;async function so(s){if(typeof DecompressionStream=="undefined")throw new Error("This browser cannot read compressed xlsx files (no DecompressionStream)");let e=new Response(s).body.pipeThrough(new DecompressionStream("deflate-raw"));return new Uint8Array(await new Response(e).arrayBuffer())}async function $n(s){let e=new DataView(s.buffer,s.byteOffset,s.byteLength),t=-1;for(let a=s.length-22;a>=Math.max(0,s.length-65557);a--)if(e.getUint32(a,!0)===101010256){t=a;break}if(t<0)throw new Error("Not a zip file");let n=e.getUint16(t+10,!0),r=e.getUint32(t+16,!0),o=new TextDecoder,i=new Map;for(let a=0;a<n;a++){if(e.getUint32(r,!0)!==33639248)throw new Error("Broken zip directory");let l=e.getUint16(r+10,!0),d=e.getUint32(r+20,!0),c=e.getUint16(r+28,!0),u=e.getUint16(r+30,!0),f=e.getUint16(r+32,!0),p=e.getUint32(r+42,!0),x=o.decode(s.subarray(r+46,r+46+c)),M=e.getUint16(p+26,!0),v=e.getUint16(p+28,!0),h=p+30+M+v,y=s.subarray(h,h+d);if(l===0)i.set(x,y);else if(l===8)i.set(x,await so(y));else throw new Error(`Unsupported zip compression ${l}`);r+=46+c+u+f}return i}function Pt(s){let e="";for(let t=s+1;t>0;t=Math.floor((t-1)/26))e=String.fromCharCode(65+(t-1)%26)+e;return e}var Pn=Date.UTC(1899,11,30),An=864e5;function io(s){return(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),s.getHours(),s.getMinutes(),s.getSeconds(),s.getMilliseconds())-Pn)/An}function ao(s){let e=new Date(Math.round(s*An)+Pn);return new Date(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds())}var lo=/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g,dt=s=>s.replace(lo,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),ye=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
6
|
-
`,At="http://schemas.openxmlformats.org/spreadsheetml/2006/main",be="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function co(s){let e=new Set;return s.map((t,n)=>{var i;let r=((i=t.name)!=null?i:`Sheet${n+1}`).replace(/[[\]:*?/\\]/g," ").slice(0,31).trim()||`Sheet${n+1}`,o=r;for(let a=2;e.has(o.toLowerCase());a++)o=`${r.slice(0,28)} (${a})`;return e.add(o.toLowerCase()),o})}function ct(s){let e=new Map([["General",0]]),t=[],n=['<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>'],r=new Map([["General||||",0]]),o=['<font><sz val="11"/><name val="Calibri"/></font>','<font><b/><sz val="11"/><name val="Calibri"/></font>'],i=new Map([["0|",0],["1|",1]]),a=['<fill><patternFill patternType="none"/></fill>','<fill><patternFill patternType="gray125"/></fill>','<fill><patternFill patternType="solid"><fgColor rgb="FFF2F4F7"/><bgColor indexed="64"/></patternFill></fill>'],l=new Map([["FFF2F4F7",2]]),d=h=>h&&/^[0-9a-f]{8}$/i.test(h)?h.toUpperCase():h&&/^[0-9a-f]{6}$/i.test(h)?`FF${h.toUpperCase()}`:"",c=(h,y)=>{let g=`${h?1:0}|${y}`,w=i.get(g);return w===void 0&&(w=o.length,o.push(`<font>${h?"<b/>":""}<sz val="11"/>${y?`<color rgb="${y}"/>`:""}<name val="Calibri"/></font>`),i.set(g,w)),w},u=h=>{if(!h)return 0;let y=l.get(h);return y===void 0&&(y=a.length,a.push(`<fill><patternFill patternType="solid"><fgColor rgb="${h}"/><bgColor indexed="64"/></patternFill></fill>`),l.set(h,y)),y},f=(h,y)=>{let g=d(y.color),w=y.header?"FFF2F4F7":d(y.fill),C=!!(y.bold||y.header),S=y.align==="left"||y.align==="center"||y.align==="right"?y.align:"",E=`${h}|${C?1:""}|${g}|${w}|${S}`,m=r.get(E);if(m!==void 0)return m;let R=e.get(h);R===void 0&&(R=164+t.length,t.push(h),e.set(h,R));let I=c(C,g),b=u(w),L=`numFmtId="${R}" fontId="${I}" fillId="${b}" borderId="0" xfId="0"`+(R?' applyNumberFormat="1"':"")+(I?' applyFont="1"':"")+(b?' applyFill="1"':"")+(S?' applyAlignment="1"':"");return m=n.length,n.push(S?`<xf ${L}><alignment horizontal="${S}"/></xf>`:`<xf ${L}/>`),r.set(E,m),m},p=co(s),x=s.map(h=>{var R,I,b;let y=h.rows.map((L,D)=>{let $=L.map((A,T)=>{var X;let F=A!==null&&typeof A=="object"&&!(A instanceof Date)?A:{v:A},z=`${Pt(T)}${D+1}`,H=F.v,V=(X=F.fmt)!=null?X:"General";H instanceof Date&&(Number.isNaN(H.getTime())?H=null:(V==="General"&&(V="yyyy-mm-dd"),H=io(H)));let G=f(V,F),U=G?` s="${G}"`:"";return H==null||H===""?U?`<c r="${z}"${U}/>`:"":typeof H=="number"?Number.isFinite(H)?`<c r="${z}"${U}><v>${H}</v></c>`:"":typeof H=="boolean"?`<c r="${z}"${U} t="b"><v>${H?1:0}</v></c>`:`<c r="${z}"${U} t="inlineStr"><is><t xml:space="preserve">${dt(String(H))}</t></is></c>`}).join("");return`<row r="${D+1}">${$}</row>`}).join(""),g=Math.max(0,...h.rows.map(L=>L.length)),w=(R=h.freezeRows)!=null?R:0,C=w?`<sheetViews><sheetView workbookViewId="0"><pane ySplit="${w}" topLeftCell="A${w+1}" activePane="bottomLeft" state="frozen"/></sheetView></sheetViews>`:'<sheetViews><sheetView workbookViewId="0"/></sheetViews>',S=(I=h.widths)!=null&&I.length?`<cols>${h.widths.map((L,D)=>`<col min="${D+1}" max="${D+1}" width="${Math.max(4,Math.min(120,L)).toFixed(1)}" customWidth="1"/>`).join("")}</cols>`:"",E=h.autoFilter&&g&&w&&h.rows.length>=w?`<autoFilter ref="A${w}:${Pt(g-1)}${h.rows.length}"/>`:"",m=(b=h.merges)!=null&&b.length?`<mergeCells count="${h.merges.length}">${h.merges.map(L=>`<mergeCell ref="${L}"/>`).join("")}</mergeCells>`:"";return`${ye}<worksheet xmlns="${At}" xmlns:r="${be}">${C}<sheetFormatPr defaultRowHeight="15"/>${S}<sheetData>${y}</sheetData>${E}${m}</worksheet>`}),M=`${ye}<styleSheet xmlns="${At}">`+(t.length?`<numFmts count="${t.length}">${t.map((h,y)=>`<numFmt numFmtId="${164+y}" formatCode="${dt(h)}"/>`).join("")}</numFmts>`:"")+`<fonts count="${o.length}">${o.join("")}</fonts><fills count="${a.length}">${a.join("")}</fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="${n.length}">${n.join("")}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`,v=[{name:"[Content_Types].xml",data:`${ye}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>`+s.map((h,y)=>`<Override PartName="/xl/worksheets/sheet${y+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join("")+"</Types>"},{name:"_rels/.rels",data:`${ye}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${be}/officeDocument" Target="xl/workbook.xml"/></Relationships>`},{name:"xl/workbook.xml",data:`${ye}<workbook xmlns="${At}" xmlns:r="${be}"><sheets>`+p.map((h,y)=>`<sheet name="${dt(h)}" sheetId="${y+1}" r:id="rId${y+1}"/>`).join("")+"</sheets>"+(s.some(h=>h.autoFilter&&h.freezeRows)?`<definedNames>${s.map((h,y)=>{let g=Math.max(0,...h.rows.map(w=>w.length));return h.autoFilter&&h.freezeRows&&g?`<definedName name="_xlnm._FilterDatabase" localSheetId="${y}" hidden="1">'${dt(p[y].replace(/'/g,"''"))}'!$A$${h.freezeRows}:$${Pt(g-1)}$${h.rows.length}</definedName>`:""}).join("")}</definedNames>`:"")+"</workbook>"},{name:"xl/_rels/workbook.xml.rels",data:`${ye}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`+s.map((h,y)=>`<Relationship Id="rId${y+1}" Type="${be}/worksheet" Target="worksheets/sheet${y+1}.xml"/>`).join("")+`<Relationship Id="rId${s.length+1}" Type="${be}/styles" Target="styles.xml"/></Relationships>`},{name:"xl/styles.xml",data:M},...x.map((h,y)=>({name:`xl/worksheets/sheet${y+1}.xml`,data:h}))];return Tn(v)}var uo=new Set([14,15,16,17,18,19,20,21,22,27,30,36,45,46,47,50,57]);function ho(s){let e=s.replace(/"[^"]*"/g,"").replace(/\[[^\]]*\]/g,"").replace(/\\./g,"");return/[dmyhs]/i.test(e)&&!/^[#0.,%\s]*$/.test(e)}function Ie(s){return s?new DOMParser().parseFromString(new TextDecoder().decode(s),"application/xml"):null}var re=(s,e)=>[...s.getElementsByTagNameNS("*",e)];function fo(s){let e=0;for(let t of s){let n=t.charCodeAt(0);if(n<65||n>90)break;e=e*26+(n-64)}return e-1}async function ut(s){var p,x,M,v,h,y,g,w,C;let e=s instanceof Uint8Array?s:new Uint8Array(s);if(!lt(e))throw new Error("Not an xlsx file");let t=await $n(e),n=Ie(t.get("xl/workbook.xml"));if(!n)throw new Error("xlsx has no workbook");let r=Ie(t.get("xl/_rels/workbook.xml.rels")),o=new Map(r?re(r,"Relationship").map(S=>{var E,m;return[(E=S.getAttribute("Id"))!=null?E:"",(m=S.getAttribute("Target"))!=null?m:""]}):[]),i=Ie(t.get("xl/sharedStrings.xml")),a=i?re(i,"si").map(S=>re(S,"t").map(E=>{var m;return(m=E.textContent)!=null?m:""}).join("")):[],l=Ie(t.get("xl/styles.xml")),d=new Map(l?re(l,"numFmt").map(S=>{var E;return[Number(S.getAttribute("numFmtId")),(E=S.getAttribute("formatCode"))!=null?E:""]}):[]),c=l?re(l,"cellXfs")[0]:void 0,u=(c?[...c.children].filter(S=>S.localName==="xf"):[]).map(S=>{var m;let E=Number((m=S.getAttribute("numFmtId"))!=null?m:0);return uo.has(E)||d.has(E)&&ho(d.get(E))}),f=[];for(let S of re(n,"sheet")){let E=(x=(p=S.getAttribute("r:id"))!=null?p:S.getAttributeNS(be,"id"))!=null?x:"",m=(M=o.get(E))!=null?M:"";m=m.startsWith("/")?m.slice(1):`xl/${m}`;let R=Ie(t.get(m)),I=[];if(R){for(let b of re(R,"row")){let L=Number((v=b.getAttribute("r"))!=null?v:I.length+1)-1,D=[],$=0;for(let A of[...b.children].filter(T=>T.localName==="c")){let T=A.getAttribute("r"),F=T?fo(T):$;$=F+1;let z=A.getAttribute("t"),H=(y=(h=re(A,"v")[0])==null?void 0:h.textContent)!=null?y:null,V=null;if(z==="s")V=H===null?null:(g=a[Number(H)])!=null?g:"";else if(z==="inlineStr")V=re(A,"t").map(G=>{var U;return(U=G.textContent)!=null?U:""}).join("");else if(z==="b")V=H==="1";else if(z==="str"||z==="e")V=H;else if(H!==null&&H!==""){let G=Number(H);V=u[Number((w=A.getAttribute("s"))!=null?w:0)]?ao(G):G}D[F]=V}for(let A=0;A<D.length;A++)D[A]===void 0&&(D[A]=null);I[L]=D}for(let b=0;b<I.length;b++)I[b]||(I[b]=[])}f.push({name:(C=S.getAttribute("name"))!=null?C:`Sheet${f.length+1}`,rows:I})}return f}function Nn(s,e){return Array.isArray(e)?e.flatMap(t=>{var r,o;let n=s.columns.getNode(t);return!n||n.children||P(t)?(N(`export: unknown column "${t}"`),[]):[{id:t,def:n.def,node:n,width:(o=(r=s.columns.getColumn(t))==null?void 0:r.width)!=null?o:n.width}]}):s.columns.displayed().filter(t=>!P(t.id)).map(t=>({id:t.id,def:t.def,node:t.node,width:t.width}))}function Fn(s,e){return e==="selected"?s.selectedRows():e==="all"?s.rowModel.server?s.rowModel.dataRows().map(t=>t.data):s.viewRows():s.rowModel.dataRows().map(t=>t.data)}var Nt=(s,e)=>{var t,n;return(n=(t=s.header)!=null?t:s.field)!=null?n:e};function Ft(s,e={}){let t=Nn(s,e.columns),n=s.store.state.locale.code,r=typeof e.separator=="string"&&e.separator.length===1?e.separator:",",o=Fn(s,e.rows).map(i=>t.map(a=>{let l=B(a.def,i),d=a.def.type;return{value:nt(a.def,l,n),text:!(d==="number"||d==="date"||d==="boolean")||typeof l=="string"}}));return e.headers!==!1&&o.unshift(t.map(i=>({value:Nt(i.def,i.id),text:!0}))),In(o,r)}function po(s){var o;let e=s.format;if(s.type==="date")return e==="datetime"?"yyyy-mm-dd hh:mm":e==="time"?"hh:mm":"yyyy-mm-dd";if(s.type!=="number"||e==null)return null;if(typeof e=="string")return e==="integer"?"#,##0":e==="percent"?"0%":e.startsWith("currency:")?"#,##0.##":/^[#0,.%]+$/.test(e)?e:null;let t=e,n=(o=t.maximumFractionDigits)!=null?o:t.minimumFractionDigits,r=n?`.${"0".repeat(Math.min(10,n))}`:"";return t.style==="percent"?`0${r}%`:`${t.useGrouping===!1?"0":"#,##0"}${r}`}function ht(s){let e=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(s.trim());if(e)return`FF${(e[1].length===3?[...e[1]].map(o=>o+o).join(""):e[1]).toUpperCase()}`;let t=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)(?:[\s,/]+([\d.]+%?))?\s*\)$/i.exec(s.trim());return!t||!((t[4]===void 0?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]))>0)?"":`FF${[t[1],t[2],t[3]].map(r=>Math.min(255,Number(r)).toString(16).padStart(2,"0")).join("").toUpperCase()}`}function go(s){let e=s.renderer.root;if(typeof getComputedStyle!="function"||!e.isConnected)return{of:()=>({}),dispose:()=>{}};let t=document.createElement("div");t.className="fg-row",t.style.cssText="position:absolute;left:-9999px;top:0;visibility:hidden;pointer-events:none";let n=document.createElement("div");t.append(n),e.append(t);let r=a=>{n.className=a?`fg-cell ${a}`:"fg-cell";let l=getComputedStyle(n),d=l.fontWeight;return{color:l.color,fill:l.backgroundColor,bold:d==="bold"||Number(d)>=600}},o=r(""),i=new Map;return{of(a){let l=i.get(a);if(!l){let d=r(a);l={},d.color!==o.color&&ht(d.color)&&(l.color=ht(d.color)),d.fill!==o.fill&&ht(d.fill)&&(l.fill=ht(d.fill)),d.bold&&!o.bold&&(l.bold=!0),i.set(a,l)}return l},dispose:()=>t.remove()}}function Ht(s,e={}){var v;let t=Nn(s,e.columns),n=s.store.state.locale.code,r=[],o=[],i=0;if(e.headers!==!1){let h=t.map(g=>{let w=[];for(let C=g.node;C;C=C.parent)w.unshift(C);return w});i=Math.max(1,...h.map(g=>g.length));let y=g=>{let w="";for(let C=g+1;C>0;C=Math.floor((C-1)/26))w=String.fromCharCode(65+(C-1)%26)+w;return w};for(let g=0;g<i;g++){let w=[];for(let C=0;C<t.length;C++){let S=h[C],E=S.length-1;if(g<E){let m=S[g],R=C>0?h[C-1][g]:null;if(w.push({v:R===m?null:Nt(m.def,m.id),header:!0}),R!==m){let I=C;for(;I+1<t.length&&h[I+1][g]===m;)I++;I>C&&o.push(`${y(C)}${g+1}:${y(I)}${g+1}`)}}else g===E?(w.push({v:Nt(t[C].def,t[C].id),header:!0}),i-1>g&&o.push(`${y(C)}${g+1}:${y(C)}${i}`)):w.push({v:null,header:!0})}r.push(w)}}let a=t.map(h=>po(h.def)),l=t.map(h=>K(h.def,n)),d=Fn(s,e.rows),c=e.styles!==!1,u=c&&t.some(h=>h.def.cellClass)?go(s):null,f=(h,y,g)=>{var C;if(O(g))return null;let w=(C=a[y])!=null?C:void 0;switch(h.def.type){case"number":{let S=typeof g=="number"?g:Number(g);return Number.isFinite(S)?{v:S,fmt:w}:String(g)}case"date":{let S=te(g);return S?{v:S,fmt:w}:String(g)}case"boolean":return typeof g=="boolean"?g:String(g);default:return l[y](g)}};try{d.forEach((h,y)=>{r.push(t.map((g,w)=>{let C=B(g.def,h),S=f(g,w,C);if(!c)return S;let E=g.def.align?{align:g.def.align}:{};if(u&&g.def.cellClass){let m;try{m=typeof g.def.cellClass=="function"?g.def.cellClass({value:C,formatted:l[w](C),row:h,rowIndex:y,column:g.def}):g.def.cellClass}catch{m=void 0}m&&(E={...E,...u.of(m)})}return Object.keys(E).length?S!==null&&typeof S=="object"&&!(S instanceof Date)?{...S,...E}:{v:S,...E}:S}))})}finally{u==null||u.dispose()}let p=new Set,x=h=>{let y="";for(let g=h+1;g>0;g=Math.floor((g-1)/26))y=String.fromCharCode(65+(g-1)%26)+y;return y},M=(h,y,g,w)=>{for(let C=h;C<=g;C++)for(let S=y;S<=w;S++)if(p.has(`${C},${S}`))return;for(let C=h;C<=g;C++)for(let S=y;S<=w;S++)p.add(`${C},${S}`);o.push(`${x(y)}${i+h+1}:${x(w)}${i+g+1}`)};return d.forEach((h,y)=>t.forEach((g,w)=>{let C=g.def.colSpan?ke(g.def.colSpan,g.def,h,y,t.length-w):1;C>1&&M(y,w,y,w+C-1)})),t.forEach((h,y)=>{if(!h.def.merge&&!h.def.rowSpan)return;let g=Ve(d,h.def);for(let w=0;w<d.length;w++)g.start[w]===w&&g.end[w]>w&&M(w,y,g.end[w],y)}),ct([{name:(v=e.sheetName)!=null?v:"Sheet1",rows:r,widths:t.map(h=>Math.round(h.width/7)),merges:o,freezeRows:i,autoFilter:i>0}])}function Bt(s,e,t){if(typeof URL=="undefined"||typeof URL.createObjectURL!="function"||typeof document=="undefined"){N("downloads are not supported in this environment");return}let n=URL.createObjectURL(new Blob(e,{type:t})),r=document.createElement("a");r.href=n,r.download=s,r.style.display="none",document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}var ft=s=>String(s!=null?s:"").trim().toLowerCase();function mo(s){var e;return s==null?"":s instanceof Date?s.getHours()||s.getMinutes()||s.getSeconds()?s.toISOString():(e=Y(s))!=null?e:"":String(s)}async function Hn(s,e,t={}){var M;let n=e instanceof Uint8Array?e:new Uint8Array(e instanceof ArrayBuffer?e:await e.arrayBuffer()),r;if(lt(n)){let v=await ut(n),h=typeof t.sheet=="string"?v.find(y=>y.name===t.sheet):v[typeof t.sheet=="number"?t.sheet:0];if(!h)throw new Error(`Sheet ${String(t.sheet)} not found`);r=h.rows}else{let v=new TextDecoder().decode(n);r=at(v,$t(v))}if(!r.length)return{rows:[],skipped:0};let o=[],i=v=>v.forEach(h=>h.children?i(h.children):!P(h.id)&&h.def.field&&o.push(h));i(s.columns.roots());let a=v=>{var y,g;let h=ft(v);return h&&(g=(y=o.find(w=>ft(w.def.header)===h))!=null?y:o.find(w=>ft(w.def.field)===h||ft(w.id)===h))!=null?g:null},l=1,d=new Set(r[0].map(a).filter(Boolean));for(;l<Math.min(r.length,5);){let h=((M=r[l])!=null?M:[]).filter(g=>g!=null&&String(g).trim()!==""),y=h.map(a).filter(g=>g&&!d.has(g));if(!h.length||!h.every(g=>typeof g=="string")||!y.length)break;y.forEach(g=>d.add(g)),l++}let c=Math.max(...r.slice(0,l).map(v=>{var h;return(h=v==null?void 0:v.length)!=null?h:0})),u=Array.from({length:c},(v,h)=>{var y;for(let g=l-1;g>=0;g--){let w=(y=r[g])==null?void 0:y[h];if(w!=null&&String(w).trim()!=="")return a(w)}return null}),f=s.store.state.data[0],p=0,x=[];for(let v of r.slice(l)){if(!v||v.every(y=>y==null||String(y).trim()===""))continue;let h={};u.forEach((y,g)=>{if(!y)return;let w=y.def,C=mo(v[g]),S=s.acceptText(w,h,C,f==null?void 0:f[w.field]);S.ok?C===""&&(S.value===null||S.value==="")||(h[w.field]=S.value):p++}),x.push(h)}return t.mode==="replace"?s.setData(x):s.addRows(x),{rows:x,skipped:p}}var wo="http://www.w3.org/2000/svg";var zt=["var(--fg-accent, #2563eb)","#f59e0b","#10b981","#ef4444","#8b5cf6","#06b6d4","#ec4899","#84cc16","#f97316","#64748b","#14b8a6","#a855f7"],xe=s=>zt[s%zt.length];function j(s,e={},t=""){let n=document.createElementNS(wo,s);t&&n.setAttribute("class",t);for(let[r,o]of Object.entries(e))n.setAttribute(r,String(o));return n}function Ot(s,e){let t=j("title");t.textContent=e,s.append(t)}function vo(s,e,t=5){let n=Math.min(0,s),r=Math.max(0,e);n===r&&(r=n+1);let o=(r-n)/t,i=10**Math.floor(Math.log10(o)),a=[1,2,5,10].map(d=>d*i).find(d=>d>=o);n=Math.floor(n/a)*a,r=Math.ceil(r/a)*a;let l=[];for(let d=n;d<=r+a/2;d+=a)l.push(Math.round(d/a)*a);return l}function pt(s,e){var R,I;let t=new Intl.NumberFormat(e.locale,{maximumFractionDigits:2}),n=new Intl.NumberFormat(e.locale,{notation:"compact",maximumFractionDigits:1}),r=j("svg",{viewBox:"0 0 640 360",role:"img",preserveAspectRatio:"xMidYMid meet"},`fg-chart fg-chart-is-${e.type}`);e.title&&r.setAttribute("aria-label",e.title);let o=e.series.slice(0,zt.length),i=e.categories,a=16;if(e.title){let b=j("text",{x:320,y:22,"text-anchor":"middle"},"fg-chart-title");b.textContent=e.title,r.append(b),a=36}let l=j("g",{},"fg-chart-legend"),d=e.type==="pie"?i:o.map(b=>b.name),c=16;d.forEach((b,L)=>{let D=j("g",{transform:`translate(${c},350)`},"fg-chart-legend-item");D.append(j("rect",{x:0,y:-9,width:10,height:10,rx:2,fill:xe(L)}));let $=j("text",{x:14,y:0});$.textContent=b,D.append($),l.append(D),c+=24+Math.min(140,b.length*7)});let u=308;if(e.type==="pie"){let b=((I=(R=o[0])==null?void 0:R.values)!=null?I:[]).map(F=>F!==null&&F>0?F:0),L=b.reduce((F,z)=>F+z,0),D=640/2,$=(a+u)/2,A=Math.max(10,(u-a)/2-6),T=-Math.PI/2;b.forEach((F,z)=>{if(!F||!L)return;let H=T+F/L*Math.PI*2,V=H-T>Math.PI?1:0,G=W=>`${D+A*Math.cos(W)},${$+A*Math.sin(W)}`,U=F===L?`M${D-A},${$}a${A},${A} 0 1,0 ${2*A},0a${A},${A} 0 1,0 ${-2*A},0`:`M${D},${$}L${G(T)}A${A},${A} 0 ${V} 1 ${G(H)}Z`,X=j("path",{d:U,fill:xe(z)},"fg-chart-slice");Ot(X,`${i[z]}: ${t.format(F)} (${Math.round(F/L*1e3)/10}%)`),r.append(X),T=H}),r.append(l),s.replaceChildren(r);return}let f=e.type==="stackedBar",p=0,x=0;i.forEach((b,L)=>{let D=0,$=0;for(let A of o){let T=A.values[L];T==null||!Number.isFinite(T)||(f?T>=0?D+=T:$+=T:(x=Math.max(x,T),p=Math.min(p,T)))}f&&(x=Math.max(x,D),p=Math.min(p,$))});let M=vo(p,x),v=M[0],h=M[M.length-1],y=56,g=624,w=b=>u-(b-v)/(h-v)*(u-a),C=j("g",{},"fg-chart-axis");for(let b of M){C.append(j("line",{x1:y,x2:g,y1:w(b),y2:w(b)},b===0?"fg-chart-zero":"fg-chart-grid"));let L=j("text",{x:y-6,y:w(b)+4,"text-anchor":"end"});L.textContent=n.format(b),C.append(L)}let S=(g-y)/Math.max(1,i.length),E=Math.max(1,Math.ceil(i.length/Math.floor((g-y)/56)));i.forEach((b,L)=>{if(L%E)return;let D=j("text",{x:y+S*(L+.5),y:u+16,"text-anchor":"middle"});D.textContent=b.length>12?`${b.slice(0,11)}\u2026`:b,C.append(D)}),r.append(C);let m=j("g",{},"fg-chart-plot");if(e.type==="bar"||f){let b=S*.72,L=f?b:b/Math.max(1,o.length);i.forEach((D,$)=>{let A=0,T=0;o.forEach((F,z)=>{let H=F.values[$];if(H==null||!Number.isFinite(H))return;let V=0,G=H;f&&(V=H>=0?A:T,G=V+H,H>=0?A=G:T=G);let U=y+S*$+(S-b)/2+(f?0:L*z),X=j("rect",{x:U,y:Math.min(w(V),w(G)),width:Math.max(1,L-2),height:Math.max(.5,Math.abs(w(G)-w(V))),fill:xe(z),rx:2},"fg-chart-bar");Ot(X,`${F.name} \xB7 ${D}: ${t.format(H)}`),m.append(X)})})}else o.forEach((b,L)=>{let D=b.values.map((T,F)=>T==null||!Number.isFinite(T)?null:[y+S*(F+.5),w(T),T]),$="",A=!1;for(let T of D){if(!T){A=!1;continue}$+=`${A?"L":"M"}${T[0]},${T[1]}`,A=!0}if(e.type==="area"){let T=D.filter(F=>!!F);if(T.length){let F=`M${T[0][0]},${w(0)}${T.map(z=>`L${z[0]},${z[1]}`).join("")}L${T[T.length-1][0]},${w(0)}Z`;m.append(j("path",{d:F,fill:xe(L),"fill-opacity":.18},"fg-chart-area"))}}m.append(j("path",{d:$,fill:"none",stroke:xe(L),"stroke-width":2.2,"stroke-linejoin":"round"},"fg-chart-line")),D.forEach((T,F)=>{if(!T)return;let z=j("circle",{cx:T[0],cy:T[1],r:3.5,fill:xe(L)},"fg-chart-point");Ot(z,`${b.name} \xB7 ${i[F]}: ${t.format(T[2])}`),m.append(z)})});r.append(m,l),s.replaceChildren(r)}var yo=12,Bn=500,Gt=["bar","stackedBar","line","area","pie"],gt=class{constructor(e){this.grid=e;this.handles=new Set}create(e={}){var M,v;let{grid:t}=this,n=Gt.includes(e.type)?e.type:"bar",r=()=>t.store.state.locale,o=(M=e.range)!=null?M:t.store.state.range,i=null;if(o){let h=t.columns.getColumn(o.start.colId),y=t.columns.getColumn(o.end.colId);if(h&&y){let g=Le({start:{rowIndex:o.start.rowIndex,colIndex:h.index},end:{rowIndex:o.end.rowIndex,colIndex:y.index}}),w=[];for(let C=g.r1;C<=g.r2&&w.length<Bn;C++){let S=t.rowModel.getRow(C);S&&!S.kind&&w.push(S.data)}i={rows:w,colIds:t.columns.displayed().slice(g.c1,g.c2+1).filter(C=>!P(C.id)).map(C=>C.id)}}}let a=()=>{var m;let h=i?i.rows:t.rowModel.dataRows().slice(0,Bn).map(R=>R.data),y=(i?i.colIds.map(R=>t.columns.getColumn(R)):t.columns.displayed().filter(R=>!P(R.id))).filter(R=>!!R),g=y[0]&&y[0].def.type!=="number"?y[0]:i?null:(m=y.find(R=>R.def.type!=="number"))!=null?m:null,w=R=>!!R.node.parent&&R.node.parent.id==="pivotgroup|total",C=y.filter(R=>R!==g&&R.def.type==="number"&&(i||!w(R))).slice(0,yo),S=R=>{var b,L,D;let I=[];for(let $=R.node.parent;$;$=$.parent)I.unshift((b=$.def.header)!=null?b:$.id);return I.push((D=(L=R.def.header)!=null?L:R.def.field)!=null?D:R.id),I.join(" \xB7 ")},E=g?K(g.def,r().code):null;return{categories:h.map((R,I)=>g&&E?E(B(g.def,R)):String(I+1)),series:C.map(R=>({name:S(R),values:h.map(I=>{let b=B(R.def,I),L=typeof b=="number"?b:b==null||b===""?NaN:Number(b);return Number.isFinite(L)?L:null})}))}},l=k("div","fg-chart-body"),d=null,c=()=>pt(l,{type:n,title:e.title,locale:r().code,...a()}),u=h=>({bar:r().chartBar,stackedBar:r().chartStacked,line:r().chartLine,area:r().chartArea,pie:r().chartPie})[h],f=()=>d==null?void 0:d.querySelectorAll(".fg-chart-type").forEach(h=>h.setAttribute("aria-pressed",String(h.dataset.type===n)));if(e.container)e.container.append(l);else{d=k("div","fg-chart-panel",{role:"dialog","aria-label":(v=e.title)!=null?v:u(n)});let h=k("div","fg-chart-head");for(let g of Gt){let w=k("button","fg-chart-type",{type:"button",title:u(g)});w.dataset.type=g,w.textContent=u(g),w.addEventListener("click",()=>x.setType(g)),h.append(w)}let y=k("button","fg-chooser-close",{type:"button","aria-label":r().close});y.textContent="\xD7",y.addEventListener("click",()=>x.destroy()),h.append(k("span","fg-chart-spacer"),y),d.append(h,l),t.renderer.root.append(d)}let p=[t.events.on("cellValueChanged",()=>c()),t.events.on("rowsAdded",()=>c()),t.events.on("rowsRemoved",()=>c())];i||p.push(t.events.on("sortChange",()=>c()),t.events.on("filterChange",()=>c()));let x={el:l,setType:h=>{Gt.includes(h)&&(n=h,f(),c())},update:()=>c(),destroy:()=>{p.forEach(h=>h()),(d!=null?d:l).remove(),this.handles.delete(x)}};return this.handles.add(x),f(),c(),x}destroy(){for(let e of[...this.handles])e.destroy()}};function On(s,e,t){return typeof s=="number"&&typeof e=="number"?s-e:s instanceof Date&&e instanceof Date?s.getTime()-e.getTime():typeof s=="boolean"&&typeof e=="boolean"?Number(s)-Number(e):t.compare(String(s),String(e))}function bo(s,e){var t,n;if(O(e))return null;if(s.type==="number"){let r=typeof e=="number"?e:Number(e);return Number.isNaN(r)?null:r}return s.type==="date"?(n=(t=te(e))==null?void 0:t.getTime())!=null?n:null:e}function ue(s,e,t){let n=O(s),r=O(e);return n||r?n===r?0:n?1:-1:On(s,e,t)}function zn(s,e,t,n){let r=e.map(a=>({def:t(a.colId),mul:a.dir==="desc"?-1:1})).filter(a=>!!a.def);if(!r.length)return s;let o=r.map(a=>s.map(l=>{let d=B(a.def,l.data);return a.def.comparator?d:bo(a.def,d)})),i=s.map((a,l)=>l);return i.sort((a,l)=>{var d;for(let c=0;c<r.length;c++){let{def:u,mul:f}=r[c],p=o[c][a],x=o[c][l],M;if(u.comparator)try{M=(Number(u.comparator(p,x,s[a].data,s[l].data))||0)*f}catch{N(`comparator of column "${(d=u.id)!=null?d:u.field}" threw; treating values as equal`),M=0}else{let v=O(p),h=O(x);M=v||h?v===h?0:v?1:-1:On(p,x,n)*f}if(M)return M}return a-l}),i.map(a=>s[a])}var Gn=new WeakMap,xo=s=>typeof s=="function"?"custom":s;function Vt(s,e){var t,n,r;return{rows:((t=s.rows)!=null?t:[]).filter(e),columns:((n=s.columns)!=null?n:[]).filter(e),values:((r=s.values)!=null?r:[]).filter(o=>o&&e(o.colId)).map(o=>{var i;return{colId:o.colId,aggFunc:(i=o.aggFunc)!=null?i:"sum"}}),totals:s.totals!==!1}}function Vn(s,e,t,n,r){let o=Vt(e,g=>!!t(g)),i=new Intl.Collator(r,{numeric:!0,sensitivity:"base"}),a=g=>t(g),l=(g,w)=>g.map(C=>Z(B(a(C),w))).join(""),d=new Map;for(let g of s){let w=l(o.columns,g);d.has(w)||d.set(w,o.columns.map(C=>B(a(C),g)))}let c=[...d.entries()].sort((g,w)=>{for(let C=0;C<o.columns.length;C++){let S=ue(g[1][C],w[1][C],i);if(S)return S}return 0});o.columns.length||c.splice(0,c.length,["",[]]);let u=[],f=(g,w,C)=>{var b,L;let S=o.values[w],E=a(S.colId),m=`pivot|${C}|${w}`;u.push({id:m,comboKey:g,valueIndex:w});let R=D=>g===null||l(o.columns,D)===g,I=S.aggFunc;return{id:m,field:m,header:`${(L=(b=E.header)!=null?b:E.field)!=null?L:S.colId} (${n.agg(xo(I))})`,type:"number",format:I==="count"?"integer":E.format,width:130,aggFunc:(D,$)=>{let A=$.flatMap(T=>{var F;return(F=Gn.get(T))!=null?F:[]}).filter(R);return A.length?me(I,A.map(T=>B(E,T)),A):null}}},p=[],x=(g,w)=>{if(O(w))return n.blank;let C=a(g);return C.type==="number"&&!C.format?String(w):K(C,r)(w)};if(!o.columns.length)o.values.forEach((g,w)=>p.push(f("",w,0)));else{let g=(w,C,S)=>{let E=[],m=0;for(;m<w.length;){let R=w[m][1][C],I=Z(R),b=m;for(;b<w.length&&Z(w[b][1][C])===I;)b++;let L=w.slice(m,b),D=C===o.columns.length-1?o.values.map(($,A)=>f(L[0][0],A,S+m)):g(L,C+1,S+m);E.push({id:`pivotgroup|${C}|${S+m}`,header:x(o.columns[C],R),children:D}),m=b}return E};p.push(...g(c,0,0)),o.totals&&o.values.length&&p.push({id:"pivotgroup|total",header:n.total,children:o.values.map((w,C)=>f(null,C,"total"))})}let M=new Map;for(let g of s){let w=l(o.rows,g),C=M.get(w);C||M.set(w,C={values:o.rows.map(S=>B(a(S),g)),src:[]}),C.src.push(g)}let h=[...M.values()].sort((g,w)=>{for(let C=0;C<o.rows.length;C++){let S=ue(g.values[C],w.values[C],i);if(S)return S}return 0}).map(g=>{var S;let w={};o.rows.forEach((E,m)=>{var R;w[(R=a(E).field)!=null?R:E]=g.values[m]});let C=new Map;if(o.columns.length)for(let E of g.src){let m=l(o.columns,E),R=C.get(m);R||C.set(m,R=[]),R.push(E)}for(let E of u){let m=o.values[E.valueIndex],R=E.comboKey===null||!o.columns.length?g.src:(S=C.get(E.comboKey))!=null?S:[],I=a(m.colId);w[E.id]=R.length?me(m.aggFunc,R.map(b=>B(I,b)),R):null}return Gn.set(w,g.src),w});return{columns:[...o.rows.map(g=>{var C,S,E,m;let w=a(g);return{id:g,field:(C=w.field)!=null?C:g,header:(E=(S=w.header)!=null?S:w.field)!=null?E:g,type:w.type,format:w.format,width:(m=w.width)!=null?m:140}}),...p],rows:h,groupBy:o.rows.slice(0,-1)}}var De="0.8.0";var Co={kty:"EC",crv:"P-256",x:"sUTKkglZmk-HMKPNub8p7AeLBKesHCU8irIkw9rJlbE",y:"j0U_aKRDR7iApY9UpaD3hUemhBLZJwDv9-QiT_hUyw8"},Ut="https://freegrid.app/pricing/",Un="https://freegrid.app/api/usage",Ro="https://freegrid.app/api/domain-status",qn=s=>{let e=atob(s.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-s.length%4)%4));return Uint8Array.from(e,t=>t.charCodeAt(0))};function Kt(s){let e=s.toLowerCase().replace(/^\[|\]$/g,"");return!e||e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="0.0.0.0"||e.endsWith(".localhost")||e.endsWith(".test")||e.endsWith(".local")||/^(10|192\.168|172\.(1[6-9]|2\d|3[01]))\./.test(e)}function ko(s,e){let t=s.toLowerCase().replace(/\.$/,"");return e.some(n=>{let r=n.toLowerCase().replace(/^\*\./,"").replace(/\.$/,"");return!!r&&(t===r||t.endsWith(`.${r}`))})}var So=s=>`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`;async function _t(s,e,t={}){var i,a;let n=typeof s=="string"?s.trim().split("."):[];if(n.length!==3||n[0]!=="FG1")return{ok:!1,reason:"format"};let r;try{if(r=JSON.parse(new TextDecoder().decode(qn(n[1]))),!Array.isArray(r.domains)||typeof r.expires!="string")return{ok:!1,reason:"format"}}catch{return{ok:!1,reason:"format"}}let o=typeof crypto!="undefined"?crypto.subtle:void 0;if(!o)return{ok:!1,reason:"unsupported",info:r};try{let l=await o.importKey("jwk",(i=t.publicKey)!=null?i:Co,{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]),d=new TextEncoder().encode(`${n[0]}.${n[1]}`);if(!await o.verify({name:"ECDSA",hash:"SHA-256"},l,qn(n[2]),d))return{ok:!1,reason:"signature",info:r}}catch{return{ok:!1,reason:"signature",info:r}}return So((a=t.now)!=null?a:new Date)>r.expires?{ok:!1,reason:"expired",info:r}:ko(e,r.domains)?{ok:!0,info:r}:{ok:!1,reason:"domain",info:r}}var qt,Kn=new Map,Te=null;function jn(s){qt=s}var _n={missing:`FreeGrid is free for personal use. Company use needs a domain license (\u20A9200,000 per domain per year): ${Ut}
|
|
6
|
+
`,At="http://schemas.openxmlformats.org/spreadsheetml/2006/main",be="http://schemas.openxmlformats.org/officeDocument/2006/relationships";function co(s){let e=new Set;return s.map((t,n)=>{var i;let r=((i=t.name)!=null?i:`Sheet${n+1}`).replace(/[[\]:*?/\\]/g," ").slice(0,31).trim()||`Sheet${n+1}`,o=r;for(let a=2;e.has(o.toLowerCase());a++)o=`${r.slice(0,28)} (${a})`;return e.add(o.toLowerCase()),o})}function ct(s){let e=new Map([["General",0]]),t=[],n=['<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>'],r=new Map([["General||||",0]]),o=['<font><sz val="11"/><name val="Calibri"/></font>','<font><b/><sz val="11"/><name val="Calibri"/></font>'],i=new Map([["0|",0],["1|",1]]),a=['<fill><patternFill patternType="none"/></fill>','<fill><patternFill patternType="gray125"/></fill>','<fill><patternFill patternType="solid"><fgColor rgb="FFF2F4F7"/><bgColor indexed="64"/></patternFill></fill>'],l=new Map([["FFF2F4F7",2]]),d=h=>h&&/^[0-9a-f]{8}$/i.test(h)?h.toUpperCase():h&&/^[0-9a-f]{6}$/i.test(h)?`FF${h.toUpperCase()}`:"",c=(h,y)=>{let g=`${h?1:0}|${y}`,w=i.get(g);return w===void 0&&(w=o.length,o.push(`<font>${h?"<b/>":""}<sz val="11"/>${y?`<color rgb="${y}"/>`:""}<name val="Calibri"/></font>`),i.set(g,w)),w},u=h=>{if(!h)return 0;let y=l.get(h);return y===void 0&&(y=a.length,a.push(`<fill><patternFill patternType="solid"><fgColor rgb="${h}"/><bgColor indexed="64"/></patternFill></fill>`),l.set(h,y)),y},f=(h,y)=>{let g=d(y.color),w=y.header?"FFF2F4F7":d(y.fill),C=!!(y.bold||y.header),S=y.align==="left"||y.align==="center"||y.align==="right"?y.align:"",E=`${h}|${C?1:""}|${g}|${w}|${S}`,m=r.get(E);if(m!==void 0)return m;let R=e.get(h);R===void 0&&(R=164+t.length,t.push(h),e.set(h,R));let I=c(C,g),b=u(w),L=`numFmtId="${R}" fontId="${I}" fillId="${b}" borderId="0" xfId="0"`+(R?' applyNumberFormat="1"':"")+(I?' applyFont="1"':"")+(b?' applyFill="1"':"")+(S?' applyAlignment="1"':"");return m=n.length,n.push(S?`<xf ${L}><alignment horizontal="${S}"/></xf>`:`<xf ${L}/>`),r.set(E,m),m},p=co(s),x=s.map(h=>{var R,I,b;let y=h.rows.map((L,D)=>{let $=L.map((A,T)=>{var X;let F=A!==null&&typeof A=="object"&&!(A instanceof Date)?A:{v:A},z=`${Pt(T)}${D+1}`,H=F.v,V=(X=F.fmt)!=null?X:"General";H instanceof Date&&(Number.isNaN(H.getTime())?H=null:(V==="General"&&(V="yyyy-mm-dd"),H=io(H)));let G=f(V,F),U=G?` s="${G}"`:"";return H==null||H===""?U?`<c r="${z}"${U}/>`:"":typeof H=="number"?Number.isFinite(H)?`<c r="${z}"${U}><v>${H}</v></c>`:"":typeof H=="boolean"?`<c r="${z}"${U} t="b"><v>${H?1:0}</v></c>`:`<c r="${z}"${U} t="inlineStr"><is><t xml:space="preserve">${dt(String(H))}</t></is></c>`}).join("");return`<row r="${D+1}">${$}</row>`}).join(""),g=Math.max(0,...h.rows.map(L=>L.length)),w=(R=h.freezeRows)!=null?R:0,C=w?`<sheetViews><sheetView workbookViewId="0"><pane ySplit="${w}" topLeftCell="A${w+1}" activePane="bottomLeft" state="frozen"/></sheetView></sheetViews>`:'<sheetViews><sheetView workbookViewId="0"/></sheetViews>',S=(I=h.widths)!=null&&I.length?`<cols>${h.widths.map((L,D)=>`<col min="${D+1}" max="${D+1}" width="${Math.max(4,Math.min(120,L)).toFixed(1)}" customWidth="1"/>`).join("")}</cols>`:"",E=h.autoFilter&&g&&w&&h.rows.length>=w?`<autoFilter ref="A${w}:${Pt(g-1)}${h.rows.length}"/>`:"",m=(b=h.merges)!=null&&b.length?`<mergeCells count="${h.merges.length}">${h.merges.map(L=>`<mergeCell ref="${L}"/>`).join("")}</mergeCells>`:"";return`${ye}<worksheet xmlns="${At}" xmlns:r="${be}">${C}<sheetFormatPr defaultRowHeight="15"/>${S}<sheetData>${y}</sheetData>${E}${m}</worksheet>`}),M=`${ye}<styleSheet xmlns="${At}">`+(t.length?`<numFmts count="${t.length}">${t.map((h,y)=>`<numFmt numFmtId="${164+y}" formatCode="${dt(h)}"/>`).join("")}</numFmts>`:"")+`<fonts count="${o.length}">${o.join("")}</fonts><fills count="${a.length}">${a.join("")}</fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="${n.length}">${n.join("")}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`,v=[{name:"[Content_Types].xml",data:`${ye}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>`+s.map((h,y)=>`<Override PartName="/xl/worksheets/sheet${y+1}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`).join("")+"</Types>"},{name:"_rels/.rels",data:`${ye}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${be}/officeDocument" Target="xl/workbook.xml"/></Relationships>`},{name:"xl/workbook.xml",data:`${ye}<workbook xmlns="${At}" xmlns:r="${be}"><sheets>`+p.map((h,y)=>`<sheet name="${dt(h)}" sheetId="${y+1}" r:id="rId${y+1}"/>`).join("")+"</sheets>"+(s.some(h=>h.autoFilter&&h.freezeRows)?`<definedNames>${s.map((h,y)=>{let g=Math.max(0,...h.rows.map(w=>w.length));return h.autoFilter&&h.freezeRows&&g?`<definedName name="_xlnm._FilterDatabase" localSheetId="${y}" hidden="1">'${dt(p[y].replace(/'/g,"''"))}'!$A$${h.freezeRows}:$${Pt(g-1)}$${h.rows.length}</definedName>`:""}).join("")}</definedNames>`:"")+"</workbook>"},{name:"xl/_rels/workbook.xml.rels",data:`${ye}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`+s.map((h,y)=>`<Relationship Id="rId${y+1}" Type="${be}/worksheet" Target="worksheets/sheet${y+1}.xml"/>`).join("")+`<Relationship Id="rId${s.length+1}" Type="${be}/styles" Target="styles.xml"/></Relationships>`},{name:"xl/styles.xml",data:M},...x.map((h,y)=>({name:`xl/worksheets/sheet${y+1}.xml`,data:h}))];return Tn(v)}var uo=new Set([14,15,16,17,18,19,20,21,22,27,30,36,45,46,47,50,57]);function ho(s){let e=s.replace(/"[^"]*"/g,"").replace(/\[[^\]]*\]/g,"").replace(/\\./g,"");return/[dmyhs]/i.test(e)&&!/^[#0.,%\s]*$/.test(e)}function Ie(s){return s?new DOMParser().parseFromString(new TextDecoder().decode(s),"application/xml"):null}var re=(s,e)=>[...s.getElementsByTagNameNS("*",e)];function fo(s){let e=0;for(let t of s){let n=t.charCodeAt(0);if(n<65||n>90)break;e=e*26+(n-64)}return e-1}async function ut(s){var p,x,M,v,h,y,g,w,C;let e=s instanceof Uint8Array?s:new Uint8Array(s);if(!lt(e))throw new Error("Not an xlsx file");let t=await $n(e),n=Ie(t.get("xl/workbook.xml"));if(!n)throw new Error("xlsx has no workbook");let r=Ie(t.get("xl/_rels/workbook.xml.rels")),o=new Map(r?re(r,"Relationship").map(S=>{var E,m;return[(E=S.getAttribute("Id"))!=null?E:"",(m=S.getAttribute("Target"))!=null?m:""]}):[]),i=Ie(t.get("xl/sharedStrings.xml")),a=i?re(i,"si").map(S=>re(S,"t").map(E=>{var m;return(m=E.textContent)!=null?m:""}).join("")):[],l=Ie(t.get("xl/styles.xml")),d=new Map(l?re(l,"numFmt").map(S=>{var E;return[Number(S.getAttribute("numFmtId")),(E=S.getAttribute("formatCode"))!=null?E:""]}):[]),c=l?re(l,"cellXfs")[0]:void 0,u=(c?[...c.children].filter(S=>S.localName==="xf"):[]).map(S=>{var m;let E=Number((m=S.getAttribute("numFmtId"))!=null?m:0);return uo.has(E)||d.has(E)&&ho(d.get(E))}),f=[];for(let S of re(n,"sheet")){let E=(x=(p=S.getAttribute("r:id"))!=null?p:S.getAttributeNS(be,"id"))!=null?x:"",m=(M=o.get(E))!=null?M:"";m=m.startsWith("/")?m.slice(1):`xl/${m}`;let R=Ie(t.get(m)),I=[];if(R){for(let b of re(R,"row")){let L=Number((v=b.getAttribute("r"))!=null?v:I.length+1)-1,D=[],$=0;for(let A of[...b.children].filter(T=>T.localName==="c")){let T=A.getAttribute("r"),F=T?fo(T):$;$=F+1;let z=A.getAttribute("t"),H=(y=(h=re(A,"v")[0])==null?void 0:h.textContent)!=null?y:null,V=null;if(z==="s")V=H===null?null:(g=a[Number(H)])!=null?g:"";else if(z==="inlineStr")V=re(A,"t").map(G=>{var U;return(U=G.textContent)!=null?U:""}).join("");else if(z==="b")V=H==="1";else if(z==="str"||z==="e")V=H;else if(H!==null&&H!==""){let G=Number(H);V=u[Number((w=A.getAttribute("s"))!=null?w:0)]?ao(G):G}D[F]=V}for(let A=0;A<D.length;A++)D[A]===void 0&&(D[A]=null);I[L]=D}for(let b=0;b<I.length;b++)I[b]||(I[b]=[])}f.push({name:(C=S.getAttribute("name"))!=null?C:`Sheet${f.length+1}`,rows:I})}return f}function Nn(s,e){return Array.isArray(e)?e.flatMap(t=>{var r,o;let n=s.columns.getNode(t);return!n||n.children||P(t)?(N(`export: unknown column "${t}"`),[]):[{id:t,def:n.def,node:n,width:(o=(r=s.columns.getColumn(t))==null?void 0:r.width)!=null?o:n.width}]}):s.columns.displayed().filter(t=>!P(t.id)).map(t=>({id:t.id,def:t.def,node:t.node,width:t.width}))}function Fn(s,e){return e==="selected"?s.selectedRows():e==="all"?s.rowModel.server?s.rowModel.dataRows().map(t=>t.data):s.viewRows():s.rowModel.dataRows().map(t=>t.data)}var Nt=(s,e)=>{var t,n;return(n=(t=s.header)!=null?t:s.field)!=null?n:e};function Ft(s,e={}){let t=Nn(s,e.columns),n=s.store.state.locale.code,r=typeof e.separator=="string"&&e.separator.length===1?e.separator:",",o=Fn(s,e.rows).map(i=>t.map(a=>{let l=B(a.def,i),d=a.def.type;return{value:nt(a.def,l,n),text:!(d==="number"||d==="date"||d==="boolean")||typeof l=="string"}}));return e.headers!==!1&&o.unshift(t.map(i=>({value:Nt(i.def,i.id),text:!0}))),In(o,r)}function po(s){var o;let e=s.format;if(s.type==="date")return e==="datetime"?"yyyy-mm-dd hh:mm":e==="time"?"hh:mm":"yyyy-mm-dd";if(s.type!=="number"||e==null)return null;if(typeof e=="string")return e==="integer"?"#,##0":e==="percent"?"0%":e.startsWith("currency:")?"#,##0.##":/^[#0,.%]+$/.test(e)?e:null;let t=e,n=(o=t.maximumFractionDigits)!=null?o:t.minimumFractionDigits,r=n?`.${"0".repeat(Math.min(10,n))}`:"";return t.style==="percent"?`0${r}%`:`${t.useGrouping===!1?"0":"#,##0"}${r}`}function ht(s){let e=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(s.trim());if(e)return`FF${(e[1].length===3?[...e[1]].map(o=>o+o).join(""):e[1]).toUpperCase()}`;let t=/^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)(?:[\s,/]+([\d.]+%?))?\s*\)$/i.exec(s.trim());return!t||!((t[4]===void 0?1:t[4].endsWith("%")?parseFloat(t[4])/100:parseFloat(t[4]))>0)?"":`FF${[t[1],t[2],t[3]].map(r=>Math.min(255,Number(r)).toString(16).padStart(2,"0")).join("").toUpperCase()}`}function go(s){let e=s.renderer.root;if(typeof getComputedStyle!="function"||!e.isConnected)return{of:()=>({}),dispose:()=>{}};let t=document.createElement("div");t.className="fg-row",t.style.cssText="position:absolute;left:-9999px;top:0;visibility:hidden;pointer-events:none";let n=document.createElement("div");t.append(n),e.append(t);let r=a=>{n.className=a?`fg-cell ${a}`:"fg-cell";let l=getComputedStyle(n),d=l.fontWeight;return{color:l.color,fill:l.backgroundColor,bold:d==="bold"||Number(d)>=600}},o=r(""),i=new Map;return{of(a){let l=i.get(a);if(!l){let d=r(a);l={},d.color!==o.color&&ht(d.color)&&(l.color=ht(d.color)),d.fill!==o.fill&&ht(d.fill)&&(l.fill=ht(d.fill)),d.bold&&!o.bold&&(l.bold=!0),i.set(a,l)}return l},dispose:()=>t.remove()}}function Ht(s,e={}){var v;let t=Nn(s,e.columns),n=s.store.state.locale.code,r=[],o=[],i=0;if(e.headers!==!1){let h=t.map(g=>{let w=[];for(let C=g.node;C;C=C.parent)w.unshift(C);return w});i=Math.max(1,...h.map(g=>g.length));let y=g=>{let w="";for(let C=g+1;C>0;C=Math.floor((C-1)/26))w=String.fromCharCode(65+(C-1)%26)+w;return w};for(let g=0;g<i;g++){let w=[];for(let C=0;C<t.length;C++){let S=h[C],E=S.length-1;if(g<E){let m=S[g],R=C>0?h[C-1][g]:null;if(w.push({v:R===m?null:Nt(m.def,m.id),header:!0}),R!==m){let I=C;for(;I+1<t.length&&h[I+1][g]===m;)I++;I>C&&o.push(`${y(C)}${g+1}:${y(I)}${g+1}`)}}else g===E?(w.push({v:Nt(t[C].def,t[C].id),header:!0}),i-1>g&&o.push(`${y(C)}${g+1}:${y(C)}${i}`)):w.push({v:null,header:!0})}r.push(w)}}let a=t.map(h=>po(h.def)),l=t.map(h=>K(h.def,n)),d=Fn(s,e.rows),c=e.styles!==!1,u=c&&t.some(h=>h.def.cellClass)?go(s):null,f=(h,y,g)=>{var C;if(O(g))return null;let w=(C=a[y])!=null?C:void 0;switch(h.def.type){case"number":{let S=typeof g=="number"?g:Number(g);return Number.isFinite(S)?{v:S,fmt:w}:String(g)}case"date":{let S=te(g);return S?{v:S,fmt:w}:String(g)}case"boolean":return typeof g=="boolean"?g:String(g);default:return l[y](g)}};try{d.forEach((h,y)=>{r.push(t.map((g,w)=>{let C=B(g.def,h),S=f(g,w,C);if(!c)return S;let E=g.def.align?{align:g.def.align}:{};if(u&&g.def.cellClass){let m;try{m=typeof g.def.cellClass=="function"?g.def.cellClass({value:C,formatted:l[w](C),row:h,rowIndex:y,column:g.def}):g.def.cellClass}catch{m=void 0}m&&(E={...E,...u.of(m)})}return Object.keys(E).length?S!==null&&typeof S=="object"&&!(S instanceof Date)?{...S,...E}:{v:S,...E}:S}))})}finally{u==null||u.dispose()}let p=new Set,x=h=>{let y="";for(let g=h+1;g>0;g=Math.floor((g-1)/26))y=String.fromCharCode(65+(g-1)%26)+y;return y},M=(h,y,g,w)=>{for(let C=h;C<=g;C++)for(let S=y;S<=w;S++)if(p.has(`${C},${S}`))return;for(let C=h;C<=g;C++)for(let S=y;S<=w;S++)p.add(`${C},${S}`);o.push(`${x(y)}${i+h+1}:${x(w)}${i+g+1}`)};return d.forEach((h,y)=>t.forEach((g,w)=>{let C=g.def.colSpan?ke(g.def.colSpan,g.def,h,y,t.length-w):1;C>1&&M(y,w,y,w+C-1)})),t.forEach((h,y)=>{if(!h.def.merge&&!h.def.rowSpan)return;let g=Ve(d,h.def);for(let w=0;w<d.length;w++)g.start[w]===w&&g.end[w]>w&&M(w,y,g.end[w],y)}),ct([{name:(v=e.sheetName)!=null?v:"Sheet1",rows:r,widths:t.map(h=>Math.round(h.width/7)),merges:o,freezeRows:i,autoFilter:i>0}])}function Bt(s,e,t){if(typeof URL=="undefined"||typeof URL.createObjectURL!="function"||typeof document=="undefined"){N("downloads are not supported in this environment");return}let n=URL.createObjectURL(new Blob(e,{type:t})),r=document.createElement("a");r.href=n,r.download=s,r.style.display="none",document.body.append(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}var ft=s=>String(s!=null?s:"").trim().toLowerCase();function mo(s){var e;return s==null?"":s instanceof Date?s.getHours()||s.getMinutes()||s.getSeconds()?s.toISOString():(e=Y(s))!=null?e:"":String(s)}async function Hn(s,e,t={}){var M;let n=e instanceof Uint8Array?e:new Uint8Array(e instanceof ArrayBuffer?e:await e.arrayBuffer()),r;if(lt(n)){let v=await ut(n),h=typeof t.sheet=="string"?v.find(y=>y.name===t.sheet):v[typeof t.sheet=="number"?t.sheet:0];if(!h)throw new Error(`Sheet ${String(t.sheet)} not found`);r=h.rows}else{let v=new TextDecoder().decode(n);r=at(v,$t(v))}if(!r.length)return{rows:[],skipped:0};let o=[],i=v=>v.forEach(h=>h.children?i(h.children):!P(h.id)&&h.def.field&&o.push(h));i(s.columns.roots());let a=v=>{var y,g;let h=ft(v);return h&&(g=(y=o.find(w=>ft(w.def.header)===h))!=null?y:o.find(w=>ft(w.def.field)===h||ft(w.id)===h))!=null?g:null},l=1,d=new Set(r[0].map(a).filter(Boolean));for(;l<Math.min(r.length,5);){let h=((M=r[l])!=null?M:[]).filter(g=>g!=null&&String(g).trim()!==""),y=h.map(a).filter(g=>g&&!d.has(g));if(!h.length||!h.every(g=>typeof g=="string")||!y.length)break;y.forEach(g=>d.add(g)),l++}let c=Math.max(...r.slice(0,l).map(v=>{var h;return(h=v==null?void 0:v.length)!=null?h:0})),u=Array.from({length:c},(v,h)=>{var y;for(let g=l-1;g>=0;g--){let w=(y=r[g])==null?void 0:y[h];if(w!=null&&String(w).trim()!=="")return a(w)}return null}),f=s.store.state.data[0],p=0,x=[];for(let v of r.slice(l)){if(!v||v.every(y=>y==null||String(y).trim()===""))continue;let h={};u.forEach((y,g)=>{if(!y)return;let w=y.def,C=mo(v[g]),S=s.acceptText(w,h,C,f==null?void 0:f[w.field]);S.ok?C===""&&(S.value===null||S.value==="")||(h[w.field]=S.value):p++}),x.push(h)}return t.mode==="replace"?s.setData(x):s.addRows(x),{rows:x,skipped:p}}var wo="http://www.w3.org/2000/svg";var zt=["var(--fg-accent, #2563eb)","#f59e0b","#10b981","#ef4444","#8b5cf6","#06b6d4","#ec4899","#84cc16","#f97316","#64748b","#14b8a6","#a855f7"],xe=s=>zt[s%zt.length];function j(s,e={},t=""){let n=document.createElementNS(wo,s);t&&n.setAttribute("class",t);for(let[r,o]of Object.entries(e))n.setAttribute(r,String(o));return n}function Ot(s,e){let t=j("title");t.textContent=e,s.append(t)}function vo(s,e,t=5){let n=Math.min(0,s),r=Math.max(0,e);n===r&&(r=n+1);let o=(r-n)/t,i=10**Math.floor(Math.log10(o)),a=[1,2,5,10].map(d=>d*i).find(d=>d>=o);n=Math.floor(n/a)*a,r=Math.ceil(r/a)*a;let l=[];for(let d=n;d<=r+a/2;d+=a)l.push(Math.round(d/a)*a);return l}function pt(s,e){var R,I;let t=new Intl.NumberFormat(e.locale,{maximumFractionDigits:2}),n=new Intl.NumberFormat(e.locale,{notation:"compact",maximumFractionDigits:1}),r=j("svg",{viewBox:"0 0 640 360",role:"img",preserveAspectRatio:"xMidYMid meet"},`fg-chart fg-chart-is-${e.type}`);e.title&&r.setAttribute("aria-label",e.title);let o=e.series.slice(0,zt.length),i=e.categories,a=16;if(e.title){let b=j("text",{x:320,y:22,"text-anchor":"middle"},"fg-chart-title");b.textContent=e.title,r.append(b),a=36}let l=j("g",{},"fg-chart-legend"),d=e.type==="pie"?i:o.map(b=>b.name),c=16;d.forEach((b,L)=>{let D=j("g",{transform:`translate(${c},350)`},"fg-chart-legend-item");D.append(j("rect",{x:0,y:-9,width:10,height:10,rx:2,fill:xe(L)}));let $=j("text",{x:14,y:0});$.textContent=b,D.append($),l.append(D),c+=24+Math.min(140,b.length*7)});let u=308;if(e.type==="pie"){let b=((I=(R=o[0])==null?void 0:R.values)!=null?I:[]).map(F=>F!==null&&F>0?F:0),L=b.reduce((F,z)=>F+z,0),D=640/2,$=(a+u)/2,A=Math.max(10,(u-a)/2-6),T=-Math.PI/2;b.forEach((F,z)=>{if(!F||!L)return;let H=T+F/L*Math.PI*2,V=H-T>Math.PI?1:0,G=W=>`${D+A*Math.cos(W)},${$+A*Math.sin(W)}`,U=F===L?`M${D-A},${$}a${A},${A} 0 1,0 ${2*A},0a${A},${A} 0 1,0 ${-2*A},0`:`M${D},${$}L${G(T)}A${A},${A} 0 ${V} 1 ${G(H)}Z`,X=j("path",{d:U,fill:xe(z)},"fg-chart-slice");Ot(X,`${i[z]}: ${t.format(F)} (${Math.round(F/L*1e3)/10}%)`),r.append(X),T=H}),r.append(l),s.replaceChildren(r);return}let f=e.type==="stackedBar",p=0,x=0;i.forEach((b,L)=>{let D=0,$=0;for(let A of o){let T=A.values[L];T==null||!Number.isFinite(T)||(f?T>=0?D+=T:$+=T:(x=Math.max(x,T),p=Math.min(p,T)))}f&&(x=Math.max(x,D),p=Math.min(p,$))});let M=vo(p,x),v=M[0],h=M[M.length-1],y=56,g=624,w=b=>u-(b-v)/(h-v)*(u-a),C=j("g",{},"fg-chart-axis");for(let b of M){C.append(j("line",{x1:y,x2:g,y1:w(b),y2:w(b)},b===0?"fg-chart-zero":"fg-chart-grid"));let L=j("text",{x:y-6,y:w(b)+4,"text-anchor":"end"});L.textContent=n.format(b),C.append(L)}let S=(g-y)/Math.max(1,i.length),E=Math.max(1,Math.ceil(i.length/Math.floor((g-y)/56)));i.forEach((b,L)=>{if(L%E)return;let D=j("text",{x:y+S*(L+.5),y:u+16,"text-anchor":"middle"});D.textContent=b.length>12?`${b.slice(0,11)}\u2026`:b,C.append(D)}),r.append(C);let m=j("g",{},"fg-chart-plot");if(e.type==="bar"||f){let b=S*.72,L=f?b:b/Math.max(1,o.length);i.forEach((D,$)=>{let A=0,T=0;o.forEach((F,z)=>{let H=F.values[$];if(H==null||!Number.isFinite(H))return;let V=0,G=H;f&&(V=H>=0?A:T,G=V+H,H>=0?A=G:T=G);let U=y+S*$+(S-b)/2+(f?0:L*z),X=j("rect",{x:U,y:Math.min(w(V),w(G)),width:Math.max(1,L-2),height:Math.max(.5,Math.abs(w(G)-w(V))),fill:xe(z),rx:2},"fg-chart-bar");Ot(X,`${F.name} \xB7 ${D}: ${t.format(H)}`),m.append(X)})})}else o.forEach((b,L)=>{let D=b.values.map((T,F)=>T==null||!Number.isFinite(T)?null:[y+S*(F+.5),w(T),T]),$="",A=!1;for(let T of D){if(!T){A=!1;continue}$+=`${A?"L":"M"}${T[0]},${T[1]}`,A=!0}if(e.type==="area"){let T=D.filter(F=>!!F);if(T.length){let F=`M${T[0][0]},${w(0)}${T.map(z=>`L${z[0]},${z[1]}`).join("")}L${T[T.length-1][0]},${w(0)}Z`;m.append(j("path",{d:F,fill:xe(L),"fill-opacity":.18},"fg-chart-area"))}}m.append(j("path",{d:$,fill:"none",stroke:xe(L),"stroke-width":2.2,"stroke-linejoin":"round"},"fg-chart-line")),D.forEach((T,F)=>{if(!T)return;let z=j("circle",{cx:T[0],cy:T[1],r:3.5,fill:xe(L)},"fg-chart-point");Ot(z,`${b.name} \xB7 ${i[F]}: ${t.format(T[2])}`),m.append(z)})});r.append(m,l),s.replaceChildren(r)}var yo=12,Bn=500,Gt=["bar","stackedBar","line","area","pie"],gt=class{constructor(e){this.grid=e;this.handles=new Set}create(e={}){var M,v;let{grid:t}=this,n=Gt.includes(e.type)?e.type:"bar",r=()=>t.store.state.locale,o=(M=e.range)!=null?M:t.store.state.range,i=null;if(o){let h=t.columns.getColumn(o.start.colId),y=t.columns.getColumn(o.end.colId);if(h&&y){let g=Le({start:{rowIndex:o.start.rowIndex,colIndex:h.index},end:{rowIndex:o.end.rowIndex,colIndex:y.index}}),w=[];for(let C=g.r1;C<=g.r2&&w.length<Bn;C++){let S=t.rowModel.getRow(C);S&&!S.kind&&w.push(S.data)}i={rows:w,colIds:t.columns.displayed().slice(g.c1,g.c2+1).filter(C=>!P(C.id)).map(C=>C.id)}}}let a=()=>{var m;let h=i?i.rows:t.rowModel.dataRows().slice(0,Bn).map(R=>R.data),y=(i?i.colIds.map(R=>t.columns.getColumn(R)):t.columns.displayed().filter(R=>!P(R.id))).filter(R=>!!R),g=y[0]&&y[0].def.type!=="number"?y[0]:i?null:(m=y.find(R=>R.def.type!=="number"))!=null?m:null,w=R=>!!R.node.parent&&R.node.parent.id==="pivotgroup|total",C=y.filter(R=>R!==g&&R.def.type==="number"&&(i||!w(R))).slice(0,yo),S=R=>{var b,L,D;let I=[];for(let $=R.node.parent;$;$=$.parent)I.unshift((b=$.def.header)!=null?b:$.id);return I.push((D=(L=R.def.header)!=null?L:R.def.field)!=null?D:R.id),I.join(" \xB7 ")},E=g?K(g.def,r().code):null;return{categories:h.map((R,I)=>g&&E?E(B(g.def,R)):String(I+1)),series:C.map(R=>({name:S(R),values:h.map(I=>{let b=B(R.def,I),L=typeof b=="number"?b:b==null||b===""?NaN:Number(b);return Number.isFinite(L)?L:null})}))}},l=k("div","fg-chart-body"),d=null,c=()=>pt(l,{type:n,title:e.title,locale:r().code,...a()}),u=h=>({bar:r().chartBar,stackedBar:r().chartStacked,line:r().chartLine,area:r().chartArea,pie:r().chartPie})[h],f=()=>d==null?void 0:d.querySelectorAll(".fg-chart-type").forEach(h=>h.setAttribute("aria-pressed",String(h.dataset.type===n)));if(e.container)e.container.append(l);else{d=k("div","fg-chart-panel",{role:"dialog","aria-label":(v=e.title)!=null?v:u(n)});let h=k("div","fg-chart-head");for(let g of Gt){let w=k("button","fg-chart-type",{type:"button",title:u(g)});w.dataset.type=g,w.textContent=u(g),w.addEventListener("click",()=>x.setType(g)),h.append(w)}let y=k("button","fg-chooser-close",{type:"button","aria-label":r().close});y.textContent="\xD7",y.addEventListener("click",()=>x.destroy()),h.append(k("span","fg-chart-spacer"),y),d.append(h,l),t.renderer.root.append(d)}let p=[t.events.on("cellValueChanged",()=>c()),t.events.on("rowsAdded",()=>c()),t.events.on("rowsRemoved",()=>c())];i||p.push(t.events.on("sortChange",()=>c()),t.events.on("filterChange",()=>c()));let x={el:l,setType:h=>{Gt.includes(h)&&(n=h,f(),c())},update:()=>c(),destroy:()=>{p.forEach(h=>h()),(d!=null?d:l).remove(),this.handles.delete(x)}};return this.handles.add(x),f(),c(),x}destroy(){for(let e of[...this.handles])e.destroy()}};function On(s,e,t){return typeof s=="number"&&typeof e=="number"?s-e:s instanceof Date&&e instanceof Date?s.getTime()-e.getTime():typeof s=="boolean"&&typeof e=="boolean"?Number(s)-Number(e):t.compare(String(s),String(e))}function bo(s,e){var t,n;if(O(e))return null;if(s.type==="number"){let r=typeof e=="number"?e:Number(e);return Number.isNaN(r)?null:r}return s.type==="date"?(n=(t=te(e))==null?void 0:t.getTime())!=null?n:null:e}function ue(s,e,t){let n=O(s),r=O(e);return n||r?n===r?0:n?1:-1:On(s,e,t)}function zn(s,e,t,n){let r=e.map(a=>({def:t(a.colId),mul:a.dir==="desc"?-1:1})).filter(a=>!!a.def);if(!r.length)return s;let o=r.map(a=>s.map(l=>{let d=B(a.def,l.data);return a.def.comparator?d:bo(a.def,d)})),i=s.map((a,l)=>l);return i.sort((a,l)=>{var d;for(let c=0;c<r.length;c++){let{def:u,mul:f}=r[c],p=o[c][a],x=o[c][l],M;if(u.comparator)try{M=(Number(u.comparator(p,x,s[a].data,s[l].data))||0)*f}catch{N(`comparator of column "${(d=u.id)!=null?d:u.field}" threw; treating values as equal`),M=0}else{let v=O(p),h=O(x);M=v||h?v===h?0:v?1:-1:On(p,x,n)*f}if(M)return M}return a-l}),i.map(a=>s[a])}var Gn=new WeakMap,xo=s=>typeof s=="function"?"custom":s;function Vt(s,e){var t,n,r;return{rows:((t=s.rows)!=null?t:[]).filter(e),columns:((n=s.columns)!=null?n:[]).filter(e),values:((r=s.values)!=null?r:[]).filter(o=>o&&e(o.colId)).map(o=>{var i;return{colId:o.colId,aggFunc:(i=o.aggFunc)!=null?i:"sum"}}),totals:s.totals!==!1}}function Vn(s,e,t,n,r){let o=Vt(e,g=>!!t(g)),i=new Intl.Collator(r,{numeric:!0,sensitivity:"base"}),a=g=>t(g),l=(g,w)=>g.map(C=>Z(B(a(C),w))).join(""),d=new Map;for(let g of s){let w=l(o.columns,g);d.has(w)||d.set(w,o.columns.map(C=>B(a(C),g)))}let c=[...d.entries()].sort((g,w)=>{for(let C=0;C<o.columns.length;C++){let S=ue(g[1][C],w[1][C],i);if(S)return S}return 0});o.columns.length||c.splice(0,c.length,["",[]]);let u=[],f=(g,w,C)=>{var b,L;let S=o.values[w],E=a(S.colId),m=`pivot|${C}|${w}`;u.push({id:m,comboKey:g,valueIndex:w});let R=D=>g===null||l(o.columns,D)===g,I=S.aggFunc;return{id:m,field:m,header:`${(L=(b=E.header)!=null?b:E.field)!=null?L:S.colId} (${n.agg(xo(I))})`,type:"number",format:I==="count"?"integer":E.format,width:130,aggFunc:(D,$)=>{let A=$.flatMap(T=>{var F;return(F=Gn.get(T))!=null?F:[]}).filter(R);return A.length?me(I,A.map(T=>B(E,T)),A):null}}},p=[],x=(g,w)=>{if(O(w))return n.blank;let C=a(g);return C.type==="number"&&!C.format?String(w):K(C,r)(w)};if(!o.columns.length)o.values.forEach((g,w)=>p.push(f("",w,0)));else{let g=(w,C,S)=>{let E=[],m=0;for(;m<w.length;){let R=w[m][1][C],I=Z(R),b=m;for(;b<w.length&&Z(w[b][1][C])===I;)b++;let L=w.slice(m,b),D=C===o.columns.length-1?o.values.map(($,A)=>f(L[0][0],A,S+m)):g(L,C+1,S+m);E.push({id:`pivotgroup|${C}|${S+m}`,header:x(o.columns[C],R),children:D}),m=b}return E};p.push(...g(c,0,0)),o.totals&&o.values.length&&p.push({id:"pivotgroup|total",header:n.total,children:o.values.map((w,C)=>f(null,C,"total"))})}let M=new Map;for(let g of s){let w=l(o.rows,g),C=M.get(w);C||M.set(w,C={values:o.rows.map(S=>B(a(S),g)),src:[]}),C.src.push(g)}let h=[...M.values()].sort((g,w)=>{for(let C=0;C<o.rows.length;C++){let S=ue(g.values[C],w.values[C],i);if(S)return S}return 0}).map(g=>{var S;let w={};o.rows.forEach((E,m)=>{var R;w[(R=a(E).field)!=null?R:E]=g.values[m]});let C=new Map;if(o.columns.length)for(let E of g.src){let m=l(o.columns,E),R=C.get(m);R||C.set(m,R=[]),R.push(E)}for(let E of u){let m=o.values[E.valueIndex],R=E.comboKey===null||!o.columns.length?g.src:(S=C.get(E.comboKey))!=null?S:[],I=a(m.colId);w[E.id]=R.length?me(m.aggFunc,R.map(b=>B(I,b)),R):null}return Gn.set(w,g.src),w});return{columns:[...o.rows.map(g=>{var C,S,E,m;let w=a(g);return{id:g,field:(C=w.field)!=null?C:g,header:(E=(S=w.header)!=null?S:w.field)!=null?E:g,type:w.type,format:w.format,width:(m=w.width)!=null?m:140}}),...p],rows:h,groupBy:o.rows.slice(0,-1)}}var De="0.8.1";var Co={kty:"EC",crv:"P-256",x:"sUTKkglZmk-HMKPNub8p7AeLBKesHCU8irIkw9rJlbE",y:"j0U_aKRDR7iApY9UpaD3hUemhBLZJwDv9-QiT_hUyw8"},Ut="https://freegrid.app/pricing/",Un="https://freegrid.app/api/usage",Ro="https://freegrid.app/api/domain-status",qn=s=>{let e=atob(s.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-s.length%4)%4));return Uint8Array.from(e,t=>t.charCodeAt(0))};function Kt(s){let e=s.toLowerCase().replace(/^\[|\]$/g,"");return!e||e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="0.0.0.0"||e.endsWith(".localhost")||e.endsWith(".test")||e.endsWith(".local")||/^(10|192\.168|172\.(1[6-9]|2\d|3[01]))\./.test(e)}function ko(s,e){let t=s.toLowerCase().replace(/\.$/,"");return e.some(n=>{let r=n.toLowerCase().replace(/\.$/,""),o=r.startsWith("*."),i=o?r.slice(2):r;return i?t===i||t===`www.${i}`?!0:o&&t.endsWith(`.${i}`):!1})}var So=s=>`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`;async function _t(s,e,t={}){var i,a;let n=typeof s=="string"?s.trim().split("."):[];if(n.length!==3||n[0]!=="FG1")return{ok:!1,reason:"format"};let r;try{if(r=JSON.parse(new TextDecoder().decode(qn(n[1]))),!Array.isArray(r.domains)||typeof r.expires!="string")return{ok:!1,reason:"format"}}catch{return{ok:!1,reason:"format"}}let o=typeof crypto!="undefined"?crypto.subtle:void 0;if(!o)return{ok:!1,reason:"unsupported",info:r};try{let l=await o.importKey("jwk",(i=t.publicKey)!=null?i:Co,{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]),d=new TextEncoder().encode(`${n[0]}.${n[1]}`);if(!await o.verify({name:"ECDSA",hash:"SHA-256"},l,qn(n[2]),d))return{ok:!1,reason:"signature",info:r}}catch{return{ok:!1,reason:"signature",info:r}}return So((a=t.now)!=null?a:new Date)>r.expires?{ok:!1,reason:"expired",info:r}:ko(e,r.domains)?{ok:!0,info:r}:{ok:!1,reason:"domain",info:r}}var qt,Kn=new Map,Te=null;function jn(s){qt=s}var _n={missing:`FreeGrid is free for personal use. Company use needs a domain license (\u20A9200,000 per domain per year): ${Ut}
|
|
7
7
|
FreeGrid\uB294 \uAC1C\uC778\uC5D0\uAC8C \uBB34\uB8CC\uC785\uB2C8\uB2E4. \uD68C\uC0AC\uC5D0\uC11C \uC4F0\uB824\uBA74 \uB3C4\uBA54\uC778 \uB77C\uC774\uC120\uC2A4(\uB3C4\uBA54\uC778\uB2F9 \uC5F0 20\uB9CC \uC6D0)\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4: ${Ut}`,format:"FreeGrid: the license key is not in the right format. / \uB77C\uC774\uC120\uC2A4 \uD0A4 \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.",signature:"FreeGrid: the license key could not be verified. / \uB77C\uC774\uC120\uC2A4 \uD0A4\uB97C \uD655\uC778\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.",expired:"FreeGrid: the license key has expired. / \uB77C\uC774\uC120\uC2A4 \uAE30\uAC04\uC774 \uB05D\uB0AC\uC2B5\uB2C8\uB2E4.",domain:"FreeGrid: the license key is for a different domain. / \uB2E4\uB978 \uB3C4\uBA54\uC778\uC6A9 \uB77C\uC774\uC120\uC2A4 \uD0A4\uC785\uB2C8\uB2E4."};function Wn(s,e=typeof location!="undefined"?location.hostname:""){try{if(Kt(e)||typeof navigator=="undefined")return;let t=new Date().toISOString().slice(0,10),n=`${e}|${t}|${s.licensed?1:0}`,r=typeof localStorage!="undefined"?localStorage:null;if((r==null?void 0:r.getItem("freegrid:usage"))===n)return;r==null||r.setItem("freegrid:usage",n);let o=JSON.stringify({version:s.version,licensed:s.licensed,company:s.company,url:`${location.origin}${location.pathname}`});typeof navigator.sendBeacon=="function"?navigator.sendBeacon(Un,o):typeof fetch=="function"&&fetch(Un,{method:"POST",body:o,mode:"no-cors",keepalive:!0}).catch(()=>{})}catch{}}function Mo(s=qt,e=typeof location!="undefined"?location.hostname:""){if(Kt(e))return Promise.resolve(!0);let t=s!=null?s:qt,n=`${t!=null?t:""}@${e}`,r=Kn.get(n);return r||(t?r=_t(t,e).then(o=>{if(Wn({version:De,licensed:o.ok,company:o.ok?o.info.company:void 0},e),o.ok||o.reason==="unsupported")return o.ok||o.reason==="unsupported";let i=o.info?` (${o.info.domains.join(", ")}, ${o.info.expires})`:"";return console.warn(`${_n[o.reason]}${i}
|
|
8
8
|
${Ut}`),!1},()=>!1):(console.info(_n.missing),Wn({version:De,licensed:!1},e),r=Promise.resolve(!1)),Kn.set(n,r),r)}function Eo(s=typeof location!="undefined"?location.hostname:""){var n;if(Kt(s)||typeof fetch!="function")return Promise.resolve(!1);if(Te)return Te;let e=new Date().toISOString().slice(0,10),t=null;try{t=typeof localStorage!="undefined"?localStorage:null;let r=JSON.parse((n=t==null?void 0:t.getItem("freegrid:badge"))!=null?n:"null");if(r&&r.host===s&&r.day===e)return Te=Promise.resolve(r.show)}catch{}return Te=fetch(Ro,{mode:"cors",credentials:"omit"}).then(r=>r.ok?r.json():{badge:!1}).then(r=>{let o=r.badge===!0;try{t==null||t.setItem("freegrid:badge",JSON.stringify({host:s,day:e,show:o}))}catch{}return o},()=>!1),Te}async function Xn(s,e=typeof location!="undefined"?location.hostname:""){return await Mo(s,e)?!1:Eo(e)}var Yn={text:["contains","equals","notEquals","startsWith","endsWith","blank","notBlank"],number:["eq","ne","lt","lte","gt","gte","between","blank","notBlank"],date:["equals","before","after","between","blank","notBlank"]},Zn=["blank","notBlank"],Wt=500,mt=class{constructor(e){this.grid=e;this.popup=null;this.colId=null;this.off=[]}get openColumn(){return this.colId}toggle(e,t){this.colId===e?this.close():this.open(e,t)}open(e,t){var M;this.close();let n=this.grid.columns.getNode(e);if(!n||n.children||P(e))return;let r=this.grid.store.state.locale,o=n.def,i=k("div",`fg-menu fg-theme-${this.grid.store.state.theme}`,{role:"dialog","aria-label":r.columnMenu});this.grid.applyFontTo(i),de(o)&&i.append(this.section([[r.sortAsc,()=>this.grid.setSort([{colId:e,dir:"asc"}])],[r.sortDesc,()=>this.grid.setSort([{colId:e,dir:"desc"}])],[r.clearSort,()=>this.grid.setSort(this.grid.store.state.sort.filter(v=>v.colId!==e))]])),i.append(this.section([[r.pinLeft,()=>this.grid.setPinned(e,"left")],[r.pinRight,()=>this.grid.setPinned(e,"right")],[r.unpin,()=>this.grid.setPinned(e,null)]]));let a=this.grid.getGroupBy();if(!this.grid.options.treeData&&(this.grid.options.groupPanel||a.length)){let v=a.includes(e)?[[r.ungroup,()=>this.grid.setGroupBy(a.filter(h=>h!==e))]]:[[r.groupByThis,()=>this.grid.setGroupBy([...a,e])]];a.length&&v.push([r.expandAll,()=>this.grid.expandAll(!0)],[r.collapseAll,()=>this.grid.expandAll(!1)]),i.append(this.section(v))}let l=[[r.autosizeThis,()=>this.grid.autoSize([e])],[r.autosizeAll,()=>this.grid.autoSize()]];o.lockVisible||l.push([r.hideColumn,()=>this.grid.setColumnsVisible([e],!1)]),l.push([r.chooseColumns,()=>this.grid.chooser.open()],[r.resetColumns,()=>this.grid.resetColumns()]),i.append(this.section(l));let d=this.filterSection(e,()=>this.close());d&&i.append(d),ie(this.grid.renderer.root).append(i);let c=t.getBoundingClientRect(),u=i.offsetWidth||248;i.style.left=`${Math.max(4,Math.min(c.right-u,window.innerWidth-u-4))}px`;let f=Math.max(4,Math.min(c.bottom+4,window.innerHeight-240));i.style.top=`${f}px`,i.style.maxHeight=`${Math.max(160,window.innerHeight-f-8)}px`,this.popup=i,this.colId=e;let p=v=>{ve(v,i,t)||this.close()},x=v=>{v.key==="Escape"&&(this.close(),this.grid.renderer.gridEl.focus())};document.addEventListener("pointerdown",p,!0),document.addEventListener("keydown",x,!0),this.off.push(()=>document.removeEventListener("pointerdown",p,!0),()=>document.removeEventListener("keydown",x,!0)),(M=i.querySelector(".fg-filter-value:not([hidden]), .fg-set-search, .fg-menu-item"))==null||M.focus()}filterSection(e,t){let n=this.grid.columns.getNode(e);if(!n||n.children)return null;let r=this.grid.store.state.locale,o=pe(n.def);return o==="set"?this.setFilter(e,r,t):o?this.conditionFilter(e,o,r,t):null}close(){var e;for(let t of this.off)t();this.off=[],(e=this.popup)==null||e.remove(),this.popup=null,this.colId=null}section(e){let t=k("div","fg-menu-section");for(let[n,r]of e){let o=k("button","fg-menu-item",{type:"button"});o.textContent=n,o.addEventListener("click",()=>{r(),this.close()}),t.append(o)}return t}actions(e,t,n,r){let o=k("div","fg-menu-actions"),i=k("button","fg-btn",{type:"button"});i.textContent=t.reset,i.addEventListener("click",()=>{this.grid.setFilter(e,null),r()});let a=k("button","fg-btn fg-btn-primary",{type:"button"});return a.textContent=t.apply,a.addEventListener("click",n),o.append(i,a),o}title(e){let t=k("div","fg-menu-title");return t.textContent=e.filter,t}conditionFilter(e,t,n,r){var x;let o=this.grid.store.state.filters[e],i=o&&o.type===t?o:void 0,a=k("div","fg-menu-section fg-filter"),l=k("select","fg-filter-op",{"aria-label":n.filter});for(let M of Yn[t]){let v=k("option");v.value=M,v.textContent=n.ops[M],l.append(v)}l.value=(x=i==null?void 0:i.op)!=null?x:Yn[t][0];let d=t==="text"?"text":t,c=k("input","fg-input fg-filter-value",{type:d,placeholder:n.value,"aria-label":n.value}),u=k("input","fg-input fg-filter-value-to",{type:d,placeholder:n.valueTo,"aria-label":n.valueTo});i&&(c.value=i.value!=null?String(i.value):"",u.value="valueTo"in i&&i.valueTo!=null?String(i.valueTo):"");let f=()=>{c.hidden=Zn.includes(l.value),u.hidden=l.value!=="between"};l.addEventListener("change",f),f();let p=()=>{let M=l.value,v=!Zn.includes(M),h=null;if(t==="number"){let y=c.value===""?void 0:Number(c.value),g=u.value===""?void 0:Number(u.value);(!v||y!==void 0)&&(h={type:t,op:M,value:y,valueTo:g})}else t==="date"?(!v||c.value)&&(h={type:t,op:M,value:c.value||void 0,valueTo:u.value||void 0}):(!v||c.value)&&(h={type:t,op:M,value:c.value});this.grid.setFilter(e,h),r()};for(let M of[c,u])M.addEventListener("keydown",v=>v.key==="Enter"&&p());return a.append(this.title(n),l,c,u,this.actions(e,n,p,r)),a}setFilter(e,t,n){let{grid:r}=this,o=r.columns.getNode(e).def,i=K(o,t.code),a=r.collator(),l=new Map;for(let S of r.rowModel.allNodes()){let E=B(o,S.data),m=Z(E);l.has(m)||l.set(m,E)}let d=[...l.entries()].sort((S,E)=>ue(S[1],E[1],a)),c=r.store.state.filters[e],u=new Set((c==null?void 0:c.type)==="set"?c.values.map(Z).filter(S=>l.has(S)):l.keys()),f=(S,E)=>S===""?t.blanks:i(E),p=k("div","fg-menu-section fg-filter fg-set-filter"),x=k("input","fg-input fg-set-search",{type:"search",placeholder:t.search,"aria-label":t.search}),M=k("label","fg-set-item fg-set-all"),v=k("input","fg-checkbox",{type:"checkbox"});M.append(v,document.createTextNode(t.selectAll));let h=k("div","fg-set-list"),y=()=>{let S=x.value.trim().toLowerCase();return S?d.filter(([E,m])=>f(E,m).toLowerCase().includes(S)):d},g=()=>{let S=y(),E=S.filter(([m])=>u.has(m)).length;v.checked=E>0&&E===S.length,v.indeterminate=E>0&&E<S.length},w=()=>{let S=y();if(h.replaceChildren(...S.slice(0,Wt).map(([E,m])=>{let R=k("label","fg-set-item"),I=k("input","fg-checkbox",{type:"checkbox"});return I.checked=u.has(E),I.addEventListener("change",()=>{I.checked?u.add(E):u.delete(E),g()}),R.append(I,document.createTextNode(f(E,m))),R})),S.length>Wt){let E=k("div","fg-set-more");E.textContent=`\u2026 +${S.length-Wt}`,h.append(E)}g()};v.addEventListener("change",()=>{for(let[S]of y())v.checked?u.add(S):u.delete(S);w()}),x.addEventListener("input",w);let C=()=>{r.setFilter(e,u.size===l.size?null:{type:"set",values:d.filter(([S])=>u.has(S)).map(([,S])=>S)}),n()};return x.addEventListener("keydown",S=>S.key==="Enter"&&C()),w(),p.append(this.title(t),x,M,h,this.actions(e,t,C,n)),p}};var Jn=new WeakMap,Lo=0;function $e(s){let e=Jn.get(s);return e||Jn.set(s,e=`r${++Lo}`),e}var wt=class{constructor(e){this.deps=e;this.stats={filterRuns:0,sortRuns:0};this.server=!1;this.full=[];this.last={};this.nodes=[];this.filtered=[];this.sorted=[];this.display=[];this.indexById=null;this.layoutCache=null}update(e){var u,f,p,x;let t=this.deps.collator(),n=e.display,r=!!(n!=null&&n.getParentId)!=!!((u=this.last.display)!=null&&u.getParentId),o=e.data!==this.last.data,i=o||r||e.filters!==this.last.filters||e.quickFilter!==this.last.quickFilter,a=i||e.sort!==this.last.sort||t!==this.last.collator,l=a||(n==null?void 0:n.version)!==this.last.displayVersion||(n==null?void 0:n.groupBy)!==((f=this.last.display)==null?void 0:f.groupBy);if(o){let M=this.deps.getRowId;this.nodes=e.data.map((v,h)=>({id:M?String(M(v)):$e(v),data:v,sourceIndex:h}))}i&&(this.filtered=this.filter(e),this.stats.filterRuns++),a&&(this.sorted=zn(this.filtered,e.sort,M=>this.deps.columnDef(M),t),this.stats.sortRuns++),l&&(this.full=n?this.buildDisplay(n,e.sort,t):this.sorted);let d=(p=e.page)!=null?p:null,c=(x=this.last.page)!=null?x:null;(l||(d==null?void 0:d.index)!==(c==null?void 0:c.index)||(d==null?void 0:d.size)!==(c==null?void 0:c.size))&&(this.display=d?this.full.slice(d.index*d.size,(d.index+1)*d.size):this.full,this.indexById=null,this.layoutCache=null),this.last={...e,collator:t,displayVersion:n==null?void 0:n.version}}invalidate(){this.last={}}fullCount(){return this.full.length}dataCount(){return this.sorted.length}loading(){return!1}getRowCount(){return this.display.length}getRow(e){return this.display[e]}rows(){return this.display}dataRows(){return this.sorted}allNodes(){return this.nodes}idOf(e){return this.deps.getRowId?String(this.deps.getRowId(e)):$e(e)}indexOfId(e){var t;return this.indexById||(this.indexById=new Map(this.display.map((n,r)=>[n.id,r]))),(t=this.indexById.get(e))!=null?t:-1}layout(e,t,n,r=0){var c;let o=this.layoutCache;if(o&&o.rows===this.display&&o.rh===e&&o.dh===t&&o.hv===r)return o;let i=this.display.length,a=new Float64Array(i+1),l=!0,d=n&&n.size?n:null;for(let u=0;u<i;u++){let f=this.display[u],p=e;f.kind==="detail"?p=t:d&&!f.kind&&(p=(c=d.get(f.id))!=null?c:e),p!==e&&(l=!1),a[u+1]=a[u]+p}return this.layoutCache={rows:this.display,rh:e,dh:t,hv:r,offsets:a,uniform:l},this.layoutCache}filter(e){var d;let t=Object.entries(e.filters).map(([c,u])=>({def:this.deps.columnDef(c),pred:cn(u)})).filter(c=>!!c.def),n=un(e.quickFilter),r=n.length?this.deps.quickColumns():[];if(!t.length&&!n.length)return this.nodes;let o=this.nodes.filter(c=>{for(let u of t)if(!u.pred(B(u.def,c.data)))return!1;if(n.length){let u=r.map(f=>this.deps.format(f,B(f,c.data))).join("").toLowerCase();if(!hn(n,u))return!1}return!0}),i=(d=e.display)==null?void 0:d.getParentId;if(!i)return o;let a=new Map(this.nodes.map(c=>[c.id,c])),l=new Set(o);for(let c of o){let u=i(c.data),f=new Set;for(;u!=null&&!f.has(u);){f.add(u);let p=a.get(String(u));if(!p)break;l.add(p),u=i(p.data)}}return this.nodes.filter(c=>l.has(c))}isOpen(e,t,n){let r=e.expanded.get(t);return r!==void 0?r:e.defaultExpanded===-1||n<e.defaultExpanded}withDetails(e,t,n){for(let r of t)n.push(r),e.detailOpen.has(r.id)&&(!e.isMaster||e.isMaster(r.data))&&n.push({id:`detail:${r.id}`,data:{},sourceIndex:-1,kind:"detail",detailOf:r})}buildDisplay(e,t,n){let r=[];if(e.getParentId)return this.buildTree(e,r),r;let o=e.groupBy.filter(a=>this.deps.columnDef(a));if(!o.length)return e.detailOpen.size?(this.withDetails(e,this.sorted,r),r):this.sorted;let i=(a,l,d)=>{var M;let c=o[l],u=this.deps.columnDef(c),f=new Map;for(let v of a){let h=B(u,v.data),y=O(h)?"":Z(h),g=f.get(y);g||f.set(y,g={value:h,nodes:[]}),g.nodes.push(v)}let p=((M=t.find(v=>v.colId===c))==null?void 0:M.dir)==="desc"?-1:1,x=[...f.entries()].sort((v,h)=>ue(v[1].value,h[1].value,n)*p);for(let[v,h]of x){let y=`${d}${c}:${v}`,g=this.isOpen(e,y,l);r.push({id:`group:${y}`,data:{},sourceIndex:-1,kind:"group",level:l,group:{key:y,colId:c,value:h.value,rows:h.nodes.map(w=>w.data),expanded:g}}),g&&(l+1<o.length?i(h.nodes,l+1,`${y}|`):this.withDetails(e,h.nodes.map(w=>({...w,level:l+1})),r))}};return i(this.sorted,0,""),r}buildTree(e,t){let n=new Set(this.sorted.map(a=>a.id)),r=new Map,o=[];for(let a of this.sorted){let l=e.getParentId(a.data),d=l==null?null:String(l);if(d!==null&&n.has(d)&&d!==a.id){let c=r.get(d);c||r.set(d,c=[]),c.push(a)}else o.push(a)}let i=(a,l,d)=>{var c,u,f;for(let p of a){if(d.has(p.id))continue;let x=(c=r.get(p.id))!=null?c:[],M=!x.length&&!!((u=e.lazyChildren)!=null&&u.call(e,p.id,p.data)),v=x.length>0&&this.isOpen(e,p.id,l),h={...p,level:l,hasChildren:x.length>0||M,expanded:v};M&&((f=e.loading)!=null&&f.has(p.id))&&(h.loading=!0),this.withDetails(e,[h],t),v&&i(x,l+1,new Set([...d,p.id]))}};i(o,0,new Set)}};var Io=3e3,Do=new Float64Array(0),Pe=class{constructor(e){this.deps=e;this.stats={filterRuns:0,sortRuns:0};this.server=!0;this.blocks=new Map;this.total=null;this.loadedEnd=0;this.gen=0;this.query=null;this.page=null;this.lastBlock=0;this.version=0;this.cache=null}get bs(){return this.page?this.page.size:this.deps.blockSize}get base(){return this.page?this.page.index*this.page.size:0}update(e){var i,a,l,d;let t=this.query,n=!t||t.sort!==e.sort||t.filters!==e.filters||t.quickFilter!==e.quickFilter,r=(i=e.page)!=null?i:null,o=((a=r==null?void 0:r.size)!=null?a:0)!==((d=(l=this.page)==null?void 0:l.size)!=null?d:0);this.query={sort:e.sort,filters:e.filters,quickFilter:e.quickFilter},this.page=r?{...r}:null,(n||o)&&this.purge(),this.ensure(Math.floor(this.base/this.bs))}invalidate(){}purge(){this.gen++,this.blocks.clear(),this.total=null,this.loadedEnd=0,this.touch(),this.query&&this.ensure(Math.floor(this.base/this.bs))}touch(){this.version++,this.cache=null}fullCount(){if(this.total!==null)return this.total;if(!this.loadedEnd)return 0;let e=this.blocks.get(Math.floor((this.loadedEnd-1)/this.bs));return this.loadedEnd+(e&&e.nodes.length<this.bs?0:this.bs)}getRowCount(){let e=this.fullCount();return this.page?Math.max(0,Math.min(this.page.size,e-this.base)):e}dataCount(){return this.fullCount()}loading(){for(let e of this.blocks.values())if(e.state==="loading")return!0;return!1}placeholder(e){return{id:`loading:${e}`,data:{},sourceIndex:-1,kind:"loading"}}peek(e){var r;let t=Math.floor(e/this.bs),n=this.blocks.get(t);return(n==null?void 0:n.state)==="loaded"&&(r=n.nodes[e-t*this.bs])!=null?r:null}getRow(e){let t=this.base+e,n=this.peek(t);return n||(e>=0&&e<this.getRowCount()&&this.ensure(Math.floor(t/this.bs)),this.placeholder(t))}ensure(e){var d;let t=this.blocks.get(e);if(t&&(t.state!=="failed"||Date.now()<((d=t.retryAt)!=null?d:0))||this.total!==null&&e*this.bs>=this.total&&e>0)return;let n=e*this.bs,r=n+this.bs,o=this.gen;this.lastBlock=e,this.blocks.set(e,{state:"loading",nodes:[]});let i=this.query,a=c=>{o===this.gen&&(this.blocks.set(e,{state:"failed",nodes:[],retryAt:Date.now()+Io}),this.deps.onFailed(n,r,c))},l;try{l=Promise.resolve(this.deps.datasource.getRows({start:n,end:r,sort:[...i.sort],filters:{...i.filters},quickFilter:i.quickFilter}))}catch(c){l=Promise.reject(c)}l.then(c=>{if(o!==this.gen)return;let u=Array.isArray(c==null?void 0:c.rows)?c.rows.filter(x=>x!==null&&typeof x=="object"):null;if(!u){N("datasource.getRows must resolve to { rows: Row[], total?: number }"),a(new Error("invalid datasource response"));return}let f=this.deps.getRowId,p=u.slice(0,this.bs).map((x,M)=>({id:f?String(f(x)):$e(x),data:x,sourceIndex:n+M}));this.blocks.set(e,{state:"loaded",nodes:p}),typeof c.total=="number"&&c.total>=0?this.total=c.total:p.length<this.bs&&(this.total=n+p.length),this.loadedEnd=Math.max(this.loadedEnd,n+p.length),this.evict(),this.touch(),this.deps.onLoaded(n,n+p.length,this.total)},a)}evict(){let e=Math.max(2,this.deps.maxBlocks);if(this.blocks.size<=e)return;let t=[...this.blocks.keys()].sort((n,r)=>Math.abs(r-this.lastBlock)-Math.abs(n-this.lastBlock));for(let n of t){if(this.blocks.size<=e)break;this.blocks.get(n).state!=="loading"&&this.blocks.delete(n)}}built(){var n;if(((n=this.cache)==null?void 0:n.ver)===this.version)return this.cache;let e=[];for(let r of[...this.blocks.keys()].sort((o,i)=>o-i)){let o=this.blocks.get(r);o.state==="loaded"&&e.push(...o.nodes)}let t=new Map;for(let r of e)t.set(r.id,r.sourceIndex);return this.cache={ver:this.version,data:e,rows:null,ids:t},this.cache}rows(){var t;let e=this.built();if(!e.rows){let n=this.getRowCount();e.rows=new Array(n);for(let r=0;r<n;r++)e.rows[r]=(t=this.peek(this.base+r))!=null?t:this.placeholder(this.base+r)}return e.rows}dataRows(){return this.built().data}allNodes(){return this.built().data}idOf(e){return this.deps.getRowId?String(this.deps.getRowId(e)):$e(e)}indexOfId(e){let t=this.built().ids.get(e);if(t===void 0)return-1;let n=t-this.base;return n>=0&&n<this.getRowCount()?n:-1}layout(){return{offsets:Do,uniform:!0}}};function Qn(s){let e=s.idAt(s.index);if(s.mode==="single"){let t=new Set;return s.toggle&&s.selected.has(e)||t.add(e),{selected:t,anchorIndex:s.index}}if(s.range&&s.anchorIndex!=null){let t=s.toggle?new Set(s.selected):new Set,n=Math.min(s.anchorIndex,s.index),r=Math.max(s.anchorIndex,s.index);for(let o=n;o<=r;o++)t.add(s.idAt(o));return{selected:t,anchorIndex:s.anchorIndex}}if(s.toggle){let t=new Set(s.selected);return t.has(e)?t.delete(e):t.add(e),{selected:t,anchorIndex:s.index}}return{selected:new Set([e]),anchorIndex:s.index}}var vt=class{constructor(e){this.bus=new we;this.current=e}get state(){return this.current}set(e){let t=Object.keys(e).filter(n=>e[n]!==this.current[n]);t.length&&(this.current={...this.current,...e},this.bus.emit("change",t))}};var er=s=>Math.round(s*2.75),tr=s=>Math.round(s*3.1),nr=13,To=[],$o=100,Po=new Map;function ae(s){return s.every(e=>e!==null&&typeof e=="object")?s:(N("data contains entries that are not objects; they were skipped"),s.filter(e=>e!==null&&typeof e=="object"))}var jt=class{constructor(e,t){this.options=t;this.events=new we;this.pinnedRows={top:[],bottom:[]};this.spanCache=null;this.editVersion=0;this.tracker=new it;this.history=new st;this.disposers=[];this.collatorCache=null;this.destroyed=!1;this.summaryOpts=null;this.summaryValues=[];this.groupBy=[];this.expanded=new Map;this.defaultExpanded=0;this.detailOpen=new Set;this.displayVersion=0;this.aggCache={ver:-1,map:new WeakMap};this.charts=new gt(this);this.sourceDefs=[];this.pivotCfg=null;this.pivotData=null;this.savedGroup=null;this.page=0;this.pageSize=$o;this.treeLoaded=new Set;this.treeLoading=new Set;this.lazyChildren=(e,t)=>{var n,r;if(this.treeLoaded.has(e))return!1;try{return!!((r=(n=this.options.treeData)==null?void 0:n.hasChildren)!=null&&r.call(n,t))}catch{return!1}};var i,a,l,d,c,u,f,p,x,M;Array.isArray(t.columns)||N("options.columns must be an array"),t.data!=null&&!Array.isArray(t.data)&&N("options.data must be an array"),this.store=new vt({data:Array.isArray(t.data)?ae(t.data):[],sort:[],filters:{},quickFilter:"",selected:new Set,anchorId:null,focus:null,range:null,extraRanges:[],locale:Re(t.locale),theme:(i=t.theme)!=null?i:"light"}),this.sourceDefs=Array.isArray(t.columns)?t.columns:[],this.columns=new He(this.withSelect(this.sourceDefs));let n=t.pagination;n&&typeof n=="object"&&n.pageSize!==void 0&&(Number.isInteger(n.pageSize)&&n.pageSize>0?this.pageSize=n.pageSize:N("pagination.pageSize must be a positive integer")),t.datasource&&typeof t.datasource.getRows!="function"&&N("datasource.getRows must be a function"),this.rowModel=t.datasource&&typeof t.datasource.getRows=="function"?new Pe({datasource:t.datasource,blockSize:Number.isInteger(t.blockSize)&&t.blockSize>0?t.blockSize:100,maxBlocks:Number.isInteger(t.maxBlocks)&&t.maxBlocks>0?t.maxBlocks:100,getRowId:t.getRowId,onLoaded:(v,h,y)=>this.serverLoaded(v,h,y),onFailed:(v,h,y)=>this.serverFailed(v,h,y)}):new wt({getRowId:t.getRowId,columnDef:v=>{var h;return(h=this.columns.getNode(v))==null?void 0:h.def},quickColumns:()=>this.columns.displayed().filter(v=>!P(v.id)).map(v=>v.def),format:(v,h)=>K(v,this.store.state.locale.code)(h),collator:()=>this.collator()}),this.groupBy=this.validGroupBy((a=t.groupBy)!=null?a:[]),this.defaultExpanded=(l=t.groupDefaultExpanded)!=null?l:0,t.treeData&&!t.getRowId&&N("treeData needs getRowId so parent ids can be matched"),this.updateRows(),this.summaryOpts=(d=t.summary)!=null?d:null,this.refreshSummary();let r=t.fontSize!=null&&t.fontSize>0?t.fontSize:null;t.fontSize!=null&&!(t.fontSize>0)&&N("fontSize must be a positive number"),this.font={size:r,family:(c=t.fontFamily)!=null?c:null};let o=r!=null?r:nr;if(this.renderer=new qe(e,this,{rowHeight:(u=t.rowHeight)!=null?u:er(o),headerHeight:(f=t.headerHeight)!=null?f:tr(o)}),this.renderer.applyFont(this.font.size,this.font.family),this.menu=new mt(this),this.chooser=new Ze(this),this.contextMenu=new Qe(this),this.editor=new ot(this),this.finder=new tt(this),this.fillHandle=new et(this),this.groupPanel=t.groupPanel?new Ke(this):null,this.pinnedRows={top:ae((p=t.pinnedTopRows)!=null?p:[]),bottom:ae((x=t.pinnedBottomRows)!=null?x:[])},this.sideBar=t.sideBar?new Je(this,typeof t.sideBar=="object"&&!!t.sideBar.open,(M=typeof t.sideBar=="object"?t.sideBar.panels:void 0)!=null?M:t.pivot||t.pivotPanel?["columns","filters","pivot"]:void 0):null,this.disposers.push(this.store.bus.on("change",v=>this.onChange(v)),Ln(this),Cn(this),()=>this.menu.close(),()=>this.chooser.close(),()=>this.contextMenu.destroy(),()=>this.editor.cancel(),()=>this.fillHandle.destroy(),()=>{var v;return(v=this.groupPanel)==null?void 0:v.destroy()},()=>this.charts.destroy()),typeof ResizeObserver!="undefined"){let v=new ResizeObserver(()=>this.renderer.schedule());v.observe(this.renderer.main),this.disposers.push(()=>v.disconnect())}t.pivot&&this.setPivot(t.pivot),Xn(t.licenseKey).then(v=>{v&&!this.destroyed&&this.renderer.showFreeBadge()}),this.renderer.render(),this.api=this.createApi(),_e.set(this.renderer.root,this)}collator(){var t;let e=this.store.state.locale.code;return((t=this.collatorCache)==null?void 0:t.code)!==e&&(this.collatorCache={code:e,collator:new Intl.Collator(e,{numeric:!0,sensitivity:"base"})}),this.collatorCache.collator}layoutChanged(){this.renderer.invalidateHeights(),this.renderer.invalidate({header:!0,rows:!0}),this.refreshChoosers()}columnsChanged(){this.rowModel.invalidate(),this.updateRows(),this.refreshSummary(),this.renderer.invalidate({header:!0,rows:!0}),this.refreshChoosers()}display(){var e,t;return{groupBy:this.options.treeData?To:this.groupBy,getParentId:(e=this.options.treeData)==null?void 0:e.getParentId,expanded:this.expanded,defaultExpanded:this.defaultExpanded,detailOpen:this.options.detailRenderer?this.detailOpen:new Set,isMaster:this.options.isRowMaster,lazyChildren:(t=this.options.treeData)!=null&&t.hasChildren?this.lazyChildren:void 0,loading:this.treeLoading,version:this.displayVersion}}updateRows(){var n;let e=!!this.options.pagination,t=(n=this.pivotData)!=null?n:this.store.state.data;this.rowModel.update({...this.store.state,data:t,display:this.display(),page:e?{index:this.page,size:this.pageSize}:null}),e&&this.page>=this.getPageCount()&&(this.page=this.getPageCount()-1,this.rowModel.update({...this.store.state,data:t,display:this.display(),page:{index:this.page,size:this.pageSize}}))}viewRows(){var e;return(e=this.pivotData)!=null?e:this.store.state.data}sourceLeaves(){let e=[],t=n=>{var r,o;for(let i of n)!i||typeof i!="object"||(Array.isArray(i.children)?t(i.children):((r=i.id)!=null?r:i.field)&&e.push({id:(o=i.id)!=null?o:i.field,def:i}))};return t(this.sourceDefs),e}getPivot(){let e=this.pivotCfg;if(!e)return null;let t={rows:[...e.rows],columns:[...e.columns],values:e.values.map(n=>({...n}))};return e.totals||(t.totals=!1),t}setPivot(e){if(e&&this.clientOnly("pivot"))return;if(e&&(typeof e!="object"||!Array.isArray(e.rows)||!Array.isArray(e.values))){N("setPivot: expected { rows: string[], values: [...] }");return}if(this.editor.cancel(),!e){if(!this.pivotCfg)return;this.pivotCfg=null,this.pivotData=null,this.columns.setDefs(this.withSelect(this.sourceDefs)),this.savedGroup&&(this.groupBy=this.savedGroup.groupBy,this.expanded=this.savedGroup.expanded,this.defaultExpanded=this.savedGroup.defaultExpanded,this.savedGroup=null),this.afterPivotSwitch();return}let t=new Set(this.sourceLeaves().map(n=>n.id));this.pivotCfg||(this.savedGroup={groupBy:this.groupBy,expanded:this.expanded,defaultExpanded:this.defaultExpanded}),this.pivotCfg=Vt(e,n=>t.has(n)),this.expanded=new Map,this.defaultExpanded=-1,this.rebuildPivot(!1),this.afterPivotSwitch()}afterPivotSwitch(){var e;this.page=0,this.store.set({sort:[],filters:{},range:null,focus:null}),this.rowModel.invalidate(),this.updateRows(),this.displayVersion++,this.updateRows(),(e=this.groupPanel)==null||e.refresh(),this.renderer.invalidate({header:!0,rows:!0}),this.refreshChoosers(),this.events.emit("pivotChange",{pivot:this.getPivot()})}rebuildPivot(e=!0){let t=this.pivotCfg;if(!t)return;let n=this.store.state.locale,r=new Map(this.sourceLeaves().map(d=>[d.id,d.def])),o={sum:n.sum,avg:n.avg,min:n.min,max:n.max,count:n.count},i=Vn(this.store.state.data,t,d=>r.get(d),{total:n.total,blank:n.blanks,agg:d=>{var c;return(c=o[d])!=null?c:d}},n.code);if(this.pivotData=i.rows,this.columns.setDefs(this.withSelect(i.columns)),this.groupBy=i.groupBy,!e)return;let a=d=>!!this.columns.getNode(d),l=this.store.state;(l.sort.some(d=>!a(d.colId))||Object.keys(l.filters).some(d=>!a(d)))&&this.store.set({sort:l.sort.filter(d=>a(d.colId)),filters:Object.fromEntries(Object.entries(l.filters).filter(([d])=>a(d)))}),this.rowModel.invalidate(),this.displayVersion++,this.updateRows(),this.renderer.invalidate({header:!0,rows:!0}),this.refreshChoosers()}getPage(){return this.options.pagination?this.page:0}getPageSize(){return this.options.pagination?this.pageSize:this.rowModel.fullCount()}getPageCount(){return this.options.pagination?Math.max(1,Math.ceil(this.rowModel.fullCount()/this.pageSize)):1}setPage(e){if(!this.options.pagination||!Number.isFinite(e))return;let t=Math.max(0,Math.min(this.getPageCount()-1,Math.floor(e)));t!==this.page&&(this.veto("beforePageChange",{page:t,pageSize:this.pageSize})||(this.page=t,this.pageMoved()))}setPageSize(e){if(!this.options.pagination)return;if(!Number.isInteger(e)||e<=0){N("setPageSize: size must be a positive integer");return}if(e===this.pageSize)return;let t=this.page*this.pageSize;this.veto("beforePageChange",{page:Math.floor(t/e),pageSize:e})||(this.pageSize=e,this.page=Math.floor(t/e),this.pageMoved())}pageMoved(){this.editor.cancel(),this.updateRows(),this.store.state.range&&this.setRange(null);let e=this.rowModel.getRowCount(),t=this.store.state.focus;t&&t.rowIndex>=e&&this.store.set({focus:e?{...t,rowIndex:e-1}:null}),this.renderer.scroller.scrollTop=0,this.finder.refresh(),this.renderer.invalidate({header:!0,rows:!0}),this.emitPage()}emitPage(){this.events.emit("pageChange",{page:this.page,pageSize:this.pageSize,pageCount:this.getPageCount()})}refreshRows(){this.rowModel instanceof Pe&&(this.rowModel.purge(),this.renderer.invalidate({rows:!0}))}serverLoaded(e,t,n){this.destroyed||(this.renderer.invalidate({header:!0,rows:!0}),this.events.emit("rowsLoaded",n===null?{start:e,end:t}:{start:e,end:t,total:n}))}serverFailed(e,t,n){this.destroyed||(N(`datasource.getRows failed for rows ${e}\u2013${t}`),this.toast(this.store.state.locale.loadFailed),this.renderer.invalidate({rows:!0}),this.events.emit("rowsLoadFailed",{start:e,end:t,error:n}))}syncScroll(e,t){if(!e||typeof e.setScrollPosition!="function"||e===this.api)return()=>{};let n=new Map,r=a=>`${a.top},${a.left}`,o=(a,l)=>a.on("scroll",d=>{if(n.get(a)===r(d)){n.delete(a);return}l.setScrollPosition(t==="vertical"?{top:d.top}:t==="horizontal"?{left:d.left}:d),n.set(l,r(l.getScrollPosition()))}),i=[o(this.api,e),o(e,this.api)];return()=>{for(let a of i)a()}}veto(e,t){let n=!1;return this.events.emit(e,{...t,cancel:()=>{n=!0}}),n}clientOnly(e){return this.rowModel.server?(N(`${e} is not available with a datasource`),!0):!1}displayChanged(){this.displayVersion++,this.updateRows(),this.store.state.range&&this.setRange(null);let e=this.rowModel.getRowCount(),t=this.store.state.focus;t&&t.rowIndex>=e&&this.store.set({focus:e?{...t,rowIndex:e-1}:null}),this.finder.refresh(),this.renderer.invalidate({header:!0,rows:!0})}validGroupBy(e){return Array.isArray(e)?e.length&&this.clientOnly("grouping")?[]:[...new Set(e)].filter(t=>{let n=this.columns.getNode(t);return!n||n.children||P(t)?(N(`groupBy: unknown column "${t}"`),!1):!0}):[]}getGroupBy(){return[...this.groupBy]}setGroupBy(e){var n;let t=this.validGroupBy(e);t.join("")!==this.groupBy.join("")&&(this.groupBy=t,this.page=0,(n=this.groupPanel)==null||n.refresh(),this.displayChanged(),this.events.emit("groupChange",{groupBy:[...t]}))}isExpandable(e){return!!e&&(e.kind==="group"||!!e.hasChildren)}expandKey(e){return e.group?e.group.key:e.id}loadChildren(e){let t=this.options.treeData,n=e.id;if(this.treeLoading.has(n))return;if(typeof t.loadChildren!="function"){N("treeData.hasChildren needs treeData.loadChildren");return}this.treeLoading.add(n),this.displayChanged();let r=()=>(this.treeLoading.delete(n),!this.destroyed&&this.store.state.data.includes(e.data));Promise.resolve().then(()=>t.loadChildren(e.data)).then(o=>{if(!r())return;let i=ae(Array.isArray(o)?o:[]);this.treeLoaded.add(n),this.expanded.set(n,!0),i.length&&this.replaceData([...this.store.state.data,...i]),this.displayChanged(),this.events.emit("childrenLoaded",{row:e.data,rows:i}),this.events.emit("groupToggle",{key:n,expanded:!0})},o=>{r()&&(N(`treeData.loadChildren failed for row "${n}"`),this.displayChanged(),this.events.emit("childrenLoadFailed",{row:e.data,error:o}))})}setGroupExpanded(e,t){var o,i;let n=this.rowModel.rows().find(a=>this.isExpandable(a)&&this.expandKey(a)===e);if((n?!!((i=(o=n.group)==null?void 0:o.expanded)!=null?i:n.expanded):this.expanded.get(e))!==t){if(t&&n&&!n.group&&this.options.treeData&&this.lazyChildren(n.id,n.data)){this.loadChildren(n);return}this.expanded.set(e,t),this.displayChanged(),this.events.emit("groupToggle",{key:e,expanded:t})}}toggleRow(e){var n,r;let t=this.rowModel.getRow(e);this.isExpandable(t)&&this.setGroupExpanded(this.expandKey(t),!((r=(n=t.group)==null?void 0:n.expanded)!=null?r:t.expanded))}expandAll(e=!0){this.expanded.clear(),this.defaultExpanded=e?-1:0,this.displayChanged()}groupAggregate(e,t){var o;let n=(o=this.columns.getNode(t))==null?void 0:o.def;if(!e.group||!(n!=null&&n.aggFunc))return;this.aggCache.ver!==this.editVersion&&(this.aggCache={ver:this.editVersion,map:new WeakMap});let r=this.aggCache.map.get(e.group);if(r||this.aggCache.map.set(e.group,r=new Map),!r.has(t)){let i=e.group.rows;try{r.set(t,me(n.aggFunc,i.map(a=>B(n,a)),i))}catch{N(`aggFunc of column "${t}" threw`),r.set(t,null)}}return r.get(t)}canExpandDetail(e){if(!this.options.detailRenderer)return!1;try{return!this.options.isRowMaster||!!this.options.isRowMaster(e)}catch{return!1}}isDetailExpanded(e){return!!e&&typeof e=="object"&&this.detailOpen.has(this.rowModel.idOf(e))}setDetailExpanded(e,t){if(!e||typeof e!="object"||t&&!this.canExpandDetail(e))return;let n=this.rowModel.idOf(e);this.detailOpen.has(n)!==t&&(t?this.detailOpen.add(n):(this.detailOpen.delete(n),this.renderer.dropDetail(n)),this.displayChanged(),this.events.emit("detailToggle",{row:e,expanded:t}))}canMoveRows(){let e=this.store.state,t=this.options.treeData;return!this.rowModel.server&&!e.sort.length&&!Object.keys(e.filters).length&&!e.quickFilter.trim()&&!this.groupBy.length&&(!t||typeof t.setParentId=="function")}get dragOptions(){let e=this.options.rowDrag;return e&&typeof e=="object"?e:{}}parentOf(e){let t=null;try{t=this.options.treeData.getParentId(e)}catch{t=null}return t==null?null:String(t)}rawParent(e){var t;try{return(t=this.options.treeData.getParentId(e))!=null?t:null}catch{return null}}idValue(e){let t=this.rowModel.idOf(e);for(let r of this.store.state.data){let o=this.rawParent(r);if(o!==null&&String(o)===t)return o}return this.store.state.data.some(r=>typeof this.rawParent(r)=="number")&&t.trim()!==""&&Number.isFinite(Number(t))?Number(t):t}canDropRow(e,t,n,r=this){if(!this.canMoveRows()||t===e)return!1;if(r===this&&this.options.treeData&&t){let i=this.rowModel.idOf(e),a=new Set;for(let l=this.rowModel.idOf(t);l!==null&&!a.has(l);){if(l===i)return!1;a.add(l);let d=this.rowModel.allNodes().find(c=>c.id===l);l=d?this.parentOf(d.data):null}}let o=this.dragOptions.canDrop;if(!o)return!0;try{return o({row:e,target:t,position:n,fromOtherGrid:r!==this})!==!1}catch{return N("rowDrag.canDrop threw; the drop was refused"),!1}}dropRow(e,t,n="after",r=this){var h,y;if(this.clientOnly("dropRow")||!e||typeof e!="object")return!1;let o=this.options.treeData;!o&&n==="inside"&&(n="after");let i=this.store.state.data,a=r!==this,l=a?-1:i.indexOf(e);if(!a&&l<0||t&&!i.includes(t)||a&&(!r.canMoveRows()||i.includes(e))||!this.canDropRow(e,t,n,r))return!1;let d=o?this.rawParent(e):null,c=!o||!t?null:n==="inside"?t:(h=this.store.state.data.find(g=>this.rowModel.idOf(g)===this.parentOf(t)))!=null?h:null,u=c?this.idValue(c):null,f=i.filter(g=>g!==e),p=!t||n==="inside"?f.length:f.indexOf(t)+(n==="after"?1:0);f.splice(p,0,e);let x=f.some((g,w)=>g!==i[w]);if(!a&&!x&&String(d!=null?d:"")===String(u!=null?u:""))return!1;let M=(g,w)=>{try{o.setParentId(e,g,w)}catch{N("treeData.setParentId threw")}},v=o&&(y=this.store.state.data.find(g=>this.rowModel.idOf(g)===this.parentOf(e)))!=null?y:null;return a?(r.removeRows([e]),o&&M(u,c),this.addRows([e],p)):(o&&M(u,c),this.replaceData(f),this.history.push({undo:()=>{o&&M(d,v),this.replaceData(i)},redo:()=>{o&&M(u,c),this.replaceData(f)}}),this.events.emit("rowDragEnd",{row:e,fromIndex:l,toIndex:p})),this.events.emit("rowDrop",{row:e,target:t,position:n,fromOtherGrid:a,fromGrid:a?r.api:null}),!0}moveRow(e,t,n=!0){if(this.clientOnly("moveRow")||!this.canMoveRows())return!1;let r=this.store.state.data,o=r.indexOf(e);if(o<0||!Number.isFinite(t))return!1;let i=Math.max(0,Math.min(r.length-1,Math.floor(t)));if(i===o)return!1;let a=[...r];return a.splice(o,1),a.splice(i,0,e),this.replaceData(a),n&&this.history.push({undo:()=>this.moveRow(e,o,!1),redo:()=>this.moveRow(e,i,!1)}),this.events.emit("rowDragEnd",{row:e,fromIndex:o,toIndex:i}),!0}setFont(e){let t=this.font.size;e.size!==void 0&&(typeof e.size=="number"&&e.size>0?t=e.size:N("setFont: size must be a positive number"));let n=e.family===void 0?this.font.family:e.family||null;this.font={size:t,family:n};let r=t!=null?t:nr;this.options.rowHeight==null&&(this.renderer.opts.rowHeight=er(r)),this.options.headerHeight==null&&(this.renderer.opts.headerHeight=tr(r)),this.renderer.applyFont(t,n),this.renderer.invalidateHeights(),this.menu.close(),this.layoutChanged()}applyFontTo(e){this.font.size&&e.style.setProperty("--fg-font-size",`${this.font.size}px`),this.font.family&&e.style.setProperty("--fg-font",this.font.family)}summary(){var e;return this.summaryOpts&&((e=this.summaryOpts.rows)!=null&&e.length)?{opts:this.summaryOpts,values:this.summaryValues}:null}setSummary(e){if(e&&!Array.isArray(e.rows)){N("setSummary: summary.rows must be an array");return}this.summaryOpts=e,this.refreshSummary(),this.renderer.invalidate({header:!0,rows:!0})}refreshSummary(){var r,o;let e=this.summaryOpts;if(!((r=e==null?void 0:e.rows)!=null&&r.length)){this.summaryValues=[];return}let t=(o=e.scope)!=null?o:"filtered",n=t==="all"?this.rowModel.allNodes().map(i=>i.data):t==="selected"?this.selectedRows():this.rowModel.dataRows().map(i=>i.data);this.summaryValues=mn(e.rows,n,i=>{var a;return(a=this.columns.getNode(i))==null?void 0:a.def})}dataColumns(){return this.columns.displayed().filter(e=>!P(e.id))}validRange(e){if(!e||this.options.rangeSelection===!1)return null;let t=this.rowModel.getRowCount(),n=r=>!!r&&!P(r.colId)&&!!this.columns.getColumn(r.colId)&&r.rowIndex>=0&&r.rowIndex<t;return n(e.start)&&n(e.end)?{start:{...e.start},end:{...e.end}}:null}setRange(e,t=!1){let n=this.validRange(e),r=t||!this.store.state.extraRanges.length?this.store.state.extraRanges:[],o=this.store.state.range;JSON.stringify(o)===JSON.stringify(n)&&r===this.store.state.extraRanges||(this.store.set({range:n,extraRanges:r}),this.events.emit("rangeChange",{range:n&&{start:{...n.start},end:{...n.end}}}))}addRange(e){let{range:t,focus:n}=this.store.state,r=this.validRange(t!=null?t:n?{start:n,end:n}:null);r&&this.store.set({extraRanges:[...this.store.state.extraRanges,r]}),this.setRange(e,!0)}getRanges(){let e=[...this.store.state.extraRanges];return this.store.state.range&&e.push(this.store.state.range),e.map(t=>({start:{...t.start},end:{...t.end}}))}setRanges(e){var n;let t=(Array.isArray(e)?e:[]).map(r=>this.validRange(r)).filter(r=>!!r);this.store.set({extraRanges:t.slice(0,-1)}),this.setRange((n=t[t.length-1])!=null?n:null,!0)}boundsOf(e){if(!e)return null;let t=this.columns.getColumn(e.start.colId),n=this.columns.getColumn(e.end.colId);return!t||!n?null:Le({start:{rowIndex:e.start.rowIndex,colIndex:t.index},end:{rowIndex:e.end.rowIndex,colIndex:n.index}})}rangeBounds(){return this.boundsOf(this.store.state.range)}allRangeBounds(){return[...this.store.state.extraRanges,this.store.state.range].map(e=>this.boundsOf(e)).filter(e=>!!e)}rangeContains(e,t){let n=this.columns.getColumn(t);return!!n&&this.allRangeBounds().some(r=>Mn(r,e,n.index))}selectAllCells(){let e=this.dataColumns(),t=this.rowModel.getRowCount();!e.length||!t||(this.store.state.focus||this.setFocus(0,e[0].id),this.setRange({start:{rowIndex:0,colId:e[0].id},end:{rowIndex:t-1,colId:e[e.length-1].id}}))}selectionTSV(e,t=!1){let n=this.store.state.locale.code,r=this.columns.displayed(),o=t?null:this.rangeBounds(),i=t,a,l,d=t?[]:this.allRangeBounds();if(d.length>1){let u=d.every(p=>p.c1===d[0].c1&&p.c2===d[0].c2),f=d.every(p=>p.r1===d[0].r1&&p.r2===d[0].r2);if(u||f){let p=[...d].sort((v,h)=>u?v.r1-h.r1:v.c1-h.c1),x=p.map(v=>this.rangeMatrix(v)),M=u?x.flat():x[0].map((v,h)=>x.flatMap(y=>{var g;return(g=y[h])!=null?g:[]}));return e&&M.unshift((u?p.slice(0,1):p).flatMap(v=>this.rangeHeaders(v))),Dt(M)}}if(o){a=[];for(let u=o.r1;u<=o.r2;u++){let f=this.rowModel.getRow(u);f.kind||a.push(f.data)}l=r.slice(o.c1,o.c2+1).filter(u=>!P(u.id))}else if(i){let u=this.store.state.selected;a=this.rowModel.dataRows().filter(f=>u.has(f.id)).map(f=>f.data),l=this.dataColumns()}else{let u=this.store.state.focus,f=u&&this.columns.getColumn(u.colId),p=u&&this.rowModel.getRow(u.rowIndex);if(!f||!p||p.kind||P(f.id))return"";a=[p.data],l=[f]}let c=a.map(u=>l.map(f=>this.copyCell(f.def,u,n)));return e&&c.unshift(l.map(u=>{var f,p;return(p=(f=u.def.header)!=null?f:u.def.field)!=null?p:u.id})),Dt(c)}rangeHeaders(e){return this.columns.displayed().slice(e.c1,e.c2+1).filter(t=>!P(t.id)).map(t=>{var n,r;return(r=(n=t.def.header)!=null?n:t.def.field)!=null?r:t.id})}rangeMatrix(e){let t=this.columns.displayed().slice(e.c1,e.c2+1).filter(o=>!P(o.id)),n=this.store.state.locale.code,r=[];for(let o=e.r1;o<=e.r2;o++){let i=this.rowModel.getRow(o);i&&!i.kind&&r.push(t.map(a=>this.copyCell(a.def,i.data,n)))}return r}copyCell(e,t,n){let r=B(e,t),o=e.copyable;if(o===!1)return"";if(typeof o=="function"){let i=!1;try{i=o({value:r,row:t,column:e})!==!1}catch{i=!1}if(!i)return""}return nt(e,r,n)}copyToClipboard(e,t=!1){var r,o,i;let n=this.selectionTSV(e,t);if(n&&typeof navigator!="undefined"&&((r=navigator.clipboard)!=null&&r.writeText))try{(i=(o=navigator.clipboard.writeText(n))==null?void 0:o.catch)==null||i.call(o,()=>{})}catch{}return n}pasteText(e){var M;let t=kn(e),n={changed:0,skipped:0};if(!t.length)return n;let r=this.columns.displayed(),o=this.rowModel.getRowCount(),i=this.rangeBounds(),a=this.store.state.focus,l=a&&this.columns.getColumn(a.colId),d,c;if(i)d=i.r1,c=i.c1;else if(a&&l&&!P(l.id))d=a.rowIndex,c=l.index;else return n;let u=[],f=t.length===1&&t[0].length===1,p=f&&i?i.r2-i.r1+1:t.length,x=f&&i?i.c2-i.c1+1:Math.max(...t.map(v=>v.length));for(let v=0;v<p;v++){let h=d+v;if(h>=o)break;let y=this.rowModel.getRow(h);if(!y.kind)for(let g=0;g<x;g++){let w=r[c+g];if(!w)break;if(P(w.id))continue;let C=f&&i?t[0][0]:(M=t[v])==null?void 0:M[g];if(C===void 0)continue;let S=w.def;if(!S.field||!ne(S,y.data,h)){n.skipped++;continue}let E=y.data[S.field],m=this.acceptText(S,y.data,C,E);if(!m.ok){n.skipped++;continue}this.writeCell(u,y.data,S.field,w.id,h,m.value)&&n.changed++}}return this.endCellTx(u),this.events.emit("paste",{...n}),n}acceptText(e,t,n,r){var a;let o,i=e.editor;if(i&&typeof i=="object"&&i.type==="select"){let l=(a=typeof i.options=="function"?i.options(t):i.options)!=null?a:[],d=n.trim().toLowerCase(),c=l.map(u=>u!==null&&typeof u=="object"&&"value"in u?u:{value:u,label:String(u),disabled:!1}).find(u=>{var f;return String(u.value).toLowerCase()===d||((f=u.label)!=null?f:"").toLowerCase()===d});if(!c||c.disabled)return{ok:!1};o=c.value}else if(e.formulas&&ge(n.trim()))o=n.trim();else{let l=rt(e,n,r);if(!l.ok)return l;o=l.value}return this.cellError(e,t,o)!==null?{ok:!1}:{ok:!0,value:o}}cellError(e,t,n){let r=this.store.state.locale;if(e.required&&O(n))return r.required;if(e.unique&&e.field&&!O(n)){let o=n instanceof Date?n.getTime():String(n),i=e.field;if(this.store.state.data.some(a=>{if(a===t)return!1;let l=a[i];return!O(l)&&(l instanceof Date?l.getTime():String(l))===o}))return r.duplicate}if(e.validate){let o;try{o=e.validate(n,t)}catch{o=r.invalidValue}if(o!==!0)return typeof o=="string"&&o?o:r.invalidValue}return null}validateAll(){let e=[],t=this.columns.getState().map(n=>({id:n.colId,def:this.columns.getNode(n.colId).def})).filter(n=>n.def.field&&n.def.editable&&(n.def.required||n.def.unique||n.def.validate));return this.store.state.data.forEach((n,r)=>{let o=this.rowModel.idOf(n),i=this.rowModel.indexOfId(o);for(let a of t){if(!ne(a.def,n,i<0?r:i))continue;let l=this.cellError(a.def,n,n[a.def.field]);l!==null&&e.push({row:n,rowIndex:i,colId:a.id,message:l})}}),e}mergeSpans(){if(this.rowModel.server||!this.columns.displayed().some(o=>o.def.merge||o.def.rowSpan))return Po;let e=this.rowModel.rows(),t=this.editVersion*1e6+this.columns.displayed().length;if(this.spanCache&&this.spanCache.rows===e&&this.spanCache.ver===t)return this.spanCache.spans;let n=new Map,r=this.columns.displayed().filter(o=>o.def.merge||o.def.rowSpan);if(r.length&&!e.some(o=>o.kind)){let o=e.map(i=>i.data);for(let i of r)n.set(i.id,Ve(o,i.def))}return this.spanCache={rows:e,ver:t,spans:n},n}rangeAggregates(){let e=this.allRangeBounds();if(!e.length)return null;let t=this.columns.displayed(),n={cells:0,count:0,numbers:0,sum:0,min:1/0,max:-1/0},r=e.length>1?new Set:null;for(let o of e)for(let i=o.r1;i<=o.r2;i++){let a=this.rowModel.getRow(i);if(!a||a.kind)continue;let l=a.data;for(let d of t.slice(o.c1,o.c2+1)){if(P(d.id))continue;if(r){let u=`${i},${d.index}`;if(r.has(u))continue;r.add(u)}n.cells++;let c=B(d.def,l);if(!O(c)&&(n.count++,typeof c=="number"||d.def.type==="number"&&!Number.isNaN(Number(c)))){let u=Number(c);n.numbers++,n.sum+=u,u<n.min&&(n.min=u),u>n.max&&(n.max=u)}}}return n}fillRange(e){var u;let t=(u=this.rangeBounds())!=null?u:(()=>{let f=this.store.state.focus,p=f&&this.columns.getColumn(f.colId);return f&&p&&!P(p.id)?{r1:f.rowIndex,r2:f.rowIndex,c1:p.index,c2:p.index}:null})(),n=this.columns.getColumn(e.start.colId),r=this.columns.getColumn(e.end.colId);if(!t||!n||!r)return;let o=Le({start:{rowIndex:e.start.rowIndex,colIndex:n.index},end:{rowIndex:e.end.rowIndex,colIndex:r.index}}),i=this.rowModel.getRowCount();o.r1=Math.max(0,o.r1),o.r2=Math.min(i-1,o.r2);let a=this.columns.displayed(),l=[],d=(f,p,x)=>{let M=a[p],v=this.rowModel.getRow(f),h=M==null?void 0:M.def;!v||v.kind||!(h!=null&&h.field)||P(M.id)||!ne(h,v.data,f)||this.cellError(h,v.data,x)===null&&this.writeCell(l,v.data,h.field,M.id,f,x)},c=(f,p)=>B(a[p].def,this.rowModel.getRow(f).data);if(o.r1<t.r1||o.r2>t.r2)for(let f=t.c1;f<=t.c2;f++){let p=[],x=[];for(let M=t.r1;M<=t.r2;M++)p.push(c(M,f));for(let M=t.r2;M>=t.r1;M--)x.push(c(M,f));Ee(p,o.r2-t.r2).forEach((M,v)=>d(t.r2+1+v,f,M)),Ee(x,t.r1-o.r1).forEach((M,v)=>d(t.r1-1-v,f,M))}else if(o.c1<t.c1||o.c2>t.c2)for(let f=t.r1;f<=t.r2;f++){let p=[],x=[];for(let M=t.c1;M<=t.c2;M++)p.push(c(f,M));for(let M=t.c2;M>=t.c1;M--)x.push(c(f,M));Ee(p,o.c2-t.c2).forEach((M,v)=>d(f,t.c2+1+v,M)),Ee(x,t.c1-o.c1).forEach((M,v)=>d(f,t.c1-1-v,M))}else return;this.endCellTx(l),this.setRange({start:{rowIndex:o.r1,colId:a[o.c1].id},end:{rowIndex:o.r2,colId:a[o.c2].id}})}setPinnedRows(e){e.top&&(this.pinnedRows.top=ae(e.top)),e.bottom&&(this.pinnedRows.bottom=ae(e.bottom)),this.renderer.invalidate({rows:!0})}writeCell(e,t,n,r,o,i){let a=t[n];return Object.is(a,i)||this.veto("beforeCellChange",{row:t,rowIndex:o,colId:r,oldValue:a,newValue:i})?!1:(this.tracker.beforeChange(t),t[n]=i,e.push({row:t,field:n,colId:r,oldValue:a,newValue:i}),this.events.emit("cellValueChanged",{row:t,rowIndex:o,colId:r,oldValue:a,newValue:i}),!0)}endCellTx(e){if(!e.length)return;let t=(n,r)=>{for(let o of n){let i=o.row[o.field];o.row[o.field]=o[r],this.events.emit("cellValueChanged",{row:o.row,rowIndex:this.rowModel.indexOfId(this.rowModel.idOf(o.row)),colId:o.colId,oldValue:i,newValue:o[r]})}this.afterDataEdit()};this.history.push({undo:()=>t([...e].reverse(),"oldValue"),redo:()=>t(e,"newValue")}),this.afterDataEdit()}afterDataEdit(){this.renderer.invalidateHeights(),this.editVersion++,this.refreshSummary(),this.renderer.invalidate({rows:!0})}applyEdit(e,t,n){var a;let r=this.rowModel.getRow(e),o=(a=this.columns.getColumn(t))==null?void 0:a.def;if(!r||!(o!=null&&o.field))return;let i=[];this.writeCell(i,r.data,o.field,t,e,n),this.endCellTx(i)}clearCells(){var a,l;let e=this.columns.displayed(),t=this.allRangeBounds(),n=this.store.state.focus,r=n?(a=this.columns.getColumn(n.colId))==null?void 0:a.index:void 0,o=t.length?t:n&&r!==void 0?[{r1:n.rowIndex,r2:n.rowIndex,c1:r,c2:r}]:[];if(!o.length)return;let i=[];for(let d of o)for(let c=d.r1;c<=d.r2;c++){let u=this.rowModel.getRow(c);for(let f=d.c1;f<=d.c2;f++){let p=(l=e[f])==null?void 0:l.def;u&&!u.kind&&(p!=null&&p.field)&&ne(p,u.data,c)&&this.writeCell(i,u.data,p.field,e[f].id,c,null)}}this.endCellTx(i)}replaceData(e){this.store.set({data:e});let t=new Set(this.rowModel.allNodes().map(i=>i.id)),n=this.store.state.selected;[...n].some(i=>!t.has(i))&&this.setSelected(new Set([...n].filter(i=>t.has(i))));let r=this.rowModel.getRowCount(),o=this.store.state.focus;o&&o.rowIndex>=r&&this.store.set({focus:r?{...o,rowIndex:r-1}:null})}addRows(e,t,n=!0){if(this.clientOnly("addRows"))return[];let r=ae(Array.isArray(e)?e:[]);if(!r.length)return[];let o=[...this.store.state.data],i=t===void 0?o.length:Math.max(0,Math.min(o.length,t));o.splice(i,0,...r);for(let a of r)this.tracker.created.add(a);return this.replaceData(o),n&&this.history.push({undo:()=>this.removeRows(r,!1),redo:()=>this.addRows(r,i,!1)}),this.events.emit("rowsAdded",{rows:[...r]}),r}removeRows(e,t=!0){if(this.clientOnly("removeRows"))return[];let n=this.store.state.data,r=typeof e=="function"?e:(l=>d=>l.has(d))(new Set(e)),o=[];if(n.forEach((l,d)=>{let c=!1;try{c=!!r(l)}catch{c=!1}c&&o.push({row:l,index:d})}),!o.length)return[];let i=new Set(o.map(l=>l.row)),a=new Set(o.filter(l=>this.tracker.created.has(l.row)).map(l=>l.row));for(let{row:l,index:d}of o)a.has(l)?this.tracker.created.delete(l):this.tracker.deleted.set(l,d);return this.replaceData(n.filter(l=>!i.has(l))),t&&this.history.push({undo:()=>{let l=[...this.store.state.data];for(let{row:d,index:c}of o)l.splice(Math.min(c,l.length),0,d),this.tracker.deleted.delete(d),a.has(d)&&this.tracker.created.add(d);this.replaceData(l)},redo:()=>this.removeRows([...i],!1)}),this.events.emit("rowsRemoved",{rows:o.map(l=>l.row)}),o.map(l=>l.row)}trackedFields(){let e=[],t=n=>{for(let r of n)r.children?t(r.children):r.def.field&&!P(r.id)&&e.push({field:r.def.field,colId:r.id})};return t(this.columns.roots()),e}getChanges(){let e=this.trackedFields(),t=[];for(let[n,r]of this.tracker.originals)if(!this.tracker.deleted.has(n))for(let o of this.tracker.diff(n,e.map(i=>i.field)))t.push({row:n,colId:e.find(i=>i.field===o).colId,oldValue:r[o],newValue:n[o]});return t}getModifiedRows(){let e=this.trackedFields().map(n=>n.field),t=this.store.state.data;return{created:t.filter(n=>this.tracker.created.has(n)),updated:t.filter(n=>this.tracker.originals.has(n)&&this.tracker.diff(n,e).length>0),deleted:[...this.tracker.deleted.keys()]}}hasChanges(){let e=this.getModifiedRows();return e.created.length+e.updated.length+e.deleted.length>0}commitChanges(){this.tracker.reset(),this.renderer.invalidate({rows:!0})}revertChanges(){this.editor.cancel();for(let[n,r]of this.tracker.originals)Object.assign(n,r);let e=this.store.state.data.filter(n=>!this.tracker.created.has(n)),t=[...this.tracker.deleted.entries()].sort((n,r)=>n[1]-r[1]);e=[...e];for(let[n,r]of t)e.splice(Math.min(r,e.length),0,n);this.tracker.reset(),this.history.clear(),this.replaceData(e),this.afterDataEdit()}undo(){this.editor.cancel(),this.history.undo()}redo(){this.editor.cancel(),this.history.redo()}toast(e){let t=k("div","fg-toast",{role:"status"});t.textContent=e,this.renderer.root.append(t),setTimeout(()=>t.remove(),3500)}refreshChoosers(){var e;this.chooser.refresh(),(e=this.sideBar)==null||e.refresh()}setColumnsVisible(e,t){let n=[];for(let r of e){let o=this.columns.getNode(r);!o||o.children||o.hide===!t||(this.columns.setHide(r,!t),n.push(r))}if(n.length){this.columnsChanged();for(let r of n)this.events.emit("columnVisible",{colId:r,visible:t})}}autoSize(e){var l,d;let t=(e?e.map(c=>this.columns.getColumn(c)):this.columns.displayed()).filter(c=>!!c&&Be(c.def)),{first:n,last:r}=this.renderer.renderedRange(),o=this.store.state.locale.code,i=66,a=24;for(let c of t){let u=this.renderer.measureText((d=(l=c.def.header)!=null?l:c.def.field)!=null?d:"",!0)+i,f=K(c.def,o);for(let x=n;x<=r;x++){let M=this.rowModel.getRow(x);M&&(u=Math.max(u,this.renderer.measureText(f(B(c.def,M.data)),!1)+a))}let p=this.columns.setWidth(c.id,Math.ceil(u));this.events.emit("columnResize",{colId:c.id,width:p})}this.layoutChanged()}resetColumns(){this.columns.reset(),this.columnsChanged()}setSort(e){let t=e.filter(n=>{let r=this.columns.getNode(n.colId);return!r||r.children?(N(`setSort: unknown column "${n.colId}"`),!1):n.dir==="asc"||n.dir==="desc"});this.veto("beforeSort",{sort:t.map(n=>({...n}))})||(this.store.set({sort:t}),this.events.emit("sortChange",{sort:[...t]}))}toggleSort(e,t){let n=this.store.state.sort,r=n.find(a=>a.colId===e),o=r?r.dir==="asc"?"desc":null:"asc",i;t?o?r?i=n.map(a=>a.colId===e?{colId:e,dir:o}:a):i=[...n,{colId:e,dir:o}]:i=n.filter(a=>a.colId!==e):i=o?[{colId:e,dir:o}]:[],this.setSort(i)}setFilter(e,t){let n=this.columns.getNode(e);if(!n||n.children){N(`setFilter: unknown column "${e}"`);return}if(this.veto("beforeFilter",{colId:e,model:t}))return;let r={...this.store.state.filters};t?r[e]=t:delete r[e],this.store.set({filters:r}),this.events.emit("filterChange",{filters:{...r}})}setPinned(e,t){this.columns.setPinned(e,t),this.layoutChanged()}setFocus(e,t){let n=this.store.state.focus;n&&n.rowIndex===e&&n.colId===t||(this.store.set({focus:{rowIndex:e,colId:t}}),this.events.emit("focusChange",{rowIndex:e,colId:t}))}setSelected(e,t=this.store.state.anchorId){this.store.set({selected:e,anchorId:t}),this.events.emit("selectionChange",{selected:this.selectedRows()})}rowSelectable(e){let t=this.options.isRowSelectable;if(!t)return!0;try{return!!t(e)}catch{return!1}}selectFromClick(e,t,n){var a,l;let r=this.options.rowSelection;if(!r||e<0||e>=this.rowModel.getRowCount())return;let o=this.rowModel.getRow(e);if(o.kind||!this.rowSelectable(o.data))return;let i=Qn({selected:this.store.state.selected,anchorIndex:this.anchorIndex(),mode:r,index:e,idAt:d=>this.rowModel.getRow(d).id,toggle:t,range:n});if(this.rowModel.rows()!==this.rowModel.dataRows()||this.options.isRowSelectable)for(let d of i.selected){if(this.store.state.selected.has(d))continue;let c=this.rowModel.indexOfId(d),u=c>=0?this.rowModel.getRow(c):null;u&&(u.kind||!this.rowSelectable(u.data))&&i.selected.delete(d)}this.setSelected(i.selected,(l=(a=this.rowModel.getRow(i.anchorIndex))==null?void 0:a.id)!=null?l:null)}anchorIndex(){let e=this.store.state.anchorId;if(e==null)return null;let t=this.rowModel.indexOfId(e);return t<0?null:t}selectableRows(){let e=this.rowModel.dataRows();return this.options.isRowSelectable?e.filter(t=>this.rowSelectable(t.data)):e}toggleSelectAll(){let e=this.selectableRows(),t=this.store.state.selected,n=e.length>0&&e.every(o=>t.has(o.id)),r=new Set(t);for(let o of e)n?r.delete(o.id):r.add(o.id);this.setSelected(r)}selectedRows(){let e=this.store.state.selected;return e.size?this.rowModel.allNodes().filter(t=>e.has(t.id)).map(t=>t.data):[]}withSelect(e){let t=[];return this.options.rowDrag&&t.push(an),this.options.rowSelection&&t.push(sn),[...t,...e]}setData(e,t){if(this.clientOnly("setData"))return;if(!Array.isArray(e)){N("setData: rows must be an array");return}this.editor.cancel(),this.tracker.reset(),this.history.clear(),this.detailOpen.clear(),this.treeLoaded.clear(),this.treeLoading.clear(),this.renderer.dropDetail(),this.store.set({data:ae(e)}),t!=null&&t.scrollToTop&&this.renderer.setScroll({top:0,left:0});let n=this.store.state.selected;if(n.size)if(this.options.getRowId){let i=new Set(this.rowModel.allNodes().map(l=>l.id)),a=new Set([...n].filter(l=>i.has(l)));a.size!==n.size&&this.setSelected(a)}else this.setSelected(new Set,null);let r=this.rowModel.getRowCount(),o=this.store.state.focus;o&&o.rowIndex>=r&&this.store.set({focus:r?{...o,rowIndex:r-1}:null})}setColumns(e){var r;if(!Array.isArray(e)){N("setColumns: columns must be an array");return}if(this.menu.close(),this.sourceDefs=e,this.pivotCfg){this.rebuildPivot();return}this.columns.setDefs(this.withSelect(e));let t=o=>!!this.columns.getNode(o),n=this.groupBy.filter(t);n.length!==this.groupBy.length&&(this.groupBy=n,(r=this.groupPanel)==null||r.refresh(),this.events.emit("groupChange",{groupBy:[...n]})),this.store.set({sort:this.store.state.sort.filter(o=>t(o.colId)),filters:Object.fromEntries(Object.entries(this.store.state.filters).filter(([o])=>t(o))),focus:null}),this.columnsChanged()}onChange(e){var r,o,i,a;let t=(...l)=>l.some(d=>e.includes(d));this.pivotCfg&&t("data","locale")&&this.rebuildPivot(!1),t("locale")&&(this.menu.close(),this.chooser.close(),(r=this.sideBar)==null||r.refresh(),this.rowModel.invalidate());let n=t("sort","filters","quickFilter")&&this.page!==0;n&&(this.page=0),t("data","sort","filters","quickFilter","locale")&&this.updateRows(),n&&this.emitPage(),t("data","sort","filters","quickFilter")&&this.store.state.range&&this.setRange(null),t("data","sort","filters","quickFilter","locale")&&this.finder.refresh(),(t("data","filters","quickFilter","locale")||t("selected")&&((o=this.summaryOpts)==null?void 0:o.scope)==="selected")&&this.refreshSummary(),t("locale")&&((i=this.groupPanel)==null||i.refresh()),t("filters")&&((a=this.sideBar)==null||a.refresh()),t("theme")&&this.renderer.applyTheme(),this.renderer.invalidate({header:t("sort","filters","quickFilter","locale","selected","data"),rows:t("data","sort","filters","quickFilter","locale")})}createApi(){let e=t=>((...n)=>{if(this.destroyed){N("API called after destroy()");return}return t(...n)});return{setData:e((t,n)=>this.setData(t,n)),getData:e(()=>this.store.state.data),setColumns:e(t=>this.setColumns(t)),getColumnState:e(()=>this.columns.getState()),applyColumnState:e(t=>{this.columns.applyState(t),this.columnsChanged()}),setSort:e(t=>this.setSort(t)),getSort:e(()=>[...this.store.state.sort]),setFilter:e((t,n)=>this.setFilter(t,n)),getFilterModel:e(()=>({...this.store.state.filters})),setQuickFilter:e(t=>this.store.set({quickFilter:t!=null?t:""})),getSelectedRows:e(()=>this.selectedRows()),selectAll:e(()=>this.setSelected(new Set([...this.store.state.selected,...this.selectableRows().map(t=>t.id)]))),deselectAll:e(()=>this.setSelected(new Set,null)),getDisplayedRowCount:e(()=>this.rowModel.getRowCount()),scrollToRow:e(t=>this.renderer.scrollToRow(t)),validate:e(()=>this.validateAll()),getScrollPosition:e(()=>this.renderer.getScroll()),setScrollPosition:e(t=>this.renderer.setScroll(t!=null?t:{})),syncScroll:e((t,n="both")=>this.syncScroll(t,n)),setTheme:e(t=>this.store.set({theme:t})),setLocale:e(t=>this.store.set({locale:Re(t)})),setFont:e(t=>this.setFont(t)),setColumnVisible:e((t,n)=>this.setColumnsVisible([t],n)),autoSizeColumns:e(t=>this.autoSize(t)),resetColumnState:e(()=>this.resetColumns()),openColumnChooser:e(()=>this.chooser.open()),closeColumnChooser:e(()=>this.chooser.close()),toggleSideBar:e((t,n)=>{var r;return(r=this.sideBar)==null?void 0:r.toggle(t,n)}),setSummary:e(t=>this.setSummary(t)),getSummaryValues:e(()=>this.summaryValues.map(t=>({...t}))),getRange:e(()=>{let t=this.store.state.range;return t&&{start:{...t.start},end:{...t.end}}}),setRange:e(t=>this.setRange(t)),getRanges:e(()=>this.getRanges()),setRanges:e(t=>this.setRanges(t)),copySelection:e(t=>this.copyToClipboard(!!(t!=null&&t.headers),!!(t!=null&&t.rows))),pasteText:e(t=>this.pasteText(t)),startEdit:e((t,n)=>this.editor.start(t,n)),stopEdit:e(t=>t?this.editor.cancel():void this.editor.commit(null)),addRows:e((t,n)=>this.addRows(t,n)),removeRows:e(t=>this.removeRows(t)),removeSelectedRows:e(()=>this.removeRows(this.selectedRows())),getModifiedRows:e(()=>this.getModifiedRows()),getChanges:e(()=>this.getChanges()),hasChanges:e(()=>this.hasChanges()),commitChanges:e(()=>this.commitChanges()),revertChanges:e(()=>this.revertChanges()),undo:e(()=>this.undo()),redo:e(()=>this.redo()),canUndo:e(()=>this.history.canUndo()),canRedo:e(()=>this.history.canRedo()),fillRange:e(t=>this.fillRange(t)),setPinnedRows:e(t=>this.setPinnedRows(t)),find:e(t=>this.finder.find(t)),findNext:e(()=>this.finder.next()),findPrevious:e(()=>this.finder.previous()),clearFind:e(()=>this.finder.clear()),setGroupBy:e(t=>this.setGroupBy(t)),getGroupBy:e(()=>this.getGroupBy()),setGroupExpanded:e((t,n)=>this.setGroupExpanded(t,n)),expandAll:e(()=>this.expandAll(!0)),collapseAll:e(()=>this.expandAll(!1)),setDetailExpanded:e((t,n)=>this.setDetailExpanded(t,n)),isDetailExpanded:e(t=>this.isDetailExpanded(t)),moveRow:e((t,n)=>this.moveRow(t,n)),dropRow:e((t,n,r)=>this.dropRow(t,n,r)),setPage:e(t=>this.setPage(t)),getPage:e(()=>this.getPage()),getPageCount:e(()=>this.getPageCount()),setPageSize:e(t=>this.setPageSize(t)),getPageSize:e(()=>this.getPageSize()),refreshRows:e(()=>this.refreshRows()),setPivot:e(t=>this.setPivot(t)),getPivot:e(()=>this.getPivot()),createChart:e(t=>this.charts.create(t)),getCsv:e(t=>Ft(this,t)),exportCsv:e((t="export.csv",n)=>Bt(t,["\uFEFF",Ft(this,n)],"text/csv;charset=utf-8")),getXlsx:e(t=>Ht(this,t)),exportXlsx:e((t="export.xlsx",n)=>Bt(t,[Ht(this,n)],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")),importFile:e((t,n)=>Hn(this,t,n)),on:e((t,n)=>this.events.on(t,n)),destroy:()=>this.destroy()}}destroy(){if(!this.destroyed){this.destroyed=!0,_e.delete(this.renderer.root);for(let e of this.disposers)e();this.renderer.destroy(),this.events.clear()}}};function rr(s,e){return new jt(s,e).api}var or={en:Q,ko:rn,"zh-CN":on,ja:nn,es:en,fr:tn,de:Qt};for(let s of Object.values(or))Ne(s);return cr(Ao);})();
|
package/dist/index.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ export { default as en } from './locales/en.js';
|
|
|
5
5
|
declare function createGrid(host: HTMLElement, options: GridOptions): GridApi;
|
|
6
6
|
|
|
7
7
|
/** FreeGrid version (kept in sync with releases.json by scripts/release.mjs). */
|
|
8
|
-
declare const version = "0.8.
|
|
8
|
+
declare const version = "0.8.1";
|
|
9
9
|
|
|
10
10
|
interface LicenseInfo {
|
|
11
|
-
/** Licensed domains;
|
|
11
|
+
/** Licensed domains (plus their www. host); `*.example.com` also covers every subdomain. */
|
|
12
12
|
domains: string[];
|
|
13
13
|
company: string;
|
|
14
14
|
/** Last valid day, YYYY-MM-DD. */
|
package/dist/index.js
CHANGED
|
@@ -5217,7 +5217,7 @@ function buildPivot(source, config, defOf, labels, locale) {
|
|
|
5217
5217
|
}
|
|
5218
5218
|
|
|
5219
5219
|
// src/version.ts
|
|
5220
|
-
var version = "0.8.
|
|
5220
|
+
var version = "0.8.1";
|
|
5221
5221
|
|
|
5222
5222
|
// src/license.ts
|
|
5223
5223
|
var PUBLIC_KEY = { kty: "EC", crv: "P-256", x: "sUTKkglZmk-HMKPNub8p7AeLBKesHCU8irIkw9rJlbE", y: "j0U_aKRDR7iApY9UpaD3hUemhBLZJwDv9-QiT_hUyw8" };
|
|
@@ -5235,8 +5235,12 @@ function isDevHost(host) {
|
|
|
5235
5235
|
function domainMatches(host, domains) {
|
|
5236
5236
|
const h = host.toLowerCase().replace(/\.$/, "");
|
|
5237
5237
|
return domains.some((d) => {
|
|
5238
|
-
const
|
|
5239
|
-
|
|
5238
|
+
const raw = d.toLowerCase().replace(/\.$/, "");
|
|
5239
|
+
const wildcard = raw.startsWith("*.");
|
|
5240
|
+
const dom = wildcard ? raw.slice(2) : raw;
|
|
5241
|
+
if (!dom) return false;
|
|
5242
|
+
if (h === dom || h === `www.${dom}`) return true;
|
|
5243
|
+
return wildcard && h.endsWith(`.${dom}`);
|
|
5240
5244
|
});
|
|
5241
5245
|
}
|
|
5242
5246
|
var today = (now) => `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@freegridjs/core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "FreeGrid — a fast data grid for the web (free for personal use): virtual scrolling, grouping, pivot, charts, Excel export, 7 languages.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|