// Stencil
import { h } from "@stencil/core";
// Tools
import { MarkdownTool } from '../../../../tools/markdown-tool';
// Constants
const MAX_COMPOSITION_DESCRIPTION_LENGTH = 200;
export class CompositionDescription {
    constructor() {
        // Props
        this.compositionTitle = '';
        this.description = '';
        this.seeMoreButton = '';
        // States
        this.moreDescription = false; // Whether to display more desription
        // Internal variables
        this.workingCompositionDescription = '';
    }
    ////////////////////////////////////////////////////////////////
    // Life Cycle
    ////////////////////////////////////////////////////////////////
    /**
     * Override
     */
    componentWillLoad() {
        this.workingCompositionDescription = this.description.slice(0, MAX_COMPOSITION_DESCRIPTION_LENGTH);
        if (this.description.length > MAX_COMPOSITION_DESCRIPTION_LENGTH) {
            this.workingCompositionDescription = this.workingCompositionDescription.concat('...');
        }
    }
    ////////////////////////////////////////////////////////////////
    // User Interactions
    ////////////////////////////////////////////////////////////////
    /**
     * Enable the full description mode
     */
    displayMoreDescription() {
        this.moreDescription = true;
        this.workingCompositionDescription = this.description;
    }
    ////////////////////////////////////////////////////////////////
    // Render
    ////////////////////////////////////////////////////////////////
    render() {
        return (h("section", { id: 'info' },
            h("div", { class: 'composition-description-container' },
                h("h4", { class: 'composition-section-title' }, this.compositionTitle),
                h("div", { class: 'composition-description-text', innerHTML: MarkdownTool.render(this.workingCompositionDescription) }),
                !this.moreDescription &&
                    h("ion-button", { fill: 'clear', color: 'primary', size: 'small', class: 'detail-button', onClick: () => this.displayMoreDescription() }, this.seeMoreButton))));
    }
    static get is() { return "composition-description"; }
    static get originalStyleUrls() { return {
        "$": ["composition-description.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["composition-description.css"]
    }; }
    static get properties() { return {
        "compositionTitle": {
            "type": "string",
            "mutable": true,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "composition-title",
            "reflect": false,
            "defaultValue": "''"
        },
        "description": {
            "type": "string",
            "mutable": true,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "description",
            "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": {}
    }; }
}
