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/productCard/hooks/useOpenNote.tsx
var useOpenNote_exports = {};
__export(useOpenNote_exports, {
  default: () => useOpenNote_default
});
module.exports = __toCommonJS(useOpenNote_exports);
var import_react = __toESM(require("react"));
var import_utils = require("@pisell/utils");
var import__ = require("../../../index");
var useOpenNote = ({ onNoteChange }, ref) => {
  const [open, setOpen] = (0, import_react.useState)(false);
  const [item, setItem] = (0, import_react.useState)({});
  const [value, setValue] = (0, import_react.useState)();
  (0, import_react.useImperativeHandle)(ref, () => {
    return {
      open: ({ item: item2 }) => {
        setItem(item2);
        setValue(item2 == null ? void 0 : item2.note);
        setOpen(true);
      }
    };
  });
  const handleOk = () => {
    onNoteChange(value);
    setOpen(false);
  };
  return /* @__PURE__ */ import_react.default.createElement(
    import__.PisellModal,
    {
      platform: (0, import_utils.isMobile)() ? "h5" : "pc",
      open,
      bodyStyle: { padding: 0 },
      title: (item == null ? void 0 : item.note) ? import_utils.locales.getText("pisell2.product.card.discount.edit.note") : import_utils.locales.getText("pisell2.product.card.discount.add.note"),
      onCancel: () => setOpen(false),
      onOk: handleOk,
      destroyOnClose: true,
      mobileModalHeight: "80vh",
      className: "pisell-lowcode__booking-select-pet-modal-wrap",
      okText: import_utils.locales.getText("pisell2.product.card.confirm"),
      cancelText: import_utils.locales.getText("pisell2.product.card.cancel")
    },
    /* @__PURE__ */ import_react.default.createElement(
      import__.Input.TextArea,
      {
        size: "large",
        placeholder: import_utils.locales.getText("pisell2.product.card.note.pla"),
        autoSize: { minRows: 4 },
        allowClear: true,
        value,
        onChange: (e) => {
          setValue(e.target.value);
        }
      }
    )
  );
};
var useOpenNote_default = (0, import_react.forwardRef)(useOpenNote);
