var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __async = (__this, __arguments, generator) => {
  return new Promise((resolve, reject) => {
    var fulfilled = (value) => {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    };
    var rejected = (value) => {
      try {
        step(generator.throw(value));
      } catch (e) {
        reject(e);
      }
    };
    var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
    step((generator = generator.apply(__this, __arguments)).next());
  });
};

// src/reactjs/CourseRating.tsx
import React4, { useEffect as useEffect2, useMemo, useState } from "react";

// src/shared/defaults.ts
var DEFAULT_GOOD_RATING_THRESHOLD = 4;
var DEFAULT_FEEDBACK_OPTIONS = [
  "Akurasi & Relevansi Modul",
  "Durasi Materi",
  "Audio/Desain Visual",
  "Others"
];
var DEFAULT_THEME = {
  primaryColor: "#9B0008",
  starColor: "#FFD45A",
  inactiveStarColor: "#E5E5E5",
  textColor: "#222222",
  mutedTextColor: "#555555",
  buttonTextColor: "#FFFFFF",
  courseButtonColor: "#2E2E2E",
  backgroundColor: "#FFFFFF",
  borderColor: "#DDDDDD",
  borderRadius: 24
};
var DEFAULT_LABELS = {
  id: {
    title: "Waktunya beri feedback!",
    description: "",
    ratingAriaLabel: "Rating course",
    closeLabel: "Tutup rating",
    impressiveQuestion: "Apa saja yang membuatmu terkesan?",
    improvementQuestion: "Apa saja yang harus kami perbaiki?",
    otherQuestion: "Apa yang bisa kami lakukan untuk meningkatkan pembelajaran ini?",
    submit: "Submit",
    successTitle: "Terima kasih telah meluangkan waktu untuk mengisi evaluasi ini",
    successDescription: "Masukan yang Anda berikan sangat berarti bagi kami.",
    backToHome: "Kembali ke home",
    nextCourse: "Lanjut course",
    others: "Others",
    loading: "Mengirim...",
    submitError: "Gagal mengirim rating. Silakan coba lagi.",
    otherInputQuestion: "Keterangan lainnya?",
    otherImpressedQuestion: "Sebutkan Aspek Lain Yang Membuatmu Terkesan?",
    otherImprovementQuestion: "Sebutkan Aspek Lain Yang Perlu Diperbaiki?",
    feedbackImpressedQuestion: "Apa yang membuatmu terkesan?",
    feedbackImprovementQuestion: "Apa yang bisa kami tingkatkan untuk meningkatkan pembelajaran ini?"
  },
  en: {
    title: "Time to share your feedback!",
    description: "",
    ratingAriaLabel: "Course rating",
    closeLabel: "Close rating",
    impressiveQuestion: "What impressed you?",
    improvementQuestion: "What should we improve?",
    otherQuestion: "What can we do to improve this learning experience?",
    submit: "Submit",
    successTitle: "Thank you for taking the time to complete this evaluation",
    successDescription: "Your feedback means a lot to us.",
    backToHome: "Back to home",
    nextCourse: "Next course",
    others: "Others",
    loading: "Submitting...",
    submitError: "Failed to submit rating. Please try again.",
    otherInputQuestion: "Other details?",
    otherImpressedQuestion: "Mention other aspects that impressed you.",
    otherImprovementQuestion: "Mention other aspects that need improvement.",
    feedbackImpressedQuestion: "What impressed you?",
    feedbackImprovementQuestion: "What can we improve to enhance this learning experience?"
  }
};
function getLabels(language = "id", overrides) {
  return __spreadValues(__spreadValues({}, DEFAULT_LABELS[language]), overrides);
}
function getTheme(overrides) {
  return __spreadValues(__spreadValues({}, DEFAULT_THEME), overrides);
}

// src/shared/options.ts
function normalizeFeedbackOptions(options, othersLabel = "Others") {
  const normalized = ((options == null ? void 0 : options.length) ? options : DEFAULT_FEEDBACK_OPTIONS).map((option) => option.trim()).filter(Boolean);
  const hasOthers = normalized.some(
    (option) => isOthersOption(option, othersLabel)
  );
  return Array.from(new Set(hasOthers ? normalized : [...normalized, othersLabel]));
}
function isOthersOption(option, othersLabel = "Others") {
  const val = option.trim().toLowerCase();
  const normalizedOthersLabel = othersLabel.trim().toLowerCase();
  return val === normalizedOthersLabel || val.includes("other") || val.includes("lainnya");
}

