import { Schema } from "effect";
import { Locale } from "../../../../../share/locale.js";
import { FormUnit } from "../../../schema.js";
export const type = "com.shwfed.form.field.collapsible";
export const compatibilityDate = "2026-05-20";
export const metadata = {
  name: "\u53EF\u6298\u53E0\u533A\u57DF",
  icon: "fluent:chevron-down-20-regular",
  w: { initial: 12, min: 4, max: Infinity },
  h: { initial: 4, min: 2, max: Infinity, grow: true },
  // Hosts a nested sub-form (its own fields + layout) — too complex for the
  // fullscreen inline-config pane; keep the (fullscreen-exiting) drill-down.
  inlineConfig: false
};
export function schema(configure) {
  const Unit = Schema.suspend(() => FormUnit(configure));
  return Schema.Struct({
    type: Schema.Literal(type),
    compatibilityDate: Schema.Literal(compatibilityDate),
    id: Schema.UUID.annotations({ description: "\u5B57\u6BB5\u552F\u4E00\u6807\u8BC6\uFF1B\u5E03\u5C40\u901A\u8FC7\u8BE5 id \u5F15\u7528\u5B57\u6BB5" }),
    displayName: Schema.optional(Schema.String.annotations({
      title: "\u5185\u90E8\u540D\u79F0",
      description: "\u4EC5\u5728\u7F16\u8F91\u5668\u5185\u53EF\u89C1\u7684\u533A\u57DF\u540D\uFF0C\u7528\u4E8E\u5728\u4FA7\u8FB9\u680F\u548C\u5E03\u5C40\u7F16\u8F91\u5668\u4E2D\u8BC6\u522B\u8BE5\u6298\u53E0\u533A\u57DF\uFF1B\u8FD0\u884C\u65F6\u4E0D\u5C55\u793A"
    })),
    header: Locale.annotations({
      title: "\u6807\u9898",
      description: "\u6298\u53E0\u533A\u57DF\u7684\u6807\u9898\uFF0C\u6E32\u67D3\u4E3A\u884C\u5185 Markdown\u3002\u652F\u6301 `{{ \u8868\u8FBE\u5F0F }}` \u63D2\u503C\uFF0C\u8868\u8FBE\u5F0F\u4E3A CEL\uFF0C\u53EF\u8BBF\u95EE `form`\uFF08\u5F53\u524D\u8868\u5355\u72B6\u6001\uFF09\u4EE5\u53CA\u5F53\u524D\u4F5C\u7528\u57DF\u5185\u7684\u5176\u4ED6\u53D8\u91CF"
    }),
    defaultCollapsed: Schema.optional(Schema.Boolean.annotations({
      title: "\u9ED8\u8BA4\u6298\u53E0",
      description: "\u6302\u8F7D\u65F6\u662F\u5426\u9ED8\u8BA4\u6298\u53E0\uFF1B\u7528\u6237\u70B9\u51FB\u5C55\u5F00/\u6536\u8D77\u540E\u5373\u65F6\u751F\u6548\uFF0C**\u4E0D**\u6301\u4E45\u5316\uFF08\u5378\u8F7D\u5373\u4E22\u5F03\uFF09"
    })),
    unit: Unit.annotations({
      identifier: "FormFieldCollapsibleUnit",
      title: "\u533A\u57DF\u5185\u5BB9",
      description: "\u6298\u53E0\u533A\u57DF\u5185\u7684\u5B57\u6BB5\u4E0E\u5E03\u5C40\uFF1B\u8FD9\u4E9B\u5B57\u6BB5\u5728\u8868\u5355\u72B6\u6001\u4E2D\u4FDD\u6301\u6241\u5E73\uFF0C\u4E0D\u4F1A\u56E0\u4E3A\u5206\u7EC4\u800C\u5F15\u5165\u65B0\u7684\u72B6\u6001\u5C42\u7EA7"
    })
  }).annotations({
    title: "CollapsibleField",
    description: "\u5E26 Markdown \u6807\u9898\u7684\u53EF\u6298\u53E0\u533A\u57DF\uFF0C\u4EC5\u7528\u4E8E\u89C6\u89C9\u5206\u7EC4\uFF0C\u4E0D\u5F71\u54CD\u5B57\u6BB5\u5728\u8868\u5355\u72B6\u6001\u4E2D\u7684\u5C42\u7EA7"
  });
}
export function defaults() {
  return {
    header: [{ locale: "zh", message: "" }],
    unit: {
      fields: [],
      layouts: [{ name: "\u9ED8\u8BA4", layout: { columns: 1, placements: {} } }]
    }
  };
}
