import { Component, Element, Event, h, Listen, Prop, State } from "@stencil/core";
import * as translation from "../../translation";
export class IntergiroMerchantTableRow {
  constructor() {
    this.opened = "";
  }
  componentWillLoad() {
    this.t = translation.create(this.element);
  }
  handleColumnClick(column) {
    this.opened = column;
    this.columnClicked.emit({ id: this.merchant.id, column });
  }
  handleSelected(e) {
    this.merchantSelected.emit({ merchant: this.merchant, checked: e.detail.selected });
    e.stopPropagation();
    e.preventDefault();
  }
  render() {
    var _a;
    return [
      !this.abbrivated && (h("td", null,
        h("smoothly-checkbox", { selected: this.selected }))),
      h("td", null,
        h("section", { class: "openable" + (this.opened == "number" ? " opened" : ""), onClick: () => this.handleColumnClick("number") }, (_a = this.merchant.number) !== null && _a !== void 0 ? _a : this.merchant.id)),
      h("td", null,
        h("section", { class: "openable" + (this.opened == "information" ? " opened" : ""), onClick: () => this.handleColumnClick("information") }, this.merchant.name)),
      h("td", null,
        h("section", { class: "openable" + (this.opened == "settlement" ? " opened" : ""), onClick: () => this.handleColumnClick("settlement") }, this.merchant.reconciliation.account)),
      h("td", null,
        h("section", { class: "openable" + (this.opened == "rules" ? " opened" : ""), onClick: () => this.handleColumnClick("rules") }, Object.values(this.merchant.rules).reduce((r, v) => (v ? (r += v.length) : r), 0) + " " + this.t("rules"))),
    ];
  }
  static get is() { return "ig-merchant-table-row"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["style.css"]
  }; }
  static get styleUrls() { return {
    "$": ["style.css"]
  }; }
  static get properties() { return {
    "abbrivated": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "abbrivated",
      "reflect": false
    },
    "merchant": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Merchant",
        "resolved": "Merchant",
        "references": {
          "Merchant": {
            "location": "import",
            "path": "@payfunc/model-acquirer"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "selected": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean | undefined",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "selected",
      "reflect": true
    },
    "opened": {
      "type": "string",
      "mutable": true,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "opened",
      "reflect": false,
      "defaultValue": "\"\""
    }
  }; }
  static get states() { return {
    "t": {}
  }; }
  static get events() { return [{
      "method": "columnClicked",
      "name": "columnClicked",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }, {
      "method": "merchantSelected",
      "name": "merchantSelected",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "complexType": {
        "original": "{ merchant: Merchant; checked: boolean }",
        "resolved": "{ merchant: Merchant; checked: boolean; }",
        "references": {
          "Merchant": {
            "location": "import",
            "path": "@payfunc/model-acquirer"
          }
        }
      }
    }]; }
  static get elementRef() { return "element"; }
  static get listeners() { return [{
      "name": "checked",
      "method": "handleSelected",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
