import { Schema } from "effect";
import { Locale } from "../../../../../share/locale.js";
import { Slot, defaultSlot } from "../../../../../share/layout.js";
import { lookupBlockRef } from "../../../../config/utils/block-ref-cache.js";
export const type = "com.shwfed.actions.button.modal.layout";
export const compatibilityDate = "2026-05-11";
export const metadata = {
  name: "\u6A21\u6001\u7A97\u53E3",
  icon: "fluent:window-edit-20-regular",
  drillable: true,
  operations: [
    { id: "close", name: "\u5173\u95ED\u5F39\u7A97", icon: "fluent:dismiss-20-regular" }
  ]
};
const CssLength = Schema.String.pipe(
  Schema.filter((s) => s.trim().length > 0 || "\u4E0D\u80FD\u4E3A\u7A7A\u5B57\u7B26\u4E32")
);
export function schema(configure) {
  const blockUnion = lookupBlockRef(configure) ?? Schema.Unknown;
  const ModalSlot = Slot(blockUnion, configure);
  return Schema.Struct({
    type: Schema.Literal(type),
    compatibilityDate: Schema.Literal(compatibilityDate),
    modalTitle: Schema.optional(Locale.annotations({
      title: "\u5F39\u7A97\u6807\u9898",
      description: "\u5F39\u7A97\u9876\u90E8\u5C55\u793A\u7684\u672C\u5730\u5316\u6807\u9898\uFF0C\u652F\u6301\u884C\u5185 Markdown\uFF1B\u4E0D\u586B\u5219\u56DE\u9000\u4F7F\u7528\u6309\u94AE\u81EA\u8EAB\u7684\u540D\u79F0"
    })),
    modalWidth: Schema.optional(CssLength.annotations({
      title: "\u5F39\u7A97\u5BBD\u5EA6",
      description: "CSS \u5BBD\u5EA6\uFF0C\u5982 `720px` / `60vw`\uFF1B\u4E0D\u586B\u4F7F\u7528\u9ED8\u8BA4\u5BBD\u5EA6"
    })),
    modalMinHeight: Schema.optional(CssLength.annotations({
      title: "\u6700\u5C0F\u9AD8\u5EA6",
      description: "CSS \u6700\u5C0F\u9AD8\u5EA6\uFF0C\u5982 `400px` / `60vh`\uFF1B\u4E0D\u586B\u5219\u8DDF\u968F\u5185\u5BB9\u81EA\u7136\u6491\u5F00"
    })),
    slot: ModalSlot.annotations({
      title: "\u5185\u5BB9",
      description: "\u5F39\u7A97\u5185\u90E8\u7684\u5757\u4E0E\u5E03\u5C40"
    })
  }).annotations({
    title: "ModalLayoutAction",
    description: "\u70B9\u51FB\u540E\u5F39\u51FA\u5305\u542B\u4E00\u7EC4\u5757\u7684\u5F39\u7A97"
  });
}
export function defaultBody() {
  return {
    slot: defaultSlot()
  };
}
