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.textarea";
export const compatibilityDate = "2026-04-22";
export const metadata = {
  name: "\u591A\u884C\u6587\u672C\u8F93\u5165",
  icon: "fluent:text-description-20-regular",
  w: { initial: 8, min: 4, max: Infinity },
  h: { initial: 3, min: 2, max: Infinity, grow: true }
};
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"
    })),
    placeholder: Schema.optional(Locale.annotations({
      title: "\u5360\u4F4D\u7B26",
      description: "\u8F93\u5165\u4E3A\u7A7A\u65F6\u7684\u5360\u4F4D\u6587\u672C"
    })),
    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 `user.bio`\uFF1B\u7559\u7A7A\u5219\u4E3A\u975E\u53D7\u63A7\u5B57\u6BB5\uFF0C\u4E0D\u5199\u5165\u8868\u5355\u72B6\u6001"
    })),
    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"
    })),
    maxLength: Schema.optional(Schema.Number.pipe(Schema.int(), Schema.positive()).annotations({
      title: "\u5B57\u6570\u9650\u5236",
      description: "\u5141\u8BB8\u8F93\u5165\u7684\u6700\u5927\u5B57\u7B26\u6570\uFF1B\u8FBE\u5230\u4E0A\u9650\u540E\u65E0\u6CD5\u7EE7\u7EED\u8F93\u5165\uFF0C\u5E76\u5728\u53F3\u4E0B\u89D2\u5C55\u793A\u5B57\u6570\u8BA1\u6570"
    })),
    derived: derivedField(configure, "string")
  }).annotations({
    title: "TextareaField",
    description: "\u591A\u884C\u6587\u672C\u8F93\u5165"
  });
}
