import { dxpPrefix } from "./cmsDefaultSettings";
export var getAssetSrc = function getAssetSrc(path) {
  return "".concat(dxpPrefix, "/dam/query/render").concat(path);
};
export var handleEvent = function handleEvent(event) {
  var value = event;

  if (event && event.target) {
    value = event.target.value;
  }

  return value;
};
export var makeEventProps = function makeEventProps(events) {
  var nameSpace = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'appRender';
  var eventProps = {};

  if (events && events.length > 0) {
    var renderModel = window.g_app._store.getState()[nameSpace];

    if (!renderModel) {
      return false;
    }

    var eventJs = renderModel.eventJs,
        form = renderModel.form,
        fetch = renderModel.fetch,
        macro = renderModel.macro;
    var ctx = {
      form: form,
      macro: macro,
      fetch: fetch,
      events: eventJs
    };

    if (eventJs) {
      events.forEach(function (eventItem) {
        var event = eventItem.event,
            fun = eventItem.function;

        if (eventJs[fun]) {
          var functions = fun.split(';');

          if (functions.length === 1) {
            if (event === 'onRow') {
              eventProps[event] = function (record) {
                return eventJs[fun](record);
              };
            } else {
              eventProps[event] = function (event) {
                eventJs[fun](handleEvent(event), ctx);
              };
            }
          } else {// 多事件方法
          }
        }
      });
    }
  }

  return eventProps;
};
//# sourceMappingURL=common.js.map