import { Schema } from "effect";
import { Locale } from "../../../../../share/locale.js";
import { ActionSchemaFields } from "../../../../actions/schema.js";
import { columnIdentityFields, registerRowVariablesIfAbsent } from "../../../utils/shared.js";
export const type = "com.shwfed.table.column.actions";
export const compatibilityDate = "2026-04-14";
export const metadata = {
  name: "\u64CD\u4F5C",
  icon: "fluent:cursor-click-20-regular"
};
export const registerRowVariables = registerRowVariablesIfAbsent;
export function schema(configure) {
  const configureWithRow = (env) => {
    configure(env);
    registerRowVariables(env);
  };
  const { fields: actionFields } = ActionSchemaFields(configureWithRow);
  const { size: _buttonSize, ...actionFieldsForColumn } = actionFields;
  return Schema.Struct({
    type: Schema.Literal(type),
    compatibilityDate: Schema.Literal(compatibilityDate),
    ...columnIdentityFields(),
    title: Schema.optional(Locale.annotations({ title: "\u6807\u9898", description: "\u5217\u6807\u9898" })),
    size: Schema.optional(Schema.Number.pipe(Schema.finite(), Schema.positive()).annotations({
      title: "\u5217\u5BBD",
      description: "\u5217\u56FA\u5B9A\u5BBD\u5EA6\uFF08\u50CF\u7D20\uFF09"
    })),
    grow: Schema.optional(Schema.Boolean.annotations({
      title: "\u5360\u636E\u5269\u4F59\u5BBD\u5EA6",
      description: "\u5217\u662F\u5426\u5360\u636E\u5269\u4F59\u7A7A\u4F59\u5BBD\u5EA6"
    })),
    ...actionFieldsForColumn
  }).annotations({ title: "ActionsRenderer", description: "\u64CD\u4F5C\u6E32\u67D3\u5668" });
}
export function defaults() {
  return {
    title: [{ locale: "zh", message: "" }],
    size: 200,
    groups: [],
    items: []
  };
}
export function toColumnDef(value, { getLocaleText }) {
  return {
    header: value.title ? getLocaleText(value.title) : void 0,
    enableSorting: false,
    enableResizing: false,
    size: value.size,
    meta: {
      grow: value.grow ?? false
    }
  };
}
