import { h, Host } from "@stencil/core";
import { state } from "./pn-product-pricelist-store";
import { sendDirectUrl, stampShopUrl } from "./data.js";
import { bolt, box_label } from "pn-design-assets/pn-assets/icons.js";
export class PnFindProductPricelistResult {
    constructor() {
        this.item = null;
        this.description = [];
        this.shownitems = [];
        this.showMeasurement = false;
        this.weightText = '';
    }
    componentWillLoad() {
        this.composeItems();
    }
    composeItems() {
        if (this.item.description) {
            this.description = this.item.description.split('#bullet').filter(x => x !== '');
        }
        this.showMeasurement = this.item.maxmått !== null || this.item.rulle !== null;
        this.shownitems = [this.item];
        // if (this.item.pricestamps) {
        //   this.shownitems.push({...this.item, priceagent: null, pricesenddirect: null});
        // }
        // if (this.item.priceagent) {
        //   this.shownitems.push({...this.item, pricestamps: null, pricesenddirect: null});
        // }
        // if (this.item.pricesenddirect) {
        //   this.shownitems.push({...this.item, pricestamps: null, priceagent: null});
        // }
        // // Parcels are always in KG. Letter KG must be converted from grams
        // this.weightText = (this.item.what === "parcel") ? this.item.maxweight + 'kg' :
        // (this.item.what === "letter" && this.item.maxweight > 999) ? Math.round(this.item.maxweight/1000) + " kg" : this.item.maxweight + " g";
    }
    render() {
        return (h(Host, { key: '0174101aee0ddd39c8d6aa8eda2c7e5a107675f9' }, this.shownitems.map(item => (h("pn-product-card", { "data-productid": item.id }, h("pn-illustration", { slot: "illustration", illustration: this.item.illustration }), h("div", { slot: "title" }, h("h2", null, item.name, " "), this.item.highestrankusp ? (this.item.highestrankusp === 'Billigast' ? (h("pn-titletag", { slot: "Billigast", icon: box_label }, this.item.highestrankusp)) : (h("pn-titletag", { slot: "Snabbast", icon: bolt, color: "blue700" }, this.item.highestrankusp))) : null), h("div", { slot: "content" }, h("div", { class: "content" }, this.item.description ? (h("div", { class: "description" }, this.description.map(desc => (h("li", null, desc))))) : null, this.item.info ? h("div", { class: "description" }, this.item.info) : null)), this.item.note ? (h("small", { slot: "note" }, h("p", null, this.item.note))) : null, this.item.additionalusp ? (h("div", { slot: "additionalUSP" })) : null, this.showMeasurement ? h("pn-product-card-info", { paket: this.item.maxmått, rulle: this.item.rulle }) : null, h("div", { slot: "cardprice" }, this.item.pricesenddirect ? (h("pn-product-card-price", { slot: "sendDirectPrice", label: state.i18n.senddirectcta, amount: this.item.pricesenddirect + '', currency: state.market.currency, url: sendDirectUrl, service: this.item.name + '-portal' })) : null, this.item.pricestamps ? (h("pn-product-card-price", { slot: "stampPrice", label: state.i18n.stampshopcta, amount: this.item.pricestamps + '', currency: state.market.currency, url: stampShopUrl, service: this.item.name + '-eshop' })) : null))
        // <pn-product-tile>
        //   <pn-illustration slot="illustration" illustration={ item.illustration }></pn-illustration>
        //   <div slot="content">
        //     <div class="content">
        //       <h3>{item.name}</h3>
        //       {(item.description) ? (<div class="description">{item.description}</div>) : null}
        //       {(item.info) ? (<div class="description">{item.info}</div>) : null}
        //     </div>
        //   </div>
        //   { item.maxweight ? (<pn-product-tile-info label={state.i18n.maxweightlabel} text={this.weightText}></pn-product-tile-info>) : null }
        //   {/* { item.maximummeasurements ? (<pn-product-tile-info label={state.i18n.maxmeasurementlabel} text={item.maximummeasurements}></pn-product-tile-info>) : null } */}
        //   { item.pricestamps ? (<pn-product-tile-price slot="price" label={state.i18n.stampshopcta} amount={item.pricestamps+''} currency={ state.market.currency }></pn-product-tile-price>) : null }
        //   {/* { item.priceagent ? (<pn-product-tile-price slot="price" label="" amount={item.priceagent+''} currency={ state.market.currency } url="https://shop.postnord.se/ebutik/default.aspx"></pn-product-tile-price>) : null } */}
        //   { item.pricesenddirect ? (<pn-product-tile-price slot="price" label={state.i18n.senddirectcta} amount={item.pricesenddirect+''} currency={ state.market.currency } url="https://portal.postnord.com/skickadirekt/"></pn-product-tile-price>) : null }
        //   { item.note ? (<small slot="note"><p>{item.note}</p></small>) : null }
        // </pn-product-tile>
        ))));
    }
    static get is() { return "pn-product-pricelist-result"; }
    static get originalStyleUrls() {
        return {
            "$": ["pn-product-pricelist-result.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["pn-product-pricelist-result.css"]
        };
    }
    static get properties() {
        return {
            "item": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "ProductPriceItem",
                    "resolved": "ProductPriceItem",
                    "references": {
                        "ProductPriceItem": {
                            "location": "import",
                            "path": "../../../globals/shared/productprice/product-price-types",
                            "id": "src/globals/shared/productprice/product-price-types.ts::ProductPriceItem"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "defaultValue": "null"
            },
            "description": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "string[]",
                    "resolved": "string[]",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "defaultValue": "[]"
            },
            "shownitems": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "ProductPriceItem[]",
                    "resolved": "ProductPriceItem[]",
                    "references": {
                        "ProductPriceItem": {
                            "location": "import",
                            "path": "../../../globals/shared/productprice/product-price-types",
                            "id": "src/globals/shared/productprice/product-price-types.ts::ProductPriceItem"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "defaultValue": "[]"
            },
            "showMeasurement": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "show-measurement",
                "reflect": false,
                "defaultValue": "false"
            }
        };
    }
    static get states() {
        return {
            "weightText": {}
        };
    }
    static get watchers() {
        return [{
                "propName": "item",
                "methodName": "composeItems"
            }];
    }
}
//# sourceMappingURL=pn-product-pricelist-result.js.map
