// packages/ag-grid-enterprise/src/license/gridLicenseManager.ts
import { BeanStub, _getDocument } 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, s, t) {
a = this.add32(this.add32(a, q), this.add32(x, t));
return this.add32(a << s | a >>> 32 - s, b);
}
ff(a, b, c, d, x, s, t) {
return this.cmn(b & c | ~b & d, a, b, x, s, t);
}
gg(a, b, c, d, x, s, t) {
return this.cmn(b & d | c & ~d, a, b, x, s, t);
}
hh(a, b, c, d, x, s, t) {
return this.cmn(b ^ c ^ d, a, b, x, s, t);
}
ii(a, b, c, d, x, s, t) {
return this.cmn(c ^ (b | ~d), a, b, x, s, t);
}
md51(s) {
const n = s.length;
const state = [1732584193, -271733879, -1732584194, 271733878];
let i;
for (i = 64; i <= s.length; i += 64) {
this.md5cycle(state, this.md5blk(s.substring(i - 64, i)));
}
s = s.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 < s.length; i++) {
tail[i >> 2] |= s.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(s) {
const md5blks = [];
for (let i = 0; i < 64; i += 4) {
md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24);
}
return md5blks;
}
rhex(n) {
const hex_chr = "0123456789abcdef".split("");
let s = "", j = 0;
for (; j < 4; j++) {
s += hex_chr[n >> j * 8 + 4 & 15] + hex_chr[n >> j * 8 & 15];
}
return s;
}
hex(x) {
for (let i = 0; i < x.length; i++) {
x[i] = this.rhex(x[i]);
}
return x.join("");
}
md5(s) {
return this.hex(this.md51(s));
}
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.indexOf("For_Trialing_ag-Grid_Only") === -1;
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.indexOf("forceWatermark") !== -1 : 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 s, o, u, a;
let f = 0;
const e = input.replace(/[^A-Za-z0-9+/=]/g, "");
while (f < e.length) {
s = keystr.indexOf(e.charAt(f++));
o = keystr.indexOf(e.charAt(f++));
u = keystr.indexOf(e.charAt(f++));
a = keystr.indexOf(e.charAt(f++));
n = s << 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;
}
static setLicenseKey(licenseKey) {
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 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";
}
};
_LicenseManager.RELEASE_INFORMATION = "MTczOTgwMzI0NzgzNQ==";
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;&:before{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMDkiIGhlaWdodD0iMzYiIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCAyMDkgMzYiPjxwYXRoIGZpbGw9IiM5QjlCOUIiIGQ9Ik0xOTIuOTkzIDIzLjY1OHYtNy45NDZoLTEzLjU0MWwtNy45NDcgNy45NDZ6TTIwOC4yNSAzLjk1aC0xNi45NzRsLTguMDEgNy45NDdoMjQuOTg0ek0xNjMuNjIyIDMxLjYwNWw0LjA2OS00LjA2OWgxMy43MzJ2Ny45NDdoLTE3LjgwMXoiLz48cGF0aCBmaWxsPSIjOUI5QjlCIiBkPSJNMTY2LjYxIDE5Ljc4aDguNzczbDguMDEtNy45NDZIMTY2LjYxek0xNTcuMDExIDMxLjYwNWg2LjYxMWw3Ljg4My03Ljk0N2gtMTQuNDk0ek0xOTEuMjc2IDMuOTVsLTQuMDY4IDQuMDdIMTYxLjI3Vi4wNzJoMzAuMDA2ek0yMC44NCAzMC4yMDZIOC4zNzhsLTIuMTYyIDUuMzRILjc1TDEyLjI1NyA4LjU5Mmg0Ljc2OEwyOC41MyAzNS41NDZoLTUuNTN6bS0xLjcxNy00LjI2TDE0LjYwOSAxNC45NWwtNC41MTQgMTAuOTk4ek0xMDQuNDM3IDE4LjUwOWMxLjU4OS0yLjM1MiA1LjU5NC0yLjYwNyA3LjI0Ny0yLjYwN3Y0LjU3OGMtMi4wMzQgMC00LjA2OS4wNjMtNS4yNzcuOTUzLTEuMjA3Ljg5LTEuODQzIDIuMDk4LTEuODQzIDMuNTZ2MTAuNTUzaC00Ljk1OVYxNS45MDJoNC43Njh6TTExOS4zNzYgMTUuOTAyaC00Ljk1OHYxOS42NDRoNC45NTh6TTExOS4zNzYgNy4xM2gtNC45NTh2NS44NDhoNC45NTh6TTE0My45NzkgNy4xM3YyOC40MTZoLTQuNzY4bC0uMTI3LTIuOTg4YTguMyA4LjMgMCAwIDEtMi42NyAyLjQ4Yy0xLjA4MS41NzItMi40MTYuODktMy45NDIuODktMS4zMzUgMC0yLjYwNi0uMjU1LTMuNjg3LS43LTEuMTQ0LS41MDgtMi4xNjItMS4xNDQtMi45ODgtMi4wMzRhOS42IDkuNiAwIDAgMS0xLjk3MS0zLjE3OWMtLjUwOC0xLjIwNy0uNjk5LTIuNjA2LS42OTktNC4xMzJzLjI1NC0yLjkyNC42OTktNC4xOTZjLjUwOS0xLjI3MSAxLjE0NS0yLjM1MiAxLjk3MS0zLjI0MnMxLjg0NC0xLjU4OSAyLjk4OC0yLjA5OCAyLjM1Mi0uNzYzIDMuNjg3LS43NjNjMS41MjYgMCAyLjc5Ny4yNTUgMy44NzguODI3czEuOTcxIDEuMzM1IDIuNjcgMi40MTZWNy4xOTNoNC45NTl6bS0xMC40MjYgMjQuNTM4YzEuNjUzIDAgMi45MjQtLjU3MiAzLjk0MS0xLjY1M3MxLjUyNi0yLjU0MyAxLjUyNi00LjMyMy0uNTA5LTMuMTc4LTEuNTI2LTQuMzIyYy0xLjAxNy0xLjA4MS0yLjI4OC0xLjY1My0zLjk0MS0xLjY1My0xLjU5IDAtMi45MjUuNTcyLTMuODc4IDEuNjUzLTEuMDE3IDEuMDgtMS41MjYgMi41NDMtMS41MjYgNC4zMjIgMCAxLjc4LjUwOSAzLjE4IDEuNTI2IDQuMjYgMS4wMTcgMS4xNDQgMi4yODggMS43MTYgMy44NzggMS43MTZNNTcuMjAyIDIwLjM1M0g0NC45MzN2NC4yNTloNi45OTNjLS4xOSAyLjE2MS0xLjAxNyAzLjgxNC0yLjQxNiA1LjE1LTEuMzk4IDEuMjctMy4xNzggMS45MDYtNS40NjcgMS45MDYtMS4yNzEgMC0yLjQ4LS4yNTQtMy40OTYtLjY5OWE3IDcgMCAwIDEtMi43MzQtMS45N2MtLjc2My0uODI3LTEuMzM1LTEuODQ0LTEuNzgtMy4wNTJzLS42MzYtMi40OC0uNjM2LTMuOTQyLjE5LTIuNzMzLjYzNi0zLjk0MWMuMzgxLTEuMjA4IDEuMDE3LTIuMTYyIDEuNzgtMy4wNTIuNzYzLS44MjYgMS42NTMtMS40NjIgMi43MzMtMS45N2E5LjEgOS4xIDAgMCAxIDMuNTYtLjdxNC4wMDUgMCA2LjEwMyAxLjkwN2wzLjMwNi0zLjMwNWMtMi40OC0xLjkwNy01LjY1OC0yLjkyNS05LjQwOS0yLjkyNS0yLjA5NyAwLTQuMDA0LjMxOC01LjcyMSAxLjAxOC0xLjcxNi42OTktMy4xNzkgMS41ODktNC4zODYgMi43OTdBMTIuMSAxMi4xIDAgMCAwIDMxLjIgMTYuMjJjLS42MzUgMS43MTctLjk1MyAzLjYyNC0uOTUzIDUuNjU4cy4zMTggMy45NDIgMS4wMTcgNS42NThjLjcgMS43MTcgMS41OSAzLjE3OSAyLjc5NyA0LjM4N2ExMi4xIDEyLjEgMCAwIDAgNC4zODcgMi43OTdjMS43MTYuNyAzLjYyMyAxLjAxNyA1LjY1NyAxLjAxNyAyLjAzNSAwIDMuODc4LS4zMTggNS41MzEtMS4wMTcgMS42NTMtLjcgMy4wNTItMS41OSA0LjE5Ni0yLjc5N3ExLjcxNi0xLjgxMiAyLjY3LTQuMzg3Yy42MzYtMS43MTYuOTU0LTMuNjIzLjk1NC01LjY1OHYtLjgyNmMtLjE5MS0uMTI3LS4yNTUtLjQ0NS0uMjU1LS43TTk1Ljk4MiAyMC4zNTNoLTEyLjI3djQuMjU5aDYuOTkzYy0uMTkgMi4xNjEtMS4wMTcgMy44MTQtMi40MTYgNS4xNS0xLjM5OCAxLjI3LTMuMTc4IDEuOTA2LTUuNDY3IDEuOTA2LTEuMjcxIDAtMi40OC0uMjU0LTMuNDk2LS42OTlhNyA3IDAgMCAxLTIuNzM0LTEuOTdjLS43NjMtLjgyNy0xLjMzNS0xLjg0NC0xLjc4LTMuMDUycy0uNjM2LTIuNDgtLjYzNi0zLjk0Mi4xOS0yLjczMy42MzYtMy45NDFjLjM4MS0xLjIwOCAxLjAxNy0yLjE2MiAxLjc4LTMuMDUyLjc2My0uODI2IDEuNjUzLTEuNDYyIDIuNzM0LTEuOTdhOS4xIDkuMSAwIDAgMSAzLjU2LS43cTQuMDA1IDAgNi4xMDMgMS45MDdsMy4zMDUtMy4zMDVjLTIuNDc5LTEuOTA3LTUuNjU4LTIuOTI1LTkuNDA4LTIuOTI1LTIuMDk4IDAtNC4wMDUuMzE4LTUuNzIyIDEuMDE4LTEuNzE2LjY5OS0zLjE3OCAxLjU4OS00LjM4NiAyLjc5N2ExMi4xIDEyLjEgMCAwIDAtMi43OTcgNC4zODZjLS42MzYgMS43MTctLjk1NCAzLjYyNC0uOTU0IDUuNjU4cy4zMTggMy45NDIgMS4wMTcgNS42NThjLjcgMS43MTcgMS41OSAzLjE3OSAyLjc5NyA0LjM4N2ExMi4xIDEyLjEgMCAwIDAgNC4zODcgMi43OTdjMS43MTYuNyAzLjYyMyAxLjAxNyA1LjY1OCAxLjAxNyAyLjAzNCAwIDMuODc4LS4zMTggNS41My0xLjAxNyAxLjY1My0uNyAzLjA1Mi0xLjU5IDQuMTk2LTIuNzk3cTEuNzE4LTEuODEyIDIuNjctNC4zODdjLjYzNi0xLjcxNi45NTQtMy42MjMuOTU0LTUuNjU4di0uODI2Yy0uMTktLjEyNy0uMjU1LS40NDUtLjI1NS0uNyIvPjwvc3ZnPg==");background-repeat:no-repeat;background-size:170px 40px;content:"";display:block;height:40px;width:170px}}:where(.ag-ltr) .ag-watermark{right:25px}:where(.ag-rtl) .ag-watermark{left:25px}.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 AgWatermark = class extends Component {
constructor() {
super(
/* html*/
`
`
);
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.addCssClass("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,
_warn as _warn3
} from "ag-grid-community";
// packages/ag-grid-enterprise/src/excelExport/excelSerializingSession.ts
import { BaseGridSerializingSession, _addGridCommonParams, _last, _mergeDeep, _warn as _warn2 } 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) => {
Object.keys(prefixedSet.map).forEach((key) => {
props += returnAttributeIfPopulated(
prefixedSet.prefix + key,
prefixedSet.map[key],
booleanTransformer
);
});
});
}
if (xmlElement.properties.rawMap) {
Object.keys(xmlElement.properties.rawMap).forEach((key) => {
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) {
xmlElement.children.forEach((it) => {
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 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), false)
};
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/excelXlsxFactory.ts
import { _escapeString as _escapeString5, _getHeaderRowCount, _warn } 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) {
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 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"
}
].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/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 && 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 && left.style } },
children: leftChildren
},
{
name: "right",
properties: { rawMap: { style: right && right.style } },
children: rightChildren
},
{
name: "top",
properties: { rawMap: { style: top && top.style } },
children: topChildren
},
{
name: "bottom",
properties: { rawMap: { style: bottom && bottom.style } },
children: bottomChildren
},
{
name: "diagonal",
properties: { rawMap: { style: diagonal && 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 _escapeString2 } 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] = _escapeString2(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.indexOf("mixedStyle") !== -1 && 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;
if (patternType != convertedPattern || fgRgb != convertedFillColor || bgRgb != convertedPatternColor) {
return false;
}
return true;
});
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) => {
if (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) {
return false;
}
return true;
});
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
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,
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: 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 _escapeString4 } 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, 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: s,
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 _escapeString3 } 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: _escapeString3(replaceInvisibleCharacters(value), false)
}
];
} else if (convertedType === "inlineStr") {
children = [
{
name: "is",
children: [
{
name: "t",
textNode: _escapeString3(replaceInvisibleCharacters(value), false)
}
]
}
];
} 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}${_escapeString4(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 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
} = config;
const { table } = worksheet;
const { rows, columns } = table;
const mergedCells = columns && 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),
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_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) {
if (config.colModel.isPivotActive()) {
showExcelTableNonCompatibleFeaturesWarning("pivot mode");
newConfig.exportAsExcelTable = false;
}
if (config.gos.get("masterDetail")) {
showExcelTableNonCompatibleFeaturesWarning("master/detail");
newConfig.exportAsExcelTable = false;
}
}
processTableConfig(worksheet, newConfig);
return createWorksheet(worksheet, newConfig);
}
function showExcelTableNonCompatibleFeaturesWarning(featureName) {
_warn(163, { featureName });
}
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)) {
_warn(164);
return;
}
XLSX_WORKSHEET_DATA_TABLES.set(sheetIndex, table);
}
function processTableConfig(worksheet, config) {
const { exportAsExcelTable, prependContent, appendContent, colModel } = config;
if (!exportAsExcelTable) {
return;
}
const tableConfig = typeof exportAsExcelTable === "boolean" ? {} : exportAsExcelTable;
const {
name: nameFromConfig,
showColumnStripes,
showRowStripes,
showFilterButton,
highlightFirstColumn,
highlightLastColumn
} = tableConfig;
const tableName = getXlsxSanitizedTableName(nameFromConfig || DEFAULT_TABLE_DISPLAY_NAME);
const sheetIndex = XLSX_SHEET_NAMES.length - 1;
const { table } = worksheet;
const { rows, columns } = table;
const headerRowCount = _getHeaderRowCount(colModel);
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 || !tableColumns.length || !tableRowCount || !tableName) {
_warn(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 = _escapeString5(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_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 createXlsxContentTypes(sheetLen) {
return createXmlPart(contentTypes_default.getTemplate(sheetLen));
}
function createXlsxRels() {
const rs = relationships_default.getTemplate([
{
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"
}
]);
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
})
);
}
// 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.config = Object.assign({}, config);
this.stylesByIds = {};
this.config.baseExcelStyles.forEach((style) => {
this.stylesByIds[style.id] = style;
});
this.excelStyles = [...this.config.baseExcelStyles, { id: "_quotePrefix", quotePrefix: 1 }];
}
addCustomContent(customContent) {
customContent.forEach((row) => {
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, collapsibleRanges) => {
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
});
}
};
}
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 { config } = this;
let name;
if (config.sheetName != null) {
const { sheetName } = config;
const sheetNameValue = typeof sheetName === "function" ? sheetName(_addGridCommonParams(this.gos, {})) : sheetName;
name = String(sheetNameValue).substring(0, 31);
} else {
name = "ag-grid";
}
const data = {
name,
table: {
columns: this.cols,
rows: this.rows
}
};
return this.createExcel(data);
}
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);
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,
index,
rowIndex,
"excel",
node
);
const styleIds = this.config.styleLinker({
rowType: "BODY",
rowIndex,
value: valueForCell,
column,
node
});
const excelStyleId = this.getStyleId(styleIds);
const colSpan = column.getColSpan(node);
const addedImage = this.addImage(rowIndex, column, valueForCell);
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(valueForCell),
valueForCell,
colSpan - 1
)
);
} else {
currentCells.push(
this.createCell(excelStyleId, this.getDataTypeForValue(valueForCell), valueForCell, valueFormatted)
);
}
};
}
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)()
};
}
createExcel(data) {
const { excelStyles, config } = this;
if (this.frozenColumnCount) {
config.frozenColumnCount = this.frozenColumnCount;
}
if (this.frozenRowCount) {
config.frozenRowCount = this.frozenRowCount;
}
return createXlsxExcel(excelStyles, data, config);
}
getDataTypeForValue(valueForCell) {
if (valueForCell === void 0) {
return "empty";
}
return this.isNumerical(valueForCell) ? "n" : "s";
}
getTypeFromStyle(style, value) {
if (this.isFormula(value)) {
return "f";
}
if (style && 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:
_warn2(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;
}
addXlsxBodyImageToMap(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) {
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" ? getXlsxStringPosition(valueToUse).toString() : value
},
mergeAcross: numOfCells
};
}
getCellValue(type, value) {
let escaped = false;
if (value == null || type === "s" && value === "") {
return { value: "", escaped: false };
}
if (type === "s") {
if (value && value[0] === "'") {
escaped = true;
value = value.slice(1);
}
value = getXlsxStringPosition(value).toString();
} else if (type === "f") {
value = value.slice(1);
} else if (type === "n") {
const numberValue = Number(value);
if (isNaN(numberValue)) {
value = "";
} else if (value !== "") {
value = numberValue.toString();
}
}
return { value, escaped };
}
getStyleId(styleIds) {
if (!styleIds || !styleIds.length) {
return null;
}
if (styleIds.length === 1) {
return styleIds[0];
}
const key = styleIds.join("-");
if (!this.mixedStyles[key]) {
this.addNewMixedStyle(styleIds);
}
return this.mixedStyles[key].excelID;
}
deepCloneObject(object) {
return JSON.parse(JSON.stringify(object));
}
addNewMixedStyle(styleIds) {
this.mixedStyleCounter += 1;
const excelId = `mixedStyle${this.mixedStyleCounter}`;
const resultantStyle = {};
for (const styleId of styleIds) {
for (const excelStyle of this.excelStyles) {
if (excelStyle.id === styleId) {
_mergeDeep(resultantStyle, this.deepCloneObject(excelStyle));
}
}
}
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;
}
return this.config.autoConvertFormulas && value.toString().startsWith("=");
}
isNumerical(value) {
if (typeof value === "bigint") {
return true;
}
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/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(s) {
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 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(s);
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 getDeflatedHeaderAndContent = async (currentFile, offset) => {
const { content } = currentFile;
const { size, content: rawContent } = !content ? { size: 0, content: Uint8Array.from([]) } : getDecodedContent(content);
let deflatedContent = void 0;
let deflatedSize = void 0;
let deflationPerformed = false;
const shouldDeflate = currentFile.type === "file" && rawContent && size > 0;
if (shouldDeflate) {
const result = await deflateLocalFile(rawContent);
deflatedContent = result.content;
deflatedSize = result.size;
deflationPerformed = true;
}
const headers = getHeaders(currentFile, deflationPerformed, offset, size, rawContent, deflatedSize);
return {
...headers,
content: deflatedContent || rawContent,
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 readyFiles = [];
let lL = 0;
for (const currentFile of totalFiles) {
const output = await getDeflatedHeaderAndContent(currentFile, lL);
const { localFileHeader, content } = output;
readyFiles.push(output);
lL += localFileHeader.length + content.length;
}
return this.packageFiles(readyFiles);
}
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) => {
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));
zipContainer.addFile("[Content_Types].xml", createXlsxContentTypes(sheetLen));
zipContainer.addFile("_rels/.rels", createXlsxRels());
};
var createExcelFileForExcel = (zipContainer, data, options = {}) => {
if (!data || data.length === 0) {
_warn3(159);
resetXlsxFactory();
return false;
}
const { fontSize = 11, author = "AG Grid", activeTab = 0 } = 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);
resetXlsxFactory();
return true;
};
var getMultipleSheetsAsExcelCompressed = (params) => {
const { data, fontSize, author, activeSheetIndex } = params;
const mimeType = params.mimeType || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
const zipContainer = new ZipContainer();
if (!createExcelFileForExcel(zipContainer, data, {
author,
fontSize,
activeTab: activeSheetIndex
})) {
return Promise.resolve(void 0);
}
return zipContainer.getZipFile(mimeType);
};
var getMultipleSheetsAsExcel = (params) => {
const { data, fontSize, author, activeSheetIndex } = params;
const mimeType = params.mimeType || "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
const zipContainer = new ZipContainer();
if (!createExcelFileForExcel(zipContainer, data, {
author,
fontSize,
activeTab: activeSheetIndex
})) {
return;
}
return zipContainer.getUncompressedZipFile(mimeType);
};
var exportMultipleSheetsAsExcel = (params) => {
const { fileName = "export.xlsx" } = params;
getMultipleSheetsAsExcelCompressed(params).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";
}
getMergedParams(params) {
const baseParams = this.gos.get("defaultExcelExportParams");
return Object.assign({}, baseParams, params);
}
export(userParams) {
if (this.isExportSuppressed()) {
_warn3(160);
return;
}
const mergedParams = this.getMergedParams(userParams);
const data = this.getData(mergedParams);
const exportParams = {
data: [data],
fontSize: mergedParams.fontSize,
author: mergedParams.author,
mimeType: mergedParams.mimeType
};
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);
}
});
}
exportDataAsExcel(params) {
this.export(params);
}
getDataAsExcel(params) {
const mergedParams = this.getMergedParams(params);
const data = this.getData(mergedParams);
const exportParams = {
data: [data],
fontSize: mergedParams.fontSize,
author: mergedParams.author,
mimeType: mergedParams.mimeType
};
return this.packageFile(exportParams);
}
setFactoryMode(factoryMode) {
setXlsxFactoryMode(factoryMode);
}
getFactoryMode() {
return getXlsxFactoryMode();
}
getSheetDataForExcel(params) {
const mergedParams = this.getMergedParams(params);
return this.getData(mergedParams);
}
getMultipleSheetsAsExcel(params) {
return getMultipleSheetsAsExcel(params);
}
exportMultipleSheetsAsExcel(params) {
exportMultipleSheetsAsExcel(params);
}
getDefaultFileExtension() {
return "xlsx";
}
createSerializingSession(params) {
const { colModel, colNames, rowGroupColsSvc, valueSvc, gos } = this.beans;
const config = {
...params,
colModel,
colNames,
rowGroupColsSvc,
valueSvc,
gos,
suppressRowOutline: params.suppressRowOutline || params.skipRowGroups,
headerRowHeight: params.headerRowHeight || params.rowHeight,
baseExcelStyles: gos.get("excelStyles") || [],
rightToLeft: params.rightToLeft ?? gos.get("enableRtl"),
styleLinker: this.styleLinker.bind(this)
};
return new ExcelSerializingSession(config);
}
styleLinker(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 = [];
const { gos, cellStyles } = this.beans;
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 styles = gos.get("excelStyles");
const applicableStyles = ["cell"];
if (!styles || !styles.length) {
return applicableStyles;
}
const styleIds = styles.map((it) => {
return it.id;
});
const colDef = column.getDefinition();
cellStyles?.processAllCellClasses(
colDef,
_addGridCommonParams2(gos, {
value,
data: node.data,
node,
colDef,
column,
rowIndex
}),
(className) => {
if (styleIds.indexOf(className) > -1) {
applicableStyles.push(className);
}
}
);
return applicableStyles.sort((left, right) => {
return styleIds.indexOf(left) < styleIds.indexOf(right) ? -1 : 1;
});
}
isExportSuppressed() {
return this.gos.get("suppressExcelExport");
}
packageCompressedFile(params) {
return getMultipleSheetsAsExcelCompressed(params);
}
packageFile(params) {
return getMultipleSheetsAsExcel(params);
}
};
// packages/ag-grid-enterprise/src/advancedFilter/advancedFilterModule.ts
import { _FilterCoreModule, _FilterValueModule, _PopupModule, _SharedDragAndDropModule } from "ag-grid-community";
// packages/ag-grid-enterprise/src/version.ts
var VERSION = "33.1.1";
// packages/ag-grid-enterprise/src/agGridEnterpriseModule.ts
var EnterpriseCoreModule = {
moduleName: "EnterpriseCore",
version: VERSION,
beans: [GridLicenseManager],
icons: {
// accordion open (filter tool panel group, charts group)
accordionOpen: "tree-open",
// accordion closed (filter tool panel group, charts group)
accordionClosed: "tree-closed",
// accordion indeterminate - shown when some children are expanded and
// others are collapsed (filter tool panel group, charts group)
accordionIndeterminate: "tree-indeterminate",
// dialog title bar
close: "cross",
// X (remove) on column 'pill' after adding it to a drop zone list
cancel: "cancel",
// button in chart regular size window title bar (click to maximise)
maximize: "maximize",
// button in chart maximised window title bar (click to make regular size)
minimize: "minimize",
// drag handle used to pick up draggable columns
columnDrag: "grip"
},
dependsOn: []
};
// packages/ag-grid-enterprise/src/advancedFilter/advanced-filter.css-GENERATED.ts
var advancedFilterCSS = (
/*css*/
`.ag-advanced-filter-header{align-items:center;background-color:var(--ag-header-background-color);border-bottom:var(--ag-header-row-border);display:flex;padding-left:var(--ag-cell-horizontal-padding);padding-right:var(--ag-cell-horizontal-padding);position:relative}.ag-advanced-filter{align-items:center;display:flex;width:100%}.ag-advanced-filter-apply-button,.ag-advanced-filter-builder-button{line-height:normal;white-space:nowrap}:where(.ag-ltr) .ag-advanced-filter-apply-button,:where(.ag-ltr) .ag-advanced-filter-builder-button{margin-left:calc(var(--ag-spacing)*2)}:where(.ag-rtl) .ag-advanced-filter-apply-button,:where(.ag-rtl) .ag-advanced-filter-builder-button{margin-right:calc(var(--ag-spacing)*2)}.ag-advanced-filter-builder-button{align-items:center;background-color:unset;border:0;display:flex;font-size:var(--ag-font-size);font-weight:600;padding:var(--ag-spacing);&:where(:not(:disabled)){cursor:pointer;&:hover{background-color:var(--ag-row-hover-color)}}}:where(.ag-ltr) .ag-advanced-filter-builder-button-label{margin-left:var(--ag-spacing)}:where(.ag-rtl) .ag-advanced-filter-builder-button-label{margin-right:var(--ag-spacing)}.ag-advanced-filter-builder{display:flex;flex-direction:column;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}.ag-advanced-filter-builder-list{flex:1;overflow:auto}.ag-advanced-filter-builder-button-panel{border-top:var(--ag-advanced-filter-builder-button-bar-border);display:flex;justify-content:flex-end;padding:var(--ag-widget-container-vertical-padding) var(--ag-widget-container-horizontal-padding)}:where(.ag-ltr) .ag-advanced-filter-builder-apply-button,:where(.ag-ltr) .ag-advanced-filter-builder-cancel-button{margin-left:calc(var(--ag-spacing)*2)}:where(.ag-rtl) .ag-advanced-filter-builder-apply-button,:where(.ag-rtl) .ag-advanced-filter-builder-cancel-button{margin-right:calc(var(--ag-spacing)*2)}.ag-advanced-filter-builder-item-wrapper{align-items:center;display:flex;flex:1 1 auto;justify-content:space-between;overflow:hidden}:where(.ag-ltr) .ag-advanced-filter-builder-item-wrapper{padding-left:calc(var(--ag-icon-size)/2);padding-right:var(--ag-icon-size)}:where(.ag-rtl) .ag-advanced-filter-builder-item-wrapper{padding-left:var(--ag-icon-size);padding-right:calc(var(--ag-icon-size)/2)}:where(.ag-virtual-list-viewport .ag-advanced-filter-builder-item-wrapper) .ag-tab-guard{position:absolute}.ag-advanced-filter-builder-item-tree-lines>*{width:var(--ag-advanced-filter-builder-indent-size)}.ag-advanced-filter-builder-item-tree-line-root{width:var(--ag-icon-size);&:before{height:50%;top:50%}}.ag-advanced-filter-builder-item-tree-line-horizontal,.ag-advanced-filter-builder-item-tree-line-vertical,.ag-advanced-filter-builder-item-tree-line-vertical-bottom,.ag-advanced-filter-builder-item-tree-line-vertical-top{align-items:center;display:flex;height:100%;position:relative;&:after,&:before{content:"";height:100%;position:absolute}}.ag-advanced-filter-builder-item-tree-line-horizontal:after{border-bottom:1px solid var(--ag-border-color);height:50%;top:0;width:calc(var(--ag-advanced-filter-builder-indent-size) - var(--ag-icon-size))}:where(.ag-ltr) .ag-advanced-filter-builder-item-tree-line-horizontal:after{left:calc(var(--ag-icon-size)/2)}:where(.ag-rtl) .ag-advanced-filter-builder-item-tree-line-horizontal:after{right:calc(var(--ag-icon-size)/2)}.ag-advanced-filter-builder-item-tree-line-vertical:before{top:0;width:calc(var(--ag-advanced-filter-builder-indent-size) - var(--ag-icon-size)/2)}:where(.ag-ltr) .ag-advanced-filter-builder-item-tree-line-vertical:before{border-left:1px solid var(--ag-border-color);left:calc(var(--ag-icon-size)/2)}:where(.ag-rtl) .ag-advanced-filter-builder-item-tree-line-vertical:before{border-right:1px solid var(--ag-border-color);right:calc(var(--ag-icon-size)/2)}.ag-advanced-filter-builder-item-tree-line-vertical-top:before{height:50%;top:0;width:calc(var(--ag-advanced-filter-builder-indent-size) - var(--ag-icon-size)/2)}:where(.ag-ltr) .ag-advanced-filter-builder-item-tree-line-vertical-top:before{border-left:1px solid var(--ag-border-color);left:calc(var(--ag-icon-size)/2)}:where(.ag-rtl) .ag-advanced-filter-builder-item-tree-line-vertical-top:before{border-right:1px solid var(--ag-border-color);right:calc(var(--ag-icon-size)/2)}.ag-advanced-filter-builder-item-tree-line-vertical-bottom:before{height:calc(50% - var(--ag-icon-size)*1.5/2);top:calc(50% + var(--ag-icon-size)*1.5/2);width:calc(var(--ag-icon-size)/2)}:where(.ag-ltr) .ag-advanced-filter-builder-item-tree-line-vertical-bottom:before{border-left:1px solid var(--ag-border-color);left:calc(var(--ag-icon-size)/2)}:where(.ag-rtl) .ag-advanced-filter-builder-item-tree-line-vertical-bottom:before{border-right:1px solid var(--ag-border-color);right:calc(var(--ag-icon-size)/2)}.ag-advanced-filter-builder-item-condition{padding-bottom:var(--ag-spacing);padding-top:var(--ag-spacing)}.ag-advanced-filter-builder-item,.ag-advanced-filter-builder-item-buttons,.ag-advanced-filter-builder-item-condition,.ag-advanced-filter-builder-item-tree-lines,.ag-advanced-filter-builder-pill,.ag-advanced-filter-builder-pill-wrapper{align-items:center;display:flex;height:100%}.ag-advanced-filter-builder-pill-wrapper{margin:0 var(--ag-spacing)}.ag-advanced-filter-builder-pill{border-radius:var(--ag-border-radius);min-height:calc(100% - var(--ag-spacing)*3);min-width:calc(var(--ag-spacing)*2);padding:var(--ag-spacing) calc(var(--ag-spacing)*2);position:relative}:where(.ag-advanced-filter-builder-pill){.ag-advanced-filter-builder-value-number{font-family:monospace;font-weight:700}.ag-advanced-filter-builder-value-empty{color:var(--ag-subtle-text-color)}}:where(.ag-ltr) :where(.ag-advanced-filter-builder-pill){.ag-picker-field-display{margin-right:var(--ag-spacing)}}:where(.ag-rtl) :where(.ag-advanced-filter-builder-pill){.ag-picker-field-display{margin-left:var(--ag-spacing)}}.ag-advanced-filter-builder-pill-display{font-weight:500;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ag-advanced-filter-builder-join-pill{background-color:var(--ag-advanced-filter-builder-join-pill-color);cursor:pointer}.ag-advanced-filter-builder-column-pill{background-color:var(--ag-advanced-filter-builder-column-pill-color);cursor:pointer}.ag-advanced-filter-builder-option-pill{background-color:var(--ag-advanced-filter-builder-option-pill-color);cursor:pointer}.ag-advanced-filter-builder-value-pill{background-color:var(--ag-advanced-filter-builder-value-pill-color);cursor:text;max-width:140px;:where(.ag-advanced-filter-builder-pill-display){display:block}}.ag-advanced-filter-builder-item-buttons>*{margin:0 calc(var(--ag-spacing)*.5)}.ag-advanced-filter-builder-item-button{color:var(--ag-subtle-text-color);cursor:pointer;position:relative}.ag-advanced-filter-builder-item-button,.ag-advanced-filter-builder-pill{&:focus-visible{box-shadow:var(--ag-focus-shadow)}}.ag-advanced-filter-builder-item-button-disabled{cursor:default;opacity:.5}.ag-advanced-filter-builder-virtual-list-container{top:var(--ag-spacing)}.ag-advanced-filter-builder-virtual-list-item{cursor:default;display:flex;height:var(--ag-list-item-height);&:hover{background-color:var(--ag-row-hover-color);:where(.ag-advanced-filter-builder-item-button){opacity:1}}}.ag-advanced-filter-builder-invalid{color:var(--ag-invalid-color);cursor:default;margin:0 var(--ag-spacing)}:where(.ag-advanced-filter-builder-validation) .ag-advanced-filter-builder-invalid,:where(.ag-advanced-filter-builder-virtual-list-item-highlight) .ag-advanced-filter-builder-item-button:focus-visible{opacity:1}`
);
// packages/ag-grid-enterprise/src/advancedFilter/advancedFilterApi.ts
function getAdvancedFilterModel(beans) {
return beans.filterManager?.getAdvFilterModel() ?? null;
}
function setAdvancedFilterModel(beans, advancedFilterModel) {
beans.filterManager?.setAdvFilterModel(advancedFilterModel);
}
function showAdvancedFilterBuilder(beans) {
beans.filterManager?.toggleAdvFilterBuilder(true, "api");
}
function hideAdvancedFilterBuilder(beans) {
beans.filterManager?.toggleAdvFilterBuilder(false, "api");
}
// packages/ag-grid-enterprise/src/advancedFilter/advancedFilterExpressionService.ts
import { BeanStub as BeanStub2, _exists, _parseDateTimeFromString, _serialiseDate, _toStringOrNull } from "ag-grid-community";
// packages/ag-grid-enterprise/src/advancedFilter/advancedFilterLocaleText.ts
var ADVANCED_FILTER_LOCALE_TEXT = {
ariaAdvancedFilterBuilderItem: (variableValues) => `${variableValues[0]}. Level ${variableValues[1]}. Press ENTER to edit`,
ariaAdvancedFilterBuilderItemValidation: (variableValues) => `${variableValues[0]}. Level ${variableValues[1]}. ${variableValues[2]} Press ENTER to edit`,
ariaAdvancedFilterBuilderList: "Advanced Filter Builder List",
ariaAdvancedFilterBuilderFilterItem: "Filter Condition",
ariaAdvancedFilterBuilderGroupItem: "Filter Group",
ariaAdvancedFilterBuilderColumn: "Column",
ariaAdvancedFilterBuilderOption: "Option",
ariaAdvancedFilterBuilderValue: "Value",
ariaAdvancedFilterBuilderJoinOperator: "Join Operator",
ariaAdvancedFilterInput: "Advanced Filter Input",
ariaLabelAdvancedFilterAutocomplete: "Advanced Filter Autocomplete",
advancedFilterContains: "contains",
advancedFilterNotContains: "does not contain",
advancedFilterTextEquals: "equals",
advancedFilterTextNotEqual: "does not equal",
advancedFilterStartsWith: "begins with",
advancedFilterEndsWith: "ends with",
advancedFilterBlank: "is blank",
advancedFilterNotBlank: "is not blank",
advancedFilterEquals: "=",
advancedFilterNotEqual: "!=",
advancedFilterGreaterThan: ">",
advancedFilterGreaterThanOrEqual: ">=",
advancedFilterLessThan: "<",
advancedFilterLessThanOrEqual: "<=",
advancedFilterTrue: "is true",
advancedFilterFalse: "is false",
advancedFilterAnd: "AND",
advancedFilterOr: "OR",
advancedFilterApply: "Apply",
advancedFilterBuilder: "Builder",
advancedFilterValidationMissingColumn: "Column is missing",
advancedFilterValidationMissingOption: "Option is missing",
advancedFilterValidationMissingValue: "Value is missing",
advancedFilterValidationInvalidColumn: "Column not found",
advancedFilterValidationInvalidOption: "Option not found",
advancedFilterValidationMissingQuote: "Value is missing an end quote",
advancedFilterValidationNotANumber: "Value is not a number",
advancedFilterValidationInvalidDate: "Value is not a valid date",
advancedFilterValidationMissingCondition: "Condition is missing",
advancedFilterValidationJoinOperatorMismatch: "Join operators within a condition must be the same",
advancedFilterValidationInvalidJoinOperator: "Join operator not found",
advancedFilterValidationMissingEndBracket: "Missing end bracket",
advancedFilterValidationExtraEndBracket: "Too many end brackets",
advancedFilterValidationMessage: (variableValues) => `Expression has an error. ${variableValues[0]} - ${variableValues[1]}.`,
advancedFilterValidationMessageAtEnd: (variableValues) => `Expression has an error. ${variableValues[0]} at end of expression.`,
advancedFilterBuilderTitle: "Advanced Filter",
advancedFilterBuilderApply: "Apply",
advancedFilterBuilderCancel: "Cancel",
advancedFilterBuilderAddButtonTooltip: "Add Filter or Group",
advancedFilterBuilderRemoveButtonTooltip: "Remove",
advancedFilterBuilderMoveUpButtonTooltip: "Move Up",
advancedFilterBuilderMoveDownButtonTooltip: "Move Down",
advancedFilterBuilderAddJoin: "Add Group",
advancedFilterBuilderAddCondition: "Add Filter",
advancedFilterBuilderSelectColumn: "Select a column",
advancedFilterBuilderSelectOption: "Select an option",
advancedFilterBuilderEnterValue: "Enter a value...",
advancedFilterBuilderValidationAlreadyApplied: "Current filter already applied.",
advancedFilterBuilderValidationIncomplete: "Not all conditions are complete.",
advancedFilterBuilderValidationSelectColumn: "Must select a column.",
advancedFilterBuilderValidationSelectOption: "Must select an option.",
advancedFilterBuilderValidationEnterValue: "Must enter a value."
};
// packages/ag-grid-enterprise/src/advancedFilter/filterExpressionUtils.ts
function getSearchString(value, position, endPosition) {
if (!value) {
return "";
}
const numChars = endPosition - position;
return numChars ? value.slice(0, value.length - numChars) : value;
}
function updateExpression(expression, startPosition, endPosition, updatedValuePart, appendSpace, appendQuote, empty) {
const secondPartStartPosition = endPosition + (!expression.length || empty ? 0 : 1);
let positionOffset = 0;
if (appendSpace) {
if (expression[secondPartStartPosition] === " ") {
positionOffset = 1;
} else {
updatedValuePart += " ";
if (appendQuote) {
updatedValuePart += `"`;
}
}
}
const updatedValue = expression.slice(0, startPosition) + updatedValuePart + expression.slice(secondPartStartPosition);
return { updatedValue, updatedPosition: startPosition + updatedValuePart.length + positionOffset };
}
function findStartPosition(expression, position, endPosition) {
let startPosition = position;
while (startPosition < endPosition) {
const char = expression[startPosition];
if (char !== " ") {
break;
}
startPosition++;
}
return startPosition;
}
function findEndPosition(expression, position, includeCloseBracket, isStartPositionUnknown) {
let endPosition = position;
let isEmpty = false;
while (endPosition < expression.length) {
const char = expression[endPosition];
if (char === "(") {
if (isStartPositionUnknown && expression[endPosition - 1] === " ") {
isEmpty = true;
} else {
endPosition = endPosition - 1;
}
break;
} else if (char === " " || includeCloseBracket && char === ")") {
endPosition = endPosition - 1;
break;
}
endPosition++;
}
return { endPosition, isEmpty };
}
function checkAndUpdateExpression(params, userValue, displayValue, endPosition) {
if (displayValue !== userValue) {
params.expression = updateExpression(
params.expression,
endPosition - userValue.length + 1,
endPosition,
displayValue
).updatedValue;
}
}
function escapeQuotes(value) {
return value.replace(/(['"])/, "\\$1");
}
// packages/ag-grid-enterprise/src/advancedFilter/colFilterExpressionParser.ts
var ColumnParser = class {
constructor(params, startPosition) {
this.params = params;
this.startPosition = startPosition;
this.type = "column";
this.valid = true;
this.hasStartChar = false;
this.hasEndChar = false;
this.colName = "";
}
parse(char, position) {
if (char === COL_FILTER_EXPRESSION_START_CHAR && !this.colName) {
this.hasStartChar = true;
} else if (char === COL_FILTER_EXPRESSION_END_CHAR && this.hasStartChar) {
const isMatch = this.parseColumn(false, position);
if (isMatch) {
this.hasEndChar = true;
return false;
} else {
this.colName += char;
}
} else {
this.colName += char;
}
return void 0;
}
getDisplayValue() {
return (this.hasStartChar ? COL_FILTER_EXPRESSION_START_CHAR : "") + this.colName + (this.hasEndChar ? COL_FILTER_EXPRESSION_END_CHAR : "");
}
getColId() {
return this.colId;
}
complete(position) {
this.parseColumn(true, position);
}
getValidationError() {
return this.valid ? null : {
message: this.params.advFilterExpSvc.translate("advancedFilterValidationInvalidColumn"),
startPosition: this.startPosition,
endPosition: this.endPosition ?? this.params.expression.length - 1
};
}
parseColumn(fromComplete, endPosition) {
this.endPosition = endPosition;
const colValue = this.params.advFilterExpSvc.getColId(this.colName);
if (colValue && this.hasStartChar) {
this.colId = colValue.colId;
checkAndUpdateExpression(this.params, this.colName, colValue.columnName, endPosition - 1);
this.colName = colValue.columnName;
this.column = this.params.colModel.getColDefCol(this.colId);
if (this.column) {
this.baseCellDataType = this.params.dataTypeSvc?.getBaseDataType(this.column) ?? "text";
return true;
}
}
if (fromComplete) {
this.valid = false;
}
this.baseCellDataType = "text";
return false;
}
};
var OperatorParser = class {
constructor(params, startPosition, baseCellDataType) {
this.params = params;
this.startPosition = startPosition;
this.baseCellDataType = baseCellDataType;
this.type = "operator";
this.valid = true;
this.expectedNumOperands = 0;
this.operator = "";
}
parse(char, position) {
if (char === " " || char === ")") {
const isMatch = this.parseOperator(false, position - 1);
if (isMatch) {
return true;
} else {
this.operator += char;
}
} else {
this.operator += char;
}
return void 0;
}
complete(position) {
this.parseOperator(true, position);
}
getValidationError() {
return this.valid ? null : {
message: this.params.advFilterExpSvc.translate("advancedFilterValidationInvalidOption"),
startPosition: this.startPosition,
endPosition: this.endPosition ?? this.params.expression.length - 1
};
}
getDisplayValue() {
return this.operator;
}
getOperatorKey() {
return this.parsedOperator;
}
parseOperator(fromComplete, endPosition) {
const operatorForType = this.params.advFilterExpSvc.getDataTypeExpressionOperator(this.baseCellDataType);
const parsedOperator = operatorForType.findOperator(this.operator);
this.endPosition = endPosition;
if (parsedOperator) {
this.parsedOperator = parsedOperator;
const operator = operatorForType.operators[parsedOperator];
this.expectedNumOperands = operator.numOperands;
const operatorDisplayValue = operator.displayValue;
checkAndUpdateExpression(this.params, this.operator, operatorDisplayValue, endPosition);
this.operator = operatorDisplayValue;
return true;
}
const isPartialMatch = parsedOperator === null;
if (fromComplete || !isPartialMatch) {
this.valid = false;
}
return false;
}
};
var OperandParser = class {
constructor(params, startPosition, baseCellDataType, column) {
this.params = params;
this.startPosition = startPosition;
this.baseCellDataType = baseCellDataType;
this.column = column;
this.type = "operand";
this.valid = true;
this.operand = "";
this.validationMessage = null;
}
parse(char, position) {
if (char === " ") {
if (this.quotes) {
this.operand += char;
} else {
this.parseOperand(false, position);
return true;
}
} else if (char === ")") {
if (this.baseCellDataType === "number" || !this.quotes) {
this.parseOperand(false, position - 1);
return true;
} else {
this.operand += char;
}
} else if (!this.operand && !this.quotes && (char === `'` || char === `"`)) {
this.quotes = char;
} else if (this.quotes && char === this.quotes) {
this.parseOperand(false, position);
return false;
} else {
this.operand += char;
}
return void 0;
}
complete(position) {
this.parseOperand(true, position);
}
getValidationError() {
return this.validationMessage ? {
message: this.validationMessage,
startPosition: this.startPosition,
endPosition: this.endPosition ?? this.params.expression.length - 1
} : null;
}
getRawValue() {
return this.operand;
}
getModelValue() {
return this.modelValue;
}
parseOperand(fromComplete, position) {
const { advFilterExpSvc } = this.params;
this.endPosition = position;
this.modelValue = this.operand;
if (fromComplete && this.quotes) {
this.valid = false;
this.validationMessage = advFilterExpSvc.translate("advancedFilterValidationMissingQuote");
} else if (this.modelValue === "") {
this.valid = false;
this.validationMessage = advFilterExpSvc.translate("advancedFilterValidationMissingValue");
} else {
const modelValue = advFilterExpSvc.getOperandModelValue(this.operand, this.baseCellDataType, this.column);
if (modelValue != null) {
this.modelValue = modelValue;
}
switch (this.baseCellDataType) {
case "number":
if (this.quotes || isNaN(this.modelValue)) {
this.valid = false;
this.validationMessage = advFilterExpSvc.translate("advancedFilterValidationNotANumber");
}
break;
case "date":
case "dateString":
if (modelValue == null) {
this.valid = false;
this.validationMessage = advFilterExpSvc.translate("advancedFilterValidationInvalidDate");
}
break;
}
}
}
};
var COL_FILTER_EXPRESSION_START_CHAR = "[";
var COL_FILTER_EXPRESSION_END_CHAR = "]";
var ColFilterExpressionParser = class {
constructor(params, startPosition) {
this.params = params;
this.startPosition = startPosition;
this.isAwaiting = true;
}
parseExpression() {
let i = this.startPosition;
const { expression } = this.params;
while (i < expression.length) {
const char = expression[i];
if (char === " " && this.isAwaiting) {
} else {
this.isAwaiting = false;
if (!this.parser) {
let parser;
if (!this.columnParser) {
this.columnParser = new ColumnParser(this.params, i);
parser = this.columnParser;
} else if (!this.operatorParser) {
this.operatorParser = new OperatorParser(this.params, i, this.columnParser.baseCellDataType);
parser = this.operatorParser;
} else {
this.operandParser = new OperandParser(
this.params,
i,
this.columnParser.baseCellDataType,
this.columnParser.column
);
parser = this.operandParser;
}
this.parser = parser;
}
const hasCompletedOnPrevChar = this.parser.parse(char, i);
if (hasCompletedOnPrevChar != null) {
if (this.isComplete()) {
return this.returnEndPosition(hasCompletedOnPrevChar ? i - 1 : i, true);
}
this.parser = void 0;
this.isAwaiting = true;
}
}
i++;
}
this.parser?.complete?.(i - 1);
return this.returnEndPosition(i);
}
isValid() {
return this.isComplete() && this.columnParser.valid && this.operatorParser.valid && (!this.operandParser || this.operandParser.valid);
}
getValidationError() {
const validationError = this.columnParser?.getValidationError() ?? this.operatorParser?.getValidationError() ?? this.operandParser?.getValidationError();
if (validationError) {
return validationError;
}
const endPosition = this.params.expression.length;
let translateKey;
if (!this.columnParser) {
translateKey = "advancedFilterValidationMissingColumn";
} else if (!this.operatorParser) {
translateKey = "advancedFilterValidationMissingOption";
} else if (this.operatorParser.expectedNumOperands && !this.operandParser) {
translateKey = "advancedFilterValidationMissingValue";
}
if (translateKey) {
return {
message: this.params.advFilterExpSvc.translate(translateKey),
startPosition: endPosition,
endPosition
};
}
return null;
}
getFunctionString(params) {
return this.getFunctionCommon(params, (operandIndex, operatorIndex, colId, evaluatorParamsIndex) => {
const escapedColId = escapeQuotes(colId);
const operand = operandIndex == null ? "" : `, params.operands[${operandIndex}]`;
return `params.operators[${operatorIndex}].evaluator(expressionProxy.getValue('${escapedColId}', node), node, params.evaluatorParams[${evaluatorParamsIndex}]${operand})`;
});
}
getFunctionParsed(params) {
return this.getFunctionCommon(params, (operandIndex, operatorIndex, colId, evaluatorParamsIndex) => {
return (expressionProxy, node, p) => p.operators[operatorIndex].evaluator(
expressionProxy.getValue(colId, node),
node,
p.evaluatorParams[evaluatorParamsIndex],
operandIndex == null ? void 0 : p.operands[operandIndex]
);
});
}
getAutocompleteListParams(position) {
if (this.isColumnPosition(position)) {
return this.getColumnAutocompleteListParams(position);
}
if (this.isOperatorPosition(position)) {
return this.getOperatorAutocompleteListParams(position);
}
if (this.isBeyondEndPosition(position)) {
return void 0;
}
return { enabled: false };
}
updateExpression(position, updateEntry, type) {
const { expression } = this.params;
if (this.isColumnPosition(position)) {
return updateExpression(
this.params.expression,
this.startPosition,
this.columnParser?.getColId() ? this.columnParser.endPosition : findEndPosition(expression, position).endPosition,
this.params.advFilterExpSvc.getColumnValue(updateEntry),
true
);
} else if (this.isOperatorPosition(position)) {
const baseCellDataType = this.getBaseCellDataTypeFromOperatorAutocompleteType(type);
const hasOperand = this.hasOperand(baseCellDataType, updateEntry.key);
const doesOperandNeedQuotes = hasOperand && this.doesOperandNeedQuotes(baseCellDataType);
let update;
if (this.operatorParser?.startPosition != null && position < this.operatorParser.startPosition) {
update = updateExpression(
expression,
position,
position,
updateEntry.displayValue ?? updateEntry.key,
hasOperand,
doesOperandNeedQuotes
);
} else {
let endPosition;
let empty = false;
if (this.operatorParser?.getOperatorKey()) {
endPosition = this.operatorParser.endPosition;
} else {
const { endPosition: calculatedEndPosition, isEmpty } = findEndPosition(
expression,
position,
true,
true
);
endPosition = calculatedEndPosition;
empty = isEmpty;
}
update = updateExpression(
expression,
findStartPosition(expression, this.columnParser.endPosition + 1, endPosition),
endPosition,
updateEntry.displayValue ?? updateEntry.key,
hasOperand,
doesOperandNeedQuotes,
empty
);
}
return { ...update, hideAutocomplete: !hasOperand };
}
return null;
}
getModel() {
const colId = this.columnParser.getColId();
const model = {
filterType: this.columnParser.baseCellDataType,
colId,
type: this.operatorParser.getOperatorKey()
};
if (this.operatorParser.expectedNumOperands) {
model.filter = this.operandParser.getModelValue();
}
return model;
}
getFunctionCommon(params, processFunc) {
const colId = this.columnParser.getColId();
const operator = this.operatorParser?.getOperatorKey();
const { operators, evaluatorParams, operands } = params;
const operatorForColumn = this.params.advFilterExpSvc.getExpressionOperator(
this.columnParser.baseCellDataType,
operator
);
const operatorIndex = this.addToListAndGetIndex(operators, operatorForColumn);
const evaluatorParamsForColumn = this.params.advFilterExpSvc.getExpressionEvaluatorParams(colId);
const evaluatorParamsIndex = this.addToListAndGetIndex(evaluatorParams, evaluatorParamsForColumn);
const operandIndex = this.operatorParser?.expectedNumOperands === 0 ? void 0 : this.addToListAndGetIndex(operands, this.getOperandValue());
return processFunc(operandIndex, operatorIndex, colId, evaluatorParamsIndex);
}
getOperandValue() {
let operand = this.operandParser.getRawValue();
const { baseCellDataType, column } = this.columnParser;
switch (baseCellDataType) {
case "number":
operand = Number(operand);
break;
case "date":
case "dateString":
operand = this.params.valueSvc.parseValue(column, null, operand, void 0);
break;
}
if (baseCellDataType === "dateString") {
const { dataTypeSvc } = this.params;
return dataTypeSvc ? dataTypeSvc.getDateParserFunction(column)(operand) : operand;
}
return operand;
}
isComplete() {
return !!(this.operatorParser && (!this.operatorParser.expectedNumOperands || this.operatorParser.expectedNumOperands && this.operandParser));
}
isColumnPosition(position) {
return !this.columnParser || this.columnParser.endPosition == null || position <= this.columnParser.endPosition + 1;
}
isOperatorPosition(position) {
return !this.operatorParser || this.operatorParser.endPosition == null || position <= this.operatorParser.endPosition + 1;
}
isBeyondEndPosition(position) {
return this.isComplete() && this.endPosition != null && position > this.endPosition + 1 && this.endPosition + 1 < this.params.expression.length;
}
returnEndPosition(returnPosition, treatAsEnd) {
this.endPosition = treatAsEnd ? returnPosition : returnPosition - 1;
return returnPosition;
}
getColumnAutocompleteListParams(position) {
return this.params.advFilterExpSvc.generateAutocompleteListParams(
this.params.advFilterExpSvc.getColumnAutocompleteEntries(),
"column",
this.getColumnSearchString(position)
);
}
getColumnSearchString(position) {
const columnName = this.columnParser?.getDisplayValue() ?? "";
const searchString = getSearchString(
columnName,
position,
this.columnParser?.endPosition == null ? this.params.expression.length : this.columnParser.endPosition + 1
);
const containsStartChar = this.columnParser?.hasStartChar && searchString.length > 0;
const containsEndChar = this.columnParser?.hasEndChar && searchString.length === columnName.length + 2;
if (containsStartChar) {
return searchString.slice(1, containsEndChar ? -1 : void 0);
}
return searchString;
}
getOperatorAutocompleteListParams(position) {
const column = this.columnParser?.column;
if (!column) {
return { enabled: false };
}
const baseCellDataType = this.columnParser.baseCellDataType;
const searchString = this.operatorParser?.startPosition != null && position < this.operatorParser.startPosition ? "" : getSearchString(
this.operatorParser?.getDisplayValue() ?? "",
position,
this.operatorParser?.endPosition == null ? this.params.expression.length : this.operatorParser.endPosition + 1
);
return this.params.advFilterExpSvc.generateAutocompleteListParams(
this.params.advFilterExpSvc.getOperatorAutocompleteEntries(column, baseCellDataType),
`operator-${baseCellDataType}`,
searchString
);
}
getBaseCellDataTypeFromOperatorAutocompleteType(type) {
return type?.replace("operator-", "");
}
hasOperand(baseCellDataType, operator) {
return !baseCellDataType || !operator || (this.params.advFilterExpSvc.getExpressionOperator(baseCellDataType, operator)?.numOperands ?? 0) > 0;
}
doesOperandNeedQuotes(baseCellDataType) {
return baseCellDataType !== "number";
}
addToListAndGetIndex(list, value) {
const index = list.length;
list.push(value);
return index;
}
};
// packages/ag-grid-enterprise/src/advancedFilter/filterExpressionOperators.ts
function findMatch(searchValue, values, getDisplayValue) {
let partialMatch = false;
const searchValueLowerCase = searchValue.toLocaleLowerCase();
const partialSearchValue = searchValueLowerCase + " ";
const parsedValue = Object.keys(values).find((key) => {
const value = values[key];
const displayValueLowerCase = getDisplayValue(value).toLocaleLowerCase();
if (displayValueLowerCase.startsWith(partialSearchValue)) {
partialMatch = true;
}
return displayValueLowerCase === searchValueLowerCase;
});
if (parsedValue) {
return parsedValue;
} else if (partialMatch) {
return null;
} else {
return void 0;
}
}
function getEntries(operators, activeOperatorKeys) {
const keys = activeOperatorKeys ?? Object.keys(operators);
return keys.map((key) => ({
key,
displayValue: operators[key].displayValue
}));
}
var TextFilterExpressionOperators = class {
constructor(params) {
this.params = params;
this.initOperators();
}
getEntries(activeOperators) {
return getEntries(this.operators, activeOperators);
}
findOperator(displayValue) {
return findMatch(displayValue, this.operators, ({ displayValue: displayValue2 }) => displayValue2);
}
initOperators() {
const { translate } = this.params;
this.operators = {
contains: {
displayValue: translate("advancedFilterContains"),
evaluator: (value, node, params, operand1) => this.evaluateExpression(value, node, params, operand1, false, (v, o) => v.includes(o)),
numOperands: 1
},
notContains: {
displayValue: translate("advancedFilterNotContains"),
evaluator: (value, node, params, operand1) => this.evaluateExpression(value, node, params, operand1, true, (v, o) => !v.includes(o)),
numOperands: 1
},
equals: {
displayValue: translate("advancedFilterTextEquals"),
evaluator: (value, node, params, operand1) => this.evaluateExpression(value, node, params, operand1, false, (v, o) => v === o),
numOperands: 1
},
notEqual: {
displayValue: translate("advancedFilterTextNotEqual"),
evaluator: (value, node, params, operand1) => this.evaluateExpression(value, node, params, operand1, true, (v, o) => v != o),
numOperands: 1
},
startsWith: {
displayValue: translate("advancedFilterStartsWith"),
evaluator: (value, node, params, operand1) => this.evaluateExpression(value, node, params, operand1, false, (v, o) => v.startsWith(o)),
numOperands: 1
},
endsWith: {
displayValue: translate("advancedFilterEndsWith"),
evaluator: (value, node, params, operand1) => this.evaluateExpression(value, node, params, operand1, false, (v, o) => v.endsWith(o)),
numOperands: 1
},
blank: {
displayValue: translate("advancedFilterBlank"),
evaluator: (value) => value == null || typeof value === "string" && value.trim().length === 0,
numOperands: 0
},
notBlank: {
displayValue: translate("advancedFilterNotBlank"),
evaluator: (value) => value != null && (typeof value !== "string" || value.trim().length > 0),
numOperands: 0
}
};
}
evaluateExpression(value, node, params, operand, nullsMatch, expression) {
if (value == null) {
return nullsMatch;
}
return params.caseSensitive ? expression(params.valueConverter(value, node), operand) : expression(params.valueConverter(value, node).toLocaleLowerCase(), operand.toLocaleLowerCase());
}
};
var ScalarFilterExpressionOperators = class {
constructor(params) {
this.params = params;
this.initOperators();
}
getEntries(activeOperators) {
return getEntries(this.operators, activeOperators);
}
findOperator(displayValue) {
return findMatch(displayValue, this.operators, ({ displayValue: displayValue2 }) => displayValue2);
}
initOperators() {
const { translate, equals } = this.params;
this.operators = {
equals: {
displayValue: translate("advancedFilterEquals"),
evaluator: (value, node, params, operand1) => this.evaluateSingleOperandExpression(
value,
node,
params,
operand1,
!!params.includeBlanksInEquals,
equals
),
numOperands: 1
},
notEqual: {
displayValue: translate("advancedFilterNotEqual"),
evaluator: (value, node, params, operand1) => this.evaluateSingleOperandExpression(
value,
node,
params,
operand1,
!!params.includeBlanksInEquals,
(v, o) => !equals(v, o)
),
numOperands: 1
},
greaterThan: {
displayValue: translate("advancedFilterGreaterThan"),
evaluator: (value, node, params, operand1) => this.evaluateSingleOperandExpression(
value,
node,
params,
operand1,
!!params.includeBlanksInGreaterThan,
(v, o) => v > o
),
numOperands: 1
},
greaterThanOrEqual: {
displayValue: translate("advancedFilterGreaterThanOrEqual"),
evaluator: (value, node, params, operand1) => this.evaluateSingleOperandExpression(
value,
node,
params,
operand1,
!!params.includeBlanksInGreaterThan,
(v, o) => v >= o
),
numOperands: 1
},
lessThan: {
displayValue: translate("advancedFilterLessThan"),
evaluator: (value, node, params, operand1) => this.evaluateSingleOperandExpression(
value,
node,
params,
operand1,
!!params.includeBlanksInLessThan,
(v, o) => v < o
),
numOperands: 1
},
lessThanOrEqual: {
displayValue: translate("advancedFilterLessThanOrEqual"),
evaluator: (value, node, params, operand1) => this.evaluateSingleOperandExpression(
value,
node,
params,
operand1,
!!params.includeBlanksInLessThan,
(v, o) => v <= o
),
numOperands: 1
},
blank: {
displayValue: translate("advancedFilterBlank"),
evaluator: (value) => value == null,
numOperands: 0
},
notBlank: {
displayValue: translate("advancedFilterNotBlank"),
evaluator: (value) => value != null,
numOperands: 0
}
};
}
evaluateSingleOperandExpression(value, node, params, operand, nullsMatch, expression) {
if (value == null) {
return nullsMatch;
}
return expression(params.valueConverter(value, node), operand);
}
};
var BooleanFilterExpressionOperators = class {
constructor(params) {
this.params = params;
this.initOperators();
}
getEntries(activeOperators) {
return getEntries(this.operators, activeOperators);
}
findOperator(displayValue) {
return findMatch(displayValue, this.operators, ({ displayValue: displayValue2 }) => displayValue2);
}
initOperators() {
const { translate } = this.params;
this.operators = {
true: {
displayValue: translate("advancedFilterTrue"),
evaluator: (value) => !!value,
numOperands: 0
},
false: {
displayValue: translate("advancedFilterFalse"),
evaluator: (value) => value === false,
numOperands: 0
},
blank: {
displayValue: translate("advancedFilterBlank"),
evaluator: (value) => value == null,
numOperands: 0
},
notBlank: {
displayValue: translate("advancedFilterNotBlank"),
evaluator: (value) => value != null,
numOperands: 0
}
};
}
};
// packages/ag-grid-enterprise/src/advancedFilter/advancedFilterExpressionService.ts
var AdvancedFilterExpressionService = class extends BeanStub2 {
constructor() {
super(...arguments);
this.beanName = "advFilterExpSvc";
this.columnNameToIdMap = {};
this.columnAutocompleteEntries = null;
this.expressionEvaluatorParams = {};
}
wireBeans(beans) {
this.valueSvc = beans.valueSvc;
this.colModel = beans.colModel;
this.colNames = beans.colNames;
this.dataTypeSvc = beans.dataTypeSvc;
}
postConstruct() {
this.expressionJoinOperators = this.generateExpressionJoinOperators();
this.expressionOperators = this.generateExpressionOperators();
}
parseJoinOperator(model) {
const { type } = model;
return this.expressionJoinOperators[type] ?? type;
}
getColumnDisplayValue(model) {
const { colId } = model;
const columnEntries = this.getColumnAutocompleteEntries();
const columnEntry = columnEntries.find(({ key }) => key === colId);
let columnName;
if (columnEntry) {
columnName = columnEntry.displayValue;
this.columnNameToIdMap[columnName.toLocaleUpperCase()] = { colId, columnName };
} else {
columnName = colId;
}
return columnName;
}
getOperatorDisplayValue(model) {
return this.getExpressionOperator(model.filterType, model.type)?.displayValue ?? model.type;
}
getOperandModelValue(operand, baseCellDataType, column) {
switch (baseCellDataType) {
case "number":
return _exists(operand) ? Number(operand) : null;
case "date":
return _serialiseDate(this.valueSvc.parseValue(column, null, operand, void 0), false);
case "dateString": {
const parsedDateString = this.valueSvc.parseValue(column, null, operand, void 0);
return this.dataTypeSvc ? _serialiseDate(this.dataTypeSvc.getDateParserFunction(column)(parsedDateString) ?? null, false) : parsedDateString;
}
}
return operand;
}
getOperandDisplayValue(model, skipFormatting) {
const { colId, filter } = model;
const column = this.colModel.getColDefCol(colId);
let operand = "";
if (filter != null) {
let operand1;
switch (model.filterType) {
case "number":
operand1 = _toStringOrNull(filter) ?? "";
break;
case "date": {
const dateValue = _parseDateTimeFromString(filter);
operand1 = column ? this.valueSvc.formatValue(column, null, dateValue) : null;
break;
}
case "dateString": {
let dateStringStringValue;
if (this.dataTypeSvc) {
const dateStringDateValue = _parseDateTimeFromString(filter);
dateStringStringValue = column ? this.dataTypeSvc?.getDateFormatterFunction(column)(dateStringDateValue ?? void 0) : null;
} else {
dateStringStringValue = filter;
}
operand1 = column ? this.valueSvc.formatValue(column, null, dateStringStringValue) : null;
break;
}
}
if (model.filterType !== "number") {
operand1 = operand1 ?? _toStringOrNull(filter) ?? "";
if (!skipFormatting) {
operand1 = `"${operand1}"`;
}
}
operand = skipFormatting ? operand1 : ` ${operand1}`;
}
return operand;
}
parseColumnFilterModel(model) {
const columnName = this.getColumnDisplayValue(model) ?? "";
const operator = this.getOperatorDisplayValue(model) ?? "";
const operands = this.getOperandDisplayValue(model);
return `[${columnName}] ${operator}${operands}`;
}
updateAutocompleteCache(updateEntry, type) {
if (type === "column") {
const { key: colId, displayValue } = updateEntry;
this.columnNameToIdMap[updateEntry.displayValue.toLocaleUpperCase()] = {
colId,
columnName: displayValue
};
}
}
translate(key, variableValues) {
let defaultValue = ADVANCED_FILTER_LOCALE_TEXT[key];
if (typeof defaultValue === "function") {
defaultValue = defaultValue(variableValues);
}
return this.getLocaleTextFunc()(key, defaultValue, variableValues);
}
generateAutocompleteListParams(entries, type, searchString) {
return {
enabled: true,
type,
searchString,
entries
};
}
getColumnAutocompleteEntries() {
if (this.columnAutocompleteEntries) {
return this.columnAutocompleteEntries;
}
const columns = this.colModel.getColDefCols() ?? [];
const entries = [];
const includeHiddenColumns = this.gos.get("includeHiddenColumnsInAdvancedFilter");
columns.forEach((column) => {
if (column.getColDef().filter && (includeHiddenColumns || column.isVisible() || column.isRowGroupActive())) {
entries.push({
key: column.getColId(),
displayValue: this.colNames.getDisplayNameForColumn(column, "advancedFilter")
});
}
});
entries.sort((a, b) => {
const aValue = a.displayValue ?? "";
const bValue = b.displayValue ?? "";
if (aValue < bValue) {
return -1;
} else if (bValue > aValue) {
return 1;
}
return 0;
});
return entries;
}
getOperatorAutocompleteEntries(column, baseCellDataType) {
const activeOperators = this.getActiveOperators(column);
return this.getDataTypeExpressionOperator(baseCellDataType).getEntries(activeOperators);
}
getJoinOperatorAutocompleteEntries() {
return Object.entries(this.expressionJoinOperators).map(([key, displayValue]) => ({ key, displayValue }));
}
getDefaultAutocompleteListParams(searchString) {
return this.generateAutocompleteListParams(this.getColumnAutocompleteEntries(), "column", searchString);
}
getDataTypeExpressionOperator(baseCellDataType) {
return this.expressionOperators[baseCellDataType];
}
getExpressionOperator(baseCellDataType, operator) {
return this.getDataTypeExpressionOperator(baseCellDataType)?.operators?.[operator];
}
getExpressionJoinOperators() {
return this.expressionJoinOperators;
}
getColId(columnName) {
const upperCaseColumnName = columnName.toLocaleUpperCase();
const cachedColId = this.columnNameToIdMap[upperCaseColumnName];
if (cachedColId) {
return cachedColId;
}
const columnAutocompleteEntries = this.getColumnAutocompleteEntries();
const colEntry = columnAutocompleteEntries.find(
({ displayValue }) => displayValue.toLocaleUpperCase() === upperCaseColumnName
);
if (colEntry) {
const { key: colId, displayValue } = colEntry;
const colValue = { colId, columnName: displayValue };
this.columnNameToIdMap[upperCaseColumnName] = colValue;
return colValue;
}
return null;
}
getExpressionEvaluatorParams(colId) {
let params = this.expressionEvaluatorParams[colId];
if (params) {
return params;
}
const column = this.colModel.getColDefCol(colId);
if (!column) {
return { valueConverter: (v) => v };
}
const baseCellDataType = this.dataTypeSvc?.getBaseDataType(column);
switch (baseCellDataType) {
case "dateString":
params = {
valueConverter: this.dataTypeSvc?.getDateParserFunction(column) ?? ((v) => v)
};
break;
case "object":
if (column.getColDef().filterValueGetter) {
params = { valueConverter: (v) => v };
} else {
params = {
valueConverter: (value, node) => this.valueSvc.formatValue(column, node, value) ?? (typeof value.toString === "function" ? value.toString() : "")
};
}
break;
case "text":
case void 0:
params = { valueConverter: (v) => _toStringOrNull(v) };
break;
default:
params = { valueConverter: (v) => v };
break;
}
const { filterParams } = column.getColDef();
if (filterParams) {
["caseSensitive", "includeBlanksInEquals", "includeBlanksInLessThan", "includeBlanksInGreaterThan"].forEach(
(param) => {
const paramValue = filterParams[param];
if (paramValue) {
params[param] = paramValue;
}
}
);
}
this.expressionEvaluatorParams[colId] = params;
return params;
}
getColumnDetails(colId) {
const column = this.colModel.getColDefCol(colId) ?? void 0;
const baseCellDataType = (column ? this.dataTypeSvc?.getBaseDataType(column) : void 0) ?? "text";
return { column, baseCellDataType };
}
generateExpressionOperators() {
const translate = (key, variableValues) => this.translate(key, variableValues);
return {
text: new TextFilterExpressionOperators({ translate }),
boolean: new BooleanFilterExpressionOperators({ translate }),
object: new TextFilterExpressionOperators({ translate }),
number: new ScalarFilterExpressionOperators({ translate, equals: (v, o) => v === o }),
date: new ScalarFilterExpressionOperators({
translate,
equals: (v, o) => v.getTime() === o.getTime()
}),
dateString: new ScalarFilterExpressionOperators({
translate,
equals: (v, o) => v.getTime() === o.getTime()
})
};
}
getColumnValue({ displayValue }) {
return `${COL_FILTER_EXPRESSION_START_CHAR}${displayValue}${COL_FILTER_EXPRESSION_END_CHAR}`;
}
generateExpressionJoinOperators() {
return {
AND: this.translate("advancedFilterAnd"),
OR: this.translate("advancedFilterOr")
};
}
getActiveOperators(column) {
const filterOptions = column.getColDef().filterParams?.filterOptions;
if (!filterOptions) {
return void 0;
}
const isValid = filterOptions.every((filterOption) => typeof filterOption === "string");
return isValid ? filterOptions : void 0;
}
resetColumnCaches() {
this.columnAutocompleteEntries = null;
this.columnNameToIdMap = {};
this.expressionEvaluatorParams = {};
}
};
// packages/ag-grid-enterprise/src/advancedFilter/advancedFilterService.ts
import { BeanStub as BeanStub7, _exists as _exists9, _isClientSideRowModel, _isServerSideRowModel, _warn as _warn5 } from "ag-grid-community";
// packages/ag-grid-enterprise/src/advancedFilter/advancedFilterCtrl.ts
import { BeanStub as BeanStub6, _getAbsoluteHeight, _getAbsoluteWidth, _removeFromParent as _removeFromParent2 } from "ag-grid-community";
// packages/ag-grid-enterprise/src/widgets/agDialog.ts
import {
Component as Component3,
TabGuardFeature,
_createIconNoSpan as _createIconNoSpan2,
_findNextFocusableElement,
_focusNextGridCoreContainer,
_setDisplayed as _setDisplayed2
} from "ag-grid-community";
// packages/ag-grid-enterprise/src/widgets/agPanel.ts
import {
Component as Component2,
PositionableFeature,
RefPlaceholder as RefPlaceholder2,
_createIconNoSpan,
_getActiveDomElement,
_getInnerHeight,
_getInnerWidth,
_isVisible,
_setDisplayed
} from "ag-grid-community";
// packages/ag-grid-enterprise/src/widgets/agPanel.css-GENERATED.ts
var agPanelCSS = (
/*css*/
`.ag-panel{background-color:var(--ag-panel-background-color);display:flex;flex-direction:column;overflow:hidden;position:relative}.ag-dialog{border:var(--ag-dialog-border);border-radius:var(--ag-border-radius);box-shadow:var(--ag-dialog-shadow);position:absolute}.ag-panel-title-bar{align-items:center;background-color:var(--ag-panel-title-bar-background-color);border-bottom:var(--ag-panel-title-bar-border);color:var(--ag-panel-title-bar-text-color);cursor:default;display:flex;flex:none;font-weight:var(--ag-panel-title-bar-font-weight);height:var(--ag-header-height);padding:var(--ag-spacing) var(--ag-cell-horizontal-padding)}.ag-panel-title-bar-button{color:var(--ag-panel-title-bar-icon-color);cursor:pointer}:where(.ag-ltr) .ag-panel-title-bar-button{margin-left:calc(var(--ag-spacing)*2);margin-right:var(--ag-spacing)}:where(.ag-rtl) .ag-panel-title-bar-button{margin-left:var(--ag-spacing);margin-right:calc(var(--ag-spacing)*2)}.ag-panel-title-bar-title{flex:1 1 auto}.ag-panel-title-bar-buttons{display:flex}.ag-panel-content-wrapper{display:flex;flex:1 1 auto;overflow:hidden;position:relative}:where(.ag-dragging-fill-handle) .ag-dialog,:where(.ag-dragging-range-handle) .ag-dialog{opacity:.7;pointer-events:none}`
);
// packages/ag-grid-enterprise/src/widgets/agPanel.ts
function getTemplate(config) {
const cssIdentifier = config.cssIdentifier || "default";
return (
/* html */
``
);
}
var CLOSE_BTN_TEMPLATE = (
/* html */
``
);
var AgPanel = class extends Component2 {
constructor(config) {
super(getTemplate(config));
this.config = config;
this.closable = true;
this.eContentWrapper = RefPlaceholder2;
this.eTitleBar = RefPlaceholder2;
this.eTitleBarButtons = RefPlaceholder2;
this.eTitle = RefPlaceholder2;
this.registerCSS(agPanelCSS);
}
postConstruct() {
const {
component,
closable,
hideTitleBar,
title,
minWidth = 250,
width,
minHeight = 250,
height,
centered,
popup,
x,
y
} = this.config;
this.positionableFeature = new PositionableFeature(this.getGui(), {
minWidth,
width,
minHeight,
height,
centered,
x,
y,
popup,
calculateTopBuffer: () => this.positionableFeature.getHeight() - this.getBodyHeight()
});
this.createManagedBean(this.positionableFeature);
const eGui = this.getGui();
if (component) {
this.setBodyComponent(component);
}
if (!hideTitleBar) {
if (title) {
this.setTitle(title);
}
this.setClosable(closable != null ? closable : this.closable);
} else {
_setDisplayed(this.eTitleBar, false);
}
this.addManagedElementListeners(this.eTitleBar, {
mousedown: (e) => {
if (eGui.contains(e.relatedTarget) || eGui.contains(_getActiveDomElement(this.beans)) || this.eTitleBarButtons.contains(e.target)) {
e.preventDefault();
return;
}
const focusEl = this.eContentWrapper.querySelector(
"button, [href], input, select, textarea, [tabindex]"
);
if (focusEl) {
focusEl.focus();
}
}
});
if (popup && this.positionableFeature.isPositioned()) {
return;
}
if (this.renderComponent) {
this.renderComponent();
}
this.positionableFeature.initialisePosition();
this.eContentWrapper.style.height = "0";
}
renderComponent() {
const eGui = this.getGui();
eGui.focus();
this.close = () => {
eGui.parentElement.removeChild(eGui);
this.destroy();
};
}
getHeight() {
return this.positionableFeature.getHeight();
}
setHeight(height) {
this.positionableFeature.setHeight(height);
}
getWidth() {
return this.positionableFeature.getWidth();
}
setWidth(width) {
this.positionableFeature.setWidth(width);
}
setClosable(closable) {
if (closable !== this.closable) {
this.closable = closable;
}
if (closable) {
const closeButtonComp = this.closeButtonComp = new Component2(CLOSE_BTN_TEMPLATE);
this.createBean(closeButtonComp);
const eGui = closeButtonComp.getGui();
const child = _createIconNoSpan("close", this.beans);
child.classList.add("ag-panel-title-bar-button-icon");
eGui.appendChild(child);
this.addTitleBarButton(closeButtonComp);
closeButtonComp.addManagedElementListeners(eGui, { click: this.onBtClose.bind(this) });
} else if (this.closeButtonComp) {
const eGui = this.closeButtonComp.getGui();
eGui.parentElement.removeChild(eGui);
this.closeButtonComp = this.destroyBean(this.closeButtonComp);
}
}
setBodyComponent(bodyComponent) {
bodyComponent.setParentComponent(this);
this.eContentWrapper.appendChild(bodyComponent.getGui());
}
addTitleBarButton(button, position) {
const eTitleBarButtons = this.eTitleBarButtons;
const buttons = eTitleBarButtons.children;
const len = buttons.length;
if (position == null) {
position = len;
}
position = Math.max(0, Math.min(position, len));
button.addCssClass("ag-panel-title-bar-button");
const eGui = button.getGui();
if (position === 0) {
eTitleBarButtons.insertAdjacentElement("afterbegin", eGui);
} else if (position === len) {
eTitleBarButtons.insertAdjacentElement("beforeend", eGui);
} else {
buttons[position - 1].insertAdjacentElement("afterend", eGui);
}
button.setParentComponent(this);
}
getBodyHeight() {
return _getInnerHeight(this.eContentWrapper);
}
getBodyWidth() {
return _getInnerWidth(this.eContentWrapper);
}
setTitle(title) {
this.eTitle.innerText = title;
}
// called when user hits the 'x' in the top right
onBtClose() {
this.close();
}
destroy() {
if (this.closeButtonComp) {
this.closeButtonComp = this.destroyBean(this.closeButtonComp);
}
const eGui = this.getGui();
if (eGui && _isVisible(eGui)) {
this.close();
}
super.destroy();
}
};
// packages/ag-grid-enterprise/src/widgets/agDialog.ts
var AgDialog = class extends AgPanel {
constructor(config) {
super({ ...config, popup: true });
this.isMaximizable = false;
this.isMaximized = false;
this.maximizeListeners = [];
this.resizeListenerDestroy = null;
this.lastPosition = {
x: 0,
y: 0,
width: 0,
height: 0
};
}
wireBeans(beans) {
this.popupSvc = beans.popupSvc;
}
postConstruct() {
const eGui = this.getGui();
const { movable, resizable, maximizable, modal, postProcessPopupParams } = this.config;
this.addCssClass("ag-dialog");
super.postConstruct();
if (postProcessPopupParams) {
const { type, eventSource, column, mouseEvent, rowNode } = postProcessPopupParams;
this.popupSvc?.callPostProcessPopup(type, eGui, eventSource, mouseEvent, column, rowNode);
}
this.tabGuardFeature = this.createManagedBean(new TabGuardFeature(this));
this.tabGuardFeature.initialiseTabGuard({
isFocusableContainer: true,
onFocusIn: () => {
this.popupSvc?.bringPopupToFront(eGui);
},
onTabKeyDown: (e) => {
if (modal) {
return;
}
const backwards = e.shiftKey;
const nextFocusableElement = _findNextFocusableElement(this.beans, eGui, false, backwards);
if (!nextFocusableElement || this.tabGuardFeature.getTabGuardCtrl().isTabGuard(nextFocusableElement)) {
if (_focusNextGridCoreContainer(this.beans, backwards)) {
e.preventDefault();
}
}
}
});
if (movable) {
this.setMovable(movable);
}
if (maximizable) {
this.setMaximizable(maximizable);
}
if (resizable) {
this.setResizable(resizable);
}
if (!this.config.modal) {
const gridCtrl = this.beans.ctrlsSvc.get("gridCtrl");
gridCtrl.addFocusableContainer(this);
this.addDestroyFunc(() => gridCtrl.removeFocusableContainer(this));
}
}
setAllowFocus(allowFocus) {
this.tabGuardFeature.getTabGuardCtrl().setAllowFocus(allowFocus);
}
renderComponent() {
const eGui = this.getGui();
const { alwaysOnTop, modal, title, afterGuiAttached } = this.config;
const translate = this.getLocaleTextFunc();
const addPopupRes = this.popupSvc?.addPopup({
modal,
eChild: eGui,
closeOnEsc: true,
closedCallback: this.onClosed.bind(this),
alwaysOnTop,
ariaLabel: title || translate("ariaLabelDialog", "Dialog"),
afterGuiAttached
});
if (addPopupRes) {
this.close = addPopupRes.hideFunc;
}
}
onClosed(event) {
this.destroy();
this.config.closedCallback?.(event);
}
toggleMaximize() {
const position = this.positionableFeature.getPosition();
if (this.isMaximized) {
const { x, y, width, height } = this.lastPosition;
this.setWidth(width);
this.setHeight(height);
this.positionableFeature.offsetElement(x, y);
} else {
this.lastPosition.width = this.getWidth();
this.lastPosition.height = this.getHeight();
this.lastPosition.x = position.x;
this.lastPosition.y = position.y;
this.positionableFeature.offsetElement(0, 0);
this.setHeight("100%");
this.setWidth("100%");
}
this.isMaximized = !this.isMaximized;
this.refreshMaximizeIcon();
}
refreshMaximizeIcon() {
_setDisplayed2(this.maximizeIcon, !this.isMaximized);
_setDisplayed2(this.minimizeIcon, this.isMaximized);
}
clearMaximizebleListeners() {
if (this.maximizeListeners.length) {
this.maximizeListeners.forEach((destroyListener) => destroyListener());
this.maximizeListeners.length = 0;
}
if (this.resizeListenerDestroy) {
this.resizeListenerDestroy();
this.resizeListenerDestroy = null;
}
}
destroy() {
this.maximizeButtonComp = this.destroyBean(this.maximizeButtonComp);
this.clearMaximizebleListeners();
super.destroy();
}
setResizable(resizable) {
this.positionableFeature.setResizable(resizable);
}
setMovable(movable) {
this.positionableFeature.setMovable(movable, this.eTitleBar);
}
setMaximizable(maximizable) {
if (!maximizable) {
this.clearMaximizebleListeners();
if (this.maximizeButtonComp) {
this.destroyBean(this.maximizeButtonComp);
this.maximizeButtonComp = this.maximizeIcon = this.minimizeIcon = void 0;
}
return;
}
const eTitleBar = this.eTitleBar;
if (!eTitleBar || maximizable === this.isMaximizable) {
return;
}
const maximizeButtonComp = this.buildMaximizeAndMinimizeElements();
this.refreshMaximizeIcon();
maximizeButtonComp.addManagedElementListeners(maximizeButtonComp.getGui(), {
click: this.toggleMaximize.bind(this)
});
this.addTitleBarButton(maximizeButtonComp, 0);
this.maximizeListeners.push(
...this.addManagedElementListeners(eTitleBar, {
dblclick: this.toggleMaximize.bind(this)
})
);
[this.resizeListenerDestroy] = this.addManagedListeners(this.positionableFeature, {
resize: () => {
this.isMaximized = false;
this.refreshMaximizeIcon();
}
});
}
buildMaximizeAndMinimizeElements() {
const maximizeButtonComp = this.maximizeButtonComp = this.createBean(
new Component3(
/* html */
``
)
);
const eGui = maximizeButtonComp.getGui();
this.maximizeIcon = _createIconNoSpan2("maximize", this.beans);
eGui.appendChild(this.maximizeIcon);
this.maximizeIcon.classList.add("ag-panel-title-bar-button-icon");
this.minimizeIcon = _createIconNoSpan2("minimize", this.beans);
eGui.appendChild(this.minimizeIcon);
this.minimizeIcon.classList.add("ag-panel-title-bar-button-icon");
return maximizeButtonComp;
}
};
// packages/ag-grid-enterprise/src/advancedFilter/advancedFilterComp.ts
import { Component as Component6, RefPlaceholder as RefPlaceholder6, _createIconNoSpan as _createIconNoSpan3, _makeNull as _makeNull2, _setDisabled } from "ag-grid-community";
// packages/ag-grid-enterprise/src/advancedFilter/autocomplete/agAutocomplete.ts
import {
AgInputTextFieldSelector,
Component as Component5,
KeyCode as KeyCode3,
RefPlaceholder as RefPlaceholder5,
_isNothingFocused,
_makeNull
} from "ag-grid-community";
// packages/ag-grid-enterprise/src/advancedFilter/autocomplete/agAutocomplete.css-GENERATED.ts
var agAutocompleteCSS = (
/*css*/
`.ag-autocomplete{align-items:center;display:flex;width:100%;>*{flex:1 1 auto}}.ag-autocomplete-list-popup{background-color:var(--ag-background-color);border-radius:var(--ag-border-radius);box-shadow:var(--ag-dropdown-shadow);padding:0;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none}.ag-autocomplete-list{height:calc(var(--ag-row-height)*6.5);min-width:200px;position:relative;width:100%}.ag-autocomplete-virtual-list-item{cursor:default;display:flex;height:var(--ag-list-item-height);&:focus-visible:after{content:none}&:hover{background-color:var(--ag-row-hover-color)}}.ag-autocomplete-row{align-items:center;display:flex;flex:1 1 auto;overflow:hidden}.ag-autocomplete-row-label{margin:0 var(--ag-widget-container-horizontal-padding);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ag-autocomplete-row-selected{background-color:var(--ag-selected-row-background-color)}`
);
// packages/ag-grid-enterprise/src/advancedFilter/autocomplete/agAutocompleteList.ts
import { KeyCode as KeyCode2, PopupComponent, RefPlaceholder as RefPlaceholder4, _exists as _exists3, _fuzzySuggestions } from "ag-grid-community";
// packages/ag-grid-enterprise/src/widgets/virtualList.ts
import {
KeyCode,
RefPlaceholder as RefPlaceholder3,
TabGuardComp,
_getAriaPosInSet,
_observeResize,
_requestAnimationFrame,
_setAriaLabel,
_setAriaPosInSet,
_setAriaRole,
_setAriaSetSize,
_stopPropagationForAgGrid,
_waitUntil,
_warn as _warn4
} from "ag-grid-community";
function getVirtualListTemplate(cssIdentifier) {
return (
/* html */
`
`
);
}
var VirtualList = class extends TabGuardComp {
constructor(params) {
super(getVirtualListTemplate(params?.cssIdentifier || "default"));
this.renderedRows = /* @__PURE__ */ new Map();
this.rowHeight = 20;
this.pageSize = -1;
this.isScrolling = false;
this.isHeightFromTheme = true;
this.eContainer = RefPlaceholder3;
this.awaitStableCallbacks = [];
const { cssIdentifier = "default", ariaRole = "listbox", listName } = params || {};
this.cssIdentifier = cssIdentifier;
this.ariaRole = ariaRole;
this.listName = listName;
}
wireBeans(beans) {
this.environment = beans.environment;
}
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.setAriaProperties();
this.addManagedEventListeners({ gridStylesChanged: this.onGridStylesChanged.bind(this) });
}
onGridStylesChanged(e) {
if (e.listItemHeightChanged) {
this.rowHeight = this.getItemHeight();
this.refresh();
}
}
setAriaProperties() {
const translate = this.getLocaleTextFunc();
const listName = translate("ariaDefaultListName", this.listName || "List");
const ariaEl = this.eContainer;
_setAriaRole(ariaEl, this.ariaRole);
_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) {
switch (e.key) {
case KeyCode.UP:
case KeyCode.DOWN:
e.preventDefault();
this.navigate(e.key === KeyCode.UP);
break;
case KeyCode.PAGE_HOME:
case KeyCode.PAGE_END:
case KeyCode.PAGE_UP:
case KeyCode.PAGE_DOWN:
if (this.navigateToPage(e.key) !== null) {
e.preventDefault();
}
break;
}
}
onTabKeyDown(e) {
_stopPropagationForAgGrid(e);
this.forceFocusOutOfContainer(e.shiftKey);
}
navigate(up) {
if (this.lastFocusedRowIndex == null) {
return;
}
const nextRow = this.lastFocusedRowIndex + (up ? -1 : 1);
if (nextRow < 0 || nextRow >= this.model.getRowCount()) {
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.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) {
_warn4(229, { index });
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.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.eContainer.clientHeight >= rowCount * this.rowHeight,
() => {
if (!this.isAlive()) {
return;
}
const callbacks = this.awaitStableCallbacks;
this.awaitStableCallbacks = [];
callbacks.forEach((c) => 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;
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 eDiv = document.createElement("div");
eDiv.classList.add("ag-virtual-list-item", `ag-${this.cssIdentifier}-virtual-list-item`);
_setAriaRole(eDiv, this.ariaRole === "tree" ? "treeitem" : "option");
_setAriaSetSize(eDiv, this.model.getRowCount());
_setAriaPosInSet(eDiv, rowIndex + 1);
eDiv.setAttribute("tabindex", "-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);
this.eContainer.removeChild(component.eDiv);
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/advancedFilter/autocomplete/agAutocompleteRow.ts
import { Component as Component4, _escapeString as _escapeString6, _exists as _exists2 } from "ag-grid-community";
var AgAutocompleteRow = class extends Component4 {
constructor() {
super(
/* html */
`
`
);
this.hasHighlighting = false;
}
setState(value, selected) {
this.value = value;
this.render();
this.updateSelected(selected);
}
updateSelected(selected) {
this.addOrRemoveCssClass("ag-autocomplete-row-selected", selected);
}
setSearchString(searchString) {
let keepHighlighting = false;
if (_exists2(searchString)) {
const index = this.value?.toLocaleLowerCase().indexOf(searchString.toLocaleLowerCase());
if (index >= 0) {
keepHighlighting = true;
this.hasHighlighting = true;
const highlightEndIndex = index + searchString.length;
const startPart = _escapeString6(this.value.slice(0, index));
const highlightedPart = _escapeString6(this.value.slice(index, highlightEndIndex));
const endPart = _escapeString6(this.value.slice(highlightEndIndex));
this.getGui().lastElementChild.innerHTML = `${startPart}
${highlightedPart}${endPart}`;
}
}
if (!keepHighlighting && this.hasHighlighting) {
this.hasHighlighting = false;
this.render();
}
}
render() {
this.getGui().lastElementChild.innerHTML = _escapeString6(this.value) ?? " ";
}
};
// packages/ag-grid-enterprise/src/advancedFilter/autocomplete/agAutocompleteList.ts
var AgAutocompleteList = class extends PopupComponent {
constructor(params) {
super(
/* html */
`