/**
 * 本地持久化用户模型。
 *
 * 后端 UserSchema 保持完整，用于接口解析；本 schema 只描述本地缓存真正
 * 会用到的字段，避免把完整 profile 长期写入 localStorage。
 */
import { z } from "zod";

import { numberOrZero, stringOrEmpty } from "../nullable-defaults";

export const PersistedUserSchema = z
  .object({
    id: stringOrEmpty,
    username: stringOrEmpty,
    countryCode: stringOrEmpty,
    dailyFreeChatLimit: numberOrZero,
    dailyFreeChatRemaining: numberOrZero,
    dailyFreePrivateLimit: numberOrZero,
    dailyFreePrivateRemaining: numberOrZero,
  })
  .readonly();

export type PersistedUserInput = z.input<typeof PersistedUserSchema>;
export type PersistedUserData = z.output<typeof PersistedUserSchema>;
