// Stencil
import { h } from "@stencil/core";
// Tools
import { MediaTool } from '../../../tools/media-tool';
import { MarkdownTool } from '../../../tools/markdown-tool';
export class AudioContent {
    constructor() {
        // Properties
        this.name = "Audio";
        this.image = [];
        this.audioTitle = '';
        this.audioSource = [];
        this.script = '';
        this.transcriptLabel = '';
        // States
        this.sourceId = 'id_' + (Math.random() * 1000000);
        this.transcriptDisplayed = true;
        this.transcriptButtonDisplayed = false;
    }
    ////////////////////////////////////////////////////////////////
    // User Interactions
    ////////////////////////////////////////////////////////////////
    /**
     * Display the transcript button when user clicks
     * on the play audio button
     */
    displayTranscriptButton() {
        if (this.script) {
            this.transcriptButtonDisplayed = true;
        }
    }
    /**
    * The user wants to display the transcript
    */
    displayTranscript() {
        this.transcriptDisplayed = true;
    }
    ////////////////////////////////////////////////////////////////
    // Render
    ////////////////////////////////////////////////////////////////
    render() {
        return (h("div", { class: 'main-container' },
            h("div", { class: 'header-container' },
                h("p", { class: 'header-text' }, this.name)),
            h("div", { class: 'picture-container', style: { backgroundImage: 'url(' + MediaTool.imageL(this.image) + ')' } },
                h("div", { class: 'audio-presentation-container' },
                    h("slot", { name: "audio-text" }),
                    h("div", { class: 'audio-player-container' },
                        h("audio-player", { contentId: this.sourceId, audioTitle: this.audioTitle, openTranscript: true, src: MediaTool.audio(this.audioSource) })))),
            h("div", { class: "transcript-container" },
                this.transcriptButtonDisplayed && !this.transcriptDisplayed &&
                    h("ion-button", { size: 'small', color: 'tertiary', class: 'audio-transcript-button', onClick: () => this.displayTranscript() }, this.transcriptLabel),
                this.script && this.transcriptDisplayed &&
                    h("div", { class: 'text-container', innerHTML: MarkdownTool.render(this.script) }))));
    }
    static get is() { return "audio-content"; }
    static get originalStyleUrls() { return {
        "$": ["audio-content.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["audio-content.css"]
    }; }
    static get properties() { return {
        "name": {
            "type": "string",
            "mutable": true,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "name",
            "reflect": false,
            "defaultValue": "\"Audio\""
        },
        "image": {
            "type": "unknown",
            "mutable": false,
            "complexType": {
                "original": "MediaElement[]",
                "resolved": "MediaElement[]",
                "references": {
                    "MediaElement": {
                        "location": "import",
                        "path": "../../../models/media/media-model"
                    }
                }
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "defaultValue": "[]"
        },
        "audioTitle": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "audio-title",
            "reflect": false,
            "defaultValue": "''"
        },
        "audioSource": {
            "type": "unknown",
            "mutable": false,
            "complexType": {
                "original": "MediaElement[]",
                "resolved": "MediaElement[]",
                "references": {
                    "MediaElement": {
                        "location": "import",
                        "path": "../../../models/media/media-model"
                    }
                }
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "defaultValue": "[]"
        },
        "script": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "script",
            "reflect": false,
            "defaultValue": "''"
        },
        "transcriptLabel": {
            "type": "string",
            "mutable": true,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "transcript-label",
            "reflect": false,
            "defaultValue": "''"
        }
    }; }
    static get states() { return {
        "sourceId": {},
        "transcriptDisplayed": {},
        "transcriptButtonDisplayed": {}
    }; }
    static get listeners() { return [{
            "name": "audioPlayed",
            "method": "displayTranscriptButton",
            "target": undefined,
            "capture": false,
            "passive": false
        }]; }
}
