@ammarkhalidfarooq/dashboard-package 0.6.71 → 0.6.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1450,15 +1450,47 @@ var parseDonationTypeChartData = function parseDonationTypeChartData(donationTyp
1450
1450
  return _objectSpread2(_objectSpread2({}, empty), parseDonationTypeTotals(donationTypeData));
1451
1451
  };
1452
1452
 
1453
+ /** Normalizes refundAndChargeBacks from API for PDF + report cards. */
1454
+ var parseRefundsChargebacks = function parseRefundsChargebacks(refundsData) {
1455
+ var _raw$refundRate, _raw$chargebackRate, _raw$totalRefundedAmo, _raw$totalRefunds, _raw$totalChargebacks, _raw$wonChargebacks, _raw$lostChargebacks, _raw$growthPercentage, _raw$totalRevenue;
1456
+ var raw = refundsData && _typeof(refundsData) === "object" ? refundsData : {};
1457
+ return {
1458
+ refundRate: Number((_raw$refundRate = raw.refundRate) !== null && _raw$refundRate !== void 0 ? _raw$refundRate : 0),
1459
+ chargebackRate: Number((_raw$chargebackRate = raw.chargebackRate) !== null && _raw$chargebackRate !== void 0 ? _raw$chargebackRate : 0),
1460
+ totalRefundedAmount: Number((_raw$totalRefundedAmo = raw.totalRefundedAmount) !== null && _raw$totalRefundedAmo !== void 0 ? _raw$totalRefundedAmo : 0),
1461
+ totalRefunds: Number((_raw$totalRefunds = raw.totalRefunds) !== null && _raw$totalRefunds !== void 0 ? _raw$totalRefunds : 0),
1462
+ totalChargebacks: Number((_raw$totalChargebacks = raw.totalChargebacks) !== null && _raw$totalChargebacks !== void 0 ? _raw$totalChargebacks : 0),
1463
+ wonChargebacks: Number((_raw$wonChargebacks = raw.wonChargebacks) !== null && _raw$wonChargebacks !== void 0 ? _raw$wonChargebacks : 0),
1464
+ lostChargebacks: Number((_raw$lostChargebacks = raw.lostChargebacks) !== null && _raw$lostChargebacks !== void 0 ? _raw$lostChargebacks : 0),
1465
+ growthPercentage: Number((_raw$growthPercentage = raw.growthPercentage) !== null && _raw$growthPercentage !== void 0 ? _raw$growthPercentage : 0),
1466
+ chartData: Array.isArray(raw.chartData) ? raw.chartData : [],
1467
+ totalRevenue: Number((_raw$totalRevenue = raw.totalRevenue) !== null && _raw$totalRevenue !== void 0 ? _raw$totalRevenue : 0)
1468
+ };
1469
+ };
1470
+
1471
+ /** Median / top-decile for avg donation KPI (not shown in Overall section UI). */
1472
+ var parseAvgDonationDetail = function parseAvgDonationDetail() {
1473
+ var _apiData$overviewStat, _ref, _ref2, _ref3, _ref4, _ref5, _overview$medianDonat, _ref6, _ref7, _ref8, _ref9, _ref0, _overview$topDecileDo;
1474
+ var apiData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1475
+ var overview = (apiData === null || apiData === void 0 || (_apiData$overviewStat = apiData.overviewStats) === null || _apiData$overviewStat === void 0 ? void 0 : _apiData$overviewStat.overview) || {};
1476
+ var median = Number((_ref = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_overview$medianDonat = overview === null || overview === void 0 ? void 0 : overview.medianDonation) !== null && _overview$medianDonat !== void 0 ? _overview$medianDonat : overview === null || overview === void 0 ? void 0 : overview.medianGift) !== null && _ref5 !== void 0 ? _ref5 : overview === null || overview === void 0 ? void 0 : overview.median) !== null && _ref4 !== void 0 ? _ref4 : apiData === null || apiData === void 0 ? void 0 : apiData.medianGift) !== null && _ref3 !== void 0 ? _ref3 : apiData === null || apiData === void 0 ? void 0 : apiData.medianDonation) !== null && _ref2 !== void 0 ? _ref2 : apiData === null || apiData === void 0 ? void 0 : apiData.median) !== null && _ref !== void 0 ? _ref : 0);
1477
+ var topDecile = Number((_ref6 = (_ref7 = (_ref8 = (_ref9 = (_ref0 = (_overview$topDecileDo = overview === null || overview === void 0 ? void 0 : overview.topDecileDonation) !== null && _overview$topDecileDo !== void 0 ? _overview$topDecileDo : overview === null || overview === void 0 ? void 0 : overview.topDecileGift) !== null && _ref0 !== void 0 ? _ref0 : overview === null || overview === void 0 ? void 0 : overview.topDecile) !== null && _ref9 !== void 0 ? _ref9 : apiData === null || apiData === void 0 ? void 0 : apiData.topDecileGift) !== null && _ref8 !== void 0 ? _ref8 : apiData === null || apiData === void 0 ? void 0 : apiData.topDecileDonation) !== null && _ref7 !== void 0 ? _ref7 : apiData === null || apiData === void 0 ? void 0 : apiData.topDecile) !== null && _ref6 !== void 0 ? _ref6 : 0);
1478
+ return {
1479
+ median: median,
1480
+ topDecile: topDecile
1481
+ // detail: `Median $${formatNumber(median)} · top decile $${formatNumber(topDecile)}`,
1482
+ };
1483
+ };
1484
+
1453
1485
  /** Mirrors PaidDonorGeographyCard row mapping from donorGeography. */