// src/shared/payload.ts
function buildSubmitPayload(input) {
  var _a, _b, _c;
  const otherText = ((_a = input.otherText) == null ? void 0 : _a.trim()) || null;
  const isOtherSelected = input.selectedReasons.some(
    (reason) => isOthersOption(reason, input.labels.others)
  );
  const isImprovementRating = input.rating < ((_b = input.goodRatingThreshold) != null ? _b : DEFAULT_GOOD_RATING_THRESHOLD);
  const feedbackText = isImprovementRating ? ((_c = input.feedbackText) == null ? void 0 : _c.trim()) || null : null;
  const selectedTagIds = [];
  input.selectedReasons.forEach((reason) => {
    var _a2;
    const tag = (_a2 = input.course.tags) == null ? void 0 : _a2.find((t) => t.label === reason);
    if (tag && tag.id !== null) {
      selectedTagIds.push(tag.id);
    }
  });
  return {
    courseId: input.course.id,
    setting_id: input.course.setting_id || 0,
    star_rating: input.rating,
    selected_tag_ids: selectedTagIds,
    is_other_selected: isOtherSelected,
    other_text: otherText,
    feedback_text: feedbackText
  };
}

// src/shared/rating.ts
function getRatingSentiment(rating, goodRatingThreshold = DEFAULT_GOOD_RATING_THRESHOLD) {
  return rating >= goodRatingThreshold ? "impressed" : "improvement";
}
function getQuestionForRating(rating, labels, goodRatingThreshold = DEFAULT_GOOD_RATING_THRESHOLD, customTitle) {
  if (customTitle) return customTitle;
  return getRatingSentiment(rating, goodRatingThreshold) === "impressed" ? labels.impressiveQuestion : labels.improvementQuestion;
}
function getFeedbackQuestion(rating, labels, goodRatingThreshold = DEFAULT_GOOD_RATING_THRESHOLD) {
  return getRatingSentiment(rating, goodRatingThreshold) === "impressed" ? labels.feedbackImpressedQuestion : labels.feedbackImprovementQuestion;
}

// src/shared/validation.ts
function validateRatingForm(state, othersLabel = "Others") {
  var _a, _b;
  const hasRating = typeof state.rating === "number" && state.rating >= 1 && state.rating <= 5;
  const hasReason = state.selectedReasons.length > 0;
  const needsOtherText = state.selectedReasons.some(
    (reason) => isOthersOption(reason, othersLabel)
  );
  const hasOtherText = Boolean((_a = state.otherText) == null ? void 0 : _a.trim());
  const hasFeedbackText = Boolean((_b = state.feedbackText) == null ? void 0 : _b.trim());
  return {
    isValid: hasRating && hasReason && (!needsOtherText || hasOtherText),
    hasRating,
    hasReason,
    needsOtherText,
    hasOtherText,
    hasFeedbackText
  };
}

// src/reactjs/assets.ts
function getResponsiveImage(assets, screen) {
  var _a, _b, _c, _d, _e, _f, _g, _h;
  const isDesktop = typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(min-width: 768px)").matches;
  if (screen === "rating") {
    return isDesktop ? (_b = (_a = assets == null ? void 0 : assets.ratingBackgroundImageDesktop) != null ? _a : assets == null ? void 0 : assets.ratingBackgroundImage) != null ? _b : assets == null ? void 0 : assets.ratingBackgroundImageMobile : (_d = (_c = assets == null ? void 0 : assets.ratingBackgroundImageMobile) != null ? _c : assets == null ? void 0 : assets.ratingBackgroundImage) != null ? _d : assets == null ? void 0 : assets.ratingBackgroundImageDesktop;
  }
  return isDesktop ? (_f = (_e = assets == null ? void 0 : assets.successBackgroundImageDesktop) != null ? _e : assets == null ? void 0 : assets.successBackgroundImage) != null ? _f : assets == null ? void 0 : assets.successBackgroundImageMobile : (_h = (_g = assets == null ? void 0 : assets.successBackgroundImageMobile) != null ? _g : assets == null ? void 0 : assets.successBackgroundImage) != null ? _h : assets == null ? void 0 : assets.successBackgroundImageDesktop;
}

