import "../styles/reset.css";
import "./notify.less";
import { Transition as __WEBPACK_EXTERNAL_MODULE_vue_Transition__, computed as __WEBPACK_EXTERNAL_MODULE_vue_computed__, createVNode as __WEBPACK_EXTERNAL_MODULE_vue_createVNode__, defineComponent as __WEBPACK_EXTERNAL_MODULE_vue_defineComponent__, nextTick as __WEBPACK_EXTERNAL_MODULE_vue_nextTick__, onMounted as __WEBPACK_EXTERNAL_MODULE_vue_onMounted__, onUnmounted as __WEBPACK_EXTERNAL_MODULE_vue_onUnmounted__, ref as __WEBPACK_EXTERNAL_MODULE_vue_ref__, render as __WEBPACK_EXTERNAL_MODULE_vue_render__, vShow as __WEBPACK_EXTERNAL_MODULE_vue_vShow__, watch as __WEBPACK_EXTERNAL_MODULE_vue_watch__, withDirectives as __WEBPACK_EXTERNAL_MODULE_vue_withDirectives__ } from "vue";
import { PropTypes as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__, bkZIndexManager as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_bkZIndexManager__, isElement as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_isElement__ } from "../shared";
import { toType as __WEBPACK_EXTERNAL_MODULE_vue_types_22de060a_toType__ } from "vue-types";
import { usePrefix as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_config_provider_fe8577a3_usePrefix__ } from "../config-provider";
import { Close as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_icon_a97c79c3_Close__, Error as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_icon_a97c79c3_Error__, Info as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_icon_a97c79c3_Info__, Success as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_icon_a97c79c3_Success__, Warn as __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_icon_a97c79c3_Warn__ } from "../icon";

;// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
function _typeof(o) {
  "@babel/helpers - typeof";

  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
    return typeof o;
  } : function (o) {
    return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  }, _typeof(o);
}

;// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js

function toPrimitive(t, r) {
  if ("object" != _typeof(t) || !t) return t;
  var e = t[Symbol.toPrimitive];
  if (void 0 !== e) {
    var i = e.call(t, r || "default");
    if ("object" != _typeof(i)) return i;
    throw new TypeError("@@toPrimitive must return a primitive value.");
  }
  return ("string" === r ? String : Number)(t);
}

;// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js


function toPropertyKey(t) {
  var i = toPrimitive(t, "string");
  return "symbol" == _typeof(i) ? i : i + "";
}

;// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js

function _defineProperty(e, r, t) {
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
    value: t,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[r] = t, e;
}

;// external "vue"

;// external "../shared"

;// ../../packages/hooks/use-message.ts

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/*
 * Tencent is pleased to support the open source community by making
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
 *
 * Copyright (C) 2025 Tencent.  All rights reserved.
 *
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
 *
 * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
 *
 * ---------------------------------------------------
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
 * the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */


