import { Schema } from "effect";
import { Expression } from "../../../../../share/expression.js";
import { Locale } from "../../../../../share/locale.js";
import { commonFieldFields, derivedField, FieldOrientationSchema } from "../../../utils/common.js";
export const type = "com.shwfed.form.field.time";
export const compatibilityDate = "2026-04-27";
export const metadata = {
  name: "\u65F6\u95F4",
  icon: "fluent:clock-20-regular",
  w: { initial: 8, min: 4, max: Infinity },
  h: { initial: 2, min: 2, max: 2 }
};
export const TIME_GRANULARITIES = ["hour", "minute", "second"];
export const TIME_GRANULARITY_OPTIONS = [
  { value: "hour", label: "\u5C0F\u65F6" },
  { value: "minute", label: "\u5206\u949F" },
  { value: "second", label: "\u79D2" }
];
export const HOUR_CYCLE_OPTIONS = [
  { value: 24, label: "24 \u5C0F\u65F6\u5236" },
  { value: 12, label: "12 \u5C0F\u65F6\u5236" }
];
export function schema(configure) {
  const CelBool = Expression({ configure, resultType: "bool" });
  return Schema.Struct({
    type: Schema.Literal(type),
    compatibilityDate: Schema.Literal(compatibilityDate),
    ...commonFieldFields(configure),
    label: Schema.optional(Locale.annotations({
      title: "\u6807\u7B7E",
      description: "\u5B57\u6BB5\u524D\u5C55\u793A\u7684\u6587\u672C\uFF1B\u7559\u7A7A\u5219\u4E0D\u6E32\u67D3\u6807\u7B7E"
    })),
    tooltip: Schema.optional(Locale.annotations({
      title: "\u63D0\u793A",
      description: "\u9F20\u6807\u60AC\u505C\u5728\u6807\u7B7E\u4E0A\u65F6\u5C55\u793A\u7684\u8BF4\u660E"
    })),
    orientation: Schema.optional(FieldOrientationSchema),
    binding: Schema.optional(Schema.String.pipe(Schema.minLength(1)).annotations({
      title: "\u7ED1\u5B9A\u8DEF\u5F84",
      description: "\u5199\u5165\u8868\u5355\u72B6\u6001\u7684 `dot-prop` \u8DEF\u5F84\uFF0C\u4F8B\u5982 `meeting.startTime`\uFF1B\u7559\u7A7A\u5219\u4E3A\u975E\u53D7\u63A7\u5B57\u6BB5"
    })),
    disabled: Schema.optional(CelBool.annotations({
      title: "\u7981\u7528\u6761\u4EF6",
      description: "\u8FD4\u56DE `true` \u65F6\u8F93\u5165\u6846\u4ECD\u7136\u6E32\u67D3\u4F46\u4E0D\u53EF\u7F16\u8F91"
    })),
    readonly: Schema.optional(CelBool.annotations({
      title: "\u53EA\u8BFB\u6761\u4EF6",
      description: "\u8FD4\u56DE `true` \u65F6\u4EC5\u4EE5\u7EAF\u6587\u672C\u5C55\u793A\u5F53\u524D\u503C"
    })),
    derived: derivedField(configure, "string"),
    valueFormat: Schema.optional(Schema.String.pipe(Schema.minLength(1)).annotations({
      title: "\u5B58\u50A8\u683C\u5F0F",
      description: "\u5199\u5165\u8868\u5355\u72B6\u6001\u7684 `date-fns` \u683C\u5F0F\u4E32\uFF1B\u7559\u7A7A\u65F6\u4F7F\u7528\u9ED8\u8BA4 `HH:mm:ss`"
    })),
    timeGranularity: Schema.optional(Schema.Literal(...TIME_GRANULARITIES).annotations({
      title: "\u65F6\u95F4\u7C92\u5EA6",
      description: "\u53EF\u7F16\u8F91\u5230\u7684\u6700\u5C0F\u65F6\u95F4\u5355\u4F4D\uFF1B\u9ED8\u8BA4 `second`"
    })),
    hourCycle: Schema.optional(Schema.Literal(12, 24).annotations({
      title: "\u5C0F\u65F6\u5236",
      description: "12 \u5C0F\u65F6\u5236\u6216 24 \u5C0F\u65F6\u5236\uFF1B\u9ED8\u8BA4 `24`"
    }))
  }).annotations({
    title: "TimeField",
    description: "\u65F6\u95F4\u9009\u62E9\u8F93\u5165"
  });
}
