var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
    for (var name in all) __defProp(target, name, {
      get: all[name],
      enumerable: !0
    });
  },
  __copyProps = (to, from, except, desc) => {
    if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
      get: () => from[key],
      enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
    });
    return to;
  };
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
  value: !0
}), mod);
var Search_exports = {};
__export(Search_exports, {
  Search: () => Search,
  SearchBar: () => SearchBar
});
module.exports = __toCommonJS(Search_exports);
var import_icons_ui = require("@truststack/icons-ui"),
  import_tamagui = require("tamagui"),
  import_Icon = require("./Icon.cjs"),
  import_Spinner = require("./Spinner.cjs"),
  import_jsx_runtime = require("react/jsx-runtime");
const SearchContext = (0, import_tamagui.createStyledContext)(),
  SearchFrame = (0, import_tamagui.styled)(import_tamagui.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 = (0, import_tamagui.styled)(import_Icon.Icon, {
    name: "SearchStartAdornment",
    width: 24,
    height: 24,
    col: "$onSurface",
    marginLeft: 16
  }),
  SearchInput = (0, import_tamagui.styled)(import_tamagui.Input, {
    name: "SearchInput",
    unstyled: !0,
    col: "$onSurfaceVariant",
    placeholder: "Search...",
    marginLeft: 16,
    marginRight: 16,
    flexGrow: 1
  }),
  SearchSpinner = (0, import_tamagui.styled)(import_Spinner.Spinner, {
    name: "SearchSpinner",
    context: SearchContext,
    size: 24,
    col: "$onSurface",
    marginRight: 16,
    variants: {
      loading: {
        true: {},
        false: {
          display: "none"
        }
      }
    },
    defaultVariants: {
      loading: !1
    }
  }),
  EndAdornment = (0, import_tamagui.styled)(import_Icon.Icon, {
    name: "SearchEndAdornment",
    width: 24,
    height: 24,
    col: "$onSurface",
    marginRight: 16
  }),
  Search = (0, import_tamagui.withStaticProperties)(SearchFrame, {
    Props: SearchContext.Provider,
    StartAdornment,
    Input: SearchInput,
    EndAdornment,
    Spinner: SearchSpinner
  });
function SearchBar({
  value,
  onChangeText,
  placeholder = "Search...",
  ...props
}) {
  return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(Search, {
    ...props,
    children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(Search.StartAdornment, {
      Icon: import_icons_ui.Search
    }), /* @__PURE__ */(0, import_jsx_runtime.jsx)(Search.Input, {
      placeholder,
      value,
      onChangeText
    }), /* @__PURE__ */(0, import_jsx_runtime.jsx)(Search.Spinner, {})]
  });
}