import { h } from "@stencil/core";
import { ResolveLocation } from '../../../models/resolve-location';
export class BceElementAudio {
    constructor() {
        this.resolveLocation = ResolveLocation.NOOP;
        this.url = '';
    }
    componentWillLoad() {
        if (!this.template)
            return;
        if (this.template.location.startsWith('BCE://'))
            this.resolveLocation(this.template.location).then(url => (this.url = url));
        else
            this.url = this.template.location;
    }
    render() {
        if (!this.template)
            return null;
        return (h("audio", { key: this.url, autoplay: this.template.autoplay, controls: true },
            h("source", { src: this.url })));
    }
    static get is() { return "bce-element-audio"; }
    static get originalStyleUrls() { return {
        "$": ["bce-element-audio.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["bce-element-audio.css"]
    }; }
    static get properties() { return {
        "template": {
            "type": "unknown",
            "mutable": false,
            "complexType": {
                "original": "Block.ElementAudio.Template",
                "resolved": "undefined | { readonly location: string; readonly autoplay: boolean; readonly metadata: ElementMetadata; }",
                "references": {
                    "Block": {
                        "location": "import",
                        "path": "../../../models/block"
                    }
                }
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            }
        },
        "resolveLocation": {
            "type": "unknown",
            "mutable": false,
            "complexType": {
                "original": "ResolveLocation",
                "resolved": "(location: string) => Promise<string>",
                "references": {
                    "ResolveLocation": {
                        "location": "import",
                        "path": "../../../models/resolve-location"
                    }
                }
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "defaultValue": "ResolveLocation.NOOP"
        }
    }; }
    static get states() { return {
        "url": {}
    }; }
}
