'use strict';

var React5 = require('react');
var reactDom = require('react-dom');
var lucideReact = require('lucide-react');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React5__default = /*#__PURE__*/_interopDefault(React5);

// src/auth/legacy/components/AuthGuard.tsx
var AuthContext = React5.createContext(void 0);
function useAuth() {
  const context = React5.useContext(AuthContext);
  if (context === void 0) {
    throw new Error("useAuth must be used within an AuthProvider");
  }
  return context;
}

// src/auth/legacy/utils/authUtils.ts
function validatePhoneNumber(phone) {
  return /^1[3-9]\d{9}$/.test(phone);
}
function validatePassword(password) {
  if (!password) {
    return { valid: false, message: "\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A" };
  }
  if (password.length < 6) {
    return { valid: false, message: "\u5BC6\u7801\u957F\u5EA6\u81F3\u5C116\u4F4D" };
  }
  return { valid: true };
}
function ForgotPasswordModal({ isOpen, onClose, onSuccess }) {
  const [formData, setFormData] = React5.useState({
    phone: "",
    newPassword: "",
    confirmPassword: "",
    verificationCode: ""
  });
  const [showPassword, setShowPassword] = React5.useState(false);
  const [showConfirmPassword, setShowConfirmPassword] = React5.useState(false);
  const [error, setError] = React5.useState("");
  const [loading, setLoading] = React5.useState(false);
  const [countdown, setCountdown] = React5.useState(0);
  const [mounted, setMounted] = React5.useState(false);
  React5.useEffect(() => {
    setMounted(true);
  }, []);
  const handleInputChange = (e) => {
    const { name, value } = e.target;
    setFormData((prev) => ({ ...prev, [name]: value }));
    if (error) setError("");
  };
  const validateForm = () => {
    if (!formData.phone || !formData.newPassword || !formData.confirmPassword || !formData.verificationCode) {
      setError("\u8BF7\u586B\u5199\u5B8C\u6574\u4FE1\u606F");
      return false;
    }
    if (!validatePhoneNumber(formData.phone)) {
      setError("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u683C\u5F0F");
      return false;
    }
    const passwordValidation = validatePassword(formData.newPassword);
    if (!passwordValidation.valid) {
      setError(passwordValidation.message || "\u5BC6\u7801\u683C\u5F0F\u9519\u8BEF");
      return false;
    }
    if (formData.newPassword !== formData.confirmPassword) {
      setError("\u4E24\u6B21\u8F93\u5165\u7684\u5BC6\u7801\u4E0D\u4E00\u81F4");
      return false;
    }
    if (!/^\d{6}$/.test(formData.verificationCode)) {
      setError("\u8BF7\u8F93\u51656\u4F4D\u6570\u5B57\u9A8C\u8BC1\u7801");
      return false;
    }
    return true;
  };
  const handleSendCode = async () => {
    if (!formData.phone) {
      setError("\u8BF7\u8F93\u5165\u624B\u673A\u53F7");
      return;
    }
    if (!validatePhoneNumber(formData.phone)) {
      setError("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u683C\u5F0F");
      return;
    }
    try {
      setLoading(true);
      setError("");
      const response = await fetch("/api/auth/send-verification-code", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ phone: formData.phone })
      });
      const data = await response.json();
      if (data.success) {
        setCountdown(60);
        const timer = setInterval(() => {
          setCountdown((prev) => {
            if (prev <= 1) {
              clearInterval(timer);
              return 0;
            }
            return prev - 1;
          });
        }, 1e3);
        console.log("\u2705 \u9A8C\u8BC1\u7801\u53D1\u9001\u6210\u529F");
      } else {
        setError(data.message || "\u53D1\u9001\u9A8C\u8BC1\u7801\u5931\u8D25");
      }
    } catch (error2) {
      console.error("\u53D1\u9001\u9A8C\u8BC1\u7801\u5F02\u5E38:", error2);
      setError("\u53D1\u9001\u9A8C\u8BC1\u7801\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
    } finally {
      setLoading(false);
    }
  };
  const handleSubmit = async (e) => {
    e.preventDefault();
    setError("");
    setLoading(true);
    try {
      if (!validateForm()) {
        return;
      }
      const response = await fetch("/api/auth/reset-password", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          phone: formData.phone,
          newPassword: formData.newPassword,
          verificationCode: formData.verificationCode
        })
      });
      const data = await response.json();
      if (data.success) {
        onSuccess();
      } else {
        setError(data.message || "\u91CD\u7F6E\u5BC6\u7801\u5931\u8D25");
      }
    } catch (error2) {
      setError("\u91CD\u7F6E\u5BC6\u7801\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
    } finally {
      setLoading(false);
    }
  };
  const handleOverlayClick = (e) => {
    if (e.target === e.currentTarget) {
      onClose();
    }
  };
  if (!isOpen || !mounted) return null;
  const modalContent = /* @__PURE__ */ React5__default.default.createElement(
    "div",
    {
      className: "fixed top-0 left-0 right-0 bottom-0 w-screen h-screen bg-black/50 backdrop-blur-sm flex items-center justify-center z-[9999] p-4",
      style: { margin: 0 },
      onClick: handleOverlayClick
    },
    /* @__PURE__ */ React5__default.default.createElement(
      "div",
      {
        className: "bg-white rounded-2xl shadow-xl w-full max-w-[420px] max-h-[90vh] overflow-y-auto relative",
        onClick: (e) => e.stopPropagation()
      },
      /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          className: "absolute top-5 right-5 bg-transparent border-none text-gray-500 cursor-pointer p-2 rounded-lg transition-all hover:bg-gray-100 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 min-w-9 min-h-9 flex items-center justify-center",
          onClick: onClose
        },
        /* @__PURE__ */ React5__default.default.createElement(lucideReact.X, { size: 20 })
      ),
      /* @__PURE__ */ React5__default.default.createElement("div", { className: "px-6 pt-6 pb-4 text-center border-b border-gray-100" }, /* @__PURE__ */ React5__default.default.createElement("h2", { className: "text-2xl font-semibold text-gray-800 mb-2" }, "\u91CD\u7F6E\u5BC6\u7801"), /* @__PURE__ */ React5__default.default.createElement("p", { className: "text-gray-500 text-sm" }, "\u8BF7\u8F93\u5165\u624B\u673A\u53F7\u548C\u9A8C\u8BC1\u7801\u91CD\u7F6E\u5BC6\u7801")),
      /* @__PURE__ */ React5__default.default.createElement("form", { onSubmit: handleSubmit, className: "p-6" }, /* @__PURE__ */ React5__default.default.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5__default.default.createElement("label", { htmlFor: "phone", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u624B\u673A\u53F7"), /* @__PURE__ */ React5__default.default.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5__default.default.createElement(lucideReact.Phone, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5__default.default.createElement(
        "input",
        {
          id: "phone",
          name: "phone",
          type: "tel",
          value: formData.phone,
          onChange: handleInputChange,
          placeholder: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7",
          className: "w-full py-3 px-4 pl-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
          disabled: loading
        }
      ))), /* @__PURE__ */ React5__default.default.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5__default.default.createElement("label", { htmlFor: "verificationCode", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u9A8C\u8BC1\u7801"), /* @__PURE__ */ React5__default.default.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5__default.default.createElement(
        "input",
        {
          id: "verificationCode",
          name: "verificationCode",
          type: "text",
          value: formData.verificationCode,
          onChange: handleInputChange,
          placeholder: "\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801",
          className: "w-full py-3 px-4 pr-28 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
          disabled: loading,
          maxLength: 6
        }
      ), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "button",
          className: "absolute right-2 top-1/2 -translate-y-1/2 bg-transparent border-none text-blue-500 text-sm font-medium cursor-pointer px-2 py-1 rounded transition-all whitespace-nowrap hover:bg-blue-50 disabled:text-gray-400 disabled:cursor-not-allowed",
          onClick: handleSendCode,
          disabled: loading || countdown > 0
        },
        countdown > 0 ? `${countdown}\u79D2\u540E\u91CD\u8BD5` : "\u53D1\u9001\u9A8C\u8BC1\u7801"
      ))), /* @__PURE__ */ React5__default.default.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5__default.default.createElement("label", { htmlFor: "newPassword", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u65B0\u5BC6\u7801"), /* @__PURE__ */ React5__default.default.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5__default.default.createElement(lucideReact.Lock, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5__default.default.createElement(
        "input",
        {
          id: "newPassword",
          name: "newPassword",
          type: showPassword ? "text" : "password",
          value: formData.newPassword,
          onChange: handleInputChange,
          placeholder: "\u8BF7\u8F93\u5165\u65B0\u5BC6\u7801",
          className: "w-full py-3 px-4 pl-12 pr-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
          disabled: loading
        }
      ), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "button",
          className: "absolute right-4 bg-transparent border-none text-gray-400 cursor-pointer p-1 rounded transition-all flex items-center justify-center min-w-6 min-h-6 hover:text-gray-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
          onClick: () => setShowPassword(!showPassword),
          disabled: loading
        },
        showPassword ? /* @__PURE__ */ React5__default.default.createElement(lucideReact.EyeOff, { size: 18 }) : /* @__PURE__ */ React5__default.default.createElement(lucideReact.Eye, { size: 18 })
      ))), /* @__PURE__ */ React5__default.default.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5__default.default.createElement("label", { htmlFor: "confirmPassword", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u786E\u8BA4\u5BC6\u7801"), /* @__PURE__ */ React5__default.default.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5__default.default.createElement(lucideReact.Lock, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5__default.default.createElement(
        "input",
        {
          id: "confirmPassword",
          name: "confirmPassword",
          type: showConfirmPassword ? "text" : "password",
          value: formData.confirmPassword,
          onChange: handleInputChange,
          placeholder: "\u8BF7\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801",
          className: "w-full py-3 px-4 pl-12 pr-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
          disabled: loading
        }
      ), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "button",
          className: "absolute right-4 bg-transparent border-none text-gray-400 cursor-pointer p-1 rounded transition-all flex items-center justify-center min-w-6 min-h-6 hover:text-gray-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
          onClick: () => setShowConfirmPassword(!showConfirmPassword),
          disabled: loading
        },
        showConfirmPassword ? /* @__PURE__ */ React5__default.default.createElement(lucideReact.EyeOff, { size: 18 }) : /* @__PURE__ */ React5__default.default.createElement(lucideReact.Eye, { size: 18 })
      ))), error && /* @__PURE__ */ React5__default.default.createElement("div", { className: "text-red-500 text-sm my-4 p-3 bg-red-50 border border-red-200 rounded-lg leading-relaxed" }, error), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "submit",
          className: "w-full bg-blue-500 text-white border-none py-3.5 px-6 rounded-lg text-base font-medium cursor-pointer transition-all mt-2 min-h-[52px] hover:bg-blue-600 hover:-translate-y-0.5 hover:shadow-lg hover:shadow-blue-500/30 active:translate-y-0 disabled:bg-gray-400 disabled:cursor-not-allowed disabled:transform-none disabled:shadow-none focus:outline-none focus:ring-2 focus:ring-blue-700 focus:ring-offset-2",
          disabled: loading
        },
        loading ? "\u63D0\u4EA4\u4E2D..." : "\u91CD\u7F6E\u5BC6\u7801"
      ))
    )
  );
  return reactDom.createPortal(modalContent, document.body);
}

