import { Search as SearchIcon } from "@truststack/icons-ui";
import {
  createStyledContext,
  Input,
  styled,
  ThemeableStack,
  withStaticProperties
} from "tamagui";
import { Icon } from "./Icon";
import { Spinner } from "./Spinner";
import { jsx, jsxs } from "react/jsx-runtime";
const SearchContext = createStyledContext(), SearchFrame = styled(ThemeableStack, {
  name: "Search",
  context: SearchContext,
  backgroundColor: "$surfaceContainerHigh",
  alignItems: "center",
  brc: "transparent",
  btc: "transparent",
  bbc: "transparent",
  blc: "transparent",
  br: "$shape.corner_full",
  height: 56,
  minWidth: 360,
  maxWidth: 720,
  flexDirection: "row",
  variants: {
    loading: {
      true: {},
      false: {}
    }
  },
  defaultVariants: {
    loading: !1
  }
}), StartAdornment = styled(Icon, {
  name: "SearchStartAdornment",
  width: 24,
  height: 24,
  col: "$onSurface",
  marginLeft: 16
}), SearchInput = styled(Input, {
  name: "SearchInput",
  unstyled: !0,
  col: "$onSurfaceVariant",
  placeholder: "Search...",
  marginLeft: 16,
  marginRight: 16,
  flexGrow: 1
}), SearchSpinner = styled(Spinner, {
  name: "SearchSpinner",
  context: SearchContext,
  size: 24,
  col: "$onSurface",
  marginRight: 16,
  variants: {
    loading: {
      true: {},
      false: {
        display: "none"
      }
    }
  },
  defaultVariants: {
    loading: !1
  }
}), EndAdornment = styled(Icon, {
  name: "SearchEndAdornment",
  width: 24,
  height: 24,
  col: "$onSurface",
  marginRight: 16
}), Search = withStaticProperties(SearchFrame, {
  Props: SearchContext.Provider,
  StartAdornment,
  Input: SearchInput,
  EndAdornment,
  Spinner: SearchSpinner
});
function SearchBar({
  value,
  onChangeText,
  placeholder = "Search...",
  ...props
}) {
  return /* @__PURE__ */ jsxs(Search, { ...props, children: [
    /* @__PURE__ */ jsx(Search.StartAdornment, { Icon: SearchIcon }),
    /* @__PURE__ */ jsx(
      Search.Input,
      {
        placeholder,
        value,
        onChangeText
      }
    ),
    /* @__PURE__ */ jsx(Search.Spinner, {})
  ] });
}
export {
  Search,
  SearchBar
};
//# sourceMappingURL=Search.js.map
