"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// packages/components/src/border-control/border-control/component.tsx
var component_exports = {};
__export(component_exports, {
  BorderControl: () => BorderControl,
  default: () => component_default
});
module.exports = __toCommonJS(component_exports);
var import_i18n = require("@wordpress/i18n");
var import_border_control_dropdown = __toESM(require("../border-control-dropdown/index.cjs"), 1);
var import_unit_control = __toESM(require("../../unit-control/index.cjs"), 1);
var import_range_control = __toESM(require("../../range-control/index.cjs"), 1);
var import_h_stack = require("../../h-stack/index.cjs");
var import_base_control_styles = require("../../base-control/styles/base-control-styles.cjs");
var import_view = require("../../view/index.cjs");
var import_visually_hidden = require("../../visually-hidden/index.cjs");
var import_context = require("../../context/index.cjs");
var import_hook = require("./hook.cjs");
var import_spacer = require("../../spacer/index.cjs");
var import_jsx_runtime = require("react/jsx-runtime");
var BorderLabel = (props) => {
  const {
    label,
    hideLabelFromVision
  } = props;
  if (!label) {
    return null;
  }
  return hideLabelFromVision ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_visually_hidden.VisuallyHidden, {
    as: "legend",
    children: label
  }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_base_control_styles.StyledLabel, {
    as: "legend",
    children: label
  });
};
var UnconnectedBorderControl = (props, forwardedRef) => {
  const {
    __next40pxDefaultSize = false,
    colors,
    disableCustomColors,
    disableUnits,
    enableAlpha,
    enableStyle,
    hideLabelFromVision,
    innerWrapperClassName,
    inputWidth,
    isStyleSettable,
    label,
    onBorderChange,
    onSliderChange,
    onWidthChange,
    placeholder,
    __unstablePopoverProps,
    previousStyleSelection,
    showDropdownHeader,
    size,
    sliderClassName,
    value: border,
    widthUnit,
    widthValue,
    withSlider,
    __experimentalIsRenderedInSidebar,
    ...otherProps
  } = (0, import_hook.useBorderControl)(props);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_view.View, {
    as: "fieldset",
    ...otherProps,
    ref: forwardedRef,
    children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(BorderLabel, {
      label,
      hideLabelFromVision
    }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_h_stack.HStack, {
      spacing: 4,
      className: innerWrapperClassName,
      children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_unit_control.default, {
        __next40pxDefaultSize,
        __shouldNotWarnDeprecated36pxSize: true,
        prefix: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spacer.Spacer, {
          marginRight: 1,
          marginBottom: 0,
          children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_border_control_dropdown.default, {
            border,
            colors,
            __unstablePopoverProps,
            disableCustomColors,
            enableAlpha,
            enableStyle,
            isStyleSettable,
            onChange: onBorderChange,
            previousStyleSelection,
            __experimentalIsRenderedInSidebar,
            size
          })
        }),
        label: (0, import_i18n.__)("Border width"),
        hideLabelFromVision: true,
        min: 0,
        onChange: onWidthChange,
        value: border?.width || "",
        placeholder,
        disableUnits,
        __unstableInputWidth: inputWidth,
        size
      }), withSlider && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_range_control.default, {
        label: (0, import_i18n.__)("Border width"),
        hideLabelFromVision: true,
        className: sliderClassName,
        initialPosition: 0,
        max: 100,
        min: 0,
        onChange: onSliderChange,
        step: ["px", "%"].includes(widthUnit) ? 1 : 0.1,
        value: widthValue || void 0,
        withInputField: false,
        __next40pxDefaultSize,
        __shouldNotWarnDeprecated36pxSize: true
      })]
    })]
  });
};
var BorderControl = (0, import_context.contextConnect)(UnconnectedBorderControl, "BorderControl");
var component_default = BorderControl;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  BorderControl
});
//# sourceMappingURL=component.cjs.map
