import type { Combination, Interaction } from "./script/types" import { isEqual } from "lodash-es" export const cSet = (...values: T[]) => new Set(values) export const cMap = (object: Record) => new Map(Object.entries(object)) export function getInteractionQueueItemId(interaction: Interaction) { let id: string if (interaction.type === "use") id = `use-${interaction.objectId}` else if (interaction.type === "combine") id = `combine-${[...interaction.objectIds].sort().join("_")}` else throw new Error("Unknown interaction type") return id } export function findMatchingCombination(combinations: Set, objectIds: Set) { return combinations.values().find(c => isEqual(new Set(c.inputs.values().map(i => i.objectId)), objectIds)) }