1454
1486
  var parseDonorGeographyList = function parseDonorGeographyList(donorGeographyData) {
1455
1487
  var rawCountries = Array.isArray(donorGeographyData) ? donorGeographyData : (donorGeographyData === null || donorGeographyData === void 0 ? void 0 : donorGeographyData.countries) || (donorGeographyData === null || donorGeographyData === void 0 ? void 0 : donorGeographyData.data) || [];
1456
1488
  return rawCountries.map(function (item) {
1457
- var _item$percentage, _ref, _ref2, _item$value;
1489
+ var _item$percentage, _ref1, _ref10, _item$value;
1458
1490
  return {
1459
1491
  country: item.countryName || item.country || item.name || "Unknown",
1460
1492
  percentage: typeof item.percentage === "number" ? item.percentage : Number((_item$percentage = item.percentage) !== null && _item$percentage !== void 0 ? _item$percentage : 0),
1461
- value: item.donations !== undefined ? item.donations : (_ref = (_ref2 = (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.totalDonors) !== null && _ref2 !== void 0 ? _ref2 : item.donors) !== null && _ref !== void 0 ? _ref : 0
1493
+ value: item.donations !== undefined ? item.donations : (_ref1 = (_ref10 = (_item$value = item.value) !== null && _item$value !== void 0 ? _item$value : item.totalDonors) !== null && _ref10 !== void 0 ? _ref10 : item.donors) !== null && _ref1 !== void 0 ? _ref1 : 0
1462
1494
  };
1463
1495
  });
1464
1496
  };
@@ -1474,12 +1506,13 @@ var getActiveFilterChips = function getActiveFilterChips(apiData) {
1474
1506
  return ["Status: Successful", "Country: United States, UAE", "Amount: $50 – $5,000"];
1475
1507
  };
1476
1508
  var buildReportData = function buildReportData() {
1477
- var _apiData$overviewStat, _overview$totalRevenu, _overview$netRevenue, _overview$totalDonati, _overview$overallAVGD, _overview$conversionR, _apiData$totalVisits, _overview$overallAVGD2, _growth$overallAVGDon, _growth$totalRevenue, _growth$netRevenue, _growth$totalDonation, _growth$overallAVGDon2, _apiData$medianGift, _apiData$topDecileGif, _apiData$roasCard, _apiData$roasCardPrev, _apiData$adSpend, _apiData$attributedRe, _growth$conversionRat, _refundsRaw$refundRat, _refundsRaw$refundRat2, _refundsRaw$refundCou, _apiData$overviewStat2, _growth$totalRevenue2;
1509
+ var _apiData$overviewStat2, _overview$totalRevenu, _overview$netRevenue, _overview$totalDonati, _overview$overallAVGD, _overview$conversionR, _apiData$totalVisits, _overview$overallAVGD2, _growth$overallAVGDon, _growth$totalRevenue, _growth$netRevenue, _growth$totalDonation, _growth$overallAVGDon2, _apiData$roasCard, _apiData$roasCardPrev, _apiData$adSpend, _apiData$attributedRe, _growth$conversionRat, _apiData$overviewStat3, _growth$totalRevenue2;
1478
1510
  var apiData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1479
- var dateName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "Last Period";
1480
- var overview = (apiData === null || apiData === void 0 || (_apiData$overviewStat = apiData.overviewStats) === null || _apiData$overviewStat === void 0 ? void 0 : _apiData$overviewStat.overview) || {};
1511
+ var overview = (apiData === null || apiData === void 0 || (_apiData$overviewStat2 = apiData.overviewStats) === null || _apiData$overviewStat2 === void 0 ? void 0 : _apiData$overviewStat2.overview) || {};
1481
1512
  var growth = (overview === null || overview === void 0 ? void 0 : overview.growthPercentage) || {};
1482
1513
  var refundsRaw = (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || {};
1514
+ var refunds = parseRefundsChargebacks(refundsRaw);
1515
+ var avgDonationDetail = parseAvgDonationDetail(apiData);
1483
1516
  var totalRaised = Number((_overview$totalRevenu = overview === null || overview === void 0 ? void 0 : overview.totalRevenue) !== null && _overview$totalRevenu !== void 0 ? _overview$totalRevenu : 240938);
1484
1517
  var netRaised = Number((_overview$netRevenue = overview === null || overview === void 0 ? void 0 : overview.netRevenue) !== null && _overview$netRevenue !== void 0 ? _overview$netRevenue : 222300);
1485
1518
  var totalDonors = Number((_overview$totalDonati = overview === null || overview === void 0 ? void 0 : overview.totalDonations) !== null && _overview$totalDonati !== void 0 ? _overview$totalDonati : 215);
@@ -1510,7 +1543,7 @@ var buildReportData = function buildReportData() {
1510
1543
  var retPct = totalMix > 0 ? 100 - newPct : 0;
1511
1544
  var hero = {
1512
1545
  value: "$".concat(formatNumber(totalRaised)),
1513
- trend: "".concat(formatTrend((_growth$totalRevenue = growth === null || growth === void 0 ? void 0 : growth.totalRevenue) !== null && _growth$totalRevenue !== void 0 ? _growth$totalRevenue : 18), " vs ").concat(dateName || "last month"),
1546
+ trend: "".concat(formatTrend((_growth$totalRevenue = growth === null || growth === void 0 ? void 0 : growth.totalRevenue) !== null && _growth$totalRevenue !== void 0 ? _growth$totalRevenue : 18), " vs pp"),
1514
1547
  detail: "".concat(passThrough, " \xB7 ").concat(formatNumber(totalDonors), " donors \xB7 $").concat(formatNumber(avgDonation), " avg \xB7 ").concat(formatNumber(totalVisits), " visits")
1515
1548
  };
1516
1549
  var metrics = [{
@@ -1526,8 +1559,8 @@ var buildReportData = function buildReportData() {
1526
1559
  }, {
1527
1560
  title: "Avg Donation",
1528
1561
  value: "$".concat(formatNumber(avgDonation)),
1529
- trend: formatTrend((_growth$overallAVGDon2 = growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations) !== null && _growth$overallAVGDon2 !== void 0 ? _growth$overallAVGDon2 : 8.4),
1530
- detail: "Median $".concat(formatNumber((_apiData$medianGift = apiData === null || apiData === void 0 ? void 0 : apiData.medianGift) !== null && _apiData$medianGift !== void 0 ? _apiData$medianGift : 75), " \xB7 top decile $").concat(formatNumber((_apiData$topDecileGif = apiData === null || apiData === void 0 ? void 0 : apiData.topDecileGift) !== null && _apiData$topDecileGif !== void 0 ? _apiData$topDecileGif : 850))
1562
+ trend: formatTrend((_growth$overallAVGDon2 = growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations) !== null && _growth$overallAVGDon2 !== void 0 ? _growth$overallAVGDon2 : 0),
1563
+ detail: avgDonationDetail.detail
1531
1564
  }, {
1532
1565
  title: "ROAS",
1533
1566
  value: "".concat(formatNumber((_apiData$roasCard = apiData === null || apiData === void 0 ? void 0 : apiData.roasCard) !== null && _apiData$roasCard !== void 0 ? _apiData$roasCard : 0), "x"),
@@ -1540,18 +1573,18 @@ var buildReportData = function buildReportData() {
1540
1573
  detail: "".concat(formatNumber(totalDonors), " from ").concat(formatNumber(totalVisits), " visits")
1541
1574
  }, {
1542
1575
  title: "Refund Rate",
1543
- value: "".concat(Number((_refundsRaw$refundRat = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRate) !== null && _refundsRaw$refundRat !== void 0 ? _refundsRaw$refundRat : 0.84).toFixed(2), "%"),
1544
- trend: formatTrend((_refundsRaw$refundRat2 = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRateChange) !== null && _refundsRaw$refundRat2 !== void 0 ? _refundsRaw$refundRat2 : -0.3, "pp"),
1545
- detail: "".concat(formatNumber((_refundsRaw$refundCou = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundCount) !== null && _refundsRaw$refundCou !== void 0 ? _refundsRaw$refundCou : 2), " refunds this period"),
1576
+ value: "".concat(refunds.refundRate.toFixed(2), "%"),
1577
+ trend: formatTrend(refunds.growthPercentage),
1578
+ detail: "".concat(formatNumber(refunds.totalRefunds), " refunds this period"),
1546
1579
  trendPositiveWhenNegative: true
1547
1580
  }];
1548
- var stackedTR = (apiData === null || apiData === void 0 || (_apiData$overviewStat2 = apiData.overviewStats) === null || _apiData$overviewStat2 === void 0 ? void 0 : _apiData$overviewStat2.totalRaised) || {};
1581
+ var stackedTR = (apiData === null || apiData === void 0 || (_apiData$overviewStat3 = apiData.overviewStats) === null || _apiData$overviewStat3 === void 0 ? void 0 : _apiData$overviewStat3.totalRaised) || {};
1549
1582
  var hasStackedData = (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.paidAds) || (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.email) || (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.organic);
1550
1583
  var mainChart = {
1551
1584
  label: "Total revenue trend",
1552
1585
  subtitle: "Last 30 days · daily aggregation",
1553
1586
  value: "$".concat(formatNumber(totalRaised)),
1554
- trend: "".concat(formatTrend((_growth$totalRevenue2 = growth === null || growth === void 0 ? void 0 : growth.totalRevenue) !== null && _growth$totalRevenue2 !== void 0 ? _growth$totalRevenue2 : 18), " vs ").concat(dateName || "last month"),
1587
+ trend: "".concat(formatTrend((_growth$totalRevenue2 = growth === null || growth === void 0 ? void 0 : growth.totalRevenue) !== null && _growth$totalRevenue2 !== void 0 ? _growth$totalRevenue2 : 18), " vs pp"),
1555
1588
  hideControls: true,
1556
1589
  stacked: true,
1557
1590
  colors: ["#6366F1", "#10B981", "#06B6D4"],
@@ -1676,7 +1709,7 @@ var buildReportData = function buildReportData() {
1676
1709
  upsellData: (apiData === null || apiData === void 0 ? void 0 : apiData.upSellDetails) || {},
1677
1710
  downsellData: (apiData === null || apiData === void 0 ? void 0 : apiData.downSellDetails) || {},
1678
1711
  referralData: (apiData === null || apiData === void 0 ? void 0 : apiData.referralDetails) || {},
1679
- refundsChargebacksData: (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || []
1712
+ refundsChargebacksData: refunds
1680
1713
  };
1681
1714
  };
1682
1715
 
@@ -2162,6 +2195,21 @@ var DonorGeographyPanel = function DonorGeographyPanel(_ref9) {
2162
2195
  })
2163
2196
  });
2164
2197
  };
2198
+ var formatDonationTypeCategory = function formatDonationTypeCategory(label, slotWidth) {
2199
+ var str = String(label !== null && label !== void 0 ? label : "").trim();
2200
+ if (!str) return "";
2201
+ var monthRange = str.match(/^([A-Za-z]{3})-([A-Za-z]{3})(?:\s+\d{2,4})?$/);
2202
+ if (monthRange) {
2203
+ var full = "".concat(monthRange[1], "-").concat(monthRange[2]);
2204
+ var mini = "".concat(monthRange[1][0], "-").concat(monthRange[2][0]);
2205
+ var fullWidth = full.length * 3.1;
2206
+ return fullWidth <= slotWidth - 2 ? full : mini;
2207
+ }
2208
+ var noYear = str.replace(/\s+['']?\d{2,4}$/, "").trim();
2209
+ var maxChars = Math.max(3, Math.floor(slotWidth / 3.1));
2210
+ if (noYear.length <= maxChars) return noYear;
2211
+ return "".concat(noYear.slice(0, Math.max(1, maxChars - 1)), "\u2026");
2212
+ };
2165
2213
  var DonationTypeBarSvg = function DonationTypeBarSvg(_ref0) {
2166
2214
  var _ref0$categories = _ref0.categories,
2167
2215
  categories = _ref0$categories === void 0 ? [] : _ref0$categories,
@@ -2178,13 +2226,15 @@ var DonationTypeBarSvg = function DonationTypeBarSvg(_ref0) {
2178
2226
  var padL = 30;
2179
2227
  var padR = 2;
2180
2228
  var padT = 14;
2181
- var padB = 18;
2229
+ var padB = 20;
2182
2230
  var chartW = width - padL - padR;
2183
2231
  var chartH = height - padT - padB;
2184
2232
  var allVals = [].concat(_toConsumableArray(recurring), _toConsumableArray(oneTime));
2185
2233
  var maxVal = Math.max.apply(Math, _toConsumableArray(allVals).concat([0])) || 1;
2186
2234
  var n = categories.length;
2187
2235
  var yTicks = [0, maxVal / 2, maxVal];
2236
+ var groupW = n > 0 ? chartW / n : chartW;
2237
+ var labelFontSize = n > 3 ? 5 : 5.5;
2188
2238
  if (!n) {
2189
2239
  return /*#__PURE__*/jsxRuntime.jsxs("svg", {
2190
2240
  width: "100%",
@@ -2209,7 +2259,6 @@ var DonationTypeBarSvg = function DonationTypeBarSvg(_ref0) {
2209
2259
  })]
2210
2260
  });
2211
2261
  }
2212
- var groupW = chartW / n;
2213
2262
  var barW = Math.min(groupW * 0.3, 12);
2214
2263
  var baseY = padT + chartH;
2215
2264
  return /*#__PURE__*/jsxRuntime.jsxs("svg", {
@@ -2219,7 +2268,19 @@ var DonationTypeBarSvg = function DonationTypeBarSvg(_ref0) {
2219
2268
  style: {
2220
2269
  display: "block"
2221
2270
  },
2222
- children: [yTicks.map(function (tick, i) {
2271
+ children: [/*#__PURE__*/jsxRuntime.jsx("defs", {
2272
+ children: categories.map(function (_, i) {
2273
+ return /*#__PURE__*/jsxRuntime.jsx("clipPath", {
2274
+ id: "donation-type-cat-clip-".concat(i),
2275
+ children: /*#__PURE__*/jsxRuntime.jsx("rect", {
2276
+ x: padL + i * groupW,
2277
+ y: baseY + 2,
2278
+ width: groupW,
2279
+ height: padB - 2
2280
+ })
2281
+ }, "clip-".concat(i));
2282
+ })
2283
+ }), yTicks.map(function (tick, i) {
2223
2284
  var y = padT + chartH - tick / maxVal * chartH;
2224
2285
  return /*#__PURE__*/jsxRuntime.jsxs("g", {
2225
2286
  children: [/*#__PURE__*/jsxRuntime.jsx("line", {
@@ -2283,11 +2344,12 @@ var DonationTypeBarSvg = function DonationTypeBarSvg(_ref0) {
2283
2344
  })]
2284
2345
  }), /*#__PURE__*/jsxRuntime.jsx("text", {
2285
2346
  x: groupX,
2286
- y: height - 4,
2347
+ y: height - 5,
2287
2348
  textAnchor: "middle",
2288
- fontSize: 7.5,
2349
+ fontSize: labelFontSize,
2289
2350
  fill: "rgba(0,0,0,0.4)",
2290
- children: cat
2351
+ clipPath: "url(#donation-type-cat-clip-".concat(i, ")"),
2352
+ children: formatDonationTypeCategory(cat, groupW)
2291
2353
  })]
2292
2354
  }, "bar-".concat(i));
2293
2355
  })]
@@ -2696,7 +2758,7 @@ var PageFooter = function PageFooter(_ref13) {
2696
2758
 
2697
2759
  // ─── Main component ───────────────────────────────────────────────────────────
2698
2760
  var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref14, ref) {
2699
- var _apiData$overviewStat, _overview$totalRevenu, _overview$netRevenue, _overview$overallAVGD, _overview$conversionR, _apiData$totalVisits, _refundsRaw$refundRat, _refundsRaw$chargebac, _apiData$trafficSourc, _apiData$trafficSourc2, _apiData$trafficSourc3, _metricByTitle$NetRa, _metricByTitle$Total, _metricByTitle$Total2, _metricByTitle$Total3, _metricByTitle$AvgDo, _metricByTitle$AvgDo2, _apiData$medianGift, _apiData$topDecileGif, _apiData$roasCard, _metricByTitle$ROAS, _apiData$roasCardPrev, _metricByTitle$ROAS2, _apiData$adSpend, _apiData$attributedRe, _metricByTitle$Conver, _metricByTitle$Conver2, _metricByTitle$Refund, _metricByTitle$Refund2, _refundsRaw$refundCou, _metricByTitle$Refund3, _mainChart$stacked, _refundsRaw$refundRat2, _ob$growthPercentage, _ob$peakDay, _up$acceptanceGrowth, _up$raisedGrowth, _dn$acceptanceGrowth, _dn$raisedGrowth, _refCard$growthPercen;
2761
+ var _apiData$overviewStat, _overview$totalRevenu, _overview$netRevenue, _overview$overallAVGD, _overview$conversionR, _apiData$totalVisits, _apiData$trafficSourc, _apiData$trafficSourc2, _apiData$trafficSourc3, _metricByTitle$NetRa, _metricByTitle$Total, _metricByTitle$Total2, _metricByTitle$Total3, _metricByTitle$AvgDo, _growth$overallAVGDon, _metricByTitle$AvgDo2, _apiData$roasCard, _metricByTitle$ROAS, _apiData$roasCardPrev, _metricByTitle$ROAS2, _apiData$adSpend, _apiData$attributedRe, _metricByTitle$Conver, _metricByTitle$Conver2, _metricByTitle$Refund, _metricByTitle$Refund2, _metricByTitle$Refund3, _mainChart$stacked, _ob$growthPercentage, _ob$peakDay, _up$acceptanceGrowth, _up$raisedGrowth, _dn$acceptanceGrowth, _dn$raisedGrowth, _refCard$growthPercen;
2700
2762
  var _ref14$apiData = _ref14.apiData,
2701
2763
  apiData = _ref14$apiData === void 0 ? {} : _ref14$apiData,
2702
2764
  _ref14$dateName = _ref14.dateName,
@@ -2768,9 +2830,15 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref14, ref) {
2768
2830
  var convRate = Number((_overview$conversionR = overview === null || overview === void 0 ? void 0 : overview.conversionRate) !== null && _overview$conversionR !== void 0 ? _overview$conversionR : 1.7);
2769
2831
  var totalVisits = Number((_apiData$totalVisits = apiData === null || apiData === void 0 ? void 0 : apiData.totalVisits) !== null && _apiData$totalVisits !== void 0 ? _apiData$totalVisits : 12438);
2770
2832
  var passThrough = totalRaised > 0 ? "".concat((netRaised / totalRaised * 100).toFixed(1), "% pass-through") : "92.3% pass-through";
2771
- var refundsRaw = (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || {};
2772
- var refundRate = Number((_refundsRaw$refundRat = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRate) !== null && _refundsRaw$refundRat !== void 0 ? _refundsRaw$refundRat : 0.84);
2773
- var chargebackRate = Number((_refundsRaw$chargebac = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.chargebackRate) !== null && _refundsRaw$chargebac !== void 0 ? _refundsRaw$chargebac : 0.1);
2833
+ var avgDonationDetail = parseAvgDonationDetail(apiData);
2834
+ var refunds = parseRefundsChargebacks(apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks);
2835
+ var refundRate = refunds.refundRate,
2836
+ chargebackRate = refunds.chargebackRate,
2837
+ growthPercentage = refunds.growthPercentage,
2838
+ totalRefundedAmount = refunds.totalRefundedAmount,
2839
+ totalRefunds = refunds.totalRefunds,
2840
+ totalChargebacks = refunds.totalChargebacks,
2841
+ lostChargebacks = refunds.lostChargebacks;
2774
2842
  var newDonors = donorMix.newDonors,
2775
2843
  returningDonors = donorMix.returningDonors,
2776
2844
  totalMix = donorMix.totalMix,
@@ -2923,8 +2991,8 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref14, ref) {
2923
2991
  }), /*#__PURE__*/jsxRuntime.jsx(KpiCard, {
2924
2992
  title: "Avg Donation",
2925
2993
  value: kpi$(avgDonation),
2926
- trend: ((_metricByTitle$AvgDo = metricByTitle["Avg Donation"]) === null || _metricByTitle$AvgDo === void 0 ? void 0 : _metricByTitle$AvgDo.trend) || signed((growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations) || 8.4),
2927
- detail: ((_metricByTitle$AvgDo2 = metricByTitle["Avg Donation"]) === null || _metricByTitle$AvgDo2 === void 0 ? void 0 : _metricByTitle$AvgDo2.detail) || "Median ".concat(d$((_apiData$medianGift = apiData === null || apiData === void 0 ? void 0 : apiData.medianGift) !== null && _apiData$medianGift !== void 0 ? _apiData$medianGift : 75), " \xB7 top decile ").concat(d$((_apiData$topDecileGif = apiData === null || apiData === void 0 ? void 0 : apiData.topDecileGift) !== null && _apiData$topDecileGif !== void 0 ? _apiData$topDecileGif : 850))
2994
+ trend: ((_metricByTitle$AvgDo = metricByTitle["Avg Donation"]) === null || _metricByTitle$AvgDo === void 0 ? void 0 : _metricByTitle$AvgDo.trend) || signed((_growth$overallAVGDon = growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations) !== null && _growth$overallAVGDon !== void 0 ? _growth$overallAVGDon : 0),
2995
+ detail: ((_metricByTitle$AvgDo2 = metricByTitle["Avg Donation"]) === null || _metricByTitle$AvgDo2 === void 0 ? void 0 : _metricByTitle$AvgDo2.detail) || avgDonationDetail.detail
2928
2996
  })]
2929
2997
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
2930
2998
  style: {
@@ -2945,8 +3013,8 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref14, ref) {
2945
3013
  }), /*#__PURE__*/jsxRuntime.jsx(KpiCard, {
2946
3014
  title: "Refund Rate",
2947
3015
  value: pct(refundRate, 2),
2948
- trend: ((_metricByTitle$Refund = metricByTitle["Refund Rate"]) === null || _metricByTitle$Refund === void 0 ? void 0 : _metricByTitle$Refund.trend) || signed((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRateChange) || -0.3, "pp"),
2949
- detail: ((_metricByTitle$Refund2 = metricByTitle["Refund Rate"]) === null || _metricByTitle$Refund2 === void 0 ? void 0 : _metricByTitle$Refund2.detail) || "".concat(formatNumber((_refundsRaw$refundCou = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundCount) !== null && _refundsRaw$refundCou !== void 0 ? _refundsRaw$refundCou : 2), " refunds this period"),
3016
+ trend: ((_metricByTitle$Refund = metricByTitle["Refund Rate"]) === null || _metricByTitle$Refund === void 0 ? void 0 : _metricByTitle$Refund.trend) || signed(growthPercentage),
3017
+ detail: ((_metricByTitle$Refund2 = metricByTitle["Refund Rate"]) === null || _metricByTitle$Refund2 === void 0 ? void 0 : _metricByTitle$Refund2.detail) || "".concat(formatNumber(totalRefunds), " refunds this period"),
2950
3018
  trendPositiveWhenNegative: (_metricByTitle$Refund3 = metricByTitle["Refund Rate"]) === null || _metricByTitle$Refund3 === void 0 ? void 0 : _metricByTitle$Refund3.trendPositiveWhenNegative
2951
3019
  })]
2952
3020
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -3287,9 +3355,7 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref14, ref) {
3287
3355
  style: {
3288
3356
  fontSize: 9
3289
3357
  },
3290
- children: formatArrowTrend((_refundsRaw$refundRat2 = refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRateChange) !== null && _refundsRaw$refundRat2 !== void 0 ? _refundsRaw$refundRat2 : 0, {
3291
- suffix: "pp"
3292
- })
3358
+ children: growthPercentage === 0 ? "stable" : formatArrowTrend(growthPercentage)
3293
3359
  })
3294
3360
  })]
