import { r as registerInstance, d as createEvent, B as Build, h } from './index-33e43734.js';
import { f as formatUSD } from './formatUSD-dae09890.js';

const totallerCardsCss = "floodteam-totaller-cards .flex-container{display:flex;flex-wrap:wrap}floodteam-totaller-cards ion-card{min-width:6rem;max-width:10rem;min-height:6rem;padding:0px 10px 10px 10px;flex-basis:18%}floodteam-totaller-cards h1{font-size:1rem;color:var(--ion-text-color)}floodteam-totaller-cards h2{font-size:.8rem;color:var(--ion-text-color)}floodteam-totaller-cards h3{font-size:.6rem}@media only screen and (max-width:415.9px){floodteam-totaller-cards .flex-container{justify-content:space-evenly}}";

let TotallerCards = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.fireenjinFetch = createEvent(this, "fireenjinFetch", 7);
  }
  async onSuccess(event) {
    var _a, _b;
    if (event.detail.endpoint === "findTotaller") {
      this.totaller = ((_b = (_a = event === null || event === void 0 ? void 0 : event.detail) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.totaller) || null;
    }
  }
  formatValue(value, sum) {
    return (sum === null || sum === void 0 ? void 0 : sum.format) === "usd" ? formatUSD(value) : value;
  }
  async fetchTotaller() {
    this.fireenjinFetch.emit({
      endpoint: "findTotaller",
      params: {
        id: this.totallerId,
      },
    });
  }
  async componentDidLoad() {
    if (!(Build === null || Build === void 0 ? void 0 : Build.isBrowser))
      return;
    this.fetchTotaller();
  }
  render() {
    var _a;
    return (h("div", { class: "flex-container" }, Object.entries((((_a = this.totaller) === null || _a === void 0 ? void 0 : _a.sums) || {})).map(([sumName, value]) => {
      var _a;
      return (h("ion-card", { class: "card" }, h("h2", null, value === null || value === void 0 ? void 0 : value.name), h("h3", null, value === null || value === void 0 ? void 0 : value.description), h("h1", null, this.formatValue(((_a = this.totals) === null || _a === void 0 ? void 0 : _a[sumName]) || 0, value))));
    })));
  }
};
TotallerCards.style = totallerCardsCss;

export { TotallerCards as floodteam_totaller_cards };

//# sourceMappingURL=floodteam-totaller-cards.entry.js.map