// src/util/news.ts
import { z } from "zod";

// src/localization/util.ts
var languages = ["en", "de"];
var languagesLocalNames = {
  en: "English",
  de: "Deutsch"
};
var DEFAULT_LANGUAGE = "en";
var LanguageUtil = {
  languages,
  DEFAULT_LANGUAGE,
  languagesLocalNames
};

// src/util/news.ts
var newsSchema = z.object({
  title: z.string(),
  description: z.string(),
  date: z.string(),
  image: z.string().url().optional(),
  externalResource: z.string().url().optional(),
  keys: z.array(z.string())
}).transform((obj) => {
  let description = [obj.description];
  if (obj.image) {
    description = [new URL(obj.image), ...description];
  }
  return {
    title: obj.title,
    date: new Date(obj.date),
    description,
    externalResource: obj.externalResource ? new URL(obj.externalResource) : void 0,
    keys: obj.keys
  };
});
var newsListSchema = z.array(newsSchema);
var localizedNewsSchema = z.record(z.enum(LanguageUtil.languages), newsListSchema);
var filterNews = (localizedNews, requiredKeys) => {
  return localizedNews.filter((news) => requiredKeys.every((value) => news.keys.includes(value)));
};
export {
  filterNews,
  localizedNewsSchema,
  newsListSchema,
  newsSchema
};
//# sourceMappingURL=news.mjs.map