{"version":3,"sources":["../src/hooks/use-copilot-runtime-client.ts"],"sourcesContent":["import {\n  CopilotRuntimeClient,\n  CopilotRuntimeClientOptions,\n  GraphQLError,\n} from \"@copilotkit/runtime-client-gql\";\nimport { useToast } from \"../components/toast/toast-provider\";\nimport { useMemo } from \"react\";\nimport { useErrorToast } from \"../components/error-boundary/error-utils\";\n\nexport const useCopilotRuntimeClient = (options: CopilotRuntimeClientOptions) => {\n  const { addGraphQLErrorsToast } = useToast();\n  const addErrorToast = useErrorToast();\n  const { addToast } = useToast();\n\n  const runtimeClient = useMemo(() => {\n    return new CopilotRuntimeClient({\n      ...options,\n      handleGQLErrors: (error) => {\n        if ((error as any).graphQLErrors.length) {\n          addGraphQLErrorsToast((error as any).graphQLErrors as GraphQLError[]);\n        } else {\n          addErrorToast([error]);\n        }\n      },\n      handleGQLWarning: (message: string) => {\n        console.warn(message);\n        addToast({ type: \"warning\", message });\n      },\n    });\n  }, [options, addGraphQLErrorsToast, addToast]);\n\n  return runtimeClient;\n};\n"],"mappings":";;;;;;;;;;AAAA;AAAA,EACE;AAAA,OAGK;AAEP,SAAS,eAAe;AAGjB,IAAM,0BAA0B,CAAC,YAAyC;AAC/E,QAAM,EAAE,sBAAsB,IAAI,SAAS;AAC3C,QAAM,gBAAgB,cAAc;AACpC,QAAM,EAAE,SAAS,IAAI,SAAS;AAE9B,QAAM,gBAAgB,QAAQ,MAAM;AAClC,WAAO,IAAI,qBAAqB,iCAC3B,UAD2B;AAAA,MAE9B,iBAAiB,CAAC,UAAU;AAC1B,YAAK,MAAc,cAAc,QAAQ;AACvC,gCAAuB,MAAc,aAA+B;AAAA,QACtE,OAAO;AACL,wBAAc,CAAC,KAAK,CAAC;AAAA,QACvB;AAAA,MACF;AAAA,MACA,kBAAkB,CAAC,YAAoB;AACrC,gBAAQ,KAAK,OAAO;AACpB,iBAAS,EAAE,MAAM,WAAW,QAAQ,CAAC;AAAA,MACvC;AAAA,IACF,EAAC;AAAA,EACH,GAAG,CAAC,SAAS,uBAAuB,QAAQ,CAAC;AAE7C,SAAO;AACT;","names":[]}