"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.createSchemaFromDefaults = createSchemaFromDefaults;
var _validation = require("@inkline/inkline/validation");
var _constants = require("@inkline/inkline/constants");
function createSchemaFromDefaults(defaultValues) {
  const resolved = {
    ..._constants.defaultValidationStateValues
  };
  for (const key of Object.keys(defaultValues)) {
    const field = defaultValues[key];
    if (Array.isArray(field)) {
      resolved[key] = field.map(item => {
        if (typeof item === "object") {
          return createSchemaFromDefaults(item);
        }
        return (0, _validation.createFormFieldSchema)({
          value: item
        });
      });
    } else if (typeof field === "object") {
      resolved[key] = createSchemaFromDefaults(field);
    } else {
      resolved[key] = (0, _validation.createFormFieldSchema)({
        value: field
      });
    }
  }
  return resolved;
}