export class SearchClient {
 constructor(key,{origin='https://search.agnt.gg'}={}){this.key=key;this.origin=origin;}
 async request(path,body,{idempotencyKey=crypto.randomUUID()}={}){
  const response=await fetch(this.origin+'/search/v1'+path,{method:body?'POST':'GET',headers:{Authorization:'Bearer '+this.key,'Content-Type':'application/json','Idempotency-Key':idempotencyKey},body:body?JSON.stringify(body):undefined,signal:AbortSignal.timeout(30000)});
  const result=await response.json();if(!response.ok){const error=Error(result.error||'Search request failed');Object.assign(error,{status:response.status,result,idempotencyKey});throw error;}return result;
 }
 search(query,options={}){const {idempotencyKey,...body}=options;return this.request('/search',{query,...body},{idempotencyKey});}
 receipt(id){return this.request('/requests/'+encodeURIComponent(id));}
}