// src/auth/legacy/components/LoginModal.tsx
function LoginModal({ isOpen, onClose, onSuccess, onSwitchToRegister }) {
  const { login } = useAuth();
  const [formData, setFormData] = React5.useState({
    phone: "",
    password: ""
  });
  const [showPassword, setShowPassword] = React5.useState(false);
  const [error, setError] = React5.useState("");
  const [loading, setLoading] = React5.useState(false);
  const [showForgotPassword, setShowForgotPassword] = React5.useState(false);
  const [mounted, setMounted] = React5.useState(false);
  React5.useEffect(() => {
    setMounted(true);
  }, []);
  const fillDemoAccount = (type) => {
    if (process.env.NODE_ENV === "development") {
      const accounts = {
        admin: { phone: "13800138000", password: "admin123456" },
        user: { phone: "13900139000", password: "test123456" }
      };
      setFormData(accounts[type]);
      setError("");
    }
  };
  const handleInputChange = (e) => {
    const { name, value } = e.target;
    setFormData((prev) => ({ ...prev, [name]: value }));
    if (error) setError("");
  };
  const handleSubmit = async (e) => {
    e.preventDefault();
    setError("");
    setLoading(true);
    console.log("\u{1F504} [LoginModal] handleSubmit \u5F00\u59CB");
    try {
      if (!formData.phone || !formData.password) {
        console.log("\u274C [LoginModal] \u524D\u7AEF\u9A8C\u8BC1\u5931\u8D25: \u4FE1\u606F\u4E0D\u5B8C\u6574");
        setError("\u8BF7\u586B\u5199\u5B8C\u6574\u4FE1\u606F");
        return;
      }
      if (!validatePhoneNumber(formData.phone)) {
        console.log("\u274C [LoginModal] \u524D\u7AEF\u9A8C\u8BC1\u5931\u8D25: \u624B\u673A\u53F7\u683C\u5F0F\u9519\u8BEF");
        setError("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7");
        return;
      }
      console.log("\u2705 [LoginModal] \u524D\u7AEF\u9A8C\u8BC1\u901A\u8FC7");
      console.log("\u{1F511} [LoginModal] \u63D0\u4EA4\u767B\u5F55\u8868\u5355:", {
        phone: formData.phone,
        password: "***"
      });
      console.log("\u{1F4DE} [LoginModal] \u51C6\u5907\u8C03\u7528 useAuth.login()...");
      const result = await login(formData);
      console.log("\u{1F4E1} [LoginModal] useAuth.login() \u8FD4\u56DE\u7ED3\u679C:", result);
      if (result.success) {
        console.log("\u2705 [LoginModal] \u767B\u5F55\u6210\u529F\uFF0C\u51C6\u5907\u8C03\u7528 onSuccess()");
        console.log("\u{1F464} [LoginModal] \u767B\u5F55\u6210\u529F\u7684\u7528\u6237\u4FE1\u606F:", result.user);
        setTimeout(() => {
          console.log("\u{1F3AF} [LoginModal] \u8C03\u7528 onSuccess \u56DE\u8C03");
          onSuccess();
          console.log("\u{1F3C1} [LoginModal] onSuccess \u8C03\u7528\u5B8C\u6210");
        }, 100);
      } else {
        console.log("\u274C [LoginModal] \u767B\u5F55\u5931\u8D25:", result.message);
        setError(result.message || "\u767B\u5F55\u5931\u8D25");
      }
    } catch (error2) {
      console.error("\u{1F4A5} [LoginModal] \u767B\u5F55\u5F02\u5E38:", error2);
      setError("\u767B\u5F55\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
    } finally {
      console.log("\u{1F51A} [LoginModal] handleSubmit \u7ED3\u675F\uFF0C\u8BBE\u7F6E loading = false");
      setLoading(false);
    }
  };
  const handleOverlayClick = (e) => {
    if (e.target === e.currentTarget) {
      onClose();
    }
  };
  if (!isOpen || !mounted) return null;
  const modalContent = /* @__PURE__ */ React5__default.default.createElement(React5__default.default.Fragment, null, /* @__PURE__ */ React5__default.default.createElement(
    "div",
    {
      className: "fixed top-0 left-0 right-0 bottom-0 w-screen h-screen bg-black/50 backdrop-blur-sm flex items-center justify-center z-[9999] p-4",
      style: { margin: 0 },
      onClick: handleOverlayClick
    },
    /* @__PURE__ */ React5__default.default.createElement(
      "div",
      {
        className: "bg-white rounded-2xl shadow-xl w-full max-w-[420px] max-h-[90vh] overflow-y-auto relative",
        onClick: (e) => e.stopPropagation()
      },
      /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          className: "absolute top-5 right-5 bg-transparent border-none text-gray-500 cursor-pointer p-2 rounded-lg transition-all hover:bg-gray-100 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 min-w-9 min-h-9 flex items-center justify-center",
          onClick: onClose
        },
        /* @__PURE__ */ React5__default.default.createElement(lucideReact.X, { size: 20 })
      ),
      /* @__PURE__ */ React5__default.default.createElement("div", { className: "px-6 pt-6 pb-4 text-center border-b border-gray-100" }, /* @__PURE__ */ React5__default.default.createElement("h2", { className: "text-2xl font-semibold text-gray-800 mb-2" }, "\u7528\u6237\u767B\u5F55"), /* @__PURE__ */ React5__default.default.createElement("p", { className: "text-gray-500 text-sm" }, "\u8BF7\u8F93\u5165\u60A8\u7684\u624B\u673A\u53F7\u548C\u5BC6\u7801")),
      process.env.NODE_ENV === "development" && /* @__PURE__ */ React5__default.default.createElement("div", { className: "px-6 py-4 bg-amber-50 border-b border-gray-100" }, /* @__PURE__ */ React5__default.default.createElement("p", { className: "text-xs text-amber-800 font-medium mb-2" }, "\u5F00\u53D1\u73AF\u5883\u5FEB\u6377\u767B\u5F55\uFF1A"), /* @__PURE__ */ React5__default.default.createElement("div", { className: "flex gap-2" }, /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "button",
          onClick: () => fillDemoAccount("admin"),
          className: "px-3 py-1.5 text-xs bg-amber-400 text-amber-900 border-none rounded-md cursor-pointer transition-all font-medium hover:bg-amber-500"
        },
        "\u7BA1\u7406\u5458\u8D26\u53F7"
      ), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "button",
          onClick: () => fillDemoAccount("user"),
          className: "px-3 py-1.5 text-xs bg-amber-400 text-amber-900 border-none rounded-md cursor-pointer transition-all font-medium hover:bg-amber-500"
        },
        "\u7528\u6237\u8D26\u53F7"
      ))),
      /* @__PURE__ */ React5__default.default.createElement("form", { onSubmit: handleSubmit, className: "p-6" }, /* @__PURE__ */ React5__default.default.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5__default.default.createElement("label", { htmlFor: "phone", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u624B\u673A\u53F7"), /* @__PURE__ */ React5__default.default.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5__default.default.createElement(lucideReact.User, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5__default.default.createElement(
        "input",
        {
          id: "phone",
          name: "phone",
          type: "tel",
          autoComplete: "tel",
          value: formData.phone,
          onChange: handleInputChange,
          placeholder: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7",
          className: "w-full py-3 px-4 pl-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
          disabled: loading
        }
      ))), /* @__PURE__ */ React5__default.default.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5__default.default.createElement("label", { htmlFor: "password", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u5BC6\u7801"), /* @__PURE__ */ React5__default.default.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5__default.default.createElement(lucideReact.Lock, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5__default.default.createElement(
        "input",
        {
          id: "password",
          name: "password",
          type: showPassword ? "text" : "password",
          autoComplete: "current-password",
          value: formData.password,
          onChange: handleInputChange,
          placeholder: "\u8BF7\u8F93\u5165\u5BC6\u7801",
          className: "w-full py-3 px-4 pl-12 pr-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
          disabled: loading
        }
      ), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "button",
          className: "absolute right-4 bg-transparent border-none text-gray-400 cursor-pointer p-1 rounded transition-all flex items-center justify-center min-w-6 min-h-6 hover:text-gray-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
          onClick: () => setShowPassword(!showPassword),
          disabled: loading
        },
        showPassword ? /* @__PURE__ */ React5__default.default.createElement(lucideReact.EyeOff, { size: 18 }) : /* @__PURE__ */ React5__default.default.createElement(lucideReact.Eye, { size: 18 })
      ))), /* @__PURE__ */ React5__default.default.createElement("div", { className: "text-right -mt-2 mb-4" }, /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "button",
          onClick: () => setShowForgotPassword(true),
          className: "bg-transparent border-none text-blue-500 cursor-pointer text-sm font-medium underline px-1 py-0.5 rounded transition-all hover:text-blue-600 hover:bg-blue-50 hover:no-underline focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
        },
        "\u5FD8\u8BB0\u5BC6\u7801\uFF1F"
      )), error && /* @__PURE__ */ React5__default.default.createElement("div", { className: "text-red-500 text-sm my-4 p-3 bg-red-50 border border-red-200 rounded-lg leading-relaxed" }, error), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "submit",
          className: "w-full bg-blue-500 text-white border-none py-3.5 px-6 rounded-lg text-base font-medium cursor-pointer transition-all mt-2 min-h-[52px] hover:bg-blue-600 hover:-translate-y-0.5 hover:shadow-lg hover:shadow-blue-500/30 active:translate-y-0 disabled:bg-gray-400 disabled:cursor-not-allowed disabled:transform-none disabled:shadow-none focus:outline-none focus:ring-2 focus:ring-blue-700 focus:ring-offset-2",
          disabled: loading
        },
        loading ? "\u767B\u5F55\u4E2D..." : "\u767B\u5F55"
      ), onSwitchToRegister && /* @__PURE__ */ React5__default.default.createElement("div", { className: "text-center mt-5 pt-4 border-t border-gray-100" }, /* @__PURE__ */ React5__default.default.createElement("span", { className: "text-gray-500 text-sm mr-1" }, "\u8FD8\u6CA1\u6709\u8D26\u53F7\uFF1F"), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "button",
          onClick: onSwitchToRegister,
          className: "bg-transparent border-none text-blue-500 cursor-pointer text-sm font-medium underline px-1 py-0.5 rounded transition-all hover:text-blue-600 hover:bg-blue-50 hover:no-underline focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
        },
        "\u7ACB\u5373\u6CE8\u518C"
      )))
    )
  ), /* @__PURE__ */ React5__default.default.createElement(
    ForgotPasswordModal,
    {
      isOpen: showForgotPassword,
      onClose: () => setShowForgotPassword(false),
      onSuccess: () => {
        setShowForgotPassword(false);
        onSuccess();
      }
    }
  ));
  return reactDom.createPortal(modalContent, document.body);
}

