/**
 * Copyright IBM Corp. 2020, 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

const require_runtime = require('../../_virtual/_rolldown/runtime.js');
const require_index = require('../../node_modules/classnames/index.js');
const require_settings = require('../../settings.js');
const require_devtools = require('../../global/js/utils/devtools.js');
const require_usePortalTarget = require('../../global/js/hooks/usePortalTarget.js');
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let _carbon_react = require("@carbon/react");

//#region src/components/CreateModal/CreateModal.tsx
/**
* Copyright IBM Corp. 2021, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
var import_classnames = /* @__PURE__ */ require_runtime.__toESM(require_index.default);
const componentName = "CreateModal";
const blockClass = `${require_settings.pkg.prefix}--create-modal`;
/**
* The `CreateModal` component provides a way for a user to quickly generate a new
resource. It is triggered by a user’s action, appears on top of the main page
content, and is persistent until dismissed. The purpose of this modal should be
immediately apparent to the user, with a clear and obvious path to completion.
*/
const CreateModal = react.default.forwardRef((props, ref) => {
	const { className, children, onRequestClose, onRequestSubmit, open, title, subtitle, description, secondaryButtonText, portalTarget: portalTargetIn, primaryButtonText, disableSubmit, selectorPrimaryFocus, ...rest } = props;
	return require_usePortalTarget.usePortalTarget(portalTargetIn)(/* @__PURE__ */ react.default.createElement(_carbon_react.ComposedModal, {
		...rest,
		selectorPrimaryFocus,
		className: (0, import_classnames.default)(blockClass, className),
		open,
		ref,
		"aria-label": title,
		size: "sm",
		preventCloseOnClickOutside: true,
		onClose: () => {
			onRequestClose?.();
			return false;
		},
		...require_devtools.getDevtoolsProps(componentName)
	}, /* @__PURE__ */ react.default.createElement(_carbon_react.ModalHeader, {
		title,
		titleClassName: `${blockClass}__title`
	}, subtitle && /* @__PURE__ */ react.default.createElement("p", { className: `${blockClass}__subtitle` }, subtitle)), /* @__PURE__ */ react.default.createElement(_carbon_react.ModalBody, { hasForm: true }, description && /* @__PURE__ */ react.default.createElement("p", { className: `${blockClass}__description` }, description), /* @__PURE__ */ react.default.createElement(_carbon_react.Form, {
		className: `${blockClass}__form`,
		"aria-label": title,
		onSubmit: (e) => e.preventDefault()
	}, children)), /* @__PURE__ */ react.default.createElement(_carbon_react.ModalFooter, null, /* @__PURE__ */ react.default.createElement(_carbon_react.Button, {
		type: "button",
		kind: "secondary",
		onClick: onRequestClose
	}, secondaryButtonText), /* @__PURE__ */ react.default.createElement(_carbon_react.Button, {
		type: "submit",
		kind: "primary",
		onClick: onRequestSubmit,
		disabled: disableSubmit
	}, primaryButtonText))));
});
CreateModal.propTypes = {
	children: prop_types.default.node,
	className: prop_types.default.string,
	description: prop_types.default.node.isRequired,
	disableSubmit: prop_types.default.bool,
	onRequestClose: prop_types.default.func,
	onRequestSubmit: prop_types.default.func,
	open: prop_types.default.bool,
	portalTarget: prop_types.default.node,
	primaryButtonText: prop_types.default.string.isRequired,
	secondaryButtonText: prop_types.default.string.isRequired,
	selectorPrimaryFocus: prop_types.default.string.isRequired,
	subtitle: prop_types.default.node,
	title: prop_types.default.node.isRequired
};
CreateModal.displayName = componentName;

//#endregion
exports.CreateModal = CreateModal;