var instances = {
  'top-left': [],
  'top-right': [],
  'bottom-left': [],
  'bottom-right': []
};
var seed = 1;
// 更新指定位置的所有 Message 实例的位置
var updateModalPosition = function updateModalPosition(position, spacing) {
  var initialOffset = 30;
  var offsetTop = initialOffset;
  instances[position].forEach(function (vm) {
    if (vm.el) {
      // 获取当前实例的实际高度（包括详情展开后的高度）
      var currentHeight = vm.el.offsetHeight || 0;
      // 直接更新 DOM 元素的 top 样式，确保位置立即生效
      vm.el.style.top = "".concat(offsetTop, "px");
      // 同时更新 props，保持数据一致性
      vm.props.offsetY = offsetTop;
      // 然后累加当前实例的高度和间距，用于计算下一个实例的位置
      offsetTop += currentHeight + spacing;
    }
  });
};
var Message = function Message(constructor, options) {
  var opts = options;
  var position = opts.position || 'top-right';
  if (typeof options === 'string') {
    opts = {
      message: options
    };
  }
  var userOnClose = options.onClose;
  var horizontalOffset = opts.offsetX || 10;
  var verticalOffset = opts.offsetY || 30;
  var _opts = opts,
    _opts$spacing = _opts.spacing,
    spacing = _opts$spacing === void 0 ? 10 : _opts$spacing;
  instances[position].forEach(function (vm) {
    verticalOffset += (vm.el.offsetHeight || 0) + spacing;
  });
  seed += 1;
  var id = "message_".concat(seed);
  opts = _objectSpread(_objectSpread({}, opts), {}, {
    offsetX: horizontalOffset,
    offsetY: verticalOffset,
    id: id,
    spacing: spacing
  });
  var container = document.createElement('div');
  var vm = __WEBPACK_EXTERNAL_MODULE_vue_createVNode__(constructor, opts);
  vm.props.onDestroy = function (id) {
    use_message_close(id, position, spacing, userOnClose);
    __WEBPACK_EXTERNAL_MODULE_vue_render__(null, container);
  };
  vm.props.onDetail = function (_isShow, id) {
    instances[position].forEach(function (item) {
      if (item.props.id !== id) {
        var _item$component;
        // 关闭其他实例的详情时，传入 shouldEmit = false 避免触发无限循环
        (_item$component = item.component) === null || _item$component === void 0 || (_item$component = _item$component.exposed) === null || _item$component === void 0 || _item$component.setDetailsShow(null, false, false);
      }
    });
    // 等待 DOM 更新完成后再更新位置
    // 详情展开/收起时，DOM 高度会变化，需要等待渲染完成
    // 由于事件已经在详情内容渲染完成后才 emit，这里只需要等待 Vue 响应式更新和浏览器布局完成
    var currentSpacing = spacing || 10;
    __WEBPACK_EXTERNAL_MODULE_vue_nextTick__(function () {
      requestAnimationFrame(function () {
        updateModalPosition(position, currentSpacing);
      });
    });
  };
  __WEBPACK_EXTERNAL_MODULE_vue_render__(vm, container);
  instances[position].push(vm);
  var target;
  if (vm.props.getContainer && __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_isElement__(vm.props.getContainer)) {
    target = vm.props.getContainer;
  } else {
    target = document.body;
  }
  target.appendChild(container.firstElementChild);
};
function use_message_close(id, position, spacing, userOnClose) {
  userOnClose === null || userOnClose === void 0 || userOnClose();
  var instanceIndex = -1;
  instances[position].forEach(function (item, index) {
    if (item.props.id === id) {
      instanceIndex = index;
    }
  });
  if (instanceIndex === -1) {
    return;
  }
  // 移除实例
  instances[position].splice(instanceIndex, 1);
  // 重新计算所有剩余实例的位置
  // 使用传入的 spacing，如果没有则从第一个实例获取，或使用默认值 10
  var currentSpacing = spacing || (instances[position].length > 0 ? instances[position][0].props.spacing : 10) || 10;
  __WEBPACK_EXTERNAL_MODULE_vue_nextTick__(function () {
    updateModalPosition(position, currentSpacing);
  });
}
/* harmony default export */ const use_message = (Message);
;// external "vue-types"

;// external "../config-provider"

;// external "../icon"

;// ../../packages/notify/src/notifyConstructor.tsx


/*
 * Tencent is pleased to support the open source community by making
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
 *
 * Copyright (C) 2025 Tencent.  All rights reserved.
 *
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
 *
 * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
 *
 * ---------------------------------------------------
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
 * the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */





