// Stencil
import { h } from "@stencil/core";
// Tools
import { MarkdownTool } from '../../../../tools/markdown-tool';
// Constants
const MAX_PLACE_DESCRIPTION_LENGTH = 200;
export class PlacePresentationDescription {
    constructor() {
        // Props
        this.description = '';
        this.descriptionTitle = '';
        this.seeMoreButton = '';
        // States
        this.moreDescription = false; // Whether to display more desription
        // Internal variables
        this.workingPlaceDescription = '';
    }
    ////////////////////////////////////////////////////////////////
    // Life Cycle
    ////////////////////////////////////////////////////////////////
    /**
     * Override
     */
    componentWillLoad() {
        // Shorten the place description
        this.workingPlaceDescription = this.description.slice(0, MAX_PLACE_DESCRIPTION_LENGTH);
        if (this.workingPlaceDescription.length > MAX_PLACE_DESCRIPTION_LENGTH) {
            this.workingPlaceDescription = this.workingPlaceDescription.concat('...');
        }
    }
    ////////////////////////////////////////////////////////////////
    // User Interactions
    ////////////////////////////////////////////////////////////////
    /**
     * Enable the full description mode
     */
    displayMoreDescription() {
        this.moreDescription = true;
        this.workingPlaceDescription = this.description;
    }
    ////////////////////////////////////////////////////////////////
    // Render
    ////////////////////////////////////////////////////////////////
    render() {
        return (h("div", null,
            h("h4", { class: 'place-section-title' }, this.descriptionTitle),
            h("div", { class: 'place-description', innerHTML: MarkdownTool.render(this.workingPlaceDescription) }),
            !this.moreDescription
                ?
                    h("ion-button", { fill: 'clear', color: 'primary', onClick: () => this.displayMoreDescription() },
                        "+ ",
                        this.seeMoreButton)
                :
                    h("br", null)));
    }
    static get is() { return "place-presentation-description"; }
    static get originalStyleUrls() { return {
        "$": ["place-presentation-description.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["place-presentation-description.css"]
    }; }
    static get properties() { return {
        "description": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "description",
            "reflect": false,
            "defaultValue": "''"
        },
        "descriptionTitle": {
            "type": "string",
            "mutable": true,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "description-title",
            "reflect": false,
            "defaultValue": "''"
        },
        "seeMoreButton": {
            "type": "string",
            "mutable": true,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "see-more-button",
            "reflect": false,
            "defaultValue": "''"
        }
    }; }
    static get states() { return {
        "moreDescription": {}
    }; }
}
