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/components/eventBooking/components/Voucher/components/Voucher.tsx
var Voucher_exports = {};
__export(Voucher_exports, {
  default: () => Voucher_default
});
module.exports = __toCommonJS(Voucher_exports);
var import_react = __toESM(require("react"));
var import_ChevronDown = __toESM(require("@pisell/icon/es/ChevronDown"));
var import_UserCircle = __toESM(require("@pisell/icon/es/UserCircle"));
var import_classnames = __toESM(require("classnames"));
var import_utils = require("@pisell/utils");
var import_materials = require("@pisell/materials");
var import_useEngineContext = __toESM(require("../../../../../hooks/useEngineContext"));
var import_locales = __toESM(require("./locales"));
var import_index = require("./index.less");
var VoucherUI = ({
  showDetail,
  onToggleDetail,
  isLogin,
  onLoginClick,
  availableData,
  onDiscountChange,
  mixedSort,
  code,
  onCodeChange,
  onApplyCode,
  codeDisabled = false
}) => {
  var _a;
  const context = (0, import_useEngineContext.default)();
  const utils = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {};
  (0, import_react.useEffect)(() => {
    var _a2;
    const locale = ((_a2 = utils == null ? void 0 : utils.storage) == null ? void 0 : _a2.get("umi_locale")) || "en";
    import_utils.locales.init(import_locales.default, locale);
  }, [utils]);
  const renderLoginCard = () => {
    if (isLogin) return null;
    return /* @__PURE__ */ import_react.default.createElement("div", { className: "login-card" }, /* @__PURE__ */ import_react.default.createElement(import_UserCircle.default, { style: { fontSize: 28 } }), /* @__PURE__ */ import_react.default.createElement("div", { className: "text-wrapper" }, /* @__PURE__ */ import_react.default.createElement(import_materials.PisellText, { className: "login-btn", onClick: onLoginClick }, import_utils.locales.getText("pisell2.voucher.login")), /* @__PURE__ */ import_react.default.createElement("span", null, " ", import_utils.locales.getText("pisell2.voucher.login-tip"))));
  };
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__event-booking-voucher-container" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "voucher-title" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "voucher-title-left" }, import_utils.locales.getText("pisell2.voucher.title")), /* @__PURE__ */ import_react.default.createElement("span", { className: "voucher-title-right", onClick: onToggleDetail }, import_utils.locales.getText("pisell2.voucher.details"), " ", /* @__PURE__ */ import_react.default.createElement(
    import_ChevronDown.default,
    {
      className: (0, import_classnames.default)("voucher-right-icon", {
        show: showDetail
      })
    }
  ))), /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)("voucher-detail", {
        show: showDetail
      })
    },
    (availableData == null ? void 0 : availableData.length) > 0 ? /* @__PURE__ */ import_react.default.createElement(
      import_materials.PisellGoodPassCard,
      {
        style: { width: "100%" },
        dataSource: availableData,
        mixedSort,
        onChange: onDiscountChange
      }
    ) : null,
    renderLoginCard(),
    /* @__PURE__ */ import_react.default.createElement("div", { className: "voucher-code-input-wrapper" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "voucher-code-input" }, /* @__PURE__ */ import_react.default.createElement("div", { style: { whiteSpace: "nowrap" } }, import_utils.locales.getText("pisell2.voucher.code"), ":"), /* @__PURE__ */ import_react.default.createElement(
      import_materials.PisellInput,
      {
        value: code,
        allowClear: true,
        onChange: (e) => {
          var _a2;
          onCodeChange((_a2 = e.target) == null ? void 0 : _a2.value);
        },
        size: "small",
        placeholder: import_utils.locales.getText("pisell2.voucher.enter-code")
      }
    )), /* @__PURE__ */ import_react.default.createElement(
      import_materials.Button,
      {
        size: "small",
        disabled: codeDisabled,
        onClick: () => onApplyCode()
      },
      import_utils.locales.getText("pisell2.voucher.apply")
    ))
  ));
};
var Voucher_default = VoucherUI;