// src/reactjs/CourseRatingForm.tsx
import React from "react";
function CourseRatingForm({
  course,
  labels,
  theme,
  feedbackOptions,
  rating,
  selectedReasons,
  otherText,
  feedbackText,
  isValid,
  isSubmitting,
  submitError,
  goodRatingThreshold,
  mascotImage,
  logoImage,
  backgroundImage,
  onRatingChange,
  onToggleReason,
  onOtherTextChange,
  onFeedbackTextChange,
  onSubmit
}) {
  const sentiment = typeof rating === "number" ? getRatingSentiment(rating, goodRatingThreshold) : void 0;
  const question = typeof rating === "number" ? getQuestionForRating(rating, labels, goodRatingThreshold, course.custom_title) : void 0;
  const otherQuestion = sentiment === "impressed" ? labels.otherImpressedQuestion : labels.otherImprovementQuestion;
  const hasOthers = selectedReasons.some(
    (reason) => isOthersOption(reason, labels.others)
  );
  const shouldShowFeedbackText = sentiment === "improvement";
  const filteredOptions = feedbackOptions.filter((option) => {
    var _a;
    if (isOthersOption(option, labels.others)) return true;
    const tag = (_a = course.tags) == null ? void 0 : _a.find((t) => t.label === option);
    if (!tag) return true;
    return tag.category === sentiment;
  });
  const style = __spreadValues({
    "--cr-primary": theme.primaryColor,
    "--cr-star": theme.starColor,
    "--cr-star-inactive": theme.inactiveStarColor,
    "--cr-text": theme.textColor,
    "--cr-muted": theme.mutedTextColor,
    "--cr-button-text": theme.buttonTextColor,
    "--cr-course-button": theme.courseButtonColor,
    "--cr-bg": theme.backgroundColor,
    "--cr-border": theme.borderColor,
    "--cr-radius": `${theme.borderRadius}px`
  }, backgroundImage ? { "--cr-rating-bg-image": `url("${backgroundImage}")` } : {});
  function handleStarKeyDown(event, value) {
    var _a, _b, _c;
    const keyToRating = {
      ArrowRight: Math.min(value + 1, 5),
      ArrowUp: Math.min(value + 1, 5),
      ArrowLeft: Math.max(value - 1, 1),
      ArrowDown: Math.max(value - 1, 1),
      Home: 1,
      End: 5
    };
    const nextRating = keyToRating[event.key];
    if (!nextRating) {
      return;
    }
    event.preventDefault();
    onRatingChange(nextRating);
    const starButtons = Array.from(
      (_b = (_a = event.currentTarget.parentElement) == null ? void 0 : _a.querySelectorAll(
        ".cr-star-button"
      )) != null ? _b : []
    );
    (_c = starButtons[nextRating - 1]) == null ? void 0 : _c.focus();
  }
  return /* @__PURE__ */ React.createElement(
    "section",
    {
      className: `cr-card cr-rating-card ${question ? "cr-rating-card-has-feedback" : ""}`,
      style
    },
    /* @__PURE__ */ React.createElement(
      "div",
      {
        className: `cr-card-background ${backgroundImage ? "cr-card-background-image" : ""}`,
        "aria-hidden": "true"
      }
    ),
    logoImage ? /* @__PURE__ */ React.createElement("img", { className: "cr-logo", src: logoImage, alt: "" }) : null,
    mascotImage ? /* @__PURE__ */ React.createElement("div", { className: "cr-mascot-wrap", "aria-hidden": "true" }, /* @__PURE__ */ React.createElement("img", { className: "cr-mascot", src: mascotImage, alt: "" })) : null,
    /* @__PURE__ */ React.createElement("div", { className: "cr-form-panel" }, /* @__PURE__ */ React.createElement("div", { className: "cr-content" }, /* @__PURE__ */ React.createElement("h2", { id: "cr-title", className: "cr-title" }, labels.title), labels.description ? /* @__PURE__ */ React.createElement("p", { className: "cr-description" }, labels.description) : null, /* @__PURE__ */ React.createElement("div", { className: "cr-course-pill" }, course.title), /* @__PURE__ */ React.createElement(
      "div",
      {
        className: "cr-stars",
        role: "radiogroup",
        "aria-label": labels.ratingAriaLabel
      },
      [1, 2, 3, 4, 5].map((value) => /* @__PURE__ */ React.createElement(
        "button",
        {
          key: value,
          className: `cr-star-button ${typeof rating === "number" && value <= rating ? "cr-star-button-active" : ""}`,
          type: "button",
          role: "radio",
          "aria-label": `${value} star${value > 1 ? "s" : ""}`,
          "aria-checked": rating === value,
          onClick: () => onRatingChange(value),
          onKeyDown: (event) => handleStarKeyDown(event, value)
        },
        /* @__PURE__ */ React.createElement("span", { className: "cr-star-shape" })
      ))
    ), question ? /* @__PURE__ */ React.createElement("div", { className: "cr-feedback" }, /* @__PURE__ */ React.createElement("div", { className: "cr-divider" }), /* @__PURE__ */ React.createElement("p", { className: "cr-question" }, question), /* @__PURE__ */ React.createElement("div", { className: "cr-chips", "aria-label": question }, filteredOptions.map((option) => {
      const isSelected = selectedReasons.includes(option);
      return /* @__PURE__ */ React.createElement(
        "button",
        {
          key: option,
          className: `cr-chip ${isSelected ? "cr-chip-active" : ""}`,
          type: "button",
          "aria-pressed": isSelected,
          onClick: () => onToggleReason(option)
        },
        option
      );
    })), hasOthers ? /* @__PURE__ */ React.createElement("label", { className: "cr-other" }, /* @__PURE__ */ React.createElement("span", null, otherQuestion), /* @__PURE__ */ React.createElement(
      "textarea",
      {
        value: otherText,
        onChange: (event) => onOtherTextChange(event.target.value),
        rows: 2
      }
    )) : null, shouldShowFeedbackText ? /* @__PURE__ */ React.createElement("label", { className: "cr-other" }, /* @__PURE__ */ React.createElement("span", null, labels.feedbackImprovementQuestion), /* @__PURE__ */ React.createElement(
      "textarea",
      {
        value: feedbackText,
        onChange: (event) => onFeedbackTextChange(event.target.value),
        rows: 3
      }
    )) : null) : null, question ? /* @__PURE__ */ React.createElement(React.Fragment, null, submitError ? /* @__PURE__ */ React.createElement("p", { className: "cr-error" }, submitError) : null, /* @__PURE__ */ React.createElement(
      "button",
      {
        className: "cr-submit",
        type: "button",
        disabled: !isValid || isSubmitting,
        onClick: onSubmit
      },
      isSubmitting ? labels.loading : labels.submit
    )) : null))
  );
}

