var HaikuVueAdapter = (function () {
'use strict';

var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};



function unwrapExports (x) {
	return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}

function createCommonjsModule(fn, module) {
	return module = { exports: {} }, fn(module, module.exports), module.exports;
}

var StringUtils = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.ALPHABET = 'abcdefghijklmnopqrstuvwxyz';
function randomString(len) {
    var str = '';
    while (str.length < len) {
        str += exports.ALPHABET[Math.floor(Math.random() * exports.ALPHABET.length)];
    }
    return str;
}
exports.randomString = randomString;

});

unwrapExports(StringUtils);
var StringUtils_1 = StringUtils.ALPHABET;
var StringUtils_2 = StringUtils.randomString;

var getParsedProperty_1 = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
var HAIKU_CONFIG_PROPS_RENAME_MAPPING = {
    haikuOptions: 'options',
    haikuStates: 'states',
    haikuInitialStates: 'states',
    haikuEventHandlers: 'eventHandlers',
    haikuTimelines: 'timelines',
    haikuVanities: 'vanities',
};
/**
 * Parses a specific property specified by `verboseKeyName` from the `props`
 * object, renaming and merging legacy props as necessary.
 * This method is mainly used by the React and Vue adapters.
 * @param props
 * @param verboseKeyName
 * @returns {Object}
 */
var getParsedProperty = function (props, verboseKeyName) {
    var result = {};
    var haikuConfigRemappedKey = HAIKU_CONFIG_PROPS_RENAME_MAPPING[verboseKeyName];
    var haikuConfigFinalKey = haikuConfigRemappedKey || verboseKeyName;
    // Special case: Options used to be a separate object, so if we see this legacy
    // format, just merge it in with the root level of the new options
    if (haikuConfigFinalKey === 'options') {
        for (var optionsSubKey in props[verboseKeyName]) {
            result[optionsSubKey] = props[verboseKeyName][optionsSubKey];
        }
    }
    else {
        result[haikuConfigFinalKey] = props[verboseKeyName];
    }
    return result;
};
exports.default = getParsedProperty;

});

unwrapExports(getParsedProperty_1);

var HaikuVueDOMAdapter_1 = createCommonjsModule(function (module, exports) {
var __assign = (commonjsGlobal && commonjsGlobal.__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 });


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.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;

});

unwrapExports(HaikuVueDOMAdapter_1);

var vueDom = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });

exports.default = HaikuVueDOMAdapter_1.default;

});

unwrapExports(vueDom);

/**
 * Copyright (c) Haiku 2016-2018. All rights reserved.
 */

var vue = vueDom.default;

return vue;

}());
