/**
 * 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.
 */

import TearsheetWrapper from "./Datagrid/addons/CustomizeColumns/TearsheetWrapper.js";
import ButtonWrapper from "./Datagrid/addons/CustomizeColumns/ButtonWrapper.js";
import * as React$1 from "react";

//#region src/components/Datagrid/useCustomizeColumns.tsx
/**
* Copyright IBM Corp. 2021, 2024
*
* 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 useInstance = (instance) => {
	const { customizeColumnsProps } = instance;
	const { labels } = customizeColumnsProps || {};
	const [isTearsheetOpen, setIsTearsheetOpen] = React$1.useState(false);
	const launcherButtonRef = React$1.useRef(null);
	const CustomizeColumnsButton = React$1.useCallback((props) => /* @__PURE__ */ React$1.createElement(ButtonWrapper, {
		...props,
		iconTooltipLabel: labels?.iconTooltipLabel,
		isTearsheetOpen,
		setIsTearsheetOpen,
		ref: launcherButtonRef
	}), [isTearsheetOpen, labels?.iconTooltipLabel]);
	const CustomizeColumnsTearsheet = React$1.useCallback((props) => /* @__PURE__ */ React$1.createElement(TearsheetWrapper, {
		...props,
		launcherButtonRef
	}), [launcherButtonRef]);
	Object.assign(instance, {
		customizeColumnsProps: {
			...customizeColumnsProps,
			isTearsheetOpen,
			setIsTearsheetOpen
		},
		CustomizeColumnsButton,
		CustomizeColumnsTearsheet
	});
};
const useCustomizeColumns = (hooks) => {
	hooks.useInstance.push(useInstance);
};

//#endregion
export { useCustomizeColumns as default };