import { isFunction as p } from "lodash-unified";
import { ROW_KEY as l } from "./constants.mjs";
function F(t, e, r) {
  let n = null;
  return { request: async (o) => {
    const i = t;
    if (!i)
      return r?.(0), {
        data: [],
        total: 0
      };
    n && (o = Object.assign(o, n));
    const { records: u, total: a } = await i(Object.assign({}, o));
    return r?.(u?.length || 0), {
      data: u?.map((c) => h(c, e)),
      total: a
    };
  }, setExtraParams: (o) => {
    n = o || null;
  } };
}
function h(t, e) {
  return p(e) ? {
    ...t,
    [l]: e(t)
  } : t;
}
function g(t) {
  return Reflect.deleteProperty(t, l), t;
}
function j(t) {
  const { renderSelectedItem: e, rightTitle: r, rightBottom: n, ...s } = t || {};
  return {
    props: { ...s, layoutType: t && "two-column" },
    slots: {
      renderSelectedItem: e,
      rightTitle: r,
      rightBottom: n
    }
  };
}
class y {
  constructor() {
    this.p = null, this.operateFn = null;
  }
  buildPromise() {
    return this.operateFn && this.operateFn.reject("Ignored Reject: reuse"), this.p = new Promise((e, r) => {
      this.operateFn = {
        reject: r,
        resolve: e
      };
    }), this.p;
  }
  clear() {
    this.p = null, this.operateFn = null;
  }
  /** 兑现回调 */
  resolve(e) {
    this.operateFn && (this.operateFn.resolve(e), this.clear());
  }
  /** 拒绝回调 */
  reject(e) {
    this.operateFn && (this.operateFn.reject("Ignored Reject: " + e), this.clear());
  }
}
function P(t) {
  return typeof t == "number" && t ? `${t}px` : t.toString();
}
export {
  y as AsyncCallback,
  h as addRowKeyField,
  g as delRowKeyField,
  F as genRequest,
  j as getModalLayoutConfig,
  P as toHeight
};
