// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';

var Curry = require("bs-platform/lib/js/curry.js");
var Json_decode = require("@glennsl/bs-json/src/Json_decode.bs.js");
var Int$OptolithClient = require("../../Data/Int.bs.js");
var Maybe$OptolithClient = require("../../Data/Maybe.bs.js");
var IntMap$OptolithClient = require("../../Data/IntMap.bs.js");
var Yaml_Zip$OptolithClient = require("../Utilities/Yaml_Zip.bs.js");
var JsonStrict$OptolithClient = require("../Utilities/JsonStrict.bs.js");

function categoryL10n(json) {
  return {
          id: Json_decode.field("id", Json_decode.$$int, json),
          name: Json_decode.field("name", Json_decode.string, json)
        };
}

function categoryUniv(json) {
  return {
          id: Json_decode.field("id", Json_decode.$$int, json),
          primaryPatronCultures: Json_decode.field("primaryPatronCultures", (function (param) {
                  return Json_decode.list(Json_decode.$$int, param);
                }), json)
        };
}

function category(univ, l10n) {
  return {
          id: univ.id,
          name: l10n.name,
          primaryPatronCultures: univ.primaryPatronCultures
        };
}

function tL10n(json) {
  return {
          id: Json_decode.field("id", Json_decode.$$int, json),
          name: Json_decode.field("name", Json_decode.string, json)
        };
}

function tUniv(json) {
  return {
          id: Json_decode.field("id", Json_decode.$$int, json),
          category: Json_decode.field("category", Json_decode.$$int, json),
          skills: Json_decode.field("skills", (function (param) {
                  return Json_decode.tuple3(Json_decode.$$int, Json_decode.$$int, Json_decode.$$int, param);
                }), json),
          limitedToCultures: Json_decode.field("limitedToCultures", (function (param) {
                  return Json_decode.list(Json_decode.$$int, param);
                }), json),
          isLimitedToCulturesReverse: JsonStrict$OptolithClient.optionalField("isLimitedToCulturesReverse", Json_decode.bool, json)
        };
}

function t(univ, l10n) {
  return [
          univ.id,
          {
            id: univ.id,
            name: l10n.name,
            category: univ.category,
            skills: univ.skills,
            limitedToCultures: univ.limitedToCultures,
            isLimitedToCulturesReverse: Maybe$OptolithClient.fromMaybe(false, univ.isLimitedToCulturesReverse)
          }
        ];
}

function all(yamlData) {
  return Curry._1(IntMap$OptolithClient.fromList, Yaml_Zip$OptolithClient.zipBy(Int$OptolithClient.show, t, (function (x) {
                    return x.id;
                  }), (function (x) {
                    return x.id;
                  }), Json_decode.list(tUniv, yamlData.patronsUniv), Json_decode.list(tL10n, yamlData.patronsL10n)));
}

var Decode = {
  categoryL10n: categoryL10n,
  categoryUniv: categoryUniv,
  category: category,
  tL10n: tL10n,
  tUniv: tUniv,
  t: t,
  all: all
};

exports.Decode = Decode;
/* IntMap-OptolithClient Not a pure module */
