import { card as r } from "@universityofmaryland/web-elements-library/composite";
import * as C from "@universityofmaryland/web-utilities-library/validation";
import { Slots as a, Register as c, Model as T, Attributes as t, Lifecycle as D } from "@universityofmaryland/web-model-library";
import { toUMDElement as d } from "@universityofmaryland/web-utilities-library/adapters";
import { e as u } from "./_event-Duz7QGRD.js";
import { createStyledSlotOrClone as S } from "@universityofmaryland/web-utilities-library/elements";
const k = ({ tagName: e }) => {
  const o = {
    headline: {
      required: !0,
      ...a.element.allowed.subHeadline
    },
    body: a.element.allowed.text
  }, n = (i) => {
    const l = t.getValue.loadingPriority({ element: i }), m = l === "eager" || l === "lazy" ? l : "lazy";
    return {
      image: C.getValidatedSlotImage({
        element: i,
        slotName: a.name.assets.image
      }),
      eyebrow: a.eyebrow.default({ element: i }),
      headline: a.headline.default({ element: i }),
      text: a.text.default({ element: i }),
      date: a.date.default({ element: i }),
      actions: a.actions.default({ element: i }),
      isTransparent: t.isVisual.transparent({ element: i }),
      isThemeDark: t.isTheme.dark({ element: i }),
      imageLoading: m
    };
  }, s = (i) => {
    const l = t.isVisual.aligned({ element: i }), m = t.isVisual.bordered({ element: i }), x = t.isDisplay.list({ element: i }), g = n(i);
    return x ? r.list({
      ...g,
      isAligned: l
    }) : r.block({
      ...g,
      isAligned: l,
      hasBorder: m
    });
  };
  return () => {
    c.registerWebComponent({
      name: e,
      element: T.createCustomElement({
        tagName: e,
        slots: o,
        createComponent: s
      })
    });
  };
}, V = "umd-element-article", f = k({ tagName: V }), M = "umd-element-event", N = {
  headline: {
    ...a.element.allowed.headline,
    required: !0
  },
  text: a.element.allowed.text,
  "date-start-iso": a.element.allowed.time,
  "date-end-iso": a.element.allowed.time,
  location: a.element.allowed.text,
  image: a.element.allowed.imageLink,
  eyebrow: a.element.allowed.eyebrow,
  actions: a.element.allowed.actions
}, E = (e) => {
  const o = u(e);
  if (!o)
    return { element: document.createElement("div"), styles: "" };
  if (t.isDisplay.feature({ element: e })) {
    const s = u(e, {
      isLargeSize: !0,
      isDateSignDark: !1
    });
    return r.block({
      actions: a.actions.default({ element: e }),
      dateSign: d(s?.dateSign),
      eventMeta: d(s?.eventMeta),
      eyebrow: a.eyebrow.default({ element: e }),
      hasEyebrowRibbon: !0,
      headline: a.headline.default({ element: e }),
      image: a.assets.image({ element: e }),
      isThemeDark: t.isTheme.dark({ element: e }),
      isTransparent: t.isVisual.transparent({ element: e }),
      text: a.text.default({ element: e })
    });
  }
  if (t.isDisplay.promo({ element: e })) {
    const s = u(e, {
      isThemeDark: !0,
      // Force dark theme for meta in overlay
      isDateSignDark: !1
    });
    return r.overlay.image({
      actions: a.actions.default({ element: e }),
      backgroundImage: a.assets.image({ element: e }),
      dateSign: d(s?.dateSign),
      eventMeta: d(s?.eventMeta),
      headline: a.headline.default({ element: e }),
      isThemeDark: t.isTheme.dark({ element: e }),
      text: a.text.default({ element: e })
    });
  }
  if (t.isDisplay.list({ element: e })) {
    const s = u(e, {
      isLargeSize: !0
    });
    return r.list({
      actions: a.actions.default({ element: e }),
      dateSign: d(s?.dateSign),
      eventMeta: d(s?.eventMeta),
      headline: a.headline.default({ element: e }),
      image: a.assets.image({ element: e }),
      isThemeDark: t.isTheme.dark({ element: e }),
      text: a.text.default({ element: e })
    });
  }
  const { eventMeta: n } = o;
  return r.block({
    actions: a.actions.default({ element: e }),
    eventMeta: d(n),
    headline: a.headline.default({ element: e }),
    image: a.assets.image({ element: e }),
    isThemeDark: t.isTheme.dark({ element: e }),
    isTransparent: t.isVisual.transparent({ element: e }),
    text: a.text.default({ element: e })
  });
}, h = c.webComponent({
  tagName: M,
  slots: N,
  createComponent: E
}), $ = "umd-element-card-icon", L = {
  headline: {
    ...a.element.allowed.headline,
    required: !0
  },
  text: a.element.allowed.text,
  image: a.element.allowed.image
}, I = (e) => r.overlay.icon({
  image: C.getValidatedSlotImage({
    element: e,
    slotName: a.name.assets.image
  }),
  headline: a.headline.default({ element: e }),
  text: a.text.default({ element: e }),
  isThemeDark: t.isTheme.dark({ element: e })
}), y = c.webComponent({
  tagName: $,
  slots: L,
  createComponent: I
}), O = "umd-element-card-overlay", q = {
  headline: {
    ...a.element.allowed.headline,
    required: !0
  },
  text: a.element.allowed.text,
  eyebrow: a.element.allowed.eyebrow,
  image: a.element.allowed.image,
  actions: a.element.allowed.actions,
  date: a.element.allowed.time,
  "cta-icon": {
    allowedElements: ["a"]
  }
}, p = ({ element: e }) => {
  const o = t.getValue.loadingPriority({ element: e }), n = o === "eager" || o === "lazy" ? o : "lazy";
  return {
    eyebrow: a.eyebrow.default({ element: e }),
    headline: a.headline.default({ element: e }),
    text: a.text.default({ element: e }),
    date: a.date.default({ element: e }),
    actions: a.actions.default({ element: e }),
    ctaIcon: S({
      element: e,
      slotRef: a.name.CTA_ICON
    }),
    isQuote: t.isVisual.quote({ element: e }),
    isThemeDark: t.isTheme.dark({ element: e }),
    isThemeLight: t.isTheme.light({ element: e }),
    imageLoading: n
  };
}, z = (e) => {
  if (t.isLayout.image({ element: e })) {
    const o = r.overlay.image({
      ...p({ element: e }),
      backgroundImage: a.assets.image({ element: e })
    });
    if (o)
      return o;
  }
  return r.overlay.color({ ...p({ element: e }) });
}, v = c.webComponent({
  tagName: O,
  slots: q,
  createComponent: z,
  afterConnect: D.hooks.loadOnConnect
}), w = k({ tagName: "umd-element-card" }), A = "umd-element-card-video", P = {
  video: {
    ...a.element.allowed.video,
    required: !0
  }
}, _ = (e) => {
  const o = a.assets.video({ element: e }), n = t.isDisplay.short({ element: e }), s = t.isVisual.play({ element: e });
  return o ? n ? r.video.short({
    video: o
  }) : r.video.block({
    video: o,
    isAutoplay: s
  }) : (console.error("Video slot is required for umd-element-card-video"), { element: document.createElement("div"), styles: "" });
}, b = c.webComponent({
  tagName: A,
  slots: P,
  createComponent: _
}), U = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  CardArticle: f,
  CardEvent: h,
  CardIcon: y,
  CardOverlay: v,
  CardStandard: w,
  CardVideo: b,
  article: f,
  event: h,
  icon: y,
  overlay: v,
  standard: w,
  video: b
}, Symbol.toStringTag, { value: "Module" }));
export {
  f as C,
  h as a,
  y as b,
  v as c,
  w as d,
  b as e,
  U as f
};
//# sourceMappingURL=index-CaWM8ZPS.js.map
