import { useState as o, useCallback as s, useMemo as d } from "../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { hasCallback as D } from "./types.js";
function k(l) {
  const [r, a] = o(null), i = s(
    (e) => e && D(l[e.selection.type]) ? {
      callback: l?.[e.selection.type]?.callback ? (c) => l[e.selection.type]?.callback?.({ showModal: () => a(e), ...c }) : () => l[e.selection.type]?.showDetails && a(e)
    } : (a(e), {}),
    [l]
  ), n = s(() => a(null), []), u = d(() => {
    const e = {};
    for (const c in l) {
      const t = l[c];
      e[c] = !t?.showDetails || !!t.callback;
    }
    return e;
  }, [l]);
  return {
    selectedDetail: r,
    updateDetails: i,
    detailsToShow: u,
    resetDetails: n
  };
}
export {
  k as default
};
