// packages/block-editor/src/components/link-control/settings.js
import { __ } from "@wordpress/i18n";
import { CheckboxControl, VisuallyHidden } from "@wordpress/components";
import { jsx, jsxs } from "react/jsx-runtime";
var noop = () => {
};
var LinkControlSettings = ({ value, onChange = noop, settings }) => {
  if (!settings || !settings.length) {
    return null;
  }
  const handleSettingChange = (setting) => (newValue) => {
    onChange({
      ...value,
      [setting.id]: newValue
    });
  };
  const theSettings = settings.map((setting) => {
    if ("render" in setting) {
      if (typeof setting.render === "function") {
        const renderedContent = setting.render(
          setting,
          value,
          onChange
        );
        return /* @__PURE__ */ jsx(
          "div",
          {
            className: "block-editor-link-control__setting",
            children: renderedContent
          },
          setting.id
        );
      }
      return null;
    }
    return /* @__PURE__ */ jsx(
      CheckboxControl,
      {
        __nextHasNoMarginBottom: true,
        className: "block-editor-link-control__setting",
        label: setting.title,
        onChange: handleSettingChange(setting),
        checked: value ? !!value[setting.id] : false,
        help: setting?.help
      },
      setting.id
    );
  }).filter(Boolean);
  return /* @__PURE__ */ jsxs("fieldset", { className: "block-editor-link-control__settings", children: [
    /* @__PURE__ */ jsx(VisuallyHidden, { as: "legend", children: __("Currently selected link settings") }),
    theSettings
  ] });
};
var settings_default = LinkControlSettings;
export {
  settings_default as default
};
//# sourceMappingURL=settings.js.map