var NotifyThemeEnum;
(function (NotifyThemeEnum) {
  NotifyThemeEnum["ERROR"] = "error";
  NotifyThemeEnum["PRIMARY"] = "primary";
  NotifyThemeEnum["SUCCESS"] = "success";
  NotifyThemeEnum["WARNING"] = "warning";
})(NotifyThemeEnum || (NotifyThemeEnum = {}));
var notifyProps = {
  id: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.string.def(''),
  title: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.string.def(''),
  message: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.oneOfType([__WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.string, __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.func]).def(''),
  theme: __WEBPACK_EXTERNAL_MODULE_vue_types_22de060a_toType__('notifyTheme', {}).def(NotifyThemeEnum.PRIMARY),
  position: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.position().def('top-right'),
  delay: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.number.def(5000),
  dismissable: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.bool.def(true),
  offsetX: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.number.def(100),
  offsetY: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.number.def(30),
  spacing: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.number.def(10),
  extCls: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.string.def(''),
  onClose: __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_PropTypes__.func
};
/* harmony default export */ const notifyConstructor = (__WEBPACK_EXTERNAL_MODULE_vue_defineComponent__({
  name: 'Notify',
  props: notifyProps,
  emits: ['destroy'],
  setup: function setup(props, _ref) {
    var emit = _ref.emit;
    var zIndex = __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_shared_edbdfb03_bkZIndexManager__.getMessageNextIndex();
    var horizontalClass = __WEBPACK_EXTERNAL_MODULE_vue_computed__(function () {
      return props.position.indexOf('right') > 1 ? 'right' : 'left';
    });
    var verticalProperty = __WEBPACK_EXTERNAL_MODULE_vue_computed__(function () {
      return props.position.startsWith('top') ? 'top' : 'bottom';
    });
    var styles = __WEBPACK_EXTERNAL_MODULE_vue_computed__(function () {
      return _defineProperty(_defineProperty(_defineProperty({}, horizontalClass.value, "".concat(props.offsetX, "px")), verticalProperty.value, "".concat(props.offsetY, "px")), "zIndex", zIndex);
    });
    var _usePrefix = __WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_config_provider_fe8577a3_usePrefix__(),
      resolveClassName = _usePrefix.resolveClassName;
    var classNames = __WEBPACK_EXTERNAL_MODULE_vue_computed__(function () {
      return [resolveClassName('notify'), resolveClassName("notify-".concat(props.theme)), horizontalClass.value];
    });
    var renderMessage = __WEBPACK_EXTERNAL_MODULE_vue_computed__(function () {
      if (typeof props.message === 'function') {
        return props.message();
      }
      return props.message;
    });
    var visible = __WEBPACK_EXTERNAL_MODULE_vue_ref__(false);
    var timer = null;
    var startTimer = function startTimer() {
      timer = setTimeout(function () {
        visible.value = false;
      }, props.delay);
    };
    var handleClose = function handleClose() {
      visible.value = false;
    };
    __WEBPACK_EXTERNAL_MODULE_vue_onMounted__(function () {
      props.delay && startTimer();
      visible.value = true;
    });
    __WEBPACK_EXTERNAL_MODULE_vue_onUnmounted__(function () {
      clearTimeout(timer);
    });
    __WEBPACK_EXTERNAL_MODULE_vue_watch__(visible, function () {
      if (!visible.value) {
        emit('destroy', props.id);
      }
    });
    return {
      classNames: classNames,
      styles: styles,
      visible: visible,
      renderMessage: renderMessage,
      handleClose: handleClose,
      resolveClassName: resolveClassName
    };
  },
  render: function render() {
    var _this = this;
    var renderIcon = function renderIcon() {
      var iconMap = {
        primary: __WEBPACK_EXTERNAL_MODULE_vue_createVNode__(__WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_icon_a97c79c3_Info__, null, null),
        warning: __WEBPACK_EXTERNAL_MODULE_vue_createVNode__(__WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_icon_a97c79c3_Warn__, null, null),
        success: __WEBPACK_EXTERNAL_MODULE_vue_createVNode__(__WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_icon_a97c79c3_Success__, null, null),
        error: __WEBPACK_EXTERNAL_MODULE_vue_createVNode__(__WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_icon_a97c79c3_Close__, null, null)
      };
      return iconMap[_this.theme];
    };
    return __WEBPACK_EXTERNAL_MODULE_vue_createVNode__(__WEBPACK_EXTERNAL_MODULE_vue_Transition__, {
      "name": "bk-notify-fade"
    }, {
      "default": function _default() {
        return [__WEBPACK_EXTERNAL_MODULE_vue_withDirectives__(__WEBPACK_EXTERNAL_MODULE_vue_createVNode__("div", {
          "style": _this.styles,
          "class": _this.classNames
        }, [__WEBPACK_EXTERNAL_MODULE_vue_createVNode__("div", {
          "class": "".concat(_this.resolveClassName('notify-content'))
        }, [__WEBPACK_EXTERNAL_MODULE_vue_createVNode__("div", {
          "class": "".concat(_this.resolveClassName('notify-icon'))
        }, [renderIcon()]), _this.title ? __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("div", {
          "class": "".concat(_this.resolveClassName('notify-content-header'))
        }, [_this.title]) : '', __WEBPACK_EXTERNAL_MODULE_vue_createVNode__("div", {
          "class": "".concat(_this.resolveClassName('notify-content-text'))
        }, [_this.renderMessage])]), _this.dismissable && __WEBPACK_EXTERNAL_MODULE_vue_createVNode__(__WEBPACK_EXTERNAL_MODULE_bkui_vue_lib_icon_a97c79c3_Error__, {
          "class": "".concat(_this.resolveClassName('notify-icon'), " ").concat(_this.resolveClassName('notify-close')),
          "onClick": _this.handleClose
        }, null)]), [[__WEBPACK_EXTERNAL_MODULE_vue_vShow__, _this.visible]])];
      }
    });
  }
}));
;// ../../packages/notify/src/index.ts
/*
 * Tencent is pleased to support the open source community by making
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
 *
 * Copyright (C) 2025 Tencent.  All rights reserved.
 *
 * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
 *
 * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
 *
 * ---------------------------------------------------
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
 * the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
 * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */


var Notify = function Notify(options) {
  use_message(notifyConstructor, options);
};
/* harmony default export */ const src = (Notify);
export { src as default };
