{"version":3,"file":"toAction.cjs","names":["fromDescriber","reduceFnMap"],"sources":["../../../src/actions/functions/toAction.ts"],"sourcesContent":["import type { PrimitiveObject } from '#bemedev/globals/types';\nimport type {\n  ActorsConfigMap,\n  EventsMap,\n  ToEventObject,\n  ToEvents,\n} from '#events';\nimport { reduceFnMap } from '#utils';\nimport type {\n  Action2,\n  ActionConfig,\n  ActionMap,\n  // eslint-disable-next-line @typescript-eslint/no-unused-vars\n  ActionResult,\n} from '#actions';\nimport { fromDescriber } from '~types';\n\nexport type ToAction_F = <\n  E extends EventsMap = EventsMap,\n  A extends ActorsConfigMap = ActorsConfigMap,\n  Pc = any,\n  Tc extends PrimitiveObject = PrimitiveObject,\n  T extends string = string,\n  Eo extends ToEventObject<ToEvents<E, A>> = ToEventObject<ToEvents<E, A>>,\n>(\n  events: E,\n  actorsMap: A,\n  action: ActionConfig,\n  actions?: ActionMap<Eo, Pc, Tc, T>,\n) => Action2<Eo, Pc, Tc, T> | undefined;\n\n/**\n * Converts an ActionConfig to a function that can be executed with the provided eventsMap and actorsMap.\n * @param events of type {@linkcode EventsMap}, events map to use for resolving the action.\n * @param actorsMap of type {@linkcode ActorsConfigMap}, the actors map to use for resolving the action.\n * @param action of type {@linkcode ActionConfig}, action configuration to convert.\n * @param actions of type {@linkcode ActionMap}, The actions map containing functions to execute.\n *\n * @see {@linkcode PrimitiveObject}\n * @see {@linkcode ActionResult}\n * @see {@linkcode reduceFnMap}\n */\nexport const toAction: ToAction_F = (\n  events,\n  actorsMap,\n  action,\n  actions,\n) => {\n  const name = fromDescriber(action);\n  const fn = actions?.[name];\n  const func = fn ? reduceFnMap(events, actorsMap, fn) : undefined;\n  return func;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA0CA,MAAa,YACX,QACA,WACA,QACA,YACG;CACH,MAAM,OAAOA,yBAAAA,cAAc,OAAO;CAClC,MAAM,KAAK,UAAU;AAErB,QADa,KAAKC,0BAAAA,YAAY,QAAQ,WAAW,GAAG,GAAG,KAAA"}