/*
 * Copyright (C) 2016-2020 Kano Computing Ltd.
 * License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 */
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
/**

`kano-animated-svg` controls changes of path descriptors of a path SVG element.
It allows you to define a set of SVG paths and switch between them.

Example:
    <kano-animated-svg paths="[[paths]]"
                       selected="start"></kano-animated-svg>

 The following custom properties and mixins are also available for styling:

 Custom property | Description | Default
 ----------------|-------------|----------
 `--kano-animated-path` | Mixin applied to the path SVG element | `{}`

@group Kano Elements
@hero hero.svg
@demo ./demo.html
*/
import { LitElement, customElement, css, html, property, query } from 'lit-element/lit-element.js';
let KanoAnimatedSvg = class KanoAnimatedSvg extends LitElement {
    constructor() {
        super(...arguments);
        this.paths = {};
        this.width = 16;
        this.height = 16;
    }
    static get styles() {
        return [css `
            :host {
                display: block;
                position: relative;
            }
            svg {
                position: absolute;
                top: 0px;
                left: 0px;
                width: 100%;
                height: 100%;
            }
            path {
                transition: all ease-in-out 200ms;
            }
        `];
    }
    render() {
        const pathData = (this.paths && this.selected) ? this.paths[this.selected] : "";
        return html `
            <svg xmlns="http://www.w3.org/2000/svg" id="svg">
                <path id="path" class="animatable" d=${pathData}></path>
            </svg>
        `;
    }
    updated(changes) {
        if (changes.has('width') || changes.has('height')) {
            this.updateViewBox();
        }
    }
    updateViewBox() {
        if (!this.svgEl) {
            return;
        }
        this.svgEl.setAttribute('width', this.width.toString());
        this.svgEl.setAttribute('height', this.height.toString());
        this.svgEl.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
    }
};
__decorate([
    property({ type: Object })
], KanoAnimatedSvg.prototype, "paths", void 0);
__decorate([
    property({ type: String })
], KanoAnimatedSvg.prototype, "selected", void 0);
__decorate([
    property({ type: Number })
], KanoAnimatedSvg.prototype, "width", void 0);
__decorate([
    property({ type: Number })
], KanoAnimatedSvg.prototype, "height", void 0);
__decorate([
    query('svg')
], KanoAnimatedSvg.prototype, "svgEl", void 0);
__decorate([
    query('path')
], KanoAnimatedSvg.prototype, "pathEl", void 0);
KanoAnimatedSvg = __decorate([
    customElement('kano-animated-svg')
], KanoAnimatedSvg);
export { KanoAnimatedSvg };
//# sourceMappingURL=kano-animated-svg.js.map