// src/auth/legacy/components/AuthGuard.tsx
function AuthGuard({
  children,
  fallback,
  requireAuth = true
}) {
  const { isAuthenticated, loading, refreshUser } = useAuth();
  const [showLoginModal, setShowLoginModal] = React5.useState(false);
  React5.useEffect(() => {
    if (!loading && requireAuth && !isAuthenticated) {
      setShowLoginModal(true);
    }
  }, [loading, requireAuth, isAuthenticated]);
  const handleLoginSuccess = () => {
    refreshUser();
    setShowLoginModal(false);
  };
  if (loading) {
    return /* @__PURE__ */ React5__default.default.createElement("div", { style: {
      display: "flex",
      alignItems: "center",
      justifyContent: "center",
      minHeight: "200px",
      color: "#6b7280",
      flexDirection: "column",
      gap: "12px"
    } }, /* @__PURE__ */ React5__default.default.createElement("div", { style: {
      width: "32px",
      height: "32px",
      border: "3px solid #e5e7eb",
      borderTop: "3px solid #3b82f6",
      borderRadius: "50%",
      animation: "spin 1s linear infinite"
    } }), /* @__PURE__ */ React5__default.default.createElement("div", null, "\u9A8C\u8BC1\u767B\u5F55\u72B6\u6001..."));
  }
  if (requireAuth && !isAuthenticated) {
    return /* @__PURE__ */ React5__default.default.createElement(React5__default.default.Fragment, null, fallback || /* @__PURE__ */ React5__default.default.createElement("div", { style: {
      display: "flex",
      alignItems: "center",
      justifyContent: "center",
      minHeight: "200px",
      color: "#6b7280",
      flexDirection: "column",
      gap: "16px",
      padding: "24px",
      textAlign: "center"
    } }, /* @__PURE__ */ React5__default.default.createElement("div", { style: {
      fontSize: "48px",
      opacity: 0.5
    } }, "\u{1F512}"), /* @__PURE__ */ React5__default.default.createElement("div", { style: {
      fontSize: "18px",
      fontWeight: "500"
    } }, "\u8BF7\u5148\u767B\u5F55\u4EE5\u8BBF\u95EE\u6B64\u9875\u9762"), /* @__PURE__ */ React5__default.default.createElement("div", { style: {
      fontSize: "14px",
      opacity: 0.7
    } }, "\u767B\u5F55\u540E\u5373\u53EF\u67E5\u770B\u76F8\u5173\u5185\u5BB9")), /* @__PURE__ */ React5__default.default.createElement(
      LoginModal,
      {
        isOpen: showLoginModal,
        onClose: () => setShowLoginModal(false),
        onSuccess: handleLoginSuccess
      }
    ));
  }
  return /* @__PURE__ */ React5__default.default.createElement(React5__default.default.Fragment, null, children);
}
function RegisterModal({ isOpen, onClose, onSuccess, onSwitchToLogin }) {
  const { register } = useAuth();
  const [formData, setFormData] = React5.useState({
    phone: "",
    password: "",
    confirmPassword: "",
    name: ""
  });
  const [showPassword, setShowPassword] = React5.useState(false);
  const [showConfirmPassword, setShowConfirmPassword] = React5.useState(false);
  const [error, setError] = React5.useState("");
  const [loading, setLoading] = React5.useState(false);
  const [mounted, setMounted] = React5.useState(false);
  React5.useEffect(() => {
    setMounted(true);
  }, []);
  const handleInputChange = (e) => {
    const { name, value } = e.target;
    setFormData((prev) => ({ ...prev, [name]: value }));
    if (error) setError("");
  };
  const validateForm = () => {
    if (!formData.phone || !formData.password || !formData.confirmPassword) {
      setError("\u8BF7\u586B\u5199\u5FC5\u8981\u4FE1\u606F");
      return false;
    }
    if (!validatePhoneNumber(formData.phone)) {
      setError("\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u624B\u673A\u53F7\u683C\u5F0F");
      return false;
    }
    const passwordValidation = validatePassword(formData.password);
    if (!passwordValidation.valid) {
      setError(passwordValidation.message || "\u5BC6\u7801\u683C\u5F0F\u9519\u8BEF");
      return false;
    }
    if (formData.password !== formData.confirmPassword) {
      setError("\u4E24\u6B21\u8F93\u5165\u7684\u5BC6\u7801\u4E0D\u4E00\u81F4");
      return false;
    }
    return true;
  };
  const handleSubmit = async (e) => {
    e.preventDefault();
    setError("");
    setLoading(true);
    try {
      if (!validateForm()) {
        return;
      }
      console.log("\u{1F4DD} [RegisterModal] \u63D0\u4EA4\u6CE8\u518C\u8868\u5355:", {
        phone: formData.phone,
        name: formData.name || "\u672A\u8BBE\u7F6E",
        password: "***"
      });
      const result = await register({
        phone: formData.phone,
        password: formData.password,
        name: formData.name || void 0
      });
      if (result.success) {
        console.log("\u2705 [RegisterModal] \u6CE8\u518C\u6210\u529F");
        onSuccess();
      } else {
        console.log("\u274C [RegisterModal] \u6CE8\u518C\u5931\u8D25:", result.message);
        setError(result.message || "\u6CE8\u518C\u5931\u8D25");
      }
    } catch (error2) {
      console.error("\u{1F4A5} [RegisterModal] \u6CE8\u518C\u5F02\u5E38:", error2);
      setError("\u6CE8\u518C\u5931\u8D25\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");
    } finally {
      setLoading(false);
    }
  };
  const handleOverlayClick = (e) => {
    if (e.target === e.currentTarget) {
      onClose();
    }
  };
  if (!isOpen || !mounted) return null;
  const modalContent = /* @__PURE__ */ React5__default.default.createElement(
    "div",
    {
      className: "fixed top-0 left-0 right-0 bottom-0 w-screen h-screen bg-black/50 backdrop-blur-sm flex items-center justify-center z-[9999] p-4",
      style: { margin: 0 },
      onClick: handleOverlayClick
    },
    /* @__PURE__ */ React5__default.default.createElement(
      "div",
      {
        className: "bg-white rounded-2xl shadow-xl w-full max-w-[420px] max-h-[90vh] overflow-y-auto relative",
        onClick: (e) => e.stopPropagation()
      },
      /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          className: "absolute top-5 right-5 bg-transparent border-none text-gray-500 cursor-pointer p-2 rounded-lg transition-all hover:bg-gray-100 hover:text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 min-w-9 min-h-9 flex items-center justify-center",
          onClick: onClose
        },
        /* @__PURE__ */ React5__default.default.createElement(lucideReact.X, { size: 20 })
      ),
      /* @__PURE__ */ React5__default.default.createElement("div", { className: "px-6 pt-6 pb-4 text-center border-b border-gray-100" }, /* @__PURE__ */ React5__default.default.createElement("h2", { className: "text-2xl font-semibold text-gray-800 mb-2" }, "\u7528\u6237\u6CE8\u518C"), /* @__PURE__ */ React5__default.default.createElement("p", { className: "text-gray-500 text-sm" }, "\u8BF7\u586B\u5199\u4EE5\u4E0B\u4FE1\u606F\u521B\u5EFA\u8D26\u6237")),
      /* @__PURE__ */ React5__default.default.createElement("form", { onSubmit: handleSubmit, className: "p-6" }, /* @__PURE__ */ React5__default.default.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5__default.default.createElement("label", { htmlFor: "phone", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u624B\u673A\u53F7 *"), /* @__PURE__ */ React5__default.default.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5__default.default.createElement(lucideReact.Phone, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5__default.default.createElement(
        "input",
        {
          id: "phone",
          name: "phone",
          type: "tel",
          autoComplete: "tel",
          value: formData.phone,
          onChange: handleInputChange,
          placeholder: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7",
          className: "w-full py-3 px-4 pl-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
          disabled: loading
        }
      ))), /* @__PURE__ */ React5__default.default.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5__default.default.createElement("label", { htmlFor: "name", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u59D3\u540D"), /* @__PURE__ */ React5__default.default.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5__default.default.createElement(lucideReact.User, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5__default.default.createElement(
        "input",
        {
          id: "name",
          name: "name",
          type: "text",
          autoComplete: "name",
          value: formData.name,
          onChange: handleInputChange,
          placeholder: "\u8BF7\u8F93\u5165\u59D3\u540D\uFF08\u53EF\u9009\uFF09",
          className: "w-full py-3 px-4 pl-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
          disabled: loading
        }
      ))), /* @__PURE__ */ React5__default.default.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5__default.default.createElement("label", { htmlFor: "password", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u5BC6\u7801 *"), /* @__PURE__ */ React5__default.default.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5__default.default.createElement(lucideReact.Lock, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5__default.default.createElement(
        "input",
        {
          id: "password",
          name: "password",
          type: showPassword ? "text" : "password",
          autoComplete: "new-password",
          value: formData.password,
          onChange: handleInputChange,
          placeholder: "\u8BF7\u8F93\u5165\u5BC6\u7801\uFF08\u81F3\u5C116\u4F4D\uFF09",
          className: "w-full py-3 px-4 pl-12 pr-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
          disabled: loading
        }
      ), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "button",
          className: "absolute right-4 bg-transparent border-none text-gray-400 cursor-pointer p-1 rounded transition-all flex items-center justify-center min-w-6 min-h-6 hover:text-gray-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
          onClick: () => setShowPassword(!showPassword),
          disabled: loading
        },
        showPassword ? /* @__PURE__ */ React5__default.default.createElement(lucideReact.EyeOff, { size: 18 }) : /* @__PURE__ */ React5__default.default.createElement(lucideReact.Eye, { size: 18 })
      ))), /* @__PURE__ */ React5__default.default.createElement("div", { className: "mb-5" }, /* @__PURE__ */ React5__default.default.createElement("label", { htmlFor: "confirmPassword", className: "block mb-1.5 text-sm font-medium text-gray-700" }, "\u786E\u8BA4\u5BC6\u7801 *"), /* @__PURE__ */ React5__default.default.createElement("div", { className: "relative flex items-center" }, /* @__PURE__ */ React5__default.default.createElement(lucideReact.Lock, { size: 18, className: "absolute left-4 text-gray-400 z-[1] pointer-events-none" }), /* @__PURE__ */ React5__default.default.createElement(
        "input",
        {
          id: "confirmPassword",
          name: "confirmPassword",
          type: showConfirmPassword ? "text" : "password",
          autoComplete: "new-password",
          value: formData.confirmPassword,
          onChange: handleInputChange,
          placeholder: "\u8BF7\u518D\u6B21\u8F93\u5165\u5BC6\u7801",
          className: "w-full py-3 px-4 pl-12 pr-12 border-2 border-gray-200 rounded-lg text-base transition-all box-border min-h-12 bg-white focus:outline-none focus:border-blue-500 focus:ring-2 focus:ring-blue-500/10 placeholder:text-gray-400 disabled:bg-gray-50 disabled:text-gray-500 disabled:cursor-not-allowed",
          disabled: loading
        }
      ), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "button",
          className: "absolute right-4 bg-transparent border-none text-gray-400 cursor-pointer p-1 rounded transition-all flex items-center justify-center min-w-6 min-h-6 hover:text-gray-600 hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
          onClick: () => setShowConfirmPassword(!showConfirmPassword),
          disabled: loading
        },
        showConfirmPassword ? /* @__PURE__ */ React5__default.default.createElement(lucideReact.EyeOff, { size: 18 }) : /* @__PURE__ */ React5__default.default.createElement(lucideReact.Eye, { size: 18 })
      ))), error && /* @__PURE__ */ React5__default.default.createElement("div", { className: "text-red-500 text-sm my-4 p-3 bg-red-50 border border-red-200 rounded-lg leading-relaxed" }, error), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "submit",
          className: "w-full bg-blue-500 text-white border-none py-3.5 px-6 rounded-lg text-base font-medium cursor-pointer transition-all mt-2 min-h-[52px] hover:bg-blue-600 hover:-translate-y-0.5 hover:shadow-lg hover:shadow-blue-500/30 active:translate-y-0 disabled:bg-gray-400 disabled:cursor-not-allowed disabled:transform-none disabled:shadow-none focus:outline-none focus:ring-2 focus:ring-blue-700 focus:ring-offset-2",
          disabled: loading
        },
        loading ? "\u6CE8\u518C\u4E2D..." : "\u6CE8\u518C"
      ), onSwitchToLogin && /* @__PURE__ */ React5__default.default.createElement("div", { className: "text-center mt-5 pt-4 border-t border-gray-100" }, /* @__PURE__ */ React5__default.default.createElement("span", { className: "text-gray-500 text-sm mr-1" }, "\u5DF2\u6709\u8D26\u53F7\uFF1F"), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          type: "button",
          onClick: onSwitchToLogin,
          className: "bg-transparent border-none text-blue-500 cursor-pointer text-sm font-medium underline px-1 py-0.5 rounded transition-all hover:text-blue-600 hover:bg-blue-50 hover:no-underline focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
        },
        "\u7ACB\u5373\u767B\u5F55"
      )))
    )
  );
  return reactDom.createPortal(modalContent, document.body);
}

