"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _utils = require("@teamix/utils");
var _utils2 = require("../utils");
var initializeDataSource = function initializeDataSource(dataSource, suffix) {
  var _dataSource$extraConf;
  var _initializeRequestExp = (0, _utils2.initializeRequestExpression)(dataSource, '$dataSource', suffix),
    expression = _initializeRequestExp.expression,
    scope = _initializeRequestExp.scope;
  return expression ? {
    reactions: [expression],
    scope: scope,
    data: {
      readOnlyOnLoading: (dataSource === null || dataSource === void 0 ? void 0 : (_dataSource$extraConf = dataSource.extraConfig) === null || _dataSource$extraConf === void 0 ? void 0 : _dataSource$extraConf.readOnly) !== false
    },
    props: {
      className: 'teamix-test-request',
      'data-teamix-test-request': "url=".concat(dataSource === null || dataSource === void 0 ? void 0 : dataSource.url, "&formatResult=").concat(!!(dataSource === null || dataSource === void 0 ? void 0 : dataSource.formatResult)),
      'data-teamix-test-params': (0, _utils.getTestRequestParams)(dataSource === null || dataSource === void 0 ? void 0 : dataSource.params),
      'data-teamix-test-data': (0, _utils.getTestRequestData)('dataSource')
    }
  } : {
    reactions: [],
    scope: {},
    dataSource: dataSource
  };
};
var _default = initializeDataSource;
exports.default = _default;