import { Component, h, Prop } from '@stencil/core';
import dotProp from 'dot-prop-immutable';
import { openWormhole } from 'stencil-wormhole';
export class ScSessionDetail {
  getPropByPath(object, path, defaultValue) {
    if (object && path.length)
      return this.getPropByPath(object[path.shift()], path, defaultValue);
    return object === undefined ? defaultValue : object;
  }
  getValue() {
    var _a, _b;
    if (!this.value) {
      return;
    }
    let value = '';
    // get metadata value
    if (this.value === 'metadata') {
      return dotProp.get((_a = this === null || this === void 0 ? void 0 : this.order) === null || _a === void 0 ? void 0 : _a.metadata, this.value || '');
    }
    // get value
    value = dotProp.get(this === null || this === void 0 ? void 0 : this.order, this.value || '');
    // if number, format it
    if (typeof value === 'number') {
      value = h("sc-format-number", { type: "currency", currency: (_b = this === null || this === void 0 ? void 0 : this.order) === null || _b === void 0 ? void 0 : _b.currency, value: value });
    }
    return value;
  }
  render() {
    if (this.loading) {
      return (h("div", { part: "base", class: {
          'order-detail': true,
        } },
        h("span", { part: "label", class: "order-detail__label" },
          h("sc-skeleton", { style: { width: '60px', height: '8px', display: 'inline-block' } })),
        h("span", { part: "value", class: "order-detail__value" },
          h("sc-skeleton", { style: { width: '120px', display: 'inline-block' } }))));
    }
    const value = this.getValue();
    if (!value) {
      if (!this.fallback) {
        return;
      }
    }
    return (h("div", { part: "base", class: {
        'order-detail': true,
      } },
      h("span", { part: "label", class: "order-detail__label" },
        h("slot", { name: "label" }, this.label)),
      h("span", { part: "value", class: "order-detail__value" },
        h("slot", { name: "value" }, value || this.fallback))));
  }
  static get is() { return "sc-order-detail"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["sc-order-detail.scss"]
  }; }
  static get styleUrls() { return {
    "$": ["sc-order-detail.css"]
  }; }
  static get properties() { return {
    "order": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Checkout",
        "resolved": "Checkout",
        "references": {
          "Checkout": {
            "location": "import",
            "path": "../../../../types"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "value": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "value",
      "reflect": false
    },
    "fallback": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "fallback",
      "reflect": false
    },
    "metaKey": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "meta-key",
      "reflect": false
    },
    "loading": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "loading",
      "reflect": false
    },
    "label": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "label",
      "reflect": false
    }
  }; }
}
openWormhole(ScSessionDetail, ['order', 'loading'], false);