// src/reactjs/CourseRatingModal.tsx
import {
  default as React2,
  useEffect,
  useRef
} from "react";
var FOCUSABLE_SELECTOR = 'button, [href], input, textarea, select, [tabindex]:not([tabindex="-1"])';
function CourseRatingModal({
  children,
  enableClose,
  closeLabel,
  dialogClassName,
  onClose
}) {
  const dialogRef = useRef(null);
  useEffect(() => {
    var _a;
    const previousActiveElement = document.activeElement;
    const previousBodyOverflow = document.body.style.overflow;
    const previousDocumentOverflow = document.documentElement.style.overflow;
    document.body.style.overflow = "hidden";
    document.documentElement.style.overflow = "hidden";
    (_a = dialogRef.current) == null ? void 0 : _a.focus();
    return () => {
      document.body.style.overflow = previousBodyOverflow;
      document.documentElement.style.overflow = previousDocumentOverflow;
      if (previousActiveElement instanceof HTMLElement) {
        previousActiveElement.focus();
      }
    };
  }, []);
  function handleKeyDown(event) {
    var _a, _b;
    if (event.key === "Escape" && !enableClose) {
      event.preventDefault();
      return;
    }
    if (event.key === "Escape" && enableClose) {
      event.preventDefault();
      onClose == null ? void 0 : onClose();
      return;
    }
    if (event.key !== "Tab") {
      return;
    }
    const focusable = Array.from(
      (_b = (_a = dialogRef.current) == null ? void 0 : _a.querySelectorAll(FOCUSABLE_SELECTOR)) != null ? _b : []
    ).filter((element) => !element.hasAttribute("disabled"));
    if (focusable.length === 0) {
      event.preventDefault();
      return;
    }
    const firstElement = focusable[0];
    const lastElement = focusable[focusable.length - 1];
    if (!event.shiftKey && document.activeElement === lastElement) {
      event.preventDefault();
      firstElement == null ? void 0 : firstElement.focus();
    }
    if (event.shiftKey && document.activeElement === firstElement) {
      event.preventDefault();
      lastElement == null ? void 0 : lastElement.focus();
    }
  }
  return /* @__PURE__ */ React2.createElement("div", { className: "cr-overlay", "data-testid": "course-rating-overlay" }, /* @__PURE__ */ React2.createElement(
    "div",
    {
      ref: dialogRef,
      className: `cr-dialog ${dialogClassName != null ? dialogClassName : ""}`,
      role: "dialog",
      "aria-modal": "true",
      "aria-labelledby": "cr-title",
      tabIndex: -1,
      onKeyDown: handleKeyDown
    },
    enableClose ? /* @__PURE__ */ React2.createElement(
      "button",
      {
        className: "cr-close",
        type: "button",
        "aria-label": closeLabel,
        onClick: onClose
      },
      "x"
    ) : null,
    children
  ));
}

