var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/saasAttendance/settings/ShiftScheduleTab.tsx
var ShiftScheduleTab_exports = {};
__export(ShiftScheduleTab_exports, {
  default: () => ShiftScheduleTab_default
});
module.exports = __toCommonJS(ShiftScheduleTab_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_shiftModal = __toESM(require("./components/shiftModal"));
var ScheduleSetting = (props) => {
  const { value, onChange } = props;
  const [open, setOpen] = (0, import_react.useState)(false);
  const label = Array.isArray(value) && value.some((d) => {
    var _a;
    return (_a = d == null ? void 0 : d.times) == null ? void 0 : _a.length;
  }) ? import_utils.locales.getText(
    "pisell2.attendance.group-settings.shift-schedule.scheduled-shifts.change-shifts"
  ) : import_utils.locales.getText(
    "pisell2.attendance.group-settings.shift-schedule.scheduled-shifts.set-shifts"
  );
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(import_antd.Button, { type: "primary", onClick: () => setOpen(true) }, label), /* @__PURE__ */ import_react.default.createElement(
    import_shiftModal.default,
    {
      open,
      value,
      onCancel: () => setOpen(false),
      onOk: (next) => {
        onChange == null ? void 0 : onChange(next);
      }
    }
  ));
};
var ShiftScheduleTab = (props) => {
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__panel", id: props.id }, /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__banner banner-blue" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "banner-icon" }, /* @__PURE__ */ import_react.default.createElement(import_materials.Icon, { type: "pisell2-calendar", size: 20 })), /* @__PURE__ */ import_react.default.createElement("div", { className: "banner-body" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "banner-title" }, import_utils.locales.getText(
    "pisell2.attendance.group-settings.shift-schedule.fixed-shifts.title"
  )), /* @__PURE__ */ import_react.default.createElement("div", { className: "banner-desc" }, import_utils.locales.getText(
    "pisell2.attendance.group-settings.shift-schedule.fixed-shifts.desc"
  )))), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Form.Item,
    {
      label: import_utils.locales.getText(
        "pisell2.attendance.group-settings.shift-schedule.attendance-type.label"
      ),
      name: ["shift", "type"],
      initialValue: "fixed"
    },
    /* @__PURE__ */ import_react.default.createElement(import_antd.Radio.Group, { className: "saas-attendance-group-settings__radio-cards" }, /* @__PURE__ */ import_react.default.createElement("label", { className: "saas-attendance-group-settings__radio-card saas-attendance-group-settings__radio-card--selected" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Radio, { value: "fixed" }), /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__radio-content" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__radio-title" }, import_utils.locales.getText(
      "pisell2.attendance.group-settings.shift-schedule.attendance-type.scheduled-shifts.title"
    )), /* @__PURE__ */ import_react.default.createElement("div", { className: "saas-attendance-group-settings__radio-desc" }, import_utils.locales.getText(
      "pisell2.attendance.group-settings.shift-schedule.fixed-shifts.desc"
    )))))
  ), /* @__PURE__ */ import_react.default.createElement(
    import_antd.Form.Item,
    {
      name: ["shift", "fixed"],
      rules: [
        {
          validator: async (_rule, value) => {
            const hasShift = Array.isArray(value) && value.some(
              (item) => Array.isArray(item == null ? void 0 : item.times) && item.times.length > 0
            );
            if (!hasShift) {
              throw new Error(
                import_utils.locales.getText(
                  "pisell2.attendance.group-settings.shift-schedule.validation.fixed-required"
                )
              );
            }
          }
        }
      ]
    },
    /* @__PURE__ */ import_react.default.createElement(ScheduleSetting, null)
  ));
};
var ShiftScheduleTab_default = ShiftScheduleTab;
