"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("react");
const Field = require("../Field.js");
const emotionReactJsxRuntime_browser_esm = require("../../../node_modules/.pnpm/@emotion_react@11.10.4_q4mq7tnhdumujvomvw24zx33y4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js");
function Array({
  name,
  label,
  title,
  options = [],
  ...props
}) {
  console.log("options:", name, options);
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(emotionReactJsxRuntime_browser_esm.Fragment, {
    children: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
      className: "relative",
      children: (fields, {
        add,
        remove,
        move
      }) => {
        return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs(emotionReactJsxRuntime_browser_esm.Fragment, {
          children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
            className: `flex flex-col ${JSON.stringify(fields) !== "[]" ? "border border-gray-200 rounded-md mb-2" : ""}`,
            children: fields == null ? void 0 : fields.map((item, index) => {
              return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
                className: "flex flex-col",
                children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
                  className: "flex justify-between p-4 bg-slate-100",
                  children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
                    className: "flex",
                    children: [label || title, " -", index + 1]
                  }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
                    className: "flex",
                    children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("button", {
                      type: "button",
                      className: "mr-4",
                      onClick: () => move(index, index - 1),
                      children: "\u4E0A\u79FB"
                    }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("button", {
                      type: "button",
                      onClick: () => remove(index),
                      children: "\u5220\u9664"
                    })]
                  })]
                }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("hr", {
                  className: "border-gray-200 border-b-1"
                }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
                  className: "flex flex-col p-4",
                  children: options.map((field, i) => /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(Field.Field, {
                    ...field,
                    name: `${name}.${index}.${field.name}`,
                    key: field == null ? void 0 : field.name
                  }, `${name}-${i}-${field.name}`))
                })]
              }, item.id);
            })
          }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("section", {
            className: "mx-auto mb-4",
            children: /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("button", {
              type: "button",
              className: "inline-flex items-center justify-center w-full px-5 py-2 text-sm font-medium text-indigo-600 border border-transparent rounded-md shadow bg-indigo-50 hover:bg-indigo-50",
              onClick: () => {
                add({});
              },
              children: "\u65B0\u589E"
            })
          })]
        });
      }
    })
  });
}
exports.Array = Array;
//# sourceMappingURL=Array.js.map