// src/reactjs/CourseRatingSuccess.tsx
import React3 from "react";
function CourseRatingSuccess({
  labels,
  theme,
  hasNext,
  mascotImage,
  backgroundImage,
  onContinue
}) {
  const style = __spreadValues({
    "--cr-primary": theme.primaryColor,
    "--cr-button-text": theme.buttonTextColor,
    "--cr-radius": `${theme.borderRadius}px`
  }, backgroundImage ? { "--cr-success-bg-image": `url("${backgroundImage}")` } : {});
  return /* @__PURE__ */ React3.createElement("section", { className: "cr-card cr-success-card", style }, /* @__PURE__ */ React3.createElement(
    "div",
    {
      className: `cr-success-background ${backgroundImage ? "cr-success-background-image" : ""}`,
      "aria-hidden": "true"
    }
  ), /* @__PURE__ */ React3.createElement("div", { className: "cr-success-content" }, /* @__PURE__ */ React3.createElement("h2", { id: "cr-title", className: "cr-success-title" }, labels.successTitle), /* @__PURE__ */ React3.createElement("p", { className: "cr-success-description" }, labels.successDescription), /* @__PURE__ */ React3.createElement("button", { className: "cr-success-button", type: "button", onClick: onContinue }, hasNext ? labels.nextCourse : labels.backToHome)), mascotImage ? /* @__PURE__ */ React3.createElement("div", { className: "cr-success-mascot-wrap", "aria-hidden": "true" }, /* @__PURE__ */ React3.createElement("img", { className: "cr-success-mascot", src: mascotImage, alt: "" })) : null);
}

