@saasquatch/mint-components 1.11.1-53 → 1.11.1-55

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.
@@ -428,9 +428,20 @@ const ReferralTableRewardsCell = class {
428
428
  constructor(hostRef) {
429
429
  index.registerInstance(this, hostRef);
430
430
  this.locale = "en";
431
+ stencilHooks_module.h$1(this);
431
432
  }
433
+ disconnectedCallback() { }
432
434
  render() {
433
435
  var _a;
436
+ reRender.useRequestRerender([
437
+ this.statusText,
438
+ this.statusLongText,
439
+ this.fuelTankText,
440
+ this.rewardReceivedText,
441
+ this.expiringText,
442
+ this.pendingForText,
443
+ this.hideDetails,
444
+ ]);
434
445
  global.intl.locale = this.locale;
435
446
  const style = {
436
447
  "@keyframes slideRight": {
@@ -579,40 +590,31 @@ const ReferralTableRewardsCell = class {
579
590
  .replace("in", "")
580
591
  .trim();
581
592
  };
582
- const getPropValue = (prop) => {
583
- return this[prop];
584
- };
585
593
  return (_a = this.rewards) === null || _a === void 0 ? void 0 : _a.map((reward) => {
586
594
  var _a, _b;
587
595
  const state = getState(reward, this.taxConnection);
588
596
  const slBadgeType = getSLBadgeType(state);
589
- const badgeText = global.intl.formatMessage({
590
- id: "statusShortMessage",
591
- defaultMessage: getPropValue("statusText"),
592
- }, {
597
+ const badgeText = global.intl.formatMessage({ id: "statusShortMessage", defaultMessage: this.statusText }, {
593
598
  status: state,
594
599
  });
595
600
  console.log({
596
601
  state,
597
602
  intl: global.intl,
598
603
  badgeText,
599
- statusText: getPropValue("statusText"),
600
- statusText2: this.statusText,
604
+ statusText: this.statusText,
601
605
  reward,
602
- locale: this.locale,
603
- locale2: getPropValue("locale"),
604
606
  });
605
607
  const statusText = global.intl.formatMessage({
606
608
  id: "statusLongMessage",
607
- defaultMessage: getPropValue("statusLongText"),
609
+ defaultMessage: this.statusLongText,
608
610
  }, {
609
611
  status: state,
610
612
  });
611
- return (index.h("sl-details", { class: sheet.classes.Details, disabled: getPropValue("hideDetails") }, index.h("style", { type: "text/css" }, styleString), index.h("div", { slot: "summary", class: sheet.classes.DetailsContainer }, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, index.h("span", { part: "sqm-cell-value", class: sheet.classes.BoldText }, reward.prettyValue)), index.h("div", { class: sheet.classes.BadgeContainer }, state === "PENDING" && reward.dateScheduledFor ? (index.h("sl-badge", { class: slBadgeType === "primary"
613
+ return (index.h("sl-details", { class: sheet.classes.Details, disabled: this.hideDetails }, index.h("style", { type: "text/css" }, styleString), index.h("div", { slot: "summary", class: sheet.classes.DetailsContainer }, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, index.h("span", { part: "sqm-cell-value", class: sheet.classes.BoldText }, reward.prettyValue)), index.h("div", { class: sheet.classes.BadgeContainer }, state === "PENDING" && reward.dateScheduledFor ? (index.h("sl-badge", { class: slBadgeType === "primary"
612
614
  ? sheet.classes.RedeemBadge
613
615
  : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, global.intl.formatMessage({
614
616
  id: "pendingForText",
615
- defaultMessage: getPropValue("pendingForText"),
617
+ defaultMessage: this.pendingForText,
616
618
  }, {
617
619
  status: badgeText,
618
620
  date: getTimeDiff(reward.dateScheduledFor),
@@ -620,23 +622,21 @@ const ReferralTableRewardsCell = class {
620
622
  ? sheet.classes.RedeemBadge
621
623
  : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, badgeText)), reward.dateExpires && state === "AVAILABLE" && (index.h("sl-badge", { class: slBadgeType === "primary"
622
624
  ? sheet.classes.RedeemBadge
623
- : sheet.classes.StatusBadge, type: "info", pill: true }, getPropValue("expiringText"), ` ${getTimeDiff(reward.dateExpires)}`)))), index.h("div", null, state === "PENDING_REVIEW" && ((_a = reward.referral) === null || _a === void 0 ? void 0 : _a.dateModerated) && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.referral.dateModerated)
624
- .setLocale(utils.luxonLocale(getPropValue("locale")))
625
+ : sheet.classes.StatusBadge, type: "info", pill: true }, this.expiringText, ` ${getTimeDiff(reward.dateExpires)}`)))), index.h("div", null, state === "PENDING_REVIEW" && ((_a = reward.referral) === null || _a === void 0 ? void 0 : _a.dateModerated) && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.referral.dateModerated)
626
+ .setLocale(utils.luxonLocale(this.locale))
625
627
  .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), state === "PAYOUT_APPROVED" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PAYOUT_FAILED" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PAYOUT_CANCELLED" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PENDING_TAX_REVIEW" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PENDING_NEW_TAX_FORM" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PENDING_TAX_SUBMISSION" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "PENDING_PARTNER_CREATION" && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText))), state === "DENIED" && ((_b = reward.referral) === null || _b === void 0 ? void 0 : _b.dateModerated) && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.referral.dateModerated)
626
- .setLocale(utils.luxonLocale(getPropValue("locale")))
627
- .toLocaleString(luxon.luxon.DateTime.DATE_MED)), ".", getPropValue("deniedHelpText")
628
- ? ` ${getPropValue("deniedHelpText")}`
629
- : ``))), reward.dateGiven && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, getPropValue("rewardReceivedText"), " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateGiven)
630
- .setLocale(utils.luxonLocale(getPropValue("locale")))
628
+ .setLocale(utils.luxonLocale(this.locale))
629
+ .toLocaleString(luxon.luxon.DateTime.DATE_MED)), ".", this.deniedHelpText ? ` ${this.deniedHelpText}` : ``))), reward.dateGiven && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, this.rewardReceivedText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateGiven)
630
+ .setLocale(utils.luxonLocale(this.locale))
631
631
  .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), state === "EXPIRED" && reward.dateExpires && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateExpires)
632
- .setLocale(utils.luxonLocale(getPropValue("locale")))
632
+ .setLocale(utils.luxonLocale(this.locale))
633
633
  .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), state === "CANCELLED" && reward.dateCancelled && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateCancelled)
634
- .setLocale(utils.luxonLocale(getPropValue("locale")))
634
+ .setLocale(utils.luxonLocale(this.locale))
635
635
  .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), state === "PENDING" && reward.dateScheduledFor && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateScheduledFor)
636
- .setLocale(utils.luxonLocale(getPropValue("locale")))
636
+ .setLocale(utils.luxonLocale(this.locale))
637
637
  .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), " ", state === "AVAILABLE" && reward.dateExpires && (index.h("div", null, index.h(sqmTextSpanView.TextSpanView, { type: "p" }, statusText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.luxon.DateTime.fromMillis(reward.dateExpires)
638
- .setLocale(utils.luxonLocale(getPropValue("locale")))
639
- .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), reward.fuelTankCode && (index.h("div", null, getPropValue("fuelTankText"), " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, reward.fuelTankCode))))));
638
+ .setLocale(utils.luxonLocale(this.locale))
639
+ .toLocaleString(luxon.luxon.DateTime.DATE_MED))))), reward.fuelTankCode && (index.h("div", null, this.fuelTankText, " ", index.h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, reward.fuelTankCode))))));
640
640
  });
641
641
  }
642
642
  };
@@ -1,15 +1,28 @@
1
1
  import { Component, h, Prop } from "@stencil/core";
2
2
  import { DateTime } from "luxon";
3
- import { TextSpanView } from "../../sqm-text-span/sqm-text-span-view";
4
- import { createStyleSheet } from "../../../styling/JSS";
5
3
  import { intl } from "../../../global/global";
4
+ import { createStyleSheet } from "../../../styling/JSS";
5
+ import { useRequestRerender } from "../../../tables/re-render";
6
6
  import { luxonLocale } from "../../../utils/utils";
