import { PopupDefaultProps } from './props';
import { compareVersion } from '../_util/compareVersion';
import '../_util/assert-component2';
var SDKVersion = my.SDKVersion;
var isOldVersion = compareVersion(SDKVersion, '2.0.0') < 0;
var component2 = my.canIUse('component2');
Component({
    props: PopupDefaultProps,
    data: {
        closing: false,
        isOldVersion: isOldVersion,
    },
    didUpdate: function (prevProps) {
        if (component2) {
            return;
        }
        var _a = this.props, visible = _a.visible, duration = _a.duration, animation = _a.animation;
        if (prevProps.visible && !visible) {
            if (animation && duration > 0) {
                this.setData({ closing: true });
            }
        }
    },
    deriveDataFromProps: function (nextProps) {
        var visible = nextProps.visible, duration = nextProps.duration, animation = nextProps.animation;
        if (this.props.visible && !visible) {
            if (animation && duration > 0) {
                this.setData({ closing: true });
            }
        }
    },
    methods: {
        onTapMask: function () {
            var closing = this.data.closing;
            if (closing) {
                return;
            }
            var onClose = this.props.onClose;
            if (onClose) {
                onClose();
            }
        },
        onAnimationEnd: function () {
            var closing = this.data.closing;
            if (closing) {
                this.setData({ closing: false });
            }
        },
    },
});