// src/reactjs/CourseRating.tsx
var EMPTY_FORM_STATE = {
  rating: void 0,
  selectedReasons: [],
  otherText: "",
  feedbackText: ""
};
function CourseRating({
  data,
  onSubmitRating,
  onDone,
  onBackToHome,
  enableClose,
  onClose,
  language = "id",
  labels: labelOverrides,
  feedbackOptions,
  goodRatingThreshold = DEFAULT_GOOD_RATING_THRESHOLD,
  assets,
  theme: themeOverrides
}) {
  var _a, _b;
  const [isVisible, setIsVisible] = useState(Boolean(data == null ? void 0 : data.length));
  const [currentIndex, setCurrentIndex] = useState(0);
  const [view, setView] = useState("form");
  const [formState, setFormState] = useState(EMPTY_FORM_STATE);
  const [isSubmitting, setIsSubmitting] = useState(false);
  const [submitError, setSubmitError] = useState();
  const labels = useMemo(
    () => getLabels(language, labelOverrides),
    [language, labelOverrides]
  );
  const theme = useMemo(() => getTheme(themeOverrides), [themeOverrides]);
  const courses = data != null ? data : [];
  const course = courses[currentIndex];
  const options = useMemo(() => {
    var _a2;
    const courseTags = ((_a2 = course == null ? void 0 : course.tags) == null ? void 0 : _a2.map((t) => t.label)) || [];
    const baseOptions = courseTags.length ? courseTags : feedbackOptions;
    return normalizeFeedbackOptions(baseOptions, labels.others);
  }, [feedbackOptions, labels.others, course]);
  const total = courses.length;
  const hasNext = currentIndex < total - 1;
  const validation = validateRatingForm(formState, labels.others);
  useEffect2(() => {
    if (view === "success") return;
    if (data == null ? void 0 : data.length) {
      setIsVisible(true);
      setCurrentIndex(0);
      setView("form");
      setFormState(EMPTY_FORM_STATE);
      setSubmitError(void 0);
    } else {
      setIsVisible(false);
    }
  }, [data, view]);
  if (!isVisible || view !== "success" && !course) {
    return null;
  }
  const activeCourse = course;
  function resetForm() {
    setFormState(EMPTY_FORM_STATE);
    setSubmitError(void 0);
    setIsSubmitting(false);
  }
  function handleClose() {
    setIsVisible(false);
    onClose == null ? void 0 : onClose();
  }
  function handleRatingChange(nextRating) {
    setSubmitError(void 0);
    setFormState((current) => __spreadProps(__spreadValues({}, current), {
      rating: nextRating
    }));
  }
  function handleToggleReason(reason) {
    setSubmitError(void 0);
    setFormState((current) => {
      const isSelected = current.selectedReasons.includes(reason);
      return __spreadProps(__spreadValues({}, current), {
        selectedReasons: isSelected ? current.selectedReasons.filter((item) => item !== reason) : [...current.selectedReasons, reason]
      });
    });
  }
  function handleSubmit() {
    return __async(this, null, function* () {
      const currentValidation = validateRatingForm(formState, labels.others);
      if (!currentValidation.isValid || typeof formState.rating !== "number") {
        return;
      }
      setIsSubmitting(true);
      setSubmitError(void 0);
      try {
        yield onSubmitRating(
          buildSubmitPayload({
            course: activeCourse,
            rating: formState.rating,
            selectedReasons: formState.selectedReasons,
            otherText: formState.otherText,
            feedbackText: formState.feedbackText,
            language,
            labels,
            goodRatingThreshold,
            index: currentIndex,
            total
          })
        );
        setView("success");
      } catch (e) {
        setSubmitError(labels.submitError);
      } finally {
        setIsSubmitting(false);
      }
    });
  }
  function handleContinue() {
    if (hasNext) {
      setCurrentIndex((index) => index + 1);
      setView("form");
      resetForm();
      return;
    }
    setIsVisible(false);
    onDone == null ? void 0 : onDone();
    onBackToHome == null ? void 0 : onBackToHome();
  }
  return /* @__PURE__ */ React4.createElement(
    CourseRatingModal,
    {
      enableClose,
      closeLabel: labels.closeLabel,
      dialogClassName: view === "success" ? "cr-dialog-success" : void 0,
      onClose: enableClose ? handleClose : void 0
    },
    view === "success" ? /* @__PURE__ */ React4.createElement(
      CourseRatingSuccess,
      {
        labels,
        theme,
        hasNext,
        mascotImage: assets == null ? void 0 : assets.mascotImage,
        backgroundImage: getResponsiveImage(assets, "success"),
        onContinue: handleContinue
      }
    ) : /* @__PURE__ */ React4.createElement(
      CourseRatingForm,
      {
        course: activeCourse,
        labels,
        theme,
        feedbackOptions: options,
        rating: formState.rating,
        selectedReasons: formState.selectedReasons,
        otherText: (_a = formState.otherText) != null ? _a : "",
        feedbackText: (_b = formState.feedbackText) != null ? _b : "",
        isValid: validation.isValid,
        isSubmitting,
        submitError,
        goodRatingThreshold,
        mascotImage: assets == null ? void 0 : assets.mascotImage,
        logoImage: assets == null ? void 0 : assets.logoImage,
        backgroundImage: getResponsiveImage(assets, "rating"),
        onRatingChange: handleRatingChange,
        onToggleReason: handleToggleReason,
        onOtherTextChange: (otherText) => setFormState((current) => __spreadProps(__spreadValues({}, current), { otherText })),
        onFeedbackTextChange: (feedbackText) => setFormState((current) => __spreadProps(__spreadValues({}, current), { feedbackText })),
        onSubmit: handleSubmit
      }
    )
  );
}

// src/reactjs/CourseRatingSummary.tsx
import React6 from "react";