3295
3361
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -3314,7 +3380,13 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref14, ref) {
3314
3380
  fontSize: 9,
3315
3381
  color: "#9CA3AF"
3316
3382
  },
3317
- children: "stable"
3383
+ children: growthPercentage === 0 ? "stable" : /*#__PURE__*/jsxRuntime.jsx(TrendText, {
3384
+ invert: true,
3385
+ style: {
3386
+ fontSize: 9
3387
+ },
3388
+ children: formatArrowTrend(growthPercentage)
3389
+ })
3318
3390
  })]
3319
3391
  })]
3320
3392
  }), /*#__PURE__*/jsxRuntime.jsx(Divider, {
@@ -3325,7 +3397,7 @@ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref14, ref) {
3325
3397
  color: "#6B7280",
3326
3398
  lineHeight: 1.45
3327
3399
  },
3328
- children: [d$((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundAmount) || 0), " refunded \xB7 ", d$((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.disputedAmount) || 0), " disputed \xB7 ", formatNumber((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.casesLost) || 0), " cases lost"]
3400
+ children: [d$(totalRefundedAmount), " refunded \xB7 ", formatNumber(totalChargebacks), " chargebacks \xB7 ", formatNumber(lostChargebacks), " cases lost"]
3329
3401
  })]
3330
3402
  }), /*#__PURE__*/jsxRuntime.jsx(Panel, {
3331
3403
  title: "Traffic source",