// src/auth/legacy/components/UserMenu.tsx
function UserMenu({ customMenuItems = [], className }) {
  const { user, isAuthenticated, logout } = useAuth();
  const [isOpen, setIsOpen] = React5.useState(false);
  const [showLoginModal, setShowLoginModal] = React5.useState(false);
  const [showRegisterModal, setShowRegisterModal] = React5.useState(false);
  const toggleMenu = () => {
    setIsOpen(!isOpen);
  };
  const handleMenuClick = (e) => {
    e.stopPropagation();
  };
  const handleCustomMenuClick = (item) => {
    console.log(`\u{1F527} [UserMenu] \u81EA\u5B9A\u4E49\u83DC\u5355\u9879\u88AB\u70B9\u51FB: ${item.label}`);
    item.onClick();
    setIsOpen(false);
  };
  const handleLogin = () => {
    console.log("\u{1F511} [UserMenu] \u767B\u5F55\u6309\u94AE\u88AB\u70B9\u51FB");
    setShowLoginModal(true);
    setIsOpen(false);
  };
  const handleRegister = () => {
    console.log("\u{1F4DD} [UserMenu] \u6CE8\u518C\u6309\u94AE\u88AB\u70B9\u51FB");
    setShowRegisterModal(true);
    setIsOpen(false);
  };
  const handleLogout = async () => {
    console.log("\u{1F6AA} [UserMenu] \u9000\u51FA\u767B\u5F55\u6309\u94AE\u88AB\u70B9\u51FB");
    try {
      await logout();
      console.log("\u2705 [UserMenu] \u9000\u51FA\u767B\u5F55\u6210\u529F");
    } catch (error) {
      console.error("\u9000\u51FA\u767B\u5F55\u5931\u8D25:", error);
    }
    setIsOpen(false);
  };
  const handleAuthSuccess = () => {
    console.log("\u{1F389} [UserMenu] \u8BA4\u8BC1\u6210\u529F\u56DE\u8C03\u88AB\u8C03\u7528");
    console.log("\u{1F464} [UserMenu] \u5F53\u524DuseAuth\u72B6\u6001:", {
      user: user ? `${user.name || "\u672A\u8BBE\u7F6E"} (${user.phone})` : null,
      isAuthenticated
    });
    setShowLoginModal(false);
    setShowRegisterModal(false);
    console.log("\u2705 [UserMenu] \u8BA4\u8BC1\u6210\u529F\u5904\u7406\u5B8C\u6210 - \u6A21\u6001\u6846\u5DF2\u5173\u95ED");
    setTimeout(() => {
      console.log("\u{1F50D} [UserMenu] \u5EF6\u8FDF\u72B6\u6001\u68C0\u67E5:", {
        user: user ? `${user.name || "\u672A\u8BBE\u7F6E"} (${user.phone})` : null,
        isAuthenticated
      });
    }, 500);
  };
  const handleSwitchToRegister = () => {
    console.log("\u{1F504} [UserMenu] \u4ECE\u767B\u5F55\u5207\u6362\u5230\u6CE8\u518C");
    setShowLoginModal(false);
    setShowRegisterModal(true);
  };
  const handleSwitchToLogin = () => {
    console.log("\u{1F504} [UserMenu] \u4ECE\u6CE8\u518C\u5207\u6362\u5230\u767B\u5F55");
    setShowRegisterModal(false);
    setShowLoginModal(true);
  };
  const getVisibleCustomMenuItems = () => {
    return customMenuItems.filter((item) => {
      if (item.requireAuth === true) {
        return isAuthenticated;
      }
      if (item.requireAuth === false) {
        return !isAuthenticated;
      }
      return true;
    });
  };
  React5__default.default.useEffect(() => {
    const handleGlobalClick = () => {
      setIsOpen(false);
    };
    if (isOpen) {
      document.addEventListener("click", handleGlobalClick);
    }
    return () => {
      document.removeEventListener("click", handleGlobalClick);
    };
  }, [isOpen]);
  const visibleCustomMenuItems = getVisibleCustomMenuItems();
  return /* @__PURE__ */ React5__default.default.createElement("div", { className: `relative inline-block ${className || ""}` }, /* @__PURE__ */ React5__default.default.createElement(
    "button",
    {
      className: "flex items-center gap-2 px-3 py-2 bg-slate-50 text-slate-500 border border-slate-200 rounded-lg cursor-pointer transition-all min-w-11 min-h-11 text-sm font-medium hover:bg-slate-200 hover:text-slate-800 focus:outline-none focus:ring-2 focus:ring-blue-500/10",
      onClick: toggleMenu
    },
    /* @__PURE__ */ React5__default.default.createElement(lucideReact.User, { size: 24 }),
    isAuthenticated && user && /* @__PURE__ */ React5__default.default.createElement("span", { className: "max-w-[120px] overflow-hidden text-ellipsis whitespace-nowrap" }, user.name || user.phone)
  ), isOpen && /* @__PURE__ */ React5__default.default.createElement(
    "div",
    {
      className: "absolute top-[calc(100%+0.5rem)] right-0 z-[1000] min-w-[200px] bg-white border border-slate-200 rounded-xl shadow-lg max-h-[90vh] overflow-y-auto p-2 animate-in slide-in-from-top-2 fade-in duration-200",
      onClick: handleMenuClick
    },
    isAuthenticated && user ? (
      // 已登录状态的菜单
      /* @__PURE__ */ React5__default.default.createElement(React5__default.default.Fragment, null, /* @__PURE__ */ React5__default.default.createElement("div", { className: "p-3 mb-2 bg-slate-50 rounded-lg" }, /* @__PURE__ */ React5__default.default.createElement("div", { className: "text-sm font-semibold text-slate-800 mb-1 overflow-hidden text-ellipsis whitespace-nowrap" }, user.name || "\u672A\u8BBE\u7F6E\u540D\u79F0"), /* @__PURE__ */ React5__default.default.createElement("div", { className: "text-xs text-slate-500 mb-1 overflow-hidden text-ellipsis whitespace-nowrap" }, user.phone), /* @__PURE__ */ React5__default.default.createElement("div", { className: "text-xs text-blue-500 font-medium" }, user.role === "admin" ? "\u7BA1\u7406\u5458" : "\u666E\u901A\u7528\u6237")), visibleCustomMenuItems.length > 0 && /* @__PURE__ */ React5__default.default.createElement(React5__default.default.Fragment, null, /* @__PURE__ */ React5__default.default.createElement("div", { className: "h-px bg-slate-200 my-2" }), visibleCustomMenuItems.map((item) => {
        const IconComponent = item.icon;
        return /* @__PURE__ */ React5__default.default.createElement(
          "button",
          {
            key: item.id,
            className: "flex items-center gap-3 w-full p-3 bg-transparent border-none rounded-lg text-gray-700 text-sm font-medium cursor-pointer transition-all text-left min-h-11 hover:bg-slate-100 hover:text-slate-800 focus:outline-none focus:bg-slate-100 focus:ring-2 focus:ring-blue-500/10",
            onClick: () => handleCustomMenuClick(item)
          },
          IconComponent && /* @__PURE__ */ React5__default.default.createElement(IconComponent, { size: 16 }),
          /* @__PURE__ */ React5__default.default.createElement("span", null, item.label)
        );
      })), /* @__PURE__ */ React5__default.default.createElement("div", { className: "h-px bg-slate-200 my-2" }), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          className: "flex items-center gap-3 w-full p-3 bg-transparent border-none rounded-lg text-gray-700 text-sm font-medium cursor-pointer transition-all text-left min-h-11 hover:bg-red-50 hover:text-red-600 focus:outline-none focus:bg-red-50 focus:text-red-600 focus:ring-2 focus:ring-red-500/10",
          onClick: handleLogout
        },
        /* @__PURE__ */ React5__default.default.createElement(lucideReact.LogOut, { size: 16 }),
        /* @__PURE__ */ React5__default.default.createElement("span", null, "\u9000\u51FA\u767B\u5F55")
      ))
    ) : (
      // 未登录状态的菜单
      /* @__PURE__ */ React5__default.default.createElement(React5__default.default.Fragment, null, /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          className: "flex items-center gap-3 w-full p-3 bg-transparent border-none rounded-lg text-gray-700 text-sm font-medium cursor-pointer transition-all text-left min-h-11 hover:bg-slate-100 hover:text-slate-800 focus:outline-none focus:bg-slate-100 focus:ring-2 focus:ring-blue-500/10",
          onClick: handleLogin
        },
        /* @__PURE__ */ React5__default.default.createElement(lucideReact.LogIn, { size: 16 }),
        /* @__PURE__ */ React5__default.default.createElement("span", null, "\u767B\u5F55")
      ), /* @__PURE__ */ React5__default.default.createElement(
        "button",
        {
          className: "flex items-center gap-3 w-full p-3 bg-transparent border-none rounded-lg text-gray-700 text-sm font-medium cursor-pointer transition-all text-left min-h-11 hover:bg-slate-100 hover:text-slate-800 focus:outline-none focus:bg-slate-100 focus:ring-2 focus:ring-blue-500/10",
          onClick: handleRegister
        },
        /* @__PURE__ */ React5__default.default.createElement(lucideReact.User, { size: 16 }),
        /* @__PURE__ */ React5__default.default.createElement("span", null, "\u6CE8\u518C")
      ), visibleCustomMenuItems.length > 0 && /* @__PURE__ */ React5__default.default.createElement(React5__default.default.Fragment, null, /* @__PURE__ */ React5__default.default.createElement("div", { className: "h-px bg-slate-200 my-2" }), visibleCustomMenuItems.map((item) => {
        const IconComponent = item.icon;
        return /* @__PURE__ */ React5__default.default.createElement(
          "button",
          {
            key: item.id,
            className: "flex items-center gap-3 w-full p-3 bg-transparent border-none rounded-lg text-gray-700 text-sm font-medium cursor-pointer transition-all text-left min-h-11 hover:bg-slate-100 hover:text-slate-800 focus:outline-none focus:bg-slate-100 focus:ring-2 focus:ring-blue-500/10",
            onClick: () => handleCustomMenuClick(item)
          },
          IconComponent && /* @__PURE__ */ React5__default.default.createElement(IconComponent, { size: 16 }),
          /* @__PURE__ */ React5__default.default.createElement("span", null, item.label)
        );
      })))
    )
  ), /* @__PURE__ */ React5__default.default.createElement(
    LoginModal,
    {
      isOpen: showLoginModal,
      onClose: () => setShowLoginModal(false),
      onSuccess: handleAuthSuccess,
      onSwitchToRegister: handleSwitchToRegister
    }
  ), /* @__PURE__ */ React5__default.default.createElement(
    RegisterModal,
    {
      isOpen: showRegisterModal,
      onClose: () => setShowRegisterModal(false),
      onSuccess: handleAuthSuccess,
      onSwitchToLogin: handleSwitchToLogin
    }
  ));
}

exports.AuthGuard = AuthGuard;
exports.ForgotPasswordModal = ForgotPasswordModal;
exports.LoginModal = LoginModal;
exports.RegisterModal = RegisterModal;
exports.UserMenu = UserMenu;
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map