"use strict";
/**
 * Copyright (c) Haiku 2016-2018. All rights reserved.
 */
var __assign = (this && this.__assign) || Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
        s = arguments[i];
        for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
            t[p] = s[p];
    }
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
var StringUtils_1 = require("../../helpers/StringUtils");
var getParsedProperty_1 = require("../../helpers/getParsedProperty");
function clearProps(props) {
    var result = {};
    for (var verboseKeyName in props) {
        if (props[verboseKeyName] === undefined) {
            continue;
        }
        result = __assign({}, result, getParsedProperty_1.default(props, verboseKeyName));
    }
    return result;
}
// tslint:disable-next-line:function-name
function HaikuVueDOMAdapter(haikuComponentFactory) {
    return {
        props: {
            // We use null (which is the equivalent of 'any') for Boolean values
            // because Vue does typecasting for us, which sets undefined to false.
            automount: null,
            autoplay: null,
            forceFlush: null,
            freeze: null,
            loop: null,
            alwaysComputeSizing: null,
            useWebkitPrefix: null,
            seed: String,
            sizing: String,
            timestamp: Number,
            frame: Function,
            clock: Object,
            preserve3d: String,
            contextMenu: String,
            position: String,
            overflowX: String,
            overflowY: String,
            overflow: String,
            mixpanel: String,
            interactionMode: Object,
            states: Object,
            eventHandlers: Object,
            timelines: Object,
            vanities: Object,
            children: Array,
            placeholder: Object,
            // LEGACY
            haikuOptions: Object,
        },
        mounted: function () {
            var _this = this;
            var clearedProps = clearProps(this.$props);
            this.haiku = haikuComponentFactory(this.$el, __assign({}, clearedProps, { ref: this.$el, onHaikuComponentWillInitialize: function (component) {
                    _this.$emit('haikuComponentWillInitialize', component);
                }, onHaikuComponentDidMount: function (component) {
                    _this.$emit('haikuComponentDidMount', component);
                }, onHaikuComponentWillMount: function (component) {
                    _this.$emit('haikuComponentWillMount', component);
                }, onHaikuComponentDidInitialize: function (component) {
                    _this.$emit('haikuComponentDidInitialize', component);
                }, onHaikuComponentWillUnmount: function (component) {
                    _this.$emit('haikuComponentWillUnmount', component);
                } }));
        },
        updated: function () {
            var clearedProps = clearProps(this.$props);
            this.haiku.assignConfig(clearedProps);
        },
        destroyed: function () {
            this.haiku.callUnmount();
        },
        render: function (createElement) {
            return createElement('div', {
                attrs: {
                    id: 'haiku-vueroot-' + StringUtils_1.randomString(24),
                },
                style: {
                    position: 'relative',
                    margin: 0,
                    padding: 0,
                    border: 0,
                    width: '100%',
                    height: '100%',
                    transform: 'matrix3d(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)',
                },
            });
        },
    };
}
exports.default = HaikuVueDOMAdapter;
//# sourceMappingURL=HaikuVueDOMAdapter.js.map