7
+ import { TextSpanView } from "../../sqm-text-span/sqm-text-span-view";
8
+ import { withHooks } from "@saasquatch/stencil-hooks";
7
9
  export class ReferralTableRewardsCell {
8
10
  constructor() {
9
11
  this.locale = "en";
12
+ withHooks(this);
10
13
  }
14
+ disconnectedCallback() { }
11
15
  render() {
12
16
  var _a;
17
+ useRequestRerender([
18
+ this.statusText,
19
+ this.statusLongText,
20
+ this.fuelTankText,
21
+ this.rewardReceivedText,
22
+ this.expiringText,
23
+ this.pendingForText,
24
+ this.hideDetails,
25
+ ]);
13
26
  intl.locale = this.locale;
14
27
  const style = {
15
28
  "@keyframes slideRight": {
@@ -158,36 +171,27 @@ export class ReferralTableRewardsCell {
158
171
  .replace("in", "")
159
172
  .trim();
160
173
  };
161
- const getPropValue = (prop) => {
162
- return this[prop];
163
- };
164
174
  return (_a = this.rewards) === null || _a === void 0 ? void 0 : _a.map((reward) => {
165
175
  var _a, _b;
166
176
  const state = getState(reward, this.taxConnection);
167
177
  const slBadgeType = getSLBadgeType(state);
168
- const badgeText = intl.formatMessage({
169
- id: "statusShortMessage",
170
- defaultMessage: getPropValue("statusText"),
171
- }, {
178
+ const badgeText = intl.formatMessage({ id: "statusShortMessage", defaultMessage: this.statusText }, {
172
179
  status: state,
173
180
  });
174
181
  console.log({
175
182
  state,
176
183
  intl,
177
184
  badgeText,
178
- statusText: getPropValue("statusText"),
179
- statusText2: this.statusText,
185
+ statusText: this.statusText,
180
186
  reward,
181
- locale: this.locale,
182
- locale2: getPropValue("locale"),
183
187
  });
184
188
  const statusText = intl.formatMessage({
185
189
  id: "statusLongMessage",
186
- defaultMessage: getPropValue("statusLongText"),
190
+ defaultMessage: this.statusLongText,
187
191
  }, {
188
192
  status: state,
189
193
  });
190
- return (h("sl-details", { class: sheet.classes.Details, disabled: getPropValue("hideDetails") },
194
+ return (h("sl-details", { class: sheet.classes.Details, disabled: this.hideDetails },
191
195
  h("style", { type: "text/css" }, styleString),
192
196
  h("div", { slot: "summary", class: sheet.classes.DetailsContainer },
193
197
  h(TextSpanView, { type: "p" },
@@ -197,7 +201,7 @@ export class ReferralTableRewardsCell {
197
201
  ? sheet.classes.RedeemBadge
198
202
  : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, intl.formatMessage({
199
203
  id: "pendingForText",
200
- defaultMessage: getPropValue("pendingForText"),
204
+ defaultMessage: this.pendingForText,
201
205
  }, {
202
206
  status: badgeText,
203
207
  date: getTimeDiff(reward.dateScheduledFor),
@@ -207,7 +211,7 @@ export class ReferralTableRewardsCell {
207
211
  reward.dateExpires && state === "AVAILABLE" && (h("sl-badge", { class: slBadgeType === "primary"
208
212
  ? sheet.classes.RedeemBadge
209
213
  : sheet.classes.StatusBadge, type: "info", pill: true },
210
- getPropValue("expiringText"),
214
+ this.expiringText,
211
215
  ` ${getTimeDiff(reward.dateExpires)}`)))),
212
216
  h("div", null,
213
217
  state === "PENDING_REVIEW" && ((_a = reward.referral) === null || _a === void 0 ? void 0 : _a.dateModerated) && (h("div", null,
@@ -215,7 +219,7 @@ export class ReferralTableRewardsCell {
215
219
  statusText,
216
220
  " ",
217
221
  h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, DateTime.fromMillis(reward.referral.dateModerated)
218
- .setLocale(luxonLocale(getPropValue("locale")))
222
+ .setLocale(luxonLocale(this.locale))
219
223
  .toLocaleString(DateTime.DATE_MED))))),
220
224
  state === "PAYOUT_APPROVED" && (h("div", null,
221
225
  h(TextSpanView, { type: "p" }, statusText))),
@@ -236,39 +240,37 @@ export class ReferralTableRewardsCell {
236
240
  statusText,
237
241
  " ",
238
242
  h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, DateTime.fromMillis(reward.referral.dateModerated)
239
- .setLocale(luxonLocale(getPropValue("locale")))
243
+ .setLocale(luxonLocale(this.locale))
240
244
  .toLocaleString(DateTime.DATE_MED)),
241
245
  ".",
242
- getPropValue("deniedHelpText")
243
- ? ` ${getPropValue("deniedHelpText")}`
244
- : ``))),
246
+ this.deniedHelpText ? ` ${this.deniedHelpText}` : ``))),
245
247
  reward.dateGiven && (h("div", null,
246
248
  h(TextSpanView, { type: "p" },
247
- getPropValue("rewardReceivedText"),
249
+ this.rewardReceivedText,
248
250
  " ",
249
251
  h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, DateTime.fromMillis(reward.dateGiven)
250
- .setLocale(luxonLocale(getPropValue("locale")))
252
+ .setLocale(luxonLocale(this.locale))
251
253
  .toLocaleString(DateTime.DATE_MED))))),
252
254
  state === "EXPIRED" && reward.dateExpires && (h("div", null,
253
255
  h(TextSpanView, { type: "p" },
254
256
  statusText,
255
257
  " ",
256
258
  h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, DateTime.fromMillis(reward.dateExpires)
257
- .setLocale(luxonLocale(getPropValue("locale")))
259
+ .setLocale(luxonLocale(this.locale))
258
260
  .toLocaleString(DateTime.DATE_MED))))),
259
261
  state === "CANCELLED" && reward.dateCancelled && (h("div", null,
260
262
  h(TextSpanView, { type: "p" },
261
263
  statusText,
262
264
  " ",
263
265
  h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, DateTime.fromMillis(reward.dateCancelled)
264
- .setLocale(luxonLocale(getPropValue("locale")))
266
+ .setLocale(luxonLocale(this.locale))
265
267
  .toLocaleString(DateTime.DATE_MED))))),
266
268
  state === "PENDING" && reward.dateScheduledFor && (h("div", null,
267
269
  h(TextSpanView, { type: "p" },
268
270
  statusText,
269
271
  " ",
270
272
  h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, DateTime.fromMillis(reward.dateScheduledFor)
271
- .setLocale(luxonLocale(getPropValue("locale")))
273
+ .setLocale(luxonLocale(this.locale))
272
274
  .toLocaleString(DateTime.DATE_MED))))),
273
275
  " ",
274
276
  state === "AVAILABLE" && reward.dateExpires && (h("div", null,
@@ -276,10 +278,10 @@ export class ReferralTableRewardsCell {
276
278
  statusText,
277
279
  " ",
278
280
  h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, DateTime.fromMillis(reward.dateExpires)
279
- .setLocale(luxonLocale(getPropValue("locale")))
281
+ .setLocale(luxonLocale(this.locale))
280
282
  .toLocaleString(DateTime.DATE_MED))))),
281
283
  reward.fuelTankCode && (h("div", null,
282
- getPropValue("fuelTankText"),
284
+ this.fuelTankText,
283
285
  " ",
284
286
  h("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, reward.fuelTankCode))))));
285
287
  });
@@ -424,9 +424,20 @@ const ReferralTableRewardsCell = class {
424
424
  constructor(hostRef) {
425
425
  registerInstance(this, hostRef);
426
426
  this.locale = "en";
427
+ h(this);
427
428
  }
429
+ disconnectedCallback() { }
428
430
  render() {
429
431
  var _a;
432
+ useRequestRerender([
433
+ this.statusText,
434
+ this.statusLongText,
435
+ this.fuelTankText,
436
+ this.rewardReceivedText,
437
+ this.expiringText,
438
+ this.pendingForText,
439
+ this.hideDetails,
440
+ ]);
430
441
  intl.locale = this.locale;
431
442
  const style = {
432
443
  "@keyframes slideRight": {
@@ -575,40 +586,31 @@ const ReferralTableRewardsCell = class {
575
586
  .replace("in", "")
576
587
  .trim();
577
588
  };
578
- const getPropValue = (prop) => {
579
- return this[prop];
580
- };
581
589
  return (_a = this.rewards) === null || _a === void 0 ? void 0 : _a.map((reward) => {
582
590
  var _a, _b;
583
591
  const state = getState(reward, this.taxConnection);
584
592
  const slBadgeType = getSLBadgeType(state);
585
- const badgeText = intl.formatMessage({
586
- id: "statusShortMessage",
587
- defaultMessage: getPropValue("statusText"),
588
- }, {
593
+ const badgeText = intl.formatMessage({ id: "statusShortMessage", defaultMessage: this.statusText }, {
589
594
  status: state,
590
595
  });
591
596
  console.log({
592
597
  state,
593
598
  intl,
594
599
  badgeText,
595
- statusText: getPropValue("statusText"),
596
- statusText2: this.statusText,
600
+ statusText: this.statusText,
597
601
  reward,
598
- locale: this.locale,
599
- locale2: getPropValue("locale"),
600
602
  });
601
603
  const statusText = intl.formatMessage({
602
604
  id: "statusLongMessage",
603
- defaultMessage: getPropValue("statusLongText"),
605
+ defaultMessage: this.statusLongText,
604
606
  }, {
605
607
  status: state,
606
608
  });
607
- return (h$1("sl-details", { class: sheet.classes.Details, disabled: getPropValue("hideDetails") }, h$1("style", { type: "text/css" }, styleString), h$1("div", { slot: "summary", class: sheet.classes.DetailsContainer }, h$1(TextSpanView, { type: "p" }, h$1("span", { part: "sqm-cell-value", class: sheet.classes.BoldText }, reward.prettyValue)), h$1("div", { class: sheet.classes.BadgeContainer }, state === "PENDING" && reward.dateScheduledFor ? (h$1("sl-badge", { class: slBadgeType === "primary"
609
+ return (h$1("sl-details", { class: sheet.classes.Details, disabled: this.hideDetails }, h$1("style", { type: "text/css" }, styleString), h$1("div", { slot: "summary", class: sheet.classes.DetailsContainer }, h$1(TextSpanView, { type: "p" }, h$1("span", { part: "sqm-cell-value", class: sheet.classes.BoldText }, reward.prettyValue)), h$1("div", { class: sheet.classes.BadgeContainer }, state === "PENDING" && reward.dateScheduledFor ? (h$1("sl-badge", { class: slBadgeType === "primary"
608
610
  ? sheet.classes.RedeemBadge
609
611
  : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, intl.formatMessage({
610
612
  id: "pendingForText",
611
- defaultMessage: getPropValue("pendingForText"),
613
+ defaultMessage: this.pendingForText,
612
614
  }, {
613
615
  status: badgeText,
614
616
  date: getTimeDiff(reward.dateScheduledFor),
@@ -616,23 +618,21 @@ const ReferralTableRewardsCell = class {
616
618
  ? sheet.classes.RedeemBadge
617
619
  : sheet.classes.StatusBadge, type: slBadgeType, pill: true }, badgeText)), reward.dateExpires && state === "AVAILABLE" && (h$1("sl-badge", { class: slBadgeType === "primary"
618
620
  ? sheet.classes.RedeemBadge
619
- : sheet.classes.StatusBadge, type: "info", pill: true }, getPropValue("expiringText"), ` ${getTimeDiff(reward.dateExpires)}`)))), h$1("div", null, state === "PENDING_REVIEW" && ((_a = reward.referral) === null || _a === void 0 ? void 0 : _a.dateModerated) && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.referral.dateModerated)
620
- .setLocale(luxonLocale(getPropValue("locale")))
621
+ : sheet.classes.StatusBadge, type: "info", pill: true }, this.expiringText, ` ${getTimeDiff(reward.dateExpires)}`)))), h$1("div", null, state === "PENDING_REVIEW" && ((_a = reward.referral) === null || _a === void 0 ? void 0 : _a.dateModerated) && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.referral.dateModerated)
622
+ .setLocale(luxonLocale(this.locale))
621
623
  .toLocaleString(luxon.DateTime.DATE_MED))))), state === "PAYOUT_APPROVED" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PAYOUT_FAILED" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PAYOUT_CANCELLED" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PENDING_TAX_REVIEW" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PENDING_NEW_TAX_FORM" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PENDING_TAX_SUBMISSION" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "PENDING_PARTNER_CREATION" && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText))), state === "DENIED" && ((_b = reward.referral) === null || _b === void 0 ? void 0 : _b.dateModerated) && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.referral.dateModerated)
622
- .setLocale(luxonLocale(getPropValue("locale")))
623
- .toLocaleString(luxon.DateTime.DATE_MED)), ".", getPropValue("deniedHelpText")
624
- ? ` ${getPropValue("deniedHelpText")}`
625
- : ``))), reward.dateGiven && (h$1("div", null, h$1(TextSpanView, { type: "p" }, getPropValue("rewardReceivedText"), " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateGiven)
626
- .setLocale(luxonLocale(getPropValue("locale")))
624
+ .setLocale(luxonLocale(this.locale))
625
+ .toLocaleString(luxon.DateTime.DATE_MED)), ".", this.deniedHelpText ? ` ${this.deniedHelpText}` : ``))), reward.dateGiven && (h$1("div", null, h$1(TextSpanView, { type: "p" }, this.rewardReceivedText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateGiven)
626
+ .setLocale(luxonLocale(this.locale))
627
627
  .toLocaleString(luxon.DateTime.DATE_MED))))), state === "EXPIRED" && reward.dateExpires && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateExpires)
628
- .setLocale(luxonLocale(getPropValue("locale")))
628
+ .setLocale(luxonLocale(this.locale))
629
629
  .toLocaleString(luxon.DateTime.DATE_MED))))), state === "CANCELLED" && reward.dateCancelled && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateCancelled)
630
- .setLocale(luxonLocale(getPropValue("locale")))
630
+ .setLocale(luxonLocale(this.locale))
631
631
  .toLocaleString(luxon.DateTime.DATE_MED))))), state === "PENDING" && reward.dateScheduledFor && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateScheduledFor)
