@yukino.js/yukino 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -11
- package/dist/a2a-ANR7PFD4.js +15 -0
- package/dist/acp-4E7R254I.js +14 -0
- package/dist/{anthropic-74ALYMH2.js → anthropic-ZO73YJFY.js} +1 -1
- package/dist/browser/dist/index.html +44 -0
- package/dist/browser/dist/static/index.css +2 -0
- package/dist/browser/dist/static/index.js +203 -0
- package/dist/bwrap-LVIPV72Q.js +0 -0
- package/dist/chunk-3KKA6537.js +0 -0
- package/dist/chunk-3RH3COZW.js +365 -0
- package/dist/chunk-4JHZPFU6.js +67 -0
- package/dist/chunk-7MKA3SHV.js +0 -0
- package/dist/{chunk-OREDGNI6.js → chunk-B2RNOTT5.js} +1 -1
- package/dist/{chunk-APJAUOF6.js → chunk-C56EKYBO.js} +1 -1
- package/dist/{chunk-WGFROGUC.js → chunk-CKOUBYG6.js} +0 -0
- package/dist/{chunk-6JUOKMSJ.js → chunk-CW6G3RYM.js} +1 -1
- package/dist/{chunk-556TRLPT.js → chunk-CWWRUTF2.js} +1 -1
- package/dist/chunk-DVB57IVG.js +18 -0
- package/dist/chunk-ETZPOVUC.js +4 -0
- package/dist/chunk-F3JTT3TI.js +110 -0
- package/dist/chunk-FC2LG24U.js +4 -0
- package/dist/chunk-FNQMXCCE.js +4 -0
- package/dist/chunk-HWCLMDQF.js +0 -0
- package/dist/chunk-I74AL3PF.js +0 -0
- package/dist/chunk-IOMQY54U.js +967 -0
- package/dist/chunk-IQT2IFSO.js +4 -0
- package/dist/chunk-K45OXLJJ.js +16 -0
- package/dist/chunk-KJJYW5IY.js +0 -0
- package/dist/chunk-LCWNSYZU.js +0 -0
- package/dist/chunk-LR4ZNAAM.js +4 -0
- package/dist/chunk-LTMY67B2.js +5 -0
- package/dist/chunk-MDPSQ6L7.js +0 -0
- package/dist/chunk-MQAQBW7F.js +0 -0
- package/dist/{chunk-NEU4ER5V.js → chunk-NSNTZXFL.js} +1 -1
- package/dist/chunk-P6DHMU7R.js +0 -0
- package/dist/chunk-VCIRD267.js +0 -0
- package/dist/chunk-VM4YKTHC.js +0 -0
- package/dist/chunk-VU3JWAJR.js +0 -0
- package/dist/chunk-W4GMCNWF.js +0 -0
- package/dist/chunk-XY7ZFVZL.js +4 -0
- package/dist/devtools-UVGRIXO2.js +0 -0
- package/dist/{esm-HW2JMFYC.js → esm-2JJG3HR7.js} +1 -1
- package/dist/esm-7DWXO52B.js +4 -0
- package/dist/{esm-6L5BJ5GT.js → esm-EOOB75BT.js} +1 -1
- package/dist/{esm-DIYJ5HX6.js → esm-H73EL6IR.js} +1 -1
- package/dist/{esm-YKAO4ES6.js → esm-IBZKE3IU.js} +1 -1
- package/dist/esm-W4NAAZTQ.js +225 -0
- package/dist/{esm-RPR2GBJ2.js → esm-Y237QNPJ.js} +1 -1
- package/dist/getMachineId-bsd-A3UCSHLE.js +4 -0
- package/dist/getMachineId-bsd-E27XJQLX.js +0 -0
- package/dist/getMachineId-darwin-35UPAIXP.js +0 -0
- package/dist/getMachineId-darwin-MWJEU7OI.js +5 -0
- package/dist/getMachineId-linux-FNSLKUDN.js +4 -0
- package/dist/getMachineId-linux-MKXIYT6A.js +0 -0
- package/dist/getMachineId-unsupported-PKQWB2OJ.js +4 -0
- package/dist/getMachineId-unsupported-ZXVGGFX2.js +0 -0
- package/dist/getMachineId-win-3A667JT3.js +4 -0
- package/dist/getMachineId-win-RNVIYJG5.js +0 -0
- package/dist/lib/{anthropic-EQRUGP2C.js → anthropic-SQBOFRPQ.js} +4 -4
- package/dist/lib/{chunk-EGT7BJRD.js → chunk-AW2577J5.js} +2 -2
- package/dist/lib/{chunk-JYCSWXCR.js → chunk-GPJL4PLE.js} +2 -2
- package/dist/lib/{chunk-UBVKYJFI.js → chunk-IHVYAEY2.js} +1058 -522
- package/dist/lib/{chunk-CDMR25FD.js → chunk-U3OT4POQ.js} +3 -3
- package/dist/lib/{chunk-HUTUNNDX.js → chunk-WNGF7243.js} +0 -1
- package/dist/lib/{chunk-FUJDUZTH.js → chunk-WXR5HNB4.js} +1 -1
- package/dist/lib/{chunk-WWCSFKMR.js → chunk-XS3GONYN.js} +2 -11
- package/dist/lib/index.d.ts +98 -282
- package/dist/lib/index.js +1092 -2409
- package/dist/lib/{openai-B3I5WBFT.js → openai-UV4KFNQV.js} +3 -3
- package/dist/lib/{providers-EJ4VBHNP.js → providers-77VBEX3K.js} +2 -2
- package/dist/lib/{tool-filter-TURPCYFR.js → tool-filter-MLYQGWM5.js} +3 -3
- package/dist/{main-JEEKFCGX.js → main-653YZQHY.js} +228 -232
- package/dist/main.js +2 -2
- package/dist/node-634LOHDX.js +0 -0
- package/dist/{openai-7C6BVQ7M.js → openai-FKLMHNNC.js} +1 -1
- package/dist/providers-4IU7SUEQ.js +4 -0
- package/dist/seatbelt-UO7HGD4Z.js +0 -0
- package/dist/server-4NHV4RJL.js +4 -0
- package/dist/slim-Q56GHZZP.js +0 -0
- package/dist/{src-JBRNH4FA.js → src-DEVJGNXS.js} +1 -1
- package/dist/{src-X6JWWHHT.js → src-EMFESWQS.js} +1 -1
- package/dist/{src-R4BSSIJJ.js → src-GG4YROJH.js} +1 -1
- package/dist/{src-43CPCEK2.js → src-JFAO2DGP.js} +1 -1
- package/dist/tool-filter-LJTLMGFP.js +4 -0
- package/dist/turndown.es-NQ3KDXM7.js +0 -0
- package/package.json +22 -21
- package/dist/a2a-DKWMWGID.js +0 -14
- package/dist/acp-RL6DKS3R.js +0 -14
- package/dist/chunk-2LHY3FND.js +0 -67
- package/dist/chunk-3QL446GD.js +0 -4
- package/dist/chunk-6FSIG63T.js +0 -364
- package/dist/chunk-A5G5NTDB.js +0 -1015
- package/dist/chunk-A7CJPQC5.js +0 -5
- package/dist/chunk-AGSYLE4E.js +0 -16
- package/dist/chunk-CJSMVCUF.js +0 -6
- package/dist/chunk-CU3IISCC.js +0 -4
- package/dist/chunk-HMZQYFYG.js +0 -4
- package/dist/chunk-JFKC4VCA.js +0 -4
- package/dist/chunk-KCMBAHWU.js +0 -4
- package/dist/chunk-SCR7NDDL.js +0 -63
- package/dist/esm-57CJEGGK.js +0 -4
- package/dist/esm-YOQPBF42.js +0 -225
- package/dist/fe/dist/index.html +0 -21
- package/dist/fe/dist/static/index.css +0 -2
- package/dist/fe/dist/static/index.js +0 -203
- package/dist/providers-U23PWAHG.js +0 -4
- package/dist/server-EOSEQPNY.js +0 -4
- package/dist/tool-filter-UDSHRE5F.js +0 -4
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __yukinoCreateRequire } from "node:module";
|
|
3
|
+
const require = __yukinoCreateRequire(import.meta.url);
|
|
4
|
+
import{k as ft,o as Vt}from"./chunk-HWCLMDQF.js";import{d as Ro,f as Me,g as Eo,h as vt,i as Ze,j as vr,k as Rt,l as ke,o as St,p as At,q as kt,s as It,t as Nt,u as er,v as Mt}from"./chunk-XY7ZFVZL.js";import{a as Ne}from"./chunk-CWWRUTF2.js";import{a as Ct}from"./chunk-ETZPOVUC.js";import{b as Oe,d as Un,h as xe,i as Tt,j as Er}from"./chunk-LR4ZNAAM.js";import{a as xt,c as Rr,g as Lo,j as Et,l as Sr,m as Lt,n as xr,p as qe,u as Pt,v as Bn}from"./chunk-K45OXLJJ.js";import{b as Ye,c as So,d as Je,e as xo,f as yt,l as bt}from"./chunk-IQT2IFSO.js";import{c as ee,e as Se,f as Ae,g as yo,k as br,n as bo,o as te,p as M,r as vo,s as be,u as Z}from"./chunk-VCIRD267.js";Z();var jn=Object.defineProperty,O=(r,e)=>{for(var t in e)jn(r,t,{get:e[t],enumerable:!0})};function oe(r){if(typeof process<"u"&&process.env[r])return process.env[r];if(typeof globalThis<"u")return globalThis[r]}function ko(r){let e=atob(r);return Uint8Array.from(e,t=>t.codePointAt(0))}function To(r){let e=Array.from(r,t=>String.fromCharCode(t)).join("");return btoa(e)}function Ht(r){if(typeof Buffer<"u")return Buffer.from(r,"utf8").toString("base64");let e=new TextEncoder().encode(r);return To(e)}var Io=(r=>(r[r.NONE=4]="NONE",r[r.ERROR=3]="ERROR",r[r.WARN=2]="WARN",r[r.INFO=1]="INFO",r[r.DEBUG=0]="DEBUG",r))(Io||{});function zn(){var r;if(typeof process=="object"&&"env"in process){if(((r=oe("LANGFUSE_DEBUG"))==null?void 0:r.toLowerCase())==="true")return 0;let e=oe("LANGFUSE_LOG_LEVEL");switch((e??"").toUpperCase()){case"NONE":return 4;case"ERROR":return 3;case"WARN":return 2;case"INFO":return 1;case"DEBUG":return 0;default:return}}}var Ut=class{constructor(r={level:1}){this.config={enableTimestamp:!0,...r}}shouldLog(r){return r>=this.config.level}formatMessage(r,e){let t=this.config.enableTimestamp?new Date().toISOString():"",a=this.config.prefix||"[Langfuse SDK]";return[t,a,`[${r}]`,e].filter(Boolean).join(" ")}error(r,...e){this.shouldLog(3)&&console.error(this.formatMessage("ERROR",r),...e)}warn(r,...e){this.shouldLog(2)&&console.warn(this.formatMessage("WARN",r),...e)}info(r,...e){this.shouldLog(1)&&console.info(this.formatMessage("INFO",r),...e)}debug(r,...e){this.shouldLog(0)&&console.debug(this.formatMessage("DEBUG",r),...e)}setLevel(r){this.config.level=r}getLevel(){return this.config.level}isLevelEnabled(r){return this.shouldLog(r)}},Bt,No=class ve{static getInstance(){return ve.instance||(ve.instance=new Ut(ve.defaultConfig)),ve.instance}static configure(e){ve.defaultConfig=e,ve.instance=new Ut(e)}static reset(){ve.instance=null,ve.defaultConfig={level:1}}};No.instance=null;No.defaultConfig={level:(Bt=zn())!=null?Bt:1};var Kn=No;var re=()=>Kn.getInstance();var Xn={name:"@langfuse/core",version:"5.13.1",description:"Core functions and utilities for Langfuse packages",type:"module",sideEffects:!1,main:"./dist/index.cjs",module:"./dist/index.mjs",types:"./dist/index.d.ts",exports:{".":{import:{types:"./dist/index.d.ts",default:"./dist/index.mjs"},require:{types:"./dist/index.d.cts",default:"./dist/index.cjs"}}},scripts:{build:"tsup",test:"vitest run","test:watch":"vitest",format:'prettier --write "src/**/*.ts"',"format:check":'prettier --check "src/**/*.ts"',clean:"rm -rf dist"},author:"Langfuse",license:"MIT",repository:{type:"git",url:"https://github.com/langfuse/langfuse-js.git",directory:"packages/core"},files:["dist"],peerDependencies:{"@opentelemetry/api":"^1.9.0"},devDependencies:{"@types/node":"^24.1.0"}},rr="langfuse-sdk",or=Xn.version;var Dn="sdk-experiment",j=(r=>(r.TRACE_NAME="langfuse.trace.name",r.TRACE_USER_ID="user.id",r.TRACE_SESSION_ID="session.id",r.TRACE_TAGS="langfuse.trace.tags",r.TRACE_PUBLIC="langfuse.trace.public",r.TRACE_METADATA="langfuse.trace.metadata",r.TRACE_INPUT="langfuse.trace.input",r.TRACE_OUTPUT="langfuse.trace.output",r.OBSERVATION_TYPE="langfuse.observation.type",r.OBSERVATION_METADATA="langfuse.observation.metadata",r.OBSERVATION_LEVEL="langfuse.observation.level",r.OBSERVATION_STATUS_MESSAGE="langfuse.observation.status_message",r.OBSERVATION_INPUT="langfuse.observation.input",r.OBSERVATION_OUTPUT="langfuse.observation.output",r.OBSERVATION_COMPLETION_START_TIME="langfuse.observation.completion_start_time",r.OBSERVATION_MODEL="langfuse.observation.model.name",r.OBSERVATION_MODEL_PARAMETERS="langfuse.observation.model.parameters",r.OBSERVATION_USAGE_DETAILS="langfuse.observation.usage_details",r.OBSERVATION_COST_DETAILS="langfuse.observation.cost_details",r.OBSERVATION_PROMPT_NAME="langfuse.observation.prompt.name",r.OBSERVATION_PROMPT_VERSION="langfuse.observation.prompt.version",r.ENVIRONMENT="langfuse.environment",r.RELEASE="langfuse.release",r.VERSION="langfuse.version",r.AS_ROOT="langfuse.internal.as_root",r.IS_APP_ROOT="langfuse.internal.is_app_root",r.EXPERIMENT_ID="langfuse.experiment.id",r.EXPERIMENT_NAME="langfuse.experiment.name",r.EXPERIMENT_DESCRIPTION="langfuse.experiment.description",r.EXPERIMENT_METADATA="langfuse.experiment.metadata",r.EXPERIMENT_DATASET_ID="langfuse.experiment.dataset.id",r.EXPERIMENT_ITEM_ID="langfuse.experiment.item.id",r.EXPERIMENT_ITEM_EXPECTED_OUTPUT="langfuse.experiment.item.expected_output",r.EXPERIMENT_ITEM_METADATA="langfuse.experiment.item.metadata",r.EXPERIMENT_ITEM_ROOT_OBSERVATION_ID="langfuse.experiment.item.root_observation_id",r.TRACE_COMPAT_USER_ID="langfuse.user.id",r.TRACE_COMPAT_SESSION_ID="langfuse.session.id",r))(j||{}),Gn={};O(Gn,{AnnotationQueueObjectType:()=>Fn,AnnotationQueueStatus:()=>Hn});var Hn={Pending:"PENDING",Completed:"COMPLETED"},Fn={Trace:"TRACE",Observation:"OBSERVATION",Session:"SESSION"},$n={};O($n,{BlobStorageExportFieldGroup:()=>qn,BlobStorageExportFrequency:()=>Zn,BlobStorageExportMode:()=>Jn,BlobStorageExportSource:()=>On,BlobStorageIntegrationFileType:()=>Qn,BlobStorageIntegrationFileTypeResponse:()=>Yn,BlobStorageIntegrationType:()=>Wn,BlobStorageSyncStatus:()=>es});var Wn={S3:"S3",S3Compatible:"S3_COMPATIBLE",AzureBlobStorage:"AZURE_BLOB_STORAGE"},Qn={Json:"JSON",Csv:"CSV",Jsonl:"JSONL",Parquet:"PARQUET"},Yn={Json:"JSON",Csv:"CSV",Jsonl:"JSONL",Parquet:"PARQUET"},Jn={FullHistory:"FULL_HISTORY",FromToday:"FROM_TODAY",FromCustomDate:"FROM_CUSTOM_DATE"},Zn={Every20Minutes:"every_20_minutes",Hourly:"hourly",Daily:"daily",Weekly:"weekly"},On={LegacyTracesObservations:"LEGACY_TRACES_OBSERVATIONS",ObservationsV2:"OBSERVATIONS_V2",LegacyTracesAndEnrichedObservations:"LEGACY_TRACES_AND_ENRICHED_OBSERVATIONS"},qn={Core:"core",Basic:"basic",Time:"time",Io:"io",Metadata:"metadata",Model:"model",Usage:"usage",Prompt:"prompt",Metrics:"metrics",Tools:"tools",TraceContext:"trace_context"},es={Idle:"idle",Running:"running",Queued:"queued",UpToDate:"up_to_date",Disabled:"disabled",Error:"error"};var rs={};O(rs,{AccessDeniedError:()=>v,CommentObjectType:()=>is,DatasetItemMediaReferenceField:()=>os,DatasetStatus:()=>ls,Error:()=>y,MethodNotAllowedError:()=>S,ModelUsageUnit:()=>ns,NotFoundError:()=>R,ObservationLevel:()=>ss,PricingTierAttributeSource:()=>ts,PricingTierOperator:()=>as,ScoreConfigDataType:()=>us,ScoreDataType:()=>cs,ScoreSource:()=>ds,UnauthorizedError:()=>b});var os={Input:"input",ExpectedOutput:"expectedOutput",Metadata:"metadata"},ts={ModelParameters:"model_parameters",Metadata:"metadata"},as={Gt:"gt",Gte:"gte",Lt:"lt",Lte:"lte",Eq:"eq",Neq:"neq"},ns={Characters:"CHARACTERS",Tokens:"TOKENS",Milliseconds:"MILLISECONDS",Seconds:"SECONDS",Images:"IMAGES",Requests:"REQUESTS"},ss={Debug:"DEBUG",Default:"DEFAULT",Warning:"WARNING",Error:"ERROR"},is={Trace:"TRACE",Observation:"OBSERVATION",Session:"SESSION",Prompt:"PROMPT"},ls={Active:"ACTIVE",Archived:"ARCHIVED"},ds={Annotation:"ANNOTATION",Api:"API",Eval:"EVAL"},us={Numeric:"NUMERIC",Boolean:"BOOLEAN",Categorical:"CATEGORICAL",Text:"TEXT"},cs={Numeric:"NUMERIC",Boolean:"BOOLEAN",Categorical:"CATEGORICAL",Correction:"CORRECTION",Text:"TEXT"},Mo=(r,e,t)=>JSON.stringify(r,e,t);function Po(r,e){return JSON.parse(r,e)}var m=class Ft extends Error{constructor({message:e,statusCode:t,body:a,rawResponse:s}){super(ws({message:e,statusCode:t,body:a})),Object.setPrototypeOf(this,Ft.prototype),this.statusCode=t,this.body=a,this.rawResponse=s}};function ws({message:r,statusCode:e,body:t}){let a=[];return r!=null&&a.push(r),e!=null&&a.push(`Status code: ${e.toString()}`),t!=null&&a.push(`Body: ${Mo(t,void 0,2)}`),a.join(`
|
|
5
|
+
`)}var L=class $t extends Error{constructor(e){super(e),Object.setPrototypeOf(this,$t.prototype)}},y=class Wt extends m{constructor(e,t){super({message:"Error",statusCode:400,body:e,rawResponse:t}),Object.setPrototypeOf(this,Wt.prototype)}},b=class Qt extends m{constructor(e,t){super({message:"UnauthorizedError",statusCode:401,body:e,rawResponse:t}),Object.setPrototypeOf(this,Qt.prototype)}},v=class Yt extends m{constructor(e,t){super({message:"AccessDeniedError",statusCode:403,body:e,rawResponse:t}),Object.setPrototypeOf(this,Yt.prototype)}},R=class Jt extends m{constructor(e,t){super({message:"NotFoundError",statusCode:404,body:e,rawResponse:t}),Object.setPrototypeOf(this,Jt.prototype)}},S=class Zt extends m{constructor(e,t){super({message:"MethodNotAllowedError",statusCode:405,body:e,rawResponse:t}),Object.setPrototypeOf(this,Zt.prototype)}};var hs={};O(hs,{CodeEvaluatorSourceCodeLanguage:()=>gs,EvaluationRuleArrayOptionsFilterOperator:()=>vs,EvaluationRuleBooleanFilterOperator:()=>Rs,EvaluationRuleNullFilterOperator:()=>Ss,EvaluationRuleNumberFilterOperator:()=>ys,EvaluationRuleOptionsFilterOperator:()=>bs,EvaluationRuleStringFilterOperator:()=>fs,EvaluatorOutputScoreType:()=>ps,EvaluatorType:()=>ms,LegacyEvaluationObject:()=>xs,PromptVariableMappingSource:()=>_s});var ms={LlmAsJudge:"llm_as_judge",Code:"code"},gs={Python:"PYTHON",Typescript:"TYPESCRIPT"},_s={Input:"input",Output:"output",Metadata:"metadata",ToolCalls:"tool_calls",ExpectedOutput:"expected_output",ExperimentItemMetadata:"experiment_item_metadata"},ps={Numeric:"NUMERIC",Boolean:"BOOLEAN",Categorical:"CATEGORICAL"},fs={Equals:"=",Contains:"contains",DoesNotContain:"does not contain",StartsWith:"starts with",EndsWith:"ends with"},ys={Equals:"=",GreaterThan:">",LessThan:"<",GreaterThanOrEqual:">=",LessThanOrEqual:"<="},bs={AnyOf:"any of",NoneOf:"none of"},vs={AnyOf:"any of",NoneOf:"none of",AllOf:"all of"},Rs={Equals:"=",NotEquals:"<>"},Ss={IsNull:"is null",IsNotNull:"is not null"},xs={Trace:"trace",Span:"span",Generation:"generation",Event:"event",Agent:"agent",Tool:"tool",Chain:"chain",Retriever:"retriever",Evaluator:"evaluator",Embedding:"embedding",Guardrail:"guardrail",DatasetItem:"dataset_item"},Es={};O(Es,{BadRequestError:()=>Ee,ConflictError:()=>Tr,EvaluationAccessDeniedError:()=>le,EvaluationMethodNotAllowedError:()=>de,EvaluationNotFoundError:()=>Re,EvaluationUnauthorizedError:()=>ie,InternalServerError:()=>ce,PreconditionFailedError:()=>Co,PublicApiErrorCode:()=>Ls,TooManyRequestsError:()=>ue});var Ls={AuthenticationFailed:"authentication_failed",AccessDenied:"access_denied",InvalidRequest:"invalid_request",InvalidQuery:"invalid_query",InvalidBody:"invalid_body",ResourceNotFound:"resource_not_found",Conflict:"conflict",RateLimited:"rate_limited",MethodNotAllowed:"method_not_allowed",InternalError:"internal_error"},Ee=class Ot extends m{constructor(e,t){super({message:"BadRequestError",statusCode:400,body:e,rawResponse:t}),Object.setPrototypeOf(this,Ot.prototype)}},ie=class qt extends m{constructor(e,t){super({message:"EvaluationUnauthorizedError",statusCode:401,body:e,rawResponse:t}),Object.setPrototypeOf(this,qt.prototype)}},le=class ea extends m{constructor(e,t){super({message:"EvaluationAccessDeniedError",statusCode:403,body:e,rawResponse:t}),Object.setPrototypeOf(this,ea.prototype)}},Re=class ra extends m{constructor(e,t){super({message:"EvaluationNotFoundError",statusCode:404,body:e,rawResponse:t}),Object.setPrototypeOf(this,ra.prototype)}},de=class oa extends m{constructor(e,t){super({message:"EvaluationMethodNotAllowedError",statusCode:405,body:e,rawResponse:t}),Object.setPrototypeOf(this,oa.prototype)}},Tr=class ta extends m{constructor(e,t){super({message:"ConflictError",statusCode:409,body:e,rawResponse:t}),Object.setPrototypeOf(this,ta.prototype)}},Co=class aa extends m{constructor(e,t){super({message:"PreconditionFailedError",statusCode:412,body:e,rawResponse:t}),Object.setPrototypeOf(this,aa.prototype)}},ue=class na extends m{constructor(e,t){super({message:"TooManyRequestsError",statusCode:429,body:e,rawResponse:t}),Object.setPrototypeOf(this,na.prototype)}},ce=class sa extends m{constructor(e,t){super({message:"InternalServerError",statusCode:500,body:e,rawResponse:t}),Object.setPrototypeOf(this,sa.prototype)}};var Ts={};O(Ts,{EvaluatorChatMessageRole:()=>Ps,EvaluatorStatus:()=>Cs});var Ps={System:"system",User:"user",Assistant:"assistant"},Cs={Active:"active",Paused:"paused"};var As={};O(As,{FeedbackNotConfiguredError:()=>ia,FeedbackTargetType:()=>ks});var ks={Skill:"skill",McpTool:"mcp-tool",Cli:"cli",Docs:"docs",PublicApi:"public-api",Other:"other"},ia=class la extends m{constructor(e){super({message:"FeedbackNotConfiguredError",statusCode:409,rawResponse:e}),Object.setPrototypeOf(this,la.prototype)}},Is={};O(Is,{ServiceUnavailableError:()=>da});var da=class ua extends m{constructor(e){super({message:"ServiceUnavailableError",statusCode:503,rawResponse:e}),Object.setPrototypeOf(this,ua.prototype)}},Ns={};O(Ns,{ObservationType:()=>Ms});var Ms={Span:"SPAN",Generation:"GENERATION",Event:"EVENT",Agent:"AGENT",Tool:"TOOL",Chain:"CHAIN",Retriever:"RETRIEVER",Evaluator:"EVALUATOR",Embedding:"EMBEDDING",Guardrail:"GUARDRAIL"},Vs={};O(Vs,{CreateScoreSource:()=>Vo,metricsV1:()=>Us,observationsV1:()=>Bs,scoreV1:()=>ca});var Us={},Bs={},ca={};O(ca,{CreateScoreSource:()=>Vo});var Vo={Api:"API",Annotation:"ANNOTATION"},js={};O(js,{LlmAdapter:()=>zs});var zs={Anthropic:"anthropic",OpenAi:"openai",Azure:"azure",Bedrock:"bedrock",GoogleVertexAi:"google-vertex-ai",GoogleAiStudio:"google-ai-studio"},Ks={};O(Ks,{MediaContentType:()=>Xs});var Xs={ImagePng:"image/png",ImageJpeg:"image/jpeg",ImageJpg:"image/jpg",ImageWebp:"image/webp",ImageGif:"image/gif",ImageSvgXml:"image/svg+xml",ImageTiff:"image/tiff",ImageBmp:"image/bmp",ImageAvif:"image/avif",ImageHeic:"image/heic",AudioMpeg:"audio/mpeg",AudioMp3:"audio/mp3",AudioWav:"audio/wav",AudioOgg:"audio/ogg",AudioOga:"audio/oga",AudioAac:"audio/aac",AudioMp4:"audio/mp4",AudioFlac:"audio/flac",AudioOpus:"audio/opus",AudioWebm:"audio/webm",VideoMp4:"video/mp4",VideoWebm:"video/webm",VideoOgg:"video/ogg",VideoMpeg:"video/mpeg",VideoQuicktime:"video/quicktime",VideoXMsvideo:"video/x-msvideo",VideoXMatroska:"video/x-matroska",TextPlain:"text/plain",TextHtml:"text/html",TextCss:"text/css",TextCsv:"text/csv",TextMarkdown:"text/markdown",TextXPython:"text/x-python",ApplicationJavascript:"application/javascript",TextXTypescript:"text/x-typescript",ApplicationXYaml:"application/x-yaml",ApplicationPdf:"application/pdf",ApplicationMsword:"application/msword",ApplicationMsExcel:"application/vnd.ms-excel",ApplicationOpenxmlSpreadsheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ApplicationZip:"application/zip",ApplicationJson:"application/json",ApplicationXml:"application/xml",ApplicationOctetStream:"application/octet-stream",ApplicationOpenxmlWord:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",ApplicationOpenxmlPresentation:"application/vnd.openxmlformats-officedocument.presentationml.presentation",ApplicationRtf:"application/rtf",ApplicationXNdjson:"application/x-ndjson",ApplicationParquet:"application/vnd.apache.parquet",ApplicationGzip:"application/gzip",ApplicationXTar:"application/x-tar",ApplicationX7ZCompressed:"application/x-7z-compressed"};var Ds={};O(Ds,{ModelTokenizerId:()=>Gs});var Gs={Openai:"openai",Claude:"claude"};var Hs={};O(Hs,{MembershipRole:()=>Fs});var Fs={Owner:"OWNER",Admin:"ADMIN",Member:"MEMBER",Viewer:"VIEWER"};var $s={};O($s,{ChatMessageType:()=>Qs,CreateChatPromptType:()=>Js,CreateTextPromptType:()=>Zs,PlaceholderMessageType:()=>Ys,PromptType:()=>Ws});var Ws={Chat:"chat",Text:"text"},Qs={Chatmessage:"chatmessage"},Ys={Placeholder:"placeholder"},Js={Chat:"chat"},Zs={Text:"text"};var Os={};O(Os,{CreateScoreSource:()=>Vo});var k={};O(k,{AccessDeniedError:()=>xa,BadRequestError:()=>ba,ConflictError:()=>Aa,DashboardWidgetChartType:()=>ga,DashboardWidgetMetricAggregation:()=>_a,DashboardWidgetSortOrder:()=>pa,DashboardWidgetView:()=>ha,DashboardWidgetViewWithLegacy:()=>ma,InternalServerError:()=>Ma,MethodNotAllowedError:()=>Pa,NotFoundError:()=>La,PublicApiErrorCode:()=>ya,TooManyRequestsError:()=>Ia,UnauthorizedError:()=>Ra,dashboardWidgets:()=>wa,dashboards:()=>qs,errors:()=>fa});var wa={};O(wa,{DashboardWidgetChartType:()=>ga,DashboardWidgetMetricAggregation:()=>_a,DashboardWidgetSortOrder:()=>pa,DashboardWidgetView:()=>ha,DashboardWidgetViewWithLegacy:()=>ma});var ha={Observations:"observations",ScoresNumeric:"scores-numeric",ScoresBoolean:"scores-boolean",ScoresCategorical:"scores-categorical"},ma={Observations:"observations",ScoresNumeric:"scores-numeric",ScoresBoolean:"scores-boolean",ScoresCategorical:"scores-categorical",Traces:"traces"},ga={LineTimeSeries:"LINE_TIME_SERIES",AreaTimeSeries:"AREA_TIME_SERIES",BarTimeSeries:"BAR_TIME_SERIES",HorizontalBar:"HORIZONTAL_BAR",VerticalBar:"VERTICAL_BAR",Pie:"PIE",Number:"NUMBER",Histogram:"HISTOGRAM",PivotTable:"PIVOT_TABLE"},_a={Sum:"sum",Avg:"avg",Count:"count",Max:"max",Min:"min",P50:"p50",P75:"p75",P90:"p90",P95:"p95",P99:"p99",Histogram:"histogram",Uniq:"uniq"},pa={Asc:"ASC",Desc:"DESC"},qs={},fa={};O(fa,{AccessDeniedError:()=>xa,BadRequestError:()=>ba,ConflictError:()=>Aa,InternalServerError:()=>Ma,MethodNotAllowedError:()=>Pa,NotFoundError:()=>La,PublicApiErrorCode:()=>ya,TooManyRequestsError:()=>Ia,UnauthorizedError:()=>Ra});var ya={AuthenticationFailed:"authentication_failed",AccessDenied:"access_denied",InvalidRequest:"invalid_request",InvalidQuery:"invalid_query",InvalidBody:"invalid_body",ResourceNotFound:"resource_not_found",Conflict:"conflict",RateLimited:"rate_limited",MethodNotAllowed:"method_not_allowed",InternalError:"internal_error"},ba=class va extends m{constructor(e,t){super({message:"BadRequestError",statusCode:400,body:e,rawResponse:t}),Object.setPrototypeOf(this,va.prototype)}},Ra=class Sa extends m{constructor(e,t){super({message:"UnauthorizedError",statusCode:401,body:e,rawResponse:t}),Object.setPrototypeOf(this,Sa.prototype)}},xa=class Ea extends m{constructor(e,t){super({message:"AccessDeniedError",statusCode:403,body:e,rawResponse:t}),Object.setPrototypeOf(this,Ea.prototype)}},La=class Ta extends m{constructor(e,t){super({message:"NotFoundError",statusCode:404,body:e,rawResponse:t}),Object.setPrototypeOf(this,Ta.prototype)}},Pa=class Ca extends m{constructor(e,t){super({message:"MethodNotAllowedError",statusCode:405,body:e,rawResponse:t}),Object.setPrototypeOf(this,Ca.prototype)}},Aa=class ka extends m{constructor(e,t){super({message:"ConflictError",statusCode:409,body:e,rawResponse:t}),Object.setPrototypeOf(this,ka.prototype)}},Ia=class Na extends m{constructor(e,t){super({message:"TooManyRequestsError",statusCode:429,body:e,rawResponse:t}),Object.setPrototypeOf(this,Na.prototype)}},Ma=class Va extends m{constructor(e,t){super({message:"InternalServerError",statusCode:500,body:e,rawResponse:t}),Object.setPrototypeOf(this,Va.prototype)}},ei={};O(ei,{pagination:()=>ri});var ri={};function x(...r){let e={};for(let[t,a]of r.filter(s=>s!=null).flatMap(s=>Object.entries(s)))a!=null?e[t]=a:t in e&&delete e[t];return e}function T(...r){let e={};for(let[t,a]of r.filter(s=>s!=null).flatMap(s=>Object.entries(s)))a!=null&&(e[t]=a);return e}var oi={arrayFormat:"indices",encode:!0};function jt(r,e){if(r===void 0||r===null)return"";let t=String(r);return e?encodeURIComponent(t):t}function Ao(r,e="",t){let a=[];for(let[s,i]of Object.entries(r)){let l=e?`${e}[${s}]`:s;if(i!==void 0)if(Array.isArray(i)){if(i.length===0)continue;for(let u=0;u<i.length;u++){let c=i[u];if(c!==void 0)if(typeof c=="object"&&!Array.isArray(c)&&c!==null){let w=t.arrayFormat==="indices"?`${l}[${u}]`:l;a.push(...Ao(c,w,t))}else{let w=t.arrayFormat==="indices"?`${l}[${u}]`:l,d=t.encode?encodeURIComponent(w):w;a.push(`${d}=${jt(c,t.encode)}`)}}}else if(typeof i=="object"&&i!==null){if(Object.keys(i).length===0)continue;a.push(...Ao(i,l,t))}else{let u=t.encode?encodeURIComponent(l):l;a.push(`${u}=${jt(i,t.encode)}`)}}return a}function Ua(r,e){return r==null||typeof r!="object"?"":Ao(r,"",{...oi,...e}).join("&")}function ti(r,e){let t=Ua(e,{arrayFormat:"repeat"});return t?`${r}?${t}`:r}function ai(r){let e={get bodyUsed(){return r.bodyUsed},stream:()=>r.body,arrayBuffer:r.arrayBuffer.bind(r),blob:r.blob.bind(r)};return"bytes"in r&&typeof r.bytes=="function"&&(e.bytes=r.bytes.bind(r)),e}function ni(r){return r.body!=null}async function Ba(r,e){if(!ni(r))return;switch(e){case"binary-response":return ai(r);case"blob":return await r.blob();case"arrayBuffer":return await r.arrayBuffer();case"sse":return r.body;case"streaming":return r.body;case"text":return await r.text()}let t=await r.text();if(t.length>0)try{return Po(t)}catch{return{ok:!1,error:{reason:"non-json",statusCode:r.status,rawBody:t}}}}async function si(r){var e,t,a;let s=(e=r.headers.get("Content-Type"))==null?void 0:e.toLowerCase();if(s==null||s.length===0)return Ba(r);switch(s.indexOf(";")!==-1&&(s=(a=(t=s.split(";")[0])==null?void 0:t.trim())!=null?a:""),s){case"application/hal+json":case"application/json":case"application/ld+json":case"application/problem+json":case"application/vnd.api+json":case"text/json":let i=await r.text();return i.length>0?Po(i):void 0;default:if(s.startsWith("application/vnd.")&&s.endsWith("+json")){let l=await r.text();return l.length>0?Po(l):void 0}return await r.text()}}async function ii(){return fetch}async function li({body:r,type:e}){return e.includes("json")?Mo(r):r}var di="timeout";function ui(r){let e=new AbortController,t=setTimeout(()=>e.abort(di),r);return{signal:e.signal,abortId:t}}function ci(...r){let e=r.length===1&&Array.isArray(r[0])?r[0]:r,t=new AbortController;for(let a of e){if(a.aborted){t.abort(a?.reason);break}a.addEventListener("abort",()=>t.abort(a?.reason),{signal:t.signal})}return t.signal}var wi=async(r,e,t,a,s,i,l,u,c)=>{let w=[],d;if(i!=null){let{signal:_,abortId:h}=ui(i);d=h,w.push(_)}l!=null&&w.push(l);let o=ci(w),n=await r(e,{method:t,headers:a,body:s,signal:o,credentials:u?"include":void 0,duplex:c});return d!=null&&clearTimeout(d),n},Pr;typeof globalThis.Headers<"u"?Pr=globalThis.Headers:Pr=class ja{constructor(e){if(this.headers=new Map,e)if(e instanceof ja)e.forEach((t,a)=>this.append(a,t));else if(Array.isArray(e))for(let[t,a]of e)if(typeof t=="string"&&typeof a=="string")this.append(t,a);else throw new TypeError("Each header entry must be a [string, string] tuple");else for(let[t,a]of Object.entries(e))if(typeof a=="string")this.append(t,a);else throw new TypeError("Header values must be strings")}append(e,t){let a=e.toLowerCase(),s=this.headers.get(a)||[];this.headers.set(a,[...s,t])}delete(e){let t=e.toLowerCase();this.headers.delete(t)}get(e){let t=e.toLowerCase(),a=this.headers.get(t);return a?a.join(", "):null}has(e){let t=e.toLowerCase();return this.headers.has(t)}set(e,t){let a=e.toLowerCase();this.headers.set(a,[t])}forEach(e,t){let a=t?e.bind(t):e;this.headers.forEach((s,i)=>a(s.join(", "),i,this))}getSetCookie(){return this.headers.get("set-cookie")||[]}*entries(){for(let[e,t]of this.headers.entries())yield[e,t.join(", ")]}*keys(){yield*this.headers.keys()}*values(){for(let e of this.headers.values())yield e.join(", ")}[Symbol.iterator](){return this.entries()}};var zt={headers:new Pr,redirected:!1,status:499,statusText:"Client Closed Request",type:"error",url:""},Kt={headers:new Pr,redirected:!1,status:0,statusText:"Unknown Error",type:"error",url:""};function Xt(r){return{headers:r.headers,redirected:r.redirected,status:r.status,statusText:r.statusText,type:r.type,url:r.url}}var hi=1e3,Lr=6e4,mi=2,za=.2;function gi(r){let e=1+Math.random()*za;return r*e}function _i(r){let e=1+(Math.random()-.5)*za;return r*e}function pi(r,e){let t=r.headers.get("Retry-After");if(t){let s=parseInt(t,10);if(!isNaN(s)&&s>0)return Math.min(s*1e3,Lr);let i=new Date(t);if(!isNaN(i.getTime())){let l=i.getTime()-Date.now();if(l>0)return Math.min(Math.max(l,0),Lr)}}let a=r.headers.get("X-RateLimit-Reset");if(a){let s=parseInt(a,10);if(!isNaN(s)){let i=s*1e3-Date.now();if(i>0)return gi(Math.min(i,Lr))}}return _i(Math.min(hi*Math.pow(2,e),Lr))}async function fi(r,e=mi){let t=await r();for(let a=0;a<e&&([408,429].includes(t.status)||t.status>=500);++a){let s=pi(t,a);await new Promise(i=>setTimeout(i,s)),t=await r()}return t}var g={get:async r=>typeof r=="function"?r():r};async function yi(r){let e={};if(r.body!==void 0&&r.contentType!=null&&(e["Content-Type"]=r.contentType),r.headers==null)return e;for(let[t,a]of Object.entries(r.headers)){let s=await g.get(a);if(typeof s=="string"){e[t]=s;continue}s!=null&&(e[t]=`${s}`)}return e}async function bi(r){let e=ti(r.url,r.queryParameters),t=await li({body:r.body,type:r.requestType==="json"?"json":"other"}),a=await ii();try{let s=await fi(async()=>wi(a,e,r.method,await yi(r),t,r.timeoutMs,r.abortSignal,r.withCredentials,r.duplex),r.maxRetries);return s.status>=200&&s.status<400?{ok:!0,body:await Ba(s,r.responseType),headers:s.headers,rawResponse:Xt(s)}:{ok:!1,error:{reason:"status-code",statusCode:s.status,body:await si(s)},rawResponse:Xt(s)}}catch(s){return r.abortSignal!=null&&r.abortSignal.aborted?{ok:!1,error:{reason:"unknown",errorMessage:"The user aborted a request"},rawResponse:zt}:s instanceof Error&&s.name==="AbortError"?{ok:!1,error:{reason:"timeout"},rawResponse:zt}:s instanceof Error?{ok:!1,error:{reason:"unknown",errorMessage:s.message},rawResponse:Kt}:{ok:!1,error:{reason:"unknown",errorMessage:Mo(s)},rawResponse:Kt}}}var P=bi,C=class Ve extends Promise{constructor(e){super(t=>{t(void 0)}),this.innerPromise=e}static fromFunction(e,...t){return new Ve(e(...t))}static interceptFunction(e){return(...t)=>Ve.fromPromise(e(...t))}static fromPromise(e){return new Ve(e)}static fromExecutor(e){let t=new Promise(e);return new Ve(t)}static fromResult(e){let t=Promise.resolve(e);return new Ve(t)}unwrap(){return this.unwrappedPromise||(this.unwrappedPromise=this.innerPromise.then(({data:e})=>e)),this.unwrappedPromise}then(e,t){return this.unwrap().then(e,t)}catch(e){return this.unwrap().catch(e)}finally(e){return this.unwrap().finally(e)}async withRawResponse(){return await this.innerPromise}},E={};O(E,{join:()=>vi,toQueryString:()=>Ua});function vi(r,...e){if(!r)return"";if(e.length===0)return r;if(r.includes("://")){let t;try{t=new URL(r)}catch{return Dt(r,...e)}let a=e[e.length-1],s=a&&a.endsWith("/");for(let i of e){let l=Xa(i);l&&(t.pathname=Ka(t.pathname,l))}return s&&!t.pathname.endsWith("/")&&(t.pathname+="/"),t.toString()}return Dt(r,...e)}function Dt(r,...e){if(e.length===0)return r;let t=r,a=e[e.length-1],s=a&&a.endsWith("/");for(let i of e){let l=Xa(i);l&&(t=Ka(t,l))}return s&&!t.endsWith("/")&&(t+="/"),t}function Ka(r,e){return r.endsWith("/")?r+e:r+"/"+e}function Xa(r){if(!r)return r;let e=0,t=r.length;return r.startsWith("/")&&(e=1),r.endsWith("/")&&(t=r.length-1),e===0&&t===r.length?r:r.slice(e,t)}function Ri(r){let e=atob(r);return Uint8Array.from(e,t=>t.codePointAt(0))}function Si(r){let e=String.fromCodePoint(...r);return btoa(e)}function xi(r){if(typeof Buffer<"u")return Buffer.from(r,"utf8").toString("base64");let e=new TextEncoder().encode(r);return Si(e)}function Ei(r){if(typeof Buffer<"u")return Buffer.from(r,"base64").toString("utf8");let e=Ri(r);return new TextDecoder().decode(e)}var Li=/^Basic /i,G={toAuthorizationHeader:r=>r==null?void 0:`Basic ${xi(`${r.username}:${r.password}`)}`,fromAuthorizationHeader:r=>{let e=r.replace(Li,""),t=Ei(e),[a,s]=t.split(":",2);if(a==null||s==null)throw new Error("Invalid basic auth");return{username:a,password:s}}},Ti=class{constructor(r){this._options=r}listQueues(r={},e){return C.fromPromise(this.__listQueues(r,e))}async __listQueues(r={},e){var t,a,s,i,l,u,c,w;let{page:d,limit:o}=r,n={};d!=null&&(n.page=d.toString()),o!=null&&(n.limit=o.toString());let _=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),h=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/annotation-queues"),method:"GET",headers:_,queryParameters:{...n,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new y(h.error.body,h.rawResponse);case 401:throw new b(h.error.body,h.rawResponse);case 403:throw new v(h.error.body,h.rawResponse);case 405:throw new S(h.error.body,h.rawResponse);case 404:throw new R(h.error.body,h.rawResponse);default:throw new m({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}switch(h.error.reason){case"non-json":throw new m({statusCode:h.error.statusCode,body:h.error.rawBody,rawResponse:h.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/annotation-queues.");case"unknown":throw new m({message:h.error.errorMessage,rawResponse:h.rawResponse})}}createQueue(r,e){return C.fromPromise(this.__createQueue(r,e))}async __createQueue(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/annotation-queues"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/annotation-queues.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getQueue(r,e){return C.fromPromise(this.__getQueue(r,e))}async __getQueue(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/annotation-queues/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/annotation-queues/{queueId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}listQueueItems(r,e={},t){return C.fromPromise(this.__listQueueItems(r,e,t))}async __listQueueItems(r,e={},t){var a,s,i,l,u,c,w,d;let{status:o,page:n,limit:_}=e,h={};o!=null&&(h.status=o),n!=null&&(h.page=n.toString()),_!=null&&(h.limit=_.toString());let p=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),f=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/annotation-queues/${encodeURIComponent(r)}/items`),method:"GET",headers:p,queryParameters:{...h,...t?.queryParams},timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 400:throw new y(f.error.body,f.rawResponse);case 401:throw new b(f.error.body,f.rawResponse);case 403:throw new v(f.error.body,f.rawResponse);case 405:throw new S(f.error.body,f.rawResponse);case 404:throw new R(f.error.body,f.rawResponse);default:throw new m({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new m({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/annotation-queues/{queueId}/items.");case"unknown":throw new m({message:f.error.errorMessage,rawResponse:f.rawResponse})}}getQueueItem(r,e,t){return C.fromPromise(this.__getQueueItem(r,e,t))}async __getQueueItem(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/annotation-queues/${encodeURIComponent(r)}/items/${encodeURIComponent(e)}`),method:"GET",headers:o,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/annotation-queues/{queueId}/items/{itemId}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}createQueueItem(r,e,t){return C.fromPromise(this.__createQueueItem(r,e,t))}async __createQueueItem(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/annotation-queues/${encodeURIComponent(r)}/items`),method:"POST",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/annotation-queues/{queueId}/items.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}updateQueueItem(r,e,t,a){return C.fromPromise(this.__updateQueueItem(r,e,t,a))}async __updateQueueItem(r,e,t,a){var s,i,l,u,c,w,d,o;let n=x((s=this._options)==null?void 0:s.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(l=a?.xLangfuseSdkName)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(c=a?.xLangfuseSdkVersion)!=null?c:(u=this._options)==null?void 0:u.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(d=a?.xLangfusePublicKey)!=null?d:(w=this._options)==null?void 0:w.xLangfusePublicKey}),a?.headers),_=await P({url:E.join((o=await g.get(this._options.baseUrl))!=null?o:await g.get(this._options.environment),`/api/public/annotation-queues/${encodeURIComponent(r)}/items/${encodeURIComponent(e)}`),method:"PATCH",headers:n,contentType:"application/json",queryParameters:a?.queryParams,requestType:"json",body:t,timeoutMs:a?.timeoutInSeconds!=null?a.timeoutInSeconds*1e3:6e4,maxRetries:a?.maxRetries,abortSignal:a?.abortSignal});if(_.ok)return{data:_.body,rawResponse:_.rawResponse};if(_.error.reason==="status-code")switch(_.error.statusCode){case 400:throw new y(_.error.body,_.rawResponse);case 401:throw new b(_.error.body,_.rawResponse);case 403:throw new v(_.error.body,_.rawResponse);case 405:throw new S(_.error.body,_.rawResponse);case 404:throw new R(_.error.body,_.rawResponse);default:throw new m({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse})}switch(_.error.reason){case"non-json":throw new m({statusCode:_.error.statusCode,body:_.error.rawBody,rawResponse:_.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PATCH /api/public/annotation-queues/{queueId}/items/{itemId}.");case"unknown":throw new m({message:_.error.errorMessage,rawResponse:_.rawResponse})}}deleteQueueItem(r,e,t){return C.fromPromise(this.__deleteQueueItem(r,e,t))}async __deleteQueueItem(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/annotation-queues/${encodeURIComponent(r)}/items/${encodeURIComponent(e)}`),method:"DELETE",headers:o,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/annotation-queues/{queueId}/items/{itemId}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}createQueueAssignment(r,e,t){return C.fromPromise(this.__createQueueAssignment(r,e,t))}async __createQueueAssignment(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/annotation-queues/${encodeURIComponent(r)}/assignments`),method:"POST",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/annotation-queues/{queueId}/assignments.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}deleteQueueAssignment(r,e,t){return C.fromPromise(this.__deleteQueueAssignment(r,e,t))}async __deleteQueueAssignment(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/annotation-queues/${encodeURIComponent(r)}/assignments`),method:"DELETE",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/annotation-queues/{queueId}/assignments.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Pi=class{constructor(r){this._options=r}getBlobStorageIntegrations(r){return C.fromPromise(this.__getBlobStorageIntegrations(r))}async __getBlobStorageIntegrations(r){var e,t,a,s,i,l,u,c;let w=x((e=this._options)==null?void 0:e.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(a=r?.xLangfuseSdkName)!=null?a:(t=this._options)==null?void 0:t.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(i=r?.xLangfuseSdkVersion)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(u=r?.xLangfusePublicKey)!=null?u:(l=this._options)==null?void 0:l.xLangfusePublicKey}),r?.headers),d=await P({url:E.join((c=await g.get(this._options.baseUrl))!=null?c:await g.get(this._options.environment),"/api/public/integrations/blob-storage"),method:"GET",headers:w,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new y(d.error.body,d.rawResponse);case 401:throw new b(d.error.body,d.rawResponse);case 403:throw new v(d.error.body,d.rawResponse);case 405:throw new S(d.error.body,d.rawResponse);case 404:throw new R(d.error.body,d.rawResponse);default:throw new m({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new m({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/integrations/blob-storage.");case"unknown":throw new m({message:d.error.errorMessage,rawResponse:d.rawResponse})}}upsertBlobStorageIntegration(r,e){return C.fromPromise(this.__upsertBlobStorageIntegration(r,e))}async __upsertBlobStorageIntegration(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/integrations/blob-storage"),method:"PUT",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PUT /api/public/integrations/blob-storage.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getBlobStorageIntegrationStatus(r,e){return C.fromPromise(this.__getBlobStorageIntegrationStatus(r,e))}async __getBlobStorageIntegrationStatus(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/integrations/blob-storage/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/integrations/blob-storage/{id}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteBlobStorageIntegration(r,e){return C.fromPromise(this.__deleteBlobStorageIntegration(r,e))}async __deleteBlobStorageIntegration(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/integrations/blob-storage/${encodeURIComponent(r)}`),method:"DELETE",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/integrations/blob-storage/{id}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Ci=class{constructor(r){this._options=r}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/comments"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/comments.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}get(r={},e){return C.fromPromise(this.__get(r,e))}async __get(r={},e){var t,a,s,i,l,u,c,w;let{page:d,limit:o,objectType:n,objectId:_,authorUserId:h}=r,p={};d!=null&&(p.page=d.toString()),o!=null&&(p.limit=o.toString()),n!=null&&(p.objectType=n),_!=null&&(p.objectId=_),h!=null&&(p.authorUserId=h);let f=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),A=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/comments"),method:"GET",headers:f,queryParameters:{...p,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(A.ok)return{data:A.body,rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 400:throw new y(A.error.body,A.rawResponse);case 401:throw new b(A.error.body,A.rawResponse);case 403:throw new v(A.error.body,A.rawResponse);case 405:throw new S(A.error.body,A.rawResponse);case 404:throw new R(A.error.body,A.rawResponse);default:throw new m({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}switch(A.error.reason){case"non-json":throw new m({statusCode:A.error.statusCode,body:A.error.rawBody,rawResponse:A.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/comments.");case"unknown":throw new m({message:A.error.errorMessage,rawResponse:A.rawResponse})}}getById(r,e){return C.fromPromise(this.__getById(r,e))}async __getById(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/comments/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/comments/{commentId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Ai=class{constructor(r){this._options=r}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/dataset-items"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/dataset-items.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}get(r,e){return C.fromPromise(this.__get(r,e))}async __get(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/dataset-items/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/dataset-items/{id}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}list(r={},e){return C.fromPromise(this.__list(r,e))}async __list(r={},e){var t,a,s,i,l,u,c,w;let{datasetName:d,sourceTraceId:o,sourceObservationId:n,version:_,page:h,limit:p}=r,f={};d!=null&&(f.datasetName=d),o!=null&&(f.sourceTraceId=o),n!=null&&(f.sourceObservationId=n),_!=null&&(f.version=_),h!=null&&(f.page=h.toString()),p!=null&&(f.limit=p.toString());let A=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),I=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/dataset-items"),method:"GET",headers:A,queryParameters:{...f,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(I.ok)return{data:I.body,rawResponse:I.rawResponse};if(I.error.reason==="status-code")switch(I.error.statusCode){case 400:throw new y(I.error.body,I.rawResponse);case 401:throw new b(I.error.body,I.rawResponse);case 403:throw new v(I.error.body,I.rawResponse);case 405:throw new S(I.error.body,I.rawResponse);case 404:throw new R(I.error.body,I.rawResponse);default:throw new m({statusCode:I.error.statusCode,body:I.error.body,rawResponse:I.rawResponse})}switch(I.error.reason){case"non-json":throw new m({statusCode:I.error.statusCode,body:I.error.rawBody,rawResponse:I.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/dataset-items.");case"unknown":throw new m({message:I.error.errorMessage,rawResponse:I.rawResponse})}}delete(r,e){return C.fromPromise(this.__delete(r,e))}async __delete(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/dataset-items/${encodeURIComponent(r)}`),method:"DELETE",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/dataset-items/{id}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},ki=class{constructor(r){this._options=r}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/dataset-run-items"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/dataset-run-items.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}list(r,e){return C.fromPromise(this.__list(r,e))}async __list(r,e){var t,a,s,i,l,u,c,w;let{datasetId:d,runName:o,page:n,limit:_}=r,h={};h.datasetId=d,h.runName=o,n!=null&&(h.page=n.toString()),_!=null&&(h.limit=_.toString());let p=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),f=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/dataset-run-items"),method:"GET",headers:p,queryParameters:{...h,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 400:throw new y(f.error.body,f.rawResponse);case 401:throw new b(f.error.body,f.rawResponse);case 403:throw new v(f.error.body,f.rawResponse);case 405:throw new S(f.error.body,f.rawResponse);case 404:throw new R(f.error.body,f.rawResponse);default:throw new m({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new m({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/dataset-run-items.");case"unknown":throw new m({message:f.error.errorMessage,rawResponse:f.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Ii=class{constructor(r){this._options=r}list(r={},e){return C.fromPromise(this.__list(r,e))}async __list(r={},e){var t,a,s,i,l,u,c,w;let{page:d,limit:o}=r,n={};d!=null&&(n.page=d.toString()),o!=null&&(n.limit=o.toString());let _=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),h=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/v2/datasets"),method:"GET",headers:_,queryParameters:{...n,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new y(h.error.body,h.rawResponse);case 401:throw new b(h.error.body,h.rawResponse);case 403:throw new v(h.error.body,h.rawResponse);case 405:throw new S(h.error.body,h.rawResponse);case 404:throw new R(h.error.body,h.rawResponse);default:throw new m({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}switch(h.error.reason){case"non-json":throw new m({statusCode:h.error.statusCode,body:h.error.rawBody,rawResponse:h.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/datasets.");case"unknown":throw new m({message:h.error.errorMessage,rawResponse:h.rawResponse})}}get(r,e){return C.fromPromise(this.__get(r,e))}async __get(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/v2/datasets/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/datasets/{datasetName}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/v2/datasets"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/v2/datasets.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getRun(r,e,t){return C.fromPromise(this.__getRun(r,e,t))}async __getRun(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/datasets/${encodeURIComponent(r)}/runs/${encodeURIComponent(e)}`),method:"GET",headers:o,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/datasets/{datasetName}/runs/{runName}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}deleteRun(r,e,t){return C.fromPromise(this.__deleteRun(r,e,t))}async __deleteRun(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/datasets/${encodeURIComponent(r)}/runs/${encodeURIComponent(e)}`),method:"DELETE",headers:o,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/datasets/{datasetName}/runs/{runName}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}getRuns(r,e={},t){return C.fromPromise(this.__getRuns(r,e,t))}async __getRuns(r,e={},t){var a,s,i,l,u,c,w,d;let{page:o,limit:n}=e,_={};o!=null&&(_.page=o.toString()),n!=null&&(_.limit=n.toString());let h=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),p=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/datasets/${encodeURIComponent(r)}/runs`),method:"GET",headers:h,queryParameters:{..._,...t?.queryParams},timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(p.ok)return{data:p.body,rawResponse:p.rawResponse};if(p.error.reason==="status-code")switch(p.error.statusCode){case 400:throw new y(p.error.body,p.rawResponse);case 401:throw new b(p.error.body,p.rawResponse);case 403:throw new v(p.error.body,p.rawResponse);case 405:throw new S(p.error.body,p.rawResponse);case 404:throw new R(p.error.body,p.rawResponse);default:throw new m({statusCode:p.error.statusCode,body:p.error.body,rawResponse:p.rawResponse})}switch(p.error.reason){case"non-json":throw new m({statusCode:p.error.statusCode,body:p.error.rawBody,rawResponse:p.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/datasets/{datasetName}/runs.");case"unknown":throw new m({message:p.error.errorMessage,rawResponse:p.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Ni=class{constructor(r){this._options=r}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/v2/evaluation-rules"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new Ee(o.error.body,o.rawResponse);case 401:throw new ie(o.error.body,o.rawResponse);case 403:throw new le(o.error.body,o.rawResponse);case 404:throw new Re(o.error.body,o.rawResponse);case 405:throw new de(o.error.body,o.rawResponse);case 409:throw new Tr(o.error.body,o.rawResponse);case 429:throw new ue(o.error.body,o.rawResponse);case 500:throw new ce(o.error.body,o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/v2/evaluation-rules.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}list(r={},e){return C.fromPromise(this.__list(r,e))}async __list(r={},e){var t,a,s,i,l,u,c,w;let{limit:d,cursor:o}=r,n={};d!=null&&(n.limit=d.toString()),o!=null&&(n.cursor=o);let _=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),h=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/v2/evaluation-rules"),method:"GET",headers:_,queryParameters:{...n,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new Ee(h.error.body,h.rawResponse);case 401:throw new ie(h.error.body,h.rawResponse);case 403:throw new le(h.error.body,h.rawResponse);case 405:throw new de(h.error.body,h.rawResponse);case 429:throw new ue(h.error.body,h.rawResponse);case 500:throw new ce(h.error.body,h.rawResponse);case 400:throw new y(h.error.body,h.rawResponse);case 401:throw new b(h.error.body,h.rawResponse);case 403:throw new v(h.error.body,h.rawResponse);case 405:throw new S(h.error.body,h.rawResponse);case 404:throw new R(h.error.body,h.rawResponse);default:throw new m({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}switch(h.error.reason){case"non-json":throw new m({statusCode:h.error.statusCode,body:h.error.rawBody,rawResponse:h.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/evaluation-rules.");case"unknown":throw new m({message:h.error.errorMessage,rawResponse:h.rawResponse})}}get(r,e){return C.fromPromise(this.__get(r,e))}async __get(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/v2/evaluation-rules/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new ie(o.error.body,o.rawResponse);case 403:throw new le(o.error.body,o.rawResponse);case 404:throw new Re(o.error.body,o.rawResponse);case 405:throw new de(o.error.body,o.rawResponse);case 429:throw new ue(o.error.body,o.rawResponse);case 500:throw new ce(o.error.body,o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/evaluation-rules/{evaluationRuleId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}update(r,e,t){return C.fromPromise(this.__update(r,e,t))}async __update(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/v2/evaluation-rules/${encodeURIComponent(r)}`),method:"PATCH",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new Ee(n.error.body,n.rawResponse);case 401:throw new ie(n.error.body,n.rawResponse);case 403:throw new le(n.error.body,n.rawResponse);case 404:throw new Re(n.error.body,n.rawResponse);case 405:throw new de(n.error.body,n.rawResponse);case 409:throw new Tr(n.error.body,n.rawResponse);case 429:throw new ue(n.error.body,n.rawResponse);case 500:throw new ce(n.error.body,n.rawResponse);case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PATCH /api/public/v2/evaluation-rules/{evaluationRuleId}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}delete(r,e){return C.fromPromise(this.__delete(r,e))}async __delete(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/v2/evaluation-rules/${encodeURIComponent(r)}`),method:"DELETE",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new ie(o.error.body,o.rawResponse);case 403:throw new le(o.error.body,o.rawResponse);case 404:throw new Re(o.error.body,o.rawResponse);case 405:throw new de(o.error.body,o.rawResponse);case 429:throw new ue(o.error.body,o.rawResponse);case 500:throw new ce(o.error.body,o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/v2/evaluation-rules/{evaluationRuleId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Mi=class{constructor(r){this._options=r}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/v2/evaluators"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new Ee(o.error.body,o.rawResponse);case 401:throw new ie(o.error.body,o.rawResponse);case 403:throw new le(o.error.body,o.rawResponse);case 405:throw new de(o.error.body,o.rawResponse);case 412:throw new Co(o.error.body,o.rawResponse);case 429:throw new ue(o.error.body,o.rawResponse);case 500:throw new ce(o.error.body,o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/v2/evaluators.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}list(r={},e){return C.fromPromise(this.__list(r,e))}async __list(r={},e){var t,a,s,i,l,u,c,w;let{limit:d,cursor:o}=r,n={};d!=null&&(n.limit=d.toString()),o!=null&&(n.cursor=o);let _=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),h=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/v2/evaluators"),method:"GET",headers:_,queryParameters:{...n,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new Ee(h.error.body,h.rawResponse);case 401:throw new ie(h.error.body,h.rawResponse);case 403:throw new le(h.error.body,h.rawResponse);case 405:throw new de(h.error.body,h.rawResponse);case 429:throw new ue(h.error.body,h.rawResponse);case 500:throw new ce(h.error.body,h.rawResponse);case 400:throw new y(h.error.body,h.rawResponse);case 401:throw new b(h.error.body,h.rawResponse);case 403:throw new v(h.error.body,h.rawResponse);case 405:throw new S(h.error.body,h.rawResponse);case 404:throw new R(h.error.body,h.rawResponse);default:throw new m({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}switch(h.error.reason){case"non-json":throw new m({statusCode:h.error.statusCode,body:h.error.rawBody,rawResponse:h.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/evaluators.");case"unknown":throw new m({message:h.error.errorMessage,rawResponse:h.rawResponse})}}get(r,e){return C.fromPromise(this.__get(r,e))}async __get(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/v2/evaluators/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new ie(o.error.body,o.rawResponse);case 403:throw new le(o.error.body,o.rawResponse);case 404:throw new Re(o.error.body,o.rawResponse);case 405:throw new de(o.error.body,o.rawResponse);case 429:throw new ue(o.error.body,o.rawResponse);case 500:throw new ce(o.error.body,o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/evaluators/{evaluatorId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}update(r,e,t){return C.fromPromise(this.__update(r,e,t))}async __update(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/v2/evaluators/${encodeURIComponent(r)}`),method:"PATCH",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new Ee(n.error.body,n.rawResponse);case 401:throw new ie(n.error.body,n.rawResponse);case 403:throw new le(n.error.body,n.rawResponse);case 404:throw new Re(n.error.body,n.rawResponse);case 405:throw new de(n.error.body,n.rawResponse);case 409:throw new Tr(n.error.body,n.rawResponse);case 412:throw new Co(n.error.body,n.rawResponse);case 429:throw new ue(n.error.body,n.rawResponse);case 500:throw new ce(n.error.body,n.rawResponse);case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PATCH /api/public/v2/evaluators/{evaluatorId}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}delete(r,e){return C.fromPromise(this.__delete(r,e))}async __delete(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/v2/evaluators/${encodeURIComponent(r)}`),method:"DELETE",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 401:throw new ie(o.error.body,o.rawResponse);case 403:throw new le(o.error.body,o.rawResponse);case 404:throw new Re(o.error.body,o.rawResponse);case 405:throw new de(o.error.body,o.rawResponse);case 429:throw new ue(o.error.body,o.rawResponse);case 500:throw new ce(o.error.body,o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/v2/evaluators/{evaluatorId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}listVersions(r,e={},t){return C.fromPromise(this.__listVersions(r,e,t))}async __listVersions(r,e={},t){var a,s,i,l,u,c,w,d;let{limit:o,cursor:n}=e,_={};o!=null&&(_.limit=o.toString()),n!=null&&(_.cursor=n);let h=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),p=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/v2/evaluators/${encodeURIComponent(r)}/versions`),method:"GET",headers:h,queryParameters:{..._,...t?.queryParams},timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(p.ok)return{data:p.body,rawResponse:p.rawResponse};if(p.error.reason==="status-code")switch(p.error.statusCode){case 400:throw new Ee(p.error.body,p.rawResponse);case 401:throw new ie(p.error.body,p.rawResponse);case 403:throw new le(p.error.body,p.rawResponse);case 404:throw new Re(p.error.body,p.rawResponse);case 405:throw new de(p.error.body,p.rawResponse);case 429:throw new ue(p.error.body,p.rawResponse);case 500:throw new ce(p.error.body,p.rawResponse);case 400:throw new y(p.error.body,p.rawResponse);case 401:throw new b(p.error.body,p.rawResponse);case 403:throw new v(p.error.body,p.rawResponse);case 405:throw new S(p.error.body,p.rawResponse);case 404:throw new R(p.error.body,p.rawResponse);default:throw new m({statusCode:p.error.statusCode,body:p.error.body,rawResponse:p.rawResponse})}switch(p.error.reason){case"non-json":throw new m({statusCode:p.error.statusCode,body:p.error.rawBody,rawResponse:p.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/evaluators/{evaluatorId}/versions.");case"unknown":throw new m({message:p.error.errorMessage,rawResponse:p.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Vi=class{constructor(r){this._options=r}list(r,e){return C.fromPromise(this.__list(r,e))}async __list(r,e){var t,a,s,i,l,u,c,w;let{fields:d,limit:o,scoreLimit:n,cursor:_,fromStartTime:h,toStartTime:p,id:f,name:A,datasetId:I,filter:V}=r,H={};d!=null&&(H.fields=d),o!=null&&(H.limit=o.toString()),n!=null&&(H.scoreLimit=n.toString()),_!=null&&(H.cursor=_),H.fromStartTime=h,p!=null&&(H.toStartTime=p),f!=null&&(H.id=f),A!=null&&(H.name=A),I!=null&&(H.datasetId=I),V!=null&&(H.filter=V);let D=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),B=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/experiments"),method:"GET",headers:D,queryParameters:{...H,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(B.ok)return{data:B.body,rawResponse:B.rawResponse};if(B.error.reason==="status-code")switch(B.error.statusCode){case 400:throw new y(B.error.body,B.rawResponse);case 401:throw new b(B.error.body,B.rawResponse);case 403:throw new v(B.error.body,B.rawResponse);case 405:throw new S(B.error.body,B.rawResponse);case 404:throw new R(B.error.body,B.rawResponse);default:throw new m({statusCode:B.error.statusCode,body:B.error.body,rawResponse:B.rawResponse})}switch(B.error.reason){case"non-json":throw new m({statusCode:B.error.statusCode,body:B.error.rawBody,rawResponse:B.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/experiments.");case"unknown":throw new m({message:B.error.errorMessage,rawResponse:B.rawResponse})}}listItems(r,e){return C.fromPromise(this.__listItems(r,e))}async __listItems(r,e){var t,a,s,i,l,u,c,w;let{fields:d,limit:o,scoreLimit:n,cursor:_,fromStartTime:h,toStartTime:p,experimentId:f,experimentName:A,experimentItemId:I,datasetId:V,filter:H}=r,D={};d!=null&&(D.fields=d),o!=null&&(D.limit=o.toString()),n!=null&&(D.scoreLimit=n.toString()),_!=null&&(D.cursor=_),D.fromStartTime=h,p!=null&&(D.toStartTime=p),f!=null&&(D.experimentId=f),A!=null&&(D.experimentName=A),I!=null&&(D.experimentItemId=I),V!=null&&(D.datasetId=V),H!=null&&(D.filter=H);let B=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),N=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/experiment-items"),method:"GET",headers:B,queryParameters:{...D,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(N.ok)return{data:N.body,rawResponse:N.rawResponse};if(N.error.reason==="status-code")switch(N.error.statusCode){case 400:throw new y(N.error.body,N.rawResponse);case 401:throw new b(N.error.body,N.rawResponse);case 403:throw new v(N.error.body,N.rawResponse);case 405:throw new S(N.error.body,N.rawResponse);case 404:throw new R(N.error.body,N.rawResponse);default:throw new m({statusCode:N.error.statusCode,body:N.error.body,rawResponse:N.rawResponse})}switch(N.error.reason){case"non-json":throw new m({statusCode:N.error.statusCode,body:N.error.rawBody,rawResponse:N.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/experiment-items.");case"unknown":throw new m({message:N.error.errorMessage,rawResponse:N.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Ui=class{constructor(r){this._options=r}submit(r,e){return C.fromPromise(this.__submit(r,e))}async __submit(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/feedback"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 409:throw new ia(o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/feedback.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Bi=class{constructor(r){this._options=r}health(r){return C.fromPromise(this.__health(r))}async __health(r){var e,t,a,s,i,l,u,c;let w=x((e=this._options)==null?void 0:e.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(a=r?.xLangfuseSdkName)!=null?a:(t=this._options)==null?void 0:t.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(i=r?.xLangfuseSdkVersion)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(u=r?.xLangfusePublicKey)!=null?u:(l=this._options)==null?void 0:l.xLangfusePublicKey}),r?.headers),d=await P({url:E.join((c=await g.get(this._options.baseUrl))!=null?c:await g.get(this._options.environment),"/api/public/health"),method:"GET",headers:w,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 503:throw new da(d.rawResponse);case 400:throw new y(d.error.body,d.rawResponse);case 401:throw new b(d.error.body,d.rawResponse);case 403:throw new v(d.error.body,d.rawResponse);case 405:throw new S(d.error.body,d.rawResponse);case 404:throw new R(d.error.body,d.rawResponse);default:throw new m({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new m({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/health.");case"unknown":throw new m({message:d.error.errorMessage,rawResponse:d.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},ji=class{constructor(r){this._options=r}batch(r,e){return C.fromPromise(this.__batch(r,e))}async __batch(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/ingestion"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/ingestion.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},zi=class{constructor(r){this._options=r}metrics(r,e){return C.fromPromise(this.__metrics(r,e))}async __metrics(r,e){var t,a,s,i,l,u,c,w;let{query:d}=r,o={};o.query=d;let n=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),_=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/metrics"),method:"GET",headers:n,queryParameters:{...o,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(_.ok)return{data:_.body,rawResponse:_.rawResponse};if(_.error.reason==="status-code")switch(_.error.statusCode){case 400:throw new y(_.error.body,_.rawResponse);case 401:throw new b(_.error.body,_.rawResponse);case 403:throw new v(_.error.body,_.rawResponse);case 405:throw new S(_.error.body,_.rawResponse);case 404:throw new R(_.error.body,_.rawResponse);default:throw new m({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse})}switch(_.error.reason){case"non-json":throw new m({statusCode:_.error.statusCode,body:_.error.rawBody,rawResponse:_.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/metrics.");case"unknown":throw new m({message:_.error.errorMessage,rawResponse:_.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Ki=class{constructor(r){this._options=r}get(r,e){return C.fromPromise(this.__get(r,e))}async __get(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/observations/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/observations/{observationId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getMany(r={},e){return C.fromPromise(this.__getMany(r,e))}async __getMany(r={},e){var t,a,s,i,l,u,c,w;let{page:d,limit:o,name:n,userId:_,type:h,traceId:p,level:f,parentObservationId:A,environment:I,fromStartTime:V,toStartTime:H,version:D,filter:B}=r,N={};d!=null&&(N.page=d.toString()),o!=null&&(N.limit=o.toString()),n!=null&&(N.name=n),_!=null&&(N.userId=_),h!=null&&(N.type=h),p!=null&&(N.traceId=p),f!=null&&(N.level=f),A!=null&&(N.parentObservationId=A),I!=null&&(Array.isArray(I)?N.environment=I.map(X=>X):N.environment=I),V!=null&&(N.fromStartTime=V),H!=null&&(N.toStartTime=H),D!=null&&(N.version=D),B!=null&&(N.filter=B);let F=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),K=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/observations"),method:"GET",headers:F,queryParameters:{...N,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(K.ok)return{data:K.body,rawResponse:K.rawResponse};if(K.error.reason==="status-code")switch(K.error.statusCode){case 400:throw new y(K.error.body,K.rawResponse);case 401:throw new b(K.error.body,K.rawResponse);case 403:throw new v(K.error.body,K.rawResponse);case 405:throw new S(K.error.body,K.rawResponse);case 404:throw new R(K.error.body,K.rawResponse);default:throw new m({statusCode:K.error.statusCode,body:K.error.body,rawResponse:K.rawResponse})}switch(K.error.reason){case"non-json":throw new m({statusCode:K.error.statusCode,body:K.error.rawBody,rawResponse:K.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/observations.");case"unknown":throw new m({message:K.error.errorMessage,rawResponse:K.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Da=class{constructor(r){this._options=r}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/scores"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/scores.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getMany(r={},e){return C.fromPromise(this.__getMany(r,e))}async __getMany(r={},e){var t,a,s,i,l,u,c,w;let{page:d,limit:o,userId:n,name:_,fromTimestamp:h,toTimestamp:p,environment:f,source:A,operator:I,value:V,scoreIds:H,configId:D,sessionId:B,datasetRunId:N,traceId:F,observationId:K,queueId:X,dataType:se,traceTags:$,fields:Ce,filter:U}=r,W={};d!=null&&(W.page=d.toString()),o!=null&&(W.limit=o.toString()),n!=null&&(W.userId=n),_!=null&&(W.name=_),h!=null&&(W.fromTimestamp=h),p!=null&&(W.toTimestamp=p),f!=null&&(Array.isArray(f)?W.environment=f.map(fo=>fo):W.environment=f),A!=null&&(W.source=A),I!=null&&(W.operator=I),V!=null&&(W.value=V.toString()),H!=null&&(W.scoreIds=H),D!=null&&(W.configId=D),B!=null&&(W.sessionId=B),N!=null&&(W.datasetRunId=N),F!=null&&(W.traceId=F),K!=null&&(W.observationId=K),X!=null&&(W.queueId=X),se!=null&&(W.dataType=se),$!=null&&(Array.isArray($)?W.traceTags=$.map(fo=>fo):W.traceTags=$),Ce!=null&&(W.fields=Ce),U!=null&&(W.filter=U);let Q=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),Y=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/v2/scores"),method:"GET",headers:Q,queryParameters:{...W,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(Y.ok)return{data:Y.body,rawResponse:Y.rawResponse};if(Y.error.reason==="status-code")switch(Y.error.statusCode){case 400:throw new y(Y.error.body,Y.rawResponse);case 401:throw new b(Y.error.body,Y.rawResponse);case 403:throw new v(Y.error.body,Y.rawResponse);case 405:throw new S(Y.error.body,Y.rawResponse);case 404:throw new R(Y.error.body,Y.rawResponse);default:throw new m({statusCode:Y.error.statusCode,body:Y.error.body,rawResponse:Y.rawResponse})}switch(Y.error.reason){case"non-json":throw new m({statusCode:Y.error.statusCode,body:Y.error.rawBody,rawResponse:Y.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/scores.");case"unknown":throw new m({message:Y.error.errorMessage,rawResponse:Y.rawResponse})}}getById(r,e){return C.fromPromise(this.__getById(r,e))}async __getById(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/v2/scores/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/scores/{scoreId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Xi=class{constructor(r){this._options=r}create(r,e){return new Da(this._options).create(r,e)}delete(r,e){return C.fromPromise(this.__delete(r,e))}async __delete(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/scores/${encodeURIComponent(r)}`),method:"DELETE",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/scores/{scoreId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Di=class{constructor(r){this._options=r}get metricsV1(){var r;return(r=this._metricsV1)!=null?r:this._metricsV1=new zi(this._options)}get observationsV1(){var r;return(r=this._observationsV1)!=null?r:this._observationsV1=new Ki(this._options)}get scoreV1(){var r;return(r=this._scoreV1)!=null?r:this._scoreV1=new Xi(this._options)}},Gi=class{constructor(r){this._options=r}list(r={},e){return C.fromPromise(this.__list(r,e))}async __list(r={},e){var t,a,s,i,l,u,c,w;let{page:d,limit:o}=r,n={};d!=null&&(n.page=d.toString()),o!=null&&(n.limit=o.toString());let _=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),h=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/llm-connections"),method:"GET",headers:_,queryParameters:{...n,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new y(h.error.body,h.rawResponse);case 401:throw new b(h.error.body,h.rawResponse);case 403:throw new v(h.error.body,h.rawResponse);case 405:throw new S(h.error.body,h.rawResponse);case 404:throw new R(h.error.body,h.rawResponse);default:throw new m({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}switch(h.error.reason){case"non-json":throw new m({statusCode:h.error.statusCode,body:h.error.rawBody,rawResponse:h.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/llm-connections.");case"unknown":throw new m({message:h.error.errorMessage,rawResponse:h.rawResponse})}}upsert(r,e){return C.fromPromise(this.__upsert(r,e))}async __upsert(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/llm-connections"),method:"PUT",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PUT /api/public/llm-connections.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}delete(r,e){return C.fromPromise(this.__delete(r,e))}async __delete(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/llm-connections/${encodeURIComponent(r)}`),method:"DELETE",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/llm-connections/{id}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Hi=class{constructor(r){this._options=r}get(r,e){return C.fromPromise(this.__get(r,e))}async __get(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/media/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/media/{mediaId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}patch(r,e,t){return C.fromPromise(this.__patch(r,e,t))}async __patch(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/media/${encodeURIComponent(r)}`),method:"PATCH",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:void 0,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PATCH /api/public/media/{mediaId}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}getUploadUrl(r,e){return C.fromPromise(this.__getUploadUrl(r,e))}async __getUploadUrl(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/media"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/media.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Fi=class{constructor(r){this._options=r}metrics(r,e){return C.fromPromise(this.__metrics(r,e))}async __metrics(r,e){var t,a,s,i,l,u,c,w;let{query:d}=r,o={};o.query=d;let n=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),_=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/v2/metrics"),method:"GET",headers:n,queryParameters:{...o,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(_.ok)return{data:_.body,rawResponse:_.rawResponse};if(_.error.reason==="status-code")switch(_.error.statusCode){case 400:throw new y(_.error.body,_.rawResponse);case 401:throw new b(_.error.body,_.rawResponse);case 403:throw new v(_.error.body,_.rawResponse);case 405:throw new S(_.error.body,_.rawResponse);case 404:throw new R(_.error.body,_.rawResponse);default:throw new m({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse})}switch(_.error.reason){case"non-json":throw new m({statusCode:_.error.statusCode,body:_.error.rawBody,rawResponse:_.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/metrics.");case"unknown":throw new m({message:_.error.errorMessage,rawResponse:_.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},$i=class{constructor(r){this._options=r}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/models"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/models.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}upsert(r,e,t){return C.fromPromise(this.__upsert(r,e,t))}async __upsert(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/models/${encodeURIComponent(r)}`),method:"PUT",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PUT /api/public/models/{id}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}list(r={},e){return C.fromPromise(this.__list(r,e))}async __list(r={},e){var t,a,s,i,l,u,c,w;let{page:d,limit:o}=r,n={};d!=null&&(n.page=d.toString()),o!=null&&(n.limit=o.toString());let _=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),h=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/models"),method:"GET",headers:_,queryParameters:{...n,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new y(h.error.body,h.rawResponse);case 401:throw new b(h.error.body,h.rawResponse);case 403:throw new v(h.error.body,h.rawResponse);case 405:throw new S(h.error.body,h.rawResponse);case 404:throw new R(h.error.body,h.rawResponse);default:throw new m({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}switch(h.error.reason){case"non-json":throw new m({statusCode:h.error.statusCode,body:h.error.rawBody,rawResponse:h.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/models.");case"unknown":throw new m({message:h.error.errorMessage,rawResponse:h.rawResponse})}}get(r,e){return C.fromPromise(this.__get(r,e))}async __get(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/models/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/models/{id}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}delete(r,e){return C.fromPromise(this.__delete(r,e))}async __delete(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/models/${encodeURIComponent(r)}`),method:"DELETE",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:void 0,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/models/{id}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Wi=class{constructor(r){this._options=r}getMany(r={},e){return C.fromPromise(this.__getMany(r,e))}async __getMany(r={},e){var t,a,s,i,l,u,c,w;let{fields:d,expandMetadata:o,limit:n,cursor:_,parseIoAsJson:h,name:p,userId:f,sessionId:A,type:I,traceId:V,level:H,parentObservationId:D,isRootObservation:B,environment:N,fromStartTime:F,toStartTime:K,version:X,filter:se}=r,$={};d!=null&&($.fields=d),o!=null&&($.expandMetadata=o),n!=null&&($.limit=n.toString()),_!=null&&($.cursor=_),h!=null&&($.parseIoAsJson=h.toString()),p!=null&&($.name=p),f!=null&&($.userId=f),A!=null&&($.sessionId=A),I!=null&&($.type=I),V!=null&&($.traceId=V),H!=null&&($.level=H),D!=null&&($.parentObservationId=D),B!=null&&($.isRootObservation=B.toString()),N!=null&&(Array.isArray(N)?$.environment=N.map(W=>W):$.environment=N),F!=null&&($.fromStartTime=F),K!=null&&($.toStartTime=K),X!=null&&($.version=X),se!=null&&($.filter=se);let Ce=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),U=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/v2/observations"),method:"GET",headers:Ce,queryParameters:{...$,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(U.ok)return{data:U.body,rawResponse:U.rawResponse};if(U.error.reason==="status-code")switch(U.error.statusCode){case 400:throw new y(U.error.body,U.rawResponse);case 401:throw new b(U.error.body,U.rawResponse);case 403:throw new v(U.error.body,U.rawResponse);case 405:throw new S(U.error.body,U.rawResponse);case 404:throw new R(U.error.body,U.rawResponse);default:throw new m({statusCode:U.error.statusCode,body:U.error.body,rawResponse:U.rawResponse})}switch(U.error.reason){case"non-json":throw new m({statusCode:U.error.statusCode,body:U.error.rawBody,rawResponse:U.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/observations.");case"unknown":throw new m({message:U.error.errorMessage,rawResponse:U.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Qi=class{constructor(r){this._options=r}exportTraces(r,e){return C.fromPromise(this.__exportTraces(r,e))}async __exportTraces(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/otel/v1/traces"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/otel/v1/traces.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Yi=class{constructor(r){this._options=r}getOrganizationMemberships(r){return C.fromPromise(this.__getOrganizationMemberships(r))}async __getOrganizationMemberships(r){var e,t,a,s,i,l,u,c;let w=x((e=this._options)==null?void 0:e.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(a=r?.xLangfuseSdkName)!=null?a:(t=this._options)==null?void 0:t.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(i=r?.xLangfuseSdkVersion)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(u=r?.xLangfusePublicKey)!=null?u:(l=this._options)==null?void 0:l.xLangfusePublicKey}),r?.headers),d=await P({url:E.join((c=await g.get(this._options.baseUrl))!=null?c:await g.get(this._options.environment),"/api/public/organizations/memberships"),method:"GET",headers:w,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new y(d.error.body,d.rawResponse);case 401:throw new b(d.error.body,d.rawResponse);case 403:throw new v(d.error.body,d.rawResponse);case 405:throw new S(d.error.body,d.rawResponse);case 404:throw new R(d.error.body,d.rawResponse);default:throw new m({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new m({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/organizations/memberships.");case"unknown":throw new m({message:d.error.errorMessage,rawResponse:d.rawResponse})}}updateOrganizationMembership(r,e){return C.fromPromise(this.__updateOrganizationMembership(r,e))}async __updateOrganizationMembership(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/organizations/memberships"),method:"PUT",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PUT /api/public/organizations/memberships.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteOrganizationMembership(r,e){return C.fromPromise(this.__deleteOrganizationMembership(r,e))}async __deleteOrganizationMembership(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/organizations/memberships"),method:"DELETE",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/organizations/memberships.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getProjectMemberships(r,e){return C.fromPromise(this.__getProjectMemberships(r,e))}async __getProjectMemberships(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/projects/${encodeURIComponent(r)}/memberships`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/projects/{projectId}/memberships.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}updateProjectMembership(r,e,t){return C.fromPromise(this.__updateProjectMembership(r,e,t))}async __updateProjectMembership(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/projects/${encodeURIComponent(r)}/memberships`),method:"PUT",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PUT /api/public/projects/{projectId}/memberships.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}deleteProjectMembership(r,e,t){return C.fromPromise(this.__deleteProjectMembership(r,e,t))}async __deleteProjectMembership(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/projects/${encodeURIComponent(r)}/memberships`),method:"DELETE",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/projects/{projectId}/memberships.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}getOrganizationProjects(r){return C.fromPromise(this.__getOrganizationProjects(r))}async __getOrganizationProjects(r){var e,t,a,s,i,l,u,c;let w=x((e=this._options)==null?void 0:e.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(a=r?.xLangfuseSdkName)!=null?a:(t=this._options)==null?void 0:t.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(i=r?.xLangfuseSdkVersion)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(u=r?.xLangfusePublicKey)!=null?u:(l=this._options)==null?void 0:l.xLangfusePublicKey}),r?.headers),d=await P({url:E.join((c=await g.get(this._options.baseUrl))!=null?c:await g.get(this._options.environment),"/api/public/organizations/projects"),method:"GET",headers:w,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new y(d.error.body,d.rawResponse);case 401:throw new b(d.error.body,d.rawResponse);case 403:throw new v(d.error.body,d.rawResponse);case 405:throw new S(d.error.body,d.rawResponse);case 404:throw new R(d.error.body,d.rawResponse);default:throw new m({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new m({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/organizations/projects.");case"unknown":throw new m({message:d.error.errorMessage,rawResponse:d.rawResponse})}}getOrganizationApiKeys(r){return C.fromPromise(this.__getOrganizationApiKeys(r))}async __getOrganizationApiKeys(r){var e,t,a,s,i,l,u,c;let w=x((e=this._options)==null?void 0:e.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(a=r?.xLangfuseSdkName)!=null?a:(t=this._options)==null?void 0:t.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(i=r?.xLangfuseSdkVersion)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(u=r?.xLangfusePublicKey)!=null?u:(l=this._options)==null?void 0:l.xLangfusePublicKey}),r?.headers),d=await P({url:E.join((c=await g.get(this._options.baseUrl))!=null?c:await g.get(this._options.environment),"/api/public/organizations/apiKeys"),method:"GET",headers:w,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new y(d.error.body,d.rawResponse);case 401:throw new b(d.error.body,d.rawResponse);case 403:throw new v(d.error.body,d.rawResponse);case 405:throw new S(d.error.body,d.rawResponse);case 404:throw new R(d.error.body,d.rawResponse);default:throw new m({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new m({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/organizations/apiKeys.");case"unknown":throw new m({message:d.error.errorMessage,rawResponse:d.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Ji=class{constructor(r){this._options=r}get(r){return C.fromPromise(this.__get(r))}async __get(r){var e,t,a,s,i,l,u,c;let w=x((e=this._options)==null?void 0:e.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(a=r?.xLangfuseSdkName)!=null?a:(t=this._options)==null?void 0:t.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(i=r?.xLangfuseSdkVersion)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(u=r?.xLangfusePublicKey)!=null?u:(l=this._options)==null?void 0:l.xLangfusePublicKey}),r?.headers),d=await P({url:E.join((c=await g.get(this._options.baseUrl))!=null?c:await g.get(this._options.environment),"/api/public/projects"),method:"GET",headers:w,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new y(d.error.body,d.rawResponse);case 401:throw new b(d.error.body,d.rawResponse);case 403:throw new v(d.error.body,d.rawResponse);case 405:throw new S(d.error.body,d.rawResponse);case 404:throw new R(d.error.body,d.rawResponse);default:throw new m({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new m({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/projects.");case"unknown":throw new m({message:d.error.errorMessage,rawResponse:d.rawResponse})}}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/projects"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/projects.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}update(r,e,t){return C.fromPromise(this.__update(r,e,t))}async __update(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/projects/${encodeURIComponent(r)}`),method:"PUT",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PUT /api/public/projects/{projectId}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}delete(r,e){return C.fromPromise(this.__delete(r,e))}async __delete(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/projects/${encodeURIComponent(r)}`),method:"DELETE",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/projects/{projectId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getApiKeys(r,e){return C.fromPromise(this.__getApiKeys(r,e))}async __getApiKeys(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/projects/${encodeURIComponent(r)}/apiKeys`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/projects/{projectId}/apiKeys.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}createApiKey(r,e={},t){return C.fromPromise(this.__createApiKey(r,e,t))}async __createApiKey(r,e={},t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/projects/${encodeURIComponent(r)}/apiKeys`),method:"POST",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/projects/{projectId}/apiKeys.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}deleteApiKey(r,e,t){return C.fromPromise(this.__deleteApiKey(r,e,t))}async __deleteApiKey(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/projects/${encodeURIComponent(r)}/apiKeys/${encodeURIComponent(e)}`),method:"DELETE",headers:o,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/projects/{projectId}/apiKeys/{apiKeyId}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Zi=class{constructor(r){this._options=r}update(r,e,t,a){return C.fromPromise(this.__update(r,e,t,a))}async __update(r,e,t,a){var s,i,l,u,c,w,d,o;let n=x((s=this._options)==null?void 0:s.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(l=a?.xLangfuseSdkName)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(c=a?.xLangfuseSdkVersion)!=null?c:(u=this._options)==null?void 0:u.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(d=a?.xLangfusePublicKey)!=null?d:(w=this._options)==null?void 0:w.xLangfusePublicKey}),a?.headers),_=await P({url:E.join((o=await g.get(this._options.baseUrl))!=null?o:await g.get(this._options.environment),`/api/public/v2/prompts/${encodeURIComponent(r)}/versions/${encodeURIComponent(e)}`),method:"PATCH",headers:n,contentType:"application/json",queryParameters:a?.queryParams,requestType:"json",body:t,timeoutMs:a?.timeoutInSeconds!=null?a.timeoutInSeconds*1e3:6e4,maxRetries:a?.maxRetries,abortSignal:a?.abortSignal});if(_.ok)return{data:_.body,rawResponse:_.rawResponse};if(_.error.reason==="status-code")switch(_.error.statusCode){case 400:throw new y(_.error.body,_.rawResponse);case 401:throw new b(_.error.body,_.rawResponse);case 403:throw new v(_.error.body,_.rawResponse);case 405:throw new S(_.error.body,_.rawResponse);case 404:throw new R(_.error.body,_.rawResponse);default:throw new m({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse})}switch(_.error.reason){case"non-json":throw new m({statusCode:_.error.statusCode,body:_.error.rawBody,rawResponse:_.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PATCH /api/public/v2/prompts/{name}/versions/{version}.");case"unknown":throw new m({message:_.error.errorMessage,rawResponse:_.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},Oi=class{constructor(r){this._options=r}get(r,e={},t){return C.fromPromise(this.__get(r,e,t))}async __get(r,e={},t){var a,s,i,l,u,c,w,d;let{version:o,label:n,resolve:_}=e,h={};o!=null&&(h.version=o.toString()),n!=null&&(h.label=n),_!=null&&(h.resolve=_.toString());let p=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),f=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/v2/prompts/${encodeURIComponent(r)}`),method:"GET",headers:p,queryParameters:{...h,...t?.queryParams},timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(f.ok)return{data:f.body,rawResponse:f.rawResponse};if(f.error.reason==="status-code")switch(f.error.statusCode){case 400:throw new y(f.error.body,f.rawResponse);case 401:throw new b(f.error.body,f.rawResponse);case 403:throw new v(f.error.body,f.rawResponse);case 405:throw new S(f.error.body,f.rawResponse);case 404:throw new R(f.error.body,f.rawResponse);default:throw new m({statusCode:f.error.statusCode,body:f.error.body,rawResponse:f.rawResponse})}switch(f.error.reason){case"non-json":throw new m({statusCode:f.error.statusCode,body:f.error.rawBody,rawResponse:f.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/prompts/{promptName}.");case"unknown":throw new m({message:f.error.errorMessage,rawResponse:f.rawResponse})}}list(r={},e){return C.fromPromise(this.__list(r,e))}async __list(r={},e){var t,a,s,i,l,u,c,w;let{name:d,label:o,tag:n,page:_,limit:h,fromUpdatedAt:p,toUpdatedAt:f}=r,A={};d!=null&&(A.name=d),o!=null&&(A.label=o),n!=null&&(A.tag=n),_!=null&&(A.page=_.toString()),h!=null&&(A.limit=h.toString()),p!=null&&(A.fromUpdatedAt=p),f!=null&&(A.toUpdatedAt=f);let I=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),V=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/v2/prompts"),method:"GET",headers:I,queryParameters:{...A,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(V.ok)return{data:V.body,rawResponse:V.rawResponse};if(V.error.reason==="status-code")switch(V.error.statusCode){case 400:throw new y(V.error.body,V.rawResponse);case 401:throw new b(V.error.body,V.rawResponse);case 403:throw new v(V.error.body,V.rawResponse);case 405:throw new S(V.error.body,V.rawResponse);case 404:throw new R(V.error.body,V.rawResponse);default:throw new m({statusCode:V.error.statusCode,body:V.error.body,rawResponse:V.rawResponse})}switch(V.error.reason){case"non-json":throw new m({statusCode:V.error.statusCode,body:V.error.rawBody,rawResponse:V.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v2/prompts.");case"unknown":throw new m({message:V.error.errorMessage,rawResponse:V.rawResponse})}}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/v2/prompts"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/v2/prompts.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}delete(r,e={},t){return C.fromPromise(this.__delete(r,e,t))}async __delete(r,e={},t){var a,s,i,l,u,c,w,d;let{label:o,version:n}=e,_={};o!=null&&(_.label=o),n!=null&&(_.version=n.toString());let h=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),p=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/v2/prompts/${encodeURIComponent(r)}`),method:"DELETE",headers:h,queryParameters:{..._,...t?.queryParams},timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(p.ok)return{data:void 0,rawResponse:p.rawResponse};if(p.error.reason==="status-code")switch(p.error.statusCode){case 400:throw new y(p.error.body,p.rawResponse);case 401:throw new b(p.error.body,p.rawResponse);case 403:throw new v(p.error.body,p.rawResponse);case 405:throw new S(p.error.body,p.rawResponse);case 404:throw new R(p.error.body,p.rawResponse);default:throw new m({statusCode:p.error.statusCode,body:p.error.body,rawResponse:p.rawResponse})}switch(p.error.reason){case"non-json":throw new m({statusCode:p.error.statusCode,body:p.error.rawBody,rawResponse:p.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/v2/prompts/{promptName}.");case"unknown":throw new m({message:p.error.errorMessage,rawResponse:p.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},qi=class{constructor(r){this._options=r}getServiceProviderConfig(r){return C.fromPromise(this.__getServiceProviderConfig(r))}async __getServiceProviderConfig(r){var e,t,a,s,i,l,u,c;let w=x((e=this._options)==null?void 0:e.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(a=r?.xLangfuseSdkName)!=null?a:(t=this._options)==null?void 0:t.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(i=r?.xLangfuseSdkVersion)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(u=r?.xLangfusePublicKey)!=null?u:(l=this._options)==null?void 0:l.xLangfusePublicKey}),r?.headers),d=await P({url:E.join((c=await g.get(this._options.baseUrl))!=null?c:await g.get(this._options.environment),"/api/public/scim/ServiceProviderConfig"),method:"GET",headers:w,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new y(d.error.body,d.rawResponse);case 401:throw new b(d.error.body,d.rawResponse);case 403:throw new v(d.error.body,d.rawResponse);case 405:throw new S(d.error.body,d.rawResponse);case 404:throw new R(d.error.body,d.rawResponse);default:throw new m({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new m({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/scim/ServiceProviderConfig.");case"unknown":throw new m({message:d.error.errorMessage,rawResponse:d.rawResponse})}}getResourceTypes(r){return C.fromPromise(this.__getResourceTypes(r))}async __getResourceTypes(r){var e,t,a,s,i,l,u,c;let w=x((e=this._options)==null?void 0:e.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(a=r?.xLangfuseSdkName)!=null?a:(t=this._options)==null?void 0:t.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(i=r?.xLangfuseSdkVersion)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(u=r?.xLangfusePublicKey)!=null?u:(l=this._options)==null?void 0:l.xLangfusePublicKey}),r?.headers),d=await P({url:E.join((c=await g.get(this._options.baseUrl))!=null?c:await g.get(this._options.environment),"/api/public/scim/ResourceTypes"),method:"GET",headers:w,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new y(d.error.body,d.rawResponse);case 401:throw new b(d.error.body,d.rawResponse);case 403:throw new v(d.error.body,d.rawResponse);case 405:throw new S(d.error.body,d.rawResponse);case 404:throw new R(d.error.body,d.rawResponse);default:throw new m({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new m({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/scim/ResourceTypes.");case"unknown":throw new m({message:d.error.errorMessage,rawResponse:d.rawResponse})}}getSchemas(r){return C.fromPromise(this.__getSchemas(r))}async __getSchemas(r){var e,t,a,s,i,l,u,c;let w=x((e=this._options)==null?void 0:e.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(a=r?.xLangfuseSdkName)!=null?a:(t=this._options)==null?void 0:t.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(i=r?.xLangfuseSdkVersion)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(u=r?.xLangfusePublicKey)!=null?u:(l=this._options)==null?void 0:l.xLangfusePublicKey}),r?.headers),d=await P({url:E.join((c=await g.get(this._options.baseUrl))!=null?c:await g.get(this._options.environment),"/api/public/scim/Schemas"),method:"GET",headers:w,queryParameters:r?.queryParams,timeoutMs:r?.timeoutInSeconds!=null?r.timeoutInSeconds*1e3:6e4,maxRetries:r?.maxRetries,abortSignal:r?.abortSignal});if(d.ok)return{data:d.body,rawResponse:d.rawResponse};if(d.error.reason==="status-code")switch(d.error.statusCode){case 400:throw new y(d.error.body,d.rawResponse);case 401:throw new b(d.error.body,d.rawResponse);case 403:throw new v(d.error.body,d.rawResponse);case 405:throw new S(d.error.body,d.rawResponse);case 404:throw new R(d.error.body,d.rawResponse);default:throw new m({statusCode:d.error.statusCode,body:d.error.body,rawResponse:d.rawResponse})}switch(d.error.reason){case"non-json":throw new m({statusCode:d.error.statusCode,body:d.error.rawBody,rawResponse:d.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/scim/Schemas.");case"unknown":throw new m({message:d.error.errorMessage,rawResponse:d.rawResponse})}}listUsers(r={},e){return C.fromPromise(this.__listUsers(r,e))}async __listUsers(r={},e){var t,a,s,i,l,u,c,w;let{filter:d,startIndex:o,count:n}=r,_={};d!=null&&(_.filter=d),o!=null&&(_.startIndex=o.toString()),n!=null&&(_.count=n.toString());let h=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),p=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/scim/Users"),method:"GET",headers:h,queryParameters:{..._,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(p.ok)return{data:p.body,rawResponse:p.rawResponse};if(p.error.reason==="status-code")switch(p.error.statusCode){case 400:throw new y(p.error.body,p.rawResponse);case 401:throw new b(p.error.body,p.rawResponse);case 403:throw new v(p.error.body,p.rawResponse);case 405:throw new S(p.error.body,p.rawResponse);case 404:throw new R(p.error.body,p.rawResponse);default:throw new m({statusCode:p.error.statusCode,body:p.error.body,rawResponse:p.rawResponse})}switch(p.error.reason){case"non-json":throw new m({statusCode:p.error.statusCode,body:p.error.rawBody,rawResponse:p.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/scim/Users.");case"unknown":throw new m({message:p.error.errorMessage,rawResponse:p.rawResponse})}}createUser(r,e){return C.fromPromise(this.__createUser(r,e))}async __createUser(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/scim/Users"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/scim/Users.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}getUser(r,e){return C.fromPromise(this.__getUser(r,e))}async __getUser(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/scim/Users/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/scim/Users/{userId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}deleteUser(r,e){return C.fromPromise(this.__deleteUser(r,e))}async __deleteUser(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/scim/Users/${encodeURIComponent(r)}`),method:"DELETE",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/scim/Users/{userId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},el=class{constructor(r){this._options=r}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/score-configs"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/score-configs.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}get(r={},e){return C.fromPromise(this.__get(r,e))}async __get(r={},e){var t,a,s,i,l,u,c,w;let{page:d,limit:o}=r,n={};d!=null&&(n.page=d.toString()),o!=null&&(n.limit=o.toString());let _=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),h=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/score-configs"),method:"GET",headers:_,queryParameters:{...n,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new y(h.error.body,h.rawResponse);case 401:throw new b(h.error.body,h.rawResponse);case 403:throw new v(h.error.body,h.rawResponse);case 405:throw new S(h.error.body,h.rawResponse);case 404:throw new R(h.error.body,h.rawResponse);default:throw new m({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}switch(h.error.reason){case"non-json":throw new m({statusCode:h.error.statusCode,body:h.error.rawBody,rawResponse:h.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/score-configs.");case"unknown":throw new m({message:h.error.errorMessage,rawResponse:h.rawResponse})}}getById(r,e){return C.fromPromise(this.__getById(r,e))}async __getById(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/score-configs/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/score-configs/{configId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}update(r,e,t){return C.fromPromise(this.__update(r,e,t))}async __update(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/score-configs/${encodeURIComponent(r)}`),method:"PATCH",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PATCH /api/public/score-configs/{configId}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},rl=class{constructor(r){this._options=r}getManyV3(r={},e){return C.fromPromise(this.__getManyV3(r,e))}async __getManyV3(r={},e){var t,a,s,i,l,u,c,w;let{limit:d,cursor:o,fields:n,id:_,name:h,source:p,dataType:f,environment:A,configId:I,queueId:V,authorUserId:H,value:D,valueMin:B,valueMax:N,traceId:F,sessionId:K,observationId:X,experimentId:se,fromTimestamp:$,toTimestamp:Ce}=r,U={};d!=null&&(U.limit=d.toString()),o!=null&&(U.cursor=o),n!=null&&(U.fields=n),_!=null&&(U.id=_),h!=null&&(U.name=h),p!=null&&(U.source=p),f!=null&&(U.dataType=f),A!=null&&(U.environment=A),I!=null&&(U.configId=I),V!=null&&(U.queueId=V),H!=null&&(U.authorUserId=H),D!=null&&(U.value=D),B!=null&&(U.valueMin=B.toString()),N!=null&&(U.valueMax=N.toString()),F!=null&&(U.traceId=F),K!=null&&(U.sessionId=K),X!=null&&(U.observationId=X),se!=null&&(U.experimentId=se),$!=null&&(U.fromTimestamp=$),Ce!=null&&(U.toTimestamp=Ce);let W=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),Q=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/v3/scores"),method:"GET",headers:W,queryParameters:{...U,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(Q.ok)return{data:Q.body,rawResponse:Q.rawResponse};if(Q.error.reason==="status-code")switch(Q.error.statusCode){case 400:throw new y(Q.error.body,Q.rawResponse);case 401:throw new b(Q.error.body,Q.rawResponse);case 403:throw new v(Q.error.body,Q.rawResponse);case 405:throw new S(Q.error.body,Q.rawResponse);case 404:throw new R(Q.error.body,Q.rawResponse);default:throw new m({statusCode:Q.error.statusCode,body:Q.error.body,rawResponse:Q.rawResponse})}switch(Q.error.reason){case"non-json":throw new m({statusCode:Q.error.statusCode,body:Q.error.rawBody,rawResponse:Q.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/v3/scores.");case"unknown":throw new m({message:Q.error.errorMessage,rawResponse:Q.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},ol=class{constructor(r){this._options=r}list(r={},e){return C.fromPromise(this.__list(r,e))}async __list(r={},e){var t,a,s,i,l,u,c,w;let{page:d,limit:o,fromTimestamp:n,toTimestamp:_,environment:h}=r,p={};d!=null&&(p.page=d.toString()),o!=null&&(p.limit=o.toString()),n!=null&&(p.fromTimestamp=n),_!=null&&(p.toTimestamp=_),h!=null&&(Array.isArray(h)?p.environment=h.map(I=>I):p.environment=h);let f=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),A=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/sessions"),method:"GET",headers:f,queryParameters:{...p,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(A.ok)return{data:A.body,rawResponse:A.rawResponse};if(A.error.reason==="status-code")switch(A.error.statusCode){case 400:throw new y(A.error.body,A.rawResponse);case 401:throw new b(A.error.body,A.rawResponse);case 403:throw new v(A.error.body,A.rawResponse);case 405:throw new S(A.error.body,A.rawResponse);case 404:throw new R(A.error.body,A.rawResponse);default:throw new m({statusCode:A.error.statusCode,body:A.error.body,rawResponse:A.rawResponse})}switch(A.error.reason){case"non-json":throw new m({statusCode:A.error.statusCode,body:A.error.rawBody,rawResponse:A.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/sessions.");case"unknown":throw new m({message:A.error.errorMessage,rawResponse:A.rawResponse})}}get(r,e){return C.fromPromise(this.__get(r,e))}async __get(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/sessions/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/sessions/{sessionId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},tl=class{constructor(r){this._options=r}get(r,e={},t){return C.fromPromise(this.__get(r,e,t))}async __get(r,e={},t){var a,s,i,l,u,c,w,d;let{fields:o}=e,n={};o!=null&&(n.fields=o);let _=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),h=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/traces/${encodeURIComponent(r)}`),method:"GET",headers:_,queryParameters:{...n,...t?.queryParams},timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new y(h.error.body,h.rawResponse);case 401:throw new b(h.error.body,h.rawResponse);case 403:throw new v(h.error.body,h.rawResponse);case 405:throw new S(h.error.body,h.rawResponse);case 404:throw new R(h.error.body,h.rawResponse);default:throw new m({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}switch(h.error.reason){case"non-json":throw new m({statusCode:h.error.statusCode,body:h.error.rawBody,rawResponse:h.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/traces/{traceId}.");case"unknown":throw new m({message:h.error.errorMessage,rawResponse:h.rawResponse})}}delete(r,e){return C.fromPromise(this.__delete(r,e))}async __delete(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/traces/${encodeURIComponent(r)}`),method:"DELETE",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/traces/{traceId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}list(r={},e){return C.fromPromise(this.__list(r,e))}async __list(r={},e){var t,a,s,i,l,u,c,w;let{page:d,limit:o,userId:n,name:_,sessionId:h,fromTimestamp:p,toTimestamp:f,orderBy:A,tags:I,version:V,release:H,environment:D,fields:B,filter:N}=r,F={};d!=null&&(F.page=d.toString()),o!=null&&(F.limit=o.toString()),n!=null&&(F.userId=n),_!=null&&(F.name=_),h!=null&&(F.sessionId=h),p!=null&&(F.fromTimestamp=p),f!=null&&(F.toTimestamp=f),A!=null&&(F.orderBy=A),I!=null&&(Array.isArray(I)?F.tags=I.map(se=>se):F.tags=I),V!=null&&(F.version=V),H!=null&&(F.release=H),D!=null&&(Array.isArray(D)?F.environment=D.map(se=>se):F.environment=D),B!=null&&(F.fields=B),N!=null&&(F.filter=N);let K=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),X=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/traces"),method:"GET",headers:K,queryParameters:{...F,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(X.ok)return{data:X.body,rawResponse:X.rawResponse};if(X.error.reason==="status-code")switch(X.error.statusCode){case 400:throw new y(X.error.body,X.rawResponse);case 401:throw new b(X.error.body,X.rawResponse);case 403:throw new v(X.error.body,X.rawResponse);case 405:throw new S(X.error.body,X.rawResponse);case 404:throw new R(X.error.body,X.rawResponse);default:throw new m({statusCode:X.error.statusCode,body:X.error.body,rawResponse:X.rawResponse})}switch(X.error.reason){case"non-json":throw new m({statusCode:X.error.statusCode,body:X.error.rawBody,rawResponse:X.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/traces.");case"unknown":throw new m({message:X.error.errorMessage,rawResponse:X.rawResponse})}}deleteMultiple(r,e){return C.fromPromise(this.__deleteMultiple(r,e))}async __deleteMultiple(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/traces"),method:"DELETE",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/traces.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},al=class{constructor(r){this._options=r}list(r={},e){return C.fromPromise(this.__list(r,e))}async __list(r={},e){var t,a,s,i,l,u,c,w;let{page:d,limit:o}=r,n={};d!=null&&(n.page=d.toString()),o!=null&&(n.limit=o.toString());let _=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),h=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/unstable/dashboard-widgets"),method:"GET",headers:_,queryParameters:{...n,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new k.BadRequestError(h.error.body,h.rawResponse);case 401:throw new k.UnauthorizedError(h.error.body,h.rawResponse);case 403:throw new k.AccessDeniedError(h.error.body,h.rawResponse);case 405:throw new k.MethodNotAllowedError(h.error.body,h.rawResponse);case 429:throw new k.TooManyRequestsError(h.error.body,h.rawResponse);case 500:throw new k.InternalServerError(h.error.body,h.rawResponse);case 400:throw new y(h.error.body,h.rawResponse);case 401:throw new b(h.error.body,h.rawResponse);case 403:throw new v(h.error.body,h.rawResponse);case 405:throw new S(h.error.body,h.rawResponse);case 404:throw new R(h.error.body,h.rawResponse);default:throw new m({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}switch(h.error.reason){case"non-json":throw new m({statusCode:h.error.statusCode,body:h.error.rawBody,rawResponse:h.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/unstable/dashboard-widgets.");case"unknown":throw new m({message:h.error.errorMessage,rawResponse:h.rawResponse})}}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/unstable/dashboard-widgets"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new k.BadRequestError(o.error.body,o.rawResponse);case 401:throw new k.UnauthorizedError(o.error.body,o.rawResponse);case 403:throw new k.AccessDeniedError(o.error.body,o.rawResponse);case 405:throw new k.MethodNotAllowedError(o.error.body,o.rawResponse);case 429:throw new k.TooManyRequestsError(o.error.body,o.rawResponse);case 500:throw new k.InternalServerError(o.error.body,o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/unstable/dashboard-widgets.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}get(r,e){return C.fromPromise(this.__get(r,e))}async __get(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/unstable/dashboard-widgets/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new k.BadRequestError(o.error.body,o.rawResponse);case 401:throw new k.UnauthorizedError(o.error.body,o.rawResponse);case 403:throw new k.AccessDeniedError(o.error.body,o.rawResponse);case 404:throw new k.NotFoundError(o.error.body,o.rawResponse);case 405:throw new k.MethodNotAllowedError(o.error.body,o.rawResponse);case 429:throw new k.TooManyRequestsError(o.error.body,o.rawResponse);case 500:throw new k.InternalServerError(o.error.body,o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/unstable/dashboard-widgets/{widgetId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}update(r,e,t){return C.fromPromise(this.__update(r,e,t))}async __update(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/unstable/dashboard-widgets/${encodeURIComponent(r)}`),method:"PATCH",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new k.BadRequestError(n.error.body,n.rawResponse);case 401:throw new k.UnauthorizedError(n.error.body,n.rawResponse);case 403:throw new k.AccessDeniedError(n.error.body,n.rawResponse);case 404:throw new k.NotFoundError(n.error.body,n.rawResponse);case 405:throw new k.MethodNotAllowedError(n.error.body,n.rawResponse);case 429:throw new k.TooManyRequestsError(n.error.body,n.rawResponse);case 500:throw new k.InternalServerError(n.error.body,n.rawResponse);case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PATCH /api/public/unstable/dashboard-widgets/{widgetId}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}delete(r,e){return C.fromPromise(this.__delete(r,e))}async __delete(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/unstable/dashboard-widgets/${encodeURIComponent(r)}`),method:"DELETE",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new k.BadRequestError(o.error.body,o.rawResponse);case 401:throw new k.UnauthorizedError(o.error.body,o.rawResponse);case 403:throw new k.AccessDeniedError(o.error.body,o.rawResponse);case 404:throw new k.NotFoundError(o.error.body,o.rawResponse);case 405:throw new k.MethodNotAllowedError(o.error.body,o.rawResponse);case 409:throw new k.ConflictError(o.error.body,o.rawResponse);case 429:throw new k.TooManyRequestsError(o.error.body,o.rawResponse);case 500:throw new k.InternalServerError(o.error.body,o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/unstable/dashboard-widgets/{widgetId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},nl=class{constructor(r){this._options=r}list(r={},e){return C.fromPromise(this.__list(r,e))}async __list(r={},e){var t,a,s,i,l,u,c,w;let{page:d,limit:o}=r,n={};d!=null&&(n.page=d.toString()),o!=null&&(n.limit=o.toString());let _=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),h=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/unstable/dashboards"),method:"GET",headers:_,queryParameters:{...n,...e?.queryParams},timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(h.ok)return{data:h.body,rawResponse:h.rawResponse};if(h.error.reason==="status-code")switch(h.error.statusCode){case 400:throw new k.BadRequestError(h.error.body,h.rawResponse);case 401:throw new k.UnauthorizedError(h.error.body,h.rawResponse);case 403:throw new k.AccessDeniedError(h.error.body,h.rawResponse);case 405:throw new k.MethodNotAllowedError(h.error.body,h.rawResponse);case 429:throw new k.TooManyRequestsError(h.error.body,h.rawResponse);case 500:throw new k.InternalServerError(h.error.body,h.rawResponse);case 400:throw new y(h.error.body,h.rawResponse);case 401:throw new b(h.error.body,h.rawResponse);case 403:throw new v(h.error.body,h.rawResponse);case 405:throw new S(h.error.body,h.rawResponse);case 404:throw new R(h.error.body,h.rawResponse);default:throw new m({statusCode:h.error.statusCode,body:h.error.body,rawResponse:h.rawResponse})}switch(h.error.reason){case"non-json":throw new m({statusCode:h.error.statusCode,body:h.error.rawBody,rawResponse:h.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/unstable/dashboards.");case"unknown":throw new m({message:h.error.errorMessage,rawResponse:h.rawResponse})}}create(r,e){return C.fromPromise(this.__create(r,e))}async __create(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),"/api/public/unstable/dashboards"),method:"POST",headers:d,contentType:"application/json",queryParameters:e?.queryParams,requestType:"json",body:r,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new k.BadRequestError(o.error.body,o.rawResponse);case 401:throw new k.UnauthorizedError(o.error.body,o.rawResponse);case 403:throw new k.AccessDeniedError(o.error.body,o.rawResponse);case 404:throw new k.NotFoundError(o.error.body,o.rawResponse);case 405:throw new k.MethodNotAllowedError(o.error.body,o.rawResponse);case 429:throw new k.TooManyRequestsError(o.error.body,o.rawResponse);case 500:throw new k.InternalServerError(o.error.body,o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/unstable/dashboards.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}get(r,e){return C.fromPromise(this.__get(r,e))}async __get(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/unstable/dashboards/${encodeURIComponent(r)}`),method:"GET",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new k.BadRequestError(o.error.body,o.rawResponse);case 401:throw new k.UnauthorizedError(o.error.body,o.rawResponse);case 403:throw new k.AccessDeniedError(o.error.body,o.rawResponse);case 404:throw new k.NotFoundError(o.error.body,o.rawResponse);case 405:throw new k.MethodNotAllowedError(o.error.body,o.rawResponse);case 429:throw new k.TooManyRequestsError(o.error.body,o.rawResponse);case 500:throw new k.InternalServerError(o.error.body,o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling GET /api/public/unstable/dashboards/{dashboardId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}update(r,e,t){return C.fromPromise(this.__update(r,e,t))}async __update(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/unstable/dashboards/${encodeURIComponent(r)}`),method:"PATCH",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new k.BadRequestError(n.error.body,n.rawResponse);case 401:throw new k.UnauthorizedError(n.error.body,n.rawResponse);case 403:throw new k.AccessDeniedError(n.error.body,n.rawResponse);case 404:throw new k.NotFoundError(n.error.body,n.rawResponse);case 405:throw new k.MethodNotAllowedError(n.error.body,n.rawResponse);case 429:throw new k.TooManyRequestsError(n.error.body,n.rawResponse);case 500:throw new k.InternalServerError(n.error.body,n.rawResponse);case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PATCH /api/public/unstable/dashboards/{dashboardId}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}delete(r,e){return C.fromPromise(this.__delete(r,e))}async __delete(r,e){var t,a,s,i,l,u,c,w;let d=x((t=this._options)==null?void 0:t.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(s=e?.xLangfuseSdkName)!=null?s:(a=this._options)==null?void 0:a.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(l=e?.xLangfuseSdkVersion)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(c=e?.xLangfusePublicKey)!=null?c:(u=this._options)==null?void 0:u.xLangfusePublicKey}),e?.headers),o=await P({url:E.join((w=await g.get(this._options.baseUrl))!=null?w:await g.get(this._options.environment),`/api/public/unstable/dashboards/${encodeURIComponent(r)}`),method:"DELETE",headers:d,queryParameters:e?.queryParams,timeoutMs:e?.timeoutInSeconds!=null?e.timeoutInSeconds*1e3:6e4,maxRetries:e?.maxRetries,abortSignal:e?.abortSignal});if(o.ok)return{data:o.body,rawResponse:o.rawResponse};if(o.error.reason==="status-code")switch(o.error.statusCode){case 400:throw new k.BadRequestError(o.error.body,o.rawResponse);case 401:throw new k.UnauthorizedError(o.error.body,o.rawResponse);case 403:throw new k.AccessDeniedError(o.error.body,o.rawResponse);case 404:throw new k.NotFoundError(o.error.body,o.rawResponse);case 405:throw new k.MethodNotAllowedError(o.error.body,o.rawResponse);case 429:throw new k.TooManyRequestsError(o.error.body,o.rawResponse);case 500:throw new k.InternalServerError(o.error.body,o.rawResponse);case 400:throw new y(o.error.body,o.rawResponse);case 401:throw new b(o.error.body,o.rawResponse);case 403:throw new v(o.error.body,o.rawResponse);case 405:throw new S(o.error.body,o.rawResponse);case 404:throw new R(o.error.body,o.rawResponse);default:throw new m({statusCode:o.error.statusCode,body:o.error.body,rawResponse:o.rawResponse})}switch(o.error.reason){case"non-json":throw new m({statusCode:o.error.statusCode,body:o.error.rawBody,rawResponse:o.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/unstable/dashboards/{dashboardId}.");case"unknown":throw new m({message:o.error.errorMessage,rawResponse:o.rawResponse})}}addPlacement(r,e,t){return C.fromPromise(this.__addPlacement(r,e,t))}async __addPlacement(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/unstable/dashboards/${encodeURIComponent(r)}/placements`),method:"POST",headers:o,contentType:"application/json",queryParameters:t?.queryParams,requestType:"json",body:e,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new k.BadRequestError(n.error.body,n.rawResponse);case 401:throw new k.UnauthorizedError(n.error.body,n.rawResponse);case 403:throw new k.AccessDeniedError(n.error.body,n.rawResponse);case 404:throw new k.NotFoundError(n.error.body,n.rawResponse);case 405:throw new k.MethodNotAllowedError(n.error.body,n.rawResponse);case 409:throw new k.ConflictError(n.error.body,n.rawResponse);case 429:throw new k.TooManyRequestsError(n.error.body,n.rawResponse);case 500:throw new k.InternalServerError(n.error.body,n.rawResponse);case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling POST /api/public/unstable/dashboards/{dashboardId}/placements.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}updatePlacement(r,e,t,a){return C.fromPromise(this.__updatePlacement(r,e,t,a))}async __updatePlacement(r,e,t,a){var s,i,l,u,c,w,d,o;let n=x((s=this._options)==null?void 0:s.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(l=a?.xLangfuseSdkName)!=null?l:(i=this._options)==null?void 0:i.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(c=a?.xLangfuseSdkVersion)!=null?c:(u=this._options)==null?void 0:u.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(d=a?.xLangfusePublicKey)!=null?d:(w=this._options)==null?void 0:w.xLangfusePublicKey}),a?.headers),_=await P({url:E.join((o=await g.get(this._options.baseUrl))!=null?o:await g.get(this._options.environment),`/api/public/unstable/dashboards/${encodeURIComponent(r)}/placements/${encodeURIComponent(e)}`),method:"PATCH",headers:n,contentType:"application/json",queryParameters:a?.queryParams,requestType:"json",body:t,timeoutMs:a?.timeoutInSeconds!=null?a.timeoutInSeconds*1e3:6e4,maxRetries:a?.maxRetries,abortSignal:a?.abortSignal});if(_.ok)return{data:_.body,rawResponse:_.rawResponse};if(_.error.reason==="status-code")switch(_.error.statusCode){case 400:throw new k.BadRequestError(_.error.body,_.rawResponse);case 401:throw new k.UnauthorizedError(_.error.body,_.rawResponse);case 403:throw new k.AccessDeniedError(_.error.body,_.rawResponse);case 404:throw new k.NotFoundError(_.error.body,_.rawResponse);case 405:throw new k.MethodNotAllowedError(_.error.body,_.rawResponse);case 429:throw new k.TooManyRequestsError(_.error.body,_.rawResponse);case 500:throw new k.InternalServerError(_.error.body,_.rawResponse);case 400:throw new y(_.error.body,_.rawResponse);case 401:throw new b(_.error.body,_.rawResponse);case 403:throw new v(_.error.body,_.rawResponse);case 405:throw new S(_.error.body,_.rawResponse);case 404:throw new R(_.error.body,_.rawResponse);default:throw new m({statusCode:_.error.statusCode,body:_.error.body,rawResponse:_.rawResponse})}switch(_.error.reason){case"non-json":throw new m({statusCode:_.error.statusCode,body:_.error.rawBody,rawResponse:_.rawResponse});case"timeout":throw new L("Timeout exceeded when calling PATCH /api/public/unstable/dashboards/{dashboardId}/placements/{placementId}.");case"unknown":throw new m({message:_.error.errorMessage,rawResponse:_.rawResponse})}}deletePlacement(r,e,t){return C.fromPromise(this.__deletePlacement(r,e,t))}async __deletePlacement(r,e,t){var a,s,i,l,u,c,w,d;let o=x((a=this._options)==null?void 0:a.headers,T({Authorization:await this._getAuthorizationHeader(),"X-Langfuse-Sdk-Name":(i=t?.xLangfuseSdkName)!=null?i:(s=this._options)==null?void 0:s.xLangfuseSdkName,"X-Langfuse-Sdk-Version":(u=t?.xLangfuseSdkVersion)!=null?u:(l=this._options)==null?void 0:l.xLangfuseSdkVersion,"X-Langfuse-Public-Key":(w=t?.xLangfusePublicKey)!=null?w:(c=this._options)==null?void 0:c.xLangfusePublicKey}),t?.headers),n=await P({url:E.join((d=await g.get(this._options.baseUrl))!=null?d:await g.get(this._options.environment),`/api/public/unstable/dashboards/${encodeURIComponent(r)}/placements/${encodeURIComponent(e)}`),method:"DELETE",headers:o,queryParameters:t?.queryParams,timeoutMs:t?.timeoutInSeconds!=null?t.timeoutInSeconds*1e3:6e4,maxRetries:t?.maxRetries,abortSignal:t?.abortSignal});if(n.ok)return{data:n.body,rawResponse:n.rawResponse};if(n.error.reason==="status-code")switch(n.error.statusCode){case 400:throw new k.BadRequestError(n.error.body,n.rawResponse);case 401:throw new k.UnauthorizedError(n.error.body,n.rawResponse);case 403:throw new k.AccessDeniedError(n.error.body,n.rawResponse);case 404:throw new k.NotFoundError(n.error.body,n.rawResponse);case 405:throw new k.MethodNotAllowedError(n.error.body,n.rawResponse);case 429:throw new k.TooManyRequestsError(n.error.body,n.rawResponse);case 500:throw new k.InternalServerError(n.error.body,n.rawResponse);case 400:throw new y(n.error.body,n.rawResponse);case 401:throw new b(n.error.body,n.rawResponse);case 403:throw new v(n.error.body,n.rawResponse);case 405:throw new S(n.error.body,n.rawResponse);case 404:throw new R(n.error.body,n.rawResponse);default:throw new m({statusCode:n.error.statusCode,body:n.error.body,rawResponse:n.rawResponse})}switch(n.error.reason){case"non-json":throw new m({statusCode:n.error.statusCode,body:n.error.rawBody,rawResponse:n.rawResponse});case"timeout":throw new L("Timeout exceeded when calling DELETE /api/public/unstable/dashboards/{dashboardId}/placements/{placementId}.");case"unknown":throw new m({message:n.error.errorMessage,rawResponse:n.rawResponse})}}async _getAuthorizationHeader(){let r=await g.get(this._options.username),e=await g.get(this._options.password);if(r!=null&&e!=null)return G.toAuthorizationHeader({username:r,password:e})}},sl=class{constructor(r){this._options=r}get dashboardWidgets(){var r;return(r=this._dashboardWidgets)!=null?r:this._dashboardWidgets=new al(this._options)}get dashboards(){var r;return(r=this._dashboards)!=null?r:this._dashboards=new nl(this._options)}},Ga=class{constructor(r){this._options={...r,headers:x({"X-Langfuse-Sdk-Name":r?.xLangfuseSdkName,"X-Langfuse-Sdk-Version":r?.xLangfuseSdkVersion,"X-Langfuse-Public-Key":r?.xLangfusePublicKey},r?.headers)}}get annotationQueues(){var r;return(r=this._annotationQueues)!=null?r:this._annotationQueues=new Ti(this._options)}get blobStorageIntegrations(){var r;return(r=this._blobStorageIntegrations)!=null?r:this._blobStorageIntegrations=new Pi(this._options)}get comments(){var r;return(r=this._comments)!=null?r:this._comments=new Ci(this._options)}get datasetItems(){var r;return(r=this._datasetItems)!=null?r:this._datasetItems=new Ai(this._options)}get datasetRunItems(){var r;return(r=this._datasetRunItems)!=null?r:this._datasetRunItems=new ki(this._options)}get datasets(){var r;return(r=this._datasets)!=null?r:this._datasets=new Ii(this._options)}get evaluationRules(){var r;return(r=this._evaluationRules)!=null?r:this._evaluationRules=new Ni(this._options)}get evaluators(){var r;return(r=this._evaluators)!=null?r:this._evaluators=new Mi(this._options)}get experiments(){var r;return(r=this._experiments)!=null?r:this._experiments=new Vi(this._options)}get feedback(){var r;return(r=this._feedback)!=null?r:this._feedback=new Ui(this._options)}get health(){var r;return(r=this._health)!=null?r:this._health=new Bi(this._options)}get ingestion(){var r;return(r=this._ingestion)!=null?r:this._ingestion=new ji(this._options)}get legacy(){var r;return(r=this._legacy)!=null?r:this._legacy=new Di(this._options)}get llmConnections(){var r;return(r=this._llmConnections)!=null?r:this._llmConnections=new Gi(this._options)}get media(){var r;return(r=this._media)!=null?r:this._media=new Hi(this._options)}get metrics(){var r;return(r=this._metrics)!=null?r:this._metrics=new Fi(this._options)}get models(){var r;return(r=this._models)!=null?r:this._models=new $i(this._options)}get observations(){var r;return(r=this._observations)!=null?r:this._observations=new Wi(this._options)}get opentelemetry(){var r;return(r=this._opentelemetry)!=null?r:this._opentelemetry=new Qi(this._options)}get organizations(){var r;return(r=this._organizations)!=null?r:this._organizations=new Yi(this._options)}get projects(){var r;return(r=this._projects)!=null?r:this._projects=new Ji(this._options)}get promptVersion(){var r;return(r=this._promptVersion)!=null?r:this._promptVersion=new Zi(this._options)}get prompts(){var r;return(r=this._prompts)!=null?r:this._prompts=new Oi(this._options)}get scim(){var r;return(r=this._scim)!=null?r:this._scim=new qi(this._options)}get scoreConfigs(){var r;return(r=this._scoreConfigs)!=null?r:this._scoreConfigs=new el(this._options)}get scoresV3(){var r;return(r=this._scoresV3)!=null?r:this._scoresV3=new rl(this._options)}get scores(){var r;return(r=this._scores)!=null?r:this._scores=new Da(this._options)}get sessions(){var r;return(r=this._sessions)!=null?r:this._sessions=new ol(this._options)}get trace(){var r;return(r=this._trace)!=null?r:this._trace=new tl(this._options)}get unstable(){var r;return(r=this._unstable)!=null?r:this._unstable=new sl(this._options)}},Uo=class{constructor(r){let{source:e}=r;if(this._source=e,e==="base64_data_uri"){let[t,a]=this.parseBase64DataUri(r.base64DataUri);this._contentBytes=t,this._contentType=a}else this._contentBytes=r.contentBytes,this._contentType=r.contentType}parseBase64DataUri(r){try{if(!r||typeof r!="string")throw new Error("Data URI is not a string");if(!r.startsWith("data:"))throw new Error("Data URI does not start with 'data:'");let[e,t]=r.slice(5).split(",",2);if(!e||!t)throw new Error("Invalid URI");let a=e.split(";");if(!a.includes("base64"))throw new Error("Data is not base64 encoded");let s=a[0];if(!s)throw new Error("Content type is empty");return[ko(t),s]}catch(e){return re().error("Error parsing base64 data URI",e),[void 0,void 0]}}async getId(){let r=await this.getSha256Hash();return r?r.replaceAll("+","-").replaceAll("/","_").slice(0,22):null}get contentLength(){var r;return(r=this._contentBytes)==null?void 0:r.length}async getSha256Hash(){if(this._contentBytes)try{let r=await crypto.subtle.digest("SHA-256",this._contentBytes);return To(new Uint8Array(r))}catch(r){re().warn("[Langfuse] Failed to generate SHA-256 hash for media content:",r);return}}async getTag(){let r=await this.getId();return!this._contentType||!this._source||!r?null:`@@@langfuseMedia:type=${this._contentType}|id=${r}|source=${this._source}@@@`}get base64DataUri(){return this._contentBytes?`data:${this._contentType};base64,${To(this._contentBytes)}`:null}toJSON(){return this.base64DataUri}};async function Ha(r){var e;let{apiClient:t,media:a,traceId:s,observationId:i,datasetId:l,datasetItemId:u,field:c,maxRetries:w=3,baseDelay:d=1e3}=r,o=(e=r.logger)!=null?e:re(),n=await a.getSha256Hash();if(!a.contentLength||!a._contentType||!n||!a._contentBytes)throw new Error("Cannot upload media: media content is incomplete.");let{uploadUrl:_,mediaId:h}=await t.media.getUploadUrl({contentLength:a.contentLength,traceId:s,observationId:i,datasetId:l,datasetItemId:u,field:c,contentType:a._contentType,sha256Hash:n});if(!_){o.debug(`Media status: Media with ID ${h} already uploaded. Skipping duplicate upload.`);return}let p=await a.getId();if(p!==h)throw new Error(`Media integrity error: Media ID mismatch between SDK (${p}) and Server (${h}). Upload cancelled.`);o.debug(`Uploading media ${h}...`);let f=Date.now(),A=await il({uploadUrl:_,contentBytes:a._contentBytes,contentType:a._contentType,contentSha256Hash:n,maxRetries:w,baseDelay:d});if(!A)throw new Error("Media upload process failed");let I=A.status===200||A.status===201;if(await t.media.patch(h,{uploadedAt:new Date().toISOString(),uploadHttpStatus:A.status,uploadHttpError:await A.text(),uploadTimeMs:Date.now()-f}),o.debug(`Media upload status reported for ${h}`),!I)throw new Error(`Media upload failed with HTTP ${A.status} after ${w} retries.`)}async function il(r){let{uploadUrl:e,contentType:t,contentSha256Hash:a,contentBytes:s,maxRetries:i,baseDelay:l}=r;for(let u=0;u<=i;u++)try{let c;try{c=new URL(e).hostname}catch{c=""}let d=c==="storage.googleapis.com"||c.endsWith(".storage.googleapis.com")?{"Content-Type":t}:{"Content-Type":t,"x-amz-checksum-sha256":a,"x-ms-blob-type":"BlockBlob"},o=await fetch(e,{method:"PUT",body:s,headers:d});if(u<i&&o.status!==200&&o.status!==201)throw new Error(`Upload failed with status ${o.status}`);return o}catch(c){if(u===i)throw c;let w=l*Math.pow(2,u),d=Math.random()*1e3;await new Promise(o=>setTimeout(o,w+d))}}var ll=["experimentId","experimentName","experimentMetadata","experimentDatasetId","experimentItemId","experimentItemMetadata","experimentItemRootObservationId"],me={userId:ee("langfuse_user_id"),sessionId:ee("langfuse_session_id"),metadata:ee("langfuse_metadata"),version:ee("langfuse_version"),tags:ee("langfuse_tags"),traceName:ee("langfuse_trace_name"),environment:ee("langfuse_environment"),promptName:ee("langfuse_prompt_name"),promptVersion:ee("langfuse_prompt_version"),experimentId:ee("langfuse_experiment_id"),experimentName:ee("langfuse_experiment_name"),experimentMetadata:ee("langfuse_experiment_metadata"),experimentDatasetId:ee("langfuse_experiment_dataset_id"),experimentItemId:ee("langfuse_experiment_item_id"),experimentItemMetadata:ee("langfuse_experiment_item_metadata"),experimentItemRootObservationId:ee("langfuse_experiment_item_root_observation_id")},q="langfuse_",dl=",",Fa="langfuse_trace_id";function $a(r){let e=vo.getBaggage(r),t=e?.getEntry(Fa);if(t?.value)return t.value.toLowerCase()}function Wa(r){let e={},t=vo.getBaggage(r);t&&t.getAllEntries().forEach(([n,_])=>{if(n!==Fa&&n.startsWith(q)){let h=wl(n);if(h){if(h==="langfuse.environment"){Gt(_.value)&&(e[h]=_.value);return}if(h==="langfuse.observation.prompt.version"&&/^\d+$/.test(_.value)){e[h]=Number(_.value);return}let p=n==cl("tags");e[h]=p?_.value.split(dl):_.value}}});let a=r.getValue(me.userId);if(a&&typeof a=="string"){let n=J("userId");e[n]=a}let s=r.getValue(me.sessionId);if(s&&typeof s=="string"){let n=J("sessionId");e[n]=s}let i=r.getValue(me.version);if(i&&typeof i=="string"){let n=J("version");e[n]=i}let l=r.getValue(me.traceName);if(l&&typeof l=="string"){let n=J("traceName");e[n]=l}let u=r.getValue(me.environment);Gt(u)&&(e["langfuse.environment"]=u);let c=r.getValue(me.tags);if(c&&Array.isArray(c)){let n=J("tags");e[n]=c}let w=r.getValue(me.promptName);if(w&&typeof w=="string"){let n=J("promptName");e[n]=w}let d=r.getValue(me.promptVersion);if(typeof d=="number"){let n=J("promptVersion");e[n]=d}let o=r.getValue(me.metadata);if(o&&typeof o=="object"&&o!==null)for(let[n,_]of Object.entries(o)){let h=`langfuse.trace.metadata.${n}`;e[h]=String(_)}for(let n of ll){let _=me[n],h=r.getValue(_);if(h&&typeof h=="string"){let p=J(n);e[p]=h}}return e[J("experimentItemRootObservationId")]&&(e["langfuse.environment"]=Dn),e}var ul=/^(?!langfuse)[a-z0-9_-]+$/;function Gt(r){let e=re();return typeof r!="string"?(r!==void 0&&e.warn("Propagated attribute 'environment' must be a string. Dropping value."),!1):r.length>40?(e.warn(`Propagated attribute 'environment' value is over 40 characters (${r.length} chars). Dropping value.`),!1):ul.test(r)?!0:(e.warn("Propagated attribute 'environment' must be a lowercase alphanumeric string with optional hyphens or underscores and must not start with 'langfuse'. Dropping value."),!1)}function J(r){switch(r){case"userId":return"user.id";case"sessionId":return"session.id";case"version":return"langfuse.version";case"traceName":return"langfuse.trace.name";case"environment":return"langfuse.environment";case"metadata":return"langfuse.trace.metadata";case"tags":return"langfuse.trace.tags";case"promptName":return"langfuse.observation.prompt.name";case"promptVersion":return"langfuse.observation.prompt.version";case"experimentId":return"langfuse.experiment.id";case"experimentName":return"langfuse.experiment.name";case"experimentMetadata":return"langfuse.experiment.metadata";case"experimentDatasetId":return"langfuse.experiment.dataset.id";case"experimentItemId":return"langfuse.experiment.item.id";case"experimentItemMetadata":return"langfuse.experiment.item.metadata";case"experimentItemRootObservationId":return"langfuse.experiment.item.root_observation_id";default:throw Error("Unhandled propagated key",r)}}function cl(r){switch(r){case"userId":return`${q}user_id`;case"sessionId":return`${q}session_id`;case"version":return`${q}version`;case"traceName":return`${q}trace_name`;case"environment":return`${q}environment`;case"metadata":return`${q}metadata`;case"tags":return`${q}tags`;case"promptName":return`${q}prompt_name`;case"promptVersion":return`${q}prompt_version`;case"experimentId":return`${q}experiment_id`;case"experimentName":return`${q}experiment_name`;case"experimentMetadata":return`${q}experiment_metadata`;case"experimentDatasetId":return`${q}experiment_dataset_id`;case"experimentItemId":return`${q}experiment_item_id`;case"experimentItemMetadata":return`${q}experiment_item_metadata`;case"experimentItemRootObservationId":return`${q}experiment_item_root_observation_id`;default:throw Error("Unhandled propagated key",r)}}function wl(r){if(!r.startsWith(q))return;let e=r.slice(q.length);if(e.startsWith("metadata_"))return`langfuse.trace.metadata.${e.slice(9)}`;switch(e){case"user_id":return J("userId");case"session_id":return J("sessionId");case"version":return J("version");case"trace_name":return J("traceName");case"environment":return J("environment");case"tags":return J("tags");case"prompt_name":return J("promptName");case"prompt_version":return J("promptVersion");case"experiment_id":return J("experimentId");case"experiment_name":return J("experimentName");case"experiment_metadata":return J("experimentMetadata");case"experiment_dataset_id":return J("experimentDatasetId");case"experiment_item_id":return J("experimentItemId");case"experiment_item_metadata":return J("experimentItemMetadata");case"experiment_item_root_observation_id":return J("experimentItemRootObservationId")}}Un();var hl=class{constructor(r){this.pendingMediaUploads=new Set,this.apiClient=r.apiClient}get logger(){return re()}async flush(){await Promise.all(Array.from(this.pendingMediaUploads))}async process(r){var e;let t=[j.OBSERVATION_INPUT,j.TRACE_INPUT,j.OBSERVATION_OUTPUT,j.TRACE_OUTPUT,j.OBSERVATION_METADATA,j.TRACE_METADATA];for(let a of t){let s=Object.keys(r.attributes).filter(i=>i.startsWith(a));for(let i of s){let l=r.attributes[i];if(typeof l!="string"){this.logger.warn(`Span attribute ${a} is not a stringified object. Skipping media handling.`);continue}let u=l,c=/data:[^;]+;base64,[A-Za-z0-9+/]+=*/g,w=[...new Set((e=l.match(c))!=null?e:[])];if(w.length!==0){for(let d of w){let o=new Uo({base64DataUri:d,source:"base64_data_uri"}),n=await o.getTag();if(!n){this.logger.warn("Failed to create Langfuse media tag. Skipping media item.");continue}this.scheduleUpload({span:r,media:o,field:a.includes("input")?"input":a.includes("output")?"output":"metadata"}),u=u.replaceAll(d,n)}r.attributes[i]=u}}}if(["ai","gen_ai"].includes(r.instrumentationScope.name)){let a=["ai.prompt.messages","ai.prompt"];for(let i of a){let l=r.attributes[i];if(!l||typeof l!="string")continue;let u=l;try{let c=JSON.parse(l);if(Array.isArray(c)){for(let w of c)if(Array.isArray(w.content)){let d=w.content;for(let o of d)if(o.type==="file"){let n=null,_=o.mediaType;if(typeof o.data=="string"&&!o.data.startsWith("http")&&(n=o.data),typeof o.image=="string"&&!o.image.startsWith("http")&&(n=o.image),!n||typeof _!="string")continue;u=await this.replaceBytesMedia({span:r,mediaReplacedValue:u,base64Content:n,contentType:_,field:"input"})}}}r.attributes[i]=u}catch(c){this.logger.warn(`Failed to handle media for AI SDK attribute ${i} for span ${r.spanContext().spanId}`,c)}}let s=[{attribute:"gen_ai.input.messages",field:"input"},{attribute:"gen_ai.output.messages",field:"output"}];for(let{attribute:i,field:l}of s){let u=r.attributes[i];if(!u||typeof u!="string")continue;let c=u;try{let w=JSON.parse(u);if(Array.isArray(w)){for(let d of w)if(Array.isArray(d.parts))for(let o of d.parts){let n=o.content,_=o.mime_type;if(o.type!=="blob"||typeof n!="string"||!n||typeof _!="string"||n.startsWith("http"))continue;let h=ml(n);h&&(c=await this.replaceBytesMedia({span:r,mediaReplacedValue:c,base64Content:h.base64Content,contentToReplace:n,contentType:_,field:l}))}}r.attributes[i]=c}catch(w){this.logger.warn(`Failed to handle media for AI SDK v7 attribute ${i} for span ${r.spanContext().spanId}`,w)}}}}async replaceBytesMedia(r){var e;let t=new Uo({contentType:r.contentType,contentBytes:ko(r.base64Content),source:"bytes"}),a=await t.getTag();return a?(this.scheduleUpload({span:r.span,media:t,field:r.field}),r.mediaReplacedValue.replaceAll((e=r.contentToReplace)!=null?e:r.base64Content,a)):(this.logger.warn("Failed to create Langfuse media tag. Skipping media item."),r.mediaReplacedValue)}scheduleUpload(r){let{span:e,field:t,media:a}=r,s=this.handleUpload({media:a,traceId:e.spanContext().traceId,observationId:e.spanContext().spanId,field:t}).catch(i=>{this.logger.error("Media upload failed with error: ",i)});this.pendingMediaUploads.add(s),s.finally(()=>{this.pendingMediaUploads.delete(s)})}async handleUpload({media:r,traceId:e,observationId:t,field:a}){try{await Ha({apiClient:this.apiClient,media:r,traceId:e,observationId:t,field:a,logger:this.logger})}catch(s){this.logger.error(`Error processing media item: ${s}`)}}};function ml(r){if(!r.startsWith("data:"))return{base64Content:r};let e=r.indexOf(";base64,");if(e===-1)return;let t=r.slice(e+8);if(t)return{base64Content:t}}var Bo=64*1024*1024;function gl(r){var e,t;let a=0;for(let s of r){a+=s.name.length+((t=(e=s.status.message)==null?void 0:e.length)!=null?t:0)+jo(s.attributes);for(let i of s.events)a+=i.name.length+jo(i.attributes);for(let i of s.links)a+=jo(i.attributes)}return a}function jo(r={}){let e=0;for(let[t,a]of Object.entries(r))if(e+=t.length,typeof a=="string")e+=a.length;else if(Array.isArray(a))for(let s of a)typeof s=="string"&&(e+=s.length);return e}function _l(r){let e=r?.trim();if(!e)return Bo;let t=/^\d+$/.test(e)?Number(e):Number.NaN;return Number.isSafeInteger(t)&&t>0?t:(re().warn("Invalid LANGFUSE_OTEL_MAX_BATCH_SIZE_BYTES. Using the default limit.",{defaultMaxBatchSizeBytes:Bo}),Bo)}function pl(){return _l(oe("LANGFUSE_OTEL_MAX_BATCH_SIZE_BYTES"))}var fl=class{constructor(r){this.delegate=r.delegate,this.maxBatchSizeBytes=r.maxBatchSizeBytes}export(r,e){let t=gl(r);if(t>this.maxBatchSizeBytes){re().warn("Dropping OpenTelemetry span batch because it exceeds the configured byte limit.",{maxBatchSizeBytes:this.maxBatchSizeBytes,sizeLowerBoundBytes:t,spanCount:r.length}),e({code:ke.FAILED,error:new Error(`OpenTelemetry span batch size of at least ${t} bytes exceeds the configured limit of ${this.maxBatchSizeBytes} bytes.`)});return}this.delegate.export(r,e)}forceFlush(){var r,e,t;return(t=(e=(r=this.delegate).forceFlush)==null?void 0:e.call(r))!=null?t:Promise.resolve()}shutdown(){return this.delegate.shutdown()}},yl=[rr,"agent_framework","ai","haystack","langsmith","litellm","openinference","opentelemetry.instrumentation.anthropic","opentelemetry.instrumentation.aws_bedrock","opentelemetry.instrumentation.bedrock","opentelemetry.instrumentation.gemini","opentelemetry.instrumentation.google_genai","opentelemetry.instrumentation.google_generativeai","opentelemetry.instrumentation.openai","opentelemetry.instrumentation.openai_v2","opentelemetry.instrumentation.vertex_ai","opentelemetry.instrumentation.vertexai","strands-agents","vllm"],bl=new Set(["ai"]);function vl(r){return r.instrumentationScope.name===rr}function Rl(r){return Object.keys(r.attributes).some(e=>e.startsWith("gen_ai."))}function Sl(r){let e=r.instrumentationScope.name;return yl.some(t=>e===t||!bl.has(t)&&e.startsWith(`${t}.`))}function xl(r){return vl(r)||Rl(r)||Sl(r)}var Ya=class{constructor(r){this.pendingEndedSpans=new Set,this.spanExportExpectationById=new Map;var e,t,a,s,i,l,u,c,w,d,o,n,_;let h=re(),p=(e=r?.publicKey)!=null?e:oe("LANGFUSE_PUBLIC_KEY"),f=(t=r?.secretKey)!=null?t:oe("LANGFUSE_SECRET_KEY"),A=(i=(s=(a=r?.baseUrl)!=null?a:oe("LANGFUSE_BASE_URL"))!=null?s:oe("LANGFUSE_BASEURL"))!=null?i:"https://cloud.langfuse.com";!r?.exporter&&!p&&h.warn("No exporter configured and no public key provided in constructor or as LANGFUSE_PUBLIC_KEY env var. Span exports will fail."),!r?.exporter&&!f&&h.warn("No exporter configured and no secret key provided in constructor or as LANGFUSE_SECRET_KEY env var. Span exports will fail."),r?.exporter&&r.compression!==void 0&&h.warn("The compression option is ignored because a custom exporter was provided. Configure compression on the exporter instead.");let I=(l=r?.flushAt)!=null?l:oe("LANGFUSE_FLUSH_AT"),V=(u=r?.flushInterval)!=null?u:oe("LANGFUSE_FLUSH_INTERVAL"),H=Ht(`${p}:${f}`),D=(w=r?.timeout)!=null?w:Number((c=oe("LANGFUSE_TIMEOUT"))!=null?c:5),B=oe("LANGFUSE_MEDIA_UPLOAD_ENABLED"),N=(d=r?.mediaUploadEnabled)!=null?d:B?!["false","0"].includes(B.toLowerCase()):!0,F=r?.compression!==void 0?Qa(r.compression,"compression"):Qa(oe("LANGFUSE_OTEL_COMPRESSION"),"LANGFUSE_OTEL_COMPRESSION"),K=r?.exporter?r.exporter:new fl({maxBatchSizeBytes:pl(),delegate:new Ct({url:`${A}/api/public/otel/v1/traces`,headers:{Authorization:`Basic ${H}`,"x-langfuse-sdk-name":"javascript","x-langfuse-sdk-version":or,"x-langfuse-public-key":p??"<missing>",...r?.additionalHeaders},timeoutMillis:D*1e3,compression:F})});this.processor=r?.exportMode==="immediate"?new Mt(K):new er(K,{maxExportBatchSize:I?Number(I):void 0,scheduledDelayMillis:V?Number(V)*1e3:void 0}),this.publicKey=p,this.baseUrl=A,this.environment=(o=r?.environment)!=null?o:oe("LANGFUSE_TRACING_ENVIRONMENT"),this.release=(n=r?.release)!=null?n:oe("LANGFUSE_RELEASE"),this.mask=r?.mask,this.shouldExportSpan=(_=r?.shouldExportSpan)!=null?_:({otelSpan:X})=>xl(X),this.mediaUploadEnabled=N,this.apiClient=new Ga({baseUrl:this.baseUrl,username:this.publicKey,password:f,xLangfusePublicKey:this.publicKey,xLangfuseSdkVersion:or,xLangfuseSdkName:"javascript",environment:"",headers:r?.additionalHeaders}),this.mediaService=new hl({apiClient:this.apiClient}),h.debug("Initialized LangfuseSpanProcessor with params:",{publicKey:p,baseUrl:A,environment:this.environment,release:this.release,timeoutSeconds:D,flushAt:I,flushIntervalSeconds:V,mediaUploadEnabled:N,compression:F})}get logger(){return re()}onStart(r,e){let t=Wa(e);r.attributes[j.OBSERVATION_PROMPT_NAME]!=null&&(delete t[j.OBSERVATION_PROMPT_NAME],delete t[j.OBSERVATION_PROMPT_VERSION]),r.setAttributes({[j.ENVIRONMENT]:this.environment,[j.RELEASE]:this.release,...t});try{this.markAppRootCandidate(r,e)}catch(a){this.logger.debug("App-root start-time check failed. Span will not be marked as app root.",{spanName:r.name},a)}return this.processor.onStart(r,e)}onEnd(r){this.spanExportExpectationById.delete(r.spanContext().spanId);let e=this.processEndedSpan(r).catch(t=>{this.logger.error(t)});this.pendingEndedSpans.add(e),e.finally(()=>this.pendingEndedSpans.delete(e))}async flush(){await Promise.all(Array.from(this.pendingEndedSpans)),await this.mediaService.flush()}async forceFlush(){return await this.flush(),this.processor.forceFlush()}async shutdown(){return await this.flush(),this.processor.shutdown()}async processEndedSpan(r){var e,t;try{if(this.shouldExportSpan({otelSpan:r})===!1){this.logger.debug("Dropped span due to shouldExportSpan filter.",{spanName:r.name,instrumentationScope:r.instrumentationScope.name});return}}catch(a){this.logger.error("shouldExportSpan failed with error. Dropping span.",{spanName:r.name,instrumentationScope:r.instrumentationScope.name},a);return}await this.applyMaskInPlace(r),this.mediaUploadEnabled&&await this.mediaService.process(r),this.logger.isLevelEnabled(Io.DEBUG)&&this.logger.debug(`Processed span:
|
|
6
|
+
${JSON.stringify({name:r.name,traceId:r.spanContext().traceId,spanId:r.spanContext().spanId,parentSpanId:(t=(e=r.parentSpanContext)==null?void 0:e.spanId)!=null?t:null,attributes:r.attributes,startTime:new Date(vr(r.startTime)),endTime:new Date(vr(r.endTime)),durationMs:vr(r.duration),kind:r.kind,status:r.status,resource:r.resource.attributes,instrumentationScope:r.instrumentationScope},null,2)}`),this.processor.onEnd(r)}markAppRootCandidate(r,e){var t;let a=r.spanContext().traceId,s=r.spanContext().spanId,i=(t=r.parentSpanContext)==null?void 0:t.spanId,l=this.isExpectedExportedAtStart(r),u=$a(e),c=i!==void 0?this.spanExportExpectationById.get(i)===!0:!1,w=u===a;this.spanExportExpectationById.set(s,l),l&&!c&&!w&&r.setAttribute(j.IS_APP_ROOT,!0)}isExpectedExportedAtStart(r){let e=r;try{return this.shouldExportSpan({otelSpan:e})===!0}catch(t){return this.logger.debug("shouldExportSpan threw during app-root start-time check. Span will not be marked as app root.",{spanName:r.name,instrumentationScope:e.instrumentationScope.name},t),!1}}async applyMaskInPlace(r){let e=[j.OBSERVATION_INPUT,j.TRACE_INPUT,j.OBSERVATION_OUTPUT,j.TRACE_OUTPUT,j.OBSERVATION_METADATA,j.TRACE_METADATA];for(let t of e)t in r.attributes&&(r.attributes[t]=await this.applyMask(r.attributes[t]))}async applyMask(r){if(!this.mask)return r;try{return await this.mask({data:r})}catch(e){return this.logger.warn(`Applying mask function failed due to error, fully masking property. Error: ${e}`),"<fully masked due to failed mask function>"}}};function Qa(r,e){let t=r?.trim().toLowerCase();if(t){if(t===Oe.GZIP)return Oe.GZIP;if(t===Oe.NONE)return Oe.NONE;re().warn(`Invalid ${e} value "${r}". Expected "gzip" or "none". Falling back to the OTEL_EXPORTER_OTLP_*COMPRESSION environment variables.`)}}Z();Z();function El({input:r,output:e}={}){let t={[j.TRACE_INPUT]:ge(r),[j.TRACE_OUTPUT]:ge(e)};return Object.fromEntries(Object.entries(t).filter(([a,s])=>s!=null))}function Ja(r,e){let{metadata:t,input:a,output:s,level:i,statusMessage:l,version:u,environment:c,completionStartTime:w,model:d,modelParameters:o,usageDetails:n,costDetails:_,prompt:h}=e,p={[j.OBSERVATION_TYPE]:r,[j.OBSERVATION_LEVEL]:i,[j.OBSERVATION_STATUS_MESSAGE]:l,[j.VERSION]:u,[j.ENVIRONMENT]:c,[j.OBSERVATION_INPUT]:ge(a),[j.OBSERVATION_OUTPUT]:ge(s),[j.OBSERVATION_MODEL]:d,[j.OBSERVATION_USAGE_DETAILS]:ge(n),[j.OBSERVATION_COST_DETAILS]:ge(_),[j.OBSERVATION_COMPLETION_START_TIME]:ge(w),[j.OBSERVATION_MODEL_PARAMETERS]:ge(o),...h&&!h.isFallback?{[j.OBSERVATION_PROMPT_NAME]:h.name,[j.OBSERVATION_PROMPT_VERSION]:h.version}:{},...Ll(t,"observation")};return Object.fromEntries(Object.entries(p).filter(([f,A])=>A!=null))}function ge(r){try{return typeof r=="string"?r:r!=null?JSON.stringify(r):void 0}catch{return"<failed to serialize>"}}function Ll(r,e){let t=e==="observation"?j.OBSERVATION_METADATA:j.TRACE_METADATA,a={};if(r==null)return a;if(typeof r!="object"||Array.isArray(r)){let s=ge(r);s&&(a[t]=s)}else for(let[s,i]of Object.entries(r)){let l=typeof i=="string"?i:ge(i);l&&(a[`${t}.${s}`]=l)}return a}var zo=Symbol.for("langfuse");function Tl(){return{isolatedTracerProvider:null}}function Za(){let r=Tl();try{let e=globalThis;return typeof e!="object"||e===null?(re().warn("globalThis is not available, using fallback state"),r):(e[zo]||Object.defineProperty(e,zo,{value:r,writable:!1,configurable:!1,enumerable:!1}),e[zo])}catch(e){return e instanceof Error?re().error(`Failed to access global state: ${e.message}`):re().error(`Failed to access global state: ${String(e)}`),r}}function Ko(r){Za().isolatedTracerProvider=r}function Pl(){let{isolatedTracerProvider:r}=Za();return r||be.getTracerProvider()}function Oa(){return Pl().getTracer(rr,or)}var _e=class{constructor(r){var e;this.otelSpan=r.otelSpan,this.id=r.otelSpan.spanContext().spanId,this.traceId=r.otelSpan.spanContext().traceId,this.type=r.type,this.otelSpan.setAttributes(Ja(r.type,(e=r.attributes)!=null?e:{}))}get tracer(){return Oa()}end(r){this.otelSpan.end(r)}updateOtelSpanAttributes(r){this.otelSpan.setAttributes(Ja(this.type,r))}setTraceIO(r){return this.otelSpan.setAttributes(El(r)),this}setTraceAsPublic(){return this.otelSpan.setAttributes({[j.TRACE_PUBLIC]:!0}),this}startObservation(r,e,t){let{asType:a="span"}=t||{};return tr(r,e,{asType:a,parentSpanContext:this.otelSpan.spanContext()})}},Cl=class extends _e{constructor(r){super({...r,type:"span"})}update(r){return super.updateOtelSpanAttributes(r),this}},Al=class extends _e{constructor(r){super({...r,type:"agent"})}update(r){return super.updateOtelSpanAttributes(r),this}},kl=class extends _e{constructor(r){super({...r,type:"tool"})}update(r){return super.updateOtelSpanAttributes(r),this}},Il=class extends _e{constructor(r){super({...r,type:"chain"})}update(r){return super.updateOtelSpanAttributes(r),this}},Nl=class extends _e{constructor(r){super({...r,type:"retriever"})}update(r){return super.updateOtelSpanAttributes(r),this}},Ml=class extends _e{constructor(r){super({...r,type:"evaluator"})}update(r){return super.updateOtelSpanAttributes(r),this}},Vl=class extends _e{constructor(r){super({...r,type:"guardrail"})}update(r){return super.updateOtelSpanAttributes(r),this}},Ul=class extends _e{constructor(r){super({...r,type:"generation"})}update(r){return this.updateOtelSpanAttributes(r),this}},Bl=class extends _e{constructor(r){super({...r,type:"embedding"})}update(r){return this.updateOtelSpanAttributes(r),this}},jl=class extends _e{constructor(r){super({...r,type:"event"}),this.otelSpan.end(r.timestamp)}};function zl(r){return Oa().startSpan(r.name,{startTime:r.startTime},Kl(r.parentSpanContext))}function Kl(r){if(r)return be.setSpanContext(te.active(),r)}function tr(r,e,t){var a;let{asType:s="span",...i}=t||{},l=zl({name:r,...i});switch(s){case"generation":return new Ul({otelSpan:l,attributes:e});case"embedding":return new Bl({otelSpan:l,attributes:e});case"agent":return new Al({otelSpan:l,attributes:e});case"tool":return new kl({otelSpan:l,attributes:e});case"chain":return new Il({otelSpan:l,attributes:e});case"retriever":return new Nl({otelSpan:l,attributes:e});case"evaluator":return new Ml({otelSpan:l,attributes:e});case"guardrail":return new Vl({otelSpan:l,attributes:e});case"event":{let u=(a=i?.startTime)!=null?a:new Date;return new jl({otelSpan:l,attributes:e,timestamp:u})}default:return new Cl({otelSpan:l,attributes:e})}}Z();Er();Z();Er();Bn();qe();Er();Z();Z();qe();bt();Z();function Xl(r){return Xo(r,new WeakSet)}function Xo(r,e){if(r==null||typeof r=="string"||typeof r=="number"||typeof r=="boolean"||r instanceof Uint8Array)return!0;if(typeof r=="object"){if(e.has(r))return!1;if(e.add(r),Array.isArray(r)){for(let a of r)if(!Xo(a,e))return!1;return!0}let t=r;if(t.constructor!==Object&&t.constructor!==void 0)return!1;for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a)&&!Xo(t[a],e))return!1;return!0}return!1}var ae;(function(r){r[r.DROP_INVALID=0]="DROP_INVALID",r[r.DROP_LIMIT_REACHED=1]="DROP_LIMIT_REACHED",r[r.ADD_NEW=2]="ADD_NEW",r[r.ADD_OVERWRITE_EXISTING=3]="ADD_OVERWRITE_EXISTING"})(ae||(ae={}));function Go(r,e,t,a,s){if(a.length===0)return M.warn(`Invalid attribute key: ${a}`),ae.DROP_INVALID;if(!Xl(s))return M.warn(`Invalid attribute value set for key: ${a}`),ae.DROP_INVALID;let i=!Object.prototype.hasOwnProperty.call(r,a);return i&&t>=e.attributeCountLimit?ae.DROP_LIMIT_REACHED:(r[a]=Do(s,e.attributeValueLengthLimit),i?ae.ADD_NEW:ae.ADD_OVERWRITE_EXISTING)}function Do(r,e){if(e<=0)return M.warn(`Attribute value limit must be positive, got ${e}`),r;if(r==null)return r;if(typeof r=="string")return r.length<=e?r:r.substring(0,e);if(r instanceof Uint8Array)return r;if(Array.isArray(r))return r.map(t=>Do(t,e));if(typeof r=="object"){let t={};for(let[a,s]of Object.entries(r))t[a]=Do(s,e);return t}return r}function qa(r,e){if(e==null)return{};let t={},a=0,s=0;for(let[i,l]of Object.entries(e)){let u=Go(t,r,a,i,l);u===ae.ADD_NEW?a+=1:(u===ae.DROP_INVALID||u===ae.DROP_LIMIT_REACHED)&&(s+=1)}return{attributes:a>0?t:void 0,droppedAttributesCount:s}}var Cr=class{resource;instrumentationScope;attributes={};_hrTime;_hrTimeObserved;_spanContext;_severityText;_severityNumber;_body;_eventName;_attributesCount=0;_droppedAttributesCount=0;_isReadonly=!1;_logRecordLimits;get hrTime(){return this._hrTime}set hrTime(e){this._isLogRecordReadonly()||(this._hrTime=e)}get hrTimeObserved(){return this._hrTimeObserved}set hrTimeObserved(e){this._isLogRecordReadonly()||(this._hrTimeObserved=e)}get spanContext(){return this._spanContext}set spanContext(e){this._isLogRecordReadonly()||(this._spanContext=e)}set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(e,t,a){let{timestamp:s,observedTimestamp:i,eventName:l,severityNumber:u,severityText:c,body:w,attributes:d={},exception:o,context:n}=a,_=Date.now();if(this._hrTime=Lo(s??_),this._hrTimeObserved=Lo(i??_),n){let h=be.getSpanContext(n);h&&br(h)&&(this._spanContext=h)}this.severityNumber=u,this.severityText=c,this.body=w,this.resource=e.resource,this.instrumentationScope=t,this._logRecordLimits=e.logRecordLimits,this._eventName=l,this.setAttributes(d),o!=null&&this._setException(o)}setAttribute(e,t){if(this._isLogRecordReadonly())return this;let a=Go(this.attributes,this._logRecordLimits,this._attributesCount,e,t);return a===ae.DROP_LIMIT_REACHED?(this._droppedAttributesCount++,this._droppedAttributesCount===1&&M.warn("Dropping extra attributes.")):a===ae.ADD_NEW&&this._attributesCount++,this}setAttributes(e){for(let[t,a]of Object.entries(e))this.setAttribute(t,a);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_setException(e){let t=!1;if(typeof e=="string"||typeof e=="number")Object.hasOwn(this.attributes,Ye)||this.setAttribute(Ye,String(e)),t=!0;else if(e&&typeof e=="object"){let a=e;a.code?(Object.hasOwn(this.attributes,Je)||this.setAttribute(Je,a.code.toString()),t=!0):a.name&&(Object.hasOwn(this.attributes,Je)||this.setAttribute(Je,a.name),t=!0),a.message&&(Object.hasOwn(this.attributes,Ye)||this.setAttribute(Ye,a.message),t=!0),a.stack&&(Object.hasOwn(this.attributes,So)||this.setAttribute(So,a.stack),t=!0)}t||M.warn(`Failed to record an exception ${e}`)}_isLogRecordReadonly(){return this._isReadonly&&M.warn("Can not execute the operation on emitted log record"),this._isReadonly}};var kr=class{_instrumentationScope;_sharedState;_loggerConfig;constructor(e,t){this._instrumentationScope=e,this._sharedState=t,this._loggerConfig=this._sharedState.getLoggerConfig(this._instrumentationScope)}emit(e){let t=e.context||te.active();if(!this.enabled(e))return;let a=new Cr(this._sharedState,this._instrumentationScope,{context:t,...e});this._sharedState.loggerMetrics.emitLog(),this._sharedState.activeProcessor.onEmit(a,t),a._makeReadonly()}enabled(e){if(this._sharedState.hasShutdown)return!1;let t=this._loggerConfig;if(t.disabled)return!1;let a=e?.severityNumber;if(typeof a=="number"&&a!==xe.UNSPECIFIED&&a<t.minimumSeverity)return!1;let s=e?.context||te.active();if(t.traceBased){let l=be.getSpanContext(s);if(l&&br(l)&&!((l.traceFlags&yo.SAMPLED)===yo.SAMPLED))return!1}let i={context:s,instrumentationScope:this._instrumentationScope,severityNumber:e?.severityNumber,eventName:e?.eventName};for(let l of this._sharedState.processors)if(!l.enabled||l.enabled(i))return!0;return!1}};Z();Er();var Ir=class{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}enabled(e){return!1}};qe();var Nr=class{processors;constructor(e){this.processors=e}async forceFlush(e){let t=e?.timeoutMillis??3e4;await Promise.all(this.processors.map(a=>Lt(a.forceFlush(),t)))}onEmit(e,t){this.processors.forEach(a=>a.onEmit(e,t))}async shutdown(){await Promise.all(this.processors.map(e=>e.shutdown()))}enabled(e){for(let t of this.processors)if(!t.enabled||t.enabled(e))return!0;return!1}};function Ho(r){if(r===void 0)return["u",null];if(r===null)return["n",null];let e=typeof r;return e==="string"?["s",r]:e==="boolean"?["b",r]:e==="number"?Number.isNaN(r)?["nan",null]:r===1/0?["inf",null]:r===-1/0?["-inf",null]:Object.is(r,-0)?["n0",null]:["d",r]:r instanceof Uint8Array?["bytes",Array.from(r)]:Array.isArray(r)?["arr",r.map(Ho)]:["map",Object.entries(r).sort(([t],[a])=>t.localeCompare(a)).map(([t,a])=>[t,Ho(a)])]}function Mr(r){return JSON.stringify([r.name,r.version||"",r.schemaUrl||"",Ho(r.attributes),r.droppedAttributesCount??0])}var en="otel.sdk.log.created",rn="otel.sdk.processor.log.processed",on="otel.sdk.processor.log.queue.capacity",tn="otel.sdk.processor.log.queue.size",an="otel.component.name",nn="otel.component.type",sn="batching_log_processor";var Fo="error.type";var Vr=class{createdLogs;constructor(e){this.createdLogs=e.createCounter(en,{unit:"{log_record}",description:"The number of logs submitted to enabled SDK Loggers."})}emitLog(){this.createdLogs.add(1)}};var ln="0.222.0";var Dl={disabled:!1,minimumSeverity:xe.UNSPECIFIED,traceBased:!1},$o=()=>({...Dl}),Ur=class{loggers=new Map;activeProcessor;registeredLogRecordProcessors=[];resource;logRecordLimits;processors;loggerMetrics;hasShutdown=!1;_loggerConfigurator;_loggerConfigs=new Map;constructor(e,t,a,s,i){this.resource=e,this.logRecordLimits=t,this.processors=a,a.length>0?(this.registeredLogRecordProcessors=a,this.activeProcessor=new Nr(this.registeredLogRecordProcessors)):this.activeProcessor=new Ir,this._loggerConfigurator=s??$o;let l=i?i.getMeter("@opentelemetry/sdk-logs",ln):Se();this.loggerMetrics=new Vr(l)}getLoggerConfig(e){let t=Mr(e),a=this._loggerConfigs.get(t);return a||(a=this._loggerConfigurator(e),this._loggerConfigs.set(t,a),a)}};var Gl="unknown",ar=class{_shutdownOnce;_sharedState;constructor(e={}){let t={resource:e.resource??Pt(),logRecordLimits:{attributeCountLimit:e.logRecordLimits?.attributeCountLimit??128,attributeValueLengthLimit:e.logRecordLimits?.attributeValueLengthLimit??1/0},loggerConfigurator:e.loggerConfigurator??$o,processors:e.processors??[],meterProvider:e.meterProvider};this._sharedState=new Ur(t.resource,t.logRecordLimits,t.processors,t.loggerConfigurator,t.meterProvider),this._shutdownOnce=new xr(this._shutdown,this)}getLogger(e,t,a){if(this._shutdownOnce.isCalled)return M.warn("A shutdown LoggerProvider cannot provide a Logger"),Tt();e||M.warn("Logger requested without instrumentation scope name.");let i={name:e||Gl,version:t,schemaUrl:a?.schemaUrl,...qa(this._sharedState.logRecordLimits,a?.attributes)},l=Mr(i);return this._sharedState.loggers.has(l)||this._sharedState.loggers.set(l,new kr(i,this._sharedState)),this._sharedState.loggers.get(l)}forceFlush(e){return this._shutdownOnce.isCalled?(M.warn("invalid attempt to force flush after LoggerProvider shutdown"),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush(e)}shutdown(){return this._shutdownOnce.isCalled?(M.warn("shutdown may only be called once per LoggerProvider"),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.hasShutdown=!0,this._sharedState.activeProcessor.shutdown()}};qe();var nr=class{export(e,t){this._sendLogRecords(e,t)}async forceFlush(){}async shutdown(){}_exportInfo(e){return{resource:{attributes:e.resource.attributes},instrumentationScope:e.instrumentationScope,timestamp:Et(e.hrTime),traceId:e.spanContext?.traceId,spanId:e.spanContext?.spanId,traceFlags:e.spanContext?.traceFlags,severityText:e.severityText,severityNumber:e.severityNumber,eventName:e.eventName,body:e.body,attributes:e.attributes}}_sendLogRecords(e,t){for(let a of e)console.dir(this._exportInfo(a),{depth:3});t?.({code:Sr.SUCCESS})}};var dn=new Map,Br=class{processedLogs;queueSize;queueSizeCallback;standardAttrs;droppedAttrs;constructor(e,t,a){let s=dn.get(e)??0;if(dn.set(e,s+1),this.standardAttrs={[nn]:e,[an]:`${e}/${s}`},this.droppedAttrs={...this.standardAttrs,[Fo]:"queue_full"},this.processedLogs=t.createCounter(rn,{unit:"{log_record}",description:"The number of log records for which the processing has finished, either successful or failed."}),a){let{capacity:i,getQueueSize:l}=a;t.createUpDownCounter(on,{unit:"{log_record}",description:"The maximum number of log records the queue of a given instance of an SDK log processor can hold."}).add(i,this.standardAttrs),this.queueSize=t.createObservableUpDownCounter(tn,{unit:"{log_record}",description:"The number of log records in the queue of a given instance of an SDK log processor."}),this.queueSizeCallback=c=>c.observe(l(),this.standardAttrs),this.queueSize.addCallback(this.queueSizeCallback)}}dropLogs(e){this.processedLogs.add(e,this.droppedAttrs)}finishLogs(e,t){if(!t){this.processedLogs.add(e,this.standardAttrs);return}let a={...this.standardAttrs,[Fo]:t.name};this.processedLogs.add(e,a)}shutdown(){this.queueSize&&this.queueSizeCallback&&this.queueSize.removeCallback(this.queueSizeCallback)}};Z();qe();async function Hl(r){let e=[];for(let t=0,a=r.length;t<a;t++){let s=r[t];s.resource.asyncAttributesPending&&s.resource.waitForAsyncAttributes&&e.push(s.resource.waitForAsyncAttributes())}e!=null&&e.length>0&&await Promise.all(e)}var jr=class{_exportCompleted;_exportScheduledPromise;_metrics;_exportScheduledResolve;constructor(e,t,a,s){this._exportScheduledPromise=new Promise(i=>{this._exportScheduledResolve=i}),this._exportCompleted=this._executeExport(e,t,a),this._metrics=s}get exportCompleted(){return this._exportCompleted}get exportScheduled(){return this._exportScheduledPromise}async _executeExport(e,t,a){try{await Hl(t),await te.with(xt(te.active()),async()=>this._exportWithTimeout(e,t,a))}catch(s){Rr(s),this._exportScheduledResolve()}}async _exportWithTimeout(e,t,a){return new Promise((s,i)=>{let l=setTimeout(()=>{i(new Error("Timeout"))},a);e.export(t,u=>{this._metrics.finishLogs(t.length,u.error),clearTimeout(l),u.code===Sr.SUCCESS?s():i(u.error??new Error("BatchLogRecordProcessor: log record export failed"))}),this._exportScheduledResolve()})}},zr=class{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_metrics;_currentExport=null;_finishedLogRecords=[];_timer;_shutdownOnce;_flushing=!1;constructor(e){this._exporter=e.exporter,this._maxExportBatchSize=e.maxExportBatchSize??512,this._maxQueueSize=e.maxQueueSize??2048,this._scheduledDelayMillis=e.scheduledDelayMillis??1e3,this._exportTimeoutMillis=e.exportTimeoutMillis??3e4,this._shutdownOnce=new xr(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(M.warn("BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize);let t=e?.selfObsMeterProvider?e.selfObsMeterProvider.getMeter("@opentelemetry/sdk-logs"):Se();this._metrics=new Br(sn,t,{capacity:this._maxQueueSize,getQueueSize:()=>this._finishedLogRecords.length})}onEmit(e){this._shutdownOnce.isCalled||this._addToBuffer(e)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}_addToBuffer(e){if(this._finishedLogRecords.length>=this._maxQueueSize){this._metrics.dropLogs(1);return}this._finishedLogRecords.push(e),this._maybeStartTimer()}shutdown(){return this._shutdownOnce.call()}async _shutdown(){this.onShutdown(),await this._flushAll(),this._metrics.shutdown(),await this._exporter.shutdown()}async _flushAll(){if(this._flushing)return;this._flushing=!0;let e=this._finishedLogRecords;this._finishedLogRecords=[],this._clearTimer();let t=this._currentExport;for(t!==null&&(await this._exporter.forceFlush(),await t.exportCompleted,this._currentExport=null);e.length>0;){let a;e.length<=this._maxExportBatchSize?(a=e,e=[]):a=e.splice(0,this._maxExportBatchSize);let s=new jr(this._exporter,a,this._exportTimeoutMillis,this._metrics);this._currentExport=s;try{await s.exportScheduled,await this._exporter.forceFlush(),await s.exportCompleted}catch(i){Rr(i)}finally{this._currentExport=null}}this._flushing=!1,this._maybeStartTimer()}_extractBatch(){if(this._finishedLogRecords.length===0)return null;if(this._finishedLogRecords.length<=this._maxExportBatchSize){let e=this._finishedLogRecords;return this._finishedLogRecords=[],e}else return this._finishedLogRecords.splice(0,this._maxExportBatchSize)}_exportOneBatch(){this._clearTimer();let e=this._extractBatch();if(e===null)return;let t=new jr(this._exporter,e,this._exportTimeoutMillis,this._metrics);this._currentExport=t,t.exportCompleted.then(()=>{this._currentExport=null,this._maybeStartTimer()}).catch(a=>{this._currentExport=null,Rr(a),this._maybeStartTimer()})}_maybeStartTimer(){if(!this._shutdownOnce.isCalled&&!this._flushing&&this._finishedLogRecords.length!==0&&this._currentExport===null){if(this._finishedLogRecords.length>=this._maxExportBatchSize){this._exportOneBatch();return}this._timer===void 0&&(this._timer=setTimeout(()=>{this._timer=void 0,this._exportOneBatch()},this._scheduledDelayMillis),typeof this._timer!="number"&&this._timer.unref())}}_clearTimer(){this._timer!==void 0&&(clearTimeout(this._timer),this._timer=void 0)}};var Ie=class extends zr{onShutdown(){}};var Ue;(function(r){r[r.DELTA=0]="DELTA",r[r.CUMULATIVE=1]="CUMULATIVE"})(Ue||(Ue={}));var z;(function(r){r.COUNTER="COUNTER",r.GAUGE="GAUGE",r.HISTOGRAM="HISTOGRAM",r.UP_DOWN_COUNTER="UP_DOWN_COUNTER",r.OBSERVABLE_COUNTER="OBSERVABLE_COUNTER",r.OBSERVABLE_GAUGE="OBSERVABLE_GAUGE",r.OBSERVABLE_UP_DOWN_COUNTER="OBSERVABLE_UP_DOWN_COUNTER"})(z||(z={}));var pe;(function(r){r[r.HISTOGRAM=0]="HISTOGRAM",r[r.EXPONENTIAL_HISTOGRAM=1]="EXPONENTIAL_HISTOGRAM",r[r.GAUGE=2]="GAUGE",r[r.SUM=3]="SUM"})(pe||(pe={}));Z();function Kr(r){let e=Object.keys(r);return e.length===0?"":(e=e.sort(),JSON.stringify(e.map(t=>[t,r[t]])))}function un(r){return`${r.name}:${r.version??""}:${r.schemaUrl??""}`}var sr=class r extends Error{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};function Le(r,e){let t,a=new Promise(function(i,l){t=setTimeout(function(){l(new sr("Operation timed out."))},e)});return Promise.race([r,a]).then(s=>(clearTimeout(t),s),s=>{throw clearTimeout(t),s})}function cn(r,e){if(r.size!==e.size)return!1;for(let t of r)if(!e.has(t))return!1;return!0}function wn(r,e){let t=0,a=r.length-1,s=r.length;for(;a>=t;){let i=t+Math.trunc((a-t)/2);r[i]<e?t=i+1:(s=i,a=i-1)}return s}function hn(r,e){return r.toLowerCase()===e.toLowerCase()}Z();var we;(function(r){r[r.DROP=0]="DROP",r[r.SUM=1]="SUM",r[r.LAST_VALUE=2]="LAST_VALUE",r[r.HISTOGRAM=3]="HISTOGRAM",r[r.EXPONENTIAL_HISTOGRAM=4]="EXPONENTIAL_HISTOGRAM"})(we||(we={}));var ir=class{kind=we.DROP;createAccumulation(){}merge(e,t){}diff(e,t){}toMetricData(e,t,a,s){}};function Fl(r){let e=r.map(()=>0);return e.push(0),{buckets:{boundaries:r,counts:e},sum:0,count:0,hasMinMax:!1,min:1/0,max:-1/0}}var Be=class{startTime;_boundaries;_recordMinMax;_current;constructor(e,t,a=!0,s=Fl(t)){this.startTime=e,this._boundaries=t,this._recordMinMax=a,this._current=s}record(e){if(Number.isNaN(e))return;this._current.count+=1,this._current.sum+=e,this._recordMinMax&&(this._current.min=Math.min(e,this._current.min),this._current.max=Math.max(e,this._current.max),this._current.hasMinMax=!0);let t=wn(this._boundaries,e);this._current.buckets.counts[t]+=1}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},je=class{kind=we.HISTOGRAM;_boundaries;_recordMinMax;constructor(e,t){this._boundaries=e,this._recordMinMax=t}createAccumulation(e){return new Be(e,this._boundaries,this._recordMinMax)}merge(e,t){let a=e.toPointValue(),s=t.toPointValue(),i=a.buckets.counts,l=s.buckets.counts,u=new Array(i.length);for(let d=0;d<i.length;d++)u[d]=i[d]+l[d];let c=1/0,w=-1/0;return this._recordMinMax&&(a.hasMinMax&&s.hasMinMax?(c=Math.min(a.min,s.min),w=Math.max(a.max,s.max)):a.hasMinMax?(c=a.min,w=a.max):s.hasMinMax&&(c=s.min,w=s.max)),new Be(e.startTime,a.buckets.boundaries,this._recordMinMax,{buckets:{boundaries:a.buckets.boundaries,counts:u},count:a.count+s.count,sum:a.sum+s.sum,hasMinMax:this._recordMinMax&&(a.hasMinMax||s.hasMinMax),min:c,max:w})}diff(e,t){let a=e.toPointValue(),s=t.toPointValue(),i=a.buckets.counts,l=s.buckets.counts,u=new Array(i.length);for(let c=0;c<i.length;c++)u[c]=l[c]-i[c];return new Be(t.startTime,a.buckets.boundaries,this._recordMinMax,{buckets:{boundaries:a.buckets.boundaries,counts:u},count:s.count-a.count,sum:s.sum-a.sum,hasMinMax:!1,min:1/0,max:-1/0})}toMetricData(e,t,a,s){return{descriptor:e,aggregationTemporality:t,dataPointType:pe.HISTOGRAM,dataPoints:a.map(([i,l])=>{let u=l.toPointValue(),c=e.type===z.GAUGE||e.type===z.UP_DOWN_COUNTER||e.type===z.OBSERVABLE_GAUGE||e.type===z.OBSERVABLE_UP_DOWN_COUNTER;return{attributes:i,startTime:l.startTime,endTime:s,value:{min:u.hasMinMax?u.min:void 0,max:u.hasMinMax?u.max:void 0,sum:c?void 0:u.sum,buckets:u.buckets,count:u.count}}})}}};Z();var lr=class r{backing;indexBase;indexStart;indexEnd;constructor(e=new Wo,t=0,a=0,s=0){this.backing=e,this.indexBase=t,this.indexStart=a,this.indexEnd=s}get offset(){return this.indexStart}get length(){return this.backing.length===0||this.indexEnd===this.indexStart&&this.at(0)===0?0:this.indexEnd-this.indexStart+1}counts(){return Array.from({length:this.length},(e,t)=>this.at(t))}at(e){let t=this.indexBase-this.indexStart;return e<t&&(e+=this.backing.length),e-=t,this.backing.countAt(e)}incrementBucket(e,t){this.backing.increment(e,t)}decrementBucket(e,t){this.backing.decrement(e,t)}trim(){for(let e=0;e<this.length;e++)if(this.at(e)!==0){this.indexStart+=e;break}else if(e===this.length-1){this.indexStart=this.indexEnd=this.indexBase=0;return}for(let e=this.length-1;e>=0;e--)if(this.at(e)!==0){this.indexEnd-=this.length-e-1;break}this._rotate()}downscale(e){this._rotate();let t=1+this.indexEnd-this.indexStart,a=1<<e,s=0,i=0;for(let l=this.indexStart;l<=this.indexEnd;){let u=l%a;u<0&&(u+=a);for(let c=u;c<a&&s<t;c++)this._relocateBucket(i,s),s++,l++;i++}this.indexStart>>=e,this.indexEnd>>=e,this.indexBase=this.indexStart}clone(){return new r(this.backing.clone(),this.indexBase,this.indexStart,this.indexEnd)}_rotate(){let e=this.indexBase-this.indexStart;e!==0&&(e>0?(this.backing.reverse(0,this.backing.length),this.backing.reverse(0,e),this.backing.reverse(e,this.backing.length)):(this.backing.reverse(0,this.backing.length),this.backing.reverse(0,this.backing.length+e)),this.indexBase=this.indexStart)}_relocateBucket(e,t){e!==t&&this.incrementBucket(e,this.backing.emptyBucket(t))}},Wo=class r{_counts;constructor(e=[0]){this._counts=e}get length(){return this._counts.length}countAt(e){return this._counts[e]}growTo(e,t,a){let s=new Array(e).fill(0);s.splice(a,this._counts.length-t,...this._counts.slice(t)),s.splice(0,t,...this._counts.slice(0,t)),this._counts=s}reverse(e,t){let a=Math.floor((e+t)/2)-e;for(let s=0;s<a;s++){let i=this._counts[e+s];this._counts[e+s]=this._counts[t-s-1],this._counts[t-s-1]=i}}emptyBucket(e){let t=this._counts[e];return this._counts[e]=0,t}increment(e,t){this._counts[e]+=t}decrement(e,t){this._counts[e]>=t?this._counts[e]-=t:this._counts[e]=0}clone(){return new r([...this._counts])}};var dr=Math.pow(2,-1022),Qo=new DataView(new ArrayBuffer(8));function mn(r){return Qo.setFloat64(0,r),{hi:Qo.getUint32(0),lo:Qo.getUint32(4)}}function Xr(r){let{hi:e}=mn(r);return((e&2146435072)>>20)-1023}function Dr(r){let{hi:e,lo:t}=mn(r);return(e&1048575)===0&&t===0}function ur(r,e){return r===0||r===Number.POSITIVE_INFINITY||r===Number.NEGATIVE_INFINITY||Number.isNaN(r)?r:r*Math.pow(2,e)}function _n(r){return r--,r|=r>>1,r|=r>>2,r|=r>>4,r|=r>>8,r|=r>>16,r++,r}var fe=class extends Error{};var Gr=class{_shift;constructor(e){this._shift=-e}mapToIndex(e){if(e<dr)return this._minNormalLowerBoundaryIndex();let t=Xr(e),a=Dr(e)?-1:0;return t+a>>this._shift}lowerBoundary(e){let t=this._minNormalLowerBoundaryIndex();if(e<t)throw new fe(`underflow: ${e} is < minimum lower boundary: ${t}`);let a=this._maxNormalLowerBoundaryIndex();if(e>a)throw new fe(`overflow: ${e} is > maximum lower boundary: ${a}`);return ur(1,e<<this._shift)}get scale(){return this._shift===0?0:-this._shift}_minNormalLowerBoundaryIndex(){let e=-1022>>this._shift;return this._shift<2&&e--,e}_maxNormalLowerBoundaryIndex(){return 1023>>this._shift}};var Hr=class{_scale;_scaleFactor;_inverseFactor;constructor(e){this._scale=e,this._scaleFactor=ur(Math.LOG2E,e),this._inverseFactor=ur(Math.LN2,-e)}mapToIndex(e){if(e<=dr)return this._minNormalLowerBoundaryIndex()-1;if(Dr(e))return(Xr(e)<<this._scale)-1;let t=Math.floor(Math.log(e)*this._scaleFactor),a=this._maxNormalLowerBoundaryIndex();return t>=a?a:t}lowerBoundary(e){let t=this._maxNormalLowerBoundaryIndex();if(e>=t){if(e===t)return 2*Math.exp((e-(1<<this._scale))/this._scaleFactor);throw new fe(`overflow: ${e} is > maximum lower boundary: ${t}`)}let a=this._minNormalLowerBoundaryIndex();if(e<=a){if(e===a)return dr;if(e===a-1)return Math.exp((e+(1<<this._scale))/this._scaleFactor)/2;throw new fe(`overflow: ${e} is < minimum lower boundary: ${a}`)}return Math.exp(e*this._inverseFactor)}get scale(){return this._scale}_minNormalLowerBoundaryIndex(){return-1022<<this._scale}_maxNormalLowerBoundaryIndex(){return(1024<<this._scale)-1}};var fn=-10,yn=20,$l=Array.from({length:31},(r,e)=>e>10?new Hr(e-10):new Gr(e-10));function Zo(r){if(r>yn||r<fn)throw new fe(`expected scale >= ${fn} && <= ${yn}, got: ${r}`);return $l[r+10]}var ze=class r{static combine(e,t){return new r(Math.min(e.low,t.low),Math.max(e.high,t.high))}low;high;constructor(e,t){this.low=e,this.high=t}},Wl=20,Ql=160,Oo=2,Fr=class r{startTime;_maxSize;_recordMinMax;_sum;_count;_zeroCount;_min;_max;_positive;_negative;_mapping;constructor(e,t=Ql,a=!0,s=0,i=0,l=0,u=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,w=new lr,d=new lr,o=Zo(Wl)){this.startTime=e,this._maxSize=t,this._recordMinMax=a,this._sum=s,this._count=i,this._zeroCount=l,this._min=u,this._max=c,this._positive=w,this._negative=d,this._mapping=o,this._maxSize<Oo&&(M.warn(`Exponential Histogram Max Size set to ${this._maxSize}, changing to the minimum size of: ${Oo}`),this._maxSize=Oo)}record(e){this.updateByIncrement(e,1)}setStartTime(e){this.startTime=e}toPointValue(){return{hasMinMax:this._recordMinMax,min:this.min,max:this.max,sum:this.sum,positive:{offset:this.positive.offset,bucketCounts:this.positive.counts()},negative:{offset:this.negative.offset,bucketCounts:this.negative.counts()},count:this.count,scale:this.scale,zeroCount:this.zeroCount}}get sum(){return this._sum}get min(){return this._min}get max(){return this._max}get count(){return this._count}get zeroCount(){return this._zeroCount}get scale(){return this._count===this._zeroCount?0:this._mapping.scale}get positive(){return this._positive}get negative(){return this._negative}updateByIncrement(e,t){if(Number.isFinite(e)){if(e>this._max&&(this._max=e),e<this._min&&(this._min=e),this._count+=t,e===0){this._zeroCount+=t;return}this._sum+=e*t,e>0?this._updateBuckets(this._positive,e,t):this._updateBuckets(this._negative,-e,t)}}merge(e){this._count===0?(this._min=e.min,this._max=e.max):e.count!==0&&(e.min<this.min&&(this._min=e.min),e.max>this.max&&(this._max=e.max)),this.startTime=e.startTime,this._sum+=e.sum,this._count+=e.count,this._zeroCount+=e.zeroCount;let t=this._minScale(e);this._downscale(this.scale-t),this._mergeBuckets(this.positive,e,e.positive,t),this._mergeBuckets(this.negative,e,e.negative,t)}diff(e){this._min=1/0,this._max=-1/0,this._sum-=e.sum,this._count-=e.count,this._zeroCount-=e.zeroCount;let t=this._minScale(e);this._downscale(this.scale-t),this._diffBuckets(this.positive,e,e.positive,t),this._diffBuckets(this.negative,e,e.negative,t)}clone(){return new r(this.startTime,this._maxSize,this._recordMinMax,this._sum,this._count,this._zeroCount,this._min,this._max,this.positive.clone(),this.negative.clone(),this._mapping)}_updateBuckets(e,t,a){let s=this._mapping.mapToIndex(t),i=!1,l=0,u=0;if(e.length===0?(e.indexStart=s,e.indexEnd=e.indexStart,e.indexBase=e.indexStart):s<e.indexStart&&e.indexEnd-s>=this._maxSize?(i=!0,u=s,l=e.indexEnd):s>e.indexEnd&&s-e.indexStart>=this._maxSize&&(i=!0,u=e.indexStart,l=s),i){let c=this._changeScale(l,u);this._downscale(c),s=this._mapping.mapToIndex(t)}this._incrementIndexBy(e,s,a)}_incrementIndexBy(e,t,a){if(a===0)return;if(e.length===0&&(e.indexStart=e.indexEnd=e.indexBase=t),t<e.indexStart){let i=e.indexEnd-t;i>=e.backing.length&&this._grow(e,i+1),e.indexStart=t}else if(t>e.indexEnd){let i=t-e.indexStart;i>=e.backing.length&&this._grow(e,i+1),e.indexEnd=t}let s=t-e.indexBase;s<0&&(s+=e.backing.length),e.incrementBucket(s,a)}_grow(e,t){let a=e.backing.length,s=e.indexBase-e.indexStart,i=a-s,l=_n(t);l>this._maxSize&&(l=this._maxSize);let u=l-s;e.backing.growTo(l,i,u)}_changeScale(e,t){let a=0;for(;e-t>=this._maxSize;)e>>=1,t>>=1,a++;return a}_downscale(e){if(e===0)return;if(e<0)throw new Error(`impossible change of scale: ${this.scale}`);let t=this._mapping.scale-e;this._positive.downscale(e),this._negative.downscale(e),this._mapping=Zo(t)}_minScale(e){let t=Math.min(this.scale,e.scale),a=ze.combine(this._highLowAtScale(this.positive,this.scale,t),this._highLowAtScale(e.positive,e.scale,t)),s=ze.combine(this._highLowAtScale(this.negative,this.scale,t),this._highLowAtScale(e.negative,e.scale,t));return Math.min(t-this._changeScale(a.high,a.low),t-this._changeScale(s.high,s.low))}_highLowAtScale(e,t,a){if(e.length===0)return new ze(0,-1);let s=t-a;return new ze(e.indexStart>>s,e.indexEnd>>s)}_mergeBuckets(e,t,a,s){let i=a.offset,l=t.scale-s;for(let u=0;u<a.length;u++)this._incrementIndexBy(e,i+u>>l,a.at(u))}_diffBuckets(e,t,a,s){let i=a.offset,l=t.scale-s;for(let u=0;u<a.length;u++){let w=(i+u>>l)-e.indexBase;w<0&&(w+=e.backing.length),e.decrementBucket(w,a.at(u))}e.trim()}},cr=class{kind=we.EXPONENTIAL_HISTOGRAM;_maxSize;_recordMinMax;constructor(e,t){this._maxSize=e,this._recordMinMax=t}createAccumulation(e){return new Fr(e,this._maxSize,this._recordMinMax)}merge(e,t){let a=t.clone();return a.merge(e),a}diff(e,t){let a=t.clone();return a.diff(e),a}toMetricData(e,t,a,s){return{descriptor:e,aggregationTemporality:t,dataPointType:pe.EXPONENTIAL_HISTOGRAM,dataPoints:a.map(([i,l])=>{let u=l.toPointValue(),c=e.type===z.GAUGE||e.type===z.UP_DOWN_COUNTER||e.type===z.OBSERVABLE_GAUGE||e.type===z.OBSERVABLE_UP_DOWN_COUNTER;return{attributes:i,startTime:l.startTime,endTime:s,value:{min:u.hasMinMax?u.min:void 0,max:u.hasMinMax?u.max:void 0,sum:c?void 0:u.sum,positive:{offset:u.positive.offset,bucketCounts:u.positive.bucketCounts},negative:{offset:u.negative.offset,bucketCounts:u.negative.bucketCounts},count:u.count,scale:u.scale,zeroCount:u.zeroCount}}})}}};var Ke=class{startTime;_current;sampleTime;constructor(e,t=0,a=[0,0]){this.startTime=e,this._current=t,this.sampleTime=a}record(e){this._current=e,this.sampleTime=Me(Date.now())}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},wr=class{kind=we.LAST_VALUE;createAccumulation(e){return new Ke(e)}merge(e,t){let a=Ze(t.sampleTime)>=Ze(e.sampleTime)?t:e;return new Ke(e.startTime,a.toPointValue(),a.sampleTime)}diff(e,t){let a=Ze(t.sampleTime)>=Ze(e.sampleTime)?t:e;return new Ke(t.startTime,a.toPointValue(),a.sampleTime)}toMetricData(e,t,a,s){return{descriptor:e,aggregationTemporality:t,dataPointType:pe.GAUGE,dataPoints:a.map(([i,l])=>({attributes:i,startTime:l.startTime,endTime:s,value:l.toPointValue()}))}}};var Te=class{startTime;monotonic;_current;reset;constructor(e,t,a=0,s=!1){this.startTime=e,this.monotonic=t,this._current=a,this.reset=s}record(e){this.monotonic&&e<0||(this._current+=e)}setStartTime(e){this.startTime=e}toPointValue(){return this._current}},Xe=class{kind=we.SUM;monotonic;constructor(e){this.monotonic=e}createAccumulation(e){return new Te(e,this.monotonic)}merge(e,t){let a=e.toPointValue(),s=t.toPointValue();return t.reset?new Te(t.startTime,this.monotonic,s,t.reset):new Te(e.startTime,this.monotonic,a+s)}diff(e,t){let a=e.toPointValue(),s=t.toPointValue();return this.monotonic&&a>s?new Te(t.startTime,this.monotonic,s,!0):new Te(t.startTime,this.monotonic,s-a)}toMetricData(e,t,a,s){return{descriptor:e,aggregationTemporality:t,dataPointType:pe.SUM,dataPoints:a.map(([i,l])=>({attributes:i,startTime:l.startTime,endTime:s,value:l.toPointValue()})),isMonotonic:this.monotonic}}};var qo=class r{static DEFAULT_INSTANCE=new ir;createAggregator(e){return r.DEFAULT_INSTANCE}},et=class r{static MONOTONIC_INSTANCE=new Xe(!0);static NON_MONOTONIC_INSTANCE=new Xe(!1);createAggregator(e){switch(e.type){case z.COUNTER:case z.OBSERVABLE_COUNTER:case z.HISTOGRAM:return r.MONOTONIC_INSTANCE;default:return r.NON_MONOTONIC_INSTANCE}}},rt=class r{static DEFAULT_INSTANCE=new wr;createAggregator(e){return r.DEFAULT_INSTANCE}},ot=class r{static DEFAULT_INSTANCE=new je([0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4],!0);createAggregator(e){return r.DEFAULT_INSTANCE}},hr=class{_boundaries;_recordMinMax;constructor(e,t=!0){if(e==null)throw new Error("ExplicitBucketHistogramAggregation should be created with explicit boundaries, if a single bucket histogram is required, please pass an empty array");e=e.concat(),e=e.sort((i,l)=>i-l);let a=e.lastIndexOf(-1/0),s=e.indexOf(1/0);s===-1&&(s=void 0),this._boundaries=e.slice(a+1,s),this._recordMinMax=t}createAggregator(e){return new je(this._boundaries,this._recordMinMax)}},mr=class{_maxSize;_recordMinMax;constructor(e=160,t=!0){this._maxSize=e,this._recordMinMax=t}createAggregator(e){return new cr(this._maxSize,this._recordMinMax)}},tt=class{_resolve(e){switch(e.type){case z.COUNTER:case z.UP_DOWN_COUNTER:case z.OBSERVABLE_COUNTER:case z.OBSERVABLE_UP_DOWN_COUNTER:return nt;case z.GAUGE:case z.OBSERVABLE_GAUGE:return st;case z.HISTOGRAM:return e.advice.explicitBucketBoundaries?new hr(e.advice.explicitBucketBoundaries):it}return M.warn(`Unable to recognize instrument type: ${e.type}`),at}createAggregator(e){return this._resolve(e).createAggregator(e)}},at=new qo,nt=new et,st=new rt,it=new ot,Lw=new mr,bn=new tt;var he;(function(r){r[r.DEFAULT=0]="DEFAULT",r[r.DROP=1]="DROP",r[r.SUM=2]="SUM",r[r.LAST_VALUE=3]="LAST_VALUE",r[r.EXPLICIT_BUCKET_HISTOGRAM=4]="EXPLICIT_BUCKET_HISTOGRAM",r[r.EXPONENTIAL_HISTOGRAM=5]="EXPONENTIAL_HISTOGRAM"})(he||(he={}));function $r(r){switch(r.type){case he.DEFAULT:return bn;case he.DROP:return at;case he.SUM:return nt;case he.LAST_VALUE:return st;case he.EXPONENTIAL_HISTOGRAM:{let e=r;return new mr(e.options?.maxSize,e.options?.recordMinMax)}case he.EXPLICIT_BUCKET_HISTOGRAM:{let e=r;return e.options==null?it:new hr(e.options?.boundaries,e.options?.recordMinMax)}default:throw new Error("Unsupported Aggregation")}}var vn=r=>({type:he.DEFAULT}),Wr=r=>Ue.CUMULATIVE;var Rn="otel.component.name",Sn="otel.component.type",xn="periodic_metric_reader",En="otel.sdk.metric_reader.collection.duration",Ln="error.type";var Tn=new Map,gr=class{collectionDuration;standardAttrs;constructor(e,t){let a=Tn.get(e)??0;Tn.set(e,a+1),this.standardAttrs={[Sn]:e,[Rn]:`${e}/${a}`},this.collectionDuration=t.createHistogram(En,{unit:"s",description:"The duration of the collect operation of the metric reader.",advice:{explicitBucketBoundaries:[]}})}recordCollection(e,t){let a=t?{...this.standardAttrs,[Ln]:t}:this.standardAttrs;this.collectionDuration.record(e,a)}};var Pn="2.12.0";var De=class{_shutdown=!1;_metricProducers;_sdkMetricProducer;_selfObsMetrics;_aggregationTemporalitySelector;_aggregationSelector;_cardinalitySelector;_otelComponentType;constructor(e){this._aggregationSelector=e?.aggregationSelector??vn,this._aggregationTemporalitySelector=e?.aggregationTemporalitySelector??Wr,this._metricProducers=e?.metricProducers??[],this._cardinalitySelector=e?.cardinalitySelector,this._otelComponentType=e?.otelComponentType??this.constructor.name,this._selfObsMetrics=new gr(this._otelComponentType,Se())}setMetricProducer(e){if(this._sdkMetricProducer)throw new Error("MetricReader can not be bound to a MeterProvider again.");this._sdkMetricProducer=e,this.onInitialized()}_setSelfObsMeterProvider(e){let t=e.getMeter("@opentelemetry/sdk-metrics",Pn);this._selfObsMetrics=new gr(this._otelComponentType,t)}selectAggregation(e){return this._aggregationSelector(e)}selectAggregationTemporality(e){return this._aggregationTemporalitySelector(e)}selectCardinalityLimit(e){return this._cardinalitySelector?this._cardinalitySelector(e):2e3}onInitialized(){}async collect(e){if(this._sdkMetricProducer===void 0)throw new Error("MetricReader is not bound to a MetricProducer");if(this._shutdown)throw new Error("MetricReader is shutdown");let t=Eo(),[a,...s]=await Promise.all([this._sdkMetricProducer.collect({timeoutMillis:e?.timeoutMillis}),...this._metricProducers.map(d=>d.collect({timeoutMillis:e?.timeoutMillis}))]),i=Eo(),l=a.errors.concat(s.flatMap(d=>d.errors)),u=Rt(vt(t,i));this._selfObsMetrics.recordCollection(u,l.length>0?l[0].name??"collect_error":void 0);let c=a.resourceMetrics.resource,w=a.resourceMetrics.scopeMetrics.concat(s.flatMap(d=>d.resourceMetrics.scopeMetrics));return{resourceMetrics:{resource:c,scopeMetrics:w},errors:l}}async shutdown(e){if(this._shutdown){M.error("Cannot call shutdown twice.");return}e?.timeoutMillis==null?await this.onShutdown():await Le(this.onShutdown(),e.timeoutMillis),this._shutdown=!0}async forceFlush(e){if(this._shutdown){M.warn("Cannot forceFlush on already shutdown MetricReader.");return}if(e?.timeoutMillis==null){await this.onForceFlush();return}await Le(this.onForceFlush(),e.timeoutMillis)}};Z();function Cn(r,e){if(!Number.isInteger(e)||e<=0)throw new Error("maxExportBatchSize must be a positive integer");let t=[],a=0,s=[];function i(){s.length>0&&(t.push({resource:r.resource,scopeMetrics:s}),s=[],a=0)}for(let l of r.scopeMetrics){let u=null;for(let c of l.metrics){let w=c.dataPoints;if(w.length===0){u||(u={scope:l.scope,metrics:[]},s.push(u)),u.metrics.push(c);continue}let d=0;for(;d<w.length;){let o=e-a,n=Math.min(o,w.length-d);u||(u={scope:l.scope,metrics:[]},s.push(u));let _={...c,dataPoints:w.slice(d,d+n)};u.metrics.push(_),d+=n,a+=n,a===e&&(i(),u=null)}}}return i(),t}var _r=class extends De{_interval;_exporter;_exportInterval;_exportTimeout;_maxExportBatchSize;_ongoingExportPromise=null;constructor(e){let{exporter:t,exportIntervalMillis:a=6e4,metricProducers:s,cardinalityLimits:i,maxExportBatchSize:l}=e,{exportTimeoutMillis:u=3e4}=e;if(super({aggregationSelector:t.selectAggregation?.bind(t),aggregationTemporalitySelector:t.selectAggregationTemporality?.bind(t),otelComponentType:xn,metricProducers:s,cardinalitySelector:c=>{let w={default:2e3,...i};switch(c){case z.COUNTER:return w.counter??w.default;case z.GAUGE:return w.gauge??w.default;case z.HISTOGRAM:return w.histogram??w.default;case z.OBSERVABLE_COUNTER:return w.observableCounter??w.default;case z.OBSERVABLE_UP_DOWN_COUNTER:return w.observableUpDownCounter??w.default;case z.OBSERVABLE_GAUGE:return w.observableGauge??w.default;case z.UP_DOWN_COUNTER:return w.upDownCounter??w.default;default:return w.default}}}),a<=0)throw Error("exportIntervalMillis must be greater than 0");if(u<=0)throw Error("exportTimeoutMillis must be greater than 0");if(l!==void 0&&(!Number.isInteger(l)||l<=0))throw Error("maxExportBatchSize must be a positive integer");if(a<u){if("exportIntervalMillis"in e&&"exportTimeoutMillis"in e)throw Error("exportIntervalMillis must be greater than or equal to exportTimeoutMillis");M.info(`Timeout of ${u} exceeds the interval of ${a}. Clamping timeout to interval duration.`),u=a}this._exportInterval=a,this._exportTimeout=u,this._exporter=t,this._maxExportBatchSize=l}async _runOnce(){try{await this._doRun()}catch(e){Ro(e)}}async _doRun(){if(this._ongoingExportPromise){M.debug("PeriodicExportingMetricReader: export already in progress, skipping");return}let e=async()=>{let{resourceMetrics:t,errors:a}=await this.collect({timeoutMillis:this._exportTimeout});if(a.length>0&&M.error("PeriodicExportingMetricReader: metrics collection errors",...a),t.resource.asyncAttributesPending)try{await t.resource.waitForAsyncAttributes?.()}catch(l){M.debug("Error while resolving async portion of resource: ",l),Ro(l)}if(t.scopeMetrics.length===0)return;let s=this._maxExportBatchSize?Cn(t,this._maxExportBatchSize):[t],i=null;for(let l of s)try{let u=await Le(St._export(this._exporter,l),this._exportTimeout);u.code!==ke.SUCCESS&&(i=new Error(`PeriodicExportingMetricReader: metrics export failed (error ${u.error})`))}catch(u){if(u instanceof sr){M.error(`PeriodicExportingMetricReader: metrics export timed out after ${this._exportTimeout}ms`);break}else M.error("PeriodicExportingMetricReader: metrics export threw error",u),i=u instanceof Error?u:new Error(String(u))}if(i)throw i};this._ongoingExportPromise=e();try{await this._ongoingExportPromise}finally{this._ongoingExportPromise=null}}onInitialized(){this._interval=setInterval(()=>{this._runOnce()},this._exportInterval),typeof this._interval!="number"&&this._interval.unref()}async onForceFlush(){await this._awaitOngoingExport(),this._ongoingExportPromise?await this._awaitOngoingExport():await this._runOnce(),await this._exporter.forceFlush()}async _awaitOngoingExport(){if(this._ongoingExportPromise){M.debug("PeriodicExportingMetricReader: export already in progress, awaiting ongoing export");try{await this._ongoingExportPromise}catch{}}}async onShutdown(){this._interval&&clearInterval(this._interval),await this.onForceFlush(),await this._exporter.shutdown()}};var pr=class r{_shutdown=!1;_temporalitySelector;constructor(e){this._temporalitySelector=e?.temporalitySelector??Wr}export(e,t){if(this._shutdown){t({code:ke.FAILED});return}return r._sendMetrics(e,t)}forceFlush(){return Promise.resolve()}selectAggregationTemporality(e){return this._temporalitySelector(e)}shutdown(){return this._shutdown=!0,Promise.resolve()}static _sendMetrics(e,t){for(let a of e.scopeMetrics)for(let s of a.metrics)console.dir({descriptor:s.descriptor,dataPointType:s.dataPointType,dataPoints:s.dataPoints},{depth:null});t({code:ke.SUCCESS})}};Z();var Qr=class{_registeredViews=[];addView(e){this._registeredViews.push(e)}findViews(e,t){return this._registeredViews.filter(s=>this._matchInstrument(s.instrumentSelector,e)&&this._matchMeter(s.meterSelector,t))}_matchInstrument(e,t){return(e.getType()===void 0||t.type===e.getType())&&e.getNameFilter().match(t.name)&&e.getUnitFilter().match(t.unit)}_matchMeter(e,t){return e.getNameFilter().match(t.name)&&(t.version===void 0||e.getVersionFilter().match(t.version))&&(t.schemaUrl===void 0||e.getSchemaUrlFilter().match(t.schemaUrl))}};Z();function ye(r,e,t){return Jl(r)||M.warn(`Invalid metric name: "${r}". The metric name should be a ASCII string with a length no greater than 255 characters.`),{name:r,type:e,description:t?.description??"",unit:t?.unit??"",valueType:t?.valueType??Ae.DOUBLE,advice:t?.advice??{}}}function An(r,e){return{name:r.name??e.name,description:r.description??e.description,type:e.type,unit:e.unit,valueType:e.valueType,advice:e.advice}}function kn(r,e){return hn(r.name,e.name)&&r.unit===e.unit&&r.type===e.type&&r.valueType===e.valueType}var Yl=/^[a-z][a-z0-9_.\-/]{0,254}$/i;function Jl(r){return Yl.test(r)}Z();var Ge=class{_writableMetricStorage;_descriptor;constructor(e,t){this._writableMetricStorage=e,this._descriptor=t}_record(e,t={},a){if(typeof e!="number"){M.warn(`non-number value provided to metric ${this._descriptor.name}: ${e}`);return}this._descriptor.valueType===Ae.INT&&!Number.isInteger(e)&&(M.warn(`INT value type cannot accept a floating-point value for ${this._descriptor.name}, ignoring the fractional digits.`),e=Math.trunc(e),!Number.isInteger(e))||this._writableMetricStorage.record(e,t,a,Date.now())}},Yr=class extends Ge{add(e,t,a){this._record(e,t,a)}},Jr=class extends Ge{add(e,t,a){if(e<0){M.warn(`negative value provided to counter ${this._descriptor.name}: ${e}`);return}this._record(e,t,a)}},Zr=class extends Ge{record(e,t,a){this._record(e,t,a)}},Or=class extends Ge{record(e,t,a){if(e<0){M.warn(`negative value provided to histogram ${this._descriptor.name}: ${e}`);return}this._record(e,t,a)}},He=class{_metricStorages;_descriptor;_observableRegistry;constructor(e,t,a){this._descriptor=e,this._metricStorages=t,this._observableRegistry=a}addCallback(e){this._observableRegistry.addCallback(e,this)}removeCallback(e){this._observableRegistry.removeCallback(e,this)}},qr=class extends He{},eo=class extends He{},ro=class extends He{};function fr(r){return r instanceof He}var oo=class{_meterSharedState;constructor(e){this._meterSharedState=e}createGauge(e,t){let a=ye(e,z.GAUGE,t),s=this._meterSharedState.registerMetricStorage(a);return new Zr(s,a)}createHistogram(e,t){let a=ye(e,z.HISTOGRAM,t),s=this._meterSharedState.registerMetricStorage(a);return new Or(s,a)}createCounter(e,t){let a=ye(e,z.COUNTER,t),s=this._meterSharedState.registerMetricStorage(a);return new Jr(s,a)}createUpDownCounter(e,t){let a=ye(e,z.UP_DOWN_COUNTER,t),s=this._meterSharedState.registerMetricStorage(a);return new Yr(s,a)}createObservableGauge(e,t){let a=ye(e,z.OBSERVABLE_GAUGE,t),s=this._meterSharedState.registerAsyncMetricStorage(a);return new eo(a,s,this._meterSharedState.observableRegistry)}createObservableCounter(e,t){let a=ye(e,z.OBSERVABLE_COUNTER,t),s=this._meterSharedState.registerAsyncMetricStorage(a);return new qr(a,s,this._meterSharedState.observableRegistry)}createObservableUpDownCounter(e,t){let a=ye(e,z.OBSERVABLE_UP_DOWN_COUNTER,t),s=this._meterSharedState.registerAsyncMetricStorage(a);return new ro(a,s,this._meterSharedState.observableRegistry)}addBatchObservableCallback(e,t){this._meterSharedState.observableRegistry.addBatchCallback(e,t)}removeBatchObservableCallback(e,t){this._meterSharedState.observableRegistry.removeBatchCallback(e,t)}};var Fe=class{_instrumentDescriptor;constructor(e){this._instrumentDescriptor=e}getInstrumentDescriptor(){return this._instrumentDescriptor}updateDescription(e){this._instrumentDescriptor=ye(this._instrumentDescriptor.name,this._instrumentDescriptor.type,{description:e,valueType:this._instrumentDescriptor.valueType,unit:this._instrumentDescriptor.unit,advice:this._instrumentDescriptor.advice})}};var lt=class{_valueMap=new Map;_keyMap=new Map;_hash;constructor(e){this._hash=e}get(e,t){return t??=this._hash(e),this._valueMap.get(t)}getOrDefault(e,t){let a=this._hash(e);if(this._valueMap.has(a))return this._valueMap.get(a);let s=t();return this._keyMap.has(a)||this._keyMap.set(a,e),this._valueMap.set(a,s),s}set(e,t,a){a??=this._hash(e),this._keyMap.has(a)||this._keyMap.set(a,e),this._valueMap.set(a,t)}has(e,t){return t??=this._hash(e),this._valueMap.has(t)}*keys(){let e=this._keyMap.entries(),t=e.next();for(;t.done!==!0;)yield[t.value[1],t.value[0]],t=e.next()}*entries(){let e=this._valueMap.entries(),t=e.next();for(;t.done!==!0;)yield[this._keyMap.get(t.value[0]),t.value[1],t.value[0]],t=e.next()}get size(){return this._valueMap.size}},ne=class extends lt{constructor(){super(Kr)}};var $e=class{_activeCollectionStorage=new ne;_cumulativeMemoStorage=new ne;_cardinalityLimit;_overflowAttributes={"otel.metric.overflow":!0};_overflowHashCode;_aggregator;constructor(e,t){this._aggregator=e,this._cardinalityLimit=(t??2e3)-1,this._overflowHashCode=Kr(this._overflowAttributes)}record(e,t,a){let s=this._activeCollectionStorage.get(t);if(!s){let i=Me(a);if(this._activeCollectionStorage.size>=this._cardinalityLimit){this._activeCollectionStorage.getOrDefault(this._overflowAttributes,()=>this._aggregator.createAccumulation(i))?.record(e);return}s=this._aggregator.createAccumulation(i),this._activeCollectionStorage.set(t,s)}s?.record(e)}batchCumulate(e,t){for(let[a,s,i]of e.entries()){let l=a,u=i,c=this._aggregator.createAccumulation(t);c?.record(s);let w=c;if(this._cumulativeMemoStorage.has(l,u)){let d=this._cumulativeMemoStorage.get(l,u);w=this._aggregator.diff(d,c)}else if(this._cumulativeMemoStorage.size>=this._cardinalityLimit&&(l=this._overflowAttributes,u=this._overflowHashCode,this._cumulativeMemoStorage.has(l,u))){let d=this._cumulativeMemoStorage.get(l,u);w=this._aggregator.diff(d,c)}if(this._activeCollectionStorage.has(l,u)){let d=this._activeCollectionStorage.get(l,u);w=this._aggregator.merge(d,w)}this._cumulativeMemoStorage.set(l,c,u),this._activeCollectionStorage.set(l,w,u)}}collect(){let e=this._activeCollectionStorage;return this._activeCollectionStorage=new ne,e}};var We=class r{_aggregator;_unreportedAccumulations=new Map;_reportHistory=new Map;constructor(e,t){this._aggregator=e,t.forEach(a=>{this._unreportedAccumulations.set(a,[])})}buildMetrics(e,t,a,s){this._stashAccumulations(a);let i=this._getMergedUnreportedAccumulations(e),l=i,u;if(this._reportHistory.has(e)){let w=this._reportHistory.get(e),d=w.collectionTime;u=w.aggregationTemporality,u===Ue.CUMULATIVE?l=r.merge(w.accumulations,i,this._aggregator):l=r.calibrateStartTime(w.accumulations,i,d)}else u=e.selectAggregationTemporality(t.type);this._reportHistory.set(e,{accumulations:l,collectionTime:s,aggregationTemporality:u});let c=Zl(l);if(c.length!==0)return this._aggregator.toMetricData(t,u,c,s)}_stashAccumulations(e){let t=this._unreportedAccumulations.keys();for(let a of t){let s=this._unreportedAccumulations.get(a);s===void 0&&(s=[],this._unreportedAccumulations.set(a,s)),s.push(e)}}_getMergedUnreportedAccumulations(e){let t=new ne,a=this._unreportedAccumulations.get(e);if(this._unreportedAccumulations.set(e,[]),a===void 0)return t;for(let s of a)t=r.merge(t,s,this._aggregator);return t}static merge(e,t,a){let s=e,i=t.entries(),l=i.next();for(;l.done!==!0;){let[u,c,w]=l.value;if(e.has(u,w)){let d=e.get(u,w),o=a.merge(d,c);s.set(u,o,w)}else s.set(u,c,w);l=i.next()}return s}static calibrateStartTime(e,t,a){for(let[s,i]of e.keys())t.get(s,i)?.setStartTime(a);return t}};function Zl(r){return Array.from(r.entries())}var to=class extends Fe{_aggregationCardinalityLimit;_deltaMetricStorage;_temporalMetricStorage;_attributesProcessor;constructor(e,t,a,s,i){super(e),this._aggregationCardinalityLimit=i,this._deltaMetricStorage=new $e(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new We(t,s),this._attributesProcessor=a}record(e,t){if(this._attributesProcessor===void 0){this._deltaMetricStorage.batchCumulate(e,t);return}let a=new ne;for(let[s,i]of e.entries())a.set(this._attributesProcessor.process(s),i);this._deltaMetricStorage.batchCumulate(a,t)}collect(e,t){let a=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(e,this._instrumentDescriptor,a,t)}};Z();function dt(r,e){let t="";return r.unit!==e.unit&&(t+=` - Unit '${r.unit}' does not match '${e.unit}'
|
|
7
|
+
`),r.type!==e.type&&(t+=` - Type '${r.type}' does not match '${e.type}'
|
|
8
|
+
`),r.valueType!==e.valueType&&(t+=` - Value Type '${r.valueType}' does not match '${e.valueType}'
|
|
9
|
+
`),r.description!==e.description&&(t+=` - Description '${r.description}' does not match '${e.description}'
|
|
10
|
+
`),t}function Ol(r,e){return` - use valueType '${r.valueType}' on instrument creation or use an instrument name other than '${e.name}'`}function ql(r,e){return` - use unit '${r.unit}' on instrument creation or use an instrument name other than '${e.name}'`}function ed(r,e){let t={name:e.name,type:e.type,unit:e.unit},a=JSON.stringify(t);return` - create a new view with a name other than '${r.name}' and InstrumentSelector '${a}'`}function rd(r,e){let t={name:e.name,type:e.type,unit:e.unit},a=JSON.stringify(t);return` - create a new view with a name other than '${r.name}' and InstrumentSelector '${a}'
|
|
11
|
+
- OR - create a new view with the name ${r.name} and description '${r.description}' and InstrumentSelector ${a}
|
|
12
|
+
- OR - create a new view with the name ${e.name} and description '${r.description}' and InstrumentSelector ${a}`}function ut(r,e){return r.valueType!==e.valueType?Ol(r,e):r.unit!==e.unit?ql(r,e):r.type!==e.type?ed(r,e):r.description!==e.description?rd(r,e):""}var ao=class r{_sharedRegistry=new Map;_perCollectorRegistry=new Map;static create(){return new r}getStorages(e){let t=[];for(let s of this._sharedRegistry.values())t=t.concat(s);let a=this._perCollectorRegistry.get(e);if(a!=null)for(let s of a.values())t=t.concat(s);return t}register(e){this._registerStorage(e,this._sharedRegistry)}registerForCollector(e,t){let a=this._perCollectorRegistry.get(e);a==null&&(a=new Map,this._perCollectorRegistry.set(e,a)),this._registerStorage(t,a)}findOrUpdateCompatibleStorage(e){let t=this._sharedRegistry.get(e.name);return t===void 0?null:this._findOrUpdateCompatibleStorage(e,t)}findOrUpdateCompatibleCollectorStorage(e,t){let a=this._perCollectorRegistry.get(e);if(a===void 0)return null;let s=a.get(t.name);return s===void 0?null:this._findOrUpdateCompatibleStorage(t,s)}_registerStorage(e,t){let a=e.getInstrumentDescriptor(),s=t.get(a.name);if(s===void 0){t.set(a.name,[e]);return}s.push(e)}_findOrUpdateCompatibleStorage(e,t){let a=null;for(let s of t){let i=s.getInstrumentDescriptor();kn(i,e)?(i.description!==e.description&&(e.description.length>i.description.length&&s.updateDescription(e.description),M.warn("A view or instrument with the name ",e.name,` has already been registered, but has a different description and is incompatible with another registered view.
|
|
13
|
+
`,`Details:
|
|
14
|
+
`,dt(i,e),`The longer description will be used.
|
|
15
|
+
To resolve the conflict:`,ut(i,e))),a=s):M.warn("A view or instrument with the name ",e.name,` has already been registered and is incompatible with another registered view.
|
|
16
|
+
`,`Details:
|
|
17
|
+
`,dt(i,e),`To resolve the conflict:
|
|
18
|
+
`,ut(i,e))}return a}};Z();var no=class{_backingStorages;hasAttributeProcessor;constructor(e){this._backingStorages=e,this.hasAttributeProcessor=e.some(t=>t.hasAttributeProcessor)}record(e,t,a,s){this.hasAttributeProcessor&&a===void 0&&(a=te.active());let i=this._backingStorages;for(let l=0;l<i.length;l++)i[l].record(e,t,a,s)}};Z();Z();var so=class{_buffer=new ne;_instrumentName;_valueType;constructor(e,t){this._instrumentName=e,this._valueType=t}observe(e,t={}){if(typeof e!="number"){M.warn(`non-number value provided to metric ${this._instrumentName}: ${e}`);return}this._valueType===Ae.INT&&!Number.isInteger(e)&&(M.warn(`INT value type cannot accept a floating-point value for ${this._instrumentName}, ignoring the fractional digits.`),e=Math.trunc(e),!Number.isInteger(e))||this._buffer.set(t,e)}},io=class{_buffer=new Map;observe(e,t,a={}){if(!fr(e))return;let s=this._buffer.get(e);if(s==null&&(s=new ne,this._buffer.set(e,s)),typeof t!="number"){M.warn(`non-number value provided to metric ${e._descriptor.name}: ${t}`);return}e._descriptor.valueType===Ae.INT&&!Number.isInteger(t)&&(M.warn(`INT value type cannot accept a floating-point value for ${e._descriptor.name}, ignoring the fractional digits.`),t=Math.trunc(t),!Number.isInteger(t))||s.set(a,t)}};var lo=class{_callbacks=[];_batchCallbacks=[];addCallback(e,t){this._findCallback(e,t)>=0||this._callbacks.push({callback:e,instrument:t})}removeCallback(e,t){let a=this._findCallback(e,t);a<0||this._callbacks.splice(a,1)}addBatchCallback(e,t){let a=new Set(t.filter(fr));if(a.size===0){M.error("BatchObservableCallback is not associated with valid instruments",t);return}this._findBatchCallback(e,a)>=0||this._batchCallbacks.push({callback:e,instruments:a})}removeBatchCallback(e,t){let a=new Set(t.filter(fr)),s=this._findBatchCallback(e,a);s<0||this._batchCallbacks.splice(s,1)}async observe(e,t){let a=this._observeCallbacks(e,t),s=this._observeBatchCallbacks(e,t);return(await Promise.allSettled([...a,...s])).filter(u=>u.status==="rejected").map(u=>u.reason)}_observeCallbacks(e,t){return this._callbacks.map(async({callback:a,instrument:s})=>{let i=new so(s._descriptor.name,s._descriptor.valueType),l=Promise.resolve(a(i));t!=null&&(l=Le(l,t)),await l,s._metricStorages.forEach(u=>{u.record(i._buffer,e)})})}_observeBatchCallbacks(e,t){return this._batchCallbacks.map(async({callback:a,instruments:s})=>{let i=new io,l=Promise.resolve(a(i));t!=null&&(l=Le(l,t)),await l,s.forEach(u=>{let c=i._buffer.get(u);c!=null&&u._metricStorages.forEach(w=>{w.record(c,e)})})})}_findCallback(e,t){return this._callbacks.findIndex(a=>a.callback===e&&a.instrument===t)}_findBatchCallback(e,t){return this._batchCallbacks.findIndex(a=>a.callback===e&&cn(a.instruments,t))}};Z();var uo=class extends Fe{_aggregationCardinalityLimit;_deltaMetricStorage;_temporalMetricStorage;_attributesProcessor;constructor(e,t,a,s,i){super(e),this._aggregationCardinalityLimit=i,this._deltaMetricStorage=new $e(t,this._aggregationCardinalityLimit),this._temporalMetricStorage=new We(t,s),this._attributesProcessor=a,this.hasAttributeProcessor=a!==void 0}hasAttributeProcessor;record(e,t,a,s){this._attributesProcessor!==void 0&&(t=this._attributesProcessor.process(t,a??te.active())),this._deltaMetricStorage.record(e,t,s)}collect(e,t){let a=this._deltaMetricStorage.collect();return this._temporalMetricStorage.buildMetrics(e,this._instrumentDescriptor,a,t)}};var co=class{metricStorageRegistry=new ao;observableRegistry=new lo;meter;_meterProviderSharedState;_instrumentationScope;constructor(e,t){this.meter=new oo(this),this._meterProviderSharedState=e,this._instrumentationScope=t}registerMetricStorage(e){let t=this._registerMetricStorage(e,uo);return t.length===1?t[0]:new no(t)}registerAsyncMetricStorage(e){return this._registerMetricStorage(e,to)}async collect(e,t,a){let s=await this.observableRegistry.observe(t,a?.timeoutMillis),i=this.metricStorageRegistry.getStorages(e);if(i.length===0)return null;let l=[];return i.forEach(u=>{let c=u.collect(e,t);c!=null&&l.push(c)}),l.length===0?{errors:s}:{scopeMetrics:{scope:this._instrumentationScope,metrics:l},errors:s}}_registerMetricStorage(e,t){let s=this._meterProviderSharedState.viewRegistry.findViews(e,this._instrumentationScope).map(i=>{let l=An(i,e),u=this.metricStorageRegistry.findOrUpdateCompatibleStorage(l);if(u!=null)return u;let c=i.aggregation.createAggregator(l),w=new t(l,c,i.attributesProcessor,this._meterProviderSharedState.metricCollectors,i.aggregationCardinalityLimit);return this.metricStorageRegistry.register(w),w});if(s.length===0){let l=this._meterProviderSharedState.selectAggregations(e.type).map(([u,c])=>{let w=this.metricStorageRegistry.findOrUpdateCompatibleCollectorStorage(u,e);if(w!=null)return w;let d=c.createAggregator(e),o=u.selectCardinalityLimit(e.type),n=new t(e,d,void 0,[u],o);return this.metricStorageRegistry.registerForCollector(u,n),n});s=s.concat(l)}return s}};var wo=class{viewRegistry=new Qr;metricCollectors=[];meterSharedStates=new Map;resource;constructor(e){this.resource=e}getMeterSharedState(e){let t=un(e),a=this.meterSharedStates.get(t);return a==null&&(a=new co(this,e),this.meterSharedStates.set(t,a)),a}selectAggregations(e){let t=[];for(let a of this.metricCollectors)t.push([a,$r(a.selectAggregation(e))]);return t}};var ho=class{_sharedState;_metricReader;constructor(e,t){this._sharedState=e,this._metricReader=t}async collect(e){let t=Me(Date.now()),a=[],s=[],i=Array.from(this._sharedState.meterSharedStates.values()).map(async l=>{let u=await l.collect(this,t,e);u?.scopeMetrics!=null&&a.push(u.scopeMetrics),u?.errors!=null&&s.push(...u.errors)});return await Promise.all(i),{resourceMetrics:{resource:this._sharedState.resource,scopeMetrics:a},errors:s}}async forceFlush(e){await this._metricReader.forceFlush(e)}async shutdown(e){await this._metricReader.shutdown(e)}selectAggregationTemporality(e){return this._metricReader.selectAggregationTemporality(e)}selectAggregation(e){return this._metricReader.selectAggregation(e)}selectCardinalityLimit(e){return this._metricReader.selectCardinalityLimit?.(e)??2e3}};var od=/[\^$\\.+?()[\]{}|]/g,Qe=class r{_matchAll;_regexp;constructor(e){e==="*"?(this._matchAll=!0,this._regexp=/.*/):(this._matchAll=!1,this._regexp=new RegExp(r.escapePattern(e)))}match(e){return this._matchAll?!0:this._regexp.test(e)}static escapePattern(e){return`^${e.replace(od,"\\$&").replace("*",".*")}$`}static hasWildcard(e){return e.includes("*")}},Pe=class{_matchAll;_pattern;constructor(e){this._matchAll=e===void 0,this._pattern=e}match(e){return!!(this._matchAll||e===this._pattern)}};var ct=class{process(e,t){return e}},wt=class{_processors;constructor(e){this._processors=e}process(e,t){let a=e;for(let s of this._processors)a=s.process(a,t);return a}};function In(){return td}function Nn(r){return new wt(r)}var td=new ct;var mo=class{_nameFilter;_type;_unitFilter;constructor(e){this._nameFilter=new Qe(e?.name??"*"),this._type=e?.type,this._unitFilter=new Pe(e?.unit)}getType(){return this._type}getNameFilter(){return this._nameFilter}getUnitFilter(){return this._unitFilter}};var go=class{_nameFilter;_versionFilter;_schemaUrlFilter;constructor(e){this._nameFilter=new Pe(e?.name),this._versionFilter=new Pe(e?.version),this._schemaUrlFilter=new Pe(e?.schemaUrl)}getNameFilter(){return this._nameFilter}getVersionFilter(){return this._versionFilter}getSchemaUrlFilter(){return this._schemaUrlFilter}};function ad(r){return r.instrumentName==null&&r.instrumentType==null&&r.instrumentUnit==null&&r.meterName==null&&r.meterVersion==null&&r.meterSchemaUrl==null}function nd(r){if(ad(r))throw new Error("Cannot create view with no selector arguments supplied");if(r.name!=null&&(r?.instrumentName==null||Qe.hasWildcard(r.instrumentName)))throw new Error("Views with a specified name must be declared with an instrument selector that selects at most one instrument per meter.")}var _o=class{name;description;aggregation;attributesProcessor;instrumentSelector;meterSelector;aggregationCardinalityLimit;constructor(e){nd(e),e.attributesProcessors!=null?this.attributesProcessor=Nn(e.attributesProcessors):this.attributesProcessor=In(),this.name=e.name,this.description=e.description,this.aggregation=$r(e.aggregation??{type:he.DEFAULT}),this.instrumentSelector=new mo({name:e.instrumentName,type:e.instrumentType,unit:e.instrumentUnit}),this.meterSelector=new go({name:e.meterName,version:e.meterVersion,schemaUrl:e.meterSchemaUrl}),this.aggregationCardinalityLimit=e.aggregationCardinalityLimit}};var yr=class{_sharedState;_shutdown=!1;constructor(e){if(this._sharedState=new wo(e?.resource??kt()),e?.views!=null&&e.views.length>0)for(let t of e.views)this._sharedState.viewRegistry.addView(new _o(t));if(e?.readers!=null&&e.readers.length>0)for(let t of e.readers){let a=new ho(this._sharedState,t);t.setMetricProducer(a),this._sharedState.metricCollectors.push(a),e.sdkMetricsEnabled&&t instanceof De&&t._setSelfObsMeterProvider(this)}}getMeter(e,t="",a={}){return this._shutdown?(M.warn("A shutdown MeterProvider cannot provide a Meter"),Se()):this._sharedState.getMeterSharedState({name:e,version:t,schemaUrl:a.schemaUrl}).meter}async shutdown(e){if(this._shutdown){M.warn("shutdown may only be called once per MeterProvider");return}this._shutdown=!0,await Promise.all(this._sharedState.metricCollectors.map(t=>t.shutdown(e)))}async forceFlush(e){if(this._shutdown){M.warn("invalid attempt to force flush after MeterProvider shutdown");return}await Promise.all(this._sharedState.metricCollectors.map(t=>t.forceFlush(e)))}};bt();import{homedir as sd}from"os";function Mn(r){let e=Object.entries(process.env).flatMap(([i,l])=>/(?:API_KEY|TOKEN|SECRET|PASSWORD|PRIVATE_KEY|DSN)/iu.test(i)&&l&&l.length>=4?[l,encodeURIComponent(l)]:[]),t=i=>{for(let u of e)i=i.replaceAll(u,"[redacted]");let l=sd();return l&&l!=="/"&&(i=i.replaceAll(l,"~").replaceAll(encodeURIComponent(l),"~")),i.replace(/\b(Bearer\s+)[\w.+/~=-]+/giu,"$1[redacted]")},a=new WeakSet,s=i=>{if(!(typeof i!="object"||i===null||a.has(i))){if(a.add(i),Array.isArray(i))for(let l=0;l<i.length;l++){let u=i[l];typeof u=="string"?i[l]=t(u):s(u)}else if(Vt(i))for(let[l,u]of Object.entries(i))/(?:authorization|api[_-]?key|password|secret|credential|(?:^|[_-])token(?:$|[_-])|access[_-]?token|refresh[_-]?token|private[_-]?key|(?:^|[_-])dsn(?:$|[_-])|^(?:cookie|set-cookie)$)/iu.test(l)?i[l]="[redacted]":typeof u=="string"?i[l]=t(u):s(u)}};s(r)}var id=ft({module:"telemetry"}),ld=6e4,ht=2e3;function _t(r){return(r??"").split(",").map(e=>e.trim()).filter(e=>e.length>0&&e!=="none")}function dd(r,e){let t=Number.parseInt(r??"",10);return Number.isFinite(t)&&t>0?t:e}function pt(r){let e=`OTEL_EXPORTER_OTLP_${r.toUpperCase()}_PROTOCOL`,a=process.env[e]?.trim()||process.env.OTEL_EXPORTER_OTLP_PROTOCOL?.trim()||"http/protobuf";if(a==="grpc"||a==="http/json"||a==="http/protobuf")return a;throw new Error(`Unsupported OpenTelemetry protocol: ${a}`)}function ud(r){let e={};for(let t of r?.split(",")??[]){let a=t.indexOf("=");if(a<=0)continue;let s=t.slice(0,a).trim(),i=t.slice(a+1).trim();if(s&&i)try{e[decodeURIComponent(s)]=decodeURIComponent(i)}catch{e[s]=i}}return e}function cd(){return At({[xo]:"yukino",[yt]:Ne,...ud(process.env.OTEL_RESOURCE_ATTRIBUTES),...process.env.OTEL_SERVICE_NAME?{[xo]:process.env.OTEL_SERVICE_NAME}:{}})}async function wd(r){switch(r){case"grpc":{let{OTLPTraceExporter:e}=await import("./src-GG4YROJH.js");return new e}case"http/json":{let{OTLPTraceExporter:e}=await import("./esm-H73EL6IR.js");return new e}case"http/protobuf":{let{OTLPTraceExporter:e}=await import("./esm-Y237QNPJ.js");return new e}}}async function hd(r){switch(r){case"grpc":{let{OTLPLogExporter:e}=await import("./src-EMFESWQS.js");return new e}case"http/json":{let{OTLPLogExporter:e}=await import("./esm-EOOB75BT.js");return new e}case"http/protobuf":{let{OTLPLogExporter:e}=await import("./esm-IBZKE3IU.js");return new e}}}async function md(r){switch(r){case"grpc":{let{OTLPMetricExporter:e}=await import("./src-DEVJGNXS.js");return new e}case"http/json":{let{OTLPMetricExporter:e}=await import("./esm-2JJG3HR7.js");return new e}case"http/protobuf":{let{OTLPMetricExporter:e}=await import("./esm-7DWXO52B.js");return new e}}}async function gd(r){let e=[],t=_t(process.env.OTEL_TRACES_EXPORTER);for(let s of t)if(s==="console")e.push(new er(new It));else if(s==="otlp")e.push(new er(await wd(pt("traces"))));else throw new Error(`Unsupported trace exporter: ${s}`);if(process.env.LANGFUSE_PUBLIC_KEY&&process.env.LANGFUSE_SECRET_KEY&&e.push(new Ya({mediaUploadEnabled:!1,release:process.env.LANGFUSE_RELEASE??Ne})),e.length===0)return null;let a=new Nt({resource:r,spanProcessors:e});return Ko(a),a}async function _d(r){let e=[];for(let t of _t(process.env.OTEL_LOGS_EXPORTER)){let a;if(t==="console")a=new nr;else if(t==="otlp")a=await hd(pt("logs"));else throw new Error(`Unsupported log exporter: ${t}`);e.push(new Ie({exporter:a}))}return e.length>0?new ar({resource:r,processors:e}):null}async function pd(){let r=[],e=dd(process.env.OTEL_METRIC_EXPORT_INTERVAL,ld);for(let t of _t(process.env.OTEL_METRICS_EXPORTER)){if(t==="prometheus"){let{PrometheusExporter:s}=await import("./src-JFAO2DGP.js");r.push(new s);continue}let a;if(t==="console")a=new pr;else if(t==="otlp")a=await md(pt("metrics"));else throw new Error(`Unsupported metric exporter: ${t}`);r.push(new _r({exporter:a,exportIntervalMillis:e}))}return r}async function fd(){if(!process.env.SENTRY_DSN)return null;let r=await import("./esm-W4NAAZTQ.js");return r.init({debug:process.env.SENTRY_DEBUG?.toLowerCase()==="true",dsn:process.env.SENTRY_DSN,environment:process.env.SENTRY_ENVIRONMENT,includeLocalVariables:!1,integrations:e=>e.filter(t=>t.name!=="OnUncaughtException"&&t.name!=="OnUnhandledRejection"),registerEsmLoaderHooks:!1,release:process.env.SENTRY_RELEASE??Ne,sendDefaultPii:!1,beforeSend(e){return e.request&&(delete e.request.data,delete e.request.cookies),Mn(e),e},skipOpenTelemetrySetup:!0,tracesSampleRate:0}),r}async function po(r,e){try{return await e()}catch(t){return id.error({err:t,label:r},"telemetry initialization failed"),null}}function Vn(r){return new Promise(e=>{let t=setTimeout(e,ht);t.unref(),r.then(()=>{clearTimeout(t),e()},()=>{clearTimeout(t),e()})})}function yd(r){switch(r){case"error":return xe.ERROR;case"info":return xe.INFO;case"warn":return xe.WARN}}function bd(r,e,t){switch(r){case"agent":return tr(e,{metadata:t},{asType:"agent"});case"generation":{let a=typeof t.model=="string"?t.model:void 0;return tr(e,{metadata:t,model:a},{asType:"generation"})}case"tool":return tr(e,{metadata:t},{asType:"tool"})}}function vd(r,e,t,a){switch(e){case"agent":return r.startObservation(t,{metadata:a},{asType:"agent"});case"generation":{let s=typeof a.model=="string"?a.model:void 0;return r.startObservation(t,{metadata:a,model:s},{asType:"generation"})}case"tool":return r.startObservation(t,{metadata:a},{asType:"tool"})}}var mt=class r{constructor(e){this.observation=e}observation;end(){this.observation.end()}recordException(e){let t=e instanceof Error?e.name:typeof e;this.observation.otelSpan.setAttribute("error.type",t),this.observation.otelSpan.setStatus({code:bo.ERROR}),this.observation.updateOtelSpanAttributes({level:"ERROR",statusMessage:t})}startChild(e,t,a={}){return new r(vd(this.observation,e,t,a))}update(e){this.observation.updateOtelSpanAttributes(e)}},gt=class{constructor(e,t,a,s,i,l){this.tracerProvider=e;this.loggerProvider=t;this.meterProvider=a;this.meter=s;this.logger=i;this.sentry=l}tracerProvider;loggerProvider;meterProvider;meter;logger;sentry;counters=new Map;histograms=new Map;mode="unknown";captureError(e,t){e instanceof Error&&e.name==="AbortError"||(this.sentry?.captureException(e,{tags:{context:t,mode:this.mode}}),this.emitLog("yukino.error","error",{context:t,"error.type":e instanceof Error?e.name:typeof e}))}emitLog(e,t,a={}){this.logger?.emit({attributes:{...a,"yukino.mode":this.mode},body:e,severityNumber:yd(t),severityText:t.toUpperCase()})}async flush(){let e=[];this.tracerProvider&&e.push(this.tracerProvider.forceFlush()),this.loggerProvider&&e.push(this.loggerProvider.forceFlush()),this.meterProvider&&e.push(this.meterProvider.forceFlush()),this.sentry&&e.push(this.sentry.flush(ht)),await Vn(Promise.allSettled(e).then(()=>{}))}recordMetric(e,t,a,s={}){if(!this.meter)return;let i={...s,"yukino.mode":this.mode};if(t==="counter"){let u=this.counters.get(e);u||(u=this.meter.createCounter(e),this.counters.set(e,u)),u.add(a,i);return}let l=this.histograms.get(e);l||(l=this.meter.createHistogram(e,{unit:"ms"}),this.histograms.set(e,l)),l.record(a,i)}setMode(e){this.mode=e,this.sentry?.setTag("yukino.mode",e)}async shutdown(){let e=[];this.tracerProvider&&e.push(this.tracerProvider.shutdown()),this.loggerProvider&&e.push(this.loggerProvider.shutdown()),this.meterProvider&&e.push(this.meterProvider.shutdown()),this.sentry&&e.push(this.sentry.close(ht)),await Vn(Promise.allSettled(e).then(()=>{})),Ko(null)}startObservation(e,t,a={}){return this.tracerProvider?new mt(bd(e,t,{...a,"yukino.mode":this.mode})):{end:()=>{},recordException:()=>{},startChild:(s,i,l)=>this.startObservation(s,i,l),update:()=>{}}}};async function Fm(){let r=cd(),e=process.env.OTEL_SDK_DISABLED?.toLowerCase()!=="true",[t,a,s,i]=await Promise.all([e?po("traces",()=>gd(r)):Promise.resolve(null),e?po("logs",()=>_d(r)):Promise.resolve(null),e?po("metrics",pd):Promise.resolve(null),po("sentry",fd)]),l=s&&s.length>0?new yr({readers:s,resource:r}):null,u=l?.getMeter("@yukino.js/yukino",Ne)??null,c=a?.getLogger("@yukino.js/yukino",Ne)??null;return new gt(t,a,l,u,c,i)}export{_t as a,Fm as b};
|