"use client"

import { buildSearchUrl, type SearchParams } from "@/lib/mail-search/search-params"
import { useAdvancedSearchForm } from "@/lib/mail-search/use-advanced-search-form"
import { AdvancedSearchPanelMobile } from "@/components/gmail/mail-search/advanced-search-fields"

export function MobileAdvancedSearch({
  initialQuery,
  onSubmit,
}: {
  initialQuery: string
  onSubmit: (url: string) => void
}) {
  const form = useAdvancedSearchForm(initialQuery, null)

  const handleSubmit = () => {
    onSubmit(buildSearchUrl(form.buildParams()))
  }

  return <AdvancedSearchPanelMobile form={form} onSubmit={handleSubmit} />
}
