import { struct as a } from "../../../utils/struct/main.js";
import { enumerable as e } from "../../../utils/struct/property.js";
import { isFunction as d, isUndefined as m } from "../../../utils/value/is.js";
import { noop as c } from "../../../utils/common.js";
const E = () => {
  const r = new class extends EventTarget {
  }(), l = (o, ...t) => {
    const [n] = t;
    t.length && m(n) && console.warn(
      "Unexpected value `undefined` provided for event detail.\n	Turn off this warning by doing either of the following:\n	(1) omit the optional event detail parameter.\n	(2) explicitly pass `null` for the event detail parameter (instead of `undefined`).\n"
    );
    const i = new CustomEvent(
      o,
      a({
        bubbles: e(!1),
        cancelable: e(!1),
        detail: e(n ?? null)
      })
    );
    return r.dispatchEvent(i);
  }, s = (o, t) => {
    if (!d(t)) return c;
    const n = (i) => t.call(
      null,
      a({
        detail: e(i.detail),
        timeStamp: e(i.timeStamp),
        type: e(i.type)
      })
    );
    return r.addEventListener(o, n), () => r.removeEventListener(o, n);
  };
  return a({
    emit: e(l),
    on: e(s)
  });
};
export {
  E as createEventEmitter
};
