// packages/ag-grid-enterprise/src/license/gridLicenseManager.ts import { BeanStub, _getDocument } from "ag-grid-community"; // packages/ag-grid-enterprise/src/license/shared/licenseManager.ts import { _exists, _logPreInitWarn } from "ag-grid-community"; // packages/ag-grid-enterprise/src/license/shared/md5.ts var MD5 = class { constructor() { this.ieCompatibility = false; } init() { this.ieCompatibility = this.md5("hello") != "5d41402abc4b2a76b9719d911017c592"; } md5cycle(x, k) { let a = x[0], b = x[1], c = x[2], d = x[3]; a = this.ff(a, b, c, d, k[0], 7, -680876936); d = this.ff(d, a, b, c, k[1], 12, -389564586); c = this.ff(c, d, a, b, k[2], 17, 606105819); b = this.ff(b, c, d, a, k[3], 22, -1044525330); a = this.ff(a, b, c, d, k[4], 7, -176418897); d = this.ff(d, a, b, c, k[5], 12, 1200080426); c = this.ff(c, d, a, b, k[6], 17, -1473231341); b = this.ff(b, c, d, a, k[7], 22, -45705983); a = this.ff(a, b, c, d, k[8], 7, 1770035416); d = this.ff(d, a, b, c, k[9], 12, -1958414417); c = this.ff(c, d, a, b, k[10], 17, -42063); b = this.ff(b, c, d, a, k[11], 22, -1990404162); a = this.ff(a, b, c, d, k[12], 7, 1804603682); d = this.ff(d, a, b, c, k[13], 12, -40341101); c = this.ff(c, d, a, b, k[14], 17, -1502002290); b = this.ff(b, c, d, a, k[15], 22, 1236535329); a = this.gg(a, b, c, d, k[1], 5, -165796510); d = this.gg(d, a, b, c, k[6], 9, -1069501632); c = this.gg(c, d, a, b, k[11], 14, 643717713); b = this.gg(b, c, d, a, k[0], 20, -373897302); a = this.gg(a, b, c, d, k[5], 5, -701558691); d = this.gg(d, a, b, c, k[10], 9, 38016083); c = this.gg(c, d, a, b, k[15], 14, -660478335); b = this.gg(b, c, d, a, k[4], 20, -405537848); a = this.gg(a, b, c, d, k[9], 5, 568446438); d = this.gg(d, a, b, c, k[14], 9, -1019803690); c = this.gg(c, d, a, b, k[3], 14, -187363961); b = this.gg(b, c, d, a, k[8], 20, 1163531501); a = this.gg(a, b, c, d, k[13], 5, -1444681467); d = this.gg(d, a, b, c, k[2], 9, -51403784); c = this.gg(c, d, a, b, k[7], 14, 1735328473); b = this.gg(b, c, d, a, k[12], 20, -1926607734); a = this.hh(a, b, c, d, k[5], 4, -378558); d = this.hh(d, a, b, c, k[8], 11, -2022574463); c = this.hh(c, d, a, b, k[11], 16, 1839030562); b = this.hh(b, c, d, a, k[14], 23, -35309556); a = this.hh(a, b, c, d, k[1], 4, -1530992060); d = this.hh(d, a, b, c, k[4], 11, 1272893353); c = this.hh(c, d, a, b, k[7], 16, -155497632); b = this.hh(b, c, d, a, k[10], 23, -1094730640); a = this.hh(a, b, c, d, k[13], 4, 681279174); d = this.hh(d, a, b, c, k[0], 11, -358537222); c = this.hh(c, d, a, b, k[3], 16, -722521979); b = this.hh(b, c, d, a, k[6], 23, 76029189); a = this.hh(a, b, c, d, k[9], 4, -640364487); d = this.hh(d, a, b, c, k[12], 11, -421815835); c = this.hh(c, d, a, b, k[15], 16, 530742520); b = this.hh(b, c, d, a, k[2], 23, -995338651); a = this.ii(a, b, c, d, k[0], 6, -198630844); d = this.ii(d, a, b, c, k[7], 10, 1126891415); c = this.ii(c, d, a, b, k[14], 15, -1416354905); b = this.ii(b, c, d, a, k[5], 21, -57434055); a = this.ii(a, b, c, d, k[12], 6, 1700485571); d = this.ii(d, a, b, c, k[3], 10, -1894986606); c = this.ii(c, d, a, b, k[10], 15, -1051523); b = this.ii(b, c, d, a, k[1], 21, -2054922799); a = this.ii(a, b, c, d, k[8], 6, 1873313359); d = this.ii(d, a, b, c, k[15], 10, -30611744); c = this.ii(c, d, a, b, k[6], 15, -1560198380); b = this.ii(b, c, d, a, k[13], 21, 1309151649); a = this.ii(a, b, c, d, k[4], 6, -145523070); d = this.ii(d, a, b, c, k[11], 10, -1120210379); c = this.ii(c, d, a, b, k[2], 15, 718787259); b = this.ii(b, c, d, a, k[9], 21, -343485551); x[0] = this.add32(a, x[0]); x[1] = this.add32(b, x[1]); x[2] = this.add32(c, x[2]); x[3] = this.add32(d, x[3]); } cmn(q, a, b, x, s2, t) { a = this.add32(this.add32(a, q), this.add32(x, t)); return this.add32(a << s2 | a >>> 32 - s2, b); } ff(a, b, c, d, x, s2, t) { return this.cmn(b & c | ~b & d, a, b, x, s2, t); } gg(a, b, c, d, x, s2, t) { return this.cmn(b & d | c & ~d, a, b, x, s2, t); } hh(a, b, c, d, x, s2, t) { return this.cmn(b ^ c ^ d, a, b, x, s2, t); } ii(a, b, c, d, x, s2, t) { return this.cmn(c ^ (b | ~d), a, b, x, s2, t); } md51(s2) { const n = s2.length; const state = [1732584193, -271733879, -1732584194, 271733878]; let i; for (i = 64; i <= s2.length; i += 64) { this.md5cycle(state, this.md5blk(s2.substring(i - 64, i))); } s2 = s2.substring(i - 64); const tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; for (i = 0; i < s2.length; i++) { tail[i >> 2] |= s2.charCodeAt(i) << (i % 4 << 3); } tail[i >> 2] |= 128 << (i % 4 << 3); if (i > 55) { this.md5cycle(state, tail); for (i = 0; i < 16; i++) { tail[i] = 0; } } tail[14] = n * 8; this.md5cycle(state, tail); return state; } /* there needs to be support for Unicode here, * unless we pretend that we can redefine the MD-5 * algorithm for multi-byte characters (perhaps by adding every four 16-bit characters and * shortening the sum to 32 bits). Otherwise I suthis.ggest performing MD-5 as if every character * was two bytes--e.g., 0040 0025 = @%--but then how will an ordinary MD-5 sum be matched? * There is no way to standardize text to something like UTF-8 before transformation; speed cost is * utterly prohibitive. The JavaScript standard itself needs to look at this: it should start * providing access to strings as preformed UTF-8 8-bit unsigned value arrays. */ md5blk(s2) { const md5blks = []; for (let i = 0; i < 64; i += 4) { md5blks[i >> 2] = s2.charCodeAt(i) + (s2.charCodeAt(i + 1) << 8) + (s2.charCodeAt(i + 2) << 16) + (s2.charCodeAt(i + 3) << 24); } return md5blks; } rhex(n) { const hex_chr = "0123456789abcdef".split(""); let s2 = "", j = 0; for (; j < 4; j++) { s2 += hex_chr[n >> j * 8 + 4 & 15] + hex_chr[n >> j * 8 & 15]; } return s2; } hex(x) { for (let i = 0; i < x.length; i++) { x[i] = this.rhex(x[i]); } return x.join(""); } md5(s2) { return this.hex(this.md51(s2)); } add32(a, b) { return this.ieCompatibility ? this.add32Compat(a, b) : this.add32Std(a, b); } /* this function is much faster, so if possible we use it. Some IEs are the only ones I know of that need the idiotic second function, generated by an if clause. */ add32Std(a, b) { return a + b & 4294967295; } add32Compat(x, y) { const lsw = (x & 65535) + (y & 65535), msw = (x >> 16) + (y >> 16) + (lsw >> 16); return msw << 16 | lsw & 65535; } }; // packages/ag-grid-enterprise/src/license/shared/licenseManager.ts var LICENSE_TYPES = { "01": "GRID", "02": "CHARTS", "0102": "BOTH" }; var LICENSING_HELP_URL = "https://www.ag-grid.com/licensing/"; var _LicenseManager = class _LicenseManager { constructor(document2) { this.watermarkMessage = void 0; this.totalMessageLength = 124; this.document = document2; this.md5 = new MD5(); this.md5.init(); } validateLicense() { const licenseDetails = this.getLicenseDetails(_LicenseManager.licenseKey); const currentLicenseName = `AG Grid ${licenseDetails.currentLicenseType === "BOTH" ? "and AG Charts " : ""}Enterprise`; const suppliedLicenseName = licenseDetails.suppliedLicenseType === void 0 ? "" : `AG ${licenseDetails.suppliedLicenseType === "BOTH" ? "Grid and AG Charts" : licenseDetails.suppliedLicenseType === "GRID" ? "Grid" : "Charts"} Enterprise`; if (licenseDetails.missing) { if (!this.isWebsiteUrl() || this.isForceWatermark()) { this.outputMissingLicenseKey(currentLicenseName); } } else if (licenseDetails.expired) { const gridReleaseDate = _LicenseManager.getGridReleaseDate(); const formattedReleaseDate = _LicenseManager.formatDate(gridReleaseDate); this.outputExpiredKey(licenseDetails.expiry, formattedReleaseDate, currentLicenseName, suppliedLicenseName); } else if (!licenseDetails.valid) { this.outputInvalidLicenseKey( !!licenseDetails.incorrectLicenseType, currentLicenseName, suppliedLicenseName ); } else if (licenseDetails.isTrial && licenseDetails.trialExpired) { this.outputExpiredTrialKey(licenseDetails.expiry, currentLicenseName, suppliedLicenseName); } } static extractExpiry(license) { const restrictionHashed = license.substring(license.lastIndexOf("_") + 1, license.length); return new Date(parseInt(_LicenseManager.decode(restrictionHashed), 10)); } static extractLicenseComponents(licenseKey) { let cleanedLicenseKey = licenseKey.replace(/[\u200B-\u200D\uFEFF]/g, ""); cleanedLicenseKey = cleanedLicenseKey.replace(/\r?\n|\r/g, ""); if (licenseKey.length <= 32) { return { md5: null, license: licenseKey, version: null, isTrial: null }; } const hashStart = cleanedLicenseKey.length - 32; const md5 = cleanedLicenseKey.substring(hashStart); const license = cleanedLicenseKey.substring(0, hashStart); const [version, isTrial, type] = _LicenseManager.extractBracketedInformation(cleanedLicenseKey); return { md5, license, version, isTrial, type }; } getLicenseDetails(licenseKey) { const currentLicenseType = _LicenseManager.chartsLicenseManager ? "BOTH" : "GRID"; if (!licenseKey?.length) { return { licenseKey, valid: false, missing: true, currentLicenseType }; } const gridReleaseDate = _LicenseManager.getGridReleaseDate(); const { md5, license, version, isTrial, type } = _LicenseManager.extractLicenseComponents(licenseKey); let valid = md5 === this.md5.md5(license) && !licenseKey.includes("For_Trialing_ag-Grid_Only"); let trialExpired = void 0; let expired = void 0; let expiry = null; let incorrectLicenseType = false; let suppliedLicenseType = void 0; function handleTrial() { const now = /* @__PURE__ */ new Date(); trialExpired = expiry < now; expired = void 0; } if (valid) { expiry = _LicenseManager.extractExpiry(license); valid = !isNaN(expiry.getTime()); if (valid) { expired = gridReleaseDate > expiry; switch (version) { case "legacy": case "2": { if (isTrial) { handleTrial(); } break; } case "3": { if (!type?.length) { valid = false; } else { suppliedLicenseType = type; if (type !== LICENSE_TYPES["01"] && type !== LICENSE_TYPES["0102"] || currentLicenseType === "BOTH" && suppliedLicenseType !== "BOTH") { valid = false; incorrectLicenseType = true; } else if (isTrial) { handleTrial(); } } } } } } if (!valid) { return { licenseKey, valid, incorrectLicenseType, currentLicenseType, suppliedLicenseType }; } return { licenseKey, valid, expiry: _LicenseManager.formatDate(expiry), expired, version, isTrial, trialExpired, incorrectLicenseType, currentLicenseType, suppliedLicenseType }; } isDisplayWatermark() { return this.isForceWatermark() || !this.isLocalhost() && !this.isWebsiteUrl() && !!this.watermarkMessage?.length; } getWatermarkMessage() { return this.watermarkMessage || ""; } getHostname() { const win = this.document.defaultView || window; const loc = win.location; const { hostname = "" } = loc; return hostname; } isForceWatermark() { const win = this.document.defaultView || window; const loc = win.location; const { pathname } = loc; return pathname ? pathname.includes("forceWatermark") : false; } isWebsiteUrl() { const hostname = this.getHostname(); return hostname.match(/^((?:[\w-]+\.)?ag-grid\.com)$/) !== null; } isLocalhost() { const hostname = this.getHostname(); return hostname.match(/^(?:127\.0\.0\.1|localhost)$/) !== null; } static formatDate(date) { const monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; const day = date.getDate(); const monthIndex = date.getMonth(); const year = date.getFullYear(); return day + " " + monthNames[monthIndex] + " " + year; } static getGridReleaseDate() { return new Date(parseInt(_LicenseManager.decode(_LicenseManager.RELEASE_INFORMATION), 10)); } static decode(input) { const keystr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; let t = ""; let n, r, i; let s2, o, u, a; let f = 0; const e = input.replace(/[^A-Za-z0-9+/=]/g, ""); while (f < e.length) { s2 = keystr.indexOf(e.charAt(f++)); o = keystr.indexOf(e.charAt(f++)); u = keystr.indexOf(e.charAt(f++)); a = keystr.indexOf(e.charAt(f++)); n = s2 << 2 | o >> 4; r = (o & 15) << 4 | u >> 2; i = (u & 3) << 6 | a; t = t + String.fromCharCode(n); if (u != 64) { t = t + String.fromCharCode(r); } if (a != 64) { t = t + String.fromCharCode(i); } } t = _LicenseManager.utf8_decode(t); return t; } static utf8_decode(input) { input = input.replace(/rn/g, "n"); let t = ""; for (let n = 0; n < input.length; n++) { const r = input.charCodeAt(n); if (r < 128) { t += String.fromCharCode(r); } else if (r > 127 && r < 2048) { t += String.fromCharCode(r >> 6 | 192); t += String.fromCharCode(r & 63 | 128); } else { t += String.fromCharCode(r >> 12 | 224); t += String.fromCharCode(r >> 6 & 63 | 128); t += String.fromCharCode(r & 63 | 128); } } return t; } static setChartsLicenseManager(dependantLicenseManager) { this.chartsLicenseManager = dependantLicenseManager; this.chartsLicenseManager?.setLicenseKey(this.licenseKey, true); } static setLicenseKey(licenseKey) { if (_exists(this.licenseKey) && this.licenseKey !== licenseKey) { _logPreInitWarn( 291, void 0, "AG Grid: License Key being set multiple times with different values. This can result in an incorrect license key being used." ); } this.licenseKey = licenseKey; this.chartsLicenseManager?.setLicenseKey(licenseKey, true); } static extractBracketedInformation(licenseKey) { if (!licenseKey.includes("[")) { return ["legacy", false, void 0]; } const matches = licenseKey.match(/\[(.*?)\]/g).map((match) => match.replace("[", "").replace("]", "")); if (!matches || matches.length === 0) { return ["legacy", false, void 0]; } const isTrial = matches.filter((match) => match === "TRIAL").length === 1; const rawVersion = matches.filter((match) => match.indexOf("v") === 0)[0]; const version = rawVersion ? rawVersion.replace("v", "") : "legacy"; const type = LICENSE_TYPES[matches.filter((match) => LICENSE_TYPES[match])[0]]; return [version, isTrial, type]; } centerPadAndOutput(input) { const paddingRequired = this.totalMessageLength - input.length; console.error(input.padStart(paddingRequired / 2 + input.length, "*").padEnd(this.totalMessageLength, "*")); } padAndOutput(input, padding = "*", terminateWithPadding = "") { console.error( input.padEnd(this.totalMessageLength - terminateWithPadding.length, padding) + terminateWithPadding ); } outputInvalidLicenseKey(incorrectLicenseType, currentLicenseName, suppliedLicenseName) { if (incorrectLicenseType) { this.centerPadAndOutput(""); this.centerPadAndOutput(` ${currentLicenseName} License `); this.centerPadAndOutput(" Incompatible License Key "); this.padAndOutput( `* Your license key is for ${suppliedLicenseName} only and does not cover you for ${currentLicenseName}.`, " ", "*" ); this.padAndOutput(`* To troubleshoot your license key visit ${LICENSING_HELP_URL}.`, " ", "*"); this.centerPadAndOutput(""); this.centerPadAndOutput(""); } else { this.centerPadAndOutput(""); this.centerPadAndOutput(` ${currentLicenseName} License `); this.centerPadAndOutput(" Invalid License Key "); this.padAndOutput(`* Your license key is not valid.`, " ", "*"); this.padAndOutput(`* To troubleshoot your license key visit ${LICENSING_HELP_URL}.`, " ", "*"); this.centerPadAndOutput(""); this.centerPadAndOutput(""); } this.watermarkMessage = "Invalid License"; } outputExpiredTrialKey(formattedExpiryDate, currentLicenseName, suppliedLicenseName) { this.centerPadAndOutput(""); this.centerPadAndOutput(` ${currentLicenseName} License `); this.centerPadAndOutput(" Trial Period Expired. "); this.padAndOutput( `* Your trial only license for ${suppliedLicenseName} expired on ${formattedExpiryDate}.`, " ", "*" ); this.padAndOutput("* Please email info@ag-grid.com to purchase a license.", " ", "*"); this.centerPadAndOutput(""); this.centerPadAndOutput(""); this.watermarkMessage = "Trial Period Expired"; } outputMissingLicenseKey(currentLicenseName) { this.centerPadAndOutput(""); this.centerPadAndOutput(` ${currentLicenseName} License `); this.centerPadAndOutput(" License Key Not Found "); this.padAndOutput(`* All ${currentLicenseName} features are unlocked for trial.`, " ", "*"); this.padAndOutput( "* If you want to hide the watermark please email info@ag-grid.com for a trial license key.", " ", "*" ); this.centerPadAndOutput(""); this.centerPadAndOutput(""); this.watermarkMessage = "For Trial Use Only"; } outputExpiredKey(formattedExpiryDate, formattedReleaseDate, currentLicenseName, suppliedLicenseName) { this.centerPadAndOutput(""); this.centerPadAndOutput(` ${currentLicenseName} License `); this.centerPadAndOutput(" Incompatible Software Version "); this.padAndOutput( `* Your license key works with versions${suppliedLicenseName == "" ? "" : ` of ${suppliedLicenseName}`} released before ${formattedExpiryDate}.`, " ", "*" ); this.padAndOutput(`* The version you are trying to use was released on ${formattedReleaseDate}.`, " ", "*"); this.padAndOutput("* Please contact info@ag-grid.com to renew your license key.", " ", "*"); this.centerPadAndOutput(""); this.centerPadAndOutput(""); this.watermarkMessage = "License Expired"; } }; // eslint-disable-next-line no-restricted-syntax _LicenseManager.RELEASE_INFORMATION = "MTc3MDgwOTgzNDk5MQ=="; var LicenseManager = _LicenseManager; // packages/ag-grid-enterprise/src/license/watermark.ts import { Component, RefPlaceholder } from "ag-grid-community"; // packages/ag-grid-enterprise/src/license/watermark.css-GENERATED.ts var watermarkCSS = ( /*css*/ `.ag-watermark{bottom:20px;color:#9b9b9b;opacity:.7;position:absolute;transition:opacity 1s ease-out 3s}:where(.ag-ltr) .ag-watermark{right:25px}:where(.ag-rtl) .ag-watermark{left:25px}.ag-watermark:before{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMDkiIGhlaWdodD0iMzYiIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAyMDkgMzYiPjxwYXRoIGZpbGw9IiM5YjliOWIiIGQ9Ik0xOTIuOTkzIDIzLjY1OHYtNy45NDZoLTEzLjU0MWwtNy45NDcgNy45NDZ6TTIwOC4yNSAzLjk1aC0xNi45NzRsLTguMDEgNy45NDdoMjQuOTg0ek0xNjMuNjIyIDMxLjYwNWw0LjA2OS00LjA2OWgxMy43MzJ2Ny45NDdoLTE3LjgwMXoiLz48cGF0aCBmaWxsPSIjOWI5YjliIiBkPSJNMTY2LjYxIDE5Ljc4aDguNzczbDguMDEtNy45NDZIMTY2LjYxek0xNTcuMDExIDMxLjYwNWg2LjYxMWw3Ljg4My03Ljk0N2gtMTQuNDk0ek0xOTEuMjc2IDMuOTVsLTQuMDY4IDQuMDdIMTYxLjI3Vi4wNzJoMzAuMDA2ek0yMC44NCAzMC4yMDZIOC4zNzhsLTIuMTYyIDUuMzRILjc1TDEyLjI1NyA4LjU5Mmg0Ljc2OEwyOC41MyAzNS41NDZoLTUuNTN6bS0xLjcxNy00LjI2TDE0LjYwOSAxNC45NWwtNC41MTQgMTAuOTk4ek0xMDQuNDM3IDE4LjUwOWMxLjU4OS0yLjM1MiA1LjU5NC0yLjYwNyA3LjI0Ny0yLjYwN3Y0LjU3OGMtMi4wMzQgMC00LjA2OS4wNjMtNS4yNzcuOTUzLTEuMjA3Ljg5LTEuODQzIDIuMDk4LTEuODQzIDMuNTZ2MTAuNTUzaC00Ljk1OVYxNS45MDJoNC43Njh6TTExOS4zNzYgMTUuOTAyaC00Ljk1OHYxOS42NDRoNC45NTh6TTExOS4zNzYgNy4xM2gtNC45NTh2NS44NDhoNC45NTh6TTE0My45NzkgNy4xM3YyOC40MTZoLTQuNzY4bC0uMTI3LTIuOTg4YTguMyA4LjMgMCAwIDEtMi42NyAyLjQ4Yy0xLjA4MS41NzItMi40MTYuODktMy45NDIuODktMS4zMzUgMC0yLjYwNi0uMjU1LTMuNjg3LS43LTEuMTQ0LS41MDgtMi4xNjItMS4xNDQtMi45ODgtMi4wMzRhOS42IDkuNiAwIDAgMS0xLjk3MS0zLjE3OWMtLjUwOC0xLjIwNy0uNjk5LTIuNjA2LS42OTktNC4xMzJzLjI1NC0yLjkyNC42OTktNC4xOTZjLjUwOS0xLjI3MSAxLjE0NS0yLjM1MiAxLjk3MS0zLjI0MnMxLjg0NC0xLjU4OSAyLjk4OC0yLjA5OCAyLjM1Mi0uNzYzIDMuNjg3LS43NjNjMS41MjYgMCAyLjc5Ny4yNTUgMy44NzguODI3czEuOTcxIDEuMzM1IDIuNjcgMi40MTZWNy4xOTNoNC45NTl6bS0xMC40MjYgMjQuNTM4YzEuNjUzIDAgMi45MjQtLjU3MiAzLjk0MS0xLjY1M3MxLjUyNi0yLjU0MyAxLjUyNi00LjMyMy0uNTA5LTMuMTc4LTEuNTI2LTQuMzIyYy0xLjAxNy0xLjA4MS0yLjI4OC0xLjY1My0zLjk0MS0xLjY1My0xLjU5IDAtMi45MjUuNTcyLTMuODc4IDEuNjUzLTEuMDE3IDEuMDgtMS41MjYgMi41NDMtMS41MjYgNC4zMjIgMCAxLjc4LjUwOSAzLjE4IDEuNTI2IDQuMjYgMS4wMTcgMS4xNDQgMi4yODggMS43MTYgMy44NzggMS43MTZNNTcuMjAyIDIwLjM1M0g0NC45MzN2NC4yNTloNi45OTNjLS4xOSAyLjE2MS0xLjAxNyAzLjgxNC0yLjQxNiA1LjE1LTEuMzk4IDEuMjctMy4xNzggMS45MDYtNS40NjcgMS45MDYtMS4yNzEgMC0yLjQ4LS4yNTQtMy40OTYtLjY5OWE3IDcgMCAwIDEtMi43MzQtMS45N2MtLjc2My0uODI3LTEuMzM1LTEuODQ0LTEuNzgtMy4wNTJzLS42MzYtMi40OC0uNjM2LTMuOTQyLjE5LTIuNzMzLjYzNi0zLjk0MWMuMzgxLTEuMjA4IDEuMDE3LTIuMTYyIDEuNzgtMy4wNTIuNzYzLS44MjYgMS42NTMtMS40NjIgMi43MzMtMS45N2E5LjEgOS4xIDAgMCAxIDMuNTYtLjdxNC4wMDUgMCA2LjEwMyAxLjkwN2wzLjMwNi0zLjMwNWMtMi40OC0xLjkwNy01LjY1OC0yLjkyNS05LjQwOS0yLjkyNS0yLjA5NyAwLTQuMDA0LjMxOC01LjcyMSAxLjAxOC0xLjcxNi42OTktMy4xNzkgMS41ODktNC4zODYgMi43OTdBMTIuMSAxMi4xIDAgMCAwIDMxLjIgMTYuMjJjLS42MzUgMS43MTctLjk1MyAzLjYyNC0uOTUzIDUuNjU4cy4zMTggMy45NDIgMS4wMTcgNS42NThjLjcgMS43MTcgMS41OSAzLjE3OSAyLjc5NyA0LjM4N2ExMi4xIDEyLjEgMCAwIDAgNC4zODcgMi43OTdjMS43MTYuNyAzLjYyMyAxLjAxNyA1LjY1NyAxLjAxNyAyLjAzNSAwIDMuODc4LS4zMTggNS41MzEtMS4wMTcgMS42NTMtLjcgMy4wNTItMS41OSA0LjE5Ni0yLjc5N3ExLjcxNi0xLjgxMiAyLjY3LTQuMzg3Yy42MzYtMS43MTYuOTU0LTMuNjIzLjk1NC01LjY1OHYtLjgyNmMtLjE5MS0uMTI3LS4yNTUtLjQ0NS0uMjU1LS43TTk1Ljk4MiAyMC4zNTNoLTEyLjI3djQuMjU5aDYuOTkzYy0uMTkgMi4xNjEtMS4wMTcgMy44MTQtMi40MTYgNS4xNS0xLjM5OCAxLjI3LTMuMTc4IDEuOTA2LTUuNDY3IDEuOTA2LTEuMjcxIDAtMi40OC0uMjU0LTMuNDk2LS42OTlhNyA3IDAgMCAxLTIuNzM0LTEuOTdjLS43NjMtLjgyNy0xLjMzNS0xLjg0NC0xLjc4LTMuMDUycy0uNjM2LTIuNDgtLjYzNi0zLjk0Mi4xOS0yLjczMy42MzYtMy45NDFjLjM4MS0xLjIwOCAxLjAxNy0yLjE2MiAxLjc4LTMuMDUyLjc2My0uODI2IDEuNjUzLTEuNDYyIDIuNzM0LTEuOTdhOS4xIDkuMSAwIDAgMSAzLjU2LS43cTQuMDA1IDAgNi4xMDMgMS45MDdsMy4zMDUtMy4zMDVjLTIuNDc5LTEuOTA3LTUuNjU4LTIuOTI1LTkuNDA4LTIuOTI1LTIuMDk4IDAtNC4wMDUuMzE4LTUuNzIyIDEuMDE4LTEuNzE2LjY5OS0zLjE3OCAxLjU4OS00LjM4NiAyLjc5N2ExMi4xIDEyLjEgMCAwIDAtMi43OTcgNC4zODZjLS42MzYgMS43MTctLjk1NCAzLjYyNC0uOTU0IDUuNjU4cy4zMTggMy45NDIgMS4wMTcgNS42NThjLjcgMS43MTcgMS41OSAzLjE3OSAyLjc5NyA0LjM4N2ExMi4xIDEyLjEgMCAwIDAgNC4zODcgMi43OTdjMS43MTYuNyAzLjYyMyAxLjAxNyA1LjY1OCAxLjAxNyAyLjAzNCAwIDMuODc4LS4zMTggNS41My0xLjAxNyAxLjY1My0uNyAzLjA1Mi0xLjU5IDQuMTk2LTIuNzk3cTEuNzE4LTEuODEyIDIuNjctNC4zODdjLjYzNi0xLjcxNi45NTQtMy42MjMuOTU0LTUuNjU4di0uODI2Yy0uMTktLjEyNy0uMjU1LS40NDUtLjI1NS0uNyIvPjwvc3ZnPg==");background-repeat:no-repeat;background-size:170px 40px;content:"";display:block;height:40px;width:170px}.ag-watermark-text{font-family:Impact,sans-serif;font-size:19px;font-weight:700;opacity:.5}:where(.ag-ltr) .ag-watermark-text{padding-left:.7rem}:where(.ag-rtl) .ag-watermark-text{padding-right:.7rem}` ); // packages/ag-grid-enterprise/src/license/watermark.ts var WatermarkElement = { tag: "div", cls: "ag-watermark", children: [{ tag: "div", ref: "eLicenseTextRef", cls: "ag-watermark-text" }] }; var AgWatermark = class extends Component { constructor() { super(WatermarkElement); this.eLicenseTextRef = RefPlaceholder; this.registerCSS(watermarkCSS); } wireBeans(beans) { this.licenseManager = beans.licenseManager; } postConstruct() { const show = this.shouldDisplayWatermark(); this.setDisplayed(show); if (show) { this.eLicenseTextRef.textContent = this.licenseManager.getWatermarkMessage(); window.setTimeout(() => this.addCss("ag-opacity-zero"), 0); window.setTimeout(() => this.setDisplayed(false), 5e3); } } shouldDisplayWatermark() { return this.licenseManager.isDisplayWatermark(); } }; var AgWatermarkSelector = { selector: "AG-WATERMARK", component: AgWatermark }; // packages/ag-grid-enterprise/src/license/gridLicenseManager.ts var GridLicenseManager = class extends BeanStub { constructor() { super(...arguments); this.beanName = "licenseManager"; } postConstruct() { this.validateLicense(); } validateLicense() { this.licenseManager = new LicenseManager(_getDocument(this.beans)); this.licenseManager.validateLicense(); } static getLicenseDetails(licenseKey) { return new LicenseManager(null).getLicenseDetails(licenseKey); } getWatermarkSelector() { return AgWatermarkSelector; } isDisplayWatermark() { return this.licenseManager.isDisplayWatermark(); } getWatermarkMessage() { return this.licenseManager.getWatermarkMessage(); } static setLicenseKey(licenseKey) { LicenseManager.setLicenseKey(licenseKey); } static setChartsLicenseManager(chartsLicenseManager) { LicenseManager.setChartsLicenseManager(chartsLicenseManager); } }; // packages/ag-grid-enterprise/src/excelExport/excelCreator.ts import { BaseCreator, _addGridCommonParams as _addGridCommonParams2, _downloadFile, _getHeaderClassesFromColDef, _getHeaderRowCount, _warn as _warn3 } from "ag-grid-community"; // packages/ag-grid-enterprise/src/excelExport/excelSerializingSession.ts import { BaseGridSerializingSession, _addGridCommonParams, _isExpressionString, _last, _mergeDeep, _warn } from "ag-grid-community"; // packages/ag-grid-enterprise/src/excelExport/assets/excelUtils.ts import { _escapeString } from "ag-grid-community"; // packages/ag-grid-enterprise/src/excelExport/assets/excelConstants.ts var INCH_TO_EMU = 9525; var numberFormatMap = { "0": 1, "0.00": 2, "#,##0": 3, "#,##0.00": 4, "0%": 9, "0.00%": 10, "0.00E+00": 11, "# ?/?": 12, "# ??/??": 13, "mm-dd-yy": 14, "d-mmm-yy": 15, "d-mmm": 16, "mmm-yy": 17, "h:mm AM/PM": 18, "h:mm:ss AM/PM": 19, "h:mm": 20, "h:mm:ss": 21, "m/d/yy h:mm": 22, "#,##0 ;(#,##0)": 37, "#,##0 ;[Red](#,##0)": 38, "#,##0.00;(#,##0.00)": 39, "#,##0.00;[Red](#,##0.00)": 40, "mm:ss": 45, "[h]:mm:ss": 46, "mmss.0": 47, "##0.0E+0": 48, "@": 49 }; // packages/ag-grid-enterprise/src/excelExport/assets/xmlFactory.ts var LINE_SEPARATOR = "\r\n"; function returnAttributeIfPopulated(key, value, booleanTransformer) { if (!value && value !== "" && value !== 0) { return ""; } let xmlValue = value; if (typeof value === "boolean") { if (booleanTransformer) { xmlValue = booleanTransformer(value); } } return ` ${key}="${xmlValue}"`; } function createXmlHeader(headerElement = {}) { const headerStart = ""; const headerEnd = "?>"; const keys = ["version"]; if (!headerElement.version) { headerElement.version = "1.0"; } if (headerElement.encoding) { keys.push("encoding"); } if (headerElement.standalone) { keys.push("standalone"); } const att = keys.map((key) => `${key}="${headerElement[key]}"`).join(" "); return `${headerStart}xml ${att} ${headerEnd}`; } function createXml(xmlElement, booleanTransformer) { let props = ""; if (xmlElement.properties) { if (xmlElement.properties.prefixedAttributes) { xmlElement.properties.prefixedAttributes.forEach((prefixedSet) => { for (const key of Object.keys(prefixedSet.map)) { props += returnAttributeIfPopulated( prefixedSet.prefix + key, prefixedSet.map[key], booleanTransformer ); } }); } if (xmlElement.properties.rawMap) { for (const key of Object.keys(xmlElement.properties.rawMap)) { props += returnAttributeIfPopulated(key, xmlElement.properties.rawMap[key], booleanTransformer); } } } let result = "<" + xmlElement.name + props; if (!xmlElement.children && xmlElement.textNode == null) { return result + "/>" + LINE_SEPARATOR; } if (xmlElement.textNode != null) { return result + ">" + xmlElement.textNode + "" + xmlElement.name + ">" + LINE_SEPARATOR; } result += ">" + LINE_SEPARATOR; if (xmlElement.children) { for (const it of xmlElement.children) { result += createXml(it, booleanTransformer); } } return result + "" + xmlElement.name + ">" + LINE_SEPARATOR; } // packages/ag-grid-enterprise/src/excelExport/assets/excelUtils.ts var pointsToPixel = (points) => { return Math.round(points * 96 / 72); }; var pixelsToEMU = (value) => { return Math.ceil(value * INCH_TO_EMU); }; var getFontFamilyId = (name) => { if (name === void 0) { return; } const families = ["Automatic", "Roman", "Swiss", "Modern", "Script", "Decorative"]; const pos = families.indexOf(name || "Automatic"); return Math.max(pos, 0); }; var getHeightFromProperty = (rowIndex, height) => { if (!height) { return; } let finalHeight; if (typeof height === "number") { finalHeight = height; } else { const heightFunc = height; finalHeight = heightFunc({ rowIndex }); } return finalHeight; }; var setExcelImageTotalWidth = (image, columnsToExport) => { const { colSpan, column } = image.position; if (!image.width) { return; } if (colSpan) { const columnsInSpan = columnsToExport.slice(column - 1, column + colSpan - 1); let totalWidth = 0; for (let i = 0; i < columnsInSpan.length; i++) { const colWidth = columnsInSpan[i].getActualWidth(); if (image.width < totalWidth + colWidth) { image.position.colSpan = i + 1; image.totalWidth = image.width; image.width = image.totalWidth - totalWidth; break; } totalWidth += colWidth; } } else { image.totalWidth = image.width; } }; var setExcelImageTotalHeight = (image, rowHeight) => { const { rowSpan, row } = image.position; if (!image.height) { return; } if (rowSpan) { let totalHeight = 0; let counter = 0; for (let i = row; i < row + rowSpan; i++) { const nextRowHeight = pointsToPixel(getHeightFromProperty(i, rowHeight) || 20); if (image.height < totalHeight + nextRowHeight) { image.position.rowSpan = counter + 1; image.totalHeight = image.height; image.height = image.totalHeight - totalHeight; break; } totalHeight += nextRowHeight; counter++; } } else { image.totalHeight = image.height; } }; var createXmlPart = (body, skipHeader) => { const header = createXmlHeader({ encoding: "UTF-8", standalone: "yes" }); const xmlBody = createXml(body); if (skipHeader) { return xmlBody; } return `${header}${xmlBody}`; }; var getExcelColumnName = (colIdx) => { const startCode = 65; const tableWidth = 26; const fromCharCode = String.fromCharCode; const pos = Math.floor(colIdx / tableWidth); const tableIdx = colIdx % tableWidth; if (!pos || colIdx === tableWidth) { return fromCharCode(startCode + colIdx - 1); } if (!tableIdx) { return getExcelColumnName(pos - 1) + "Z"; } if (pos < tableWidth) { return fromCharCode(startCode + pos - 1) + fromCharCode(startCode + tableIdx - 1); } return getExcelColumnName(pos) + fromCharCode(startCode + tableIdx - 1); }; var sanitizeTableName = (name) => { return name.replaceAll("\n", "_x000a_"); }; var replaceInvisibleCharacters = (str) => { if (str == null) { return null; } let newString = ""; for (let i = 0; i < str.length; i++) { const point = str.charCodeAt(i); if (point >= 0 && point <= 31 && point !== 10) { const convertedCode = point.toString(16).toUpperCase(); const paddedCode = convertedCode.padStart(4, "0"); const newValue = `_x${paddedCode}_`; newString += newValue; } else { newString += str[i]; } } return newString; }; var buildSharedString = (strMap) => { const ret = []; for (const key of strMap.keys()) { const textNode = key.toString(); const child = { name: "t", textNode: _escapeString(replaceInvisibleCharacters(textNode)) }; const preserveSpaces = textNode.trim().length !== textNode.length; if (preserveSpaces) { child.properties = { rawMap: { "xml:space": "preserve" } }; } ret.push({ name: "si", children: [child] }); } return ret; }; // packages/ag-grid-enterprise/src/excelExport/excelSerializingSession.ts var ExcelSerializingSession = class extends BaseGridSerializingSession { constructor(config) { super(config); this.mixedStyles = {}; this.mixedStyleCounter = 0; this.rows = []; this.frozenRowCount = 0; this.skipFrozenRows = false; this.frozenColumnCount = 0; this.skipFrozenColumns = false; this.formulaSvc = config.formulaSvc; this.config = Object.assign({}, config); this.workbook = config.workbook; this.stylesByIds = {}; for (const style of this.config.baseExcelStyles) { this.stylesByIds[style.id] = style; } const quotePrefixStyle = { id: "_quotePrefix", quotePrefix: 1 }; this.stylesByIds[quotePrefixStyle.id] = quotePrefixStyle; this.excelStyles = [...this.config.baseExcelStyles, quotePrefixStyle]; } addCustomContent(customContent) { for (const row of customContent) { const rowLen = this.rows.length + 1; let outlineLevel; if (!this.config.suppressRowOutline && row.outlineLevel != null) { outlineLevel = row.outlineLevel; } const rowObj = { height: getHeightFromProperty(rowLen, row.height || this.config.rowHeight), cells: (row.cells || []).map((cell, idx) => { const image = this.addImage(rowLen, this.columnsToExport[idx], cell.data?.value); let excelStyles = null; if (cell.styleId) { excelStyles = typeof cell.styleId === "string" ? [cell.styleId] : cell.styleId; } const excelStyleId = this.getStyleId(excelStyles); if (image) { return this.createCell( excelStyleId, this.getDataTypeForValue(image.value), image.value == null ? "" : image.value ); } const value = cell.data?.value ?? ""; const type = this.getDataTypeForValue(value); if (cell.mergeAcross) { return this.createMergedCell(excelStyleId, type, value, cell.mergeAcross); } return this.createCell(excelStyleId, type, value); }), outlineLevel }; if (row.collapsed != null) { rowObj.collapsed = row.collapsed; } if (row.hidden != null) { rowObj.hidden = row.hidden; } this.rows.push(rowObj); } } onNewHeaderGroupingRow() { const currentCells = []; const { freezeRows, headerRowHeight } = this.config; this.rows.push({ cells: currentCells, height: getHeightFromProperty(this.rows.length + 1, headerRowHeight) }); if (freezeRows) { this.frozenRowCount++; } return { onColumn: (columnGroup, header, index, span, collapsibleGroupRanges) => { const styleIds = this.config.styleLinker({ rowType: "HEADER_GROUPING", rowIndex: 1, value: `grouping-${header}`, columnGroup }); currentCells.push({ ...this.createMergedCell( this.getStyleId(styleIds), this.getDataTypeForValue("string"), header, span ), collapsibleRanges: collapsibleGroupRanges }); } }; } onNewHeaderRow() { const { freezeRows, headerRowHeight } = this.config; if (freezeRows) { this.frozenRowCount++; } return this.onNewRow(this.onNewHeaderColumn, headerRowHeight); } onNewBodyRow(node) { const { freezeRows, rowHeight } = this.config; if (!this.skipFrozenRows) { if (freezeRows === "headersAndPinnedRows" && node?.rowPinned === "top") { this.frozenRowCount++; } else if (typeof freezeRows === "function") { if (freezeRows(_addGridCommonParams(this.gos, { node }))) { this.frozenRowCount++; } else { this.skipFrozenRows = true; } } else { this.skipFrozenRows = true; } } const rowAccumulator = this.onNewRow(this.onNewBodyColumn, rowHeight); if (node) { this.addRowOutlineIfNecessary(node); } return rowAccumulator; } prepare(columnsToExport) { super.prepare(columnsToExport); this.columnsToExport = [...columnsToExport]; this.cols = columnsToExport.map((col, i) => this.convertColumnToExcel(col, i)); } parse() { const longestRow = this.rows.reduce((a, b) => Math.max(a, b.cells.length), 0); while (this.cols.length < longestRow) { this.cols.push(this.convertColumnToExcel(null, this.cols.length + 1)); } const worksheet = this.createWorksheet(); return this.addWorksheetToWorkbook(worksheet); } createWorksheet() { const { sheetName } = this.config; let name; if (sheetName != null) { const sheetNameValue = typeof sheetName === "function" ? sheetName(_addGridCommonParams(this.gos, {})) : sheetName; name = String(sheetNameValue).substring(0, 31); } else { name = "ag-grid"; } return { name, table: { columns: this.cols, rows: this.rows } }; } addRowOutlineIfNecessary(node) { const { gos, suppressRowOutline, rowGroupExpandState = "expanded" } = this.config; const isGroupHideOpenParents = gos.get("groupHideOpenParents"); if (isGroupHideOpenParents || suppressRowOutline || node.level == null) { return; } const padding = node.footer ? 1 : 0; const currentRow = _last(this.rows); if (node.uiLevel == null || node.level === node.uiLevel) { const outlineLevel = Math.min(node.level + padding, 7); currentRow.outlineLevel = outlineLevel; } if (rowGroupExpandState === "expanded") { return; } const collapseAll = rowGroupExpandState === "collapsed"; if (node.isExpandable()) { const isExpanded = !collapseAll && node.expanded; currentRow.collapsed = !isExpanded; } currentRow.hidden = // always show the node if there is no parent to be expanded !!node.parent && // or if it is a child of the root node node.parent.level !== -1 && (collapseAll || this.isAnyParentCollapsed(node.parent)); } isAnyParentCollapsed(node) { while (node && node.level !== -1) { if (!node.expanded) { return true; } node = node.parent; } return false; } convertColumnToExcel(column, index) { const columnWidth = this.config.columnWidth; const headerValue = column ? this.extractHeaderValue(column) : void 0; const displayName = headerValue ?? ""; const filterAllowed = column ? column.isFilterAllowed() : false; if (columnWidth) { if (typeof columnWidth === "number") { return { width: columnWidth, displayName, filterAllowed }; } return { width: columnWidth({ column, index }), displayName, filterAllowed }; } if (column) { const smallestUsefulWidth = 75; return { width: Math.max(column.getActualWidth(), smallestUsefulWidth), displayName, filterAllowed }; } return { displayName, filterAllowed }; } onNewHeaderColumn(rowIndex, currentCells) { return (column) => { const nameForCol = this.extractHeaderValue(column); const styleIds = this.config.styleLinker({ rowType: "HEADER", rowIndex, value: nameForCol, column }); currentCells.push( this.createCell(this.getStyleId(styleIds), this.getDataTypeForValue("string"), nameForCol) ); }; } onNewBodyColumn(rowIndex, currentCells) { let skipCols = 0; const { freezeColumns, rightToLeft } = this.config; return (column, index, node) => { if (skipCols > 0) { skipCols -= 1; return; } if (!this.skipFrozenColumns) { const pinned = column.getPinned(); const isPinnedLeft = pinned === true || pinned === "left"; if (freezeColumns === "pinned" && pinned && isPinnedLeft !== rightToLeft) { this.frozenColumnCount++; } else if (typeof freezeColumns === "function" && freezeColumns(_addGridCommonParams(this.gos, { column }))) { this.frozenColumnCount++; } else { this.skipFrozenColumns = true; } } const { value: valueForCell, valueFormatted } = this.extractRowCellValue({ column, node, currentColumnIndex: index, accumulatedRowIndex: rowIndex, type: "excel", useRawFormula: true }); const rawValueForCell = valueForCell; const valueForCellString = typeof rawValueForCell === "bigint" ? rawValueForCell.toString() : rawValueForCell; const styleIds = this.config.styleLinker({ rowType: "BODY", rowIndex, value: rawValueForCell, column, node }); const excelStyleId = this.getStyleId(styleIds); const colSpan = column.getColSpan(node); const addedImage = this.addImage(rowIndex, column, valueForCellString); if (addedImage) { currentCells.push( this.createCell( excelStyleId, this.getDataTypeForValue(addedImage.value), addedImage.value == null ? "" : addedImage.value ) ); } else if (colSpan > 1) { skipCols = colSpan - 1; currentCells.push( this.createMergedCell( excelStyleId, this.getDataTypeForValue(rawValueForCell), valueForCellString, colSpan - 1 ) ); } else { const isFormula = column.isAllowFormula() && this.formulaSvc?.isFormula(valueForCellString); const cell = this.createCell( excelStyleId, isFormula ? "f" : this.getDataTypeForValue(rawValueForCell), isFormula ? this.formulaSvc?.updateFormulaByOffset({ value: valueForCellString, rowDelta: rowIndex - (node.formulaRowIndex + 1), useRefFormat: false }) : valueForCellString, valueFormatted ); currentCells.push(cell); } }; } onNewRow(onNewColumnAccumulator, height) { const currentCells = []; this.rows.push({ cells: currentCells, height: getHeightFromProperty(this.rows.length + 1, height) }); return { onColumn: onNewColumnAccumulator.bind(this, this.rows.length, currentCells)() }; } addWorksheetToWorkbook(worksheet) { const { excelStyles, config } = this; this.mapSharedStrings(worksheet); if (this.frozenColumnCount) { config.frozenColumnCount = this.frozenColumnCount; } if (this.frozenRowCount) { config.frozenRowCount = this.frozenRowCount; } return this.workbook.addWorksheet(excelStyles, worksheet, config); } mapSharedStrings(worksheet) { let emptyStringPosition; for (const row of worksheet.table.rows) { for (const cell of row.cells) { const data = cell.data; if (!data || data.type !== "s") { continue; } const value = data.value; if (value == null) { continue; } if (value === "") { emptyStringPosition ?? (emptyStringPosition = this.workbook.getStringPosition("").toString()); data.value = emptyStringPosition; continue; } data.value = this.workbook.getStringPosition(String(value)).toString(); } } } getDataTypeForValue(valueForCell) { if (valueForCell === void 0) { return "empty"; } let dataType = "s"; try { if (this.isNumerical(valueForCell)) { dataType = "n"; } } catch (e) { } return dataType; } getTypeFromStyle(style, value) { if (this.isFormula(value)) { return "f"; } if (style?.dataType) { switch (style.dataType.toLocaleLowerCase()) { case "formula": return "f"; case "string": return "s"; case "number": return "n"; case "datetime": return "d"; case "error": return "e"; case "boolean": return "b"; default: _warn(162, { id: style.id, dataType: style.dataType }); } } return null; } addImage(rowIndex, column, value) { if (!this.config.addImageToCell) { return; } const addedImage = this.config.addImageToCell(rowIndex, column, value); if (!addedImage) { return; } this.workbook.addBodyImageToMap( addedImage.image, rowIndex, column, this.columnsToExport, this.config.rowHeight ); return addedImage; } createCell(styleId, type, value, valueFormatted) { const actualStyle = this.getStyleById(styleId); if (!actualStyle?.dataType && type === "s" && valueFormatted != null) { value = valueFormatted; } const processedType = this.getTypeFromStyle(actualStyle, value) || type; const { value: processedValue, escaped } = this.getCellValue(processedType, value); const styles = []; if (actualStyle) { styles.push(styleId); } if (escaped) { styles.push("_quotePrefix"); } styleId = this.getStyleId(styles) || void 0; return { styleId, data: { type: processedType, value: processedValue } }; } createMergedCell(styleId, type, value, numOfCells) { const valueToUse = value == null ? "" : value; return { styleId: this.getStyleById(styleId) ? styleId : void 0, data: { type, value: type === "s" ? String(valueToUse) : value }, mergeAcross: numOfCells }; } getCellValue(type, value) { let escaped = false; if (value == null || type === "s" && value === "") { return { value: "", escaped: false }; } if (type === "s") { value = String(value); if (value[0] === "'") { escaped = true; value = value.slice(1); } } else if (type === "f") { value = this.addXlfnPrefix(value).slice(1); } else if (type === "n") { const numberValue = Number(value); if (isNaN(numberValue)) { value = ""; } else if (value !== "") { value = numberValue.toString(); } } return { value, escaped }; } addXlfnPrefix(value) { if (!value) { return value; } const concatRegex = /(^|[^A-Z0-9._])(CONCAT)(\s*\()/gi; return value.replace(concatRegex, (_match, prefix, fn, openParen) => `${prefix}_xlfn.${fn}${openParen}`); } getStyleId(styleIds) { if (!styleIds?.length) { return null; } const filteredStyleIds = styleIds.filter((styleId) => this.stylesByIds[styleId] != null); if (!filteredStyleIds.length) { return null; } if (filteredStyleIds.length === 1) { return filteredStyleIds[0]; } const key = filteredStyleIds.join("-"); if (!this.mixedStyles[key]) { this.addNewMixedStyle(filteredStyleIds); } return this.mixedStyles[key].excelID; } addNewMixedStyle(styleIds) { this.mixedStyleCounter += 1; const excelId = `mixedStyle${this.mixedStyleCounter}`; const resultantStyle = {}; for (const styleId of styleIds) { const excelStyle = this.stylesByIds[styleId]; if (excelStyle) { _mergeDeep(resultantStyle, excelStyle, true, true); } } resultantStyle.id = excelId; const key = styleIds.join("-"); this.mixedStyles[key] = { excelID: excelId, key, result: resultantStyle }; this.excelStyles.push(resultantStyle); this.stylesByIds[excelId] = resultantStyle; } isFormula(value) { if (value == null) { return false; } const strValue = String(value); return this.config.autoConvertFormulas && _isExpressionString(strValue); } isNumerical(value) { if (typeof value === "bigint") { return false; } return isFinite(value) && value !== "" && !isNaN(parseFloat(value)); } getStyleById(styleId) { if (styleId == null) { return null; } return this.stylesByIds[styleId] || null; } }; // packages/ag-grid-enterprise/src/excelExport/excelXlsxFactory.ts import { _escapeString as _escapeString7, _warn as _warn2 } from "ag-grid-community"; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/contentType.ts var contentTypeFactory = { getTemplate(config) { const { name, ContentType, Extension, PartName } = config; return { name, properties: { rawMap: { Extension, PartName, ContentType } } }; } }; var contentType_default = contentTypeFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/contentTypes.ts var _normaliseImageExtension = (ext) => ext === "jpg" ? "jpeg" : ext; var contentTypesFactory = { getTemplate({ sheetLen, hasCustomProperties }) { const worksheets = new Array(sheetLen).fill(void 0).map((v, i) => ({ name: "Override", ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml", PartName: `/xl/worksheets/sheet${i + 1}.xml` })); const sheetsWithImages = XLSX_WORKSHEET_IMAGES.size; const headerFooterImages = XLSX_WORKSHEET_HEADER_FOOTER_IMAGES.size; const imageTypesObject = {}; XLSX_WORKBOOK_IMAGE_IDS.forEach((v) => { imageTypesObject[_normaliseImageExtension(v.type)] = true; }); const imageDocs = new Array(sheetsWithImages).fill(void 0).map((v, i) => ({ name: "Override", ContentType: "application/vnd.openxmlformats-officedocument.drawing+xml", PartName: `/xl/drawings/drawing${i + 1}.xml` })); const tableDocs = []; XLSX_WORKSHEET_DATA_TABLES.forEach(({ name }) => { tableDocs.push({ name: "Override", ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml", PartName: `/xl/tables/${name}.xml` }); }); const customPropertiesDocs = hasCustomProperties ? [ { name: "Override", ContentType: "application/vnd.openxmlformats-officedocument.custom-properties+xml", PartName: "/docProps/custom.xml" } ] : []; const imageTypes = Object.keys(imageTypesObject).map((ext) => ({ name: "Default", ContentType: `image/${ext}`, Extension: ext })); if (headerFooterImages) { imageTypes.push({ name: "Default", Extension: "vml", ContentType: "application/vnd.openxmlformats-officedocument.vmlDrawing" }); } const children = [ ...imageTypes, { name: "Default", Extension: "rels", ContentType: "application/vnd.openxmlformats-package.relationships+xml" }, { name: "Default", ContentType: "application/xml", Extension: "xml" }, { name: "Override", ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", PartName: "/xl/workbook.xml" }, ...worksheets, { name: "Override", ContentType: "application/vnd.openxmlformats-officedocument.theme+xml", PartName: "/xl/theme/theme1.xml" }, { name: "Override", ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml", PartName: "/xl/styles.xml" }, { name: "Override", ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml", PartName: "/xl/sharedStrings.xml" }, ...imageDocs, ...tableDocs, { name: "Override", ContentType: "application/vnd.openxmlformats-package.core-properties+xml", PartName: "/docProps/core.xml" }, ...customPropertiesDocs ].map((contentType) => contentType_default.getTemplate(contentType)); return { name: "Types", properties: { rawMap: { xmlns: "http://schemas.openxmlformats.org/package/2006/content-types" } }, children }; } }; var contentTypes_default = contentTypesFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/core.ts var coreFactory = { getTemplate(author) { const dt = /* @__PURE__ */ new Date(); const jsonDate = dt.toJSON(); return { name: "cp:coreProperties", properties: { prefixedAttributes: [ { prefix: "xmlns:", map: { cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties", dc: "http://purl.org/dc/elements/1.1/", dcterms: "http://purl.org/dc/terms/", dcmitype: "http://purl.org/dc/dcmitype/", xsi: "http://www.w3.org/2001/XMLSchema-instance" } } ] }, children: [ { name: "dc:creator", textNode: author }, { name: "dc:title", textNode: "Workbook" }, { name: "dcterms:created", properties: { rawMap: { "xsi:type": "dcterms:W3CDTF" } }, textNode: jsonDate }, { name: "dcterms:modified", properties: { rawMap: { "xsi:type": "dcterms:W3CDTF" } }, textNode: jsonDate } ] }; } }; var core_default = coreFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/customProperties.ts import { _escapeString as _escapeString2 } from "ag-grid-community"; var DEFAULT_FMTID = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"; var buildPropertyElements = (metadata) => { const keys = Object.keys(metadata).filter((name) => name && metadata[name] != null); return keys.map((name, index) => ({ name: "property", properties: { rawMap: { fmtid: DEFAULT_FMTID, pid: (index + 2).toString(), name: _escapeString2(name) ?? "" } }, children: [ { name: "vt:lpwstr", textNode: _escapeString2(replaceInvisibleCharacters(String(metadata[name]))) ?? "" } ] })); }; var customPropertiesFactory = { getTemplate(metadata) { return { name: "Properties", properties: { rawMap: { xmlns: "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties", "xmlns:vt": "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes" } }, children: buildPropertyElements(metadata) }; } }; var customProperties_default = customPropertiesFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/drawing.ts var getAnchor = (name, imageAnchor) => ({ name: `xdr:${name}`, children: [ { name: "xdr:col", textNode: imageAnchor.col.toString() }, { name: "xdr:colOff", textNode: imageAnchor.offsetX.toString() }, { name: "xdr:row", textNode: imageAnchor.row.toString() }, { name: "xdr:rowOff", textNode: imageAnchor.offsetY.toString() } ] }); var getExt = (image) => { const children = [ { name: "a:ext", properties: { rawMap: { uri: "{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}" } }, children: [ { name: "a16:creationId", properties: { rawMap: { id: "{822E6D20-D7BC-2841-A643-D49A6EF008A2}", "xmlns:a16": "http://schemas.microsoft.com/office/drawing/2014/main" } } } ] } ]; const recolor = image.recolor?.toLowerCase(); switch (recolor) { case "grayscale": case "sepia": case "washout": children.push({ name: "a:ext", properties: { rawMap: { uri: "{C183D7F6-B498-43B3-948B-1728B52AA6E4}" } }, children: [ { name: "adec:decorative", properties: { rawMap: { val: "0", "xmlns:adec": "http://schemas.microsoft.com/office/drawing/2017/decorative" } } } ] }); } return { name: "a:extLst", children }; }; var getNvPicPr = (image, index) => ({ name: "xdr:nvPicPr", children: [ { name: "xdr:cNvPr", properties: { rawMap: { id: index, name: image.id, descr: image.altText != null ? image.altText : void 0 } }, children: [getExt(image)] }, { name: "xdr:cNvPicPr", properties: { rawMap: { preferRelativeResize: "0" } }, children: [ { name: "a:picLocks" } ] } ] }); var getColorDetails = (color) => { if (!color.saturation && !color.tint) { return; } const ret = []; if (color.saturation) { ret.push({ name: "a:satMod", properties: { rawMap: { val: color.saturation * 1e3 } } }); } if (color.tint) { ret.push({ name: "a:tint", properties: { rawMap: { val: color.tint * 1e3 } } }); } return ret; }; var getDuoTone = (primaryColor, secondaryColor) => { return { name: "a:duotone", children: [ { name: "a:prstClr", properties: { rawMap: { val: primaryColor.color } }, children: getColorDetails(primaryColor) }, { name: "a:srgbClr", properties: { rawMap: { val: secondaryColor.color } }, children: getColorDetails(secondaryColor) } ] }; }; var getBlipFill = (image, index) => { let blipChildren; if (image.transparency) { const transparency = Math.min(Math.max(image.transparency, 0), 100); blipChildren = [ { name: "a:alphaModFix", properties: { rawMap: { amt: 1e5 - Math.round(transparency * 1e3) } } } ]; } if (image.recolor) { if (!blipChildren) { blipChildren = []; } switch (image.recolor.toLocaleLowerCase()) { case "grayscale": blipChildren.push({ name: "a:grayscl" }); break; case "sepia": blipChildren.push(getDuoTone({ color: "black" }, { color: "D9C3A5", tint: 50, saturation: 180 })); break; case "washout": blipChildren.push({ name: "a:lum", properties: { rawMap: { bright: "70000", contrast: "-70000" } } }); break; default: } } return { name: "xdr:blipFill", children: [ { name: "a:blip", properties: { rawMap: { cstate: "print", "r:embed": `rId${index}`, "xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships" } }, children: blipChildren }, { name: "a:stretch", children: [ { name: "a:fillRect" } ] } ] }; }; var getSpPr = (image, imageBoxSize) => { const xfrm = { name: "a:xfrm", children: [ { name: "a:off", properties: { rawMap: { x: 0, y: 0 } } }, { name: "a:ext", properties: { rawMap: { cx: imageBoxSize.width, cy: imageBoxSize.height } } } ] }; if (image.rotation) { const rotation = image.rotation; xfrm.properties = { rawMap: { rot: Math.min(Math.max(rotation, 0), 360) * 6e4 } }; } const prstGeom = { name: "a:prstGeom", properties: { rawMap: { prst: "rect" } }, children: [{ name: "a:avLst" }] }; const ret = { name: "xdr:spPr", children: [xfrm, prstGeom] }; return ret; }; var getImageBoxSize = (image) => { image.fitCell = !!image.fitCell || !image.width || !image.height; const { position = {}, fitCell, width = 0, height = 0, totalHeight, totalWidth } = image; const { offsetX = 0, offsetY = 0, row = 1, rowSpan = 1, column = 1, colSpan = 1 } = position; return { from: { row: row - 1, col: column - 1, offsetX: pixelsToEMU(offsetX), offsetY: pixelsToEMU(offsetY) }, to: { row: row - 1 + (fitCell ? 1 : rowSpan - 1), col: column - 1 + (fitCell ? 1 : colSpan - 1), offsetX: pixelsToEMU(width + offsetX), offsetY: pixelsToEMU(height + offsetY) }, height: pixelsToEMU(totalHeight || height), width: pixelsToEMU(totalWidth || width) }; }; var getPicture = (image, currentIndex, worksheetImageIndex, imageBoxSize) => { return { name: "xdr:pic", children: [ getNvPicPr(image, currentIndex + 1), getBlipFill(image, worksheetImageIndex + 1), getSpPr(image, imageBoxSize) ] }; }; var drawingFactory = { getTemplate(config) { const { sheetIndex } = config; const sheetImages = XLSX_WORKSHEET_IMAGES.get(sheetIndex); const sheetImageIds = XLSX_WORKSHEET_IMAGE_IDS.get(sheetIndex); const children = sheetImages.map((image, idx) => { const boxSize = getImageBoxSize(image); return { name: "xdr:twoCellAnchor", properties: { rawMap: { editAs: "absolute" } }, children: [ getAnchor("from", boxSize.from), getAnchor("to", boxSize.to), getPicture(image, idx, sheetImageIds.get(image.id).index, boxSize), { name: "xdr:clientData" } ] }; }); return { name: "xdr:wsDr", properties: { rawMap: { "xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main", "xmlns:xdr": "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing" } }, children }; } }; var drawing_default = drawingFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/relationship.ts var relationshipFactory = { getTemplate(config) { const { Id, Type, Target } = config; return { name: "Relationship", properties: { rawMap: { Id, Type, Target } } }; } }; var relationship_default = relationshipFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/relationships.ts var relationshipsFactory = { getTemplate(c) { const children = c.map((relationship) => relationship_default.getTemplate(relationship)); return { name: "Relationships", properties: { rawMap: { xmlns: "http://schemas.openxmlformats.org/package/2006/relationships" } }, children }; } }; var relationships_default = relationshipsFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/sharedStrings.ts var sharedStrings = { getTemplate(strings) { return { name: "sst", properties: { rawMap: { xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", count: strings.size, uniqueCount: strings.size } }, children: buildSharedString(strings) }; } }; var sharedStrings_default = sharedStrings; // packages/ag-grid-enterprise/src/excelExport/assets/excelLegacyConvert.ts var getWeightName = (value) => { switch (value) { case 1: return "thin"; case 2: return "medium"; case 3: return "thick"; default: return "hair"; } }; var mappedBorderNames = { None: "None", Dot: "Dotted", Dash: "Dashed", Double: "Double", DashDot: "DashDot", DashDotDot: "DashDotDot", SlantDashDot: "SlantDashDot", Continuous: "Continuous" }; var mediumBorders = ["Dashed", "DashDot", "DashDotDot"]; var colorMap = { None: "none", Solid: "solid", Gray50: "mediumGray", Gray75: "darkGray", Gray25: "lightGray", HorzStripe: "darkHorizontal", VertStripe: "darkVertical", ReverseDiagStripe: "darkDown", DiagStripe: "darkUp", DiagCross: "darkGrid", ThickDiagCross: "darkTrellis", ThinHorzStripe: "lightHorizontal", ThinVertStripe: "lightVertical", ThinReverseDiagStripe: "lightDown", ThinDiagStripe: "lightUp", ThinHorzCross: "lightGrid", ThinDiagCross: "lightTrellis", Gray125: "gray125", Gray0625: "gray0625" }; var horizontalAlignmentMap = { Automatic: "general", Left: "left", Center: "center", Right: "right", Fill: "fill", Justify: "justify", CenterAcrossSelection: "centerContinuous", Distributed: "distributed", JustifyDistributed: "justify" }; var verticalAlignmentMap = { Automatic: void 0, Top: "top", Bottom: "bottom", Center: "center", Justify: "justify", Distributed: "distributed", JustifyDistributed: "justify" }; var convertLegacyPattern = (name) => { if (!name) { return "none"; } return colorMap[name] || name; }; var convertLegacyColor = (color) => { if (color == void 0) { return color; } if (color.charAt(0) === "#") { color = color.substring(1); } return color.length === 6 ? "FF" + color : color; }; var convertLegacyBorder = (type, weight) => { if (!type) { return "thin"; } const namedWeight = getWeightName(weight); if (type === "Continuous") { return namedWeight; } const mappedName = mappedBorderNames[type]; if (namedWeight === "medium" && mediumBorders.some((type2) => type2 === mappedName)) { return `medium${mappedName}`; } return `${mappedName.charAt(0).toLowerCase()}${mappedName.substring(1)}`; }; var convertLegacyHorizontalAlignment = (alignment) => { return horizontalAlignmentMap[alignment] || "general"; }; var convertLegacyVerticalAlignment = (alignment) => { return verticalAlignmentMap[alignment] || void 0; }; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/border.ts var getBorderColor = (color) => { return { name: "color", properties: { rawMap: { rgb: convertLegacyColor(color || "#000000") } } }; }; var borderFactory = { getTemplate(border) { const { left, right, top, bottom, diagonal } = border; const leftChildren = left ? [getBorderColor(left.color)] : void 0; const rightChildren = right ? [getBorderColor(right.color)] : void 0; const topChildren = top ? [getBorderColor(top.color)] : void 0; const bottomChildren = bottom ? [getBorderColor(bottom.color)] : void 0; const diagonalChildren = diagonal ? [getBorderColor(diagonal.color)] : void 0; return { name: "border", children: [ { name: "left", properties: { rawMap: { style: left?.style } }, children: leftChildren }, { name: "right", properties: { rawMap: { style: right?.style } }, children: rightChildren }, { name: "top", properties: { rawMap: { style: top?.style } }, children: topChildren }, { name: "bottom", properties: { rawMap: { style: bottom?.style } }, children: bottomChildren }, { name: "diagonal", properties: { rawMap: { style: diagonal?.style } }, children: diagonalChildren } ] }; } }; var border_default = borderFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/borders.ts var bordersFactory = { getTemplate(borders) { return { name: "borders", properties: { rawMap: { count: borders.length } }, children: borders.map((border) => border_default.getTemplate(border)) }; } }; var borders_default = bordersFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/alignment.ts var getReadingOrderId = (readingOrder) => { const order = ["Context", "LeftToRight", "RightToLeft"]; const pos = order.indexOf(readingOrder); return Math.max(pos, 0); }; var alignmentFactory = { getTemplate(alignment) { const { horizontal, indent, readingOrder, rotate, shrinkToFit, vertical, wrapText } = alignment; return { name: "alignment", properties: { rawMap: { horizontal: horizontal && convertLegacyHorizontalAlignment(horizontal), indent, readingOrder: readingOrder && getReadingOrderId(readingOrder), textRotation: rotate, shrinkToFit, vertical: vertical && convertLegacyVerticalAlignment(vertical), wrapText } } }; } }; var alignment_default = alignmentFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/protection.ts var protectionFactory = { getTemplate(protection) { const locked = protection.protected === false ? 0 : 1; const hidden = protection.hideFormula === true ? 1 : 0; return { name: "protection", properties: { rawMap: { hidden, locked } } }; } }; var protection_default = protectionFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/xf.ts var xfFactory = { getTemplate(xf) { const { alignment, borderId, fillId, fontId, numFmtId, protection, quotePrefix, xfId } = xf; const children = []; if (alignment) { children.push(alignment_default.getTemplate(alignment)); } if (protection) { children.push(protection_default.getTemplate(protection)); } return { name: "xf", properties: { rawMap: { applyAlignment: alignment ? 1 : void 0, applyProtection: protection ? 1 : void 0, applyBorder: borderId ? 1 : void 0, applyFill: fillId ? 1 : void 0, borderId, fillId, applyFont: fontId ? 1 : void 0, fontId, applyNumberFormat: numFmtId ? 1 : void 0, numFmtId, quotePrefix: quotePrefix ? 1 : void 0, xfId } }, children: children.length ? children : void 0 }; } }; var xf_default = xfFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/cellStyleXfs.ts var cellStylesXfsFactory = { getTemplate(xfs) { return { name: "cellStyleXfs", properties: { rawMap: { count: xfs.length } }, children: xfs.map((xf) => xf_default.getTemplate(xf)) }; } }; var cellStyleXfs_default = cellStylesXfsFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/cellStyle.ts var borderFactory2 = { getTemplate(cellStyle) { const { builtinId, name, xfId } = cellStyle; return { name: "cellStyle", properties: { rawMap: { builtinId, name, xfId } } }; } }; var cellStyle_default = borderFactory2; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/cellStyles.ts var cellStylesFactory = { getTemplate(cellStyles) { return { name: "cellStyles", properties: { rawMap: { count: cellStyles.length } }, children: cellStyles.map((cellStyle) => cellStyle_default.getTemplate(cellStyle)) }; } }; var cellStyles_default = cellStylesFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/cellXfs.ts var cellXfsFactory = { getTemplate(xfs) { return { name: "cellXfs", properties: { rawMap: { count: xfs.length } }, children: xfs.map((xf) => xf_default.getTemplate(xf)) }; } }; var cellXfs_default = cellXfsFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/fill.ts var fillFactory = { getTemplate(fill) { const { patternType, fgTheme, fgTint, fgRgb, bgRgb, bgIndexed } = fill; const pf = { name: "patternFill", properties: { rawMap: { patternType } } }; if (fgTheme || fgTint || fgRgb) { pf.children = [ { name: "fgColor", properties: { rawMap: { theme: fgTheme, tint: fgTint, rgb: fgRgb } } } ]; } if (bgIndexed || bgRgb) { if (!pf.children) { pf.children = []; } pf.children.push({ name: "bgColor", properties: { rawMap: { indexed: bgIndexed, rgb: bgRgb } } }); } return { name: "fill", children: [pf] }; } }; var fill_default = fillFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/fills.ts var fillsFactory = { getTemplate(fills) { return { name: "fills", properties: { rawMap: { count: fills.length } }, children: fills.map((fill) => fill_default.getTemplate(fill)) }; } }; var fills_default = fillsFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/font.ts var fontFactory = { getTemplate(font) { const { size, colorTheme, color = "FF000000", fontName = "Calibri", family, scheme, italic, bold, strikeThrough, outline, shadow: shadow2, underline, verticalAlign } = font; const children = [ { name: "sz", properties: { rawMap: { val: size } } }, { name: "color", properties: { rawMap: { theme: colorTheme, rgb: color } } }, { name: "name", properties: { rawMap: { val: fontName } } } ]; if (family) { children.push({ name: "family", properties: { rawMap: { val: family } } }); } if (scheme) { children.push({ name: "scheme", properties: { rawMap: { val: scheme } } }); } if (italic) { children.push({ name: "i" }); } if (bold) { children.push({ name: "b" }); } if (strikeThrough) { children.push({ name: "strike" }); } if (outline) { children.push({ name: "outline" }); } if (shadow2) { children.push({ name: "shadow" }); } if (underline) { children.push({ name: "u", properties: { rawMap: { val: underline } } }); } if (verticalAlign) { children.push({ name: "vertAlign", properties: { rawMap: { val: verticalAlign } } }); } return { name: "font", children }; } }; var font_default = fontFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/fonts.ts var fontsFactory = { getTemplate(fonts) { return { name: "fonts", properties: { rawMap: { count: fonts.length } }, children: fonts.map((font) => font_default.getTemplate(font)) }; } }; var fonts_default = fontsFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/numberFormat.ts import { _escapeString as _escapeString3 } from "ag-grid-community"; function prepareString(str) { const split = str.split(/(\[[^\]]*\])/); for (let i = 0; i < split.length; i++) { let currentString = split[i]; if (!currentString.length) { continue; } if (!currentString.startsWith("[")) { currentString = currentString.replace(/\$/g, '"$"'); } split[i] = _escapeString3(currentString); } return split.join(""); } var numberFormatFactory = { getTemplate(numberFormat) { let { formatCode, numFmtId } = numberFormat; if (formatCode.length) { formatCode = prepareString(formatCode); } return { name: "numFmt", properties: { rawMap: { formatCode, numFmtId } } }; } }; var numberFormat_default = numberFormatFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/numberFormats.ts var numberFormatsFactory = { getTemplate(numberFormats) { return { name: "numFmts", properties: { rawMap: { count: numberFormats.length } }, children: numberFormats.map((numberFormat) => numberFormat_default.getTemplate(numberFormat)) }; } }; var numberFormats_default = numberFormatsFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/styles/stylesheet.ts var stylesMap; var registeredNumberFmts; var registeredFonts; var registeredFills; var registeredBorders; var registeredCellStyleXfs; var registeredCellXfs; var registeredCellStyles; var currentSheet; var getStyleName = (name, currentSheet2) => { if (name.includes("mixedStyle") && currentSheet2 > 1) { name += `_${currentSheet2}`; } return name; }; var resetStylesheetValues = () => { stylesMap = { base: 0 }; registeredNumberFmts = []; registeredFonts = [{ fontName: "Calibri", colorTheme: "1", family: "2", scheme: "minor" }]; registeredFills = [{ patternType: "none" }, { patternType: "gray125" }]; registeredBorders = [{ left: void 0, right: void 0, top: void 0, bottom: void 0, diagonal: void 0 }]; registeredCellStyleXfs = [{ borderId: 0, fillId: 0, fontId: 0, numFmtId: 0 }]; registeredCellXfs = [{ borderId: 0, fillId: 0, fontId: 0, numFmtId: 0, xfId: 0 }]; registeredCellStyles = [{ builtinId: 0, name: "Normal", xfId: 0 }]; }; var registerFill = (fill) => { const convertedPattern = convertLegacyPattern(fill.pattern); const convertedFillColor = convertLegacyColor(fill.color); const convertedPatternColor = convertLegacyColor(fill.patternColor); let pos = registeredFills.findIndex((currentFill) => { const { patternType, fgRgb, bgRgb } = currentFill; return !(patternType != convertedPattern || fgRgb != convertedFillColor || bgRgb != convertedPatternColor); }); if (pos === -1) { pos = registeredFills.length; registeredFills.push({ patternType: convertedPattern, fgRgb: convertedFillColor, bgRgb: convertedPatternColor }); } return pos; }; var registerNumberFmt = (format) => { if (numberFormatMap[format]) { return numberFormatMap[format]; } let pos = registeredNumberFmts.findIndex((currentFormat) => currentFormat.formatCode === format); if (pos === -1) { pos = registeredNumberFmts.length + 164; registeredNumberFmts.push({ formatCode: format, numFmtId: pos }); } else { pos = registeredNumberFmts[pos].numFmtId; } return pos; }; var registerBorders = (borders) => { const { borderBottom, borderTop, borderLeft, borderRight } = borders; let bottomStyle; let topStyle; let leftStyle; let rightStyle; let bottomColor; let topColor; let leftColor; let rightColor; if (borderLeft) { leftStyle = convertLegacyBorder(borderLeft.lineStyle, borderLeft.weight); leftColor = convertLegacyColor(borderLeft.color); } if (borderRight) { rightStyle = convertLegacyBorder(borderRight.lineStyle, borderRight.weight); rightColor = convertLegacyColor(borderRight.color); } if (borderBottom) { bottomStyle = convertLegacyBorder(borderBottom.lineStyle, borderBottom.weight); bottomColor = convertLegacyColor(borderBottom.color); } if (borderTop) { topStyle = convertLegacyBorder(borderTop.lineStyle, borderTop.weight); topColor = convertLegacyColor(borderTop.color); } let pos = registeredBorders.findIndex((currentBorder) => { const { left, right, top, bottom } = currentBorder; if (!left && (leftStyle || leftColor)) { return false; } if (!right && (rightStyle || rightColor)) { return false; } if (!top && (topStyle || topColor)) { return false; } if (!bottom && (bottomStyle || bottomColor)) { return false; } const { style: clS, color: clC } = left || {}; const { style: crS, color: crC } = right || {}; const { style: ctS, color: ctC } = top || {}; const { style: cbS, color: cbC } = bottom || {}; if (clS != leftStyle || clC != leftColor) { return false; } if (crS != rightStyle || crC != rightColor) { return false; } if (ctS != topStyle || ctC != topColor) { return false; } if (cbS != bottomStyle || cbC != bottomColor) { return false; } return true; }); if (pos === -1) { pos = registeredBorders.length; registeredBorders.push({ left: { style: leftStyle, color: leftColor }, right: { style: rightStyle, color: rightColor }, top: { style: topStyle, color: topColor }, bottom: { style: bottomStyle, color: bottomColor }, diagonal: { style: void 0, color: void 0 } }); } return pos; }; var registerFont = (font) => { const { fontName: name = "Calibri", color, size, bold, italic, outline, shadow: shadow2, strikeThrough, underline, family, verticalAlign } = font; const convertedColor = convertLegacyColor(color); const familyId = getFontFamilyId(family); const convertedUnderline = underline ? underline.toLocaleLowerCase() : void 0; const convertedVerticalAlign = verticalAlign ? verticalAlign.toLocaleLowerCase() : void 0; let pos = registeredFonts.findIndex((currentFont) => { return !(currentFont.fontName != name || currentFont.color != convertedColor || currentFont.size != size || currentFont.bold != bold || currentFont.italic != italic || currentFont.outline != outline || currentFont.shadow != shadow2 || currentFont.strikeThrough != strikeThrough || currentFont.underline != convertedUnderline || currentFont.verticalAlign != convertedVerticalAlign || currentFont.family != familyId); }); if (pos === -1) { pos = registeredFonts.length; registeredFonts.push({ fontName: name, color: convertedColor, size, bold, italic, outline, shadow: shadow2, strikeThrough, underline: convertedUnderline, verticalAlign: convertedVerticalAlign, family: familyId != null ? familyId.toString() : void 0 }); } return pos; }; var registerStyle = (config) => { const { alignment, borders, font, interior, numberFormat, protection, quotePrefix } = config; let { id } = config; let currentFill = 0; let currentBorder = 0; let currentFont = 0; let currentNumberFmt = 0; if (!id) { return; } id = getStyleName(id, currentSheet); if (stylesMap[id] != void 0) { return; } if (interior) { currentFill = registerFill(interior); } if (borders) { currentBorder = registerBorders(borders); } if (font) { currentFont = registerFont(font); } if (numberFormat) { currentNumberFmt = registerNumberFmt(numberFormat.format); } stylesMap[id] = registeredCellXfs.length; registeredCellXfs.push({ alignment, borderId: currentBorder || 0, fillId: currentFill || 0, fontId: currentFont || 0, numFmtId: currentNumberFmt || 0, protection, quotePrefix, xfId: 0 }); }; var stylesheetFactory = { getTemplate(defaultFontSize) { const numberFormats = numberFormats_default.getTemplate(registeredNumberFmts); const fonts = fonts_default.getTemplate( registeredFonts.map((font) => ({ ...font, size: font.size != null ? font.size : defaultFontSize })) ); const fills = fills_default.getTemplate(registeredFills); const borders = borders_default.getTemplate(registeredBorders); const cellStylesXfs = cellStyleXfs_default.getTemplate(registeredCellStyleXfs); const cellXfs = cellXfs_default.getTemplate(registeredCellXfs); const cellStyles = cellStyles_default.getTemplate(registeredCellStyles); resetStylesheetValues(); return { name: "styleSheet", properties: { rawMap: { "mc:Ignorable": "x14ac x16r2 xr", xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006", "xmlns:x14ac": "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac", "xmlns:x16r2": "http://schemas.microsoft.com/office/spreadsheetml/2015/02/main", "xmlns:xr": "http://schemas.microsoft.com/office/spreadsheetml/2014/revision" } }, children: [ numberFormats, fonts, fills, borders, cellStylesXfs, cellXfs, cellStyles, { name: "tableStyles", properties: { rawMap: { count: 0, defaultPivotStyle: "PivotStyleLight16", defaultTableStyle: "TableStyleMedium2" } } } ] }; } }; var getStyleId = (name, currentSheet2) => { return stylesMap[getStyleName(name, currentSheet2)] || 0; }; var registerStyles = (styles, _currentSheet) => { currentSheet = _currentSheet; if (currentSheet === 1) { resetStylesheetValues(); } styles.forEach(registerStyle); }; var stylesheet_default = stylesheetFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/table.ts import { _escapeString as _escapeString4 } from "ag-grid-community"; var tableFactory = { getTemplate(dataTable, idx) { const { name, columns, rowRange, displayName, showRowStripes, showColumnStripes, showFilterButtons, highlightFirstColumn, highlightLastColumn } = dataTable || {}; const noRows = !rowRange || rowRange[0] - rowRange[1] === 0; if (!dataTable || !name || !Array.isArray(columns) || !columns.length || noRows) { return { name: "table" }; } const filterColumns = columns.map((col, idx2) => ({ name: "filterColumn", properties: { rawMap: { colId: idx2.toString(), // For filters, this should start with 0 hiddenButton: showFilterButtons[idx2] ? 0 : 1 } } })); const firstCell = `A${rowRange[0]}`; const lastCell = `${getExcelColumnName(columns.length)}${rowRange[1]}`; const ref = `${firstCell}:${lastCell}`; const id = `${idx + 1}`; const displayNameToUse = idx ? `${displayName}_${id}` : displayName; return { name: "table", properties: { rawMap: { xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main", "xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006", "mc:Ignorable": "xr xr3", "xmlns:xr": "http://schemas.microsoft.com/office/spreadsheetml/2014/revision", "xmlns:xr3": "http://schemas.microsoft.com/office/spreadsheetml/2016/revision3", name: displayNameToUse, displayName: displayNameToUse, ref, totalsRowShown: 0, id } }, children: [ { name: "autoFilter", properties: { rawMap: { ref } }, children: filterColumns }, { name: "tableColumns", properties: { rawMap: { count: columns.length } }, children: columns.map((col, idx2) => ({ name: "tableColumn", properties: { rawMap: { id: (idx2 + 1).toString(), name: _escapeString4(sanitizeTableName(col)), dataCellStyle: "Normal" } } })) }, { name: "tableStyleInfo", properties: { rawMap: { name: "TableStyleLight1", showFirstColumn: highlightFirstColumn ? 1 : 0, showLastColumn: highlightLastColumn ? 1 : 0, showRowStripes: showRowStripes ? 1 : 0, showColumnStripes: showColumnStripes ? 1 : 0 } } } ] }; } }; var table_default = tableFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/themes/office/colorScheme.ts var getColorChildren = (props) => { const [type, innerType, val, lastClr] = props; return { name: `a:${type}`, children: [ { name: `a:${innerType}`, properties: { rawMap: { val, lastClr } } } ] }; }; var colorScheme = { getTemplate() { return { name: "a:clrScheme", properties: { rawMap: { name: "Office" } }, children: [ getColorChildren(["dk1", "sysClr", "windowText", "000000"]), getColorChildren(["lt1", "sysClr", "window", "FFFFFF"]), getColorChildren(["dk2", "srgbClr", "44546A"]), getColorChildren(["lt2", "srgbClr", "E7E6E6"]), getColorChildren(["accent1", "srgbClr", "4472C4"]), getColorChildren(["accent2", "srgbClr", "ED7D31"]), getColorChildren(["accent3", "srgbClr", "A5A5A5"]), getColorChildren(["accent4", "srgbClr", "FFC000"]), getColorChildren(["accent5", "srgbClr", "5B9BD5"]), getColorChildren(["accent6", "srgbClr", "70AD47"]), getColorChildren(["hlink", "srgbClr", "0563C1"]), getColorChildren(["folHlink", "srgbClr", "954F72"]) ] }; } }; var colorScheme_default = colorScheme; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/themes/office/fontScheme.ts var getFont = (props) => { const [type, typeface, script, panose] = props; return { name: `a:${type}`, properties: { rawMap: { script, typeface, panose } } }; }; var fontScheme = { getTemplate() { return { name: "a:fontScheme", properties: { rawMap: { name: "Office" } }, children: [ { name: "a:majorFont", children: [ getFont(["latin", "Calibri Light", void 0, "020F0302020204030204"]), getFont(["ea", ""]), getFont(["cs", ""]), getFont(["font", "\u6E38\u30B4\u30B7\u30C3\u30AF Light", "Jpan"]), getFont(["font", "\uB9D1\uC740 \uACE0\uB515", "Hang"]), getFont(["font", "\u7B49\u7EBF Light", "Hans"]), getFont(["font", "\u65B0\u7D30\u660E\u9AD4", "Hant"]), getFont(["font", "Times New Roman", "Arab"]), getFont(["font", "Times New Roman", "Hebr"]), getFont(["font", "Tahoma", "Thai"]), getFont(["font", "Nyala", "Ethi"]), getFont(["font", "Vrinda", "Beng"]), getFont(["font", "Shruti", "Gujr"]), getFont(["font", "MoolBoran", "Khmr"]), getFont(["font", "Tunga", "Knda"]), getFont(["font", "Raavi", "Guru"]), getFont(["font", "Euphemia", "Cans"]), getFont(["font", "Plantagenet Cherokee", "Cher"]), getFont(["font", "Microsoft Yi Baiti", "Yiii"]), getFont(["font", "Microsoft Himalaya", "Tibt"]), getFont(["font", "MV Boli", "Thaa"]), getFont(["font", "Mangal", "Deva"]), getFont(["font", "Gautami", "Telu"]), getFont(["font", "Latha", "Taml"]), getFont(["font", "Estrangelo Edessa", "Syrc"]), getFont(["font", "Kalinga", "Orya"]), getFont(["font", "Kartika", "Mlym"]), getFont(["font", "DokChampa", "Laoo"]), getFont(["font", "Iskoola Pota", "Sinh"]), getFont(["font", "Mongolian Baiti", "Mong"]), getFont(["font", "Times New Roman", "Viet"]), getFont(["font", "Microsoft Uighur", "Uigh"]), getFont(["font", "Sylfaen", "Geor"]), getFont(["font", "Arial", "Armn"]), getFont(["font", "Leelawadee UI", "Bugi"]), getFont(["font", "Microsoft JhengHei", "Bopo"]), getFont(["font", "Javanese Text", "Java"]), getFont(["font", "Segoe UI", "Lisu"]), getFont(["font", "Myanmar Text", "Mymr"]), getFont(["font", "Ebrima", "Nkoo"]), getFont(["font", "Nirmala UI", "Olck"]), getFont(["font", "Ebrima", "Osma"]), getFont(["font", "Phagspa", "Phag"]), getFont(["font", "Estrangelo Edessa", "Syrn"]), getFont(["font", "Estrangelo Edessa", "Syrj"]), getFont(["font", "Estrangelo Edessa", "Syre"]), getFont(["font", "Nirmala UI", "Sora"]), getFont(["font", "Microsoft Tai Le", "Tale"]), getFont(["font", "Microsoft New Tai Lue", "Talu"]), getFont(["font", "Ebrima", "Tfng"]) ] }, { name: "a:minorFont", children: [ getFont(["latin", "Calibri", void 0, "020F0502020204030204"]), getFont(["ea", ""]), getFont(["cs", ""]), getFont(["font", "\u6E38\u30B4\u30B7\u30C3\u30AF", "Jpan"]), getFont(["font", "\uB9D1\uC740 \uACE0\uB515", "Hang"]), getFont(["font", "\u7B49\u7EBF", "Hans"]), getFont(["font", "\u65B0\u7D30\u660E\u9AD4", "Hant"]), getFont(["font", "Arial", "Arab"]), getFont(["font", "Arial", "Hebr"]), getFont(["font", "Tahoma", "Thai"]), getFont(["font", "Nyala", "Ethi"]), getFont(["font", "Vrinda", "Beng"]), getFont(["font", "Shruti", "Gujr"]), getFont(["font", "DaunPenh", "Khmr"]), getFont(["font", "Tunga", "Knda"]), getFont(["font", "Raavi", "Guru"]), getFont(["font", "Euphemia", "Cans"]), getFont(["font", "Plantagenet Cherokee", "Cher"]), getFont(["font", "Microsoft Yi Baiti", "Yiii"]), getFont(["font", "Microsoft Himalaya", "Tibt"]), getFont(["font", "MV Boli", "Thaa"]), getFont(["font", "Mangal", "Deva"]), getFont(["font", "Gautami", "Telu"]), getFont(["font", "Latha", "Taml"]), getFont(["font", "Estrangelo Edessa", "Syrc"]), getFont(["font", "Kalinga", "Orya"]), getFont(["font", "Kartika", "Mlym"]), getFont(["font", "DokChampa", "Laoo"]), getFont(["font", "Iskoola Pota", "Sinh"]), getFont(["font", "Mongolian Baiti", "Mong"]), getFont(["font", "Arial", "Viet"]), getFont(["font", "Microsoft Uighur", "Uigh"]), getFont(["font", "Sylfaen", "Geor"]), getFont(["font", "Arial", "Armn"]), getFont(["font", "Leelawadee UI", "Bugi"]), getFont(["font", "Microsoft JhengHei", "Bopo"]), getFont(["font", "Javanese Text", "Java"]), getFont(["font", "Segoe UI", "Lisu"]), getFont(["font", "Myanmar Text", "Mymr"]), getFont(["font", "Ebrima", "Nkoo"]), getFont(["font", "Nirmala UI", "Olck"]), getFont(["font", "Ebrima", "Osma"]), getFont(["font", "Phagspa", "Phag"]), getFont(["font", "Estrangelo Edessa", "Syrn"]), getFont(["font", "Estrangelo Edessa", "Syrj"]), getFont(["font", "Estrangelo Edessa", "Syre"]), getFont(["font", "Nirmala UI", "Sora"]), getFont(["font", "Microsoft Tai Le", "Tale"]), getFont(["font", "Microsoft New Tai Lue", "Talu"]), getFont(["font", "Ebrima", "Tfng"]) ] } ] }; } }; var fontScheme_default = fontScheme; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/themes/office/formatScheme.ts var getPropertyVal = (name, val, children) => ({ name: `a:${name}`, properties: { rawMap: { val } }, children }); var getGs = (props) => { const [pos, schemeColor, satMod, lumMod, tint, shade] = props; const children = []; children.push(getPropertyVal("satMod", satMod)); if (lumMod) { children.push(getPropertyVal("lumMod", lumMod)); } if (tint) { children.push(getPropertyVal("tint", tint)); } if (shade) { children.push(getPropertyVal("shade", shade)); } return { name: "a:gs", properties: { rawMap: { pos } }, children: [ { name: "a:schemeClr", properties: { rawMap: { val: schemeColor } }, children } ] }; }; var getSolidFill = (val, children) => ({ name: "a:solidFill", children: [getPropertyVal("schemeClr", val, children)] }); var getGradFill = (props) => { const [rotWithShape, gs1, gs2, gs3, lin] = props; const [ang, scaled] = lin; return { name: "a:gradFill", properties: { rawMap: { rotWithShape } }, children: [ { name: "a:gsLst", children: [getGs(gs1), getGs(gs2), getGs(gs3)] }, { name: "a:lin", properties: { rawMap: { ang, scaled } } } ] }; }; var getLine = (props) => { const [w, cap, cmpd, algn] = props; return { name: "a:ln", properties: { rawMap: { w, cap, cmpd, algn } }, children: [ getSolidFill("phClr"), getPropertyVal("prstDash", "solid"), { name: "a:miter", properties: { rawMap: { lim: "800000" } } } ] }; }; var getEffectStyle = (shadow2) => { const children = []; if (shadow2) { const [blurRad, dist, dir, algn, rotWithShape] = shadow2; children.push({ name: "a:outerShdw", properties: { rawMap: { blurRad, dist, dir, algn, rotWithShape } }, children: [getPropertyVal("srgbClr", "000000", [getPropertyVal("alpha", "63000")])] }); } return { name: "a:effectStyle", children: [ Object.assign( {}, { name: "a:effectLst" }, children.length ? { children } : {} ) ] }; }; var getFillStyleList = () => ({ name: "a:fillStyleLst", children: [ getSolidFill("phClr"), getGradFill([ "1", ["0", "phClr", "105000", "110000", "67000"], ["50000", "phClr", "103000", "105000", "73000"], ["100000", "phClr", "109000", "105000", "81000"], ["5400000", "0"] ]), getGradFill([ "1", ["0", "phClr", "103000", "102000", "94000"], ["50000", "phClr", "110000", "100000", void 0, "100000"], ["100000", "phClr", "120000", "99000", void 0, "78000"], ["5400000", "0"] ]) ] }); var getLineStyleList = () => ({ name: "a:lnStyleLst", children: [ getLine(["6350", "flat", "sng", "ctr"]), getLine(["12700", "flat", "sng", "ctr"]), getLine(["19050", "flat", "sng", "ctr"]) ] }); var getEffectStyleList = () => ({ name: "a:effectStyleLst", children: [getEffectStyle(), getEffectStyle(), getEffectStyle(["57150", "19050", "5400000", "ctr", "0"])] }); var getBgFillStyleList = () => ({ name: "a:bgFillStyleLst", children: [ getSolidFill("phClr"), getSolidFill("phClr", [getPropertyVal("tint", "95000"), getPropertyVal("satMod", "170000")]), getGradFill([ "1", ["0", "phClr", "150000", "102000", "93000", "98000"], ["50000", "phClr", "130000", "103000", "98000", "90000"], ["100000", "phClr", "120000", void 0, void 0, "63000"], ["5400000", "0"] ]) ] }); var formatScheme = { getTemplate() { return { name: "a:fmtScheme", properties: { rawMap: { name: "Office" } }, children: [getFillStyleList(), getLineStyleList(), getEffectStyleList(), getBgFillStyleList()] }; } }; var formatScheme_default = formatScheme; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/themes/office/themeElements.ts var themeElements = { getTemplate() { return { name: "a:themeElements", children: [colorScheme_default.getTemplate(), fontScheme_default.getTemplate(), formatScheme_default.getTemplate()] }; } }; var themeElements_default = themeElements; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/themes/office.ts var officeTheme = { getTemplate() { return { name: "a:theme", properties: { prefixedAttributes: [ { prefix: "xmlns:", map: { a: "http://schemas.openxmlformats.org/drawingml/2006/main" } } ], rawMap: { name: "Office Theme" } }, children: [ themeElements_default.getTemplate(), { name: "a:objectDefaults" }, { name: "a:extraClrSchemeLst" } ] }; } }; var office_default = officeTheme; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/vmlDrawing.ts var getShapeLayout = () => ({ name: "o:shapelayout", properties: { prefixedAttributes: [ { prefix: "v:", map: { ext: "edit" } } ] }, children: [ { name: "o:idmap", properties: { prefixedAttributes: [ { prefix: "v:", map: { ext: "edit" } } ], rawMap: { data: "1" } } } ] }); var getStroke = () => ({ name: "v:stroke", properties: { rawMap: { joinstyle: "miter" } } }); var getFormulas = (formulas) => ({ name: "v:formulas", children: formulas.map((formula) => ({ name: "v:f", properties: { rawMap: { eqn: formula } } })) }); var getPath = () => ({ name: "v:path", properties: { prefixedAttributes: [ { prefix: "o:", map: { connecttype: "rect", extrusionok: "f" } } ], rawMap: { gradientshapeok: "t" } } }); var getLock = (params) => { const { aspectratio, rotation } = params || {}; const rawMap = {}; if (aspectratio) { rawMap.aspectratio = "t"; } if (rotation) { rawMap.rotation = "t"; } return { name: "o:lock", properties: { prefixedAttributes: [ { prefix: "v:", map: { ext: "edit" } } ], rawMap } }; }; function mapNumber(value, startSource, endSource, startTarget, endTarget) { return (value - startSource) / (endSource - startSource) * (endTarget - startTarget) + startTarget; } var getImageData = (image, idx) => { let rawMap; const { recolor, brightness, contrast, id } = image; if (recolor) { rawMap = {}; if (recolor === "Washout" || recolor === "Grayscale") { rawMap.gain = "19661f"; rawMap.blacklevel = "22938f"; } if (recolor === "Black & White" || recolor === "Grayscale") { rawMap.grayscale = "t"; if (recolor === "Black & White") { rawMap.bilevel = "t"; } } } if (!recolor || recolor === "Grayscale") { if (!rawMap) { rawMap = {}; } if (contrast != null && contrast !== 50) { let gain = "1"; if (contrast >= 0) { if (contrast < 50) { gain = String(contrast / 50); } else if (contrast < 100) { gain = String(50 / (100 - contrast)); } else if (contrast === 100) { gain = "2147483647f"; } } rawMap.gain = gain; } if (brightness != null && brightness !== 50) { rawMap.blacklevel = mapNumber(brightness, 0, 100, -0.5, 0.5).toString(); } } return { name: "v:imagedata", properties: { prefixedAttributes: [ { prefix: "o:", map: { relid: `rId${idx}`, title: id } } ], rawMap } }; }; var getShapeType = () => { const formulas = [ "if lineDrawn pixelLineWidth 0", "sum @0 1 0", "sum 0 0 @1", "prod @2 1 2", "prod @3 21600 pixelWidth", "prod @3 21600 pixelHeight", "sum @0 0 1", "prod @6 1 2", "prod @7 21600 pixelWidth", "sum @8 21600 0", "prod @7 21600 pixelHeight", "sum @10 21600 0" ]; return { name: "v:shapetype", properties: { prefixedAttributes: [ { prefix: "o:", map: { spt: "75", preferrelative: "t" } } ], rawMap: { coordsize: "21600,21600", filled: "f", id: "_x0000_t75", path: "m@4@5l@4@11@9@11@9@5xe", stroked: "f" } }, children: [getStroke(), getFormulas(formulas), getPath(), getLock({ aspectratio: true })] }; }; var pixelToPoint = (value) => Math.floor((value ?? 0) * 0.74999943307122); var getShape = (image, idx) => { const { width = 0, height = 0, altText } = image; const imageWidth = pixelToPoint(width); const imageHeight = pixelToPoint(height); return { name: "v:shape", properties: { rawMap: { id: image.headerFooterPosition, "o:spid": "_x0000_s1025", style: `position: absolute; margin-left: 0; margin-top: 10in; margin-bottom: 0; margin-right: 0; width: ${imageWidth}pt; height: ${imageHeight}pt; z-index: ${idx + 1}`, type: "#_x0000_t75", alt: altText } }, children: [getImageData(image, idx + 1), getLock({ rotation: true })] }; }; var vmlDrawingFactory = { getTemplate(params) { const headerFooterImages = XLSX_WORKSHEET_HEADER_FOOTER_IMAGES.get(params.sheetIndex) || []; const children = [ getShapeLayout(), getShapeType(), ...headerFooterImages.map((img, idx) => getShape(img, idx)) ]; return { name: "xml", properties: { prefixedAttributes: [ { prefix: "xmlns:", map: { v: "urn:schemas-microsoft-com:vml", o: "urn:schemas-microsoft-com:office:office", x: "urn:schemas-microsoft-com:office:excel" } } ] }, children }; } }; var vmlDrawing_default = vmlDrawingFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/sheet.ts var sheetFactory = { getTemplate(name, idx) { const sheetId = (idx + 1).toString(); return { name: "sheet", properties: { rawMap: { name, sheetId, "r:id": `rId${sheetId}` } } }; } }; var sheet_default = sheetFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/sheets.ts var sheetsFactory = { getTemplate(names) { return { name: "sheets", children: names.map((sheet, idx) => sheet_default.getTemplate(sheet, idx)) }; } }; var sheets_default = sheetsFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/workbook.ts var workbookFactory = { getTemplate(names, activeTab) { return { name: "workbook", properties: { prefixedAttributes: [ { prefix: "xmlns:", map: { r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships" } } ], rawMap: { xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main" } }, children: [ { name: "bookViews", children: [ { name: "workbookView", properties: { rawMap: { activeTab } } } ] }, sheets_default.getTemplate(names) ] }; } }; var workbook_default = workbookFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/worksheet.ts import { _escapeString as _escapeString6 } from "ag-grid-community"; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/column.ts var getExcelCellWidth = (width) => Math.ceil((width - 12) / 7 + 1); var colFactory = { getTemplate(config) { const { min, max, outlineLevel, s: s2, width, hidden, bestFit } = config; let excelWidth = 1; let customWidth = "0"; if (width > 1) { excelWidth = getExcelCellWidth(width); customWidth = "1"; } return { name: "col", properties: { rawMap: { min, max, outlineLevel: outlineLevel != null ? outlineLevel : void 0, width: excelWidth, style: s2, hidden: hidden ? "1" : "0", bestFit: bestFit ? "1" : "0", customWidth } } }; } }; var column_default = colFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/mergeCell.ts var mergeCellFactory = { getTemplate(ref) { return { name: "mergeCell", properties: { rawMap: { ref } } }; } }; var mergeCell_default = mergeCellFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/cell.ts import { _escapeString as _escapeString5 } from "ag-grid-community"; var convertLegacyType = (type) => { const t = type.charAt(0).toLowerCase(); return t === "s" ? "inlineStr" : t; }; var cellFactory = { getTemplate(config, idx, currentSheet2) { const { ref, data, styleId } = config; const { type, value } = data || { type: "empty", value: null }; let convertedType = type; if (type === "f") { convertedType = "str"; } else if (type.charAt(0) === type.charAt(0).toUpperCase()) { convertedType = convertLegacyType(type); } const obj = { name: "c", properties: { rawMap: { r: ref, t: convertedType === "empty" ? void 0 : convertedType, s: styleId ? getStyleId(styleId, currentSheet2) : void 0 } } }; if (convertedType === "empty") { return obj; } let children; if (convertedType === "str" && type === "f") { children = [ { name: "f", textNode: _escapeString5(replaceInvisibleCharacters(value)) } ]; } else if (convertedType === "inlineStr") { children = [ { name: "is", children: [ { name: "t", textNode: _escapeString5(replaceInvisibleCharacters(value)) } ] } ]; } else { children = [ { name: "v", textNode: value } ]; } return Object.assign({}, obj, { children }); } }; var cell_default = cellFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/row.ts var addEmptyCells = (cells, rowIdx) => { const mergeMap = []; let posCounter = 0; for (let i = 0; i < cells.length; i++) { const cell = cells[i]; if (cell.mergeAcross) { mergeMap.push({ pos: i, excelPos: posCounter }); posCounter += cell.mergeAcross; } posCounter++; } if (mergeMap.length) { for (let i = mergeMap.length - 1; i >= 0; i--) { const mergedCells = []; const cell = cells[mergeMap[i].pos]; for (let j = 1; j <= cell.mergeAcross; j++) { mergedCells.push({ ref: `${getExcelColumnName(mergeMap[i].excelPos + 1 + j)}${rowIdx + 1}`, styleId: cell.styleId, data: { type: "empty", value: null } }); } if (mergedCells.length) { cells.splice(mergeMap[i].pos + 1, 0, ...mergedCells); } } } }; var shouldDisplayCell = (cell) => cell.data?.value !== "" || cell.styleId !== void 0; var rowFactory = { getTemplate(config, idx, currentSheet2) { const { collapsed, hidden, height, outlineLevel, cells = [] } = config; addEmptyCells(cells, idx); const children = cells.filter(shouldDisplayCell).map((cell, idx2) => cell_default.getTemplate(cell, idx2, currentSheet2)); return { name: "row", properties: { rawMap: { r: idx + 1, collapsed: collapsed ? "1" : "0", hidden: hidden ? "1" : "0", ht: height, customHeight: height != null ? "1" : "0", spans: "1:1", outlineLevel: outlineLevel || void 0 } }, children }; } }; var row_default = rowFactory; // packages/ag-grid-enterprise/src/excelExport/files/ooxml/worksheet.ts var getMergedCellsAndAddColumnGroups = (rows, cols, suppressColumnOutline) => { const mergedCells = []; const cellsWithCollapsibleGroups = []; rows.forEach((currentRow, rowIdx) => { const cells = currentRow.cells; let merges = 0; let lastCol; cells.forEach((currentCell, cellIdx) => { const min = cellIdx + merges + 1; const start = getExcelColumnName(min); const outputRow = rowIdx + 1; if (currentCell.mergeAcross) { merges += currentCell.mergeAcross; const end = getExcelColumnName(cellIdx + merges + 1); mergedCells.push(`${start}${outputRow}:${end}${outputRow}`); } if (!cols[min - 1]) { cols[min - 1] = {}; } const { collapsibleRanges } = currentCell; if (collapsibleRanges) { collapsibleRanges.forEach((range) => { cellsWithCollapsibleGroups.push([min + range[0], min + range[1]]); }); } lastCol = cols[min - 1]; lastCol.min = min; lastCol.max = min; currentCell.ref = `${start}${outputRow}`; }); }); cellsWithCollapsibleGroups.sort((a, b) => { if (a[0] !== b[0]) { return a[0] - b[0]; } return b[1] - a[1]; }); const rangeMap = /* @__PURE__ */ new Map(); const outlineLevel = /* @__PURE__ */ new Map(); cellsWithCollapsibleGroups.filter((currentRange) => { const rangeString = currentRange.toString(); const inMap = rangeMap.get(rangeString); if (inMap) { return false; } rangeMap.set(rangeString, true); return true; }).forEach((range) => { const refCol = cols.find((col) => col.min == range[0] && col.max == range[1]); const currentOutlineLevel = outlineLevel.get(range[0]); cols.push({ min: range[0], max: range[1], outlineLevel: suppressColumnOutline ? void 0 : currentOutlineLevel || 1, width: (refCol || { width: 100 }).width }); outlineLevel.set(range[0], (currentOutlineLevel || 0) + 1); }); return mergedCells; }; var getPageOrientation = (orientation) => { if (!orientation || orientation !== "Portrait" && orientation !== "Landscape") { return "portrait"; } return orientation.toLocaleLowerCase(); }; var getPageSize = (pageSize) => { if (pageSize == null) { return 1; } const positions = [ "Letter", "Letter Small", "Tabloid", "Ledger", "Legal", "Statement", "Executive", "A3", "A4", "A4 Small", "A5", "A6", "B4", "B5", "Folio", "Envelope", "Envelope DL", "Envelope C5", "Envelope B5", "Envelope C3", "Envelope C4", "Envelope C6", "Envelope Monarch", "Japanese Postcard", "Japanese Double Postcard" ]; const pos = positions.indexOf(pageSize); return pos === -1 ? 1 : pos + 1; }; var replaceHeaderFooterTokens = (value) => { const map = { "&[Page]": "&P", "&[Pages]": "&N", "&[Date]": "&D", "&[Time]": "&T", "&[Tab]": "&A", "&[Path]": "&Z", "&[File]": "&F", "&[Picture]": "&G" }; for (const key of Object.keys(map)) { value = value.replace(key, map[key]); } return value; }; var getHeaderPosition = (position) => { if (position === "Center") { return "C"; } if (position === "Right") { return "R"; } return "L"; }; var applyHeaderFontStyle = (headerString, font) => { if (!font) { return headerString; } headerString += "&""; headerString += font.fontName || "Calibri"; if (font.bold !== font.italic) { headerString += font.bold ? ",Bold" : ",Italic"; } else if (font.bold) { headerString += ",Bold Italic"; } else { headerString += ",Regular"; } headerString += """; if (font.size) { headerString += `&${font.size}`; } if (font.strikeThrough) { headerString += "&S"; } if (font.underline) { headerString += `&${font.underline === "Double" ? "E" : "U"}`; } if (font.color) { headerString += `&K${font.color.replace("#", "").toUpperCase()}`; } return headerString; }; var processHeaderFooterContent = (content, location, rule) => content.reduce((prev, curr, idx) => { const pos = getHeaderPosition(curr.position); const output = applyHeaderFontStyle(`${prev}&${pos}`, curr.font); const PositionMap = ["Left", "Center", "Right"]; if (!curr.position) { curr.position = PositionMap[idx]; } const { image } = curr; if (curr.value === "&[Picture]" && image) { const imagePosition = `${pos}${location}${rule}`; addXlsxHeaderFooterImageToMap(image, imagePosition); } return `${output}${_escapeString6(replaceHeaderFooterTokens(curr.value))}`; }, ""); var buildHeaderFooter = (headerFooterConfig) => { const rules = ["all", "first", "even"]; const headersAndFooters = []; rules.forEach((rule) => { const headerFooter = headerFooterConfig[rule]; const namePrefix = rule === "all" ? "odd" : rule; if (!headerFooter) { return; } for (const key of Object.keys(headerFooter)) { const value = headerFooter[key]; const nameSuffix = `${key.charAt(0).toUpperCase()}${key.slice(1)}`; const location = key[0].toUpperCase(); if (value) { const normalizedRule = rule === "all" ? "" : rule.toUpperCase(); headersAndFooters.push({ name: `${namePrefix}${nameSuffix}`, properties: { rawMap: { "xml:space": "preserve" } }, textNode: processHeaderFooterContent(value, location, normalizedRule) }); } } }); return headersAndFooters; }; var addColumns = (columns) => { return (params) => { if (columns.length) { params.children.push({ name: "cols", children: columns.map((column) => column_default.getTemplate(column)) }); } return params; }; }; var addSheetData = (rows, sheetNumber) => { return (params) => { if (rows.length) { params.children.push({ name: "sheetData", children: rows.map((row, idx) => row_default.getTemplate(row, idx, sheetNumber)) }); } return params; }; }; var getPasswordHash = (password) => { const passwordLength = password.length; if (!passwordLength) { return ""; } const passwordArray = new Array(passwordLength + 1); passwordArray[0] = passwordLength; for (let i = 1; i <= passwordLength; i++) { passwordArray[i] = password.charCodeAt(i - 1) & 255; } let verifier = 0; for (let i = passwordArray.length - 1; i >= 0; i--) { const passwordByte = passwordArray[i]; const intermediate1 = (verifier & 16384) === 0 ? 0 : 1; const intermediate2 = verifier << 1 & 32767; verifier = (intermediate1 | intermediate2) ^ passwordByte; } return (verifier ^ 52811).toString(16).toUpperCase().padStart(4, "0"); }; var addSheetProtection = (protectSheet) => { return (params) => { if (!protectSheet) { return params; } const sheetProtection = typeof protectSheet === "boolean" ? {} : protectSheet; const rawMap = { sheet: 1 }; const passwordHash = sheetProtection.password ? getPasswordHash(sheetProtection.password) : ""; if (passwordHash) { rawMap.password = passwordHash; } const defaults = { autoFilter: false, deleteColumns: false, deleteRows: false, formatCells: false, formatColumns: false, formatRows: false, insertColumns: false, insertHyperlinks: false, insertRows: false, pivotTables: false, selectLockedCells: true, selectUnlockedCells: true }; Object.keys(defaults).forEach( (key) => { const allow = sheetProtection[key]; if (allow == null || allow === defaults[key]) { return; } rawMap[key] = allow ? 0 : 1; } ); params.children.push({ name: "sheetProtection", properties: { rawMap } }); return params; }; }; var addMergeCells = (mergeCells) => { return (params) => { if (mergeCells.length) { params.children.push({ name: "mergeCells", properties: { rawMap: { count: mergeCells.length } }, children: mergeCells.map((mergedCell) => mergeCell_default.getTemplate(mergedCell)) }); } return params; }; }; var addPageMargins = (margins) => { return (params) => { const { top = 0.75, right = 0.7, bottom = 0.75, left = 0.7, header = 0.3, footer = 0.3 } = margins; params.children.push({ name: "pageMargins", properties: { rawMap: { bottom, footer, header, left, right, top } } }); return params; }; }; var addPageSetup = (pageSetup) => { return (params) => { if (pageSetup) { params.children.push({ name: "pageSetup", properties: { rawMap: { horizontalDpi: 0, verticalDpi: 0, orientation: getPageOrientation(pageSetup.orientation), paperSize: getPageSize(pageSetup.pageSize) } } }); } return params; }; }; var addHeaderFooter = (headerFooterConfig) => { return (params) => { if (!headerFooterConfig) { return params; } const differentFirst = headerFooterConfig.first != null ? 1 : 0; const differentOddEven = headerFooterConfig.even != null ? 1 : 0; params.children.push({ name: "headerFooter", properties: { rawMap: { differentFirst, differentOddEven } }, children: buildHeaderFooter(headerFooterConfig) }); return params; }; }; var addExcelTableRel = (excelTable) => { return (params) => { if (excelTable) { params.children.push({ name: "tableParts", properties: { rawMap: { count: "1" } }, children: [ { name: "tablePart", properties: { rawMap: { "r:id": `rId${++params.rIdCounter}` } } } ] }); } return params; }; }; var addDrawingRel = (currentSheet2) => { return (params) => { const worksheetImages = XLSX_WORKSHEET_IMAGES.get(currentSheet2); if (worksheetImages?.length) { params.children.push({ name: "drawing", properties: { rawMap: { "r:id": `rId${++params.rIdCounter}` } } }); } return params; }; }; var addVmlDrawingRel = (currentSheet2) => { return (params) => { if (XLSX_WORKSHEET_HEADER_FOOTER_IMAGES.get(currentSheet2)) { params.children.push({ name: "legacyDrawingHF", properties: { rawMap: { "r:id": `rId${++params.rIdCounter}` } } }); } return params; }; }; var getPane = (xSplit = 0, ySplit = 0) => { const shouldSplit = xSplit > 0 || ySplit > 0; return shouldSplit ? [ { name: "pane", properties: { rawMap: { state: shouldSplit ? "frozen" : void 0, topLeftCell: shouldSplit ? `${getExcelColumnName(xSplit + 1)}${ySplit + 1}` : void 0, xSplit: xSplit === 0 ? void 0 : xSplit, ySplit: ySplit === 0 ? void 0 : ySplit } } } ] : void 0; }; var addSheetViews = (rtl = false, xSplit, ySplit) => { return (params) => { params.children.push({ name: "sheetViews", children: [ { name: "sheetView", properties: { rawMap: { rightToLeft: rtl === true ? "1" : "0", workbookViewId: "0" } }, children: getPane(xSplit, ySplit) } ] }); return params; }; }; var addSheetPr = () => { return (params) => { params.children.push({ name: "sheetPr", children: [ { name: "outlinePr", properties: { rawMap: { summaryBelow: 0 } } } ] }); return params; }; }; var addSheetFormatPr = (rows) => { return (params) => { const maxOutline = rows.reduce((prev, row) => { if (row.outlineLevel && row.outlineLevel > prev) { return row.outlineLevel; } return prev; }, 0); params.children.push({ name: "sheetFormatPr", properties: { rawMap: { baseColWidth: 10, defaultRowHeight: 16, outlineLevelRow: maxOutline ? maxOutline : void 0 } } }); return params; }; }; var worksheetFactory = { getTemplate(params) { const { worksheet, currentSheet: currentSheet2, config } = params; const { margins = {}, pageSetup, headerFooterConfig, suppressColumnOutline, rightToLeft, frozenRowCount, frozenColumnCount, protectSheet } = config; const { table } = worksheet; const { rows, columns } = table; const mergedCells = columns?.length ? getMergedCellsAndAddColumnGroups(rows, columns, !!suppressColumnOutline) : []; const worksheetExcelTables = XLSX_WORKSHEET_DATA_TABLES.get(currentSheet2); const { children } = [ addSheetPr(), addSheetViews(rightToLeft, frozenColumnCount, frozenRowCount), addSheetFormatPr(rows), addColumns(columns), addSheetData(rows, currentSheet2 + 1), addSheetProtection(protectSheet), addMergeCells(mergedCells), addPageMargins(margins), addPageSetup(pageSetup), addHeaderFooter(headerFooterConfig), addDrawingRel(currentSheet2), addVmlDrawingRel(currentSheet2), addExcelTableRel(worksheetExcelTables) ].reduce((composed, f) => f(composed), { children: [], rIdCounter: 0 }); return { name: "worksheet", properties: { prefixedAttributes: [ { prefix: "xmlns:", map: { r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships" } } ], rawMap: { xmlns: "http://schemas.openxmlformats.org/spreadsheetml/2006/main" } }, children }; } }; var worksheet_default = worksheetFactory; // packages/ag-grid-enterprise/src/excelExport/excelXlsxFactory.ts var XLSX_SHARED_STRINGS = /* @__PURE__ */ new Map(); var XLSX_SHEET_NAMES = []; var XLSX_SHEET_DATA = []; var XLSX_SHEET_CONTENT_INDICES = /* @__PURE__ */ new Map(); var XLSX_IMAGES = /* @__PURE__ */ new Map(); var XLSX_WORKSHEET_IMAGES = /* @__PURE__ */ new Map(); var XLSX_WORKSHEET_HEADER_FOOTER_IMAGES = /* @__PURE__ */ new Map(); var XLSX_WORKBOOK_IMAGE_IDS = /* @__PURE__ */ new Map(); var XLSX_WORKSHEET_IMAGE_IDS = /* @__PURE__ */ new Map(); var XLSX_WORKSHEET_DATA_TABLES = /* @__PURE__ */ new Map(); var DEFAULT_TABLE_DISPLAY_NAME = "AG-GRID-TABLE"; var XLSX_FACTORY_MODE = "SINGLE_SHEET"; function getXlsxFactoryMode() { return XLSX_FACTORY_MODE; } function setXlsxFactoryMode(factoryMode) { XLSX_FACTORY_MODE = factoryMode; } function createXlsxExcel(styles, worksheet, config) { addSheetName(worksheet); registerStyles(styles, XLSX_SHEET_NAMES.length); const newConfig = Object.assign({}, config); if (config.exportAsExcelTable && config.pivotModeActive) { _warn2(163, { featureName: "pivot mode" }); newConfig.exportAsExcelTable = false; } processTableConfig(worksheet, newConfig); const worksheetXml = createWorksheet(worksheet, newConfig); registerSheetXml(worksheetXml); return worksheetXml; } function getXlsxSanitizedTableName(name) { return name.replace(/^[^a-zA-Z_]+/, "_").replace(/\s/g, "_").replace(/[^a-zA-Z0-9_]/g, "_"); } function addXlsxTableToSheet(sheetIndex, table) { if (XLSX_WORKSHEET_DATA_TABLES.has(sheetIndex)) { _warn2(164); return; } XLSX_WORKSHEET_DATA_TABLES.set(sheetIndex, table); } function processTableConfig(worksheet, config) { const { exportAsExcelTable, prependContent, appendContent, headerRowCount = 0 } = config; if (!exportAsExcelTable) { return; } const tableConfig = typeof exportAsExcelTable === "boolean" ? {} : exportAsExcelTable; const { name, showColumnStripes, showRowStripes, showFilterButton, highlightFirstColumn, highlightLastColumn } = tableConfig; const tableName = getXlsxSanitizedTableName(name || DEFAULT_TABLE_DISPLAY_NAME); const sheetIndex = XLSX_SHEET_NAMES.length - 1; const { table } = worksheet; const { rows, columns } = table; const skipTopRows = prependContent ? prependContent.length : 0; const removeFromBottom = appendContent ? appendContent.length : 0; const tableRowCount = rows.length; const tableColCount = columns.length; const tableColumns = []; const showFilterButtons = []; for (let i = 0; i < tableColCount; i++) { const col = columns[i]; tableColumns.push(col.displayName || ""); showFilterButtons.push( showFilterButton === "match" || showFilterButton === void 0 ? col.filterAllowed ?? false : showFilterButton ); } if (!tableColumns?.length || !tableRowCount || !tableName) { _warn2(165); return; } addXlsxTableToSheet(sheetIndex, { name: `table${XLSX_WORKSHEET_DATA_TABLES.size + 1}`, displayName: tableName, columns: tableColumns, showFilterButtons, rowRange: [headerRowCount + skipTopRows, headerRowCount + (tableRowCount - headerRowCount) - removeFromBottom], showRowStripes: showRowStripes ?? true, showColumnStripes: showColumnStripes ?? false, highlightFirstColumn: highlightFirstColumn ?? false, highlightLastColumn: highlightLastColumn ?? false }); } function addXlsxHeaderFooterImageToMap(image, position) { const sheetIndex = XLSX_SHEET_NAMES.length - 1; const headerFooterImage = image; headerFooterImage.headerFooterPosition = position; buildImageMap({ imageToAdd: headerFooterImage, idx: sheetIndex }); let headerFooterImagesForSheet = XLSX_WORKSHEET_HEADER_FOOTER_IMAGES.get(sheetIndex); if (!headerFooterImagesForSheet) { headerFooterImagesForSheet = []; XLSX_WORKSHEET_HEADER_FOOTER_IMAGES.set(sheetIndex, headerFooterImagesForSheet); } if (!headerFooterImagesForSheet.find((img) => img.id === image.id)) { headerFooterImagesForSheet.push(image); } } function addXlsxBodyImageToMap(image, rowIndex, col, columnsToExport, rowHeight) { const sheetIndex = XLSX_SHEET_NAMES.length; const { row, column } = image.position || {}; const calculatedImage = image; if (columnsToExport) { if (rowIndex != null && col != null && (!row || !column)) { if (!image.position) { image.position = {}; } image.position = Object.assign({}, image.position, { row: rowIndex, column: columnsToExport.indexOf(col) + 1 }); } setExcelImageTotalWidth(calculatedImage, columnsToExport); setExcelImageTotalHeight(calculatedImage, rowHeight); } buildImageMap({ imageToAdd: calculatedImage, idx: sheetIndex }); let worksheetImageIdMap = XLSX_WORKSHEET_IMAGE_IDS.get(sheetIndex); if (!worksheetImageIdMap) { worksheetImageIdMap = /* @__PURE__ */ new Map(); XLSX_WORKSHEET_IMAGE_IDS.set(sheetIndex, worksheetImageIdMap); } const sheetImages = XLSX_WORKSHEET_IMAGES.get(sheetIndex); if (!sheetImages) { XLSX_WORKSHEET_IMAGES.set(sheetIndex, [calculatedImage]); } else { sheetImages.push(calculatedImage); } if (!worksheetImageIdMap.get(image.id)) { worksheetImageIdMap.set(image.id, { index: worksheetImageIdMap.size, type: image.imageType }); } } function buildImageMap(params) { const { imageToAdd, idx } = params; const mappedImagesToSheet = XLSX_IMAGES.get(imageToAdd.id); if (mappedImagesToSheet) { const currentSheetImages = mappedImagesToSheet.find((currentImage) => currentImage.sheetId === idx); if (currentSheetImages) { currentSheetImages.image.push(imageToAdd); } else { mappedImagesToSheet.push({ sheetId: idx, image: [imageToAdd] }); } } else { XLSX_IMAGES.set(imageToAdd.id, [{ sheetId: idx, image: [imageToAdd] }]); XLSX_WORKBOOK_IMAGE_IDS.set(imageToAdd.id, { type: imageToAdd.imageType, index: XLSX_WORKBOOK_IMAGE_IDS.size }); } } function addSheetName(worksheet) { const name = _escapeString7(worksheet.name) || ""; let append = ""; while (XLSX_SHEET_NAMES.indexOf(`${name}${append}`) !== -1) { if (append === "") { append = "_1"; } else { const curr = parseInt(append.slice(1), 10); append = `_${curr + 1}`; } } worksheet.name = `${name}${append}`; XLSX_SHEET_NAMES.push(worksheet.name); } function getXlsxStringPosition(str) { if (XLSX_SHARED_STRINGS.has(str)) { return XLSX_SHARED_STRINGS.get(str); } XLSX_SHARED_STRINGS.set(str, XLSX_SHARED_STRINGS.size); return XLSX_SHARED_STRINGS.size - 1; } function resetXlsxFactory() { XLSX_SHARED_STRINGS.clear(); XLSX_IMAGES.clear(); XLSX_WORKSHEET_IMAGES.clear(); XLSX_WORKSHEET_HEADER_FOOTER_IMAGES.clear(); XLSX_WORKBOOK_IMAGE_IDS.clear(); XLSX_WORKSHEET_IMAGE_IDS.clear(); XLSX_WORKSHEET_DATA_TABLES.clear(); XLSX_SHEET_NAMES = []; XLSX_SHEET_DATA = []; XLSX_SHEET_CONTENT_INDICES = /* @__PURE__ */ new Map(); XLSX_FACTORY_MODE = "SINGLE_SHEET"; } function createXlsxWorkbook(currentSheet2) { return createXmlPart(workbook_default.getTemplate(XLSX_SHEET_NAMES, currentSheet2)); } function createXlsxStylesheet(defaultFontSize) { return createXmlPart(stylesheet_default.getTemplate(defaultFontSize)); } function createXlsxSharedStrings() { return createXmlPart(sharedStrings_default.getTemplate(XLSX_SHARED_STRINGS)); } function createXlsxCore(author) { return createXmlPart(core_default.getTemplate(author)); } function createXlsxCustomProperties(metadata) { return createXmlPart(customProperties_default.getTemplate(metadata)); } function createXlsxContentTypes(sheetLen, hasCustomProperties) { return createXmlPart(contentTypes_default.getTemplate({ sheetLen, hasCustomProperties })); } function createXlsxRels(hasCustomProperties) { const relationships = [ { Id: "rId1", Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", Target: "xl/workbook.xml" }, { Id: "rId2", Type: "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties", Target: "docProps/core.xml" } ]; if (hasCustomProperties) { relationships.push({ Id: "rId3", Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties", Target: "docProps/custom.xml" }); } const rs = relationships_default.getTemplate(relationships); return createXmlPart(rs); } function createXlsxTheme() { return createXmlPart(office_default.getTemplate()); } function createXlsxTable(dataTable, index) { return createXmlPart(table_default.getTemplate(dataTable, index)); } function createXlsxWorkbookRels(sheetLen) { const worksheets = new Array(sheetLen).fill(void 0).map((v, i) => ({ Id: `rId${i + 1}`, Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet", Target: `worksheets/sheet${i + 1}.xml` })); const rs = relationships_default.getTemplate([ ...worksheets, { Id: `rId${sheetLen + 1}`, Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", Target: "theme/theme1.xml" }, { Id: `rId${sheetLen + 2}`, Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", Target: "styles.xml" }, { Id: `rId${sheetLen + 3}`, Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings", Target: "sharedStrings.xml" } ]); return createXmlPart(rs); } function createXlsxDrawing(sheetIndex) { return createXmlPart(drawing_default.getTemplate({ sheetIndex })); } function createXlsxDrawingRel(sheetIndex) { const worksheetImageIds = XLSX_WORKSHEET_IMAGE_IDS.get(sheetIndex) || []; const XMLArr = []; for (const [key, value] of worksheetImageIds) { const { index, type } = value; XMLArr.push({ Id: `rId${index + 1}`, Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", Target: `../media/image${XLSX_WORKBOOK_IMAGE_IDS.get(key).index + 1}.${_normaliseImageExtension(type)}` }); } return createXmlPart(relationships_default.getTemplate(XMLArr)); } function createXlsxVmlDrawing(sheetIndex) { return createXmlPart(vmlDrawing_default.getTemplate({ sheetIndex }), true); } function createXlsxVmlDrawingRel(sheetIndex) { const worksheetHeaderFooterImages = XLSX_WORKSHEET_HEADER_FOOTER_IMAGES.get(sheetIndex) || []; const XMLArr = []; for (let i = 0; i < worksheetHeaderFooterImages.length; i++) { const headerFooterImage = worksheetHeaderFooterImages[i]; const workbookImage = XLSX_WORKBOOK_IMAGE_IDS.get(headerFooterImage.id); if (!workbookImage) { continue; } const { index, type } = workbookImage; XMLArr.push({ Id: `rId${i + 1}`, Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image", Target: `../media/image${index + 1}.${_normaliseImageExtension(type)}` }); } return createXmlPart(relationships_default.getTemplate(XMLArr)); } function createXlsxRelationships({ drawingIndex, vmlDrawingIndex, tableName } = {}) { if (drawingIndex === void 0 && vmlDrawingIndex === void 0 && tableName === void 0) { return ""; } const config = []; if (drawingIndex != null) { config.push({ Id: `rId${config.length + 1}`, Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing", Target: `../drawings/drawing${drawingIndex + 1}.xml` }); } if (vmlDrawingIndex != null) { config.push({ Id: `rId${config.length + 1}`, Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing", Target: `../drawings/vmlDrawing${vmlDrawingIndex + 1}.vml` }); } if (tableName != null) { config.push({ Id: `rId${config.length + 1}`, Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table", Target: `../tables/${tableName}.xml` }); } const rs = relationships_default.getTemplate(config); return createXmlPart(rs); } function createWorksheet(worksheet, config) { return createXmlPart( worksheet_default.getTemplate({ worksheet, currentSheet: XLSX_SHEET_NAMES.length - 1, config }) ); } var reorderSheetSpecificMap = (map, order) => { if (!map.size) { return; } const remapped = /* @__PURE__ */ new Map(); order.forEach((originalIdx, newIdx) => { if (map.has(originalIdx)) { remapped.set(newIdx, map.get(originalIdx)); } }); map.clear(); remapped.forEach((value, key) => map.set(key, value)); }; var registerSheetXml = (worksheetXml) => { const indices = XLSX_SHEET_CONTENT_INDICES.get(worksheetXml) ?? []; indices.push(XLSX_SHEET_NAMES.length - 1); XLSX_SHEET_CONTENT_INDICES.set(worksheetXml, indices); XLSX_SHEET_DATA.push(worksheetXml); }; var getSheetOrderFromRefs = (data) => { const refMap = new Map(XLSX_SHEET_CONTENT_INDICES); const order = []; for (const sheetData of data) { const indices = refMap.get(sheetData); if (!indices?.length) { return null; } const idx = indices.shift(); order.push(idx); refMap.set(sheetData, indices); } return order; }; var getSheetOrderFromData = (data) => { if (!data.length || XLSX_SHEET_DATA.length === 0) { return null; } const consumed = /* @__PURE__ */ new Set(); const order = []; for (const sheetData of data) { const matchIndex = XLSX_SHEET_DATA.findIndex((value, idx) => !consumed.has(idx) && value === sheetData); if (matchIndex === -1) { return null; } consumed.add(matchIndex); order.push(matchIndex); } return order; }; var reorderSheetState = (order) => { const indexRemap = /* @__PURE__ */ new Map(); order.forEach((originalIdx, newIdx) => indexRemap.set(originalIdx, newIdx)); XLSX_SHEET_NAMES = order.map((idx) => XLSX_SHEET_NAMES[idx]); XLSX_SHEET_DATA = order.map((idx) => XLSX_SHEET_DATA[idx]); reorderSheetSpecificMap(XLSX_WORKSHEET_IMAGES, order); reorderSheetSpecificMap(XLSX_WORKSHEET_HEADER_FOOTER_IMAGES, order); reorderSheetSpecificMap(XLSX_WORKSHEET_DATA_TABLES, order); reorderSheetSpecificMap(XLSX_WORKSHEET_IMAGE_IDS, order); XLSX_IMAGES.forEach((sheetImages) => { sheetImages.forEach((entry) => { const remappedId = indexRemap.get(entry.sheetId); if (remappedId != null) { entry.sheetId = remappedId; } }); }); XLSX_SHEET_CONTENT_INDICES = /* @__PURE__ */ new Map(); XLSX_SHEET_DATA.forEach((xml, idx) => { const indices = XLSX_SHEET_CONTENT_INDICES.get(xml) ?? []; indices.push(idx); XLSX_SHEET_CONTENT_INDICES.set(xml, indices); }); }; var syncXlsxOrderWithSheetData = (data) => { if (data.length <= 1) { return; } const order = getSheetOrderFromRefs(data) ?? getSheetOrderFromData(data); if (!order) { return; } reorderSheetState(order); }; var Workbook = class { getStringPosition(str) { return getXlsxStringPosition(str); } addBodyImageToMap(image, rowIndex, col, columnsToExport, rowHeight) { addXlsxBodyImageToMap(image, rowIndex, col, columnsToExport, rowHeight); } addHeaderFooterImageToMap(image, position) { addXlsxHeaderFooterImageToMap(image, position); } addWorksheet(styles, worksheet, config) { return createXlsxExcel(styles, worksheet, config); } syncOrderWithSheetData(data) { syncXlsxOrderWithSheetData(data); } reset() { resetXlsxFactory(); } setFactoryMode(factoryMode) { setXlsxFactoryMode(factoryMode); } getFactoryMode() { return getXlsxFactoryMode(); } getSheetNames() { return [...XLSX_SHEET_NAMES]; } }; // packages/ag-grid-enterprise/src/excelExport/zipContainer/zipContainerHelper.ts import { _errMsg } from "ag-grid-community"; // packages/ag-grid-enterprise/src/excelExport/zipContainer/compress.ts var compressBlob = async (data) => { let chunksSize = 0; const chunks = []; const writeCompressedData = new WritableStream({ write: (chunk) => { chunks.push(chunk); chunksSize += chunk.length; } }); const readable = new ReadableStream({ start: (controller) => { const reader = new FileReader(); reader.onload = (e) => { if (e.target?.result) { controller.enqueue(e.target.result); } controller.close(); }; reader.readAsArrayBuffer(data); } }); const compressStream = new window.CompressionStream("deflate-raw"); await readable.pipeThrough(compressStream).pipeTo(writeCompressedData); return { size: chunksSize, content: new Blob(chunks) }; }; var deflateLocalFile = async (rawContent) => { const contentAsBlob = new Blob([rawContent]); const { size: compressedSize, content: compressedContent } = await compressBlob(contentAsBlob); const compressedContentAsUint8Array = new Uint8Array(await compressedContent.arrayBuffer()); return { size: compressedSize, content: compressedContentAsUint8Array }; }; // packages/ag-grid-enterprise/src/excelExport/zipContainer/convert.ts var convertTime = (date) => { let time = date.getHours(); time <<= 6; time = time | date.getMinutes(); time <<= 5; time = time | date.getSeconds() / 2; return time; }; var convertDate = (date) => { let dt = date.getFullYear() - 1980; dt <<= 4; dt = dt | date.getMonth() + 1; dt <<= 5; dt = dt | date.getDate(); return dt; }; function convertDecToHex(number, bytes) { let hex = ""; for (let i = 0; i < bytes; i++) { hex += String.fromCharCode(number & 255); number >>>= 8; } return hex; } // packages/ag-grid-enterprise/src/excelExport/zipContainer/crcTable.ts var getCrcFromCrc32TableAndByteArray = (content) => { if (!content.length) { return 0; } let crc = 0 ^ -1; let j = 0; let k = 0; let l = 0; for (let i = 0; i < content.length; i++) { j = content[i]; k = (crc ^ j) & 255; l = crcTable[k]; crc = crc >>> 8 ^ l; } return crc ^ -1; }; var getCrcFromCrc32Table = (content) => { if (!content.length) { return 0; } if (typeof content === "string") { return getCrcFromCrc32TableAndByteArray(new TextEncoder().encode(content)); } return getCrcFromCrc32TableAndByteArray(content); }; var crcTable = /* @__PURE__ */ new Uint32Array([ 0, 1996959894, 3993919788, 2567524794, 124634137, 1886057615, 3915621685, 2657392035, 249268274, 2044508324, 3772115230, 2547177864, 162941995, 2125561021, 3887607047, 2428444049, 498536548, 1789927666, 4089016648, 2227061214, 450548861, 1843258603, 4107580753, 2211677639, 325883990, 1684777152, 4251122042, 2321926636, 335633487, 1661365465, 4195302755, 2366115317, 997073096, 1281953886, 3579855332, 2724688242, 1006888145, 1258607687, 3524101629, 2768942443, 901097722, 1119000684, 3686517206, 2898065728, 853044451, 1172266101, 3705015759, 2882616665, 651767980, 1373503546, 3369554304, 3218104598, 565507253, 1454621731, 3485111705, 3099436303, 671266974, 1594198024, 3322730930, 2970347812, 795835527, 1483230225, 3244367275, 3060149565, 1994146192, 31158534, 2563907772, 4023717930, 1907459465, 112637215, 2680153253, 3904427059, 2013776290, 251722036, 2517215374, 3775830040, 2137656763, 141376813, 2439277719, 3865271297, 1802195444, 476864866, 2238001368, 4066508878, 1812370925, 453092731, 2181625025, 4111451223, 1706088902, 314042704, 2344532202, 4240017532, 1658658271, 366619977, 2362670323, 4224994405, 1303535960, 984961486, 2747007092, 3569037538, 1256170817, 1037604311, 2765210733, 3554079995, 1131014506, 879679996, 2909243462, 3663771856, 1141124467, 855842277, 2852801631, 3708648649, 1342533948, 654459306, 3188396048, 3373015174, 1466479909, 544179635, 3110523913, 3462522015, 1591671054, 702138776, 2966460450, 3352799412, 1504918807, 783551873, 3082640443, 3233442989, 3988292384, 2596254646, 62317068, 1957810842, 3939845945, 2647816111, 81470997, 1943803523, 3814918930, 2489596804, 225274430, 2053790376, 3826175755, 2466906013, 167816743, 2097651377, 4027552580, 2265490386, 503444072, 1762050814, 4150417245, 2154129355, 426522225, 1852507879, 4275313526, 2312317920, 282753626, 1742555852, 4189708143, 2394877945, 397917763, 1622183637, 3604390888, 2714866558, 953729732, 1340076626, 3518719985, 2797360999, 1068828381, 1219638859, 3624741850, 2936675148, 906185462, 1090812512, 3747672003, 2825379669, 829329135, 1181335161, 3412177804, 3160834842, 628085408, 1382605366, 3423369109, 3138078467, 570562233, 1426400815, 3317316542, 2998733608, 733239954, 1555261956, 3268935591, 3050360625, 752459403, 1541320221, 2607071920, 3965973030, 1969922972, 40735498, 2617837225, 3943577151, 1913087877, 83908371, 2512341634, 3803740692, 2075208622, 213261112, 2463272603, 3855990285, 2094854071, 198958881, 2262029012, 4057260610, 1759359992, 534414190, 2176718541, 4139329115, 1873836001, 414664567, 2282248934, 4279200368, 1711684554, 285281116, 2405801727, 4167216745, 1634467795, 376229701, 2685067896, 3608007406, 1308918612, 956543938, 2808555105, 3495958263, 1231636301, 1047427035, 2932959818, 3654703836, 1088359270, 936918e3, 2847714899, 3736837829, 1202900863, 817233897, 3183342108, 3401237130, 1404277552, 615818150, 3134207493, 3453421203, 1423857449, 601450431, 3009837614, 3294710456, 1567103746, 711928724, 3020668471, 3272380065, 1510334235, 755167117 ]); // packages/ag-grid-enterprise/src/excelExport/zipContainer/zipContainerHelper.ts function _utf8_encode(s2) { const stringFromCharCode = String.fromCharCode; function ucs2decode(string) { const output = []; if (!string) { return []; } const len = string.length; let counter = 0; let value; let extra; while (counter < len) { value = string.charCodeAt(counter++); if (value >= 55296 && value <= 56319 && counter < len) { extra = string.charCodeAt(counter++); if ((extra & 64512) == 56320) { output.push(((value & 1023) << 10) + (extra & 1023) + 65536); } else { output.push(value); counter--; } } else { output.push(value); } } return output; } function checkScalarValue(point) { if (point >= 55296 && point <= 57343) { throw new Error(_errMsg(255, { point })); } } function createByte(point, shift) { return stringFromCharCode(point >> shift & 63 | 128); } function encodeCodePoint(point) { if ((point & 4294967168) == 0) { return stringFromCharCode(point); } let symbol = ""; if ((point & 4294965248) == 0) { symbol = stringFromCharCode(point >> 6 & 31 | 192); } else if ((point & 4294901760) == 0) { checkScalarValue(point); symbol = stringFromCharCode(point >> 12 & 15 | 224); symbol += createByte(point, 6); } else if ((point & 4292870144) == 0) { symbol = stringFromCharCode(point >> 18 & 7 | 240); symbol += createByte(point, 12); symbol += createByte(point, 6); } symbol += stringFromCharCode(point & 63 | 128); return symbol; } const codePoints = ucs2decode(s2); const length = codePoints.length; let index = -1; let codePoint; let byteString = ""; while (++index < length) { codePoint = codePoints[index]; byteString += encodeCodePoint(codePoint); } return byteString; } var getHeaders = (currentFile, isCompressed, offset, rawSize, rawContent, deflatedSize) => { const { content, path, created: creationDate } = currentFile; const time = convertTime(creationDate); const dt = convertDate(creationDate); const crcFlag = getCrcFromCrc32Table(rawContent); const zipSize = deflatedSize !== void 0 ? deflatedSize : rawSize; const utfPath = _utf8_encode(path); const isUTF8 = utfPath !== path; let extraFields = ""; if (isUTF8) { const uExtraFieldPath = convertDecToHex(1, 1) + convertDecToHex(getCrcFromCrc32Table(utfPath), 4) + utfPath; extraFields = "up" + convertDecToHex(uExtraFieldPath.length, 2) + uExtraFieldPath; } const commonHeader = "\0" + // version needed to extract (isUTF8 ? "\0\b" : "\0\0") + // Language encoding flag (EFS) (12th bit turned on) convertDecToHex(isCompressed ? 8 : 0, 2) + // As per ECMA-376 Part 2 specs convertDecToHex(time, 2) + // last modified time convertDecToHex(dt, 2) + // last modified date convertDecToHex(zipSize ? crcFlag : 0, 4) + convertDecToHex(deflatedSize ?? rawSize, 4) + // compressed size convertDecToHex(rawSize, 4) + // uncompressed size convertDecToHex(utfPath.length, 2) + // file name length convertDecToHex(extraFields.length, 2); const localFileHeader = "PK" + commonHeader + utfPath + extraFields; const centralDirectoryHeader = "PK\0" + commonHeader + // file header "\0\0\0\0\0\0" + (content ? "\0\0\0\0" : "\0\0\0") + // external file attributes convertDecToHex(offset, 4) + // relative offset of local header utfPath + // file name extraFields; return { localFileHeader: Uint8Array.from(localFileHeader, (c) => c.charCodeAt(0)), centralDirectoryHeader: Uint8Array.from(centralDirectoryHeader, (c) => c.charCodeAt(0)) }; }; var getDecodedContent = (content) => { let contentToUse; if (typeof content === "string") { const base64String = atob(content.split(";base64,")[1]); contentToUse = Uint8Array.from(base64String, (c) => c.charCodeAt(0)); } else { contentToUse = content; } return { size: contentToUse.length, content: contentToUse }; }; var preprocessFileForZip = async (currentFile) => { const { content } = currentFile; const { size: rawSize, content: rawContent } = !content ? { size: 0, content: Uint8Array.from([]) } : getDecodedContent(content); let deflatedContent; let deflatedSize; let deflationPerformed = false; const shouldDeflate = currentFile.type === "file" && rawContent && rawSize > 0; if (shouldDeflate) { const result = await deflateLocalFile(rawContent); deflatedContent = result.content; deflatedSize = result.size; deflationPerformed = true; } return { rawContent, rawSize, deflatedContent, deflatedSize, isCompressed: deflationPerformed }; }; var getHeaderAndContent = (currentFile, offset) => { const { content } = currentFile; const { content: rawContent } = !content ? { content: Uint8Array.from([]) } : getDecodedContent(content); const headers = getHeaders(currentFile, false, offset, rawContent.length, rawContent, void 0); return { ...headers, content: rawContent, isCompressed: false }; }; var buildCentralDirectoryEnd = (tLen, cLen, lLen) => { const str = "PK\0\0\0\0" + convertDecToHex(tLen, 2) + // total number of entries in the central folder convertDecToHex(tLen, 2) + // total number of entries in the central folder convertDecToHex(cLen, 4) + // size of the central folder convertDecToHex(lLen, 4) + // central folder start offset "\0\0"; return Uint8Array.from(str, (c) => c.charCodeAt(0)); }; // packages/ag-grid-enterprise/src/excelExport/zipContainer/zipContainer.ts var ZipContainer = class { constructor() { this.folders = []; this.files = []; } addFolders(paths) { paths.forEach(this.addFolder.bind(this)); } addFolder(path) { this.folders.push({ path, created: /* @__PURE__ */ new Date(), isBase64: false, type: "folder" }); } addFile(path, content, isBase64 = false) { this.files.push({ path, created: /* @__PURE__ */ new Date(), content: isBase64 ? content : new TextEncoder().encode(content), isBase64, type: "file" }); } async getZipFile(mimeType = "application/zip") { const textOutput = await this.buildCompressedFileStream(); this.clearStream(); return new Blob([textOutput], { type: mimeType }); } getUncompressedZipFile(mimeType = "application/zip") { const textOutput = this.buildFileStream(); this.clearStream(); return new Blob([textOutput], { type: mimeType }); } clearStream() { this.folders = []; this.files = []; } packageFiles(files) { let fileLen = 0; let folderLen = 0; for (const currentFile of files) { const { localFileHeader, centralDirectoryHeader, content } = currentFile; fileLen += localFileHeader.length + content.length; folderLen += centralDirectoryHeader.length; } const fileData = new Uint8Array(fileLen); const folderData = new Uint8Array(folderLen); let fileOffset = 0; let folderOffset = 0; for (const currentFile of files) { const { localFileHeader, centralDirectoryHeader, content } = currentFile; fileData.set(localFileHeader, fileOffset); fileOffset += localFileHeader.length; fileData.set(content, fileOffset); fileOffset += content.length; folderData.set(centralDirectoryHeader, folderOffset); folderOffset += centralDirectoryHeader.length; } const folderEnd = buildCentralDirectoryEnd(files.length, folderLen, fileLen); const result = new Uint8Array(fileData.length + folderData.length + folderEnd.length); result.set(fileData); result.set(folderData, fileData.length); result.set(folderEnd, fileData.length + folderData.length); return result; } async buildCompressedFileStream() { const totalFiles = [...this.folders, ...this.files]; const preprocessed = await Promise.all(totalFiles.map(preprocessFileForZip)); const processed = []; let offset = 0; for (let i = 0; i < totalFiles.length; i++) { const currentFile = totalFiles[i]; const { rawContent, rawSize, deflatedContent, deflatedSize, isCompressed } = preprocessed[i]; const headers = getHeaders(currentFile, isCompressed, offset, rawSize, rawContent, deflatedSize); const contentToUse = deflatedContent ?? rawContent; processed.push({ ...headers, content: contentToUse, isCompressed }); offset += headers.localFileHeader.length + contentToUse.length; } return this.packageFiles(processed); } buildFileStream() { const totalFiles = [...this.folders, ...this.files]; const readyFiles = []; let lL = 0; for (const currentFile of totalFiles) { const readyFile = getHeaderAndContent(currentFile, lL); const { localFileHeader, content } = readyFile; readyFiles.push(readyFile); lL += localFileHeader.length + content.length; } return this.packageFiles(readyFiles); } }; // packages/ag-grid-enterprise/src/excelExport/excelCreator.ts var createExcelXMLCoreFolderStructure = (zipContainer) => { zipContainer.addFolders(["_rels/", "docProps/", "xl/", "xl/theme/", "xl/_rels/", "xl/worksheets/"]); if (!XLSX_IMAGES.size) { return; } zipContainer.addFolders(["xl/worksheets/_rels", "xl/drawings/", "xl/drawings/_rels", "xl/media/"]); let imgCounter = 0; XLSX_IMAGES.forEach((value) => { const firstImage = value[0].image[0]; const { base64, imageType } = firstImage; zipContainer.addFile(`xl/media/image${++imgCounter}.${_normaliseImageExtension(imageType)}`, base64, true); }); }; var createExcelXmlWorksheets = (zipContainer, data) => { let imageRelationCounter = 0; let headerFooterImageCounter = 0; for (let i = 0; i < data.length; i++) { const value = data[i]; zipContainer.addFile(`xl/worksheets/sheet${i + 1}.xml`, value, false); const hasImages = XLSX_IMAGES.size > 0 && XLSX_WORKSHEET_IMAGES.has(i); const tableData = XLSX_WORKSHEET_DATA_TABLES.size > 0 && XLSX_WORKSHEET_DATA_TABLES.get(i); const hasHeaderFooterImages = XLSX_IMAGES.size && XLSX_WORKSHEET_HEADER_FOOTER_IMAGES.has(i); if (!hasImages && !tableData && !hasHeaderFooterImages) { continue; } let tableName; let drawingIndex; let vmlDrawingIndex; if (hasImages) { createExcelXmlDrawings(zipContainer, i, imageRelationCounter); drawingIndex = imageRelationCounter; imageRelationCounter++; } if (hasHeaderFooterImages) { createExcelVmlDrawings(zipContainer, i, headerFooterImageCounter); vmlDrawingIndex = headerFooterImageCounter; headerFooterImageCounter++; } if (tableData) { tableName = tableData.name; } const worksheetRelFile = `xl/worksheets/_rels/sheet${i + 1}.xml.rels`; zipContainer.addFile( worksheetRelFile, createXlsxRelationships({ tableName, drawingIndex, vmlDrawingIndex }) ); } }; var createExcelXmlDrawings = (zipContainer, sheetIndex, drawingIndex) => { const drawingFolder = "xl/drawings"; const drawingFileName = `${drawingFolder}/drawing${drawingIndex + 1}.xml`; const relFileName = `${drawingFolder}/_rels/drawing${drawingIndex + 1}.xml.rels`; zipContainer.addFile(relFileName, createXlsxDrawingRel(sheetIndex)); zipContainer.addFile(drawingFileName, createXlsxDrawing(sheetIndex)); }; var createExcelVmlDrawings = (zipContainer, sheetIndex, drawingIndex) => { const drawingFolder = "xl/drawings"; const drawingFileName = `${drawingFolder}/vmlDrawing${drawingIndex + 1}.vml`; const relFileName = `${drawingFolder}/_rels/vmlDrawing${drawingIndex + 1}.vml.rels`; zipContainer.addFile(drawingFileName, createXlsxVmlDrawing(sheetIndex)); zipContainer.addFile(relFileName, createXlsxVmlDrawingRel(sheetIndex)); }; var createExcelXmlTables = (zipContainer) => { const tablesDataByWorksheet = XLSX_WORKSHEET_DATA_TABLES; const worksheetKeys = Array.from(tablesDataByWorksheet.keys()); for (let i = 0; i < worksheetKeys.length; i++) { const sheetIndex = worksheetKeys[i]; const table = tablesDataByWorksheet.get(sheetIndex); if (!table) { continue; } zipContainer.addFile(`xl/tables/${table.name}.xml`, createXlsxTable(table, i)); } }; var createExcelXmlCoreSheets = (zipContainer, fontSize, author, sheetLen, activeTab, customMetadata) => { const hasCustomMetadata = !!customMetadata && Object.keys(customMetadata).some((key) => customMetadata[key] != null); zipContainer.addFile("xl/workbook.xml", createXlsxWorkbook(activeTab)); zipContainer.addFile("xl/styles.xml", createXlsxStylesheet(fontSize)); zipContainer.addFile("xl/sharedStrings.xml", createXlsxSharedStrings()); zipContainer.addFile("xl/theme/theme1.xml", createXlsxTheme()); zipContainer.addFile("xl/_rels/workbook.xml.rels", createXlsxWorkbookRels(sheetLen)); zipContainer.addFile("docProps/core.xml", createXlsxCore(author)); if (hasCustomMetadata) { zipContainer.addFile("docProps/custom.xml", createXlsxCustomProperties(customMetadata)); } zipContainer.addFile("[Content_Types].xml", createXlsxContentTypes(sheetLen, hasCustomMetadata)); zipContainer.addFile("_rels/.rels", createXlsxRels(hasCustomMetadata)); }; var createExcelFileForExcel = (zipContainer, data, options = {}, workbook) => { if (!data || data.length === 0) { _warn3(159); workbook.reset(); return false; } workbook.syncOrderWithSheetData(data); const { fontSize = 11, author = "AG Grid", activeTab = 0, customMetadata } = options; const len = data.length; const activeTabWithinBounds = Math.max(Math.min(activeTab, len - 1), 0); createExcelXMLCoreFolderStructure(zipContainer); createExcelXmlTables(zipContainer); createExcelXmlWorksheets(zipContainer, data); createExcelXmlCoreSheets(zipContainer, fontSize, author, len, activeTabWithinBounds, customMetadata); workbook.reset(); return true; }; var getMultipleSheetsAsExcelCompressed = (params, workbook = new Workbook()) => { const { data, fontSize, author, activeSheetIndex, customMetadata } = params; const mimeType = params.mimeType || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; const zipContainer = new ZipContainer(); if (!createExcelFileForExcel( zipContainer, data, { author, fontSize, activeTab: activeSheetIndex, customMetadata }, workbook )) { return Promise.resolve(void 0); } return zipContainer.getZipFile(mimeType); }; var getMultipleSheetsAsExcel = (params, workbook = new Workbook()) => { const { data, fontSize, author, activeSheetIndex: activeTab, customMetadata } = params; const mimeType = params.mimeType || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; const zipContainer = new ZipContainer(); if (!createExcelFileForExcel( zipContainer, data, { author, fontSize, activeTab, customMetadata }, workbook )) { return; } return zipContainer.getUncompressedZipFile(mimeType); }; var exportMultipleSheetsAsExcel = (params) => { const { fileName = "export.xlsx" } = params; const workbook = new Workbook(); getMultipleSheetsAsExcelCompressed(params, workbook).then((contents) => { if (contents) { const downloadFileName = typeof fileName === "function" ? fileName() : fileName; _downloadFile(downloadFileName, contents); } }); }; var ExcelCreator = class extends BaseCreator { constructor() { super(...arguments); this.beanName = "excelCreator"; this.workbook = new Workbook(); } getMergedParams(params) { const baseParams = this.gos.get("defaultExcelExportParams"); return Object.assign({}, baseParams, params); } export(userParams) { if (this.isExportSuppressed()) { _warn3(160); return; } const exportFunc = () => { const mergedParams = this.getMergedParams(userParams); const data = this.getData(mergedParams); const { fontSize, author, mimeType, customMetadata } = mergedParams; const exportParams = { data: [data], fontSize, author, mimeType, customMetadata }; this.packageCompressedFile(exportParams).then((packageFile) => { if (packageFile) { const { fileName } = mergedParams; const providedFileName = typeof fileName === "function" ? fileName(_addGridCommonParams2(this.gos, {})) : fileName; _downloadFile(this.getFileName(providedFileName), packageFile); } }); }; const { overlays } = this.beans; if (overlays) { overlays.showExportOverlay(exportFunc); } else { exportFunc(); } } exportDataAsExcel(params) { this.export(params); } getDataAsExcel(params) { const mergedParams = this.getMergedParams(params); const data = this.getData(mergedParams); const { fontSize, author, mimeType, customMetadata } = mergedParams; const exportParams = { data: [data], fontSize, author, mimeType, customMetadata }; return this.packageFile(exportParams); } setFactoryMode(factoryMode) { this.workbook.setFactoryMode(factoryMode); } getFactoryMode() { return this.workbook.getFactoryMode(); } getSheetDataForExcel(params) { const mergedParams = this.getMergedParams(params); return this.getData(mergedParams); } getMultipleSheetsAsExcel(params) { return getMultipleSheetsAsExcel(params, this.workbook); } exportMultipleSheetsAsExcel(params) { getMultipleSheetsAsExcelCompressed(params, this.workbook).then((contents) => { const { fileName = "export.xlsx" } = params; if (contents) { const downloadFileName = typeof fileName === "function" ? fileName() : fileName; _downloadFile(downloadFileName, contents); } }); } getDefaultFileExtension() { return "xlsx"; } createSerializingSession(params) { const { colModel, colNames, rowGroupColsSvc, valueSvc, formula, gos } = this.beans; const baseExcelStyles = gos.get("excelStyles") || []; const styleLinker = this.createStyleLinker(baseExcelStyles); const config = { ...params, colModel, colNames, rowGroupColsSvc, valueSvc, formulaSvc: formula, gos, suppressRowOutline: params.suppressRowOutline || params.skipRowGroups, headerRowHeight: params.headerRowHeight || params.rowHeight, baseExcelStyles, rightToLeft: params.rightToLeft ?? gos.get("enableRtl"), styleLinker, headerRowCount: _getHeaderRowCount(colModel), pivotModeActive: colModel.isPivotActive(), workbook: this.workbook }; return new ExcelSerializingSession(config); } createStyleLinker(baseExcelStyles) { const styleIds = []; const styleIdsSet = /* @__PURE__ */ new Set(); const styleIdOrder = /* @__PURE__ */ new Map(); baseExcelStyles.forEach((it, idx) => { styleIds.push(it.id); styleIdsSet.add(it.id); styleIdOrder.set(it.id, idx); }); const { gos, cellStyles } = this.beans; return (params) => { const { rowType, rowIndex, value, column, columnGroup, node } = params; const isHeader = rowType === "HEADER"; const isGroupHeader = rowType === "HEADER_GROUPING"; const col = isHeader ? column : columnGroup; let headerClasses = []; if (isHeader || isGroupHeader) { headerClasses.push("header"); if (isGroupHeader) { headerClasses.push("headerGroup"); } if (col) { headerClasses = headerClasses.concat( _getHeaderClassesFromColDef( col.getDefinition(), gos, column || null, columnGroup || null ) ); } return headerClasses; } const applicableStyles = ["cell"]; if (!styleIds.length) { return applicableStyles; } const colDef = column.getDefinition(); cellStyles?.processAllCellClasses( colDef, _addGridCommonParams2(gos, { value, data: node.data, node, colDef, column, rowIndex }), (className) => { if (styleIdsSet.has(className)) { applicableStyles.push(className); } } ); return applicableStyles.sort((left, right) => { const leftIdx = styleIdOrder.get(left) ?? -1; const rightIdx = styleIdOrder.get(right) ?? -1; return leftIdx === rightIdx ? 0 : leftIdx < rightIdx ? -1 : 1; }); }; } isExportSuppressed() { return this.gos.get("suppressExcelExport"); } packageCompressedFile(params) { return getMultipleSheetsAsExcelCompressed(params, this.workbook); } packageFile(params) { return getMultipleSheetsAsExcel(params, this.workbook); } }; // packages/ag-grid-enterprise/src/agStack/agVirtualList.ts import { KeyCode, RefPlaceholder as RefPlaceholder2, _AgTabGuardComp, _createAgElement, _getAriaPosInSet, _observeResize, _requestAnimationFrame, _setAriaLabel, _setAriaPosInSet, _setAriaRole, _setAriaSetSize, _waitUntil } from "ag-grid-community"; // packages/ag-grid-enterprise/src/agStack/agVirtualList.css-GENERATED.ts var agVirtualListCSS = ( /*css*/ `:where(.ag-virtual-list-viewport) .ag-tab-guard{position:sticky}.ag-virtual-list-viewport{flex:1 1 auto;height:100%;min-width:0;overflow:auto;position:relative;width:100%}.ag-virtual-list-container{overflow:hidden;position:relative}.ag-virtual-list-item{height:var(--ag-list-item-height);position:absolute;width:100%}` ); // packages/ag-grid-enterprise/src/agStack/agVirtualList.ts function getVirtualListTemplate(cssIdentifier) { return { tag: "div", cls: `ag-virtual-list-viewport ag-${cssIdentifier}-virtual-list-viewport`, role: "presentation", children: [ { tag: "div", ref: "eContainer", cls: `ag-virtual-list-container ag-${cssIdentifier}-virtual-list-container` } ] }; } var AgVirtualList = class extends _AgTabGuardComp { constructor(stopPropagationCallbacks, params) { super(getVirtualListTemplate(params?.cssIdentifier || "default")); this.stopPropagationCallbacks = stopPropagationCallbacks; this.renderedRows = /* @__PURE__ */ new Map(); this.rowHeight = 20; this.pageSize = -1; this.isScrolling = false; this.isHeightFromTheme = true; this.eContainer = RefPlaceholder2; this.awaitStableCallbacks = []; this.registerCSS(agVirtualListCSS); const { cssIdentifier = "default", ariaRole = "listbox", listName, moveItemCallback } = params || {}; this.cssIdentifier = cssIdentifier; this.ariaRole = ariaRole; this.listName = listName; this.moveItemCallback = moveItemCallback; } postConstruct() { this.addScrollListener(); this.rowHeight = this.getItemHeight(); this.addResizeObserver(); this.initialiseTabGuard( { onFocusIn: (e) => this.onFocusIn(e), onFocusOut: (e) => this.onFocusOut(e), focusInnerElement: (fromBottom) => this.focusInnerElement(fromBottom), onTabKeyDown: (e) => this.onTabKeyDown(e), handleKeyDown: (e) => this.handleKeyDown(e) }, this.stopPropagationCallbacks ); this.refreshAriaProperties(); this.addManagedEventListeners({ stylesChanged: this.onStylesChanged.bind(this) }); } onStylesChanged(e) { if (e.listItemHeightChanged) { this.rowHeight = this.getItemHeight(); this.refresh(); } } refreshAriaProperties() { const translate = this.getLocaleTextFunc(); const listName = translate("ariaDefaultListName", this.listName || "List"); const ariaEl = this.eContainer; _setAriaRole(ariaEl, this.model?.getRowCount() > 0 ? this.ariaRole : "presentation"); _setAriaLabel(ariaEl, listName); } addResizeObserver() { const listener = () => _requestAnimationFrame(this.beans, () => this.drawVirtualRows()); const destroyObserver = _observeResize(this.beans, this.getGui(), listener); this.addDestroyFunc(destroyObserver); } focusInnerElement(fromBottom) { this.focusRow(fromBottom ? this.model.getRowCount() - 1 : 0); return true; } onFocusIn(e) { const target = e.target; if (target.classList.contains("ag-virtual-list-item")) { this.lastFocusedRowIndex = _getAriaPosInSet(target) - 1; } } onFocusOut(e) { if (!this.getFocusableElement().contains(e.relatedTarget)) { this.lastFocusedRowIndex = null; } } handleKeyDown(e) { const { key, shiftKey } = e; switch (key) { case KeyCode.UP: case KeyCode.DOWN: { const isUp = key === KeyCode.UP; e.preventDefault(); if (shiftKey) { this.moveItem(isUp); } else { this.navigate(isUp); } } break; case KeyCode.PAGE_HOME: case KeyCode.PAGE_END: case KeyCode.PAGE_UP: case KeyCode.PAGE_DOWN: if (this.navigateToPage(key) !== null) { e.preventDefault(); } break; } } onTabKeyDown(e) { this.stopPropagationCallbacks?.stopPropagation(e); this.forceFocusOutOfContainer(e.shiftKey); } getNextRow(up) { if (this.lastFocusedRowIndex == null) { return void 0; } const nextRow = this.lastFocusedRowIndex + (up ? -1 : 1); if (nextRow < 0 || nextRow >= this.model.getRowCount()) { return void 0; } return nextRow; } moveItem(up) { if (!this.moveItemCallback) { return; } const item = this.getComponentAt(this.lastFocusedRowIndex); if (!item) { return; } this.moveItemCallback(item, up); } navigate(up) { const nextRow = this.getNextRow(up); if (nextRow === void 0) { return; } this.focusRow(nextRow); } navigateToPage(key, fromItem = "focused") { let hasFocus = false; if (fromItem === "focused") { fromItem = this.getLastFocusedRow(); hasFocus = true; } const rowCount = this.model.getRowCount() - 1; let newIndex = -1; if (key === KeyCode.PAGE_HOME) { newIndex = 0; } else if (key === KeyCode.PAGE_END) { newIndex = rowCount; } else if (key === KeyCode.PAGE_DOWN) { newIndex = Math.min(fromItem + this.pageSize, rowCount); } else if (key === KeyCode.PAGE_UP) { newIndex = Math.max(fromItem - this.pageSize, 0); } if (newIndex === -1) { return null; } if (hasFocus) { this.focusRow(newIndex); } else { this.ensureIndexVisible(newIndex); } return newIndex; } getLastFocusedRow() { return this.lastFocusedRowIndex; } focusRow(rowNumber) { if (this.isScrolling) { return; } this.isScrolling = true; this.ensureIndexVisible(rowNumber); _requestAnimationFrame(this.beans, () => { this.isScrolling = false; if (!this.isAlive()) { return; } const renderedRow = this.renderedRows.get(rowNumber); if (renderedRow) { renderedRow.eDiv.focus(); } }); } getComponentAt(rowIndex) { const comp = this.renderedRows.get(rowIndex); return comp && comp.rowComponent; } forEachRenderedRow(func) { this.renderedRows.forEach((value, key) => func(value.rowComponent, key)); } getItemHeight() { if (!this.isHeightFromTheme) { return this.rowHeight; } return this.beans.environment.getDefaultListItemHeight(); } /** * Returns true if the view had to be scrolled, otherwise, false. */ ensureIndexVisible(index, scrollPartialIntoView = true) { const lastRow = this.model.getRowCount(); if (typeof index !== "number" || index < 0 || index >= lastRow) { return false; } const rowTopPixel = index * this.rowHeight; const rowBottomPixel = rowTopPixel + this.rowHeight; const eGui = this.getGui(); const viewportTopPixel = eGui.scrollTop; const viewportHeight = eGui.offsetHeight; const viewportBottomPixel = viewportTopPixel + viewportHeight; const diff = scrollPartialIntoView ? 0 : this.rowHeight; const viewportScrolledPastRow = viewportTopPixel > rowTopPixel + diff; const viewportScrolledBeforeRow = viewportBottomPixel < rowBottomPixel - diff; if (viewportScrolledPastRow) { eGui.scrollTop = rowTopPixel; return true; } if (viewportScrolledBeforeRow) { const newScrollPosition = rowBottomPixel - viewportHeight; eGui.scrollTop = newScrollPosition; return true; } return false; } setComponentCreator(componentCreator) { this.componentCreator = componentCreator; } setComponentUpdater(componentUpdater) { this.componentUpdater = componentUpdater; } getRowHeight() { return this.rowHeight; } getScrollTop() { return this.getGui().scrollTop; } setRowHeight(rowHeight) { this.isHeightFromTheme = false; this.rowHeight = rowHeight; this.refresh(); } refresh(softRefresh) { if (this.model == null || !this.isAlive()) { return; } const rowCount = this.model.getRowCount(); this.eContainer.style.height = `${rowCount * this.rowHeight}px`; this.refreshAriaProperties(); this.awaitStable(() => { if (!this.isAlive()) { return; } if (this.canSoftRefresh(softRefresh)) { this.drawVirtualRows(true); } else { this.clearVirtualRows(); this.drawVirtualRows(); } }); } awaitStable(callback) { this.awaitStableCallbacks.push(callback); if (this.awaitStableCallbacks.length > 1) { return; } const rowCount = this.model.getRowCount(); _waitUntil( this, () => this.eContainer.clientHeight >= rowCount * this.rowHeight, () => { if (!this.isAlive()) { return; } const callbacks = this.awaitStableCallbacks; this.awaitStableCallbacks = []; for (const c of callbacks) { c(); } } ); } canSoftRefresh(softRefresh) { return !!(softRefresh && this.renderedRows.size && typeof this.model.areRowsEqual === "function" && this.componentUpdater); } clearVirtualRows() { this.renderedRows.forEach((_, rowIndex) => this.removeRow(rowIndex)); } drawVirtualRows(softRefresh) { if (!this.isAlive() || !this.model) { return; } const gui = this.getGui(); const topPixel = gui.scrollTop; const bottomPixel = topPixel + gui.offsetHeight; if (topPixel === bottomPixel) { this.clearVirtualRows(); } else { const firstRow = Math.floor(topPixel / this.rowHeight); const lastRow = Math.floor(bottomPixel / this.rowHeight); this.pageSize = Math.floor((bottomPixel - topPixel) / this.rowHeight); this.ensureRowsRendered(firstRow, lastRow, softRefresh); } } ensureRowsRendered(start, finish, softRefresh) { this.renderedRows.forEach((_, rowIndex) => { if ((rowIndex < start || rowIndex > finish) && rowIndex !== this.lastFocusedRowIndex) { this.removeRow(rowIndex); } }); if (softRefresh) { this.refreshRows(); } for (let rowIndex = start; rowIndex <= finish; rowIndex++) { if (this.renderedRows.has(rowIndex)) { continue; } if (rowIndex < this.model.getRowCount()) { this.insertRow(rowIndex); } } } insertRow(rowIndex) { const value = this.model.getRow(rowIndex); const role = this.ariaRole === "tree" ? "treeitem" : "option"; const eDiv = _createAgElement({ tag: "div", cls: `ag-virtual-list-item ag-${this.cssIdentifier}-virtual-list-item`, role, attrs: { tabindex: "-1" } }); _setAriaSetSize(eDiv, this.model.getRowCount()); _setAriaPosInSet(eDiv, rowIndex + 1); eDiv.style.height = `${this.rowHeight}px`; eDiv.style.top = `${this.rowHeight * rowIndex}px`; const rowComponent = this.componentCreator(value, eDiv); rowComponent.addGuiEventListener("focusin", () => this.lastFocusedRowIndex = rowIndex); eDiv.appendChild(rowComponent.getGui()); if (this.renderedRows.has(rowIndex - 1)) { this.renderedRows.get(rowIndex - 1).eDiv.insertAdjacentElement("afterend", eDiv); } else if (this.renderedRows.has(rowIndex + 1)) { this.renderedRows.get(rowIndex + 1).eDiv.insertAdjacentElement("beforebegin", eDiv); } else { this.eContainer.appendChild(eDiv); } this.renderedRows.set(rowIndex, { rowComponent, eDiv, value }); } removeRow(rowIndex) { const component = this.renderedRows.get(rowIndex); component.eDiv.remove(); this.destroyBean(component.rowComponent); this.renderedRows.delete(rowIndex); } refreshRows() { const rowCount = this.model.getRowCount(); this.renderedRows.forEach((row, rowIndex) => { if (rowIndex >= rowCount) { this.removeRow(rowIndex); } else { const newValue = this.model.getRow(rowIndex); if (this.model.areRowsEqual?.(row.value, newValue)) { this.componentUpdater(newValue, row.rowComponent); } else { this.removeRow(rowIndex); } } }); } addScrollListener() { this.addGuiEventListener("scroll", () => this.drawVirtualRows(), { passive: true }); } setModel(model) { this.model = model; } getAriaElement() { return this.eContainer; } destroy() { if (!this.isAlive()) { return; } this.clearVirtualRows(); this.awaitStableCallbacks.length = 0; super.destroy(); } }; // packages/ag-grid-enterprise/src/agStack/agVirtualListDragFeature.ts import { AutoScrollService, _AgBeanStub, _radioCssClass } from "ag-grid-community"; // packages/ag-grid-enterprise/src/agStack/agVirtualListDragFeature.css-GENERATED.ts var agVirtualListDragFeatureCSS = ( /*css*/ `.ag-list-item-hovered:after{background-color:var(--ag-accent-color);content:"";height:1px;left:0;position:absolute;right:0}.ag-item-highlight-top:after{top:0}.ag-item-highlight-bottom:after{bottom:0}` ); // packages/ag-grid-enterprise/src/agStack/agVirtualListDragFeature.ts var LIST_ITEM_HOVERED = "ag-list-item-hovered"; var AgVirtualListDragFeature = class extends _AgBeanStub { constructor(comp, virtualList, params) { super(); this.comp = comp; this.virtualList = virtualList; this.params = params; this.currentDragValue = null; this.lastHoveredListItem = null; } postConstruct() { this.beans.environment.addGlobalCSS(agVirtualListDragFeatureCSS, "component-AgVirtualListDragFeature"); this.params.addListeners(this, this.listItemDragStart.bind(this), this.listItemDragEnd.bind(this)); this.createDropTarget(); this.createAutoScrollService(); } listItemDragStart(event) { this.currentDragValue = this.params.getCurrentDragValue(event); this.moveBlocked = this.params.isMoveBlocked(this.currentDragValue); } listItemDragEnd() { window.setTimeout(() => { this.currentDragValue = null; this.moveBlocked = false; }, 10); } createDropTarget() { const dropTarget = { isInterestedIn: (type) => type === this.params.dragSourceType, getIconName: () => this.moveBlocked ? "pinned" : "move", getContainer: () => this.comp.getGui(), onDragging: (e) => this.onDragging(e), onDragStop: () => this.onDragStop(), onDragLeave: () => this.onDragLeave(), onDragCancel: () => this.onDragCancel() }; this.beans.dragAndDrop?.addDropTarget(dropTarget); } createAutoScrollService() { const virtualListGui = this.virtualList.getGui(); this.autoScrollService = new AutoScrollService({ scrollContainer: virtualListGui, scrollAxis: "y", getVerticalPosition: () => virtualListGui.scrollTop, setVerticalPosition: (position) => virtualListGui.scrollTop = position }); } onDragging(e) { if (!this.currentDragValue || this.moveBlocked) { return; } const hoveredListItem = this.getListDragItem(e); const comp = this.virtualList.getComponentAt(hoveredListItem.rowIndex); if (!comp) { return; } const el = comp.getGui().parentElement; if (this.lastHoveredListItem && this.lastHoveredListItem.rowIndex === hoveredListItem.rowIndex && this.lastHoveredListItem.position === hoveredListItem.position) { return; } this.autoScrollService.check(e.event); this.clearHoveredItems(); this.lastHoveredListItem = hoveredListItem; _radioCssClass(el, LIST_ITEM_HOVERED); _radioCssClass(el, `ag-item-highlight-${hoveredListItem.position}`); } getListDragItem(e) { const virtualListGui = this.virtualList.getGui(); const paddingTop = Number.parseFloat(window.getComputedStyle(virtualListGui).paddingTop); const rowHeight = this.virtualList.getRowHeight(); const scrollTop = this.virtualList.getScrollTop(); const rowIndex = Math.max(0, (e.y - paddingTop + scrollTop) / rowHeight); const maxLen = this.params.getNumRows(this.comp) - 1; const normalizedRowIndex = Math.min(maxLen, rowIndex) | 0; return { rowIndex: normalizedRowIndex, position: Math.round(rowIndex) > rowIndex || rowIndex > maxLen ? "bottom" : "top", component: this.virtualList.getComponentAt(normalizedRowIndex) }; } onDragStop() { if (this.moveBlocked) { return; } this.params.moveItem(this.currentDragValue, this.lastHoveredListItem); this.clearDragProperties(); } onDragCancel() { this.clearDragProperties(); } onDragLeave() { this.clearDragProperties(); } clearDragProperties() { this.clearHoveredItems(); this.autoScrollService.ensureCleared(); } clearHoveredItems() { const virtualListGui = this.virtualList.getGui(); for (const el of virtualListGui.querySelectorAll(`.${LIST_ITEM_HOVERED}`)) { for (const cls of [LIST_ITEM_HOVERED, "ag-item-highlight-top", "ag-item-highlight-bottom"]) { el.classList.remove(cls); } } this.lastHoveredListItem = null; } }; // packages/ag-grid-enterprise/src/agStack/agSlider.ts import { AgAbstractLabel, AgInputNumberFieldSelector, RefPlaceholder as RefPlaceholder3 } from "ag-grid-community"; // packages/ag-grid-enterprise/src/agStack/agInputRange.ts import { AgAbstractInputField } from "ag-grid-community"; var AgInputRange = class extends AgAbstractInputField { constructor(config) { super(config, "ag-range-field", "range"); } postConstruct() { super.postConstruct(); const { min, max, step } = this.config; if (min != null) { this.setMinValue(min); } if (max != null) { this.setMaxValue(max); } this.setStep(step || 1); } addInputListeners() { this.addManagedElementListeners(this.eInput, { input: (e) => { const value = e.target.value; this.setValue(value); } }); } setMinValue(value) { this.min = value; this.eInput.setAttribute("min", value.toString()); return this; } setMaxValue(value) { this.max = value; this.eInput.setAttribute("max", value.toString()); return this; } setStep(value) { this.eInput.setAttribute("step", value.toString()); return this; } setValue(value, silent) { if (this.min != null) { value = Math.max(parseFloat(value), this.min).toString(); } if (this.max != null) { value = Math.min(parseFloat(value), this.max).toString(); } const ret = super.setValue(value, silent); this.eInput.value = value; return ret; } }; var AgInputRangeSelector = { selector: "AG-INPUT-RANGE", component: AgInputRange }; // packages/ag-grid-enterprise/src/agStack/agSlider.ts var AgSlider = class extends AgAbstractLabel { constructor(config) { super( config, /* html */ `
`, [AgInputRangeSelector, AgInputNumberFieldSelector] ); this.eLabel = RefPlaceholder3; this.eSlider = RefPlaceholder3; this.eText = RefPlaceholder3; this.labelAlignment = "top"; } postConstruct() { super.postConstruct(); this.eSlider.addCss("ag-slider-field"); const { minValue, maxValue, textFieldWidth, step, value, onValueChange } = this.config; if (minValue != null) { this.setMinValue(minValue); } if (maxValue != null) { this.setMaxValue(maxValue); } if (textFieldWidth != null) { this.setTextFieldWidth(textFieldWidth); } if (step != null) { this.setStep(step); } if (value != null) { this.setValue(value); } if (onValueChange != null) { this.onValueChange(onValueChange); } } onValueChange(callbackFn) { this.addManagedListeners(this.eText, { fieldValueChanged: () => { const textValue = parseFloat(this.eText.getValue()); this.eSlider.setValue(textValue.toString(), true); callbackFn(textValue || 0); } }); this.addManagedListeners(this.eSlider, { fieldValueChanged: () => { const sliderValue = this.eSlider.getValue(); this.eText.setValue(sliderValue, true); callbackFn(parseFloat(sliderValue)); } }); return this; } setSliderWidth(width) { this.eSlider.setWidth(width); return this; } setTextFieldWidth(width) { this.eText.setWidth(width); return this; } setMinValue(minValue) { this.eSlider.setMinValue(minValue); this.eText.setMin(minValue); return this; } setMaxValue(maxValue) { this.eSlider.setMaxValue(maxValue); this.eText.setMax(maxValue); return this; } getValue() { return this.eText.getValue(); } setValue(value, silent) { if (this.getValue() === value) { return this; } this.eText.setValue(value, true); this.eSlider.setValue(value, true); if (!silent) { this.dispatchLocalEvent({ type: "fieldValueChanged" }); } return this; } setStep(step) { this.eSlider.setStep(step); this.eText.setStep(step); return this; } }; var AgSliderSelector = { selector: "AG-SLIDER", component: AgSlider }; // packages/ag-grid-enterprise/src/agStack/agColorPicker.ts import { AgPickerField, _createElement } from "ag-grid-community"; // packages/ag-grid-enterprise/src/agStack/agColorPanel.ts import { KeyCode as KeyCode2, RefPlaceholder as RefPlaceholder5, _AgComponentStub, _exists as _exists2, _setDisplayed } from "ag-grid-community"; // packages/ag-grid-enterprise/src/agStack/agColorInput.ts import { AgInputTextField, RefPlaceholder as RefPlaceholder4 } from "ag-grid-community"; var AgColorInput = class extends AgInputTextField { constructor() { super({ template: { tag: "div", cls: "ag-color-input", role: "presentation", children: [ { tag: "div", ref: "eLabel", cls: "ag-input-field-label" }, { tag: "div", ref: "eWrapper", cls: "ag-wrapper ag-input-wrapper", role: "presentation", children: [ { tag: "input", ref: "eInput", cls: "ag-input-field-input" }, { tag: "div", ref: "eColor", cls: "ag-color-input-color" } ] } ] } }); this.eColor = RefPlaceholder4; } wireBeans(beans) { this.color = beans.agChartsExports._Util.Color; } setColor(color) { const rgbaColor = color.toRgbaString(); this.setValue(this.color.fromString(rgbaColor).toHexString().toUpperCase(), true); this.eColor.style.backgroundColor = rgbaColor; } setValue(value, silent) { const isValid = this.color.validColorString(value ?? ""); this.eInput.setCustomValidity( isValid ? "" : this.getLocaleTextFunc()("invalidColor", "Color value is invalid") ); super.setValue(value, silent); if (isValid && !silent) { this.dispatchLocalEvent({ type: "colorChanged" }); } return this; } onColorChanged(callback) { this.addManagedListeners(this, { colorChanged: () => callback(this.color.fromString(this.value)) }); } }; var AgColorInputSelector = { selector: "AG-COLOR-INPUT", component: AgColorInput }; // packages/ag-grid-enterprise/src/agStack/agColorPanel.ts var maxRecentColors = 8; var sharedRecentColors = []; var AgColorPanel = class extends _AgComponentStub { constructor(config) { super( /* html */ `