632
- .setLocale(luxonLocale(getPropValue("locale")))
632
+ .setLocale(luxonLocale(this.locale))
633
633
  .toLocaleString(luxon.DateTime.DATE_MED))))), " ", state === "AVAILABLE" && reward.dateExpires && (h$1("div", null, h$1(TextSpanView, { type: "p" }, statusText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, luxon.DateTime.fromMillis(reward.dateExpires)
634
- .setLocale(luxonLocale(getPropValue("locale")))
635
- .toLocaleString(luxon.DateTime.DATE_MED))))), reward.fuelTankCode && (h$1("div", null, getPropValue("fuelTankText"), " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, reward.fuelTankCode))))));
634
+ .setLocale(luxonLocale(this.locale))
635
+ .toLocaleString(luxon.DateTime.DATE_MED))))), reward.fuelTankCode && (h$1("div", null, this.fuelTankText, " ", h$1("span", { class: sheet.classes.BoldText, part: "sqm-cell-value" }, reward.fuelTankCode))))));
636
636
  });
637
637
  }
638
638
  };
@@ -1 +1 @@
1
- var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++){t=arguments[r];for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n))e[n]=t[n]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,r,a){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,l){function i(e){try{o(a.next(e))}catch(e){l(e)}}function s(e){try{o(a["throw"](e))}catch(e){l(e)}}function o(e){e.done?r(e.value):n(e.value).then(i,s)}o((a=a.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,n,l,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(e){return function(t){return o([e,t])}}function o(i){if(a)throw new TypeError("Generator is already executing.");while(r)try{if(a=1,n&&(l=i[0]&2?n["return"]:i[0]?n["throw"]||((l=n["return"])&&l.call(n),0):n.next)&&!(l=l.call(n,i[1])).done)return l;if(n=0,l)i=[i[0]&2,l.value];switch(i[0]){case 0:case 1:l=i;break;case 4:r.label++;return{value:i[1],done:false};case 5:r.label++;n=i[1];i=[0];continue;case 7:i=r.ops.pop();r.trys.pop();continue;default:if(!(l=r.trys,l=l.length>0&&l[l.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!l||i[1]>l[0]&&i[1]<l[3])){r.label=i[1];break}if(i[0]===6&&r.label<l[1]){r.label=l[1];l=i;break}if(l&&r.label<l[2]){r.label=l[2];r.ops.push(i);break}if(l[2])r.ops.pop();r.trys.pop();continue}i=t.call(e,r)}catch(e){i=[6,e];n=0}finally{a=l=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};var __spreadArrays=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var a=Array(e),n=0,t=0;t<r;t++)for(var l=arguments[t],i=0,s=l.length;i<s;i++,n++)a[n]=l[i];return a};import{r as registerInstance,h as h$1,g as getElement,c as Host}from"./index-17b4da69.js";import{n as h,j as useReducer,u as useMemo,f as useEffect}from"./stencil-hooks.module-ac12ca1c.js";import{i as intl}from"./global-04c7d3b5.js";import{i as isDemo}from"./index.module-def4aec5.js";import{c as cjs}from"./cjs-bdfb4486.js";import"./mixins-f60a614c.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import{G as GenericTableView}from"./GenericTableView-d59d8ab4.js";import{a as useRequestRerender,u as useRerenderListener}from"./re-render-12fd274a.js";import{u as useChildElements}from"./useChildElements-32e1bda1.js";import{l as luxon}from"./luxon-7600be8d.js";import{g as getPaypalMeta}from"./mockRewardData-0eb6e778.js";import{u as useReferralTable,t as tryMethod}from"./useReferralTable-f4de0650.js";import{l as luxonLocale}from"./utils-334c1e34.js";import{T as TextSpanView}from"./sqm-text-span-view-8d140661.js";var mockReferralData=function(e){if(e===void 0){e=4}var t=__spreadArrays(Array(e)).map((function(){return getMockData()}));return{totalCount:6,count:e,referredByReferral:{dateConverted:null,dateReferralStarted:1643912659850,referrerUser:{firstName:"John",lastName:"Snow",rewards:[]}},data:t}};var statuses=[["AVAILABLE"],["PENDING"],["CANCELLED"],["EXPIRED"],["REDEEMED"]];var firstNames=["Rajesh","Pierre","Ji-Ho","Chinua","Charleston","Sally","Gael","Jill","Jane","Khadija"];var lastNames=["Smith","Parker","Kent","Chew","Stark","Banner","Jones","Odinson","Pym","Rogers"];var getMockData=function(){return{id:"5cae6b0fcc540e209db45b53",referredUser:{id:"5cae6b0ce4b0d81c67b78e82",accountId:"SPX1MZBIPTFL3E1H",firstName:firstNames[Math.floor(Math.random()*firstNames.length)],lastName:lastNames[Math.floor(Math.random()*lastNames.length)],email:"example.uexwltgh@mailosaur.io",programGoals:[]},shareLinkUsed:null,referralCodeUsed:"JIMBONEUTRON2",moderationStatus:"PENDING",dateConverted:Math.floor(Math.random()*10)>=5?luxon.DateTime.now().minus({days:6}).toMillis():null,dateFraudChecksCompleted:null,dateModerated:1558730033306,dateModified:1554934543447,dateReferralEnded:null,dateReferralPaid:null,dateReferralStarted:luxon.DateTime.now().minus({days:8}).toMillis(),dateUserModified:null,programId:"sam-partner-test-2",program:{id:"sam-partner-test-2",name:"Partner Program 2.0"},rewards:Math.floor(Math.random()*10)>=5?[{id:"5cae6b16cc540e209db45cfa",type:"CREDIT",value:1,unit:"POINT",name:"Partner Reward",dateGiven:1554934550726,dateExpires:null,dateCancelled:null,dateRedeemed:1637004373582,dateScheduledFor:null,fuelTankCode:null,fuelTankType:null,currency:null,prettyValue:"1 Point",statuses:statuses[Math.floor(Math.random()*statuses.length)],globalRewardKey:null,programRewardKey:"partnerReward",meta:__assign({},getPaypalMeta()),rewardRedemptionTransactions:{data:[{exchangedRewards:{data:[{prettyValue:"CAD10.00 Visa* Prepaid Card CAD",type:"INTEGRATION",fuelTankCode:null,globalRewardKey:"gc1"}]}}]}}]:[],childNodes:{data:[{data:{id:"5cae6b16cc540e209db45cb3",statuses:statuses[Math.floor(Math.random()*statuses.length)],type:"PCT_DISCOUNT",value:50},depth:1},{data:{id:"5cae6b16cc540e209db45cfa",statuses:statuses[Math.floor(Math.random()*statuses.length)],type:"CREDIT",value:1},depth:1}]}}};var ReferralTable=function(){function e(e){registerInstance(this,e);this.perPage=4;this.hideLabels=false;this.prevLabel="Prev";this.moreLabel="Next";this.showReferrer=false;this.hiddenColumns="0";this.smBreakpoint=599;this.mdBreakpoint=799;h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=h$1(EmptySlot,null);var t=h$1(LoadingSlot,null);var r=isDemo()?useReferralTableDemo(this,e,t):useReferralTable(this,e,t),a=r.states,n=r.data,l=r.callbacks,i=r.elements;useRequestRerender([this.showReferrer,this.perPage]);return h$1(GenericTableView,{states:a,data:n,callbacks:l,elements:i})};return e}();function EmptySlot(){return h$1("slot",{name:"empty"},h$1("sqm-empty",{"empty-state-image":"https://res.cloudinary.com/saasquatch/image/upload/v1644000223/squatch-assets/empty_referral2.png","empty-state-header":"View your referral details","empty-state-text":"Refer a friend to view the status of your referrals and rewards earned"}))}function LoadingSlot(){return h$1("slot",{name:"loading"},h$1(LoadingRow,null),h$1(LoadingRow,null),h$1(LoadingRow,null),h$1(LoadingRow,null))}function LoadingRow(){return h$1("sqm-table-row",null,h$1("sqm-table-cell",{colspan:5},h$1("sl-skeleton",null)))}function useReferralTableDemo(e,t,r){var a=useReducer((function(e,t){return __assign(__assign({},e),t)}),{columns:[],rows:[],loading:false,page:0}),n=a[0],l=a[1];var i=useRerenderListener();var s=useMemo((function(){var t;return((t=e.demoData)===null||t===void 0?void 0:t.mockData)||mockReferralData(e.perPage)}),[e.perPage]);var o=useChildElements();function u(t){return __awaiter(this,void 0,void 0,(function(){var r,a,n,i,o,u,d,c,f,h,v,p,m,T;var _=this;return __generator(this,(function(E){switch(E.label){case 0:n=s===null||s===void 0?void 0:s.referredByReferral;i=e.showReferrer&&!!((r=s===null||s===void 0?void 0:s.referredByReferral)===null||r===void 0?void 0:r.dateReferralStarted);if(i){a=s.data.slice(0,e.perPage-1)}else{a=s.data.slice(0,e.perPage)}o=t.filter((function(e){var t,r;return e.slot!=="loading"&&e.slot!=="empty"&&((t=e===null||e===void 0?void 0:e.firstElementChild)===null||t===void 0?void 0:t.getAttribute("slot"))!=="loading"&&((r=e===null||e===void 0?void 0:e.firstElementChild)===null||r===void 0?void 0:r.getAttribute("slot"))!=="empty"}));u=o===null||o===void 0?void 0:o.map((function(e,t){return __awaiter(_,void 0,void 0,(function(){var r,a,n;return __generator(this,(function(l){a=(r=e===null||e===void 0?void 0:e.firstElementChild)===null||r===void 0?void 0:r.getAttribute("slot");if(e.tagName==="RAISINS-PLOP-TARGET"&&a!=="loading"&&a!=="empty"){e.setAttribute("slot","column-"+t);e.style.position="absolute";n=e.firstElementChild.childNodes[1];n.innerHTML="+";n.style.lineHeight="20px";return[2,tryMethod(e,(function(){return e.renderLabel(t)}))]}return[2,tryMethod(e,(function(){return e.renderLabel()}))]}))}))}));if(!i)return[3,2];c=o===null||o===void 0?void 0:o.map((function(e){return __awaiter(_,void 0,void 0,(function(){return __generator(this,(function(t){return[2,tryMethod(e,(function t(){return e.renderCell(n,e)}))]}))}))}));return[4,Promise.all(c)];case 1:d=E.sent();E.label=2;case 2:f=a===null||a===void 0?void 0:a.map((function(e){return __awaiter(_,void 0,void 0,(function(){var t,r;var a=this;return __generator(this,(function(n){switch(n.label){case 0:t=o===null||o===void 0?void 0:o.map((function(t){return __awaiter(a,void 0,void 0,(function(){return __generator(this,(function(r){return[2,tryMethod(t,(function(){return t.renderCell(e,undefined)}))]}))}))}));return[4,Promise.all(t)];case 1:r=n.sent();return[2,r]}}))}))}));v=f;if(!v)return[3,4];p=[[d]];return[4,Promise.all(f)];case 3:v=__spreadArrays.apply(void 0,p.concat([E.sent()])).filter((function(e){return e}));E.label=4;case 4:h=v;l({rows:h});T=u;if(!T)return[3,6];return[4,Promise.all(u)];case 5:T=E.sent();E.label=6;case 6:m=T;l({columns:m,loading:false,page:0});return[2]}}))}))}useEffect((function(){l({loading:true});(s===null||s===void 0?void 0:s.data)&&u(o)}),[s===null||s===void 0?void 0:s.data,o,i]);var d=cjs({states:{hasPrev:false,hasNext:false,loading:false,show:"rows"},callbacks:{prevPage:function(){return console.log("Prev")},nextPage:function(){return console.log("Next")}},data:{textOverrides:{showLabels:!e.hideLabels,prevLabel:e.prevLabel,moreLabel:e.moreLabel},hiddenColumns:e.hiddenColumns,referralData:[],mdBreakpoint:799,smBreakpoint:599},elements:{columns:n.columns,rows:n.rows,emptyElement:t,loadingElement:r}},e.demoData||{},{arrayMerge:function(e,t){return t}});return d}var ReferralTableCell=function(){function e(e){registerInstance(this,e);this.ignored=true;h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){return h$1("div",{innerHTML:this.innerTemplate})};return e}();var ReferralTableGenericColumn=function(){function e(e){registerInstance(this,e);h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,h$1("sqm-referral-table-cell",{"inner-template":getElement(this).innerHTML})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,Promise.resolve(this.columnTitle)]}))}))};e.prototype.render=function(){useRequestRerender([this.columnTitle]);return h$1(Host,{style:{display:"none"}},h$1("slot",null))};return e}();var ReferralTableDateCell=function(){function e(e){registerInstance(this,e);this.ignored=true;this.locale="en";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e;var t=!this.date?"-":(e=luxon.DateTime.fromMillis(this.date))===null||e===void 0?void 0:e.setLocale(luxonLocale(this.locale)).toLocaleString(luxon.DateTime.DATE_MED);return t};return e}();var ReferralTableDateColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Date converted";this.dateShown="dateConverted";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return[2,h$1("sqm-referral-table-date-cell",{date:e[this.dateShown],locale:t===null||t===void 0?void 0:t.locale})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,h$1("sqm-referral-table-date-cell",{date:e[this.dateShown]})]}))}))};e.prototype.render=function(){useRequestRerender([this.dateShown,this.columnTitle]);return h$1(Host,{style:{display:"none"}})};return e}();var ReferralTableRewardsCell=function(){function e(e){registerInstance(this,e);this.locale="en"}e.prototype.render=function(){var e=this;var t;intl.locale=this.locale;var r={"@keyframes slideRight":{from:{opacity:0},to:{opacity:1}},DetailsContainer:{width:"100%",display:"flex","align-items":"center","justify-content":"space-between","margin-right":"var(--sl-spacing-small)","flex-wrap":"wrap"},Details:{"padding-bottom":"var(--sl-spacing-small)","max-width":"500px","&::part(header)":{padding:"var(--sl-spacing-x-small)",cursor:""+(this.hideDetails?"default":"pointer")},"&::part(content)":{padding:"var(--sl-spacing-x-small) var(--sl-spacing-medium)"},"&::part(base)":{opacity:"1"},"&::part(summary-icon)":{display:""+(this.hideDetails?"none":"flex")},"&::part(summary-icon[open])":{transform:"rotate(-90deg)",background:"red"}},BadgeContainer:{"& > :not(:last-child)":{"margin-right":"var(--sl-spacing-x-small)"}},BoldText:{"font-weight":"var(--sl-font-weight-semibold)"},StatusBadge:{paddingLeft:"var(--sl-spacing-xxx-small)","&::part(base)":{textAlign:"center",maxWidth:"170px",whiteSpace:"pre-line"}},RedeemBadge:{paddingLeft:"var(--sl-spacing-xxx-small)","&::part(base)":{background:"var(--sl-color-blue-600)"}}};var a=createStyleSheet(r);var n=a.toString();var l=function(e,t){var r,a,n,l,i,s,o,u,d,c,f,h;var v=["REDEEMED","CANCELLED","EXPIRED","PENDING","AVAILABLE","PENDING_REVIEW","DENIED","PAYOUT_APPROVED","PAYOUT_CANCELLED","PAYOUT_FAILED","PENDING_TAX_REVIEW","PENDING_NEW_TAX_FORM","PENDING_TAX_SUBMISSION","PENDING_PARTNER_CREATION"];if(((a=(r=e.referral)===null||r===void 0?void 0:r.fraudData)===null||a===void 0?void 0:a.moderationStatus)!=="APPROVED"){if(((l=(n=e.referral)===null||n===void 0?void 0:n.fraudData)===null||l===void 0?void 0:l.moderationStatus)==="PENDING")return"PENDING_REVIEW";if(((s=(i=e.referral)===null||i===void 0?void 0:i.fraudData)===null||s===void 0?void 0:s.moderationStatus)==="DENIED")return"DENIED"}var p=(o=e.partnerFundsTransfer)===null||o===void 0?void 0:o.status;if(p==="NOT_YET_DUE"||p==="TRANSFERRED"){return"PAYOUT_APPROVED"}else if(p==="OVERDUE")return"PAYOUT_FAILED";else if(p==="REVERSED")return"PAYOUT_CANCELLED";if((u=e===null||e===void 0?void 0:e.pendingReasons)===null||u===void 0?void 0:u.includes("US_TAX")){if(!(t===null||t===void 0?void 0:t.taxHandlingEnabled))return"PENDING";if(!(t===null||t===void 0?void 0:t.connected))return"PENDING_PARTNER_CREATION";if((d=t===null||t===void 0?void 0:t.publisher)===null||d===void 0?void 0:d.requiredTaxDocumentType){if(!((c=t===null||t===void 0?void 0:t.publisher)===null||c===void 0?void 0:c.currentTaxDocument))return"PENDING_TAX_SUBMISSION";var m=t.publisher.currentTaxDocument.status;if(m==="INACTIVE")return"PENDING_NEW_TAX_FORM";if(m==="NOT_VERIFIED")return"PENDING_TAX_REVIEW"}if(!((f=t===null||t===void 0?void 0:t.publisher)===null||f===void 0?void 0:f.withdrawalSettings))return"PENDING_PARTNER_CREATION"}if((h=e===null||e===void 0?void 0:e.pendingReasons)===null||h===void 0?void 0:h.includes("PAYOUT_CONFIGURATION_MISSING")){return"PENDING_PARTNER_CREATION"}if(e.statuses.length===1)return e.statuses[0];return v.find((function(t){return e.statuses.includes(t)&&t}))};var i=function(e){switch(e){case"REDEEMED":case"PAYOUT_APPROVED":return"primary";case"DENIED":case"EXPIRED":case"CANCELLED":case"PAYOUT_FAILED":case"PAYOUT_CANCELLED":return"danger";case"PENDING":case"PENDING_REVIEW":case"PENDING_TAX_REVIEW":case"PENDING_NEW_TAX_FORM":case"PENDING_TAX_SUBMISSION":case"PENDING_PARTNER_CREATION":return"warning";case"AVAILABLE":return"success"}};var s=function(t){return luxon.DateTime.fromMillis(t).setLocale(luxonLocale(e.locale)).toRelative().replace("in","").trim()};var o=function(t){return e[t]};return(t=this.rewards)===null||t===void 0?void 0:t.map((function(t){var r,u;var d=l(t,e.taxConnection);var c=i(d);var f=intl.formatMessage({id:"statusShortMessage",defaultMessage:o("statusText")},{status:d});console.log({state:d,intl:intl,badgeText:f,statusText:o("statusText"),statusText2:e.statusText,reward:t,locale:e.locale,locale2:o("locale")});var h=intl.formatMessage({id:"statusLongMessage",defaultMessage:o("statusLongText")},{status:d});return h$1("sl-details",{class:a.classes.Details,disabled:o("hideDetails")},h$1("style",{type:"text/css"},n),h$1("div",{slot:"summary",class:a.classes.DetailsContainer},h$1(TextSpanView,{type:"p"},h$1("span",{part:"sqm-cell-value",class:a.classes.BoldText},t.prettyValue)),h$1("div",{class:a.classes.BadgeContainer},d==="PENDING"&&t.dateScheduledFor?h$1("sl-badge",{class:c==="primary"?a.classes.RedeemBadge:a.classes.StatusBadge,type:c,pill:true},intl.formatMessage({id:"pendingForText",defaultMessage:o("pendingForText")},{status:f,date:s(t.dateScheduledFor)})):h$1("sl-badge",{class:c==="primary"?a.classes.RedeemBadge:a.classes.StatusBadge,type:c,pill:true},f),t.dateExpires&&d==="AVAILABLE"&&h$1("sl-badge",{class:c==="primary"?a.classes.RedeemBadge:a.classes.StatusBadge,type:"info",pill:true},o("expiringText")," "+s(t.dateExpires)))),h$1("div",null,d==="PENDING_REVIEW"&&((r=t.referral)===null||r===void 0?void 0:r.dateModerated)&&h$1("div",null,h$1(TextSpanView,{type:"p"},h," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.referral.dateModerated).setLocale(luxonLocale(o("locale"))).toLocaleString(luxon.DateTime.DATE_MED)))),d==="PAYOUT_APPROVED"&&h$1("div",null,h$1(TextSpanView,{type:"p"},h)),d==="PAYOUT_FAILED"&&h$1("div",null,h$1(TextSpanView,{type:"p"},h)),d==="PAYOUT_CANCELLED"&&h$1("div",null,h$1(TextSpanView,{type:"p"},h)),d==="PENDING_TAX_REVIEW"&&h$1("div",null,h$1(TextSpanView,{type:"p"},h)),d==="PENDING_NEW_TAX_FORM"&&h$1("div",null,h$1(TextSpanView,{type:"p"},h)),d==="PENDING_TAX_SUBMISSION"&&h$1("div",null,h$1(TextSpanView,{type:"p"},h)),d==="PENDING_PARTNER_CREATION"&&h$1("div",null,h$1(TextSpanView,{type:"p"},h)),d==="DENIED"&&((u=t.referral)===null||u===void 0?void 0:u.dateModerated)&&h$1("div",null,h$1(TextSpanView,{type:"p"},h," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.referral.dateModerated).setLocale(luxonLocale(o("locale"))).toLocaleString(luxon.DateTime.DATE_MED)),".",o("deniedHelpText")?" "+o("deniedHelpText"):"")),t.dateGiven&&h$1("div",null,h$1(TextSpanView,{type:"p"},o("rewardReceivedText")," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateGiven).setLocale(luxonLocale(o("locale"))).toLocaleString(luxon.DateTime.DATE_MED)))),d==="EXPIRED"&&t.dateExpires&&h$1("div",null,h$1(TextSpanView,{type:"p"},h," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateExpires).setLocale(luxonLocale(o("locale"))).toLocaleString(luxon.DateTime.DATE_MED)))),d==="CANCELLED"&&t.dateCancelled&&h$1("div",null,h$1(TextSpanView,{type:"p"},h," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateCancelled).setLocale(luxonLocale(o("locale"))).toLocaleString(luxon.DateTime.DATE_MED)))),d==="PENDING"&&t.dateScheduledFor&&h$1("div",null,h$1(TextSpanView,{type:"p"},h," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateScheduledFor).setLocale(luxonLocale(o("locale"))).toLocaleString(luxon.DateTime.DATE_MED))))," ",d==="AVAILABLE"&&t.dateExpires&&h$1("div",null,h$1(TextSpanView,{type:"p"},h," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateExpires).setLocale(luxonLocale(o("locale"))).toLocaleString(luxon.DateTime.DATE_MED)))),t.fuelTankCode&&h$1("div",null,o("fuelTankText")," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},t.fuelTankCode))))}))};return e}();var ReferralTableRewardsColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Rewards";this.statusText="{status, select, AVAILABLE {Available} CANCELLED {Cancelled} PENDING {Pending} PENDING_REVIEW {Pending} PAYOUT_APPROVED {Payout Approved} PAYOUT_FAILED {Payout Failed} PAYOUT_CANCELLED {Payout Cancelled} PENDING_TAX_REVIEW {Pending} PENDING_NEW_TAX_FORM {Pending} PENDING_TAX_SUBMISSION {Pending} PENDING_PARTNER_CREATION {Pending} DENIED {Denied} EXPIRED {Expired} REDEEMED {Redeemed} other {Not available} }";this.statusLongText="{status, select, AVAILABLE {Reward expiring on} CANCELLED {Reward cancelled on} PENDING {Available on} PENDING_REVIEW {Pending since} PAYOUT_APPROVED {Reward approved for payout and was scheduled for payment based on your settings.} PAYOUT_FAILED {Payout failed due to a fulfillment issue and is currently being retried.} PAYOUT_CANCELLED {If you think this is a mistake, contact our Support team.} PENDING_TAX_REVIEW {Awaiting tax form review} PENDING_NEW_TAX_FORM {Invalid tax form. Submit a new form to receive your rewards.} PENDING_TAX_SUBMISSION {Submit your tax documents to receive your rewards} PENDING_PARTNER_CREATION {Complete your tax and cash payout setup to receive your rewards} DENIED {Denied on} EXPIRED {Reward expired on} other {Not available} }";this.fuelTankText="Your code is";this.rewardReceivedText="Reward received on";this.expiringText="Expiring in";this.pendingForText="{status} for {date}";this.deniedHelpText="Contact support if you think this is a mistake.";this.hideDetails=false;h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){console.log({statusText:this.statusText});return[2,h$1("sqm-referral-table-rewards-cell",{rewards:e.rewards,"tax-connection":t===null||t===void 0?void 0:t.taxConnection,"status-text":this.statusText,"status-long-text":this.statusLongText,"fuel-tank-text":this.fuelTankText,"reward-received-text":this.rewardReceivedText,"expiring-text":this.expiringText,"pending-for-text":this.pendingForText,"hide-details":this.hideDetails,"denied-help-text":this.deniedHelpText,locale:t===null||t===void 0?void 0:t.locale,exportparts:"sqm-cell-value"})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,h$1("sqm-referral-table-rewards-cell",{rewards:e.rewards,exportparts:"sqm-cell-value"})]}))}))};e.prototype.render=function(){useRequestRerender([this.columnTitle,this.statusText,this.statusLongText,this.fuelTankText,this.rewardReceivedText,this.expiringText,this.pendingForText,this.hideDetails]);return h$1(Host,{style:{display:"none"}})};return e}();var style={Badge:{"&::part(base)":{fontSize:"var(--sl-font-size-small)",padding:"4px 8px",whiteSpace:"pre-line"}},SubText:{fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)",margin:"0"}};var sheet=createStyleSheet(style);var styleString=sheet.toString();var ReferralTableStatusCell=function(){function e(e){registerInstance(this,e)}e.prototype.render=function(){var e=this;var t=function(t){if(t==="PENDING")return"warning";if(t==="DENIED")return"danger";if(e.converted)return"success";return"warning"};return h$1("div",null,h$1("style",{type:"text/css"},styleString),h$1("sl-badge",{pill:true,type:t(this.fraudStatus),class:sheet.classes.Badge},this.statusText),this.statusSubText?h$1("p",{class:sheet.classes.SubText},this.statusSubText):null)};return e}();var ReferralTableStatusColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Status";this.convertedStatusText="Converted";this.inProgressStatusText="In Progress";this.pendingReviewStatusText="Pending";this.deniedStatusText="Denied";this.pendingReviewStatusSubText="Awaiting review";this.deniedStatusSubText="Detected self-referral";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,a,n;return __generator(this,(function(l){n=(t=e===null||e===void 0?void 0:e.fraudData)===null||t===void 0?void 0:t.moderationStatus;if(n==="DENIED"){r=this.deniedStatusText;a=this.deniedStatusSubText}else if(n==="PENDING"){r=this.pendingReviewStatusText;a=this.pendingReviewStatusSubText}else{r=e.dateConverted?this.convertedStatusText:this.inProgressStatusText}return[2,h$1("sqm-referral-table-status-cell",{"status-text":r,"status-sub-text":a,"fraud-status":n,converted:e.dateConverted?true:false})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){t=e.dateConverted?this.convertedStatusText:this.inProgressStatusText;return[2,h$1("sqm-referral-table-status-cell",{"status-text":t,converted:e.dateConverted?true:false})]}))}))};e.prototype.render=function(){useRequestRerender([this.columnTitle,this.convertedStatusText,this.inProgressStatusText]);return h$1(Host,{style:{display:"none"}})};return e}();var ReferralTableUserCell=function(){function e(e){registerInstance(this,e)}e.prototype.render=function(){return this.name};return e}();var ReferralTableUserColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Customer";this.anonymousUser="Anonymous User";this.deletedUser="Deleted User";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,a,n,l,i,s,o,u;return __generator(this,(function(d){if(!(e===null||e===void 0?void 0:e.referredUser)&&!(e===null||e===void 0?void 0:e.referrerUser)){u=this.deletedUser}else if(!((t=e===null||e===void 0?void 0:e.referredUser)===null||t===void 0?void 0:t.firstName)&&!((r=e===null||e===void 0?void 0:e.referredUser)===null||r===void 0?void 0:r.lastName)&&!((a=e===null||e===void 0?void 0:e.referrerUser)===null||a===void 0?void 0:a.firstName)&&!((n=e===null||e===void 0?void 0:e.referrerUser)===null||n===void 0?void 0:n.lastName)){u=this.anonymousUser}else if(e===null||e===void 0?void 0:e.referrerUser){u=((l=e===null||e===void 0?void 0:e.referrerUser)===null||l===void 0?void 0:l.firstName)+" "+((i=e===null||e===void 0?void 0:e.referrerUser)===null||i===void 0?void 0:i.lastName)}else{u=((s=e===null||e===void 0?void 0:e.referredUser)===null||s===void 0?void 0:s.firstName)+" "+((o=e===null||e===void 0?void 0:e.referredUser)===null||o===void 0?void 0:o.lastName)}return[2,h$1("sqm-referral-table-user-cell",{name:u})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,a,n,l;return __generator(this,(function(i){if(!e){l=this.deletedUser}else if(!((t=e===null||e===void 0?void 0:e.referrerUser)===null||t===void 0?void 0:t.firstName)&&!((r=e.referrerUser)===null||r===void 0?void 0:r.lastName)){l=this.anonymousUser}else{l=((a=e===null||e===void 0?void 0:e.referrerUser)===null||a===void 0?void 0:a.firstName)+" "+((n=e===null||e===void 0?void 0:e.referrerUser)===null||n===void 0?void 0:n.lastName)}return[2,h$1("sqm-referral-table-user-cell",{name:l})]}))}))};e.prototype.render=function(){useRequestRerender([this.deletedUser,this.anonymousUser,this.columnTitle]);return h$1(Host,{style:{display:"none"}})};return e}();export{ReferralTable as sqm_referral_table,ReferralTableCell as sqm_referral_table_cell,ReferralTableGenericColumn as sqm_referral_table_column,ReferralTableDateCell as sqm_referral_table_date_cell,ReferralTableDateColumn as sqm_referral_table_date_column,ReferralTableRewardsCell as sqm_referral_table_rewards_cell,ReferralTableRewardsColumn as sqm_referral_table_rewards_column,ReferralTableStatusCell as sqm_referral_table_status_cell,ReferralTableStatusColumn as sqm_referral_table_status_column,ReferralTableUserCell as sqm_referral_table_user_cell,ReferralTableUserColumn as sqm_referral_table_user_column};
1
+ var __assign=this&&this.__assign||function(){__assign=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++){t=arguments[r];for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n))e[n]=t[n]}return e};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(e,t,r,a){function n(e){return e instanceof r?e:new r((function(t){t(e)}))}return new(r||(r=Promise))((function(r,l){function i(e){try{o(a.next(e))}catch(e){l(e)}}function s(e){try{o(a["throw"](e))}catch(e){l(e)}}function o(e){e.done?r(e.value):n(e.value).then(i,s)}o((a=a.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},a,n,l,i;return i={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(i[Symbol.iterator]=function(){return this}),i;function s(e){return function(t){return o([e,t])}}function o(i){if(a)throw new TypeError("Generator is already executing.");while(r)try{if(a=1,n&&(l=i[0]&2?n["return"]:i[0]?n["throw"]||((l=n["return"])&&l.call(n),0):n.next)&&!(l=l.call(n,i[1])).done)return l;if(n=0,l)i=[i[0]&2,l.value];switch(i[0]){case 0:case 1:l=i;break;case 4:r.label++;return{value:i[1],done:false};case 5:r.label++;n=i[1];i=[0];continue;case 7:i=r.ops.pop();r.trys.pop();continue;default:if(!(l=r.trys,l=l.length>0&&l[l.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!l||i[1]>l[0]&&i[1]<l[3])){r.label=i[1];break}if(i[0]===6&&r.label<l[1]){r.label=l[1];l=i;break}if(l&&r.label<l[2]){r.label=l[2];r.ops.push(i);break}if(l[2])r.ops.pop();r.trys.pop();continue}i=t.call(e,r)}catch(e){i=[6,e];n=0}finally{a=l=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:true}}};var __spreadArrays=this&&this.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var a=Array(e),n=0,t=0;t<r;t++)for(var l=arguments[t],i=0,s=l.length;i<s;i++,n++)a[n]=l[i];return a};import{r as registerInstance,h as h$1,g as getElement,c as Host}from"./index-17b4da69.js";import{n as h,j as useReducer,u as useMemo,f as useEffect}from"./stencil-hooks.module-ac12ca1c.js";import{i as intl}from"./global-04c7d3b5.js";import{i as isDemo}from"./index.module-def4aec5.js";import{c as cjs}from"./cjs-bdfb4486.js";import"./mixins-f60a614c.js";import{c as createStyleSheet}from"./JSS-67b5cff8.js";import{G as GenericTableView}from"./GenericTableView-d59d8ab4.js";import{a as useRequestRerender,u as useRerenderListener}from"./re-render-12fd274a.js";import{u as useChildElements}from"./useChildElements-32e1bda1.js";import{l as luxon}from"./luxon-7600be8d.js";import{g as getPaypalMeta}from"./mockRewardData-0eb6e778.js";import{u as useReferralTable,t as tryMethod}from"./useReferralTable-f4de0650.js";import{l as luxonLocale}from"./utils-334c1e34.js";import{T as TextSpanView}from"./sqm-text-span-view-8d140661.js";var mockReferralData=function(e){if(e===void 0){e=4}var t=__spreadArrays(Array(e)).map((function(){return getMockData()}));return{totalCount:6,count:e,referredByReferral:{dateConverted:null,dateReferralStarted:1643912659850,referrerUser:{firstName:"John",lastName:"Snow",rewards:[]}},data:t}};var statuses=[["AVAILABLE"],["PENDING"],["CANCELLED"],["EXPIRED"],["REDEEMED"]];var firstNames=["Rajesh","Pierre","Ji-Ho","Chinua","Charleston","Sally","Gael","Jill","Jane","Khadija"];var lastNames=["Smith","Parker","Kent","Chew","Stark","Banner","Jones","Odinson","Pym","Rogers"];var getMockData=function(){return{id:"5cae6b0fcc540e209db45b53",referredUser:{id:"5cae6b0ce4b0d81c67b78e82",accountId:"SPX1MZBIPTFL3E1H",firstName:firstNames[Math.floor(Math.random()*firstNames.length)],lastName:lastNames[Math.floor(Math.random()*lastNames.length)],email:"example.uexwltgh@mailosaur.io",programGoals:[]},shareLinkUsed:null,referralCodeUsed:"JIMBONEUTRON2",moderationStatus:"PENDING",dateConverted:Math.floor(Math.random()*10)>=5?luxon.DateTime.now().minus({days:6}).toMillis():null,dateFraudChecksCompleted:null,dateModerated:1558730033306,dateModified:1554934543447,dateReferralEnded:null,dateReferralPaid:null,dateReferralStarted:luxon.DateTime.now().minus({days:8}).toMillis(),dateUserModified:null,programId:"sam-partner-test-2",program:{id:"sam-partner-test-2",name:"Partner Program 2.0"},rewards:Math.floor(Math.random()*10)>=5?[{id:"5cae6b16cc540e209db45cfa",type:"CREDIT",value:1,unit:"POINT",name:"Partner Reward",dateGiven:1554934550726,dateExpires:null,dateCancelled:null,dateRedeemed:1637004373582,dateScheduledFor:null,fuelTankCode:null,fuelTankType:null,currency:null,prettyValue:"1 Point",statuses:statuses[Math.floor(Math.random()*statuses.length)],globalRewardKey:null,programRewardKey:"partnerReward",meta:__assign({},getPaypalMeta()),rewardRedemptionTransactions:{data:[{exchangedRewards:{data:[{prettyValue:"CAD10.00 Visa* Prepaid Card CAD",type:"INTEGRATION",fuelTankCode:null,globalRewardKey:"gc1"}]}}]}}]:[],childNodes:{data:[{data:{id:"5cae6b16cc540e209db45cb3",statuses:statuses[Math.floor(Math.random()*statuses.length)],type:"PCT_DISCOUNT",value:50},depth:1},{data:{id:"5cae6b16cc540e209db45cfa",statuses:statuses[Math.floor(Math.random()*statuses.length)],type:"CREDIT",value:1},depth:1}]}}};var ReferralTable=function(){function e(e){registerInstance(this,e);this.perPage=4;this.hideLabels=false;this.prevLabel="Prev";this.moreLabel="Next";this.showReferrer=false;this.hiddenColumns="0";this.smBreakpoint=599;this.mdBreakpoint=799;h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=h$1(EmptySlot,null);var t=h$1(LoadingSlot,null);var r=isDemo()?useReferralTableDemo(this,e,t):useReferralTable(this,e,t),a=r.states,n=r.data,l=r.callbacks,i=r.elements;useRequestRerender([this.showReferrer,this.perPage]);return h$1(GenericTableView,{states:a,data:n,callbacks:l,elements:i})};return e}();function EmptySlot(){return h$1("slot",{name:"empty"},h$1("sqm-empty",{"empty-state-image":"https://res.cloudinary.com/saasquatch/image/upload/v1644000223/squatch-assets/empty_referral2.png","empty-state-header":"View your referral details","empty-state-text":"Refer a friend to view the status of your referrals and rewards earned"}))}function LoadingSlot(){return h$1("slot",{name:"loading"},h$1(LoadingRow,null),h$1(LoadingRow,null),h$1(LoadingRow,null),h$1(LoadingRow,null))}function LoadingRow(){return h$1("sqm-table-row",null,h$1("sqm-table-cell",{colspan:5},h$1("sl-skeleton",null)))}function useReferralTableDemo(e,t,r){var a=useReducer((function(e,t){return __assign(__assign({},e),t)}),{columns:[],rows:[],loading:false,page:0}),n=a[0],l=a[1];var i=useRerenderListener();var s=useMemo((function(){var t;return((t=e.demoData)===null||t===void 0?void 0:t.mockData)||mockReferralData(e.perPage)}),[e.perPage]);var o=useChildElements();function u(t){return __awaiter(this,void 0,void 0,(function(){var r,a,n,i,o,u,d,c,f,h,p,v,m,T;var _=this;return __generator(this,(function(E){switch(E.label){case 0:n=s===null||s===void 0?void 0:s.referredByReferral;i=e.showReferrer&&!!((r=s===null||s===void 0?void 0:s.referredByReferral)===null||r===void 0?void 0:r.dateReferralStarted);if(i){a=s.data.slice(0,e.perPage-1)}else{a=s.data.slice(0,e.perPage)}o=t.filter((function(e){var t,r;return e.slot!=="loading"&&e.slot!=="empty"&&((t=e===null||e===void 0?void 0:e.firstElementChild)===null||t===void 0?void 0:t.getAttribute("slot"))!=="loading"&&((r=e===null||e===void 0?void 0:e.firstElementChild)===null||r===void 0?void 0:r.getAttribute("slot"))!=="empty"}));u=o===null||o===void 0?void 0:o.map((function(e,t){return __awaiter(_,void 0,void 0,(function(){var r,a,n;return __generator(this,(function(l){a=(r=e===null||e===void 0?void 0:e.firstElementChild)===null||r===void 0?void 0:r.getAttribute("slot");if(e.tagName==="RAISINS-PLOP-TARGET"&&a!=="loading"&&a!=="empty"){e.setAttribute("slot","column-"+t);e.style.position="absolute";n=e.firstElementChild.childNodes[1];n.innerHTML="+";n.style.lineHeight="20px";return[2,tryMethod(e,(function(){return e.renderLabel(t)}))]}return[2,tryMethod(e,(function(){return e.renderLabel()}))]}))}))}));if(!i)return[3,2];c=o===null||o===void 0?void 0:o.map((function(e){return __awaiter(_,void 0,void 0,(function(){return __generator(this,(function(t){return[2,tryMethod(e,(function t(){return e.renderCell(n,e)}))]}))}))}));return[4,Promise.all(c)];case 1:d=E.sent();E.label=2;case 2:f=a===null||a===void 0?void 0:a.map((function(e){return __awaiter(_,void 0,void 0,(function(){var t,r;var a=this;return __generator(this,(function(n){switch(n.label){case 0:t=o===null||o===void 0?void 0:o.map((function(t){return __awaiter(a,void 0,void 0,(function(){return __generator(this,(function(r){return[2,tryMethod(t,(function(){return t.renderCell(e,undefined)}))]}))}))}));return[4,Promise.all(t)];case 1:r=n.sent();return[2,r]}}))}))}));p=f;if(!p)return[3,4];v=[[d]];return[4,Promise.all(f)];case 3:p=__spreadArrays.apply(void 0,v.concat([E.sent()])).filter((function(e){return e}));E.label=4;case 4:h=p;l({rows:h});T=u;if(!T)return[3,6];return[4,Promise.all(u)];case 5:T=E.sent();E.label=6;case 6:m=T;l({columns:m,loading:false,page:0});return[2]}}))}))}useEffect((function(){l({loading:true});(s===null||s===void 0?void 0:s.data)&&u(o)}),[s===null||s===void 0?void 0:s.data,o,i]);var d=cjs({states:{hasPrev:false,hasNext:false,loading:false,show:"rows"},callbacks:{prevPage:function(){return console.log("Prev")},nextPage:function(){return console.log("Next")}},data:{textOverrides:{showLabels:!e.hideLabels,prevLabel:e.prevLabel,moreLabel:e.moreLabel},hiddenColumns:e.hiddenColumns,referralData:[],mdBreakpoint:799,smBreakpoint:599},elements:{columns:n.columns,rows:n.rows,emptyElement:t,loadingElement:r}},e.demoData||{},{arrayMerge:function(e,t){return t}});return d}var ReferralTableCell=function(){function e(e){registerInstance(this,e);this.ignored=true;h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){return h$1("div",{innerHTML:this.innerTemplate})};return e}();var ReferralTableGenericColumn=function(){function e(e){registerInstance(this,e);h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,h$1("sqm-referral-table-cell",{"inner-template":getElement(this).innerHTML})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,Promise.resolve(this.columnTitle)]}))}))};e.prototype.render=function(){useRequestRerender([this.columnTitle]);return h$1(Host,{style:{display:"none"}},h$1("slot",null))};return e}();var ReferralTableDateCell=function(){function e(e){registerInstance(this,e);this.ignored=true;this.locale="en";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e;var t=!this.date?"-":(e=luxon.DateTime.fromMillis(this.date))===null||e===void 0?void 0:e.setLocale(luxonLocale(this.locale)).toLocaleString(luxon.DateTime.DATE_MED);return t};return e}();var ReferralTableDateColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Date converted";this.dateShown="dateConverted";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){return[2,h$1("sqm-referral-table-date-cell",{date:e[this.dateShown],locale:t===null||t===void 0?void 0:t.locale})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,h$1("sqm-referral-table-date-cell",{date:e[this.dateShown]})]}))}))};e.prototype.render=function(){useRequestRerender([this.dateShown,this.columnTitle]);return h$1(Host,{style:{display:"none"}})};return e}();var ReferralTableRewardsCell=function(){function e(e){registerInstance(this,e);this.locale="en";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.render=function(){var e=this;var t;useRequestRerender([this.statusText,this.statusLongText,this.fuelTankText,this.rewardReceivedText,this.expiringText,this.pendingForText,this.hideDetails]);intl.locale=this.locale;var r={"@keyframes slideRight":{from:{opacity:0},to:{opacity:1}},DetailsContainer:{width:"100%",display:"flex","align-items":"center","justify-content":"space-between","margin-right":"var(--sl-spacing-small)","flex-wrap":"wrap"},Details:{"padding-bottom":"var(--sl-spacing-small)","max-width":"500px","&::part(header)":{padding:"var(--sl-spacing-x-small)",cursor:""+(this.hideDetails?"default":"pointer")},"&::part(content)":{padding:"var(--sl-spacing-x-small) var(--sl-spacing-medium)"},"&::part(base)":{opacity:"1"},"&::part(summary-icon)":{display:""+(this.hideDetails?"none":"flex")},"&::part(summary-icon[open])":{transform:"rotate(-90deg)",background:"red"}},BadgeContainer:{"& > :not(:last-child)":{"margin-right":"var(--sl-spacing-x-small)"}},BoldText:{"font-weight":"var(--sl-font-weight-semibold)"},StatusBadge:{paddingLeft:"var(--sl-spacing-xxx-small)","&::part(base)":{textAlign:"center",maxWidth:"170px",whiteSpace:"pre-line"}},RedeemBadge:{paddingLeft:"var(--sl-spacing-xxx-small)","&::part(base)":{background:"var(--sl-color-blue-600)"}}};var a=createStyleSheet(r);var n=a.toString();var l=function(e,t){var r,a,n,l,i,s,o,u,d,c,f,h;var p=["REDEEMED","CANCELLED","EXPIRED","PENDING","AVAILABLE","PENDING_REVIEW","DENIED","PAYOUT_APPROVED","PAYOUT_CANCELLED","PAYOUT_FAILED","PENDING_TAX_REVIEW","PENDING_NEW_TAX_FORM","PENDING_TAX_SUBMISSION","PENDING_PARTNER_CREATION"];if(((a=(r=e.referral)===null||r===void 0?void 0:r.fraudData)===null||a===void 0?void 0:a.moderationStatus)!=="APPROVED"){if(((l=(n=e.referral)===null||n===void 0?void 0:n.fraudData)===null||l===void 0?void 0:l.moderationStatus)==="PENDING")return"PENDING_REVIEW";if(((s=(i=e.referral)===null||i===void 0?void 0:i.fraudData)===null||s===void 0?void 0:s.moderationStatus)==="DENIED")return"DENIED"}var v=(o=e.partnerFundsTransfer)===null||o===void 0?void 0:o.status;if(v==="NOT_YET_DUE"||v==="TRANSFERRED"){return"PAYOUT_APPROVED"}else if(v==="OVERDUE")return"PAYOUT_FAILED";else if(v==="REVERSED")return"PAYOUT_CANCELLED";if((u=e===null||e===void 0?void 0:e.pendingReasons)===null||u===void 0?void 0:u.includes("US_TAX")){if(!(t===null||t===void 0?void 0:t.taxHandlingEnabled))return"PENDING";if(!(t===null||t===void 0?void 0:t.connected))return"PENDING_PARTNER_CREATION";if((d=t===null||t===void 0?void 0:t.publisher)===null||d===void 0?void 0:d.requiredTaxDocumentType){if(!((c=t===null||t===void 0?void 0:t.publisher)===null||c===void 0?void 0:c.currentTaxDocument))return"PENDING_TAX_SUBMISSION";var m=t.publisher.currentTaxDocument.status;if(m==="INACTIVE")return"PENDING_NEW_TAX_FORM";if(m==="NOT_VERIFIED")return"PENDING_TAX_REVIEW"}if(!((f=t===null||t===void 0?void 0:t.publisher)===null||f===void 0?void 0:f.withdrawalSettings))return"PENDING_PARTNER_CREATION"}if((h=e===null||e===void 0?void 0:e.pendingReasons)===null||h===void 0?void 0:h.includes("PAYOUT_CONFIGURATION_MISSING")){return"PENDING_PARTNER_CREATION"}if(e.statuses.length===1)return e.statuses[0];return p.find((function(t){return e.statuses.includes(t)&&t}))};var i=function(e){switch(e){case"REDEEMED":case"PAYOUT_APPROVED":return"primary";case"DENIED":case"EXPIRED":case"CANCELLED":case"PAYOUT_FAILED":case"PAYOUT_CANCELLED":return"danger";case"PENDING":case"PENDING_REVIEW":case"PENDING_TAX_REVIEW":case"PENDING_NEW_TAX_FORM":case"PENDING_TAX_SUBMISSION":case"PENDING_PARTNER_CREATION":return"warning";case"AVAILABLE":return"success"}};var s=function(t){return luxon.DateTime.fromMillis(t).setLocale(luxonLocale(e.locale)).toRelative().replace("in","").trim()};return(t=this.rewards)===null||t===void 0?void 0:t.map((function(t){var r,o;var u=l(t,e.taxConnection);var d=i(u);var c=intl.formatMessage({id:"statusShortMessage",defaultMessage:e.statusText},{status:u});console.log({state:u,intl:intl,badgeText:c,statusText:e.statusText,reward:t});var f=intl.formatMessage({id:"statusLongMessage",defaultMessage:e.statusLongText},{status:u});return h$1("sl-details",{class:a.classes.Details,disabled:e.hideDetails},h$1("style",{type:"text/css"},n),h$1("div",{slot:"summary",class:a.classes.DetailsContainer},h$1(TextSpanView,{type:"p"},h$1("span",{part:"sqm-cell-value",class:a.classes.BoldText},t.prettyValue)),h$1("div",{class:a.classes.BadgeContainer},u==="PENDING"&&t.dateScheduledFor?h$1("sl-badge",{class:d==="primary"?a.classes.RedeemBadge:a.classes.StatusBadge,type:d,pill:true},intl.formatMessage({id:"pendingForText",defaultMessage:e.pendingForText},{status:c,date:s(t.dateScheduledFor)})):h$1("sl-badge",{class:d==="primary"?a.classes.RedeemBadge:a.classes.StatusBadge,type:d,pill:true},c),t.dateExpires&&u==="AVAILABLE"&&h$1("sl-badge",{class:d==="primary"?a.classes.RedeemBadge:a.classes.StatusBadge,type:"info",pill:true},e.expiringText," "+s(t.dateExpires)))),h$1("div",null,u==="PENDING_REVIEW"&&((r=t.referral)===null||r===void 0?void 0:r.dateModerated)&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.referral.dateModerated).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),u==="PAYOUT_APPROVED"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PAYOUT_FAILED"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PAYOUT_CANCELLED"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PENDING_TAX_REVIEW"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PENDING_NEW_TAX_FORM"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PENDING_TAX_SUBMISSION"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="PENDING_PARTNER_CREATION"&&h$1("div",null,h$1(TextSpanView,{type:"p"},f)),u==="DENIED"&&((o=t.referral)===null||o===void 0?void 0:o.dateModerated)&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.referral.dateModerated).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)),".",e.deniedHelpText?" "+e.deniedHelpText:"")),t.dateGiven&&h$1("div",null,h$1(TextSpanView,{type:"p"},e.rewardReceivedText," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateGiven).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),u==="EXPIRED"&&t.dateExpires&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateExpires).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),u==="CANCELLED"&&t.dateCancelled&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateCancelled).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),u==="PENDING"&&t.dateScheduledFor&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateScheduledFor).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED))))," ",u==="AVAILABLE"&&t.dateExpires&&h$1("div",null,h$1(TextSpanView,{type:"p"},f," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},luxon.DateTime.fromMillis(t.dateExpires).setLocale(luxonLocale(e.locale)).toLocaleString(luxon.DateTime.DATE_MED)))),t.fuelTankCode&&h$1("div",null,e.fuelTankText," ",h$1("span",{class:a.classes.BoldText,part:"sqm-cell-value"},t.fuelTankCode))))}))};return e}();var ReferralTableRewardsColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Rewards";this.statusText="{status, select, AVAILABLE {Available} CANCELLED {Cancelled} PENDING {Pending} PENDING_REVIEW {Pending} PAYOUT_APPROVED {Payout Approved} PAYOUT_FAILED {Payout Failed} PAYOUT_CANCELLED {Payout Cancelled} PENDING_TAX_REVIEW {Pending} PENDING_NEW_TAX_FORM {Pending} PENDING_TAX_SUBMISSION {Pending} PENDING_PARTNER_CREATION {Pending} DENIED {Denied} EXPIRED {Expired} REDEEMED {Redeemed} other {Not available} }";this.statusLongText="{status, select, AVAILABLE {Reward expiring on} CANCELLED {Reward cancelled on} PENDING {Available on} PENDING_REVIEW {Pending since} PAYOUT_APPROVED {Reward approved for payout and was scheduled for payment based on your settings.} PAYOUT_FAILED {Payout failed due to a fulfillment issue and is currently being retried.} PAYOUT_CANCELLED {If you think this is a mistake, contact our Support team.} PENDING_TAX_REVIEW {Awaiting tax form review} PENDING_NEW_TAX_FORM {Invalid tax form. Submit a new form to receive your rewards.} PENDING_TAX_SUBMISSION {Submit your tax documents to receive your rewards} PENDING_PARTNER_CREATION {Complete your tax and cash payout setup to receive your rewards} DENIED {Denied on} EXPIRED {Reward expired on} other {Not available} }";this.fuelTankText="Your code is";this.rewardReceivedText="Reward received on";this.expiringText="Expiring in";this.pendingForText="{status} for {date}";this.deniedHelpText="Contact support if you think this is a mistake.";this.hideDetails=false;h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e,t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){console.log({statusText:this.statusText});return[2,h$1("sqm-referral-table-rewards-cell",{rewards:e.rewards,"tax-connection":t===null||t===void 0?void 0:t.taxConnection,"status-text":this.statusText,"status-long-text":this.statusLongText,"fuel-tank-text":this.fuelTankText,"reward-received-text":this.rewardReceivedText,"expiring-text":this.expiringText,"pending-for-text":this.pendingForText,"hide-details":this.hideDetails,"denied-help-text":this.deniedHelpText,locale:t===null||t===void 0?void 0:t.locale,exportparts:"sqm-cell-value"})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,h$1("sqm-referral-table-rewards-cell",{rewards:e.rewards,exportparts:"sqm-cell-value"})]}))}))};e.prototype.render=function(){useRequestRerender([this.columnTitle,this.statusText,this.statusLongText,this.fuelTankText,this.rewardReceivedText,this.expiringText,this.pendingForText,this.hideDetails]);return h$1(Host,{style:{display:"none"}})};return e}();var style={Badge:{"&::part(base)":{fontSize:"var(--sl-font-size-small)",padding:"4px 8px",whiteSpace:"pre-line"}},SubText:{fontSize:"var(--sl-font-size-small)",color:"var(--sl-color-neutral-500)",margin:"0"}};var sheet=createStyleSheet(style);var styleString=sheet.toString();var ReferralTableStatusCell=function(){function e(e){registerInstance(this,e)}e.prototype.render=function(){var e=this;var t=function(t){if(t==="PENDING")return"warning";if(t==="DENIED")return"danger";if(e.converted)return"success";return"warning"};return h$1("div",null,h$1("style",{type:"text/css"},styleString),h$1("sl-badge",{pill:true,type:t(this.fraudStatus),class:sheet.classes.Badge},this.statusText),this.statusSubText?h$1("p",{class:sheet.classes.SubText},this.statusSubText):null)};return e}();var ReferralTableStatusColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Status";this.convertedStatusText="Converted";this.inProgressStatusText="In Progress";this.pendingReviewStatusText="Pending";this.deniedStatusText="Denied";this.pendingReviewStatusSubText="Awaiting review";this.deniedStatusSubText="Detected self-referral";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,a,n;return __generator(this,(function(l){n=(t=e===null||e===void 0?void 0:e.fraudData)===null||t===void 0?void 0:t.moderationStatus;if(n==="DENIED"){r=this.deniedStatusText;a=this.deniedStatusSubText}else if(n==="PENDING"){r=this.pendingReviewStatusText;a=this.pendingReviewStatusSubText}else{r=e.dateConverted?this.convertedStatusText:this.inProgressStatusText}return[2,h$1("sqm-referral-table-status-cell",{"status-text":r,"status-sub-text":a,"fraud-status":n,converted:e.dateConverted?true:false})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(r){t=e.dateConverted?this.convertedStatusText:this.inProgressStatusText;return[2,h$1("sqm-referral-table-status-cell",{"status-text":t,converted:e.dateConverted?true:false})]}))}))};e.prototype.render=function(){useRequestRerender([this.columnTitle,this.convertedStatusText,this.inProgressStatusText]);return h$1(Host,{style:{display:"none"}})};return e}();var ReferralTableUserCell=function(){function e(e){registerInstance(this,e)}e.prototype.render=function(){return this.name};return e}();var ReferralTableUserColumn=function(){function e(e){registerInstance(this,e);this.columnTitle="Customer";this.anonymousUser="Anonymous User";this.deletedUser="Deleted User";h(this)}e.prototype.disconnectedCallback=function(){};e.prototype.renderCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,a,n,l,i,s,o,u;return __generator(this,(function(d){if(!(e===null||e===void 0?void 0:e.referredUser)&&!(e===null||e===void 0?void 0:e.referrerUser)){u=this.deletedUser}else if(!((t=e===null||e===void 0?void 0:e.referredUser)===null||t===void 0?void 0:t.firstName)&&!((r=e===null||e===void 0?void 0:e.referredUser)===null||r===void 0?void 0:r.lastName)&&!((a=e===null||e===void 0?void 0:e.referrerUser)===null||a===void 0?void 0:a.firstName)&&!((n=e===null||e===void 0?void 0:e.referrerUser)===null||n===void 0?void 0:n.lastName)){u=this.anonymousUser}else if(e===null||e===void 0?void 0:e.referrerUser){u=((l=e===null||e===void 0?void 0:e.referrerUser)===null||l===void 0?void 0:l.firstName)+" "+((i=e===null||e===void 0?void 0:e.referrerUser)===null||i===void 0?void 0:i.lastName)}else{u=((s=e===null||e===void 0?void 0:e.referredUser)===null||s===void 0?void 0:s.firstName)+" "+((o=e===null||e===void 0?void 0:e.referredUser)===null||o===void 0?void 0:o.lastName)}return[2,h$1("sqm-referral-table-user-cell",{name:u})]}))}))};e.prototype.renderLabel=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.columnTitle]}))}))};e.prototype.renderReferrerCell=function(e){return __awaiter(this,void 0,void 0,(function(){var t,r,a,n,l;return __generator(this,(function(i){if(!e){l=this.deletedUser}else if(!((t=e===null||e===void 0?void 0:e.referrerUser)===null||t===void 0?void 0:t.firstName)&&!((r=e.referrerUser)===null||r===void 0?void 0:r.lastName)){l=this.anonymousUser}else{l=((a=e===null||e===void 0?void 0:e.referrerUser)===null||a===void 0?void 0:a.firstName)+" "+((n=e===null||e===void 0?void 0:e.referrerUser)===null||n===void 0?void 0:n.lastName)}return[2,h$1("sqm-referral-table-user-cell",{name:l})]}))}))};e.prototype.render=function(){useRequestRerender([this.deletedUser,this.anonymousUser,this.columnTitle]);return h$1(Host,{style:{display:"none"}})};return e}();export{ReferralTable as sqm_referral_table,ReferralTableCell as sqm_referral_table_cell,ReferralTableGenericColumn as sqm_referral_table_column,ReferralTableDateCell as sqm_referral_table_date_cell,ReferralTableDateColumn as sqm_referral_table_date_column,ReferralTableRewardsCell as sqm_referral_table_rewards_cell,ReferralTableRewardsColumn as sqm_referral_table_rewards_column,ReferralTableStatusCell as sqm_referral_table_status_cell,ReferralTableStatusColumn as sqm_referral_table_status_column,ReferralTableUserCell as sqm_referral_table_user_cell,ReferralTableUserColumn as sqm_referral_table_user_column};