@svgrid/enterprise 3.1.2 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,58 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jszip.min-CX2fPs3O.js","./rolldown-runtime-Dd_uD5pT.js","./pdfmake-BpIYFHoG.js","./vfs_fonts-BV-Ul9v2.js","./src-CITpcm6b.js","./chart-export-B6bkQ3X8.js"])))=>i.map(i=>d[i]);
2
+ import{i as e,n as t}from"./rolldown-runtime-Dd_uD5pT.js";import{a as n,c as r,d as i,i as a,l as o,n as s,o as c,s as l,t as u,u as d}from"./export-format-DGscOjS9.js";import{t as f}from"./preload-helper-HclGiUj8.js";var p={arrows:[`↓`,`→`,`↑`],traffic:[`🔴`,`🟡`,`🟢`],triangles:[`▼`,`◆`,`▲`]};function m(e){let t=1/0,n=-1/0,r=!1;for(let i of e){if(i==null||i===``)continue;let e=Number(i);Number.isFinite(e)&&(r=!0,e<t&&(t=e),e>n&&(n=e))}return r?{min:t,max:n}:null}function h(e,t,n){let r=0;for(let e=0;e<t.length;e+=1)n>=t[e]&&(r=e+1);return e[Math.min(e.length-1,Math.max(0,r))]??e[e.length-1]}function g(e){return e<0?0:e>1?1:e}function _(e){let t=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!t)return null;let n=parseInt(t[1],16);return[n>>16&255,n>>8&255,n&255]}function v(e){return`#`+e.map(e=>Math.round(g(e/255)*255).toString(16).padStart(2,`0`)).join(``)}function y(e){let t=_(e);if(!t)return null;let n=t.map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*n[0]+.7152*n[1]+.0722*n[2]>.45?`#1e293b`:`#ffffff`}function b(e,t,n){let r=_(e),i=_(t);if(!r||!i)return e;let a=g(n);return v([r[0]+(i[0]-r[0])*a,r[1]+(i[1]-r[1])*a,r[2]+(i[2]-r[2])*a])}function x(e,t){let n=_(e);return n?`rgba(${n[0]}, ${n[1]}, ${n[2]}, ${g(t).toFixed(3)})`:e}function ee(e,t){let n=[...e].sort((e,t)=>e.offset-t.offset);if(n.length===0)return`#000000`;if(t<=n[0].offset)return n[0].color;let r=n[n.length-1];if(t>=r.offset)return r.color;for(let e=0;e<n.length-1;e+=1){let r=n[e],i=n[e+1];if(t>=r.offset&&t<=i.offset){let e=i.offset-r.offset||1;return b(r.color,i.color,(t-r.offset)/e)}}return r.color}function te(e,t){if(e.stops&&e.stops.length>=2)return ee(e.stops,t);let n=e.min??`#ffffff`,r=e.max??`#000000`;return e.mid?t<=.5?b(n,e.mid,t/.5):b(e.mid,r,(t-.5)/.5):b(n,r,t)}function S(e,t,n,r){let i;if(e.compareColumn){let r=Number(n?.[e.compareColumn]);if(!Number.isFinite(r)||r===0)return null;i=g(t/r)}else if(e.type===`colorScale`&&e.zeroCentred){let n=e.minValue??r?.min??t,a=e.maxValue??r?.max??t;i=g(.5+t/(Math.max(Math.abs(n),Math.abs(a))||1)/2)}else{let n=r?.min??t,a=r?.max??t,o,s;if(e.bounds===`percent`){let t=a-n;o=n+(e.minValue??0)/100*t,s=n+(e.maxValue??100)/100*t}else o=e.minValue??n,s=e.maxValue??a;i=s===o?.5:g((t-o)/(s-o))}return e.type===`colorScale`&&e.reverse&&(i=1-i),i}function C(e,t,n,r,i){let a={};for(let o of r){if(o.columns&&!o.columns.includes(n))continue;let r=Number(e);if(o.type===`rule`){if(o.when({value:e,row:t})){if(o.background&&(a.background=o.background,!o.color)){let e=y(o.background);e&&(a.color=e)}o.color&&(a.color=o.color),o.fontWeight!=null&&(a.fontWeight=o.fontWeight),o.icon&&(a.icon=o.icon)}continue}if(!(e==null||e===``||!Number.isFinite(r))){if(o.type===`colorScale`){let n=S(o,r,t,i);if(n==null)continue;if(o.mode===`alpha`){let[e,t]=o.alphaBounds??[.05,.85];a.background=x(o.base??`#2563eb`,e+(t-e)*n)}else{a.background=te(o,n);let e=y(a.background);e&&(a.color=e)}o.tooltip===`value`?a.title=String(e):o.tooltip===`percent`&&(a.title=`${Math.round(n*100)}%`)}else if(o.type===`dataBar`){let e;if(o.compareColumn){let n=S(o,r,t,i);if(n==null)continue;e=n*100}else if(o.bounds===`percent`){let n=S(o,r,t,i);if(n==null)continue;e=n*100}else{let t=o.minValue??Math.min(0,i?.min??0),n=(o.maxValue??i?.max??r)-t||1;e=g((r-t)/n)*100}a.dataBar={percent:e,color:r<0?o.negativeColor??`#ef4444`:o.color,fromRight:!1,gradient:o.gradient},o.showValue===!1&&(a.color=`transparent`)}else if(o.type===`iconSet`){let e=p[o.set??`arrows`];a.icon=h(e,o.thresholds,r),o.iconOnly&&(a.iconOnly=!0)}}}return a}function ne(e){return(e.type===`colorScale`||e.type===`dataBar`)&&!(`compareColumn`in e&&e.compareColumn)}function re(e){return e.some(ne)}var w=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),T=(e,t)=>e>>>t|e<<32-t;function ie(e){let t=new TextEncoder().encode(e),n=t.length*8,r=Math.ceil((t.length+9)/64)*64,i=new Uint8Array(r);i.set(t),i[t.length]=128;let a=new DataView(i.buffer);a.setUint32(r-8,Math.floor(n/4294967296)),a.setUint32(r-4,n>>>0);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=new Uint32Array(64);for(let e=0;e<r;e+=64){for(let t=0;t<16;t++)s[t]=a.getUint32(e+t*4);for(let e=16;e<64;e++){let t=T(s[e-15],7)^T(s[e-15],18)^s[e-15]>>>3,n=T(s[e-2],17)^T(s[e-2],19)^s[e-2]>>>10;s[e]=s[e-16]+t+s[e-7]+n>>>0}let t=o[0],n=o[1],r=o[2],i=o[3],c=o[4],l=o[5],u=o[6],d=o[7];for(let e=0;e<64;e++){let a=T(c,6)^T(c,11)^T(c,25),o=c&l^~c&u,f=d+a+o+w[e]+s[e]>>>0,p=(T(t,2)^T(t,13)^T(t,22))+(t&n^t&r^n&r)>>>0;d=u,u=l,l=c,c=i+f>>>0,i=r,r=n,n=t,t=f+p>>>0}o[0]=o[0]+t>>>0,o[1]=o[1]+n>>>0,o[2]=o[2]+r>>>0,o[3]=o[3]+i>>>0,o[4]=o[4]+c>>>0,o[5]=o[5]+l>>>0,o[6]=o[6]+u>>>0,o[7]=o[7]+d>>>0}let c=``;for(let e of o)c+=e.toString(16).padStart(8,`0`);return c}function E(e,t){return e===`suite`||t===`grid`}function D(e,t=new Date){return e==null||e.trim()===``?{status:`unset`,valid:!1,edition:`suite`}:ie(e.trim().toLowerCase())===`dabe98638cdc5760637bb2a741e65680a6ff0fb590d8b1018c9597650486cb10`?{status:`licensed`,valid:!0,edition:`suite`}:{status:`invalid`,valid:!1,edition:`suite`}}var O=new Set([`svgrid.com`,`www.svgrid.com`]);function k(){let e=globalThis.location?.hostname;return typeof e==`string`&&O.has(e.toLowerCase())}var A=`data-svgrid-enterprise-watermark`,j=`data-svgrid-enterprise-nudged`,M=`https://svgrid.com/pricing/?utm_source=svgrid-enterprise&utm_medium=watermark`,ae=`www.svgrid.com`,oe=5e3,se=700,ce=!1,N=null;function P(){k()||(le(),!(typeof document>`u`||typeof window>`u`)&&(queueMicrotask(()=>ue()),N||(N=new MutationObserver(()=>ue()),N.observe(document.body,{childList:!0,subtree:!0}))))}function le(){ce||(ce=!0,!(typeof console>`u`)&&console.log(`%c @svgrid/enterprise %c User is using a Commercial version which requires a license.
3
+ Contact sales@jqwidgets.com for details or visit the license page: https://svgrid.com/pricing/?utm_source=svgrid-enterprise&utm_medium=console`,`background:#4f46e5;color:#fff;padding:2px 6px;border-radius:3px;font-weight:600`,`color:inherit`))}function ue(){if(typeof document>`u`)return;let e=document.querySelectorAll(`.sv-grid-root, [role="grid"]`);if(e.length===0){pe();return}document.querySelectorAll(`[${A}="fixed"]`).forEach(e=>e.remove());let t=new Set;e.forEach(e=>{let n=de(e);n&&t.add(n)}),t.forEach(fe)}function de(e){let t=e.closest(`.sv-grid-root`);if(t)return t;let n=e;for(;n&&/^(TABLE|THEAD|TBODY|TFOOT|TR|COLGROUP)$/.test(n.tagName);)n=n.parentElement;return n}function fe(e){if(e.hasAttribute(j))return;e.setAttribute(j,`1`),getComputedStyle(e).position===`static`&&(e.style.position=`relative`);let t=me(`grid`);ge(t,!1),e.appendChild(t),he(t)}function pe(){if(typeof document>`u`||document.querySelector(`[${A}="fixed"]`))return;let e=me(`fixed`);ge(e,!0),document.body.appendChild(e),he(e)}function me(e){let t=document.createElement(`a`);return t.setAttribute(A,e),t.href=M,t.target=`_blank`,t.rel=`noopener noreferrer`,t.textContent=ae,t.title=`Unlicensed @svgrid/enterprise. Contact sales@jqwidgets.com or visit www.svgrid.com.`,t}function he(e){if(typeof window>`u`){e.remove();return}window.setTimeout(()=>{if(typeof window>`u`){e.remove();return}e.style.opacity=`0`,window.setTimeout(()=>e.remove(),se)},oe)}function ge(e,t){Object.assign(e.style,{position:t?`fixed`:`absolute`,bottom:t?`12px`:`6px`,right:t?`12px`:`8px`,zIndex:`2147483647`,background:`rgba(15,23,42,0.85)`,color:`#fff`,padding:t?`6px 10px`:`4px 8px`,borderRadius:t?`4px`:`3px`,fontFamily:`-apple-system, "Segoe UI", Roboto, sans-serif`,fontSize:t?`11px`:`10px`,lineHeight:`1.2`,textDecoration:`none`,boxShadow:t?`0 2px 12px rgba(0,0,0,0.35)`:`0 1px 4px rgba(0,0,0,0.3)`,border:`1px solid rgba(255,255,255,0.18)`,pointerEvents:`auto`,letterSpacing:`0.02em`,opacity:`1`,transition:`opacity ${se}ms ease`})}var _e=`data-svgrid-enterprise-upgrade`,ve=`https://svgrid.com/pricing`,ye=`https://svgrid.com/pricing?ref=in-app&utm_source=svgrid-enterprise&utm_medium=upgrade-prompt`,be=!1;function F(e,t){if(be||typeof document>`u`||typeof window>`u`||k()||document.querySelector(`[${_e}]`))return;be=!0;let n=xe(e,t?.expired===!0);document.body.appendChild(n),requestAnimationFrame(()=>{n.style.opacity=`1`,n.style.transform=`translateY(0)`})}function I(e){e.style.opacity=`0`,e.style.transform=`translateY(8px)`,window.setTimeout(()=>e.remove(),220)}function xe(e,t=!1){let n=document.createElement(`div`);n.setAttribute(_e,`1`),n.setAttribute(`role`,`dialog`),n.setAttribute(`aria-label`,t?`Your trial has ended`:`Unlock SvGrid Pro`),Object.assign(n.style,{position:`fixed`,bottom:`16px`,right:`16px`,zIndex:`2147483646`,width:`320px`,maxWidth:`calc(100vw - 32px)`,boxSizing:`border-box`,padding:`16px 16px 14px`,background:`#0f172a`,color:`#e2e8f0`,borderRadius:`12px`,border:`1px solid rgba(99,102,241,0.4)`,boxShadow:`0 12px 40px rgba(0,0,0,0.45)`,fontFamily:`-apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`,fontSize:`13px`,lineHeight:`1.45`,opacity:`0`,transform:`translateY(8px)`,transition:`opacity 220ms ease, transform 220ms ease`});let r=e?`<strong style="color:#fff">${Se(e?String(e):`This`)}</strong> is a Pro feature.`:`You just used a <strong style="color:#fff">Pro</strong> feature.`,i=t?`TRIAL ENDED`:`PRO`,a=t?`Your trial has ended`:`Unlock SvGrid Pro`,o=t?`${r} Your evaluation period is over - everything still works,
4
+ but this notice stays until a licence key is set.`:`${r} It runs in evaluation with a watermark - start a free trial
5
+ to remove it and ship to production.`;return n.innerHTML=`
6
+ <button type="button" data-act="x" aria-label="Dismiss"
7
+ style="position:absolute;top:8px;right:8px;width:24px;height:24px;display:flex;
8
+ align-items:center;justify-content:center;background:transparent;border:0;
9
+ color:#94a3b8;font-size:18px;line-height:1;cursor:pointer;border-radius:6px;">&times;</button>
10
+ <div style="display:flex;align-items:center;gap:8px;margin-bottom:8px;">
11
+ <span style="display:inline-block;background:${t?`#b45309`:`#4f46e5`};color:#fff;font-size:10px;
12
+ font-weight:700;letter-spacing:0.06em;padding:2px 7px;border-radius:999px;">${i}</span>
13
+ <span style="font-weight:700;color:#fff;">${a}</span>
14
+ </div>
15
+ <p style="margin:0 0 12px;color:#cbd5e1;">
16
+ ${o}
17
+ </p>
18
+ <div style="display:flex;gap:8px;align-items:center;">
19
+ <a data-act="trial" href="${ye}" target="_blank" rel="noopener noreferrer"
20
+ style="flex:1;text-align:center;background:#6366f1;color:#fff;font-weight:600;
21
+ text-decoration:none;padding:8px 12px;border-radius:8px;">${t?`Buy a licence`:`Start free trial`}</a>
22
+ <a data-act="pricing" href="${ve}" target="_blank" rel="noopener noreferrer"
23
+ style="color:#a5b4fc;text-decoration:none;padding:8px 6px;font-weight:600;">Pricing</a>
24
+ </div>
25
+ <p style="margin:10px 0 0;font-size:11px;color:#64748b;">
26
+ Already licensed? Call <code style="color:#94a3b8;">setLicenseKey()</code> at startup to hide this.
27
+ </p>
28
+ `,n.querySelector(`[data-act="x"]`)?.addEventListener(`click`,()=>I(n)),n.querySelector(`[data-act="trial"]`)?.addEventListener(`click`,()=>I(n)),n.querySelector(`[data-act="pricing"]`)?.addEventListener(`click`,()=>I(n)),n}function Se(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}var L=null,Ce=!1,we=!1,Te=new Set;function R(e){if(we)return;we=!0;let t=e.expiresAt?` on ${e.expiresAt.toISOString().slice(0,10)}`:``;console.info(`@svgrid/enterprise: your evaluation license expired${t}. Everything still works, but the watermark and upgrade notice stay until a license key is set. Contact sales@jqwidgets.com or see https://svgrid.com/pricing/?utm_source=svgrid-enterprise&utm_medium=console`)}function Ee(e){return e.status===`dev`||e.status===`eval`}var De=!1;function z(e){De||e.status!==`invalid`&&e.status!==`revoked`||k()||(De=!0,console.warn(`@svgrid/enterprise: the license key passed to setLicenseKey() is not valid, so the watermark stays. Copy the key from your order email, or contact sales@jqwidgets.com.`))}function Oe(){return D(L).valid}function ke(e){let t=D(L),n=Ee(t)&&t.expired===!0;t.valid&&!n||(z(t),P(),n&&R(t),F(e,{expired:n}))}var Ae={grid:`the enterprise grid`,spreadsheet:`the spreadsheet`,studio:`the Studio`};function je(e){Te.has(e)||(Te.add(e),console.info(`@svgrid/enterprise: your Grid license does not cover ${Ae[e]}. Everything still works, but the watermark and upgrade notice stay until the license is upgraded to Suite. Contact sales@jqwidgets.com or see https://svgrid.com/pricing/?utm_source=svgrid-enterprise&utm_medium=console`))}function Me(e,t){let n=D(L),r=n.valid&&E(n.edition,e),i=Ee(n)&&n.expired===!0;if(r&&!i)return;z(n);let a=n.valid&&!i&&!r;P(),a?je(e):i&&R(n),F(t,{expired:i})}function Ne(e){let t=D(L);switch(t.status){case`unset`:P(),F(e);return;case`invalid`:case`revoked`:z(t),P(),F(e);return;case`dev`:case`eval`:if(t.expired){P(),R(t),F(e,{expired:!0});return}Ce||=(console.info(`@svgrid/enterprise: using a development / evaluation license. Not for production use.`),!0);return;case`licensed`:return}}var Pe=!1;function Fe(){if(Pe)return;if(typeof window>`u`)throw Error(`@svgrid/enterprise: installSmartShim() requires a browser environment`);let e=window.Smart??{Utilities:{}};e.Utilities=e.Utilities??{},typeof e.Utilities.Assign!=`function`&&(e.Utilities.Assign=(t,n)=>{e.Utilities[t]=n}),(!e.Utilities.Core||typeof e.Utilities.Core.toDash!=`function`)&&(e.Utilities.Core={toDash:e=>e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase())}),window.Smart=e,Pe=!0}var Ie=/[\x00-\x08\x0B\x0C\x0E-\x1F]/g;function B(e){return e.replace(Ie,``).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`)}function Le(e){let t=(e,t=2)=>String(e).padStart(t,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}.000`}async function Re(e,t,n,r={}){let o=Math.max(1,r.chunkRows??5e3),s=n.length,c=r.rawValues===!0,l=r.cellVisual,u=r.precisionSafe===!0,f=new Map,p=[`<Style ss:ID="sHeader"><Font ss:Bold="1"/><Interior ss:Color="#F2F2F2" ss:Pattern="Solid"/></Style>`],m=e=>e===`right`?`Right`:e===`center`?`Center`:`Left`,h=e=>{let t=e.align&&e.align!==`left`;if(!e.numFmt&&!e.fill&&!e.color&&!e.bold&&!t)return;let n=`${e.numFmt??``}|${e.fill??``}|${e.color??``}|${e.bold?`b`:``}|${e.align??``}`,r=f.get(n);if(r)return r;let i=`s${f.size+1}`,a=[];return t&&a.push(`<Alignment ss:Horizontal="${m(e.align)}"/>`),(e.color||e.bold)&&a.push(`<Font${e.color?` ss:Color="${e.color}"`:``}${e.bold?` ss:Bold="1"`:``}/>`),e.fill&&a.push(`<Interior ss:Color="${e.fill}" ss:Pattern="Solid"/>`),e.numFmt&&a.push(`<NumberFormat ss:Format="${B(e.numFmt)}"/>`),p.push(`<Style ss:ID="${i}">${a.join(``)}</Style>`),f.set(n,i),i};function g(e,t,n,r){let o=e.link?.(t)||void 0,s=l?.(n,r),f=t=>h({numFmt:t,fill:s?.fill,color:s?.color,bold:s?.bold,align:e.align});if(e.exportValue){let n=e.exportValue(t),r=n==null?``:String(n);return{type:`String`,value:s?.icon?`${s.icon} ${r}`:r,styleId:f(),href:o}}let p=t[e.field];if(s?.icon){let t=c?String(p??``):a(p,e.format);return{type:`String`,value:`${s.icon} ${t}`,styleId:f(),href:o}}let m=e=>u&&Math.abs(e)>=0x38d7ea4c68000;if(c){let e=p==null?``:String(p);return typeof p==`number`&&Number.isFinite(p)&&!m(p)?{type:`Number`,value:e,styleId:f(),href:o}:{type:`String`,value:e,styleId:f(),href:o}}let g=i(p,e.format);if(g.ok){let t=d(e.format);return g.value instanceof Date?{type:`DateTime`,value:Le(g.value),styleId:f(t),href:o}:m(g.value)?{type:`String`,value:String(g.value),styleId:f(),href:o}:{type:`Number`,value:String(g.value),styleId:f(t),href:o}}return{type:`String`,value:a(p,e.format),styleId:f(),href:o}}let _=e=>`<Cell${e.styleId?` ss:StyleID="${e.styleId}"`:``}${e.href?` ss:HRef="${B(e.href)}"`:``}><Data ss:Type="${e.type}">${B(e.value)}</Data></Cell>`,v=r.widths?r.widths.map(e=>`<Column ss:Width="${Math.round(e*.75)}"/>`).join(``):``,y=Math.max(0,Math.floor(r.freezeColumns??0)),b=r.freezeHeader||y>0?`<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"><FreezePanes/><FrozenNoSplit/>`+(r.freezeHeader?`<SplitHorizontal>1</SplitHorizontal><TopRowBottomPane>1</TopRowBottomPane>`:``)+(y>0?`<SplitVertical>${y}</SplitVertical><LeftColumnRightPane>${y}</LeftColumnRightPane>`:``)+`<ActivePane>2</ActivePane></WorksheetOptions>`:``,x=[`<Row>${t.map(e=>`<Cell ss:StyleID="sHeader"><Data ss:Type="String">${B(e.header??e.field)}</Data></Cell>`).join(``)}</Row>`];for(let e=0;e<s;e++){if(r.signal?.aborted)throw new DOMException(`Export aborted`,`AbortError`);let i=n[e],a=t.map((t,n)=>_(g(t,i,e,n))).join(``);x.push(`<Row>${a}</Row>`),e>0&&e%o===0&&(r.onProgress?.({phase:`serialize`,ratio:e/s,row:e,total:s}),await new Promise(e=>setTimeout(e,0)))}return r.onProgress?.({phase:`serialize`,ratio:1,row:s,total:s}),`<?xml version="1.0"?>
29
+ <?mso-application progid="Excel.Sheet"?>
30
+ <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"><Styles>${p.join(``)}</Styles><Worksheet ss:Name="${B(e.slice(0,31)||`Sheet1`)}"><Table>${v}${x.join(``)}</Table>`+b+`</Worksheet></Workbook>`}var ze={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&apos;`},Be=/[\x00-\x08\x0B\x0C\x0E-\x1F]/g;function V(e){return e.replace(Be,``).replace(/[&<>"']/g,e=>ze[e])}function H(e){let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return n}function U(e){if(!e)return null;let t=/^#?([0-9a-f]{6})$/i.exec(e.trim());return t?`FF`+t[1].toUpperCase():null}function Ve(e){return(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())-Date.UTC(1899,11,30))/864e5}function He(e){if(e instanceof Date)return e;let t=String(e).trim(),n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);return n?new Date(Number(n[1]),Number(n[2])-1,Number(n[3])):new Date(t)}var Ue=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
31
+ <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/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/></Types>`,We=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
32
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>`;function Ge(e){return e.replace(/[\\/?*[\]:]/g,` `).trim().slice(0,31)||`Sheet1`}function Ke(e){return`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
33
+ <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="${V(Ge(e))}" sheetId="1" r:id="rId1"/></sheets></workbook>`}var qe=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
34
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>`;function Je(e,t){let n=new Map,r=164,i=e=>{if(!e)return 0;let t=n.get(e);if(t!=null)return t;let i=r++;return n.set(e,i),i},a=[`<font><sz val="11"/><name val="Calibri"/></font>`,`<font><b/><sz val="11"/><name val="Calibri"/></font>`],o=new Map,s=(e,t)=>{let n=U(t);if(!e&&!n)return 0;let r=`${e?`b`:``}|${n??``}`,i=o.get(r);if(i!=null)return i;let s=a.length;return a.push(`<font>${e?`<b/>`:``}<sz val="11"/><name val="Calibri"/>${n?`<color rgb="${n}"/>`:``}</font>`),o.set(r,s),s},c=[`<fill><patternFill patternType="none"/></fill>`,`<fill><patternFill patternType="gray125"/></fill>`],l=new Map,u=e=>{let t=U(e);if(!t)return 0;let n=l.get(t);if(n!=null)return n;let r=c.length;return c.push(`<fill><patternFill patternType="solid"><fgColor rgb="${t}"/><bgColor indexed="64"/></patternFill></fill>`),l.set(t,r),r},d=[`<xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>`,`<xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/>`],f=new Map,p=(e,t,n,r)=>{let i=`${e}|${t}|${n}|${r??``}`,a=f.get(i);if(a!=null)return a;let o=d.length,s=r&&r!==`left`?`<alignment horizontal="${r}"/>`:``;return d.push(`<xf numFmtId="${e}" fontId="${t}" fillId="${n}" borderId="0" xfId="0"${e?` applyNumberFormat="1"`:``}${t?` applyFont="1"`:``}${n?` applyFill="1"`:``}${s?` applyAlignment="1"`:``}>${s}</xf>`),f.set(i,o),o},m=e=>{let t=i(e.numFmt),n=s(e.bold===!0,e.color),r=u(e.fill);return t===0&&n===0&&r===0&&(!e.align||e.align===`left`)?0:p(t,n,r,e.align)};for(let e of t)for(let t of e)m(t);return{styleIndexOf:m,build:()=>`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
35
+ <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">`+(n.size>0?`<numFmts count="${n.size}">${[...n.entries()].map(([e,t])=>`<numFmt numFmtId="${t}" formatCode="${V(e)}"/>`).join(``)}</numFmts>`:``)+`<fonts count="${a.length}">${a.join(``)}</fonts><fills count="${c.length}">${c.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="${d.length}">${d.join(``)}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`}}function Ye(e){let{header:t,rows:n}=e,r=Je(t,n),i=[],a=[`<row r="1">${t.map((e,t)=>`<c r="${H(t)}1" s="1" t="inlineStr"><is><t xml:space="preserve">${V(e)}</t></is></c>`).join(``)}</row>`];for(let e=0;e<n.length;e++){let t=e+2,o=n[e],s=[];for(let e=0;e<o.length;e++){let n=o[e],a=`${H(e)}${t}`,c=r.styleIndexOf(n),l=c?` s="${c}"`:``;if(n.link&&i.push({ref:a,url:n.link,id:`rId${i.length+1}`}),n.value==null||n.value===``)s.push(`<c r="${a}"${l}/>`);else if(n.t===`n`)s.push(`<c r="${a}"${l}><v>${Number(n.value)}</v></c>`);else if(n.t===`d`){let e=He(n.value);s.push(`<c r="${a}"${l}><v>${Ve(e)}</v></c>`)}else n.t===`b`?s.push(`<c r="${a}"${l} t="b"><v>${+!!n.value}</v></c>`):s.push(`<c r="${a}"${l} t="inlineStr"><is><t xml:space="preserve">${V(String(n.value))}</t></is></c>`)}a.push(`<row r="${t}">${s.join(``)}</row>`)}let o=e.widths?`<cols>${e.widths.map((e,t)=>`<col min="${t+1}" max="${t+1}" width="${Math.max(4,Math.round(e/7*100)/100)}" customWidth="1"/>`).join(``)}</cols>`:``,s=Math.max(0,Math.floor(e.freezeColumns??0)),c=+!!e.freezeHeader,l=`<sheetView workbookViewId="0"/>`;if(c>0||s>0){let e=`${H(s)}${c+1}`,t=s>0&&c>0?`bottomRight`:s>0?`topRight`:`bottomLeft`;l=`<sheetView workbookViewId="0"><pane${s>0?` xSplit="${s}"`:``}${c>0?` ySplit="${c}"`:``} topLeftCell="${e}" activePane="${t}" state="frozen"/><selection pane="${t}" activeCell="${e}" sqref="${e}"/></sheetView>`}let u=n.length>0?(e.condFormats??[]).map((e,t)=>{let r=H(e.colIdx),i=`${r}2:${r}${n.length+1}`;if(e.kind===`dataBar`){let n=U(e.color)??`FF638EC6`;return`<conditionalFormatting sqref="${i}"><cfRule type="dataBar" priority="${t+1}"><dataBar><cfvo type="min"/><cfvo type="max"/><color rgb="${n}"/></dataBar></cfRule></conditionalFormatting>`}let a=e.colors.map(e=>U(e)??`FFFFFFFF`),o=a.length>=3?`<cfvo type="min"/><cfvo type="percentile" val="50"/><cfvo type="max"/>`:`<cfvo type="min"/><cfvo type="max"/>`,s=a.map(e=>`<color rgb="${e}"/>`).join(``);return`<conditionalFormatting sqref="${i}"><cfRule type="colorScale" priority="${t+1}"><colorScale>${o}${s}</colorScale></cfRule></conditionalFormatting>`}).join(``):``,d=i.length?`<hyperlinks>${i.map(e=>`<hyperlink ref="${e.ref}" r:id="${e.id}"/>`).join(``)}</hyperlinks>`:``,f=``,p=``,m=``;if(e.table&&t.length>0){let o=e.table,s=new Set,c=t.map((e,t)=>{let n=(e??``).trim()||`Column${t+1}`,r=n,i=1;for(;s.has(r.toLowerCase());)r=`${n}${++i}`;return s.add(r.toLowerCase()),r}),l=H(t.length-1),u=n.length+1,d=u+1,h=o.totalsRow&&n.length>0,g=o.totalsFns.findIndex(e=>!e);if(h){let e=t.map((e,t)=>{let i=`${H(t)}${d}`,a=o.totalsFns[t];if(a){let e=0;for(let r of n){let n=r[t];n?.t===`n`&&typeof n.value==`number`&&(e+=n.value)}let s=n.find(e=>e[t]?.t===`n`)?.[t]?.numFmt,l=r.styleIndexOf({t:`n`,value:e,numFmt:s,bold:!0}),u=a===`average`?101:a===`count`?103:109,d=a===`count`?n.length:e;return`<c r="${i}"${l?` s="${l}"`:``}><f>SUBTOTAL(${u},${o.name}[${V(c[t])}])</f><v>${d}</v></c>`}if(t===g){let e=r.styleIndexOf({t:`s`,value:`Total`,bold:!0});return`<c r="${i}"${e?` s="${e}"`:``} t="inlineStr"><is><t>Total</t></is></c>`}return`<c r="${i}"/>`});a.push(`<row r="${d}">${e.join(``)}</row>`)}let _=c.map((e,t)=>{let n=h?o.totalsFns[t]:void 0,r=h?n?` totalsRowFunction="${n}"`:t===g?` totalsRowLabel="Total"`:``:``;return`<tableColumn id="${t+1}" name="${V(e)}"${r}/>`}).join(``);f=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
36
+ <table xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" id="1" name="${V(o.name)}" displayName="${V(o.name)}" ref="A1:${l}${h?d:u}"${h?` totalsRowCount="1"`:` totalsRowShown="0"`}><autoFilter ref="A1:${l}${u}"/><tableColumns count="${t.length}">${_}</tableColumns><tableStyleInfo name="${V(o.style??`TableStyleMedium2`)}" showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0"/></table>`,m=`rId${i.length+1}`,p=`<tableParts count="1"><tablePart r:id="${m}"/></tableParts>`}let h=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
37
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheetViews>${l}</sheetViews><sheetFormatPr defaultRowHeight="15"/>`+o+`<sheetData>${a.join(``)}</sheetData>`+u+d+p+`</worksheet>`,g={"[Content_Types].xml":f?Ue.replace(`</Types>`,`<Override PartName="/xl/tables/table1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"/></Types>`):Ue,"_rels/.rels":We,"xl/workbook.xml":Ke(e.sheetName),"xl/_rels/workbook.xml.rels":qe,"xl/styles.xml":r.build(),"xl/worksheets/sheet1.xml":h};if(f&&(g[`xl/tables/table1.xml`]=f),i.length||m){let e=i.map(e=>`<Relationship Id="${e.id}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="${V(e.url)}" TargetMode="External"/>`);m&&e.push(`<Relationship Id="${m}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/table" Target="../tables/table1.xml"/>`),g[`xl/worksheets/_rels/sheet1.xml.rels`]=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
38
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">`+e.join(``)+`</Relationships>`}return g}async function Xe(e,t){let n=new t;for(let[t,r]of Object.entries(e))n.file(t,r);return n.generateAsync({type:`blob`,mimeType:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`})}function Ze(e){let t=e=>!!e&&typeof e==`object`&&Object.keys(e).some(e=>/\.(ttf|otf)$/i.test(e))&&Object.values(e).every(e=>typeof e==`string`),n=new Set,r=e=>{if(!e||typeof e!=`object`||n.has(e))return null;if(n.add(e),t(e))return e;let i=e;return r(i.pdfMake?.vfs)??r(i.vfs)??r(i.default)};return r(e)}function Qe(e,t){let n=Ze(t);return n?(typeof e.addVirtualFileSystem==`function`&&e.addVirtualFileSystem(n),e.vfs=n,!0):!1}function $e(e){if(!e)return null;let t=e.trim(),n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t);if(n){let e=n[1];return`#`+(e.length===3?e.split(``).map(e=>e+e).join(``):e).toLowerCase()}let r=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:[\s,/]+([\d.]+%?))?\s*\)$/i.exec(t);if(!r||!((r[4]===void 0?1:r[4].endsWith(`%`)?Number(r[4].slice(0,-1))/100:Number(r[4]))>.05))return null;let i=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`);return`#`+i(r[1])+i(r[2])+i(r[3])}function et(e){let t=parseInt(e.slice(1),16),n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*n(t>>16&255)+.7152*n(t>>8&255)+.0722*n(t&255)}function tt(e){if(!e||typeof getComputedStyle!=`function`)return{};let t=t=>e.querySelector(t),n=(e,t)=>e?$e(getComputedStyle(e).getPropertyValue(t)):null,r=e=>{for(let t=e;t;t=t.parentElement){let e=n(t,`background-color`);if(e)return e}return null},i=`:not([class*="row-number"]):not([class*="selection"])`,a=t(`.sv-grid-head .sv-grid-column${i}`)??t(`.sv-grid-header-cell`)??t(`thead th`),o=t(`.sv-grid-body .sv-grid-row:not(.sv-grid-row-alt):not(.sv-grid-header-row) .sv-grid-cell${i}`)??t(`tbody td`),s=t(`.sv-grid-body .sv-grid-row-alt .sv-grid-cell${i}`),c=t(`.sv-grid-group-row .sv-grid-cell`),l={},u=r(a),d=n(a,`color`);u&&(l.headerColor=u),d&&(l.headerTextColor=d);let f=r(o?o.parentElement:t(`.sv-grid-container`)??e),p=n(o,`color`);if(f&&et(f)<.4||p&&et(p)>.5)return l;p&&(l.textColor=p);let m=n(o,`border-bottom-color`)??n(a,`border-bottom-color`);m&&(l.borderColor=m);let h=n(s,`background-color`);h&&h!==f&&(l.zebraColor=h);let g=n(c,`background-color`),_=n(c,`color`);return g&&g!==f&&(l.groupColor=g),_&&(l.groupTextColor=_),l}var nt={A4:[595.28,841.89],A3:[841.89,1190.55],A5:[419.53,595.28],LETTER:[612,792],LEGAL:[612,1008]};async function rt(e,t){if(!e?.length)return[];let n=[];for(let r of e){if(`image`in r){n.push(r);continue}let e=await t(r.element),i=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error??Error(`could not read the chart image`)),r.readAsDataURL(e)});n.push({image:i,title:r.title,caption:r.caption,width:r.width})}return n}function it(e){let{columns:t}=e,n=e.opts??{},r=e.styles??{},i=e.theme??{},a=e.now??new Date(0),o=n.fontSize??8,s=n.headerColor??r.headerRow?.backgroundColor??i.headerColor??`#334155`,c=n.headerTextColor??r.headerRow?.color??i.headerTextColor??`#ffffff`,l=n.zebra??!0,u=n.zebraColor??r.rowAlternate?.backgroundColor??i.zebraColor??`#f1f5f9`,d=n.groupColor??i.groupColor??`#e2e8f0`,f=n.groupTextColor??i.groupTextColor??`#0f172a`,p=n.subtotalColor??i.subtotalColor??`#f8fafc`,m=n.textColor??r.rows?.color??i.textColor,h=n.borderColor??i.borderColor??`#e2e8f0`,g=n.repeatHeader??!0,_=e=>e===`bold`||typeof e==`number`&&e>=600,v=e=>{if(e===void 0)return;let t=typeof e==`number`?e:parseFloat(e);return Number.isFinite(t)&&t>0?t:void 0},y=(e,t)=>{if(!t)return;t.backgroundColor&&(e.fillColor=t.backgroundColor),t.color&&(e.color=t.color),_(t.fontWeight)?e.bold=!0:t.fontWeight===`normal`&&(e.bold=!1),t.fontStyle===`italic`&&(e.italics=!0);let n=v(t.fontSize);n&&(e.fontSize=n),t.textAlign&&(e.alignment=t.textAlign)},b=new Map;for(let[e,t]of Object.entries(r.cells??{})){let n=/^([A-Z]+)(\d+)$/i.exec(e.trim());if(!n)continue;let r=0;for(let e of n[1].toUpperCase())r=r*26+(e.charCodeAt(0)-64);b.set(`${Number(n[2])-1}:${r-1}`,t)}let x=n.pageOrientation??(t.length>(n.autoLandscapeThreshold??8)?`landscape`:`portrait`),ee=Array.isArray(n.columnWidths)?n.columnWidths:t.map(()=>n.columnWidths===`auto`?`auto`:`*`),te=t.map((e,t)=>{let n={text:e.header,bold:!0,alignment:e.align??`left`,color:c,fillColor:s};return y(n,r.headerRow?{...r.headerRow,backgroundColor:void 0,color:void 0}:void 0),y(n,b.get(`0:${t}`)),n}),S=e.body??(e.rows??[]).map(e=>({kind:`data`,cells:e})),C=e.dataCellStyle,ne=e.dataCellLink,re=0,w=new Set,T=[te];if(S.forEach((e,n)=>{let i=n+1;if(e.kind===`group`){let n={text:e.label,bold:!0,color:f,fillColor:d,colSpan:t.length,margin:[(e.level??0)*12,2,0,2]},r=Array.from({length:Math.max(0,t.length-1)},()=>({text:``}));T.push([n,...r])}else if(e.kind===`subtotal`)T.push(t.map((t,n)=>({text:e.cells[n]??``,bold:!0,alignment:t.align??`left`,fillColor:p})));else{w.add(i);let n=re++;T.push(t.map((t,i)=>{let a={text:e.cells[i]??``,alignment:t.align??`left`};m&&(a.color=m),y(a,r.rows?{...r.rows,backgroundColor:void 0}:void 0),l&&n%2==1&&r.rowAlternate?.color&&(a.color=r.rowAlternate.color),y(a,b.get(`${n+1}:${i}`));let o=C?.(n,i);o&&(o.fill&&(a.fillColor=o.fill),o.color&&(a.color=o.color),o.bold&&(a.bold=!0));let s=ne?.(n,i);return s&&(a.link=s,a.decoration=`underline`,o?.color||(a.color=`#2563eb`)),a}))}}),e.merges?.length&&!e.body){let n=[...w].sort((e,t)=>e-t);for(let r of e.merges){let e=Math.max(1,Math.floor(r.rowSpan??1)),i=Math.max(1,Math.floor(r.colSpan??1));if(e===1&&i===1)continue;let a=n[r.row];if(a===void 0||r.col<0||r.col>=t.length)continue;let o=T[a]?.[r.col];if(o){e>1&&(o.rowSpan=Math.min(e,T.length-a)),i>1&&(o.colSpan=Math.min(i,t.length-r.col));for(let e=0;e<(o.rowSpan??1);e+=1)for(let t=0;t<(o.colSpan??1);t+=1){if(e===0&&t===0)continue;let n=T[a+e]?.[r.col+t];n&&(n.text=``)}}}}let ie={table:{headerRows:+!!g,dontBreakRows:!0,widths:ee,body:T},layout:{fillColor:e=>l&&e>0&&e%2==0&&w.has(e)?u:null,hLineWidth:()=>.5,vLineWidth:()=>.5,hLineColor:()=>h,vLineColor:()=>h,paddingTop:()=>3,paddingBottom:()=>3,paddingLeft:()=>5,paddingRight:()=>5}},E=(e,t)=>(e??[]).map(e=>{if(`image`in e)return{image:e.image,...e.width?{width:e.width}:{},...e.height?{height:e.height}:{},margin:t};if(`text`in e){let n={text:e.text};return y(n,e.style),{...n,margin:t}}return{columns:[{text:e.left??``,alignment:`left`},{text:e.center??``,alignment:`center`},{text:e.right??``,alignment:`right`}],margin:t}}),D=[];if(D.push(...E(e.headerLines,[0,0,0,4])),n.logo&&D.push({image:n.logo,width:n.logoWidth??90,margin:[0,0,0,8]}),n.title&&D.push({text:n.title,fontSize:o+8,bold:!0,margin:[0,0,0,2]}),n.subtitle&&D.push({text:n.subtitle,fontSize:o+1,color:`#64748b`,margin:[0,0,0,8]}),n.kpis?.length){let e=n.kpiColor??`#f8fafc`;D.push({table:{widths:n.kpis.map(()=>`*`),body:[n.kpis.map(t=>({fillColor:e,margin:[8,6,8,6],stack:[{text:t.label,fontSize:o,color:`#64748b`},{text:t.value,fontSize:o+10,bold:!0,margin:[0,2,0,0]},...t.delta?[{text:t.delta,fontSize:o,color:t.color??`#64748b`,margin:[0,2,0,0]}]:[]]}))]},layout:{hLineWidth:()=>0,vLineWidth:()=>4,vLineColor:()=>`#ffffff`,paddingLeft:()=>0,paddingRight:()=>0,paddingTop:()=>0,paddingBottom:()=>0},margin:[0,0,0,10]})}let O=n.margins??[28,34,28,34],[k,A]=nt[n.pageSize??`A4`],j=(x===`landscape`?A:k)-O[0]-O[2],M=(e.charts??(n.charts??[]).filter(e=>`image`in e)).map(e=>({stack:[...e.title?[{text:e.title,fontSize:o+3,bold:!0,margin:[0,0,0,4]}]:[],{image:e.image,width:Math.min(e.width??j,j)},...e.caption?[{text:e.caption,fontSize:o,color:`#64748b`,margin:[0,3,0,0]}]:[]],margin:[0,0,0,12],unbreakable:!0}));n.chartsPosition!==`below`&&D.push(...M),D.push(ie),n.chartsPosition===`below`&&(M.length&&D.push({text:``,margin:[0,0,0,12]}),D.push(...M)),D.push(...E(e.footerLines,[0,4,0,0]));let ae={pageSize:n.pageSize??`A4`,pageOrientation:x,pageMargins:n.margins??[28,34,28,34],defaultStyle:{fontSize:o},content:D};if(n.showPageNumbers??!0){let e=a.toISOString().slice(0,10);ae.footer=(t,n)=>({margin:[28,6,28,0],columns:[{text:e,alignment:`left`,fontSize:7,color:`#94a3b8`},{text:`Page ${t} of ${n}`,alignment:`right`,fontSize:7,color:`#94a3b8`}]})}return ae}function at(e,t){let n=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!n)return e;let r=parseInt(n[1],16);return`#`+[r>>16&255,r>>8&255,r&255].map(e=>Math.round(e+(255-e)*t).toString(16).padStart(2,`0`)).join(``)}function ot(e){let t={};return e.background&&(t.fill=e.background),!t.fill&&e.dataBar&&(t.fill=at(e.dataBar.color,.72)),e.color&&e.color!==`transparent`&&(t.color=e.color),(e.fontWeight===`bold`||typeof e.fontWeight==`number`&&e.fontWeight>=600)&&(t.bold=!0),e.icon&&(t.icon=e.icon),Object.keys(t).length>0?t:void 0}function W(e,t,n){if(!n||n.length===0)return()=>void 0;let r=new Map;if(re(n))for(let n of e)r.set(n.field,m(t.map(e=>e[n.field])));return(i,a)=>{let o=e[a],s=t[i];if(!o||!s)return;let c=s[o.field];return ot(C(c,s,o.field,n,r.get(o.field)??null))}}var st=[`csv`,`tsv`,`html`,`json`,`xml`,`md`],ct=null;async function lt(){if(typeof window>`u`)throw Error(`@svgrid/enterprise: export requires a browser environment`);return ct||=(async()=>{Fe(),await f(()=>import(`./smart.export-CDCwbFH4.js`),[],import.meta.url);let e=window.Smart?.Utilities?.DataExporter;if(!e)throw Error(`@svgrid/enterprise: failed to load Smart.Utilities.DataExporter`);return e})(),ct}async function ut(t){let n=globalThis;if(t===`xlsx`&&n.JSZip==null){let t;try{t=await f(()=>import(`./jszip.min-CX2fPs3O.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1]),import.meta.url)}catch{throw Error(`@svgrid/enterprise: xlsx export requires the "jszip" peer dependency. Install it with: pnpm add jszip`)}n.JSZip=t.default??t}if(t===`pdf`&&n.pdfMake==null){let t,r;try{t=await f(()=>import(`./pdfmake-BpIYFHoG.js`).then(t=>e(t.default,1)),__vite__mapDeps([2,1]),import.meta.url),r=await f(()=>import(`./vfs_fonts-BV-Ul9v2.js`).then(t=>e(t.default,1)),__vite__mapDeps([3,1]),import.meta.url)}catch{throw Error(`@svgrid/enterprise: pdf export requires the "pdfmake" peer dependency. Install it with: pnpm add pdfmake`)}let i=t.default??t;if(!Qe(i,r))throw Error(`@svgrid/enterprise: "pdfmake/build/vfs_fonts" did not contain a font map; the installed pdfmake is not one this export knows.`);n.pdfMake=i}}function G(e,t){if(Array.isArray(t))return t;switch(t){case`selected`:return e.getSelectedRows();case`all`:return e.getData();case`displayed`:case void 0:default:return e.getDisplayedRows()}}function K(e,t,n){if(t.columns&&t.columns.length>0)return t.columns;let r=e.getColumns().filter(e=>e.visible&&e.field);return r.length>0?r.map(e=>({field:e.field,header:e.header,format:e.format,align:e.align})):n.length>0?Object.keys(n[0]).filter(e=>!e.startsWith(`_`)).map(e=>({field:e})):[]}function q(e,t,n){if(e.exportValue)return e.exportValue(t)??``;let r=t[e.field];return n?r:a(r,e.format)}async function J(e,t,n){let r=n.rawValues===!0,i={};for(let e of t)i[e.field]=e.header??e.field;let a=[i],o=e.length;for(let i=0;i<o;i++){if(n.signal?.aborted)throw new DOMException(`Export aborted`,`AbortError`);let s=e[i],c={};for(let e of t)c[e.field]=q(e,s,r);a.push(c),i>0&&i%5e3==0&&(n.onProgress?.({phase:`project`,ratio:i/o,row:i,total:o}),await new Promise(e=>setTimeout(e,0)))}return n.onProgress?.({phase:`project`,ratio:1,row:o,total:o}),a}function dt(e){if(!e)return;let t={};e.headerRow&&(t.header={...e.headerRow});let n=e.rows?{...e.rows}:{};return e.rowAlternate&&(n.alternationCount=2,n.alternationStart=0,e.rowAlternate.backgroundColor&&(n.alternationIndex1BackgroundColor=e.rowAlternate.backgroundColor),e.rowAlternate.color&&(n.alternationIndex1Color=e.rowAlternate.color)),Object.keys(n).length>0&&(t.rows=n),e.cells&&(t.cells=e.cells),t}var ft=0,pt=new Map;function mt(e){let t=pt.get(e);if(t)return t;let n=`img${++ft}`;return pt.set(e,n),n}function ht(e,t=64,n=64){let r=/^data:image\/([a-zA-Z0-9+]+);/i.exec(e)?.[1]?.toLowerCase()??`png`,i=r===`jpg`?`jpeg`:r===`svg+xml`?`svg`:r;return{id:mt(e),base64:e,imageType:i,width:t,height:n}}function gt(e,t){if(!e||e.length===0||t.length===0)return;let n=t[0],r=[];for(let i of e){let e={},a;if(`image`in i)e[n]=i.image,a={mergeAcross:!0,textAlign:`left`};else if(`text`in i)e[n]=i.text,a={mergeAcross:!0,...i.style??{}};else{let r=t[Math.floor(t.length/2)],o=t[t.length-1];i.left!==void 0&&(e[n]=i.left),i.center!==void 0&&(e[r]=i.center),i.right!==void 0&&(e[o]=i.right),a={textAlign:`left`}}r.push({cells:e,style:a})}return r}function _t(e,t){let n=e&&e.length>0?new Set(e):null;return(e,r,i)=>typeof i!=`string`||!/^data:image\//i.test(i)?null:n&&!n.has(r)?{image:ht(i,96,96),value:``}:{image:ht(i,t.width,t.height),value:``}}function vt(e){let t={exportHeader:!0,pageOrientation:e.pageOrientation??`portrait`};e.freezeHeader!==!1&&(t.freezeHeader=!0),e.freezeColumns&&e.freezeColumns>0&&(t.freezeColumnsCount=Math.floor(e.freezeColumns));let n=dt(e.styles);if(n&&(t.style=n),e.hierarchical&&(t.hierarchical=!0),e.merges?.length&&!e.groupBy?.length&&!e.hierarchical){let n=e.merges.map(e=>({cell:[e.row,e.col],rowspan:Math.max(1,Math.floor(e.rowSpan??1)),colspan:Math.max(1,Math.floor(e.colSpan??1))})).filter(e=>e.rowspan>1||e.colspan>1);n.length&&(t.mergedCells=n)}return t}function yt(e,t,n){let r=gt(t.header,n),i=gt(t.footer,n);r&&(e.headerContent=r),i&&(e.footerContent=i);let a=(t.header?.some(e=>`image`in e)??!1)||(t.footer?.some(e=>`image`in e)??!1);if(t.imageFields?.length||a){let n=t.imageSize??{width:32,height:32};e.addImageToCell=_t(t.imageFields,n)}return e}function Y(e,t){return e.toLowerCase().endsWith(`.`+t)?e:`${e}.${t}`}function bt(e,t,n,r,i){return i!==!1&&u(e,t),{blob:e,filename:t,mime:n,rowCount:r,byteSize:e.size}}function xt(e,t,n,r,i){i!==!1&&s(e,t,n);let a=new Blob([e],{type:n});return{blob:a,filename:t,mime:n,rowCount:r,byteSize:a.size}}function X(e,t,n){let r=Math.min(t.length,200);return e.map(e=>{if(typeof e.width==`number`)return e.width;let i=String(e.header??e.field).length;for(let a=0;a<r;a++){let r=q(e,t[a],n),o=r==null?0:String(r).length;o>i&&(i=o)}return Math.max(48,Math.min(400,i*7+14))})}function St(e,t,n){if(typeof t.freezeColumns==`number`)return t.freezeColumns;let r=e.getColumnPinning().left;if(!r||r.length===0)return;let i=new Set(r),a=0;for(let e of n)if(i.has(e.field))a++;else break;return a>0?a:void 0}function Ct(e){let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return n}function Z(e,t){if(e.some(e=>e.link))return(n,r)=>{let i=e[r],a=t[n];if(!(!i?.link||!a))return i.link(a)||void 0}}function wt(e){let t={};for(let n of e)n.align&&(t[n.field]=n.align);return t}async function Tt(e,t,i,a,s,u){let d=i.map(e=>e.field),f={onProgress:a.onProgress,signal:a.signal};switch(e){case`html`:return{text:await c(t,d,{...f,title:(a.filename??`grid`).trim()||`grid`,align:wt(i),cellStyle:s,cellLink:u}),mime:`text/html;charset=utf-8`,ext:`html`};case`json`:return{text:await l(t,d,f),mime:`application/json;charset=utf-8`,ext:`json`};case`xml`:return{text:await o(t,d,f),mime:`application/xml;charset=utf-8`,ext:`xml`};case`md`:return{text:await r(t,d,{...f,align:wt(i)}),mime:`text/markdown;charset=utf-8`,ext:`md`};case`tsv`:return{text:await n(t,d,{...f,csv:{...a.csv,delimiter:` `}}),mime:`text/tab-separated-values;charset=utf-8`,ext:`tsv`};default:{let e=a.csv?.delimiter??`,`;return{text:await n(t,d,{...f,csv:{...a.csv,delimiter:e}}),mime:`text/csv;charset=utf-8`,ext:`csv`}}}}async function Et(e,t){if(t.sheets&&t.sheets.length>0)throw Error(`@svgrid/enterprise: multi-sheet export requires format 'xlsx', got '${t.format}'`);let n=G(e,t.rows);if(n.length===0)throw Error(`@svgrid/enterprise: nothing to export - the grid has no rows`);let r=K(e,t,n),i=await J(n,r,t.format===`json`?{...t,rawValues:t.rawValues??!0}:t),a=(t.filename??`grid`).trim()||`grid`,o=t.format===`html`?W(r,n,t.conditionalFormats):void 0,s=t.format===`html`?Z(r,n):void 0,{text:c,mime:l,ext:u}=await Tt(t.format,i,r,t,o,s);return xt(c,Y(a,u),l,n.length,t.download)}async function Dt(e,t){if(t.sheets&&t.sheets.length>0)throw Error(`@svgrid/enterprise: multi-sheet export requires format 'xlsx'. Use 'xls' for a single legacy sheet.`);let n=G(e,t.rows);if(n.length===0)throw Error(`@svgrid/enterprise: nothing to export - the grid has no rows`);let r=K(e,t,n),i=(t.filename??`grid`).trim()||`grid`,a=W(r,n,t.conditionalFormats);return xt(await Re(i,r,n,{rawValues:t.rawValues,onProgress:t.onProgress,signal:t.signal,freezeHeader:t.freezeHeader!==!1,freezeColumns:St(e,t,r),widths:t.autoFitColumns===!1?void 0:X(r,n,t.rawValues===!0),cellVisual:t.conditionalFormats?.length?a:void 0,precisionSafe:t.precisionSafe}),Y(i,`xls`),`application/vnd.ms-excel;charset=utf-8`,n.length,t.download)}function Q(e){return e.format?.type===`number`||e.format?.type===`currency`}function Ot(e,t,n){let r=[],i=t=>e.find(e=>e.field===t)?.header??t,o=e.findIndex(e=>!Q(e)),s=(t,c)=>{if(c>=n.length){for(let n of t)r.push({kind:`data`,cells:e.map(e=>String(q(e,n,!1)??``))});return}let l=n[c],u=new Map;for(let e of t){let t=String(e[l]??``),n=u.get(t);n?n.push(e):u.set(t,[e])}for(let[t,n]of u)if(r.push({kind:`group`,label:`${i(l)}: ${t} (${n.length})`,level:c}),s(n,c+1),e.some(Q)){let i=e.map(e=>{if(!Q(e))return``;let t=n.reduce((t,n)=>t+(Number(n[e.field])||0),0);return a(t,e.format)});o>=0&&(i[o]=`Subtotal (${t})`),r.push({kind:`subtotal`,cells:i})}};return s(t,0),r}async function kt(e,t){await ut(`pdf`);let n=globalThis.pdfMake;if(!n)throw Error(`@svgrid/enterprise: pdf export requires the "pdfmake" peer dependency.`);let r=G(e,t.rows);if(r.length===0)throw Error(`@svgrid/enterprise: nothing to export - the grid has no rows`);let i=K(e,t,r),a=i.map(e=>e.field),o=i.map(e=>({header:e.header??e.field,align:e.align})),s=t.autoGroup!==!1&&!t.groupBy?.length&&!t.hierarchical?(e.getState().grouping??[]).filter(e=>!!e).map(e=>String(e)):[],c=t.groupBy?.length?t.groupBy:s.length>0?s:void 0;if(t.signal?.aborted)throw new DOMException(`Export aborted`,`AbortError`);t.onProgress?.({phase:`write`,ratio:0,total:r.length});let l={...t.pdf,pageOrientation:t.pdf?.pageOrientation??t.pageOrientation},u=l.matchTheme===!1?{}:tt(e.getElement?.()??null),d={headerLines:t.header,footerLines:t.footer},p=await rt(l.charts,async e=>{let{chartToPngBlob:t}=await f(async()=>{let{chartToPngBlob:e}=await import(`./src-CITpcm6b.js`).then(e=>e.t);return{chartToPngBlob:e}},__vite__mapDeps([4,1,5]),import.meta.url);return t(e,{scale:2})}),m=new Date,h;if(c?.length)h=it({columns:o,body:Ot(i,r,c),opts:l,styles:t.styles,theme:u,...d,charts:p,now:m});else{let e=(await J(r,i,t)).slice(1).map(e=>a.map(t=>String(e[t]??``))),n=W(i,r,t.conditionalFormats);for(let t=0;t<e.length;t++)for(let r=0;r<i.length;r++){let i=n(t,r)?.icon;i&&(e[t][r]=`${i} ${e[t][r]??``}`)}h=it({columns:o,rows:e,dataCellStyle:(e,t)=>{let r=n(e,t);return r?{fill:r.fill,color:r.color,bold:r.bold}:void 0},dataCellLink:Z(i,r),opts:l,styles:t.styles,theme:u,...d,merges:t.merges,charts:p,now:m})}let g=(t.filename??`grid`).trim()||`grid`,_=await new Promise(e=>n.createPdf(h).getBlob(e));return t.onProgress?.({phase:`write`,ratio:1,total:r.length}),bt(_,Y(g,`pdf`),`application/pdf`,r.length,t.download)}async function At(e,t,n,r,o,s){let c=e.map(e=>e.header??e.field),l=s?.precisionSafe===!0,u=(e,t,n)=>l&&Math.abs(e)>=0x38d7ea4c68000?{t:`s`,value:String(e),...t}:{t:`n`,value:e,numFmt:n,...t},f=(t,s,c)=>{let l=e[c],f=r(s,c),p={align:l.align,fill:f?.fill,color:f?.color,bold:f?.bold,link:o?.(s,c)};if(l.exportValue){let e=l.exportValue(t);return typeof e==`number`&&Number.isFinite(e)?u(e,p,d(l.format)):e instanceof Date?{t:`d`,value:e,numFmt:d(l.format)??`yyyy-mm-dd`,...p}:{t:`s`,value:e==null?``:String(e),...p}}let m=t[l.field];if(f?.icon){let e=n?String(m??``):a(m,l.format);return{t:`s`,value:`${f.icon} ${e}`,...p}}if(n)return typeof m==`number`&&Number.isFinite(m)?u(m,p):{t:`s`,value:m==null?``:String(m),...p};let h=i(m,l.format);return h.ok?h.value instanceof Date?{t:`d`,value:h.value,numFmt:d(l.format)??`yyyy-mm-dd`,...p}:u(h.value,p,d(l.format)):{t:`s`,value:a(m,l.format),...p}},p=[],m=t.length;for(let n=0;n<m;n++){if(s?.signal?.aborted)throw new DOMException(`Export aborted`,`AbortError`);let r=t[n];p.push(e.map((e,t)=>f(r,n,t))),n>0&&n%2e3==0&&(s?.onProgress?.({phase:`project`,ratio:n/m,row:n,total:m}),await new Promise(e=>setTimeout(e,0)))}return{header:c,cells:p}}async function jt(e,t){await ut(`xlsx`);let n=globalThis.JSZip;if(!n)throw Error(`@svgrid/enterprise: xlsx export requires the "jszip" peer dependency.`);let r=G(e,t.rows);if(r.length===0)throw Error(`@svgrid/enterprise: nothing to export - the grid has no rows`);let i=K(e,t,r),a=t.rawValues===!0,o=t.conditionalFormats??[],s=W(i,r,o.filter(e=>e.type===`rule`||e.type===`iconSet`)),c=Z(i,r),l=[];for(let e of o){if(e.type!==`colorScale`&&e.type!==`dataBar`)continue;let t=e.columns&&e.columns.length>0?i.map((t,n)=>e.columns.includes(t.field)?n:-1).filter(e=>e>=0):i.map((e,t)=>t);for(let n of t)if(e.type===`dataBar`)l.push({kind:`dataBar`,colIdx:n,color:e.color});else{let t=e.min??`#ffffff`,r=e.max??`#000000`;l.push({kind:`colorScale`,colIdx:n,colors:e.mid?[t,e.mid,r]:[t,r]})}}if(t.signal?.aborted)throw new DOMException(`Export aborted`,`AbortError`);t.onProgress?.({phase:`write`,ratio:0,total:r.length});let{header:u,cells:d}=await At(i,r,a,s,c,{onProgress:t.onProgress,signal:t.signal,precisionSafe:t.precisionSafe}),f=t.autoFitColumns===!1?void 0:X(i,r,a),p=(t.filename??`grid`).trim()||`grid`,m;t.excelTable&&(m={name:`Table1`,totalsRow:typeof t.excelTable==`object`&&t.excelTable.totalsRow===!0,style:typeof t.excelTable==`object`?t.excelTable.style:void 0,totalsFns:i.map(e=>Q(e)?`sum`:void 0)});let h=await Xe(Ye({sheetName:p,header:u,rows:d,widths:f,freezeHeader:t.freezeHeader!==!1,freezeColumns:St(e,t,i),condFormats:l,table:m}),n);return t.onProgress?.({phase:`write`,ratio:1,total:r.length}),bt(h,Y(p,`xlsx`),`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,r.length,t.download)}async function Mt(e,t){if(Ne(`Export`),st.includes(t.format))return Et(e,t);if(t.format===`xls`)return Dt(e,t);if(t.format===`pdf`)return kt(e,t);if(t.format===`xlsx`){let n=t.autoGroup===!1?[]:(e.getState().grouping??[]).filter(e=>!!e),r=(t.groupBy?.length??0)>0||n.length>0,i=!!t.styles&&!t.conditionalFormats?.length;if(!t.sheets?.length&&!r&&!t.hierarchical&&!t.merges?.length&&!t.header?.length&&!t.footer?.length&&!t.imageFields?.length&&!i)return jt(e,t)}await ut(t.format);let n=await lt();if(t.sheets&&t.sheets.length>0){if(t.format!==`xlsx`)throw Error(`@svgrid/enterprise: multi-sheet export requires format 'xlsx', got '${t.format}'`);let r=t.rawValues===!0,i=t.sheets.map(n=>{let i=K(e,{columns:n.columns??t.columns},n.rows),a=n.rows.map(e=>{let t={};for(let n of i)t[n.field]=q(n,e,r);return t}),o=t.autoFitColumns===!1?null:X(i,n.rows,r);return{label:n.label,dataSource:a,columns:i.map((e,t)=>o?{dataField:e.field,label:e.header??e.field,width:o[t]}:{dataField:e.field,label:e.header??e.field}),dataFields:i.map(e=>e.field),style:dt(n.styles??t.styles)}}),a=(t.filename??`grid`).trim()||`grid`,o=vt(t),s=i[0],c=new n(o);c.spreadsheets=i,yt(c,t,s.dataFields);let l={};for(let e of s.columns)l[e.dataField]=e.label;let u=[l,...s.dataSource];if(t.download===!1)throw Error(`@svgrid/enterprise: download:false is not supported for multi-sheet xlsx.`);c.exportData(u,t.format,a);return}let r=G(e,t.rows);if(r.length===0)throw Error(`@svgrid/enterprise: nothing to export - the grid has no rows`);let i=K(e,t,r),a=await J(r,i,t),o=(t.filename??`grid`).trim()||`grid`,s=i.map(e=>e.field),c=t.autoGroup!==!1&&!t.groupBy?.length&&!t.hierarchical?(e.getState().grouping??[]).filter(e=>!!e).map(e=>String(e)):[],l=t.groupBy?.length?t.groupBy:c.length>0?c:void 0,u=!t.hierarchical&&l?.length?l:void 0,d=vt(t);if(t.conditionalFormats?.length){let e=W(i,r,t.conditionalFormats),n={};for(let t=0;t<r.length;t++)for(let r=0;r<i.length;r++){let o=e(t,r);if(!o)continue;let s={};if(o.fill&&(s.backgroundColor=o.fill),o.color&&(s.color=o.color),o.bold&&(s.fontWeight=`bold`),Object.keys(s).length&&(n[Ct(r)+(t+2)]=s),o.icon){let e=a[t+1],n=i[r].field;e&&(e[n]=`${o.icon} ${e[n]??``}`)}}if(Object.keys(n).length){let e=d.style??{};d.style={...e,cells:{...e.cells??{},...n}}}}if(t.download===!1)throw Error(`@svgrid/enterprise: download:false is not supported for this xlsx export (grouped / merges / header / footer / images). Use a plain xlsx, xls, pdf, or a text format.`);if(t.signal?.aborted)throw new DOMException(`Export aborted`,`AbortError`);t.onProgress?.({phase:`write`,ratio:0,total:a.length-1});let f=new n(d,u);yt(f,t,s),f.exportData(a,t.format,o),t.onProgress?.({phase:`write`,ratio:1,total:a.length-1})}var Nt={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`};function $(e){return(e==null?``:String(e)).replace(/[&<>"']/g,e=>Nt[e])}function Pt(e){let{columns:t,rows:n}=e,r=e.cellStyle,i=e.cellLink,a=e.opts??{},o=a.orientation??`portrait`,s=a.pageSize?`${a.pageSize} ${o}`:o,c=a.margin??`14mm`,l=a.zebra??!0,u=a.zebraColor??`#f6f8fa`,d=a.headerColor??`#f1f5f9`,f=a.headerTextColor??`#0f172a`,p=a.fontSize??9,m=e=>e&&e!==`left`?` style="text-align:${e}"`:``,h=`<thead><tr>`+t.map(e=>`<th${m(e.align)}>${$(e.header)}</th>`).join(``)+`</tr></thead>`,g=(e,t,n,a)=>{let o=[];e.align&&e.align!==`left`&&o.push(`text-align:${e.align}`);let s=r?.(n,a);s?.fill&&o.push(`background:${s.fill}`),s?.color&&o.push(`color:${s.color}`),s?.bold&&o.push(`font-weight:700`);let c=o.length?` style="${o.join(`;`)}"`:``,l=s?.icon?`${$(s.icon)} ${$(t)}`:$(t),u=i?.(n,a);return u&&(l=`<a href="${$(u)}">${l}</a>`),`<td${c}>${l}</td>`},_=`<tbody>`+n.map((e,n)=>`<tr>`+t.map((t,r)=>g(t,e[r]??``,n,r)).join(``)+`</tr>`).join(``)+`</tbody>`,v=[];return a.logo&&v.push(`<img class="logo" src="${$(a.logo)}" alt="" />`),a.title&&v.push(`<h1>${$(a.title)}</h1>`),a.subtitle&&v.push(`<p class="subtitle">${$(a.subtitle)}</p>`),`<!DOCTYPE html>
39
+ <html><head><meta charset="utf-8"><title>${$(a.title??`Grid`)}</title>
40
+ <style>
41
+ @page { size: ${s}; margin: ${c}; }
42
+ @media print { body { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
43
+ body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; color: #111; margin: 0; }
44
+ .logo { max-height: ${a.logoWidth?``:`48px`}; width: ${a.logoWidth?`${a.logoWidth}px`:`auto`}; display: block; margin-bottom: 8px; }
45
+ h1 { font-size: 16pt; margin: 0 0 2px 0; }
46
+ .subtitle { font-size: 10pt; color: #64748b; margin: 0 0 10px 0; }
47
+ table { border-collapse: collapse; width: 100%; font-size: ${p}pt; }
48
+ thead { display: table-header-group; }
49
+ tr { break-inside: avoid; }
50
+ th, td { border: 1px solid #cbd5e1; padding: 4px 7px; text-align: left; }
51
+ th { background: ${d}; color: ${f}; font-weight: 700; }
52
+ ${l?`tbody tr:nth-child(even) { background: ${u}; }`:``}
53
+ </style></head>
54
+ <body>
55
+ ${v.join(`
56
+ `)}
57
+ <table>${h}${_}</table>
58
+ </body></html>`}async function Ft(e,t){if(Ne(`Print`),typeof window>`u`)throw Error(`@svgrid/enterprise: print requires a browser environment`);let n=G(e,t?.rows);if(n.length===0)throw Error(`@svgrid/enterprise: nothing to print - the grid has no rows`);let r=K(e,{columns:t?.columns},n),i=r.map(e=>e.field),a=(await J(n,r,{rawValues:t?.rawValues})).slice(1).map(e=>i.map(t=>String(e[t]??``))),o=r.map(e=>({header:e.header??e.field,align:e.align})),s={title:t?.title??`Grid`,subtitle:t?.subtitle,logo:t?.logo,orientation:t?.orientation??`portrait`,pageSize:t?.pageSize,margin:t?.margin,zebra:t?.zebra,headerColor:t?.headerColor},c=W(r,n,t?.conditionalFormats),l=Pt({columns:o,rows:a,cellStyle:(e,t)=>c(e,t),cellLink:Z(r,n),opts:s}),u=window.open(``,`_blank`,`width=900,height=700`);if(!u)throw Error(`@svgrid/enterprise: print() could not open a window - the browser blocked the popup`);u.document.open(),u.document.write(l),u.document.close(),u.focus(),u.addEventListener(`load`,()=>{setTimeout(()=>u.print(),50)}),setTimeout(()=>{try{u.print()}catch{}},300)}var It=t({ALL_VALUES:()=>ALL_VALUES,DATA_BAR_COLOR:()=>DATA_BAR_COLOR,DATA_BAR_NEGATIVE_COLOR:()=>DATA_BAR_NEGATIVE_COLOR,DEFAULT_ALERT_MESSAGE:()=>DEFAULT_ALERT_MESSAGE,DEFAULT_TABLE_STYLE:()=>DEFAULT_TABLE_STYLE,GRAND_TOTAL_ROW_ID:()=>GRAND_TOTAL_ROW_ID,GROUP_TOTAL_ROW_ID_PREFIX:()=>GROUP_TOTAL_ROW_ID_PREFIX,NO_TABLE_STYLE:()=>NO_TABLE_STYLE,PROTECTED_MESSAGE:()=>PROTECTED_MESSAGE,countReducer:()=>countReducer,exportGrid:()=>Mt,printGrid:()=>Ft});export{P as a,re as c,Me as i,C as l,Oe as n,m as o,ke as r,ne as s,It as t};
@@ -4,13 +4,13 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>SvGrid Studio - Designer</title>
7
- <script type="module" crossorigin src="./assets/index-V_cMXdxt.js"></script>
7
+ <script type="module" crossorigin src="./assets/index-BgVTSVoK.js"></script>
8
8
  <link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-Dd_uD5pT.js">
9
9
  <link rel="modulepreload" crossorigin href="./assets/disclose-version-CIm4S9xS.js">
10
10
  <link rel="modulepreload" crossorigin href="./assets/cell-formatting-BWrW_O0n.js">
11
11
  <link rel="modulepreload" crossorigin href="./assets/export-format-DGscOjS9.js">
12
12
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-HclGiUj8.js">
13
- <link rel="modulepreload" crossorigin href="./assets/src-Mu7AGqT8.js">
13
+ <link rel="modulepreload" crossorigin href="./assets/src-BqEXoOog.js">
14
14
  <link rel="modulepreload" crossorigin href="./assets/editor-contract-Bpoa7A5g.js">
15
15
  <link rel="modulepreload" crossorigin href="./assets/date-format-B8JbEtIG.js">
16
16
  <link rel="modulepreload" crossorigin href="./assets/list-option-BP_dWS66.js">
@@ -0,0 +1,2 @@
1
+ /** True on svgrid.com itself. False on the server and everywhere else. */
2
+ export declare function isFirstPartySite(): boolean;
@@ -0,0 +1,11 @@
1
+ // svgrid.com runs every Enterprise demo without a license key and without the
2
+ // watermark. It cannot carry the key: the site is public JavaScript, and the
3
+ // one license key in a public bundle is the key for everyone. So the nudges
4
+ // (watermark, upgrade card, console notice) stand down on the site's own
5
+ // hostnames instead. Any other host needs the key.
6
+ const FIRST_PARTY_HOSTS = new Set(['svgrid.com', 'www.svgrid.com']);
7
+ /** True on svgrid.com itself. False on the server and everywhere else. */
8
+ export function isFirstPartySite() {
9
+ const host = globalThis.location?.hostname;
10
+ return typeof host === 'string' && FIRST_PARTY_HOSTS.has(host.toLowerCase());
11
+ }
@@ -16,7 +16,7 @@
16
16
  * ```
17
17
  */
18
18
  import { registerGanttView } from '@svgrid/grid';
19
- import { isLicenseKeySet } from '../license.js';
19
+ import { hasValidLicense } from '../license.js';
20
20
  import { emitUnlicensedNudge } from '../watermark.js';
21
21
  import SvGridGantt from './SvGridGantt.svelte';
22
22
  let enabled = false;
@@ -30,7 +30,7 @@ export function enableGanttView() {
30
30
  return;
31
31
  enabled = true;
32
32
  registerGanttView(SvGridGantt);
33
- if (!isLicenseKeySet())
33
+ if (!hasValidLicense())
34
34
  emitUnlicensedNudge();
35
35
  }
36
36
  export { default as SvGridGantt } from './SvGridGantt.svelte';
package/dist/install.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { exportGrid, copyExportToClipboard, } from './export.js';
2
2
  import { printGrid } from './print.js';
3
3
  import { importData } from './import.js';
4
- import { isLicenseKeySet } from './license.js';
4
+ import { hasValidLicense } from './license.js';
5
5
  import { emitUnlicensedNudge } from './watermark.js';
6
6
  // AI helpers are built-in + free in @svgrid/grid now; enterprise just wires them
7
7
  // into the Pro API and registers its export engine so AI exports can write xlsx/pdf.
@@ -71,7 +71,7 @@ export function installEnterprise(api) {
71
71
  };
72
72
  // Surface the unlicensed state at install time so the watermark appears
73
73
  // alongside the grid, not just after the user clicks Export.
74
- if (!isLicenseKeySet())
74
+ if (!hasValidLicense())
75
75
  emitUnlicensedNudge();
76
76
  return pro;
77
77
  }
@@ -1,3 +1,4 @@
1
+ /** Kept for messages and older callers; no longer what makes a key valid. */
1
2
  export declare const VALID_PREFIX = "SVENTERPRISE-";
2
3
  /**
3
4
  * What an order bought. `grid` is the enterprise grid on its own; `suite` adds
@@ -3,10 +3,24 @@
3
3
  // (which reads the key from the SVGRID_LICENSE_KEY env var). One definition of
4
4
  // "what a valid key is," so the two contexts can never drift.
5
5
  //
6
- // This is deliberately NOT crypto (see license.ts). It classifies a key string;
7
- // callers decide what to do with the result. The Studio never blocks:
8
- // unlicensed use still works, it just nudges.
9
- import { REVOKED_KEYS } from './revoked.js';
6
+ // It classifies a key string; callers decide what to do with the result. The
7
+ // Studio never blocks: unlicensed use still works, it just nudges.
8
+ //
9
+ // One key (2026-10-07). Every customer receives the same license key, and the
10
+ // package stores only its SHA-256, so the key itself is not readable in
11
+ // node_modules or in this public source. Before this, any string starting with
12
+ // "SVENTERPRISE-" passed as a paid Suite license, which the published key
13
+ // format made trivial to type. A key that does not hash to LICENSE_KEY_SHA256
14
+ // is 'invalid' and gets the watermark, never an exception. The key carries no
15
+ // edition and no expiry: it reads as Suite, and a paid key cannot lapse into
16
+ // the watermark (EULA s.6: paid-term versions keep working).
17
+ //
18
+ // Rotating the key: issue a new one, put its hash here, release. Versions
19
+ // already shipped keep accepting the old key, which matches the perpetual
20
+ // license.
21
+ import { sha256Hex } from './sha256.js';
22
+ import { LICENSE_KEY_SHA256 } from './license-hash.js';
23
+ /** Kept for messages and older callers; no longer what makes a key valid. */
10
24
  export const VALID_PREFIX = 'SVENTERPRISE-';
11
25
  /** Does `edition` cover `product`? Pure, and the only place the answer lives. */
12
26
  export function editionCovers(edition, product) {
@@ -68,25 +82,13 @@ export function parseLicenseExpiry(key) {
68
82
  export function checkLicenseKey(key, now = new Date()) {
69
83
  // An unusable key reports `suite` rather than a narrower edition on purpose:
70
84
  // callers branch on `valid` first, and an edition on a rejected key would
71
- // read as though something had been granted.
72
- if (key == null || key === '')
85
+ // read as though something had been granted. `now` stays in the signature
86
+ // for callers and tests; the one key has no expiry to compare it with.
87
+ void now;
88
+ if (key == null || key.trim() === '')
73
89
  return { status: 'unset', valid: false, edition: 'suite' };
74
- if (!key.startsWith(VALID_PREFIX))
90
+ if (sha256Hex(key.trim().toLowerCase()) !== LICENSE_KEY_SHA256) {
75
91
  return { status: 'invalid', valid: false, edition: 'suite' };
76
- if (REVOKED_KEYS.has(key))
77
- return { status: 'revoked', valid: false, edition: 'suite' };
78
- const expiresAt = parseLicenseExpiry(key) ?? undefined;
79
- // Left undefined rather than false when the key encodes no date, so callers
80
- // can tell "not expired" apart from "no expiry to check".
81
- const expired = expiresAt ? now.getTime() > expiresAt.getTime() : undefined;
82
- const status = key.startsWith('SVENTERPRISE-DEV')
83
- ? 'dev'
84
- : key.startsWith('SVENTERPRISE-EVAL')
85
- ? 'eval'
86
- : 'licensed';
87
- // Only a paid key can be narrowed: a trial evaluates the whole product, and
88
- // `SVENTERPRISE-GRID` is an edition marker rather than a kind, so it lands in
89
- // the same segment DEV and EVAL use.
90
- const edition = status === 'licensed' && key.startsWith(`${VALID_PREFIX}GRID-`) ? 'grid' : 'suite';
91
- return { status, valid: true, edition, expiresAt, expired };
92
+ }
93
+ return { status: 'licensed', valid: true, edition: 'suite' };
92
94
  }
@@ -0,0 +1 @@
1
+ export declare const LICENSE_KEY_SHA256 = "dabe98638cdc5760637bb2a741e65680a6ff0fb590d8b1018c9597650486cb10";
@@ -0,0 +1,6 @@
1
+ // SHA-256 of the one @svgrid/enterprise license key, lower-cased and trimmed
2
+ // (see license-core.ts). The key itself is never in this repository; this hash
3
+ // is what the package compares a key against. Its own module so tests can swap
4
+ // in the hash of a test key without knowing the real one, and so
5
+ // tools/issue-license.mjs can check the master key it issues against it.
6
+ export const LICENSE_KEY_SHA256 = 'dabe98638cdc5760637bb2a741e65680a6ff0fb590d8b1018c9597650486cb10';
package/dist/license.js CHANGED
@@ -1,30 +1,29 @@
1
- // Polite license gate. Not crypto - anyone with devtools can extract the key
2
- // from a deployed bundle. The point is to make commercial use require a
3
- // transaction, not to defeat reverse engineering.
1
+ // Polite license gate. Not DRM - anyone with devtools can patch a deployed
2
+ // bundle. The point is to make commercial use require a transaction, not to
3
+ // defeat reverse engineering.
4
4
  //
5
- // Behavior matrix:
5
+ // One license key for every customer (see license-core.ts); the package keeps
6
+ // only its SHA-256. Behavior:
6
7
  //
7
8
  // currentKey state -> result
8
9
  // ────────────────────────────────────────────────────────────────────
9
- // null (no key set) -> evaluation: watermark + console.log,
10
- // feature still runs
11
- // does not start with "SVENTERPRISE-" -> throws (programmer error)
12
- // in REVOKED_KEYS -> throws (revoked / leaked / expired)
13
- // starts with "SVENTERPRISE-DEV" or
14
- // "SVENTERPRISE-EVAL" -> works; one-time console.info notice
15
- // an EXPIRED dev/eval key -> still works, but stops looking
16
- // licensed: watermark + a one-time
17
- // console notice naming the expiry date
18
- // + the upgrade card. Never blocks,
19
- // so a trial ending cannot break a build.
20
- // any other "SVENTERPRISE-..." -> works silently (paid production)
10
+ // null (no key set) -> evaluation: watermark + console.log
11
+ // + upgrade card, feature still runs
12
+ // anything but the license key -> same as no key, plus a one-time
13
+ // console warning that the key is not
14
+ // valid. Never throws: a wrong key must
15
+ // not break a running app.
16
+ // the license key -> works silently, every edition, no
17
+ // expiry (a paid key never lapses into
18
+ // the watermark; EULA s.6)
21
19
  //
22
- // Editions cut across that matrix. A paid key names GRID or SUITE (and a key
23
- // issued before editions existed reads as SUITE). `nudgeEnterpriseFor` is the
24
- // gate for a surface a GRID key does not reach: same never-blocks contract, with
25
- // its own console notice saying which edition covers it.
26
- import { checkLicenseKey, editionCovers, VALID_PREFIX, } from './license-core.js';
20
+ // On svgrid.com itself none of the nudges show (first-party.ts).
21
+ //
22
+ // The dev / eval / expiry branches below stay for the statuses the type still
23
+ // names; the one-key check never produces them.
24
+ import { checkLicenseKey, editionCovers, } from './license-core.js';
27
25
  import { emitUnlicensedNudge } from './watermark.js';
26
+ import { isFirstPartySite } from './first-party.js';
28
27
  import { showUpgradePrompt } from './upgrade-prompt.js';
29
28
  export { checkLicenseKey, editionCovers, } from './license-core.js';
30
29
  // The nudge the key silences, on the same subpath as the key: an app that only
@@ -49,7 +48,23 @@ function noticeExpired(info) {
49
48
  // eslint-disable-next-line no-console
50
49
  console.info(`@svgrid/enterprise: your evaluation license expired${on}. Everything still ` +
51
50
  'works, but the watermark and upgrade notice stay until a license key is set. ' +
52
- 'Contact sales@jqwidgets.com or see https://svgrid.com/pricing');
51
+ 'Contact sales@jqwidgets.com or see https://svgrid.com/pricing/?utm_source=svgrid-enterprise&utm_medium=console');
52
+ }
53
+ /** dev / eval keys are trials; only they can lapse. */
54
+ function isTrial(info) {
55
+ return info.status === 'dev' || info.status === 'eval';
56
+ }
57
+ let noticedInvalid = false;
58
+ /** One-time console warning for a key that is set but is not the license key. */
59
+ function noticeInvalid(info) {
60
+ if (noticedInvalid || (info.status !== 'invalid' && info.status !== 'revoked'))
61
+ return;
62
+ if (isFirstPartySite())
63
+ return;
64
+ noticedInvalid = true;
65
+ // eslint-disable-next-line no-console
66
+ console.warn('@svgrid/enterprise: the license key passed to setLicenseKey() is not valid, so the ' +
67
+ 'watermark stays. Copy the key from your order email, or contact sales@jqwidgets.com.');
53
68
  }
54
69
  export function setLicenseKey(key) {
55
70
  if (typeof key !== 'string' || key.length === 0) {
@@ -58,12 +73,14 @@ export function setLicenseKey(key) {
58
73
  currentKey = key;
59
74
  noticedDev = false;
60
75
  noticedExpired = false;
76
+ noticedInvalid = false;
61
77
  noticedEdition.clear();
62
78
  }
63
79
  export function clearLicenseKey() {
64
80
  currentKey = null;
65
81
  noticedDev = false;
66
82
  noticedExpired = false;
83
+ noticedInvalid = false;
67
84
  noticedEdition.clear();
68
85
  }
69
86
  export function getLicenseKey() {
@@ -104,9 +121,12 @@ export function nudgeEnterprise(feature) {
104
121
  const info = checkLicenseKey(currentKey);
105
122
  // `valid` stays true past a trial's expiry (the feature keeps running), so
106
123
  // checking it alone would let a lapsed trial through silently forever.
107
- if (info.valid && !info.expired)
124
+ // Only a trial key can lapse. A paid key carries no expiry, and even if one
125
+ // ever did, it must not bring the watermark back (EULA s.6).
126
+ const lapsedTrial = isTrial(info) && info.expired === true;
127
+ if (info.valid && !lapsedTrial)
108
128
  return;
109
- const lapsedTrial = info.valid && info.expired === true;
129
+ noticeInvalid(info);
110
130
  // A lapsed trial gets the same treatment as an unlicensed app - watermark,
111
131
  // console notice and card. The evaluation is over; the app keeps running,
112
132
  // but it stops looking licensed.
@@ -132,7 +152,7 @@ function noticeEdition(product) {
132
152
  console.info(`@svgrid/enterprise: your Grid license does not cover ${PRODUCT_LABEL[product]}. ` +
133
153
  'Everything still works, but the watermark and upgrade notice stay until the ' +
134
154
  'license is upgraded to Suite. Contact sales@jqwidgets.com or see ' +
135
- 'https://svgrid.com/pricing');
155
+ 'https://svgrid.com/pricing/?utm_source=svgrid-enterprise&utm_medium=console');
136
156
  }
137
157
  /**
138
158
  * True when the current key covers `product`. Use it to hide a Suite-only entry
@@ -157,18 +177,20 @@ export function getLicenseEdition() {
157
177
  export function nudgeEnterpriseFor(product, feature) {
158
178
  const info = checkLicenseKey(currentKey);
159
179
  const covered = info.valid && editionCovers(info.edition, product);
160
- if (covered && !info.expired)
180
+ const lapsedTrial = isTrial(info) && info.expired === true;
181
+ if (covered && !lapsedTrial)
161
182
  return;
183
+ noticeInvalid(info);
162
184
  // A key that is valid, unexpired and merely out of edition is a different
163
185
  // message from an unlicensed or lapsed one, so it gets its own notice. The
164
186
  // watermark and the card are the same either way.
165
- const outOfEdition = info.valid && info.expired !== true && !covered;
187
+ const outOfEdition = info.valid && !lapsedTrial && !covered;
166
188
  emitUnlicensedNudge();
167
189
  if (outOfEdition)
168
190
  noticeEdition(product);
169
- else if (info.valid && info.expired === true)
191
+ else if (lapsedTrial)
170
192
  noticeExpired(info);
171
- showUpgradePrompt(feature, { expired: info.valid && info.expired === true });
193
+ showUpgradePrompt(feature, { expired: lapsedTrial });
172
194
  }
173
195
  export function assertEnterpriseLicensed(feature) {
174
196
  const info = checkLicenseKey(currentKey);
@@ -182,10 +204,13 @@ export function assertEnterpriseLicensed(feature) {
182
204
  showUpgradePrompt(feature);
183
205
  return;
184
206
  case 'invalid':
185
- throw new Error(`@svgrid/enterprise: invalid license key format (expected "${VALID_PREFIX}..." prefix).`);
186
207
  case 'revoked':
187
- throw new Error('@svgrid/enterprise: this license key has been revoked. ' +
188
- 'Contact sales@jqwidgets.com for a replacement.');
208
+ // A wrong key is treated like no key: the feature runs, nudged. It used to
209
+ // throw, which turned a typo (or an old-format key) into a broken app.
210
+ noticeInvalid(info);
211
+ emitUnlicensedNudge();
212
+ showUpgradePrompt(feature);
213
+ return;
189
214
  case 'dev':
190
215
  case 'eval':
191
216
  if (info.expired) {