import { h } from "@stencil/core";
import { linker } from '../../../utils/input-linker';
export class BceElementVideoTemplate {
    constructor() {
        this.metadata = {};
        this.location = '';
        this.autoplay = false;
        this.labelAutoplay = 'Autoplay';
        this.placeholderLocation = 'Video URL';
        this._link = linker(this, this.handleInput);
        this._location = this._link('location');
        this._autoplay = this._link('autoplay');
    }
    handleInput(name, event) {
        const input = event.target;
        if (!input)
            return;
        event.cancelBubble = true;
        this[name] = input.value;
        this.value = this.updateValue({ [name]: input.value });
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    updateValue(part = {}) {
        const current = {
            location: this.location,
            autoplay: this.autoplay,
            metadata: Object.assign({}, this.metadata)
        };
        return Object.assign({}, current, part);
    }
    componentDidLoad() {
        this.value = this.updateValue();
        this.el.dispatchEvent(new Event('input', { bubbles: true }));
    }
    render() {
        const buttons = {
            labelUploadButton: this.labelUploadButton,
            labelDeleteButton: this.labelDeleteButton
        };
        return [
            h("bce-upload-input", Object.assign({}, this._location, buttons)),
            h("bce-input", Object.assign({ type: "switch" }, this._autoplay))
        ];
    }
    static get is() { return "bce-element-video-template"; }
    static get properties() { return {
        "value": {
            "type": "unknown",
            "mutable": true,
            "complexType": {
                "original": "VideoTemplate",
                "resolved": "undefined | { readonly location: string; readonly autoplay: boolean; readonly metadata: ElementMetadata; }",
                "references": {
                    "VideoTemplate": {
                        "location": "local"
                    }
                }
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            }
        },
        "metadata": {
            "type": "unknown",
            "mutable": false,
            "complexType": {
                "original": "Block.ElementMetadata",
                "resolved": "ElementMetadata",
                "references": {
                    "Block": {
                        "location": "import",
                        "path": "../../../models/block"
                    }
                }
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "defaultValue": "{}"
        },
        "location": {
            "type": "string",
            "mutable": true,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "location",
            "reflect": false,
            "defaultValue": "''"
        },
        "autoplay": {
            "type": "boolean",
            "mutable": true,
            "complexType": {
                "original": "boolean",
                "resolved": "boolean",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "autoplay",
            "reflect": false,
            "defaultValue": "false"
        },
        "labelUploadButton": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string | undefined",
                "references": {}
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-upload-button",
            "reflect": false
        },
        "labelDeleteButton": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string | undefined",
                "references": {}
            },
            "required": false,
            "optional": true,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-delete-button",
            "reflect": false
        },
        "labelAutoplay": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "label-autoplay",
            "reflect": false,
            "defaultValue": "'Autoplay'"
        },
        "placeholderLocation": {
            "type": "string",
            "mutable": false,
            "complexType": {
                "original": "string",
                "resolved": "string",
                "references": {}
            },
            "required": false,
            "optional": false,
            "docs": {
                "tags": [],
                "text": ""
            },
            "attribute": "placeholder-location",
            "reflect": false,
            "defaultValue": "'Video URL'"
        }
    }; }
    static get elementRef() { return "el"; }
}
