"use client";
import * as React from "react";
import { useComboboxRootContext } from "../root/ComboboxRootContext.js";
import { resolveSelectedLabel } from "../../utils/resolveValueLabel.js";
import { selectors } from "../store.js";
import { jsx } from "react/jsx-runtime";
import { useStore } from "../../../../utils/esm/store/useStore.js";
function ComboboxValue(props) {
  const {
    children: childrenProp
  } = props;
  const store = useComboboxRootContext();
  const itemToStringLabel = useStore(store, selectors.itemToStringLabel);
  const selectedValue = useStore(store, selectors.selectedValue);
  const items = useStore(store, selectors.items);
  let returnValue = null;
  if (typeof childrenProp === "function") {
    returnValue = childrenProp(selectedValue);
  } else if (childrenProp != null) {
    returnValue = childrenProp;
  } else {
    returnValue = resolveSelectedLabel(selectedValue, items, itemToStringLabel);
  }
  return /* @__PURE__ */ jsx(React.Fragment, {
    children: returnValue
  });
}
export {
  ComboboxValue
};
//# sourceMappingURL=ComboboxValue.js.map
