import { E as compilerRuntimeExports, j as jsxRuntimeExports, r as reactExports } from "./vendor-react-DYNCg6N5.js";
import { c as useAppSelector } from "./index-DfebxkL9.js";
import { b as gq } from "./vendor-icons-xWhXK_Ui.js";
import { u as useTranslation } from "./vendor-i18n-wisIXUFi.js";
import { a4 as Select } from "./vendor-mantine-h0WlM2Mj.js";
const option = "_option_1b4kc_1";
const classes = {
  option
};
const src = (lng) => `https://flagcdn.com/${lng === "en" ? "us" : lng}.svg`;
const RenderLanguageOption = (item) => {
  const $ = compilerRuntimeExports.c(11);
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    t0 = {
      flexShrink: 0
    };
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  let t1;
  if ($[1] !== item.option.value) {
    t1 = src(item.option.value);
    $[1] = item.option.value;
    $[2] = t1;
  } else {
    t1 = $[2];
  }
  let t2;
  if ($[3] !== item.option.value || $[4] !== t1) {
    t2 = /* @__PURE__ */ jsxRuntimeExports.jsx("img", { width: 18, height: 18, style: t0, src: t1, alt: item.option.value });
    $[3] = item.option.value;
    $[4] = t1;
    $[5] = t2;
  } else {
    t2 = $[5];
  }
  let t3;
  if ($[6] !== item.option.label) {
    t3 = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: item.option.label });
    $[6] = item.option.label;
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  let t4;
  if ($[8] !== t2 || $[9] !== t3) {
    t4 = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: classes.option, children: [
      t2,
      t3
    ] });
    $[8] = t2;
    $[9] = t3;
    $[10] = t4;
  } else {
    t4 = $[10];
  }
  return t4;
};
const LanguageSelect = (t0) => {
  var _a;
  const $ = compilerRuntimeExports.c(23);
  let rest;
  let value;
  if ($[0] !== t0) {
    ({
      value,
      ...rest
    } = t0);
    $[0] = t0;
    $[1] = rest;
    $[2] = value;
  } else {
    rest = $[1];
    value = $[2];
  }
  const {
    t
  } = useTranslation();
  const {
    Languages
  } = useAppSelector(_temp);
  let t1;
  if ($[3] !== Languages) {
    t1 = (_a = Object.values(Languages)) == null ? void 0 : _a.map(_temp2);
    $[3] = Languages;
    $[4] = t1;
  } else {
    t1 = $[4];
  }
  const languageData = t1;
  let t2;
  if ($[5] !== value) {
    t2 = src(value);
    $[5] = value;
    $[6] = t2;
  } else {
    t2 = $[6];
  }
  const currentLang = t2;
  let t3;
  if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
    t3 = {
      label: {
        color: "#667085",
        fontSize: 12
      }
    };
    $[7] = t3;
  } else {
    t3 = $[7];
  }
  let t4;
  if ($[8] !== currentLang || $[9] !== value) {
    t4 = value ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { width: 18, height: 18, style: {
      flexShrink: 0
    }, src: currentLang, alt: currentLang }) : null;
    $[8] = currentLang;
    $[9] = value;
    $[10] = t4;
  } else {
    t4 = $[10];
  }
  let t5;
  if ($[11] !== t) {
    t5 = t("profile.language");
    $[11] = t;
    $[12] = t5;
  } else {
    t5 = $[12];
  }
  let t6;
  if ($[13] !== t) {
    t6 = t("profile.selectLanguage");
    $[13] = t;
    $[14] = t6;
  } else {
    t6 = $[14];
  }
  let t7;
  if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
    t7 = /* @__PURE__ */ jsxRuntimeExports.jsx(gq, { stroke: 1.5 });
    $[15] = t7;
  } else {
    t7 = $[15];
  }
  let t8;
  if ($[16] !== languageData || $[17] !== rest || $[18] !== t4 || $[19] !== t5 || $[20] !== t6 || $[21] !== value) {
    t8 = /* @__PURE__ */ jsxRuntimeExports.jsx(Select, { w: "100%", miw: 352, maw: 380, styles: t3, radius: "md", leftSection: t4, renderOption: RenderLanguageOption, label: t5, placeholder: t6, data: languageData, value, mb: 25, rightSection: t7, searchable: true, allowDeselect: false, ...rest });
    $[16] = languageData;
    $[17] = rest;
    $[18] = t4;
    $[19] = t5;
    $[20] = t6;
    $[21] = value;
    $[22] = t8;
  } else {
    t8 = $[22];
  }
  return t8;
};
function _temp(state) {
  return state.commonSettings.LanguageSettings;
}
function _temp2(language) {
  return {
    label: language.Name,
    value: language.Id
  };
}
const TimezoneSelect = ({
  value,
  ...rest
}) => {
  const {
    t,
    i18n
  } = useTranslation();
  const language = i18n.language;
  const {
    Timezones
  } = useAppSelector((state) => state.commonSettings.TimezoneSettings);
  const data = reactExports.useMemo(() => {
    return Object.values(Timezones).sort((a, b) => a.utcOffsetMinutes - b.utcOffsetMinutes).map((a_0) => {
      const timezone = t(`timezones.${a_0.tzName}`);
      return {
        ...a_0,
        label: `(UTC${a_0.utc}) ${timezone}`
      };
    });
  }, [Timezones, language]);
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Select, { w: "100%", miw: 352, maw: 380, styles: {
    label: {
      color: "#667085",
      fontSize: 12
    }
  }, radius: "md", label: t("profile.timeZone"), placeholder: t("profile.selectTimeZone"), data, value, mb: 25, rightSection: /* @__PURE__ */ jsxRuntimeExports.jsx(gq, { stroke: 1.5 }), searchable: true, ...rest });
};
export {
  LanguageSelect as L,
  TimezoneSelect as T
};
//# sourceMappingURL=index-lG79Dd5P.js.map
