mapSpec = {
const mapSpec = {
layerProps: { states: "state", regions: "region", decentralized: "isDecentralized" },
colorProps: {}
};
const getOrCreateColorProps = (color) => (mapSpec.colorProps[color] ??= {})
for (let [stateId, state] of Object.entries(states)) {
for (let color of state.provinces) {
const colorProps = getOrCreateColorProps(color);
colorProps.state = stateId;
colorProps.region = state.region;
}
}
for (let [countryId, country] of Object.entries(countries)) {
for (let color of country.provinces) {
const colorProps = getOrCreateColorProps(color);
colorProps.country = countryId;
if (!country.isDecentralized) colorProps.isDecentralized = true;
}
}
return mapSpec
}