import { h, render } from 'atomico';
import { g as getComponentOrDefine } from './65ef80fe.js';
import '../kun-icon.js';

const _jsxFileName = "/Users/rang/rang/frond_ng/packages/six/src/common/six-loading.tsx";
const style = `
    .name {
    top: 10%;
    position: fixed;
    left: 0;
    right: 0;
    background: #1b1a1a85;
    padding: 5px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 24px;
    width: min-content;
    margin: 0 auto;
    border-radius: 6px;
    color: white;
    }
`;

const SixLoading = () => (
  h('host', { shadowDom: true, __self: undefined, __source: {fileName: _jsxFileName, lineNumber: 27}}
    , h('style', {__self: undefined, __source: {fileName: _jsxFileName, lineNumber: 28}}, style)
    , h('div', { class: "name", __self: undefined, __source: {fileName: _jsxFileName, lineNumber: 29}}
      , h('kun-icon', { iconType: "loading", iconHeight: 26, iconWidth: 26, __self: undefined, __source: {fileName: _jsxFileName, lineNumber: 30}} )
    )
  )
);


getComponentOrDefine("six-loading", SixLoading);

const _jsxFileName$1 = "/Users/rang/rang/frond_ng/packages/six/src/common/exec-confirm.tsx";
let loading = false;

const execWithSixLoad = async ( callback) => {
  if (loading) {
    return;
  }
  const container = document.createElement("div");
  document.body.appendChild(container);

  loading = true;
  render(h('host', {__self: undefined, __source: {fileName: _jsxFileName$1, lineNumber: 14}}, h('six-loading', {__self: undefined, __source: {fileName: _jsxFileName$1, lineNumber: 14}} )) , container);

  try {
    const r = await callback() ;
    // eslint-disable-next-line consistent-return
    return r;
  } catch (e) {
    // toastrError(String(e));
  } finally {
    document.body.removeChild(container);
    loading = false;
  }
};

export { execWithSixLoad as e };
