/**
 * GENERATED by `imprint emit` — DO NOT EDIT BY HAND.
 *
 * Tool: autocomplete_hotel_location
 * Site: google-hotels
 * Intent: Resolve a free-text place query into Google Hotels location autocomplete suggestions (display names and place identifiers).
 *
 * To regenerate: imprint emit ~/.imprint/google-hotels/autocomplete_hotel_location/workflow.json --force
 */

import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
import {
  executeWorkflow,
  type CredentialStore,
} from 'imprint/runtime';
import type { ToolResult, Workflow } from 'imprint/types';

const WORKFLOW: Workflow = {
  "toolName": "autocomplete_hotel_location",
  "intent": {
    "description": "Resolve a free-text place query into Google Hotels location autocomplete suggestions (display names and place identifiers).",
    "userSaid": "searched for hotels at chicago loop; changed location to tahoe city; searched for hotels in tahoe; searched for hotels in denver downtown"
  },
  "parameters": [
    {
      "name": "query",
      "type": "string",
      "description": "Partial place/hotel text to autocomplete, e.g. 'chicago loop' or 'tahoe city hotels'.",
      "verified": true
    }
  ],
  "requests": [
    {
      "method": "POST",
      "url": "https://www.google.com/_/TravelFrontendUi/data/batchexecute?rpcids=mejVKc&source-path=%2Ftravel%2Fsearch&f.sid=-7129101702754032847&bl=boq_travel-frontend-ui_20260603.00_p0&hl=en-US&soc-app=162&soc-platform=1&soc-device=1&_reqid=1943921&rt=c",
      "headers": {
        "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
        "X-Same-Domain": "1",
        "x-goog-ext-259736195-jspb": "[\"en-US\",\"US\",\"USD\",2,null,[420],null,null,7,[]]",
        "Origin": "https://www.google.com",
        "Referer": "https://www.google.com/travel/search",
        "Accept-Language": "en-US,en;q=0.9",
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36"
      },
      "body": "f.req=%5B%5B%5B%22mejVKc%22%2C%22%5B%5C%22${param.query}%5C%22%2C%5C%22${param.query}%5C%22%2C1%2C1%2Cnull%2C30%5D%22%2Cnull%2C%22generic%22%5D%5D%5D&",
      "effect": "safe"
    }
  ],
  "site": "google-hotels",
  "parserModule": "./parser.ts",
  "requestTransformModule": "./request-transform.ts",
  "liveVerified": true
};

export interface AutocompleteHotelLocationInput {
  /** Partial place/hotel text to autocomplete, e.g. 'chicago loop' or 'tahoe city hotels'. */
  query: string;
}

export async function autocompleteHotelLocation(
  input: AutocompleteHotelLocationInput,
  opts: { credentials?: CredentialStore; fetchImpl?: typeof fetch; initialState?: Record<string, unknown> } = {},
): Promise<ToolResult> {
  const __dirname = dirname(fileURLToPath(import.meta.url));
  const params: Record<string, string | number | boolean> = {
    query: input.query,

  };
  return executeWorkflow({
    workflow: WORKFLOW,
    params,
    credentials: opts.credentials,
    fetchImpl: opts.fetchImpl,
    initialState: opts.initialState,
    workflowPath: join(__dirname, 'workflow.json'),
  });
}

export { WORKFLOW };
