"use client";
const require_create_split_props = require("../../utils/create-split-props.cjs");
const require_tree_collection = require("../collection/tree-collection.cjs");
const require_use_tree_view = require("../tree-view/use-tree-view.cjs");
const require_get_branch_value = require("./get-branch-value.cjs");
let react = require("react");
let _zag_js_json_tree_utils = require("@zag-js/json-tree-utils");
//#region src/components/json-tree-view/use-json-tree-view.ts
var splitJsonTreeViewProps = require_create_split_props.createSplitProps();
var useJsonTreeView = (props) => {
	const [jsonTreeProps, localProps] = splitJsonTreeViewProps(props, [
		"maxPreviewItems",
		"collapseStringsAfterLength",
		"quotesOnKeys",
		"groupArraysAfterLength",
		"showNonenumerable"
	]);
	const { data, defaultExpandedDepth = 1, ...restProps } = localProps;
	const collection = (0, react.useMemo)(() => {
		return require_tree_collection.createTreeCollection({
			nodeToValue: _zag_js_json_tree_utils.nodeToValue,
			nodeToString: _zag_js_json_tree_utils.nodeToString,
			rootNode: (0, _zag_js_json_tree_utils.getRootNode)(data)
		});
	}, [data]);
	return {
		...require_use_tree_view.useTreeView({
			defaultExpandedValue: (0, react.useMemo)(() => {
				return defaultExpandedDepth != null ? require_get_branch_value.getBranchValues(collection, defaultExpandedDepth) : void 0;
			}, [collection, defaultExpandedDepth]),
			...restProps,
			collection,
			typeahead: false
		}),
		options: jsonTreeProps
	};
};
//#endregion
exports.useJsonTreeView = useJsonTreeView;