// src/reactjs/StarRating.tsx
import React5 from "react";
function StarRating({ rating, size = 18 }) {
  return /* @__PURE__ */ React5.createElement("div", { className: "cr-stars-display", style: { "--cr-star-size": `${size}px` } }, [1, 2, 3, 4, 5].map((value) => {
    const fillAmount = Math.max(0, Math.min(1, rating - (value - 1)));
    return /* @__PURE__ */ React5.createElement("div", { key: value, className: "cr-star-item" }, /* @__PURE__ */ React5.createElement(
      "span",
      {
        className: "cr-star-shape",
        style: { "--cr-star-fill": `${fillAmount * 100}%` }
      }
    ));
  }));
}

// src/reactjs/CourseRatingSummary.tsx
var SUMMARY_LABELS = {
  id: { outOfFive: "dari 5", ratings: "Penilaian", stars: "Bintang" },
  en: { outOfFive: "out of 5", ratings: "Ratings", stars: "Stars" }
};
function CourseRatingSummary({
  data,
  theme,
  waveImage,
  language = "id"
}) {
  var _a;
  const labels = (_a = SUMMARY_LABELS[language]) != null ? _a : SUMMARY_LABELS.id;
  const style = __spreadValues({
    "--cr-primary": (theme == null ? void 0 : theme.primaryColor) || "#9b0008",
    "--cr-star": (theme == null ? void 0 : theme.starColor) || "#ffd45a"
  }, waveImage ? { "--cr-wave-bg": `url("${waveImage}")` } : {});
  return /* @__PURE__ */ React6.createElement("div", { className: "cr-summary-container", style }, /* @__PURE__ */ React6.createElement("div", { className: "cr-summary-card" }, /* @__PURE__ */ React6.createElement("div", { className: "cr-summary-bg-wave" }), /* @__PURE__ */ React6.createElement("div", { className: "cr-summary-left" }, /* @__PURE__ */ React6.createElement("div", { className: "cr-summary-score-wrap" }, /* @__PURE__ */ React6.createElement("span", { className: "cr-summary-score" }, data.averageRating), /* @__PURE__ */ React6.createElement("span", { className: "cr-summary-out-of" }, labels.outOfFive)), /* @__PURE__ */ React6.createElement("div", { className: "cr-summary-stars" }, /* @__PURE__ */ React6.createElement(StarRating, { rating: data.averageRating, size: 22 })), /* @__PURE__ */ React6.createElement("div", { className: "cr-summary-total" }, data.totalRatings.toLocaleString(), " ", labels.ratings)), /* @__PURE__ */ React6.createElement("div", { className: "cr-summary-divider" }), /* @__PURE__ */ React6.createElement("div", { className: "cr-summary-right" }, data.distribution.map((item) => /* @__PURE__ */ React6.createElement("div", { key: item.stars, className: "cr-summary-row" }, /* @__PURE__ */ React6.createElement("span", { className: "cr-summary-label" }, item.stars, " ", labels.stars), /* @__PURE__ */ React6.createElement("div", { className: "cr-summary-progress" }, /* @__PURE__ */ React6.createElement(
    "div",
    {
      className: "cr-summary-progress-bar",
      style: { width: `${item.percentage}%` }
    }
  )), /* @__PURE__ */ React6.createElement("span", { className: "cr-summary-percent" }, item.percentage, "%"))))));
}

// src/reactjs/CourseRatingScore.tsx
import React7 from "react";
function CourseRatingScore({
  score,
  totalRatings,
  size = 16,
  showText = true
}) {
  return /* @__PURE__ */ React7.createElement("div", { className: "cr-score-display" }, /* @__PURE__ */ React7.createElement(StarRating, { rating: score, size }), showText && /* @__PURE__ */ React7.createElement("span", { className: "cr-score-text" }, score.toFixed(1)), totalRatings !== void 0 && /* @__PURE__ */ React7.createElement("span", { className: "cr-score-total" }, "(", totalRatings, ")"));
}
export {
  CourseRating,
  CourseRatingScore,
  CourseRatingSummary,
  DEFAULT_FEEDBACK_OPTIONS,
  DEFAULT_GOOD_RATING_THRESHOLD,
  DEFAULT_LABELS,
  DEFAULT_THEME,
  StarRating,
  buildSubmitPayload,
  getFeedbackQuestion,
  getLabels,
  getQuestionForRating,
  getRatingSentiment,
  getTheme,
  isOthersOption,
  normalizeFeedbackOptions,
  validateRatingForm
};
//# sourceMappingURL=index.js.map