<template>
    <view>
        <van-transition
            name="slide-down"
            :show="show"
            custom-class="van-notify__container"
            :custom-style="'z-index: ' + zIndex + '; top: ' + utils.addUnit(top)"
            @tap.native="onTap"
        >
            <view :class="'van-notify van-notify--' + type" :style="'background:' + background + ';color:' + color + ';'">
                <view v-if="safeAreaInsetTop" :style="'height: ' + statusBarHeight + 'px'" />
                <text>{{ message }}</text>
            </view>
        </van-transition>
    </view>
</template>
<script module="utils" lang="wxs" src="@/node_modules/@vant/weapp/lib/wxs/utils.wxs"></script>
<script>
'use strict';
Object.defineProperty(exports, '__esModule', {
    value: true
});
var component_1 = require('../common/component');
var color_1 = require('../common/color');
component_1.VantComponent({
    props: {
        message: String,
        background: String,
        type: {
            type: String,
            value: 'danger'
        },
        color: {
            type: String,
            value: color_1.WHITE
        },
        duration: {
            type: Number,
            value: 3000
        },
        zIndex: {
            type: Number,
            value: 110
        },
        safeAreaInsetTop: {
            type: Boolean,
            value: false
        },
        top: null
    },
    data: {
        show: false
    },
    created: function () {
        var statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
        this.setData({
            statusBarHeight: statusBarHeight
        });
    },
    methods: {
        show: function () {
            var that = this;
            var _a = this;
            var duration = _a.duration;
            var onOpened = _a.onOpened;
            clearTimeout(this.timer);
            this.setData({
                show: true
            });
            this.$nextTick(onOpened);
            if (duration > 0 && duration !== Infinity) {
                this.timer = setTimeout(function () {
                    that.hide();
                }, duration);
            }
        },
        hide: function () {
            var onClose = this.onClose;
            clearTimeout(this.timer);
            this.setData({
                show: false
            });
            this.$nextTick(onClose);
        },
        onTap: function (event) {
            var onClick = this.onClick;
            if (onClick) {
                onClick(event.detail);
            }
        }
    }
});
</script>
<style>
@import './index.css';
</style>
