fern-api 3.56.0 → 3.56.10
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/cli.cjs +7 -7
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -1432,7 +1432,7 @@ Error details: ${p||f||"No output"}`);if(_!==0)throw new Error(`Container exited
|
|
|
1432
1432
|
${f}
|
|
1433
1433
|
${p}`)}async function FzD(e,t){await Th(void 0,t??"docker",["pull",e],{all:!0,doNotPipeOutput:!0})}var LZi=se(require("path"),1),CAn="/fern",qGc="output",TGc="config.json",RGc="ir.json",QzD="snippet.json",UzD="snippet-templates.json",LzD="generators",VzD="sources",WzD=LZi.default.join(CAn,qGc),xzD=LZi.default.join(CAn,TGc),GzD=LZi.default.join(CAn,RGc),HzD=LZi.default.join(CAn,QzD),KzD=LZi.default.join(CAn,UzD),U4G=LZi.default.join(CAn,LzD),$zD=LZi.default.join(CAn,VzD);var dou=WzD,Dka=xzD,pou=GzD,_ou=HzD,hou=KzD;var seh=$zD,you="9229";var VZi=class{containerImage;keepContainer;runner;constructor({containerImage:t,keepContainer:r,runner:i,dockerImage:n,keepDocker:a}){this.containerImage=t??n??"",this.keepContainer=r??a??!1,this.runner=i}async execute({generatorName:t,irPath:r,configPath:i,outputPath:n,snippetPath:a,snippetTemplatePath:o,licenseFilePath:c,context:d,inspect:s,runner:u}){d.logger.info(`Executing generator ${t} using container image: ${this.containerImage}`);let f=[`${i}:${Dka}:ro`,`${r}:${pou}:ro`,`${n}:${dou}`];a&&f.push(`${a}:${_ou}`),o&&f.push(`${o}:${hou}`),c&&f.push(`${c}:/tmp/LICENSE:ro`);let p={},_={};s&&(p.NODE_OPTIONS=`--inspect-brk=0.0.0.0:${you}`,_[you]=you),await CGc({logger:d.logger,imageName:this.containerImage,args:[Dka],binds:f,envVars:p,ports:_,removeAfterCompletion:!this.keepContainer,runner:this.runner??u})}};var CC={};$t(CC,{AvailabilityStatusSchema:()=>leh,FernDefinitionError:()=>qka,FernDefinitionTimeoutError:()=>Tka,FormDataBodyEncodingStyle:()=>geh,HttpMethodSchema:()=>Oeh,ObjectPropertyAccess:()=>Peh,StreamFormat:()=>meh,SupportedSdkLanguageSchema:()=>heh,WebSocketOrigin:()=>Meh,WebhookMethodSchema:()=>Seh,auth:()=>ceh,availability:()=>zGc,commons:()=>feh,encoding:()=>deh,environments:()=>peh,errors:()=>_eh,examples:()=>NGc,file:()=>yeh,pagination:()=>beh,products:()=>veh,serialization:()=>l9c,service:()=>FGc,source:()=>Aeh,types:()=>QGc,validation:()=>jeh,variables:()=>weh,versioning:()=>Eeh,webhooks:()=>UGc,websocket:()=>LGc});var ceh={};var zGc={};$t(zGc,{AvailabilityStatusSchema:()=>leh});var leh={InDevelopment:"in-development",PreRelease:"pre-release",Deprecated:"deprecated",GenerallyAvailable:"generally-available"};var feh={};var deh={};var peh={};var _eh={};var NGc={};$t(NGc,{SupportedSdkLanguageSchema:()=>heh});var heh={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Js:"js",Node:"node",Ts:"ts",Nodets:"nodets",Golang:"golang",Dotnet:"dotnet",Jvm:"jvm",Csharp2:"c#"};var yeh={};var beh={};var veh={};var FGc={};$t(FGc,{FormDataBodyEncodingStyle:()=>geh,HttpMethodSchema:()=>Oeh,StreamFormat:()=>meh});var geh={Json:"json",Exploded:"exploded",Form:"form"};var Oeh={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD"};var meh={Sse:"sse",Json:"json"};var Aeh={};var QGc={};$t(QGc,{ObjectPropertyAccess:()=>Peh});var Peh={ReadOnly:"read-only",WriteOnly:"write-only"};var jeh={};var weh={};var Eeh={};var UGc={};$t(UGc,{WebhookMethodSchema:()=>Seh});var Seh={Post:"POST",Get:"GET"};var LGc={};$t(LGc,{WebSocketOrigin:()=>Meh});var Meh={Client:"client",Server:"server"};var l9c={};$t(l9c,{AliasSchema:()=>Yuu,AnyAuthItem:()=>mou,AnyAuthSchemesSchema:()=>Aou,ApiAuthSchema:()=>wou,AuthSchemeDeclarationSchema:()=>Lou,AuthSchemeKey:()=>Qla,AuthSchemeReferenceSchema:()=>zla,AuthScope:()=>Fla,AuthVariable:()=>TAn,AvailabilitySchema:()=>Wou,AvailabilityStatusSchema:()=>Ula,AvailabilityUnionSchema:()=>xou,BaseTypeDeclarationSchema:()=>SDe,BaseTypeReferenceSchema:()=>Gla,BasicAuthSchemeSchema:()=>Eou,BearerAuthSchemeSchema:()=>Cou,CasingOverridesSchema:()=>nsu,CursorPaginationSchema:()=>Fuu,CustomPaginationSchema:()=>Quu,DeclarationSchema:()=>Q2t,DeclarationWithNameSchema:()=>nth,DeclarationWithoutDocsSchema:()=>Gou,DefinitionFileSchema:()=>Esu,DiscriminatedUnionSchema:()=>isu,EncodingSchema:()=>Vla,EndpointSecuritySchema:()=>jou,EndpointSecuritySchemaDetails:()=>Pou,EnumSchema:()=>usu,EnumValue:()=>osu,EnumValueSchema:()=>asu,EnvironmentSchema:()=>euu,ErrorDeclarationSchema:()=>iuu,ErrorDiscriminationSchema:()=>Dsu,ExampleBodyResponseSchema:()=>nuu,ExampleCodeSampleSchema:()=>suu,ExampleCodeSampleSchemaLanguage:()=>auu,ExampleCodeSampleSchemaSdk:()=>uuu,ExampleEndpointCallArraySchema:()=>ath,ExampleEndpointCallSchema:()=>xla,ExampleResponseSchema:()=>duu,ExampleSseEventSchema:()=>cuu,ExampleSseResponseSchema:()=>luu,ExampleStreamResponseSchema:()=>fuu,ExampleTypeReferenceSchema:()=>bN,ExampleTypeSchema:()=>Wla,ExampleTypeValueSchema:()=>ruu,ExampleWebSocketMessage:()=>_uu,ExampleWebSocketSession:()=>huu,ExampleWebhookCallSchema:()=>puu,Export:()=>Isu,ExportDetailed:()=>Bsu,FormDataBodyEncodingStyle:()=>Suu,GrpcTransport:()=>Kuu,HeaderAuthSchemeSchema:()=>qou,HttpEndpointAuth:()=>muu,HttpEndpointSchema:()=>$uu,HttpEndpointSecurity:()=>Ouu,HttpEndpointSecurityItem:()=>guu,HttpHeaderSchema:()=>wDe,HttpInlineFileRequestBodyPropertySchema:()=>Muu,HttpInlineRequestBodyPropertySchema:()=>Duu,HttpInlineRequestBodySchema:()=>Buu,HttpMethodSchema:()=>Auu,HttpPathParameterSchema:()=>U2t,HttpQueryParameterSchema:()=>Hla,HttpReferencedRequestBodySchema:()=>Iuu,HttpRequest:()=>Tuu,HttpRequestBodySchema:()=>Cuu,HttpRequestSchema:()=>quu,HttpResponseSchema:()=>Kla,HttpResponseSchemaDetailed:()=>Ruu,HttpResponseStreamSchema:()=>$la,HttpResponseStreamSchemaDetailed:()=>Nuu,HttpServiceSchema:()=>Juu,InferredAuthenticatedRequestHeader:()=>Sou,InferredBearerAuthSchema:()=>Bou,InferredGetTokenEndpointSchema:()=>Dou,InferredGetTokenEndpointSchemaObject:()=>Mou,ListValidationSchema:()=>Kou,MapValidationSchema:()=>$ou,MultipleBaseUrlsEnvironmentSchema:()=>Zou,Navigation:()=>Csu,NumberValidationSchema:()=>Jou,OAuthAccessTokenRequestPropertiesSchema:()=>Tou,OAuthAccessTokenResponsePropertiesSchema:()=>Rou,OAuthGetTokenEndpointSchema:()=>zou,OAuthRefreshTokenEndpointSchema:()=>Qou,OAuthRefreshTokenRequestPropertiesSchema:()=>Nou,OAuthRefreshTokenResponsePropertiesSchema:()=>Fou,OAuthSchemeSchema:()=>Uou,ObjectExtendsSchema:()=>EDe,ObjectPropertyAccess:()=>ssu,ObjectPropertySchema:()=>HZi,ObjectPropertyWithAccessSchema:()=>csu,ObjectSchema:()=>lsu,OffsetPaginationSchema:()=>Uuu,OpenApiSourceSchema:()=>yuu,PackageMarkerFileSchema:()=>oth,Pagination:()=>Luu,PaginationSchema:()=>Jla,ProductDeclarationHeaderObjectSchema:()=>qsu,ProductDeclarationHeaderSchema:()=>Tsu,ProductDeclarationSchema:()=>Lsu,ProductValue:()=>Usu,ProductValueDetailed:()=>Qsu,PropertyBasedErrorDiscrimination:()=>Ssu,ProtobufSourceSchema:()=>buu,ProtobufTypeSchema:()=>Xou,QueryParameterTypeReferenceDetailed:()=>Euu,ResponseError:()=>Wuu,ResponseErrorWithDocsSchema:()=>Vuu,ResponseErrorsSchema:()=>xuu,RetriesConfiguration:()=>Huu,RetriesDisabledSchema:()=>Guu,RootApiFileSchema:()=>uth,ServiceTransport:()=>Yla,SingleBaseUrlEnvironmentSchema:()=>kou,SingleUndiscriminatedUnionTypeDetailedSchema:()=>fsu,SingleUndiscriminatedUnionTypeSchema:()=>dsu,SingleUnionTypeDetailedSchema:()=>kuu,SingleUnionTypeKey:()=>Zuu,SingleUnionTypeKeySchema:()=>Xuu,SingleUnionTypeSchema:()=>esu,SourceSchema:()=>GZi,StatusCodeBasedErrorDiscrimination:()=>Msu,StreamFormat:()=>zuu,StringValidationSchema:()=>You,SupportedSdkLanguageSchema:()=>ouu,TokenBearerAuthSchema:()=>Iou,TypeDeclarationSchema:()=>_su,TypeReferenceDeclarationWithEnvOverride:()=>wuu,TypeReferenceDeclarationWithEnvOverrideSchema:()=>juu,TypeReferenceDeclarationWithName:()=>jDe,TypeReferenceDeclarationWithNameSchema:()=>sth,TypeReferenceDetailedSchema:()=>vuu,TypeReferenceSchema:()=>Z3i,UndiscriminatedUnionSchema:()=>psu,UnionDiscriminant:()=>rsu,UnionDiscriminantSchema:()=>tsu,ValidationSchema:()=>xZi,VariableDeclarationDetailed:()=>Vsu,VariableDeclarationSchema:()=>Wsu,VariableReferenceSchema:()=>Puu,VersionDeclarationHeaderObjectSchema:()=>Rsu,VersionDeclarationHeaderSchema:()=>zsu,VersionDeclarationSchema:()=>Xla,VersionValue:()=>Fsu,VersionValueDetailed:()=>Nsu,WebSocketChannelInlinedMessageSchema:()=>Osu,WebSocketChannelMessageBodySchema:()=>Asu,WebSocketChannelMessageSchema:()=>jsu,WebSocketChannelReferencedMessageSchema:()=>msu,WebSocketChannelSchema:()=>wsu,WebSocketOrigin:()=>Psu,WebhookInlinedPayloadSchema:()=>ysu,WebhookMethodSchema:()=>hsu,WebhookPayloadSchema:()=>vsu,WebhookReferencedPayloadSchema:()=>bsu,WebhookSchema:()=>gsu,WithAudiences:()=>eU,WithAuthSchema:()=>Vou,WithAvailability:()=>g5,WithDisplayName:()=>tU,WithDocsSchema:()=>uo,WithEnvironmentVariable:()=>Nla,WithEnvironmentsSchema:()=>tuu,WithHeadersSchema:()=>xsu,WithMethodName:()=>Hou,WithName:()=>xv,WithValidation:()=>Lla,auth:()=>HGc,availability:()=>KGc,commons:()=>$Gc,encoding:()=>JGc,environments:()=>YGc,errors:()=>XGc,examples:()=>ZGc,file:()=>kGc,pagination:()=>e9c,products:()=>t9c,service:()=>r9c,source:()=>i9c,types:()=>n9c,validation:()=>a9c,variables:()=>o9c,versioning:()=>u9c,webhooks:()=>s9c,websocket:()=>c9c});var HGc={};$t(HGc,{AnyAuthItem:()=>mou,AnyAuthSchemesSchema:()=>Aou,ApiAuthSchema:()=>wou,AuthSchemeDeclarationSchema:()=>Lou,AuthSchemeKey:()=>Qla,AuthSchemeReferenceSchema:()=>zla,AuthScope:()=>Fla,AuthVariable:()=>TAn,BasicAuthSchemeSchema:()=>Eou,BearerAuthSchemeSchema:()=>Cou,EndpointSecuritySchema:()=>jou,EndpointSecuritySchemaDetails:()=>Pou,HeaderAuthSchemeSchema:()=>qou,InferredAuthenticatedRequestHeader:()=>Sou,InferredBearerAuthSchema:()=>Bou,InferredGetTokenEndpointSchema:()=>Dou,InferredGetTokenEndpointSchemaObject:()=>Mou,OAuthAccessTokenRequestPropertiesSchema:()=>Tou,OAuthAccessTokenResponsePropertiesSchema:()=>Rou,OAuthGetTokenEndpointSchema:()=>zou,OAuthRefreshTokenEndpointSchema:()=>Qou,OAuthRefreshTokenRequestPropertiesSchema:()=>Nou,OAuthRefreshTokenResponsePropertiesSchema:()=>Fou,OAuthSchemeSchema:()=>Uou,TokenBearerAuthSchema:()=>Iou,WithAuthSchema:()=>Vou,WithEnvironmentVariable:()=>Nla});var Deh=(e,t,r)=>JSON.stringify(e,t,r);var ne={};$t(ne,{JsonError:()=>qla,ParseError:()=>Tla,any:()=>xeh,bigint:()=>Ieh,boolean:()=>Geh,booleanLiteral:()=>Veh,date:()=>Ceh,discriminant:()=>tth,enum_:()=>vou,getObjectLikeUtils:()=>w5t,getObjectUtils:()=>qAn,getSchemaUtils:()=>OP,isProperty:()=>WZi,lazy:()=>qeh,lazyObject:()=>Ueh,list:()=>Oou,never:()=>Heh,number:()=>Keh,object:()=>gou,objectWithoutOptionalProperties:()=>Qeh,optional:()=>VGc,property:()=>Reh,record:()=>Xeh,set:()=>Zeh,string:()=>$eh,stringLiteral:()=>Weh,transform:()=>WGc,undiscriminatedUnion:()=>eth,union:()=>ith,unknown:()=>Jeh,withParsedProperties:()=>GGc});var ap={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function NA(e,t){return`Expected ${t}. Received ${JzD(e)}.`}function JzD(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function ZQ(e){return{...e,json:Beh(e.json),parse:Beh(e.parse)}}function Beh(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1434
1434
|
`)),{ok:!0,value:t}):i}}function bou(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var qla=class e extends Error{errors;constructor(t){super(t.map(bou).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var Tla=class e extends Error{errors;constructor(t){super(t.map(bou).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function OP(e){return{nullable:()=>YzD(e),optional:()=>VGc(e),optionalNullable:()=>XzD(e),transform:t=>WGc(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new Tla(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new qla(i.errors)}}}function YzD(e){let t={parse:(r,i)=>r==null?{ok:!0,value:null}:e.parse(r,i),json:(r,i)=>r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>ap.NULLABLE};return{...t,...OP(t)}}function VGc(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>ap.OPTIONAL};return{...t,...OP(t)}}function XzD(e){let t={parse:(r,i)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.parse(r,i),json:(r,i)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.json(r,i),getType:()=>ap.OPTIONAL_NULLABLE};return{...t,...OP(t)}}function WGc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...OP(r)}}function Ieh(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t}:typeof t=="number"?{ok:!0,value:BigInt(t)}:{ok:!1,errors:[{path:r,message:NA(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="bigint"?{ok:!1,errors:[{path:r,message:NA(t,"bigint")}]}:{ok:!0,value:t},getType:()=>ap.BIGINT};return{...ZQ(e),...OP(e)}}var ZzD=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function Ceh(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:NA(t,"string")}]}:ZzD.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:NA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:NA(t,"Date object")}]},getType:()=>ap.DATE};return{...ZQ(e),...OP(e)}}function kQ(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...ZQ(r),...OP(r)}}}function vou(e){let t=new Set(e);return kQ(ap.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:NA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:NA(i,"enum")}]}:{ok:!0,value:i})()}function qeh(e){let t=xGc(e);return{...t,...OP(t)}}function xGc(e){return{parse:(t,r)=>Rla(e).parse(t,r),json:(t,r)=>Rla(e).json(t,r),getType:()=>Rla(e).getType()}}function Rla(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function Bka(e){return Object.entries(e)}function Ika(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function X3i(e){if(typeof e!="object"||e===null)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Cka(e){return Object.keys(e)}function Teh(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function w5t(e){return{withParsedProperties:t=>GGc(e,t)}}function GGc(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[d,s])=>({...c,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(i,n)=>{if(!X3i(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:NA(i,"object")}]};let a=new Set(Object.keys(t)),o=Ika(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...OP(r),...w5t(r)}}function Reh(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function WZi(e){return e.isProperty}function gou(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>WZi(i)?i.rawKey:r),_getParsedProperties:()=>Cka(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of Bka(e)){let d=WZi(c)?c.rawKey:o,s=WZi(c)?c.valueSchema:c,u={rawKey:d,parsedKey:o,valueSchema:s};n[d]=u,Feh(s)&&a.push(d)}return zeh({value:r,requiredKeys:a,getProperty:o=>{let c=n[o];if(c!=null)return{transformedKey:c.parsedKey,transform:d=>c.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,o]of Bka(e)){let c=WZi(o)?o.valueSchema:o;Feh(c)&&n.push(a)}return zeh({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return WZi(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>ap.OBJECT};return{...ZQ(t),...OP(t),...w5t(t),...qAn(t)}}function zeh({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!X3i(e))return{ok:!1,errors:[{path:a,message:NA(e,"object")}]};let o=new Set(t),c=[],d={};for(let[s,u]of Object.entries(e)){let f=r(s);if(f!=null){o.delete(s);let p=f.transform(u);p.ok?d[f.transformedKey]=p.value:(d[s]=u,c.push(...p.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:d}:{ok:!1,errors:c}}function qAn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>Neh({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>Neh({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>ap.OBJECT};return{...r,...OP(r),...w5t(r),...qAn(r)}},passthrough:()=>{let t=new Set(e._getRawProperties()),r=new Set(e._getParsedProperties()),i={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(n,a)=>{let o=e.parse(n,{...a,unrecognizedObjectKeys:"passthrough"});if(!o.ok)return o;let c={};if(typeof n=="object"&&n!=null)for(let[d,s]of Object.entries(n))t.has(d)||(c[d]=s);return{ok:!0,value:{...c,...o.value}}},json:(n,a)=>{let o=e.json(n,{...a,unrecognizedObjectKeys:"passthrough"});if(!o.ok)return o;let c={};if(typeof n=="object"&&n!=null)for(let[d,s]of Object.entries(n))r.has(d)||(c[d]=s);return{ok:!0,value:{...c,...o.value}}},getType:()=>ap.OBJECT};return{...i,...OP(i),...w5t(i),...qAn(i)}}}}function Neh({extensionKeys:e,value:t,transformBase:r,transformExtension:i,breadcrumbsPrefix:n=[]}){if(!X3i(t))return{ok:!1,errors:[{path:n,message:NA(t,"object")}]};let a=new Set(e),[o,c]=Teh(Cka(t),u=>a.has(u)),d=r(Ika(t,c)),s=i(Ika(t,o));return d.ok&&s.ok?{ok:!0,value:{...d.value,...s.value}}:{ok:!1,errors:[...d.ok?[]:d.errors,...s.ok?[]:s.errors]}}function Feh(e){return!kzD(e)}function kzD(e){switch(e.getType()){case ap.ANY:case ap.UNKNOWN:case ap.OPTIONAL:case ap.OPTIONAL_NULLABLE:return!0;default:return!1}}function Qeh(e){return gou(e)}function Ueh(e){let t={...xGc(e),_getRawProperties:()=>Rla(e)._getRawProperties(),_getParsedProperties:()=>Rla(e)._getParsedProperties()};return{...t,...OP(t),...w5t(t),...qAn(t)}}function Oou(e){let t={parse:(r,i)=>Leh(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Leh(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>ap.LIST};return{...ZQ(t),...OP(t)}}function Leh(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:NA(e,"list"),path:[]}]}}function Veh(e){return kQ(ap.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:NA(r,`${e.toString()}`)}]})()}function Weh(e){return kQ(ap.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:NA(r,`"${e}"`)}]})()}var xeh=kQ(ap.ANY,e=>({ok:!0,value:e}));var Geh=kQ(ap.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:NA(e,"boolean")}]});var Heh=kQ(ap.NEVER,(e,{breadcrumbsPrefix:t=[]}={})=>({ok:!1,errors:[{path:t,message:"Expected never"}]}));var Keh=kQ(ap.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:NA(e,"number")}]});var $eh=kQ(ap.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:NA(e,"string")}]});var Jeh=kQ(ap.UNKNOWN,e=>({ok:!0,value:e}));function Xeh(e,t){let r={parse:(i,n)=>Yeh({value:i,isKeyNumeric:e.getType()===ap.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>Yeh({value:i,isKeyNumeric:e.getType()===ap.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>ap.RECORD};return{...ZQ(r),...OP(r)}}function Yeh({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return X3i(e)?Bka(e).reduce((a,[o,c])=>{if(c===void 0)return a;let d=a,s=o;if(t){let _=o.length>0?Number(o):NaN;Number.isNaN(_)||(s=_)}let u=r(s),f=i(c,s);if(d.ok&&u.ok&&f.ok)return{ok:!0,value:{...d.value,[u.value]:f.value}};let p=[];return d.ok||p.push(...d.errors),u.ok||p.push(...u.errors),f.ok||p.push(...f.errors),{ok:!1,errors:p}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:NA(e,"object")}]}}function Zeh(e){let t=Oou(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:NA(i,"Set")}]},getType:()=>ap.SET};return{...ZQ(r),...OP(r)}}function eth(e){let t={parse:(r,i)=>keh((n,a)=>n.parse(r,a),e,i),json:(r,i)=>keh((n,a)=>n.json(r,a),e,i),getType:()=>ap.UNDISCRIMINATED_UNION};return{...ZQ(t),...OP(t)}}function keh(e,t,r){let i=[];for(let[n,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function tth(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function ith(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=vou(Cka(t)),a={parse:(o,c)=>rth({value:o,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>rth({value:o,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>ap.UNION};return{...ZQ(a),...OP(a),...w5t(a)}}function rth({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!X3i(e))return{ok:!1,errors:[{path:c,message:NA(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=i(d);if(!u.ok)return{ok:!1,errors:u.errors};let f=n(u.value);if(f==null)return a?{ok:!0,value:{[r]:u.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let p=o(s,f);return p.ok?{ok:!0,value:{[r]:d,...p.value}}:p}var uo=ne.object({docs:ne.string().optional()});var zla=ne.object({scheme:ne.string()}).extend(uo);var mou=ne.undiscriminatedUnion([ne.string(),zla]);var Aou=ne.object({any:ne.list(mou)}).extend(uo);var Pou=ne.object({});var jou=ne.object({"endpoint-security":Pou}).extend(uo);var wou=ne.undiscriminatedUnion([ne.string(),zla,Aou,jou]);var xv=ne.object({name:ne.string().optional()});var Nla=ne.object({env:ne.string().optional()});var TAn=ne.object({omit:ne.boolean().optional()}).extend(Nla).extend(xv);var Eou=ne.object({scheme:ne.stringLiteral("basic"),username:TAn.optional(),password:TAn.optional()}).extend(uo);var Sou=ne.object({"response-property":ne.string(),"header-name":ne.string(),"value-prefix":ne.string().optional()});var Mou=ne.object({endpoint:ne.string(),"expiry-response-property":ne.string().optional(),"authenticated-request-headers":ne.list(Sou).optional()});var Dou=ne.undiscriminatedUnion([ne.string(),Mou]);var Bou=ne.object({scheme:ne.stringLiteral("bearer"),"get-token":Dou}).extend(uo);var Iou=ne.object({scheme:ne.stringLiteral("bearer"),token:TAn.optional()}).extend(uo);var Cou=ne.undiscriminatedUnion([Iou,Bou]);var qou=ne.object({header:ne.string(),type:ne.string().optional(),prefix:ne.string().optional()}).extend(Nla).extend(xv).extend(uo);var Fla=ne.string();var Tou=ne.object({"client-id":ne.string().optional(),"client-secret":ne.string().optional(),scopes:ne.string().optional()});var Rou=ne.object({"access-token":ne.string().optional(),"expires-in":ne.string().optional(),"refresh-token":ne.string().optional()});var zou=ne.object({endpoint:ne.string(),"request-properties":Tou.optional(),"response-properties":Rou.optional()});var Nou=ne.object({"refresh-token":ne.string()});var Fou=ne.object({"access-token":ne.string().optional(),"expires-in":ne.string().optional(),"refresh-token":ne.string().optional()});var Qou=ne.object({endpoint:ne.string(),"request-properties":Nou.optional(),"response-properties":Fou.optional()});var Uou=ne.object({scheme:ne.stringLiteral("oauth"),type:ne.stringLiteral("client-credentials"),scopes:ne.list(Fla).optional(),"client-id-env":ne.string().optional(),"client-secret-env":ne.string().optional(),"token-prefix":ne.string().optional(),"token-header":ne.string().optional(),"get-token":zou,"refresh-token":Qou.optional()}).extend(uo);var Lou=ne.undiscriminatedUnion([Uou,qou,Eou,Cou]);var Qla=ne.string();var Vou=ne.object({auth:wou.optional(),"auth-schemes":ne.record(Qla,Lou).optional()});var KGc={};$t(KGc,{AvailabilitySchema:()=>Wou,AvailabilityStatusSchema:()=>Ula,AvailabilityUnionSchema:()=>xou});var Ula=ne.enum_(["in-development","pre-release","deprecated","generally-available"]);var Wou=ne.object({status:Ula,message:ne.string().optional()});var xou=ne.undiscriminatedUnion([Ula,Wou]);var $Gc={};$t($Gc,{DeclarationSchema:()=>Q2t,DeclarationWithNameSchema:()=>nth,DeclarationWithoutDocsSchema:()=>Gou,WithAudiences:()=>eU,WithAvailability:()=>g5,WithDisplayName:()=>tU,WithDocsSchema:()=>uo,WithMethodName:()=>Hou,WithName:()=>xv,WithValidation:()=>Lla});var eU=ne.object({audiences:ne.list(ne.string()).optional()});var g5=ne.object({availability:xou.optional()});var Q2t=ne.object({}).extend(uo).extend(g5).extend(eU);var nth=ne.object({}).extend(Q2t).extend(xv);var Gou=ne.object({}).extend(g5).extend(eU);var tU=ne.object({"display-name":ne.string().optional()});var Hou=ne.object({"method-name":ne.string().optional()});var Kou=ne.object({minItems:ne.number().optional(),maxItems:ne.number().optional()});var $ou=ne.object({minProperties:ne.number().optional(),maxProperties:ne.number().optional()});var Jou=ne.object({min:ne.number().optional(),max:ne.number().optional(),exclusiveMin:ne.boolean().optional(),exclusiveMax:ne.boolean().optional(),multipleOf:ne.number().optional()});var You=ne.object({minLength:ne.number().optional(),maxLength:ne.number().optional(),pattern:ne.string().optional(),format:ne.string().optional()});var xZi=ne.undiscriminatedUnion([You,Jou,Kou,$ou]);var Lla=ne.object({validation:xZi.optional()});var JGc={};$t(JGc,{EncodingSchema:()=>Vla,ProtobufTypeSchema:()=>Xou});var Xou=ne.object({type:ne.string()});var Vla=ne.object({proto:Xou.optional()});var YGc={};$t(YGc,{EnvironmentSchema:()=>euu,MultipleBaseUrlsEnvironmentSchema:()=>Zou,SingleBaseUrlEnvironmentSchema:()=>kou,WithEnvironmentsSchema:()=>tuu});var Zou=ne.object({urls:ne.record(ne.string(),ne.string())}).extend(eU).extend(uo);var kou=ne.object({url:ne.string()}).extend(eU).extend(uo);var euu=ne.undiscriminatedUnion([ne.string(),kou,Zou]);var tuu=ne.object({"default-url":ne.string().optional(),"default-environment":ne.string().optional(),environments:ne.record(ne.string(),euu).optional()});var XGc={};$t(XGc,{ErrorDeclarationSchema:()=>iuu});var ruu=ne.unknown();var Wla=ne.object({value:ruu}).extend(xv).extend(uo);var iuu=ne.object({"status-code":ne.number(),type:ne.string().optional(),examples:ne.list(Wla).optional()}).extend(uo);var ZGc={};$t(ZGc,{ExampleBodyResponseSchema:()=>nuu,ExampleCodeSampleSchema:()=>suu,ExampleCodeSampleSchemaLanguage:()=>auu,ExampleCodeSampleSchemaSdk:()=>uuu,ExampleEndpointCallArraySchema:()=>ath,ExampleEndpointCallSchema:()=>xla,ExampleResponseSchema:()=>duu,ExampleSseEventSchema:()=>cuu,ExampleSseResponseSchema:()=>luu,ExampleStreamResponseSchema:()=>fuu,ExampleTypeReferenceSchema:()=>bN,ExampleTypeSchema:()=>Wla,ExampleTypeValueSchema:()=>ruu,ExampleWebSocketMessage:()=>_uu,ExampleWebSocketSession:()=>huu,ExampleWebhookCallSchema:()=>puu,SupportedSdkLanguageSchema:()=>ouu});var bN=ne.unknown();var nuu=ne.object({error:ne.string().optional(),body:bN.optional()});var auu=ne.object({language:ne.string(),code:ne.string(),install:ne.string().optional()}).extend(uo).extend(xv);var ouu=ne.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","js","node","ts","nodets","golang","dotnet","jvm","c#"]);var uuu=ne.object({sdk:ouu,code:ne.string()}).extend(uo).extend(xv);var suu=ne.undiscriminatedUnion([uuu,auu]);var cuu=ne.object({event:ne.string(),data:bN.optional()});var luu=ne.object({stream:ne.list(cuu)});var fuu=ne.object({stream:ne.list(bN)});var duu=ne.undiscriminatedUnion([nuu,fuu,luu]);var xla=ne.object({id:ne.string().optional(),"path-parameters":ne.record(ne.string(),bN).optional(),"query-parameters":ne.record(ne.string(),bN).optional(),headers:ne.record(ne.string(),bN).optional(),request:bN.optional(),response:duu.optional(),"code-samples":ne.list(suu).optional()}).extend(xv).extend(uo);var ath=ne.list(xla);var puu=ne.object({id:ne.string().optional(),payload:bN}).extend(xv).extend(uo);var _uu=ne.object({type:ne.string(),body:ne.unknown()});var huu=ne.object({"path-parameters":ne.record(ne.string(),bN).optional(),"query-parameters":ne.record(ne.string(),bN).optional(),headers:ne.record(ne.string(),bN).optional(),messages:ne.list(_uu)}).extend(xv).extend(uo);var kGc={};$t(kGc,{DefinitionFileSchema:()=>Esu,ErrorDiscriminationSchema:()=>Dsu,Export:()=>Isu,ExportDetailed:()=>Bsu,Navigation:()=>Csu,PackageMarkerFileSchema:()=>oth,PropertyBasedErrorDiscrimination:()=>Ssu,RootApiFileSchema:()=>uth,StatusCodeBasedErrorDiscrimination:()=>Msu,WithHeadersSchema:()=>xsu});var yuu=ne.object({openapi:ne.string()});var buu=ne.object({proto:ne.string()});var GZi=ne.undiscriminatedUnion([yuu,buu]);var Gla=ne.object({default:ne.unknown().optional(),encoding:Vla.optional(),validation:xZi.optional()}).extend(uo).extend(g5);var vuu=ne.object({type:ne.string()}).extend(Gla).extend(xv).extend(eU);var Z3i=ne.undiscriminatedUnion([ne.string(),vuu]);var guu=ne.record(Qla,ne.list(Fla));var Ouu=ne.list(guu);var muu=ne.undiscriminatedUnion([ne.boolean(),Ouu]);var Auu=ne.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD"]);var Puu=ne.object({variable:ne.string()}).extend(g5).extend(uo);var U2t=ne.undiscriminatedUnion([Z3i,Puu]);var jDe=ne.object({type:ne.string()}).extend(Gla).extend(xv).extend(eU);var juu=ne.object({env:ne.string().optional()}).extend(jDe);var wuu=ne.undiscriminatedUnion([ne.string(),juu]);var wDe=wuu;var Euu=ne.object({"allow-multiple":ne.boolean().optional()}).extend(jDe);var Hla=ne.undiscriminatedUnion([ne.string(),Euu]);var EDe=ne.undiscriminatedUnion([ne.string(),ne.list(ne.string())]);var Suu=ne.enum_(["json","exploded","form"]);var Muu=ne.object({style:Suu.optional(),"content-type":ne.string().optional()}).extend(jDe);var Duu=ne.undiscriminatedUnion([ne.string(),Muu]);var Buu=ne.object({extends:EDe.optional(),"extra-properties":ne.boolean().optional(),properties:ne.record(ne.string(),Duu).optional()});var Iuu=ne.object({type:ne.string()}).extend(uo);var Cuu=ne.undiscriminatedUnion([ne.string(),Iuu,Buu]);var quu=ne.object({"content-type":ne.string().optional(),"path-parameters":ne.record(ne.string(),U2t).optional(),"query-parameters":ne.record(ne.string(),Hla).optional(),headers:ne.record(ne.string(),wDe).optional(),body:Cuu.optional()}).extend(xv).extend(uo);var Tuu=ne.undiscriminatedUnion([ne.string(),quu]);var Ruu=ne.object({type:ne.string().optional(),property:ne.string().optional(),"status-code":ne.number().optional()}).extend(uo);var Kla=ne.undiscriminatedUnion([ne.string(),Ruu]);var zuu=ne.enum_(["sse","json"]);var Nuu=ne.object({type:ne.string(),format:zuu.optional(),terminator:ne.string().optional()}).extend(uo);var $la=ne.undiscriminatedUnion([ne.string(),Nuu]);var Fuu=ne.object({cursor:ne.string(),next_cursor:ne.string(),results:ne.string()});var Quu=ne.object({type:ne.stringLiteral("custom"),results:ne.string()});var Uuu=ne.object({offset:ne.string(),results:ne.string(),step:ne.string().optional(),"has-next-page":ne.string().optional()});var Jla=ne.undiscriminatedUnion([Fuu,Uuu,Quu]);var Luu=ne.undiscriminatedUnion([Jla,ne.boolean()]);var Vuu=ne.object({error:ne.string()}).extend(uo);var Wuu=ne.undiscriminatedUnion([ne.string(),Vuu]);var xuu=ne.list(Wuu);var Guu=ne.object({disabled:ne.boolean().optional()});var Huu=ne.undiscriminatedUnion([Guu]);var Kuu=ne.object({"service-name":ne.string()});var Yla=ne.object({grpc:Kuu.optional()});var $uu=ne.object({method:Auu.optional(),"base-path":ne.string().optional(),path:ne.string(),url:ne.string().optional(),"path-parameters":ne.record(ne.string(),U2t).optional(),auth:muu.optional(),idempotent:ne.boolean().optional(),"stream-condition":ne.string().optional(),request:Tuu.optional(),response:Kla.optional(),"response-stream":$la.optional(),errors:xuu.optional(),examples:ne.list(xla).optional(),pagination:Luu.optional(),transport:Yla.optional(),source:GZi.optional(),retries:Huu.optional()}).extend(tU).extend(Q2t);var Juu=ne.object({auth:ne.boolean(),url:ne.string().optional(),"base-path":ne.string(),"path-parameters":ne.record(ne.string(),Z3i).optional(),idempotent:ne.boolean().optional(),headers:ne.record(ne.string(),Z3i).optional(),transport:Yla.optional(),source:GZi.optional(),endpoints:ne.record(ne.string(),$uu)}).extend(Gou).extend(tU);var SDe=ne.object({examples:ne.list(Wla).optional(),encoding:Vla.optional(),source:GZi.optional(),inline:ne.boolean().optional()}).extend(uo).extend(g5).extend(eU);var Yuu=ne.object({type:ne.string(),validation:xZi.optional()}).extend(SDe);var Xuu=ne.object({value:ne.string()}).extend(xv);var Zuu=ne.undiscriminatedUnion([ne.string(),Xuu]);var kuu=ne.object({type:ne.string().optional(),key:Zuu.optional()}).extend(uo).extend(xv).extend(g5).extend(tU).extend(Lla);var esu=ne.undiscriminatedUnion([ne.string(),kuu]);var tsu=ne.object({value:ne.string()}).extend(xv);var rsu=ne.undiscriminatedUnion([ne.string(),tsu]);var isu=ne.object({discriminant:rsu.optional(),extends:EDe.optional(),"base-properties":ne.record(ne.string(),Z3i).optional(),union:ne.record(ne.string(),esu)}).extend(SDe);var nsu=ne.object({camel:ne.string().optional(),snake:ne.string().optional(),pascal:ne.string().optional(),"screaming-snake":ne.string().optional()});var asu=ne.object({value:ne.string(),casing:nsu.optional()}).extend(uo).extend(xv);var osu=ne.undiscriminatedUnion([ne.string(),asu]);var usu=ne.object({default:ne.string().optional(),enum:ne.list(osu)}).extend(SDe);var ssu=ne.enum_(["read-only","write-only"]);var csu=ne.object({access:ssu.optional()}).extend(jDe);var HZi=ne.undiscriminatedUnion([ne.string(),csu]);var lsu=ne.object({extends:EDe.optional(),properties:ne.record(ne.string(),HZi).optional(),"extra-properties":ne.boolean().optional()}).extend(SDe);var fsu=ne.object({type:ne.string()}).extend(uo).extend(tU).extend(Lla);var dsu=ne.undiscriminatedUnion([ne.string(),fsu]);var psu=ne.object({discriminated:ne.booleanLiteral(!1),union:ne.list(dsu)}).extend(SDe);var _su=ne.undiscriminatedUnion([ne.string(),lsu,usu,isu,psu,Yuu]);var hsu=ne.enum_(["POST","GET"]);var ysu=ne.object({name:ne.string(),extends:EDe.optional(),properties:ne.record(ne.string(),HZi).optional()});var bsu=ne.object({type:ne.string()}).extend(uo);var vsu=ne.undiscriminatedUnion([ne.string(),bsu,ysu]);var gsu=ne.object({method:hsu,headers:ne.record(ne.string(),wDe).optional(),payload:vsu,response:Kla.optional(),"response-stream":$la.optional(),examples:ne.list(puu).optional()}).extend(g5).extend(eU).extend(uo).extend(tU);var Osu=ne.object({name:ne.string(),extends:EDe.optional(),properties:ne.record(ne.string(),HZi).optional()});var msu=ne.object({type:ne.string()}).extend(uo);var Asu=ne.undiscriminatedUnion([ne.string(),msu,Osu]);var Psu=ne.enum_(["client","server"]);var jsu=ne.object({origin:Psu,body:Asu}).extend(Q2t).extend(tU).extend(Hou);var wsu=ne.object({auth:ne.boolean(),url:ne.string().optional(),path:ne.string(),headers:ne.record(ne.string(),wDe).optional(),"path-parameters":ne.record(ne.string(),U2t).optional(),"query-parameters":ne.record(ne.string(),Hla).optional(),messages:ne.record(ne.string(),jsu).optional(),examples:ne.list(huu).optional()}).extend(Q2t).extend(tU);var Esu=ne.object({imports:ne.record(ne.string(),ne.string()).optional(),types:ne.record(ne.string(),_su).optional(),service:Juu.optional(),errors:ne.record(ne.string(),iuu).optional(),webhooks:ne.record(ne.string(),gsu).optional(),channel:wsu.optional()}).extend(uo);var Ssu=ne.object({strategy:ne.stringLiteral("property"),"property-name":ne.string()});var Msu=ne.object({strategy:ne.stringLiteral("status-code")});var Dsu=ne.undiscriminatedUnion([Ssu,Msu]);var Bsu=ne.object({dependency:ne.string(),url:ne.string().optional()});var Isu=ne.undiscriminatedUnion([ne.string(),Bsu]);var Csu=ne.undiscriminatedUnion([ne.string(),ne.list(ne.string())]);var oth=ne.object({navigation:Csu.optional(),export:Isu.optional()}).extend(Esu);var qsu=ne.object({name:ne.string().optional(),env:ne.string().optional(),value:ne.string()});var Tsu=ne.undiscriminatedUnion([ne.string(),qsu]);var Rsu=ne.object({name:ne.string().optional(),env:ne.string().optional(),value:ne.string()});var zsu=ne.undiscriminatedUnion([ne.string(),Rsu]);var Nsu=ne.object({value:ne.string()}).extend(uo).extend(xv);var Fsu=ne.undiscriminatedUnion([ne.string(),Nsu]);var Xla=ne.object({default:ne.string().optional(),values:ne.list(Fsu),header:zsu});var Qsu=ne.object({value:ne.string(),versions:Xla.optional()}).extend(uo).extend(xv);var Usu=ne.undiscriminatedUnion([ne.string(),Qsu]);var Lsu=ne.object({default:ne.string().optional(),values:ne.list(Usu),header:Tsu});var Vsu=ne.object({type:ne.string()}).extend(uo);var Wsu=ne.undiscriminatedUnion([ne.string(),Vsu]);var xsu=ne.object({headers:ne.record(ne.string(),wDe).optional()});var uth=ne.object({name:ne.string(),imports:ne.record(ne.string(),ne.string()).optional(),"error-discrimination":Dsu.optional(),audiences:ne.list(ne.string()).optional(),errors:ne.list(ne.string()).optional(),"base-path":ne.string().optional(),"path-parameters":ne.record(ne.string(),U2t).optional(),"idempotency-headers":ne.record(ne.string(),wDe).optional(),variables:ne.record(ne.string(),Wsu).optional(),pagination:Jla.optional(),product:Lsu.optional(),version:Xla.optional()}).extend(uo).extend(tU).extend(tuu).extend(Vou).extend(xsu);var e9c={};$t(e9c,{CursorPaginationSchema:()=>Fuu,CustomPaginationSchema:()=>Quu,OffsetPaginationSchema:()=>Uuu,PaginationSchema:()=>Jla});var t9c={};$t(t9c,{ProductDeclarationHeaderObjectSchema:()=>qsu,ProductDeclarationHeaderSchema:()=>Tsu,ProductDeclarationSchema:()=>Lsu,ProductValue:()=>Usu,ProductValueDetailed:()=>Qsu});var r9c={};$t(r9c,{FormDataBodyEncodingStyle:()=>Suu,GrpcTransport:()=>Kuu,HttpEndpointAuth:()=>muu,HttpEndpointSchema:()=>$uu,HttpEndpointSecurity:()=>Ouu,HttpEndpointSecurityItem:()=>guu,HttpHeaderSchema:()=>wDe,HttpInlineFileRequestBodyPropertySchema:()=>Muu,HttpInlineRequestBodyPropertySchema:()=>Duu,HttpInlineRequestBodySchema:()=>Buu,HttpMethodSchema:()=>Auu,HttpPathParameterSchema:()=>U2t,HttpQueryParameterSchema:()=>Hla,HttpReferencedRequestBodySchema:()=>Iuu,HttpRequest:()=>Tuu,HttpRequestBodySchema:()=>Cuu,HttpRequestSchema:()=>quu,HttpResponseSchema:()=>Kla,HttpResponseSchemaDetailed:()=>Ruu,HttpResponseStreamSchema:()=>$la,HttpResponseStreamSchemaDetailed:()=>Nuu,HttpServiceSchema:()=>Juu,Pagination:()=>Luu,QueryParameterTypeReferenceDetailed:()=>Euu,ResponseError:()=>Wuu,ResponseErrorWithDocsSchema:()=>Vuu,ResponseErrorsSchema:()=>xuu,RetriesConfiguration:()=>Huu,RetriesDisabledSchema:()=>Guu,ServiceTransport:()=>Yla,StreamFormat:()=>zuu,TypeReferenceDeclarationWithEnvOverride:()=>wuu,TypeReferenceDeclarationWithEnvOverrideSchema:()=>juu});var i9c={};$t(i9c,{OpenApiSourceSchema:()=>yuu,ProtobufSourceSchema:()=>buu,SourceSchema:()=>GZi});var n9c={};$t(n9c,{AliasSchema:()=>Yuu,BaseTypeDeclarationSchema:()=>SDe,BaseTypeReferenceSchema:()=>Gla,CasingOverridesSchema:()=>nsu,DiscriminatedUnionSchema:()=>isu,EnumSchema:()=>usu,EnumValue:()=>osu,EnumValueSchema:()=>asu,ObjectExtendsSchema:()=>EDe,ObjectPropertyAccess:()=>ssu,ObjectPropertySchema:()=>HZi,ObjectPropertyWithAccessSchema:()=>csu,ObjectSchema:()=>lsu,SingleUndiscriminatedUnionTypeDetailedSchema:()=>fsu,SingleUndiscriminatedUnionTypeSchema:()=>dsu,SingleUnionTypeDetailedSchema:()=>kuu,SingleUnionTypeKey:()=>Zuu,SingleUnionTypeKeySchema:()=>Xuu,SingleUnionTypeSchema:()=>esu,TypeDeclarationSchema:()=>_su,TypeReferenceDeclarationWithName:()=>jDe,TypeReferenceDeclarationWithNameSchema:()=>sth,TypeReferenceDetailedSchema:()=>vuu,TypeReferenceSchema:()=>Z3i,UndiscriminatedUnionSchema:()=>psu,UnionDiscriminant:()=>rsu,UnionDiscriminantSchema:()=>tsu});var sth=ne.undiscriminatedUnion([ne.string(),jDe]);var a9c={};$t(a9c,{ListValidationSchema:()=>Kou,MapValidationSchema:()=>$ou,NumberValidationSchema:()=>Jou,StringValidationSchema:()=>You,ValidationSchema:()=>xZi});var o9c={};$t(o9c,{VariableDeclarationDetailed:()=>Vsu,VariableDeclarationSchema:()=>Wsu,VariableReferenceSchema:()=>Puu});var u9c={};$t(u9c,{VersionDeclarationHeaderObjectSchema:()=>Rsu,VersionDeclarationHeaderSchema:()=>zsu,VersionDeclarationSchema:()=>Xla,VersionValue:()=>Fsu,VersionValueDetailed:()=>Nsu});var s9c={};$t(s9c,{WebhookInlinedPayloadSchema:()=>ysu,WebhookMethodSchema:()=>hsu,WebhookPayloadSchema:()=>vsu,WebhookReferencedPayloadSchema:()=>bsu,WebhookSchema:()=>gsu});var c9c={};$t(c9c,{WebSocketChannelInlinedMessageSchema:()=>Osu,WebSocketChannelMessageBodySchema:()=>Asu,WebSocketChannelMessageSchema:()=>jsu,WebSocketChannelReferencedMessageSchema:()=>msu,WebSocketChannelSchema:()=>wsu,WebSocketOrigin:()=>Psu});var qka=class extends Error{statusCode;body;rawResponse;constructor({message:t,statusCode:r,body:i,rawResponse:n}){super(eND({message:t,statusCode:r,body:i})),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.statusCode=r,this.body=i,this.rawResponse=n}};function eND({message:e,statusCode:t,body:r}){let i=[];return e!=null&&i.push(e),t!=null&&i.push(`Status code: ${t.toString()}`),r!=null&&i.push(`Body: ${Deh(r,void 0,2)}`),i.join(`
|
|
1435
|
-
`)}var Tka=class extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};function f9c(e){return e.scheme==="oauth"}var tND={optional:"optional",nullable:"nullable",set:"set",list:"list",map:"map",literal:"literal"},cth=new Set(Object.values(tND));function HB(e){let t=e.match(/([\w.]+)<([\w,\s]+)>/);if(t?.[0]!=null&&t[1]!=null&&t[2]!=null&&!cth.has(t[1].trim()))return{name:t[1].trim(),arguments:t[2].split(",").map(r=>r.trim())}}function MDe(e){return HB(e)!=null}function d9c(e){if(e.request!=null)return typeof e.request=="string"?e.request:e.request.body}var k3i=class{REFERENCE_REGEX=/^(?:(\w+)::)?(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/;validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let i=t.match(this.REFERENCE_REGEX);if(!(i==null||i[2]==null||i[3]==null))return{namespace:i[1],method:i[2],path:i[3]}}};function AE(e){return typeof e=="string"?!1:e?.extends!=null||e?.properties!=null}function L2t(e){return e?e.proto!=null:!1}var rND="text";function KZi(e){return e===rND}var Br={};$t(Br,{ApiDefinitionSource:()=>MZ,ApiVersionScheme:()=>XZi,AuthScheme:()=>mP,AuthSchemesRequirement:()=>vN,AvailabilityStatus:()=>nR,ContainerType:()=>Js,Environments:()=>xD,ErrorDeclarationDiscriminantValue:()=>YZi,ErrorDiscriminationStrategy:()=>Rme,ExampleCodeSample:()=>qme,ExampleContainer:()=>S_,ExampleEndpointSuccessResponse:()=>PE,ExamplePrimitive:()=>Xn,ExampleQueryParameterShape:()=>gN,ExampleRequestBody:()=>O5,ExampleResponse:()=>Zw,ExampleSingleUnionTypeProperties:()=>Qq,ExampleStyle:()=>$su,ExampleTypeReferenceShape:()=>as,ExampleTypeShape:()=>ib,ExampleWebSocketMessageBody:()=>zme,FileProperty:()=>EZ,FileUploadBodyPropertyEncoding:()=>Rka,FileUploadRequestProperty:()=>oR,HttpEndpointSource:()=>m5,HttpMethod:()=>jE,HttpRequestBody:()=>FA,HttpResponseBody:()=>op,JsonResponse:()=>Nq,Literal:()=>rU,NamedTypeDefault:()=>Zla,NonStreamHttpResponseBody:()=>j3,OAuthConfiguration:()=>$Zi,ObjectPropertyAccess:()=>x2t,Pagination:()=>A5,PathParameterLocation:()=>BDe,PrimitiveTypeV1:()=>Ps,PrimitiveTypeV2:()=>Cn,ProtobufMethodType:()=>S5t,ProtobufType:()=>rb,PublishTarget:()=>Fq,PublishingConfig:()=>W2t,RequestPropertyValue:()=>SZ,ResolvedTypeReference:()=>w3,SdkRequestBodyType:()=>E5t,SdkRequestShape:()=>IDe,ShapeType:()=>M5t,SingleUnionTypeProperties:()=>iU,Source:()=>eWi,StreamingResponse:()=>qC,SupportedSdkLanguage:()=>Tme,Transport:()=>CDe,Type:()=>Jl,TypeReference:()=>_i,V2AuthValues:()=>DDe,V2EndpointLocationHttpMethod:()=>V2t,V2HttpEndpointResponseBody:()=>aR,WebSocketMessageBody:()=>E3,WebSocketMessageOrigin:()=>Ysu,WebhookHttpMethod:()=>Jsu,WebhookPayload:()=>nU,WellKnownProtobufType:()=>In,audience:()=>lth,auth:()=>p9c,commons:()=>_9c,constants:()=>fth,dynamic:()=>er,environment:()=>A9c,errors:()=>P9c,examples:()=>j9c,generatorExec:()=>zl,http:()=>E9c,ir:()=>S9c,proto:()=>M9c,publish:()=>D9c,types:()=>B9c,variables:()=>Tth,webhooks:()=>I9c,websocket:()=>C9c});var lth={};var p9c={};$t(p9c,{AuthScheme:()=>mP,AuthSchemesRequirement:()=>vN,OAuthConfiguration:()=>$Zi});var mP={bearer:e=>({...e,type:"bearer",_visit:function(t){return mP._visit(this,t)}}),basic:e=>({...e,type:"basic",_visit:function(t){return mP._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return mP._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return mP._visit(this,t)}}),inferred:e=>({...e,type:"inferred",_visit:function(t){return mP._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"bearer":return t.bearer(e);case"basic":return t.basic(e);case"header":return t.header(e);case"oauth":return t.oauth(e);case"inferred":return t.inferred(e);default:return t._other(e)}}};var iND={All:"ALL",Any:"ANY",EndpointSecurity:"ENDPOINT_SECURITY"},vN={...iND,_visit:(e,t)=>{switch(e){case vN.All:return t.all();case vN.Any:return t.any();case vN.EndpointSecurity:return t.endpointSecurity();default:return t._other()}}};var $Zi={clientCredentials:e=>({...e,type:"clientCredentials",_visit:function(t){return $Zi._visit(this,t)}}),_visit:(e,t)=>e.type==="clientCredentials"?t.clientCredentials(e):t._other(e)};var _9c={};$t(_9c,{AvailabilityStatus:()=>nR});var nND={InDevelopment:"IN_DEVELOPMENT",PreRelease:"PRE_RELEASE",GeneralAvailability:"GENERAL_AVAILABILITY",Deprecated:"DEPRECATED"},nR={...nND,_visit:(e,t)=>{switch(e){case nR.InDevelopment:return t.inDevelopment();case nR.PreRelease:return t.preRelease();case nR.GeneralAvailability:return t.generalAvailability();case nR.Deprecated:return t.deprecated();default:return t._other()}}};var fth={};var er={};$t(er,{Auth:()=>dth,AuthValues:()=>pth,Environments:()=>mth,ErrorSeverity:()=>Gsu,FileUploadRequestBodyProperty:()=>yth,GeneratorOutputConfig:()=>Ath,HttpMethod:()=>JZi,InlinedRequestBody:()=>bth,LiteralType:()=>jth,NamedType:()=>wth,ObjectPropertyAccess:()=>Hsu,PrimitiveTypeV1:()=>P7,PublishInfo:()=>Pth,ReferencedRequestBodyType:()=>vth,Request:()=>gth,Response:()=>Oth,SingleDiscriminatedUnionType:()=>Eth,TypeReference:()=>Sth,auth:()=>h9c,commons:()=>_th,declaration:()=>hth,endpoints:()=>y9c,environment:()=>b9c,http:()=>v9c,ir:()=>g9c,snippets:()=>O9c,types:()=>m9c,variables:()=>Mth});var h9c={};$t(h9c,{Auth:()=>dth,AuthValues:()=>pth});var dth={basic:e=>({...e,type:"basic",_visit:function(t){return er.Auth._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return er.Auth._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return er.Auth._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return er.Auth._visit(this,t)}}),inferred:e=>({...e,type:"inferred",_visit:function(t){return er.Auth._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"oauth":return t.oauth(e);case"inferred":return t.inferred(e);default:return t._other(e)}}};var pth={basic:e=>({...e,type:"basic",_visit:function(t){return er.AuthValues._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return er.AuthValues._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return er.AuthValues._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return er.AuthValues._visit(this,t)}}),inferred:e=>({...e,type:"inferred",_visit:function(t){return er.AuthValues._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"oauth":return t.oauth(e);case"inferred":return t.inferred(e);default:return t._other(e)}}};var _th={};var hth={};var y9c={};$t(y9c,{FileUploadRequestBodyProperty:()=>yth,InlinedRequestBody:()=>bth,ReferencedRequestBodyType:()=>vth,Request:()=>gth,Response:()=>Oth});var yth={file:e=>({...e,type:"file",_visit:function(t){return er.FileUploadRequestBodyProperty._visit(this,t)}}),fileArray:e=>({...e,type:"fileArray",_visit:function(t){return er.FileUploadRequestBodyProperty._visit(this,t)}}),bodyProperty:e=>({...e,type:"bodyProperty",_visit:function(t){return er.FileUploadRequestBodyProperty._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"fileArray":return t.fileArray(e);case"bodyProperty":return t.bodyProperty(e);default:return t._other(e)}}};var bth={properties:e=>({value:e,type:"properties",_visit:function(t){return er.InlinedRequestBody._visit(this,t)}}),referenced:e=>({...e,type:"referenced",_visit:function(t){return er.InlinedRequestBody._visit(this,t)}}),fileUpload:e=>({...e,type:"fileUpload",_visit:function(t){return er.InlinedRequestBody._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"properties":return t.properties(e.value);case"referenced":return t.referenced(e);case"fileUpload":return t.fileUpload(e);default:return t._other(e)}}};var vth={bytes:()=>({type:"bytes",_visit:function(e){return er.ReferencedRequestBodyType._visit(this,e)}}),typeReference:e=>({value:e,type:"typeReference",_visit:function(t){return er.ReferencedRequestBodyType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"bytes":return t.bytes();case"typeReference":return t.typeReference(e.value);default:return t._other(e)}}};var gth={body:e=>({...e,type:"body",_visit:function(t){return er.Request._visit(this,t)}}),inlined:e=>({...e,type:"inlined",_visit:function(t){return er.Request._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"body":return t.body(e);case"inlined":return t.inlined(e);default:return t._other(e)}}};var Oth={json:()=>({type:"json",_visit:function(e){return er.Response._visit(this,e)}}),streaming:()=>({type:"streaming",_visit:function(e){return er.Response._visit(this,e)}}),streamParameter:()=>({type:"streamParameter",_visit:function(e){return er.Response._visit(this,e)}}),fileDownload:()=>({type:"fileDownload",_visit:function(e){return er.Response._visit(this,e)}}),text:()=>({type:"text",_visit:function(e){return er.Response._visit(this,e)}}),bytes:()=>({type:"bytes",_visit:function(e){return er.Response._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json();case"streaming":return t.streaming();case"streamParameter":return t.streamParameter();case"fileDownload":return t.fileDownload();case"text":return t.text();case"bytes":return t.bytes();default:return t._other(e)}}};var b9c={};$t(b9c,{Environments:()=>mth});var mth={singleBaseUrl:e=>({...e,type:"singleBaseUrl",_visit:function(t){return er.Environments._visit(this,t)}}),multipleBaseUrls:e=>({...e,type:"multipleBaseUrls",_visit:function(t){return er.Environments._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"singleBaseUrl":return t.singleBaseUrl(e);case"multipleBaseUrls":return t.multipleBaseUrls(e);default:return t._other(e)}}};var v9c={};$t(v9c,{HttpMethod:()=>JZi});var aND={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD"},JZi={...aND,_visit:(e,t)=>{switch(e){case JZi.Get:return t.get();case JZi.Post:return t.post();case JZi.Put:return t.put();case JZi.Patch:return t.patch();case JZi.Delete:return t.delete();case JZi.Head:return t.head();default:return t._other()}}};var g9c={};$t(g9c,{GeneratorOutputConfig:()=>Ath,PublishInfo:()=>Pth});var Ath={publish:e=>({value:e,type:"publish",_visit:function(t){return er.GeneratorOutputConfig._visit(this,t)}}),local:()=>({type:"local",_visit:function(e){return er.GeneratorOutputConfig._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"publish":return t.publish(e.value);case"local":return t.local();default:return t._other(e)}}};var Pth={go:e=>({...e,type:"go",_visit:function(t){return er.PublishInfo._visit(this,t)}}),swift:e=>({...e,type:"swift",_visit:function(t){return er.PublishInfo._visit(this,t)}}),maven:e=>({...e,type:"maven",_visit:function(t){return er.PublishInfo._visit(this,t)}}),npm:e=>({...e,type:"npm",_visit:function(t){return er.PublishInfo._visit(this,t)}}),nuget:e=>({...e,type:"nuget",_visit:function(t){return er.PublishInfo._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return er.PublishInfo._visit(this,t)}}),rubygems:e=>({...e,type:"rubygems",_visit:function(t){return er.PublishInfo._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return er.PublishInfo._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"go":return t.go(e);case"swift":return t.swift(e);case"maven":return t.maven(e);case"npm":return t.npm(e);case"nuget":return t.nuget(e);case"pypi":return t.pypi(e);case"rubygems":return t.rubygems(e);case"crates":return t.crates(e);default:return t._other(e)}}};var O9c={};$t(O9c,{ErrorSeverity:()=>Gsu});var oND={Critical:"CRITICAL",Warning:"WARNING"},Gsu={...oND,_visit:(e,t)=>{switch(e){case Gsu.Critical:return t.critical();case Gsu.Warning:return t.warning();default:return t._other()}}};var m9c={};$t(m9c,{LiteralType:()=>jth,NamedType:()=>wth,ObjectPropertyAccess:()=>Hsu,PrimitiveTypeV1:()=>P7,SingleDiscriminatedUnionType:()=>Eth,TypeReference:()=>Sth});var jth={boolean:e=>({value:e,type:"boolean",_visit:function(t){return er.LiteralType._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return er.LiteralType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var wth={alias:e=>({...e,type:"alias",_visit:function(t){return er.NamedType._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return er.NamedType._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return er.NamedType._visit(this,t)}}),discriminatedUnion:e=>({...e,type:"discriminatedUnion",_visit:function(t){return er.NamedType._visit(this,t)}}),undiscriminatedUnion:e=>({...e,type:"undiscriminatedUnion",_visit:function(t){return er.NamedType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"alias":return t.alias(e);case"enum":return t.enum(e);case"object":return t.object(e);case"discriminatedUnion":return t.discriminatedUnion(e);case"undiscriminatedUnion":return t.undiscriminatedUnion(e);default:return t._other(e)}}};var uND={ReadOnly:"READ_ONLY",WriteOnly:"WRITE_ONLY"},Hsu={...uND,_visit:(e,t)=>{switch(e){case Hsu.ReadOnly:return t.readOnly();case Hsu.WriteOnly:return t.writeOnly();default:return t._other()}}};var sND={Integer:"INTEGER",Long:"LONG",Uint:"UINT",Uint64:"UINT_64",Float:"FLOAT",Double:"DOUBLE",Boolean:"BOOLEAN",String:"STRING",Date:"DATE",DateTime:"DATE_TIME",Uuid:"UUID",Base64:"BASE_64",BigInteger:"BIG_INTEGER"},P7={...sND,_visit:(e,t)=>{switch(e){case P7.Integer:return t.integer();case P7.Long:return t.long();case P7.Uint:return t.uint();case P7.Uint64:return t.uint64();case P7.Float:return t.float();case P7.Double:return t.double();case P7.Boolean:return t.boolean();case P7.String:return t.string();case P7.Date:return t.date();case P7.DateTime:return t.dateTime();case P7.Uuid:return t.uuid();case P7.Base64:return t.base64();case P7.BigInteger:return t.bigInteger();default:return t._other()}}};var Eth={samePropertiesAsObject:e=>({...e,type:"samePropertiesAsObject",_visit:function(t){return er.SingleDiscriminatedUnionType._visit(this,t)}}),singleProperty:e=>({...e,type:"singleProperty",_visit:function(t){return er.SingleDiscriminatedUnionType._visit(this,t)}}),noProperties:e=>({...e,type:"noProperties",_visit:function(t){return er.SingleDiscriminatedUnionType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"samePropertiesAsObject":return t.samePropertiesAsObject(e);case"singleProperty":return t.singleProperty(e);case"noProperties":return t.noProperties(e);default:return t._other(e)}}};var Sth={list:e=>({value:e,type:"list",_visit:function(t){return er.TypeReference._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return er.TypeReference._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return er.TypeReference._visit(this,t)}}),named:e=>({value:e,type:"named",_visit:function(t){return er.TypeReference._visit(this,t)}}),nullable:e=>({value:e,type:"nullable",_visit:function(t){return er.TypeReference._visit(this,t)}}),optional:e=>({value:e,type:"optional",_visit:function(t){return er.TypeReference._visit(this,t)}}),primitive:e=>({value:e,type:"primitive",_visit:function(t){return er.TypeReference._visit(this,t)}}),set:e=>({value:e,type:"set",_visit:function(t){return er.TypeReference._visit(this,t)}}),unknown:()=>({type:"unknown",_visit:function(e){return er.TypeReference._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"list":return t.list(e.value);case"literal":return t.literal(e.value);case"map":return t.map(e);case"named":return t.named(e.value);case"nullable":return t.nullable(e.value);case"optional":return t.optional(e.value);case"primitive":return t.primitive(e.value);case"set":return t.set(e.value);case"unknown":return t.unknown();default:return t._other(e)}}};var Mth={};var A9c={};$t(A9c,{Environments:()=>xD});var xD={singleBaseUrl:e=>({...e,type:"singleBaseUrl",_visit:function(t){return xD._visit(this,t)}}),multipleBaseUrls:e=>({...e,type:"multipleBaseUrls",_visit:function(t){return xD._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"singleBaseUrl":return t.singleBaseUrl(e);case"multipleBaseUrls":return t.multipleBaseUrls(e);default:return t._other(e)}}};var P9c={};$t(P9c,{ErrorDeclarationDiscriminantValue:()=>YZi});var YZi={property:e=>({...e,type:"property",_visit:function(t){return YZi._visit(this,t)}}),statusCode:()=>({type:"statusCode",_visit:function(e){return YZi._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"property":return t.property(e);case"statusCode":return t.statusCode();default:return t._other(e)}}};var j9c={};$t(j9c,{V2AuthValues:()=>DDe,V2EndpointLocationHttpMethod:()=>V2t,V2HttpEndpointResponseBody:()=>aR});var DDe={basic:e=>({...e,type:"basic",_visit:function(t){return DDe._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return DDe._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return DDe._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return DDe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"oauth":return t.oauth(e);default:return t._other(e)}}};var cND={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD"},V2t={...cND,_visit:(e,t)=>{switch(e){case V2t.Get:return t.get();case V2t.Post:return t.post();case V2t.Put:return t.put();case V2t.Patch:return t.patch();case V2t.Delete:return t.delete();case V2t.Head:return t.head();default:return t._other()}}};var aR={error:e=>({value:e,type:"error",_visit:function(t){return aR._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return aR._visit(this,t)}}),stream:e=>({value:e,type:"stream",_visit:function(t){return aR._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"error":return t.error(e.value);case"json":return t.json(e.value);case"stream":return t.stream(e.value);default:return t._other(e)}}};var zl={};$t(zl,{GeneratorEnvironment:()=>Dth,GeneratorPublishTarget:()=>Bth,GithubPublishInfo:()=>Ith,LicenseConfig:()=>Cth,LicenseId:()=>Ksu,OutputMode:()=>qth,config:()=>w9c});var w9c={};$t(w9c,{GeneratorEnvironment:()=>Dth,GeneratorPublishTarget:()=>Bth,GithubPublishInfo:()=>Ith,LicenseConfig:()=>Cth,LicenseId:()=>Ksu,OutputMode:()=>qth});var Dth={local:()=>({type:"local",_visit:function(e){return zl.GeneratorEnvironment._visit(this,e)}}),remote:e=>({...e,type:"remote",_visit:function(t){return zl.GeneratorEnvironment._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"local":return t.local();case"remote":return t.remote(e);default:return t._other(e)}}};var Bth={maven:e=>({...e,type:"maven",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),npm:e=>({...e,type:"npm",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),postman:e=>({...e,type:"postman",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),rubygems:e=>({...e,type:"rubygems",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),nuget:e=>({...e,type:"nuget",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"maven":return t.maven(e);case"npm":return t.npm(e);case"pypi":return t.pypi(e);case"postman":return t.postman(e);case"rubygems":return t.rubygems(e);case"nuget":return t.nuget(e);case"crates":return t.crates(e);default:return t._other(e)}}};var Ith={npm:e=>({...e,type:"npm",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),maven:e=>({...e,type:"maven",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),postman:e=>({...e,type:"postman",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),rubygems:e=>({...e,type:"rubygems",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),nuget:e=>({...e,type:"nuget",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"npm":return t.npm(e);case"maven":return t.maven(e);case"postman":return t.postman(e);case"pypi":return t.pypi(e);case"rubygems":return t.rubygems(e);case"nuget":return t.nuget(e);case"crates":return t.crates(e);default:return t._other(e)}}};var Cth={basic:e=>({...e,type:"basic",_visit:function(t){return zl.LicenseConfig._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return zl.LicenseConfig._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"custom":return t.custom(e);default:return t._other(e)}}};var lND={Mit:"MIT",Apache2:"Apache-2.0"},Ksu={...lND,_visit:(e,t)=>{switch(e){case Ksu.Mit:return t.mit();case Ksu.Apache2:return t.apache2();default:return t._other()}}};var qth={publish:e=>({...e,type:"publish",_visit:function(t){return zl.OutputMode._visit(this,t)}}),downloadFiles:()=>({type:"downloadFiles",_visit:function(e){return zl.OutputMode._visit(this,e)}}),github:e=>({...e,type:"github",_visit:function(t){return zl.OutputMode._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"publish":return t.publish(e);case"downloadFiles":return t.downloadFiles();case"github":return t.github(e);default:return t._other(e)}}};var E9c={};$t(E9c,{ExampleCodeSample:()=>qme,ExampleEndpointSuccessResponse:()=>PE,ExampleQueryParameterShape:()=>gN,ExampleRequestBody:()=>O5,ExampleResponse:()=>Zw,FileProperty:()=>EZ,FileUploadBodyPropertyEncoding:()=>Rka,FileUploadRequestProperty:()=>oR,HttpEndpointSource:()=>m5,HttpMethod:()=>jE,HttpRequestBody:()=>FA,HttpResponseBody:()=>op,JsonResponse:()=>Nq,NonStreamHttpResponseBody:()=>j3,Pagination:()=>A5,PathParameterLocation:()=>BDe,RequestPropertyValue:()=>SZ,SdkRequestBodyType:()=>E5t,SdkRequestShape:()=>IDe,StreamingResponse:()=>qC,SupportedSdkLanguage:()=>Tme,Transport:()=>CDe});var qme={language:e=>({...e,type:"language",_visit:function(t){return qme._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return qme._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"language":return t.language(e);case"sdk":return t.sdk(e);default:return t._other(e)}}};var PE={body:e=>({value:e,type:"body",_visit:function(t){return PE._visit(this,t)}}),stream:e=>({value:e,type:"stream",_visit:function(t){return PE._visit(this,t)}}),sse:e=>({value:e,type:"sse",_visit:function(t){return PE._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"body":return t.body(e.value);case"stream":return t.stream(e.value);case"sse":return t.sse(e.value);default:return t._other(e)}}};var gN={single:()=>({type:"single",_visit:function(e){return gN._visit(this,e)}}),exploded:()=>({type:"exploded",_visit:function(e){return gN._visit(this,e)}}),commaSeparated:()=>({type:"commaSeparated",_visit:function(e){return gN._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"single":return t.single();case"exploded":return t.exploded();case"commaSeparated":return t.commaSeparated();default:return t._other(e)}}};var O5={inlinedRequestBody:e=>({...e,type:"inlinedRequestBody",_visit:function(t){return O5._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return O5._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedRequestBody":return t.inlinedRequestBody(e);case"reference":return t.reference(e);default:return t._other(e)}}};var Zw={ok:e=>({value:e,type:"ok",_visit:function(t){return Zw._visit(this,t)}}),error:e=>({...e,type:"error",_visit:function(t){return Zw._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"ok":return t.ok(e.value);case"error":return t.error(e);default:return t._other(e)}}};var EZ={file:e=>({...e,type:"file",_visit:function(t){return EZ._visit(this,t)}}),fileArray:e=>({...e,type:"fileArray",_visit:function(t){return EZ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"fileArray":return t.fileArray(e);default:return t._other(e)}}};var fND={Exploded:"exploded",Json:"json",Form:"form"},Rka={...fND,_visit:(e,t)=>{switch(e){case Rka.Exploded:return t.exploded();case Rka.Json:return t.json();case Rka.Form:return t.form();default:return t._other()}}};var oR={file:e=>({value:e,type:"file",_visit:function(t){return oR._visit(this,t)}}),bodyProperty:e=>({...e,type:"bodyProperty",_visit:function(t){return oR._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e.value);case"bodyProperty":return t.bodyProperty(e);default:return t._other(e)}}};var m5={proto:e=>({...e,type:"proto",_visit:function(t){return m5._visit(this,t)}}),openapi:()=>({type:"openapi",_visit:function(e){return m5._visit(this,e)}}),openrpc:()=>({type:"openrpc",_visit:function(e){return m5._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"proto":return t.proto(e);case"openapi":return t.openapi();case"openrpc":return t.openrpc();default:return t._other(e)}}};var dND={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD"},jE={...dND,_visit:(e,t)=>{switch(e){case jE.Get:return t.get();case jE.Post:return t.post();case jE.Put:return t.put();case jE.Patch:return t.patch();case jE.Delete:return t.delete();case jE.Head:return t.head();default:return t._other()}}};var FA={inlinedRequestBody:e=>({...e,type:"inlinedRequestBody",_visit:function(t){return FA._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return FA._visit(this,t)}}),fileUpload:e=>({...e,type:"fileUpload",_visit:function(t){return FA._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return FA._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedRequestBody":return t.inlinedRequestBody(e);case"reference":return t.reference(e);case"fileUpload":return t.fileUpload(e);case"bytes":return t.bytes(e);default:return t._other(e)}}};var op={json:e=>({value:e,type:"json",_visit:function(t){return op._visit(this,t)}}),fileDownload:e=>({...e,type:"fileDownload",_visit:function(t){return op._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return op._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return op._visit(this,t)}}),streaming:e=>({value:e,type:"streaming",_visit:function(t){return op._visit(this,t)}}),streamParameter:e=>({...e,type:"streamParameter",_visit:function(t){return op._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json(e.value);case"fileDownload":return t.fileDownload(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streaming":return t.streaming(e.value);case"streamParameter":return t.streamParameter(e);default:return t._other(e)}}};var Nq={response:e=>({...e,type:"response",_visit:function(t){return Nq._visit(this,t)}}),nestedPropertyAsResponse:e=>({...e,type:"nestedPropertyAsResponse",_visit:function(t){return Nq._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"response":return t.response(e);case"nestedPropertyAsResponse":return t.nestedPropertyAsResponse(e);default:return t._other(e)}}};var j3={json:e=>({value:e,type:"json",_visit:function(t){return j3._visit(this,t)}}),fileDownload:e=>({...e,type:"fileDownload",_visit:function(t){return j3._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return j3._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return j3._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json(e.value);case"fileDownload":return t.fileDownload(e);case"text":return t.text(e);case"bytes":return t.bytes(e);default:return t._other(e)}}};var A5={cursor:e=>({...e,type:"cursor",_visit:function(t){return A5._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return A5._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return A5._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var pND={Root:"ROOT",Service:"SERVICE",Endpoint:"ENDPOINT"},BDe={...pND,_visit:(e,t)=>{switch(e){case BDe.Root:return t.root();case BDe.Service:return t.service();case BDe.Endpoint:return t.endpoint();default:return t._other()}}};var SZ={query:e=>({...e,type:"query",_visit:function(t){return SZ._visit(this,t)}}),body:e=>({...e,type:"body",_visit:function(t){return SZ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"query":return t.query(e);case"body":return t.body(e);default:return t._other(e)}}};var E5t={typeReference:e=>({...e,type:"typeReference",_visit:function(t){return E5t._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return E5t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"typeReference":return t.typeReference(e);case"bytes":return t.bytes(e);default:return t._other(e)}}};var IDe={justRequestBody:e=>({value:e,type:"justRequestBody",_visit:function(t){return IDe._visit(this,t)}}),wrapper:e=>({...e,type:"wrapper",_visit:function(t){return IDe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"justRequestBody":return t.justRequestBody(e.value);case"wrapper":return t.wrapper(e);default:return t._other(e)}}};var qC={json:e=>({...e,type:"json",_visit:function(t){return qC._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return qC._visit(this,t)}}),sse:e=>({...e,type:"sse",_visit:function(t){return qC._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json(e);case"text":return t.text(e);case"sse":return t.sse(e);default:return t._other(e)}}};var _ND={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Php:"php",Rust:"rust",Swift:"swift"},Tme={..._ND,_visit:(e,t)=>{switch(e){case Tme.Curl:return t.curl();case Tme.Python:return t.python();case Tme.Javascript:return t.javascript();case Tme.Typescript:return t.typescript();case Tme.Go:return t.go();case Tme.Ruby:return t.ruby();case Tme.Csharp:return t.csharp();case Tme.Java:return t.java();case Tme.Php:return t.php();case Tme.Rust:return t.rust();case Tme.Swift:return t.swift();default:return t._other()}}};var CDe={http:()=>({type:"http",_visit:function(e){return CDe._visit(this,e)}}),grpc:e=>({...e,type:"grpc",_visit:function(t){return CDe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"http":return t.http();case"grpc":return t.grpc(e);default:return t._other(e)}}};var S9c={};$t(S9c,{ApiDefinitionSource:()=>MZ,ApiVersionScheme:()=>XZi,ErrorDiscriminationStrategy:()=>Rme,ExampleStyle:()=>$su});var MZ={proto:e=>({...e,type:"proto",_visit:function(t){return MZ._visit(this,t)}}),openapi:()=>({type:"openapi",_visit:function(e){return MZ._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"proto":return t.proto(e);case"openapi":return t.openapi();default:return t._other(e)}}};var XZi={header:e=>({...e,type:"header",_visit:function(t){return XZi._visit(this,t)}}),_visit:(e,t)=>e.type==="header"?t.header(e):t._other(e)};var Rme={statusCode:()=>({type:"statusCode",_visit:function(e){return Rme._visit(this,e)}}),property:e=>({...e,type:"property",_visit:function(t){return Rme._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"statusCode":return t.statusCode();case"property":return t.property(e);default:return t._other(e)}}};var hND={Minimal:"minimal",Comprehensive:"comprehensive"},$su={...hND,_visit:(e,t)=>{switch(e){case $su.Minimal:return t.minimal();case $su.Comprehensive:return t.comprehensive();default:return t._other()}}};var M9c={};$t(M9c,{ProtobufMethodType:()=>S5t,ProtobufType:()=>rb,WellKnownProtobufType:()=>In});var yND={Unary:"UNARY",ClientStream:"CLIENT_STREAM",ServerStream:"SERVER_STREAM",BidirectionalStream:"BIDIRECTIONAL_STREAM"},S5t={...yND,_visit:(e,t)=>{switch(e){case S5t.Unary:return t.unary();case S5t.ClientStream:return t.clientStream();case S5t.ServerStream:return t.serverStream();case S5t.BidirectionalStream:return t.bidirectionalStream();default:return t._other()}}};var rb={wellKnown:e=>({value:e,type:"wellKnown",_visit:function(t){return rb._visit(this,t)}}),userDefined:e=>({...e,type:"userDefined",_visit:function(t){return rb._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"wellKnown":return t.wellKnown(e.value);case"userDefined":return t.userDefined(e);default:return t._other(e)}}};var In={any:()=>({type:"any",_visit:function(e){return In._visit(this,e)}}),api:()=>({type:"api",_visit:function(e){return In._visit(this,e)}}),boolValue:()=>({type:"boolValue",_visit:function(e){return In._visit(this,e)}}),bytesValue:()=>({type:"bytesValue",_visit:function(e){return In._visit(this,e)}}),doubleValue:()=>({type:"doubleValue",_visit:function(e){return In._visit(this,e)}}),duration:()=>({type:"duration",_visit:function(e){return In._visit(this,e)}}),empty:()=>({type:"empty",_visit:function(e){return In._visit(this,e)}}),enum:()=>({type:"enum",_visit:function(e){return In._visit(this,e)}}),enumValue:()=>({type:"enumValue",_visit:function(e){return In._visit(this,e)}}),field:()=>({type:"field",_visit:function(e){return In._visit(this,e)}}),fieldCardinality:()=>({type:"fieldCardinality",_visit:function(e){return In._visit(this,e)}}),fieldKind:()=>({type:"fieldKind",_visit:function(e){return In._visit(this,e)}}),fieldMask:()=>({type:"fieldMask",_visit:function(e){return In._visit(this,e)}}),floatValue:()=>({type:"floatValue",_visit:function(e){return In._visit(this,e)}}),int32Value:()=>({type:"int32Value",_visit:function(e){return In._visit(this,e)}}),int64Value:()=>({type:"int64Value",_visit:function(e){return In._visit(this,e)}}),listValue:()=>({type:"listValue",_visit:function(e){return In._visit(this,e)}}),method:()=>({type:"method",_visit:function(e){return In._visit(this,e)}}),mixin:()=>({type:"mixin",_visit:function(e){return In._visit(this,e)}}),nullValue:()=>({type:"nullValue",_visit:function(e){return In._visit(this,e)}}),option:()=>({type:"option",_visit:function(e){return In._visit(this,e)}}),sourceContext:()=>({type:"sourceContext",_visit:function(e){return In._visit(this,e)}}),stringValue:()=>({type:"stringValue",_visit:function(e){return In._visit(this,e)}}),struct:()=>({type:"struct",_visit:function(e){return In._visit(this,e)}}),syntax:()=>({type:"syntax",_visit:function(e){return In._visit(this,e)}}),timestamp:()=>({type:"timestamp",_visit:function(e){return In._visit(this,e)}}),type:()=>({type:"type",_visit:function(e){return In._visit(this,e)}}),uint32Value:()=>({type:"uint32Value",_visit:function(e){return In._visit(this,e)}}),uint64Value:()=>({type:"uint64Value",_visit:function(e){return In._visit(this,e)}}),value:()=>({type:"value",_visit:function(e){return In._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"any":return t.any();case"api":return t.api();case"boolValue":return t.boolValue();case"bytesValue":return t.bytesValue();case"doubleValue":return t.doubleValue();case"duration":return t.duration();case"empty":return t.empty();case"enum":return t.enum();case"enumValue":return t.enumValue();case"field":return t.field();case"fieldCardinality":return t.fieldCardinality();case"fieldKind":return t.fieldKind();case"fieldMask":return t.fieldMask();case"floatValue":return t.floatValue();case"int32Value":return t.int32Value();case"int64Value":return t.int64Value();case"listValue":return t.listValue();case"method":return t.method();case"mixin":return t.mixin();case"nullValue":return t.nullValue();case"option":return t.option();case"sourceContext":return t.sourceContext();case"stringValue":return t.stringValue();case"struct":return t.struct();case"syntax":return t.syntax();case"timestamp":return t.timestamp();case"type":return t.type();case"uint32Value":return t.uint32Value();case"uint64Value":return t.uint64Value();case"value":return t.value();default:return t._other(e)}}};var D9c={};$t(D9c,{PublishTarget:()=>Fq,PublishingConfig:()=>W2t});var W2t={github:e=>({...e,type:"github",_visit:function(t){return W2t._visit(this,t)}}),direct:e=>({...e,type:"direct",_visit:function(t){return W2t._visit(this,t)}}),filesystem:e=>({...e,type:"filesystem",_visit:function(t){return W2t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"github":return t.github(e);case"direct":return t.direct(e);case"filesystem":return t.filesystem(e);default:return t._other(e)}}};var Fq={postman:e=>({...e,type:"postman",_visit:function(t){return Fq._visit(this,t)}}),npm:e=>({...e,type:"npm",_visit:function(t){return Fq._visit(this,t)}}),maven:e=>({...e,type:"maven",_visit:function(t){return Fq._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return Fq._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return Fq._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"postman":return t.postman(e);case"npm":return t.npm(e);case"maven":return t.maven(e);case"pypi":return t.pypi(e);case"crates":return t.crates(e);default:return t._other(e)}}};var B9c={};$t(B9c,{ContainerType:()=>Js,ExampleContainer:()=>S_,ExamplePrimitive:()=>Xn,ExampleSingleUnionTypeProperties:()=>Qq,ExampleTypeReferenceShape:()=>as,ExampleTypeShape:()=>ib,Literal:()=>rU,NamedTypeDefault:()=>Zla,ObjectPropertyAccess:()=>x2t,PrimitiveTypeV1:()=>Ps,PrimitiveTypeV2:()=>Cn,ResolvedTypeReference:()=>w3,ShapeType:()=>M5t,SingleUnionTypeProperties:()=>iU,Source:()=>eWi,Type:()=>Jl,TypeReference:()=>_i});var Js={list:e=>({list:e,type:"list",_visit:function(t){return Js._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Js._visit(this,t)}}),nullable:e=>({nullable:e,type:"nullable",_visit:function(t){return Js._visit(this,t)}}),optional:e=>({optional:e,type:"optional",_visit:function(t){return Js._visit(this,t)}}),set:e=>({set:e,type:"set",_visit:function(t){return Js._visit(this,t)}}),literal:e=>({literal:e,type:"literal",_visit:function(t){return Js._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"list":return t.list(e.list);case"map":return t.map(e);case"nullable":return t.nullable(e.nullable);case"optional":return t.optional(e.optional);case"set":return t.set(e.set);case"literal":return t.literal(e.literal);default:return t._other(e)}}};var S_={list:e=>({...e,type:"list",_visit:function(t){return S_._visit(this,t)}}),set:e=>({...e,type:"set",_visit:function(t){return S_._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return S_._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return S_._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return S_._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return S_._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"list":return t.list(e);case"set":return t.set(e);case"optional":return t.optional(e);case"nullable":return t.nullable(e);case"map":return t.map(e);case"literal":return t.literal(e);default:return t._other(e)}}};var Xn={integer:e=>({integer:e,type:"integer",_visit:function(t){return Xn._visit(this,t)}}),long:e=>({long:e,type:"long",_visit:function(t){return Xn._visit(this,t)}}),uint:e=>({uint:e,type:"uint",_visit:function(t){return Xn._visit(this,t)}}),uint64:e=>({uint64:e,type:"uint64",_visit:function(t){return Xn._visit(this,t)}}),float:e=>({float:e,type:"float",_visit:function(t){return Xn._visit(this,t)}}),double:e=>({double:e,type:"double",_visit:function(t){return Xn._visit(this,t)}}),boolean:e=>({boolean:e,type:"boolean",_visit:function(t){return Xn._visit(this,t)}}),string:e=>({string:e,type:"string",_visit:function(t){return Xn._visit(this,t)}}),date:e=>({date:e,type:"date",_visit:function(t){return Xn._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Xn._visit(this,t)}}),uuid:e=>({uuid:e,type:"uuid",_visit:function(t){return Xn._visit(this,t)}}),base64:e=>({base64:e,type:"base64",_visit:function(t){return Xn._visit(this,t)}}),bigInteger:e=>({bigInteger:e,type:"bigInteger",_visit:function(t){return Xn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"integer":return t.integer(e.integer);case"long":return t.long(e.long);case"uint":return t.uint(e.uint);case"uint64":return t.uint64(e.uint64);case"float":return t.float(e.float);case"double":return t.double(e.double);case"boolean":return t.boolean(e.boolean);case"string":return t.string(e.string);case"date":return t.date(e.date);case"datetime":return t.datetime(e);case"uuid":return t.uuid(e.uuid);case"base64":return t.base64(e.base64);case"bigInteger":return t.bigInteger(e.bigInteger);default:return t._other(e)}}};var Qq={samePropertiesAsObject:e=>({...e,type:"samePropertiesAsObject",_visit:function(t){return Qq._visit(this,t)}}),singleProperty:e=>({...e,type:"singleProperty",_visit:function(t){return Qq._visit(this,t)}}),noProperties:()=>({type:"noProperties",_visit:function(e){return Qq._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"samePropertiesAsObject":return t.samePropertiesAsObject(e);case"singleProperty":return t.singleProperty(e);case"noProperties":return t.noProperties();default:return t._other(e)}}};var as={primitive:e=>({primitive:e,type:"primitive",_visit:function(t){return as._visit(this,t)}}),container:e=>({container:e,type:"container",_visit:function(t){return as._visit(this,t)}}),unknown:e=>({unknown:e,type:"unknown",_visit:function(t){return as._visit(this,t)}}),named:e=>({...e,type:"named",_visit:function(t){return as._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.primitive);case"container":return t.container(e.container);case"unknown":return t.unknown(e.unknown);case"named":return t.named(e);default:return t._other(e)}}};var ib={alias:e=>({...e,type:"alias",_visit:function(t){return ib._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ib._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ib._visit(this,t)}}),union:e=>({...e,type:"union",_visit:function(t){return ib._visit(this,t)}}),undiscriminatedUnion:e=>({...e,type:"undiscriminatedUnion",_visit:function(t){return ib._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"alias":return t.alias(e);case"enum":return t.enum(e);case"object":return t.object(e);case"union":return t.union(e);case"undiscriminatedUnion":return t.undiscriminatedUnion(e);default:return t._other(e)}}};var rU={string:e=>({string:e,type:"string",_visit:function(t){return rU._visit(this,t)}}),boolean:e=>({boolean:e,type:"boolean",_visit:function(t){return rU._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"string":return t.string(e.string);case"boolean":return t.boolean(e.boolean);default:return t._other(e)}}};var Zla={enum:e=>({...e,type:"enum",_visit:function(t){return Zla._visit(this,t)}}),_visit:(e,t)=>e.type==="enum"?t.enum(e):t._other(e)};var bND={ReadOnly:"READ_ONLY",WriteOnly:"WRITE_ONLY"},x2t={...bND,_visit:(e,t)=>{switch(e){case x2t.ReadOnly:return t.readOnly();case x2t.WriteOnly:return t.writeOnly();default:return t._other()}}};var vND={Integer:"INTEGER",Long:"LONG",Uint:"UINT",Uint64:"UINT_64",Float:"FLOAT",Double:"DOUBLE",Boolean:"BOOLEAN",String:"STRING",Date:"DATE",DateTime:"DATE_TIME",Uuid:"UUID",Base64:"BASE_64",BigInteger:"BIG_INTEGER"},Ps={...vND,_visit:(e,t)=>{switch(e){case Ps.Integer:return t.integer();case Ps.Long:return t.long();case Ps.Uint:return t.uint();case Ps.Uint64:return t.uint64();case Ps.Float:return t.float();case Ps.Double:return t.double();case Ps.Boolean:return t.boolean();case Ps.String:return t.string();case Ps.Date:return t.date();case Ps.DateTime:return t.dateTime();case Ps.Uuid:return t.uuid();case Ps.Base64:return t.base64();case Ps.BigInteger:return t.bigInteger();default:return t._other()}}};var Cn={integer:e=>({...e,type:"integer",_visit:function(t){return Cn._visit(this,t)}}),long:e=>({...e,type:"long",_visit:function(t){return Cn._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Cn._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Cn._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Cn._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Cn._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Cn._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Cn._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Cn._visit(this,t)}}),dateTime:e=>({...e,type:"dateTime",_visit:function(t){return Cn._visit(this,t)}}),uuid:e=>({...e,type:"uuid",_visit:function(t){return Cn._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Cn._visit(this,t)}}),bigInteger:e=>({...e,type:"bigInteger",_visit:function(t){return Cn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"integer":return t.integer(e);case"long":return t.long(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"boolean":return t.boolean(e);case"string":return t.string(e);case"date":return t.date(e);case"dateTime":return t.dateTime(e);case"uuid":return t.uuid(e);case"base64":return t.base64(e);case"bigInteger":return t.bigInteger(e);default:return t._other(e)}}};var w3={container:e=>({container:e,type:"container",_visit:function(t){return w3._visit(this,t)}}),named:e=>({...e,type:"named",_visit:function(t){return w3._visit(this,t)}}),primitive:e=>({primitive:e,type:"primitive",_visit:function(t){return w3._visit(this,t)}}),unknown:()=>({type:"unknown",_visit:function(e){return w3._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"container":return t.container(e.container);case"named":return t.named(e);case"primitive":return t.primitive(e.primitive);case"unknown":return t.unknown();default:return t._other(e)}}};var gND={Enum:"ENUM",Object:"OBJECT",Union:"UNION",UndiscriminatedUnion:"UNDISCRIMINATED_UNION"},M5t={...gND,_visit:(e,t)=>{switch(e){case M5t.Enum:return t.enum();case M5t.Object:return t.object();case M5t.Union:return t.union();case M5t.UndiscriminatedUnion:return t.undiscriminatedUnion();default:return t._other()}}};var iU={samePropertiesAsObject:e=>({...e,propertiesType:"samePropertiesAsObject",_visit:function(t){return iU._visit(this,t)}}),singleProperty:e=>({...e,propertiesType:"singleProperty",_visit:function(t){return iU._visit(this,t)}}),noProperties:()=>({propertiesType:"noProperties",_visit:function(e){return iU._visit(this,e)}}),_visit:(e,t)=>{switch(e.propertiesType){case"samePropertiesAsObject":return t.samePropertiesAsObject(e);case"singleProperty":return t.singleProperty(e);case"noProperties":return t.noProperties();default:return t._other(e)}}};var eWi={proto:e=>({value:e,type:"proto",_visit:function(t){return eWi._visit(this,t)}}),_visit:(e,t)=>e.type==="proto"?t.proto(e.value):t._other(e)};var Jl={alias:e=>({...e,type:"alias",_visit:function(t){return Jl._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Jl._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Jl._visit(this,t)}}),union:e=>({...e,type:"union",_visit:function(t){return Jl._visit(this,t)}}),undiscriminatedUnion:e=>({...e,type:"undiscriminatedUnion",_visit:function(t){return Jl._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"alias":return t.alias(e);case"enum":return t.enum(e);case"object":return t.object(e);case"union":return t.union(e);case"undiscriminatedUnion":return t.undiscriminatedUnion(e);default:return t._other(e)}}};var _i={container:e=>({container:e,type:"container",_visit:function(t){return _i._visit(this,t)}}),named:e=>({...e,type:"named",_visit:function(t){return _i._visit(this,t)}}),primitive:e=>({primitive:e,type:"primitive",_visit:function(t){return _i._visit(this,t)}}),unknown:()=>({type:"unknown",_visit:function(e){return _i._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"container":return t.container(e.container);case"named":return t.named(e);case"primitive":return t.primitive(e.primitive);case"unknown":return t.unknown();default:return t._other(e)}}};var Tth={};var I9c={};$t(I9c,{WebhookHttpMethod:()=>Jsu,WebhookPayload:()=>nU});var OND={Get:"GET",Post:"POST"},Jsu={...OND,_visit:(e,t)=>{switch(e){case Jsu.Get:return t.get();case Jsu.Post:return t.post();default:return t._other()}}};var nU={inlinedPayload:e=>({...e,type:"inlinedPayload",_visit:function(t){return nU._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return nU._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedPayload":return t.inlinedPayload(e);case"reference":return t.reference(e);default:return t._other(e)}}};var C9c={};$t(C9c,{ExampleWebSocketMessageBody:()=>zme,WebSocketMessageBody:()=>E3,WebSocketMessageOrigin:()=>Ysu});var zme={inlinedBody:e=>({...e,type:"inlinedBody",_visit:function(t){return zme._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return zme._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedBody":return t.inlinedBody(e);case"reference":return t.reference(e);default:return t._other(e)}}};var E3={inlinedBody:e=>({...e,type:"inlinedBody",_visit:function(t){return E3._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return E3._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedBody":return t.inlinedBody(e);case"reference":return t.reference(e);default:return t._other(e)}}};var mND={Client:"client",Server:"server"},Ysu={...mND,_visit:(e,t)=>{switch(e){case Ysu.Client:return t.client();case Ysu.Server:return t.server();default:return t._other()}}};var sa={};$t(sa,{AliasTypeDeclaration:()=>Bpu,ApiAuth:()=>gcu,ApiDefinitionSource:()=>Qdu,ApiDefinitionSourceId:()=>Ndu,ApiVersionScheme:()=>Ldu,AudienceDefinition:()=>tcu,AudienceReference:()=>rfa,AuthScheme:()=>bcu,AuthSchemeKey:()=>ifa,AuthSchemesRequirement:()=>vcu,AuthScope:()=>Ocu,AutogeneratedEndpointExample:()=>Ufu,Availability:()=>K2t,AvailabilityStatus:()=>acu,Base64Type:()=>opu,BaseAuthScheme:()=>qDe,BasicAuthScheme:()=>rcu,BasicAuthValues:()=>Wlu,BearerAuthScheme:()=>icu,BearerAuthValues:()=>xlu,BigIntegerType:()=>upu,BooleanType:()=>spu,BytesRequest:()=>Efa,BytesResponse:()=>Sfa,Constants:()=>Pcu,ContainerType:()=>xfa,CratesPublishTarget:()=>Hdu,CsharpProtobufFileOptions:()=>edu,CursorPagination:()=>Lfu,CustomPagination:()=>Vfu,DateTimeType:()=>cpu,DateType:()=>lpu,Declaration:()=>uR,DeclaredErrorName:()=>s2i,DeclaredServiceName:()=>Wfu,DeclaredTypeName:()=>mS,DirectPublish:()=>Xdu,DisplayName:()=>r2i,DoubleType:()=>dpu,DoubleValidationRules:()=>fpu,Encoding:()=>Ufa,EndpointId:()=>rWi,EndpointName:()=>xfu,EndpointReference:()=>kZi,EnumTypeDeclaration:()=>Lfa,EnumTypeReference:()=>hrh,EnumValue:()=>iWi,EnvironmentBaseUrlId:()=>Nme,EnvironmentBaseUrlWithId:()=>Tlu,EnvironmentId:()=>X2t,EnvironmentUrl:()=>u2i,EnvironmentVariable:()=>TDe,Environments:()=>Qlu,EnvironmentsConfig:()=>Ulu,ErrorDeclaration:()=>Vlu,ErrorDeclarationDiscriminantValue:()=>drh,ErrorDiscriminationByPropertyStrategy:()=>Vdu,ErrorDiscriminationStrategy:()=>Wdu,ErrorId:()=>i2i,EscapedString:()=>mcu,ExampleAliasType:()=>v_u,ExampleCodeSample:()=>Kfu,ExampleCodeSampleLanguage:()=>Gfu,ExampleCodeSampleSdk:()=>Hfu,ExampleContainer:()=>m_u,ExampleDatetime:()=>g_u,ExampleEndpointCall:()=>wfa,ExampleEndpointErrorResponse:()=>zfu,ExampleEndpointSuccessResponse:()=>Ffu,ExampleEnumType:()=>S_u,ExampleError:()=>Llu,ExampleExtraObjectProperty:()=>M_u,ExampleHeader:()=>FAn,ExampleInlinedRequestBody:()=>jfa,ExampleInlinedRequestBodyExtraProperty:()=>qfu,ExampleInlinedRequestBodyProperty:()=>Tfu,ExampleKeyValuePair:()=>D_u,ExampleListContainer:()=>A_u,ExampleLiteralContainer:()=>O_u,ExampleMapContainer:()=>P_u,ExampleNamedType:()=>B_u,ExampleNullableContainer:()=>j_u,ExampleObjectProperty:()=>$fa,ExampleObjectType:()=>Jfa,ExampleObjectTypeWithTypeId:()=>I_u,ExampleOptionalContainer:()=>w_u,ExamplePathParameter:()=>c2i,ExamplePrimitive:()=>Kfa,ExampleQueryParameter:()=>Pfa,ExampleQueryParameterShape:()=>Cfu,ExampleRequestBody:()=>Rfu,ExampleResponse:()=>Qfu,ExampleServerSideEvent:()=>Nfu,ExampleSetContainer:()=>E_u,ExampleSingleUnionType:()=>C_u,ExampleSingleUnionTypeProperties:()=>q_u,ExampleStyle:()=>xdu,ExampleType:()=>xka,ExampleTypeReference:()=>xf,ExampleTypeReferenceShape:()=>T_u,ExampleTypeShape:()=>Vfa,ExampleUndiscriminatedUnionType:()=>R_u,ExampleUnionBaseProperty:()=>N_u,ExampleUnionType:()=>z_u,ExampleWebSocketMessage:()=>Xpu,ExampleWebSocketMessageBody:()=>Ypu,ExampleWebSocketSession:()=>Zpu,ExampleWebhookCall:()=>Lpu,FeatureId:()=>Uka,FernFilepath:()=>RDe,FileDownloadResponse:()=>Dfa,FileProperty:()=>Yfu,FilePropertyArray:()=>$fu,FilePropertySingle:()=>Jfu,FileUploadBodyProperty:()=>Zfu,FileUploadBodyPropertyEncoding:()=>Xfu,FileUploadRequest:()=>Ifa,FileUploadRequestProperty:()=>kfu,Filesystem:()=>Zdu,FloatType:()=>_pu,FloatValidationRules:()=>ppu,GenerationMetadata:()=>Gdu,GithubPublish:()=>kdu,GrpcTransport:()=>idu,HeaderApiVersionScheme:()=>Udu,HeaderAuthScheme:()=>ncu,HeaderAuthValues:()=>Glu,HttpEndpoint:()=>qdu,HttpEndpointSecurityItem:()=>ndu,HttpEndpointSource:()=>udu,HttpHeader:()=>cU,HttpMethod:()=>sdu,HttpPath:()=>NDe,HttpPathPart:()=>cdu,HttpRequestBody:()=>Tfa,HttpRequestBodyReference:()=>qfa,HttpResponse:()=>l2i,HttpResponseBody:()=>vdu,HttpService:()=>zdu,InferredAuthScheme:()=>scu,InferredAuthSchemeTokenEndpoint:()=>ucu,InferredAuthenticatedRequestHeader:()=>ocu,InlinedRequestBody:()=>ldu,InlinedRequestBodyProperty:()=>Bfa,InlinedWebSocketMessageBody:()=>e_u,InlinedWebSocketMessageBodyProperty:()=>kpu,InlinedWebhookPayload:()=>Gpu,InlinedWebhookPayloadProperty:()=>xpu,IntegerType:()=>ypu,IntegerValidationRules:()=>hpu,IntermediateRepresentation:()=>_rh,JsonEncoding:()=>Tdu,JsonResponse:()=>Rfa,JsonResponseBody:()=>fdu,JsonResponseBodyWithProperty:()=>ddu,JsonStreamChunk:()=>pdu,Literal:()=>y_u,LongType:()=>vpu,LongValidationRules:()=>bpu,MapType:()=>b_u,MavenPublishTarget:()=>Kdu,MultipleBaseUrlsEnvironment:()=>Rlu,MultipleBaseUrlsEnvironments:()=>zlu,MultipleEnvironmentUrlValues:()=>Hlu,Name:()=>so,NameAndWireValue:()=>Ol,NamedType:()=>Q_u,NamedTypeDefault:()=>F_u,NonStreamHttpResponseBody:()=>ydu,NpmPublishTarget:()=>$du,OAuthAccessTokenRequestProperties:()=>dcu,OAuthAccessTokenResponseProperties:()=>afa,OAuthClientCredentials:()=>_cu,OAuthConfiguration:()=>hcu,OAuthRefreshEndpoint:()=>fcu,OAuthRefreshTokenRequestProperties:()=>lcu,OAuthScheme:()=>ycu,OAuthTokenEndpoint:()=>pcu,OAuthValues:()=>Klu,ObjectProperty:()=>j7,ObjectPropertyAccess:()=>e2i,ObjectTypeDeclaration:()=>Ipu,OffsetPagination:()=>gdu,Package:()=>Hfa,PackageNavigationConfig:()=>u_u,Pagination:()=>Odu,PathParameter:()=>B5t,PathParameterLocation:()=>mdu,PlatformHeaders:()=>f_u,PostmanPublishTarget:()=>Jdu,PrimitiveType:()=>Wfa,PrimitiveTypeV1:()=>apu,PrimitiveTypeV2:()=>Epu,PropertyPathItem:()=>nfa,ProtoEncoding:()=>Rdu,ProtoSource:()=>Fdu,ProtoSourceInfo:()=>odu,ProtobufFile:()=>Cfa,ProtobufFileOptions:()=>tdu,ProtobufMethodType:()=>adu,ProtobufService:()=>rdu,ProtobufType:()=>ipu,PublishTarget:()=>f2i,PublishingConfig:()=>epu,PypiPublishTarget:()=>Ydu,QueryParameter:()=>t2i,ReadmeConfig:()=>c_u,ReadmeCustomSection:()=>s_u,RequestProperty:()=>P5,RequestPropertyValue:()=>ccu,ResolvedNamedType:()=>Mpu,ResolvedTypeReference:()=>Dpu,ResponseError:()=>Adu,ResponseErrors:()=>Pdu,ResponseProperty:()=>sU,RetriesConfiguration:()=>wdu,RetriesDisabledSchema:()=>jdu,SafeAndUnsafeString:()=>zAn,SdkConfig:()=>d_u,SdkRequest:()=>Ddu,SdkRequestBodyType:()=>Edu,SdkRequestShape:()=>Mdu,SdkRequestWrapper:()=>Sdu,ServiceId:()=>G2t,ServiceTypeReferenceInfo:()=>p_u,ShapeType:()=>Spu,SingleBaseUrlEnvironment:()=>Nlu,SingleBaseUrlEnvironments:()=>Flu,SingleUnionType:()=>zpu,SingleUnionTypeProperties:()=>Rpu,SingleUnionTypeProperty:()=>Tpu,Source:()=>npu,SourceConfig:()=>__u,SseStreamChunk:()=>_du,StreamParameterResponse:()=>bdu,StreamingResponse:()=>zfa,StringType:()=>Opu,StringValidationRules:()=>gpu,Subpackage:()=>h_u,SubpackageId:()=>H2t,SupportedSdkLanguage:()=>Mfa,TextResponse:()=>Nfa,TextStreamChunk:()=>hdu,Transport:()=>Qfa,Type:()=>Fpu,TypeDeclaration:()=>Qpu,TypeId:()=>S3,TypeReference:()=>Ys,Uint64Type:()=>Apu,Uint64ValidationRules:()=>mpu,UintType:()=>jpu,UintValidationRules:()=>Ppu,UndiscriminatedUnionMember:()=>Cpu,UndiscriminatedUnionTypeDeclaration:()=>qpu,UnionTypeDeclaration:()=>Npu,UserAgent:()=>l_u,UserDefinedProtobufType:()=>tpu,UserSpecifiedEndpointExample:()=>Bdu,UuidType:()=>wpu,V2AuthValues:()=>dfa,V2EndpointLocation:()=>Jlu,V2EndpointLocationHttpMethod:()=>$lu,V2EnvironmentValues:()=>pfa,V2HttpEndpointCodeSample:()=>Ylu,V2HttpEndpointExample:()=>Lka,V2HttpEndpointExamples:()=>efu,V2HttpEndpointRequest:()=>Xlu,V2HttpEndpointResponse:()=>klu,V2HttpEndpointResponseBody:()=>Zlu,V2HttpRequestBodies:()=>Idu,V2HttpResponses:()=>Cdu,V2SchemaExample:()=>Qka,V2SchemaExamples:()=>uU,V2ValueExamples:()=>Z2t,V2WebSocketEndpointLocation:()=>rfu,V2WebSocketMessageExample:()=>ifu,V2WebSocketSessionExample:()=>Wka,V2WebSocketSessionExamples:()=>nfu,V2WebhookExample:()=>Vka,V2WebhookExamples:()=>tfu,VariableDeclaration:()=>Upu,VariableId:()=>Ffa,WebSocketChannel:()=>o_u,WebSocketChannelId:()=>ufa,WebSocketMessage:()=>n_u,WebSocketMessageBody:()=>r_u,WebSocketMessageBodyReference:()=>t_u,WebSocketMessageId:()=>Gfa,WebSocketMessageOrigin:()=>i_u,WebSocketName:()=>a_u,Webhook:()=>$pu,WebhookGroup:()=>Jpu,WebhookGroupId:()=>ofa,WebhookHttpMethod:()=>Vpu,WebhookId:()=>Acu,WebhookName:()=>Wpu,WebhookPayload:()=>Kpu,WebhookPayloadReference:()=>Hpu,WellKnownProtobufType:()=>rpu,WithContentType:()=>zDe,WithDocs:()=>pa,WithDocsAndAvailability:()=>n2i,WithJsonExample:()=>$2t,WithV2Examples:()=>OS,audience:()=>N9c,auth:()=>F9c,commons:()=>Q9c,constants:()=>U9c,dynamic:()=>GD,environment:()=>X9c,errors:()=>Z9c,examples:()=>k9c,generatorExec:()=>tHc,http:()=>rHc,ir:()=>iHc,proto:()=>nHc,publish:()=>aHc,types:()=>oHc,variables:()=>uHc,webhooks:()=>sHc,websocket:()=>cHc});var N9c={};$t(N9c,{AudienceDefinition:()=>tcu,AudienceReference:()=>rfa});var D={};$t(D,{JsonError:()=>kla,ParseError:()=>efa,any:()=>Jth,bigint:()=>zth,boolean:()=>Yth,booleanLiteral:()=>Kth,date:()=>Nth,discriminant:()=>orh,enum_:()=>Zsu,getObjectLikeUtils:()=>D5t,getObjectUtils:()=>RAn,getSchemaUtils:()=>AP,isProperty:()=>ZZi,lazy:()=>Fth,lazyObject:()=>Gth,list:()=>ecu,never:()=>Xth,number:()=>Zth,object:()=>ksu,objectWithoutOptionalProperties:()=>xth,optional:()=>q9c,property:()=>Uth,record:()=>rrh,set:()=>irh,string:()=>kth,stringLiteral:()=>$th,transform:()=>T9c,undiscriminatedUnion:()=>arh,union:()=>srh,unknown:()=>erh,withParsedProperties:()=>z9c});var up={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function QA(e,t){return`Expected ${t}. Received ${AND(e)}.`}function AND(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function aU(e){return{...e,json:Rth(e.json),parse:Rth(e.parse)}}function Rth(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1435
|
+
`)}var Tka=class extends Error{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};function f9c(e){return e.scheme==="oauth"}var tND={optional:"optional",nullable:"nullable",set:"set",list:"list",map:"map",literal:"literal"},cth=new Set(Object.values(tND));function HB(e){let t=e.match(/([\w.]+)<([\w,\s]+)>/);if(t?.[0]!=null&&t[1]!=null&&t[2]!=null&&!cth.has(t[1].trim()))return{name:t[1].trim(),arguments:t[2].split(",").map(r=>r.trim())}}function MDe(e){return HB(e)!=null}function d9c(e){if(e.request!=null)return typeof e.request=="string"?e.request:e.request.body}var k3i=class{REFERENCE_REGEX=/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/;validate(t){return this.REFERENCE_REGEX.test(t)?{type:"valid"}:{type:"invalid"}}tryParse(t){if(this.validate(t).type==="invalid")return;let i=t.match(this.REFERENCE_REGEX);if(!(i==null||i[1]==null||i[2]==null))return{method:i[1],path:i[2]}}};function AE(e){return typeof e=="string"?!1:e?.extends!=null||e?.properties!=null}function L2t(e){return e?e.proto!=null:!1}var rND="text";function KZi(e){return e===rND}var Br={};$t(Br,{ApiDefinitionSource:()=>MZ,ApiVersionScheme:()=>XZi,AuthScheme:()=>mP,AuthSchemesRequirement:()=>vN,AvailabilityStatus:()=>nR,ContainerType:()=>Js,Environments:()=>xD,ErrorDeclarationDiscriminantValue:()=>YZi,ErrorDiscriminationStrategy:()=>Rme,ExampleCodeSample:()=>qme,ExampleContainer:()=>S_,ExampleEndpointSuccessResponse:()=>PE,ExamplePrimitive:()=>Xn,ExampleQueryParameterShape:()=>gN,ExampleRequestBody:()=>O5,ExampleResponse:()=>Zw,ExampleSingleUnionTypeProperties:()=>Qq,ExampleStyle:()=>$su,ExampleTypeReferenceShape:()=>as,ExampleTypeShape:()=>ib,ExampleWebSocketMessageBody:()=>zme,FileProperty:()=>EZ,FileUploadBodyPropertyEncoding:()=>Rka,FileUploadRequestProperty:()=>oR,HttpEndpointSource:()=>m5,HttpMethod:()=>jE,HttpRequestBody:()=>FA,HttpResponseBody:()=>op,JsonResponse:()=>Nq,Literal:()=>rU,NamedTypeDefault:()=>Zla,NonStreamHttpResponseBody:()=>j3,OAuthConfiguration:()=>$Zi,ObjectPropertyAccess:()=>x2t,Pagination:()=>A5,PathParameterLocation:()=>BDe,PrimitiveTypeV1:()=>Ps,PrimitiveTypeV2:()=>Cn,ProtobufMethodType:()=>S5t,ProtobufType:()=>rb,PublishTarget:()=>Fq,PublishingConfig:()=>W2t,RequestPropertyValue:()=>SZ,ResolvedTypeReference:()=>w3,SdkRequestBodyType:()=>E5t,SdkRequestShape:()=>IDe,ShapeType:()=>M5t,SingleUnionTypeProperties:()=>iU,Source:()=>eWi,StreamingResponse:()=>qC,SupportedSdkLanguage:()=>Tme,Transport:()=>CDe,Type:()=>Jl,TypeReference:()=>_i,V2AuthValues:()=>DDe,V2EndpointLocationHttpMethod:()=>V2t,V2HttpEndpointResponseBody:()=>aR,WebSocketMessageBody:()=>E3,WebSocketMessageOrigin:()=>Ysu,WebhookHttpMethod:()=>Jsu,WebhookPayload:()=>nU,WellKnownProtobufType:()=>In,audience:()=>lth,auth:()=>p9c,commons:()=>_9c,constants:()=>fth,dynamic:()=>er,environment:()=>A9c,errors:()=>P9c,examples:()=>j9c,generatorExec:()=>zl,http:()=>E9c,ir:()=>S9c,proto:()=>M9c,publish:()=>D9c,types:()=>B9c,variables:()=>Tth,webhooks:()=>I9c,websocket:()=>C9c});var lth={};var p9c={};$t(p9c,{AuthScheme:()=>mP,AuthSchemesRequirement:()=>vN,OAuthConfiguration:()=>$Zi});var mP={bearer:e=>({...e,type:"bearer",_visit:function(t){return mP._visit(this,t)}}),basic:e=>({...e,type:"basic",_visit:function(t){return mP._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return mP._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return mP._visit(this,t)}}),inferred:e=>({...e,type:"inferred",_visit:function(t){return mP._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"bearer":return t.bearer(e);case"basic":return t.basic(e);case"header":return t.header(e);case"oauth":return t.oauth(e);case"inferred":return t.inferred(e);default:return t._other(e)}}};var iND={All:"ALL",Any:"ANY",EndpointSecurity:"ENDPOINT_SECURITY"},vN={...iND,_visit:(e,t)=>{switch(e){case vN.All:return t.all();case vN.Any:return t.any();case vN.EndpointSecurity:return t.endpointSecurity();default:return t._other()}}};var $Zi={clientCredentials:e=>({...e,type:"clientCredentials",_visit:function(t){return $Zi._visit(this,t)}}),_visit:(e,t)=>e.type==="clientCredentials"?t.clientCredentials(e):t._other(e)};var _9c={};$t(_9c,{AvailabilityStatus:()=>nR});var nND={InDevelopment:"IN_DEVELOPMENT",PreRelease:"PRE_RELEASE",GeneralAvailability:"GENERAL_AVAILABILITY",Deprecated:"DEPRECATED"},nR={...nND,_visit:(e,t)=>{switch(e){case nR.InDevelopment:return t.inDevelopment();case nR.PreRelease:return t.preRelease();case nR.GeneralAvailability:return t.generalAvailability();case nR.Deprecated:return t.deprecated();default:return t._other()}}};var fth={};var er={};$t(er,{Auth:()=>dth,AuthValues:()=>pth,Environments:()=>mth,ErrorSeverity:()=>Gsu,FileUploadRequestBodyProperty:()=>yth,GeneratorOutputConfig:()=>Ath,HttpMethod:()=>JZi,InlinedRequestBody:()=>bth,LiteralType:()=>jth,NamedType:()=>wth,ObjectPropertyAccess:()=>Hsu,PrimitiveTypeV1:()=>P7,PublishInfo:()=>Pth,ReferencedRequestBodyType:()=>vth,Request:()=>gth,Response:()=>Oth,SingleDiscriminatedUnionType:()=>Eth,TypeReference:()=>Sth,auth:()=>h9c,commons:()=>_th,declaration:()=>hth,endpoints:()=>y9c,environment:()=>b9c,http:()=>v9c,ir:()=>g9c,snippets:()=>O9c,types:()=>m9c,variables:()=>Mth});var h9c={};$t(h9c,{Auth:()=>dth,AuthValues:()=>pth});var dth={basic:e=>({...e,type:"basic",_visit:function(t){return er.Auth._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return er.Auth._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return er.Auth._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return er.Auth._visit(this,t)}}),inferred:e=>({...e,type:"inferred",_visit:function(t){return er.Auth._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"oauth":return t.oauth(e);case"inferred":return t.inferred(e);default:return t._other(e)}}};var pth={basic:e=>({...e,type:"basic",_visit:function(t){return er.AuthValues._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return er.AuthValues._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return er.AuthValues._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return er.AuthValues._visit(this,t)}}),inferred:e=>({...e,type:"inferred",_visit:function(t){return er.AuthValues._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"oauth":return t.oauth(e);case"inferred":return t.inferred(e);default:return t._other(e)}}};var _th={};var hth={};var y9c={};$t(y9c,{FileUploadRequestBodyProperty:()=>yth,InlinedRequestBody:()=>bth,ReferencedRequestBodyType:()=>vth,Request:()=>gth,Response:()=>Oth});var yth={file:e=>({...e,type:"file",_visit:function(t){return er.FileUploadRequestBodyProperty._visit(this,t)}}),fileArray:e=>({...e,type:"fileArray",_visit:function(t){return er.FileUploadRequestBodyProperty._visit(this,t)}}),bodyProperty:e=>({...e,type:"bodyProperty",_visit:function(t){return er.FileUploadRequestBodyProperty._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"fileArray":return t.fileArray(e);case"bodyProperty":return t.bodyProperty(e);default:return t._other(e)}}};var bth={properties:e=>({value:e,type:"properties",_visit:function(t){return er.InlinedRequestBody._visit(this,t)}}),referenced:e=>({...e,type:"referenced",_visit:function(t){return er.InlinedRequestBody._visit(this,t)}}),fileUpload:e=>({...e,type:"fileUpload",_visit:function(t){return er.InlinedRequestBody._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"properties":return t.properties(e.value);case"referenced":return t.referenced(e);case"fileUpload":return t.fileUpload(e);default:return t._other(e)}}};var vth={bytes:()=>({type:"bytes",_visit:function(e){return er.ReferencedRequestBodyType._visit(this,e)}}),typeReference:e=>({value:e,type:"typeReference",_visit:function(t){return er.ReferencedRequestBodyType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"bytes":return t.bytes();case"typeReference":return t.typeReference(e.value);default:return t._other(e)}}};var gth={body:e=>({...e,type:"body",_visit:function(t){return er.Request._visit(this,t)}}),inlined:e=>({...e,type:"inlined",_visit:function(t){return er.Request._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"body":return t.body(e);case"inlined":return t.inlined(e);default:return t._other(e)}}};var Oth={json:()=>({type:"json",_visit:function(e){return er.Response._visit(this,e)}}),streaming:()=>({type:"streaming",_visit:function(e){return er.Response._visit(this,e)}}),streamParameter:()=>({type:"streamParameter",_visit:function(e){return er.Response._visit(this,e)}}),fileDownload:()=>({type:"fileDownload",_visit:function(e){return er.Response._visit(this,e)}}),text:()=>({type:"text",_visit:function(e){return er.Response._visit(this,e)}}),bytes:()=>({type:"bytes",_visit:function(e){return er.Response._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json();case"streaming":return t.streaming();case"streamParameter":return t.streamParameter();case"fileDownload":return t.fileDownload();case"text":return t.text();case"bytes":return t.bytes();default:return t._other(e)}}};var b9c={};$t(b9c,{Environments:()=>mth});var mth={singleBaseUrl:e=>({...e,type:"singleBaseUrl",_visit:function(t){return er.Environments._visit(this,t)}}),multipleBaseUrls:e=>({...e,type:"multipleBaseUrls",_visit:function(t){return er.Environments._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"singleBaseUrl":return t.singleBaseUrl(e);case"multipleBaseUrls":return t.multipleBaseUrls(e);default:return t._other(e)}}};var v9c={};$t(v9c,{HttpMethod:()=>JZi});var aND={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD"},JZi={...aND,_visit:(e,t)=>{switch(e){case JZi.Get:return t.get();case JZi.Post:return t.post();case JZi.Put:return t.put();case JZi.Patch:return t.patch();case JZi.Delete:return t.delete();case JZi.Head:return t.head();default:return t._other()}}};var g9c={};$t(g9c,{GeneratorOutputConfig:()=>Ath,PublishInfo:()=>Pth});var Ath={publish:e=>({value:e,type:"publish",_visit:function(t){return er.GeneratorOutputConfig._visit(this,t)}}),local:()=>({type:"local",_visit:function(e){return er.GeneratorOutputConfig._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"publish":return t.publish(e.value);case"local":return t.local();default:return t._other(e)}}};var Pth={go:e=>({...e,type:"go",_visit:function(t){return er.PublishInfo._visit(this,t)}}),swift:e=>({...e,type:"swift",_visit:function(t){return er.PublishInfo._visit(this,t)}}),maven:e=>({...e,type:"maven",_visit:function(t){return er.PublishInfo._visit(this,t)}}),npm:e=>({...e,type:"npm",_visit:function(t){return er.PublishInfo._visit(this,t)}}),nuget:e=>({...e,type:"nuget",_visit:function(t){return er.PublishInfo._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return er.PublishInfo._visit(this,t)}}),rubygems:e=>({...e,type:"rubygems",_visit:function(t){return er.PublishInfo._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return er.PublishInfo._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"go":return t.go(e);case"swift":return t.swift(e);case"maven":return t.maven(e);case"npm":return t.npm(e);case"nuget":return t.nuget(e);case"pypi":return t.pypi(e);case"rubygems":return t.rubygems(e);case"crates":return t.crates(e);default:return t._other(e)}}};var O9c={};$t(O9c,{ErrorSeverity:()=>Gsu});var oND={Critical:"CRITICAL",Warning:"WARNING"},Gsu={...oND,_visit:(e,t)=>{switch(e){case Gsu.Critical:return t.critical();case Gsu.Warning:return t.warning();default:return t._other()}}};var m9c={};$t(m9c,{LiteralType:()=>jth,NamedType:()=>wth,ObjectPropertyAccess:()=>Hsu,PrimitiveTypeV1:()=>P7,SingleDiscriminatedUnionType:()=>Eth,TypeReference:()=>Sth});var jth={boolean:e=>({value:e,type:"boolean",_visit:function(t){return er.LiteralType._visit(this,t)}}),string:e=>({value:e,type:"string",_visit:function(t){return er.LiteralType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"boolean":return t.boolean(e.value);case"string":return t.string(e.value);default:return t._other(e)}}};var wth={alias:e=>({...e,type:"alias",_visit:function(t){return er.NamedType._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return er.NamedType._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return er.NamedType._visit(this,t)}}),discriminatedUnion:e=>({...e,type:"discriminatedUnion",_visit:function(t){return er.NamedType._visit(this,t)}}),undiscriminatedUnion:e=>({...e,type:"undiscriminatedUnion",_visit:function(t){return er.NamedType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"alias":return t.alias(e);case"enum":return t.enum(e);case"object":return t.object(e);case"discriminatedUnion":return t.discriminatedUnion(e);case"undiscriminatedUnion":return t.undiscriminatedUnion(e);default:return t._other(e)}}};var uND={ReadOnly:"READ_ONLY",WriteOnly:"WRITE_ONLY"},Hsu={...uND,_visit:(e,t)=>{switch(e){case Hsu.ReadOnly:return t.readOnly();case Hsu.WriteOnly:return t.writeOnly();default:return t._other()}}};var sND={Integer:"INTEGER",Long:"LONG",Uint:"UINT",Uint64:"UINT_64",Float:"FLOAT",Double:"DOUBLE",Boolean:"BOOLEAN",String:"STRING",Date:"DATE",DateTime:"DATE_TIME",Uuid:"UUID",Base64:"BASE_64",BigInteger:"BIG_INTEGER"},P7={...sND,_visit:(e,t)=>{switch(e){case P7.Integer:return t.integer();case P7.Long:return t.long();case P7.Uint:return t.uint();case P7.Uint64:return t.uint64();case P7.Float:return t.float();case P7.Double:return t.double();case P7.Boolean:return t.boolean();case P7.String:return t.string();case P7.Date:return t.date();case P7.DateTime:return t.dateTime();case P7.Uuid:return t.uuid();case P7.Base64:return t.base64();case P7.BigInteger:return t.bigInteger();default:return t._other()}}};var Eth={samePropertiesAsObject:e=>({...e,type:"samePropertiesAsObject",_visit:function(t){return er.SingleDiscriminatedUnionType._visit(this,t)}}),singleProperty:e=>({...e,type:"singleProperty",_visit:function(t){return er.SingleDiscriminatedUnionType._visit(this,t)}}),noProperties:e=>({...e,type:"noProperties",_visit:function(t){return er.SingleDiscriminatedUnionType._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"samePropertiesAsObject":return t.samePropertiesAsObject(e);case"singleProperty":return t.singleProperty(e);case"noProperties":return t.noProperties(e);default:return t._other(e)}}};var Sth={list:e=>({value:e,type:"list",_visit:function(t){return er.TypeReference._visit(this,t)}}),literal:e=>({value:e,type:"literal",_visit:function(t){return er.TypeReference._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return er.TypeReference._visit(this,t)}}),named:e=>({value:e,type:"named",_visit:function(t){return er.TypeReference._visit(this,t)}}),nullable:e=>({value:e,type:"nullable",_visit:function(t){return er.TypeReference._visit(this,t)}}),optional:e=>({value:e,type:"optional",_visit:function(t){return er.TypeReference._visit(this,t)}}),primitive:e=>({value:e,type:"primitive",_visit:function(t){return er.TypeReference._visit(this,t)}}),set:e=>({value:e,type:"set",_visit:function(t){return er.TypeReference._visit(this,t)}}),unknown:()=>({type:"unknown",_visit:function(e){return er.TypeReference._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"list":return t.list(e.value);case"literal":return t.literal(e.value);case"map":return t.map(e);case"named":return t.named(e.value);case"nullable":return t.nullable(e.value);case"optional":return t.optional(e.value);case"primitive":return t.primitive(e.value);case"set":return t.set(e.value);case"unknown":return t.unknown();default:return t._other(e)}}};var Mth={};var A9c={};$t(A9c,{Environments:()=>xD});var xD={singleBaseUrl:e=>({...e,type:"singleBaseUrl",_visit:function(t){return xD._visit(this,t)}}),multipleBaseUrls:e=>({...e,type:"multipleBaseUrls",_visit:function(t){return xD._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"singleBaseUrl":return t.singleBaseUrl(e);case"multipleBaseUrls":return t.multipleBaseUrls(e);default:return t._other(e)}}};var P9c={};$t(P9c,{ErrorDeclarationDiscriminantValue:()=>YZi});var YZi={property:e=>({...e,type:"property",_visit:function(t){return YZi._visit(this,t)}}),statusCode:()=>({type:"statusCode",_visit:function(e){return YZi._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"property":return t.property(e);case"statusCode":return t.statusCode();default:return t._other(e)}}};var j9c={};$t(j9c,{V2AuthValues:()=>DDe,V2EndpointLocationHttpMethod:()=>V2t,V2HttpEndpointResponseBody:()=>aR});var DDe={basic:e=>({...e,type:"basic",_visit:function(t){return DDe._visit(this,t)}}),bearer:e=>({...e,type:"bearer",_visit:function(t){return DDe._visit(this,t)}}),header:e=>({...e,type:"header",_visit:function(t){return DDe._visit(this,t)}}),oauth:e=>({...e,type:"oauth",_visit:function(t){return DDe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"bearer":return t.bearer(e);case"header":return t.header(e);case"oauth":return t.oauth(e);default:return t._other(e)}}};var cND={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD"},V2t={...cND,_visit:(e,t)=>{switch(e){case V2t.Get:return t.get();case V2t.Post:return t.post();case V2t.Put:return t.put();case V2t.Patch:return t.patch();case V2t.Delete:return t.delete();case V2t.Head:return t.head();default:return t._other()}}};var aR={error:e=>({value:e,type:"error",_visit:function(t){return aR._visit(this,t)}}),json:e=>({value:e,type:"json",_visit:function(t){return aR._visit(this,t)}}),stream:e=>({value:e,type:"stream",_visit:function(t){return aR._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"error":return t.error(e.value);case"json":return t.json(e.value);case"stream":return t.stream(e.value);default:return t._other(e)}}};var zl={};$t(zl,{GeneratorEnvironment:()=>Dth,GeneratorPublishTarget:()=>Bth,GithubPublishInfo:()=>Ith,LicenseConfig:()=>Cth,LicenseId:()=>Ksu,OutputMode:()=>qth,config:()=>w9c});var w9c={};$t(w9c,{GeneratorEnvironment:()=>Dth,GeneratorPublishTarget:()=>Bth,GithubPublishInfo:()=>Ith,LicenseConfig:()=>Cth,LicenseId:()=>Ksu,OutputMode:()=>qth});var Dth={local:()=>({type:"local",_visit:function(e){return zl.GeneratorEnvironment._visit(this,e)}}),remote:e=>({...e,type:"remote",_visit:function(t){return zl.GeneratorEnvironment._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"local":return t.local();case"remote":return t.remote(e);default:return t._other(e)}}};var Bth={maven:e=>({...e,type:"maven",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),npm:e=>({...e,type:"npm",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),postman:e=>({...e,type:"postman",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),rubygems:e=>({...e,type:"rubygems",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),nuget:e=>({...e,type:"nuget",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return zl.GeneratorPublishTarget._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"maven":return t.maven(e);case"npm":return t.npm(e);case"pypi":return t.pypi(e);case"postman":return t.postman(e);case"rubygems":return t.rubygems(e);case"nuget":return t.nuget(e);case"crates":return t.crates(e);default:return t._other(e)}}};var Ith={npm:e=>({...e,type:"npm",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),maven:e=>({...e,type:"maven",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),postman:e=>({...e,type:"postman",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),rubygems:e=>({...e,type:"rubygems",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),nuget:e=>({...e,type:"nuget",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return zl.GithubPublishInfo._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"npm":return t.npm(e);case"maven":return t.maven(e);case"postman":return t.postman(e);case"pypi":return t.pypi(e);case"rubygems":return t.rubygems(e);case"nuget":return t.nuget(e);case"crates":return t.crates(e);default:return t._other(e)}}};var Cth={basic:e=>({...e,type:"basic",_visit:function(t){return zl.LicenseConfig._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return zl.LicenseConfig._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"basic":return t.basic(e);case"custom":return t.custom(e);default:return t._other(e)}}};var lND={Mit:"MIT",Apache2:"Apache-2.0"},Ksu={...lND,_visit:(e,t)=>{switch(e){case Ksu.Mit:return t.mit();case Ksu.Apache2:return t.apache2();default:return t._other()}}};var qth={publish:e=>({...e,type:"publish",_visit:function(t){return zl.OutputMode._visit(this,t)}}),downloadFiles:()=>({type:"downloadFiles",_visit:function(e){return zl.OutputMode._visit(this,e)}}),github:e=>({...e,type:"github",_visit:function(t){return zl.OutputMode._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"publish":return t.publish(e);case"downloadFiles":return t.downloadFiles();case"github":return t.github(e);default:return t._other(e)}}};var E9c={};$t(E9c,{ExampleCodeSample:()=>qme,ExampleEndpointSuccessResponse:()=>PE,ExampleQueryParameterShape:()=>gN,ExampleRequestBody:()=>O5,ExampleResponse:()=>Zw,FileProperty:()=>EZ,FileUploadBodyPropertyEncoding:()=>Rka,FileUploadRequestProperty:()=>oR,HttpEndpointSource:()=>m5,HttpMethod:()=>jE,HttpRequestBody:()=>FA,HttpResponseBody:()=>op,JsonResponse:()=>Nq,NonStreamHttpResponseBody:()=>j3,Pagination:()=>A5,PathParameterLocation:()=>BDe,RequestPropertyValue:()=>SZ,SdkRequestBodyType:()=>E5t,SdkRequestShape:()=>IDe,StreamingResponse:()=>qC,SupportedSdkLanguage:()=>Tme,Transport:()=>CDe});var qme={language:e=>({...e,type:"language",_visit:function(t){return qme._visit(this,t)}}),sdk:e=>({...e,type:"sdk",_visit:function(t){return qme._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"language":return t.language(e);case"sdk":return t.sdk(e);default:return t._other(e)}}};var PE={body:e=>({value:e,type:"body",_visit:function(t){return PE._visit(this,t)}}),stream:e=>({value:e,type:"stream",_visit:function(t){return PE._visit(this,t)}}),sse:e=>({value:e,type:"sse",_visit:function(t){return PE._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"body":return t.body(e.value);case"stream":return t.stream(e.value);case"sse":return t.sse(e.value);default:return t._other(e)}}};var gN={single:()=>({type:"single",_visit:function(e){return gN._visit(this,e)}}),exploded:()=>({type:"exploded",_visit:function(e){return gN._visit(this,e)}}),commaSeparated:()=>({type:"commaSeparated",_visit:function(e){return gN._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"single":return t.single();case"exploded":return t.exploded();case"commaSeparated":return t.commaSeparated();default:return t._other(e)}}};var O5={inlinedRequestBody:e=>({...e,type:"inlinedRequestBody",_visit:function(t){return O5._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return O5._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedRequestBody":return t.inlinedRequestBody(e);case"reference":return t.reference(e);default:return t._other(e)}}};var Zw={ok:e=>({value:e,type:"ok",_visit:function(t){return Zw._visit(this,t)}}),error:e=>({...e,type:"error",_visit:function(t){return Zw._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"ok":return t.ok(e.value);case"error":return t.error(e);default:return t._other(e)}}};var EZ={file:e=>({...e,type:"file",_visit:function(t){return EZ._visit(this,t)}}),fileArray:e=>({...e,type:"fileArray",_visit:function(t){return EZ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e);case"fileArray":return t.fileArray(e);default:return t._other(e)}}};var fND={Exploded:"exploded",Json:"json",Form:"form"},Rka={...fND,_visit:(e,t)=>{switch(e){case Rka.Exploded:return t.exploded();case Rka.Json:return t.json();case Rka.Form:return t.form();default:return t._other()}}};var oR={file:e=>({value:e,type:"file",_visit:function(t){return oR._visit(this,t)}}),bodyProperty:e=>({...e,type:"bodyProperty",_visit:function(t){return oR._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"file":return t.file(e.value);case"bodyProperty":return t.bodyProperty(e);default:return t._other(e)}}};var m5={proto:e=>({...e,type:"proto",_visit:function(t){return m5._visit(this,t)}}),openapi:()=>({type:"openapi",_visit:function(e){return m5._visit(this,e)}}),openrpc:()=>({type:"openrpc",_visit:function(e){return m5._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"proto":return t.proto(e);case"openapi":return t.openapi();case"openrpc":return t.openrpc();default:return t._other(e)}}};var dND={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Head:"HEAD"},jE={...dND,_visit:(e,t)=>{switch(e){case jE.Get:return t.get();case jE.Post:return t.post();case jE.Put:return t.put();case jE.Patch:return t.patch();case jE.Delete:return t.delete();case jE.Head:return t.head();default:return t._other()}}};var FA={inlinedRequestBody:e=>({...e,type:"inlinedRequestBody",_visit:function(t){return FA._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return FA._visit(this,t)}}),fileUpload:e=>({...e,type:"fileUpload",_visit:function(t){return FA._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return FA._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedRequestBody":return t.inlinedRequestBody(e);case"reference":return t.reference(e);case"fileUpload":return t.fileUpload(e);case"bytes":return t.bytes(e);default:return t._other(e)}}};var op={json:e=>({value:e,type:"json",_visit:function(t){return op._visit(this,t)}}),fileDownload:e=>({...e,type:"fileDownload",_visit:function(t){return op._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return op._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return op._visit(this,t)}}),streaming:e=>({value:e,type:"streaming",_visit:function(t){return op._visit(this,t)}}),streamParameter:e=>({...e,type:"streamParameter",_visit:function(t){return op._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json(e.value);case"fileDownload":return t.fileDownload(e);case"text":return t.text(e);case"bytes":return t.bytes(e);case"streaming":return t.streaming(e.value);case"streamParameter":return t.streamParameter(e);default:return t._other(e)}}};var Nq={response:e=>({...e,type:"response",_visit:function(t){return Nq._visit(this,t)}}),nestedPropertyAsResponse:e=>({...e,type:"nestedPropertyAsResponse",_visit:function(t){return Nq._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"response":return t.response(e);case"nestedPropertyAsResponse":return t.nestedPropertyAsResponse(e);default:return t._other(e)}}};var j3={json:e=>({value:e,type:"json",_visit:function(t){return j3._visit(this,t)}}),fileDownload:e=>({...e,type:"fileDownload",_visit:function(t){return j3._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return j3._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return j3._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json(e.value);case"fileDownload":return t.fileDownload(e);case"text":return t.text(e);case"bytes":return t.bytes(e);default:return t._other(e)}}};var A5={cursor:e=>({...e,type:"cursor",_visit:function(t){return A5._visit(this,t)}}),offset:e=>({...e,type:"offset",_visit:function(t){return A5._visit(this,t)}}),custom:e=>({...e,type:"custom",_visit:function(t){return A5._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"cursor":return t.cursor(e);case"offset":return t.offset(e);case"custom":return t.custom(e);default:return t._other(e)}}};var pND={Root:"ROOT",Service:"SERVICE",Endpoint:"ENDPOINT"},BDe={...pND,_visit:(e,t)=>{switch(e){case BDe.Root:return t.root();case BDe.Service:return t.service();case BDe.Endpoint:return t.endpoint();default:return t._other()}}};var SZ={query:e=>({...e,type:"query",_visit:function(t){return SZ._visit(this,t)}}),body:e=>({...e,type:"body",_visit:function(t){return SZ._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"query":return t.query(e);case"body":return t.body(e);default:return t._other(e)}}};var E5t={typeReference:e=>({...e,type:"typeReference",_visit:function(t){return E5t._visit(this,t)}}),bytes:e=>({...e,type:"bytes",_visit:function(t){return E5t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"typeReference":return t.typeReference(e);case"bytes":return t.bytes(e);default:return t._other(e)}}};var IDe={justRequestBody:e=>({value:e,type:"justRequestBody",_visit:function(t){return IDe._visit(this,t)}}),wrapper:e=>({...e,type:"wrapper",_visit:function(t){return IDe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"justRequestBody":return t.justRequestBody(e.value);case"wrapper":return t.wrapper(e);default:return t._other(e)}}};var qC={json:e=>({...e,type:"json",_visit:function(t){return qC._visit(this,t)}}),text:e=>({...e,type:"text",_visit:function(t){return qC._visit(this,t)}}),sse:e=>({...e,type:"sse",_visit:function(t){return qC._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"json":return t.json(e);case"text":return t.text(e);case"sse":return t.sse(e);default:return t._other(e)}}};var _ND={Curl:"curl",Python:"python",Javascript:"javascript",Typescript:"typescript",Go:"go",Ruby:"ruby",Csharp:"csharp",Java:"java",Php:"php",Rust:"rust",Swift:"swift"},Tme={..._ND,_visit:(e,t)=>{switch(e){case Tme.Curl:return t.curl();case Tme.Python:return t.python();case Tme.Javascript:return t.javascript();case Tme.Typescript:return t.typescript();case Tme.Go:return t.go();case Tme.Ruby:return t.ruby();case Tme.Csharp:return t.csharp();case Tme.Java:return t.java();case Tme.Php:return t.php();case Tme.Rust:return t.rust();case Tme.Swift:return t.swift();default:return t._other()}}};var CDe={http:()=>({type:"http",_visit:function(e){return CDe._visit(this,e)}}),grpc:e=>({...e,type:"grpc",_visit:function(t){return CDe._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"http":return t.http();case"grpc":return t.grpc(e);default:return t._other(e)}}};var S9c={};$t(S9c,{ApiDefinitionSource:()=>MZ,ApiVersionScheme:()=>XZi,ErrorDiscriminationStrategy:()=>Rme,ExampleStyle:()=>$su});var MZ={proto:e=>({...e,type:"proto",_visit:function(t){return MZ._visit(this,t)}}),openapi:()=>({type:"openapi",_visit:function(e){return MZ._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"proto":return t.proto(e);case"openapi":return t.openapi();default:return t._other(e)}}};var XZi={header:e=>({...e,type:"header",_visit:function(t){return XZi._visit(this,t)}}),_visit:(e,t)=>e.type==="header"?t.header(e):t._other(e)};var Rme={statusCode:()=>({type:"statusCode",_visit:function(e){return Rme._visit(this,e)}}),property:e=>({...e,type:"property",_visit:function(t){return Rme._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"statusCode":return t.statusCode();case"property":return t.property(e);default:return t._other(e)}}};var hND={Minimal:"minimal",Comprehensive:"comprehensive"},$su={...hND,_visit:(e,t)=>{switch(e){case $su.Minimal:return t.minimal();case $su.Comprehensive:return t.comprehensive();default:return t._other()}}};var M9c={};$t(M9c,{ProtobufMethodType:()=>S5t,ProtobufType:()=>rb,WellKnownProtobufType:()=>In});var yND={Unary:"UNARY",ClientStream:"CLIENT_STREAM",ServerStream:"SERVER_STREAM",BidirectionalStream:"BIDIRECTIONAL_STREAM"},S5t={...yND,_visit:(e,t)=>{switch(e){case S5t.Unary:return t.unary();case S5t.ClientStream:return t.clientStream();case S5t.ServerStream:return t.serverStream();case S5t.BidirectionalStream:return t.bidirectionalStream();default:return t._other()}}};var rb={wellKnown:e=>({value:e,type:"wellKnown",_visit:function(t){return rb._visit(this,t)}}),userDefined:e=>({...e,type:"userDefined",_visit:function(t){return rb._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"wellKnown":return t.wellKnown(e.value);case"userDefined":return t.userDefined(e);default:return t._other(e)}}};var In={any:()=>({type:"any",_visit:function(e){return In._visit(this,e)}}),api:()=>({type:"api",_visit:function(e){return In._visit(this,e)}}),boolValue:()=>({type:"boolValue",_visit:function(e){return In._visit(this,e)}}),bytesValue:()=>({type:"bytesValue",_visit:function(e){return In._visit(this,e)}}),doubleValue:()=>({type:"doubleValue",_visit:function(e){return In._visit(this,e)}}),duration:()=>({type:"duration",_visit:function(e){return In._visit(this,e)}}),empty:()=>({type:"empty",_visit:function(e){return In._visit(this,e)}}),enum:()=>({type:"enum",_visit:function(e){return In._visit(this,e)}}),enumValue:()=>({type:"enumValue",_visit:function(e){return In._visit(this,e)}}),field:()=>({type:"field",_visit:function(e){return In._visit(this,e)}}),fieldCardinality:()=>({type:"fieldCardinality",_visit:function(e){return In._visit(this,e)}}),fieldKind:()=>({type:"fieldKind",_visit:function(e){return In._visit(this,e)}}),fieldMask:()=>({type:"fieldMask",_visit:function(e){return In._visit(this,e)}}),floatValue:()=>({type:"floatValue",_visit:function(e){return In._visit(this,e)}}),int32Value:()=>({type:"int32Value",_visit:function(e){return In._visit(this,e)}}),int64Value:()=>({type:"int64Value",_visit:function(e){return In._visit(this,e)}}),listValue:()=>({type:"listValue",_visit:function(e){return In._visit(this,e)}}),method:()=>({type:"method",_visit:function(e){return In._visit(this,e)}}),mixin:()=>({type:"mixin",_visit:function(e){return In._visit(this,e)}}),nullValue:()=>({type:"nullValue",_visit:function(e){return In._visit(this,e)}}),option:()=>({type:"option",_visit:function(e){return In._visit(this,e)}}),sourceContext:()=>({type:"sourceContext",_visit:function(e){return In._visit(this,e)}}),stringValue:()=>({type:"stringValue",_visit:function(e){return In._visit(this,e)}}),struct:()=>({type:"struct",_visit:function(e){return In._visit(this,e)}}),syntax:()=>({type:"syntax",_visit:function(e){return In._visit(this,e)}}),timestamp:()=>({type:"timestamp",_visit:function(e){return In._visit(this,e)}}),type:()=>({type:"type",_visit:function(e){return In._visit(this,e)}}),uint32Value:()=>({type:"uint32Value",_visit:function(e){return In._visit(this,e)}}),uint64Value:()=>({type:"uint64Value",_visit:function(e){return In._visit(this,e)}}),value:()=>({type:"value",_visit:function(e){return In._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"any":return t.any();case"api":return t.api();case"boolValue":return t.boolValue();case"bytesValue":return t.bytesValue();case"doubleValue":return t.doubleValue();case"duration":return t.duration();case"empty":return t.empty();case"enum":return t.enum();case"enumValue":return t.enumValue();case"field":return t.field();case"fieldCardinality":return t.fieldCardinality();case"fieldKind":return t.fieldKind();case"fieldMask":return t.fieldMask();case"floatValue":return t.floatValue();case"int32Value":return t.int32Value();case"int64Value":return t.int64Value();case"listValue":return t.listValue();case"method":return t.method();case"mixin":return t.mixin();case"nullValue":return t.nullValue();case"option":return t.option();case"sourceContext":return t.sourceContext();case"stringValue":return t.stringValue();case"struct":return t.struct();case"syntax":return t.syntax();case"timestamp":return t.timestamp();case"type":return t.type();case"uint32Value":return t.uint32Value();case"uint64Value":return t.uint64Value();case"value":return t.value();default:return t._other(e)}}};var D9c={};$t(D9c,{PublishTarget:()=>Fq,PublishingConfig:()=>W2t});var W2t={github:e=>({...e,type:"github",_visit:function(t){return W2t._visit(this,t)}}),direct:e=>({...e,type:"direct",_visit:function(t){return W2t._visit(this,t)}}),filesystem:e=>({...e,type:"filesystem",_visit:function(t){return W2t._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"github":return t.github(e);case"direct":return t.direct(e);case"filesystem":return t.filesystem(e);default:return t._other(e)}}};var Fq={postman:e=>({...e,type:"postman",_visit:function(t){return Fq._visit(this,t)}}),npm:e=>({...e,type:"npm",_visit:function(t){return Fq._visit(this,t)}}),maven:e=>({...e,type:"maven",_visit:function(t){return Fq._visit(this,t)}}),pypi:e=>({...e,type:"pypi",_visit:function(t){return Fq._visit(this,t)}}),crates:e=>({...e,type:"crates",_visit:function(t){return Fq._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"postman":return t.postman(e);case"npm":return t.npm(e);case"maven":return t.maven(e);case"pypi":return t.pypi(e);case"crates":return t.crates(e);default:return t._other(e)}}};var B9c={};$t(B9c,{ContainerType:()=>Js,ExampleContainer:()=>S_,ExamplePrimitive:()=>Xn,ExampleSingleUnionTypeProperties:()=>Qq,ExampleTypeReferenceShape:()=>as,ExampleTypeShape:()=>ib,Literal:()=>rU,NamedTypeDefault:()=>Zla,ObjectPropertyAccess:()=>x2t,PrimitiveTypeV1:()=>Ps,PrimitiveTypeV2:()=>Cn,ResolvedTypeReference:()=>w3,ShapeType:()=>M5t,SingleUnionTypeProperties:()=>iU,Source:()=>eWi,Type:()=>Jl,TypeReference:()=>_i});var Js={list:e=>({list:e,type:"list",_visit:function(t){return Js._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return Js._visit(this,t)}}),nullable:e=>({nullable:e,type:"nullable",_visit:function(t){return Js._visit(this,t)}}),optional:e=>({optional:e,type:"optional",_visit:function(t){return Js._visit(this,t)}}),set:e=>({set:e,type:"set",_visit:function(t){return Js._visit(this,t)}}),literal:e=>({literal:e,type:"literal",_visit:function(t){return Js._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"list":return t.list(e.list);case"map":return t.map(e);case"nullable":return t.nullable(e.nullable);case"optional":return t.optional(e.optional);case"set":return t.set(e.set);case"literal":return t.literal(e.literal);default:return t._other(e)}}};var S_={list:e=>({...e,type:"list",_visit:function(t){return S_._visit(this,t)}}),set:e=>({...e,type:"set",_visit:function(t){return S_._visit(this,t)}}),optional:e=>({...e,type:"optional",_visit:function(t){return S_._visit(this,t)}}),nullable:e=>({...e,type:"nullable",_visit:function(t){return S_._visit(this,t)}}),map:e=>({...e,type:"map",_visit:function(t){return S_._visit(this,t)}}),literal:e=>({...e,type:"literal",_visit:function(t){return S_._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"list":return t.list(e);case"set":return t.set(e);case"optional":return t.optional(e);case"nullable":return t.nullable(e);case"map":return t.map(e);case"literal":return t.literal(e);default:return t._other(e)}}};var Xn={integer:e=>({integer:e,type:"integer",_visit:function(t){return Xn._visit(this,t)}}),long:e=>({long:e,type:"long",_visit:function(t){return Xn._visit(this,t)}}),uint:e=>({uint:e,type:"uint",_visit:function(t){return Xn._visit(this,t)}}),uint64:e=>({uint64:e,type:"uint64",_visit:function(t){return Xn._visit(this,t)}}),float:e=>({float:e,type:"float",_visit:function(t){return Xn._visit(this,t)}}),double:e=>({double:e,type:"double",_visit:function(t){return Xn._visit(this,t)}}),boolean:e=>({boolean:e,type:"boolean",_visit:function(t){return Xn._visit(this,t)}}),string:e=>({string:e,type:"string",_visit:function(t){return Xn._visit(this,t)}}),date:e=>({date:e,type:"date",_visit:function(t){return Xn._visit(this,t)}}),datetime:e=>({...e,type:"datetime",_visit:function(t){return Xn._visit(this,t)}}),uuid:e=>({uuid:e,type:"uuid",_visit:function(t){return Xn._visit(this,t)}}),base64:e=>({base64:e,type:"base64",_visit:function(t){return Xn._visit(this,t)}}),bigInteger:e=>({bigInteger:e,type:"bigInteger",_visit:function(t){return Xn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"integer":return t.integer(e.integer);case"long":return t.long(e.long);case"uint":return t.uint(e.uint);case"uint64":return t.uint64(e.uint64);case"float":return t.float(e.float);case"double":return t.double(e.double);case"boolean":return t.boolean(e.boolean);case"string":return t.string(e.string);case"date":return t.date(e.date);case"datetime":return t.datetime(e);case"uuid":return t.uuid(e.uuid);case"base64":return t.base64(e.base64);case"bigInteger":return t.bigInteger(e.bigInteger);default:return t._other(e)}}};var Qq={samePropertiesAsObject:e=>({...e,type:"samePropertiesAsObject",_visit:function(t){return Qq._visit(this,t)}}),singleProperty:e=>({...e,type:"singleProperty",_visit:function(t){return Qq._visit(this,t)}}),noProperties:()=>({type:"noProperties",_visit:function(e){return Qq._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"samePropertiesAsObject":return t.samePropertiesAsObject(e);case"singleProperty":return t.singleProperty(e);case"noProperties":return t.noProperties();default:return t._other(e)}}};var as={primitive:e=>({primitive:e,type:"primitive",_visit:function(t){return as._visit(this,t)}}),container:e=>({container:e,type:"container",_visit:function(t){return as._visit(this,t)}}),unknown:e=>({unknown:e,type:"unknown",_visit:function(t){return as._visit(this,t)}}),named:e=>({...e,type:"named",_visit:function(t){return as._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"primitive":return t.primitive(e.primitive);case"container":return t.container(e.container);case"unknown":return t.unknown(e.unknown);case"named":return t.named(e);default:return t._other(e)}}};var ib={alias:e=>({...e,type:"alias",_visit:function(t){return ib._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return ib._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return ib._visit(this,t)}}),union:e=>({...e,type:"union",_visit:function(t){return ib._visit(this,t)}}),undiscriminatedUnion:e=>({...e,type:"undiscriminatedUnion",_visit:function(t){return ib._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"alias":return t.alias(e);case"enum":return t.enum(e);case"object":return t.object(e);case"union":return t.union(e);case"undiscriminatedUnion":return t.undiscriminatedUnion(e);default:return t._other(e)}}};var rU={string:e=>({string:e,type:"string",_visit:function(t){return rU._visit(this,t)}}),boolean:e=>({boolean:e,type:"boolean",_visit:function(t){return rU._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"string":return t.string(e.string);case"boolean":return t.boolean(e.boolean);default:return t._other(e)}}};var Zla={enum:e=>({...e,type:"enum",_visit:function(t){return Zla._visit(this,t)}}),_visit:(e,t)=>e.type==="enum"?t.enum(e):t._other(e)};var bND={ReadOnly:"READ_ONLY",WriteOnly:"WRITE_ONLY"},x2t={...bND,_visit:(e,t)=>{switch(e){case x2t.ReadOnly:return t.readOnly();case x2t.WriteOnly:return t.writeOnly();default:return t._other()}}};var vND={Integer:"INTEGER",Long:"LONG",Uint:"UINT",Uint64:"UINT_64",Float:"FLOAT",Double:"DOUBLE",Boolean:"BOOLEAN",String:"STRING",Date:"DATE",DateTime:"DATE_TIME",Uuid:"UUID",Base64:"BASE_64",BigInteger:"BIG_INTEGER"},Ps={...vND,_visit:(e,t)=>{switch(e){case Ps.Integer:return t.integer();case Ps.Long:return t.long();case Ps.Uint:return t.uint();case Ps.Uint64:return t.uint64();case Ps.Float:return t.float();case Ps.Double:return t.double();case Ps.Boolean:return t.boolean();case Ps.String:return t.string();case Ps.Date:return t.date();case Ps.DateTime:return t.dateTime();case Ps.Uuid:return t.uuid();case Ps.Base64:return t.base64();case Ps.BigInteger:return t.bigInteger();default:return t._other()}}};var Cn={integer:e=>({...e,type:"integer",_visit:function(t){return Cn._visit(this,t)}}),long:e=>({...e,type:"long",_visit:function(t){return Cn._visit(this,t)}}),uint:e=>({...e,type:"uint",_visit:function(t){return Cn._visit(this,t)}}),uint64:e=>({...e,type:"uint64",_visit:function(t){return Cn._visit(this,t)}}),float:e=>({...e,type:"float",_visit:function(t){return Cn._visit(this,t)}}),double:e=>({...e,type:"double",_visit:function(t){return Cn._visit(this,t)}}),boolean:e=>({...e,type:"boolean",_visit:function(t){return Cn._visit(this,t)}}),string:e=>({...e,type:"string",_visit:function(t){return Cn._visit(this,t)}}),date:e=>({...e,type:"date",_visit:function(t){return Cn._visit(this,t)}}),dateTime:e=>({...e,type:"dateTime",_visit:function(t){return Cn._visit(this,t)}}),uuid:e=>({...e,type:"uuid",_visit:function(t){return Cn._visit(this,t)}}),base64:e=>({...e,type:"base64",_visit:function(t){return Cn._visit(this,t)}}),bigInteger:e=>({...e,type:"bigInteger",_visit:function(t){return Cn._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"integer":return t.integer(e);case"long":return t.long(e);case"uint":return t.uint(e);case"uint64":return t.uint64(e);case"float":return t.float(e);case"double":return t.double(e);case"boolean":return t.boolean(e);case"string":return t.string(e);case"date":return t.date(e);case"dateTime":return t.dateTime(e);case"uuid":return t.uuid(e);case"base64":return t.base64(e);case"bigInteger":return t.bigInteger(e);default:return t._other(e)}}};var w3={container:e=>({container:e,type:"container",_visit:function(t){return w3._visit(this,t)}}),named:e=>({...e,type:"named",_visit:function(t){return w3._visit(this,t)}}),primitive:e=>({primitive:e,type:"primitive",_visit:function(t){return w3._visit(this,t)}}),unknown:()=>({type:"unknown",_visit:function(e){return w3._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"container":return t.container(e.container);case"named":return t.named(e);case"primitive":return t.primitive(e.primitive);case"unknown":return t.unknown();default:return t._other(e)}}};var gND={Enum:"ENUM",Object:"OBJECT",Union:"UNION",UndiscriminatedUnion:"UNDISCRIMINATED_UNION"},M5t={...gND,_visit:(e,t)=>{switch(e){case M5t.Enum:return t.enum();case M5t.Object:return t.object();case M5t.Union:return t.union();case M5t.UndiscriminatedUnion:return t.undiscriminatedUnion();default:return t._other()}}};var iU={samePropertiesAsObject:e=>({...e,propertiesType:"samePropertiesAsObject",_visit:function(t){return iU._visit(this,t)}}),singleProperty:e=>({...e,propertiesType:"singleProperty",_visit:function(t){return iU._visit(this,t)}}),noProperties:()=>({propertiesType:"noProperties",_visit:function(e){return iU._visit(this,e)}}),_visit:(e,t)=>{switch(e.propertiesType){case"samePropertiesAsObject":return t.samePropertiesAsObject(e);case"singleProperty":return t.singleProperty(e);case"noProperties":return t.noProperties();default:return t._other(e)}}};var eWi={proto:e=>({value:e,type:"proto",_visit:function(t){return eWi._visit(this,t)}}),_visit:(e,t)=>e.type==="proto"?t.proto(e.value):t._other(e)};var Jl={alias:e=>({...e,type:"alias",_visit:function(t){return Jl._visit(this,t)}}),enum:e=>({...e,type:"enum",_visit:function(t){return Jl._visit(this,t)}}),object:e=>({...e,type:"object",_visit:function(t){return Jl._visit(this,t)}}),union:e=>({...e,type:"union",_visit:function(t){return Jl._visit(this,t)}}),undiscriminatedUnion:e=>({...e,type:"undiscriminatedUnion",_visit:function(t){return Jl._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"alias":return t.alias(e);case"enum":return t.enum(e);case"object":return t.object(e);case"union":return t.union(e);case"undiscriminatedUnion":return t.undiscriminatedUnion(e);default:return t._other(e)}}};var _i={container:e=>({container:e,type:"container",_visit:function(t){return _i._visit(this,t)}}),named:e=>({...e,type:"named",_visit:function(t){return _i._visit(this,t)}}),primitive:e=>({primitive:e,type:"primitive",_visit:function(t){return _i._visit(this,t)}}),unknown:()=>({type:"unknown",_visit:function(e){return _i._visit(this,e)}}),_visit:(e,t)=>{switch(e.type){case"container":return t.container(e.container);case"named":return t.named(e);case"primitive":return t.primitive(e.primitive);case"unknown":return t.unknown();default:return t._other(e)}}};var Tth={};var I9c={};$t(I9c,{WebhookHttpMethod:()=>Jsu,WebhookPayload:()=>nU});var OND={Get:"GET",Post:"POST"},Jsu={...OND,_visit:(e,t)=>{switch(e){case Jsu.Get:return t.get();case Jsu.Post:return t.post();default:return t._other()}}};var nU={inlinedPayload:e=>({...e,type:"inlinedPayload",_visit:function(t){return nU._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return nU._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedPayload":return t.inlinedPayload(e);case"reference":return t.reference(e);default:return t._other(e)}}};var C9c={};$t(C9c,{ExampleWebSocketMessageBody:()=>zme,WebSocketMessageBody:()=>E3,WebSocketMessageOrigin:()=>Ysu});var zme={inlinedBody:e=>({...e,type:"inlinedBody",_visit:function(t){return zme._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return zme._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedBody":return t.inlinedBody(e);case"reference":return t.reference(e);default:return t._other(e)}}};var E3={inlinedBody:e=>({...e,type:"inlinedBody",_visit:function(t){return E3._visit(this,t)}}),reference:e=>({...e,type:"reference",_visit:function(t){return E3._visit(this,t)}}),_visit:(e,t)=>{switch(e.type){case"inlinedBody":return t.inlinedBody(e);case"reference":return t.reference(e);default:return t._other(e)}}};var mND={Client:"client",Server:"server"},Ysu={...mND,_visit:(e,t)=>{switch(e){case Ysu.Client:return t.client();case Ysu.Server:return t.server();default:return t._other()}}};var sa={};$t(sa,{AliasTypeDeclaration:()=>Bpu,ApiAuth:()=>gcu,ApiDefinitionSource:()=>Qdu,ApiDefinitionSourceId:()=>Ndu,ApiVersionScheme:()=>Ldu,AudienceDefinition:()=>tcu,AudienceReference:()=>rfa,AuthScheme:()=>bcu,AuthSchemeKey:()=>ifa,AuthSchemesRequirement:()=>vcu,AuthScope:()=>Ocu,AutogeneratedEndpointExample:()=>Ufu,Availability:()=>K2t,AvailabilityStatus:()=>acu,Base64Type:()=>opu,BaseAuthScheme:()=>qDe,BasicAuthScheme:()=>rcu,BasicAuthValues:()=>Wlu,BearerAuthScheme:()=>icu,BearerAuthValues:()=>xlu,BigIntegerType:()=>upu,BooleanType:()=>spu,BytesRequest:()=>Efa,BytesResponse:()=>Sfa,Constants:()=>Pcu,ContainerType:()=>xfa,CratesPublishTarget:()=>Hdu,CsharpProtobufFileOptions:()=>edu,CursorPagination:()=>Lfu,CustomPagination:()=>Vfu,DateTimeType:()=>cpu,DateType:()=>lpu,Declaration:()=>uR,DeclaredErrorName:()=>s2i,DeclaredServiceName:()=>Wfu,DeclaredTypeName:()=>mS,DirectPublish:()=>Xdu,DisplayName:()=>r2i,DoubleType:()=>dpu,DoubleValidationRules:()=>fpu,Encoding:()=>Ufa,EndpointId:()=>rWi,EndpointName:()=>xfu,EndpointReference:()=>kZi,EnumTypeDeclaration:()=>Lfa,EnumTypeReference:()=>hrh,EnumValue:()=>iWi,EnvironmentBaseUrlId:()=>Nme,EnvironmentBaseUrlWithId:()=>Tlu,EnvironmentId:()=>X2t,EnvironmentUrl:()=>u2i,EnvironmentVariable:()=>TDe,Environments:()=>Qlu,EnvironmentsConfig:()=>Ulu,ErrorDeclaration:()=>Vlu,ErrorDeclarationDiscriminantValue:()=>drh,ErrorDiscriminationByPropertyStrategy:()=>Vdu,ErrorDiscriminationStrategy:()=>Wdu,ErrorId:()=>i2i,EscapedString:()=>mcu,ExampleAliasType:()=>v_u,ExampleCodeSample:()=>Kfu,ExampleCodeSampleLanguage:()=>Gfu,ExampleCodeSampleSdk:()=>Hfu,ExampleContainer:()=>m_u,ExampleDatetime:()=>g_u,ExampleEndpointCall:()=>wfa,ExampleEndpointErrorResponse:()=>zfu,ExampleEndpointSuccessResponse:()=>Ffu,ExampleEnumType:()=>S_u,ExampleError:()=>Llu,ExampleExtraObjectProperty:()=>M_u,ExampleHeader:()=>FAn,ExampleInlinedRequestBody:()=>jfa,ExampleInlinedRequestBodyExtraProperty:()=>qfu,ExampleInlinedRequestBodyProperty:()=>Tfu,ExampleKeyValuePair:()=>D_u,ExampleListContainer:()=>A_u,ExampleLiteralContainer:()=>O_u,ExampleMapContainer:()=>P_u,ExampleNamedType:()=>B_u,ExampleNullableContainer:()=>j_u,ExampleObjectProperty:()=>$fa,ExampleObjectType:()=>Jfa,ExampleObjectTypeWithTypeId:()=>I_u,ExampleOptionalContainer:()=>w_u,ExamplePathParameter:()=>c2i,ExamplePrimitive:()=>Kfa,ExampleQueryParameter:()=>Pfa,ExampleQueryParameterShape:()=>Cfu,ExampleRequestBody:()=>Rfu,ExampleResponse:()=>Qfu,ExampleServerSideEvent:()=>Nfu,ExampleSetContainer:()=>E_u,ExampleSingleUnionType:()=>C_u,ExampleSingleUnionTypeProperties:()=>q_u,ExampleStyle:()=>xdu,ExampleType:()=>xka,ExampleTypeReference:()=>xf,ExampleTypeReferenceShape:()=>T_u,ExampleTypeShape:()=>Vfa,ExampleUndiscriminatedUnionType:()=>R_u,ExampleUnionBaseProperty:()=>N_u,ExampleUnionType:()=>z_u,ExampleWebSocketMessage:()=>Xpu,ExampleWebSocketMessageBody:()=>Ypu,ExampleWebSocketSession:()=>Zpu,ExampleWebhookCall:()=>Lpu,FeatureId:()=>Uka,FernFilepath:()=>RDe,FileDownloadResponse:()=>Dfa,FileProperty:()=>Yfu,FilePropertyArray:()=>$fu,FilePropertySingle:()=>Jfu,FileUploadBodyProperty:()=>Zfu,FileUploadBodyPropertyEncoding:()=>Xfu,FileUploadRequest:()=>Ifa,FileUploadRequestProperty:()=>kfu,Filesystem:()=>Zdu,FloatType:()=>_pu,FloatValidationRules:()=>ppu,GenerationMetadata:()=>Gdu,GithubPublish:()=>kdu,GrpcTransport:()=>idu,HeaderApiVersionScheme:()=>Udu,HeaderAuthScheme:()=>ncu,HeaderAuthValues:()=>Glu,HttpEndpoint:()=>qdu,HttpEndpointSecurityItem:()=>ndu,HttpEndpointSource:()=>udu,HttpHeader:()=>cU,HttpMethod:()=>sdu,HttpPath:()=>NDe,HttpPathPart:()=>cdu,HttpRequestBody:()=>Tfa,HttpRequestBodyReference:()=>qfa,HttpResponse:()=>l2i,HttpResponseBody:()=>vdu,HttpService:()=>zdu,InferredAuthScheme:()=>scu,InferredAuthSchemeTokenEndpoint:()=>ucu,InferredAuthenticatedRequestHeader:()=>ocu,InlinedRequestBody:()=>ldu,InlinedRequestBodyProperty:()=>Bfa,InlinedWebSocketMessageBody:()=>e_u,InlinedWebSocketMessageBodyProperty:()=>kpu,InlinedWebhookPayload:()=>Gpu,InlinedWebhookPayloadProperty:()=>xpu,IntegerType:()=>ypu,IntegerValidationRules:()=>hpu,IntermediateRepresentation:()=>_rh,JsonEncoding:()=>Tdu,JsonResponse:()=>Rfa,JsonResponseBody:()=>fdu,JsonResponseBodyWithProperty:()=>ddu,JsonStreamChunk:()=>pdu,Literal:()=>y_u,LongType:()=>vpu,LongValidationRules:()=>bpu,MapType:()=>b_u,MavenPublishTarget:()=>Kdu,MultipleBaseUrlsEnvironment:()=>Rlu,MultipleBaseUrlsEnvironments:()=>zlu,MultipleEnvironmentUrlValues:()=>Hlu,Name:()=>so,NameAndWireValue:()=>Ol,NamedType:()=>Q_u,NamedTypeDefault:()=>F_u,NonStreamHttpResponseBody:()=>ydu,NpmPublishTarget:()=>$du,OAuthAccessTokenRequestProperties:()=>dcu,OAuthAccessTokenResponseProperties:()=>afa,OAuthClientCredentials:()=>_cu,OAuthConfiguration:()=>hcu,OAuthRefreshEndpoint:()=>fcu,OAuthRefreshTokenRequestProperties:()=>lcu,OAuthScheme:()=>ycu,OAuthTokenEndpoint:()=>pcu,OAuthValues:()=>Klu,ObjectProperty:()=>j7,ObjectPropertyAccess:()=>e2i,ObjectTypeDeclaration:()=>Ipu,OffsetPagination:()=>gdu,Package:()=>Hfa,PackageNavigationConfig:()=>u_u,Pagination:()=>Odu,PathParameter:()=>B5t,PathParameterLocation:()=>mdu,PlatformHeaders:()=>f_u,PostmanPublishTarget:()=>Jdu,PrimitiveType:()=>Wfa,PrimitiveTypeV1:()=>apu,PrimitiveTypeV2:()=>Epu,PropertyPathItem:()=>nfa,ProtoEncoding:()=>Rdu,ProtoSource:()=>Fdu,ProtoSourceInfo:()=>odu,ProtobufFile:()=>Cfa,ProtobufFileOptions:()=>tdu,ProtobufMethodType:()=>adu,ProtobufService:()=>rdu,ProtobufType:()=>ipu,PublishTarget:()=>f2i,PublishingConfig:()=>epu,PypiPublishTarget:()=>Ydu,QueryParameter:()=>t2i,ReadmeConfig:()=>c_u,ReadmeCustomSection:()=>s_u,RequestProperty:()=>P5,RequestPropertyValue:()=>ccu,ResolvedNamedType:()=>Mpu,ResolvedTypeReference:()=>Dpu,ResponseError:()=>Adu,ResponseErrors:()=>Pdu,ResponseProperty:()=>sU,RetriesConfiguration:()=>wdu,RetriesDisabledSchema:()=>jdu,SafeAndUnsafeString:()=>zAn,SdkConfig:()=>d_u,SdkRequest:()=>Ddu,SdkRequestBodyType:()=>Edu,SdkRequestShape:()=>Mdu,SdkRequestWrapper:()=>Sdu,ServiceId:()=>G2t,ServiceTypeReferenceInfo:()=>p_u,ShapeType:()=>Spu,SingleBaseUrlEnvironment:()=>Nlu,SingleBaseUrlEnvironments:()=>Flu,SingleUnionType:()=>zpu,SingleUnionTypeProperties:()=>Rpu,SingleUnionTypeProperty:()=>Tpu,Source:()=>npu,SourceConfig:()=>__u,SseStreamChunk:()=>_du,StreamParameterResponse:()=>bdu,StreamingResponse:()=>zfa,StringType:()=>Opu,StringValidationRules:()=>gpu,Subpackage:()=>h_u,SubpackageId:()=>H2t,SupportedSdkLanguage:()=>Mfa,TextResponse:()=>Nfa,TextStreamChunk:()=>hdu,Transport:()=>Qfa,Type:()=>Fpu,TypeDeclaration:()=>Qpu,TypeId:()=>S3,TypeReference:()=>Ys,Uint64Type:()=>Apu,Uint64ValidationRules:()=>mpu,UintType:()=>jpu,UintValidationRules:()=>Ppu,UndiscriminatedUnionMember:()=>Cpu,UndiscriminatedUnionTypeDeclaration:()=>qpu,UnionTypeDeclaration:()=>Npu,UserAgent:()=>l_u,UserDefinedProtobufType:()=>tpu,UserSpecifiedEndpointExample:()=>Bdu,UuidType:()=>wpu,V2AuthValues:()=>dfa,V2EndpointLocation:()=>Jlu,V2EndpointLocationHttpMethod:()=>$lu,V2EnvironmentValues:()=>pfa,V2HttpEndpointCodeSample:()=>Ylu,V2HttpEndpointExample:()=>Lka,V2HttpEndpointExamples:()=>efu,V2HttpEndpointRequest:()=>Xlu,V2HttpEndpointResponse:()=>klu,V2HttpEndpointResponseBody:()=>Zlu,V2HttpRequestBodies:()=>Idu,V2HttpResponses:()=>Cdu,V2SchemaExample:()=>Qka,V2SchemaExamples:()=>uU,V2ValueExamples:()=>Z2t,V2WebSocketEndpointLocation:()=>rfu,V2WebSocketMessageExample:()=>ifu,V2WebSocketSessionExample:()=>Wka,V2WebSocketSessionExamples:()=>nfu,V2WebhookExample:()=>Vka,V2WebhookExamples:()=>tfu,VariableDeclaration:()=>Upu,VariableId:()=>Ffa,WebSocketChannel:()=>o_u,WebSocketChannelId:()=>ufa,WebSocketMessage:()=>n_u,WebSocketMessageBody:()=>r_u,WebSocketMessageBodyReference:()=>t_u,WebSocketMessageId:()=>Gfa,WebSocketMessageOrigin:()=>i_u,WebSocketName:()=>a_u,Webhook:()=>$pu,WebhookGroup:()=>Jpu,WebhookGroupId:()=>ofa,WebhookHttpMethod:()=>Vpu,WebhookId:()=>Acu,WebhookName:()=>Wpu,WebhookPayload:()=>Kpu,WebhookPayloadReference:()=>Hpu,WellKnownProtobufType:()=>rpu,WithContentType:()=>zDe,WithDocs:()=>pa,WithDocsAndAvailability:()=>n2i,WithJsonExample:()=>$2t,WithV2Examples:()=>OS,audience:()=>N9c,auth:()=>F9c,commons:()=>Q9c,constants:()=>U9c,dynamic:()=>GD,environment:()=>X9c,errors:()=>Z9c,examples:()=>k9c,generatorExec:()=>tHc,http:()=>rHc,ir:()=>iHc,proto:()=>nHc,publish:()=>aHc,types:()=>oHc,variables:()=>uHc,webhooks:()=>sHc,websocket:()=>cHc});var N9c={};$t(N9c,{AudienceDefinition:()=>tcu,AudienceReference:()=>rfa});var D={};$t(D,{JsonError:()=>kla,ParseError:()=>efa,any:()=>Jth,bigint:()=>zth,boolean:()=>Yth,booleanLiteral:()=>Kth,date:()=>Nth,discriminant:()=>orh,enum_:()=>Zsu,getObjectLikeUtils:()=>D5t,getObjectUtils:()=>RAn,getSchemaUtils:()=>AP,isProperty:()=>ZZi,lazy:()=>Fth,lazyObject:()=>Gth,list:()=>ecu,never:()=>Xth,number:()=>Zth,object:()=>ksu,objectWithoutOptionalProperties:()=>xth,optional:()=>q9c,property:()=>Uth,record:()=>rrh,set:()=>irh,string:()=>kth,stringLiteral:()=>$th,transform:()=>T9c,undiscriminatedUnion:()=>arh,union:()=>srh,unknown:()=>erh,withParsedProperties:()=>z9c});var up={BIGINT:"bigint",DATE:"date",ENUM:"enum",LIST:"list",STRING_LITERAL:"stringLiteral",BOOLEAN_LITERAL:"booleanLiteral",OBJECT:"object",ANY:"any",BOOLEAN:"boolean",NUMBER:"number",STRING:"string",UNKNOWN:"unknown",NEVER:"never",RECORD:"record",SET:"set",UNION:"union",UNDISCRIMINATED_UNION:"undiscriminatedUnion",NULLABLE:"nullable",OPTIONAL:"optional",OPTIONAL_NULLABLE:"optionalNullable"};function QA(e,t){return`Expected ${t}. Received ${AND(e)}.`}function AND(e){if(Array.isArray(e))return"list";if(e===null)return"null";if(e instanceof BigInt)return"BigInt";switch(typeof e){case"string":return`"${e}"`;case"bigint":case"number":case"boolean":case"undefined":return`${e}`}return typeof e}function aU(e){return{...e,json:Rth(e.json),parse:Rth(e.parse)}}function Rth(e){return(t,r)=>{let i=e(t,r),{skipValidation:n=!1}=r??{};return!i.ok&&n?(console.warn(["Failed to validate.",...i.errors.map(a=>" - "+(a.path.length>0?`${a.path.join(".")}: ${a.message}`:a.message))].join(`
|
|
1436
1436
|
`)),{ok:!0,value:t}):i}}function Xsu(e){return e.path.length===0?e.message:`${e.path.join(" -> ")}: ${e.message}`}var kla=class e extends Error{errors;constructor(t){super(t.map(Xsu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};var efa=class e extends Error{errors;constructor(t){super(t.map(Xsu).join("; ")),this.errors=t,Object.setPrototypeOf(this,e.prototype)}};function AP(e){return{nullable:()=>PND(e),optional:()=>q9c(e),optionalNullable:()=>jND(e),transform:t=>T9c(e,t),parseOrThrow:(t,r)=>{let i=e.parse(t,r);if(i.ok)return i.value;throw new efa(i.errors)},jsonOrThrow:(t,r)=>{let i=e.json(t,r);if(i.ok)return i.value;throw new kla(i.errors)}}}function PND(e){let t={parse:(r,i)=>r==null?{ok:!0,value:null}:e.parse(r,i),json:(r,i)=>r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>up.NULLABLE};return{...t,...AP(t)}}function q9c(e){let t={parse:(r,i)=>r==null?{ok:!0,value:void 0}:e.parse(r,i),json:(r,i)=>i?.omitUndefined&&r===void 0?{ok:!0,value:void 0}:r==null?{ok:!0,value:null}:e.json(r,i),getType:()=>up.OPTIONAL};return{...t,...AP(t)}}function jND(e){let t={parse:(r,i)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.parse(r,i),json:(r,i)=>r===void 0?{ok:!0,value:void 0}:r===null?{ok:!0,value:null}:e.json(r,i),getType:()=>up.OPTIONAL_NULLABLE};return{...t,...AP(t)}}function T9c(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);return a.ok?{ok:!0,value:t.transform(a.value)}:a},json:(i,n)=>{let a=t.untransform(i);return e.json(a,n)},getType:()=>e.getType()};return{...r,...AP(r)}}function zth(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t=="bigint"?{ok:!0,value:t}:typeof t=="number"?{ok:!0,value:BigInt(t)}:{ok:!1,errors:[{path:r,message:QA(t,"bigint | number")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="bigint"?{ok:!1,errors:[{path:r,message:QA(t,"bigint")}]}:{ok:!0,value:t},getType:()=>up.BIGINT};return{...aU(e),...AP(e)}}var wND=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function Nth(){let e={parse:(t,{breadcrumbsPrefix:r=[]}={})=>typeof t!="string"?{ok:!1,errors:[{path:r,message:QA(t,"string")}]}:wND.test(t)?{ok:!0,value:new Date(t)}:{ok:!1,errors:[{path:r,message:QA(t,"ISO 8601 date string")}]},json:(t,{breadcrumbsPrefix:r=[]}={})=>t instanceof Date?{ok:!0,value:t.toISOString()}:{ok:!1,errors:[{path:r,message:QA(t,"Date object")}]},getType:()=>up.DATE};return{...aU(e),...AP(e)}}function oU(e,t){return()=>{let r={parse:t,json:t,getType:()=>e};return{...aU(r),...AP(r)}}}function Zsu(e){let t=new Set(e);return oU(up.ENUM,(i,{allowUnrecognizedEnumValues:n,breadcrumbsPrefix:a=[]}={})=>typeof i!="string"?{ok:!1,errors:[{path:a,message:QA(i,"string")}]}:!t.has(i)&&!n?{ok:!1,errors:[{path:a,message:QA(i,"enum")}]}:{ok:!0,value:i})()}function Fth(e){let t=R9c(e);return{...t,...AP(t)}}function R9c(e){return{parse:(t,r)=>tfa(e).parse(t,r),json:(t,r)=>tfa(e).json(t,r),getType:()=>tfa(e).getType()}}function tfa(e){let t=e;return t.__zurg_memoized==null&&(t.__zurg_memoized=e()),t.__zurg_memoized}function zka(e){return Object.entries(e)}function Nka(e,t){let r=new Set(t);return Object.entries(e).reduce((i,[n,a])=>(r.has(n)&&(i[n]=a),i),{})}function tWi(e){if(typeof e!="object"||e===null)return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Fka(e){return Object.keys(e)}function Qth(e,t){let r=[],i=[];for(let n of e)t(n)?r.push(n):i.push(n);return[r,i]}function D5t(e){return{withParsedProperties:t=>z9c(e,t)}}function z9c(e,t){let r={parse:(i,n)=>{let a=e.parse(i,n);if(!a.ok)return a;let o=Object.entries(t).reduce((c,[d,s])=>({...c,[d]:typeof s=="function"?s(a.value):s}),{});return{ok:!0,value:{...a.value,...o}}},json:(i,n)=>{if(!tWi(i))return{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:QA(i,"object")}]};let a=new Set(Object.keys(t)),o=Nka(i,Object.keys(i).filter(c=>!a.has(c)));return e.json(o,n)},getType:()=>e.getType()};return{...r,...AP(r),...D5t(r)}}function Uth(e,t){return{rawKey:e,valueSchema:t,isProperty:!0}}function ZZi(e){return e.isProperty}function ksu(e){let t={_getRawProperties:()=>Object.entries(e).map(([r,i])=>ZZi(i)?i.rawKey:r),_getParsedProperties:()=>Fka(e),parse:(r,i)=>{let n={},a=[];for(let[o,c]of zka(e)){let d=ZZi(c)?c.rawKey:o,s=ZZi(c)?c.valueSchema:c,u={rawKey:d,parsedKey:o,valueSchema:s};n[d]=u,Wth(s)&&a.push(d)}return Lth({value:r,requiredKeys:a,getProperty:o=>{let c=n[o];if(c!=null)return{transformedKey:c.parsedKey,transform:d=>c.valueSchema.parse(d,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],o]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},json:(r,i)=>{let n=[];for(let[a,o]of zka(e)){let c=ZZi(o)?o.valueSchema:o;Wth(c)&&n.push(a)}return Lth({value:r,requiredKeys:n,getProperty:a=>{let o=e[a];if(o!=null)return ZZi(o)?{transformedKey:o.rawKey,transform:c=>o.valueSchema.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}:{transformedKey:a,transform:c=>o.json(c,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],a]})}},unrecognizedObjectKeys:i?.unrecognizedObjectKeys,skipValidation:i?.skipValidation,breadcrumbsPrefix:i?.breadcrumbsPrefix,omitUndefined:i?.omitUndefined})},getType:()=>up.OBJECT};return{...aU(t),...AP(t),...D5t(t),...RAn(t)}}function Lth({value:e,requiredKeys:t,getProperty:r,unrecognizedObjectKeys:i="fail",skipValidation:n=!1,breadcrumbsPrefix:a=[]}){if(!tWi(e))return{ok:!1,errors:[{path:a,message:QA(e,"object")}]};let o=new Set(t),c=[],d={};for(let[s,u]of Object.entries(e)){let f=r(s);if(f!=null){o.delete(s);let p=f.transform(u);p.ok?d[f.transformedKey]=p.value:(d[s]=u,c.push(...p.errors))}else switch(i){case"fail":c.push({path:[...a,s],message:`Unexpected key "${s}"`});break;case"strip":break;case"passthrough":d[s]=u;break}}return c.push(...t.filter(s=>o.has(s)).map(s=>({path:a,message:`Missing required key "${s}"`}))),c.length===0||n?{ok:!0,value:d}:{ok:!1,errors:c}}function RAn(e){return{extend:t=>{let r={_getParsedProperties:()=>[...e._getParsedProperties(),...t._getParsedProperties()],_getRawProperties:()=>[...e._getRawProperties(),...t._getRawProperties()],parse:(i,n)=>Vth({extensionKeys:t._getRawProperties(),value:i,transformBase:a=>e.parse(a,n),transformExtension:a=>t.parse(a,n),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>Vth({extensionKeys:t._getParsedProperties(),value:i,transformBase:a=>e.json(a,n),transformExtension:a=>t.json(a,n),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>up.OBJECT};return{...r,...AP(r),...D5t(r),...RAn(r)}},passthrough:()=>{let t=new Set(e._getRawProperties()),r=new Set(e._getParsedProperties()),i={_getParsedProperties:()=>e._getParsedProperties(),_getRawProperties:()=>e._getRawProperties(),parse:(n,a)=>{let o=e.parse(n,{...a,unrecognizedObjectKeys:"passthrough"});if(!o.ok)return o;let c={};if(typeof n=="object"&&n!=null)for(let[d,s]of Object.entries(n))t.has(d)||(c[d]=s);return{ok:!0,value:{...c,...o.value}}},json:(n,a)=>{let o=e.json(n,{...a,unrecognizedObjectKeys:"passthrough"});if(!o.ok)return o;let c={};if(typeof n=="object"&&n!=null)for(let[d,s]of Object.entries(n))r.has(d)||(c[d]=s);return{ok:!0,value:{...c,...o.value}}},getType:()=>up.OBJECT};return{...i,...AP(i),...D5t(i),...RAn(i)}}}}function Vth({extensionKeys:e,value:t,transformBase:r,transformExtension:i,breadcrumbsPrefix:n=[]}){if(!tWi(t))return{ok:!1,errors:[{path:n,message:QA(t,"object")}]};let a=new Set(e),[o,c]=Qth(Fka(t),u=>a.has(u)),d=r(Nka(t,c)),s=i(Nka(t,o));return d.ok&&s.ok?{ok:!0,value:{...d.value,...s.value}}:{ok:!1,errors:[...d.ok?[]:d.errors,...s.ok?[]:s.errors]}}function Wth(e){return!END(e)}function END(e){switch(e.getType()){case up.ANY:case up.UNKNOWN:case up.OPTIONAL:case up.OPTIONAL_NULLABLE:return!0;default:return!1}}function xth(e){return ksu(e)}function Gth(e){let t={...R9c(e),_getRawProperties:()=>tfa(e)._getRawProperties(),_getParsedProperties:()=>tfa(e)._getParsedProperties()};return{...t,...AP(t),...D5t(t),...RAn(t)}}function ecu(e){let t={parse:(r,i)=>Hth(r,(n,a)=>e.parse(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),json:(r,i)=>Hth(r,(n,a)=>e.json(n,{...i,breadcrumbsPrefix:[...i?.breadcrumbsPrefix??[],`[${a}]`]})),getType:()=>up.LIST};return{...aU(t),...AP(t)}}function Hth(e,t){return Array.isArray(e)?e.map((i,n)=>t(i,n)).reduce((i,n)=>{if(i.ok&&n.ok)return{ok:!0,value:[...i.value,n.value]};let a=[];return i.ok||a.push(...i.errors),n.ok||a.push(...n.errors),{ok:!1,errors:a}},{ok:!0,value:[]}):{ok:!1,errors:[{message:QA(e,"list"),path:[]}]}}function Kth(e){return oU(up.BOOLEAN_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:QA(r,`${e.toString()}`)}]})()}function $th(e){return oU(up.STRING_LITERAL,(r,{breadcrumbsPrefix:i=[]}={})=>r===e?{ok:!0,value:e}:{ok:!1,errors:[{path:i,message:QA(r,`"${e}"`)}]})()}var Jth=oU(up.ANY,e=>({ok:!0,value:e}));var Yth=oU(up.BOOLEAN,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:QA(e,"boolean")}]});var Xth=oU(up.NEVER,(e,{breadcrumbsPrefix:t=[]}={})=>({ok:!1,errors:[{path:t,message:"Expected never"}]}));var Zth=oU(up.NUMBER,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="number"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:QA(e,"number")}]});var kth=oU(up.STRING,(e,{breadcrumbsPrefix:t=[]}={})=>typeof e=="string"?{ok:!0,value:e}:{ok:!1,errors:[{path:t,message:QA(e,"string")}]});var erh=oU(up.UNKNOWN,e=>({ok:!0,value:e}));function rrh(e,t){let r={parse:(i,n)=>trh({value:i,isKeyNumeric:e.getType()===up.NUMBER,transformKey:a=>e.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.parse(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),json:(i,n)=>trh({value:i,isKeyNumeric:e.getType()===up.NUMBER,transformKey:a=>e.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${a} (key)`]}),transformValue:(a,o)=>t.json(a,{...n,breadcrumbsPrefix:[...n?.breadcrumbsPrefix??[],`${o}`]}),breadcrumbsPrefix:n?.breadcrumbsPrefix}),getType:()=>up.RECORD};return{...aU(r),...AP(r)}}function trh({value:e,isKeyNumeric:t,transformKey:r,transformValue:i,breadcrumbsPrefix:n=[]}){return tWi(e)?zka(e).reduce((a,[o,c])=>{if(c===void 0)return a;let d=a,s=o;if(t){let _=o.length>0?Number(o):NaN;Number.isNaN(_)||(s=_)}let u=r(s),f=i(c,s);if(d.ok&&u.ok&&f.ok)return{ok:!0,value:{...d.value,[u.value]:f.value}};let p=[];return d.ok||p.push(...d.errors),u.ok||p.push(...u.errors),f.ok||p.push(...f.errors),{ok:!1,errors:p}},{ok:!0,value:{}}):{ok:!1,errors:[{path:n,message:QA(e,"object")}]}}function irh(e){let t=ecu(e),r={parse:(i,n)=>{let a=t.parse(i,n);return a.ok?{ok:!0,value:new Set(a.value)}:a},json:(i,n)=>i instanceof Set?t.json([...i],n):{ok:!1,errors:[{path:n?.breadcrumbsPrefix??[],message:QA(i,"Set")}]},getType:()=>up.SET};return{...aU(r),...AP(r)}}function arh(e){let t={parse:(r,i)=>nrh((n,a)=>n.parse(r,a),e,i),json:(r,i)=>nrh((n,a)=>n.json(r,a),e,i),getType:()=>up.UNDISCRIMINATED_UNION};return{...aU(t),...AP(t)}}function nrh(e,t,r){let i=[];for(let[n,a]of t.entries()){let o=e(a,{...r,skipValidation:!1});if(o.ok)return o;for(let c of o.errors)i.push({path:c.path,message:`[Variant ${n}] ${c.message}`})}return{ok:!1,errors:i}}function orh(e,t){return{parsedDiscriminant:e,rawDiscriminant:t}}function srh(e,t){let r=typeof e=="string"?e:e.rawDiscriminant,i=typeof e=="string"?e:e.parsedDiscriminant,n=Zsu(Fka(t)),a={parse:(o,c)=>urh({value:o,discriminant:r,transformedDiscriminant:i,transformDiscriminantValue:d=>n.parse(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],r]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.parse(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),json:(o,c)=>urh({value:o,discriminant:i,transformedDiscriminant:r,transformDiscriminantValue:d=>n.json(d,{allowUnrecognizedEnumValues:c?.allowUnrecognizedUnionMembers,breadcrumbsPrefix:[...c?.breadcrumbsPrefix??[],i]}),getAdditionalPropertiesSchema:d=>t[d],allowUnrecognizedUnionMembers:c?.allowUnrecognizedUnionMembers,transformAdditionalProperties:(d,s)=>s.json(d,c),breadcrumbsPrefix:c?.breadcrumbsPrefix}),getType:()=>up.UNION};return{...aU(a),...AP(a),...D5t(a)}}function urh({value:e,discriminant:t,transformedDiscriminant:r,transformDiscriminantValue:i,getAdditionalPropertiesSchema:n,allowUnrecognizedUnionMembers:a=!1,transformAdditionalProperties:o,breadcrumbsPrefix:c=[]}){if(!tWi(e))return{ok:!1,errors:[{path:c,message:QA(e,"object")}]};let{[t]:d,...s}=e;if(d==null)return{ok:!1,errors:[{path:c,message:`Missing discriminant ("${t}")`}]};let u=i(d);if(!u.ok)return{ok:!1,errors:u.errors};let f=n(u.value);if(f==null)return a?{ok:!0,value:{[r]:u.value,...s}}:{ok:!1,errors:[{path:[...c,t],message:"Unexpected discriminant value"}]};let p=o(s,f);return p.ok?{ok:!0,value:{[r]:d,...p.value}}:p}var tcu=D.string();var rfa=D.string();var F9c={};$t(F9c,{ApiAuth:()=>gcu,AuthScheme:()=>bcu,AuthSchemeKey:()=>ifa,AuthSchemesRequirement:()=>vcu,AuthScope:()=>Ocu,BaseAuthScheme:()=>qDe,BasicAuthScheme:()=>rcu,BearerAuthScheme:()=>icu,EnvironmentVariable:()=>TDe,HeaderAuthScheme:()=>ncu,InferredAuthScheme:()=>scu,InferredAuthSchemeTokenEndpoint:()=>ucu,InferredAuthenticatedRequestHeader:()=>ocu,OAuthAccessTokenRequestProperties:()=>dcu,OAuthAccessTokenResponseProperties:()=>afa,OAuthClientCredentials:()=>_cu,OAuthConfiguration:()=>hcu,OAuthRefreshEndpoint:()=>fcu,OAuthRefreshTokenRequestProperties:()=>lcu,OAuthScheme:()=>ycu,OAuthTokenEndpoint:()=>pcu});var pa=D.objectWithoutOptionalProperties({docs:D.string().optional()});var zAn=D.objectWithoutOptionalProperties({unsafeName:D.string(),safeName:D.string()});var so=D.objectWithoutOptionalProperties({originalName:D.string(),camelCase:zAn,pascalCase:zAn,snakeCase:zAn,screamingSnakeCase:zAn});var ifa=D.string();var qDe=D.objectWithoutOptionalProperties({key:ifa}).extend(pa);var TDe=D.string();var rcu=D.objectWithoutOptionalProperties({username:so,usernameEnvVar:TDe.optional(),usernameOmit:D.boolean().optional(),password:so,passwordEnvVar:TDe.optional(),passwordOmit:D.boolean().optional()}).extend(qDe);var icu=D.objectWithoutOptionalProperties({token:so,tokenEnvVar:TDe.optional()}).extend(qDe);var Ol=D.objectWithoutOptionalProperties({wireValue:D.string(),name:so});var ncu=D.objectWithoutOptionalProperties({name:Ol,valueType:D.lazy(()=>Ys),prefix:D.string().optional(),headerEnvVar:TDe.optional()}).extend(qDe);var rWi=D.string();var G2t=D.string();var H2t=D.string();var kZi=D.objectWithoutOptionalProperties({endpointId:rWi,serviceId:G2t,subpackageId:H2t.optional()});var acu=D.enum_(["IN_DEVELOPMENT","PRE_RELEASE","GENERAL_AVAILABILITY","DEPRECATED"]);var K2t=D.objectWithoutOptionalProperties({status:acu,message:D.string().optional()});var uR=D.objectWithoutOptionalProperties({availability:K2t.optional()}).extend(pa);var Qka=D.unknown();var uU=D.objectWithoutOptionalProperties({userSpecifiedExamples:D.record(D.string(),Qka),autogeneratedExamples:D.record(D.string(),Qka)});var e2i=D.enum_(["READ_ONLY","WRITE_ONLY"]);var j7=D.objectWithoutOptionalProperties({name:Ol,valueType:D.lazy(()=>Ys),propertyAccess:e2i.optional(),v2Examples:uU.optional()}).extend(uR);var nfa=D.objectWithoutOptionalProperties({name:so,type:D.lazy(()=>Ys)});var sU=D.objectWithoutOptionalProperties({propertyPath:D.list(nfa).optional(),property:j7});var ocu=D.objectWithoutOptionalProperties({responseProperty:sU,headerName:D.string(),valuePrefix:D.string().optional()});var ucu=D.objectWithoutOptionalProperties({endpoint:kZi,expiryProperty:sU.optional(),authenticatedRequestHeaders:D.list(ocu)});var scu=D.objectWithoutOptionalProperties({tokenEndpoint:ucu}).extend(qDe);var afa=D.objectWithoutOptionalProperties({accessToken:sU,expiresIn:sU.optional(),refreshToken:sU.optional()});var t2i=D.objectWithoutOptionalProperties({name:Ol,valueType:D.lazy(()=>Ys),allowMultiple:D.boolean(),v2Examples:uU.optional(),explode:D.boolean().optional()}).extend(uR);var ccu=D.union("type",{query:t2i,body:j7}).transform({transform:e=>{switch(e.type){case"query":return SZ.query(e);case"body":return SZ.body(e);default:return e}},untransform:({_visit:e,...t})=>t});var P5=D.objectWithoutOptionalProperties({propertyPath:D.list(nfa).optional(),property:ccu});var lcu=D.objectWithoutOptionalProperties({refreshToken:P5});var fcu=D.objectWithoutOptionalProperties({endpointReference:kZi,requestProperties:lcu,responseProperties:afa});var dcu=D.objectWithoutOptionalProperties({clientId:P5,clientSecret:P5,scopes:P5.optional(),customProperties:D.list(P5).optional()});var pcu=D.objectWithoutOptionalProperties({endpointReference:kZi,requestProperties:dcu,responseProperties:afa});var _cu=D.objectWithoutOptionalProperties({clientIdEnvVar:TDe.optional(),clientSecretEnvVar:TDe.optional(),tokenPrefix:D.string().optional(),tokenHeader:D.string().optional(),scopes:D.list(D.string()).optional(),tokenEndpoint:pcu,refreshEndpoint:fcu.optional()});var hcu=D.union("type",{clientCredentials:_cu}).transform({transform:e=>e.type==="clientCredentials"?$Zi.clientCredentials(e):e,untransform:({_visit:e,...t})=>t});var ycu=D.objectWithoutOptionalProperties({configuration:hcu}).extend(qDe);var bcu=D.union(D.discriminant("type","_type"),{bearer:icu,basic:rcu,header:ncu,oauth:ycu,inferred:scu}).transform({transform:e=>{switch(e.type){case"bearer":return mP.bearer(e);case"basic":return mP.basic(e);case"header":return mP.header(e);case"oauth":return mP.oauth(e);case"inferred":return mP.inferred(e);default:return e}},untransform:({_visit:e,...t})=>t});var vcu=D.enum_(["ALL","ANY","ENDPOINT_SECURITY"]);var gcu=D.objectWithoutOptionalProperties({requirement:vcu,schemes:D.list(bcu)}).extend(pa);var Ocu=D.string();var Q9c={};$t(Q9c,{Availability:()=>K2t,AvailabilityStatus:()=>acu,Declaration:()=>uR,DisplayName:()=>r2i,EndpointId:()=>rWi,EndpointReference:()=>kZi,ErrorId:()=>i2i,EscapedString:()=>mcu,FeatureId:()=>Uka,FernFilepath:()=>RDe,Name:()=>so,NameAndWireValue:()=>Ol,SafeAndUnsafeString:()=>zAn,ServiceId:()=>G2t,SubpackageId:()=>H2t,TypeId:()=>S3,WebSocketChannelId:()=>ufa,WebhookGroupId:()=>ofa,WebhookId:()=>Acu,WithContentType:()=>zDe,WithDocs:()=>pa,WithDocsAndAvailability:()=>n2i,WithJsonExample:()=>$2t});var r2i=D.string();var i2i=D.string();var mcu=D.objectWithoutOptionalProperties({original:D.string()});var Uka=D.string();var RDe=D.objectWithoutOptionalProperties({allParts:D.list(so),packagePath:D.list(so),file:so.optional()});var S3=D.string();var ofa=D.string();var Acu=D.string();var ufa=D.string();var zDe=D.objectWithoutOptionalProperties({contentType:D.string().optional()});var n2i=D.objectWithoutOptionalProperties({availability:K2t.optional()}).extend(pa);var $2t=D.objectWithoutOptionalProperties({jsonExample:D.unknown()});var U9c={};$t(U9c,{Constants:()=>Pcu});var Pcu=D.objectWithoutOptionalProperties({errorInstanceIdKey:Ol});var GD={};$t(GD,{AliasType:()=>slu,Auth:()=>Bcu,AuthValues:()=>zcu,BasicAuth:()=>jcu,BasicAuthValues:()=>Icu,BearerAuth:()=>wcu,BearerAuthValues:()=>Ccu,BodyRequest:()=>Qcu,CratesPublishInfo:()=>ulu,Declaration:()=>j5,DiscriminatedUnionType:()=>plu,DynamicIntermediateRepresentation:()=>Dlu,Endpoint:()=>kcu,EndpointExample:()=>xcu,EndpointId:()=>Ncu,EndpointLocation:()=>lfa,EndpointSnippetRequest:()=>Wcu,EndpointSnippetResponse:()=>crh,EnumType:()=>_lu,EnvironmentBaseUrlId:()=>a2i,EnvironmentBaseUrlWithId:()=>elu,EnvironmentId:()=>Y2t,EnvironmentUrl:()=>o2i,EnvironmentValues:()=>Vcu,Environments:()=>alu,EnvironmentsConfig:()=>olu,ErrorSeverity:()=>Blu,Error_:()=>Ilu,FernFilepath:()=>Fcu,FileUploadRequestBody:()=>Hcu,FileUploadRequestBodyProperty:()=>Gcu,GeneratorConfig:()=>Mlu,GeneratorOutputConfig:()=>Slu,GoPublishInfo:()=>glu,HeaderAuth:()=>Scu,HeaderAuthValues:()=>qcu,HttpMethod:()=>Ucu,InferredAuth:()=>Mcu,InferredAuthValues:()=>Tcu,InlinedRequest:()=>Ycu,InlinedRequestBody:()=>$cu,InlinedRequestMetadata:()=>Jcu,LiteralType:()=>Clu,MapType:()=>lrh,MavenPublishInfo:()=>Olu,MultipleBaseUrlsEnvironment:()=>tlu,MultipleBaseUrlsEnvironments:()=>rlu,MultipleEnvironmentUrlValues:()=>Lcu,Name:()=>gS,NameAndWireValue:()=>M3,NamedParameter:()=>wE,NamedType:()=>blu,NpmPublishInfo:()=>mlu,NugetPublishInfo:()=>Alu,OAuth:()=>Dcu,OAuthValues:()=>Rcu,ObjectPropertyAccess:()=>Ecu,ObjectType:()=>hlu,PrimitiveTypeV1:()=>qlu,PublishInfo:()=>Elu,PypiPublishInfo:()=>Plu,ReferencedRequestBody:()=>Kcu,ReferencedRequestBodyType:()=>cfa,Request:()=>Xcu,Response:()=>Zcu,RubyGemsPublishInfo:()=>jlu,SafeAndUnsafeString:()=>NAn,SingleBaseUrlEnvironment:()=>ilu,SingleBaseUrlEnvironments:()=>nlu,SingleDiscriminatedUnionType:()=>dlu,SingleDiscriminatedUnionTypeNoProperties:()=>clu,SingleDiscriminatedUnionTypeObject:()=>llu,SingleDiscriminatedUnionTypeSingleProperty:()=>flu,SwiftPublishInfo:()=>wlu,TypeId:()=>J2t,TypeReference:()=>frh,UndiscriminatedUnionType:()=>ylu,Values:()=>ffa,VariableDeclaration:()=>vlu,WithDocs:()=>sfa,auth:()=>L9c,commons:()=>V9c,declaration:()=>W9c,endpoints:()=>x9c,environment:()=>G9c,http:()=>H9c,ir:()=>K9c,snippets:()=>$9c,types:()=>J9c,variables:()=>Y9c});var L9c={};$t(L9c,{Auth:()=>Bcu,AuthValues:()=>zcu,BasicAuth:()=>jcu,BasicAuthValues:()=>Icu,BearerAuth:()=>wcu,BearerAuthValues:()=>Ccu,HeaderAuth:()=>Scu,HeaderAuthValues:()=>qcu,InferredAuth:()=>Mcu,InferredAuthValues:()=>Tcu,OAuth:()=>Dcu,OAuthValues:()=>Rcu});var NAn=D.objectWithoutOptionalProperties({unsafeName:D.string(),safeName:D.string()});var gS=D.objectWithoutOptionalProperties({originalName:D.string(),camelCase:NAn,pascalCase:NAn,snakeCase:NAn,screamingSnakeCase:NAn});var jcu=D.objectWithoutOptionalProperties({username:gS,password:gS});var wcu=D.objectWithoutOptionalProperties({token:gS});var M3=D.objectWithoutOptionalProperties({wireValue:D.string(),name:gS});var Ecu=D.enum_(["READ_ONLY","WRITE_ONLY"]);var wE=D.objectWithoutOptionalProperties({name:M3,typeReference:D.lazy(()=>GD.TypeReference),propertyAccess:Ecu.optional(),variable:D.string().optional()});var Scu=D.objectWithoutOptionalProperties({header:wE});var Mcu=D.objectWithoutOptionalProperties({parameters:D.list(wE).optional()});var Dcu=D.objectWithoutOptionalProperties({clientId:gS,clientSecret:gS});var Bcu=D.union("type",{basic:jcu,bearer:wcu,header:Scu,oauth:Dcu,inferred:Mcu}).transform({transform:e=>{switch(e.type){case"basic":return er.Auth.basic(e);case"bearer":return er.Auth.bearer(e);case"header":return er.Auth.header(e);case"oauth":return er.Auth.oauth(e);case"inferred":return er.Auth.inferred(e);default:return e}},untransform:({_visit:e,...t})=>t});var Icu=D.objectWithoutOptionalProperties({username:D.string(),password:D.string()});var Ccu=D.objectWithoutOptionalProperties({token:D.string()});var qcu=D.objectWithoutOptionalProperties({value:D.unknown()});var Tcu=D.objectWithoutOptionalProperties({values:D.record(D.string(),D.unknown()).optional()});var Rcu=D.objectWithoutOptionalProperties({clientId:D.string(),clientSecret:D.string()});var zcu=D.union("type",{basic:Icu,bearer:Ccu,header:qcu,oauth:Rcu,inferred:Tcu}).transform({transform:e=>{switch(e.type){case"basic":return er.AuthValues.basic(e);case"bearer":return er.AuthValues.bearer(e);case"header":return er.AuthValues.header(e);case"oauth":return er.AuthValues.oauth(e);case"inferred":return er.AuthValues.inferred(e);default:return e}},untransform:({_visit:e,...t})=>t});var V9c={};$t(V9c,{EndpointId:()=>Ncu,FernFilepath:()=>Fcu,Name:()=>gS,NameAndWireValue:()=>M3,SafeAndUnsafeString:()=>NAn,TypeId:()=>J2t,WithDocs:()=>sfa});var Ncu=D.string();var Fcu=D.objectWithoutOptionalProperties({allParts:D.list(gS),packagePath:D.list(gS),file:gS.optional()});var J2t=D.string();var sfa=D.objectWithoutOptionalProperties({docs:D.string().optional()});var W9c={};$t(W9c,{Declaration:()=>j5});var j5=D.objectWithoutOptionalProperties({fernFilepath:Fcu,name:gS});var x9c={};$t(x9c,{BodyRequest:()=>Qcu,Endpoint:()=>kcu,EndpointExample:()=>xcu,EndpointLocation:()=>lfa,FileUploadRequestBody:()=>Hcu,FileUploadRequestBodyProperty:()=>Gcu,InlinedRequest:()=>Ycu,InlinedRequestBody:()=>$cu,InlinedRequestMetadata:()=>Jcu,ReferencedRequestBody:()=>Kcu,ReferencedRequestBodyType:()=>cfa,Request:()=>Xcu,Response:()=>Zcu});var cfa=D.union("type",{bytes:D.object({}),typeReference:D.object({value:D.lazy(()=>GD.TypeReference)})}).transform({transform:e=>{switch(e.type){case"bytes":return er.ReferencedRequestBodyType.bytes();case"typeReference":return er.ReferencedRequestBodyType.typeReference(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Qcu=D.objectWithoutOptionalProperties({pathParameters:D.list(wE).optional(),body:cfa.optional()});var Ucu=D.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD"]);var lfa=D.objectWithoutOptionalProperties({method:Ucu,path:D.string()});var Y2t=D.string();var a2i=D.string();var o2i=D.string();var Lcu=D.record(a2i,o2i);var Vcu=D.undiscriminatedUnion([Y2t,Lcu]);var ffa=D.record(D.string(),D.unknown());var Wcu=D.objectWithoutOptionalProperties({endpoint:lfa,baseUrl:D.property("baseURL",D.string().optional()),environment:Vcu.optional(),auth:zcu.optional(),pathParameters:ffa.optional(),queryParameters:ffa.optional(),headers:ffa.optional(),requestBody:D.unknown().optional()});var xcu=D.objectWithoutOptionalProperties({id:D.string(),name:D.string().optional()}).extend(Wcu);var Gcu=D.union("type",{file:M3,fileArray:M3,bodyProperty:wE}).transform({transform:e=>{switch(e.type){case"file":return er.FileUploadRequestBodyProperty.file(e);case"fileArray":return er.FileUploadRequestBodyProperty.fileArray(e);case"bodyProperty":return er.FileUploadRequestBodyProperty.bodyProperty(e);default:return e}},untransform:({_visit:e,...t})=>t});var Hcu=D.objectWithoutOptionalProperties({properties:D.list(Gcu)});var Kcu=D.objectWithoutOptionalProperties({bodyKey:gS,bodyType:cfa});var $cu=D.union("type",{properties:D.object({value:D.list(wE)}),referenced:Kcu,fileUpload:Hcu}).transform({transform:e=>{switch(e.type){case"properties":return er.InlinedRequestBody.properties(e.value);case"referenced":return er.InlinedRequestBody.referenced(e);case"fileUpload":return er.InlinedRequestBody.fileUpload(e);default:return e}},untransform:({_visit:e,...t})=>t});var Jcu=D.objectWithoutOptionalProperties({includePathParameters:D.boolean(),onlyPathParameters:D.boolean()});var Ycu=D.objectWithoutOptionalProperties({declaration:j5,pathParameters:D.list(wE).optional(),queryParameters:D.list(wE).optional(),headers:D.list(wE).optional(),body:$cu.optional(),metadata:Jcu.optional()});var Xcu=D.union("type",{body:Qcu,inlined:Ycu}).transform({transform:e=>{switch(e.type){case"body":return er.Request.body(e);case"inlined":return er.Request.inlined(e);default:return e}},untransform:({_visit:e,...t})=>t});var Zcu=D.union("type",{json:D.object({}),streaming:D.object({}),streamParameter:D.object({}),fileDownload:D.object({}),text:D.object({}),bytes:D.object({})}).transform({transform:e=>{switch(e.type){case"json":return er.Response.json();case"streaming":return er.Response.streaming();case"streamParameter":return er.Response.streamParameter();case"fileDownload":return er.Response.fileDownload();case"text":return er.Response.text();case"bytes":return er.Response.bytes();default:return e}},untransform:({_visit:e,...t})=>t});var kcu=D.objectWithoutOptionalProperties({auth:Bcu.optional(),declaration:j5,location:lfa,request:Xcu,response:Zcu,examples:D.list(xcu).optional()});var G9c={};$t(G9c,{EnvironmentBaseUrlId:()=>a2i,EnvironmentBaseUrlWithId:()=>elu,EnvironmentId:()=>Y2t,EnvironmentUrl:()=>o2i,EnvironmentValues:()=>Vcu,Environments:()=>alu,EnvironmentsConfig:()=>olu,MultipleBaseUrlsEnvironment:()=>tlu,MultipleBaseUrlsEnvironments:()=>rlu,MultipleEnvironmentUrlValues:()=>Lcu,SingleBaseUrlEnvironment:()=>ilu,SingleBaseUrlEnvironments:()=>nlu});var elu=D.objectWithoutOptionalProperties({id:a2i,name:gS});var tlu=D.objectWithoutOptionalProperties({id:Y2t,name:gS,urls:D.record(a2i,o2i)}).extend(sfa);var rlu=D.objectWithoutOptionalProperties({baseUrls:D.list(elu),environments:D.list(tlu)});var ilu=D.objectWithoutOptionalProperties({id:Y2t,name:gS,url:o2i}).extend(sfa);var nlu=D.objectWithoutOptionalProperties({environments:D.list(ilu)});var alu=D.union("type",{singleBaseUrl:nlu,multipleBaseUrls:rlu}).transform({transform:e=>{switch(e.type){case"singleBaseUrl":return er.Environments.singleBaseUrl(e);case"multipleBaseUrls":return er.Environments.multipleBaseUrls(e);default:return e}},untransform:({_visit:e,...t})=>t});var olu=D.objectWithoutOptionalProperties({defaultEnvironment:Y2t.optional(),environments:alu});var H9c={};$t(H9c,{HttpMethod:()=>Ucu});var K9c={};$t(K9c,{CratesPublishInfo:()=>ulu,DynamicIntermediateRepresentation:()=>Dlu,GeneratorConfig:()=>Mlu,GeneratorOutputConfig:()=>Slu,GoPublishInfo:()=>glu,MavenPublishInfo:()=>Olu,NpmPublishInfo:()=>mlu,NugetPublishInfo:()=>Alu,PublishInfo:()=>Elu,PypiPublishInfo:()=>Plu,RubyGemsPublishInfo:()=>jlu,SwiftPublishInfo:()=>wlu});var ulu=D.objectWithoutOptionalProperties({version:D.string(),packageName:D.string(),repoUrl:D.string().optional()});var slu=D.objectWithoutOptionalProperties({declaration:j5,typeReference:D.lazy(()=>GD.TypeReference)});var clu=D.objectWithoutOptionalProperties({discriminantValue:M3,properties:D.list(wE).optional()});var llu=D.objectWithoutOptionalProperties({typeId:J2t,discriminantValue:M3,properties:D.list(wE)});var flu=D.objectWithoutOptionalProperties({typeReference:D.lazy(()=>GD.TypeReference),discriminantValue:M3,properties:D.list(wE).optional()});var dlu=D.union("type",{samePropertiesAsObject:llu,singleProperty:flu,noProperties:clu}).transform({transform:e=>{switch(e.type){case"samePropertiesAsObject":return er.SingleDiscriminatedUnionType.samePropertiesAsObject(e);case"singleProperty":return er.SingleDiscriminatedUnionType.singleProperty(e);case"noProperties":return er.SingleDiscriminatedUnionType.noProperties(e);default:return e}},untransform:({_visit:e,...t})=>t});var plu=D.objectWithoutOptionalProperties({declaration:j5,discriminant:M3,types:D.record(D.string(),dlu)});var _lu=D.objectWithoutOptionalProperties({declaration:j5,values:D.list(M3)});var hlu=D.objectWithoutOptionalProperties({declaration:j5,properties:D.list(wE),extends:D.list(J2t).optional(),additionalProperties:D.boolean().optional()});var ylu=D.objectWithoutOptionalProperties({declaration:j5,types:D.list(D.lazy(()=>GD.TypeReference))});var blu=D.union("type",{alias:slu,enum:_lu,object:hlu,discriminatedUnion:plu,undiscriminatedUnion:ylu}).transform({transform:e=>{switch(e.type){case"alias":return er.NamedType.alias(e);case"enum":return er.NamedType.enum(e);case"object":return er.NamedType.object(e);case"discriminatedUnion":return er.NamedType.discriminatedUnion(e);case"undiscriminatedUnion":return er.NamedType.undiscriminatedUnion(e);default:return e}},untransform:({_visit:e,...t})=>t});var vlu=D.objectWithoutOptionalProperties({id:D.string(),name:so,typeReference:D.lazy(()=>GD.TypeReference)});var glu=D.objectWithoutOptionalProperties({version:D.string(),repoUrl:D.string()});var Olu=D.objectWithoutOptionalProperties({version:D.string(),coordinate:D.string(),repoUrl:D.string().optional()});var mlu=D.objectWithoutOptionalProperties({version:D.string(),packageName:D.string(),repoUrl:D.string().optional()});var Alu=D.objectWithoutOptionalProperties({version:D.string(),packageName:D.string(),repoUrl:D.string().optional()});var Plu=D.objectWithoutOptionalProperties({version:D.string(),packageName:D.string(),repoUrl:D.string().optional()});var jlu=D.objectWithoutOptionalProperties({version:D.string(),packageName:D.string(),repoUrl:D.string().optional()});var wlu=D.objectWithoutOptionalProperties({version:D.string(),repoUrl:D.string()});var Elu=D.union("type",{go:glu,swift:wlu,maven:Olu,npm:mlu,nuget:Alu,pypi:Plu,rubygems:jlu,crates:ulu}).transform({transform:e=>{switch(e.type){case"go":return er.PublishInfo.go(e);case"swift":return er.PublishInfo.swift(e);case"maven":return er.PublishInfo.maven(e);case"npm":return er.PublishInfo.npm(e);case"nuget":return er.PublishInfo.nuget(e);case"pypi":return er.PublishInfo.pypi(e);case"rubygems":return er.PublishInfo.rubygems(e);case"crates":return er.PublishInfo.crates(e);default:return e}},untransform:({_visit:e,...t})=>t});var Slu=D.union("type",{publish:D.object({value:Elu}),local:D.object({})}).transform({transform:e=>{switch(e.type){case"publish":return er.GeneratorOutputConfig.publish(e.value);case"local":return er.GeneratorOutputConfig.local();default:return e}},untransform:({_visit:e,...t})=>t});var Mlu=D.objectWithoutOptionalProperties({apiName:D.string(),organization:D.string(),customConfig:D.unknown(),outputConfig:Slu});var Dlu=D.objectWithoutOptionalProperties({version:D.stringLiteral("1.0.0"),types:D.record(J2t,blu),endpoints:D.record(Ncu,kcu),environments:olu.optional(),headers:D.list(wE).optional(),pathParameters:D.list(wE).optional(),variables:D.list(vlu).optional(),generatorConfig:Mlu.optional()});var $9c={};$t($9c,{EndpointSnippetRequest:()=>Wcu,EndpointSnippetResponse:()=>crh,ErrorSeverity:()=>Blu,Error_:()=>Ilu,Values:()=>ffa});var Blu=D.enum_(["CRITICAL","WARNING"]);var Ilu=D.objectWithoutOptionalProperties({severity:Blu,message:D.string()});var crh=D.objectWithoutOptionalProperties({snippet:D.string(),errors:D.list(Ilu).optional()});var J9c={};$t(J9c,{AliasType:()=>slu,DiscriminatedUnionType:()=>plu,EnumType:()=>_lu,LiteralType:()=>Clu,MapType:()=>lrh,NamedParameter:()=>wE,NamedType:()=>blu,ObjectPropertyAccess:()=>Ecu,ObjectType:()=>hlu,PrimitiveTypeV1:()=>qlu,SingleDiscriminatedUnionType:()=>dlu,SingleDiscriminatedUnionTypeNoProperties:()=>clu,SingleDiscriminatedUnionTypeObject:()=>llu,SingleDiscriminatedUnionTypeSingleProperty:()=>flu,TypeReference:()=>frh,UndiscriminatedUnionType:()=>ylu});var Clu=D.union("type",{boolean:D.object({value:D.boolean()}),string:D.object({value:D.string()})}).transform({transform:e=>{switch(e.type){case"boolean":return er.LiteralType.boolean(e.value);case"string":return er.LiteralType.string(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var lrh=D.objectWithoutOptionalProperties({key:D.lazy(()=>GD.TypeReference),value:D.lazy(()=>GD.TypeReference)});var qlu=D.enum_(["INTEGER","LONG","UINT","UINT_64","FLOAT","DOUBLE","BOOLEAN","STRING","DATE","DATE_TIME","UUID","BASE_64","BIG_INTEGER"]);var frh=D.union("type",{list:D.object({value:D.lazy(()=>GD.TypeReference)}),literal:D.object({value:Clu}),map:D.lazyObject(()=>GD.MapType),named:D.object({value:J2t}),nullable:D.object({value:D.lazy(()=>GD.TypeReference)}),optional:D.object({value:D.lazy(()=>GD.TypeReference)}),primitive:D.object({value:qlu}),set:D.object({value:D.lazy(()=>GD.TypeReference)}),unknown:D.object({})}).transform({transform:e=>{switch(e.type){case"list":return er.TypeReference.list(e.value);case"literal":return er.TypeReference.literal(e.value);case"map":return er.TypeReference.map(e);case"named":return er.TypeReference.named(e.value);case"nullable":return er.TypeReference.nullable(e.value);case"optional":return er.TypeReference.optional(e.value);case"primitive":return er.TypeReference.primitive(e.value);case"set":return er.TypeReference.set(e.value);case"unknown":return er.TypeReference.unknown();default:return e}},untransform:({_visit:e,...t})=>t});var Y9c={};$t(Y9c,{VariableDeclaration:()=>vlu});var X9c={};$t(X9c,{EnvironmentBaseUrlId:()=>Nme,EnvironmentBaseUrlWithId:()=>Tlu,EnvironmentId:()=>X2t,EnvironmentUrl:()=>u2i,Environments:()=>Qlu,EnvironmentsConfig:()=>Ulu,MultipleBaseUrlsEnvironment:()=>Rlu,MultipleBaseUrlsEnvironments:()=>zlu,SingleBaseUrlEnvironment:()=>Nlu,SingleBaseUrlEnvironments:()=>Flu});var Nme=D.string();var Tlu=D.objectWithoutOptionalProperties({id:Nme,name:so});var X2t=D.string();var u2i=D.string();var Rlu=D.objectWithoutOptionalProperties({id:X2t,name:so,urls:D.record(Nme,u2i)}).extend(pa);var zlu=D.objectWithoutOptionalProperties({baseUrls:D.list(Tlu),environments:D.list(Rlu)});var Nlu=D.objectWithoutOptionalProperties({id:X2t,name:so,url:u2i}).extend(pa);var Flu=D.objectWithoutOptionalProperties({environments:D.list(Nlu)});var Qlu=D.union("type",{singleBaseUrl:Flu,multipleBaseUrls:zlu}).transform({transform:e=>{switch(e.type){case"singleBaseUrl":return xD.singleBaseUrl(e);case"multipleBaseUrls":return xD.multipleBaseUrls(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ulu=D.objectWithoutOptionalProperties({defaultEnvironment:X2t.optional(),environments:Qlu});var Z9c={};$t(Z9c,{DeclaredErrorName:()=>s2i,ErrorDeclaration:()=>Vlu,ErrorDeclarationDiscriminantValue:()=>drh,ExampleError:()=>Llu});var s2i=D.objectWithoutOptionalProperties({errorId:i2i,fernFilepath:RDe,name:so});var cU=D.objectWithoutOptionalProperties({name:Ol,valueType:D.lazy(()=>Ys),env:D.string().optional(),v2Examples:uU.optional()}).extend(uR);var Llu=D.objectWithoutOptionalProperties({name:so.optional(),shape:D.lazyObject(()=>xf)}).extend($2t).extend(pa);var Vlu=D.objectWithoutOptionalProperties({name:s2i,displayName:D.string().optional(),discriminantValue:Ol,type:D.lazy(()=>Ys).optional(),statusCode:D.number(),isWildcardStatusCode:D.boolean().optional(),examples:D.list(Llu),v2Examples:uU.optional(),headers:D.list(cU).optional()}).extend(pa);var drh=D.union("type",{property:Ol,statusCode:D.object({})}).transform({transform:e=>{switch(e.type){case"property":return YZi.property(e);case"statusCode":return YZi.statusCode();default:return e}},untransform:({_visit:e,...t})=>t});var k9c={};$t(k9c,{BasicAuthValues:()=>Wlu,BearerAuthValues:()=>xlu,HeaderAuthValues:()=>Glu,MultipleEnvironmentUrlValues:()=>Hlu,OAuthValues:()=>Klu,V2AuthValues:()=>dfa,V2EndpointLocation:()=>Jlu,V2EndpointLocationHttpMethod:()=>$lu,V2EnvironmentValues:()=>pfa,V2HttpEndpointCodeSample:()=>Ylu,V2HttpEndpointExample:()=>Lka,V2HttpEndpointExamples:()=>efu,V2HttpEndpointRequest:()=>Xlu,V2HttpEndpointResponse:()=>klu,V2HttpEndpointResponseBody:()=>Zlu,V2SchemaExample:()=>Qka,V2SchemaExamples:()=>uU,V2ValueExamples:()=>Z2t,V2WebSocketEndpointLocation:()=>rfu,V2WebSocketMessageExample:()=>ifu,V2WebSocketSessionExample:()=>Wka,V2WebSocketSessionExamples:()=>nfu,V2WebhookExample:()=>Vka,V2WebhookExamples:()=>tfu,WithV2Examples:()=>OS});var Wlu=D.objectWithoutOptionalProperties({username:D.string(),password:D.string()});var xlu=D.objectWithoutOptionalProperties({token:D.string()});var Glu=D.objectWithoutOptionalProperties({value:D.unknown()});var Hlu=D.record(Nme,u2i);var Klu=D.objectWithoutOptionalProperties({clientId:D.string(),clientSecret:D.string()});var dfa=D.union("type",{basic:Wlu,bearer:xlu,header:Glu,oauth:Klu}).transform({transform:e=>{switch(e.type){case"basic":return DDe.basic(e);case"bearer":return DDe.bearer(e);case"header":return DDe.header(e);case"oauth":return DDe.oauth(e);default:return e}},untransform:({_visit:e,...t})=>t});var $lu=D.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD"]);var Jlu=D.objectWithoutOptionalProperties({method:$lu,path:D.string()});var pfa=D.undiscriminatedUnion([X2t,Hlu]);var Ylu=D.objectWithoutOptionalProperties({name:D.string().optional(),language:D.string(),code:D.string()}).extend(pa);var Z2t=D.record(D.string(),D.unknown());var Xlu=D.objectWithoutOptionalProperties({endpoint:Jlu,baseUrl:D.property("baseURL",D.string().optional()),environment:pfa.optional(),auth:dfa.optional(),pathParameters:Z2t.optional(),queryParameters:Z2t.optional(),headers:Z2t.optional(),requestBody:D.unknown().optional()}).extend(pa);var Zlu=D.union("type",{error:D.object({value:D.unknown()}),json:D.object({value:D.unknown()}),stream:D.object({value:D.list(D.unknown())})}).transform({transform:e=>{switch(e.type){case"error":return aR.error(e.value);case"json":return aR.json(e.value);case"stream":return aR.stream(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var klu=D.objectWithoutOptionalProperties({statusCode:D.number().optional(),body:Zlu.optional()}).extend(pa);var Lka=D.objectWithoutOptionalProperties({displayName:D.string().optional(),request:Xlu.optional(),response:klu.optional(),codeSamples:D.list(Ylu).optional()});var efu=D.objectWithoutOptionalProperties({userSpecifiedExamples:D.record(D.string(),Lka),autogeneratedExamples:D.record(D.string(),Lka)});var Vka=D.objectWithoutOptionalProperties({name:D.string().optional(),payload:D.unknown()});var tfu=D.objectWithoutOptionalProperties({userSpecifiedExamples:D.record(D.string(),Vka),autogeneratedExamples:D.record(D.string(),Vka)});var rfu=D.objectWithoutOptionalProperties({path:D.string()});var ifu=D.objectWithoutOptionalProperties({type:D.string(),body:D.unknown()});var Wka=D.objectWithoutOptionalProperties({channel:rfu,baseUrl:D.property("baseURL",D.string().optional()),environment:pfa.optional(),auth:dfa.optional(),pathParameters:Z2t.optional(),queryParameters:Z2t.optional(),headers:Z2t.optional(),messages:D.list(ifu).optional()});var nfu=D.objectWithoutOptionalProperties({autogeneratedExamples:D.record(D.string(),Wka),userSpecifiedExamples:D.record(D.string(),Wka)});var OS=D.objectWithoutOptionalProperties({v2Examples:uU.optional()});var tHc={};$t(tHc,{BasicLicense:()=>ofu,CratesGithubPublishInfo:()=>ufu,CratesRegistryConfig:()=>_fa,CustomLicense:()=>sfu,EnvironmentVariable:()=>KB,GeneratorConfig:()=>prh,GeneratorEnvironment:()=>lfu,GeneratorOutputConfig:()=>Bfu,GeneratorPublishConfig:()=>Afa,GeneratorPublishTarget:()=>_fu,GeneratorRegistriesConfig:()=>bfu,GeneratorRegistriesConfigV2:()=>vfu,GithubOutputMode:()=>Sfu,GithubPublishInfo:()=>Efu,LicenseConfig:()=>Ifu,LicenseId:()=>afu,MavenCentralSignature:()=>hfa,MavenCentralSignatureGithubInfo:()=>gfu,MavenGithubPublishInfo:()=>Ofu,MavenRegistryConfig:()=>hfu,MavenRegistryConfigV2:()=>yfa,NpmGithubPublishInfo:()=>mfu,NpmRegistryConfig:()=>yfu,NpmRegistryConfigV2:()=>bfa,NugetGithubPublishInfo:()=>Afu,NugetRegistryConfig:()=>vfa,OutputMetadata:()=>pfu,OutputMetadataAuthor:()=>dfu,OutputMode:()=>Mfu,PostmanConfig:()=>ffu,PostmanGithubPublishInfo:()=>Pfu,PublishingMetadata:()=>Dfu,PypiGithubPublishInfo:()=>jfu,PypiMetadata:()=>gfa,PypiRegistryConfig:()=>Ofa,RemoteGeneratorEnvironment:()=>cfu,RubyGemsGithubPublishInfo:()=>wfu,RubyGemsRegistryConfig:()=>mfa,config:()=>eHc});var eHc={};$t(eHc,{BasicLicense:()=>ofu,CratesGithubPublishInfo:()=>ufu,CratesRegistryConfig:()=>_fa,CustomLicense:()=>sfu,EnvironmentVariable:()=>KB,GeneratorConfig:()=>prh,GeneratorEnvironment:()=>lfu,GeneratorOutputConfig:()=>Bfu,GeneratorPublishConfig:()=>Afa,GeneratorPublishTarget:()=>_fu,GeneratorRegistriesConfig:()=>bfu,GeneratorRegistriesConfigV2:()=>vfu,GithubOutputMode:()=>Sfu,GithubPublishInfo:()=>Efu,LicenseConfig:()=>Ifu,LicenseId:()=>afu,MavenCentralSignature:()=>hfa,MavenCentralSignatureGithubInfo:()=>gfu,MavenGithubPublishInfo:()=>Ofu,MavenRegistryConfig:()=>hfu,MavenRegistryConfigV2:()=>yfa,NpmGithubPublishInfo:()=>mfu,NpmRegistryConfig:()=>yfu,NpmRegistryConfigV2:()=>bfa,NugetGithubPublishInfo:()=>Afu,NugetRegistryConfig:()=>vfa,OutputMetadata:()=>pfu,OutputMetadataAuthor:()=>dfu,OutputMode:()=>Mfu,PostmanConfig:()=>ffu,PostmanGithubPublishInfo:()=>Pfu,PublishingMetadata:()=>Dfu,PypiGithubPublishInfo:()=>jfu,PypiMetadata:()=>gfa,PypiRegistryConfig:()=>Ofa,RemoteGeneratorEnvironment:()=>cfu,RubyGemsGithubPublishInfo:()=>wfu,RubyGemsRegistryConfig:()=>mfa});var afu=D.enum_(["MIT","Apache-2.0"]);var ofu=D.objectWithoutOptionalProperties({id:afu});var KB=D.string();var ufu=D.objectWithoutOptionalProperties({registryUrl:D.string(),packageName:D.string(),tokenEnvironmentVariable:KB,shouldGeneratePublishWorkflow:D.boolean().optional()});var _fa=D.objectWithoutOptionalProperties({registryUrl:D.string(),token:D.string(),packageName:D.string()});var sfu=D.objectWithoutOptionalProperties({filename:D.string()});var cfu=D.objectWithoutOptionalProperties({coordinatorUrl:D.string(),coordinatorUrlV2:D.string(),id:D.string()});var lfu=D.union(D.discriminant("type","_type"),{local:D.object({}),remote:cfu}).transform({transform:e=>{switch(e.type){case"local":return zl.GeneratorEnvironment.local();case"remote":return zl.GeneratorEnvironment.remote(e);default:return e}},untransform:({_visit:e,...t})=>t});var hfa=D.objectWithoutOptionalProperties({keyId:D.string(),password:D.string(),secretKey:D.string()});var yfa=D.objectWithoutOptionalProperties({registryUrl:D.string(),username:D.string(),password:D.string(),coordinate:D.string(),signature:hfa.optional()});var bfa=D.objectWithoutOptionalProperties({registryUrl:D.string(),token:D.string(),packageName:D.string()});var vfa=D.objectWithoutOptionalProperties({registryUrl:D.string(),apiKey:D.string(),packageName:D.string()});var ffu=D.objectWithoutOptionalProperties({apiKey:D.string(),workspaceId:D.string()});var dfu=D.objectWithoutOptionalProperties({name:D.string(),email:D.string()});var pfu=D.objectWithoutOptionalProperties({description:D.string().optional(),authors:D.list(dfu).optional()});var gfa=D.objectWithoutOptionalProperties({keywords:D.list(D.string()).optional(),documentationLink:D.string().optional(),homepageLink:D.string().optional()}).extend(pfu);var Ofa=D.objectWithoutOptionalProperties({registryUrl:D.string(),username:D.string(),password:D.string(),packageName:D.string(),pypiMetadata:gfa.optional()});var mfa=D.objectWithoutOptionalProperties({registryUrl:D.string(),apiKey:D.string(),packageName:D.string()});var _fu=D.union("type",{maven:yfa,npm:bfa,pypi:Ofa,postman:ffu,rubygems:mfa,nuget:vfa,crates:_fa}).transform({transform:e=>{switch(e.type){case"maven":return zl.GeneratorPublishTarget.maven(e);case"npm":return zl.GeneratorPublishTarget.npm(e);case"pypi":return zl.GeneratorPublishTarget.pypi(e);case"postman":return zl.GeneratorPublishTarget.postman(e);case"rubygems":return zl.GeneratorPublishTarget.rubygems(e);case"nuget":return zl.GeneratorPublishTarget.nuget(e);case"crates":return zl.GeneratorPublishTarget.crates(e);default:return e}},untransform:({_visit:e,...t})=>t});var hfu=D.objectWithoutOptionalProperties({registryUrl:D.string(),username:D.string(),password:D.string(),group:D.string(),signature:hfa.optional()});var yfu=D.objectWithoutOptionalProperties({registryUrl:D.string(),token:D.string(),scope:D.string()});var bfu=D.objectWithoutOptionalProperties({maven:hfu,npm:yfu});var vfu=D.objectWithoutOptionalProperties({maven:yfa,npm:bfa,pypi:Ofa,rubygems:mfa,nuget:vfa,crates:_fa});var Afa=D.objectWithoutOptionalProperties({registries:bfu,registriesV2:vfu,publishTarget:_fu.optional(),version:D.string()});var gfu=D.objectWithoutOptionalProperties({keyIdEnvironmentVariable:KB,passwordEnvironmentVariable:KB,secretKeyEnvironmentVariable:KB});var Ofu=D.objectWithoutOptionalProperties({registryUrl:D.string(),coordinate:D.string(),usernameEnvironmentVariable:KB,passwordEnvironmentVariable:KB,signature:gfu.optional(),shouldGeneratePublishWorkflow:D.boolean().optional()});var mfu=D.objectWithoutOptionalProperties({registryUrl:D.string(),packageName:D.string(),tokenEnvironmentVariable:KB,shouldGeneratePublishWorkflow:D.boolean().optional()});var Afu=D.objectWithoutOptionalProperties({registryUrl:D.string(),packageName:D.string(),apiKeyEnvironmentVariable:KB,shouldGeneratePublishWorkflow:D.boolean().optional()});var Pfu=D.objectWithoutOptionalProperties({apiKeyEnvironmentVariable:KB,workspaceIdEnvironmentVariable:KB});var jfu=D.objectWithoutOptionalProperties({registryUrl:D.string(),packageName:D.string(),usernameEnvironmentVariable:KB,passwordEnvironmentVariable:KB,pypiMetadata:gfa.optional(),shouldGeneratePublishWorkflow:D.boolean().optional()});var wfu=D.objectWithoutOptionalProperties({registryUrl:D.string(),packageName:D.string(),apiKeyEnvironmentVariable:KB,shouldGeneratePublishWorkflow:D.boolean().optional()});var Efu=D.union("type",{npm:mfu,maven:Ofu,postman:Pfu,pypi:jfu,rubygems:wfu,nuget:Afu,crates:ufu}).transform({transform:e=>{switch(e.type){case"npm":return zl.GithubPublishInfo.npm(e);case"maven":return zl.GithubPublishInfo.maven(e);case"postman":return zl.GithubPublishInfo.postman(e);case"pypi":return zl.GithubPublishInfo.pypi(e);case"rubygems":return zl.GithubPublishInfo.rubygems(e);case"nuget":return zl.GithubPublishInfo.nuget(e);case"crates":return zl.GithubPublishInfo.crates(e);default:return e}},untransform:({_visit:e,...t})=>t});var Sfu=D.objectWithoutOptionalProperties({version:D.string(),repoUrl:D.string(),installationToken:D.string().optional(),branch:D.string().optional(),publishInfo:Efu.optional()});var Mfu=D.union("type",{publish:Afa,downloadFiles:D.object({}),github:Sfu}).transform({transform:e=>{switch(e.type){case"publish":return zl.OutputMode.publish(e);case"downloadFiles":return zl.OutputMode.downloadFiles();case"github":return zl.OutputMode.github(e);default:return e}},untransform:({_visit:e,...t})=>t});var Dfu=D.objectWithoutOptionalProperties({packageDescription:D.property("package_description",D.string().optional()),publisherEmail:D.property("publisher_email",D.string().optional()),referenceUrl:D.property("reference_url",D.string().optional()),publisherName:D.property("publisher_name",D.string().optional())});var Bfu=D.objectWithoutOptionalProperties({path:D.string(),snippetFilepath:D.string().optional(),snippetTemplateFilepath:D.string().optional(),publishingMetadata:Dfu.optional(),mode:Mfu});var Ifu=D.union("type",{basic:ofu,custom:sfu}).transform({transform:e=>{switch(e.type){case"basic":return zl.LicenseConfig.basic(e);case"custom":return zl.LicenseConfig.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var prh=D.objectWithoutOptionalProperties({dryRun:D.boolean(),irFilepath:D.string(),originalReadmeFilepath:D.string().optional(),license:Ifu.optional(),output:Bfu,publish:Afa.optional(),workspaceName:D.string(),organization:D.string(),customConfig:D.unknown(),environment:lfu,whitelabel:D.boolean(),writeUnitTests:D.boolean(),generatePaginatedClients:D.boolean().optional(),generateOauthClients:D.boolean()});var rHc={};$t(rHc,{AutogeneratedEndpointExample:()=>Ufu,BytesRequest:()=>Efa,BytesResponse:()=>Sfa,CursorPagination:()=>Lfu,CustomPagination:()=>Vfu,DeclaredServiceName:()=>Wfu,EndpointName:()=>xfu,ExampleCodeSample:()=>Kfu,ExampleCodeSampleLanguage:()=>Gfu,ExampleCodeSampleSdk:()=>Hfu,ExampleEndpointCall:()=>wfa,ExampleEndpointErrorResponse:()=>zfu,ExampleEndpointSuccessResponse:()=>Ffu,ExampleHeader:()=>FAn,ExampleInlinedRequestBody:()=>jfa,ExampleInlinedRequestBodyExtraProperty:()=>qfu,ExampleInlinedRequestBodyProperty:()=>Tfu,ExamplePathParameter:()=>c2i,ExampleQueryParameter:()=>Pfa,ExampleQueryParameterShape:()=>Cfu,ExampleRequestBody:()=>Rfu,ExampleResponse:()=>Qfu,ExampleServerSideEvent:()=>Nfu,FileDownloadResponse:()=>Dfa,FileProperty:()=>Yfu,FilePropertyArray:()=>$fu,FilePropertySingle:()=>Jfu,FileUploadBodyProperty:()=>Zfu,FileUploadBodyPropertyEncoding:()=>Xfu,FileUploadRequest:()=>Ifa,FileUploadRequestProperty:()=>kfu,GrpcTransport:()=>idu,HttpEndpoint:()=>qdu,HttpEndpointSecurityItem:()=>ndu,HttpEndpointSource:()=>udu,HttpHeader:()=>cU,HttpMethod:()=>sdu,HttpPath:()=>NDe,HttpPathPart:()=>cdu,HttpRequestBody:()=>Tfa,HttpRequestBodyReference:()=>qfa,HttpResponse:()=>l2i,HttpResponseBody:()=>vdu,HttpService:()=>zdu,InlinedRequestBody:()=>ldu,InlinedRequestBodyProperty:()=>Bfa,JsonResponse:()=>Rfa,JsonResponseBody:()=>fdu,JsonResponseBodyWithProperty:()=>ddu,JsonStreamChunk:()=>pdu,NonStreamHttpResponseBody:()=>ydu,OffsetPagination:()=>gdu,Pagination:()=>Odu,PathParameter:()=>B5t,PathParameterLocation:()=>mdu,PropertyPathItem:()=>nfa,ProtoSourceInfo:()=>odu,QueryParameter:()=>t2i,RequestProperty:()=>P5,RequestPropertyValue:()=>ccu,ResponseError:()=>Adu,ResponseErrors:()=>Pdu,ResponseProperty:()=>sU,RetriesConfiguration:()=>wdu,RetriesDisabledSchema:()=>jdu,SdkRequest:()=>Ddu,SdkRequestBodyType:()=>Edu,SdkRequestShape:()=>Mdu,SdkRequestWrapper:()=>Sdu,SseStreamChunk:()=>_du,StreamParameterResponse:()=>bdu,StreamingResponse:()=>zfa,SupportedSdkLanguage:()=>Mfa,TextResponse:()=>Nfa,TextStreamChunk:()=>hdu,Transport:()=>Qfa,UserSpecifiedEndpointExample:()=>Bdu,V2HttpRequestBodies:()=>Idu,V2HttpResponses:()=>Cdu});var FAn=D.objectWithoutOptionalProperties({name:Ol,value:D.lazyObject(()=>xf)});var c2i=D.objectWithoutOptionalProperties({name:so,value:D.lazyObject(()=>xf)});var Cfu=D.union("type",{single:D.object({}),exploded:D.object({}),commaSeparated:D.object({})}).transform({transform:e=>{switch(e.type){case"single":return gN.single();case"exploded":return gN.exploded();case"commaSeparated":return gN.commaSeparated();default:return e}},untransform:({_visit:e,...t})=>t});var Pfa=D.objectWithoutOptionalProperties({name:Ol,value:D.lazyObject(()=>xf),shape:Cfu.optional()});var qfu=D.objectWithoutOptionalProperties({name:Ol,value:D.lazyObject(()=>xf)});var mS=D.objectWithoutOptionalProperties({typeId:S3,fernFilepath:RDe,name:so,displayName:r2i.optional()});var Tfu=D.objectWithoutOptionalProperties({name:Ol,value:D.lazyObject(()=>xf),originalTypeDeclaration:mS.optional()});var jfa=D.objectWithoutOptionalProperties({properties:D.list(Tfu),extraProperties:D.list(qfu).optional()}).extend($2t);var Rfu=D.union("type",{inlinedRequestBody:jfa,reference:D.lazyObject(()=>xf)}).transform({transform:e=>{switch(e.type){case"inlinedRequestBody":return O5.inlinedRequestBody(e);case"reference":return O5.reference(e);default:return e}},untransform:({_visit:e,...t})=>t});var zfu=D.objectWithoutOptionalProperties({error:s2i,body:D.lazyObject(()=>xf).optional()});var Nfu=D.objectWithoutOptionalProperties({event:D.string(),data:D.lazyObject(()=>xf)});var Ffu=D.union("type",{body:D.object({value:D.lazyObject(()=>xf).optional()}),stream:D.object({value:D.list(D.lazyObject(()=>xf))}),sse:D.object({value:D.list(Nfu)})}).transform({transform:e=>{switch(e.type){case"body":return PE.body(e.value);case"stream":return PE.stream(e.value);case"sse":return PE.sse(e.value);default:return e}},untransform:({_visit:e,...t})=>t});var Qfu=D.union("type",{ok:D.object({value:Ffu}),error:zfu}).transform({transform:e=>{switch(e.type){case"ok":return Zw.ok(e.value);case"error":return Zw.error(e);default:return e}},untransform:({_visit:e,...t})=>t});var wfa=D.objectWithoutOptionalProperties({id:D.string().optional(),name:so.optional(),url:D.string(),rootPathParameters:D.list(c2i),servicePathParameters:D.list(c2i),endpointPathParameters:D.list(c2i),serviceHeaders:D.list(FAn),endpointHeaders:D.list(FAn),queryParameters:D.list(Pfa),request:Rfu.optional(),response:Qfu}).extend(pa);var Ufu=D.objectWithoutOptionalProperties({example:wfa});var Efa=D.objectWithoutOptionalProperties({isOptional:D.boolean()}).extend(pa).extend(OS).extend(zDe);var Sfa=D.objectWithoutOptionalProperties({}).extend(pa).extend(OS);var Lfu=D.objectWithoutOptionalProperties({page:P5,next:sU,results:sU});var Vfu=D.objectWithoutOptionalProperties({results:sU});var Wfu=D.objectWithoutOptionalProperties({fernFilepath:RDe});var xfu=so;var Gfu=D.objectWithoutOptionalProperties({name:so.optional(),language:D.string(),code:D.string(),install:D.string().optional()}).extend(pa);var Mfa=D.enum_(["curl","python","javascript","typescript","go","ruby","csharp","java","php","rust","swift"]);var Hfu=D.objectWithoutOptionalProperties({name:so.optional(),sdk:Mfa,code:D.string()}).extend(pa);var Kfu=D.union("type",{language:Gfu,sdk:Hfu}).transform({transform:e=>{switch(e.type){case"language":return qme.language(e);case"sdk":return qme.sdk(e);default:return e}},untransform:({_visit:e,...t})=>t});var Dfa=D.objectWithoutOptionalProperties({}).extend(pa).extend(OS);var $fu=D.objectWithoutOptionalProperties({key:Ol,isOptional:D.boolean(),contentType:D.string().optional()}).extend(pa);var Jfu=D.objectWithoutOptionalProperties({key:Ol,isOptional:D.boolean(),contentType:D.string().optional()}).extend(pa);var Yfu=D.union("type",{file:Jfu,fileArray:$fu}).transform({transform:e=>{switch(e.type){case"file":return EZ.file(e);case"fileArray":return EZ.fileArray(e);default:return e}},untransform:({_visit:e,...t})=>t});var Xfu=D.enum_(["exploded","json","form"]);var Bfa=D.objectWithoutOptionalProperties({name:Ol,valueType:D.lazy(()=>Ys),v2Examples:uU.optional(),propertyAccess:e2i.optional()}).extend(n2i);var Zfu=D.objectWithoutOptionalProperties({style:Xfu.optional()}).extend(Bfa).extend(zDe);var kfu=D.union("type",{file:D.object({value:Yfu}),bodyProperty:Zfu}).transform({transform:e=>{switch(e.type){case"file":return oR.file(e.value);case"bodyProperty":return oR.bodyProperty(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ifa=D.objectWithoutOptionalProperties({name:so,properties:D.list(kfu)}).extend(pa).extend(OS).extend(zDe);var edu=D.objectWithoutOptionalProperties({namespace:D.string()});var tdu=D.objectWithoutOptionalProperties({csharp:edu.optional()});var Cfa=D.objectWithoutOptionalProperties({filepath:D.string(),packageName:D.string().optional(),options:tdu.optional()});var rdu=D.objectWithoutOptionalProperties({file:Cfa,name:so});var idu=D.objectWithoutOptionalProperties({service:rdu});var ndu=D.record(ifa,D.list(Ocu));var adu=D.enum_(["UNARY","CLIENT_STREAM","SERVER_STREAM","BIDIRECTIONAL_STREAM"]);var odu=D.objectWithoutOptionalProperties({methodType:adu.optional()});var udu=D.union("type",{proto:odu,openapi:D.object({}),openrpc:D.object({})}).transform({transform:e=>{switch(e.type){case"proto":return m5.proto(e);case"openapi":return m5.openapi();case"openrpc":return m5.openrpc();default:return e}},untransform:({_visit:e,...t})=>t});var sdu=D.enum_(["GET","POST","PUT","PATCH","DELETE","HEAD"]);var cdu=D.objectWithoutOptionalProperties({pathParameter:D.string(),tail:D.string()});var NDe=D.objectWithoutOptionalProperties({head:D.string(),parts:D.list(cdu)});var qfa=D.objectWithoutOptionalProperties({requestBodyType:D.lazy(()=>Ys)}).extend(pa).extend(zDe).extend(OS);var ldu=D.objectWithoutOptionalProperties({name:so,extends:D.list(mS),properties:D.list(Bfa),extendedProperties:D.list(j7).optional(),extraProperties:D.property("extra-properties",D.boolean())}).extend(pa).extend(OS).extend(zDe);var Tfa=D.union("type",{inlinedRequestBody:ldu,reference:qfa,fileUpload:Ifa,bytes:Efa}).transform({transform:e=>{switch(e.type){case"inlinedRequestBody":return FA.inlinedRequestBody(e);case"reference":return FA.reference(e);case"fileUpload":return FA.fileUpload(e);case"bytes":return FA.bytes(e);default:return e}},untransform:({_visit:e,...t})=>t});var fdu=D.objectWithoutOptionalProperties({responseBodyType:D.lazy(()=>Ys)}).extend(pa).extend(OS);var ddu=D.objectWithoutOptionalProperties({responseBodyType:D.lazy(()=>Ys),responseProperty:j7.optional()}).extend(pa).extend(OS);var Rfa=D.union("type",{response:fdu,nestedPropertyAsResponse:ddu}).transform({transform:e=>{switch(e.type){case"response":return Nq.response(e);case"nestedPropertyAsResponse":return Nq.nestedPropertyAsResponse(e);default:return e}},untransform:({_visit:e,...t})=>t});var pdu=D.objectWithoutOptionalProperties({payload:D.lazy(()=>Ys),terminator:D.string().optional()}).extend(pa).extend(OS);var _du=D.objectWithoutOptionalProperties({payload:D.lazy(()=>Ys),terminator:D.string().optional()}).extend(pa).extend(OS);var hdu=D.objectWithoutOptionalProperties({}).extend(pa).extend(OS);var zfa=D.union("type",{json:pdu,text:hdu,sse:_du}).transform({transform:e=>{switch(e.type){case"json":return qC.json(e);case"text":return qC.text(e);case"sse":return qC.sse(e);default:return e}},untransform:({_visit:e,...t})=>t});var Nfa=D.objectWithoutOptionalProperties({}).extend(pa).extend(OS);var ydu=D.union("type",{json:D.object({value:Rfa}),fileDownload:Dfa,text:Nfa,bytes:Sfa}).transform({transform:e=>{switch(e.type){case"json":return j3.json(e.value);case"fileDownload":return j3.fileDownload(e);case"text":return j3.text(e);case"bytes":return j3.bytes(e);default:return e}},untransform:({_visit:e,...t})=>t});var bdu=D.objectWithoutOptionalProperties({nonStreamResponse:ydu,streamResponse:zfa});var vdu=D.union("type",{json:D.object({value:Rfa}),fileDownload:Dfa,text:Nfa,bytes:Sfa,streaming:D.object({value:zfa}),streamParameter:bdu}).transform({transform:e=>{switch(e.type){case"json":return op.json(e.value);case"fileDownload":return op.fileDownload(e);case"text":return op.text(e);case"bytes":return op.bytes(e);case"streaming":return op.streaming(e.value);case"streamParameter":return op.streamParameter(e);default:return e}},untransform:({_visit:e,...t})=>t});var l2i=D.objectWithoutOptionalProperties({statusCode:D.property("status-code",D.number().optional()),isWildcardStatusCode:D.boolean().optional(),body:vdu.optional()}).extend(pa);var gdu=D.objectWithoutOptionalProperties({page:P5,results:sU,hasNextPage:sU.optional(),step:P5.optional()});var Odu=D.union("type",{cursor:Lfu,offset:gdu,custom:Vfu}).transform({transform:e=>{switch(e.type){case"cursor":return A5.cursor(e);case"offset":return A5.offset(e);case"custom":return A5.custom(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ffa=D.string();var mdu=D.enum_(["ROOT","SERVICE","ENDPOINT"]);var B5t=D.objectWithoutOptionalProperties({name:so,valueType:D.lazy(()=>Ys),location:mdu,variable:Ffa.optional(),v2Examples:uU.optional(),explode:D.boolean().optional()}).extend(pa);var Adu=D.objectWithoutOptionalProperties({error:s2i}).extend(pa);var Pdu=D.list(Adu);var jdu=D.objectWithoutOptionalProperties({disabled:D.boolean().optional()});var wdu=D.undiscriminatedUnion([jdu]);var Edu=D.union("type",{typeReference:qfa,bytes:Efa}).transform({transform:e=>{switch(e.type){case"typeReference":return E5t.typeReference(e);case"bytes":return E5t.bytes(e);default:return e}},untransform:({_visit:e,...t})=>t});var Sdu=D.objectWithoutOptionalProperties({wrapperName:so,bodyKey:so,includePathParameters:D.boolean().optional(),onlyPathParameters:D.boolean().optional()});var Mdu=D.union("type",{justRequestBody:D.object({value:Edu}),wrapper:Sdu}).transform({transform:e=>{switch(e.type){case"justRequestBody":return IDe.justRequestBody(e.value);case"wrapper":return IDe.wrapper(e);default:return e}},untransform:({_visit:e,...t})=>t});var Ddu=D.objectWithoutOptionalProperties({streamParameter:P5.optional(),requestParameterName:so,shape:Mdu});var Qfa=D.union("type",{http:D.object({}),grpc:idu}).transform({transform:e=>{switch(e.type){case"http":return CDe.http();case"grpc":return CDe.grpc(e);default:return e}},untransform:({_visit:e,...t})=>t});var Bdu=D.objectWithoutOptionalProperties({codeSamples:D.list(Kfu).optional(),example:wfa.optional()});var Idu=D.objectWithoutOptionalProperties({requestBodies:D.list(Tfa).optional()});var Cdu=D.objectWithoutOptionalProperties({responses:D.list(l2i).optional()});var qdu=D.objectWithoutOptionalProperties({id:rWi,name:xfu,displayName:D.string().optional(),method:sdu,headers:D.list(cU),responseHeaders:D.list(cU).optional(),baseUrl:Nme.optional(),v2BaseUrls:D.list(Nme).optional(),basePath:NDe.optional(),path:NDe,fullPath:NDe,pathParameters:D.list(B5t),allPathParameters:D.list(B5t),queryParameters:D.list(t2i),requestBody:Tfa.optional(),v2RequestBodies:Idu.optional(),sdkRequest:Ddu.optional(),response:l2i.optional(),v2Responses:Cdu.optional(),errors:Pdu,auth:D.boolean(),security:D.list(ndu).optional(),idempotent:D.boolean(),pagination:Odu.optional(),userSpecifiedExamples:D.list(Bdu),autogeneratedExamples:D.list(Ufu),v2Examples:efu.optional(),transport:Qfa.optional(),source:udu.optional(),audiences:D.list(rfa).optional(),retries:wdu.optional(),apiPlayground:D.boolean().optional()}).extend(uR);var Tdu=D.objectWithoutOptionalProperties({});var Rdu=D.objectWithoutOptionalProperties({});var Ufa=D.objectWithoutOptionalProperties({json:Tdu.optional(),proto:Rdu.optional()});var zdu=D.objectWithoutOptionalProperties({availability:K2t.optional(),name:Wfu,displayName:D.string().optional(),basePath:NDe,endpoints:D.list(qdu),headers:D.list(cU),pathParameters:D.list(B5t),encoding:Ufa.optional(),transport:Qfa.optional(),audiences:D.list(rfa).optional()});var iHc={};$t(iHc,{ApiDefinitionSource:()=>Qdu,ApiDefinitionSourceId:()=>Ndu,ApiVersionScheme:()=>Ldu,ErrorDiscriminationByPropertyStrategy:()=>Vdu,ErrorDiscriminationStrategy:()=>Wdu,ExampleStyle:()=>xdu,GenerationMetadata:()=>Gdu,HeaderApiVersionScheme:()=>Udu,IntermediateRepresentation:()=>_rh,Package:()=>Hfa,PackageNavigationConfig:()=>u_u,PlatformHeaders:()=>f_u,ProtoSource:()=>Fdu,ReadmeConfig:()=>c_u,ReadmeCustomSection:()=>s_u,SdkConfig:()=>d_u,ServiceTypeReferenceInfo:()=>p_u,SourceConfig:()=>__u,Subpackage:()=>h_u,UserAgent:()=>l_u});var Ndu=D.string();var Fdu=D.objectWithoutOptionalProperties({id:Ndu,protoRootUrl:D.string()});var Qdu=D.union("type",{proto:Fdu,openapi:D.object({})}).transform({transform:e=>{switch(e.type){case"proto":return MZ.proto(e);case"openapi":return MZ.openapi();default:return e}},untransform:({_visit:e,...t})=>t});var iWi=D.objectWithoutOptionalProperties({name:Ol}).extend(uR);var Lfa=D.objectWithoutOptionalProperties({default:iWi.optional(),values:D.list(iWi)});var Udu=D.objectWithoutOptionalProperties({header:cU,value:Lfa});var Ldu=D.union("type",{header:Udu}).transform({transform:e=>e.type==="header"?XZi.header(e):e,untransform:({_visit:e,...t})=>t});var Vdu=D.objectWithoutOptionalProperties({discriminant:Ol,contentProperty:Ol});var Wdu=D.union("type",{statusCode:D.object({}),property:Vdu}).transform({transform:e=>{switch(e.type){case"statusCode":return Rme.statusCode();case"property":return Rme.property(e);default:return e}},untransform:({_visit:e,...t})=>t});var xdu=D.enum_(["minimal","comprehensive"]);var Gdu=D.objectWithoutOptionalProperties({cliVersion:D.string(),generatorName:D.string(),generatorVersion:D.string(),generatorConfig:D.unknown().optional()});var Hdu=D.objectWithoutOptionalProperties({version:D.string().optional(),packageName:D.string().optional()});var Kdu=D.objectWithoutOptionalProperties({coordinate:D.string().optional(),version:D.string().optional(),usernameEnvironmentVariable:D.string(),passwordEnvironmentVariable:D.string(),mavenUrlEnvironmentVariable:D.string()});var $du=D.objectWithoutOptionalProperties({version:D.string().optional(),packageName:D.string().optional(),tokenEnvironmentVariable:D.string()});var Jdu=D.objectWithoutOptionalProperties({apiKey:D.string(),workspaceId:D.string(),collectionId:D.string().optional()});var Ydu=D.objectWithoutOptionalProperties({version:D.string().optional(),packageName:D.string().optional()});var f2i=D.union("type",{postman:Jdu,npm:$du,maven:Kdu,pypi:Ydu,crates:Hdu}).transform({transform:e=>{switch(e.type){case"postman":return Fq.postman(e);case"npm":return Fq.npm(e);case"maven":return Fq.maven(e);case"pypi":return Fq.pypi(e);case"crates":return Fq.crates(e);default:return e}},untransform:({_visit:e,...t})=>t});var Xdu=D.objectWithoutOptionalProperties({target:f2i});var Zdu=D.objectWithoutOptionalProperties({generateFullProject:D.boolean(),publishTarget:f2i.optional()});var kdu=D.objectWithoutOptionalProperties({owner:D.string(),repo:D.string(),uri:D.string().optional(),token:D.string().optional(),mode:D.stringLiteral("pull-request").optional(),branch:D.string().optional(),target:f2i});var epu=D.union("type",{github:kdu,direct:Xdu,filesystem:Zdu}).transform({transform:e=>{switch(e.type){case"github":return W2t.github(e);case"direct":return W2t.direct(e);case"filesystem":return W2t.filesystem(e);default:return e}},untransform:({_visit:e,...t})=>t});var xka=D.objectWithoutOptionalProperties({name:so.optional(),shape:D.lazy(()=>Vfa)}).extend($2t).extend(pa);var tpu=D.objectWithoutOptionalProperties({file:Cfa,name:so});var rpu=D.union("type",{any:D.object({}),api:D.object({}),boolValue:D.object({}),bytesValue:D.object({}),doubleValue:D.object({}),duration:D.object({}),empty:D.object({}),enum:D.object({}),enumValue:D.object({}),field:D.object({}),fieldCardinality:D.object({}),fieldKind:D.object({}),fieldMask:D.object({}),floatValue:D.object({}),int32Value:D.object({}),int64Value:D.object({}),listValue:D.object({}),method:D.object({}),mixin:D.object({}),nullValue:D.object({}),option:D.object({}),sourceContext:D.object({}),stringValue:D.object({}),struct:D.object({}),syntax:D.object({}),timestamp:D.object({}),type:D.object({}),uint32Value:D.object({}),uint64Value:D.object({}),value:D.object({})}).transform({transform:e=>{switch(e.type){case"any":return In.any();case"api":return In.api();case"boolValue":return In.boolValue();case"bytesValue":return In.bytesValue();case"doubleValue":return In.doubleValue();case"duration":return In.duration();case"empty":return In.empty();case"enum":return In.enum();case"enumValue":return In.enumValue();case"field":return In.field();case"fieldCardinality":return In.fieldCardinality();case"fieldKind":return In.fieldKind();case"fieldMask":return In.fieldMask();case"floatValue":return In.floatValue();case"int32Value":return In.int32Value();case"int64Value":return In.int64Value();case"listValue":return In.listValue();case"method":return In.method();case"mixin":return In.mixin();case"nullValue":return In.nullValue();case"option":return In.option();case"sourceContext":return In.sourceContext();case"stringValue":return In.stringValue();case"struct":return In.struct();case"syntax":return In.syntax();case"timestamp":return In.timestamp();case"type":return In.type();case"uint32Value":return In.uint32Value();case"uint64Value":return In.uint64Value();case"value":return In.value();default:return e}},untransform:({_visit:e,...t})=>t});var ipu=D.union("type",{wellKnown:D.object({value:rpu}),userDefined:tpu}).transform({transform:e=>{switch(e.type){case"wellKnown":return rb.wellKnown(e.value);case"userDefined":return rb.userDefined(e);default:return e}},untransform:({_visit:e,...t})=>t});var npu=D.union("type",{proto:D.object({value:ipu})}).transform({transform:e=>e.type==="proto"?eWi.proto(e.value):e,untransform:({_visit:e,...t})=>t});var apu=D.enum_(["INTEGER","LONG","UINT","UINT_64","FLOAT","DOUBLE","BOOLEAN","STRING","DATE","DATE_TIME","UUID","BASE_64","BIG_INTEGER"]);var opu=D.objectWithoutOptionalProperties({});var upu=D.objectWithoutOptionalProperties({default:D.string().optional()});var spu=D.objectWithoutOptionalProperties({default:D.boolean().optional()});var cpu=D.objectWithoutOptionalProperties({});var lpu=D.objectWithoutOptionalProperties({});var fpu=D.objectWithoutOptionalProperties({min:D.number().optional(),max:D.number().optional(),exclusiveMin:D.boolean().optional(),exclusiveMax:D.boolean().optional(),multipleOf:D.number().optional()});var dpu=D.objectWithoutOptionalProperties({default:D.number().optional(),validation:fpu.optional()});var ppu=D.objectWithoutOptionalProperties({min:D.number().optional(),max:D.number().optional(),exclusiveMin:D.boolean().optional(),exclusiveMax:D.boolean().optional(),multipleOf:D.number().optional()});var _pu=D.objectWithoutOptionalProperties({default:D.number().optional(),validation:ppu.optional()});var hpu=D.objectWithoutOptionalProperties({min:D.number().optional(),max:D.number().optional(),exclusiveMin:D.boolean().optional(),exclusiveMax:D.boolean().optional(),multipleOf:D.number().optional()});var ypu=D.objectWithoutOptionalProperties({default:D.number().optional(),validation:hpu.optional()});var bpu=D.objectWithoutOptionalProperties({min:D.number().optional(),max:D.number().optional(),exclusiveMin:D.boolean().optional(),exclusiveMax:D.boolean().optional(),multipleOf:D.number().optional()});var vpu=D.objectWithoutOptionalProperties({default:D.number().optional(),validation:bpu.optional()});var gpu=D.objectWithoutOptionalProperties({format:D.string().optional(),pattern:D.string().optional(),minLength:D.number().optional(),maxLength:D.number().optional()});var Opu=D.objectWithoutOptionalProperties({default:D.string().optional(),validation:gpu.optional()});var mpu=D.objectWithoutOptionalProperties({min:D.number().optional(),max:D.number().optional(),exclusiveMin:D.boolean().optional(),exclusiveMax:D.boolean().optional(),multipleOf:D.number().optional()});var Apu=D.objectWithoutOptionalProperties({default:D.number().optional(),validation:mpu.optional()});var Ppu=D.objectWithoutOptionalProperties({min:D.number().optional(),max:D.number().optional(),exclusiveMin:D.boolean().optional(),exclusiveMax:D.boolean().optional(),multipleOf:D.number().optional()});var jpu=D.objectWithoutOptionalProperties({default:D.number().optional(),validation:Ppu.optional()});var wpu=D.objectWithoutOptionalProperties({});var Epu=D.union("type",{integer:ypu,long:vpu,uint:jpu,uint64:Apu,float:_pu,double:dpu,boolean:spu,string:Opu,date:lpu,dateTime:cpu,uuid:wpu,base64:opu,bigInteger:upu}).transform({transform:e=>{switch(e.type){case"integer":return Cn.integer(e);case"long":return Cn.long(e);case"uint":return Cn.uint(e);case"uint64":return Cn.uint64(e);case"float":return Cn.float(e);case"double":return Cn.double(e);case"boolean":return Cn.boolean(e);case"string":return Cn.string(e);case"date":return Cn.date(e);case"dateTime":return Cn.dateTime(e);case"uuid":return Cn.uuid(e);case"base64":return Cn.base64(e);case"bigInteger":return Cn.bigInteger(e);default:return e}},untransform:({_visit:e,...t})=>t});var Wfa=D.objectWithoutOptionalProperties({v1:apu,v2:Epu.optional()});var Spu=D.enum_(["ENUM","OBJECT","UNION","UNDISCRIMINATED_UNION"]);var Mpu=D.objectWithoutOptionalProperties({name:mS,shape:Spu});var Dpu=D.union(D.discriminant("type","_type"),{container:D.object({container:D.lazy(()=>xfa)}),named:Mpu,primitive:D.object({primitive:Wfa}),unknown:D.object({})}).transform({transform:e=>{switch(e.type){case"container":return w3.container(e.container);case"named":return w3.named(e);case"primitive":return w3.primitive(e.primitive);case"unknown":return w3.unknown();default:return e}},untransform:({_visit:e,...t})=>t});var Bpu=D.objectWithoutOptionalProperties({aliasOf:D.lazy(()=>Ys),resolvedType:Dpu});var Ipu=D.objectWithoutOptionalProperties({extends:D.list(mS),properties:D.list(j7),extendedProperties:D.list(j7).optional(),extraProperties:D.property("extra-properties",D.boolean())});var Cpu=D.objectWithoutOptionalProperties({type:D.lazy(()=>Ys)}).extend(pa);var qpu=D.objectWithoutOptionalProperties({members:D.list(Cpu)});var Tpu=D.objectWithoutOptionalProperties({name:Ol,type:D.lazy(()=>Ys)});var Rpu=D.union(D.discriminant("propertiesType","_type"),{samePropertiesAsObject:mS,singleProperty:Tpu,noProperties:D.object({})}).transform({transform:e=>{switch(e.propertiesType){case"samePropertiesAsObject":return iU.samePropertiesAsObject(e);case"singleProperty":return iU.singleProperty(e);case"noProperties":return iU.noProperties();default:return e}},untransform:({_visit:e,...t})=>t});var zpu=D.objectWithoutOptionalProperties({discriminantValue:Ol,shape:Rpu,displayName:D.string().optional(),availability:K2t.optional()}).extend(pa);var Npu=D.objectWithoutOptionalProperties({discriminant:Ol,extends:D.list(mS),types:D.list(zpu),baseProperties:D.list(j7)});var Fpu=D.union(D.discriminant("type","_type"),{alias:Bpu,enum:Lfa,object:Ipu,union:Npu,undiscriminatedUnion:qpu}).transform({transform:e=>{switch(e.type){case"alias":return Jl.alias(e);case"enum":return Jl.enum(e);case"object":return Jl.object(e);case"union":return Jl.union(e);case"undiscriminatedUnion":return Jl.undiscriminatedUnion(e);default:return e}},untransform:({_visit:e,...t})=>t});var Qpu=D.objectWithoutOptionalProperties({name:mS,shape:Fpu,autogeneratedExamples:D.list(xka),userProvidedExamples:D.list(xka),v2Examples:uU.optional(),referencedTypes:D.set(S3),encoding:Ufa.optional(),source:npu.optional(),inline:D.boolean().optional()}).extend(uR);var Upu=D.objectWithoutOptionalProperties({id:Ffa,name:so,type:D.lazy(()=>Ys)}).extend(pa);var Lpu=D.objectWithoutOptionalProperties({name:so.optional(),payload:D.lazyObject(()=>xf)}).extend(pa);var Vpu=D.enum_(["GET","POST"]);var Wpu=so;var xpu=D.objectWithoutOptionalProperties({name:Ol,valueType:D.lazy(()=>Ys)}).extend(n2i);var Gpu=D.objectWithoutOptionalProperties({name:so,extends:D.list(mS),properties:D.list(xpu)});var Hpu=D.objectWithoutOptionalProperties({payloadType:D.lazy(()=>Ys)}).extend(pa);var Kpu=D.union("type",{inlinedPayload:Gpu,reference:Hpu}).transform({transform:e=>{switch(e.type){case"inlinedPayload":return nU.inlinedPayload(e);case"reference":return nU.reference(e);default:return e}},untransform:({_visit:e,...t})=>t});var $pu=D.objectWithoutOptionalProperties({id:Acu,name:Wpu,displayName:D.string().optional(),method:Vpu,headers:D.list(cU),payload:Kpu,fileUploadPayload:Ifa.optional(),responses:D.list(l2i).optional(),examples:D.list(Lpu).optional(),v2Examples:tfu.optional()}).extend(uR);var Jpu=D.list($pu);var Ypu=D.union("type",{inlinedBody:jfa,reference:D.lazyObject(()=>xf)}).transform({transform:e=>{switch(e.type){case"inlinedBody":return zme.inlinedBody(e);case"reference":return zme.reference(e);default:return e}},untransform:({_visit:e,...t})=>t});var Gfa=D.string();var Xpu=D.objectWithoutOptionalProperties({type:Gfa,body:Ypu});var Zpu=D.objectWithoutOptionalProperties({name:so.optional(),url:D.string(),pathParameters:D.list(c2i),headers:D.list(FAn),queryParameters:D.list(Pfa),messages:D.list(Xpu)}).extend(pa);var kpu=D.objectWithoutOptionalProperties({name:Ol,valueType:D.lazy(()=>Ys)}).extend(n2i);var e_u=D.objectWithoutOptionalProperties({name:so,extends:D.list(mS),properties:D.list(kpu)});var t_u=D.objectWithoutOptionalProperties({bodyType:D.lazy(()=>Ys)}).extend(pa);var r_u=D.union("type",{inlinedBody:e_u,reference:t_u}).transform({transform:e=>{switch(e.type){case"inlinedBody":return E3.inlinedBody(e);case"reference":return E3.reference(e);default:return e}},untransform:({_visit:e,...t})=>t});var i_u=D.enum_(["client","server"]);var n_u=D.objectWithoutOptionalProperties({type:Gfa,displayName:D.string().optional(),methodName:D.string().optional(),origin:i_u,body:r_u}).extend(uR);var a_u=so;var o_u=D.objectWithoutOptionalProperties({name:a_u,displayName:D.string().optional(),baseUrl:Nme.optional(),path:NDe,auth:D.boolean(),headers:D.list(cU),queryParameters:D.list(t2i),pathParameters:D.list(B5t),messages:D.list(n_u),examples:D.list(Zpu),v2Examples:nfu.optional()}).extend(uR);var u_u=D.objectWithoutOptionalProperties({pointsTo:H2t});var Hfa=D.objectWithoutOptionalProperties({fernFilepath:RDe,service:G2t.optional(),types:D.list(S3),errors:D.list(i2i),webhooks:ofa.optional(),websocket:ufa.optional(),subpackages:D.list(H2t),hasEndpointsInTree:D.boolean(),navigationConfig:u_u.optional()}).extend(pa);var s_u=D.objectWithoutOptionalProperties({title:D.string(),language:Mfa,content:D.string()});var c_u=D.objectWithoutOptionalProperties({defaultEndpoint:rWi.optional(),bannerLink:D.string().optional(),introduction:D.string().optional(),apiReferenceLink:D.string().optional(),apiName:D.string().optional(),disabledFeatures:D.list(Uka).optional(),whiteLabel:D.boolean().optional(),features:D.record(Uka,D.list(rWi)).optional(),customSections:D.list(s_u).optional(),exampleStyle:xdu.optional()});var l_u=D.objectWithoutOptionalProperties({header:D.stringLiteral("User-Agent"),value:D.string()});var f_u=D.objectWithoutOptionalProperties({language:D.string(),sdkName:D.string(),sdkVersion:D.string(),userAgent:l_u.optional()});var d_u=D.objectWithoutOptionalProperties({isAuthMandatory:D.boolean(),hasStreamingEndpoints:D.boolean(),hasPaginatedEndpoints:D.boolean(),hasFileDownloadEndpoints:D.boolean(),platformHeaders:f_u});var p_u=D.objectWithoutOptionalProperties({typesReferencedOnlyByService:D.record(G2t,D.list(S3)),sharedTypes:D.list(S3)});var __u=D.objectWithoutOptionalProperties({sources:D.list(Qdu)});var h_u=D.objectWithoutOptionalProperties({name:so,displayName:r2i.optional()}).extend(Hfa);var _rh=D.objectWithoutOptionalProperties({fdrApiDefinitionId:D.string().optional(),apiVersion:Ldu.optional(),apiName:so,apiDisplayName:D.string().optional(),apiDocs:D.string().optional(),auth:gcu,headers:D.list(cU),idempotencyHeaders:D.list(cU),types:D.record(S3,Qpu),services:D.record(G2t,zdu),webhookGroups:D.record(ofa,Jpu),websocketChannels:D.record(ufa,o_u).optional(),errors:D.record(i2i,Vlu),subpackages:D.record(H2t,h_u),rootPackage:Hfa,constants:Pcu,environments:Ulu.optional(),basePath:NDe.optional(),pathParameters:D.list(B5t),errorDiscriminationStrategy:Wdu,sdkConfig:d_u,variables:D.list(Upu),serviceTypeReferenceInfo:p_u,readmeConfig:c_u.optional(),sourceConfig:__u.optional(),publishConfig:epu.optional(),dynamic:Dlu.optional(),selfHosted:D.boolean().optional(),audiences:D.list(tcu).optional(),generationMetadata:Gdu.optional(),apiPlayground:D.boolean().optional()});var nHc={};$t(nHc,{CsharpProtobufFileOptions:()=>edu,ProtobufFile:()=>Cfa,ProtobufFileOptions:()=>tdu,ProtobufMethodType:()=>adu,ProtobufService:()=>rdu,ProtobufType:()=>ipu,UserDefinedProtobufType:()=>tpu,WellKnownProtobufType:()=>rpu});var aHc={};$t(aHc,{CratesPublishTarget:()=>Hdu,DirectPublish:()=>Xdu,Filesystem:()=>Zdu,GithubPublish:()=>kdu,MavenPublishTarget:()=>Kdu,NpmPublishTarget:()=>$du,PostmanPublishTarget:()=>Jdu,PublishTarget:()=>f2i,PublishingConfig:()=>epu,PypiPublishTarget:()=>Ydu});var oHc={};$t(oHc,{AliasTypeDeclaration:()=>Bpu,Base64Type:()=>opu,BigIntegerType:()=>upu,BooleanType:()=>spu,ContainerType:()=>xfa,DateTimeType:()=>cpu,DateType:()=>lpu,DeclaredTypeName:()=>mS,DoubleType:()=>dpu,DoubleValidationRules:()=>fpu,Encoding:()=>Ufa,EnumTypeDeclaration:()=>Lfa,EnumTypeReference:()=>hrh,EnumValue:()=>iWi,ExampleAliasType:()=>v_u,ExampleContainer:()=>m_u,ExampleDatetime:()=>g_u,ExampleEnumType:()=>S_u,ExampleExtraObjectProperty:()=>M_u,ExampleKeyValuePair:()=>D_u,ExampleListContainer:()=>A_u,ExampleLiteralContainer:()=>O_u,ExampleMapContainer:()=>P_u,ExampleNamedType:()=>B_u,ExampleNullableContainer:()=>j_u,ExampleObjectProperty:()=>$fa,ExampleObjectType:()=>Jfa,ExampleObjectTypeWithTypeId:()=>I_u,ExampleOptionalContainer:()=>w_u,ExamplePrimitive:()=>Kfa,ExampleSetContainer:()=>E_u,ExampleSingleUnionType:()=>C_u,ExampleSingleUnionTypeProperties:()=>q_u,ExampleType:()=>xka,ExampleTypeReference:()=>xf,ExampleTypeReferenceShape:()=>T_u,ExampleTypeShape:()=>Vfa,ExampleUndiscriminatedUnionType:()=>R_u,ExampleUnionBaseProperty:()=>N_u,ExampleUnionType:()=>z_u,FloatType:()=>_pu,FloatValidationRules:()=>ppu,IntegerType:()=>ypu,IntegerValidationRules:()=>hpu,JsonEncoding:()=>Tdu,Literal:()=>y_u,LongType:()=>vpu,LongValidationRules:()=>bpu,MapType:()=>b_u,NamedType:()=>Q_u,NamedTypeDefault:()=>F_u,ObjectProperty:()=>j7,ObjectPropertyAccess:()=>e2i,ObjectTypeDeclaration:()=>Ipu,PrimitiveType:()=>Wfa,PrimitiveTypeV1:()=>apu,PrimitiveTypeV2:()=>Epu,ProtoEncoding:()=>Rdu,ResolvedNamedType:()=>Mpu,ResolvedTypeReference:()=>Dpu,ShapeType:()=>Spu,SingleUnionType:()=>zpu,SingleUnionTypeProperties:()=>Rpu,SingleUnionTypeProperty:()=>Tpu,Source:()=>npu,StringType:()=>Opu,StringValidationRules:()=>gpu,Type:()=>Fpu,TypeDeclaration:()=>Qpu,TypeReference:()=>Ys,Uint64Type:()=>Apu,Uint64ValidationRules:()=>mpu,UintType:()=>jpu,UintValidationRules:()=>Ppu,UndiscriminatedUnionMember:()=>Cpu,UndiscriminatedUnionTypeDeclaration:()=>qpu,UnionTypeDeclaration:()=>Npu,UuidType:()=>wpu});var y_u=D.union("type",{string:D.object({string:D.string()}),boolean:D.object({boolean:D.boolean()})}).transform({transform:e=>{switch(e.type){case"string":return rU.string(e.string);case"boolean":return rU.boolean(e.boolean);default:return e}},untransform:({_visit:e,...t})=>t});var xfa=D.union(D.discriminant("type","_type"),{list:D.object({list:D.lazy(()=>Ys)}),map:D.lazyObject(()=>b_u),nullable:D.object({nullable:D.lazy(()=>Ys)}),optional:D.object({optional:D.lazy(()=>Ys)}),set:D.object({set:D.lazy(()=>Ys)}),literal:D.object({literal:y_u})}).transform({transform:e=>{switch(e.type){case"list":return Js.list(e.list);case"map":return Js.map(e);case"nullable":return Js.nullable(e.nullable);case"optional":return Js.optional(e.optional);case"set":return Js.set(e.set);case"literal":return Js.literal(e.literal);default:return e}},untransform:({_visit:e,...t})=>t});var hrh=D.objectWithoutOptionalProperties({default:iWi.optional(),name:mS});var v_u=D.objectWithoutOptionalProperties({value:D.lazyObject(()=>xf)});var g_u=D.objectWithoutOptionalProperties({datetime:D.date(),raw:D.string().optional()});var Kfa=D.union("type",{integer:D.object({integer:D.number()}),long:D.object({long:D.number()}),uint:D.object({uint:D.number()}),uint64:D.object({uint64:D.number()}),float:D.object({float:D.number()}),double:D.object({double:D.number()}),boolean:D.object({boolean:D.boolean()}),string:D.object({string:mcu}),date:D.object({date:D.string()}),datetime:g_u,uuid:D.object({uuid:D.string()}),base64:D.object({base64:D.string()}),bigInteger:D.object({bigInteger:D.string()})}).transform({transform:e=>{switch(e.type){case"integer":return Xn.integer(e.integer);case"long":return Xn.long(e.long);case"uint":return Xn.uint(e.uint);case"uint64":return Xn.uint64(e.uint64);case"float":return Xn.float(e.float);case"double":return Xn.double(e.double);case"boolean":return Xn.boolean(e.boolean);case"string":return Xn.string(e.string);case"date":return Xn.date(e.date);case"datetime":return Xn.datetime(e);case"uuid":return Xn.uuid(e.uuid);case"base64":return Xn.base64(e.base64);case"bigInteger":return Xn.bigInteger(e.bigInteger);default:return e}},untransform:({_visit:e,...t})=>t});var O_u=D.objectWithoutOptionalProperties({literal:Kfa});var m_u=D.union("type",{list:D.lazyObject(()=>A_u),set:D.lazyObject(()=>E_u),optional:D.lazyObject(()=>w_u),nullable:D.lazyObject(()=>j_u),map:D.lazyObject(()=>P_u),literal:O_u}).transform({transform:e=>{switch(e.type){case"list":return S_.list(e);case"set":return S_.set(e);case"optional":return S_.optional(e);case"nullable":return S_.nullable(e);case"map":return S_.map(e);case"literal":return S_.literal(e);default:return e}},untransform:({_visit:e,...t})=>t});var S_u=D.objectWithoutOptionalProperties({value:Ol});var M_u=D.objectWithoutOptionalProperties({name:Ol,value:D.lazyObject(()=>xf)});var D_u=D.objectWithoutOptionalProperties({key:D.lazyObject(()=>xf),value:D.lazyObject(()=>xf)});var A_u=D.objectWithoutOptionalProperties({list:D.list(D.lazyObject(()=>xf)),itemType:D.lazy(()=>Ys)});var P_u=D.objectWithoutOptionalProperties({map:D.list(D.lazyObject(()=>D_u)),keyType:D.lazy(()=>Ys),valueType:D.lazy(()=>Ys)});var B_u=D.objectWithoutOptionalProperties({typeName:mS,shape:D.lazy(()=>Vfa)});var j_u=D.objectWithoutOptionalProperties({nullable:D.lazyObject(()=>xf).optional(),valueType:D.lazy(()=>Ys)});var $fa=D.objectWithoutOptionalProperties({name:Ol,value:D.lazyObject(()=>xf),propertyAccess:e2i.optional(),originalTypeDeclaration:mS});var Jfa=D.objectWithoutOptionalProperties({properties:D.list(D.lazyObject(()=>$fa)),extraProperties:D.list(D.lazyObject(()=>M_u)).optional()});var I_u=D.objectWithoutOptionalProperties({typeId:S3,object:D.lazyObject(()=>Jfa)});var w_u=D.objectWithoutOptionalProperties({optional:D.lazyObject(()=>xf).optional(),valueType:D.lazy(()=>Ys)});var E_u=D.objectWithoutOptionalProperties({set:D.list(D.lazyObject(()=>xf)),itemType:D.lazy(()=>Ys)});var C_u=D.objectWithoutOptionalProperties({wireDiscriminantValue:Ol,shape:D.lazy(()=>q_u)});var q_u=D.union("type",{samePropertiesAsObject:D.lazyObject(()=>I_u),singleProperty:D.lazyObject(()=>xf),noProperties:D.object({})}).transform({transform:e=>{switch(e.type){case"samePropertiesAsObject":return Qq.samePropertiesAsObject(e);case"singleProperty":return Qq.singleProperty(e);case"noProperties":return Qq.noProperties();default:return e}},untransform:({_visit:e,...t})=>t});var xf=D.objectWithoutOptionalProperties({shape:D.lazy(()=>T_u)}).extend($2t);var T_u=D.union("type",{primitive:D.object({primitive:Kfa}),container:D.object({container:D.lazy(()=>m_u)}),unknown:D.object({unknown:D.unknown()}),named:D.lazyObject(()=>B_u)}).transform({transform:e=>{switch(e.type){case"primitive":return as.primitive(e.primitive);case"container":return as.container(e.container);case"unknown":return as.unknown(e.unknown);case"named":return as.named(e);default:return e}},untransform:({_visit:e,...t})=>t});var Vfa=D.union("type",{alias:D.lazyObject(()=>v_u),enum:S_u,object:D.lazyObject(()=>Jfa),union:D.lazyObject(()=>z_u),undiscriminatedUnion:D.lazyObject(()=>R_u)}).transform({transform:e=>{switch(e.type){case"alias":return ib.alias(e);case"enum":return ib.enum(e);case"object":return ib.object(e);case"union":return ib.union(e);case"undiscriminatedUnion":return ib.undiscriminatedUnion(e);default:return e}},untransform:({_visit:e,...t})=>t});var R_u=D.objectWithoutOptionalProperties({index:D.number(),singleUnionType:D.lazyObject(()=>xf)});var N_u=D.objectWithoutOptionalProperties({name:Ol,value:D.lazyObject(()=>xf)});var z_u=D.objectWithoutOptionalProperties({discriminant:Ol,singleUnionType:D.lazyObject(()=>C_u),extendProperties:D.list(D.lazyObject(()=>$fa)).optional(),baseProperties:D.list(D.lazyObject(()=>N_u)).optional()});var b_u=D.objectWithoutOptionalProperties({keyType:D.lazy(()=>Ys),valueType:D.lazy(()=>Ys)});var F_u=D.union("type",{enum:iWi}).transform({transform:e=>e.type==="enum"?Zla.enum(e):e,untransform:({_visit:e,...t})=>t});var Q_u=D.objectWithoutOptionalProperties({typeId:S3,fernFilepath:RDe,name:so,displayName:r2i.optional(),default:F_u.optional(),inline:D.boolean().optional()});var Ys=D.union(D.discriminant("type","_type"),{container:D.object({container:D.lazy(()=>xfa)}),named:Q_u,primitive:D.object({primitive:Wfa}),unknown:D.object({})}).transform({transform:e=>{switch(e.type){case"container":return _i.container(e.container);case"named":return _i.named(e);case"primitive":return _i.primitive(e.primitive);case"unknown":return _i.unknown();default:return e}},untransform:({_visit:e,...t})=>t});var uHc={};$t(uHc,{VariableDeclaration:()=>Upu,VariableId:()=>Ffa});var sHc={};$t(sHc,{ExampleWebhookCall:()=>Lpu,InlinedWebhookPayload:()=>Gpu,InlinedWebhookPayloadProperty:()=>xpu,Webhook:()=>$pu,WebhookGroup:()=>Jpu,WebhookHttpMethod:()=>Vpu,WebhookName:()=>Wpu,WebhookPayload:()=>Kpu,WebhookPayloadReference:()=>Hpu});var cHc={};$t(cHc,{ExampleWebSocketMessage:()=>Xpu,ExampleWebSocketMessageBody:()=>Ypu,ExampleWebSocketSession:()=>Zpu,InlinedWebSocketMessageBody:()=>e_u,InlinedWebSocketMessageBodyProperty:()=>kpu,WebSocketChannel:()=>o_u,WebSocketMessage:()=>n_u,WebSocketMessageBody:()=>r_u,WebSocketMessageBodyReference:()=>t_u,WebSocketMessageId:()=>Gfa,WebSocketMessageOrigin:()=>i_u,WebSocketName:()=>a_u});var w7={integer:"integer",long:"long",uint:"uint",uint64:"uint64",float:"float",double:"double",boolean:"boolean",string:"string",datetime:"datetime",base64:"base64",uuid:"uuid",date:"date",bigint:"bigint",unknown:"unknown"};var DZ={MAP:/^map<\s*([^,]*)\s*,\s*(.*)\s*>$/,LIST:/^list<\s*(.*)\s*>$/,SET:/^set<\s*(.*)\s*>$/,OPTIONAL:/^optional<\s*(.*)\s*>$/,NULLABLE:/^nullable<\s*(.*)\s*>$/,LITERAL:/^literal<\s*(?:"(.*)"|(true|false))\s*>$/};function QAn({type:e,_default:t,validation:r,visitor:i}){switch(e){case w7.integer:{let u=r??void 0;return i.primitive({v1:Ps.Integer,v2:Cn.integer({default:t??void 0,validation:u!=null?{min:u.min,max:u.max,exclusiveMin:u.exclusiveMin,exclusiveMax:u.exclusiveMax,multipleOf:u.multipleOf}:void 0})})}case w7.double:{let u=r??void 0;return i.primitive({v1:Ps.Double,v2:Cn.double({default:t??void 0,validation:u!=null?{min:u.min,max:u.max,exclusiveMin:u.exclusiveMin,exclusiveMax:u.exclusiveMax,multipleOf:u.multipleOf}:void 0})})}case w7.string:{let u=r??void 0;return i.primitive({v1:Ps.String,v2:Cn.string({default:t??void 0,validation:u!=null?{format:u.format,pattern:u.pattern,minLength:u.minLength,maxLength:u.maxLength}:void 0})})}case w7.float:return i.primitive({v1:Ps.Float,v2:void 0});case w7.long:{let u=r??void 0;return i.primitive({v1:Ps.Long,v2:Cn.long({default:t??void 0,validation:u!=null?{min:u.min,max:u.max,exclusiveMin:u.exclusiveMin,exclusiveMax:u.exclusiveMax,multipleOf:u.multipleOf}:void 0})})}case w7.boolean:return i.primitive({v1:Ps.Boolean,v2:Cn.boolean({default:t??void 0})});case w7.datetime:return i.primitive({v1:Ps.DateTime,v2:void 0});case w7.date:return i.primitive({v1:Ps.Date,v2:void 0});case w7.uuid:return i.primitive({v1:Ps.Uuid,v2:void 0});case w7.base64:return i.primitive({v1:Ps.Base64,v2:void 0});case w7.bigint:return i.primitive({v1:Ps.BigInteger,v2:Cn.bigInteger({default:t??void 0})});case w7.uint:return i.primitive({v1:Ps.Uint,v2:void 0});case w7.uint64:return i.primitive({v1:Ps.Uint64,v2:void 0});case w7.unknown:return i.unknown()}let n=e.match(DZ.MAP);if(n?.[1]!=null&&n[2]!=null)return i.map({keyType:n[1],valueType:n[2]});let a=e.match(DZ.LIST);if(a?.[1]!=null)return i.list(a[1]);let o=e.match(DZ.SET);if(o?.[1]!=null)return i.set(o[1]);let c=e.match(DZ.OPTIONAL);if(c?.[1]!=null)return i.optional(c[1]);let d=e.match(DZ.NULLABLE);if(d?.[1]!=null)return i.nullable(d[1]);let s=e.match(DZ.LITERAL);if(s?.[1]!=null)return i.literal(rU.string(s[1]));if(s?.[2]!=null){let u=s[2];switch(u){case"false":return i.literal(rU.boolean(!1));case"true":return i.literal(rU.boolean(!0));default:throw new Error(`Unsupported literal value: ${u}`)}}return i.named(e)}var yrh="bytes";function FDe(e){if(e===yrh)return{isOptional:!1};if(e.match(DZ.OPTIONAL)?.[1]===yrh)return{isOptional:!0}}function Gka(e){let t=typeof e=="string"?e:typeof e.body=="string"?e.body:void 0;if(t!=null)return FDe(t)}function fHc({input:e,typeName:t}){for(let r of e.arguments)if(typeof r=="string"){if(r===t)return!0}else if(fHc({input:r,typeName:t}))return!0;return!1}function brh(e){return fHc({input:e,typeName:"file"})}function vrh(e){let t=0,r=0;function i(){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t>=e.length)return;let a="";for(;t<e.length&&e[t]!=="<"&&e[t]!==","&&e[t]!==">";)a+=e[t++];if(a.trim()){for(;t<e.length&&/\s/.test(e[t]);)t++;if(t<e.length&&e[t]==="<"){if(t++,r++,r>128)throw new Error("Internal error; Exceeded maximum recursion depth while parsing generics.");let o={name:a.trim(),arguments:[]};for(;t<e.length&&e[t]!==">";){for(;t<e.length&&/[\s,]/.test(e[t]);)t++;if(t<e.length&&e[t]!==">"){let c=i();c&&o.arguments.push(c)}}if(t<e.length&&e[t]===">")t++,r--;else throw new Error("Malformed input: missing closing '>' for generic arguments.");return o}else return a.trim()}}let n=i();if(typeof n=="object")return n}var dHc="file";function grh(e){return e.match(DZ.LIST)?.[1]===dHc}function BZ(e){if(e===dHc)return{isOptional:!1,isArray:!1};let t=e.match(DZ.OPTIONAL);if(t?.[1]!==void 0){if(t[1]===dHc)return{isOptional:!0,isArray:!1};if(grh(t[1]))return{isOptional:!0,isArray:!0}}if(grh(e))return{isOptional:!1,isArray:!0}}function SND(e){return typeof e=="string"?!1:Zm.parse(e["content-type"])?.isMultiPartFormData()??!1?!0:e.body==null?!1:!!(AE(e.body)&&Object.values(e.body.properties??[]).some(DND))}function UAn(e){if(!(!SND(e)||e.body==null)&&e.name!=null&&e.body!=null&&AE(e.body))return MND(e.name,e.body)}function MND(e,t){let r=Object.entries(t.properties??[]).reduce((i,[n,a])=>{let o=typeof a!="string"?a.docs:void 0,c=typeof a!="string"?a["content-type"]:void 0,d=typeof a!="string"?a.style:void 0,s=BZ(typeof a=="string"?a:a.type);return s!=null?i.push({isFile:!0,key:n,docs:o,isOptional:s.isOptional,isArray:s.isArray,contentType:c,style:d}):i.push({isFile:!1,key:n,propertyType:a,docs:o,contentType:c,style:d}),i},[]);return t["extra-properties"],{name:e,extends:t.extends,properties:r}}function DND(e){let t=typeof e=="string"?e:e.type;if(t==="file")return!0;if(!t.includes("file"))return!1;let r=vrh(t);return r==null?!1:brh(r)}var Orh="text";function LAn(e){if(e===Orh)return{isOptional:!1};if(e.match(DZ.OPTIONAL)?.[1]===Orh)return{isOptional:!0}}function Uq({type:e,_default:t,validation:r,visitor:i}){return QAn({type:e,_default:t,validation:r,visitor:{primitive:i.primitive,map:({keyType:n,valueType:a})=>i.map({keyType:Uq({type:n,_default:void 0,validation:void 0,visitor:i}),valueType:Uq({type:a,_default:void 0,validation:void 0,visitor:i})}),list:n=>i.list(Uq({type:n,_default:void 0,validation:void 0,visitor:i})),set:n=>i.set(Uq({type:n,_default:void 0,validation:void 0,visitor:i})),optional:n=>i.optional(Uq({type:n,_default:t,validation:r,visitor:i})),nullable:n=>i.nullable(Uq({type:n,_default:t,validation:r,visitor:i})),literal:i.literal,named:i.named,unknown:i.unknown}})}function pHc(e,t){if(BND(e))return t.sdk(e);if(IND(e))return t.language(e);de(e)}function BND(e){return e.sdk!=null}function IND(e){return e.language!=null}function mrh(e){return e["response-stream"]!=null&&(typeof e["response-stream"]=="string"||e["response-stream"].format==null||e["response-stream"].format==="json")}function Arh(e){return e["response-stream"]!=null&&typeof e["response-stream"]!="string"&&e["response-stream"].format==="sse"}function VAn(e,t,r){return CND(e,t)?r.stream(t):qND(e,t)?r.events(t):r.body(t)}function CND(e,t){return t.stream!==void 0&&mrh(e)}function qND(e,t){return t.stream!==void 0&&Arh(e)}function WAn(e,t){if(Prh(e))return t.single(e);if(jrh(e))return t.any(e);if(TND(e))return t.endpointSecurity(e);de(e)}function Prh(e){return typeof e=="string"||e.scheme!=null}function jrh(e){let[t,...r]=Object.keys(e);return t==="any"&&r.length===0}function TND(e){let[t,...r]=Object.keys(e);return t==="endpoint-security"&&r.length===0}function Hka(e,t){if(wrh(e))return t.header(e);switch(e.scheme){case"basic":return t.basic(e);case"bearer":return"get-token"in e?t.inferredBearer(e):t.tokenBearer(e);case"oauth":return t.oauth(e);default:de(e)}}function wrh(e){return e.header!=null}function k2t(e,t){if(Erh(e))return t.singleBaseUrl(e);if(Fme(e))return t.multipleBaseUrls(e);de(e)}function Erh(e){return typeof e=="string"||"url"in e}function Fme(e){return typeof e!="string"&&"urls"in e}function Yfa(e){return typeof e=="string"?e.startsWith("$"):"variable"in e}function Lq(e,t){if(d2i(e))return t.alias(e);if(p2i(e))return t.discriminatedUnion(e);if(Gv(e))return t.object(e);if(Xfa(e))return t.undiscriminatedUnion(e);if(I5t(e))return t.enum(e);de(e)}function d2i(e){return typeof e=="string"||e.type!=null}function Gv(e){return e.extends!=null||e.properties!=null}function p2i(e){return e.union!=null&&e.discriminated==null}function Xfa(e){let t=e;return t.union!=null&&t.discriminated!=null}function I5t(e){return e.enum!=null}var Srh=require("fs"),U_u=class{parse({absoluteFilePath:t}){let r=(0,Srh.readFileSync)(t,"utf-8"),i=r.match(/option\s+csharp_namespace\s*=\s*"([^"]+)";/),n=r.match(/package\s+([a-zA-Z_][\w.]*);/),a=r.match(/service\s+([a-zA-Z_]\w*)\s*{/);return{csharpNamespace:i?.[1],packageName:n?.[1],serviceName:a?.[1]}}};var EE=class{context;workspace;sourceCache;constructor(t,r){this.context=t,this.workspace=r,this.sourceCache=new Map}resolveSourceOrThrow({source:t,relativeFilepath:r}){let i=this.resolveSource({source:t});return i==null&&L2t(t)&&this.context.logger.warn(`Cannot resolve source ${t.proto} from file ${r}`),i}resolveSource({source:t}){return L2t(t)?this.resolveProtobufSource({source:t}):this.resolveOpenAPISource({source:t})}resolveProtobufSource({source:t}){let r=ot(this.workspace.absoluteFilePath,Pe.of(t.proto));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!HMe(r))return;let n=new U_u().parse({absoluteFilePath:r}),a={type:"protobuf",absoluteFilePath:r,relativeFilePath:Pe.of(t.proto),csharpNamespace:n.csharpNamespace,packageName:n.packageName,serviceName:n.serviceName};return this.sourceCache.set(r,a),a}resolveOpenAPISource({source:t}){let r=ot(this.workspace.absoluteFilePath,Pe.of(t.openapi));if(this.sourceCache.has(r))return this.sourceCache.get(r);if(!HMe(r))return;let i={type:"openapi",absoluteFilePath:r,relativeFilePath:Pe.of(t.openapi)};return this.sourceCache.set(r,i),i}};function _Hc({rawApiFileSchema:e,casingsGenerator:t}){if(e.auth==null)return{docs:void 0,requirement:vN.All,schemes:[]};let r=typeof e.auth!="string"?e.auth.docs:void 0;return WAn(e.auth,{single:i=>{let n=Mrh({reference:i,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t});return{docs:r,requirement:vN.All,schemes:[n]}},any:({any:i})=>({docs:r,requirement:vN.Any,schemes:i.map(n=>Mrh({reference:n,authSchemeDeclarations:e["auth-schemes"],casingsGenerator:t}))}),endpointSecurity:()=>({docs:r,requirement:vN.EndpointSecurity,schemes:[]})})}function Mrh({reference:e,authSchemeDeclarations:t,casingsGenerator:r}){let i=(a,o)=>{let c=t?.[a];if(c==null)throw new Error("Unknown auth scheme: "+a);return Hka(c,{header:d=>mP.header({key:a,docs:o,name:r.generateNameAndWireValue({name:d.name??a,wireValue:d.header}),valueType:_i.primitive({v1:Ps.String,v2:Cn.string({default:void 0,validation:void 0})}),prefix:d.prefix,headerEnvVar:d.env}),basic:d=>Drh({key:a,casingsGenerator:r,docs:o,rawScheme:d}),tokenBearer:d=>L_u({key:a,casingsGenerator:r,docs:o,rawScheme:d}),inferredBearer(d){return L_u({key:a,casingsGenerator:r,docs:o,rawScheme:void 0})},oauth:d=>L_u({key:a,casingsGenerator:r,docs:o,rawScheme:void 0})})},n=typeof e=="string"?e:e.scheme;switch(n){case"bearer":case"oauth":return L_u({key:n,casingsGenerator:r,docs:void 0,rawScheme:void 0});case"basic":return Drh({key:n,casingsGenerator:r,docs:void 0,rawScheme:void 0});default:return i(n,typeof e!="string"?e.docs:void 0)}}function L_u({key:e,casingsGenerator:t,docs:r,rawScheme:i}){return mP.bearer({key:e,docs:r,token:t.generateName(i?.token?.name??"token"),tokenEnvVar:i?.token?.env})}function Drh({key:e,casingsGenerator:t,docs:r,rawScheme:i}){return mP.basic({key:e,docs:r,username:t.generateName(i?.username?.name??"username"),usernameEnvVar:i?.username?.env,usernameOmit:i?.username?.omit,password:t.generateName(i?.password?.name??"password"),passwordEnvVar:i?.password?.env,passwordOmit:i?.password?.omit})}function HD(e){let t=zND(e),{value:r,done:i}=hHc(t,"{");return i?{head:r,parts:[]}:{head:r,parts:[...RND(t)]}}function*RND(e){let t;do{let{value:r}=hHc(e,"}"),i=hHc(e,"{");t=i.done,yield{pathParameter:r,tail:i.value}}while(!t)}function*zND(e){for(let t of e)yield t}function hHc(e,t){let r="",i=e.next();for(;i.done!==!0&&i.value!==t;)r+=i.value,i=e.next();return{value:r,done:i.done??!1}}function Kka({rawApiFileSchema:{"default-environment":e,environments:t},casingsGenerator:r}){if(t==null)return;let i=Object.values(t)[0];if(i!=null)return{environmentsConfig:{defaultEnvironment:e??void 0,environments:k2t(i,{singleBaseUrl:()=>xD.singleBaseUrl(NND({environments:t,casingsGenerator:r})),multipleBaseUrls:n=>xD.multipleBaseUrls(FND({baseUrls:Object.keys(n.urls),environments:t,casingsGenerator:r}))})},audiences:{...Object.fromEntries(Object.entries(t).map(([n,a])=>[n,k2t(a,{singleBaseUrl:o=>[...typeof o=="string"?[]:o.audiences??[]],multipleBaseUrls:o=>[...o.audiences??[]]})]))}}}function NND({environments:e,casingsGenerator:t}){return{environments:Object.entries(e).map(([r,i])=>k2t(i,{singleBaseUrl:n=>({docs:typeof n=="string"?void 0:n.docs,id:r,name:t.generateName(r),url:Brh(typeof n=="string"?n:n.url)}),multipleBaseUrls:()=>{throw new Error(`Environment ${r} has multiple base URLs`)}}))}}function FND({baseUrls:e,environments:t,casingsGenerator:r}){return{baseUrls:e.map(i=>({id:i,name:r.generateName(i)})),environments:Object.entries(t).map(([i,n])=>k2t(n,{multipleBaseUrls:a=>({docs:a.docs,id:i,name:r.generateName(i),urls:gn(a.urls,o=>Brh(o))}),singleBaseUrl:()=>{throw new Error(`Environment ${i} does not have multiple base URLs`)}}))}}function Brh(e){return e.endsWith("/")?e.slice(0,-1):e}function _2i(e){let t=2166136261;function r(n,a){if(typeof n=="object"&&n!=null){if(a>64){i("[MaxDepthExceeded]");return}if(Array.isArray(n)){i("[");for(let o=0;o<n.length;o++)o>0&&i(","),r(n[o],a+1);i("]")}else i("{"),Object.keys(n).sort().forEach((c,d)=>{d>0&&i(","),i(c),i(":"),r(n[c],a+1)}),i("}")}else i(String(n))}function i(n){for(let a=0;a<n.length;a++){let o=n.charCodeAt(a);t^=o,t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24),t>>>=0}}return r(e,0),t.toString(16)}function ekt({typeReference:e,typeDeclarations:t}){if(e.type==="container"&&e.container.type==="optional")return!0;if(e.type==="named"){let r=t?.[e.typeId];if(r?.shape.type==="alias"&&r?.shape.resolvedType.type==="container"&&r?.shape.resolvedType.container.type==="optional")return!0}return!1}function Irh({fieldName:e,containerType:t,maxDepth:r,currentDepth:i,typeDeclarations:n,skipOptionalProperties:a}){if(i>=r)return tkt({containerType:t});switch(t.type){case"list":{let o=PP({fieldName:e,typeReference:t.list,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?tkt({containerType:t}):{type:"success",example:S_.list({list:[o.example,o.example],itemType:t.list}),jsonExample:[o.jsonExample,o.jsonExample]}}case"literal":return{type:"success",example:S_.literal({literal:t.literal._visit({boolean:o=>Xn.boolean(o),string:o=>Xn.string({original:o}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:t.literal._visit({boolean:o=>o,string:o=>o,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":{if(a)return tkt({containerType:t});let o=PP({fieldName:e,typeReference:t.optional,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?tkt({containerType:t}):{type:"success",example:S_.optional({optional:o.example,valueType:t.optional}),jsonExample:o.jsonExample}}case"nullable":{if(a)return tkt({containerType:t});let o=PP({fieldName:e,typeReference:t.nullable,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?tkt({containerType:t}):{type:"success",example:S_.nullable({nullable:o.example,valueType:t.nullable}),jsonExample:o.jsonExample}}case"set":{let o=PP({fieldName:e,typeReference:t.set,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"?tkt({containerType:t}):{type:"success",example:S_.set({set:[o.example],itemType:t.set}),jsonExample:[o.jsonExample]}}case"map":{let o=PP({fieldName:e,typeReference:t.keyType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a}),c=PP({fieldName:e,typeReference:t.valueType,maxDepth:r,currentDepth:i+1,typeDeclarations:n,skipOptionalProperties:a});return o.type==="failure"||c.type==="failure"?tkt({containerType:t}):{type:"success",example:S_.map({map:[{key:o.example,value:c.example}],keyType:t.keyType,valueType:t.valueType}),jsonExample:{[o.jsonExample]:c.jsonExample}}}default:de(t)}}function tkt({containerType:e}){switch(e.type){case"list":return{type:"success",example:S_.list({list:[],itemType:e.list}),jsonExample:[]};case"literal":return{type:"success",example:S_.literal({literal:e.literal._visit({boolean:t=>Xn.boolean(t),string:t=>Xn.string({original:t}),_other:()=>{throw new Error("Encountered unknown literal type")}})}),jsonExample:e.literal._visit({boolean:t=>t,string:t=>t,_other:()=>{throw new Error("Encountered unknown literal type")}})};case"optional":return{type:"success",example:S_.optional({optional:void 0,valueType:e.optional}),jsonExample:void 0};case"nullable":return{type:"success",example:S_.nullable({nullable:void 0,valueType:e.nullable}),jsonExample:void 0};case"set":return{type:"success",example:S_.set({set:[],itemType:e.set}),jsonExample:[]};case"map":return{type:"success",example:S_.map({map:[],keyType:e.keyType,valueType:e.valueType}),jsonExample:{}};default:de(e)}}function qrh({fieldName:e,primitiveType:t}){switch(t.v1){case"STRING":return WND({fieldName:e,default_:QND(t.v2),validation:UND(t.v2)});case"BASE_64":return{type:"success",example:Xn.base64(la.BASE64),jsonExample:la.BASE64};case"BOOLEAN":return{type:"success",example:Xn.boolean(la.BOOLEAN),jsonExample:la.BOOLEAN};case"DATE":return{type:"success",example:Xn.date(la.DATE),jsonExample:la.DATE};case"DATE_TIME":return{type:"success",example:Xn.datetime({datetime:new Date(la.DATE_TIME),raw:la.DATE_TIME}),jsonExample:la.DATE_TIME};case"DOUBLE":return xND({fieldName:e,validation:LND(t.v2)});case"FLOAT":return{type:"success",example:Xn.float(la.FLOAT),jsonExample:la.FLOAT};case"INTEGER":return GND({fieldName:e,validation:VND(t.v2)});case"UINT_64":return{type:"success",example:Xn.uint64(la.INT64),jsonExample:la.INT64};case"UINT":return{type:"success",example:Xn.uint(la.UINT),jsonExample:la.UINT};case"BIG_INTEGER":return{type:"success",example:Xn.bigInteger(la.INT64.toString()),jsonExample:`${la.INT64}`};case"LONG":return{type:"success",example:Xn.long(la.INT64),jsonExample:la.INT64};case"UUID":return{type:"success",example:Xn.uuid(la.UUID),jsonExample:la.UUID};default:de(t.v1)}}function QND(e){if(e?.type==="string")return e.default}function UND(e){if(e?.type==="string")return e.validation}function LND(e){if(e?.type==="double")return e.validation}function VND(e){if(e?.type==="integer")return e.validation}function Crh(e){if(e<=0)return"";if(e<=la.SAMPLE_STRINGS.length){let t=la.SAMPLE_STRINGS[e-1];if(t)return t;throw new Error(`Unexpected undefined value in SAMPLE_STRINGS at index ${e-1}`)}return la.SAMPLE_STRINGS[la.SAMPLE_STRINGS.length-1]+".".repeat(e-la.SAMPLE_STRINGS.length)}function WND({fieldName:e,default_:t,validation:r}){if(t!=null)return{type:"success",example:Xn.string({original:t}),jsonExample:t};if(r){let n=r.minLength,a=r.maxLength;if(n){let o=Crh(n);return{type:"success",example:Xn.string({original:o}),jsonExample:o}}else if(a!=null&&a<10){let o=Crh(a);return{type:"success",example:Xn.string({original:o}),jsonExample:o}}}let i=e??la.STRING;return{type:"success",example:Xn.string({original:i}),jsonExample:i}}function xND({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Xn.double(r),jsonExample:r};if(i)return{type:"success",example:Xn.double(i),jsonExample:i}}return{type:"success",example:Xn.double(la.DOUBLE),jsonExample:la.DOUBLE}}function GND({fieldName:e,validation:t}){if(t){let r=t.max,i=t.min;if(r)return{type:"success",example:Xn.integer(r),jsonExample:r};if(i)return{type:"success",example:Xn.integer(i),jsonExample:i}}return{type:"success",example:Xn.integer(la.INT),jsonExample:la.INT}}function HND(e,t){if(e.type==="primitive"||e.type==="container"&&e.container.type==="literal")return!0;if(e.type==="named"){let r=t[e.typeId];if(r!=null&&r.shape.type==="enum")return!0}return!1}function xAn({fieldName:e,typeDeclarations:t,typeDeclaration:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){switch(r.shape.type){case"alias":{let o=PP({fieldName:e,typeDeclarations:t,typeReference:r.shape.aliasOf,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(o.type==="failure")return o;let{example:c,jsonExample:d}=o;return{type:"success",example:ib.alias({value:c}),jsonExample:d}}case"enum":{let o=r.shape.values[0];return o==null?{type:"failure",message:"No enum values present"}:{type:"success",example:ib.enum({value:o.name}),jsonExample:o.name.wireValue}}case"object":{let o={},c=[];if((r.shape.extendedProperties==null||r.shape.extendedProperties.length===0)&&r.shape.extends!=null)for(let f of r.shape.extends){let p=t[f.typeId];if(p==null)continue;let _=xAn({fieldName:e,typeDeclaration:p,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});_!=null&&_.type==="success"&&_.example.type==="object"&&(Object.assign(o,_.jsonExample),c.push(..._.example.properties))}let d=KND({fieldName:e,typeDeclaration:r,objectTypeDeclaration:r.shape,typeDeclarations:t,currentDepth:n,maxDepth:i,skipOptionalProperties:a});if(d.type==="failure")return d;let{example:s,jsonExample:u}=d;return{type:"success",example:ib.object({properties:[...c,...s.properties],extraProperties:s.extraProperties}),jsonExample:Object.assign({},o,u)}}case"undiscriminatedUnion":{let o=r.shape.members;if(o.every(s=>HND(s.type,t))){let s=o.findIndex(u=>{if(u.type.type==="container"&&u.type.container.type==="literal")return!0;if(u.type.type==="named"){let f=t[u.type.typeId];if(f!=null&&f.shape.type==="enum")return f.shape.values.length>0}return!1});if(s!==-1){let u=o[s];if(u!=null){let f=PP({fieldName:e,typeReference:u.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(f.type==="success"){let{example:p,jsonExample:_}=f;return{type:"success",example:ib.undiscriminatedUnion({index:s,singleUnionType:p}),jsonExample:_}}}}}let d=0;for(let s of o){let u=PP({fieldName:e,typeReference:s.type,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(u.type==="failure"){++d;continue}let{example:f,jsonExample:p}=u;return{type:"success",example:ib.undiscriminatedUnion({index:d,singleUnionType:f}),jsonExample:p}}break}case"union":{let o=r.shape.discriminant,c={};if(r.shape.baseProperties!=null)for(let u of r.shape.baseProperties){let f=PP({fieldName:u.name.wireValue,typeReference:u.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});f.type==="success"&&(c[u.name.wireValue]=f.jsonExample)}let d=r.shape.baseProperties.map(u=>{let f=PP({fieldName:u.name.wireValue,typeReference:u.valueType,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(f.type==="failure")throw new Error(`Failed to generate example for union base property ${u.name.wireValue}`);let{example:p}=f;return{name:u.name,value:p}}),s=r.shape.extends.flatMap(u=>{let f=t[u.typeId];if(f==null)throw new Error(`Failed to find extended type declaration with id ${u.typeId}`);let p=xAn({fieldName:e,typeDeclaration:f,typeDeclarations:t,currentDepth:n+1,maxDepth:i,skipOptionalProperties:a});if(p==null||p.type==="failure")throw new Error(`Failed to generate example for extended type declaration ${f.name.typeId}`);if(p.example.type!=="object")throw new Error(`Extended type declaration ${f.name.typeId} is not an object`);return p.example.properties});for(let u of r.shape.types){let f=u.shape._visit({noProperties:()=>({type:"success",example:ib.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:Qq.noProperties()},baseProperties:d,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,...c}}),samePropertiesAsObject:p=>{let _=t[p.typeId];if(_==null)return{type:"failure",message:`Failed to find type declaration with id ${p.typeId}`};let h=xAn({currentDepth:n,maxDepth:i,fieldName:e,typeDeclaration:_,typeDeclarations:t,skipOptionalProperties:a});if(h==null)return{type:"failure",message:"Failed to generate example for type reference"};if(h.type==="failure")return h;let{example:y,jsonExample:b}=h;return{type:"success",example:ib.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:Qq.samePropertiesAsObject({typeId:_.name.typeId,object:y.type==="object"?y:{properties:[],extraProperties:void 0}})},baseProperties:d,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,...typeof b=="object"?b:{},...c}}},singleProperty:p=>{let _=PP({currentDepth:n+1,maxDepth:i,fieldName:e,typeReference:p.type,typeDeclarations:t,skipOptionalProperties:a});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;return{type:"success",example:ib.union({discriminant:o,singleUnionType:{wireDiscriminantValue:u.discriminantValue,shape:Qq.singleProperty(h)},baseProperties:d,extendProperties:s}),jsonExample:{[o.wireValue]:u.discriminantValue.wireValue,[p.name.wireValue]:y,...c}}},_other:()=>{throw new Error("Encountered unknown union type")}});if(f.type!=="failure")return f}}}return{type:"failure",message:"Failed to generate example for type reference"}}function KND({fieldName:e,typeDeclaration:t,objectTypeDeclaration:r,typeDeclarations:i,maxDepth:n,currentDepth:a,skipOptionalProperties:o}){let c={},d=[];for(let s of[...r.properties??[],...r.extendedProperties??[]]){let u=PP({fieldName:s.name.wireValue,typeReference:s.valueType,typeDeclarations:i,currentDepth:a+1,maxDepth:n,skipOptionalProperties:o});if(u.type==="failure"&&!ekt({typeDeclarations:i,typeReference:s.valueType}))return{type:"failure",message:`Failed to generate required property ${s.name.wireValue} b/c ${u.message}`};if(u.type==="failure")continue;let{example:f,jsonExample:p}=u;d.push({name:s.name,originalTypeDeclaration:t.name,value:f,propertyAccess:s.propertyAccess}),c[s.name.wireValue]=p}return{type:"success",example:ib.object({properties:d,extraProperties:void 0}),jsonExample:c}}function PP({fieldName:e,typeReference:t,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a}){if(n>i)return{type:"failure",message:`Exceeded max depth of ${i}`};switch(t.type){case"named":{let o=r[t.typeId];if(o==null)return{type:"failure",message:`Failed to find type declaration with id ${t.typeId}`};let c=xAn({fieldName:e,typeDeclaration:o,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(c==null)return{type:"failure",message:"Failed to generate example for type declaration"};if(c.type==="failure")return c;let{example:d,jsonExample:s}=c;return{type:"success",example:{jsonExample:s,shape:as.named({shape:d,typeName:o.name})},jsonExample:s}}case"container":{let o=Irh({fieldName:e,containerType:t.container,typeDeclarations:r,maxDepth:i,currentDepth:n,skipOptionalProperties:a});if(o.type==="failure"){let{example:s,jsonExample:u}=tkt({containerType:t.container});return{type:"success",example:{jsonExample:u,shape:as.container(s)},jsonExample:u}}let{example:c,jsonExample:d}=o;return{type:"success",example:{jsonExample:d,shape:as.container(c)},jsonExample:d}}case"primitive":{let{jsonExample:o,example:c}=qrh({fieldName:e,primitiveType:t.primitive});return{type:"success",example:{jsonExample:o,shape:as.primitive(c)},jsonExample:o}}case"unknown":{let o={key:"value"};return{type:"success",example:{jsonExample:o,shape:as.unknown(o)},jsonExample:o}}}}function GAn(e,t){let r=[];for(let i of e){let n=PP({fieldName:i.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function Zfa(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&ekt({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=PP({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??1,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,value:n.example})}return{type:"success",example:r,jsonExample:void 0}}function V_u(e,t){let r=[];for(let i of e){if(t.skipOptionalRequestProperties&&ekt({typeDeclarations:t.typeDeclarations,typeReference:i.valueType}))continue;let n=PP({fieldName:i.name.name.originalName,currentDepth:0,maxDepth:t.maxDepth??10,typeDeclarations:t.typeDeclarations,typeReference:i.valueType,skipOptionalProperties:t.skipOptionalRequestProperties});if(n.type==="failure")return n;r.push({name:i.name,shape:i.allowMultiple?gN.exploded():gN.single(),value:n.example})}return{type:"success",example:r,jsonExample:void 0}}var yHc=_i.primitive({v1:Ps.String,v2:Cn.string({default:void 0,validation:void 0})});function kfa({ir:e,endpoint:t,service:r,typeDeclarations:i,skipOptionalRequestProperties:n,generationResponse:a}){let o={name:void 0,endpointHeaders:[],endpointPathParameters:[],queryParameters:[],servicePathParameters:[],serviceHeaders:[],rootPathParameters:[],request:void 0,response:Zw.ok(PE.body(void 0)),docs:void 0},c=GAn(t.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(c.type==="failure")return c;o.endpointPathParameters=c.example;let d=GAn(r.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(d.type==="failure")return d;o.servicePathParameters=d.example;let s=GAn(e.pathParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(s.type==="failure")return s;o.rootPathParameters=s.example;let u=V_u(t.queryParameters,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:10});if(u.type==="failure")return u;o.queryParameters=u.example;let f=Zfa(t.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(f.type==="failure")return f;o.endpointHeaders=f.example;let p=Zfa(r.headers,{typeDeclarations:i,skipOptionalRequestProperties:n,maxDepth:1});if(p.type==="failure")return p;if(o.serviceHeaders=p.example,t.requestBody!=null)switch(t.requestBody.type){case"bytes":return{type:"failure",message:"Bytes request unsupported"};case"fileUpload":return{type:"failure",message:"File upload unsupported"};case"inlinedRequestBody":{let _={},h=[];if(t.requestBody.extends!=null)for(let y of t.requestBody.extends){let b=i[y.typeId];if(b==null)throw new Error(`Failed to find extended type declaration with id ${y.typeId}`);let v=xAn({typeDeclaration:b,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});v!=null&&v.type==="success"&&Object.assign(_,v.jsonExample)}for(let y of[...t.requestBody.properties??[],...t.requestBody.extendedProperties??[]]){let b=PP({fieldName:y.name.wireValue,typeReference:y.valueType,typeDeclarations:i,currentDepth:1,maxDepth:10,skipOptionalProperties:n});if(b.type==="failure"&&!ekt({typeDeclarations:i,typeReference:y.valueType}))return{type:"failure",message:`Failed to generate required property ${y.name.wireValue} b/c ${b.message}`};if(b.type==="failure")continue;let{example:v,jsonExample:O}=b;h.push({name:y.name,originalTypeDeclaration:void 0,value:v}),_[y.name.wireValue]=O}o.request=O5.inlinedRequestBody({jsonExample:_,properties:h,extraProperties:void 0});break}case"reference":{let _=PP({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.requestBody.requestBodyType,skipOptionalProperties:n});if(_.type==="failure")return _;let{example:h}=_;o.request=O5.reference(h);break}default:de(t.requestBody)}if(a.type==="success"&&t.response?.body!=null)switch(t.response.body.type){case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":{let _=PP({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.responseBodyType,skipOptionalProperties:!1});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=Zw.ok(PE.body({...h,jsonExample:y}));break}case"streamParameter":{let _;switch(t.response.body.nonStreamResponse.type){case"bytes":return{type:"failure",message:"Bytes unsupported"};case"fileDownload":return{type:"failure",message:"File download unsupported"};case"json":_=PP({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.nonStreamResponse.value.responseBodyType,skipOptionalProperties:!1});break;case"text":_=PP({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:yHc,skipOptionalProperties:!1});break;default:de(t.response.body.nonStreamResponse)}if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=Zw.ok(PE.body({...h,jsonExample:y}));break}case"streaming":{let _;switch(t.response.body.value.type){case"sse":{if(_=PP({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=Zw.ok(PE.sse([{data:{...h,jsonExample:y},event:""}]));break}case"json":{if(_=PP({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:t.response.body.value.payload,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=Zw.ok(PE.stream([{...h,jsonExample:y}]));break}case"text":{if(_=PP({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:yHc,skipOptionalProperties:!1}),_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=Zw.ok(PE.stream([{...h,jsonExample:y}]));break}default:de(t.response.body.value)}break}case"text":{let _=PP({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:yHc,skipOptionalProperties:!1});if(_.type==="failure")return _;let{example:h,jsonExample:y}=_;o.response=Zw.ok(PE.body({...h,jsonExample:y}));break}case"bytes":return{type:"failure",message:"Bytes unsupported"};default:de(t.response.body)}else if(a.type==="error")if(a.declaration.type==null)o.response=Zw.error({body:void 0,error:a.declaration.name});else{let _=PP({currentDepth:0,maxDepth:10,typeDeclarations:i,typeReference:a.declaration.type,skipOptionalProperties:n});if(_.type==="failure")return _;let{example:h}=_;o.response=Zw.error({body:h,error:a.declaration.name})}try{return{type:"success",example:{id:_2i(o),url:$ND(t,o),...o},jsonExample:void 0}}catch(_){return{type:"failure",message:`Parse failure with exceptions ${_}`}}}function $ND(e,t){let r={};[...t.rootPathParameters,...t.servicePathParameters,...t.endpointPathParameters].forEach(n=>{let a=n.value.jsonExample,o=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=o});let i=e.fullPath.head+e.fullPath.parts.map(n=>encodeURIComponent(`${r[n.pathParameter]}`)+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function bHc({ir:e,channel:t,typeDeclarations:r,skipOptionalRequestProperties:i}){let n={name:void 0,pathParameters:[],headers:[],queryParameters:[],messages:[],docs:void 0},a=GAn(t.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(a.type==="failure")return a;n.pathParameters.push(...a.example);let o=GAn(e.pathParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(o.type==="failure")return o;n.pathParameters.push(...o.example);let c=V_u(t.queryParameters,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:10});if(c.type==="failure")return c;n.queryParameters=c.example;let d=Zfa(t.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(d.type==="failure")return d;n.headers.push(...d.example);let s=Zfa(e.headers,{typeDeclarations:r,skipOptionalRequestProperties:i,maxDepth:1});if(s.type==="failure")return s;n.headers.push(...s.example);let f=t.messages.filter(h=>h.origin==="client")[0];if(f!=null){let h=Trh({message:f,typeDeclarations:r,skipOptionalRequestProperties:i});h!=null&&n.messages.push({type:f.type,body:h})}let _=t.messages.filter(h=>h.origin==="server")[0];if(_!=null){let h=Trh({message:_,typeDeclarations:r,skipOptionalRequestProperties:i});h!=null&&n.messages.push({type:_.type,body:h})}return{type:"success",example:{...n,url:JND(t,n)},jsonExample:void 0}}function Trh({message:e,typeDeclarations:t,skipOptionalRequestProperties:r}){if(e.body.type==="inlinedBody")return;let i=PP({currentDepth:0,maxDepth:10,typeDeclarations:t,typeReference:e.body.bodyType,skipOptionalProperties:r});if(i.type==="success")return zme.reference(i.example)}function JND(e,t){let r={};[...t.pathParameters].forEach(n=>{let a=n.value.jsonExample,o=typeof a=="string"?a:JSON.stringify(a);r[n.name.originalName]=o});let i=e.path.head+e.path.parts.map(n=>encodeURIComponent(`${r[n.pathParameter]}`)+n.tail).join("");return i.startsWith("/")||i===""?i:`/${i}`}function eda(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{},i=Object.values(t)[0],n=Object.values(r)[0];return{userExample:i,autoExample:n}}function h2i(e){let t=e?.userSpecifiedExamples??{},r=e?.autogeneratedExamples??{};return{userExamples:t,autoExamples:r}}function Rrh({ir:e,endpoint:t,skipOptionalRequestProperties:r}){let i=e.types,n={pathParameters:{},queryParameters:{},headers:{}};for(let o of t.pathParameters){let{userExample:c,autoExample:d}=eda(o.v2Examples);c!==void 0?n.pathParameters[o.name.originalName]=c:d!==void 0&&(n.pathParameters[o.name.originalName]=d)}for(let o of t.queryParameters){let{userExample:c,autoExample:d}=eda(o.v2Examples);if(c!==void 0)n.queryParameters[o.name.name.originalName]=c;else if(d!==void 0){if(r&&ekt({typeReference:o.valueType,typeDeclarations:i}))continue;n.queryParameters[o.name.name.originalName]=d}}let a=[...t.headers,...e.headers,...e.idempotencyHeaders];for(let o of a){let{userExample:c,autoExample:d}=eda(o.v2Examples);if(c!==void 0)n.headers[o.name.wireValue]=c;else if(d!==void 0){if(r&&ekt({typeReference:o.valueType,typeDeclarations:i}))continue;n.headers[o.name.wireValue]=d}}return n}function zrh({endpoint:e,ir:t,skipOptionalRequestProperties:r}){let{pathParameters:i,queryParameters:n,headers:a}=Rrh({endpoint:e,ir:t,skipOptionalRequestProperties:r}),o={},c={},d={endpoint:{method:e.method,path:YND(e)},baseUrl:void 0,environment:e.baseUrl,auth:void 0,pathParameters:i,queryParameters:n,headers:a,requestBody:void 0,docs:void 0};if(e.requestBody!=null)switch(e.requestBody.type){case"bytes":break;case"fileUpload":{let{userExamples:s,autoExamples:u}=h2i(e.requestBody.v2Examples);for(let[f,p]of Object.entries(s))o[f]={...d,requestBody:p};for(let[f,p]of Object.entries(u))c[f]={...d,requestBody:p};break}case"inlinedRequestBody":{let{userExamples:s,autoExamples:u}=h2i(e.requestBody.v2Examples);for(let[f,p]of Object.entries(s))o[f]={...d,requestBody:p};for(let[f,p]of Object.entries(u))c[f]={...d,requestBody:p};break}case"reference":{let{userExamples:s,autoExamples:u}=h2i(e.requestBody.v2Examples);for(let[f,p]of Object.entries(s))o[f]={...d,requestBody:p};for(let[f,p]of Object.entries(u))c[f]={...d,requestBody:p};break}default:de(e.requestBody)}return{userRequestExamples:o,autoRequestExamples:c,baseExample:d}}function YND(e){let t={};[...e.pathParameters,...e.allPathParameters].forEach(i=>{let{userExample:n,autoExample:a}=eda(i.v2Examples),o=n??a,c;o==null?c=i.name.originalName:c=typeof o=="string"?o:JSON.stringify(o),t[i.name.originalName]=c});let r=e.fullPath.head+e.fullPath.parts.map(i=>encodeURIComponent(`${t[i.pathParameter]}`)+i.tail).join("");return r.startsWith("/")||r===""?r:`/${r}`}function W_u({endpoint:e,responseObject:t}){let r=t!==void 0?t:e.response,i={},n={},a={statusCode:r?.statusCode,body:void 0,docs:void 0};if(r==null)return{userResponseExamples:{},autoResponseExamples:{},baseExample:a};if(r.body==null)return e.source?.type==="openrpc"?{userResponseExamples:{},autoResponseExamples:{},baseExample:{...a,body:aR.json($ka(null))}}:{userResponseExamples:{},autoResponseExamples:{},baseExample:a};switch(r.body.type){case"bytes":break;case"fileDownload":break;case"text":{let o=r.body,{userExamples:c,autoExamples:d}=h2i(o.v2Examples);for(let[s,u]of Object.entries(c)){let f=e.source?.type==="openrpc"?$ka(u):u;i[s]={...a,body:aR.json(f)}}for(let[s,u]of Object.entries(d)){let f=e.source?.type==="openrpc"?$ka(u):u;n[s]={...a,body:aR.json(f)}}break}case"json":{let o=r.body.value;if(o.type==="response"){let{userExamples:c,autoExamples:d}=h2i(o.v2Examples);for(let[s,u]of Object.entries(c)){let f=e.source?.type==="openrpc"?$ka(u):u;i[s]={...a,body:aR.json(f)}}for(let[s,u]of Object.entries(d)){let f=e.source?.type==="openrpc"?$ka(u):u;n[s]={...a,body:aR.json(f)}}}break}case"streaming":{let o=r.body.value;if(o.type==="json"){let{userExamples:c,autoExamples:d}=h2i(o.v2Examples);for(let[s,u]of Object.entries(c))i[s]={...a,body:aR.stream([u])};for(let[s,u]of Object.entries(d))n[s]={...a,body:aR.stream([u])}}break}case"streamParameter":break;default:de(r.body)}return{userResponseExamples:i,autoResponseExamples:n,baseExample:a}}function $ka(e,t=1){return{id:t,jsonrpc:"2.0",result:e}}var tda=(e,t,r)=>{let i;return e===t?i=`${e}`:i=`${e}_${t}`,r&&(i=`${i}_${r}`),i},XND=({exampleStore:e,key:t,example:r})=>e.has(t)?!1:(e.set(t,r),!0);function x_u({key:e,displayName:t,request:r,response:i,exampleStore:n,userOrAutoStore:a}){if(!n.has(e)){let o={displayName:t,request:r,response:i,codeSamples:void 0};return a[e]=o,XND({exampleStore:n,key:e,example:o}),!0}return!1}function Nrh({endpoint:e,ir:t,skipOptionalRequestProperties:r}){let i={},n={},a=new Map,{userRequestExamples:o,autoRequestExamples:c,baseExample:d}=zrh({endpoint:e,ir:t,skipOptionalRequestProperties:r}),s=Object.keys(o)[0],u=Object.values(o)[0],f=Object.keys(c)[0],p=Object.values(c)[0],_=ZND({endpoint:e,userRequestExamples:o,baseRequestExample:d,firstUserRequestName:s,firstUserRequestExample:u,firstAutoRequestName:f,firstAutoRequestExample:p,userResults:i,autoResults:n,exampleStore:a});if(kND({endpoint:e,userRequestExamples:o,requestExamplesUsed:_,userResults:i,exampleStore:a}),Object.keys(i).length===0&&Object.keys(n).length===0){let{baseExample:h}=W_u({endpoint:e}),y=tda(f??"base","base",void 0);x_u({key:y,displayName:f??"base",request:p??d,response:h,exampleStore:a,userOrAutoStore:n})}return{userFullExamples:i,autoFullExamples:n}}function ZND({endpoint:e,userRequestExamples:t,baseRequestExample:r,firstUserRequestName:i,firstUserRequestExample:n,firstAutoRequestName:a,firstAutoRequestExample:o,userResults:c,autoResults:d,exampleStore:s}){let u=e.v2Responses?.responses??[e.response],f=new Set;for(let p of u){let _=!1,{userResponseExamples:h,autoResponseExamples:y,baseExample:b}=W_u({endpoint:e,responseObject:p}),v=Object.keys(y)[0],O=Object.values(y)[0];for(let[m,g]of Object.entries(h)){let A,j;t[m]?(j=t[m],f.add(m),A=tda(m,m,p?.statusCode)):o&&a?(j=o,A=tda(a,m,p?.statusCode)):(j=r,A=tda("base",m,p?.statusCode)),x_u({key:A,displayName:m,request:j,response:g,exampleStore:s,userOrAutoStore:c})&&(_=!0)}if(!_){let m=mn(`${e.name.originalName}_example`);i&&n&&f.add(i);let g=tda(i??a??"base",v??"base",p?.statusCode);x_u({key:g,displayName:i??a??m,request:n??o??r,response:O??b,exampleStore:s,userOrAutoStore:d})&&(_=!0)}}return f}function kND({endpoint:e,userRequestExamples:t,requestExamplesUsed:r,userResults:i,exampleStore:n}){let{userResponseExamples:a,autoResponseExamples:o,baseExample:c}=W_u({endpoint:e}),d=Object.values(a)[0],s=Object.keys(a)[0],u=Object.keys(o)[0],f=Object.values(o)[0],p=Object.entries(t).filter(([_])=>!r.has(_));for(let[_,h]of p){let y=tda(_,s??u??"base",d?d.statusCode:f?f.statusCode:c.statusCode);x_u({key:y,displayName:_,request:h,response:d??f??c,exampleStore:n,userOrAutoStore:i})}}function Jka({ir:e,exampleGeneration:t}){let r={disabled:t.disabled,includeOptionalRequestPropertyExamples:t.includeOptionalRequestPropertyExamples??!1,skipAutogenerationIfManualExamplesExist:t.skipAutogenerationIfManualExamplesExist??!1,skipErrorAutogenerationIfManualErrorExamplesExist:t.skipErrorAutogenerationIfManualErrorExamplesExist??!1};for(let[i,n]of Object.entries(e.services))for(let a of n.endpoints){let o=[];if(a.userSpecifiedExamples.length===0||r.skipAutogenerationIfManualExamplesExist===!1){let c=kfa({ir:e,service:n,endpoint:a,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples,generationResponse:{type:"success"}});c.type==="success"&&o.push({example:c.example})}if(a.userSpecifiedExamples.filter(c=>c.example?.response.type==="error").length===0||r.skipErrorAutogenerationIfManualErrorExamplesExist===!1)for(let c of a.errors){let d=e.errors[c.error.errorId];if(!d)continue;let s=kfa({ir:e,service:n,endpoint:a,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples,generationResponse:{type:"error",declaration:d}});s.type==="success"&&o.push({example:s.example})}a.autogeneratedExamples=o}for(let[i,n]of Object.entries(e.websocketChannels??{})){if(n.examples.length>0&&r.skipAutogenerationIfManualExamplesExist===!0)continue;let a=bHc({ir:e,channel:n,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(a.type==="failure")continue;let{example:o}=a;n.examples=[...n.examples,o]}return e}function vHc({ir:e,exampleGeneration:t}){let r={disabled:t.disabled,includeOptionalRequestPropertyExamples:t.includeOptionalRequestPropertyExamples??!1,skipAutogenerationIfManualExamplesExist:t.skipAutogenerationIfManualExamplesExist??!1,skipErrorAutogenerationIfManualErrorExamplesExist:t.skipErrorAutogenerationIfManualErrorExamplesExist??!1};for(let[i,n]of Object.entries(e.services))for(let a of n.endpoints){a.v2Examples==null&&(a.v2Examples={userSpecifiedExamples:{},autogeneratedExamples:{}});let{userFullExamples:o,autoFullExamples:c}=Nrh({endpoint:a,ir:e,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(Object.keys(a.v2Examples.userSpecifiedExamples).length>0){if(Object.values(a.v2Examples.userSpecifiedExamples).some(s=>s.request!=null||s.response!=null))continue;let d=Object.values(a.v2Examples.userSpecifiedExamples).filter(s=>s!=null).flatMap(s=>s.codeSamples??[]);for(let[s,u]of Object.entries(c))c[s]={...u,codeSamples:d};for(let[s,u]of Object.entries(o))o[s]={...u,codeSamples:d}}a.v2Examples.autogeneratedExamples=c,a.v2Examples.userSpecifiedExamples=o}for(let[i,n]of Object.entries(e.websocketChannels??{})){if(n.examples.length>0&&r.skipAutogenerationIfManualExamplesExist===!0)continue;let a=bHc({ir:e,channel:n,typeDeclarations:e.types,skipOptionalRequestProperties:!r.includeOptionalRequestPropertyExamples});if(a.type==="failure")continue;let{example:o}=a;n.examples=[...n.examples,o]}return e}function Qrh({filteredIr:e,singleUnionTypeProperties:t}){return t._visit({samePropertiesAsObject:r=>{let i=e.hasTypeId(r.typeId)?{...r,object:{...r.object,properties:r.object.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:$B({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)}}:void 0;return i!==void 0?Qq.samePropertiesAsObject(i):void 0},singleProperty:r=>{let i=$B({filteredIr:e,exampleTypeReference:r});return i!==void 0?Qq.singleProperty(i):void 0},noProperties:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}})}function $B({filteredIr:e,exampleTypeReference:t}){return t.shape._visit({primitive:()=>t,container:r=>r._visit({list:i=>({...t,shape:as.container(S_.list({...i,list:i.list.map(n=>$B({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),set:i=>({...t,shape:as.container(S_.set({...i,set:i.set.map(n=>$B({filteredIr:e,exampleTypeReference:n})).filter(n=>n!==void 0)}))}),optional:i=>{let n=i.optional!=null?$B({filteredIr:e,exampleTypeReference:i.optional}):void 0;return n!=null?{...t,shape:as.container(S_.optional({optional:n,valueType:i.valueType}))}:void 0},nullable:i=>{let n=i.nullable!=null?$B({filteredIr:e,exampleTypeReference:i.nullable}):void 0;return n!=null?{...t,shape:as.container(S_.nullable({nullable:n,valueType:i.valueType}))}:void 0},map:i=>({...t,shape:as.container(S_.map({...i,map:i.map.map(n=>{let a=$B({filteredIr:e,exampleTypeReference:n.key}),o=$B({filteredIr:e,exampleTypeReference:n.value});return a!==void 0&&o!==void 0?{key:a,value:o}:void 0}).filter(n=>n!==void 0)}))}),literal:()=>t,_other:()=>{throw new Error("Received unknown type for example.")}}),named:r=>e.hasTypeId(r.typeName.typeId)?r.shape._visit({alias:i=>{let n=$B({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...t,shape:as.named({...r,shape:ib.alias({...i,value:n})})}:void 0},enum:i=>({...t,shape:as.named({...r,shape:ib.enum(i)})}),object:i=>({...t,shape:as.named({...r,shape:ib.object({...i,properties:i.properties.filter(n=>e.hasProperty(n.originalTypeDeclaration.typeId,n.name.wireValue)).map(n=>({...n,value:$B({filteredIr:e,exampleTypeReference:n.value})})).filter(n=>n.value!==void 0)})})}),union:i=>{let n=Qrh({filteredIr:e,singleUnionTypeProperties:i.singleUnionType.shape});return n!==void 0?{...t,shape:as.named({...r,shape:ib.union({...i,singleUnionType:{...i.singleUnionType,shape:n}})})}:void 0},undiscriminatedUnion:i=>{let n=$B({filteredIr:e,exampleTypeReference:i.singleUnionType});return n!==void 0?{...t,shape:as.named({...r,shape:ib.undiscriminatedUnion({...i,singleUnionType:n})})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}}):void 0,unknown:()=>t,_other:()=>t})}function gHc({filteredIr:e,pathParameters:t}){return t.map(r=>{let i=$B({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function eFD({filteredIr:e,queryParameters:t}){return t.map(r=>{let i=$B({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function Frh({filteredIr:e,headers:t}){return t.map(r=>{let i=$B({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...r,value:i}:void 0}).filter(r=>r!==void 0)}function tFD({filteredIr:e,requestBody:t}){return t._visit({inlinedRequestBody:r=>({...t,properties:r.properties.filter(i=>i.originalTypeDeclaration?e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue):!0).map(i=>{let n=$B({filteredIr:e,exampleTypeReference:i.value});return n!==void 0?{...i,value:n}:void 0}).filter(i=>i!==void 0)}),reference:r=>{let i=$B({filteredIr:e,exampleTypeReference:r});return i!==void 0?O5.reference(i):void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function rFD({filteredIr:e,response:t}){return t._visit({ok:r=>r._visit({body:i=>Zw.ok(PE.body(i!=null?$B({filteredIr:e,exampleTypeReference:i}):void 0)),stream:i=>Zw.ok(PE.stream(i.map(n=>$B({filteredIr:e,exampleTypeReference:n})).filter(Cs))),sse:i=>Zw.ok(PE.sse(i.map(({event:n,data:a})=>{let o=$B({filteredIr:e,exampleTypeReference:a});return o!==void 0?{event:n,data:o}:void 0}).filter(Cs))),_other:({type:i})=>{throw new Error(`Received unknown type for OK example: ${i}`)}}),error:({error:r,body:i})=>Zw.error({error:r,body:i!=null?$B({filteredIr:e,exampleTypeReference:i}):void 0}),_other:({type:r})=>{throw new Error(`Received unknown type for example: ${r}`)}})}function OHc({filteredIr:e,example:t}){return{...t,rootPathParameters:gHc({filteredIr:e,pathParameters:t.rootPathParameters}),servicePathParameters:gHc({filteredIr:e,pathParameters:t.servicePathParameters}),endpointPathParameters:gHc({filteredIr:e,pathParameters:t.endpointPathParameters}),serviceHeaders:Frh({filteredIr:e,headers:t.serviceHeaders}),endpointHeaders:Frh({filteredIr:e,headers:t.endpointHeaders}),queryParameters:eFD({filteredIr:e,queryParameters:t.queryParameters}),request:t.request!==void 0?tFD({filteredIr:e,requestBody:t.request}):void 0,response:rFD({filteredIr:e,response:t.response})}}function Urh({filteredIr:e,exampleType:t}){return t.shape._visit({alias:r=>{let i=$B({filteredIr:e,exampleTypeReference:r.value});return i!==void 0?{...t,shape:ib.alias({...r,value:i})}:void 0},enum:()=>t,object:r=>({...t,shape:ib.object({...r,properties:r.properties.filter(i=>e.hasProperty(i.originalTypeDeclaration.typeId,i.name.wireValue)).map(i=>({...i,value:$B({filteredIr:e,exampleTypeReference:i.value})})).filter(i=>i.value!==void 0)})}),union:r=>{let i=Qrh({filteredIr:e,singleUnionTypeProperties:r.singleUnionType.shape});return i!==void 0?{...t,shape:ib.union({...r,singleUnionType:{...r.singleUnionType,shape:i}})}:void 0},undiscriminatedUnion:r=>{let i=$B({filteredIr:e,exampleTypeReference:r.singleUnionType});return i!==void 0?{...t,shape:ib.undiscriminatedUnion({...r,singleUnionType:i})}:void 0},_other:()=>{throw new Error("Received unknown type for example.")}})}function mHc(e,t){if(t==null)return e;let r=Gvn(e.types,c=>t.hasType(c)),i=Object.fromEntries(Object.entries(r).map(([c,d])=>{let s=[];if(d.userProvidedExamples=d.userProvidedExamples.map(u=>Urh({filteredIr:t,exampleType:u})).filter(u=>u!==void 0),d.shape.type==="object"){for(let u of d.shape.properties)t.hasProperty(c,u.name.wireValue)&&s.push(u);return[c,{...d,shape:Jl.object({...d.shape,properties:s})}]}return[c,d]})),n=Object.fromEntries(Object.entries(e.webhookGroups).map(([c,d])=>{let s=d.filter(u=>t.hasWebhook(u)).map(u=>{let f=u.id;return u.payload.type==="inlinedPayload"&&f!=null&&(u.payload={...u.payload,properties:u.payload.properties.filter(p=>t.hasWebhookPayloadProperty(f,p.name.wireValue))}),u});return[c,s]})),a=e.websocketChannels!=null?Object.fromEntries(Object.entries(e.websocketChannels).filter(([c])=>t.hasChannel(c)).map(([c,d])=>[c,{...d}])):{},o=e.environments;if(o){switch(o.environments.type){case"singleBaseUrl":{o.environments.environments=o.environments.environments.filter(c=>t.hasEnvironmentId(c.id));break}case"multipleBaseUrls":{o.environments.environments=o.environments.environments.filter(c=>t.hasEnvironmentId(c.id));break}}o.defaultEnvironment&&(t.hasEnvironmentId(o.defaultEnvironment)||(o.defaultEnvironment=void 0))}return{...e,environments:o,types:i,errors:Gvn(e.errors,c=>t.hasError(c)),services:gn(Gvn(e.services,c=>t.hasService(c)),c=>({...c,endpoints:c.endpoints.filter(d=>t.hasEndpoint(d)).map(d=>(d.autogeneratedExamples=d.autogeneratedExamples.map(s=>({...s,example:OHc({filteredIr:t,example:s.example})})),d.userSpecifiedExamples=d.userSpecifiedExamples.map(s=>({...s,example:s.example!=null?OHc({filteredIr:t,example:s.example}):void 0})),d.queryParameters.length>0&&(d.queryParameters=d.queryParameters.filter(s=>t.hasQueryParameter(d.id,s.name.wireValue))),d.requestBody?.type==="inlinedRequestBody"?{...d,requestBody:{...d.requestBody,properties:d.requestBody.properties.filter(s=>t.hasRequestProperty(d.id,s.name.wireValue))}}:d))})),websocketChannels:a,webhookGroups:n,serviceTypeReferenceInfo:iFD(e.serviceTypeReferenceInfo,t)}}function iFD(e,t){if(t==null)return e;let r={};return Object.entries(e.typesReferencedOnlyByService).forEach(([i,n])=>{t.hasServiceId(i)&&(r[i]=n.filter(a=>t.hasTypeId(a)))}),{sharedTypes:e.sharedTypes.filter(i=>t.hasTypeId(i)),typesReferencedOnlyByService:r}}function HAn(e){let t={};for(let[r,i]of Object.entries(e))if(typeof i!="string")for(let n of i.audiences??[])t[n]==null&&(t[n]=new Set),t[n]?.add(r);return t}function Qme(e){return e.allParts.map(t=>t.originalName).join("/")}var M_={generateTypeId:e=>`type_${Qme(e.fernFilepath)}:${e.name.originalName}`,generateErrorId:e=>`error_${Qme(e.fernFilepath)}:${e.name.originalName}`,generateServiceId:e=>`service_${Qme(e.fernFilepath)}`,generateServiceIdFromFernFilepath:e=>`service_${Qme(e)}`,generateSubpackageId:e=>`subpackage_${Qme(e)}`,generateEndpointId:(e,t)=>{let r=Qme(e.fernFilepath),i=t.name.originalName;return`endpoint_${r}.${i}`},generateWebhookGroupId:e=>`webhooks_${Qme(e)}`,generateWebhookId:(e,t)=>`webhooks_${Qme(e)}.${t}`,generateWebSocketChannelId:e=>`channel_${Qme(e)}`};function rda(e){return e.type!=null}var G_u=class{environments=new Set;types=new Set;properties;errors=new Set;services=new Set;endpoints=new Set;requestProperties;queryParameters;webhooks=new Set;webhookPayloadProperties;channels=new Set;subpackages=new Set;constructor({types:t,properties:r,errors:i,environments:n,services:a,endpoints:o,webhooks:c,subpackages:d,queryParameters:s,requestProperties:u,webhookPayloadProperties:f,channels:p}){this.environments=n,this.types=t,this.properties=r,this.errors=i,this.services=a,this.endpoints=o,this.webhooks=c,this.webhookPayloadProperties=f,this.subpackages=d,this.requestProperties=u,this.queryParameters=s,this.channels=p}hasTypeId(t){return this.types.has(t)}hasErrorId(t){return this.errors.has(t)}hasServiceId(t){return this.services.has(t)}hasSubpackageId(t){return this.subpackages.has(t)}hasType(t){let r=M_.generateTypeId(t.name);return this.types.has(r)}hasProperty(t,r){let i=this.properties[t];return i==null?!0:i.has(r)}hasError(t){let r=M_.generateErrorId(t.name);return this.errors.has(r)}hasService(t){let r=M_.generateServiceId(t.name);return this.services.has(r)}hasEnvironmentId(t){return this.environments.has(t)}hasEndpoint(t){return this.endpoints.has(t.id)}hasRequestProperty(t,r){let i=this.requestProperties[t];return i==null?!0:i.has(r)}hasQueryParameter(t,r){let i=this.queryParameters[t];return i==null?!0:i.has(r)}hasSubpackage(t){return this.subpackages.has(t)}hasWebhook(t){return t.id?this.webhooks.has(t.id):!0}hasChannel(t){return t?this.channels.has(t):!0}hasWebhookPayloadProperty(t,r){let i=this.webhookPayloadProperties[t];return i==null?!0:i.has(r)}};var KAn=class{types={};properties={};queryParameters={};requestProperties={};webhookProperties={};errors={};endpoints={};webhooks={};channels={};audiences;typesReferencedByService={};environmentsNeededForAudience=new Set;typesNeededForAudience=new Set;servicesNeededForAudience=new Set;endpointsNeededForAudience=new Set;webhooksNeededForAudience=new Set;channelsNeededForAudience=new Set;subpackagesNeededForAudience=new Set;constructor(t){this.audiences=nFD(t)}addType({declaredTypeName:t,descendantTypeIds:r,descendantFilepaths:i,descendantTypeIdsByAudience:n,propertiesByAudience:a}){let o=M_.generateTypeId(t),c={typeId:o,allDescendants:r,descendantsByAudience:n,referencedSubpackages:i};this.types[o]=c,this.typesReferencedByService[o]==null&&(this.typesReferencedByService[o]=new Set),this.properties[o]={typeId:o,propertiesByAudience:a}}markTypeForAudiences(t,r){let i=M_.generateTypeId(t);this.hasAudience(r)&&(this.typesNeededForAudience.add(i),this.addSubpackages(t.fernFilepath),this.types[i]?.referencedSubpackages.forEach(n=>{this.addSubpackages(n)}))}markEnvironmentForAudiences(t,r,i){t&&(this.hasAudience(r)||i)&&this.environmentsNeededForAudience.add(t.id)}getTypesReferencedByService(){for(let t of Object.values(this.endpoints))for(let r of t.referencedTypes)this.markTypeForService(r,t.serviceId);return this.typesReferencedByService}addError(t){let r=M_.generateErrorId(t.name),i=new Set,n=new Set;t.type!=null&&KD(t.type,i,n);let a={errorId:r,referencedTypes:i,referencedSubpackages:n};this.errors[r]=a}addEndpoint(t,r,i){let n=M_.generateServiceId(t.name),a=r.id,o=new Set,c=new Set,d=new Set;for(let s of[...t.headers,...r.headers])KD(s.valueType,o,d);for(let s of[...t.pathParameters,...r.pathParameters])KD(s.valueType,o,d);for(let s of r.queryParameters)KD(s.valueType,o,d);if(i!=null&&i.request!=null&&typeof i.request!="string"){let s=HAn(i.request["query-parameters"]??{});this.queryParameters[a]={endpointId:a,parametersByAudience:s}}r.requestBody!=null&&FA._visit(r.requestBody,{inlinedRequestBody:s=>{for(let u of s.extends)H_u(u,o,d);for(let u of s.properties)KD(u.valueType,o,d);if(i!=null&&typeof i.request=="object"&&typeof i.request.body=="object"&&AE(i.request.body)){let u=HAn(i.request.body.properties??{});this.requestProperties[a]={endpointId:a,propertiesByAudience:u}}},reference:({requestBodyType:s})=>{KD(s,o,d)},fileUpload:({properties:s})=>{for(let u of s)oR._visit(u,{file:At,bodyProperty:({valueType:f})=>{KD(f,o,d)},_other:()=>{throw new Error("Unknown FileUploadRequestProperty: "+u.type)}})},bytes:()=>{},_other:()=>{throw new Error("Unknown HttpRequestBody: "+r.requestBody?.type)}}),r.response?.body!=null&&op._visit(r.response.body,{fileDownload:At,json:s=>{KD(s.responseBodyType,o,d)},streaming:s=>{s._visit({sse:u=>KD(u.payload,o,d),json:u=>KD(u.payload,o,d),text:At,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.type)}})},streamParameter:s=>{s.streamResponse._visit({sse:u=>KD(u.payload,o,d),json:u=>KD(u.payload,o,d),text:At,_other:()=>{throw new Error("Unknown streamingResponse type: "+s.streamResponse.type)}}),s.nonStreamResponse.type==="json"&&KD(s.nonStreamResponse.value.responseBodyType,o,d)},text:At,bytes:At,_other:()=>{throw new Error("Unknown HttpResponse: "+r.response?.body?.type)}}),r.errors.forEach(s=>{c.add(M_.generateErrorId(s.error)),d.add(s.error.fernFilepath)}),this.endpoints[a]={endpointId:a,serviceId:n,referencedTypes:o,referencedErrors:c,referencedSubpackages:d}}markEndpointForAudience(t,r,i){if(this.hasAudience(i)){let n=M_.generateServiceId(t);this.servicesNeededForAudience.add(n),r.forEach(a=>{let o=a.id;this.endpointsNeededForAudience.add(o),this.endpoints[o]?.referencedSubpackages.forEach(c=>{this.addSubpackages(c)})}),this.servicesNeededForAudience.add(n),this.addSubpackages(t.fernFilepath)}}getFilteredSubpackages(){return this.subpackagesNeededForAudience}getFilteredServices(){return this.servicesNeededForAudience}getFilteredEndpoints(){return this.endpointsNeededForAudience}getFilteredChannels(){return this.channelsNeededForAudience}getFilteredWebhooks(){return this.webhooksNeededForAudience}addWebhook(t,r,i){let n=r.id;if(n==null)return;let a=new Set,o=new Set;r.payload!=null&&nU._visit(r.payload,{inlinedPayload:c=>{for(let d of c.extends)H_u(d,a,o);for(let d of c.properties)KD(d.valueType,a,o);if(i?.payload!=null&&typeof i.payload=="object"&&!rda(i.payload)){let d=HAn(i.payload.properties??{});this.webhookProperties[n]={webhookId:n,propertiesByAudience:d}}},reference:({payloadType:c})=>{KD(c,a,o)},_other:()=>{throw new Error("Unknown WebhookPayload: "+r.payload?.type)}}),o.add(t),this.webhooks[n]={webhookId:n,referencedTypes:a,referencedSubpackages:o}}markWebhookForAudiences(t,r,i){let n=r.id;n!=null&&this.hasAudience(i)&&(this.webhooksNeededForAudience.add(n),this.addSubpackages(t))}addChannel(t,r,i,n){if(r==null)return;let a=new Set,o=new Set;for(let c of i.messages)E3._visit(c.body,{reference:({bodyType:d})=>{KD(d,a,o)},inlinedBody:d=>{for(let s of d.extends)H_u(s,a,o);for(let s of d.properties)KD(s.valueType,a,o)},_other:()=>{}});for(let c of i.queryParameters)KD(c.valueType,a,o);o.add(t),this.channels[r]={channelId:r,referencedTypes:a,referencedSubpackages:o}}markChannelForAudiences(t,r,i){r!=null&&this.hasAudience(i)&&(this.channelsNeededForAudience.add(r),this.addSubpackages(t))}build(){let t=new Set,r=new Set;for(let c of this.endpointsNeededForAudience.keys()){let d=this.getEndpointNode(c);for(let s of d.referencedErrors){if(r.has(s))continue;r.add(s);let u=this.getErrorNode(s);this.addReferencedTypes(t,u.referencedTypes)}this.addReferencedTypes(t,d.referencedTypes)}this.addReferencedTypes(t,this.typesNeededForAudience);for(let c of this.webhooksNeededForAudience.keys()){let d=this.getWebhookNode(c);this.addReferencedTypes(t,d.referencedTypes)}for(let c of this.channelsNeededForAudience.keys()){let d=this.getChannelNode(c);this.addReferencedTypes(t,d.referencedTypes)}let i={},n={},a={},o={};if(this.audiences.type==="filtered"){for(let[c,d]of Object.entries(this.properties)){if(!t.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let f=d.propertiesByAudience[u];f?.forEach(p=>{s.add(p)})}s.size>0&&(i[c]=s),i[c]=s.size>0?s:void 0}for(let[c,d]of Object.entries(this.requestProperties)){if(!this.endpointsNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let f=d.propertiesByAudience[u];f?.forEach(p=>{s.add(p)})}n[c]=s.size>0?s:void 0}for(let[c,d]of Object.entries(this.queryParameters)){if(!this.endpointsNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let f=d.parametersByAudience[u];f?.forEach(p=>{s.add(p)})}a[c]=s.size>0?s:void 0}for(let[c,d]of Object.entries(this.webhookProperties)){if(!this.webhooksNeededForAudience.has(c))continue;let s=new Set;for(let u of this.audiences.audiences){let f=d.propertiesByAudience[u];f?.forEach(p=>{s.add(p)})}o[c]=s.size>0?s:void 0}}return new G_u({types:t,properties:i,errors:r,requestProperties:n,queryParameters:a,environments:this.environmentsNeededForAudience,services:this.servicesNeededForAudience,endpoints:this.endpointsNeededForAudience,webhooks:this.webhooksNeededForAudience,webhookPayloadProperties:o,subpackages:this.subpackagesNeededForAudience,channels:this.channelsNeededForAudience})}markTypeForService(t,r){let i=this.typesReferencedByService[t]??=new Set;if(i.has(r))return;i.add(r);let n=this.getTypeNode(t);for(let a of n.allDescendants)this.markTypeForService(a,r)}addReferencedTypes(t,r){for(let i of r){if(t.has(i))continue;t.add(i);let n=this.getTypeNode(i);if(this.audiences.type==="filtered")for(let a of this.audiences.audiences){let o=n.descendantsByAudience[a];if(o!=null)o.forEach(c=>{t.add(c)});else{n.allDescendants.forEach(c=>{t.add(c)});break}}else n.allDescendants.forEach(a=>{t.add(a)})}}getTypeNode(t){let r=this.types[t];if(r==null)throw new Error(`Failed to find type node with id ${t}`);return r}getErrorNode(t){let r=this.errors[t];if(r==null)throw new Error(`Failed to find error node with id ${t}`);return r}getEndpointNode(t){let r=this.endpoints[t];if(r==null)throw new Error(`Failed to find endpoint node with id ${t}`);return r}getWebhookNode(t){let r=this.webhooks[t];if(r==null)throw new Error(`Failed to find webhook node with id ${t}`);return r}getChannelNode(t){let r=this.channels[t];if(r==null)throw new Error(`Failed to find channel node with id ${t}`);return r}hasNoAudiences(){return this.audiences.type==="none"}hasAudience(t){let r=this.audiences;switch(r.type){case"none":return!0;case"filtered":return t.some(i=>r.audiences.has(i));default:de(r)}}addSubpackages(t){for(let r=1;r<=t.allParts.length;++r){let i={...t,allParts:t.allParts.slice(0,r)};this.subpackagesNeededForAudience.add(M_.generateSubpackageId(i))}}};function nFD(e){switch(e.type){case"all":return{type:"none"};case"select":return{type:"filtered",audiences:new Set(e.audiences)};default:de(e)}}function KD(e,t,r){_i._visit(e,{container:i=>{aFD(i,t,r)},named:i=>{H_u(i,t,r)},primitive:At,unknown:At,_other:At})}function H_u(e,t,r){t.add(M_.generateTypeId(e)),r.add(e.fernFilepath)}function aFD(e,t,r){Js._visit(e,{list:i=>{KD(i,t,r)},map:i=>{KD(i.keyType,t,r),KD(i.valueType,t,r)},optional:i=>{KD(i,t,r)},nullable:i=>{KD(i,t,r)},set:i=>{KD(i,t,r)},literal:At,_other:At})}var oFD=[Br.AvailabilityStatus.GeneralAvailability];function nWi(e){return e!==void 0&&!oFD.includes(e.status)}var AHc=class{errors;constructor(){this.errors=[]}add(t){this.errors.push({message:t})}getErrors(){return this.errors}hasErrors(){return this.errors.length>0}},Yka=class{errors;constructor(){this.errors=new AHc}async check({from:t,to:r}){let i=this.toInternalIr(t),n=this.toInternalIr(r),a=_2i(i),o=_2i(n);if(a===o)return{bump:"no_change",isBreaking:!1,errors:[]};let c=this.checkBreaking({from:i,to:n});return{bump:c.isBreaking?"major":"minor",isBreaking:c.isBreaking,errors:c.errors}}toInternalIr(t){return{types:t.types,errors:t.errors,services:t.services}}checkBreaking({from:t,to:r}){this.checkTypeBreakingChanges({from:t.types,to:r.types}),this.checkErrorsBreakingChanges({from:t.errors,to:r.errors}),this.checkServicesBreakingChanges({from:t.services,to:r.services});let i=this.errors.hasErrors();return{bump:i?"major":"minor",isBreaking:i,errors:this.errors.getErrors()}}checkTypeBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){if(nWi(n.availability))continue;let a=r[i];if(!a){this.errors.add(`Type "${i}" was removed.`);continue}if(nWi(a.availability)){this.errors.add(`Type "${i}" was moved from stable to unstable availability status.`);continue}this.areTypeDeclarationsCompatible({from:n,to:a})||this.errors.add(`Type "${i}" has an incompatible change.`)}}checkErrorsBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){let a=Object.values(r).find(o=>o.name.errorId===n.name.errorId);if(!a){this.errors.add(`Error "${n.name.errorId}" with status code "${n.statusCode}" was removed.`);continue}this.checkErrorBreakingChanges({from:n,to:a})}}checkErrorBreakingChanges({from:t,to:r}){if(t.type!=null){if(r.type==null){this.errors.add(`Error "${t.name.errorId}" with status code "${t.statusCode}" had its type removed.`);return}this.areTypeReferencesCompatible({from:t.type,to:r.type})||this.errors.add(`Error "${t.name.errorId}" type reference changed.`)}this.areDeclaredErrorNamesCompatible({from:t.name,to:r.name})||this.errors.add(`Error "${t.name.errorId}" name changed.`),this.areNameAndWireValuesCompatible({from:t.discriminantValue,to:r.discriminantValue})||this.errors.add(`Error "${t.name.errorId}" discriminant value changed.`)}checkServicesBreakingChanges({from:t,to:r}){for(let[i,n]of Object.entries(t)){if(nWi(n.availability)||(n.endpoints?.every(o=>nWi(o.availability))??!1))continue;let a=r[i];if(!a){this.errors.add(`Service "${i}" was removed.`);continue}if(nWi(a.availability)){this.errors.add(`Service "${i}" was moved from stable to unstable availability status.`);continue}this.checkServiceBreakingChanges({id:i,from:n,to:a})}}checkServiceBreakingChanges({id:t,from:r,to:i}){this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),this.checkEndpointsBreakingChanges({id:t,from:r,to:i})}checkEndpointsBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.endpoints.map(o=>[o.id,o])),a=Object.fromEntries(i.endpoints.map(o=>[o.id,o]));for(let[o,c]of Object.entries(n)){if(nWi(c.availability))continue;let d=a[o];if(!d){this.errors.add(`Endpoint "${o}" was removed.`);continue}if(nWi(d.availability)){this.errors.add(`Endpoint "${o}" was moved from stable to unstable availability status.`);continue}this.checkEndpointBreakingChanges({id:o,from:c,to:d})}}checkEndpointBreakingChanges({id:t,from:r,to:i}){this.checkHttpMethodsBreakingChanges({id:t,from:r.method,to:i.method}),this.checkHttpPathsBreakingChanges({id:t,from:r.fullPath,to:i.fullPath}),this.checkPathParametersBreakingChanges({id:t,from:r.pathParameters,to:i.pathParameters}),this.checkQueryParametersBreakingChanges({id:t,from:r.queryParameters,to:i.queryParameters}),this.checkHeadersBreakingChanges({id:t,from:r.headers,to:i.headers}),r.requestBody!=null&&(i.requestBody!=null?this.checkHttpRequestBodiesCompatible({id:t,from:r.requestBody,to:i.requestBody}):this.errors.add(`Request body was removed from endpoint "${r.id}".`)),r.response!=null&&(i.response!=null?this.checkHttpResponseBreakingChanges({id:t,from:r.response,to:i.response}):this.errors.add(`Response was removed from endpoint "${r.id}".`)),(r.pagination!=null&&i.pagination==null||r.pagination==null&&i.pagination!=null)&&this.errors.add(`Pagination was ${r.pagination!=null?"added":"removed"} from endpoint "${r.id}".`)}checkPathParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.originalName,o])),a=Object.fromEntries(i.map(o=>[o.name.originalName,o]));for(let[o,c]of Object.entries(n)){let d=a[o];if(!d){this.errors.add(`Path parameter "${o}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:d.valueType})||this.errors.add(`Path parameter "${o}" type changed in endpoint "${t}".`)}}checkQueryParametersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.wireValue,o])),a=Object.fromEntries(i.map(o=>[o.name.wireValue,o]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([o,c])=>[o,c.valueType])),to:Object.fromEntries(Object.entries(a).map(([o,c])=>[o,c.valueType]))});for(let[o,c]of Object.entries(n)){let d=a[o];if(!d){this.errors.add(`Query parameter "${o}" was removed from endpoint "${t}".`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:d.valueType})||this.errors.add(`Query parameter "${o}" type changed in endpoint "${t}".`),c.allowMultiple!==d.allowMultiple&&this.errors.add(`Query parameter "${o}" allow-multiple values changed in endpoint "${t}".`)}}checkHeadersBreakingChanges({id:t,from:r,to:i}){let n=Object.fromEntries(r.map(o=>[o.name.wireValue,o])),a=Object.fromEntries(i.map(o=>[o.name.wireValue,o]));this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(n).map(([o,c])=>[o,c.valueType])),to:Object.fromEntries(Object.entries(a).map(([o,c])=>[o,c.valueType]))});for(let[o,c]of Object.entries(n)){let d=a[o];if(!d){this.errors.add(`Header "${o}" was removed from ${t}.`);continue}this.areTypeReferencesCompatible({from:c.valueType,to:d.valueType})||this.errors.add(`Header "${o}" type changed in ${t}.`)}}checkHttpMethodsBreakingChanges({id:t,from:r,to:i}){r!==i&&this.errors.add(`HTTP method changed in ${t}.`)}checkHttpPathsBreakingChanges({id:t,from:r,to:i}){this.areHttpPathsCompatible({from:r,to:i})||this.errors.add(`HTTP path changed in ${t}.`)}areHttpPathsCompatible({from:t,to:r}){if(t.head!==r.head||t.parts.length!==r.parts.length)return!1;for(let i=0;i<t.parts.length;i++){let n=t.parts[i];if(n==null)return!1;let a=r.parts[i];if(a==null||n.pathParameter!==a.pathParameter||n.tail!==a.tail)return!1}return!0}checkHttpRequestBodiesCompatible({id:t,from:r,to:i}){switch(r.type){case"inlinedRequestBody":if(i.type==="inlinedRequestBody"&&this.areInlinedRequestBodiesCompatible({from:r,to:i}))return;break;case"reference":if(i.type==="reference"&&this.areReferenceRequestBodiesCompatible({from:r,to:i}))return;break;case"fileUpload":if(i.type==="fileUpload"&&this.areFileUploadRequestBodiesCompatible({from:r,to:i}))return;break;case"bytes":if(i.type==="bytes")return;break;default:de(r)}this.errors.add(`Request body type changed from "${r.type}" to "${i.type}" in endpoint "${t}".`)}areInlinedRequestBodiesCompatible({from:t,to:r}){let i=this.getInlinedRequestBody(t),n=this.getInlinedRequestBody(r);return this.checkForNewInlinedRequestBodyProperties({from:i,to:n}),Object.entries(i).every(([a,o])=>{let c=n[a];return c?this.areTypeReferencesCompatible({from:o,to:c}):(this.errors.add(`Request body property "${a}" was removed.`),!1)})}areReferenceRequestBodiesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.requestBodyType,to:r.requestBodyType})}areFileUploadRequestBodiesCompatible({from:t,to:r}){let i=this.getFileUploadRequest(t.properties),n=this.getFileUploadRequest(r.properties);this.checkForNewFileUploadRequestProperties({from:i,to:n});for(let[a,o]of Object.entries(i)){let c=n[a];if(!c)return this.errors.add(`File upload property "${a}" was removed.`),!1;if(o==="file"&&c!=="file")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(o==="fileArray"&&c!=="fileArray")return this.errors.add(`File upload property "${a}" type changed.`),!1;if(o!=="file"&&o!=="fileArray"&&c!=="file"&&c!=="fileArray"&&!this.areTypeReferencesCompatible({from:o,to:c}))return this.errors.add(`File upload property "${a}" type changed.`),!1}return!0}checkHttpResponseBreakingChanges({id:t,from:r,to:i}){if(r.statusCode!==i.statusCode&&this.errors.add(`Response status code changed from "${r.statusCode}" to "${i.statusCode}".`),!(r.body==null&&i.body==null)){if(r.body==null||i.body==null){this.errors.add(`Response body was ${r.body==null?"added":"removed"}.`);return}switch(r.body.type){case"json":if(i.body.type==="json"){this.areJsonResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"fileDownload":if(i.body.type==="fileDownload")return;break;case"text":if(i.body.type==="text")return;break;case"bytes":if(i.body.type==="bytes")return;break;case"streaming":if(i.body.type==="streaming"){this.areStreamingResponsesCompatible({from:r.body.value,to:i.body.value});return}break;case"streamParameter":if(i.body.type==="streamParameter"){this.areStreamingResponsesCompatible({from:r.body.streamResponse,to:i.body.streamResponse});return}break;default:de(r.body)}this.errors.add(`HTTP response type "${r.body.type}" defined for endpoint "${t}" is not compatible with type "${i.body.type}".`)}}areJsonResponsesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.responseBodyType,to:r.responseBodyType})}areStreamingResponsesCompatible({from:t,to:r}){switch(t.type){case"json":if(r.type==="json")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"sse":if(r.type==="sse")return this.areTypeReferencesCompatible({from:t.payload,to:r.payload});break;case"text":if(r.type==="text")return!0;break;default:de(t)}return this.errors.add(`Streaming response type "${t.type}" is not compatible with type "${r.type}".`),!1}areTypeDeclarationsCompatible({from:t,to:r}){return nWi(t.availability)?!0:this.areDeclaredTypeNamesCompatible({from:t.name,to:r.name})&&this.areTypeShapesCompatible({from:t.shape,to:r.shape})}areTypeShapesCompatible({from:t,to:r}){switch(t.type){case"alias":if(r.type==="alias")return this.areAliasTypesCompatible({from:t,to:r});break;case"enum":if(r.type==="enum")return this.areEnumTypesCompatible({from:t,to:r});break;case"object":if(r.type==="object")return this.areObjectTypesCompatible({from:t,to:r});break;case"union":if(r.type==="union")return this.areUnionTypesCompatible({from:t,to:r});break;case"undiscriminatedUnion":if(r.type==="undiscriminatedUnion")return this.areUndiscriminatedUnionTypesCompatible({from:t,to:r});break;default:de(t)}return this.errors.add(`Type "${t.type}" is not compatible with type "${r.type}".`),!1}areAliasTypesCompatible({from:t,to:r}){return this.areTypeReferencesCompatible({from:t.aliasOf,to:r.aliasOf})}areEnumTypesCompatible({from:t,to:r}){let i=Object.fromEntries(t.values.map(a=>[a.name.wireValue,a])),n=Object.fromEntries(r.values.map(a=>[a.name.wireValue,a]));return Object.keys(i).length!==Object.keys(n).length?!1:Object.values(i).every(a=>{let o=n[a.name.wireValue];return o?this.areNameAndWireValuesCompatible({from:a.name,to:o.name}):(this.errors.add(`Enum value "${a.name.wireValue}" was removed.`),!1)})}areObjectTypesCompatible({from:t,to:r}){let i=Object.fromEntries([...t.properties.map(a=>[a.name.wireValue,a]),...t.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]),n=Object.fromEntries([...r.properties.map(a=>[a.name.wireValue,a]),...r.extendedProperties?.map(a=>[a.name.wireValue,a])??[]]);return this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(i).map(([a,o])=>[a,o.valueType])),to:Object.fromEntries(Object.entries(n).map(([a,o])=>[a,o.valueType]))}),Object.values(i).every(a=>{let o=n[a.name.wireValue];return o?this.areObjectPropertiesCompatible({from:a,to:o}):(this.errors.add(`Object property "${a.name.wireValue}" was removed.`),!1)})}areObjectPropertiesCompatible({from:t,to:r}){return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType})}areUnionTypesCompatible({from:t,to:r}){if(!this.areNameAndWireValuesCompatible({from:t.discriminant,to:r.discriminant}))return this.errors.add(`Union type with discriminant value "${t.discriminant.wireValue}" changed.`),!1;let i=new Set(t.extends.map(s=>this.getKeyForDeclaration(s))),n=new Set(r.extends.map(s=>this.getKeyForDeclaration(s)));for(let s of i)if(!n.has(s))return this.errors.add(`Extended type "${s}" was removed.`),!1;let a=Object.fromEntries(t.baseProperties.map(s=>[s.name.wireValue,s])),o=Object.fromEntries(r.baseProperties.map(s=>[s.name.wireValue,s]));for(let s of Object.values(a)){let u=o[s.name.wireValue];if(!u)return this.errors.add(`Union type with discriminant value "${s.name.wireValue}" no longer has a property named "${s.name.wireValue}".`),!1;if(!this.areObjectPropertiesCompatible({from:s,to:u}))return!1}this.checkForNewRequiredTypeReferences({from:Object.fromEntries(Object.entries(a).map(([s,u])=>[s,u.valueType])),to:Object.fromEntries(Object.entries(o).map(([s,u])=>[s,u.valueType]))});let c=Object.fromEntries(t.types.map(s=>[s.discriminantValue.wireValue,s])),d=Object.fromEntries(r.types.map(s=>[s.discriminantValue.wireValue,s]));return Object.values(c).every(s=>{let u=d[s.discriminantValue.wireValue];return u?this.areSingleUnionTypesCompatible({from:s.shape,to:u.shape}):(this.errors.add(`Union type for discriminant value "${s.discriminantValue.wireValue}" was removed.`),!1)})}areSingleUnionTypesCompatible({from:t,to:r}){switch(t.propertiesType){case"samePropertiesAsObject":if(r.propertiesType==="samePropertiesAsObject")return this.areDeclaredTypeNamesCompatible({from:t,to:r});break;case"singleProperty":if(r.propertiesType==="singleProperty")return this.areNameAndWireValuesCompatible({from:t.name,to:r.name})&&this.areTypeReferencesCompatible({from:t.type,to:r.type});break;case"noProperties":if(r.propertiesType==="noProperties")return!0;break;default:de(t)}return this.errors.add(`Single union type of style "${t.propertiesType}" is not compatible with style "${r.propertiesType}".`),!1}areUndiscriminatedUnionTypesCompatible({from:t,to:r}){return t.members.every((i,n)=>{let a=r.members[n];return a?this.areTypeReferencesCompatible({from:i.type,to:a.type}):(this.errors.add(`Undiscriminated union member at index ${n} was removed.`),!1)})}checkForNewRequiredTypeReferences({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewFileUploadRequestProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||n==="file"||n==="fileArray"||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}checkForNewInlinedRequestBodyProperties({from:t,to:r}){for(let[i,n]of Object.entries(r))t[i]||(n.type!=="container"||n.container.type!=="optional")&&this.errors.add(`Required property "${i}" was added.`)}areTypeReferencesCompatible({from:t,to:r}){switch(t.type){case"primitive":if(r.type==="primitive")return this.arePrimitiveTypesCompatible({from:t,to:r});break;case"container":if(r.type==="container")return this.areContainerTypesCompatible({from:t.container,to:r.container});break;case"named":if(r.type==="named")return this.areNamedTypesCompatible({from:t,to:r});break;case"unknown":if(r.type==="unknown")return!0;break;default:de(t)}return this.errors.add(`TypeReference "${t.type}" is not compatible with type "${r.type}".`),!1}arePrimitiveTypesCompatible({from:t,to:r}){return t.primitive.v1===r.primitive.v1}areContainerTypesCompatible({from:t,to:r}){switch(t.type){case"list":if(r.type==="list")return this.areTypeReferencesCompatible({from:t.list,to:r.list});break;case"set":if(r.type==="set")return this.areTypeReferencesCompatible({from:t.set,to:r.set});break;case"map":if(r.type==="map")return this.areTypeReferencesCompatible({from:t.keyType,to:r.keyType})&&this.areTypeReferencesCompatible({from:t.valueType,to:r.valueType});break;case"optional":if(r.type==="optional")return this.areTypeReferencesCompatible({from:t.optional,to:r.optional});break;case"nullable":if(r.type==="nullable")return this.areTypeReferencesCompatible({from:t.nullable,to:r.nullable});break;case"literal":if(r.type==="literal")return this.areLiteralsCompatible({from:t.literal,to:r.literal});break;default:de(t)}return this.errors.add(`Container type "${t.type}" is not compatible with type "${r.type}".`),!1}areNamedTypesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredTypeNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areDeclaredErrorNamesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&this.areFernFilepathsCompatible({from:t.fernFilepath,to:r.fernFilepath})}areNameAndWireValuesCompatible({from:t,to:r}){return this.areNamesCompatible({from:t.name,to:r.name})&&t.wireValue===r.wireValue}areLiteralsCompatible({from:t,to:r}){switch(t.type){case"boolean":if(r.type==="boolean")return t.boolean===r.boolean;break;case"string":if(r.type==="string")return t.string===r.string;break;default:de(t)}return!1}areFernFilepathsCompatible({from:t,to:r}){return t.allParts.length!==r.allParts.length?!1:t.allParts.every((i,n)=>{let a=r.allParts[n];return a==null?!1:this.areNamesCompatible({from:i,to:a})})}areNamesCompatible({from:t,to:r}){return t.originalName===r.originalName}getInlinedRequestBody(t){let r={};for(let i of[...t.extendedProperties??[],...t.properties])r[i.name.wireValue]=i.valueType;return r}getFileUploadRequest(t){let r={};for(let i of t)switch(i.type){case"file":r[i.value.key.wireValue]="file";break;case"bodyProperty":r[i.name.wireValue]=i.valueType;break;default:de(i)}return r}getKeyForDeclaration({name:t,fernFilepath:r}){return`${r.allParts.map(n=>n.camelCase.unsafeName).join(".")}.${t.pascalCase.unsafeName}`}};function $An(e,t,r){let{environments:i,changedBaseUrlIds1:n,changedBaseUrlIds2:a}=sFD(e.environments,t.environments,r),{services:o,websocketChannels:c}=cFD(e,t,n,a);return{apiName:e.apiName,basePath:e.basePath,selfHosted:e.selfHosted&&t.selfHosted,apiDisplayName:e.apiDisplayName??t.apiDisplayName,apiDocs:e.apiDocs??t.apiDocs,auth:{requirement:e.auth?.requirement??t.auth?.requirement,schemes:t.auth?.schemes?.length!=null&&t.auth.schemes.length>(e.auth?.schemes?.length??0)?t.auth.schemes:e.auth?.schemes??[],docs:e.auth?.docs??t.auth?.docs},headers:[...e.headers??[],...t.headers??[]],environments:i,types:{...e.types??{},...t.types??{}},constants:{...e.constants??{},...t.constants??{}},errors:{...e.errors??{},...t.errors??{}},services:o,webhookGroups:{...e.webhookGroups??{},...t.webhookGroups??{}},subpackages:uFD(e.subpackages,t.subpackages),websocketChannels:c,rootPackage:{service:e.rootPackage.service??t.rootPackage.service,types:[...e.rootPackage.types??[],...t.rootPackage.types??[]],errors:[...e.rootPackage.errors??[],...t.rootPackage.errors??[]],subpackages:[...e.rootPackage.subpackages??[],...(t.rootPackage.subpackages??[]).filter(d=>!e.rootPackage.subpackages?.includes(d))],fernFilepath:e.rootPackage.fernFilepath??t.rootPackage.fernFilepath,webhooks:e.rootPackage.webhooks??t.rootPackage.webhooks,websocket:e.rootPackage.websocket??t.rootPackage.websocket,hasEndpointsInTree:e.rootPackage.hasEndpointsInTree||t.rootPackage.hasEndpointsInTree,navigationConfig:e.rootPackage.navigationConfig??t.rootPackage.navigationConfig,docs:e.rootPackage.docs??t.rootPackage.docs},fdrApiDefinitionId:e.fdrApiDefinitionId??t.fdrApiDefinitionId,apiVersion:e.apiVersion??t.apiVersion,idempotencyHeaders:[...e.idempotencyHeaders??[],...t.idempotencyHeaders??[]],pathParameters:[...e.pathParameters??[],...t.pathParameters??[]],errorDiscriminationStrategy:e.errorDiscriminationStrategy??t.errorDiscriminationStrategy,variables:[...e.variables??[],...t.variables??[]],serviceTypeReferenceInfo:e.serviceTypeReferenceInfo??t.serviceTypeReferenceInfo,readmeConfig:e.readmeConfig??t.readmeConfig,sourceConfig:e.sourceConfig??t.sourceConfig,publishConfig:e.publishConfig??t.publishConfig,dynamic:e.dynamic??t.dynamic,sdkConfig:e.sdkConfig??t.sdkConfig,audiences:[...e.audiences??[],...t.audiences??[]],generationMetadata:e.generationMetadata??t.generationMetadata,apiPlayground:e.apiPlayground??t.apiPlayground}}function uFD(e,t){let r=e;for(let[i,n]of Object.entries(t))r[i]==null?r[i]=n:r[i]={name:n.name,displayName:n.displayName,fernFilepath:n.fernFilepath,hasEndpointsInTree:r[i].hasEndpointsInTree||n.hasEndpointsInTree,navigationConfig:r[i].navigationConfig??n.navigationConfig,docs:r[i].docs??n.docs,service:r[i].service??n.service,subpackages:[...r[i].subpackages??[],...(n.subpackages??[]).filter(a=>!r[i]?.subpackages?.includes(a))],webhooks:r[i].webhooks??n.webhooks,websocket:r[i].websocket??n.websocket,errors:[...r[i].errors??[],...n.errors??[]],types:[...r[i].types??[],...n.types??[]]};return r}function sFD(e,t,r){if(e==null&&t==null)return{environments:void 0,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(t==null)return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(e==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};if(JSON.stringify(e)===JSON.stringify(t))return{environments:e,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let i=Lrh(e),n=Lrh(t);if(i&&n&&e.environments.type==="singleBaseUrl"&&t.environments.type==="singleBaseUrl")return{environments:{defaultEnvironment:e.defaultEnvironment??t.defaultEnvironment,environments:xD.singleBaseUrl({environments:[...e.environments.environments,...t.environments.environments]})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let a=i?t.defaultEnvironment:e.defaultEnvironment,o=e.environments,c=t.environments;if(o.type==="singleBaseUrl"&&c.type==="singleBaseUrl"){let d=i?c:o,s=i?o:c,u={},{deconflictedEnvironments2:f,changedBaseUrlIds2:p}=lFD(d,s,r);if(d.environments[0]==null)return{environments:t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0};let _="Base",h=r.generateName("Base");return d.environments.forEach(y=>{u[y.id]=_}),{environments:{defaultEnvironment:a,environments:xD.multipleBaseUrls({baseUrls:[{id:_,name:h},...f.environments.map(y=>({id:y.id,name:y.name}))],environments:d.environments.map(y=>({id:y.id,name:y.name,urls:{[_]:y.url,...Object.fromEntries(f.environments.map(b=>[b.id,b.url]))},docs:void 0}))})},changedBaseUrlIds1:i?p:u,changedBaseUrlIds2:i?u:p}}if(o.type==="multipleBaseUrls"&&c.type==="singleBaseUrl"||o.type==="singleBaseUrl"&&c.type==="multipleBaseUrls"){let d=o.type==="singleBaseUrl"?o:c,s=o.type==="multipleBaseUrls"?o:c,{deconflictedEnvironments1:u,changedBaseUrlIds1:f}=fFD(d,s,r);return{environments:{defaultEnvironment:a,environments:xD.multipleBaseUrls({baseUrls:[...s.baseUrls,...u.environments.map(p=>({id:p.id,name:p.name}))],environments:s.environments.map(p=>({...p,urls:{...p.urls,...Object.fromEntries(u.environments.map(_=>[_.id,_.url]))}}))})},changedBaseUrlIds1:o.type==="singleBaseUrl"?f:void 0,changedBaseUrlIds2:o.type==="singleBaseUrl"?void 0:f}}if(o.type==="multipleBaseUrls"&&c.type==="multipleBaseUrls"){let{deconflictedEnvironments:d,changedBaseUrlIds:s}=dFD(o,c,r);return{environments:{defaultEnvironment:a,environments:xD.multipleBaseUrls({baseUrls:[...o.baseUrls,...d.baseUrls],environments:o.environments.flatMap(u=>d.environments.map(f=>({...u,urls:{...u.urls,...f.urls}})))})},changedBaseUrlIds1:void 0,changedBaseUrlIds2:s}}return{environments:e??t,changedBaseUrlIds1:void 0,changedBaseUrlIds2:void 0}}function cFD(e,t,r,i){if(r!=null)for(let[o,c]of Object.entries(r)){for(let d of Object.values(e.services))for(let s of Object.values(d.endpoints))s.baseUrl==o&&(s.baseUrl=c),s.v2BaseUrls?.includes(o)&&(s.v2BaseUrls=s.v2BaseUrls.map(u=>u===o?c:u));for(let d of Object.values(e.websocketChannels??{}))d.baseUrl==o&&(d.baseUrl=c)}if(i!=null)for(let[o,c]of Object.entries(i)){for(let d of Object.values(t.services))for(let s of Object.values(d.endpoints))s.baseUrl==o&&(s.baseUrl=c),s.v2BaseUrls?.includes(o)&&(s.v2BaseUrls=s.v2BaseUrls.map(u=>u===o?c:u));for(let d of Object.values(t.websocketChannels??{}))d.baseUrl==o&&(d.baseUrl=c)}let n=e.services;for(let[o,c]of Object.entries(t.services))n[o]==null?n[o]=c:n[o]={availability:c.availability,name:c.name,displayName:c.displayName,basePath:c.basePath,endpoints:[...n[o].endpoints??[],...c.endpoints],pathParameters:[...n[o].pathParameters??[],...c.pathParameters??[]],headers:[...n[o].headers??[],...c.headers??[]],encoding:c.encoding,transport:c.transport,audiences:[...n[o].audiences??[],...c.audiences??[]]};let a={...e.websocketChannels??{},...t.websocketChannels??{}};return{services:n,websocketChannels:a}}function lFD(e,t,r){let i={},n=new Set(e.environments.map(s=>s.id)),a=new Set(e.environments.map(s=>s.name)),o=new Map(e.environments.map(s=>[s.url,s.id])),c=t.environments.filter(s=>{let u=o.get(s.url);return u!=null?(i[s.id]=u,!1):!0}).map(s=>{if(n.has(s.id)||a.has(s.name)){let u=PHc(s.id,n);return i[s.id]=u,{...s,id:u,name:r.generateName(u)}}return s});return{deconflictedEnvironments2:xD.singleBaseUrl({environments:c}),changedBaseUrlIds2:i}}function fFD(e,t,r){let i={},n=new Set(t.baseUrls.map(d=>d.id)),a=new Set(t.baseUrls.map(d=>d.name)),o=e.environments.map(d=>{if(n.has(d.id)||a.has(d.name)){let s=PHc(d.id,n);return i[d.id]=s,{...d,id:s,name:r.generateName(s)}}return d});return{deconflictedEnvironments1:xD.singleBaseUrl({environments:o}),changedBaseUrlIds1:i}}function dFD(e,t,r){let i={},n=new Set(e.baseUrls.map(s=>s.id)),a=new Set(e.baseUrls.map(s=>s.name)),o=t.baseUrls.map(s=>{if(n.has(s.id)||a.has(s.name)){let u=PHc(s.id,n);return i[s.id]=u,{...s,id:u,name:r.generateName(u)}}return s}),c=t.environments.map(s=>({...s,urls:Object.fromEntries(Object.entries(s.urls).map(([u,f])=>[i[u]??u,f]))}));return{deconflictedEnvironments:xD.multipleBaseUrls({baseUrls:o,environments:c}),changedBaseUrlIds:i}}function Lrh(e){return e.environments.type==="singleBaseUrl"?e.environments.environments.some(t=>t.url&&(t.url.startsWith("ws://")||t.url.startsWith("wss://"))):e.environments.type==="multipleBaseUrls"?e.environments.environments.some(t=>Object.values(t.urls).some(r=>r&&(r.startsWith("ws://")||r.startsWith("wss://")))):!1}function PHc(e,t){let r=e,i=1;for(;t.has(r);)r=`${e}-${i}`,i++;return r}function IZ({relativeFilepath:e,casingsGenerator:t}){let r=GMe(e),i=i5t(e,{stripExtension:!0}),n=r==="."?[]:r.split("/").map(c=>t.generateName(c)),a=i!==nAn?t.generateName(i):void 0,o=[];return o.push(...n),a!=null&&o.push(a),{allParts:o,packagePath:n,file:a}}function y2i({referencedIn:e,importPath:t}){return PC(GMe(e),t)}function Ume({reference:e,referencedIn:t,imports:r}){let[i,n,...a]=e.split(".");if(i==null||a.length>0)return;if(n==null)return{typeName:i,relativeFilepath:t};let c=r[i];if(c!=null)return{relativeFilepath:y2i({referencedIn:t,importPath:c}),typeName:n}}function lU({typeName:e,file:t}){let r=Ume({reference:e,referencedIn:t.relativeFilepath,imports:t.imports});if(r==null)throw new Error("Failed to locate type: "+e);let i={name:t.casingsGenerator.generateName(r.typeName),fernFilepath:IZ({relativeFilepath:r.relativeFilepath,casingsGenerator:t.casingsGenerator}),displayName:void 0};return{...i,typeId:M_.generateTypeId(i)}}function Xka(e){if(e!=null)return e=e.replace(/\*\//g,"* /"),e.endsWith(`
|
|
1437
1437
|
`)||e.endsWith("\r")?e.substring(0,e.length-1):e}var pFD={docs:void 0,availability:void 0};function w5(e){return typeof e=="string"?pFD:{docs:Xka(e.docs),availability:CZ(e.availability)}}function CZ(e){if(e!=null)return{status:_FD(typeof e=="string"?e:e.status),message:typeof e!="string"?e.message:void 0}}function Vrh(e){return typeof e=="string"?[]:e.audiences??[]}function _FD(e){switch(e){case"in-development":return nR.InDevelopment;case"pre-release":return nR.PreRelease;case"deprecated":return nR.Deprecated;case"generally-available":return nR.GeneralAvailability;default:de(e)}}function Wrh({object:e,file:t}){return Jl.object({extends:C5t(e.extends).map(r=>lU({typeName:r,file:t})),properties:Zka(e,t),extraProperties:e["extra-properties"]??!1,extendedProperties:void 0})}function Zka(e,t){return e.properties==null?[]:Object.entries(e.properties).map(([r,i])=>({...w5(i),name:t.casingsGenerator.generateNameAndWireValue({wireValue:r,name:fU({propertyKey:r,property:i}).name}),valueType:t.parseTypeReference(i),propertyAccess:ida({property:i}),v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}))}function C5t(e){return e==null?[]:typeof e=="string"?[e]:e}function fU({propertyKey:e,property:t}){return typeof t!="string"&&t.name!=null?{name:t.name,wasExplicitlySet:!0}:{name:e,wasExplicitlySet:!1}}function ida({property:e}){if(typeof e=="string")return;let t=e.access;if(t!=null)switch(t){case"read-only":return x2t.ReadOnly;case"write-only":return x2t.WriteOnly;default:de(t)}}function Grh({request:e,file:t}){let r=e!=null?Gka(e):void 0;if(r!=null)return FA.bytes({isOptional:r.isOptional,contentType:typeof e=="string"?void 0:e?.["content-type"],docs:typeof e=="string"?void 0:e?.docs,v2Examples:void 0});if(typeof e=="string")return FA.reference(K_u({requestBody:e,file:t}));if(e?.body==null)return;let i=UAn(e);if(i!=null)return FA.fileUpload({contentType:e["content-type"],name:t.casingsGenerator.generateName(i.name),properties:i.properties.map(n=>n.isFile?n.isArray?oR.file(EZ.fileArray({key:t.casingsGenerator.generateNameAndWireValue({wireValue:n.key,name:n.key}),isOptional:n.isOptional,contentType:n.contentType,docs:n.docs})):oR.file(EZ.file({key:t.casingsGenerator.generateNameAndWireValue({wireValue:n.key,name:n.key}),isOptional:n.isOptional,contentType:n.contentType,docs:n.docs})):oR.bodyProperty({...xrh({propertyKey:n.key,propertyDefinition:n.propertyType,docs:n.docs,availability:CZ(n.availability),file:t}),style:n.style??yFD(n.contentType),contentType:n.contentType})),docs:e.docs,v2Examples:void 0});if(AE(e.body)){if(e.name==null)throw new Error("Name is missing for inlined request");return FA.inlinedRequestBody({name:t.casingsGenerator.generateName(e.name),extends:C5t(e.body.extends).map(n=>lU({typeName:n,file:t})),contentType:e["content-type"],docs:e.docs,properties:e.body.properties!=null?Object.entries(e.body.properties).map(([n,a])=>xrh({propertyKey:n,propertyDefinition:a,docs:typeof a!="string"?a.docs:void 0,availability:typeof a!="string"?CZ(a.availability):void 0,file:t})):[],extraProperties:e.body["extra-properties"]??!1,extendedProperties:void 0,v2Examples:void 0})}return FA.reference(K_u({requestBody:e.body,file:t,contentType:e["content-type"]}))}var hFD={"application/json":"json"};function yFD(e){return e?hFD[e]:void 0}function K_u({requestBody:e,file:t,contentType:r}){return{docs:typeof e!="string"?e.docs:void 0,requestBodyType:t.parseTypeReference(e),contentType:r,v2Examples:void 0}}function xrh({propertyKey:e,propertyDefinition:t,docs:r,availability:i,file:n}){return{docs:r,availability:i,name:n.casingsGenerator.generateNameAndWireValue({wireValue:e,name:fU({propertyKey:e,property:t}).name}),valueType:n.parseTypeReference(t),v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}},propertyAccess:void 0}}function JAn({typeResolver:e,file:t,resolvedType:r,property:i}){switch(r._type){case"container":if(r.container._type==="optional")return JAn({typeResolver:e,file:t,resolvedType:r.container.itemType,property:i});break;case"named":if(Gv(r.declaration))return jHc({typeResolver:e,file:r.file,objectSchema:r.declaration,property:i});break;case"primitive":case"unknown":break;default:de(r)}throw new Error("Internal error; response must be an object in order to return a property as a response")}function jHc({typeResolver:e,file:t,objectSchema:r,property:i}){let a=Hrh(r,t,e)[i];if(a==null)throw new Error(`Object does not have a property named ${i}.`);return a}function Hrh(e,t,r){let i=[];typeof e.extends=="string"?i=[e.extends]:Array.isArray(e.extends)&&(i=e.extends);let n={};for(let o of i){let c=bFD(o,t,r);Object.entries(c).map(([d,s])=>{n[d]=s})}return Zka(e,t).forEach(o=>{n[o.name.name.originalName]=o}),n}function bFD(e,t,r){let i=r.resolveNamedTypeOrThrow({referenceToNamedType:e,file:t});if(i._type==="named"&&Gv(i.declaration))return Hrh(i.declaration,t,r);throw new Error(`Extended type ${e} must be another named type`)}function $_u({typeResolver:e,file:t,resolvedType:r,propertyComponents:i}){if(i.length===0)return;if(i.length===1)return JAn({typeResolver:e,file:t,resolvedType:r,property:i[0]??""});let n=$rh(r);if(n!=null)return J_u({typeResolver:e,file:t,objectSchema:n,propertyComponents:i})}function J_u({typeResolver:e,file:t,objectSchema:r,propertyComponents:i}){if(i.length===0)return;if(i.length===1)return jHc({typeResolver:e,file:t,objectSchema:r,property:i[0]??""});let n=vFD({typeResolver:e,file:t,objectSchema:r,property:i[0]??""}),a=e.resolveTypeOrThrow({type:n,file:t});return $_u({typeResolver:e,file:nda(a)??t,resolvedType:a,propertyComponents:i.slice(1)})}function vFD({typeResolver:e,file:t,objectSchema:r,property:i}){let a=Krh({typeResolver:e,file:t,objectSchema:r})[i];if(a==null)throw new Error(`Response does not have a property named ${i}.`);return a}function Krh({typeResolver:e,file:t,objectSchema:r}){let i=[];typeof r.extends=="string"?i=[r.extends]:Array.isArray(r.extends)&&(i=r.extends);let n={};for(let a of i){let o=gFD({typeResolver:e,file:t,extendedType:a});Object.entries(o).map(([c,d])=>{n[c]=d})}return r.properties!=null&&Object.entries(r.properties).map(([a,o])=>{n[a]=typeof o=="string"?o:o.type}),n}function gFD({typeResolver:e,file:t,extendedType:r}){let i=e.resolveNamedTypeOrThrow({referenceToNamedType:r,file:t});if(i._type==="named"&&Gv(i.declaration))return Krh({typeResolver:e,file:nda(i)??t,objectSchema:i.declaration});throw new Error(`Extended type ${r} must be another named type.`)}function nda(e){if(e!=null){if(e._type==="named")return e.file;if(e._type==="container"&&e.container._type==="optional")return nda(e.container.itemType)}}function $rh(e){if(e!=null){if(e._type==="named"&&Gv(e.declaration))return e.declaration;if(e._type==="container"&&e.container._type==="optional")return $rh(e.container.itemType)}}function q5t(e){return e.substring(9)?.split(".")??[]}function Lme(e){return e.substring(10)?.split(".")??[]}var Y_u="request",kka="body";function Yrh({request:e,endpointKey:t,endpoint:r,service:i,file:n,typeResolver:a,propertyResolver:o}){let c=OFD({request:e,service:i,file:n,typeResolver:a});if(c!=null)return{shape:c,requestParameterName:n.casingsGenerator.generateName(Y_u),streamParameter:r["stream-condition"]!=null?o.resolveRequestPropertyOrThrow({file:n,endpoint:t,propertyComponents:q5t(r["stream-condition"])}):void 0}}function OFD({service:e,request:t,file:r,typeResolver:i}){let n=()=>{if(typeof t=="string"||t?.name==null)throw new Error("Name is missing for request wrapper");return IDe.wrapper({wrapperName:r.casingsGenerator.generateName(t.name),bodyKey:r.casingsGenerator.generateName(kka),includePathParameters:AFD(t),onlyPathParameters:mFD({request:t,file:r,typeResolver:i})})};if(!wHc({headers:e.headers??{},file:r,typeResolver:i}))return n();if(t==null)return;if(typeof t=="string")return IDe.justRequestBody(Jrh({requestBody:t,file:r}));let{body:a}=t;if(X_u({request:t,file:r,typeResolver:i})||a!=null&&AE(a))return n();if(a!=null)return IDe.justRequestBody(Jrh({requestBody:a,file:r}))}function Jrh({requestBody:e,file:t,contentType:r}){let i=typeof e=="string"?FDe(e):FDe(e.type);return i!=null?E5t.bytes({isOptional:i.isOptional,contentType:r,docs:void 0,v2Examples:void 0}):E5t.typeReference(K_u({requestBody:e,file:t,contentType:r}))}function X_u({request:e,file:t,typeResolver:r}){let{headers:i={},"path-parameters":n={},"query-parameters":a={}}=e;return!wHc({headers:i,file:t,typeResolver:r})||KP(n)>0||KP(a)>0}function mFD({request:e,file:t,typeResolver:r}){let{headers:i={},"path-parameters":n={},"query-parameters":a={}}=e;return KP(n)>0&&wHc({headers:i,file:t,typeResolver:r})&&KP(a)===0&&e.body==null}function AFD(e){return typeof e!="string"&&e?.["path-parameters"]!=null}function wHc({headers:e,file:t,typeResolver:r}){return Object.values(e).filter(i=>{let n=typeof i=="string"?i:i.type,a=r.resolveTypeOrThrow({type:n,file:t});return!(a._type==="container"&&a.container._type==="literal")}).length===0}var wAu=se(bO(),1);function T5t(e){return typeof e.request!="string"&&e.request?.["path-parameters"]?e.request?.["path-parameters"]:e["path-parameters"]!=null?e["path-parameters"]:{}}function Z_u(e,t){let r=PFD(e);if(r.length===0)return t;let i=new Map;for(let o of t)i.set(o.name.originalName,o);let n=[],a=new Set;for(let o of r){let c=i.get(o);c!=null&&(n.push(c),a.add(o))}for(let o of t)a.has(o.name.originalName)||n.push(o);return n}function PFD(e){let t=[],r=/{([^}]+)}/g,i;for(;(i=r.exec(e))!==null;)i[1]!=null&&t.push(i[1]);return t}function Xrh({codeSample:e,file:t}){return pHc(e,{language:r=>qme.language({name:r.name!=null?t.casingsGenerator.generateName(r.name):void 0,docs:r.docs,language:r.language,code:r.code,install:r.install}),sdk:r=>qme.sdk({name:r.name!=null?t.casingsGenerator.generateName(r.name):void 0,docs:r.docs,sdk:jFD(r.sdk),code:r.code})})}function jFD(e){switch(e){case"js":return"javascript";case"node":return"javascript";case"ts":return"typescript";case"nodets":return"typescript";case"golang":return"go";case"dotnet":return"csharp";case"c#":return"csharp";case"jvm":return"java";default:return e}}var mOh=se(bO(),1);function b2i({errorName:e,file:t}){let r=Ume({reference:e,referencedIn:t.relativeFilepath,imports:t.imports});if(r==null)throw new Error("Failed to locate error "+e);let i={name:t.casingsGenerator.generateName(r.typeName),fernFilepath:IZ({relativeFilepath:r.relativeFilepath,casingsGenerator:t.casingsGenerator})};return{...i,errorId:M_.generateErrorId(i)}}function QDe(e,t){return[{message:`Expected example to be ${t}. Example is: ${typeof e!="number"?JSON.stringify(e):e}`}]}function Zrh({rawAlias:e,example:t,file:r,typeResolver:i,exampleResolver:n,workspace:a,breadcrumbs:o,depth:c}){return dU({rawTypeReference:typeof e=="string"?e:e.type,example:t,file:r,typeResolver:i,exampleResolver:n,workspace:a,breadcrumbs:o,depth:c+1})}function krh({rawEnum:e,example:t,breadcrumbs:r}){let i=e.enum.map(o=>typeof o=="string"?o:o.value),n=i.map(o=>` - ${o}`).join(`
|
|
1438
1438
|
`);if(typeof t!="string")return QDe(t,"a string");if(i.includes(t))return[];let a=t;return typeof t=="string"&&t.startsWith("\\$")&&(a=t.slice(1)),i.includes(a)?[]:[{message:`"${t}" is not a valid example for this enum. Enum values are:
|
|
@@ -1462,7 +1462,7 @@ ${p}`)}async function FzD(e,t){await Th(void 0,t??"docker",["pull",e],{all:!0,do
|
|
|
1462
1462
|
`)}];let _=typeof p=="string"?p:p.type;if(typeof _!="string")return aOh(f);let h=i.resolveType({type:_,file:a});if(h==null)return[];let y=typeof t.extends>"u"?[]:typeof t.extends=="string"?[t.extends]:t.extends;if(t["base-properties"]!=null||y.length>0){let g={properties:t["base-properties"],extends:y},A=tBe({typeName:void 0,objectDeclaration:g,typeResolver:i,definitionFile:a.definitionFile,workspace:o,filepathOfDeclaration:a.relativeFilepath,smartCasing:!1}),j=new Set(A.map(E=>E.wireKey)),w=ejn({typeName:e,typeNameForBreadcrumb:e,rawObject:g,file:a,example:f,typeResolver:i,exampleResolver:n,workspace:o,breadcrumbs:c,depth:d+1}).filter(E=>{let B=E.message.toLowerCase();if(B.includes("unexpected property")){let q=B.match(/unexpected property "([^"]+)"/);if(q&&q[1]&&!j.has(q[1]))return!1}return!0});if(w.length>0)return w}if(h._type==="named"&&Gv(h.declaration)){let g=Object.fromEntries(Object.entries(f).filter(([M])=>!(t["base-properties"]?.[M]!=null||y.some(w=>{let E=i.resolveNamedType({referenceToNamedType:w,file:a});return E?._type==="named"&&Gv(E.declaration)?E.declaration.properties?.[M]!=null:!1})))),j=h.declaration.properties?.[s]!=null||(typeof h.declaration.extends>"u"?[]:typeof h.declaration.extends=="string"?[h.declaration.extends]:h.declaration.extends).some(w=>{let E=i.resolveNamedType({referenceToNamedType:w,file:h.file});return E?._type==="named"&&Gv(E.declaration)?E.declaration.properties?.[s]!=null:!1})?{[s]:u,...g}:g;return ejn({typeName:e,typeNameForBreadcrumb:e,rawObject:h.declaration,file:h.file,example:j,typeResolver:i,exampleResolver:n,workspace:o,breadcrumbs:c,depth:d+1})}let b=typeof p!="string"&&typeof p.key=="string"?p.key:void 0;if(b==null)return[];let{[b]:v,...O}=f,m=[];return typeof v>"u"?m.push({message:`Missing property "${b}"`}):m.push(...dU({rawTypeReference:_,example:v,typeResolver:i,exampleResolver:n,file:a,workspace:o,breadcrumbs:c,depth:d+1})),m.push(...aOh(O)),m}function aOh(e){return Object.keys(e).map(t=>({severity:"fatal",message:`Unexpected property "${t}"`}))}function mAu({typeName:e,typeDeclaration:t,file:r,typeResolver:i,exampleResolver:n,example:a,workspace:o,breadcrumbs:c,depth:d}){return Lq(t,{alias:s=>Zrh({rawAlias:s,file:r,typeResolver:i,exampleResolver:n,example:a,workspace:o,breadcrumbs:c,depth:d}),enum:s=>krh({rawEnum:s,example:a,breadcrumbs:c}),object:s=>ejn({typeName:e,typeNameForBreadcrumb:e,rawObject:s,example:a,file:r,typeResolver:i,exampleResolver:n,workspace:o,breadcrumbs:c,depth:d}),discriminatedUnion:s=>oOh({typeName:e,rawUnion:s,example:a,file:r,typeResolver:i,exampleResolver:n,workspace:o,breadcrumbs:c,depth:d}),undiscriminatedUnion:s=>kgh({rawUnion:s,example:a,file:r,typeResolver:i,exampleResolver:n,workspace:o,breadcrumbs:c,depth:d})})}var hOh=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/,VcB=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,WcB=/^\d{4}-\d{2}-\d{2}$/,xcB=128;function dU({rawTypeReference:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:o,depth:c}){if(c>xcB)return[{message:"Example is too deeply nested. This may indicate a circular reference. Example generation was truncated.",severity:"warning"}];if(typeof t=="string"&&t.startsWith("$")){let d=r.resolveType({type:e,file:n});if(d==null)return[];let s=i.parseExampleReference(t);if(s==null)return[];let u=r.resolveNamedType({referenceToNamedType:s.rawTypeReference,file:n});return u==null?[]:__a({expected:d,actual:u})?[]:[{message:`Expected example to be: ${e}. Example is ${t}.`}]}return QAn({type:e,_default:void 0,validation:void 0,visitor:{primitive:d=>GcB({primitiveType:d,example:t}),named:d=>{let s=r.getDeclarationOfNamedType({referenceToNamedType:d,file:n});return s==null?[]:mAu({typeName:s.typeName,typeDeclaration:s.declaration,file:s.file,example:t,typeResolver:r,exampleResolver:i,workspace:a,breadcrumbs:o,depth:c+1})},map:({keyType:d,valueType:s})=>Wl(t)?Object.entries(t).flatMap(([u,f])=>[...dU({rawTypeReference:d,example:u,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:[...o,u],depth:c+1}),...dU({rawTypeReference:s,example:f,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:[...o,u],depth:c+1})]):QDe(t,"a map"),list:d=>Array.isArray(t)?t.flatMap((s,u)=>dU({rawTypeReference:d,example:s,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:[...o,`${u}`],depth:c+1})):QDe(t,"a list"),set:d=>{if(!Array.isArray(t))return QDe(t,"a list");let s=hAc(t);return s.length>0?[{severity:"fatal",message:`Set has duplicate elements:
|
|
1463
1463
|
`+s.map(u=>` - ${JSON.stringify(u)}`).join(`
|
|
1464
1464
|
`)}]:t.flatMap((u,f)=>dU({rawTypeReference:d,example:u,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:[...o,`${f}`],depth:c+1}))},optional:d=>t==null?[]:dU({rawTypeReference:d,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:o,depth:c+1}),nullable:d=>t===null?[]:dU({rawTypeReference:d,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a,breadcrumbs:o,depth:c+1}),unknown:()=>[],literal:d=>{switch(d.type){case"boolean":return Yme(s=>s===d.boolean,d.boolean.toString())(t);case"string":return Yme(s=>s===d.string||YcB(d.string,s),`"${d.string}"`)(t);default:de(d)}}}})}function GcB({primitiveType:e,example:t}){return e.v2!=null?Cn._visit(e.v2,{integer:r=>HcB({example:t,rules:r.validation}),long:()=>lOh(t),uint:()=>uOh(t),uint64:()=>sOh(t),double:r=>KcB({example:t,rules:r.validation}),float:()=>cOh(t),boolean:()=>fOh(t),string:r=>$cB({example:t,rules:r.validation}),uuid:()=>dOh(t),date:()=>_Oh(t),dateTime:()=>pOh(t),base64:()=>p_a(t),bigInteger:()=>p_a(t),_other:()=>{throw new Error("Unknown primitive type v2: "+e.v2)}}):Ps._visit(e.v1,{integer:()=>yOh(t),long:()=>lOh(t),uint:()=>uOh(t),uint64:()=>sOh(t),double:()=>bOh(t),float:()=>cOh(t),boolean:()=>fOh(t),string:()=>p_a(t),uuid:()=>dOh(t),dateTime:()=>pOh(t),date:()=>_Oh(t),base64:()=>p_a(t),bigInteger:()=>p_a(t),_other:()=>{throw new Error("Unknown primitive type: "+e.v1)}})}function HcB({example:e,rules:t}){let r=yOh(e);if(r.length>0||t==null)return r;let i=e;return t.min!=null&&(t.exclusiveMin&&i<=t.min||!t.exclusiveMin&&i<t.min)?[{message:`Expected integer to be greater than or equal to ${t.min}. Example is ${e}.`}]:t.max!=null&&(t.exclusiveMax&&i>=t.max||!t.exclusiveMax&&i>t.max)?[{message:`Expected integer to be less than or equal to ${t.max}. Example is ${e}.`}]:t.multipleOf!=null&&i%t.multipleOf!==0?[{message:`Expected integer to be a multiple of ${t.multipleOf}. Example is ${e}.`}]:[]}function KcB({example:e,rules:t}){let r=bOh(e);if(r.length>0||t==null)return r;let i=e;return t.min!=null&&(t.exclusiveMin&&i<=t.min||!t.exclusiveMin&&i<t.min)?[{message:`Expected double to be greater than or equal to ${t.min}. Example is ${e}.`}]:t.max!=null&&(t.exclusiveMax&&i>=t.max||!t.exclusiveMax&&i>t.max)?[{message:`Expected double to be less than or equal to ${t.max}. Example is ${e}.`}]:t.multipleOf!=null&&i%t.multipleOf!==0?[{message:`Expected double to be a multiple of ${t.multipleOf}. Example is ${e}.`}]:[]}function $cB({example:e,rules:t}){let r=p_a(e);if(r.length>0||t==null)return r;let i=e;return t.minLength!=null&&i.length<t.minLength?[{message:`Expected string length to be greater than or equal to ${t.minLength}. Example is ${e}, which is of length ${i.length}.`}]:t.maxLength!=null&&i.length>t.maxLength?[{message:`Expected string length to be less than or equal to ${t.maxLength}. Example is ${e}, which is of length ${i.length}.`}]:t.pattern!=null&&!new RegExp(t.pattern).test(i)?[{message:`Expected string to match pattern ${t.pattern}. Example is ${e}.`}]:[]}var p_a=Yme(e=>typeof e=="string","a string"),yOh=Yme(e=>Number.isInteger(e),"an integer"),uOh=Yme(e=>Number.isInteger(e)&&typeof e=="number"&&e>=0,"a uint"),sOh=Yme(e=>Number.isInteger(e)&&typeof e=="number"&&e>=0,"a uint64"),cOh=Yme(e=>typeof e=="number","a float"),bOh=Yme(e=>typeof e=="number","a double"),lOh=Yme(e=>Number.isInteger(e),"an integer"),fOh=Yme(e=>typeof e=="boolean","a boolean"),dOh=Yme(e=>typeof e=="string"&&VcB.test(e),"a UUID"),pOh=Yme(e=>typeof e=="string"&&hOh.test(e),"an ISO 8601 timestamp"),_Oh=Yme(e=>typeof e=="string"&&WcB.test(e)&&hOh.test(e),"a date");function Yme(e,t){return r=>e(r)?[]:QDe(r,t)}function __a({expected:e,actual:t}){if(e._type==="unknown")return!0;if(e._type==="primitive")return t._type==="primitive"&&e.primitive.v1===t.primitive.v1;if(e._type==="container")switch(e.container._type){case"list":case"set":return t._type==="container"&&t.container._type===e.container._type&&__a({expected:e.container.itemType,actual:t.container.itemType});case"optional":return __a({expected:e.container.itemType,actual:t._type==="container"&&t.container._type==="optional"?t.container.itemType:t});case"nullable":return __a({expected:e.container.itemType,actual:t._type==="container"&&t.container._type==="nullable"?t.container.itemType:t});case"map":return t._type==="container"&&t.container._type===e.container._type&&__a({expected:e.container.keyType,actual:t.container.keyType})&&__a({expected:e.container.valueType,actual:t.container.valueType});case"literal":return t._type!=="container"||t.container._type!==e.container._type?!1:JcB({expected:e.container.literal,actual:t.container.literal});default:de(e.container)}if(e._type==="named")return t._type==="named"&&t.filepath===e.filepath&&t.rawName===e.rawName;de(e)}function JcB({expected:e,actual:t}){switch(e.type){case"boolean":return t.type==="boolean"?e.boolean===t.boolean:!1;case"string":return t.type==="string"?e.string===t.string:!1;default:de(e)}}function YcB(e,t){if(typeof t!="string")return!1;let r=Zm.parse(e),i=Zm.parse(t);return r==null||i==null?!1:!!(r.isJSON()&&i.isJSON())}function AAu({_enum:e,file:t}){let r=e.enum.map(n=>({...w5(n),name:t.casingsGenerator.generateNameAndWireValue({wireValue:typeof n=="string"?n:n.value,name:h_a(n).name,opts:{casingOverrides:typeof n!="string"?n.casing:void 0}})})),i;if(e.default!=null&&(i=r.find(n=>n.name.wireValue===e.default),i==null))throw new Error(`Default value ${e.default} not found in enum values`);return{default:i,values:r}}function vOh(e,t){let r=t.enum.find(i=>typeof i=="string"?!1:i.value===e);return{name:typeof r=="string"?e:r?.name??e,wasExplicitlySet:!1}}function h_a(e){return typeof e=="string"?{name:e,wasExplicitlySet:!1}:e.name==null?{name:e.value,wasExplicitlySet:!1}:{name:e.name,wasExplicitlySet:!0}}var XcB=128;function a2c({typeName:e,typeDeclaration:t,example:r,typeResolver:i,exampleResolver:n,fileContainingType:a,fileContainingExample:o,workspace:c,recursionContext:d}){return Lq(t,{alias:s=>ib.alias({value:mO({example:r,rawTypeBeingExemplified:typeof s=="string"?s:s.type,fileContainingRawTypeReference:a,fileContainingExample:o,typeResolver:i,exampleResolver:n,workspace:c,recursionContext:d})}),object:s=>gOh({typeName:e,rawObject:s,example:r,fileContainingType:a,fileContainingExample:o,typeResolver:i,exampleResolver:n,workspace:c,recursionContext:d}),discriminatedUnion:s=>{let u=tjn(s);if(!Wl(r))throw new Error("Example is not an object");let f=r[u];if(f==null)throw new Error("Example is missing discriminant: "+u);if(typeof f!="string")throw new Error("Discriminant value is not a string");let p=s.union[f];if(p==null)throw new Error(`${f} is not one of the specified discriminant values.`);let _=typeof p=="string"?p:typeof p.type=="string"?p.type:void 0,h=Object.entries(s["base-properties"]??{}).map(([b,v])=>{let O=r[b];if(O!=null)return{name:o.casingsGenerator.generateNameAndWireValue({name:b,wireValue:b}),value:mO({example:O,rawTypeBeingExemplified:typeof v=="string"?v:v.type,fileContainingRawTypeReference:a,fileContainingExample:o,typeResolver:i,exampleResolver:n,workspace:c,recursionContext:d})}}).filter(b=>b!=null),y=(typeof s.extends>"u"?[]:typeof s.extends=="string"?[s.extends]:s.extends).flatMap(b=>{let v=i.resolveNamedTypeOrThrow({file:a,referenceToNamedType:b});if(v._type!=="named"||!Gv(v.declaration))throw new Error("Extended type is not a named object");let O=v.declaration;return Object.entries(O.properties??{}).map(([g,A])=>{let j=r[g];if(j!=null)return{name:o.casingsGenerator.generateNameAndWireValue({name:typeof A=="string"?g:A.name??g,wireValue:g}),value:mO({example:j,rawTypeBeingExemplified:typeof A=="string"?A:A.type,fileContainingRawTypeReference:a,fileContainingExample:o,typeResolver:i,exampleResolver:n,workspace:c,recursionContext:d}),propertyAccess:ida({property:A}),originalTypeDeclaration:e}}).filter(g=>g!=null)});return ib.union({discriminant:o.casingsGenerator.generateNameAndWireValue({name:f_a(s).name,wireValue:u}),singleUnionType:kcB({rawValueType:_,rawSingleUnionType:p,fileContainingType:a,fileContainingExample:o,typeResolver:i,exampleResolver:n,example:r,discriminantValueForExample:f,workspace:c,recursionContext:d}),baseProperties:h,extendProperties:y})},enum:s=>{if(typeof r!="string"){let u=s.enum.map(f=>typeof f=="string"?f:f.value).join(", ");throw new Error(`Expected one of ${u}. Received ${r}`)}return ib.enum({value:o.casingsGenerator.generateNameAndWireValue({name:vOh(r,s).name,wireValue:r})})},undiscriminatedUnion:s=>{for(let[p,_]of s.union.entries())if(dU({rawTypeReference:typeof _=="string"?_:_.type,example:r,typeResolver:i,exampleResolver:n,file:a,workspace:c,breadcrumbs:[],depth:0}).length===0)return ib.undiscriminatedUnion({index:p,singleUnionType:mO({example:r,rawTypeBeingExemplified:typeof _=="string"?_:_.type,fileContainingRawTypeReference:a,fileContainingExample:o,typeResolver:i,exampleResolver:n,workspace:c,recursionContext:d})});let f=s.union.map(p=>typeof p=="string"?p:p.type).join(", ");throw new Error(`Expected one of ${f}. Received ${r}`)}})}function mO({example:e,fileContainingExample:t,rawTypeBeingExemplified:r,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:c}){let d=c??{depth:0,seenTypeIds:new Set},{resolvedExample:s,file:u}=a.resolveExampleOrThrow({example:e,file:t}),f=a.resolveAllReferencesInExampleOrThrow({example:e,file:t}).resolvedExample;return{shape:QAn({type:r,_default:void 0,validation:void 0,visitor:{primitive:_=>ZcB({example:s,typeBeingExemplified:_.v1}),map:({keyType:_,valueType:h})=>{if(!Wl(s))throw new Error("Example is not an object");let y={depth:d.depth+1,seenTypeIds:d.seenTypeIds};return as.container(S_.map({map:Object.entries(s).map(([b,v])=>({key:mO({example:b,fileContainingExample:u,rawTypeBeingExemplified:_,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:y}),value:mO({example:v,fileContainingExample:u,rawTypeBeingExemplified:h,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:y})})),keyType:i.parseTypeReference(_),valueType:i.parseTypeReference(h)}))},list:_=>{if(!Array.isArray(s))throw new Error("Example is not a list");let h={depth:d.depth+1,seenTypeIds:d.seenTypeIds};return as.container(S_.list({list:s.map(y=>mO({example:y,fileContainingExample:u,rawTypeBeingExemplified:_,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:h})),itemType:i.parseTypeReference(_)}))},set:_=>{if(!Array.isArray(s))throw new Error("Example is not a list");let h={depth:d.depth+1,seenTypeIds:d.seenTypeIds};return as.container(S_.set({set:s.map(y=>mO({example:y,fileContainingExample:u,rawTypeBeingExemplified:_,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:h})),itemType:i.parseTypeReference(_)}))},optional:_=>{let h={depth:d.depth+1,seenTypeIds:d.seenTypeIds};return as.container(S_.optional({optional:s!=null?mO({example:s,fileContainingExample:u,rawTypeBeingExemplified:_,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:h}):void 0,valueType:i.parseTypeReference(_)}))},nullable:_=>{let h={depth:d.depth+1,seenTypeIds:d.seenTypeIds};return as.container(S_.nullable({nullable:s!=null?mO({example:s,fileContainingExample:u,rawTypeBeingExemplified:_,fileContainingRawTypeReference:i,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:h}):void 0,valueType:i.parseTypeReference(_)}))},literal:_=>{switch(_.type){case"boolean":return as.container(S_.literal({literal:Xn.boolean(_.boolean)}));case"string":return as.container(S_.literal({literal:Xn.string({original:_.string})}));default:de(_)}},named:_=>{let h=n.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:r,file:i}),y=i.parseTypeReference(_);if(y.type!=="named")throw new Error("Type reference is not to a named type.");let b={typeId:y.typeId,fernFilepath:y.fernFilepath,name:y.name,displayName:y.displayName};if(d.depth>XcB||d.seenTypeIds.has(y.typeId))return as.unknown(f);let v={depth:d.depth+1,seenTypeIds:new Set(d.seenTypeIds).add(y.typeId)};return as.named({typeName:b,shape:a2c({typeName:b,typeDeclaration:h.declaration,fileContainingType:h.file,fileContainingExample:u,example:s,typeResolver:n,exampleResolver:a,workspace:o,recursionContext:v})})},unknown:()=>as.unknown(f)}}),jsonExample:f}}function o2c({example:e}){return as.unknown(e)}function ZcB({example:e,typeBeingExemplified:t}){return Ps._visit(t,{string:()=>{if(typeof e!="string")return as.primitive(Xn.string({original:la.STRING}));let r=e.startsWith(`\\${"$"}`)?e.slice(1):e;return as.primitive(Xn.string({original:r}))},dateTime:()=>typeof e!="string"?as.primitive(Xn.string({original:la.DATE_TIME})):as.primitive(Xn.datetime({datetime:new Date(e),raw:e})),date:()=>typeof e!="string"?as.primitive(Xn.string({original:la.DATE})):as.primitive(Xn.date(e)),base64:()=>typeof e!="string"?as.primitive(Xn.string({original:la.BASE64})):as.primitive(Xn.string({original:e})),uint:()=>typeof e!="number"?as.primitive(Xn.uint(la.UINT)):as.primitive(Xn.uint(e)),uint64:()=>typeof e!="number"?as.primitive(Xn.uint64(la.UINT64)):as.primitive(Xn.uint64(e)),integer:()=>typeof e!="number"?as.primitive(Xn.integer(la.INT)):as.primitive(Xn.integer(e)),float:()=>typeof e!="number"?as.primitive(Xn.float(la.FLOAT)):as.primitive(Xn.float(e)),double:()=>typeof e!="number"?as.primitive(Xn.double(la.DOUBLE)):as.primitive(Xn.double(e)),long:()=>typeof e!="number"?as.primitive(Xn.long(la.UINT)):as.primitive(Xn.long(e)),boolean:()=>typeof e!="boolean"?as.primitive(Xn.boolean(la.BOOLEAN)):as.primitive(Xn.boolean(e)),uuid:()=>typeof e!="string"?as.primitive(Xn.string({original:la.UUID})):as.primitive(Xn.uuid(e)),bigInteger:()=>typeof e!="string"?as.primitive(Xn.string({original:la.BIG_INTEGER})):as.primitive(Xn.string({original:e})),_other:()=>{throw new Error("Unknown primitive type: "+t)}})}function gOh({typeName:e,rawObject:t,example:r,fileContainingType:i,fileContainingExample:n,typeResolver:a,exampleResolver:o,workspace:c,recursionContext:d}){if(!Wl(r))throw new Error(`Example is not an object. Got: ${JSON.stringify(r)}`);let s=Object.entries(r).map(([p,_])=>{let h=OOh({typeName:e,wirePropertyKey:p,rawObject:t,typeResolver:a,file:i});return[p,_,h]}),u=s.filter(([,,p])=>p!=null),f=s.filter(([,,p])=>p==null);return ib.object({properties:t.properties!=null||t.extends!=null?u.map(([p,_,h])=>{let y=mO({example:_,fileContainingExample:n,rawTypeBeingExemplified:typeof h.rawPropertyType=="string"?h.rawPropertyType:h.rawPropertyType.type,fileContainingRawTypeReference:h.file,typeResolver:a,exampleResolver:o,workspace:c,recursionContext:d});return{name:n.casingsGenerator.generateNameAndWireValue({name:fU({propertyKey:p,property:h.rawPropertyType}).name,wireValue:p}),value:y,originalTypeDeclaration:h.typeName,propertyAccess:ida({property:h.rawPropertyType})}}):[],extraProperties:t["extra-properties"]!==!0||f.length===0?void 0:f.map(([p,_])=>({name:n.casingsGenerator.generateNameAndWireValue({name:p,wireValue:p}),value:{shape:o2c({example:_}),jsonExample:_}}))})}function OOh({typeName:e,wirePropertyKey:t,rawObject:r,typeResolver:i,file:n}){let a=r.properties?.[t];return a!=null?{typeName:e,rawPropertyType:a,file:n}:iro({wirePropertyKey:t,extends_:r.extends,typeResolver:i,file:n})}function iro({wirePropertyKey:e,extends_:t,typeResolver:r,file:i}){if(t!=null){let n=typeof t=="string"?[t]:t;for(let a of n){let o=r.resolveNamedTypeOrThrow({referenceToNamedType:a,file:i});if(o._type!=="named"||!Gv(o.declaration))throw new Error("Extension is not of a named object");let c=OOh({wirePropertyKey:e,rawObject:o.declaration,typeResolver:r,typeName:o.name,file:o.file});if(c!=null)return c}}}function kcB({rawValueType:e,rawSingleUnionType:t,fileContainingType:r,fileContainingExample:i,typeResolver:n,exampleResolver:a,example:o,discriminantValueForExample:c,workspace:d,recursionContext:s}){let u=i.casingsGenerator.generateNameAndWireValue({name:d_a({unionKey:c,rawSingleUnionType:t}).name,wireValue:c});if(e==null)return{wireDiscriminantValue:u,shape:Qq.noProperties()};let f=n2c({rawSingleUnionType:t,rawValueType:e,parsedValueType:r.parseTypeReference(e),file:r,typeResolver:n});switch(f.propertiesType){case"singleProperty":{if(!Wl(o))throw new Error("Example is not an object");return{wireDiscriminantValue:u,shape:Qq.singleProperty(mO({example:o[f.name.wireValue],rawTypeBeingExemplified:e,typeResolver:n,exampleResolver:a,fileContainingRawTypeReference:r,fileContainingExample:i,workspace:d,recursionContext:s}))}}case"samePropertiesAsObject":{if(!Wl(o))throw new Error("Example is not an object");let p=n.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:e,file:r});for(;d2i(p.declaration);)p=n.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:typeof p.declaration=="string"?p.declaration:p.declaration.type,file:r});if(!Gv(p.declaration))throw new Error(`${e} is not an object`);let _={typeId:f.typeId,fernFilepath:f.fernFilepath,name:f.name,displayName:f.displayName};return{wireDiscriminantValue:u,shape:Qq.samePropertiesAsObject({typeId:M_.generateTypeId(_),object:gOh({rawObject:p.declaration,example:o,fileContainingType:p.file,fileContainingExample:i,typeResolver:n,exampleResolver:a,typeName:_,workspace:d,recursionContext:s})})}}default:de(f)}}function PAu({file:e,queryParameterKey:t,queryParameter:r}){let{name:i}=zWi({queryParameterKey:t,queryParameter:r}),n=e.parseTypeReference(r);return{...w5(r),name:e.casingsGenerator.generateNameAndWireValue({wireValue:t,name:i}),valueType:n,allowMultiple:typeof r!="string"&&r["allow-multiple"]!=null?r["allow-multiple"]:!1,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}},explode:void 0}}function zWi({queryParameterKey:e,queryParameter:t}){return typeof t!="string"&&t.name!=null?{name:t.name,wasExplicitlySet:!0}:{name:e,wasExplicitlySet:!1}}function AOh({service:e,endpoint:t,example:r,typeResolver:i,errorResolver:n,exampleResolver:a,variableResolver:o,file:c,workspace:d}){let s=tlB({service:e,endpoint:t,example:r,typeResolver:i,exampleResolver:a,variableResolver:o,file:c,workspace:d});return{id:r.name??_2i(r),name:r.name!=null?c.casingsGenerator.generateName(r.name):void 0,docs:r.docs,url:olB({file:c,service:e,endpoint:t,example:r,pathParams:s}),...s,...rlB({service:e,endpoint:t,example:r,typeResolver:i,exampleResolver:a,file:c,workspace:d}),queryParameters:r["query-parameters"]!=null?Object.entries(r["query-parameters"]).map(([u,f])=>{let p=typeof t.request!="string"?t.request?.["query-parameters"]?.[u]:void 0;if(p==null)throw new Error(`Query parameter ${u} does not exist`);return{name:c.casingsGenerator.generateNameAndWireValue({name:zWi({queryParameterKey:u,queryParameter:p}).name,wireValue:u}),value:mO({example:f,rawTypeBeingExemplified:typeof p=="string"?p:p.type,typeResolver:i,exampleResolver:a,fileContainingRawTypeReference:c,fileContainingExample:c,workspace:d}),shape:elB({queryParameter:p})}}):[],request:ilB({endpoint:t,example:r,typeResolver:i,exampleResolver:a,file:c,workspace:d}),response:nlB({endpoint:t,example:r,typeResolver:i,errorResolver:n,exampleResolver:a,file:c,workspace:d})}}function elB({queryParameter:e}){return(typeof e!="string"&&e["allow-multiple"]!=null?e["allow-multiple"]:!1)?gN.exploded():gN.single()}function tlB({service:e,endpoint:t,example:r,typeResolver:i,exampleResolver:n,variableResolver:a,file:o,workspace:c}){let d=[],s=[],u=[],f=({name:p,pathParameterDeclaration:_,examplePathParameter:h})=>{let y=nro({parameter:_,variableResolver:a,file:o});return{name:p,value:mO({example:h,rawTypeBeingExemplified:y.rawType,typeResolver:i,exampleResolver:n,fileContainingRawTypeReference:y.file,fileContainingExample:o,workspace:c})}};if(r["path-parameters"]!=null){let p=T5t(t);for(let[_,h]of Object.entries(r["path-parameters"])){let y=o.rootApiFile["path-parameters"]?.[_],b=e["path-parameters"]?.[_],v=p[_];if(y!=null)d.push(f({name:o.casingsGenerator.generateName(_),pathParameterDeclaration:y,examplePathParameter:h}));else if(v!=null)u.push(f({name:o.casingsGenerator.generateName(_),pathParameterDeclaration:v,examplePathParameter:h}));else if(b!=null)s.push(f({name:o.casingsGenerator.generateName(_),pathParameterDeclaration:b,examplePathParameter:h}));else throw new Error(`Path parameter ${_} does not exist`)}}return{rootPathParameters:d,endpointPathParameters:u,servicePathParameters:s}}function rlB({service:e,endpoint:t,example:r,typeResolver:i,exampleResolver:n,file:a,workspace:o}){let c=[],d=[];if(r.headers!=null)for(let[s,u]of Object.entries(r.headers)){let f=typeof t.request!="string"?t.request?.headers?.[s]:void 0,p=e.headers?.[s];f!=null?d.push({name:a.casingsGenerator.generateNameAndWireValue({name:jkt({headerKey:s,header:f}).name,wireValue:s}),value:mO({example:u,rawTypeBeingExemplified:typeof f=="string"?f:f.type,typeResolver:i,exampleResolver:n,fileContainingRawTypeReference:a,fileContainingExample:a,workspace:o})}):p!=null&&c.push({name:a.casingsGenerator.generateNameAndWireValue({name:jkt({headerKey:s,header:p}).name,wireValue:s}),value:mO({example:u,rawTypeBeingExemplified:typeof p=="string"?p:p.type,typeResolver:i,exampleResolver:n,fileContainingRawTypeReference:a,fileContainingExample:a,workspace:o})})}return{endpointHeaders:d,serviceHeaders:c}}function ilB({endpoint:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let o=typeof e.request!="string"?e.request?.body:e.request;if(o==null||typeof o=="string"&&Gka(o)!=null)return;if(!AE(o))return O5.reference(mO({example:t.request,rawTypeBeingExemplified:typeof o!="string"?o.type:o,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}));if(!t.request)return;if(!Wl(t.request))throw new Error(`Example is not an object. Got: ${JSON.stringify(t.request)}`);let c=[],d=[];for(let[s,u]of Object.entries(t.request)){let f=o.properties?.[s],p=typeof f=="string"?f:f?.type;if(!(p!=null&&BZ(p)!=null))if(f!=null)c.push({name:n.casingsGenerator.generateNameAndWireValue({name:fU({propertyKey:s,property:f}).name,wireValue:s}),value:mO({example:u,rawTypeBeingExemplified:typeof f!="string"?f.type:f,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),originalTypeDeclaration:void 0});else{let _=iro({extends_:o.extends,wirePropertyKey:s,typeResolver:r,file:n});if(_==null){if(o["extra-properties"]===!0){d.push({name:n.casingsGenerator.generateNameAndWireValue({name:s,wireValue:s}),value:{jsonExample:u,shape:o2c({example:u})}});continue}throw new Error("Could not find original type declaration for property: "+s)}c.push({name:n.casingsGenerator.generateNameAndWireValue({name:fU({propertyKey:s,property:_.rawPropertyType}).name,wireValue:s}),value:mO({example:u,rawTypeBeingExemplified:typeof _.rawPropertyType=="string"?_.rawPropertyType:_.rawPropertyType.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:_.file,fileContainingExample:n,workspace:a}),originalTypeDeclaration:_.typeName})}}return O5.inlinedRequestBody({jsonExample:i.resolveAllReferencesInExampleOrThrow({example:t.request,file:n}).resolvedExample,properties:c,extraProperties:d.length>0?d:void 0})}function nlB({endpoint:e,example:t,typeResolver:r,errorResolver:i,exampleResolver:n,file:a,workspace:o}){return t.response==null?Zw.ok(PE.body(void 0)):VAn(e,t.response,{body:c=>{if(c.error!=null){let d=i.getDeclarationOrThrow(c.error,a);return Zw.error({error:b2i({errorName:c.error,file:a}),body:d.declaration.type!=null?mO({example:c.body,rawTypeBeingExemplified:d.declaration.type,typeResolver:r,exampleResolver:n,fileContainingRawTypeReference:d.file,fileContainingExample:a,workspace:o}):void 0})}return Zw.ok(PE.body(alB({endpoint:e,example:c,typeResolver:r,exampleResolver:n,file:a,workspace:o})))},stream:c=>{let d=typeof e["response-stream"]=="string"?e["response-stream"]:e["response-stream"]?.type;return Zw.ok(PE.stream(c.stream.map(s=>{if(d!=null)return mO({example:s,rawTypeBeingExemplified:d,typeResolver:r,exampleResolver:n,fileContainingRawTypeReference:a,fileContainingExample:a,workspace:o})}).filter(Cs)))},events:c=>{let d=typeof e["response-stream"]=="string"?e["response-stream"]:e["response-stream"]?.type;return Zw.ok(PE.sse(c.stream.map(({event:s,data:u})=>{if(d==null)return;let f=mO({example:u,rawTypeBeingExemplified:d,typeResolver:r,exampleResolver:n,fileContainingRawTypeReference:a,fileContainingExample:a,workspace:o});return{event:s,data:f}}).filter(Cs)))}})}function alB({endpoint:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let o=typeof e.response!="string"?e.response?.type:e.response;if(o!=null&&t.body!=null)return mO({example:t.body,rawTypeBeingExemplified:o,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a})}function olB({file:e,service:t,endpoint:r,example:i,pathParams:n}){let a=(0,mOh.default)(e.rootApiFile["base-path"]??"",t["base-path"],r.path);if(i["path-parameters"]!=null)for(let o of[...n.endpointPathParameters,...n.servicePathParameters,...n.rootPathParameters])a=a.replaceAll(`{${o.name.originalName}}`,encodeURIComponent(`${o.value.jsonExample}`));return a=a.replaceAll("//","/"),a.startsWith("/")||(a=`/${a}`),a}function POh({endpoint:e,file:t,typeResolver:r}){let i=ulB({endpoint:e,file:t,typeResolver:r}),n=typeof e.response!="string"?e.response?.docs:void 0;return{body:i,statusCode:typeof e.response!="string"?e.response?.["status-code"]:void 0,isWildcardStatusCode:void 0,docs:n}}function ulB({endpoint:e,file:t,typeResolver:r}){let i=slB({endpoint:e,file:t,typeResolver:r}),n=clB({endpoint:e,file:t,typeResolver:r});if(i!=null&&n!=null){let a;switch(i.type){case"fileDownload":{a=j3.fileDownload({...i});break}case"json":{a=j3.json({...i.value});break}case"text":{a=j3.text({...i});break}case"bytes":{a=j3.bytes({...i});break}default:de(i)}return op.streamParameter({nonStreamResponse:a,streamResponse:n})}else{if(i!=null)return i;if(n!=null)return op.streaming(n)}}function slB({endpoint:e,file:t,typeResolver:r}){let{response:i}=e;if(i!=null){let n=typeof i!="string"?i.docs:void 0,a=typeof i=="string"?i:i.type;if(a!=null)return BZ(a)!=null?op.fileDownload({docs:n,v2Examples:void 0}):LAn(a)!=null?op.text({docs:n,v2Examples:void 0}):FDe(a)!=null?op.bytes({docs:n,v2Examples:void 0}):llB(i,n,t,r)}}function clB({endpoint:e,file:t,typeResolver:r}){let{["response-stream"]:i}=e;if(i!=null){let n=typeof i!="string"?i.docs:void 0,a=typeof i=="string"?i:i.type,o=typeof i=="string"?"json":i.format??"json";return KZi(a)?qC.text({docs:n,v2Examples:void 0}):typeof i!="string"&&o==="sse"?qC.sse({docs:n,payload:t.parseTypeReference(a),terminator:typeof i!="string"?i.terminator:void 0,v2Examples:void 0}):qC.json({docs:n,payload:t.parseTypeReference(a),terminator:typeof i!="string"?i.terminator:void 0,v2Examples:void 0})}}function llB(e,t,r,i){let n=typeof e!="string"?e.type:e;if(n==null)return;let a=r.parseTypeReference(typeof e=="string"?e:{...e,type:n}),o=i.resolveTypeOrThrow({type:n,file:r}),c=typeof e!="string"?e.property:void 0;return c!=null?op.json(Nq.nestedPropertyAsResponse({docs:t,responseBodyType:a,responseProperty:JAn({typeResolver:i,file:r,resolvedType:o,property:c}),v2Examples:void 0})):op.json(Nq.response({docs:t,responseBodyType:a,v2Examples:void 0}))}function jOh({propertyResolver:e,file:t,endpointName:r,endpointSchema:i,paginationPropertyComponents:n}){return A5.cursor({page:e.resolveRequestPropertyOrThrow({file:t,endpoint:r,propertyComponents:n.cursor}),next:e.resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:n.next_cursor}),results:e.resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:n.results})})}function wOh({propertyResolver:e,file:t,endpointName:r,paginationPropertyComponents:i}){return A5.custom({results:e.resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:i.results})})}function EOh({propertyResolver:e,file:t,endpointName:r,endpointSchema:i,paginationPropertyComponents:n}){return A5.offset({page:e.resolveRequestPropertyOrThrow({file:t,endpoint:r,propertyComponents:n.offset}),results:e.resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:n.results}),step:n.step!=null?e.resolveRequestPropertyOrThrow({file:t,endpoint:r,propertyComponents:n.step}):void 0,hasNextPage:n.hasNextPage!=null?e.resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:n.hasNextPage}):void 0})}function SOh(e){if(dlB(e))return{type:"offset",offset:q5t(e.offset),results:Lme(e.results),step:e.step!=null?q5t(e.step):void 0,hasNextPage:e["has-next-page"]!=null?Lme(e["has-next-page"]):void 0};if(flB(e))return{type:"cursor",cursor:q5t(e.cursor),next_cursor:Lme(e.next_cursor),results:Lme(e.results)};if(plB(e))return{type:"custom",results:Lme(e.results)};throw new Error("Invalid pagination schema")}function flB(e){return e.cursor!=null}function dlB(e){return e.offset!=null&&e.results!=null}function plB(e){return"type"in e&&e.type==="custom"}function MOh({propertyResolver:e,file:t,endpointName:r,endpointSchema:i}){let n=typeof i.pagination=="boolean"?t.rootApiFile.pagination:i.pagination;if(!n)return;let a=SOh(n);switch(a.type){case"cursor":return jOh({propertyResolver:e,file:t,endpointName:r,endpointSchema:i,paginationPropertyComponents:a});case"offset":return EOh({propertyResolver:e,file:t,endpointName:r,endpointSchema:i,paginationPropertyComponents:a});case"custom":return wOh({propertyResolver:e,file:t,endpointName:r,paginationPropertyComponents:a});default:de(a)}}function DOh({errors:e,file:t}){return e==null?[]:Object.values(e).map(r=>{let i=typeof r=="string"?r:r.error,n=b2i({errorName:i,file:t});return{docs:typeof r!="string"?r.docs:void 0,error:n}})}function BOh({endpointSchema:e}){if(e.retries&&e.retries.disabled!==void 0)return{disabled:e.retries.disabled}}function jAu({source:e}){return{filepath:e.relativeFilePath,packageName:e.packageName,options:e.csharpNamespace!=null?{csharp:{namespace:e.csharpNamespace}}:void 0}}function IOh({source:e,serviceNameOverride:t}){let r=t??e.serviceName;if(r!=null)return{file:jAu({source:e}),name:tro.generateName(r)}}function COh({file:e,serviceDeclaration:t,sourceResolver:r}){return L2t(t.source)?TOh(e,t.source,r,t.transport?.grpc?.["service-name"]):CDe.http()}function qOh({file:e,serviceTransport:t,endpointDeclaration:r,sourceResolver:i}){let n=t.type==="grpc",a=t.type==="http",o=L2t(r.source),c=!o;if(n){if(a&&o)throw new Error("Cannot have a grpc endpoint on an http service");if(n&&c)return CDe.http();if(n&&o){let d=r.source,s=r.transport?.grpc?.["service-name"];return s?TOh(e,d,i,s):void 0}throw new Error(`Internal error; failed to determine endpoint transport for
|
|
1465
|
-
${JSON.stringify(r)}"`)}}function TOh(e,t,r,i){let n=r.resolveSourceOrThrow({source:t,relativeFilepath:e.relativeFilepath});if(n==null||n.type!=="protobuf")throw new Error(`Expected a protobuf source for ${t.proto}.`);let a=IOh({source:n,serviceNameOverride:i});if(a==null)throw new Error(`Failed to resolve service name from ${n.relativeFilePath}.`);return CDe.grpc({service:a})}function ROh({rootDefaultUrl:e,rootPathParameters:t,serviceDefinition:r,file:i,errorResolver:n,typeResolver:a,propertyResolver:o,exampleResolver:c,variableResolver:d,sourceResolver:s,globalErrors:u,workspace:f,auth:p,irSettings:_}){let h=y_a({pathParameters:r["path-parameters"],location:BDe.Service,file:i,variableResolver:d}),y=_.pathParameterOrder,b=(()=>{switch(y){case Ki.PathParameterOrder.UrlOrder:return r["base-path"]?Z_u(r["base-path"],h):h;case Ki.PathParameterOrder.SpecOrder:return h;default:de(y)}})(),v=COh({file:i,serviceDeclaration:r,sourceResolver:s}),O={fernFilepath:i.fernFilepath};return{availability:CZ(r.availability),name:O,displayName:r["display-name"]??void 0,basePath:HD(r["base-path"]),headers:r.headers!=null?Object.entries(r.headers).map(([g,A])=>rBe({headerKey:g,header:A,file:i})):[],pathParameters:b,encoding:blB(v,r),transport:v,endpoints:Object.entries(r.endpoints).map(([g,A])=>{let j=A["base-path"]!=null?(0,wAu.default)(A["base-path"],A.path):i.rootApiFile["base-path"]!=null?(0,wAu.default)(i.rootApiFile["base-path"],r["base-path"],A.path):(0,wAu.default)(r["base-path"],A.path),M=y_a({pathParameters:T5t(A),location:BDe.Endpoint,file:i,variableResolver:d}),w=(()=>{switch(y){case Ki.PathParameterOrder.UrlOrder:return Z_u(A.path,M);case Ki.PathParameterOrder.SpecOrder:return M;default:de(y)}})(),E=A["base-path"]!=null?w:[...t,...b,...w],B=(()=>{switch(y){case Ki.PathParameterOrder.UrlOrder:return Z_u(j,E);case Ki.PathParameterOrder.SpecOrder:return E;default:de(y)}})(),q={...w5(A),id:"",name:i.casingsGenerator.generateName(g),displayName:A["display-name"],auth:typeof A.auth=="boolean"?A.auth:A.auth!=null?A.auth.length>0:r.auth,security:typeof A.auth>"u"||typeof A.auth=="boolean"?A.auth??r.auth===!0?vN._visit(p.requirement,{any:()=>p.schemes.map(R=>({[R.key]:[]})),all:()=>[p.schemes.reduce((R,T)=>({...R,[T.key]:[]}),{})],endpointSecurity:()=>{},_other:()=>{}}):void 0:A.auth,docs:A.docs,idempotent:A.idempotent??r.idempotent??!1,baseUrl:A.url??r.url??e,v2BaseUrls:void 0,method:A.method!=null?ylB(A.method):jE.Post,basePath:A["base-path"]!=null?HD(A["base-path"]):void 0,path:HD(A.path),fullPath:HD(j),pathParameters:w,allPathParameters:B,queryParameters:typeof A.request!="string"&&A.request?.["query-parameters"]!=null?Object.entries(A.request["query-parameters"]).map(([R,T])=>PAu({file:i,queryParameterKey:R,queryParameter:T})):[],headers:typeof A.request!="string"&&A.request?.headers!=null?Object.entries(A.request.headers).map(([R,T])=>rBe({headerKey:R,header:T,file:i})):[],requestBody:Grh({request:A.request,file:i}),v2RequestBodies:void 0,sdkRequest:Yrh({service:r,request:A.request,endpoint:A,endpointKey:g,file:i,typeResolver:a,propertyResolver:o}),response:POh({endpoint:A,file:i,typeResolver:a}),v2Responses:void 0,errors:[...DOh({errors:A.errors,file:i}),...u],userSpecifiedExamples:A.examples!=null?A.examples.map(R=>{try{let T=AOh({service:r,endpoint:A,example:R,typeResolver:a,errorResolver:n,exampleResolver:c,variableResolver:d,file:i,workspace:f});return T===void 0?void 0:{example:T,codeSamples:R["code-samples"]?.map(K=>Xrh({codeSample:K,file:i}))}}catch{return}}).filter(R=>R!==void 0):[],autogeneratedExamples:[],pagination:MOh({propertyResolver:o,file:i,endpointName:g,endpointSchema:A}),transport:qOh({file:i,serviceTransport:v,endpointDeclaration:A,sourceResolver:s}),v2Examples:void 0,source:void 0,audiences:A.audiences,retries:BOh({endpointSchema:A}),apiPlayground:void 0,responseHeaders:[]};return q.id=M_.generateEndpointId(O,q),q}),audiences:r.audiences}}function y_a({pathParameters:e,location:t,file:r,variableResolver:i}){return e==null?[]:Object.entries(e).map(([n,a])=>_lB({parameterName:n,parameter:a,location:t,file:r,variableResolver:i}))}function _lB({parameterName:e,parameter:t,location:r,file:i,variableResolver:n}){return{...w5(t),name:i.casingsGenerator.generateName(e),valueType:hlB({parameter:t,variableResolver:n,file:i}),location:r,variable:Yfa(t)?n.getVariableIdOrThrow(typeof t=="string"?t:t.variable):void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}},explode:void 0}}function hlB({parameter:e,variableResolver:t,file:r}){let i=nro({parameter:e,variableResolver:t,file:r});return i.file.parseTypeReference(i.rawType)}function nro({parameter:e,variableResolver:t,file:r}){let i=EAu({parameter:e,variableResolver:t,file:r});if(i==null)throw new Error("Cannot resolve path parameter");return i}function EAu({parameter:e,variableResolver:t,file:r}){if(Yfa(e)){let i=typeof e=="string"?e:e.variable,n=t.getDeclaration(i,r);return n==null?void 0:{rawType:typeof n.declaration=="string"?n.declaration:n.declaration.type,file:n.file}}else return{file:r,rawType:typeof e=="string"?e:e.type}}function ylB(e){switch(e){case"GET":return jE.Get;case"POST":return jE.Post;case"PUT":return jE.Put;case"PATCH":return jE.Patch;case"DELETE":return jE.Delete;case"HEAD":return jE.Head;default:de(e)}}function rBe({headerKey:e,header:t,file:r}){let{name:i}=jkt({headerKey:e,header:t});return{...w5(t),name:r.casingsGenerator.generateNameAndWireValue({wireValue:e,name:i}),valueType:r.parseTypeReference(t),env:typeof t=="string"?void 0:t.env,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}function jkt({headerKey:e,header:t}){return typeof t!="string"&&t.name!=null?{name:t.name,wasExplicitlySet:!0}:{name:e,wasExplicitlySet:!1}}function blB(e,t){switch(e.type){case"http":return{json:{},proto:void 0};case"grpc":return{json:void 0,proto:{}};default:de(e)}}var DAu=se(bO(),1);var zOh=se(require("crypto")),MAu=new Uint8Array(256),SAu=MAu.length;function u2c(){return SAu>MAu.length-16&&(zOh.default.randomFillSync(MAu),SAu=0),MAu.slice(SAu,SAu+=16)}var L3=[];for(let e=0;e<256;++e)L3.push((e+256).toString(16).slice(1));function NOh(e,t=0){return L3[e[t+0]]+L3[e[t+1]]+L3[e[t+2]]+L3[e[t+3]]+"-"+L3[e[t+4]]+L3[e[t+5]]+"-"+L3[e[t+6]]+L3[e[t+7]]+"-"+L3[e[t+8]]+L3[e[t+9]]+"-"+L3[e[t+10]]+L3[e[t+11]]+L3[e[t+12]]+L3[e[t+13]]+L3[e[t+14]]+L3[e[t+15]]}var FOh=se(require("crypto")),s2c={randomUUID:FOh.default.randomUUID};function vlB(e,t,r){if(s2c.randomUUID&&!t&&!e)return s2c.randomUUID();e=e||{};let i=e.random||(e.rng||u2c)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return NOh(i)}var Xme=vlB;var QOh="1.0.0";var BAu=class{ir;casingsGenerator;auth;authValues;generatorConfig;extendedTypeIds;constructor(t){this.ir=t.ir,this.generatorConfig=t.generatorConfig,this.casingsGenerator=N7({generationLanguage:t.generationLanguage,smartCasing:t.smartCasing??!1,keywords:void 0}),this.auth=this.convertAuth(this.ir.auth),this.authValues=this.getAuthValues(this.ir.auth),this.extendedTypeIds=this.computeExtendedTypeIds()}computeExtendedTypeIds(){let t=new Set;for(let r of Object.values(this.ir.types))if(r.shape.type==="object")for(let i of r.shape.extends)t.add(i.typeId);return t}convert({disableExamples:t}){return{version:QOh,types:this.convertNamedTypes(),headers:this.convertHeaders(),endpoints:this.convertEndpoints({disableExamples:t}),pathParameters:this.convertPathParameters({pathParameters:this.ir.pathParameters}),environments:this.ir.environments,variables:this.convertVariables(),generatorConfig:this.generatorConfig}}convertNamedTypes(){return Object.fromEntries(Object.entries(this.ir.types).map(([t,r])=>[t,this.convertTypeDeclaration(r)]))}convertHeaders(){return this.convertWireValueParameters({wireValueParameters:this.ir.headers})}convertVariables(){if(this.ir.variables.length!==0)return this.ir.variables.map(t=>({id:t.id,name:t.name,typeReference:this.convertTypeReference(t.type)}))}convertEndpoints({disableExamples:t}){let r=this.getAllHttpEndpoints();return Object.fromEntries(r.map(i=>[i.id,this.convertEndpoint({endpoint:i,disableExamples:t})]))}convertEndpoint({endpoint:t,disableExamples:r}){let i=this.convertEndpointLocation({endpoint:t});return{auth:this.auth,declaration:this.convertDeclaration({name:t.name,fernFilepath:t.fernFilepath}),location:i,request:this.convertRequest({endpoint:t}),response:t.response?.body?._visit({json:()=>er.Response.json(),streaming:()=>er.Response.streaming(),streamParameter:()=>er.Response.streamParameter(),fileDownload:()=>er.Response.fileDownload(),text:()=>er.Response.text(),bytes:()=>er.Response.bytes(),_other:()=>er.Response.json()})??er.Response.json(),examples:r?void 0:this.getEndpointSnippetRequests({endpoint:t,location:i})}}convertRequest({endpoint:t}){let r=this.convertPathParameters({pathParameters:[...t.servicePathParameters,...t.pathParameters]});if(t.sdkRequest==null&&t.requestBody==null)return er.Request.body({pathParameters:r,body:void 0});if(t.sdkRequest==null)throw new Error(`Internal error; endpoint "${t.id}" has a request body but no SDK request`);switch(t.sdkRequest.shape.type){case"justRequestBody":return er.Request.body({pathParameters:r,body:this.convertReferencedRequestBodyType({body:t.sdkRequest.shape.value})});case"wrapper":return this.convertInlinedRequest({fernFilepath:t.fernFilepath,wrapper:t.sdkRequest.shape,pathParameters:r,queryParameters:this.convertQueryParameters({queryParameters:t.queryParameters}),headers:this.convertWireValueParameters({wireValueParameters:[...t.serviceHeaders,...t.headers]}),body:t.requestBody});default:de(t.sdkRequest.shape)}}convertReferencedRequestBodyType({body:t}){switch(t.type){case"bytes":return er.ReferencedRequestBodyType.bytes();case"typeReference":return er.ReferencedRequestBodyType.typeReference(this.convertTypeReference(t.requestBodyType));default:de(t)}}convertInlinedRequest({fernFilepath:t,wrapper:r,pathParameters:i,queryParameters:n,headers:a,body:o}){return er.Request.inlined({declaration:this.convertDeclaration({name:r.wrapperName,fernFilepath:t}),pathParameters:i,queryParameters:n,headers:a,body:o!=null?this.convertInlinedRequestBody({wrapper:r,body:o}):void 0,metadata:this.convertInlinedRequestMetadata({wrapper:r})})}convertInlinedRequestMetadata({wrapper:t}){return{includePathParameters:t.includePathParameters??!1,onlyPathParameters:t.onlyPathParameters??!1}}convertInlinedRequestBody({wrapper:t,body:r}){switch(r.type){case"inlinedRequestBody":{let i=[...r.extendedProperties??[],...r.properties];return er.InlinedRequestBody.properties(this.convertBodyPropertiesToParameters({properties:i}))}case"reference":return er.InlinedRequestBody.referenced({bodyKey:t.bodyKey,bodyType:er.ReferencedRequestBodyType.typeReference(this.convertTypeReference(r.requestBodyType))});case"bytes":return er.InlinedRequestBody.referenced({bodyKey:t.bodyKey,bodyType:er.ReferencedRequestBodyType.bytes()});case"fileUpload":return this.convertFileUploadRequestBody({properties:r.properties});default:de(r)}}convertFileUploadRequestBody({properties:t}){return er.InlinedRequestBody.fileUpload({properties:this.convertFileUploadRequestBodyProperties({properties:t})})}convertFileUploadRequestBodyProperties({properties:t}){return t.map(r=>{switch(r.type){case"file":return this.convertFileUploadRequestBodyFileProperty({fileProperty:r.value});case"bodyProperty":return er.FileUploadRequestBodyProperty.bodyProperty({name:r.name,typeReference:this.convertTypeReference(r.valueType),propertyAccess:r.propertyAccess,variable:void 0});default:de(r)}})}convertFileUploadRequestBodyFileProperty({fileProperty:t}){switch(t.type){case"file":return er.FileUploadRequestBodyProperty.file(t.key);case"fileArray":return er.FileUploadRequestBodyProperty.fileArray(t.key);default:de(t)}}convertPathParameters({pathParameters:t}){return t.map(r=>({name:{name:r.name,wireValue:r.name.originalName},typeReference:this.convertTypeReference(r.valueType),propertyAccess:void 0,variable:r.variable}))}convertBodyPropertiesToParameters({properties:t}){return t.map(r=>({name:{name:r.name.name,wireValue:r.name.wireValue},typeReference:this.convertTypeReference(r.valueType),propertyAccess:r.propertyAccess,variable:void 0}))}convertWireValueParameters({wireValueParameters:t}){return t.map(r=>({name:{name:r.name.name,wireValue:r.name.wireValue},typeReference:this.convertTypeReference(r.valueType),propertyAccess:void 0,variable:void 0}))}convertQueryParameters({queryParameters:t}){let r=[];for(let i of t){let n=this.convertTypeReference(i.valueType);i.allowMultiple&&(n=er.TypeReference.list(n)),r.push({name:{name:i.name.name,wireValue:i.name.wireValue},typeReference:n,propertyAccess:void 0,variable:void 0})}return r}convertTypeReference(t){switch(t.type){case"container":return this.convertContainerType(t.container);case"named":return this.convertNamedType(t);case"primitive":return this.convertPrimitiveType(t.primitive);case"unknown":return this.convertUnknownType();default:de(t)}}convertContainerType(t){switch(t.type){case"list":return er.TypeReference.list(this.convertTypeReference(t.list));case"map":return er.TypeReference.map({key:this.convertTypeReference(t.keyType),value:this.convertTypeReference(t.valueType)});case"optional":return er.TypeReference.optional(this.convertTypeReference(t.optional));case"nullable":return er.TypeReference.nullable(this.convertTypeReference(t.nullable));case"set":return er.TypeReference.set(this.convertTypeReference(t.set));case"literal":return er.TypeReference.literal(this.convertLiteral(t.literal));default:de(t)}}convertNamedType(t){return er.TypeReference.named(t.typeId)}convertTypeDeclaration(t){let r=this.convertDeclaration(t.name);switch(t.shape.type){case"alias":return this.convertAlias({declaration:r,alias:t.shape});case"enum":return this.convertEnum({declaration:r,enum_:t.shape});case"object":return this.convertObject({declaration:r,object:t.shape,typeId:t.name.typeId});case"union":return this.convertDiscriminatedUnion({declaration:r,union:t.shape});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({declaration:r,union:t.shape});default:de(t.shape)}}convertAlias({declaration:t,alias:r}){return er.NamedType.alias({declaration:t,typeReference:this.convertTypeReference(r.aliasOf)})}convertEnum({declaration:t,enum_:r}){return er.NamedType.enum({declaration:t,values:r.values.map(i=>i.name)})}convertObject({declaration:t,object:r,typeId:i}){let a=this.extendedTypeIds.has(i)?[...r.properties,...r.extendedProperties??[]]:[...r.extendedProperties??[],...r.properties],o=r.extends.length>0?r.extends.map(c=>c.typeId):void 0;return this.convertObjectProperties({declaration:t,properties:a,extends_:o,additionalProperties:r.extraProperties})}convertObjectProperties({declaration:t,properties:r,extends_:i,additionalProperties:n}){return er.NamedType.object({declaration:t,properties:this.convertBodyPropertiesToParameters({properties:r}),extends:i,additionalProperties:n})}convertDiscriminatedUnion({declaration:t,union:r}){let i=[...this.resolveProperties(r.extends),...r.baseProperties];return er.NamedType.discriminatedUnion({declaration:t,discriminant:r.discriminant,types:Object.fromEntries(r.types.map(n=>[n.discriminantValue.wireValue,this.convertDiscriminatedUnionType({inheritedProperties:i,discriminantValue:n.discriminantValue,singleUnionTypeProperties:n.shape})]))})}convertDiscriminatedUnionType({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperties:i}){switch(i.propertiesType){case"samePropertiesAsObject":return this.convertDiscriminatedUnionTypeObject({inheritedProperties:t,discriminantValue:r,declaredTypeName:i});case"singleProperty":return this.convertDiscriminatedUnionTypeSingleProperty({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperty:i});case"noProperties":return this.convertDiscriminatedUnionTypeNoProperties({inheritedProperties:t,discriminantValue:r});default:de(i)}}convertDiscriminatedUnionTypeObject({inheritedProperties:t,discriminantValue:r,declaredTypeName:i}){return er.SingleDiscriminatedUnionType.samePropertiesAsObject({typeId:i.typeId,discriminantValue:r,properties:this.convertBodyPropertiesToParameters({properties:t})})}convertDiscriminatedUnionTypeSingleProperty({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperty:i}){return er.SingleDiscriminatedUnionType.singleProperty({typeReference:this.convertTypeReference(i.type),discriminantValue:r,properties:t.length>0?this.convertBodyPropertiesToParameters({properties:t}):void 0})}convertDiscriminatedUnionTypeNoProperties({inheritedProperties:t,discriminantValue:r}){return er.SingleDiscriminatedUnionType.noProperties({discriminantValue:r,properties:t.length>0?this.convertBodyPropertiesToParameters({properties:t}):void 0})}convertUndiscriminatedUnion({declaration:t,union:r}){return er.NamedType.undiscriminatedUnion({declaration:t,types:r.members.map(i=>this.convertTypeReference(i.type))})}convertLiteral(t){switch(t.type){case"boolean":return er.LiteralType.boolean(t.boolean);case"string":return er.LiteralType.string(t.string);default:de(t)}}convertPrimitiveType(t){return er.TypeReference.primitive(t.v1)}convertUnknownType(){return er.TypeReference.unknown()}convertAuth(t){if(t.schemes[0]==null)return;let r=t.schemes[0];switch(r.type){case"basic":return er.Auth.basic(r);case"bearer":return er.Auth.bearer(r);case"header":return er.Auth.header({header:{name:r.name,typeReference:this.convertTypeReference(r.valueType),propertyAccess:void 0,variable:void 0}});case"oauth":return er.Auth.oauth({clientId:this.casingsGenerator.generateName("clientId"),clientSecret:this.casingsGenerator.generateName("clientSecret")});case"inferred":return er.Auth.inferred({parameters:this.getInferredAuthParameters(r)});default:de(r)}}getAuthValues(t){let r=t.schemes[0];if(r!=null)switch(r.type){case"bearer":return er.AuthValues.bearer({token:"<token>"});case"basic":return er.AuthValues.basic({username:"<username>",password:"<password>"});case"header":return er.AuthValues.header({value:"<value>"});case"oauth":return er.AuthValues.oauth({clientId:"<clientId>",clientSecret:"<clientSecret>"});case"inferred":return er.AuthValues.inferred({values:this.getInferredAuthValues(r)});default:de(r)}}getInferredAuthParameters(t){let r=[],i=Object.values(this.ir.services).flatMap(n=>n.endpoints).find(n=>n.id===t.tokenEndpoint.endpoint.endpointId);if(i==null)return r;for(let n of i.headers)(n.valueType.type!=="container"||n.valueType.container.type!=="literal")&&r.push({name:{name:n.name.name,wireValue:n.name.wireValue},typeReference:this.convertTypeReference(n.valueType),propertyAccess:void 0,variable:void 0});if(i.requestBody!=null){let n=this.getRequestBodyProperties(i.requestBody);for(let a of n)(a.valueType.type!=="container"||a.valueType.container.type!=="literal")&&r.push({name:{name:a.name.name,wireValue:a.name.wireValue},typeReference:this.convertTypeReference(a.valueType),propertyAccess:void 0,variable:void 0})}return r}getInferredAuthValues(t){let r={},i=Object.values(this.ir.services).flatMap(n=>n.endpoints).find(n=>n.id===t.tokenEndpoint.endpoint.endpointId);if(i==null)return r;for(let n of i.headers)(n.valueType.type!=="container"||n.valueType.container.type!=="literal")&&(r[n.name.wireValue]=n.name.wireValue);if(i.requestBody!=null){let n=this.getRequestBodyProperties(i.requestBody);for(let a of n)(a.valueType.type!=="container"||a.valueType.container.type!=="literal")&&(r[a.name.wireValue]=a.name.wireValue)}return r}getRequestBodyProperties(t){let r=[];if(t.type==="inlinedRequestBody")r.push(...t.properties);else if(t.type==="reference"){let i=t.requestBodyType;if(i.type==="named"){let n=this.ir.types[i.typeId];n!=null&&n.shape.type==="object"&&r.push(...n.shape.properties)}}return r}convertDeclaration({name:t,fernFilepath:r}){return{name:t,fernFilepath:r}}convertEndpointLocation({endpoint:t}){return{method:t.method,path:this.getFullPathForEndpoint(t)}}getAllHttpEndpoints(){return Object.values(this.ir.services).flatMap(t=>t.endpoints.map(r=>({...r,servicePathParameters:t.pathParameters,serviceHeaders:t.headers,fernFilepath:t.name.fernFilepath})))}resolveProperties(t){let r=[];for(let i of t){let n=this.resolveObjectTypeOrThrow(i.typeId);r.push(...this.resolveProperties(n.extends)),r.push(...n.properties)}return Object.values(r)}resolveObjectTypeOrThrow(t){let r=this.ir.types[t];if(r==null)throw new Error(`Internal error; type "${t}" not found`);if(r.shape.type!=="object")throw new Error(`Internal error; type "${t}" is not an object`);return r.shape}getFullPathForEndpoint(t){let r="";t.fullPath.head.length>0&&(r=(0,DAu.default)(r,t.fullPath.head));for(let i of t.fullPath.parts)r=(0,DAu.default)(r,"{"+i.pathParameter+"}"),i.tail.length>0&&(r=(0,DAu.default)(r,i.tail));return r.startsWith("/")?r:`/${r}`}getEndpointSnippetRequests({endpoint:t,location:r}){let i=[];for(let n of[...t.userSpecifiedExamples,...t.autogeneratedExamples]){let a=new Set;[...this.ir.pathParameters,...t.pathParameters].forEach(c=>{c.variable!=null&&a.add(c.name.originalName)});let o=[...n.example?.rootPathParameters??[],...n.example?.servicePathParameters??[],...n.example?.endpointPathParameters??[]].filter(c=>!a.has(c.name.originalName));i.push({id:n?.example?.id??Xme(),name:n?.example?.name?.originalName,endpoint:r,baseUrl:void 0,environment:void 0,auth:this.authValues,headers:Object.fromEntries([...n.example?.serviceHeaders??[],...n.example?.endpointHeaders??[]].map(c=>[c.name.wireValue,c.value.jsonExample])),pathParameters:Object.fromEntries(o.map(c=>[c.name.originalName,c.value.jsonExample])),queryParameters:Object.fromEntries([...n.example?.queryParameters??[]].map(c=>[c.name.wireValue,c.value.jsonExample])),requestBody:n.example?.request?.jsonExample})}return i}};function rjn({ir:e,generationLanguage:t,smartCasing:r,disableExamples:i,generatorConfig:n}){return new BAu({ir:e,generationLanguage:t,smartCasing:r,generatorConfig:n}).convert({disableExamples:i})}var L5={};$t(L5,{validateObjectExample:()=>ejn,validateTypeExample:()=>mAu,validateTypeReferenceExample:()=>dU});function UOh(e){return{errorInstanceIdKey:e.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}}var IAu=e=>{let t=Qme(e.file.fernFilepath),r=e.endpointId;return`endpoint_${t}.${r}`};function CAu({fernFilePath:e}){return e.packagePath.length===0&&e.file==null}function qAu({resolvedEndpoint:e}){return{endpointId:IAu(e),serviceId:M_.generateServiceIdFromFernFilepath(e.file.fernFilepath),subpackageId:CAu({fernFilePath:e.file.fernFilepath})?void 0:M_.generateSubpackageId(e.file.fernFilepath)}}function LOh({endpointResolver:e,propertyResolver:t,file:r,refreshTokenEndpoint:i}){let n=e.resolveEndpointOrThrow({endpoint:i.endpoint,file:r}),a;try{a=i.responseProperties.expires_in!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.expires_in}):void 0}catch{}return{endpointReference:{endpointId:IAu(n),serviceId:M_.generateServiceIdFromFernFilepath(n.file.fernFilepath),subpackageId:CAu({fernFilePath:n.file.fernFilepath})?void 0:M_.generateSubpackageId(n.file.fernFilepath)},requestProperties:{refreshToken:t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.refresh_token})},responseProperties:{accessToken:t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.access_token}),expiresIn:a,refreshToken:i.responseProperties.refresh_token!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.refresh_token}):void 0}}}function VOh({endpointResolver:e,propertyResolver:t,file:r,tokenEndpoint:i}){let n=e.resolveEndpointOrThrow({endpoint:i.endpoint,file:r}),a=typeof n.endpoint.request=="object"&&n.endpoint.request.body!=null&&typeof n.endpoint.request.body=="object"&&"properties"in n.endpoint.request.body?n.endpoint.request.body.properties??{}:{},o;try{o=i.responseProperties.expires_in!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.expires_in}):void 0}catch{}return{endpointReference:qAu({resolvedEndpoint:n}),requestProperties:{clientId:t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.client_id}),clientSecret:t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.client_secret}),scopes:i.requestProperties.scopes!=null?t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.scopes}):void 0,customProperties:glB({requestBodyProperties:a,tokenEndpoint:i,file:r,propertyResolver:t})},responseProperties:{accessToken:t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.access_token}),expiresIn:o,refreshToken:i.responseProperties.refresh_token!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.refresh_token}):void 0}}}var glB=({requestBodyProperties:e,tokenEndpoint:t,file:r,propertyResolver:i})=>{let n=Object.keys(e).filter(a=>!t.requestProperties.client_id.includes(a)&&!t.requestProperties.client_secret.includes(a)&&(t.requestProperties.scopes==null||!t.requestProperties.scopes.includes(a)));return n.length>0?n.map(a=>i.resolveRequestPropertyOrThrow({file:r,endpoint:t.endpoint,propertyComponents:[a]})):void 0};function WOh({propertyResolver:e,endpointResolver:t,file:r,oauthScheme:i,tokenEndpoint:n,refreshTokenEndpoint:a}){let o=VOh({propertyResolver:e,endpointResolver:t,file:r,tokenEndpoint:n});if(o==null)throw new Error("Failed to convert OAuth token endpoint.");let c=a!=null?LOh({propertyResolver:e,endpointResolver:t,file:r,refreshTokenEndpoint:a}):void 0;return{clientIdEnvVar:i["client-id-env"],clientSecretEnvVar:i["client-secret-env"],tokenPrefix:i["token-prefix"],tokenHeader:i["token-header"],scopes:i.scopes,tokenEndpoint:o,refreshEndpoint:c}}var aro={requestProperties:{type:"access_token",client_id:["client_id"],client_secret:["client_secret"],scopes:void 0},responseProperties:{type:"access_token",access_token:["access_token"],expires_in:["expires_in"],refresh_token:void 0}},c2c={requestProperties:{type:"refresh_token",refresh_token:["refresh_token"]},responseProperties:{type:"access_token",access_token:["access_token"],refresh_token:void 0,expires_in:["expires_in"]}};function xOh(e){return{endpoint:e["get-token"].endpoint,requestProperties:OlB({requestProperties:e["get-token"]?.["request-properties"]}),responseProperties:mlB({responseProperties:e["get-token"]?.["response-properties"]})}}function GOh(e){if(e["refresh-token"]!=null)return{endpoint:e["refresh-token"].endpoint,requestProperties:AlB({requestProperties:e["refresh-token"]?.["request-properties"]}),responseProperties:PlB({responseProperties:e["refresh-token"]?.["response-properties"]})}}function OlB({requestProperties:e}){if(e==null)return aro.requestProperties;let t=e["client-id"],r=e["client-secret"],i=e.scopes;return{type:"access_token",client_id:t!=null?q5t(t):aro.requestProperties.client_id,client_secret:r!=null?q5t(r):aro.requestProperties.client_secret,scopes:i!=null?q5t(i):aro.requestProperties.scopes}}function mlB({responseProperties:e}){return HOh({responseProperties:e,defaultValue:aro.responseProperties})}function AlB({requestProperties:e}){if(e==null)return c2c.requestProperties;let t=e["refresh-token"];return{type:"refresh_token",refresh_token:t!=null?q5t(t):c2c.requestProperties.refresh_token}}function PlB({responseProperties:e}){return HOh({responseProperties:e,defaultValue:c2c.responseProperties})}function HOh({responseProperties:e,defaultValue:t}){if(e==null)return t;let r=e["access-token"],i=e["expires-in"],n=e["refresh-token"];return{type:"access_token",access_token:r!=null?Lme(r):t.access_token,expires_in:i!=null?Lme(i):t.expires_in,refresh_token:n!=null?Lme(n):t.refresh_token}}function YOh({rawApiFileSchema:e,file:t,propertyResolver:r,endpointResolver:i}){if(e.auth==null)return{docs:void 0,requirement:vN.All,schemes:[]};let n=typeof e.auth!="string"?e.auth.docs:void 0;return WAn(e.auth,{single:a=>{let o=l2c({reference:a,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i});return{docs:n,requirement:vN.All,schemes:[o]}},any:({any:a})=>({docs:n,requirement:vN.Any,schemes:a.map(o=>l2c({reference:o,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i}))}),endpointSecurity:()=>({docs:n,requirement:vN.EndpointSecurity,schemes:Object.keys(e["auth-schemes"]??{}).map(a=>l2c({reference:a,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i}))})})}function l2c({reference:e,authSchemeDeclarations:t,file:r,propertyResolver:i,endpointResolver:n}){let a=(c,d)=>{let s=t?.[c];if(s==null)throw new Error("Unknown auth scheme: "+c);return Hka(s,{header:u=>mP.header({key:c,docs:d,name:r.casingsGenerator.generateNameAndWireValue({name:u.name??c,wireValue:u.header}),valueType:r.parseTypeReference(u.type??"string"),prefix:u.prefix,headerEnvVar:u.env}),basic:u=>$Oh({key:c,file:r,docs:d,rawScheme:u}),tokenBearer:u=>KOh({key:c,file:r,docs:d,rawScheme:u}),inferredBearer:u=>jlB({key:c,file:r,docs:d,rawScheme:u,propertyResolver:i,endpointResolver:n}),oauth:u=>JOh({key:c,file:r,docs:d,rawScheme:u,propertyResolver:i,endpointResolver:n})})},o=typeof e=="string"?e:e.scheme;switch(o){case"bearer":return KOh({key:o,file:r,docs:void 0,rawScheme:void 0});case"basic":return $Oh({key:o,file:r,docs:void 0,rawScheme:void 0});case"oauth":return JOh({key:o,file:r,docs:void 0,rawScheme:void 0,propertyResolver:i,endpointResolver:n});default:return a(o,typeof e!="string"?e.docs:void 0)}}function KOh({key:e,file:t,docs:r,rawScheme:i}){return mP.bearer({key:e,docs:r,token:t.casingsGenerator.generateName(i?.token?.name??"token"),tokenEnvVar:i?.token?.env})}function $Oh({key:e,file:t,docs:r,rawScheme:i}){return mP.basic({key:e,docs:r,username:t.casingsGenerator.generateName(i?.username?.name??"username"),usernameEnvVar:i?.username?.env,usernameOmit:i?.username?.omit,password:t.casingsGenerator.generateName(i?.password?.name??"password"),passwordEnvVar:i?.password?.env,passwordOmit:i?.password?.omit})}function JOh({key:e,file:t,docs:r,rawScheme:i,propertyResolver:n,endpointResolver:a}){if(i?.type==="client-credentials")return mP.oauth({key:e,docs:r,configuration:$Zi.clientCredentials(WOh({propertyResolver:n,endpointResolver:a,file:t,oauthScheme:i,tokenEndpoint:xOh(i),refreshTokenEndpoint:GOh(i)}))});throw new Error(`Unknown OAuth type: '${i?.type}'`)}function jlB({key:e,file:t,docs:r,rawScheme:i,propertyResolver:n,endpointResolver:a}){return mP.inferred({key:e,docs:r,tokenEndpoint:wlB({file:t,rawScheme:i,propertyResolver:n,endpointResolver:a})})}function wlB({file:e,rawScheme:t,propertyResolver:r,endpointResolver:i}){let n=t["get-token"],a=typeof n=="string"?{endpoint:n}:n,o=i.resolveEndpointOrThrow({endpoint:a.endpoint,file:e});return{endpoint:qAu({resolvedEndpoint:o}),expiryProperty:BlB({tokenEndpoint:o,getTokenEndpointConfig:a,propertyResolver:r}),authenticatedRequestHeaders:SlB({tokenEndpoint:o,getTokenEndpointConfig:a,propertyResolver:r})}}var ElB=["access_token","accessToken","AccessToken","token","Token","auth_token","authToken","AuthToken","bearer_token","bearerToken","BearerToken","jwt","Jwt","authentication_token","authenticationToken","AuthenticationToken"];function SlB({tokenEndpoint:e,getTokenEndpointConfig:t,propertyResolver:r}){let i=new Map,n=t["authenticated-request-headers"]??[];if(n.length>0&&n.forEach(a=>{i.set(a["header-name"].toLowerCase(),{headerName:a["header-name"],responseProperty:r.resolveResponsePropertyOrThrow({file:e.file,endpoint:e.endpointId,propertyComponents:Lme(a["response-property"])}),valuePrefix:a["value-prefix"]})}),!i.has("authorization")){let a=MlB({tokenEndpoint:e,propertyResolver:r});a&&i.set("authorization",{headerName:"Authorization",responseProperty:a,valuePrefix:"Bearer "})}return Array.from(i.values())}function MlB({tokenEndpoint:e,propertyResolver:t}){for(let r of ElB)try{let i=t.resolveResponseProperty({file:e.file,endpoint:e.endpointId,propertyComponents:[r]});if(i)return i}catch{}}var DlB=["expires_in","expiresIn","ExpiresIn","exp","Exp","expiry","Expiry","expires","Expires","expires_at","expiresAt","ExpiresAt","expiration","Expiration","valid_until","validUntil","ValidUntil"];function BlB({tokenEndpoint:e,getTokenEndpointConfig:t,propertyResolver:r}){if(t["expiry-response-property"])return r.resolveResponsePropertyOrThrow({file:e.file,endpoint:e.endpointId,propertyComponents:Lme(t["expiry-response-property"])});for(let i of DlB)try{let n=r.resolveResponseProperty({file:e.file,endpoint:e.endpointId,propertyComponents:[i]});if(n)return n}catch{}}function XOh({file:e,rawApiFileSchema:t}){if(t.version!=null)return XZi.header({header:IlB({file:e,header:t.version.header}),value:ClB({file:e,versionDeclaration:t.version})})}function IlB({file:e,header:t}){return typeof t=="string"?rBe({file:e,headerKey:t,header:{type:"string"}}):rBe({file:e,headerKey:t.value,header:{type:"string",name:t.name,env:t.env}})}function ClB({file:e,versionDeclaration:t}){return AAu({_enum:{default:t.default,enum:t.values},file:e})}function ZOh({channel:e,typeResolver:t,exampleResolver:r,variableResolver:i,file:n,workspace:a}){let o=[];for(let[c,d]of Object.entries(e.messages??{}))o.push({type:c,availability:CZ(d.availability),docs:d.docs,origin:d.origin,body:RlB({body:d.body,file:n}),displayName:d["display-name"],methodName:d["method-name"]});return{availability:CZ(e.availability),path:HD(e.path),baseUrl:e.url,auth:e.auth,name:n.fernFilepath.file??n.casingsGenerator.generateName(e["display-name"]??e.path),displayName:e["display-name"],headers:e.headers!=null?Object.entries(e.headers).map(([c,d])=>rBe({headerKey:c,header:d,file:n})):[],docs:e.docs,pathParameters:e["path-parameters"]!=null?y_a({pathParameters:e["path-parameters"],location:BDe.Endpoint,file:n,variableResolver:i}):[],queryParameters:e["query-parameters"]!=null?Object.entries(e["query-parameters"]).map(([c,d])=>{let{name:s}=zWi({queryParameterKey:c,queryParameter:d}),u=n.parseTypeReference(d);return{...w5(d),name:n.casingsGenerator.generateNameAndWireValue({wireValue:c,name:s}),valueType:u,allowMultiple:typeof d!="string"&&d["allow-multiple"]!=null?d["allow-multiple"]:!1,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}},explode:void 0}}):[],messages:Object.values(o),examples:(e.examples??[]).map(c=>{let d=NlB({channel:e,example:c,typeResolver:t,exampleResolver:r,variableResolver:i,file:n,workspace:a});return{name:c.name!=null?n.casingsGenerator.generateName(c.name):void 0,docs:c.docs,url:QlB({channel:e,example:c,pathParams:d}),...d,...FlB({channel:e,example:c,typeResolver:t,exampleResolver:r,file:n,workspace:a}),queryParameters:c["query-parameters"]!=null?Object.entries(c["query-parameters"]).map(([s,u])=>{let f=e["query-parameters"]?.[s];if(f==null)throw new Error(`Query parameter ${s} does not exist`);return{name:n.casingsGenerator.generateNameAndWireValue({name:zWi({queryParameterKey:s,queryParameter:f}).name,wireValue:s}),value:mO({example:u,rawTypeBeingExemplified:typeof f=="string"?f:f.type,typeResolver:t,exampleResolver:r,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),shape:qlB({queryParameter:f})}}):[],messages:c.messages.map(s=>{let u=e.messages?.[s.type];if(u==null)throw new Error(`Message ${s.type} does not exist`);return{type:s.type,body:TlB({message:u,example:s.body,typeResolver:t,exampleResolver:r,file:n,workspace:a})}})}}),v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}function qlB({queryParameter:e}){return(typeof e!="string"&&e["allow-multiple"]!=null?e["allow-multiple"]:!1)?gN.exploded():gN.single()}function TlB({message:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){if(!UlB(e.body))return zme.reference(mO({example:t,rawTypeBeingExemplified:typeof e.body!="string"?e.body.type:e.body,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}));if(!Wl(t))throw new Error("Example must be an object");let o=[];for(let[c,d]of Object.entries(t)){let s=e.body.properties?.[c];if(s!=null)o.push({name:n.casingsGenerator.generateNameAndWireValue({name:fU({propertyKey:c,property:s}).name,wireValue:c}),value:mO({example:d,rawTypeBeingExemplified:typeof s!="string"?s.type:s,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),originalTypeDeclaration:void 0});else{let u=iro({extends_:e.body.extends,wirePropertyKey:c,typeResolver:r,file:n});if(u==null)throw new Error("Could not find original type declaration for property: "+c);o.push({name:n.casingsGenerator.generateNameAndWireValue({name:fU({propertyKey:c,property:u.rawPropertyType}).name,wireValue:c}),value:mO({example:d,rawTypeBeingExemplified:typeof u.rawPropertyType=="string"?u.rawPropertyType:u.rawPropertyType.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:u.file,fileContainingExample:n,workspace:a}),originalTypeDeclaration:u.typeName})}}return zme.inlinedBody({jsonExample:i.resolveAllReferencesInExampleOrThrow({example:t,file:n}).resolvedExample,properties:o,extraProperties:void 0})}function RlB({body:e,file:t}){return typeof e=="string"||zlB(e)?E3.reference({docs:void 0,bodyType:t.parseTypeReference(e)}):E3.inlinedBody({name:t.casingsGenerator.generateName(e.name),extends:C5t(e.extends??[]).map(r=>lU({typeName:r,file:t})),properties:Object.entries(e.properties??{}).map(([r,i])=>({name:t.casingsGenerator.generateNameAndWireValue({name:fU({propertyKey:r,property:i}).name,wireValue:r}),value:t.parseTypeReference(i),valueType:t.parseTypeReference(i),availability:void 0,docs:void 0}))})}function zlB(e){return e.type!=null}function NlB({channel:e,example:t,typeResolver:r,exampleResolver:i,variableResolver:n,file:a,workspace:o}){let c=[],d=({name:s,pathParameterDeclaration:u,examplePathParameter:f})=>{let p=nro({parameter:u,variableResolver:n,file:a});return{name:s,value:mO({example:f,rawTypeBeingExemplified:p.rawType,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:p.file,fileContainingExample:a,workspace:o})}};if(t["path-parameters"]!=null){let s=T5t(e);for(let[u,f]of Object.entries(t["path-parameters"])){let p=s[u];if(p!=null)c.push(d({name:a.casingsGenerator.generateName(u),pathParameterDeclaration:p,examplePathParameter:f}));else throw new Error(`Path parameter ${u} does not exist`)}}return{pathParameters:c}}function FlB({channel:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let o=[];if(t.headers!=null)for(let[c,d]of Object.entries(t.headers)){let s=e.headers?.[c];s!=null&&o.push({name:n.casingsGenerator.generateNameAndWireValue({name:jkt({headerKey:c,header:s}).name,wireValue:c}),value:mO({example:d,rawTypeBeingExemplified:typeof s=="string"?s:s.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a})})}return{headers:o}}function QlB({channel:e,example:t,pathParams:r}){let i=e.path;if(t["path-parameters"]!=null)for(let n of[...r.pathParameters])i=i.replaceAll(`{${n.name.originalName}}`,encodeURIComponent(`${n.value.jsonExample}`));return i}function UlB(e){return typeof e=="string"?!1:e.extends!=null||e.properties!=null}function kOh({errorName:e,errorDeclaration:t,file:r,typeResolver:i,exampleResolver:n,workspace:a}){let o=[];if(t.type!=null&&t.examples!=null)for(let c of t.examples)o.push({name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,docs:c.docs,jsonExample:n.resolveAllReferencesInExampleOrThrow({example:c.value,file:r}).resolvedExample,shape:mO({example:c.value,rawTypeBeingExemplified:t.type,fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})});return{name:b2i({errorName:e,file:r}),discriminantValue:r.casingsGenerator.generateNameAndWireValue({wireValue:e,name:e}),docs:typeof t!="string"?t.docs:void 0,statusCode:t["status-code"],isWildcardStatusCode:void 0,type:t.type!=null?r.parseTypeReference(t.type):void 0,examples:o,v2Examples:void 0,displayName:void 0,headers:[]}}var emh="content";function tmh(e,t){if(e==null||e.strategy==="status-code")return Rme.statusCode();if(e.strategy==="property")return Rme.property({discriminant:t.casingsGenerator.generateNameAndWireValue({name:e["property-name"],wireValue:e["property-name"]}),contentProperty:t.casingsGenerator.generateNameAndWireValue({name:emh,wireValue:emh})});de(e)}var TAu=se(bO(),1);function rmh({readme:e,services:t}){let r=new f2c(t);return{apiName:e.apiName,disabledFeatures:e.disabledSections?.map(i=>i.toUpperCase()),apiReferenceLink:e.apiReferenceLink,bannerLink:e.bannerLink,introduction:e.introduction,customSections:e.customSections,exampleStyle:e.exampleStyle,whiteLabel:!1,defaultEndpoint:e.defaultEndpoint!=null?r.getEndpointForReadmeOrThrow(e.defaultEndpoint).id:void 0,features:e.features!=null?Object.fromEntries(Object.entries(e.features).map(([i,n])=>[i,n.map(a=>r.getEndpointForReadmeOrThrow(a).id)])):void 0}}var f2c=class{endpoints={};constructor(t){this.endpoints=this.buildEndpoints(t)}getEndpointForReadme(t){let r=VlB({endpoint:t}),i=this.getEndpointKeyForReadmeEndpoint(r);return this.endpoints[i]}getEndpointForReadmeOrThrow(t){let r=this.getEndpointForReadme(t);if(r==null)throw new Error(`Endpoint not found for ${JSON.stringify(t)}`);return r}buildEndpoints(t){let r={};for(let i of Object.values(t))for(let n of i.endpoints)r[this.getEndpointKeyForHttpEndpoint(n)]=n;return r}getEndpointKeyForReadmeEndpoint(t){return this.getEndpointKey({method:t.method,path:t.path,stream:t.stream??!1})}getEndpointKeyForHttpEndpoint(t){return this.getEndpointKey({method:t.method,path:LlB(t),stream:t.response?.body?.type==="streaming"})}getEndpointKey({method:t,path:r,stream:i}){return`${t}|${r}|${i}`}};function LlB(e){let t="";e.fullPath.head.length>0&&(t=(0,TAu.default)(t,e.fullPath.head));for(let r of e.fullPath.parts)t=(0,TAu.default)(t,"{"+r.pathParameter+"}"),r.tail.length>0&&(t=(0,TAu.default)(t,r.tail));return t.startsWith("/")?t:`/${t}`}function VlB({endpoint:e}){if(typeof e=="string"){let t=e.split(" ");if(t.length!==2||t[0]==null||t[1]==null)throw new Error(`invalid endpoint string: ${e}`);return{method:t[0],path:t[1]}}return e}function imh({webhooks:e,file:t,typeResolver:r,exampleResolver:i,workspace:n}){let a=[];for(let[o,c]of Object.entries(e))a.push({id:M_.generateWebhookId(t.fernFilepath,o),availability:CZ(c.availability),displayName:c["display-name"],docs:c.docs,method:c.method,name:t.casingsGenerator.generateName(o),headers:c.headers!=null?Object.entries(c.headers).map(([d,s])=>rBe({headerKey:d,header:s,file:t})):[],payload:WlB({payload:c.payload,file:t}),fileUploadPayload:void 0,responses:HlB({webhook:c,file:t,typeResolver:r}),examples:c.examples!=null?GlB({webhook:c,examples:c.examples,file:t,typeResolver:r,exampleResolver:i,workspace:n}):void 0,v2Examples:void 0});return a}function WlB({payload:e,file:t}){return typeof e=="string"?nU.reference({docs:void 0,payloadType:t.parseTypeReference(e)}):rda(e)?nU.reference({docs:void 0,payloadType:t.parseTypeReference(e.type)}):nU.inlinedPayload({name:t.casingsGenerator.generateName(e.name),extends:C5t(e.extends).map(r=>lU({typeName:r,file:t})),properties:e.properties!=null?Object.entries(e.properties).map(([r,i])=>xlB({propertyKey:r,propertyDefinition:i,docs:typeof i!="string"?i.docs:void 0,availability:typeof i!="string"?CZ(i.availability):void 0,file:t})):[]})}function xlB({propertyKey:e,propertyDefinition:t,docs:r,availability:i,file:n}){return{docs:r,availability:i,name:n.casingsGenerator.generateNameAndWireValue({wireValue:e,name:fU({propertyKey:e,property:t}).name}),valueType:n.parseTypeReference(t)}}function GlB({webhook:e,examples:t,file:r,typeResolver:i,exampleResolver:n,workspace:a}){let o=typeof e.payload=="string"?e.payload:rda(e.payload)?e.payload.type:void 0;if(o!=null)return t.map(c=>({docs:e.docs,name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,payload:mO({example:c.payload,rawTypeBeingExemplified:o,fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})}));if(!Wl(e.payload))throw new Error(`Example webhook payload is not an object. Got: ${JSON.stringify(e.payload)}`);return t.map(c=>({docs:e.docs,name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,payload:mO({example:c.payload,rawTypeBeingExemplified:"map<string, unknown>",fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})}))}function HlB({webhook:e,file:t,typeResolver:r}){let i=[];if(e.response!=null){let n=KlB({response:e.response,file:t,typeResolver:r}),a=typeof e.response!="string"?e.response["status-code"]:void 0,o=typeof e.response!="string"?e.response.docs:void 0;i.push({body:n,statusCode:a,isWildcardStatusCode:void 0,docs:o})}if(e["response-stream"]!=null){let n=$lB({responseStream:e["response-stream"],file:t,typeResolver:r});if(n!=null){let a=typeof e["response-stream"]!="string"?e["response-stream"].docs:void 0;i.push({body:op.streaming(n),statusCode:void 0,isWildcardStatusCode:void 0,docs:a})}}return i.length>0?i:void 0}function KlB({response:e,file:t,typeResolver:r}){let i=typeof e!="string"?e.docs:void 0,n=typeof e=="string"?e:e.type;if(n!=null)return BZ(n)!=null?op.fileDownload({docs:i,v2Examples:void 0}):LAn(n)!=null?op.text({docs:i,v2Examples:void 0}):FDe(n)!=null?op.bytes({docs:i,v2Examples:void 0}):JlB(e,i,t,r)}function $lB({responseStream:e,file:t,typeResolver:r}){let i=typeof e!="string"?e.docs:void 0,n=typeof e=="string"?e:e.type,a=typeof e=="string"?"json":e.format??"json";return KZi(n)?qC.text({docs:i,v2Examples:void 0}):typeof e!="string"&&a==="sse"?qC.sse({docs:i,payload:t.parseTypeReference(n),terminator:typeof e!="string"?e.terminator:void 0,v2Examples:void 0}):qC.json({docs:i,payload:t.parseTypeReference(n),terminator:typeof e!="string"?e.terminator:void 0,v2Examples:void 0})}function JlB(e,t,r,i){let n=typeof e!="string"?e.type:e;if(n==null)return;let a=r.parseTypeReference(typeof e=="string"?e:{...e,type:n}),o=i.resolveTypeOrThrow({type:n,file:r}),c=typeof e!="string"?e.property:void 0;return c!=null?op.json(Nq.nestedPropertyAsResponse({docs:t,responseBodyType:a,responseProperty:JAn({typeResolver:i,file:r,resolvedType:o,property:c}),v2Examples:void 0})):op.json(Nq.response({docs:t,responseBodyType:a,v2Examples:void 0}))}function nmh({name:e,source:t}){return rb.userDefined({file:jAu({source:t}),name:tro.generateName(e)})}function amh({encoding:e}){if(e.proto!=null&&e.proto.type!=null){let t=YlB({type:e.proto.type});if(t!=null)return t}}function YlB({type:e}){switch(e){case"google.protobuf.Any":return rb.wellKnown(In.any());case"google.protobuf.Api":return rb.wellKnown(In.api());case"google.protobuf.BoolValue":return rb.wellKnown(In.boolValue());case"google.protobuf.BytesValue":return rb.wellKnown(In.bytesValue());case"google.protobuf.DoubleValue":return rb.wellKnown(In.doubleValue());case"google.protobuf.Duration":return rb.wellKnown(In.duration());case"google.protobuf.Empty":return rb.wellKnown(In.empty());case"google.protobuf.Enum":return rb.wellKnown(In.enum());case"google.protobuf.EnumValue":return rb.wellKnown(In.enumValue());case"google.protobuf.Field":return rb.wellKnown(In.field());case"google.protobuf.FieldCardinality":return rb.wellKnown(In.fieldCardinality());case"google.protobuf.FieldKind":return rb.wellKnown(In.fieldKind());case"google.protobuf.FieldMask":return rb.wellKnown(In.fieldMask());case"google.protobuf.FloatVlaue":return rb.wellKnown(In.floatValue());case"google.protobuf.Int32Value":return rb.wellKnown(In.int32Value());case"google.protobuf.Int64Value":return rb.wellKnown(In.int64Value());case"google.protobuf.ListValue":return rb.wellKnown(In.listValue());case"google.protobuf.Method":return rb.wellKnown(In.method());case"google.protobuf.Mixin":return rb.wellKnown(In.mixin());case"google.protobuf.NullValue":return rb.wellKnown(In.nullValue());case"google.protobuf.Option":return rb.wellKnown(In.option());case"google.protobuf.SourceContext":return rb.wellKnown(In.sourceContext());case"google.protobuf.StringValue":return rb.wellKnown(In.stringValue());case"google.protobuf.Struct":return rb.wellKnown(In.struct());case"google.protobuf.Syntax":return rb.wellKnown(In.syntax());case"google.protobuf.Timestamp":return rb.wellKnown(In.timestamp());case"google.protobuf.Type":return rb.wellKnown(In.type());case"google.protobuf.Uint32Value":return rb.wellKnown(In.uint32Value());case"google.protobuf.Uint64Value":return rb.wellKnown(In.uint64Value());case"google.protobuf.Value":return rb.wellKnown(In.value())}}function omh({generic:e,file:t,typeResolver:r}){let i=typeof e=="string"?e:e.type,n=HB(i);if(n==null)throw new Error(`Invalid generic type definition: ${i}`);let a=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:i,file:t});if(n.arguments&&Gv(a.declaration)){let o=HB(a.typeName)?.arguments??[],c=Object.entries(a.declaration.properties??{}).map(([d,s])=>{let u=s;return typeof s=="string"&&o?.includes(s)&&(u=n.arguments?.[o.indexOf(s)]??s),[d,u]});return Jl.object({extends:C5t(a.declaration.extends).map(d=>lU({typeName:d,file:t})),properties:Zka({properties:Object.fromEntries(c)},t),extraProperties:a.declaration["extra-properties"]??!1,extendedProperties:void 0})}throw new Error(`Generic type definition not supported: ${i}`)}function umh({alias:e,file:t,typeResolver:r}){let i=typeof e=="string"?e:e.type;return MDe(i)?omh({generic:i,file:t,typeResolver:r}):Jl.alias({aliasOf:t.parseTypeReference(e),resolvedType:XlB({aliasOf:i,file:t,typeResolver:r})})}function XlB({aliasOf:e,file:t,typeResolver:r}){let i=r.resolveTypeOrThrow({type:e,file:t});switch(i._type){case"primitive":return w3.primitive(i.originalTypeReference.primitive);case"container":return w3.container(i.originalTypeReference.container);case"unknown":return w3.unknown();case"named":{let n=Gv(i.declaration)?M5t.Object:p2i(i.declaration)?M5t.Union:I5t(i.declaration)?M5t.Enum:Xfa(i.declaration)?M5t.UndiscriminatedUnion:de(i.declaration);return w3.named({name:i.name,shape:n})}}}function smh({union:e,file:t}){let r=e.union.filter((i,n)=>{let a=typeof i=="string"?i:i.type;return e.union.findIndex(o=>(typeof o=="string"?o:o.type)===a)===n});return Jl.undiscriminatedUnion({members:r.map(i=>{let n=t.parseTypeReference(typeof i=="string"?i:i.type);return{type:n.type==="named"?{...n,displayName:typeof i=="string"?G6o(n.name.originalName):i["display-name"]??G6o(n.name.originalName)}:n,docs:typeof i=="string"?void 0:i.docs}})})}function cmh(e){let t=[];if(e.extends!=null){let r=typeof e.extends=="string"?[e.extends]:e.extends;t.push(...r)}return e.properties!=null&&t.push(...Object.values(e.properties).map(r=>typeof r=="string"?r:r.type)),t}function p2c({typeDeclaration:e,file:t,typeResolver:r,seenTypeNames:i=new d2c}){let n=Lq(e,{alias:o=>{let c=typeof o=="string"?o:o.type,d=HB(c);if(d!=null){let s=new Set(d.arguments??[]),u=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:c,file:t}),f=HB(u.typeName)?.arguments;if(Gv(u.declaration)){let p=cmh(u.declaration);f&&p.filter(_=>!f.includes(_)).forEach(_=>s.add(_))}return Array.from(s)}return[c]},object:o=>cmh(o),discriminatedUnion:o=>{let c=[];return o["base-properties"]!=null&&c.push(...Object.values(o["base-properties"]).map(d=>typeof d=="string"?d:d.type)),c.push(...Object.values(o.union).reduce((d,s)=>{let u=typeof s=="string"?s:s.type;return typeof u=="string"&&d.push(u),d},[])),c},undiscriminatedUnion:o=>Object.values(o.union).reduce((c,d)=>{let s=typeof d=="string"?d:d.type;return typeof s=="string"&&c.push(s),c},[]),enum:()=>[]}),a=[];for(let o of n){let c=Uq({type:o,_default:void 0,validation:void 0,visitor:{primitive:()=>[],map:({keyType:d,valueType:s})=>[...d,...s],list:d=>d,optional:d=>d,nullable:d=>d,set:d=>d,named:d=>[d],literal:()=>[],unknown:()=>[]}});for(let d of c){let s=lU({typeName:d,file:t});if(!i.hasTypeNameBeenSeen(s)){i.addTypeName(s),a.push(s);let u=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:d,file:t});if(MDe(u.typeName))continue;a.push(...p2c({typeDeclaration:u.declaration,file:u.file,typeResolver:r,seenTypeNames:i}))}}}return a}var d2c=class{cache=new Set;addTypeName(t){this.cache.add(this.computeCacheKey(t))}hasTypeNameBeenSeen(t){return this.cache.has(this.computeCacheKey(t))}computeCacheKey(t){return t.fernFilepath.allParts.map(r=>r.originalName).join("/")+":"+t.name.originalName}};function lmh({typeName:e,typeDeclaration:t,file:r,typeResolver:i,exampleResolver:n,sourceResolver:a,workspace:o}){let c=w5(t),d=lU({typeName:e,file:r}),s=p2c({typeDeclaration:t,file:r,typeResolver:i}),u={};Gv(t)&&(u=HAn(t.properties??{}));let f=klB({file:r,typeDeclaration:t,typeName:e,sourceResolver:a});return{propertiesByAudience:u,typeDeclaration:{...c,inline:ifB(t),name:d,shape:ZlB({typeDeclaration:t,file:r,typeResolver:i}),referencedTypes:new Set(s.map(p=>p.typeId)),encoding:efB({typeDeclaration:t,source:f}),source:f,userProvidedExamples:typeof t!="string"&&t.examples!=null?t.examples.map(p=>({name:p.name!=null?r.casingsGenerator.generateName(p.name):void 0,docs:p.docs,jsonExample:n.resolveAllReferencesInExampleOrThrow({example:p.value,file:r}).resolvedExample,shape:a2c({typeName:d,example:p.value,typeResolver:i,exampleResolver:n,typeDeclaration:t,fileContainingType:r,fileContainingExample:r,workspace:o})})):[],autogeneratedExamples:[],v2Examples:void 0},descendantFilepaths:new Set(s.map(p=>p.fernFilepath))}}function ZlB({typeDeclaration:e,file:t,typeResolver:r}){return Lq(e,{alias:i=>umh({alias:i,file:t,typeResolver:r}),object:i=>Wrh({object:i,file:t}),discriminatedUnion:i=>iOh({union:i,file:t,typeResolver:r}),undiscriminatedUnion:i=>smh({union:i,file:t}),enum:i=>Jl.enum(AAu({_enum:i,file:t}))})}function klB({file:e,typeDeclaration:t,typeName:r,sourceResolver:i}){if(typeof t=="string"||t.source==null&&t.encoding==null)return;if(t.encoding!=null){let a=amh({encoding:t.encoding});if(a!=null)return eWi.proto(a)}if(t.source==null)return;let n=i.resolveSourceOrThrow({source:t.source,relativeFilepath:e.relativeFilepath});if(!(n==null||n.type!=="protobuf"))return eWi.proto(nmh({source:n,name:r}))}function efB({typeDeclaration:e,source:t}){return typeof e!="string"&&e.encoding!=null?tfB(e.encoding):rfB(t)}function tfB(e){return e.proto!=null?{json:void 0,proto:{}}:{json:{},proto:void 0}}function rfB(e){return e!=null&&e.type==="proto"?{json:void 0,proto:{}}:{json:{},proto:void 0}}function ifB(e){if(typeof e!="string"&&"inline"in e)return e.inline}function fmh(e,t){let r=t[e];if(r==null)throw new F3i(`Illegal Error: Failed to load type declaration for type ${e}`);return r}function dmh(e){e.types=Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,afB({typeDeclaration:r,ir:e})])),e.services=Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{...r,endpoints:r.endpoints.map(i=>nfB({endpoint:i,ir:e}))}]))}function nfB({endpoint:e,ir:t}){return e.requestBody?.type!=="inlinedRequestBody"?e:{...e,requestBody:{...e.requestBody,extendedProperties:e.requestBody.extends.flatMap(r=>pmh(r,t))}}}function afB({typeDeclaration:e,ir:t}){return e.shape.type==="object"?{...e,shape:{...e.shape,extendedProperties:e.shape.extends.flatMap(r=>pmh(r,t))}}:e}function pmh(e,t){let r=_2c(e.typeId,t);return _mh({objectTypeDeclaration:r,ir:t})}function _2c(e,t){let r=fmh(e,t.types);switch(r.shape.type){case"object":return r.shape;case"alias":if(r.shape.resolvedType.type==="named")return _2c(r.shape.resolvedType.name.typeId,t)}throw new F3i(`Unexpected error: ${e} is extended but has shape ${r.shape.type}`)}function _mh({objectTypeDeclaration:e,ir:t}){let r=e.extends.flatMap(i=>{let n=_2c(i.typeId,t);return _mh({objectTypeDeclaration:n,ir:t})});return[...e.properties,...r]}var RAu=class{subpackages={};rootPackage={docs:void 0,fernFilepath:{allParts:[],packagePath:[],file:void 0},websocket:void 0,service:void 0,types:[],errors:[],subpackages:[],webhooks:void 0,navigationConfig:void 0};addPackageRedirection({from:t,to:r}){let i=this.getPackageForFernFilepath(t);if(i.navigationConfig!=null)throw new Error("Found duplicate navigationConfig for package");i.navigationConfig={pointsTo:M_.generateSubpackageId(r)}}addDocs(t,r){let i=this.getPackageForFernFilepath(t);if(i.docs!=null)throw new Error("Found duplicate docs for package");i.docs=r}addSubpackage(t){this.getPackageForFernFilepath(t)}addType(t,r){this.getPackageForFernFilepath(r.name.fernFilepath).types.push(t)}addError(t,r){this.getPackageForFernFilepath(r.name.fernFilepath).errors.push(t)}addService(t,r){let i=this.getPackageForFernFilepath(r.name.fernFilepath);if(i.service!=null)throw new Error("Found duplicate service for "+t);i.service=t}addWebhookGroup(t,r){let i=this.getPackageForFernFilepath(r);if(i.webhooks!=null)throw new Error("Found duplicate webhook group for "+t);i.webhooks=t}addWebSocketChannel(t,r){let i=this.getPackageForFernFilepath(r);if(i.webhooks!=null)throw new Error("Found duplicate webhook group for "+t);i.websocket=t}build(t){t!=null&&(Object.entries(this.subpackages).forEach(([i,n])=>{t.hasSubpackageId(i)?this.subpackages[i]={...n,types:n.types.filter(a=>t.hasTypeId(a)),errors:n.errors.filter(a=>t.hasErrorId(a)),service:n.service!=null&&t.hasServiceId(n.service)?n.service:void 0,websocket:n.websocket!=null&&t.hasChannel(n.websocket)?n.websocket:void 0,subpackages:n.subpackages.filter(a=>t.hasSubpackageId(a))}:delete this.subpackages[i]}),this.rootPackage={...this.rootPackage,types:this.rootPackage.types.filter(i=>t.hasTypeId(i)),errors:this.rootPackage.errors.filter(i=>t.hasErrorId(i)),service:this.rootPackage.service!=null&&t.hasServiceId(this.rootPackage.service)?this.rootPackage.service:void 0,subpackages:this.rootPackage.subpackages.filter(i=>t.hasSubpackageId(i)),webhooks:this.rootPackage.webhooks!=null?this.rootPackage.webhooks:void 0});let r=new Set(this.getAllChildrenWithEndpoints(this.rootPackage));return{subpackages:gn(this.subpackages,(i,n)=>({...i,hasEndpointsInTree:r.has(n)})),rootPackage:{...this.rootPackage,hasEndpointsInTree:r.size>0||this.rootPackage.service!=null}}}sortRootPackage(t){if(!hmh(this.rootPackage.subpackages,t))throw new Error("Sorted subpackages differ from unsorted packages in root");this.rootPackage.subpackages=t}sortSubpackage(t,r){let i=this.subpackages[t];if(i==null)throw new Error("Subpackage does not exist: "+t);if(!hmh(i.subpackages,r))throw new Error("Sorted subpackages differ from unsorted packages");i.subpackages=r}getAllSubpackagesWithEndpoints(t){let r=this.subpackages[t];if(r==null)throw new Error("Subpackage does not exist: "+t);let i=this.getAllChildrenWithEndpoints(r);return(i.length>0||r.service!=null)&&i.push(t),i}getAllChildrenWithEndpoints(t){return t.subpackages.flatMap(r=>[...this.getAllSubpackagesWithEndpoints(r)])}getPackageForFernFilepath(t,r=0,i=this.rootPackage){let n=t.allParts[r];if(n==null)return i;let a=i.subpackages.map(s=>{let u=this.subpackages[s];if(u==null)throw new Error("Subpackage ID is invalid: "+s);return u}),o=r+1,c={allParts:t.allParts.slice(0,o),packagePath:t.packagePath.slice(0,o),file:o===t.allParts.length?t.file:void 0},d=a.find(s=>s.name.originalName===n.originalName);if(d==null){let s=M_.generateSubpackageId(c),u={docs:void 0,fernFilepath:c,name:n,displayName:void 0,service:void 0,types:[],errors:[],subpackages:[],navigationConfig:void 0,webhooks:void 0,websocket:void 0};this.subpackages[s]=u,i.subpackages.push(s),d=u}return this.getPackageForFernFilepath(t,o,d)}};function hmh(e,t){if(e.length!==t.length)return!1;let r=new Set(e);for(let i of t)if(!r.has(i))return!1;return!0}function ymh({reference:e,referencedIn:t,imports:r}){let[i,n,...a]=e.split(".");if(i==null||a.length>0)return;if(n==null)return{endpointName:i,relativeFilepath:t};let c=r[i];if(c!=null)return{endpointName:n,relativeFilepath:y2i({referencedIn:t,importPath:c})}}var ijn=class{workspace;constructor(t){this.workspace=t}resolveEndpointOrThrow({endpoint:t,file:r}){let i=this.resolveEndpoint({endpoint:t,file:r});if(i==null)throw new Error("Cannot resolve endpoint: "+t+" in file "+r.relativeFilepath);return i}resolveEndpointByMethodAndPath({method:t,path:r,namespace:i,casingsGenerator:n}){let a;return Gq(this.workspace,(o,c,d)=>{if(i!=null&&this.getNamespaceFromFilepath(o)!==i)return;let s=ud({relativeFilepath:o,definitionFile:c,casingsGenerator:n,rootApiFile:this.workspace.definition.rootApiFile.contents,defaultUrl:d.defaultUrl});for(let[u,f]of Object.entries(c.service?.endpoints??{}))f.method===t&&f.path===r&&(a={endpointId:u,endpoint:f,file:s})}),kPn(this.workspace,(o,c)=>{if(i!=null&&this.getNamespaceFromFilepath(o)!==i)return;let d=ud({relativeFilepath:o,definitionFile:c,casingsGenerator:n,rootApiFile:this.workspace.definition.rootApiFile.contents});for(let[s,u]of Object.entries(c.service?.endpoints??{}))u.method===t&&u.path===r&&(a={endpointId:s,endpoint:u,file:d})}),a}getNamespaceFromFilepath(t){let r=t.split("/");if(r.length>1)return r[0]}resolveEndpoint({endpoint:t,file:r}){let n=new k3i().tryParse(t);if(n!=null)return this.resolveEndpointByMethodAndPath({method:n.method,path:n.path,namespace:n.namespace,casingsGenerator:r.casingsGenerator});let a=this.getDeclarationOfEndpoint({referenceToEndpoint:t,file:r});if(a==null)return;let o=a.file.definitionFile.service?.endpoints?.[a.endpointName];if(o!=null)return{endpointId:a.endpointName,endpoint:o,file:a.file}}getDeclarationOfEndpoint({referenceToEndpoint:t,file:r}){let i=ymh({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=eBe(this.workspace,i.relativeFilepath);if(!(n==null||n.service?.endpoints?.[i.endpointName]==null))return{endpointName:i.endpointName,file:ud({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}};var njn=class{workspace;constructor(t){this.workspace=t}getDeclarationOrThrow(t,r){let i=this.getDeclaration(t,r);if(i==null)throw new Error("Error does not exist: "+t);return i}getDeclaration(t,r){let i=Ume({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=eBe(this.workspace,i.relativeFilepath);if(n==null)return;let a=n.errors?.[i.typeName];if(a!=null)return{declaration:a,file:ud({definitionFile:n,relativeFilepath:i.relativeFilepath,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}};var Zme=class{typeResolver;constructor(t){this.typeResolver=t}resolveAllReferencesInExample({example:t,file:r}){if(typeof t=="string"){let i=this.resolveExample({example:t,file:r});return i==null?i:typeof i.resolvedExample=="string"?(i.resolvedExample.startsWith(`\\${"$"}`)&&(i.resolvedExample=i.resolvedExample.slice(1)),i):this.resolveAllReferencesInExample({example:i.resolvedExample,file:i.file})}else if(Wl(t)){let i={};for(let[n,a]of Object.entries(t)){let o=this.resolveAllReferencesInExample({example:a,file:r});if(o==null)return;i[n]=o.resolvedExample}return{resolvedExample:i}}else if(Array.isArray(t)){let i=[];for(let n of t){let a=this.resolveAllReferencesInExample({example:n,file:r});if(a==null)return;i.push(a.resolvedExample)}return{resolvedExample:i}}return{resolvedExample:t}}resolveAllReferencesInExampleOrThrow({example:t,file:r}){let i=this.resolveAllReferencesInExample({example:t,file:r});if(i==null)throw new Error("Failed to resolve examples");return i}resolveExample({example:t,file:r}){return typeof t!="string"?{resolvedExample:t,file:r}:t.startsWith("$")?this.parseExampleReference(t)==null?{resolvedExample:t,file:r}:this.resolveExampleReference(t,r):{resolvedExample:t,file:r}}resolveExampleReference(t,r){let i=this.parseExampleReference(t);if(i==null)return;let n=this.typeResolver.getDeclarationOfNamedType({referenceToNamedType:i.rawTypeReference,file:r});if(n==null||typeof n.declaration=="string"||n.declaration.examples==null)return;let a=n.declaration.examples.find(o=>o.name===i.exampleName);if(a!=null)return this.resolveExample({example:a.value,file:n.file})}resolveExampleOrThrow({example:t,file:r}){let i=this.resolveExample({example:t,file:r});if(i==null)throw new Error("Cannot resolve example: "+t);return i}parseExampleReference(t){let[r,i,n,...a]=t.split(".");if(r==null||i==null||a.length>0)return;if(n==null){let c=r.slice("$".length);return h2c(c)?{rawTypeReference:c,exampleName:i}:void 0}let o=r.slice("$".length);if(!(!h2c(o)||!h2c(i)))return{rawTypeReference:`${o}.${i}`,exampleName:n}}};function h2c(e){if(e.length===0)return!1;let t=e.charAt(0);return t>="a"&&t<="z"||t>="A"&&t<="Z"}var zAu=class{typeResolver;endpointResolver;constructor(t,r){this.typeResolver=t,this.endpointResolver=r,this.typeResolver=t,this.endpointResolver=r}resolveRequestPropertyOrThrow({file:t,endpoint:r,propertyComponents:i}){let n=this.resolveRequestProperty({file:t,endpoint:r,propertyComponents:i});if(n==null)throw new Error("Cannot resolve request property from endpoint: "+r+" in file "+t.relativeFilepath);return n}resolveRequestProperty({file:t,endpoint:r,propertyComponents:i}){let n=this.endpointResolver.resolveEndpointOrThrow({endpoint:r,file:t});if(n.endpoint.request==null)return;if(typeof n.endpoint.request!="string")return this.resolveRequestPropertyFromInlinedRequest({typeResolver:this.typeResolver,file:n.file,requestType:n.endpoint.request,propertyComponents:i});let a=this.typeResolver.resolveTypeOrThrow({type:n.endpoint.request,file:n.file}),o=this.resolveObjectProperty({file:n.file,resolvedType:a,propertyComponents:i});if(o!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:i,file:t,resolvedType:a}),property:SZ.body(o)}}resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:i}){let n=this.resolveResponseProperty({file:t,endpoint:r,propertyComponents:i});if(n==null)throw new Error("Cannot resolve response property from endpoint: "+r+" in file "+t.relativeFilepath);return n}resolveResponseProperty({file:t,endpoint:r,propertyComponents:i}){let n=this.endpointResolver.resolveEndpointOrThrow({endpoint:r,file:t}),a=this.typeResolver.resolveTypeOrThrow({type:(typeof n.endpoint.response!="string"?n.endpoint.response?.type:n.endpoint.response)??"",file:n.file}),o=this.resolveObjectProperty({file:n.file,resolvedType:a,propertyComponents:i});if(o!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:i,resolvedType:a,file:t}),property:o}}resolveRequestPropertyFromInlinedRequest({typeResolver:t,file:r,requestType:i,propertyComponents:n}){if(n.length===1){let a=n[0]??"",o=i["query-parameters"]?.[a]??void 0;if(o!=null)return{property:SZ.query(PAu({file:r,queryParameterKey:a,queryParameter:o})),propertyPath:void 0}}return this.resolveRequestPropertyFromInlinedRequestBody({typeResolver:t,file:r,requestType:i,propertyComponents:n})}resolveRequestPropertyFromInlinedRequestBody({typeResolver:t,file:r,requestType:i,propertyComponents:n}){if(i.body==null)return;if(typeof i.body=="string"){let c=t.resolveTypeOrThrow({type:i.body,file:r}),d=this.resolveObjectProperty({file:r,resolvedType:c,propertyComponents:n});return d==null?void 0:{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r,resolvedType:c}),property:SZ.body(d)}}if(AE(i.body)){let c=J_u({typeResolver:t,file:r,objectSchema:i.body,propertyComponents:n});return c==null?void 0:{propertyPath:this.propertyPathFromPropertyComponentsFromInlineRequestBody({propertyComponents:n,file:r,body:i.body}),property:SZ.body(c)}}let a=t.resolveTypeOrThrow({type:i.body.type,file:r}),o=$_u({typeResolver:t,file:nda(a)??r,resolvedType:a,propertyComponents:n});if(o!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r,resolvedType:a}),property:SZ.body(o)}}resolveObjectProperty({file:t,resolvedType:r,propertyComponents:i}){return $_u({typeResolver:this.typeResolver,file:nda(r)??t,resolvedType:r,propertyComponents:i})}propertyPathFromPropertyComponents({propertyComponents:t,file:r,resolvedType:i}){if(t.length<=1)return[];let n=ajn(i),a=i,o=[],c=[];for(let d of t.slice(0,-1))c.push(d),a=ofB({typeResolver:this.typeResolver,file:r,resolvedType:a,propertyName:d,breadcrumbs:c,rootTypeTitle:n}),o.push({name:r.casingsGenerator.generateName(d),type:a.originalTypeReference});return o}propertyPathFromPropertyComponentsFromInlineRequestBody({propertyComponents:t,file:r,body:i}){if(t.length<=1)return[];let n=[],a=[];for(let o of t.slice(0,-1)){a.push(o);let c=J_u({typeResolver:this.typeResolver,file:r,objectSchema:i,propertyComponents:a});if(!c)throw new Error(`Cannot find property '${a.join(".")}' in inline request body in file ${r.relativeFilepath}`);n.push({name:r.casingsGenerator.generateName(o),type:c.valueType})}return n}};function ofB({typeResolver:e,file:t,resolvedType:r,propertyName:i,breadcrumbs:n,rootTypeTitle:a}){let o=b_a({typeResolver:e,file:t,resolvedType:r,propertyName:i});if(!o)throw new Error(`Cannot find property '${n.join(".")}' in ${a}`);return o}function b_a({typeResolver:e,file:t,resolvedType:r,propertyName:i}){switch(r._type){case"container":switch(r.container._type){case"list":return;case"literal":return;case"map":return;case"nullable":{let n=b_a({typeResolver:e,file:t,resolvedType:r.container.itemType,propertyName:i});return n||void 0}case"optional":{let n=b_a({typeResolver:e,file:t,resolvedType:r.container.itemType,propertyName:i});return n||void 0}case"set":return;default:de(r.container)}break;case"primitive":return;case"unknown":return;case"named":{let n=r.declaration;if("properties"in n&&n.properties!=null){for(let[a,o]of Object.entries(n.properties))if(a===i)return e.resolveTypeOrThrow({type:typeof o=="string"?o:o.type,file:r.file})}if("base-properties"in n&&n["base-properties"]!=null){for(let[a,o]of Object.entries(n["base-properties"]))if(a===i)return e.resolveTypeOrThrow({type:typeof o=="string"?o:o.type,file:r.file})}if("extends"in n&&n.extends!=null){let a=Array.isArray(n.extends)?n.extends:[n.extends];for(let o of a){let c=e.resolveTypeOrThrow({type:o,file:r.file}),d=b_a({file:"file"in c?c.file:t,typeResolver:e,resolvedType:c,propertyName:i});if(d)return d}}if("union"in n&&n.union!=null)if(Array.isArray(n.union))for(let a of n.union){let o=e.resolveTypeOrThrow({type:typeof a=="string"?a:a.type,file:r.file}),c=b_a({file:"file"in o?o.file:t,typeResolver:e,resolvedType:o,propertyName:i});if(c)return c}else for(let[,a]of Object.entries(n.union)){let o=typeof a=="string"?a:a.type;if(!o)continue;let c=e.resolveTypeOrThrow({type:o,file:r.file}),d=b_a({file:"file"in c?c.file:t,typeResolver:e,resolvedType:c,propertyName:i});if(d)return d}return}default:de(r)}}function ajn(e){switch(e._type){case"container":switch(e.container._type){case"list":return`list<${ajn(e.container.itemType)}>}`;case"literal":return`literal<${e.container.literal._visit({boolean:t=>t.toString(),string:t=>t,_other:t=>t.type})}>`;case"map":return`map<${ajn(e.container.keyType)}, ${ajn(e.container.valueType)}>}`;case"nullable":return`nullable<${ajn(e.container.itemType)}>}`;case"optional":return`optional<${ajn(e.container.itemType)}>}`;case"set":return`set<${ajn(e.container.itemType)}>}`;default:de(e.container)}break;case"named":return e.name.name.originalName;case"primitive":return e.primitive.v1;case"unknown":return"unknown";default:de(e)}}var Kv=class{workspace;constructor(t){this.workspace=t}resolveTypeOrThrow({type:t,file:r}){let i=this.resolveType({type:t,file:r});if(i==null)throw new Error("Cannot resolve type: "+t+" in file "+r.relativeFilepath);return i}getDeclarationOfNamedTypeOrThrow({referenceToNamedType:t,file:r}){let i=this.getDeclarationOfNamedType({referenceToNamedType:t,file:r});if(i==null)throw new Error("Cannot find declaration of type: "+t+" in file "+r.relativeFilepath);return i}getDeclarationOfNamedType({referenceToNamedType:t,file:r}){let i=Ume({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=eBe(this.workspace,i.relativeFilepath);if(n==null)return;let a=n.types?.[i.typeName];if(a==null){let o=HB(i.typeName);if(o!=null){for(let c of Object.keys(n.types??{})??[])if(o.name&&c.startsWith(o.name)&&c.endsWith(">")){let d=n.types?.[c];return d!=null?{typeName:c,declaration:d,file:ud({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}:void 0}}return}return{typeName:i.typeName,declaration:a,file:ud({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}resolveType({type:t,file:r,objectPath:i=[]}){return Uq({type:t,_default:void 0,validation:void 0,visitor:{primitive:n=>({_type:"primitive",primitive:n,originalTypeReference:_i.primitive(n)}),unknown:()=>({_type:"unknown",originalTypeReference:_i.unknown()}),map:({keyType:n,valueType:a})=>n!=null&&a!=null?{_type:"container",container:{_type:"map",keyType:n,valueType:a},originalTypeReference:_i.container(Js.map({keyType:n.originalTypeReference,valueType:a.originalTypeReference}))}:void 0,list:n=>n!=null?{_type:"container",container:{_type:"list",itemType:n},originalTypeReference:_i.container(Js.list(n.originalTypeReference))}:void 0,optional:n=>n!=null?{_type:"container",container:{_type:"optional",itemType:n},originalTypeReference:_i.container(Js.optional(n.originalTypeReference))}:void 0,nullable:n=>n!=null?{_type:"container",container:{_type:"nullable",itemType:n},originalTypeReference:_i.container(Js.nullable(n.originalTypeReference))}:void 0,set:n=>n!=null?{_type:"container",container:{_type:"set",itemType:n},originalTypeReference:_i.container(Js.set(n.originalTypeReference))}:void 0,literal:n=>({_type:"container",container:{_type:"literal",literal:n},originalTypeReference:_i.container(Js.literal(n))}),named:n=>{let a=this.getDeclarationOfNamedType({referenceToNamedType:n,file:r});if(a==null)return;let o={typeName:a.typeName,file:a.file.relativeFilepath,reference:n};if(!i.some(c=>c.file===o.file&&c.typeName===o.typeName))return this.resolveNamedTypeFromDeclaration({referenceToNamedType:n,referencedIn:r,rawDeclaration:a,objectPath:[...i,o]})}}})}resolveNamedTypeOrThrow({referenceToNamedType:t,file:r}){let i=this.resolveNamedType({referenceToNamedType:t,file:r});if(i==null)throw new Error("Cannot resolve type: "+t);return i}resolveNamedType({referenceToNamedType:t,file:r}){let i=this.getDeclarationOfNamedType({referenceToNamedType:t,file:r});if(i!=null)return this.resolveNamedTypeFromDeclaration({referenceToNamedType:t,referencedIn:r,rawDeclaration:i})}resolveNamedTypeFromDeclaration({referenceToNamedType:t,referencedIn:r,rawDeclaration:i,objectPath:n=[]}){let{declaration:a,file:o}=i;if(d2i(a))return this.resolveType({type:typeof a=="string"?a:a.type,file:o,objectPath:n});let c=ero({type:t,_default:void 0,validation:void 0,file:r});if(!(c.type!=="named"||eBe(this.workspace,o.relativeFilepath)==null))return{_type:"named",rawName:i.typeName,name:c,declaration:a,filepath:o.relativeFilepath,objectPath:n,originalTypeReference:c,file:o}}};var Y5t=class e{static VARIABLE_PREFIX="$";getDeclarationOrThrow(t,r){let i=this.getDeclaration(t,r);if(i==null)throw new Error("Variable does not exist: "+t);return i}getDeclaration(t,r){if(!t.startsWith(e.VARIABLE_PREFIX))return;let i=r.rootApiFile.variables?.[t.substring(1)];if(i!=null)return{declaration:i,file:TWi({casingsGenerator:r.casingsGenerator,rootApiFile:r.rootApiFile})}}getVariableIdOrThrow(t){let r=this.getVariableId(t);if(r==null)throw new Error("Variable reference does not start with "+e.VARIABLE_PREFIX);return r}getVariableId(t){if(t.startsWith(e.VARIABLE_PREFIX))return t.substring(e.VARIABLE_PREFIX.length)}};function NAu(e,t){if(t){for(let[r,i]of Object.entries(t))if(typeof i!="string"&&r===e)return i.audiences}}var bmh={pathParameterOrder:Ki.PathParameterOrder.UrlOrder};function vmh({workspace:e}){let t=e.generatorsConfiguration?.api?.settings,r={...bmh};for(let i of Object.keys(bmh)){let n=t?.[i];n!==void 0&&(r[i]=n)}return r}function DE({workspace:e,generationLanguage:t,keywords:r,smartCasing:i,exampleGeneration:n,audiences:a,readme:o,packageName:c,version:d,fdrApiDefinitionId:s,sourceResolver:u,disableDynamicExamples:f,dynamicGeneratorConfig:p,generationMetadata:_}){let h=vmh({workspace:e}),y=N7({generationLanguage:t,keywords:r,smartCasing:i}),b=new KAn(a),v=TWi({casingsGenerator:y,rootApiFile:e.definition.rootApiFile.contents}),O=(e.definition.rootApiFile.contents.errors??[]).map(X=>({error:b2i({errorName:X,file:v}),docs:void 0})),m=new Kv(e),g=new ijn(e),A=new zAu(m,g),j=new njn(e),M=new Zme(m),w=new Y5t,B=Kka({casingsGenerator:y,rawApiFileSchema:e.definition.rootApiFile.contents})?.environmentsConfig,q={selfHosted:!1,fdrApiDefinitionId:s,apiVersion:XOh({file:v,rawApiFileSchema:e.definition.rootApiFile.contents}),apiName:y.generateName(e.definition.rootApiFile.contents.name),apiDisplayName:e.definition.rootApiFile.contents["display-name"],apiDocs:Xka(e.definition.rootApiFile.contents.docs),auth:YOh({rawApiFileSchema:e.definition.rootApiFile.contents,file:v,propertyResolver:A,endpointResolver:g}),headers:e.definition.rootApiFile.contents.headers!=null?Object.entries(e.definition.rootApiFile.contents.headers).map(([X,Ue])=>rBe({headerKey:X,header:Ue,file:v})):[],idempotencyHeaders:e.definition.rootApiFile.contents["idempotency-headers"]!=null?Object.entries(e.definition.rootApiFile.contents["idempotency-headers"]).map(([X,Ue])=>rBe({headerKey:X,header:Ue,file:v})):[],types:{},errors:{},services:{},constants:UOh(y),environments:B,errorDiscriminationStrategy:tmh(e.definition.rootApiFile.contents["error-discrimination"],v),basePath:e.definition.rootApiFile.contents["base-path"]!=null?HD(e.definition.rootApiFile.contents["base-path"]):void 0,pathParameters:y_a({pathParameters:e.definition.rootApiFile.contents["path-parameters"],file:v,location:BDe.Root,variableResolver:w}),variables:e.definition.rootApiFile.contents.variables!=null?Object.entries(e.definition.rootApiFile.contents.variables).map(([X,Ue])=>({docs:typeof Ue!="string"?Ue.docs:void 0,id:X,name:v.casingsGenerator.generateName(X),type:v.parseTypeReference(Ue)})):[],serviceTypeReferenceInfo:{typesReferencedOnlyByService:{},sharedTypes:[]},webhookGroups:{},websocketChannels:{},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,audiences:e.definition.rootApiFile.contents.audiences,generationMetadata:_,apiPlayground:!0},R=new RAu,T=X=>{R.addSubpackage(X.fernFilepath),Vb(X.definitionFile,{imports:At,docs:Ue=>{Ue!=null&&R.addDocs(X.fernFilepath,Ue)},types:Ue=>{if(Ue!=null)for(let[Ke,or]of Object.entries(Ue)){if(MDe(Ke))continue;let Ft=lmh({typeName:Ke,typeDeclaration:or,file:X,typeResolver:m,exampleResolver:M,sourceResolver:u,workspace:e}),qt=Ft.typeDeclaration;n.disabled&&(qt.userProvidedExamples=[],qt.autogeneratedExamples=[]);let Ht=Ft.descendantFilepaths,Qt=M_.generateTypeId(qt.name);q.types[Qt]=qt,R.addType(Qt,qt),b.addType({declaredTypeName:qt.name,descendantTypeIds:qt.referencedTypes,descendantTypeIdsByAudience:{},propertiesByAudience:Ft.propertiesByAudience,descendantFilepaths:Ht}),b.markTypeForAudiences(qt.name,Vrh(or))}},errors:Ue=>{if(Ue==null)return;if(e.definition.rootApiFile.contents["error-discrimination"]==null)throw new Error("error-discrimination is missing in api.yml but there are declared errors.");for(let[or,Ft]of Object.entries(Ue)){let qt=kOh({errorName:or,errorDeclaration:Ft,file:X,typeResolver:m,exampleResolver:M,workspace:e}),Ht=M_.generateErrorId(qt.name);q.errors[Ht]=qt,R.addError(Ht,qt),b.addError(qt)}},service:Ue=>{if(Ue==null)return;let Ke=ROh({rootDefaultUrl:X.defaultUrl??e.definition.rootApiFile.contents["default-url"],rootPathParameters:q.pathParameters,serviceDefinition:Ue,file:X,errorResolver:j,typeResolver:m,propertyResolver:A,exampleResolver:M,sourceResolver:u,globalErrors:O,variableResolver:w,workspace:e,auth:q.auth,irSettings:h}),or=M_.generateServiceId(Ke.name);q.services[or]=Ke,R.addService(or,Ke);let Ft={};Ke.endpoints.forEach(qt=>{n.disabled&&(qt.autogeneratedExamples=[],qt.userSpecifiedExamples=[]);let Ht=Ue.endpoints[qt.name.originalName];b.addEndpoint(Ke,qt,Ht),Ft[qt.name.originalName]=qt}),Ue.audiences!=null&&b.markEndpointForAudience(Ke.name,Ke.endpoints,Ue.audiences),Object.entries(Ue.endpoints).map(([qt,Ht])=>{let Qt=Ft[qt];Qt!=null&&Ht.audiences!=null&&b.markEndpointForAudience(Ke.name,[Qt],Ht.audiences)})},webhooks:Ue=>{if(Ue==null)return;let Ke=M_.generateWebhookGroupId(X.fernFilepath),or=imh({webhooks:Ue,file:X,typeResolver:m,exampleResolver:M,workspace:e}),Ft={};for(let qt of or)Ft[qt.name.originalName]=qt;Object.entries(Ue).forEach(([qt,Ht])=>{let Qt=Ft[qt];Qt!=null&&(b.addWebhook(X.fernFilepath,Qt,Ht),Ht.audiences!=null&&b.markWebhookForAudiences(X.fernFilepath,Qt,Ht.audiences))}),q.webhookGroups[Ke]=or,R.addWebhookGroup(Ke,X.fernFilepath)},channel:Ue=>{if(Ue==null)return;let Ke=M_.generateWebSocketChannelId(X.fernFilepath),or=ZOh({channel:Ue,file:X,variableResolver:w,typeResolver:m,exampleResolver:M,workspace:e});b.addChannel(X.fernFilepath,Ke,or,Ue),Ue.audiences!=null&&b.markChannelForAudiences(X.fernFilepath,Ke,Ue.audiences),q.websocketChannels!=null&&(q.websocketChannels[Ke]=or,R.addWebSocketChannel(Ke,X.fernFilepath))}})};Gq(e,(X,Ue,Ke)=>{T(ud({relativeFilepath:X,definitionFile:Ue,casingsGenerator:y,rootApiFile:e.definition.rootApiFile.contents,defaultUrl:Ke.defaultUrl}))}),kPn(e,(X,Ue)=>{if(Ue.navigation!=null)if(typeof Ue.navigation=="string")R.addPackageRedirection({from:IZ({relativeFilepath:X,casingsGenerator:y}),to:IZ({relativeFilepath:PC(GMe(X),_s.of(Ue.navigation)),casingsGenerator:y})});else{let Ke=Ue.navigation.map(or=>M_.generateSubpackageId(IZ({relativeFilepath:PC(GMe(X),_s.of(or)),casingsGenerator:y})));X===Wv?R.sortRootPackage(Ke):R.sortSubpackage(M_.generateSubpackageId(IZ({relativeFilepath:X,casingsGenerator:y})),Ke)}}),q.serviceTypeReferenceInfo=sfB(b),dmh(q);let K=n.disabled?q:Jka({ir:q,exampleGeneration:n}),H=e.definition.rootApiFile.contents,z=B?.environments._visit({singleBaseUrl:X=>X.environments.filter(Ue=>NAu(Ue.id,H.environments)!=null).length===0,multipleBaseUrls:X=>X.environments.filter(Ue=>NAu(Ue.id,H.environments)!=null).length===0,_other:()=>!1});B?.environments.environments.forEach(X=>{b.markEnvironmentForAudiences(X,NAu(X.id,H.environments)??[],z)});let W=b.hasNoAudiences()?void 0:b.build(),Oe=mHc(K,W),Ae=e.definition.rootApiFile.contents.auth!=null&&Object.values(Oe.services).every(X=>X.endpoints.every(Ue=>Ue.auth)),Q=Object.values(Oe.services).some(X=>X.endpoints.some(Ue=>Ue.response?.body?.type==="streaming")),U=Object.values(Oe.services).some(X=>X.endpoints.some(Ue=>Ue.pagination!=null)),ce=Object.values(Oe.services).some(X=>X.endpoints.some(Ue=>Ue.response?.body?.type==="fileDownload")),ae={isAuthMandatory:Ae,hasStreamingEndpoints:Q,hasPaginatedEndpoints:U,hasFileDownloadEndpoints:ce,platformHeaders:{language:"X-Fern-Language",sdkName:"X-Fern-SDK-Name",sdkVersion:"X-Fern-SDK-Version",userAgent:d!=null&&c!=null?{header:"User-Agent",value:`${c}/${d}`}:void 0}},fe=o??e.generatorsConfiguration?.rawConfiguration.readme,ve=fe!=null?rmh({readme:fe,services:q.services}):void 0,re=ufB({...Oe,...R.build(W),sdkConfig:ae,readmeConfig:ve});return{...re,dynamic:rjn({ir:re,generatorConfig:p,disableExamples:f,generationLanguage:t,smartCasing:i})}}function ufB(e){let t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(t);for(let i in r){let n=r[i];i==="docs"&&typeof n=="string"?r[i]=Xka(n):n&&typeof n=="object"&&t(n)}return r};return t(e)}function sfB(e){let t={},r=[],i=e.getTypesReferencedByService();for(let[n,a]of Object.entries(i)){if(a.size===1){let o=a.values().next().value;if(o==null)break;t[o]===void 0&&(t[o]=[]),t[o]?.push(n);continue}r.push(n)}return{typesReferencedOnlyByService:t,sharedTypes:r}}var Mro=process.env.FERN_STACK_TRACK?.toLowerCase()??"",f2=Mro!==""&&Mro!=="0"&&Mro!=="false",Fkc=["single","multiline","box"].includes(Mro)?Mro:"single";f2&&(Error.stackTraceLimit=50);var KEh=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),RgB=new Set(["stacktrace"]);function Qkc(e){f2&&KEh.add(e)}function Dro({maxFrames:e=50,skip:t=0,filterPaths:r=[],filterFunctions:i=[],stopOn:n=[],filterNode:a=!0,filterJs:o=!0,formatFilename:c=d=>d}={}){if(!f2)return[];i=[...i,...KEh],r=[...r,...RgB],n=[...n,"runInteractiveTask"];let d=!1;return(new Error().stack??"").split(`
|
|
1465
|
+
${JSON.stringify(r)}"`)}}function TOh(e,t,r,i){let n=r.resolveSourceOrThrow({source:t,relativeFilepath:e.relativeFilepath});if(n==null||n.type!=="protobuf")throw new Error(`Expected a protobuf source for ${t.proto}.`);let a=IOh({source:n,serviceNameOverride:i});if(a==null)throw new Error(`Failed to resolve service name from ${n.relativeFilePath}.`);return CDe.grpc({service:a})}function ROh({rootDefaultUrl:e,rootPathParameters:t,serviceDefinition:r,file:i,errorResolver:n,typeResolver:a,propertyResolver:o,exampleResolver:c,variableResolver:d,sourceResolver:s,globalErrors:u,workspace:f,auth:p,irSettings:_}){let h=y_a({pathParameters:r["path-parameters"],location:BDe.Service,file:i,variableResolver:d}),y=_.pathParameterOrder,b=(()=>{switch(y){case Ki.PathParameterOrder.UrlOrder:return r["base-path"]?Z_u(r["base-path"],h):h;case Ki.PathParameterOrder.SpecOrder:return h;default:de(y)}})(),v=COh({file:i,serviceDeclaration:r,sourceResolver:s}),O={fernFilepath:i.fernFilepath};return{availability:CZ(r.availability),name:O,displayName:r["display-name"]??void 0,basePath:HD(r["base-path"]),headers:r.headers!=null?Object.entries(r.headers).map(([g,A])=>rBe({headerKey:g,header:A,file:i})):[],pathParameters:b,encoding:blB(v,r),transport:v,endpoints:Object.entries(r.endpoints).map(([g,A])=>{let j=A["base-path"]!=null?(0,wAu.default)(A["base-path"],A.path):i.rootApiFile["base-path"]!=null?(0,wAu.default)(i.rootApiFile["base-path"],r["base-path"],A.path):(0,wAu.default)(r["base-path"],A.path),M=y_a({pathParameters:T5t(A),location:BDe.Endpoint,file:i,variableResolver:d}),w=(()=>{switch(y){case Ki.PathParameterOrder.UrlOrder:return Z_u(A.path,M);case Ki.PathParameterOrder.SpecOrder:return M;default:de(y)}})(),E=A["base-path"]!=null?w:[...t,...b,...w],B=(()=>{switch(y){case Ki.PathParameterOrder.UrlOrder:return Z_u(j,E);case Ki.PathParameterOrder.SpecOrder:return E;default:de(y)}})(),q={...w5(A),id:"",name:i.casingsGenerator.generateName(g),displayName:A["display-name"],auth:typeof A.auth=="boolean"?A.auth:A.auth!=null?A.auth.length>0:r.auth,security:typeof A.auth>"u"||typeof A.auth=="boolean"?A.auth??r.auth===!0?vN._visit(p.requirement,{any:()=>p.schemes.map(R=>({[R.key]:[]})),all:()=>[p.schemes.reduce((R,T)=>({...R,[T.key]:[]}),{})],endpointSecurity:()=>{},_other:()=>{}}):void 0:A.auth,docs:A.docs,idempotent:A.idempotent??r.idempotent??!1,baseUrl:A.url??r.url??e,v2BaseUrls:void 0,method:A.method!=null?ylB(A.method):jE.Post,basePath:A["base-path"]!=null?HD(A["base-path"]):void 0,path:HD(A.path),fullPath:HD(j),pathParameters:w,allPathParameters:B,queryParameters:typeof A.request!="string"&&A.request?.["query-parameters"]!=null?Object.entries(A.request["query-parameters"]).map(([R,T])=>PAu({file:i,queryParameterKey:R,queryParameter:T})):[],headers:typeof A.request!="string"&&A.request?.headers!=null?Object.entries(A.request.headers).map(([R,T])=>rBe({headerKey:R,header:T,file:i})):[],requestBody:Grh({request:A.request,file:i}),v2RequestBodies:void 0,sdkRequest:Yrh({service:r,request:A.request,endpoint:A,endpointKey:g,file:i,typeResolver:a,propertyResolver:o}),response:POh({endpoint:A,file:i,typeResolver:a}),v2Responses:void 0,errors:[...DOh({errors:A.errors,file:i}),...u],userSpecifiedExamples:A.examples!=null?A.examples.map(R=>{try{let T=AOh({service:r,endpoint:A,example:R,typeResolver:a,errorResolver:n,exampleResolver:c,variableResolver:d,file:i,workspace:f});return T===void 0?void 0:{example:T,codeSamples:R["code-samples"]?.map(K=>Xrh({codeSample:K,file:i}))}}catch{return}}).filter(R=>R!==void 0):[],autogeneratedExamples:[],pagination:MOh({propertyResolver:o,file:i,endpointName:g,endpointSchema:A}),transport:qOh({file:i,serviceTransport:v,endpointDeclaration:A,sourceResolver:s}),v2Examples:void 0,source:void 0,audiences:A.audiences,retries:BOh({endpointSchema:A}),apiPlayground:void 0,responseHeaders:[]};return q.id=M_.generateEndpointId(O,q),q}),audiences:r.audiences}}function y_a({pathParameters:e,location:t,file:r,variableResolver:i}){return e==null?[]:Object.entries(e).map(([n,a])=>_lB({parameterName:n,parameter:a,location:t,file:r,variableResolver:i}))}function _lB({parameterName:e,parameter:t,location:r,file:i,variableResolver:n}){return{...w5(t),name:i.casingsGenerator.generateName(e),valueType:hlB({parameter:t,variableResolver:n,file:i}),location:r,variable:Yfa(t)?n.getVariableIdOrThrow(typeof t=="string"?t:t.variable):void 0,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}},explode:void 0}}function hlB({parameter:e,variableResolver:t,file:r}){let i=nro({parameter:e,variableResolver:t,file:r});return i.file.parseTypeReference(i.rawType)}function nro({parameter:e,variableResolver:t,file:r}){let i=EAu({parameter:e,variableResolver:t,file:r});if(i==null)throw new Error("Cannot resolve path parameter");return i}function EAu({parameter:e,variableResolver:t,file:r}){if(Yfa(e)){let i=typeof e=="string"?e:e.variable,n=t.getDeclaration(i,r);return n==null?void 0:{rawType:typeof n.declaration=="string"?n.declaration:n.declaration.type,file:n.file}}else return{file:r,rawType:typeof e=="string"?e:e.type}}function ylB(e){switch(e){case"GET":return jE.Get;case"POST":return jE.Post;case"PUT":return jE.Put;case"PATCH":return jE.Patch;case"DELETE":return jE.Delete;case"HEAD":return jE.Head;default:de(e)}}function rBe({headerKey:e,header:t,file:r}){let{name:i}=jkt({headerKey:e,header:t});return{...w5(t),name:r.casingsGenerator.generateNameAndWireValue({wireValue:e,name:i}),valueType:r.parseTypeReference(t),env:typeof t=="string"?void 0:t.env,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}function jkt({headerKey:e,header:t}){return typeof t!="string"&&t.name!=null?{name:t.name,wasExplicitlySet:!0}:{name:e,wasExplicitlySet:!1}}function blB(e,t){switch(e.type){case"http":return{json:{},proto:void 0};case"grpc":return{json:void 0,proto:{}};default:de(e)}}var DAu=se(bO(),1);var zOh=se(require("crypto")),MAu=new Uint8Array(256),SAu=MAu.length;function u2c(){return SAu>MAu.length-16&&(zOh.default.randomFillSync(MAu),SAu=0),MAu.slice(SAu,SAu+=16)}var L3=[];for(let e=0;e<256;++e)L3.push((e+256).toString(16).slice(1));function NOh(e,t=0){return L3[e[t+0]]+L3[e[t+1]]+L3[e[t+2]]+L3[e[t+3]]+"-"+L3[e[t+4]]+L3[e[t+5]]+"-"+L3[e[t+6]]+L3[e[t+7]]+"-"+L3[e[t+8]]+L3[e[t+9]]+"-"+L3[e[t+10]]+L3[e[t+11]]+L3[e[t+12]]+L3[e[t+13]]+L3[e[t+14]]+L3[e[t+15]]}var FOh=se(require("crypto")),s2c={randomUUID:FOh.default.randomUUID};function vlB(e,t,r){if(s2c.randomUUID&&!t&&!e)return s2c.randomUUID();e=e||{};let i=e.random||(e.rng||u2c)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){r=r||0;for(let n=0;n<16;++n)t[r+n]=i[n];return t}return NOh(i)}var Xme=vlB;var QOh="1.0.0";var BAu=class{ir;casingsGenerator;auth;authValues;generatorConfig;extendedTypeIds;constructor(t){this.ir=t.ir,this.generatorConfig=t.generatorConfig,this.casingsGenerator=N7({generationLanguage:t.generationLanguage,smartCasing:t.smartCasing??!1,keywords:void 0}),this.auth=this.convertAuth(this.ir.auth),this.authValues=this.getAuthValues(this.ir.auth),this.extendedTypeIds=this.computeExtendedTypeIds()}computeExtendedTypeIds(){let t=new Set;for(let r of Object.values(this.ir.types))if(r.shape.type==="object")for(let i of r.shape.extends)t.add(i.typeId);return t}convert({disableExamples:t}){return{version:QOh,types:this.convertNamedTypes(),headers:this.convertHeaders(),endpoints:this.convertEndpoints({disableExamples:t}),pathParameters:this.convertPathParameters({pathParameters:this.ir.pathParameters}),environments:this.ir.environments,variables:this.convertVariables(),generatorConfig:this.generatorConfig}}convertNamedTypes(){return Object.fromEntries(Object.entries(this.ir.types).map(([t,r])=>[t,this.convertTypeDeclaration(r)]))}convertHeaders(){return this.convertWireValueParameters({wireValueParameters:this.ir.headers})}convertVariables(){if(this.ir.variables.length!==0)return this.ir.variables.map(t=>({id:t.id,name:t.name,typeReference:this.convertTypeReference(t.type)}))}convertEndpoints({disableExamples:t}){let r=this.getAllHttpEndpoints();return Object.fromEntries(r.map(i=>[i.id,this.convertEndpoint({endpoint:i,disableExamples:t})]))}convertEndpoint({endpoint:t,disableExamples:r}){let i=this.convertEndpointLocation({endpoint:t});return{auth:this.auth,declaration:this.convertDeclaration({name:t.name,fernFilepath:t.fernFilepath}),location:i,request:this.convertRequest({endpoint:t}),response:t.response?.body?._visit({json:()=>er.Response.json(),streaming:()=>er.Response.streaming(),streamParameter:()=>er.Response.streamParameter(),fileDownload:()=>er.Response.fileDownload(),text:()=>er.Response.text(),bytes:()=>er.Response.bytes(),_other:()=>er.Response.json()})??er.Response.json(),examples:r?void 0:this.getEndpointSnippetRequests({endpoint:t,location:i})}}convertRequest({endpoint:t}){let r=this.convertPathParameters({pathParameters:[...t.servicePathParameters,...t.pathParameters]});if(t.sdkRequest==null&&t.requestBody==null)return er.Request.body({pathParameters:r,body:void 0});if(t.sdkRequest==null)throw new Error(`Internal error; endpoint "${t.id}" has a request body but no SDK request`);switch(t.sdkRequest.shape.type){case"justRequestBody":return er.Request.body({pathParameters:r,body:this.convertReferencedRequestBodyType({body:t.sdkRequest.shape.value})});case"wrapper":return this.convertInlinedRequest({fernFilepath:t.fernFilepath,wrapper:t.sdkRequest.shape,pathParameters:r,queryParameters:this.convertQueryParameters({queryParameters:t.queryParameters}),headers:this.convertWireValueParameters({wireValueParameters:[...t.serviceHeaders,...t.headers]}),body:t.requestBody});default:de(t.sdkRequest.shape)}}convertReferencedRequestBodyType({body:t}){switch(t.type){case"bytes":return er.ReferencedRequestBodyType.bytes();case"typeReference":return er.ReferencedRequestBodyType.typeReference(this.convertTypeReference(t.requestBodyType));default:de(t)}}convertInlinedRequest({fernFilepath:t,wrapper:r,pathParameters:i,queryParameters:n,headers:a,body:o}){return er.Request.inlined({declaration:this.convertDeclaration({name:r.wrapperName,fernFilepath:t}),pathParameters:i,queryParameters:n,headers:a,body:o!=null?this.convertInlinedRequestBody({wrapper:r,body:o}):void 0,metadata:this.convertInlinedRequestMetadata({wrapper:r})})}convertInlinedRequestMetadata({wrapper:t}){return{includePathParameters:t.includePathParameters??!1,onlyPathParameters:t.onlyPathParameters??!1}}convertInlinedRequestBody({wrapper:t,body:r}){switch(r.type){case"inlinedRequestBody":{let i=[...r.extendedProperties??[],...r.properties];return er.InlinedRequestBody.properties(this.convertBodyPropertiesToParameters({properties:i}))}case"reference":return er.InlinedRequestBody.referenced({bodyKey:t.bodyKey,bodyType:er.ReferencedRequestBodyType.typeReference(this.convertTypeReference(r.requestBodyType))});case"bytes":return er.InlinedRequestBody.referenced({bodyKey:t.bodyKey,bodyType:er.ReferencedRequestBodyType.bytes()});case"fileUpload":return this.convertFileUploadRequestBody({properties:r.properties});default:de(r)}}convertFileUploadRequestBody({properties:t}){return er.InlinedRequestBody.fileUpload({properties:this.convertFileUploadRequestBodyProperties({properties:t})})}convertFileUploadRequestBodyProperties({properties:t}){return t.map(r=>{switch(r.type){case"file":return this.convertFileUploadRequestBodyFileProperty({fileProperty:r.value});case"bodyProperty":return er.FileUploadRequestBodyProperty.bodyProperty({name:r.name,typeReference:this.convertTypeReference(r.valueType),propertyAccess:r.propertyAccess,variable:void 0});default:de(r)}})}convertFileUploadRequestBodyFileProperty({fileProperty:t}){switch(t.type){case"file":return er.FileUploadRequestBodyProperty.file(t.key);case"fileArray":return er.FileUploadRequestBodyProperty.fileArray(t.key);default:de(t)}}convertPathParameters({pathParameters:t}){return t.map(r=>({name:{name:r.name,wireValue:r.name.originalName},typeReference:this.convertTypeReference(r.valueType),propertyAccess:void 0,variable:r.variable}))}convertBodyPropertiesToParameters({properties:t}){return t.map(r=>({name:{name:r.name.name,wireValue:r.name.wireValue},typeReference:this.convertTypeReference(r.valueType),propertyAccess:r.propertyAccess,variable:void 0}))}convertWireValueParameters({wireValueParameters:t}){return t.map(r=>({name:{name:r.name.name,wireValue:r.name.wireValue},typeReference:this.convertTypeReference(r.valueType),propertyAccess:void 0,variable:void 0}))}convertQueryParameters({queryParameters:t}){let r=[];for(let i of t){let n=this.convertTypeReference(i.valueType);i.allowMultiple&&(n=er.TypeReference.list(n)),r.push({name:{name:i.name.name,wireValue:i.name.wireValue},typeReference:n,propertyAccess:void 0,variable:void 0})}return r}convertTypeReference(t){switch(t.type){case"container":return this.convertContainerType(t.container);case"named":return this.convertNamedType(t);case"primitive":return this.convertPrimitiveType(t.primitive);case"unknown":return this.convertUnknownType();default:de(t)}}convertContainerType(t){switch(t.type){case"list":return er.TypeReference.list(this.convertTypeReference(t.list));case"map":return er.TypeReference.map({key:this.convertTypeReference(t.keyType),value:this.convertTypeReference(t.valueType)});case"optional":return er.TypeReference.optional(this.convertTypeReference(t.optional));case"nullable":return er.TypeReference.nullable(this.convertTypeReference(t.nullable));case"set":return er.TypeReference.set(this.convertTypeReference(t.set));case"literal":return er.TypeReference.literal(this.convertLiteral(t.literal));default:de(t)}}convertNamedType(t){return er.TypeReference.named(t.typeId)}convertTypeDeclaration(t){let r=this.convertDeclaration(t.name);switch(t.shape.type){case"alias":return this.convertAlias({declaration:r,alias:t.shape});case"enum":return this.convertEnum({declaration:r,enum_:t.shape});case"object":return this.convertObject({declaration:r,object:t.shape,typeId:t.name.typeId});case"union":return this.convertDiscriminatedUnion({declaration:r,union:t.shape});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({declaration:r,union:t.shape});default:de(t.shape)}}convertAlias({declaration:t,alias:r}){return er.NamedType.alias({declaration:t,typeReference:this.convertTypeReference(r.aliasOf)})}convertEnum({declaration:t,enum_:r}){return er.NamedType.enum({declaration:t,values:r.values.map(i=>i.name)})}convertObject({declaration:t,object:r,typeId:i}){let a=this.extendedTypeIds.has(i)?[...r.properties,...r.extendedProperties??[]]:[...r.extendedProperties??[],...r.properties],o=r.extends.length>0?r.extends.map(c=>c.typeId):void 0;return this.convertObjectProperties({declaration:t,properties:a,extends_:o,additionalProperties:r.extraProperties})}convertObjectProperties({declaration:t,properties:r,extends_:i,additionalProperties:n}){return er.NamedType.object({declaration:t,properties:this.convertBodyPropertiesToParameters({properties:r}),extends:i,additionalProperties:n})}convertDiscriminatedUnion({declaration:t,union:r}){let i=[...this.resolveProperties(r.extends),...r.baseProperties];return er.NamedType.discriminatedUnion({declaration:t,discriminant:r.discriminant,types:Object.fromEntries(r.types.map(n=>[n.discriminantValue.wireValue,this.convertDiscriminatedUnionType({inheritedProperties:i,discriminantValue:n.discriminantValue,singleUnionTypeProperties:n.shape})]))})}convertDiscriminatedUnionType({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperties:i}){switch(i.propertiesType){case"samePropertiesAsObject":return this.convertDiscriminatedUnionTypeObject({inheritedProperties:t,discriminantValue:r,declaredTypeName:i});case"singleProperty":return this.convertDiscriminatedUnionTypeSingleProperty({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperty:i});case"noProperties":return this.convertDiscriminatedUnionTypeNoProperties({inheritedProperties:t,discriminantValue:r});default:de(i)}}convertDiscriminatedUnionTypeObject({inheritedProperties:t,discriminantValue:r,declaredTypeName:i}){return er.SingleDiscriminatedUnionType.samePropertiesAsObject({typeId:i.typeId,discriminantValue:r,properties:this.convertBodyPropertiesToParameters({properties:t})})}convertDiscriminatedUnionTypeSingleProperty({inheritedProperties:t,discriminantValue:r,singleUnionTypeProperty:i}){return er.SingleDiscriminatedUnionType.singleProperty({typeReference:this.convertTypeReference(i.type),discriminantValue:r,properties:t.length>0?this.convertBodyPropertiesToParameters({properties:t}):void 0})}convertDiscriminatedUnionTypeNoProperties({inheritedProperties:t,discriminantValue:r}){return er.SingleDiscriminatedUnionType.noProperties({discriminantValue:r,properties:t.length>0?this.convertBodyPropertiesToParameters({properties:t}):void 0})}convertUndiscriminatedUnion({declaration:t,union:r}){return er.NamedType.undiscriminatedUnion({declaration:t,types:r.members.map(i=>this.convertTypeReference(i.type))})}convertLiteral(t){switch(t.type){case"boolean":return er.LiteralType.boolean(t.boolean);case"string":return er.LiteralType.string(t.string);default:de(t)}}convertPrimitiveType(t){return er.TypeReference.primitive(t.v1)}convertUnknownType(){return er.TypeReference.unknown()}convertAuth(t){if(t.schemes[0]==null)return;let r=t.schemes[0];switch(r.type){case"basic":return er.Auth.basic(r);case"bearer":return er.Auth.bearer(r);case"header":return er.Auth.header({header:{name:r.name,typeReference:this.convertTypeReference(r.valueType),propertyAccess:void 0,variable:void 0}});case"oauth":return er.Auth.oauth({clientId:this.casingsGenerator.generateName("clientId"),clientSecret:this.casingsGenerator.generateName("clientSecret")});case"inferred":return er.Auth.inferred({parameters:this.getInferredAuthParameters(r)});default:de(r)}}getAuthValues(t){let r=t.schemes[0];if(r!=null)switch(r.type){case"bearer":return er.AuthValues.bearer({token:"<token>"});case"basic":return er.AuthValues.basic({username:"<username>",password:"<password>"});case"header":return er.AuthValues.header({value:"<value>"});case"oauth":return er.AuthValues.oauth({clientId:"<clientId>",clientSecret:"<clientSecret>"});case"inferred":return er.AuthValues.inferred({values:this.getInferredAuthValues(r)});default:de(r)}}getInferredAuthParameters(t){let r=[],i=Object.values(this.ir.services).flatMap(n=>n.endpoints).find(n=>n.id===t.tokenEndpoint.endpoint.endpointId);if(i==null)return r;for(let n of i.headers)(n.valueType.type!=="container"||n.valueType.container.type!=="literal")&&r.push({name:{name:n.name.name,wireValue:n.name.wireValue},typeReference:this.convertTypeReference(n.valueType),propertyAccess:void 0,variable:void 0});if(i.requestBody!=null){let n=this.getRequestBodyProperties(i.requestBody);for(let a of n)(a.valueType.type!=="container"||a.valueType.container.type!=="literal")&&r.push({name:{name:a.name.name,wireValue:a.name.wireValue},typeReference:this.convertTypeReference(a.valueType),propertyAccess:void 0,variable:void 0})}return r}getInferredAuthValues(t){let r={},i=Object.values(this.ir.services).flatMap(n=>n.endpoints).find(n=>n.id===t.tokenEndpoint.endpoint.endpointId);if(i==null)return r;for(let n of i.headers)(n.valueType.type!=="container"||n.valueType.container.type!=="literal")&&(r[n.name.wireValue]=n.name.wireValue);if(i.requestBody!=null){let n=this.getRequestBodyProperties(i.requestBody);for(let a of n)(a.valueType.type!=="container"||a.valueType.container.type!=="literal")&&(r[a.name.wireValue]=a.name.wireValue)}return r}getRequestBodyProperties(t){let r=[];if(t.type==="inlinedRequestBody")r.push(...t.properties);else if(t.type==="reference"){let i=t.requestBodyType;if(i.type==="named"){let n=this.ir.types[i.typeId];n!=null&&n.shape.type==="object"&&r.push(...n.shape.properties)}}return r}convertDeclaration({name:t,fernFilepath:r}){return{name:t,fernFilepath:r}}convertEndpointLocation({endpoint:t}){return{method:t.method,path:this.getFullPathForEndpoint(t)}}getAllHttpEndpoints(){return Object.values(this.ir.services).flatMap(t=>t.endpoints.map(r=>({...r,servicePathParameters:t.pathParameters,serviceHeaders:t.headers,fernFilepath:t.name.fernFilepath})))}resolveProperties(t){let r=[];for(let i of t){let n=this.resolveObjectTypeOrThrow(i.typeId);r.push(...this.resolveProperties(n.extends)),r.push(...n.properties)}return Object.values(r)}resolveObjectTypeOrThrow(t){let r=this.ir.types[t];if(r==null)throw new Error(`Internal error; type "${t}" not found`);if(r.shape.type!=="object")throw new Error(`Internal error; type "${t}" is not an object`);return r.shape}getFullPathForEndpoint(t){let r="";t.fullPath.head.length>0&&(r=(0,DAu.default)(r,t.fullPath.head));for(let i of t.fullPath.parts)r=(0,DAu.default)(r,"{"+i.pathParameter+"}"),i.tail.length>0&&(r=(0,DAu.default)(r,i.tail));return r.startsWith("/")?r:`/${r}`}getEndpointSnippetRequests({endpoint:t,location:r}){let i=[];for(let n of[...t.userSpecifiedExamples,...t.autogeneratedExamples]){let a=new Set;[...this.ir.pathParameters,...t.pathParameters].forEach(c=>{c.variable!=null&&a.add(c.name.originalName)});let o=[...n.example?.rootPathParameters??[],...n.example?.servicePathParameters??[],...n.example?.endpointPathParameters??[]].filter(c=>!a.has(c.name.originalName));i.push({id:n?.example?.id??Xme(),name:n?.example?.name?.originalName,endpoint:r,baseUrl:void 0,environment:void 0,auth:this.authValues,headers:Object.fromEntries([...n.example?.serviceHeaders??[],...n.example?.endpointHeaders??[]].map(c=>[c.name.wireValue,c.value.jsonExample])),pathParameters:Object.fromEntries(o.map(c=>[c.name.originalName,c.value.jsonExample])),queryParameters:Object.fromEntries([...n.example?.queryParameters??[]].map(c=>[c.name.wireValue,c.value.jsonExample])),requestBody:n.example?.request?.jsonExample})}return i}};function rjn({ir:e,generationLanguage:t,smartCasing:r,disableExamples:i,generatorConfig:n}){return new BAu({ir:e,generationLanguage:t,smartCasing:r,generatorConfig:n}).convert({disableExamples:i})}var L5={};$t(L5,{validateObjectExample:()=>ejn,validateTypeExample:()=>mAu,validateTypeReferenceExample:()=>dU});function UOh(e){return{errorInstanceIdKey:e.generateNameAndWireValue({wireValue:"errorInstanceId",name:"errorInstanceId"})}}var IAu=e=>{let t=Qme(e.file.fernFilepath),r=e.endpointId;return`endpoint_${t}.${r}`};function CAu({fernFilePath:e}){return e.packagePath.length===0&&e.file==null}function qAu({resolvedEndpoint:e}){return{endpointId:IAu(e),serviceId:M_.generateServiceIdFromFernFilepath(e.file.fernFilepath),subpackageId:CAu({fernFilePath:e.file.fernFilepath})?void 0:M_.generateSubpackageId(e.file.fernFilepath)}}function LOh({endpointResolver:e,propertyResolver:t,file:r,refreshTokenEndpoint:i}){let n=e.resolveEndpointOrThrow({endpoint:i.endpoint,file:r}),a;try{a=i.responseProperties.expires_in!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.expires_in}):void 0}catch{}return{endpointReference:{endpointId:IAu(n),serviceId:M_.generateServiceIdFromFernFilepath(n.file.fernFilepath),subpackageId:CAu({fernFilePath:n.file.fernFilepath})?void 0:M_.generateSubpackageId(n.file.fernFilepath)},requestProperties:{refreshToken:t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.refresh_token})},responseProperties:{accessToken:t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.access_token}),expiresIn:a,refreshToken:i.responseProperties.refresh_token!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.refresh_token}):void 0}}}function VOh({endpointResolver:e,propertyResolver:t,file:r,tokenEndpoint:i}){let n=e.resolveEndpointOrThrow({endpoint:i.endpoint,file:r}),a=typeof n.endpoint.request=="object"&&n.endpoint.request.body!=null&&typeof n.endpoint.request.body=="object"&&"properties"in n.endpoint.request.body?n.endpoint.request.body.properties??{}:{},o;try{o=i.responseProperties.expires_in!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.expires_in}):void 0}catch{}return{endpointReference:qAu({resolvedEndpoint:n}),requestProperties:{clientId:t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.client_id}),clientSecret:t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.client_secret}),scopes:i.requestProperties.scopes!=null?t.resolveRequestPropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.requestProperties.scopes}):void 0,customProperties:glB({requestBodyProperties:a,tokenEndpoint:i,file:r,propertyResolver:t})},responseProperties:{accessToken:t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.access_token}),expiresIn:o,refreshToken:i.responseProperties.refresh_token!=null?t.resolveResponsePropertyOrThrow({file:r,endpoint:i.endpoint,propertyComponents:i.responseProperties.refresh_token}):void 0}}}var glB=({requestBodyProperties:e,tokenEndpoint:t,file:r,propertyResolver:i})=>{let n=Object.keys(e).filter(a=>!t.requestProperties.client_id.includes(a)&&!t.requestProperties.client_secret.includes(a)&&(t.requestProperties.scopes==null||!t.requestProperties.scopes.includes(a)));return n.length>0?n.map(a=>i.resolveRequestPropertyOrThrow({file:r,endpoint:t.endpoint,propertyComponents:[a]})):void 0};function WOh({propertyResolver:e,endpointResolver:t,file:r,oauthScheme:i,tokenEndpoint:n,refreshTokenEndpoint:a}){let o=VOh({propertyResolver:e,endpointResolver:t,file:r,tokenEndpoint:n});if(o==null)throw new Error("Failed to convert OAuth token endpoint.");let c=a!=null?LOh({propertyResolver:e,endpointResolver:t,file:r,refreshTokenEndpoint:a}):void 0;return{clientIdEnvVar:i["client-id-env"],clientSecretEnvVar:i["client-secret-env"],tokenPrefix:i["token-prefix"],tokenHeader:i["token-header"],scopes:i.scopes,tokenEndpoint:o,refreshEndpoint:c}}var aro={requestProperties:{type:"access_token",client_id:["client_id"],client_secret:["client_secret"],scopes:void 0},responseProperties:{type:"access_token",access_token:["access_token"],expires_in:["expires_in"],refresh_token:void 0}},c2c={requestProperties:{type:"refresh_token",refresh_token:["refresh_token"]},responseProperties:{type:"access_token",access_token:["access_token"],refresh_token:void 0,expires_in:["expires_in"]}};function xOh(e){return{endpoint:e["get-token"].endpoint,requestProperties:OlB({requestProperties:e["get-token"]?.["request-properties"]}),responseProperties:mlB({responseProperties:e["get-token"]?.["response-properties"]})}}function GOh(e){if(e["refresh-token"]!=null)return{endpoint:e["refresh-token"].endpoint,requestProperties:AlB({requestProperties:e["refresh-token"]?.["request-properties"]}),responseProperties:PlB({responseProperties:e["refresh-token"]?.["response-properties"]})}}function OlB({requestProperties:e}){if(e==null)return aro.requestProperties;let t=e["client-id"],r=e["client-secret"],i=e.scopes;return{type:"access_token",client_id:t!=null?q5t(t):aro.requestProperties.client_id,client_secret:r!=null?q5t(r):aro.requestProperties.client_secret,scopes:i!=null?q5t(i):aro.requestProperties.scopes}}function mlB({responseProperties:e}){return HOh({responseProperties:e,defaultValue:aro.responseProperties})}function AlB({requestProperties:e}){if(e==null)return c2c.requestProperties;let t=e["refresh-token"];return{type:"refresh_token",refresh_token:t!=null?q5t(t):c2c.requestProperties.refresh_token}}function PlB({responseProperties:e}){return HOh({responseProperties:e,defaultValue:c2c.responseProperties})}function HOh({responseProperties:e,defaultValue:t}){if(e==null)return t;let r=e["access-token"],i=e["expires-in"],n=e["refresh-token"];return{type:"access_token",access_token:r!=null?Lme(r):t.access_token,expires_in:i!=null?Lme(i):t.expires_in,refresh_token:n!=null?Lme(n):t.refresh_token}}function YOh({rawApiFileSchema:e,file:t,propertyResolver:r,endpointResolver:i}){if(e.auth==null)return{docs:void 0,requirement:vN.All,schemes:[]};let n=typeof e.auth!="string"?e.auth.docs:void 0;return WAn(e.auth,{single:a=>{let o=l2c({reference:a,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i});return{docs:n,requirement:vN.All,schemes:[o]}},any:({any:a})=>({docs:n,requirement:vN.Any,schemes:a.map(o=>l2c({reference:o,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i}))}),endpointSecurity:()=>({docs:n,requirement:vN.EndpointSecurity,schemes:Object.keys(e["auth-schemes"]??{}).map(a=>l2c({reference:a,authSchemeDeclarations:e["auth-schemes"],file:t,propertyResolver:r,endpointResolver:i}))})})}function l2c({reference:e,authSchemeDeclarations:t,file:r,propertyResolver:i,endpointResolver:n}){let a=(c,d)=>{let s=t?.[c];if(s==null)throw new Error("Unknown auth scheme: "+c);return Hka(s,{header:u=>mP.header({key:c,docs:d,name:r.casingsGenerator.generateNameAndWireValue({name:u.name??c,wireValue:u.header}),valueType:r.parseTypeReference(u.type??"string"),prefix:u.prefix,headerEnvVar:u.env}),basic:u=>$Oh({key:c,file:r,docs:d,rawScheme:u}),tokenBearer:u=>KOh({key:c,file:r,docs:d,rawScheme:u}),inferredBearer:u=>jlB({key:c,file:r,docs:d,rawScheme:u,propertyResolver:i,endpointResolver:n}),oauth:u=>JOh({key:c,file:r,docs:d,rawScheme:u,propertyResolver:i,endpointResolver:n})})},o=typeof e=="string"?e:e.scheme;switch(o){case"bearer":return KOh({key:o,file:r,docs:void 0,rawScheme:void 0});case"basic":return $Oh({key:o,file:r,docs:void 0,rawScheme:void 0});case"oauth":return JOh({key:o,file:r,docs:void 0,rawScheme:void 0,propertyResolver:i,endpointResolver:n});default:return a(o,typeof e!="string"?e.docs:void 0)}}function KOh({key:e,file:t,docs:r,rawScheme:i}){return mP.bearer({key:e,docs:r,token:t.casingsGenerator.generateName(i?.token?.name??"token"),tokenEnvVar:i?.token?.env})}function $Oh({key:e,file:t,docs:r,rawScheme:i}){return mP.basic({key:e,docs:r,username:t.casingsGenerator.generateName(i?.username?.name??"username"),usernameEnvVar:i?.username?.env,usernameOmit:i?.username?.omit,password:t.casingsGenerator.generateName(i?.password?.name??"password"),passwordEnvVar:i?.password?.env,passwordOmit:i?.password?.omit})}function JOh({key:e,file:t,docs:r,rawScheme:i,propertyResolver:n,endpointResolver:a}){if(i?.type==="client-credentials")return mP.oauth({key:e,docs:r,configuration:$Zi.clientCredentials(WOh({propertyResolver:n,endpointResolver:a,file:t,oauthScheme:i,tokenEndpoint:xOh(i),refreshTokenEndpoint:GOh(i)}))});throw new Error(`Unknown OAuth type: '${i?.type}'`)}function jlB({key:e,file:t,docs:r,rawScheme:i,propertyResolver:n,endpointResolver:a}){return mP.inferred({key:e,docs:r,tokenEndpoint:wlB({file:t,rawScheme:i,propertyResolver:n,endpointResolver:a})})}function wlB({file:e,rawScheme:t,propertyResolver:r,endpointResolver:i}){let n=t["get-token"],a=typeof n=="string"?{endpoint:n}:n,o=i.resolveEndpointOrThrow({endpoint:a.endpoint,file:e});return{endpoint:qAu({resolvedEndpoint:o}),expiryProperty:BlB({tokenEndpoint:o,getTokenEndpointConfig:a,propertyResolver:r}),authenticatedRequestHeaders:SlB({tokenEndpoint:o,getTokenEndpointConfig:a,propertyResolver:r})}}var ElB=["access_token","accessToken","AccessToken","token","Token","auth_token","authToken","AuthToken","bearer_token","bearerToken","BearerToken","jwt","Jwt","authentication_token","authenticationToken","AuthenticationToken"];function SlB({tokenEndpoint:e,getTokenEndpointConfig:t,propertyResolver:r}){let i=new Map,n=t["authenticated-request-headers"]??[];if(n.length>0&&n.forEach(a=>{i.set(a["header-name"].toLowerCase(),{headerName:a["header-name"],responseProperty:r.resolveResponsePropertyOrThrow({file:e.file,endpoint:e.endpointId,propertyComponents:Lme(a["response-property"])}),valuePrefix:a["value-prefix"]})}),!i.has("authorization")){let a=MlB({tokenEndpoint:e,propertyResolver:r});a&&i.set("authorization",{headerName:"Authorization",responseProperty:a,valuePrefix:"Bearer "})}return Array.from(i.values())}function MlB({tokenEndpoint:e,propertyResolver:t}){for(let r of ElB)try{let i=t.resolveResponseProperty({file:e.file,endpoint:e.endpointId,propertyComponents:[r]});if(i)return i}catch{}}var DlB=["expires_in","expiresIn","ExpiresIn","exp","Exp","expiry","Expiry","expires","Expires","expires_at","expiresAt","ExpiresAt","expiration","Expiration","valid_until","validUntil","ValidUntil"];function BlB({tokenEndpoint:e,getTokenEndpointConfig:t,propertyResolver:r}){if(t["expiry-response-property"])return r.resolveResponsePropertyOrThrow({file:e.file,endpoint:e.endpointId,propertyComponents:Lme(t["expiry-response-property"])});for(let i of DlB)try{let n=r.resolveResponseProperty({file:e.file,endpoint:e.endpointId,propertyComponents:[i]});if(n)return n}catch{}}function XOh({file:e,rawApiFileSchema:t}){if(t.version!=null)return XZi.header({header:IlB({file:e,header:t.version.header}),value:ClB({file:e,versionDeclaration:t.version})})}function IlB({file:e,header:t}){return typeof t=="string"?rBe({file:e,headerKey:t,header:{type:"string"}}):rBe({file:e,headerKey:t.value,header:{type:"string",name:t.name,env:t.env}})}function ClB({file:e,versionDeclaration:t}){return AAu({_enum:{default:t.default,enum:t.values},file:e})}function ZOh({channel:e,typeResolver:t,exampleResolver:r,variableResolver:i,file:n,workspace:a}){let o=[];for(let[c,d]of Object.entries(e.messages??{}))o.push({type:c,availability:CZ(d.availability),docs:d.docs,origin:d.origin,body:RlB({body:d.body,file:n}),displayName:d["display-name"],methodName:d["method-name"]});return{availability:CZ(e.availability),path:HD(e.path),baseUrl:e.url,auth:e.auth,name:n.fernFilepath.file??n.casingsGenerator.generateName(e["display-name"]??e.path),displayName:e["display-name"],headers:e.headers!=null?Object.entries(e.headers).map(([c,d])=>rBe({headerKey:c,header:d,file:n})):[],docs:e.docs,pathParameters:e["path-parameters"]!=null?y_a({pathParameters:e["path-parameters"],location:BDe.Endpoint,file:n,variableResolver:i}):[],queryParameters:e["query-parameters"]!=null?Object.entries(e["query-parameters"]).map(([c,d])=>{let{name:s}=zWi({queryParameterKey:c,queryParameter:d}),u=n.parseTypeReference(d);return{...w5(d),name:n.casingsGenerator.generateNameAndWireValue({wireValue:c,name:s}),valueType:u,allowMultiple:typeof d!="string"&&d["allow-multiple"]!=null?d["allow-multiple"]:!1,v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}},explode:void 0}}):[],messages:Object.values(o),examples:(e.examples??[]).map(c=>{let d=NlB({channel:e,example:c,typeResolver:t,exampleResolver:r,variableResolver:i,file:n,workspace:a});return{name:c.name!=null?n.casingsGenerator.generateName(c.name):void 0,docs:c.docs,url:QlB({channel:e,example:c,pathParams:d}),...d,...FlB({channel:e,example:c,typeResolver:t,exampleResolver:r,file:n,workspace:a}),queryParameters:c["query-parameters"]!=null?Object.entries(c["query-parameters"]).map(([s,u])=>{let f=e["query-parameters"]?.[s];if(f==null)throw new Error(`Query parameter ${s} does not exist`);return{name:n.casingsGenerator.generateNameAndWireValue({name:zWi({queryParameterKey:s,queryParameter:f}).name,wireValue:s}),value:mO({example:u,rawTypeBeingExemplified:typeof f=="string"?f:f.type,typeResolver:t,exampleResolver:r,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),shape:qlB({queryParameter:f})}}):[],messages:c.messages.map(s=>{let u=e.messages?.[s.type];if(u==null)throw new Error(`Message ${s.type} does not exist`);return{type:s.type,body:TlB({message:u,example:s.body,typeResolver:t,exampleResolver:r,file:n,workspace:a})}})}}),v2Examples:{userSpecifiedExamples:{},autogeneratedExamples:{}}}}function qlB({queryParameter:e}){return(typeof e!="string"&&e["allow-multiple"]!=null?e["allow-multiple"]:!1)?gN.exploded():gN.single()}function TlB({message:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){if(!UlB(e.body))return zme.reference(mO({example:t,rawTypeBeingExemplified:typeof e.body!="string"?e.body.type:e.body,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}));if(!Wl(t))throw new Error("Example must be an object");let o=[];for(let[c,d]of Object.entries(t)){let s=e.body.properties?.[c];if(s!=null)o.push({name:n.casingsGenerator.generateNameAndWireValue({name:fU({propertyKey:c,property:s}).name,wireValue:c}),value:mO({example:d,rawTypeBeingExemplified:typeof s!="string"?s.type:s,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a}),originalTypeDeclaration:void 0});else{let u=iro({extends_:e.body.extends,wirePropertyKey:c,typeResolver:r,file:n});if(u==null)throw new Error("Could not find original type declaration for property: "+c);o.push({name:n.casingsGenerator.generateNameAndWireValue({name:fU({propertyKey:c,property:u.rawPropertyType}).name,wireValue:c}),value:mO({example:d,rawTypeBeingExemplified:typeof u.rawPropertyType=="string"?u.rawPropertyType:u.rawPropertyType.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:u.file,fileContainingExample:n,workspace:a}),originalTypeDeclaration:u.typeName})}}return zme.inlinedBody({jsonExample:i.resolveAllReferencesInExampleOrThrow({example:t,file:n}).resolvedExample,properties:o,extraProperties:void 0})}function RlB({body:e,file:t}){return typeof e=="string"||zlB(e)?E3.reference({docs:void 0,bodyType:t.parseTypeReference(e)}):E3.inlinedBody({name:t.casingsGenerator.generateName(e.name),extends:C5t(e.extends??[]).map(r=>lU({typeName:r,file:t})),properties:Object.entries(e.properties??{}).map(([r,i])=>({name:t.casingsGenerator.generateNameAndWireValue({name:fU({propertyKey:r,property:i}).name,wireValue:r}),value:t.parseTypeReference(i),valueType:t.parseTypeReference(i),availability:void 0,docs:void 0}))})}function zlB(e){return e.type!=null}function NlB({channel:e,example:t,typeResolver:r,exampleResolver:i,variableResolver:n,file:a,workspace:o}){let c=[],d=({name:s,pathParameterDeclaration:u,examplePathParameter:f})=>{let p=nro({parameter:u,variableResolver:n,file:a});return{name:s,value:mO({example:f,rawTypeBeingExemplified:p.rawType,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:p.file,fileContainingExample:a,workspace:o})}};if(t["path-parameters"]!=null){let s=T5t(e);for(let[u,f]of Object.entries(t["path-parameters"])){let p=s[u];if(p!=null)c.push(d({name:a.casingsGenerator.generateName(u),pathParameterDeclaration:p,examplePathParameter:f}));else throw new Error(`Path parameter ${u} does not exist`)}}return{pathParameters:c}}function FlB({channel:e,example:t,typeResolver:r,exampleResolver:i,file:n,workspace:a}){let o=[];if(t.headers!=null)for(let[c,d]of Object.entries(t.headers)){let s=e.headers?.[c];s!=null&&o.push({name:n.casingsGenerator.generateNameAndWireValue({name:jkt({headerKey:c,header:s}).name,wireValue:c}),value:mO({example:d,rawTypeBeingExemplified:typeof s=="string"?s:s.type,typeResolver:r,exampleResolver:i,fileContainingRawTypeReference:n,fileContainingExample:n,workspace:a})})}return{headers:o}}function QlB({channel:e,example:t,pathParams:r}){let i=e.path;if(t["path-parameters"]!=null)for(let n of[...r.pathParameters])i=i.replaceAll(`{${n.name.originalName}}`,encodeURIComponent(`${n.value.jsonExample}`));return i}function UlB(e){return typeof e=="string"?!1:e.extends!=null||e.properties!=null}function kOh({errorName:e,errorDeclaration:t,file:r,typeResolver:i,exampleResolver:n,workspace:a}){let o=[];if(t.type!=null&&t.examples!=null)for(let c of t.examples)o.push({name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,docs:c.docs,jsonExample:n.resolveAllReferencesInExampleOrThrow({example:c.value,file:r}).resolvedExample,shape:mO({example:c.value,rawTypeBeingExemplified:t.type,fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})});return{name:b2i({errorName:e,file:r}),discriminantValue:r.casingsGenerator.generateNameAndWireValue({wireValue:e,name:e}),docs:typeof t!="string"?t.docs:void 0,statusCode:t["status-code"],isWildcardStatusCode:void 0,type:t.type!=null?r.parseTypeReference(t.type):void 0,examples:o,v2Examples:void 0,displayName:void 0,headers:[]}}var emh="content";function tmh(e,t){if(e==null||e.strategy==="status-code")return Rme.statusCode();if(e.strategy==="property")return Rme.property({discriminant:t.casingsGenerator.generateNameAndWireValue({name:e["property-name"],wireValue:e["property-name"]}),contentProperty:t.casingsGenerator.generateNameAndWireValue({name:emh,wireValue:emh})});de(e)}var TAu=se(bO(),1);function rmh({readme:e,services:t}){let r=new f2c(t);return{apiName:e.apiName,disabledFeatures:e.disabledSections?.map(i=>i.toUpperCase()),apiReferenceLink:e.apiReferenceLink,bannerLink:e.bannerLink,introduction:e.introduction,customSections:e.customSections,exampleStyle:e.exampleStyle,whiteLabel:!1,defaultEndpoint:e.defaultEndpoint!=null?r.getEndpointForReadmeOrThrow(e.defaultEndpoint).id:void 0,features:e.features!=null?Object.fromEntries(Object.entries(e.features).map(([i,n])=>[i,n.map(a=>r.getEndpointForReadmeOrThrow(a).id)])):void 0}}var f2c=class{endpoints={};constructor(t){this.endpoints=this.buildEndpoints(t)}getEndpointForReadme(t){let r=VlB({endpoint:t}),i=this.getEndpointKeyForReadmeEndpoint(r);return this.endpoints[i]}getEndpointForReadmeOrThrow(t){let r=this.getEndpointForReadme(t);if(r==null)throw new Error(`Endpoint not found for ${JSON.stringify(t)}`);return r}buildEndpoints(t){let r={};for(let i of Object.values(t))for(let n of i.endpoints)r[this.getEndpointKeyForHttpEndpoint(n)]=n;return r}getEndpointKeyForReadmeEndpoint(t){return this.getEndpointKey({method:t.method,path:t.path,stream:t.stream??!1})}getEndpointKeyForHttpEndpoint(t){return this.getEndpointKey({method:t.method,path:LlB(t),stream:t.response?.body?.type==="streaming"})}getEndpointKey({method:t,path:r,stream:i}){return`${t}|${r}|${i}`}};function LlB(e){let t="";e.fullPath.head.length>0&&(t=(0,TAu.default)(t,e.fullPath.head));for(let r of e.fullPath.parts)t=(0,TAu.default)(t,"{"+r.pathParameter+"}"),r.tail.length>0&&(t=(0,TAu.default)(t,r.tail));return t.startsWith("/")?t:`/${t}`}function VlB({endpoint:e}){if(typeof e=="string"){let t=e.split(" ");if(t.length!==2||t[0]==null||t[1]==null)throw new Error(`invalid endpoint string: ${e}`);return{method:t[0],path:t[1]}}return e}function imh({webhooks:e,file:t,typeResolver:r,exampleResolver:i,workspace:n}){let a=[];for(let[o,c]of Object.entries(e))a.push({id:M_.generateWebhookId(t.fernFilepath,o),availability:CZ(c.availability),displayName:c["display-name"],docs:c.docs,method:c.method,name:t.casingsGenerator.generateName(o),headers:c.headers!=null?Object.entries(c.headers).map(([d,s])=>rBe({headerKey:d,header:s,file:t})):[],payload:WlB({payload:c.payload,file:t}),fileUploadPayload:void 0,responses:HlB({webhook:c,file:t,typeResolver:r}),examples:c.examples!=null?GlB({webhook:c,examples:c.examples,file:t,typeResolver:r,exampleResolver:i,workspace:n}):void 0,v2Examples:void 0});return a}function WlB({payload:e,file:t}){return typeof e=="string"?nU.reference({docs:void 0,payloadType:t.parseTypeReference(e)}):rda(e)?nU.reference({docs:void 0,payloadType:t.parseTypeReference(e.type)}):nU.inlinedPayload({name:t.casingsGenerator.generateName(e.name),extends:C5t(e.extends).map(r=>lU({typeName:r,file:t})),properties:e.properties!=null?Object.entries(e.properties).map(([r,i])=>xlB({propertyKey:r,propertyDefinition:i,docs:typeof i!="string"?i.docs:void 0,availability:typeof i!="string"?CZ(i.availability):void 0,file:t})):[]})}function xlB({propertyKey:e,propertyDefinition:t,docs:r,availability:i,file:n}){return{docs:r,availability:i,name:n.casingsGenerator.generateNameAndWireValue({wireValue:e,name:fU({propertyKey:e,property:t}).name}),valueType:n.parseTypeReference(t)}}function GlB({webhook:e,examples:t,file:r,typeResolver:i,exampleResolver:n,workspace:a}){let o=typeof e.payload=="string"?e.payload:rda(e.payload)?e.payload.type:void 0;if(o!=null)return t.map(c=>({docs:e.docs,name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,payload:mO({example:c.payload,rawTypeBeingExemplified:o,fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})}));if(!Wl(e.payload))throw new Error(`Example webhook payload is not an object. Got: ${JSON.stringify(e.payload)}`);return t.map(c=>({docs:e.docs,name:c.name!=null?r.casingsGenerator.generateName(c.name):void 0,payload:mO({example:c.payload,rawTypeBeingExemplified:"map<string, unknown>",fileContainingRawTypeReference:r,fileContainingExample:r,typeResolver:i,exampleResolver:n,workspace:a})}))}function HlB({webhook:e,file:t,typeResolver:r}){let i=[];if(e.response!=null){let n=KlB({response:e.response,file:t,typeResolver:r}),a=typeof e.response!="string"?e.response["status-code"]:void 0,o=typeof e.response!="string"?e.response.docs:void 0;i.push({body:n,statusCode:a,isWildcardStatusCode:void 0,docs:o})}if(e["response-stream"]!=null){let n=$lB({responseStream:e["response-stream"],file:t,typeResolver:r});if(n!=null){let a=typeof e["response-stream"]!="string"?e["response-stream"].docs:void 0;i.push({body:op.streaming(n),statusCode:void 0,isWildcardStatusCode:void 0,docs:a})}}return i.length>0?i:void 0}function KlB({response:e,file:t,typeResolver:r}){let i=typeof e!="string"?e.docs:void 0,n=typeof e=="string"?e:e.type;if(n!=null)return BZ(n)!=null?op.fileDownload({docs:i,v2Examples:void 0}):LAn(n)!=null?op.text({docs:i,v2Examples:void 0}):FDe(n)!=null?op.bytes({docs:i,v2Examples:void 0}):JlB(e,i,t,r)}function $lB({responseStream:e,file:t,typeResolver:r}){let i=typeof e!="string"?e.docs:void 0,n=typeof e=="string"?e:e.type,a=typeof e=="string"?"json":e.format??"json";return KZi(n)?qC.text({docs:i,v2Examples:void 0}):typeof e!="string"&&a==="sse"?qC.sse({docs:i,payload:t.parseTypeReference(n),terminator:typeof e!="string"?e.terminator:void 0,v2Examples:void 0}):qC.json({docs:i,payload:t.parseTypeReference(n),terminator:typeof e!="string"?e.terminator:void 0,v2Examples:void 0})}function JlB(e,t,r,i){let n=typeof e!="string"?e.type:e;if(n==null)return;let a=r.parseTypeReference(typeof e=="string"?e:{...e,type:n}),o=i.resolveTypeOrThrow({type:n,file:r}),c=typeof e!="string"?e.property:void 0;return c!=null?op.json(Nq.nestedPropertyAsResponse({docs:t,responseBodyType:a,responseProperty:JAn({typeResolver:i,file:r,resolvedType:o,property:c}),v2Examples:void 0})):op.json(Nq.response({docs:t,responseBodyType:a,v2Examples:void 0}))}function nmh({name:e,source:t}){return rb.userDefined({file:jAu({source:t}),name:tro.generateName(e)})}function amh({encoding:e}){if(e.proto!=null&&e.proto.type!=null){let t=YlB({type:e.proto.type});if(t!=null)return t}}function YlB({type:e}){switch(e){case"google.protobuf.Any":return rb.wellKnown(In.any());case"google.protobuf.Api":return rb.wellKnown(In.api());case"google.protobuf.BoolValue":return rb.wellKnown(In.boolValue());case"google.protobuf.BytesValue":return rb.wellKnown(In.bytesValue());case"google.protobuf.DoubleValue":return rb.wellKnown(In.doubleValue());case"google.protobuf.Duration":return rb.wellKnown(In.duration());case"google.protobuf.Empty":return rb.wellKnown(In.empty());case"google.protobuf.Enum":return rb.wellKnown(In.enum());case"google.protobuf.EnumValue":return rb.wellKnown(In.enumValue());case"google.protobuf.Field":return rb.wellKnown(In.field());case"google.protobuf.FieldCardinality":return rb.wellKnown(In.fieldCardinality());case"google.protobuf.FieldKind":return rb.wellKnown(In.fieldKind());case"google.protobuf.FieldMask":return rb.wellKnown(In.fieldMask());case"google.protobuf.FloatVlaue":return rb.wellKnown(In.floatValue());case"google.protobuf.Int32Value":return rb.wellKnown(In.int32Value());case"google.protobuf.Int64Value":return rb.wellKnown(In.int64Value());case"google.protobuf.ListValue":return rb.wellKnown(In.listValue());case"google.protobuf.Method":return rb.wellKnown(In.method());case"google.protobuf.Mixin":return rb.wellKnown(In.mixin());case"google.protobuf.NullValue":return rb.wellKnown(In.nullValue());case"google.protobuf.Option":return rb.wellKnown(In.option());case"google.protobuf.SourceContext":return rb.wellKnown(In.sourceContext());case"google.protobuf.StringValue":return rb.wellKnown(In.stringValue());case"google.protobuf.Struct":return rb.wellKnown(In.struct());case"google.protobuf.Syntax":return rb.wellKnown(In.syntax());case"google.protobuf.Timestamp":return rb.wellKnown(In.timestamp());case"google.protobuf.Type":return rb.wellKnown(In.type());case"google.protobuf.Uint32Value":return rb.wellKnown(In.uint32Value());case"google.protobuf.Uint64Value":return rb.wellKnown(In.uint64Value());case"google.protobuf.Value":return rb.wellKnown(In.value())}}function omh({generic:e,file:t,typeResolver:r}){let i=typeof e=="string"?e:e.type,n=HB(i);if(n==null)throw new Error(`Invalid generic type definition: ${i}`);let a=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:i,file:t});if(n.arguments&&Gv(a.declaration)){let o=HB(a.typeName)?.arguments??[],c=Object.entries(a.declaration.properties??{}).map(([d,s])=>{let u=s;return typeof s=="string"&&o?.includes(s)&&(u=n.arguments?.[o.indexOf(s)]??s),[d,u]});return Jl.object({extends:C5t(a.declaration.extends).map(d=>lU({typeName:d,file:t})),properties:Zka({properties:Object.fromEntries(c)},t),extraProperties:a.declaration["extra-properties"]??!1,extendedProperties:void 0})}throw new Error(`Generic type definition not supported: ${i}`)}function umh({alias:e,file:t,typeResolver:r}){let i=typeof e=="string"?e:e.type;return MDe(i)?omh({generic:i,file:t,typeResolver:r}):Jl.alias({aliasOf:t.parseTypeReference(e),resolvedType:XlB({aliasOf:i,file:t,typeResolver:r})})}function XlB({aliasOf:e,file:t,typeResolver:r}){let i=r.resolveTypeOrThrow({type:e,file:t});switch(i._type){case"primitive":return w3.primitive(i.originalTypeReference.primitive);case"container":return w3.container(i.originalTypeReference.container);case"unknown":return w3.unknown();case"named":{let n=Gv(i.declaration)?M5t.Object:p2i(i.declaration)?M5t.Union:I5t(i.declaration)?M5t.Enum:Xfa(i.declaration)?M5t.UndiscriminatedUnion:de(i.declaration);return w3.named({name:i.name,shape:n})}}}function smh({union:e,file:t}){let r=e.union.filter((i,n)=>{let a=typeof i=="string"?i:i.type;return e.union.findIndex(o=>(typeof o=="string"?o:o.type)===a)===n});return Jl.undiscriminatedUnion({members:r.map(i=>{let n=t.parseTypeReference(typeof i=="string"?i:i.type);return{type:n.type==="named"?{...n,displayName:typeof i=="string"?G6o(n.name.originalName):i["display-name"]??G6o(n.name.originalName)}:n,docs:typeof i=="string"?void 0:i.docs}})})}function cmh(e){let t=[];if(e.extends!=null){let r=typeof e.extends=="string"?[e.extends]:e.extends;t.push(...r)}return e.properties!=null&&t.push(...Object.values(e.properties).map(r=>typeof r=="string"?r:r.type)),t}function p2c({typeDeclaration:e,file:t,typeResolver:r,seenTypeNames:i=new d2c}){let n=Lq(e,{alias:o=>{let c=typeof o=="string"?o:o.type,d=HB(c);if(d!=null){let s=new Set(d.arguments??[]),u=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:c,file:t}),f=HB(u.typeName)?.arguments;if(Gv(u.declaration)){let p=cmh(u.declaration);f&&p.filter(_=>!f.includes(_)).forEach(_=>s.add(_))}return Array.from(s)}return[c]},object:o=>cmh(o),discriminatedUnion:o=>{let c=[];return o["base-properties"]!=null&&c.push(...Object.values(o["base-properties"]).map(d=>typeof d=="string"?d:d.type)),c.push(...Object.values(o.union).reduce((d,s)=>{let u=typeof s=="string"?s:s.type;return typeof u=="string"&&d.push(u),d},[])),c},undiscriminatedUnion:o=>Object.values(o.union).reduce((c,d)=>{let s=typeof d=="string"?d:d.type;return typeof s=="string"&&c.push(s),c},[]),enum:()=>[]}),a=[];for(let o of n){let c=Uq({type:o,_default:void 0,validation:void 0,visitor:{primitive:()=>[],map:({keyType:d,valueType:s})=>[...d,...s],list:d=>d,optional:d=>d,nullable:d=>d,set:d=>d,named:d=>[d],literal:()=>[],unknown:()=>[]}});for(let d of c){let s=lU({typeName:d,file:t});if(!i.hasTypeNameBeenSeen(s)){i.addTypeName(s),a.push(s);let u=r.getDeclarationOfNamedTypeOrThrow({referenceToNamedType:d,file:t});if(MDe(u.typeName))continue;a.push(...p2c({typeDeclaration:u.declaration,file:u.file,typeResolver:r,seenTypeNames:i}))}}}return a}var d2c=class{cache=new Set;addTypeName(t){this.cache.add(this.computeCacheKey(t))}hasTypeNameBeenSeen(t){return this.cache.has(this.computeCacheKey(t))}computeCacheKey(t){return t.fernFilepath.allParts.map(r=>r.originalName).join("/")+":"+t.name.originalName}};function lmh({typeName:e,typeDeclaration:t,file:r,typeResolver:i,exampleResolver:n,sourceResolver:a,workspace:o}){let c=w5(t),d=lU({typeName:e,file:r}),s=p2c({typeDeclaration:t,file:r,typeResolver:i}),u={};Gv(t)&&(u=HAn(t.properties??{}));let f=klB({file:r,typeDeclaration:t,typeName:e,sourceResolver:a});return{propertiesByAudience:u,typeDeclaration:{...c,inline:ifB(t),name:d,shape:ZlB({typeDeclaration:t,file:r,typeResolver:i}),referencedTypes:new Set(s.map(p=>p.typeId)),encoding:efB({typeDeclaration:t,source:f}),source:f,userProvidedExamples:typeof t!="string"&&t.examples!=null?t.examples.map(p=>({name:p.name!=null?r.casingsGenerator.generateName(p.name):void 0,docs:p.docs,jsonExample:n.resolveAllReferencesInExampleOrThrow({example:p.value,file:r}).resolvedExample,shape:a2c({typeName:d,example:p.value,typeResolver:i,exampleResolver:n,typeDeclaration:t,fileContainingType:r,fileContainingExample:r,workspace:o})})):[],autogeneratedExamples:[],v2Examples:void 0},descendantFilepaths:new Set(s.map(p=>p.fernFilepath))}}function ZlB({typeDeclaration:e,file:t,typeResolver:r}){return Lq(e,{alias:i=>umh({alias:i,file:t,typeResolver:r}),object:i=>Wrh({object:i,file:t}),discriminatedUnion:i=>iOh({union:i,file:t,typeResolver:r}),undiscriminatedUnion:i=>smh({union:i,file:t}),enum:i=>Jl.enum(AAu({_enum:i,file:t}))})}function klB({file:e,typeDeclaration:t,typeName:r,sourceResolver:i}){if(typeof t=="string"||t.source==null&&t.encoding==null)return;if(t.encoding!=null){let a=amh({encoding:t.encoding});if(a!=null)return eWi.proto(a)}if(t.source==null)return;let n=i.resolveSourceOrThrow({source:t.source,relativeFilepath:e.relativeFilepath});if(!(n==null||n.type!=="protobuf"))return eWi.proto(nmh({source:n,name:r}))}function efB({typeDeclaration:e,source:t}){return typeof e!="string"&&e.encoding!=null?tfB(e.encoding):rfB(t)}function tfB(e){return e.proto!=null?{json:void 0,proto:{}}:{json:{},proto:void 0}}function rfB(e){return e!=null&&e.type==="proto"?{json:void 0,proto:{}}:{json:{},proto:void 0}}function ifB(e){if(typeof e!="string"&&"inline"in e)return e.inline}function fmh(e,t){let r=t[e];if(r==null)throw new F3i(`Illegal Error: Failed to load type declaration for type ${e}`);return r}function dmh(e){e.types=Object.fromEntries(Object.entries(e.types).map(([t,r])=>[t,afB({typeDeclaration:r,ir:e})])),e.services=Object.fromEntries(Object.entries(e.services).map(([t,r])=>[t,{...r,endpoints:r.endpoints.map(i=>nfB({endpoint:i,ir:e}))}]))}function nfB({endpoint:e,ir:t}){return e.requestBody?.type!=="inlinedRequestBody"?e:{...e,requestBody:{...e.requestBody,extendedProperties:e.requestBody.extends.flatMap(r=>pmh(r,t))}}}function afB({typeDeclaration:e,ir:t}){return e.shape.type==="object"?{...e,shape:{...e.shape,extendedProperties:e.shape.extends.flatMap(r=>pmh(r,t))}}:e}function pmh(e,t){let r=_2c(e.typeId,t);return _mh({objectTypeDeclaration:r,ir:t})}function _2c(e,t){let r=fmh(e,t.types);switch(r.shape.type){case"object":return r.shape;case"alias":if(r.shape.resolvedType.type==="named")return _2c(r.shape.resolvedType.name.typeId,t)}throw new F3i(`Unexpected error: ${e} is extended but has shape ${r.shape.type}`)}function _mh({objectTypeDeclaration:e,ir:t}){let r=e.extends.flatMap(i=>{let n=_2c(i.typeId,t);return _mh({objectTypeDeclaration:n,ir:t})});return[...e.properties,...r]}var RAu=class{subpackages={};rootPackage={docs:void 0,fernFilepath:{allParts:[],packagePath:[],file:void 0},websocket:void 0,service:void 0,types:[],errors:[],subpackages:[],webhooks:void 0,navigationConfig:void 0};addPackageRedirection({from:t,to:r}){let i=this.getPackageForFernFilepath(t);if(i.navigationConfig!=null)throw new Error("Found duplicate navigationConfig for package");i.navigationConfig={pointsTo:M_.generateSubpackageId(r)}}addDocs(t,r){let i=this.getPackageForFernFilepath(t);if(i.docs!=null)throw new Error("Found duplicate docs for package");i.docs=r}addSubpackage(t){this.getPackageForFernFilepath(t)}addType(t,r){this.getPackageForFernFilepath(r.name.fernFilepath).types.push(t)}addError(t,r){this.getPackageForFernFilepath(r.name.fernFilepath).errors.push(t)}addService(t,r){let i=this.getPackageForFernFilepath(r.name.fernFilepath);if(i.service!=null)throw new Error("Found duplicate service for "+t);i.service=t}addWebhookGroup(t,r){let i=this.getPackageForFernFilepath(r);if(i.webhooks!=null)throw new Error("Found duplicate webhook group for "+t);i.webhooks=t}addWebSocketChannel(t,r){let i=this.getPackageForFernFilepath(r);if(i.webhooks!=null)throw new Error("Found duplicate webhook group for "+t);i.websocket=t}build(t){t!=null&&(Object.entries(this.subpackages).forEach(([i,n])=>{t.hasSubpackageId(i)?this.subpackages[i]={...n,types:n.types.filter(a=>t.hasTypeId(a)),errors:n.errors.filter(a=>t.hasErrorId(a)),service:n.service!=null&&t.hasServiceId(n.service)?n.service:void 0,websocket:n.websocket!=null&&t.hasChannel(n.websocket)?n.websocket:void 0,subpackages:n.subpackages.filter(a=>t.hasSubpackageId(a))}:delete this.subpackages[i]}),this.rootPackage={...this.rootPackage,types:this.rootPackage.types.filter(i=>t.hasTypeId(i)),errors:this.rootPackage.errors.filter(i=>t.hasErrorId(i)),service:this.rootPackage.service!=null&&t.hasServiceId(this.rootPackage.service)?this.rootPackage.service:void 0,subpackages:this.rootPackage.subpackages.filter(i=>t.hasSubpackageId(i)),webhooks:this.rootPackage.webhooks!=null?this.rootPackage.webhooks:void 0});let r=new Set(this.getAllChildrenWithEndpoints(this.rootPackage));return{subpackages:gn(this.subpackages,(i,n)=>({...i,hasEndpointsInTree:r.has(n)})),rootPackage:{...this.rootPackage,hasEndpointsInTree:r.size>0||this.rootPackage.service!=null}}}sortRootPackage(t){if(!hmh(this.rootPackage.subpackages,t))throw new Error("Sorted subpackages differ from unsorted packages in root");this.rootPackage.subpackages=t}sortSubpackage(t,r){let i=this.subpackages[t];if(i==null)throw new Error("Subpackage does not exist: "+t);if(!hmh(i.subpackages,r))throw new Error("Sorted subpackages differ from unsorted packages");i.subpackages=r}getAllSubpackagesWithEndpoints(t){let r=this.subpackages[t];if(r==null)throw new Error("Subpackage does not exist: "+t);let i=this.getAllChildrenWithEndpoints(r);return(i.length>0||r.service!=null)&&i.push(t),i}getAllChildrenWithEndpoints(t){return t.subpackages.flatMap(r=>[...this.getAllSubpackagesWithEndpoints(r)])}getPackageForFernFilepath(t,r=0,i=this.rootPackage){let n=t.allParts[r];if(n==null)return i;let a=i.subpackages.map(s=>{let u=this.subpackages[s];if(u==null)throw new Error("Subpackage ID is invalid: "+s);return u}),o=r+1,c={allParts:t.allParts.slice(0,o),packagePath:t.packagePath.slice(0,o),file:o===t.allParts.length?t.file:void 0},d=a.find(s=>s.name.originalName===n.originalName);if(d==null){let s=M_.generateSubpackageId(c),u={docs:void 0,fernFilepath:c,name:n,displayName:void 0,service:void 0,types:[],errors:[],subpackages:[],navigationConfig:void 0,webhooks:void 0,websocket:void 0};this.subpackages[s]=u,i.subpackages.push(s),d=u}return this.getPackageForFernFilepath(t,o,d)}};function hmh(e,t){if(e.length!==t.length)return!1;let r=new Set(e);for(let i of t)if(!r.has(i))return!1;return!0}function ymh({reference:e,referencedIn:t,imports:r}){let[i,n,...a]=e.split(".");if(i==null||a.length>0)return;if(n==null)return{endpointName:i,relativeFilepath:t};let c=r[i];if(c!=null)return{endpointName:n,relativeFilepath:y2i({referencedIn:t,importPath:c})}}var ijn=class{workspace;constructor(t){this.workspace=t}resolveEndpointOrThrow({endpoint:t,file:r}){let i=this.resolveEndpoint({endpoint:t,file:r});if(i==null)throw new Error("Cannot resolve endpoint: "+t+" in file "+r.relativeFilepath);return i}resolveEndpointByMethodAndPath({method:t,path:r,casingsGenerator:i}){let n;return Gq(this.workspace,(a,o,c)=>{let d=ud({relativeFilepath:a,definitionFile:o,casingsGenerator:i,rootApiFile:this.workspace.definition.rootApiFile.contents,defaultUrl:c.defaultUrl});for(let[s,u]of Object.entries(o.service?.endpoints??{}))u.method===t&&u.path===r&&(n={endpointId:s,endpoint:u,file:d})}),kPn(this.workspace,(a,o)=>{let c=ud({relativeFilepath:a,definitionFile:o,casingsGenerator:i,rootApiFile:this.workspace.definition.rootApiFile.contents});for(let[d,s]of Object.entries(o.service?.endpoints??{}))s.method===t&&s.path===r&&(n={endpointId:d,endpoint:s,file:c})}),n}resolveEndpoint({endpoint:t,file:r}){let n=new k3i().tryParse(t);if(n!=null)return this.resolveEndpointByMethodAndPath({...n,casingsGenerator:r.casingsGenerator});let a=this.getDeclarationOfEndpoint({referenceToEndpoint:t,file:r});if(a==null)return;let o=a.file.definitionFile.service?.endpoints?.[a.endpointName];if(o!=null)return{endpointId:a.endpointName,endpoint:o,file:a.file}}getDeclarationOfEndpoint({referenceToEndpoint:t,file:r}){let i=ymh({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=eBe(this.workspace,i.relativeFilepath);if(!(n==null||n.service?.endpoints?.[i.endpointName]==null))return{endpointName:i.endpointName,file:ud({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}};var njn=class{workspace;constructor(t){this.workspace=t}getDeclarationOrThrow(t,r){let i=this.getDeclaration(t,r);if(i==null)throw new Error("Error does not exist: "+t);return i}getDeclaration(t,r){let i=Ume({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=eBe(this.workspace,i.relativeFilepath);if(n==null)return;let a=n.errors?.[i.typeName];if(a!=null)return{declaration:a,file:ud({definitionFile:n,relativeFilepath:i.relativeFilepath,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}};var Zme=class{typeResolver;constructor(t){this.typeResolver=t}resolveAllReferencesInExample({example:t,file:r}){if(typeof t=="string"){let i=this.resolveExample({example:t,file:r});return i==null?i:typeof i.resolvedExample=="string"?(i.resolvedExample.startsWith(`\\${"$"}`)&&(i.resolvedExample=i.resolvedExample.slice(1)),i):this.resolveAllReferencesInExample({example:i.resolvedExample,file:i.file})}else if(Wl(t)){let i={};for(let[n,a]of Object.entries(t)){let o=this.resolveAllReferencesInExample({example:a,file:r});if(o==null)return;i[n]=o.resolvedExample}return{resolvedExample:i}}else if(Array.isArray(t)){let i=[];for(let n of t){let a=this.resolveAllReferencesInExample({example:n,file:r});if(a==null)return;i.push(a.resolvedExample)}return{resolvedExample:i}}return{resolvedExample:t}}resolveAllReferencesInExampleOrThrow({example:t,file:r}){let i=this.resolveAllReferencesInExample({example:t,file:r});if(i==null)throw new Error("Failed to resolve examples");return i}resolveExample({example:t,file:r}){return typeof t!="string"?{resolvedExample:t,file:r}:t.startsWith("$")?this.parseExampleReference(t)==null?{resolvedExample:t,file:r}:this.resolveExampleReference(t,r):{resolvedExample:t,file:r}}resolveExampleReference(t,r){let i=this.parseExampleReference(t);if(i==null)return;let n=this.typeResolver.getDeclarationOfNamedType({referenceToNamedType:i.rawTypeReference,file:r});if(n==null||typeof n.declaration=="string"||n.declaration.examples==null)return;let a=n.declaration.examples.find(o=>o.name===i.exampleName);if(a!=null)return this.resolveExample({example:a.value,file:n.file})}resolveExampleOrThrow({example:t,file:r}){let i=this.resolveExample({example:t,file:r});if(i==null)throw new Error("Cannot resolve example: "+t);return i}parseExampleReference(t){let[r,i,n,...a]=t.split(".");if(r==null||i==null||a.length>0)return;if(n==null){let c=r.slice("$".length);return h2c(c)?{rawTypeReference:c,exampleName:i}:void 0}let o=r.slice("$".length);if(!(!h2c(o)||!h2c(i)))return{rawTypeReference:`${o}.${i}`,exampleName:n}}};function h2c(e){if(e.length===0)return!1;let t=e.charAt(0);return t>="a"&&t<="z"||t>="A"&&t<="Z"}var zAu=class{typeResolver;endpointResolver;constructor(t,r){this.typeResolver=t,this.endpointResolver=r,this.typeResolver=t,this.endpointResolver=r}resolveRequestPropertyOrThrow({file:t,endpoint:r,propertyComponents:i}){let n=this.resolveRequestProperty({file:t,endpoint:r,propertyComponents:i});if(n==null)throw new Error("Cannot resolve request property from endpoint: "+r+" in file "+t.relativeFilepath);return n}resolveRequestProperty({file:t,endpoint:r,propertyComponents:i}){let n=this.endpointResolver.resolveEndpointOrThrow({endpoint:r,file:t});if(n.endpoint.request==null)return;if(typeof n.endpoint.request!="string")return this.resolveRequestPropertyFromInlinedRequest({typeResolver:this.typeResolver,file:n.file,requestType:n.endpoint.request,propertyComponents:i});let a=this.typeResolver.resolveTypeOrThrow({type:n.endpoint.request,file:n.file}),o=this.resolveObjectProperty({file:n.file,resolvedType:a,propertyComponents:i});if(o!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:i,file:t,resolvedType:a}),property:SZ.body(o)}}resolveResponsePropertyOrThrow({file:t,endpoint:r,propertyComponents:i}){let n=this.resolveResponseProperty({file:t,endpoint:r,propertyComponents:i});if(n==null)throw new Error("Cannot resolve response property from endpoint: "+r+" in file "+t.relativeFilepath);return n}resolveResponseProperty({file:t,endpoint:r,propertyComponents:i}){let n=this.endpointResolver.resolveEndpointOrThrow({endpoint:r,file:t}),a=this.typeResolver.resolveTypeOrThrow({type:(typeof n.endpoint.response!="string"?n.endpoint.response?.type:n.endpoint.response)??"",file:n.file}),o=this.resolveObjectProperty({file:n.file,resolvedType:a,propertyComponents:i});if(o!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:i,resolvedType:a,file:t}),property:o}}resolveRequestPropertyFromInlinedRequest({typeResolver:t,file:r,requestType:i,propertyComponents:n}){if(n.length===1){let a=n[0]??"",o=i["query-parameters"]?.[a]??void 0;if(o!=null)return{property:SZ.query(PAu({file:r,queryParameterKey:a,queryParameter:o})),propertyPath:void 0}}return this.resolveRequestPropertyFromInlinedRequestBody({typeResolver:t,file:r,requestType:i,propertyComponents:n})}resolveRequestPropertyFromInlinedRequestBody({typeResolver:t,file:r,requestType:i,propertyComponents:n}){if(i.body==null)return;if(typeof i.body=="string"){let c=t.resolveTypeOrThrow({type:i.body,file:r}),d=this.resolveObjectProperty({file:r,resolvedType:c,propertyComponents:n});return d==null?void 0:{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r,resolvedType:c}),property:SZ.body(d)}}if(AE(i.body)){let c=J_u({typeResolver:t,file:r,objectSchema:i.body,propertyComponents:n});return c==null?void 0:{propertyPath:this.propertyPathFromPropertyComponentsFromInlineRequestBody({propertyComponents:n,file:r,body:i.body}),property:SZ.body(c)}}let a=t.resolveTypeOrThrow({type:i.body.type,file:r}),o=$_u({typeResolver:t,file:nda(a)??r,resolvedType:a,propertyComponents:n});if(o!=null)return{propertyPath:this.propertyPathFromPropertyComponents({propertyComponents:n,file:r,resolvedType:a}),property:SZ.body(o)}}resolveObjectProperty({file:t,resolvedType:r,propertyComponents:i}){return $_u({typeResolver:this.typeResolver,file:nda(r)??t,resolvedType:r,propertyComponents:i})}propertyPathFromPropertyComponents({propertyComponents:t,file:r,resolvedType:i}){if(t.length<=1)return[];let n=ajn(i),a=i,o=[],c=[];for(let d of t.slice(0,-1))c.push(d),a=ofB({typeResolver:this.typeResolver,file:r,resolvedType:a,propertyName:d,breadcrumbs:c,rootTypeTitle:n}),o.push({name:r.casingsGenerator.generateName(d),type:a.originalTypeReference});return o}propertyPathFromPropertyComponentsFromInlineRequestBody({propertyComponents:t,file:r,body:i}){if(t.length<=1)return[];let n=[],a=[];for(let o of t.slice(0,-1)){a.push(o);let c=J_u({typeResolver:this.typeResolver,file:r,objectSchema:i,propertyComponents:a});if(!c)throw new Error(`Cannot find property '${a.join(".")}' in inline request body in file ${r.relativeFilepath}`);n.push({name:r.casingsGenerator.generateName(o),type:c.valueType})}return n}};function ofB({typeResolver:e,file:t,resolvedType:r,propertyName:i,breadcrumbs:n,rootTypeTitle:a}){let o=b_a({typeResolver:e,file:t,resolvedType:r,propertyName:i});if(!o)throw new Error(`Cannot find property '${n.join(".")}' in ${a}`);return o}function b_a({typeResolver:e,file:t,resolvedType:r,propertyName:i}){switch(r._type){case"container":switch(r.container._type){case"list":return;case"literal":return;case"map":return;case"nullable":{let n=b_a({typeResolver:e,file:t,resolvedType:r.container.itemType,propertyName:i});return n||void 0}case"optional":{let n=b_a({typeResolver:e,file:t,resolvedType:r.container.itemType,propertyName:i});return n||void 0}case"set":return;default:de(r.container)}break;case"primitive":return;case"unknown":return;case"named":{let n=r.declaration;if("properties"in n&&n.properties!=null){for(let[a,o]of Object.entries(n.properties))if(a===i)return e.resolveTypeOrThrow({type:typeof o=="string"?o:o.type,file:r.file})}if("base-properties"in n&&n["base-properties"]!=null){for(let[a,o]of Object.entries(n["base-properties"]))if(a===i)return e.resolveTypeOrThrow({type:typeof o=="string"?o:o.type,file:r.file})}if("extends"in n&&n.extends!=null){let a=Array.isArray(n.extends)?n.extends:[n.extends];for(let o of a){let c=e.resolveTypeOrThrow({type:o,file:r.file}),d=b_a({file:"file"in c?c.file:t,typeResolver:e,resolvedType:c,propertyName:i});if(d)return d}}if("union"in n&&n.union!=null)if(Array.isArray(n.union))for(let a of n.union){let o=e.resolveTypeOrThrow({type:typeof a=="string"?a:a.type,file:r.file}),c=b_a({file:"file"in o?o.file:t,typeResolver:e,resolvedType:o,propertyName:i});if(c)return c}else for(let[,a]of Object.entries(n.union)){let o=typeof a=="string"?a:a.type;if(!o)continue;let c=e.resolveTypeOrThrow({type:o,file:r.file}),d=b_a({file:"file"in c?c.file:t,typeResolver:e,resolvedType:c,propertyName:i});if(d)return d}return}default:de(r)}}function ajn(e){switch(e._type){case"container":switch(e.container._type){case"list":return`list<${ajn(e.container.itemType)}>}`;case"literal":return`literal<${e.container.literal._visit({boolean:t=>t.toString(),string:t=>t,_other:t=>t.type})}>`;case"map":return`map<${ajn(e.container.keyType)}, ${ajn(e.container.valueType)}>}`;case"nullable":return`nullable<${ajn(e.container.itemType)}>}`;case"optional":return`optional<${ajn(e.container.itemType)}>}`;case"set":return`set<${ajn(e.container.itemType)}>}`;default:de(e.container)}break;case"named":return e.name.name.originalName;case"primitive":return e.primitive.v1;case"unknown":return"unknown";default:de(e)}}var Kv=class{workspace;constructor(t){this.workspace=t}resolveTypeOrThrow({type:t,file:r}){let i=this.resolveType({type:t,file:r});if(i==null)throw new Error("Cannot resolve type: "+t+" in file "+r.relativeFilepath);return i}getDeclarationOfNamedTypeOrThrow({referenceToNamedType:t,file:r}){let i=this.getDeclarationOfNamedType({referenceToNamedType:t,file:r});if(i==null)throw new Error("Cannot find declaration of type: "+t+" in file "+r.relativeFilepath);return i}getDeclarationOfNamedType({referenceToNamedType:t,file:r}){let i=Ume({reference:t,referencedIn:r.relativeFilepath,imports:r.imports});if(i==null)return;let n=eBe(this.workspace,i.relativeFilepath);if(n==null)return;let a=n.types?.[i.typeName];if(a==null){let o=HB(i.typeName);if(o!=null){for(let c of Object.keys(n.types??{})??[])if(o.name&&c.startsWith(o.name)&&c.endsWith(">")){let d=n.types?.[c];return d!=null?{typeName:c,declaration:d,file:ud({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}:void 0}}return}return{typeName:i.typeName,declaration:a,file:ud({relativeFilepath:i.relativeFilepath,definitionFile:n,casingsGenerator:r.casingsGenerator,rootApiFile:this.workspace.definition.rootApiFile.contents})}}resolveType({type:t,file:r,objectPath:i=[]}){return Uq({type:t,_default:void 0,validation:void 0,visitor:{primitive:n=>({_type:"primitive",primitive:n,originalTypeReference:_i.primitive(n)}),unknown:()=>({_type:"unknown",originalTypeReference:_i.unknown()}),map:({keyType:n,valueType:a})=>n!=null&&a!=null?{_type:"container",container:{_type:"map",keyType:n,valueType:a},originalTypeReference:_i.container(Js.map({keyType:n.originalTypeReference,valueType:a.originalTypeReference}))}:void 0,list:n=>n!=null?{_type:"container",container:{_type:"list",itemType:n},originalTypeReference:_i.container(Js.list(n.originalTypeReference))}:void 0,optional:n=>n!=null?{_type:"container",container:{_type:"optional",itemType:n},originalTypeReference:_i.container(Js.optional(n.originalTypeReference))}:void 0,nullable:n=>n!=null?{_type:"container",container:{_type:"nullable",itemType:n},originalTypeReference:_i.container(Js.nullable(n.originalTypeReference))}:void 0,set:n=>n!=null?{_type:"container",container:{_type:"set",itemType:n},originalTypeReference:_i.container(Js.set(n.originalTypeReference))}:void 0,literal:n=>({_type:"container",container:{_type:"literal",literal:n},originalTypeReference:_i.container(Js.literal(n))}),named:n=>{let a=this.getDeclarationOfNamedType({referenceToNamedType:n,file:r});if(a==null)return;let o={typeName:a.typeName,file:a.file.relativeFilepath,reference:n};if(!i.some(c=>c.file===o.file&&c.typeName===o.typeName))return this.resolveNamedTypeFromDeclaration({referenceToNamedType:n,referencedIn:r,rawDeclaration:a,objectPath:[...i,o]})}}})}resolveNamedTypeOrThrow({referenceToNamedType:t,file:r}){let i=this.resolveNamedType({referenceToNamedType:t,file:r});if(i==null)throw new Error("Cannot resolve type: "+t);return i}resolveNamedType({referenceToNamedType:t,file:r}){let i=this.getDeclarationOfNamedType({referenceToNamedType:t,file:r});if(i!=null)return this.resolveNamedTypeFromDeclaration({referenceToNamedType:t,referencedIn:r,rawDeclaration:i})}resolveNamedTypeFromDeclaration({referenceToNamedType:t,referencedIn:r,rawDeclaration:i,objectPath:n=[]}){let{declaration:a,file:o}=i;if(d2i(a))return this.resolveType({type:typeof a=="string"?a:a.type,file:o,objectPath:n});let c=ero({type:t,_default:void 0,validation:void 0,file:r});if(!(c.type!=="named"||eBe(this.workspace,o.relativeFilepath)==null))return{_type:"named",rawName:i.typeName,name:c,declaration:a,filepath:o.relativeFilepath,objectPath:n,originalTypeReference:c,file:o}}};var Y5t=class e{static VARIABLE_PREFIX="$";getDeclarationOrThrow(t,r){let i=this.getDeclaration(t,r);if(i==null)throw new Error("Variable does not exist: "+t);return i}getDeclaration(t,r){if(!t.startsWith(e.VARIABLE_PREFIX))return;let i=r.rootApiFile.variables?.[t.substring(1)];if(i!=null)return{declaration:i,file:TWi({casingsGenerator:r.casingsGenerator,rootApiFile:r.rootApiFile})}}getVariableIdOrThrow(t){let r=this.getVariableId(t);if(r==null)throw new Error("Variable reference does not start with "+e.VARIABLE_PREFIX);return r}getVariableId(t){if(t.startsWith(e.VARIABLE_PREFIX))return t.substring(e.VARIABLE_PREFIX.length)}};function NAu(e,t){if(t){for(let[r,i]of Object.entries(t))if(typeof i!="string"&&r===e)return i.audiences}}var bmh={pathParameterOrder:Ki.PathParameterOrder.UrlOrder};function vmh({workspace:e}){let t=e.generatorsConfiguration?.api?.settings,r={...bmh};for(let i of Object.keys(bmh)){let n=t?.[i];n!==void 0&&(r[i]=n)}return r}function DE({workspace:e,generationLanguage:t,keywords:r,smartCasing:i,exampleGeneration:n,audiences:a,readme:o,packageName:c,version:d,fdrApiDefinitionId:s,sourceResolver:u,disableDynamicExamples:f,dynamicGeneratorConfig:p,generationMetadata:_}){let h=vmh({workspace:e}),y=N7({generationLanguage:t,keywords:r,smartCasing:i}),b=new KAn(a),v=TWi({casingsGenerator:y,rootApiFile:e.definition.rootApiFile.contents}),O=(e.definition.rootApiFile.contents.errors??[]).map(X=>({error:b2i({errorName:X,file:v}),docs:void 0})),m=new Kv(e),g=new ijn(e),A=new zAu(m,g),j=new njn(e),M=new Zme(m),w=new Y5t,B=Kka({casingsGenerator:y,rawApiFileSchema:e.definition.rootApiFile.contents})?.environmentsConfig,q={selfHosted:!1,fdrApiDefinitionId:s,apiVersion:XOh({file:v,rawApiFileSchema:e.definition.rootApiFile.contents}),apiName:y.generateName(e.definition.rootApiFile.contents.name),apiDisplayName:e.definition.rootApiFile.contents["display-name"],apiDocs:Xka(e.definition.rootApiFile.contents.docs),auth:YOh({rawApiFileSchema:e.definition.rootApiFile.contents,file:v,propertyResolver:A,endpointResolver:g}),headers:e.definition.rootApiFile.contents.headers!=null?Object.entries(e.definition.rootApiFile.contents.headers).map(([X,Ue])=>rBe({headerKey:X,header:Ue,file:v})):[],idempotencyHeaders:e.definition.rootApiFile.contents["idempotency-headers"]!=null?Object.entries(e.definition.rootApiFile.contents["idempotency-headers"]).map(([X,Ue])=>rBe({headerKey:X,header:Ue,file:v})):[],types:{},errors:{},services:{},constants:UOh(y),environments:B,errorDiscriminationStrategy:tmh(e.definition.rootApiFile.contents["error-discrimination"],v),basePath:e.definition.rootApiFile.contents["base-path"]!=null?HD(e.definition.rootApiFile.contents["base-path"]):void 0,pathParameters:y_a({pathParameters:e.definition.rootApiFile.contents["path-parameters"],file:v,location:BDe.Root,variableResolver:w}),variables:e.definition.rootApiFile.contents.variables!=null?Object.entries(e.definition.rootApiFile.contents.variables).map(([X,Ue])=>({docs:typeof Ue!="string"?Ue.docs:void 0,id:X,name:v.casingsGenerator.generateName(X),type:v.parseTypeReference(Ue)})):[],serviceTypeReferenceInfo:{typesReferencedOnlyByService:{},sharedTypes:[]},webhookGroups:{},websocketChannels:{},readmeConfig:void 0,sourceConfig:void 0,publishConfig:void 0,dynamic:void 0,audiences:e.definition.rootApiFile.contents.audiences,generationMetadata:_,apiPlayground:!0},R=new RAu,T=X=>{R.addSubpackage(X.fernFilepath),Vb(X.definitionFile,{imports:At,docs:Ue=>{Ue!=null&&R.addDocs(X.fernFilepath,Ue)},types:Ue=>{if(Ue!=null)for(let[Ke,or]of Object.entries(Ue)){if(MDe(Ke))continue;let Ft=lmh({typeName:Ke,typeDeclaration:or,file:X,typeResolver:m,exampleResolver:M,sourceResolver:u,workspace:e}),qt=Ft.typeDeclaration;n.disabled&&(qt.userProvidedExamples=[],qt.autogeneratedExamples=[]);let Ht=Ft.descendantFilepaths,Qt=M_.generateTypeId(qt.name);q.types[Qt]=qt,R.addType(Qt,qt),b.addType({declaredTypeName:qt.name,descendantTypeIds:qt.referencedTypes,descendantTypeIdsByAudience:{},propertiesByAudience:Ft.propertiesByAudience,descendantFilepaths:Ht}),b.markTypeForAudiences(qt.name,Vrh(or))}},errors:Ue=>{if(Ue==null)return;if(e.definition.rootApiFile.contents["error-discrimination"]==null)throw new Error("error-discrimination is missing in api.yml but there are declared errors.");for(let[or,Ft]of Object.entries(Ue)){let qt=kOh({errorName:or,errorDeclaration:Ft,file:X,typeResolver:m,exampleResolver:M,workspace:e}),Ht=M_.generateErrorId(qt.name);q.errors[Ht]=qt,R.addError(Ht,qt),b.addError(qt)}},service:Ue=>{if(Ue==null)return;let Ke=ROh({rootDefaultUrl:X.defaultUrl??e.definition.rootApiFile.contents["default-url"],rootPathParameters:q.pathParameters,serviceDefinition:Ue,file:X,errorResolver:j,typeResolver:m,propertyResolver:A,exampleResolver:M,sourceResolver:u,globalErrors:O,variableResolver:w,workspace:e,auth:q.auth,irSettings:h}),or=M_.generateServiceId(Ke.name);q.services[or]=Ke,R.addService(or,Ke);let Ft={};Ke.endpoints.forEach(qt=>{n.disabled&&(qt.autogeneratedExamples=[],qt.userSpecifiedExamples=[]);let Ht=Ue.endpoints[qt.name.originalName];b.addEndpoint(Ke,qt,Ht),Ft[qt.name.originalName]=qt}),Ue.audiences!=null&&b.markEndpointForAudience(Ke.name,Ke.endpoints,Ue.audiences),Object.entries(Ue.endpoints).map(([qt,Ht])=>{let Qt=Ft[qt];Qt!=null&&Ht.audiences!=null&&b.markEndpointForAudience(Ke.name,[Qt],Ht.audiences)})},webhooks:Ue=>{if(Ue==null)return;let Ke=M_.generateWebhookGroupId(X.fernFilepath),or=imh({webhooks:Ue,file:X,typeResolver:m,exampleResolver:M,workspace:e}),Ft={};for(let qt of or)Ft[qt.name.originalName]=qt;Object.entries(Ue).forEach(([qt,Ht])=>{let Qt=Ft[qt];Qt!=null&&(b.addWebhook(X.fernFilepath,Qt,Ht),Ht.audiences!=null&&b.markWebhookForAudiences(X.fernFilepath,Qt,Ht.audiences))}),q.webhookGroups[Ke]=or,R.addWebhookGroup(Ke,X.fernFilepath)},channel:Ue=>{if(Ue==null)return;let Ke=M_.generateWebSocketChannelId(X.fernFilepath),or=ZOh({channel:Ue,file:X,variableResolver:w,typeResolver:m,exampleResolver:M,workspace:e});b.addChannel(X.fernFilepath,Ke,or,Ue),Ue.audiences!=null&&b.markChannelForAudiences(X.fernFilepath,Ke,Ue.audiences),q.websocketChannels!=null&&(q.websocketChannels[Ke]=or,R.addWebSocketChannel(Ke,X.fernFilepath))}})};Gq(e,(X,Ue,Ke)=>{T(ud({relativeFilepath:X,definitionFile:Ue,casingsGenerator:y,rootApiFile:e.definition.rootApiFile.contents,defaultUrl:Ke.defaultUrl}))}),kPn(e,(X,Ue)=>{if(Ue.navigation!=null)if(typeof Ue.navigation=="string")R.addPackageRedirection({from:IZ({relativeFilepath:X,casingsGenerator:y}),to:IZ({relativeFilepath:PC(GMe(X),_s.of(Ue.navigation)),casingsGenerator:y})});else{let Ke=Ue.navigation.map(or=>M_.generateSubpackageId(IZ({relativeFilepath:PC(GMe(X),_s.of(or)),casingsGenerator:y})));X===Wv?R.sortRootPackage(Ke):R.sortSubpackage(M_.generateSubpackageId(IZ({relativeFilepath:X,casingsGenerator:y})),Ke)}}),q.serviceTypeReferenceInfo=sfB(b),dmh(q);let K=n.disabled?q:Jka({ir:q,exampleGeneration:n}),H=e.definition.rootApiFile.contents,z=B?.environments._visit({singleBaseUrl:X=>X.environments.filter(Ue=>NAu(Ue.id,H.environments)!=null).length===0,multipleBaseUrls:X=>X.environments.filter(Ue=>NAu(Ue.id,H.environments)!=null).length===0,_other:()=>!1});B?.environments.environments.forEach(X=>{b.markEnvironmentForAudiences(X,NAu(X.id,H.environments)??[],z)});let W=b.hasNoAudiences()?void 0:b.build(),Oe=mHc(K,W),Ae=e.definition.rootApiFile.contents.auth!=null&&Object.values(Oe.services).every(X=>X.endpoints.every(Ue=>Ue.auth)),Q=Object.values(Oe.services).some(X=>X.endpoints.some(Ue=>Ue.response?.body?.type==="streaming")),U=Object.values(Oe.services).some(X=>X.endpoints.some(Ue=>Ue.pagination!=null)),ce=Object.values(Oe.services).some(X=>X.endpoints.some(Ue=>Ue.response?.body?.type==="fileDownload")),ae={isAuthMandatory:Ae,hasStreamingEndpoints:Q,hasPaginatedEndpoints:U,hasFileDownloadEndpoints:ce,platformHeaders:{language:"X-Fern-Language",sdkName:"X-Fern-SDK-Name",sdkVersion:"X-Fern-SDK-Version",userAgent:d!=null&&c!=null?{header:"User-Agent",value:`${c}/${d}`}:void 0}},fe=o??e.generatorsConfiguration?.rawConfiguration.readme,ve=fe!=null?rmh({readme:fe,services:q.services}):void 0,re=ufB({...Oe,...R.build(W),sdkConfig:ae,readmeConfig:ve});return{...re,dynamic:rjn({ir:re,generatorConfig:p,disableExamples:f,generationLanguage:t,smartCasing:i})}}function ufB(e){let t=r=>{if(!r||typeof r!="object")return r;if(Array.isArray(r))return r.map(t);for(let i in r){let n=r[i];i==="docs"&&typeof n=="string"?r[i]=Xka(n):n&&typeof n=="object"&&t(n)}return r};return t(e)}function sfB(e){let t={},r=[],i=e.getTypesReferencedByService();for(let[n,a]of Object.entries(i)){if(a.size===1){let o=a.values().next().value;if(o==null)break;t[o]===void 0&&(t[o]=[]),t[o]?.push(n);continue}r.push(n)}return{typesReferencedOnlyByService:t,sharedTypes:r}}var Mro=process.env.FERN_STACK_TRACK?.toLowerCase()??"",f2=Mro!==""&&Mro!=="0"&&Mro!=="false",Fkc=["single","multiline","box"].includes(Mro)?Mro:"single";f2&&(Error.stackTraceLimit=50);var KEh=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),RgB=new Set(["stacktrace"]);function Qkc(e){f2&&KEh.add(e)}function Dro({maxFrames:e=50,skip:t=0,filterPaths:r=[],filterFunctions:i=[],stopOn:n=[],filterNode:a=!0,filterJs:o=!0,formatFilename:c=d=>d}={}){if(!f2)return[];i=[...i,...KEh],r=[...r,...RgB],n=[...n,"runInteractiveTask"];let d=!1;return(new Error().stack??"").split(`
|
|
1466
1466
|
`).map(s=>{let u=s.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(u&&u.length===5){let[,f,p,_,h]=u;if(!f||!p||!_||!h)return;if(d||n.some(y=>f?.includes(y))){d=!0;return}switch(f){case"Object.<anonymous>":f="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":f=`${f.substring(f.indexOf(".")+1)}()=> { ... }`;break}return{fn:f,path:c(p),position:`${_}:${h}`}}}).filter(s=>s&&!i.some(u=>s.fn.includes(u))&&!(a&&s.path?.startsWith("node:"))&&!(o&&s.path?.endsWith(".js"))&&!r.some(u=>s.path.includes(u))).slice(t,t+e)}function Bro({maxFrames:e=50,skip:t=0,filterPaths:r=[],filterFunctions:i=[],stopOn:n=["runInteractiveTask"],filterNode:a=!0,filterJs:o=!0,multiline:c=!1,formatFilename:d=s=>s}={}){return f2?`${Dro({maxFrames:e,skip:t,filterPaths:r,filterFunctions:i,stopOn:n,filterNode:a,filterJs:o,formatFilename:d}).map(s=>`${c?`
|
|
1467
1467
|
`:" > "}${s.fn} - ${s.path}:${s.position}`).join("")}`:""}var nju=class{maxFrames;skip;filterPaths;filterFunctions;stopOn;filterNode;filterJs;multiline;formatFilename;tracking=new WeakMap;constructor({maxFrames:t=50,skip:r=0,filterPaths:i=[],filterFunctions:n=[],stopOn:a=[],filterNode:o=!0,filterJs:c=!0,multiline:d=!1,formatFilename:s=u=>u}={}){this.maxFrames=t,this.skip=r,this.filterPaths=i,this.filterFunctions=n,this.stopOn=a,this.filterNode=o,this.filterJs=c,this.multiline=d,this.formatFilename=s}tag(t){let r=this.tracking.get(t)||new Set;Dro({maxFrames:this.maxFrames,skip:this.skip,filterPaths:this.filterPaths,filterFunctions:this.filterFunctions,stopOn:this.stopOn,filterNode:this.filterNode,filterJs:this.filterJs,formatFilename:this.formatFilename}).forEach(i=>r.add(i)),this.tracking.set(t,r)}trace(t){if(!f2)return"";let r=this.tracking.get(t);return r?[...r].map(i=>`${this.multiline?`
|
|
1468
1468
|
`:""}${i.fn} - ${i.path}:${i.position}`).join(""):""}frames(t){let r=this.tracking.get(t);return r?[...r]:[]}free(t){this.tracking.delete(t)}clear(){this.tracking=new WeakMap}},Ukc;function $Eh({maxFrames:e=50,skip:t=0,filterPaths:r=[],filterFunctions:i=[],stopOn:n=[],filterNode:a=!0,filterJs:o=!0,multiline:c=!1,formatFilename:d=s=>s}={}){f2&&(Ukc??=new nju({maxFrames:e,skip:t,filterPaths:r,filterFunctions:i,stopOn:n,filterNode:a,filterJs:o,multiline:c,formatFilename:d}))}function JEh(e){Ukc?.tag(e)}function Iro(e){return Ukc?.frames(e)??[]}var YB=class{constructor(){JEh(this)}};var aju=class{formatMultiple(t){return Promise.all(t.map(r=>this.format(r)))}formatMultipleSync(t){return t.map(r=>this.formatSync(r))}},k5t=class extends aju{async format(t){return t}formatSync(t){return t}};var JM=class extends YB{value;constructor(t){super(),this.value=t}write(t){typeof this.value=="string"?t.write(this.value):typeof this.value=="function"?this.value(t):this.value.write(t)}};var zgB=4;$Eh({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var PN=class{lineBuffer=[];get buffer(){return f2&&this.nodeStackFrames.length>0&&this.writeInternal(`
|
|
@@ -1584,7 +1584,7 @@ ${t}`)}return t}getContent(){let t=this.stringifyImports();return t.length>0?t+`
|
|
|
1584
1584
|
`),n=i[0]+`
|
|
1585
1585
|
`,a=i.slice(1).join(`
|
|
1586
1586
|
`);t.write(n.replaceAll("`","\\`")),t.writeNoIndent(a.replaceAll("`","\\`")),t.write("`")}writeIterable({writer:t,iterable:r}){let i=MMB({values:r.values});if(i.length===0){t.write("[]");return}t.writeLine("["),t.indent();for(let n of i)n.write(t),t.writeLine(",");t.dedent(),t.write("]")}writeRecord({writer:t,record:r}){let i=SMB({entries:r.entries});if(i.length===0){t.write("{}");return}t.writeLine("{"),t.indent();for(let n of i)n.key.write(t),t.write(": "),n.value.write(t),t.writeLine(",");t.dedent(),t.write("}")}writeObject({writer:t,object:r}){let i=EMB({fields:r.fields});if(i.length===0){t.write("{}");return}t.writeLine("{"),t.indent();for(let n of i)t.write(`${n.name}: `),n.value.write(t),t.writeLine(",");t.dedent(),t.write("}")}static array({values:t}){return new this({type:"array",values:t})}static bigint(t){return new this({type:"bigint",value:t})}static blob(t){return new this({type:"blob",value:t})}static boolean(t){return new this({type:"boolean",value:t})}static datetime(t){return new this({type:"datetime",value:t})}static number(t){return new this({type:"number",value:t})}static object({fields:t}){return new this({type:"object",fields:t})}static record({entries:t}){return new this({type:"record",entries:t})}static reference(t){return new this({type:"reference",value:t})}static set({values:t}){return new this({type:"set",values:t})}static string(t){return new this({type:"string",value:t})}static tuple({values:t}){return new this({type:"tuple",values:t})}static unknown(t){return new this({type:"unknown",value:t})}static null(){return new this({type:"null"})}static nop(){return new this({type:"nop"})}static isNop(t){return t.internalType.type==="nop"}writeUnknown({writer:t,value:r}){switch(typeof r){case"boolean":t.write(r.toString());return;case"string":t.write(r.includes('"')?`\`${r}\``:`"${r}"`);return;case"number":t.write(r.toString());return;case"object":if(r==null){t.write("null");return}if(Array.isArray(r)){this.writeUnknownArray({writer:t,value:r});return}this.writeUnknownObject({writer:t,value:r});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof r}`)}}writeUnknownArray({writer:t,value:r}){if(r.length===0){t.write("[]");return}t.writeLine("["),t.indent();for(let i of r)t.writeNode(e.unknown(i)),t.writeLine(",");t.dedent(),t.write("]")}writeUnknownObject({writer:t,value:r}){let i=Object.entries(r);if(i.length===0){t.write("{}");return}t.writeLine("{"),t.indent();for(let[n,a]of i)t.write(`${n}: `),t.writeNode(e.unknown(a)),t.writeLine(",");t.dedent(),t.write("}")}};function EMB({fields:e}){return e.filter(t=>!s8i.isNop(t.value))}function SMB({entries:e}){return e.filter(t=>!s8i.isNop(t.key)&&!s8i.isNop(t.value))}function MMB({values:e}){return e.filter(t=>!s8i.isNop(t))}var yya=class extends IE{args;constructor(t){super(),this.args=t}write(t){this.args.export&&t.write("export "),this.args.const?t.write("const "):t.write("let "),t.write(`${this.args.name} = `),t.writeNode(this.args.initializer)}};function BMB(e){return new fya(e)}function IMB(e){return new dya(e)}function CMB(e){return new lya(e)}function qMB(e){return new pya(e)}function TMB(e){return new _ya(e)}function RMB(e){return new hya(e)}function zMB(e){return new _0n(e)}function NMB(e){return new yya(e)}function D4h({generatorConfig:e,isPackagePrivate:t}){let r=e.output.mode;switch(r.type){case"downloadFiles":return;case"publish":return{packageName:r.registriesV2.npm.packageName,version:r.version,private:t,publishInfo:{registryUrl:r.registriesV2.npm.registryUrl,token:r.registriesV2.npm.token},license:void 0,repoUrl:void 0};case"github":if(r.publishInfo!=null&&r.publishInfo.type!=="npm")throw new Error(`Expected to receive npm publish info but received ${r.publishInfo.type} instead`);return{packageName:r.publishInfo!=null?r.publishInfo.packageName:"",version:r.version,private:t,publishInfo:void 0,repoUrl:FMB(r.repoUrl),license:e.license?._visit({basic:i=>i.id,custom:i=>`See ${i.filename}`,_other:()=>{}})};default:throw new Error(`Encountered unknown output mode: ${r}`)}}function FMB(e){if(e!=null)return e.startsWith("https://github.com/")?`git+${e}`:e.startsWith("ssh://github.com/")?`github:${Eio(e).replace("ssh://github.com/","")}`:e.startsWith("https://bitbucket.org/")?`bitbucket:${Eio(e).replace("https://bitbucket.org/","")}`:e.startsWith("ssh://bitbucket.org/")?`bitbucket:${Eio(e).replace("ssh://bitbucket.org/","")}`:e.startsWith("https://gitlab.com/")?`gitlab:${Eio(e).replace("https://gitlab.com/","")}`:e.startsWith("ssh://gitlab.com/")?`gitlab:${Eio(e).replace("ssh://gitlab.com/","")}`:(e.startsWith("git+")||(e=`git+${e}`),e.endsWith(".git")||(e=`${e}.git`),e)}function Eio(e){return e.endsWith(".git")?e.slice(0,-4):e}function Etl({organization:e,workspaceName:t,namespaceExport:r}){return r??`${Wf(mn(e))}${Wf(mn(t))}`}var Qtl=se(ixh(),1);var TDB="value",kwu=class{context;constructor({context:t}){this.context=t}convert(t){let r=t.convertOpts;if(t.value===null)return this.context.isNullable(t.typeReference)?na.TypeLiteral.null():(this.context.errors.add({severity:Wr.Critical,message:"Expected non-null value, but got null"}),na.TypeLiteral.nop());if(t.value===void 0)return na.TypeLiteral.nop();switch(t.typeReference.type){case"list":return this.convertList({list:t.typeReference.value,value:t.value,convertOpts:r});case"literal":return this.convertLiteral({literalType:t.typeReference.value,value:t.value,convertOpts:r});case"map":return this.convertMap({map:t.typeReference,value:t.value,convertOpts:r});case"named":{let i=this.context.resolveNamedType({typeId:t.typeReference.value});return i==null?na.TypeLiteral.nop():this.convertNamed({named:i,value:t.value,as:t.as,convertOpts:r})}case"optional":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as,convertOpts:r});case"nullable":return this.convert({typeReference:t.typeReference.value,value:t.value,as:t.as,convertOpts:r});case"primitive":return this.convertPrimitive({primitive:t.typeReference.value,value:t.value,as:t.as,convertOpts:r});case"set":return this.convertSet({set:t.typeReference.value,value:t.value,convertOpts:r});case"unknown":return this.convertUnknown({value:t.value,convertOpts:r});default:de(t.typeReference)}}convertLiteral({literalType:t,value:r}){switch(t.type){case"boolean":{let i=this.context.getValueAsBoolean({value:r});return i==null?na.TypeLiteral.nop():na.TypeLiteral.boolean(i)}case"string":{let i=this.context.getValueAsString({value:r});return i==null?na.TypeLiteral.nop():na.TypeLiteral.string(i)}default:de(t)}}convertList({list:t,value:r,convertOpts:i}){return Array.isArray(r)?na.TypeLiteral.array({values:r.map((n,a)=>{this.context.errors.scope({index:a});try{return this.convert({typeReference:t,value:n,convertOpts:i})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:Wr.Critical,message:`Expected array but got: ${typeof r}`}),na.TypeLiteral.nop())}convertSet({set:t,value:r,convertOpts:i}){return Array.isArray(r)?na.TypeLiteral.set({values:r.map((n,a)=>{this.context.errors.scope({index:a});try{return this.convert({typeReference:t,value:n,convertOpts:i})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:Wr.Critical,message:`Expected array but got: ${typeof r}`}),na.TypeLiteral.nop())}convertMap({map:t,value:r,convertOpts:i}){return typeof r!="object"||r==null?(this.context.errors.add({severity:Wr.Critical,message:`Expected object but got: ${r==null?"null":typeof r}`}),na.TypeLiteral.nop()):na.TypeLiteral.record({entries:Object.entries(r).map(([n,a])=>{this.context.errors.scope(n);try{return{key:this.convert({typeReference:t.key,value:n,as:"key",convertOpts:i}),value:this.convert({typeReference:t.value,value:a,convertOpts:i})}}finally{this.context.errors.unscope()}})})}convertNamed({named:t,value:r,as:i,convertOpts:n}){switch(t.type){case"alias":return this.context.customConfig?.useBrandedStringAliases?na.TypeLiteral.reference(na.codeblock(a=>{a.writeNode(na.reference({name:this.context.namespaceExport,importFrom:this.context.getModuleImport(),memberName:this.context.getFullyQualifiedReference({declaration:t.declaration})})),a.write("("),a.writeNode(this.convert({typeReference:t.typeReference,value:r,as:i,convertOpts:n})),a.write(")")})):this.convert({typeReference:t.typeReference,value:r,as:i,convertOpts:n});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:t,value:r,convertOpts:n});case"enum":return this.convertEnum({enum_:t,value:r,convertOpts:n});case"object":return this.convertObject({object_:t,value:r,convertOpts:n});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:t,value:r,convertOpts:n});default:de(t)}}convertDiscriminatedUnion({discriminatedUnion:t,value:r,convertOpts:i}){let n=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:t,value:r});if(n==null)return na.TypeLiteral.nop();let a=n.singleDiscriminatedUnionType,o=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:n,unionVariant:a,convertOpts:i});if(o==null)return na.TypeLiteral.nop();if(this.context.customConfig?.includeUtilsOnUnionMembers)return na.TypeLiteral.reference(na.codeblock(d=>{d.writeNode(na.invokeMethod({on:na.reference({name:this.context.namespaceExport,importFrom:this.context.getModuleImport(),memberName:this.context.getFullyQualifiedReference({declaration:t.declaration})}),method:this.context.getMethodName(a.discriminantValue.name),arguments_:this.convertDiscriminatedUnionUtilsArgs({discriminatedUnionTypeInstance:n,unionVariant:a,unionProperties:o,convertOpts:i})}))}));let c={name:this.context.getPropertyName(t.discriminant.name),value:na.TypeLiteral.string(a.discriminantValue.wireValue)};return na.TypeLiteral.object({fields:[c,...o]})}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:t,unionVariant:r,convertOpts:i}){let n=this.getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:r});switch(r.type){case"samePropertiesAsObject":{let a=this.context.resolveNamedType({typeId:r.typeId});if(a==null)return;let o=this.convertNamed({named:a,value:t.value,convertOpts:i});if(!o.isObject()){this.context.errors.add({severity:Wr.Critical,message:"Internal error; expected union value to be an object"});return}let c=o.asObjectOrThrow();return[...n,...c.fields]}case"singleProperty":try{this.context.errors.scope(r.discriminantValue.wireValue);let a=this.context.getRecord(t.value);return a==null?[...n,{name:TDB,value:this.convert({typeReference:r.typeReference,value:t.value,convertOpts:i})}]:[...n,{name:this.context.getPropertyName(r.discriminantValue.name),value:this.convert({typeReference:r.typeReference,value:a[r.discriminantValue.wireValue],convertOpts:i})}]}finally{this.context.errors.unscope()}case"noProperties":return n;default:de(r)}}convertDiscriminatedUnionUtilsArgs({discriminatedUnionTypeInstance:t,unionVariant:r,unionProperties:i,convertOpts:n}){return r.type==="singleProperty"&&this.context.getRecord(t.value)==null&&i.length===1?[this.convert({typeReference:r.typeReference,value:t.value,convertOpts:n})]:i.length>0?[na.TypeLiteral.object({fields:i})]:[]}getBaseFields({discriminatedUnionTypeInstance:t,singleDiscriminatedUnionType:r,convertOpts:i}){return this.context.associateByWireValue({parameters:r.properties??[],values:this.context.getRecord(t.value)??{},ignoreMissingParameters:!0}).map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getPropertyName(a.name.name),value:this.convert({...a,convertOpts:i})}}finally{this.context.errors.unscope()}})}convertObject({object_:t,value:r,convertOpts:i}){let n=this.context.associateByWireValue({parameters:this.filterReadWriteProperties(t.properties,i),values:this.context.getRecord(r)??{}});return na.TypeLiteral.object({fields:n.map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getPropertyName(a.name.name),value:this.convert({...a,convertOpts:i})}}finally{this.context.errors.unscope()}})})}filterReadWriteProperties(t,r){return this.context.customConfig?.experimentalGenerateReadWriteOnlyTypes!==!0||typeof r>"u"||(r.isForRequest&&(t=t.filter(i=>i.propertyAccess!==Qtl.ObjectPropertyAccess.ReadOnly)),r.isForResponse&&(t=t.filter(i=>i.propertyAccess!==Qtl.ObjectPropertyAccess.WriteOnly))),t}convertEnum({enum_:t,value:r}){let i=this.getEnumValue({enum_:t,value:r});return i==null?na.TypeLiteral.nop():na.TypeLiteral.string(i)}getEnumValue({enum_:t,value:r}){if(typeof r!="string"){this.context.errors.add({severity:Wr.Critical,message:`Expected enum value string, got: ${typeof r}`});return}if(t.values.find(n=>n.wireValue===r)==null){this.context.errors.add({severity:Wr.Critical,message:`An enum value named "${r}" does not exist in this context`});return}return r}convertUndiscriminatedUnion({undiscriminatedUnion:t,value:r,convertOpts:i}){let n=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:r,convertOpts:i});return n??na.TypeLiteral.nop()}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:t,value:r,convertOpts:i}){for(let n of t.types)try{return this.convert({typeReference:n,value:r,convertOpts:i})}catch{continue}this.context.errors.add({severity:Wr.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof r}" value`})}convertUnknown({value:t,convertOpts:r}){return na.TypeLiteral.unknown(t)}convertPrimitive({primitive:t,value:r,as:i,convertOpts:n}){switch(t){case"INTEGER":case"UINT":{let a=this.getValueAsNumber({value:r,as:i});return a==null?na.TypeLiteral.nop():na.TypeLiteral.number(a)}case"LONG":case"UINT_64":{let a=this.getValueAsNumber({value:r,as:i});return a==null?na.TypeLiteral.nop():this.context.customConfig?.useBigInt?na.TypeLiteral.bigint(BigInt(a)):na.TypeLiteral.number(a)}case"FLOAT":case"DOUBLE":{let a=this.getValueAsNumber({value:r});return a==null?na.TypeLiteral.nop():na.TypeLiteral.number(a)}case"BOOLEAN":{let a=this.getValueAsBoolean({value:r,as:i});return a==null?na.TypeLiteral.nop():na.TypeLiteral.boolean(a)}case"BASE_64":case"DATE":case"UUID":case"STRING":{let a=this.context.getValueAsString({value:r});return a==null?na.TypeLiteral.nop():na.TypeLiteral.string(a)}case"DATE_TIME":{let a=this.context.getValueAsString({value:r});return a==null?na.TypeLiteral.nop():na.TypeLiteral.datetime(a)}case"BIG_INTEGER":{let a=this.context.getValueAsString({value:r});return a==null?na.TypeLiteral.nop():this.context.customConfig?.useBigInt?na.TypeLiteral.bigint(BigInt(a)):na.TypeLiteral.string(a)}default:de(t)}}getValueAsNumber({value:t,as:r}){let i=r==="key"&&typeof t=="string"?Number(t):t;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:t,as:r}){let i=r==="key"?typeof t=="string"?t==="true":t==="false"?!1:t:t;return this.context.getValueAsBoolean({value:i})}};var e0u=class{context;constructor({context:t}){this.context=t}getFilePropertyInfo({body:t,value:r}){let i={fileFields:[],bodyPropertyFields:[]},n=this.context.getRecord(r)??{};for(let a of t.properties)switch(a.type){case"file":i.fileFields.push({name:this.context.getPropertyName(a.name),value:this.getSingleFileProperty({property:a,record:n})});break;case"fileArray":i.fileFields.push({name:this.context.getPropertyName(a.name),value:this.getArrayFileProperty({property:a,record:n})});break;case"bodyProperty":i.bodyPropertyFields.push({name:this.context.getPropertyName(a.name.name),value:this.getBodyProperty({property:a,record:n})});break;default:de(a)}return i}getSingleFileProperty({property:t,record:r}){let i=this.context.getSingleFileValue({property:t,record:r});return i==null?na.TypeLiteral.nop():na.TypeLiteral.blob(i)}getArrayFileProperty({property:t,record:r}){let i=this.context.getFileArrayValues({property:t,record:r});return i==null?na.TypeLiteral.nop():na.TypeLiteral.array({values:i.map(n=>na.TypeLiteral.blob(n))})}getBodyProperty({property:t,record:r}){let i=r[t.name.wireValue];return i==null?na.TypeLiteral.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:i})}};var t0u=class e extends Kq{ir;customConfig;dynamicTypeLiteralMapper;filePropertyMapper;moduleName;namespaceExport;constructor({ir:t,config:r}){super({ir:t,config:r}),this.ir=t,this.customConfig=r.customConfig!=null?r.customConfig:void 0,this.dynamicTypeLiteralMapper=new kwu({context:this}),this.filePropertyMapper=new e0u({context:this}),this.moduleName=RDB({config:r,customConfig:this.customConfig}),this.namespaceExport=Etl({organization:r.organization,workspaceName:r.workspaceName,namespaceExport:this.customConfig?.namespaceExport})}clone(){return new e({ir:this.ir,config:this.config})}getModuleImport(){return{type:"named",moduleName:this.moduleName}}getRootClientName(){return`${this.namespaceExport}Client`}getPropertyName(t){return this.customConfig?.retainOriginalCasing||this.customConfig?.noSerdeLayer?this.formatOriginalPropertyName(t.originalName):t.camelCase.unsafeName}getMethodName(t){return t.camelCase.unsafeName}getTypeName(t){return t.pascalCase.unsafeName}getEnvironmentTypeReferenceFromID(t){let r=this.resolveEnvironmentName(t);if(r!=null)return this.getEnvironmentsTypeReference(r)}getFullyQualifiedReference({declaration:t}){return t.fernFilepath.allParts.length>0?`${t.fernFilepath.allParts.map(r=>r.camelCase.unsafeName).join(".")}.${this.getTypeName(t.name)}`:`${this.getTypeName(t.name)}`}getEnvironmentsTypeReference(t){return na.reference({name:`${this.namespaceExport}Environment`,importFrom:this.getModuleImport(),memberName:this.getTypeName(t)})}formatOriginalPropertyName(t){return t.includes("-")?`"${t}"`:t}};function RDB({config:e,customConfig:t}){return D4h({generatorConfig:e,isPackagePrivate:t?.private??!1})?.packageName??e.organization}var nxh="client",axh="main",zDB={type:"primitive",value:"STRING"},r0u=class{context;constructor({context:t}){this.context=t}async generateSnippet({endpoint:t,request:r}){return await this.buildCodeBlock({endpoint:t,snippet:r}).toStringAsync({customConfig:this.context.customConfig})}generateSnippetSync({endpoint:t,request:r}){return this.buildCodeBlock({endpoint:t,snippet:r}).toString({customConfig:this.context.customConfig})}async generateSnippetAst({endpoint:t,request:r}){return this.buildCodeBlock({endpoint:t,snippet:r})}buildCodeBlock({endpoint:t,snippet:r}){return na.codeblock(i=>{i.writeNode(na.function_({name:axh,async:!0,parameters:[],body:na.codeblock(n=>{n.writeNodeStatement(this.constructClient({endpoint:t,snippet:r})),n.writeNodeStatement(this.callMethod({endpoint:t,snippet:r}))})})),i.writeNodeStatement(na.invokeFunction({function_:na.reference({name:axh}),arguments_:[]}))})}constructClient({endpoint:t,snippet:r}){return na.variable({name:nxh,const:!0,initializer:na.instantiateClass({class_:na.reference({name:this.context.getRootClientName(),importFrom:this.context.getModuleImport()}),arguments_:[this.getConstructorArgs({endpoint:t,snippet:r})]})})}getConstructorArgs({endpoint:t,snippet:r}){let i=[],n=this.getConstructorEnvironmentArgs({baseUrl:r.baseURL,environment:r.environment});return n.length>0&&i.push(...n),t.auth!=null&&(r.auth!=null?i.push(...this.getConstructorAuthArgs({auth:t.auth,values:r.auth})):this.context.errors.add({severity:Wr.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(So.PathParameters),this.context.ir.pathParameters!=null&&i.push(...this.getPathParameters({namedParameters:this.context.ir.pathParameters,snippet:r})),this.context.errors.unscope(),this.context.errors.scope(So.Headers),this.context.ir.headers!=null&&r.headers!=null&&i.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:r.headers})),this.context.errors.unscope(),i.length===0?na.TypeLiteral.nop():na.TypeLiteral.object({fields:i})}getConstructorEnvironmentArgs({baseUrl:t,environment:r}){let i=this.getEnvironmentValue({baseUrl:t,environment:r});return i==null?[]:[{name:"environment",value:i}]}getEnvironmentValue({baseUrl:t,environment:r}){if(t!=null&&r!=null){this.context.errors.add({severity:Wr.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return na.TypeLiteral.string(t);if(r!=null){if(this.context.isSingleEnvironmentID(r)){let i=this.context.getEnvironmentTypeReferenceFromID(r);if(i==null){this.context.errors.add({severity:Wr.Warning,message:`Environment ${JSON.stringify(r)} was not found`});return}return na.TypeLiteral.reference(i)}if(this.context.isMultiEnvironmentValues(r))return this.context.validateMultiEnvironmentUrlValues(r)?na.TypeLiteral.object({fields:Object.entries(r).map(([i,n])=>({name:i,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:zDB,value:n})}))}):void 0}}getConstructorAuthArgs({auth:t,values:r}){switch(t.type){case"basic":return r.type!=="basic"?(this.addAuthMismatchError(t,r),[]):this.getConstructorBasicAuthArg({auth:t,values:r});case"bearer":return r.type!=="bearer"?(this.addAuthMismatchError(t,r),[]):this.getConstructorBearerAuthArgs({auth:t,values:r});case"header":return r.type!=="header"?(this.addAuthMismatchError(t,r),[]):this.getConstructorHeaderAuthArgs({auth:t,values:r});case"oauth":return r.type!=="oauth"?(this.addAuthMismatchError(t,r),[]):this.getConstructorOAuthArgs({auth:t,values:r});case"inferred":return r.type!=="inferred"?(this.addAuthMismatchError(t,r),[]):(this.addWarning("The TypeScript SDK v2 Generator does not support Inferred auth scheme yet"),[]);default:de(t)}}addAuthMismatchError(t,r){this.context.errors.add({severity:Wr.Critical,message:this.context.newAuthMismatchError({auth:t,values:r}).message})}addWarning(t){this.context.errors.add({severity:Wr.Warning,message:t})}getConstructorBasicAuthArg({auth:t,values:r}){return[{name:this.context.getPropertyName(t.username),value:na.TypeLiteral.string(r.username)},{name:this.context.getPropertyName(t.password),value:na.TypeLiteral.string(r.password)}]}getConstructorBearerAuthArgs({auth:t,values:r}){return[{name:this.context.getPropertyName(t.token),value:na.TypeLiteral.string(r.token)}]}getConstructorHeaderAuthArgs({auth:t,values:r}){return[{name:this.context.getPropertyName(t.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t.header.typeReference,value:r.value})}]}getConstructorOAuthArgs({auth:t,values:r}){return[{name:this.context.getPropertyName(t.clientId),value:na.TypeLiteral.string(r.clientId)},{name:this.context.getPropertyName(t.clientSecret),value:na.TypeLiteral.string(r.clientSecret)}]}getConstructorHeaderArgs({headers:t,values:r}){let i=[];for(let n of t){let a=this.getConstructorHeaderArg({header:n,value:r.value});a!=null&&i.push(a)}return i}getConstructorHeaderArg({header:t,value:r}){let i=this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:r});if(!na.TypeLiteral.isNop(i))return{name:this.context.getPropertyName(t.name.name),value:i}}callMethod({endpoint:t,snippet:r}){return na.invokeMethod({on:na.reference({name:nxh}),method:this.getMethod({endpoint:t}),async:!0,arguments_:this.getMethodArgs({endpoint:t,snippet:r})})}getMethodArgs({endpoint:t,snippet:r}){switch(t.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:t.request,snippet:r});case"body":return this.getMethodArgsForBodyRequest({request:t.request,snippet:r});default:de(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:r}){let i=[];this.context.errors.scope(So.PathParameters);let n=[...this.context.ir.pathParameters??[],...t.pathParameters??[]];return n.length>0&&i.push(...this.getPathParameters({namedParameters:n,snippet:r}).map(a=>a.value)),this.context.errors.unscope(),this.context.errors.scope(So.RequestBody),t.body!=null&&i.push(this.getBodyRequestArg({body:t.body,value:r.requestBody})),this.context.errors.unscope(),i}getBodyRequestArg({body:t,value:r}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:r});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:t.value,value:r,convertOpts:{isForRequest:!0}});default:de(t)}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:Wr.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),na.TypeLiteral.nop()):na.TypeLiteral.blob(t)}getMethodArgsForInlinedRequest({request:t,snippet:r}){let i=[],{inlinePathParameters:n,inlineFileProperties:a}={inlinePathParameters:this.context.customConfig?.inlinePathParameters??!1,inlineFileProperties:this.context.customConfig?.inlineFileProperties??!1};this.context.errors.scope(So.PathParameters);let o=[];t.pathParameters!=null&&o.push(...this.getPathParameters({namedParameters:t.pathParameters,snippet:r})),this.context.errors.unscope(),this.context.errors.scope(So.RequestBody);let c=this.getFilePropertyInfo({request:t,snippet:r});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:n})||i.push(...o.map(d=>d.value)),a||i.push(...c.fileFields.map(d=>d.value)),this.context.needsRequestParameter({request:t,inlinePathParameters:n,inlineFileProperties:a})&&i.push(this.getInlinedRequestArg({request:t,snippet:r,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:n})?o:[],filePropertyInfo:c})),i}getFilePropertyInfo({request:t,snippet:r}){return t.body==null||!this.context.isFileUploadRequestBody(t.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:t.body,value:r.requestBody})}getInlinedRequestArg({request:t,snippet:r,pathParameterFields:i,filePropertyInfo:n}){this.context.errors.scope(So.QueryParameters);let o=this.context.associateQueryParametersByWireValue({parameters:t.queryParameters??[],values:r.queryParameters??{}}).map(u=>({name:this.context.getPropertyName(u.name.name),value:this.context.dynamicTypeLiteralMapper.convert({...u,convertOpts:{isForRequest:!0}})}));this.context.errors.unscope(),this.context.errors.scope(So.Headers);let d=this.context.associateByWireValue({parameters:t.headers??[],values:r.headers??{}}).map(u=>({name:this.context.getPropertyName(u.name.name),value:this.context.dynamicTypeLiteralMapper.convert({...u,convertOpts:{isForRequest:!0}})}));this.context.errors.unscope(),this.context.errors.scope(So.RequestBody);let s=t.body!=null?this.getInlinedRequestBodyObjectFields({body:t.body,value:r.requestBody,filePropertyInfo:n}):[];return this.context.errors.unscope(),na.TypeLiteral.object({fields:[...i,...o,...d,...s]})}getInlinedRequestBodyObjectFields({body:t,value:r,filePropertyInfo:i}){switch(t.type){case"properties":return this.getInlinedRequestBodyPropertyObjectFields({parameters:t.value,value:r});case"referenced":return[this.getReferencedRequestBodyPropertyObjectField({body:t,value:r})];case"fileUpload":return this.getFileUploadRequestBodyObjectFields({filePropertyInfo:i});default:de(t)}}getFileUploadRequestBodyObjectFields({filePropertyInfo:t}){return this.context.customConfig?.inlineFileProperties?[...t.fileFields,...t.bodyPropertyFields]:t.bodyPropertyFields}getReferencedRequestBodyPropertyObjectField({body:t,value:r}){return{name:this.context.getPropertyName(t.bodyKey),value:this.getReferencedRequestBodyPropertyTypeLiteral({body:t.bodyType,value:r})}}getReferencedRequestBodyPropertyTypeLiteral({body:t,value:r}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:r});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:t.value,value:r,convertOpts:{isForRequest:!0}});default:de(t)}}getInlinedRequestBodyPropertyObjectFields({parameters:t,value:r}){let i=[],n=this.context.associateByWireValue({parameters:t,values:this.context.getRecord(r)??{}});for(let a of n)i.push({name:this.context.getPropertyName(a.name.name),value:this.context.dynamicTypeLiteralMapper.convert({...a,convertOpts:{isForRequest:!0}})});return i}getPathParameters({namedParameters:t,snippet:r}){let i=[],n=this.context.associateByWireValue({parameters:t,values:r.pathParameters??{},ignoreMissingParameters:!0});for(let a of n)i.push({name:this.context.getPropertyName(a.name.name),value:this.context.dynamicTypeLiteralMapper.convert({...a,convertOpts:{isForRequest:!0}})});return i}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(r=>this.context.getMethodName(r)).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}};var Mio=class extends Hq{constructor({ir:t,config:r}){super(new t0u({ir:t,config:r}))}async generate(t){return super.generate(t)}generateSync(t){return super.generateSync(t)}async generateSnippetAst(t){return super.generateSnippetAst(t)}createSnippetGenerator(t){return new r0u({context:t})}};var n0u=require("fs/promises"),oxh=se(require("path"),1);var i0u=class{context;ir;generatorConfig;dynamicSnippetsGenerator;constructor(t,r,i){this.context=t,this.ir=r,this.generatorConfig=i,this.dynamicSnippetsGenerator=new Mio({ir:MU(this.ir),config:this.buildGeneratorConfig(this.generatorConfig)})}async generateTests({outputDir:t,requests:r}){this.context.logger.debug("Generating dynamic snippet tests...");for(let[i,n]of r.entries())try{let a=SU(n);if(a==null)continue;let o=await this.dynamicSnippetsGenerator.generate(a),c=this.getTestFilePath({outputDir:t,idx:i});await(0,n0u.mkdir)(oxh.default.dirname(c),{recursive:!0}),await(0,n0u.writeFile)(c,o.snippet)}catch(a){this.context.logger.error(`Failed to generate dynamic snippet for endpoint ${JSON.stringify(n.endpoint)}: ${a}`)}this.context.logger.debug("Done generating dynamic snippet tests")}getTestFilePath({outputDir:t,idx:r}){return ot(t,Pe.of(`src/dynamic-snippets/example${r}/snippet.ts`))}buildGeneratorConfig(t){let r=t.output.mode;if(r.type!=="github")throw new Error("GitHub output mode is required for TypeScript dynamic snippet tests");let i=r.publishInfo;if(!i||i.type!=="npm")throw new Error("NPM publish info is required for TypeScript dynamic snippet tests");return{...t,output:{...t.output,mode:{...r,publishInfo:{...i,packageName:"../.."}}}}}};var a0u=class e{context;testSuite;static GENERATORS={csharp:{generator:Mju},go:{generator:zju},java:{generator:Hju},php:{generator:kju},typescript:{generator:i0u,unstable:!0},python:{generator:uwu,unstable:!0},ruby:{generator:bwu},rust:{generator:Mwu},swift:{generator:Hwu}};constructor(t,r){this.context=t,this.testSuite=r}async generateTests({outputDir:t,language:r,skipUnstable:i}){let n=e.GENERATORS[r];if(n==null||n.unstable&&i){this.context.logger.debug(`Skipping dynamic snippets test generation for language "${r}"`);return}return new n.generator(this.context,this.testSuite.ir,this.testSuite.config).generateTests({outputDir:t,requests:this.testSuite.requests})}};async function uxh({ir:e,config:t}){if(e.dynamic==null)throw new Error("Internal error; dynamic IR is not available");return{ir:e.dynamic,config:t,requests:Object.values(e.dynamic.endpoints).flatMap(r=>(r.examples??[]).map(i=>({...i,baseUrl:"https://api.fern.com"})))}}async function sxh({context:e,ir:t,config:r,language:i,outputDir:n,skipUnstable:a}){let o=await uxh({ir:t,config:r});return new a0u(e,o).generateTests({language:i,outputDir:n,skipUnstable:a})}var NOE=se(on(),1),K2n=require("fs/promises"),F3a=se(require("path"),1),N3a=require("path"),FOE=se(VQ(),1);var cxh=se(require("path"),1);async function o0u({schema:e,value:t,context:r,filepathBeingParsed:i}){let n=await e.safeParseAsync(t);if(n.success)return n.data;let a=n.error.errors.map(c=>{let d=c.path.length>0?`${c.message} at "${NDB(c.path)}"`:c.message;return V8t({content:d,prefix:" - "})}),o=[`Failed to parse file: ${cxh.default.relative(process.cwd(),i)}`,...a].join(`
|
|
1587
|
-
`);return r.failAndThrow(o)}function NDB(e){return e.reduce((t,r)=>typeof r=="number"?t+"["+r+"]":t+(t===""?"":".")+r,"")}var lxh=se(require("path"),1),FDB={dependencies:{}};async function fxh({absolutePathToWorkspace:e,rawDependenciesConfiguration:t,context:r}){if(t==null)return FDB;let i={};for(let[n,a]of Object.entries(t.dependencies))if(UDB(a)){let o=mr.of(lxh.default.join(e,a));await ni(o)?i[n]={type:"local",absoluteFilepath:o,path:a}:r.failWithoutThrowing(`Path to ${n} dependency does not exist: ${o}`)}else{let c=n.substring(1).split("/"),d=c[0],s=c[1];d!=null&&s!=null?i[n]={type:"version",organization:d,apiName:s,version:a}:r.failWithoutThrowing(`Failed to parse dependency: ${n}`)}return r.getResult()===qA.Failure&&r.failAndThrow(),{dependencies:i}}var QDB=/^\.\.\/.*$/;function UDB(e){return QDB.test(e)}var pxh=require("fs/promises");var dxh=It.object({dependencies:It.record(It.string(),It.string())});async function _xh({absolutePathToWorkspace:e,context:t}){let r=ot(e,Pe.of(dY_));if(!await ni(r))return;let i=await(0,pxh.readFile)(r),n=qi.load(i.toString());return await o0u({schema:dxh,value:n,context:t,filepathBeingParsed:r})}async function Utl({absolutePathToWorkspace:e,context:t}){let r=await _xh({absolutePathToWorkspace:e,context:t});return fxh({absolutePathToWorkspace:e,rawDependenciesConfiguration:r,context:t})}iHo();function hxh(e={accentPrimary:void 0,background:void 0},t){e.accentPrimary=e.accentPrimary??e.accentPrimaryDeprecated;let r=s0u(e);switch(r){case"dark":return{type:"dark",...u0u(e,t,"dark")};case"light":return{type:"light",...u0u(e,t,"light")};case"darkAndLight":return{type:"darkAndLight",dark:u0u(e,t,"dark"),light:u0u(e,t,"light")};default:de(r)}}function s0u({background:e,accentPrimary:t,accentPrimaryDeprecated:r}){if(t=t??r,typeof e=="string"&&typeof t=="string")return du(e).isDark()?"dark":"light";if(e!=null){if(typeof e=="string")return du(e).isDark()?"dark":"light";if(e.dark!=null&&e.light!=null)return"darkAndLight"}if(t!=null){if(typeof t=="string")return du(t).isLight()?"dark":"light";if(t.dark!=null&&t.light!=null)return"darkAndLight"}if(t!=null&&e!=null){if(e.dark!=null&&t.dark!=null)return"dark";if(e.light!=null&&t.light!=null)return"light"}return"darkAndLight"}function u0u(e,t,r){let i=vya(e.accentPrimary??e.accentPrimaryDeprecated,t,"accent-primary",r)??du.random(),n=vya(e.background,t,"background",r);return{accentPrimary:i.toRgb(),background:n?.toRgb(),border:vya(e.border,t,"border",r)?.toRgb(),sidebarBackground:vya(e.sidebarBackground,t,"sidebar-background",r)?.toRgb(),headerBackground:vya(e.headerBackground,t,"header-background",r)?.toRgb(),cardBackground:vya(e.cardBackground,t,"card-background",r)?.toRgb(),logo:void 0,backgroundImage:void 0}}function Dio(e,t,r){if(e==null)return;let i=typeof e=="string"?e:e[r];if(i==null&&t==="accent-primary"&&typeof e!="string"&&(i=e[r==="dark"?"light":"dark"]),i!=null)return i}function vya(e,t,r,i){let n=Dio(e,r,i);if(n==null)return;let a=du(n);return a.isValid()||t.failAndThrow(`'${typeof e=="string"?r:`colors.${r}.${i}`}' should be a hex color of the format #FFFFFF`),a}bE();var S0u=require("fs/promises");var U6h=se(require("path"),1);var bxh=require("fs/promises");var yxh=100;async function LDB({files:e,absolutePathToFernFolder:t}){let r=await Promise.all(e.map(async i=>{let n=await(0,bxh.readFile)(i,"utf-8");return[LQ(t,i),n]}));return Object.fromEntries(r)}async function vxh({files:e,absolutePathToFernFolder:t}){let r={};for(let i=0;i<e.length;i+=yxh){let n=e.slice(i,i+yxh),a=await LDB({files:n,absolutePathToFernFolder:t});Object.assign(r,a)}return r}function l0u({landingPage:e,navigation:t}){return ISe([e?.absolutePath,...VDB(t)])}function VDB(e){switch(e.type){case"tabbed":return e.items.flatMap(t=>t.child.type==="layout"?t.child.layout.flatMap(r=>c0u({item:r})):t.child.type==="variants"?t.child.variants.flatMap(r=>r.layout.flatMap(i=>c0u({item:i}))):t.child.type==="changelog"?t.child.changelog:[]);case"untabbed":return e.items.flatMap(t=>c0u({item:t}));case"versioned":return e.versions.flatMap(t=>l0u({landingPage:t.landingPage,navigation:t.navigation}));case"productgroup":return e.products.flatMap(t=>t.type==="external"?[]:l0u({landingPage:t.landingPage,navigation:t.navigation}));default:de(e)}}function c0u({item:e}){switch(e.type){case"apiSection":return ISe([e.overviewAbsolutePath,...e.navigation.flatMap(t=>gxh({item:t}))]);case"link":return[];case"page":return[e.absolutePath];case"section":return ISe([e.overviewAbsolutePath,...e.contents.flatMap(t=>c0u({item:t}))]);case"changelog":return e.changelog;case"pythonDocsSection":return[];default:de(e)}}function gxh({item:e}){return e.type==="page"?[e.absolutePath]:e.type==="package"||e.type==="section"?ISe([e.overviewAbsolutePath,...e.contents.flatMap(t=>gxh({item:t}))]):[]}var irl=require("fs/promises"),F6h=se(pAe(),1);function A0u({name:e}){return e.replace(/\.(md|mdx)$/i,"").toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")}function P0u({name:e}){return e.replace(/\.(md|mdx)$/i,"").replace(/[-_]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}async function eqB({absolutePath:e,readFileFn:t=(r,i)=>(0,irl.readFile)(r,i)}){try{let r=await t(e,"utf-8"),{data:i}=(0,F6h.default)(r);if(i.position==null)return;let n=typeof i.position=="string"?parseFloat(i.position):i.position;return typeof n=="number"&&Number.isFinite(n)?n:void 0}catch{return}}async function nrl({directoryPath:e,getDir:t=jC,readFileFn:r=(i,n)=>(0,irl.readFile)(i,n)}){let i=await t(e),n=i.filter(u=>u.type==="file"&&(u.name.toLowerCase().endsWith(".md")||u.name.toLowerCase().endsWith(".mdx"))),a=i.filter(u=>u.type==="directory"),o=await Promise.all(n.map(u=>eqB({absolutePath:u.absolutePath,readFileFn:r}))),c=n.map(u=>({type:"page",title:P0u({name:u.name}),absolutePath:u.absolutePath,slug:A0u({name:u.name}),icon:void 0,hidden:void 0,noindex:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0,availability:void 0})),d=await Promise.all(a.map(async u=>{let f=await nrl({directoryPath:u.absolutePath,getDir:t,readFileFn:r}),p=f.find(h=>h.type==="page"&&(h.slug==="index"||h.absolutePath.toLowerCase().endsWith("/index.mdx")||h.absolutePath.toLowerCase().endsWith("/index.md"))),_=p?f.filter(h=>h!==p):f;return{type:"section",title:P0u({name:u.name}),slug:A0u({name:u.name}),icon:void 0,contents:_,collapsed:void 0,hidden:void 0,skipUrlSlug:!1,overviewAbsolutePath:p?.type==="page"?p.absolutePath:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0,availability:void 0}})),s=[...c.map((u,f)=>({item:u,title:u.type==="page"?u.title:"",position:o[f]})),...d.map(u=>({item:u,title:u.type==="section"?u.title:"",position:void 0}))];return s.sort((u,f)=>{let p=typeof u.position=="number",_=typeof f.position=="number";if(p&&!_)return-1;if(!p&&_)return 1;if(typeof u.position=="number"&&typeof f.position=="number"){let h=u.position-f.position;return h!==0?h:u.title.localeCompare(f.title,void 0,{sensitivity:"base"})}return u.title.localeCompare(f.title,void 0,{sensitivity:"base"})}),s.map(u=>u.item)}function tqB(e){return!e||e.startsWith("<")?!1:e.startsWith(".")||e.includes("/")||e.includes("\\")||e.includes(":")}function JD(e,t){if(e)return tqB(e)?Jq(e,t):e}async function crl({rawDocsConfiguration:e,absolutePathToFernFolder:t,absoluteFilepathToDocsConfig:r,context:i}){let{instances:n,title:a,tabs:o,products:c,versions:d,navigation:s,navbarLinks:u,footerLinks:f,defaultLanguage:p,metadata:_,redirects:h,logo:y,favicon:b,backgroundImage:v,colors:O,typography:m,layout:g,integrations:A,css:j,js:M,aiChat:w,aiSearch:E,pageActions:B,experimental:q}=e,R=Fio(e.landingPage,r),T=_qB({tabs:o,products:c,versions:d,navigation:s,absolutePathToFernFolder:t,absolutePathToConfig:r,context:i}),K=T.then(Ue=>vxh({files:l0u({navigation:Ue,landingPage:R}),absolutePathToFernFolder:t})),H=rqB(y,r),z=Jq(b,r),W=iqB(v,r),Oe=m!=null?hqB({rawTypography:m,absoluteFilepathToDocsConfig:r}):void 0,Ae=nqB(j,r),Q=uqB(M,r),U=RqB(_,r),[ce,ae,fe,ve,re,X]=await Promise.all([T,K,Oe,Ae,Q,U]);return{title:a,instances:n,roles:e.roles,pages:ae,landingPage:R,navigation:ce,navbarLinks:qqB(u,r),footerLinks:TqB(f),defaultLanguage:p,languages:e.languages,announcement:e.announcement,metadata:X,redirects:h?.map(Ue=>({...Ue,permanent:Ue?.permanent})),logo:H,favicon:z,backgroundImage:W,colors:hxh(O,i),typography:fe,layout:pqB(g),settings:dqB(e.settings),theme:fqB(e.theme),analyticsConfig:{...e.analytics,intercom:e.analytics?.intercom?{...e.analytics.intercom,appId:e.analytics.intercom.appId,apiBase:e.analytics.intercom.apiBase}:void 0,fullstory:e.analytics?.fullstory,posthog:e.analytics?.posthog?{...e.analytics.posthog,apiKey:e.analytics.posthog.apiKey,endpoint:e.analytics.posthog.endpoint}:void 0,segment:e.analytics?.segment,gtm:e.analytics?.gtm,ga4:e.analytics?.ga4,amplitude:void 0,mixpanel:void 0,hotjar:void 0,koala:void 0,logrocket:void 0,pirsch:void 0,plausible:void 0,fathom:void 0,clearbit:void 0,heap:void 0},integrations:{...A,intercom:A?.intercom?A.intercom:void 0},css:ve,js:re,aiChatConfig:E??w,pageActions:sqB(B,r),header:void 0,footer:void 0,experimental:q}}function rqB(e,t){return e!=null?{dark:Jq(e.dark,t),light:Jq(e.light,t),height:e.height,href:e.href!=null?Jr.Url(e.href):void 0,rightText:e.rightText}:void 0}function iqB(e,t){if(e!=null)if(typeof e=="string"){let r=Jq(e,t);return{dark:r,light:r}}else{let r=Jq(e.dark,t),i=Jq(e.light,t);return{dark:r,light:i}}}async function nqB(e,t){if(e==null)return;let r=typeof e=="string"?[e]:e;return{inline:await Promise.all(r.map(async i=>(await(0,S0u.readFile)(Jq(i,t))).toString()))}}function aqB(e){return Object.hasOwn(e,"url")}function oqB(e){return Object.hasOwn(e,"path")}async function uqB(e,t){let r=[],i=[];if(e==null)return{files:[]};let n=Array.isArray(e)?e:[e];for(let a of n)typeof a=="string"?i.push({absolutePath:Jq(a,t)}):aqB(a)?r.push({strategy:a.strategy,url:Jr.Url(a.url)}):oqB(a)&&i.push({absolutePath:Jq(a.path,t),strategy:a.strategy});return{remote:r,files:i}}function sqB(e,t){return e==null?void 0:{default:e.default!=null?cqB(e.default):void 0,options:{askAi:e.options?.askAi??!0,copyPage:e.options?.copyPage??!0,viewAsMarkdown:e.options?.viewAsMarkdown??!0,openAi:e.options?.chatgpt??!0,claude:e.options?.claude??!0,cursor:e.options?.cursor??!0,vscode:e.options?.vscode??!1,custom:(e.options?.custom??[]).map(i=>lqB(i,t))}}}function cqB(e){switch(e){case"copy-page":return Jr.docs.v1.commons.PageActionOption.CopyPage;case"view-as-markdown":return Jr.docs.v1.commons.PageActionOption.ViewAsMarkdown;case"ask-ai":return Jr.docs.v1.commons.PageActionOption.AskAi;case"chatgpt":return Jr.docs.v1.commons.PageActionOption.OpenAi;case"claude":return Jr.docs.v1.commons.PageActionOption.Claude;case"cursor":return Jr.docs.v1.commons.PageActionOption.Cursor;case"vscode":return Jr.docs.v1.commons.PageActionOption.Vscode;default:de(e)}}function lqB(e,t){return{title:e.title,subtitle:e.subtitle,url:e.url,icon:JD(e.icon,t),default:e.default}}function fqB(e){if(e!=null)return{sidebar:e.sidebar??"default",tabs:e.tabs??"default",body:e.body??"default",pageActions:e.pageActions??"default",footerNav:e.footerNav??"default",languageSwitcher:e.languageSwitcher??"default",productSwitcher:e.productSwitcher??"default"}}function dqB(e){if(e!=null)return{darkModeCode:e.darkModeCode??!1,defaultSearchFilters:e.defaultSearchFilters??!1,language:e.language??"en",disableSearch:e.disableSearch??!1,hide404Page:e.hide404Page??!1,httpSnippets:e.httpSnippets??!0,searchText:e.searchText??void 0,useJavascriptAsTypescript:e.useJavascriptAsTypescript??!1,disableExplorerProxy:e.disableExplorerProxy??!1,disableAnalytics:e.disableAnalytics??!1}}function pqB(e){if(e!=null)return{pageWidth:e.pageWidth?.trim().toLowerCase()==="full"?{type:"full"}:j0u(e.pageWidth),contentWidth:j0u(e.contentWidth),sidebarWidth:j0u(e.sidebarWidth),headerHeight:j0u(e.headerHeight),searchbarPlacement:e.searchbarPlacement==="header"?Jr.docs.v1.commons.SearchbarPlacement.Header:e.searchbarPlacement==="header-tabs"?Jr.docs.v1.commons.SearchbarPlacement.HeaderTabs:Jr.docs.v1.commons.SearchbarPlacement.Sidebar,switcherPlacement:!e.switcherPlacement||e.switcherPlacement==="header"?Jr.docs.v1.commons.SwitcherPlacement.Header:Jr.docs.v1.commons.SwitcherPlacement.Sidebar,tabsPlacement:e.tabsPlacement==="header"?Jr.docs.v1.commons.TabsPlacement.Header:Jr.docs.v1.commons.TabsPlacement.Sidebar,contentAlignment:e.contentAlignment==="left"?Jr.docs.v1.commons.ContentAlignment.Left:Jr.docs.v1.commons.ContentAlignment.Center,headerPosition:e.headerPosition==="static"?Jr.docs.v1.commons.HeaderPosition.Absolute:Jr.docs.v1.commons.HeaderPosition.Fixed,disableHeader:e.disableHeader??!1,hideNavLinks:e.hideNavLinks??!1,hideFeedback:e.hideFeedback??!1}}function j0u(e){if(e==null)return;let t=e.trim().toLowerCase(),r=t.match(/^(\d+)px$/);if(r!=null&&r[1]!=null)return{type:"px",value:parseFloat(r[1])};let i=t.match(/^(\d+)rem$/);if(i!=null&&i[1]!=null)return{type:"rem",value:parseFloat(i[1])}}async function Q6h({versions:e,absolutePathToFernFolder:t,context:r}){let i=[];for(let n of e){let a=xo(t,n.path),o=qi.load((await(0,S0u.readFile)(a)).toString()),c=[],d=qSe(o,[],c);c.length>0&&r.logger.warn(`Version file ${n.path} contained null/undefined sections that were ignored: ${c.map(f=>f.join(".")).join(", ")}`);let s=jZ.RawSchemas.Serializer.VersionFileConfig.parseOrThrow(d),u=await srl({tabs:s.tabs,rawNavigationConfig:s.navigation,absolutePathToFernFolder:t,absolutePathToConfig:a,context:r});i.push({landingPage:Fio(s.landingPage,a),version:n.displayName,navigation:u,availability:n.availability,slug:n.slug,hidden:n.hidden,viewers:Z5(n.viewers),orphaned:n.orphaned,featureFlags:X5(n.featureFlag),announcement:n.announcement})}return{type:"versioned",versions:i}}async function _qB({tabs:e,products:t,versions:r,navigation:i,absolutePathToFernFolder:n,absolutePathToConfig:a,context:o}){if(i!=null)return await srl({tabs:e,rawNavigationConfig:i,absolutePathToFernFolder:n,absolutePathToConfig:a,context:o});if(t!=null){let c=[];for(let d of t){let s=d.image!=null?xo(n,d.image):void 0;if("path"in d){let u,f=xo(n,d.path),p=qi.load((await(0,S0u.readFile)(f)).toString()),_=[],h=qSe(p,[],_);_.length>0&&o.logger.warn(`Product file ${d.path} contained null/undefined sections that were ignored: ${_.map(b=>b.join(".")).join(", ")}`);let y=jZ.RawSchemas.Serializer.ProductFileConfig.parseOrThrow(h);d.versions!=null&&d.versions.length>0?u=await Q6h({versions:d.versions,absolutePathToFernFolder:n,context:o}):u=await srl({tabs:y.tabs,rawNavigationConfig:y.navigation,absolutePathToFernFolder:n,absolutePathToConfig:f,context:o}),c.push({type:"internal",landingPage:Fio(y.landingPage,f),product:d.displayName,navigation:u,slug:d.slug,subtitle:d.subtitle,icon:JD(d.icon,a)||"fa-solid fa-code",image:s,viewers:Z5(d.viewers),orphaned:d.orphaned,featureFlags:X5(d.featureFlag),announcement:d.announcement})}else if("href"in d&&d.href!=null)c.push({type:"external",product:d.displayName,href:d.href,target:d.target,subtitle:d.subtitle,icon:JD(d.icon,a)||"fa-solid fa-code",image:s,viewers:Z5(d.viewers),orphaned:d.orphaned,featureFlags:X5(d.featureFlag)});else throw new Error("Invalid product configuration: product must have either 'path' or valid 'href' property")}return{type:"productgroup",products:c}}else if(r!=null)return await Q6h({versions:r,absolutePathToFernFolder:n,context:o});throw new Error("Unexpected. Docs have neither navigation or versions defined.")}function X5(e){if(e!=null)return typeof e=="string"?[{flag:e,match:!0,fallbackValue:void 0}]:Array.isArray(e)?e.map(t=>({flag:t.flag,match:t.match,fallbackValue:t.fallbackValue})):[{flag:e.flag,match:e.match??!0,fallbackValue:e.fallbackValue}]}async function hqB({rawTypography:e,absoluteFilepathToDocsConfig:t}){return{headingsFont:e.headingsFont!=null?await arl({rawFontConfig:e.headingsFont,absoluteFilepathToDocsConfig:t}):void 0,bodyFont:e.bodyFont!=null?await arl({rawFontConfig:e.bodyFont,absoluteFilepathToDocsConfig:t}):void 0,codeFont:e.codeFont!=null?await arl({rawFontConfig:e.codeFont,absoluteFilepathToDocsConfig:t}):void 0}}async function arl({rawFontConfig:e,absoluteFilepathToDocsConfig:t}){return{name:e.name,variants:await yqB(e,t),display:e.display,fallback:e.fallback,fontVariationSettings:e.fontVariationSettings}}function yqB(e,t){let r=[];return e.path!=null&&r.push({path:e.path,weight:e.weight,style:e.style}),e.paths?.forEach(i=>{typeof i=="string"?r.push({path:i,weight:e.weight,style:e.style}):r.push({path:i.path,weight:i.weight??e.weight,style:i.style??e.style})}),Promise.all(r.map(async i=>({absolutePath:Jq(i.path,t),weight:bqB(i.weight),style:i.style})))}function bqB(e){return e==null?void 0:typeof e=="number"?[e.toString()]:e.split(/\D+/).filter(r=>r!==""&&["100","200","300","400","500","600","700","800","900"].includes(r))}async function vqB({tabs:e,item:t,absolutePathToFernFolder:r,absolutePathToConfig:i,context:n}){let a=e[t.tab];if(a==null)throw new Error(`Tab ${t.tab} is not defined in the tabs config.`);if(CqB(t)){let o=await Promise.all(t.variants.map(async c=>{let d=await Promise.all(c.layout.map(s=>E0u({rawConfig:s,absolutePathToFernFolder:r,absolutePathToConfig:i,context:n})));return{title:c.title,subtitle:c.subtitle,icon:JD(c.icon,i),layout:d,slug:c.slug,skipUrlSlug:c.skipSlug,hidden:c.hidden,default:c.default,viewers:Z5(c.viewers),orphaned:c.orphaned,featureFlags:X5(c.featureFlag)}}));return{title:a.displayName,icon:JD(a.icon,i),slug:a.slug,skipUrlSlug:a.skipSlug,hidden:a.hidden,child:{type:"variants",variants:o},viewers:Z5(a.viewers),orphaned:a.orphaned,featureFlags:X5(a.featureFlag)}}if(IqB(t)){let o=await Promise.all(t.layout.map(c=>E0u({rawConfig:c,absolutePathToFernFolder:r,absolutePathToConfig:i,context:n})));return{title:a.displayName,icon:JD(a.icon,i),slug:a.slug,skipUrlSlug:a.skipSlug,hidden:a.hidden,child:{type:"layout",layout:o},viewers:Z5(a.viewers),orphaned:a.orphaned,featureFlags:X5(a.featureFlag)}}if(a.href!=null)return{title:a.displayName,icon:JD(a.icon,i),slug:a.slug,skipUrlSlug:a.skipSlug,hidden:a.hidden,child:{type:"link",href:a.href,target:a.target},viewers:Z5(a.viewers),orphaned:a.orphaned,featureFlags:X5(a.featureFlag)};if(a.changelog!=null)return{title:a.displayName,icon:JD(a.icon,i),slug:a.slug,skipUrlSlug:a.skipSlug,hidden:a.hidden,child:{type:"changelog",changelog:await _3(Jq(a.changelog,i),"{md,mdx}")},viewers:Z5(a.viewers),orphaned:a.orphaned,featureFlags:X5(a.featureFlag)};de(a)}async function srl({tabs:e={},rawNavigationConfig:t,absolutePathToFernFolder:r,absolutePathToConfig:i,context:n}){return BqB(t)?{type:"tabbed",items:await Promise.all(t.map(o=>vqB({tabs:e,item:o,absolutePathToFernFolder:r,absolutePathToConfig:i,context:n})))}:{type:"untabbed",items:await Promise.all(t.map(a=>E0u({rawConfig:a,absolutePathToFernFolder:r,absolutePathToConfig:i,context:n})))}}var gqB="Changelog";async function OqB({rawConfig:e,absolutePathToFernFolder:t,absolutePathToConfig:r,context:i}){let n=Jq(e.folder,r);await ni(n)||i.failAndThrow(`Folder not found: ${e.folder}`);let a=await nrl({directoryPath:n}),o=a.find(f=>f.type==="page"&&(f.slug==="index"||f.absolutePath.toLowerCase().endsWith("/index.mdx")||f.absolutePath.toLowerCase().endsWith("/index.md"))),c=o?a.filter(f=>f!==o):a,d=U6h.default.basename(n),s=e.title??P0u({name:d}),u=e.slug??A0u({name:d});return{type:"section",title:s,icon:JD(e.icon,r),contents:c,slug:u,collapsed:e.collapsed??void 0,hidden:e.hidden??void 0,skipUrlSlug:e.skipSlug??!1,overviewAbsolutePath:o?.type==="page"?o.absolutePath:void 0,viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag),availability:e.availability}}async function E0u({rawConfig:e,absolutePathToFernFolder:t,absolutePathToConfig:r,context:i}){if(L6h(e))return Fio(e,r);if(AqB(e))return{type:"section",title:e.section,icon:JD(e.icon,r),contents:await Promise.all(e.contents.map(n=>E0u({rawConfig:n,absolutePathToFernFolder:t,absolutePathToConfig:r,context:i}))),slug:e.slug??void 0,collapsed:e.collapsed??void 0,hidden:e.hidden??void 0,skipUrlSlug:e.skipSlug??!1,overviewAbsolutePath:Jq(e.path,r),viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag),availability:e.availability};if(PqB(e))return{type:"apiSection",openrpc:e.openrpc,title:e.api,icon:JD(e.icon,r),apiName:e.apiName??void 0,audiences:e.audiences!=null?{type:"select",audiences:Qio(e.audiences)??[]}:{type:"all"},availability:e.availability,showErrors:e.displayErrors??!0,tagDescriptionPages:e.tagDescriptionPages??!1,snippetsConfiguration:e.snippets!=null?mqB({rawConfig:e.snippets}):void 0,postman:e.postman,navigation:e.layout?.flatMap(n=>w0u(n,r))??[],overviewAbsolutePath:Jq(e.summary,r),collapsed:e.collapsed??void 0,hidden:e.hidden??void 0,slug:e.slug,skipUrlSlug:e.skipSlug??!1,flattened:e.flattened??!1,alphabetized:e.alphabetized??!1,paginated:e.paginated??!1,playground:e.playground,viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag)};if(V6h(e))return{type:"link",text:e.link,url:e.href,icon:JD(e.icon,r),target:e.target};if(jqB(e))return{type:"changelog",changelog:await _3(Jq(e.changelog,r),"{md,mdx}"),hidden:e.hidden??!1,icon:JD(e.icon,r),title:e.title??gqB,slug:e.slug,viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag)};if(wqB(e))return await OqB({rawConfig:e,absolutePathToFernFolder:t,absolutePathToConfig:r,context:i});if(EqB(e))return{type:"pythonDocsSection",githubUrl:e.pythonDocs,title:e.title??void 0,slug:e.slug??void 0};de(e)}function Fio(e,t){if(e!=null)return{type:"page",title:e.page,absolutePath:Jq(e.path,t),slug:e.slug,icon:JD(e.icon,t),hidden:e.hidden,noindex:e.noindex,viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag),availability:e.availability}}function w0u(e,t){return typeof e=="string"?[{type:"item",value:e}]:L6h(e)?[Fio(e,t)]:V6h(e)?[{type:"link",text:e.link,url:e.href,icon:JD(e.icon,t),target:e.target}]:SqB(e)?[{type:"section",title:e.section,referencedSubpackages:e.referencedPackages??[],overviewAbsolutePath:Jq(e.summary,t),contents:e.contents?.flatMap(r=>w0u(r,t))??[],slug:e.slug,hidden:e.hidden,skipUrlSlug:e.skipSlug,availability:e.availability,icon:JD(e.icon,t),playground:e.playground,viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag)}]:MqB(e)?[{type:"endpoint",endpoint:e.endpoint,title:e.title,icon:JD(e.icon,t),slug:e.slug,hidden:e.hidden,availability:e.availability,playground:e.playground,viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag)}]:Object.entries(e).map(([r,i])=>DqB(i)?{type:"package",title:i.title,package:r,overviewAbsolutePath:Jq(i.summary,t),contents:i.contents?.flatMap(n=>w0u(n,t))??[],slug:i.slug,hidden:i.hidden,skipUrlSlug:i.skipSlug,icon:JD(i.icon,t),playground:i.playground,availability:i.availability,viewers:Z5(i.viewers),orphaned:i.orphaned,featureFlags:X5(i.featureFlag)}:{type:"package",title:void 0,package:r,overviewAbsolutePath:void 0,contents:i.flatMap(n=>w0u(n,t)),hidden:!1,slug:void 0,skipUrlSlug:!1,icon:void 0,playground:void 0,availability:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0})}function mqB({rawConfig:e}){return{python:e.python,typescript:e.typescript,go:e.go,java:e.java,ruby:e.ruby,csharp:e.csharp,php:e.php,swift:e.swift}}function L6h(e){return Wl(e)&&typeof e.page=="string"&&typeof e.path=="string"}function AqB(e){return e.section!=null}function PqB(e){return e.api!=null}function V6h(e){return jZ.RawSchemas,Wl(e)&&typeof e.link=="string"&&typeof e.href=="string"}function jqB(e){return Wl(e)&&typeof e.changelog=="string"}function wqB(e){return Wl(e)&&typeof e.folder=="string"}function EqB(e){return Wl(e)&&typeof e.pythonDocs=="string"}function SqB(e){return Wl(e)&&typeof e.section=="string"&&Array.isArray(e.contents)}function MqB(e){return Wl(e)&&typeof e.endpoint=="string"}function DqB(e){return!Array.isArray(e)}function Jq(e,t){if(e!=null)return xo(sn(t),e)}function BqB(e){return Array.isArray(e)&&e.length>0&&e[0].tab!=null}function IqB(e){return"layout"in e&&Array.isArray(e.layout)}function CqB(e){return"variants"in e&&Array.isArray(e.variants)}function qqB(e,t){return e?.map(r=>{if(r.type==="github"){let n=r.value;return typeof n=="string"?{type:"github",url:Jr.Url(n),viewers:void 0,target:void 0}:{type:"github",url:Jr.Url(n.url),viewers:orl(n.viewers),target:n.target}}let i=orl(r.viewers);return r.type==="dropdown"?{type:"dropdown",text:r.text,icon:JD(r.icon,t),rightIcon:JD(r.rightIcon,t),rounded:r.rounded,viewers:i,links:r.links?.map(n=>({href:n.href,target:n.target,url:Jr.Url(n.url??n.href??"/"),text:n.text,icon:JD(n.icon,t),rightIcon:JD(n.rightIcon,t),rounded:n.rounded,viewers:orl(n.viewers)}))??[]}:{type:r.type,text:r.text,url:Jr.Url(r.href??r.url??"/"),target:r.target,icon:JD(r.icon,t),rightIcon:JD(r.rightIcon,t),rounded:r.rounded,viewers:i}})}function orl(e){if(e!=null)return Array.isArray(e)?e.map(t=>Jr.RoleId(t)):[Jr.RoleId(e)]}function TqB(e){if(e==null)return;let t=[];if(Object.keys(e).forEach(r=>{let i=e[r];i!=null&&t.push({type:r,value:Jr.Url(i)})}),t.length!==0)return t}async function RqB(e,t){if(e!=null)return{"og:site_name":e.ogSiteName,"og:title":e.ogTitle,"og:description":e.ogDescription,"og:url":e.ogUrl,"og:image":await url(e.ogImage,t),"og:image:width":e.ogImageWidth,"og:image:height":e.ogImageHeight,"og:locale":e.ogLocale,"og:logo":await url(e.ogLogo,t),"twitter:title":e.twitterTitle,"twitter:description":e.twitterDescription,"twitter:image":await url(e.twitterImage,t),"twitter:handle":e.twitterHandle,"twitter:site":e.twitterSite,"twitter:url":e.twitterUrl,"twitter:card":e.twitterCard,nofollow:void 0,noindex:void 0,canonicalHost:e.canonicalHost}}async function url(e,t){if(e==null)return;if(e.startsWith("http"))return{type:"url",value:e};let r=Jq(e,t);return await ni(r)?{type:"filepath",value:r}:{type:"url",value:e}}function Z5(e){if(e!=null){if(typeof e=="string")return[Jr.RoleId(e)];if(e.length!==0)return e.map(Jr.RoleId)}}function Qio(e){if(e!=null){if(typeof e=="string")return[e];if(e.length!==0)return e}}var x6h=require("fs/promises");var W6h=It.strictObject({organization:It.string(),version:It.string()});async function _Ae({directory:e,context:t}){let r=ot(e,Pe.of(IC)),i=await(0,x6h.readFile)(r),n=JSON.parse(i.toString()),a=await o0u({schema:W6h,value:n,context:t,filepathBeingParsed:r});return{_absolutePath:r,rawConfig:a,organization:a.organization,version:a.version}}var P={TYPESCRIPT:"fernapi/fern-typescript",TYPESCRIPT_SDK:"fernapi/fern-typescript-sdk",TYPESCRIPT_NODE_SDK:"fernapi/fern-typescript-node-sdk",TYPESCRIPT_BROWSER_SDK:"fernapi/fern-typescript-browser-sdk",TYPESCRIPT_EXPRESS:"fernapi/fern-typescript-express",JAVA:"fernapi/fern-java",JAVA_MODEL:"fernapi/fern-java-model",JAVA_SDK:"fernapi/fern-java-sdk",JAVA_SPRING:"fernapi/fern-java-spring",PYTHON_FASTAPI:"fernapi/fern-fastapi-server",PYTHON_PYDANTIC:"fernapi/fern-pydantic-model",PYTHON_SDK:"fernapi/fern-python-sdk",GO_MODEL:"fernapi/fern-go-model",GO_SDK:"fernapi/fern-go-sdk",GO_FIBER:"fernapi/fern-go-fiber",RUBY_MODEL:"fernapi/fern-ruby-model",RUBY_SDK:"fernapi/fern-ruby-sdk",CSHARP_MODEL:"fernapi/fern-csharp-model",CSHARP_SDK:"fernapi/fern-csharp-sdk",SWIFT_MODEL:"fernapi/fern-swift-model",SWIFT_SDK:"fernapi/fern-swift-sdk",PHP_MODEL:"fernapi/fern-php-model",PHP_SDK:"fernapi/fern-php-sdk",RUST_MODEL:"fernapi/fern-rust-model",RUST_SDK:"fernapi/fern-rust-sdk",OPENAPI:"fernapi/fern-openapi",STOPLIGHT:"fernapi/fern-stoplight",POSTMAN:"fernapi/fern-postman",OPENAPI_PYTHON_CLIENT:"fernapi/openapi-python-client"};var Uio={[P.JAVA]:{version:"2.38.1"},[P.TYPESCRIPT_EXPRESS]:{version:"0.18.4",output:{location:"local-file-system",path:"../src/fern"}},[P.JAVA_MODEL]:{version:"1.0.0"},[P.JAVA_SDK]:{version:"2.38.1",output:{location:"local-file-system",path:"../sdks/java/src/main/java/"}},[P.JAVA_SPRING]:{version:"0.9.2",output:{location:"local-file-system",path:"../src/main/java/com/fern"}},[P.TYPESCRIPT]:{version:"0.0.247"},[P.TYPESCRIPT_SDK]:{version:"2.3.2",output:{location:"local-file-system",path:"../sdks/typescript"}},[P.TYPESCRIPT_NODE_SDK]:{version:"2.3.2",output:{location:"local-file-system",path:"../sdks/typescript"}},[P.TYPESCRIPT_BROWSER_SDK]:{version:"1.0.0",output:{location:"local-file-system",path:"../sdks/typescript"}},[P.PYTHON_PYDANTIC]:{version:"1.4.7"},[P.PYTHON_FASTAPI]:{version:"1.7.0",output:{location:"local-file-system",path:"../src/fern"}},[P.PYTHON_SDK]:{version:"4.23.2",output:{location:"local-file-system",path:"../sdks/python"}},[P.GO_FIBER]:{version:"0.23.5"},[P.GO_MODEL]:{version:"0.23.5"},[P.GO_SDK]:{version:"1.4.0",output:{location:"local-file-system",path:"../sdks/go"},config:{module:{path:"sdk"}}},[P.RUBY_MODEL]:{version:"0.0.8"},[P.RUBY_SDK]:{version:"0.8.2",output:{location:"local-file-system",path:"../sdks/ruby"}},[P.OPENAPI]:{version:"0.1.7",config:{format:"yaml"},output:{location:"local-file-system",path:"../openapi"}},[P.STOPLIGHT]:{version:"0.0.28",config:{format:"yaml"}},[P.POSTMAN]:{version:"0.4.0",output:{location:"local-file-system",path:"../postman"}},[P.OPENAPI_PYTHON_CLIENT]:{version:"0.0.0",output:{location:"local-file-system",path:"../sdks/python"},config:{format:"yaml"}},[P.CSHARP_MODEL]:{version:"0.0.1"},[P.CSHARP_SDK]:{version:"2.0.2",output:{location:"local-file-system",path:"../sdks/csharp"}},[P.SWIFT_MODEL]:{version:"0.0.0"},[P.SWIFT_SDK]:{version:"0.0.0",output:{location:"local-file-system",path:"../sdks/swift/sdk"}},[P.PHP_MODEL]:{version:"0.0.0"},[P.PHP_SDK]:{version:"1.16.3",output:{location:"local-file-system",path:"../sdks/php/sdk"}},[P.RUST_MODEL]:{version:"0.0.1",output:{location:"local-file-system",path:"../models/rust"}},[P.RUST_SDK]:{version:"0.0.1",output:{location:"local-file-system",path:"../sdks/rust"}}};var G6h="fernapi";function IU(e){return e.includes("/")?e:`${G6h}/${e}`}function lrl(e){let t=`${G6h}/`;return e.startsWith(t)?e.slice(t.length):e}function oen(e,t){let r=zqB(e);return r??t.failAndThrow("Unrecognized generator: "+e)}function zqB(e){if(e=IU(e),NqB(e))return e}function NqB(e){return Object.values(P).includes(e)}var M0u=se(KYa(),1),H6h=se(OX(),1);async function l6t({generatorName:e,cliVersion:t,channel:r,currentGeneratorVersion:i,includeMajor:n,context:a}){let o=H6h.default.parse(i),c=new M0u.FernRegistryClient({environment:"https://registry.buildwithfern.com"});a?.logger.debug(`Getting latest version for ${e} with CLI version ${t}, includeMajor: ${n}, prior version: ${o}`);let d={generator:FqB(e,a),releaseTypes:[r??M0u.FernRegistry.generators.ReleaseType.Ga],cliVersion:t==="0.0.0"?void 0:t};!n&&o!=null&&(d.generatorMajorVersion=o.major);let s=await c.generators.versions.getLatestGeneratorRelease(d);if(s.ok)return s.body.version}function FqB(e,t){switch(e.startsWith("fernapi/")&&(e=e.replace("fernapi/","")),e){case"fern-python-sdk":return"python-sdk";case"fern-pydantic-model":return"pydantic";case"fern-fastapi-server":return"fastapi";case"fern-typescript-browser-sdk":case"fern-typescript-node-sdk":case"fern-typescript-sdk":return"ts-sdk";case"fern-typescript-express":return"ts-express";case"fern-java-sdk":return"java-sdk";case"fern-java-model":return"java-model";case"fern-java-spring":return"java-spring";case"fern-go-sdk":return"go-sdk";case"fern-go-model":return"go-model";case"fern-go-fiber":return"go-fiber";case"fern-csharp-sdk":return"csharp-sdk";case"fern-csharp-model":return"csharp-model";case"fern-ruby-sdk":return"ruby-sdk";case"fern-ruby-model":return"ruby-model";case"fern-postman":return"postman";case"fern-openapi":return"openapi";case"fern-php-sdk":return"php-sdk";case"fern-php-model":return"php-model";case"fern-rust-sdk":return"rust-sdk";case"fern-rust-model":return"rust-model";case"fern-swift-sdk":return"swift-sdk";case"fern-swift-model":return"swift-model";default:return t?.logger.warn(`Unrecognized generator name found, attempting to parse manually: ${e}`),e.startsWith("fern-")?e.replace("fern-",""):e}}async function K6h({generatorsConfiguration:e,groupName:t=e[Ki.DEFAULT_GROUP_GENERATORS_CONFIG_KEY],context:r,update:i}){if(t==null)return r.failAndThrow("No group specified.");let n=e.groups??={},a=n[t];if(a==null){let o=n[t]??={generators:[]};await i(o,t)}else await i(a,t);return e}async function frl({generatorName:e,generatorsConfiguration:t,groupName:r=t[Rca],context:i,cliVersion:n}){let a=oen(e,i),o=lrl(a),c=Uio[a];return await K6h({generatorsConfiguration:t,groupName:r,context:i,update:async d=>{d.generators.some(s=>IU(s.name)===a)&&i.failAndThrow(`${e} is already installed in group ${r}.`),d.generators.push({name:o,...c,version:await l6t({cliVersion:n,generatorName:a,context:i,channel:void 0})??c.version})}})}var f6t=require("fs/promises"),H0n=se(require("path"),1);var DGh=require("buffer"),L0u=se(J6h(),1),F0u=se(LD(),1),g9h=require("child_process"),rHh=se(prl(),1),pHh=require("path"),Dya=se(prl(),1),BHh=require("events"),Trl=Object.defineProperty,GqB=Object.getOwnPropertyDescriptor,Rrl=Object.getOwnPropertyNames,HqB=Object.prototype.hasOwnProperty,Ua=(e,t)=>function(){return e&&(t=(0,e[Rrl(e)[0]])(e=0)),t},KqB=(e,t)=>function(){return t||(0,e[Rrl(e)[0]])((t={exports:{}}).exports,t),t.exports},Xq=(e,t)=>{for(var r in t)Trl(e,r,{get:t[r],enumerable:!0})},$qB=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Rrl(t))!HqB.call(e,n)&&n!==r&&Trl(e,n,{get:()=>t[n],enumerable:!(i=GqB(t,n))||i.enumerable});return e},FC=e=>$qB(Trl({},"__esModule",{value:!0}),e);function JqB(...e){let t=new String(e);return U0u.set(t,e),t}function R0u(e){return e instanceof String&&U0u.has(e)}function Y6h(e){return U0u.get(e)||[]}var U0u,xio=Ua({"src/lib/args/pathspec.ts"(){"use strict";U0u=new WeakMap}}),d8i,sen=Ua({"src/lib/errors/git-error.ts"(){"use strict";d8i=class extends Error{constructor(e,t){super(t),this.task=e,Object.setPrototypeOf(this,new.target.prototype)}}}}),Gio,Iya=Ua({"src/lib/errors/git-response-error.ts"(){"use strict";sen(),Gio=class extends d8i{constructor(e,t){super(void 0,t||String(e)),this.git=e}}}}),SGh,MGh=Ua({"src/lib/errors/task-configuration-error.ts"(){"use strict";sen(),SGh=class extends d8i{constructor(e){super(void 0,e)}}}});function BGh(e){return typeof e!="function"?G0n:e}function IGh(e){return typeof e=="function"&&e!==G0n}function CGh(e,t){let r=e.indexOf(t);return r<=0?[e,""]:[e.substr(0,r),e.substr(r+1)]}function qGh(e,t=0){return TGh(e)&&e.length>t?e[t]:void 0}function x0n(e,t=0){if(TGh(e)&&e.length>t)return e[e.length-1-t]}function TGh(e){return G0u(e)}function Hio(e="",t=!0,r=`
|
|
1587
|
+
`);return r.failAndThrow(o)}function NDB(e){return e.reduce((t,r)=>typeof r=="number"?t+"["+r+"]":t+(t===""?"":".")+r,"")}var lxh=se(require("path"),1),FDB={dependencies:{}};async function fxh({absolutePathToWorkspace:e,rawDependenciesConfiguration:t,context:r}){if(t==null)return FDB;let i={};for(let[n,a]of Object.entries(t.dependencies))if(UDB(a)){let o=mr.of(lxh.default.join(e,a));await ni(o)?i[n]={type:"local",absoluteFilepath:o,path:a}:r.failWithoutThrowing(`Path to ${n} dependency does not exist: ${o}`)}else{let c=n.substring(1).split("/"),d=c[0],s=c[1];d!=null&&s!=null?i[n]={type:"version",organization:d,apiName:s,version:a}:r.failWithoutThrowing(`Failed to parse dependency: ${n}`)}return r.getResult()===qA.Failure&&r.failAndThrow(),{dependencies:i}}var QDB=/^\.\.\/.*$/;function UDB(e){return QDB.test(e)}var pxh=require("fs/promises");var dxh=It.object({dependencies:It.record(It.string(),It.string())});async function _xh({absolutePathToWorkspace:e,context:t}){let r=ot(e,Pe.of(dY_));if(!await ni(r))return;let i=await(0,pxh.readFile)(r),n=qi.load(i.toString());return await o0u({schema:dxh,value:n,context:t,filepathBeingParsed:r})}async function Utl({absolutePathToWorkspace:e,context:t}){let r=await _xh({absolutePathToWorkspace:e,context:t});return fxh({absolutePathToWorkspace:e,rawDependenciesConfiguration:r,context:t})}iHo();function hxh(e={accentPrimary:void 0,background:void 0},t){e.accentPrimary=e.accentPrimary??e.accentPrimaryDeprecated;let r=s0u(e);switch(r){case"dark":return{type:"dark",...u0u(e,t,"dark")};case"light":return{type:"light",...u0u(e,t,"light")};case"darkAndLight":return{type:"darkAndLight",dark:u0u(e,t,"dark"),light:u0u(e,t,"light")};default:de(r)}}function s0u({background:e,accentPrimary:t,accentPrimaryDeprecated:r}){if(t=t??r,typeof e=="string"&&typeof t=="string")return du(e).isDark()?"dark":"light";if(e!=null){if(typeof e=="string")return du(e).isDark()?"dark":"light";if(e.dark!=null&&e.light!=null)return"darkAndLight"}if(t!=null){if(typeof t=="string")return du(t).isLight()?"dark":"light";if(t.dark!=null&&t.light!=null)return"darkAndLight"}if(t!=null&&e!=null){if(e.dark!=null&&t.dark!=null)return"dark";if(e.light!=null&&t.light!=null)return"light"}return"darkAndLight"}function u0u(e,t,r){let i=vya(e.accentPrimary??e.accentPrimaryDeprecated,t,"accent-primary",r)??du.random(),n=vya(e.background,t,"background",r);return{accentPrimary:i.toRgb(),background:n?.toRgb(),border:vya(e.border,t,"border",r)?.toRgb(),sidebarBackground:vya(e.sidebarBackground,t,"sidebar-background",r)?.toRgb(),headerBackground:vya(e.headerBackground,t,"header-background",r)?.toRgb(),cardBackground:vya(e.cardBackground,t,"card-background",r)?.toRgb(),logo:void 0,backgroundImage:void 0}}function Dio(e,t,r){if(e==null)return;let i=typeof e=="string"?e:e[r];if(i==null&&t==="accent-primary"&&typeof e!="string"&&(i=e[r==="dark"?"light":"dark"]),i!=null)return i}function vya(e,t,r,i){let n=Dio(e,r,i);if(n==null)return;let a=du(n);return a.isValid()||t.failAndThrow(`'${typeof e=="string"?r:`colors.${r}.${i}`}' should be a hex color of the format #FFFFFF`),a}bE();var S0u=require("fs/promises");var U6h=se(require("path"),1);var bxh=require("fs/promises");var yxh=100;async function LDB({files:e,absolutePathToFernFolder:t}){let r=await Promise.all(e.map(async i=>{let n=await(0,bxh.readFile)(i,"utf-8");return[LQ(t,i),n]}));return Object.fromEntries(r)}async function vxh({files:e,absolutePathToFernFolder:t}){let r={};for(let i=0;i<e.length;i+=yxh){let n=e.slice(i,i+yxh),a=await LDB({files:n,absolutePathToFernFolder:t});Object.assign(r,a)}return r}function l0u({landingPage:e,navigation:t}){return ISe([e?.absolutePath,...VDB(t)])}function VDB(e){switch(e.type){case"tabbed":return e.items.flatMap(t=>t.child.type==="layout"?t.child.layout.flatMap(r=>c0u({item:r})):t.child.type==="variants"?t.child.variants.flatMap(r=>r.layout.flatMap(i=>c0u({item:i}))):t.child.type==="changelog"?t.child.changelog:[]);case"untabbed":return e.items.flatMap(t=>c0u({item:t}));case"versioned":return e.versions.flatMap(t=>l0u({landingPage:t.landingPage,navigation:t.navigation}));case"productgroup":return e.products.flatMap(t=>t.type==="external"?[]:l0u({landingPage:t.landingPage,navigation:t.navigation}));default:de(e)}}function c0u({item:e}){switch(e.type){case"apiSection":return ISe([e.overviewAbsolutePath,...e.navigation.flatMap(t=>gxh({item:t}))]);case"link":return[];case"page":return[e.absolutePath];case"section":return ISe([e.overviewAbsolutePath,...e.contents.flatMap(t=>c0u({item:t}))]);case"changelog":return e.changelog;case"pythonDocsSection":return[];default:de(e)}}function gxh({item:e}){return e.type==="page"?[e.absolutePath]:e.type==="package"||e.type==="section"?ISe([e.overviewAbsolutePath,...e.contents.flatMap(t=>gxh({item:t}))]):[]}var irl=require("fs/promises"),F6h=se(pAe(),1);function A0u({name:e}){return e.replace(/\.(md|mdx)$/i,"").toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")}function P0u({name:e}){return e.replace(/\.(md|mdx)$/i,"").replace(/[-_]/g," ").replace(/\b\w/g,t=>t.toUpperCase())}async function eqB({absolutePath:e,readFileFn:t=(r,i)=>(0,irl.readFile)(r,i)}){try{let r=await t(e,"utf-8"),{data:i}=(0,F6h.default)(r);if(i.position==null)return;let n=typeof i.position=="string"?parseFloat(i.position):i.position;return typeof n=="number"&&Number.isFinite(n)?n:void 0}catch{return}}async function nrl({directoryPath:e,getDir:t=jC,readFileFn:r=(i,n)=>(0,irl.readFile)(i,n)}){let i=await t(e),n=i.filter(u=>u.type==="file"&&(u.name.endsWith(".md")||u.name.endsWith(".mdx"))),a=i.filter(u=>u.type==="directory"),o=await Promise.all(n.map(u=>eqB({absolutePath:u.absolutePath,readFileFn:r}))),c=n.map(u=>({type:"page",title:P0u({name:u.name}),absolutePath:u.absolutePath,slug:A0u({name:u.name}),icon:void 0,hidden:void 0,noindex:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0,availability:void 0})),d=await Promise.all(a.map(async u=>{let f=await nrl({directoryPath:u.absolutePath,getDir:t,readFileFn:r});return{type:"section",title:P0u({name:u.name}),slug:A0u({name:u.name}),icon:void 0,contents:f,collapsed:void 0,hidden:void 0,skipUrlSlug:!1,overviewAbsolutePath:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0,availability:void 0}})),s=[...c.map((u,f)=>({item:u,title:u.type==="page"?u.title:"",position:o[f]})),...d.map(u=>({item:u,title:u.type==="section"?u.title:"",position:void 0}))];return s.sort((u,f)=>{let p=typeof u.position=="number",_=typeof f.position=="number";if(p&&!_)return-1;if(!p&&_)return 1;if(typeof u.position=="number"&&typeof f.position=="number"){let h=u.position-f.position;return h!==0?h:u.title.localeCompare(f.title,void 0,{sensitivity:"base"})}return u.title.localeCompare(f.title,void 0,{sensitivity:"base"})}),s.map(u=>u.item)}function tqB(e){return!e||e.startsWith("<")?!1:e.startsWith(".")||e.includes("/")||e.includes("\\")||e.includes(":")}function JD(e,t){if(e)return tqB(e)?Jq(e,t):e}async function crl({rawDocsConfiguration:e,absolutePathToFernFolder:t,absoluteFilepathToDocsConfig:r,context:i}){let{instances:n,title:a,tabs:o,products:c,versions:d,navigation:s,navbarLinks:u,footerLinks:f,defaultLanguage:p,metadata:_,redirects:h,logo:y,favicon:b,backgroundImage:v,colors:O,typography:m,layout:g,integrations:A,css:j,js:M,aiChat:w,aiSearch:E,pageActions:B,experimental:q}=e,R=Fio(e.landingPage,r),T=_qB({tabs:o,products:c,versions:d,navigation:s,absolutePathToFernFolder:t,absolutePathToConfig:r,context:i}),K=T.then(Ue=>vxh({files:l0u({navigation:Ue,landingPage:R}),absolutePathToFernFolder:t})),H=rqB(y,r),z=Jq(b,r),W=iqB(v,r),Oe=m!=null?hqB({rawTypography:m,absoluteFilepathToDocsConfig:r}):void 0,Ae=nqB(j,r),Q=uqB(M,r),U=RqB(_,r),[ce,ae,fe,ve,re,X]=await Promise.all([T,K,Oe,Ae,Q,U]);return{title:a,instances:n,roles:e.roles,pages:ae,landingPage:R,navigation:ce,navbarLinks:qqB(u,r),footerLinks:TqB(f),defaultLanguage:p,languages:e.languages,announcement:e.announcement,metadata:X,redirects:h?.map(Ue=>({...Ue,permanent:Ue?.permanent})),logo:H,favicon:z,backgroundImage:W,colors:hxh(O,i),typography:fe,layout:pqB(g),settings:dqB(e.settings),theme:fqB(e.theme),analyticsConfig:{...e.analytics,intercom:e.analytics?.intercom?{...e.analytics.intercom,appId:e.analytics.intercom.appId,apiBase:e.analytics.intercom.apiBase}:void 0,fullstory:e.analytics?.fullstory,posthog:e.analytics?.posthog?{...e.analytics.posthog,apiKey:e.analytics.posthog.apiKey,endpoint:e.analytics.posthog.endpoint}:void 0,segment:e.analytics?.segment,gtm:e.analytics?.gtm,ga4:e.analytics?.ga4,amplitude:void 0,mixpanel:void 0,hotjar:void 0,koala:void 0,logrocket:void 0,pirsch:void 0,plausible:void 0,fathom:void 0,clearbit:void 0,heap:void 0},integrations:{...A,intercom:A?.intercom?A.intercom:void 0},css:ve,js:re,aiChatConfig:E??w,pageActions:sqB(B,r),header:void 0,footer:void 0,experimental:q}}function rqB(e,t){return e!=null?{dark:Jq(e.dark,t),light:Jq(e.light,t),height:e.height,href:e.href!=null?Jr.Url(e.href):void 0,rightText:e.rightText}:void 0}function iqB(e,t){if(e!=null)if(typeof e=="string"){let r=Jq(e,t);return{dark:r,light:r}}else{let r=Jq(e.dark,t),i=Jq(e.light,t);return{dark:r,light:i}}}async function nqB(e,t){if(e==null)return;let r=typeof e=="string"?[e]:e;return{inline:await Promise.all(r.map(async i=>(await(0,S0u.readFile)(Jq(i,t))).toString()))}}function aqB(e){return Object.hasOwn(e,"url")}function oqB(e){return Object.hasOwn(e,"path")}async function uqB(e,t){let r=[],i=[];if(e==null)return{files:[]};let n=Array.isArray(e)?e:[e];for(let a of n)typeof a=="string"?i.push({absolutePath:Jq(a,t)}):aqB(a)?r.push({strategy:a.strategy,url:Jr.Url(a.url)}):oqB(a)&&i.push({absolutePath:Jq(a.path,t),strategy:a.strategy});return{remote:r,files:i}}function sqB(e,t){return e==null?void 0:{default:e.default!=null?cqB(e.default):void 0,options:{askAi:e.options?.askAi??!0,copyPage:e.options?.copyPage??!0,viewAsMarkdown:e.options?.viewAsMarkdown??!0,openAi:e.options?.chatgpt??!0,claude:e.options?.claude??!0,cursor:e.options?.cursor??!0,vscode:e.options?.vscode??!1,custom:(e.options?.custom??[]).map(i=>lqB(i,t))}}}function cqB(e){switch(e){case"copy-page":return Jr.docs.v1.commons.PageActionOption.CopyPage;case"view-as-markdown":return Jr.docs.v1.commons.PageActionOption.ViewAsMarkdown;case"ask-ai":return Jr.docs.v1.commons.PageActionOption.AskAi;case"chatgpt":return Jr.docs.v1.commons.PageActionOption.OpenAi;case"claude":return Jr.docs.v1.commons.PageActionOption.Claude;case"cursor":return Jr.docs.v1.commons.PageActionOption.Cursor;case"vscode":return Jr.docs.v1.commons.PageActionOption.Vscode;default:de(e)}}function lqB(e,t){return{title:e.title,subtitle:e.subtitle,url:e.url,icon:JD(e.icon,t),default:e.default}}function fqB(e){if(e!=null)return{sidebar:e.sidebar??"default",tabs:e.tabs??"default",body:e.body??"default",pageActions:e.pageActions??"default",footerNav:e.footerNav??"default",languageSwitcher:e.languageSwitcher??"default",productSwitcher:e.productSwitcher??"default"}}function dqB(e){if(e!=null)return{darkModeCode:e.darkModeCode??!1,defaultSearchFilters:e.defaultSearchFilters??!1,language:e.language??"en",disableSearch:e.disableSearch??!1,hide404Page:e.hide404Page??!1,httpSnippets:e.httpSnippets??!0,searchText:e.searchText??void 0,useJavascriptAsTypescript:e.useJavascriptAsTypescript??!1,disableExplorerProxy:e.disableExplorerProxy??!1,disableAnalytics:e.disableAnalytics??!1}}function pqB(e){if(e!=null)return{pageWidth:e.pageWidth?.trim().toLowerCase()==="full"?{type:"full"}:j0u(e.pageWidth),contentWidth:j0u(e.contentWidth),sidebarWidth:j0u(e.sidebarWidth),headerHeight:j0u(e.headerHeight),searchbarPlacement:e.searchbarPlacement==="header"?Jr.docs.v1.commons.SearchbarPlacement.Header:e.searchbarPlacement==="header-tabs"?Jr.docs.v1.commons.SearchbarPlacement.HeaderTabs:Jr.docs.v1.commons.SearchbarPlacement.Sidebar,switcherPlacement:!e.switcherPlacement||e.switcherPlacement==="header"?Jr.docs.v1.commons.SwitcherPlacement.Header:Jr.docs.v1.commons.SwitcherPlacement.Sidebar,tabsPlacement:e.tabsPlacement==="header"?Jr.docs.v1.commons.TabsPlacement.Header:Jr.docs.v1.commons.TabsPlacement.Sidebar,contentAlignment:e.contentAlignment==="left"?Jr.docs.v1.commons.ContentAlignment.Left:Jr.docs.v1.commons.ContentAlignment.Center,headerPosition:e.headerPosition==="static"?Jr.docs.v1.commons.HeaderPosition.Absolute:Jr.docs.v1.commons.HeaderPosition.Fixed,disableHeader:e.disableHeader??!1,hideNavLinks:e.hideNavLinks??!1,hideFeedback:e.hideFeedback??!1}}function j0u(e){if(e==null)return;let t=e.trim().toLowerCase(),r=t.match(/^(\d+)px$/);if(r!=null&&r[1]!=null)return{type:"px",value:parseFloat(r[1])};let i=t.match(/^(\d+)rem$/);if(i!=null&&i[1]!=null)return{type:"rem",value:parseFloat(i[1])}}async function Q6h({versions:e,absolutePathToFernFolder:t,context:r}){let i=[];for(let n of e){let a=xo(t,n.path),o=qi.load((await(0,S0u.readFile)(a)).toString()),c=[],d=qSe(o,[],c);c.length>0&&r.logger.warn(`Version file ${n.path} contained null/undefined sections that were ignored: ${c.map(f=>f.join(".")).join(", ")}`);let s=jZ.RawSchemas.Serializer.VersionFileConfig.parseOrThrow(d),u=await srl({tabs:s.tabs,rawNavigationConfig:s.navigation,absolutePathToFernFolder:t,absolutePathToConfig:a,context:r});i.push({landingPage:Fio(s.landingPage,a),version:n.displayName,navigation:u,availability:n.availability,slug:n.slug,hidden:n.hidden,viewers:Z5(n.viewers),orphaned:n.orphaned,featureFlags:X5(n.featureFlag),announcement:n.announcement})}return{type:"versioned",versions:i}}async function _qB({tabs:e,products:t,versions:r,navigation:i,absolutePathToFernFolder:n,absolutePathToConfig:a,context:o}){if(i!=null)return await srl({tabs:e,rawNavigationConfig:i,absolutePathToFernFolder:n,absolutePathToConfig:a,context:o});if(t!=null){let c=[];for(let d of t){let s=d.image!=null?xo(n,d.image):void 0;if("path"in d){let u,f=xo(n,d.path),p=qi.load((await(0,S0u.readFile)(f)).toString()),_=[],h=qSe(p,[],_);_.length>0&&o.logger.warn(`Product file ${d.path} contained null/undefined sections that were ignored: ${_.map(b=>b.join(".")).join(", ")}`);let y=jZ.RawSchemas.Serializer.ProductFileConfig.parseOrThrow(h);d.versions!=null&&d.versions.length>0?u=await Q6h({versions:d.versions,absolutePathToFernFolder:n,context:o}):u=await srl({tabs:y.tabs,rawNavigationConfig:y.navigation,absolutePathToFernFolder:n,absolutePathToConfig:f,context:o}),c.push({type:"internal",landingPage:Fio(y.landingPage,f),product:d.displayName,navigation:u,slug:d.slug,subtitle:d.subtitle,icon:JD(d.icon,a)||"fa-solid fa-code",image:s,viewers:Z5(d.viewers),orphaned:d.orphaned,featureFlags:X5(d.featureFlag),announcement:d.announcement})}else if("href"in d&&d.href!=null)c.push({type:"external",product:d.displayName,href:d.href,target:d.target,subtitle:d.subtitle,icon:JD(d.icon,a)||"fa-solid fa-code",image:s,viewers:Z5(d.viewers),orphaned:d.orphaned,featureFlags:X5(d.featureFlag)});else throw new Error("Invalid product configuration: product must have either 'path' or valid 'href' property")}return{type:"productgroup",products:c}}else if(r!=null)return await Q6h({versions:r,absolutePathToFernFolder:n,context:o});throw new Error("Unexpected. Docs have neither navigation or versions defined.")}function X5(e){if(e!=null)return typeof e=="string"?[{flag:e,match:!0,fallbackValue:void 0}]:Array.isArray(e)?e.map(t=>({flag:t.flag,match:t.match,fallbackValue:t.fallbackValue})):[{flag:e.flag,match:e.match??!0,fallbackValue:e.fallbackValue}]}async function hqB({rawTypography:e,absoluteFilepathToDocsConfig:t}){return{headingsFont:e.headingsFont!=null?await arl({rawFontConfig:e.headingsFont,absoluteFilepathToDocsConfig:t}):void 0,bodyFont:e.bodyFont!=null?await arl({rawFontConfig:e.bodyFont,absoluteFilepathToDocsConfig:t}):void 0,codeFont:e.codeFont!=null?await arl({rawFontConfig:e.codeFont,absoluteFilepathToDocsConfig:t}):void 0}}async function arl({rawFontConfig:e,absoluteFilepathToDocsConfig:t}){return{name:e.name,variants:await yqB(e,t),display:e.display,fallback:e.fallback,fontVariationSettings:e.fontVariationSettings}}function yqB(e,t){let r=[];return e.path!=null&&r.push({path:e.path,weight:e.weight,style:e.style}),e.paths?.forEach(i=>{typeof i=="string"?r.push({path:i,weight:e.weight,style:e.style}):r.push({path:i.path,weight:i.weight??e.weight,style:i.style??e.style})}),Promise.all(r.map(async i=>({absolutePath:Jq(i.path,t),weight:bqB(i.weight),style:i.style})))}function bqB(e){return e==null?void 0:typeof e=="number"?[e.toString()]:e.split(/\D+/).filter(r=>r!==""&&["100","200","300","400","500","600","700","800","900"].includes(r))}async function vqB({tabs:e,item:t,absolutePathToFernFolder:r,absolutePathToConfig:i,context:n}){let a=e[t.tab];if(a==null)throw new Error(`Tab ${t.tab} is not defined in the tabs config.`);if(CqB(t)){let o=await Promise.all(t.variants.map(async c=>{let d=await Promise.all(c.layout.map(s=>E0u({rawConfig:s,absolutePathToFernFolder:r,absolutePathToConfig:i,context:n})));return{title:c.title,subtitle:c.subtitle,icon:JD(c.icon,i),layout:d,slug:c.slug,skipUrlSlug:c.skipSlug,hidden:c.hidden,default:c.default,viewers:Z5(c.viewers),orphaned:c.orphaned,featureFlags:X5(c.featureFlag)}}));return{title:a.displayName,icon:JD(a.icon,i),slug:a.slug,skipUrlSlug:a.skipSlug,hidden:a.hidden,child:{type:"variants",variants:o},viewers:Z5(a.viewers),orphaned:a.orphaned,featureFlags:X5(a.featureFlag)}}if(IqB(t)){let o=await Promise.all(t.layout.map(c=>E0u({rawConfig:c,absolutePathToFernFolder:r,absolutePathToConfig:i,context:n})));return{title:a.displayName,icon:JD(a.icon,i),slug:a.slug,skipUrlSlug:a.skipSlug,hidden:a.hidden,child:{type:"layout",layout:o},viewers:Z5(a.viewers),orphaned:a.orphaned,featureFlags:X5(a.featureFlag)}}if(a.href!=null)return{title:a.displayName,icon:JD(a.icon,i),slug:a.slug,skipUrlSlug:a.skipSlug,hidden:a.hidden,child:{type:"link",href:a.href,target:a.target},viewers:Z5(a.viewers),orphaned:a.orphaned,featureFlags:X5(a.featureFlag)};if(a.changelog!=null)return{title:a.displayName,icon:JD(a.icon,i),slug:a.slug,skipUrlSlug:a.skipSlug,hidden:a.hidden,child:{type:"changelog",changelog:await _3(Jq(a.changelog,i),"{md,mdx}")},viewers:Z5(a.viewers),orphaned:a.orphaned,featureFlags:X5(a.featureFlag)};de(a)}async function srl({tabs:e={},rawNavigationConfig:t,absolutePathToFernFolder:r,absolutePathToConfig:i,context:n}){return BqB(t)?{type:"tabbed",items:await Promise.all(t.map(o=>vqB({tabs:e,item:o,absolutePathToFernFolder:r,absolutePathToConfig:i,context:n})))}:{type:"untabbed",items:await Promise.all(t.map(a=>E0u({rawConfig:a,absolutePathToFernFolder:r,absolutePathToConfig:i,context:n})))}}var gqB="Changelog";async function OqB({rawConfig:e,absolutePathToFernFolder:t,absolutePathToConfig:r,context:i}){let n=Jq(e.folder,r);await ni(n)||i.failAndThrow(`Folder not found: ${e.folder}`);let a=await nrl({directoryPath:n}),o=U6h.default.basename(n),c=e.title??P0u({name:o}),d=e.slug??A0u({name:o});return{type:"section",title:c,icon:JD(e.icon,r),contents:a,slug:d,collapsed:e.collapsed??void 0,hidden:e.hidden??void 0,skipUrlSlug:e.skipSlug??!1,overviewAbsolutePath:void 0,viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag),availability:e.availability}}async function E0u({rawConfig:e,absolutePathToFernFolder:t,absolutePathToConfig:r,context:i}){if(L6h(e))return Fio(e,r);if(AqB(e))return{type:"section",title:e.section,icon:JD(e.icon,r),contents:await Promise.all(e.contents.map(n=>E0u({rawConfig:n,absolutePathToFernFolder:t,absolutePathToConfig:r,context:i}))),slug:e.slug??void 0,collapsed:e.collapsed??void 0,hidden:e.hidden??void 0,skipUrlSlug:e.skipSlug??!1,overviewAbsolutePath:Jq(e.path,r),viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag),availability:e.availability};if(PqB(e))return{type:"apiSection",openrpc:e.openrpc,title:e.api,icon:JD(e.icon,r),apiName:e.apiName??void 0,audiences:e.audiences!=null?{type:"select",audiences:Qio(e.audiences)??[]}:{type:"all"},availability:e.availability,showErrors:e.displayErrors??!0,tagDescriptionPages:e.tagDescriptionPages??!1,snippetsConfiguration:e.snippets!=null?mqB({rawConfig:e.snippets}):void 0,postman:e.postman,navigation:e.layout?.flatMap(n=>w0u(n,r))??[],overviewAbsolutePath:Jq(e.summary,r),collapsed:e.collapsed??void 0,hidden:e.hidden??void 0,slug:e.slug,skipUrlSlug:e.skipSlug??!1,flattened:e.flattened??!1,alphabetized:e.alphabetized??!1,paginated:e.paginated??!1,playground:e.playground,viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag)};if(V6h(e))return{type:"link",text:e.link,url:e.href,icon:JD(e.icon,r),target:e.target};if(jqB(e))return{type:"changelog",changelog:await _3(Jq(e.changelog,r),"{md,mdx}"),hidden:e.hidden??!1,icon:JD(e.icon,r),title:e.title??gqB,slug:e.slug,viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag)};if(wqB(e))return await OqB({rawConfig:e,absolutePathToFernFolder:t,absolutePathToConfig:r,context:i});if(EqB(e))return{type:"pythonDocsSection",githubUrl:e.pythonDocs,title:e.title??void 0,slug:e.slug??void 0};de(e)}function Fio(e,t){if(e!=null)return{type:"page",title:e.page,absolutePath:Jq(e.path,t),slug:e.slug,icon:JD(e.icon,t),hidden:e.hidden,noindex:e.noindex,viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag),availability:e.availability}}function w0u(e,t){return typeof e=="string"?[{type:"item",value:e}]:L6h(e)?[Fio(e,t)]:V6h(e)?[{type:"link",text:e.link,url:e.href,icon:JD(e.icon,t),target:e.target}]:SqB(e)?[{type:"section",title:e.section,referencedSubpackages:e.referencedPackages??[],overviewAbsolutePath:Jq(e.summary,t),contents:e.contents?.flatMap(r=>w0u(r,t))??[],slug:e.slug,hidden:e.hidden,skipUrlSlug:e.skipSlug,availability:e.availability,icon:JD(e.icon,t),playground:e.playground,viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag)}]:MqB(e)?[{type:"endpoint",endpoint:e.endpoint,title:e.title,icon:JD(e.icon,t),slug:e.slug,hidden:e.hidden,availability:e.availability,playground:e.playground,viewers:Z5(e.viewers),orphaned:e.orphaned,featureFlags:X5(e.featureFlag)}]:Object.entries(e).map(([r,i])=>DqB(i)?{type:"package",title:i.title,package:r,overviewAbsolutePath:Jq(i.summary,t),contents:i.contents?.flatMap(n=>w0u(n,t))??[],slug:i.slug,hidden:i.hidden,skipUrlSlug:i.skipSlug,icon:JD(i.icon,t),playground:i.playground,availability:i.availability,viewers:Z5(i.viewers),orphaned:i.orphaned,featureFlags:X5(i.featureFlag)}:{type:"package",title:void 0,package:r,overviewAbsolutePath:void 0,contents:i.flatMap(n=>w0u(n,t)),hidden:!1,slug:void 0,skipUrlSlug:!1,icon:void 0,playground:void 0,availability:void 0,viewers:void 0,orphaned:void 0,featureFlags:void 0})}function mqB({rawConfig:e}){return{python:e.python,typescript:e.typescript,go:e.go,java:e.java,ruby:e.ruby,csharp:e.csharp,php:e.php,swift:e.swift}}function L6h(e){return Wl(e)&&typeof e.page=="string"&&typeof e.path=="string"}function AqB(e){return e.section!=null}function PqB(e){return e.api!=null}function V6h(e){return jZ.RawSchemas,Wl(e)&&typeof e.link=="string"&&typeof e.href=="string"}function jqB(e){return Wl(e)&&typeof e.changelog=="string"}function wqB(e){return Wl(e)&&typeof e.folder=="string"}function EqB(e){return Wl(e)&&typeof e.pythonDocs=="string"}function SqB(e){return Wl(e)&&typeof e.section=="string"&&Array.isArray(e.contents)}function MqB(e){return Wl(e)&&typeof e.endpoint=="string"}function DqB(e){return!Array.isArray(e)}function Jq(e,t){if(e!=null)return xo(sn(t),e)}function BqB(e){return Array.isArray(e)&&e.length>0&&e[0].tab!=null}function IqB(e){return"layout"in e&&Array.isArray(e.layout)}function CqB(e){return"variants"in e&&Array.isArray(e.variants)}function qqB(e,t){return e?.map(r=>{if(r.type==="github"){let n=r.value;return typeof n=="string"?{type:"github",url:Jr.Url(n),viewers:void 0,target:void 0}:{type:"github",url:Jr.Url(n.url),viewers:orl(n.viewers),target:n.target}}let i=orl(r.viewers);return r.type==="dropdown"?{type:"dropdown",text:r.text,icon:JD(r.icon,t),rightIcon:JD(r.rightIcon,t),rounded:r.rounded,viewers:i,links:r.links?.map(n=>({href:n.href,target:n.target,url:Jr.Url(n.url??n.href??"/"),text:n.text,icon:JD(n.icon,t),rightIcon:JD(n.rightIcon,t),rounded:n.rounded,viewers:orl(n.viewers)}))??[]}:{type:r.type,text:r.text,url:Jr.Url(r.href??r.url??"/"),target:r.target,icon:JD(r.icon,t),rightIcon:JD(r.rightIcon,t),rounded:r.rounded,viewers:i}})}function orl(e){if(e!=null)return Array.isArray(e)?e.map(t=>Jr.RoleId(t)):[Jr.RoleId(e)]}function TqB(e){if(e==null)return;let t=[];if(Object.keys(e).forEach(r=>{let i=e[r];i!=null&&t.push({type:r,value:Jr.Url(i)})}),t.length!==0)return t}async function RqB(e,t){if(e!=null)return{"og:site_name":e.ogSiteName,"og:title":e.ogTitle,"og:description":e.ogDescription,"og:url":e.ogUrl,"og:image":await url(e.ogImage,t),"og:image:width":e.ogImageWidth,"og:image:height":e.ogImageHeight,"og:locale":e.ogLocale,"og:logo":await url(e.ogLogo,t),"twitter:title":e.twitterTitle,"twitter:description":e.twitterDescription,"twitter:image":await url(e.twitterImage,t),"twitter:handle":e.twitterHandle,"twitter:site":e.twitterSite,"twitter:url":e.twitterUrl,"twitter:card":e.twitterCard,nofollow:void 0,noindex:void 0,canonicalHost:e.canonicalHost}}async function url(e,t){if(e==null)return;if(e.startsWith("http"))return{type:"url",value:e};let r=Jq(e,t);return await ni(r)?{type:"filepath",value:r}:{type:"url",value:e}}function Z5(e){if(e!=null){if(typeof e=="string")return[Jr.RoleId(e)];if(e.length!==0)return e.map(Jr.RoleId)}}function Qio(e){if(e!=null){if(typeof e=="string")return[e];if(e.length!==0)return e}}var x6h=require("fs/promises");var W6h=It.strictObject({organization:It.string(),version:It.string()});async function _Ae({directory:e,context:t}){let r=ot(e,Pe.of(IC)),i=await(0,x6h.readFile)(r),n=JSON.parse(i.toString()),a=await o0u({schema:W6h,value:n,context:t,filepathBeingParsed:r});return{_absolutePath:r,rawConfig:a,organization:a.organization,version:a.version}}var P={TYPESCRIPT:"fernapi/fern-typescript",TYPESCRIPT_SDK:"fernapi/fern-typescript-sdk",TYPESCRIPT_NODE_SDK:"fernapi/fern-typescript-node-sdk",TYPESCRIPT_BROWSER_SDK:"fernapi/fern-typescript-browser-sdk",TYPESCRIPT_EXPRESS:"fernapi/fern-typescript-express",JAVA:"fernapi/fern-java",JAVA_MODEL:"fernapi/fern-java-model",JAVA_SDK:"fernapi/fern-java-sdk",JAVA_SPRING:"fernapi/fern-java-spring",PYTHON_FASTAPI:"fernapi/fern-fastapi-server",PYTHON_PYDANTIC:"fernapi/fern-pydantic-model",PYTHON_SDK:"fernapi/fern-python-sdk",GO_MODEL:"fernapi/fern-go-model",GO_SDK:"fernapi/fern-go-sdk",GO_FIBER:"fernapi/fern-go-fiber",RUBY_MODEL:"fernapi/fern-ruby-model",RUBY_SDK:"fernapi/fern-ruby-sdk",CSHARP_MODEL:"fernapi/fern-csharp-model",CSHARP_SDK:"fernapi/fern-csharp-sdk",SWIFT_MODEL:"fernapi/fern-swift-model",SWIFT_SDK:"fernapi/fern-swift-sdk",PHP_MODEL:"fernapi/fern-php-model",PHP_SDK:"fernapi/fern-php-sdk",RUST_MODEL:"fernapi/fern-rust-model",RUST_SDK:"fernapi/fern-rust-sdk",OPENAPI:"fernapi/fern-openapi",STOPLIGHT:"fernapi/fern-stoplight",POSTMAN:"fernapi/fern-postman",OPENAPI_PYTHON_CLIENT:"fernapi/openapi-python-client"};var Uio={[P.JAVA]:{version:"2.38.1"},[P.TYPESCRIPT_EXPRESS]:{version:"0.18.4",output:{location:"local-file-system",path:"../src/fern"}},[P.JAVA_MODEL]:{version:"1.0.0"},[P.JAVA_SDK]:{version:"2.38.1",output:{location:"local-file-system",path:"../sdks/java/src/main/java/"}},[P.JAVA_SPRING]:{version:"0.9.2",output:{location:"local-file-system",path:"../src/main/java/com/fern"}},[P.TYPESCRIPT]:{version:"0.0.247"},[P.TYPESCRIPT_SDK]:{version:"2.3.2",output:{location:"local-file-system",path:"../sdks/typescript"}},[P.TYPESCRIPT_NODE_SDK]:{version:"2.3.2",output:{location:"local-file-system",path:"../sdks/typescript"}},[P.TYPESCRIPT_BROWSER_SDK]:{version:"1.0.0",output:{location:"local-file-system",path:"../sdks/typescript"}},[P.PYTHON_PYDANTIC]:{version:"1.4.7"},[P.PYTHON_FASTAPI]:{version:"1.7.0",output:{location:"local-file-system",path:"../src/fern"}},[P.PYTHON_SDK]:{version:"4.23.2",output:{location:"local-file-system",path:"../sdks/python"}},[P.GO_FIBER]:{version:"0.23.5"},[P.GO_MODEL]:{version:"0.23.5"},[P.GO_SDK]:{version:"1.4.0",output:{location:"local-file-system",path:"../sdks/go"},config:{module:{path:"sdk"}}},[P.RUBY_MODEL]:{version:"0.0.8"},[P.RUBY_SDK]:{version:"0.8.2",output:{location:"local-file-system",path:"../sdks/ruby"}},[P.OPENAPI]:{version:"0.1.7",config:{format:"yaml"},output:{location:"local-file-system",path:"../openapi"}},[P.STOPLIGHT]:{version:"0.0.28",config:{format:"yaml"}},[P.POSTMAN]:{version:"0.4.0",output:{location:"local-file-system",path:"../postman"}},[P.OPENAPI_PYTHON_CLIENT]:{version:"0.0.0",output:{location:"local-file-system",path:"../sdks/python"},config:{format:"yaml"}},[P.CSHARP_MODEL]:{version:"0.0.1"},[P.CSHARP_SDK]:{version:"2.0.2",output:{location:"local-file-system",path:"../sdks/csharp"}},[P.SWIFT_MODEL]:{version:"0.0.0"},[P.SWIFT_SDK]:{version:"0.0.0",output:{location:"local-file-system",path:"../sdks/swift/sdk"}},[P.PHP_MODEL]:{version:"0.0.0"},[P.PHP_SDK]:{version:"1.16.3",output:{location:"local-file-system",path:"../sdks/php/sdk"}},[P.RUST_MODEL]:{version:"0.0.1",output:{location:"local-file-system",path:"../models/rust"}},[P.RUST_SDK]:{version:"0.0.1",output:{location:"local-file-system",path:"../sdks/rust"}}};var G6h="fernapi";function IU(e){return e.includes("/")?e:`${G6h}/${e}`}function lrl(e){let t=`${G6h}/`;return e.startsWith(t)?e.slice(t.length):e}function oen(e,t){let r=zqB(e);return r??t.failAndThrow("Unrecognized generator: "+e)}function zqB(e){if(e=IU(e),NqB(e))return e}function NqB(e){return Object.values(P).includes(e)}var M0u=se(KYa(),1),H6h=se(OX(),1);async function l6t({generatorName:e,cliVersion:t,channel:r,currentGeneratorVersion:i,includeMajor:n,context:a}){let o=H6h.default.parse(i),c=new M0u.FernRegistryClient({environment:"https://registry.buildwithfern.com"});a?.logger.debug(`Getting latest version for ${e} with CLI version ${t}, includeMajor: ${n}, prior version: ${o}`);let d={generator:FqB(e,a),releaseTypes:[r??M0u.FernRegistry.generators.ReleaseType.Ga],cliVersion:t==="0.0.0"?void 0:t};!n&&o!=null&&(d.generatorMajorVersion=o.major);let s=await c.generators.versions.getLatestGeneratorRelease(d);if(s.ok)return s.body.version}function FqB(e,t){switch(e.startsWith("fernapi/")&&(e=e.replace("fernapi/","")),e){case"fern-python-sdk":return"python-sdk";case"fern-pydantic-model":return"pydantic";case"fern-fastapi-server":return"fastapi";case"fern-typescript-browser-sdk":case"fern-typescript-node-sdk":case"fern-typescript-sdk":return"ts-sdk";case"fern-typescript-express":return"ts-express";case"fern-java-sdk":return"java-sdk";case"fern-java-model":return"java-model";case"fern-java-spring":return"java-spring";case"fern-go-sdk":return"go-sdk";case"fern-go-model":return"go-model";case"fern-go-fiber":return"go-fiber";case"fern-csharp-sdk":return"csharp-sdk";case"fern-csharp-model":return"csharp-model";case"fern-ruby-sdk":return"ruby-sdk";case"fern-ruby-model":return"ruby-model";case"fern-postman":return"postman";case"fern-openapi":return"openapi";case"fern-php-sdk":return"php-sdk";case"fern-php-model":return"php-model";case"fern-rust-sdk":return"rust-sdk";case"fern-rust-model":return"rust-model";case"fern-swift-sdk":return"swift-sdk";case"fern-swift-model":return"swift-model";default:return t?.logger.warn(`Unrecognized generator name found, attempting to parse manually: ${e}`),e.startsWith("fern-")?e.replace("fern-",""):e}}async function K6h({generatorsConfiguration:e,groupName:t=e[Ki.DEFAULT_GROUP_GENERATORS_CONFIG_KEY],context:r,update:i}){if(t==null)return r.failAndThrow("No group specified.");let n=e.groups??={},a=n[t];if(a==null){let o=n[t]??={generators:[]};await i(o,t)}else await i(a,t);return e}async function frl({generatorName:e,generatorsConfiguration:t,groupName:r=t[Rca],context:i,cliVersion:n}){let a=oen(e,i),o=lrl(a),c=Uio[a];return await K6h({generatorsConfiguration:t,groupName:r,context:i,update:async d=>{d.generators.some(s=>IU(s.name)===a)&&i.failAndThrow(`${e} is already installed in group ${r}.`),d.generators.push({name:o,...c,version:await l6t({cliVersion:n,generatorName:a,context:i,channel:void 0})??c.version})}})}var f6t=require("fs/promises"),H0n=se(require("path"),1);var DGh=require("buffer"),L0u=se(J6h(),1),F0u=se(LD(),1),g9h=require("child_process"),rHh=se(prl(),1),pHh=require("path"),Dya=se(prl(),1),BHh=require("events"),Trl=Object.defineProperty,GqB=Object.getOwnPropertyDescriptor,Rrl=Object.getOwnPropertyNames,HqB=Object.prototype.hasOwnProperty,Ua=(e,t)=>function(){return e&&(t=(0,e[Rrl(e)[0]])(e=0)),t},KqB=(e,t)=>function(){return t||(0,e[Rrl(e)[0]])((t={exports:{}}).exports,t),t.exports},Xq=(e,t)=>{for(var r in t)Trl(e,r,{get:t[r],enumerable:!0})},$qB=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Rrl(t))!HqB.call(e,n)&&n!==r&&Trl(e,n,{get:()=>t[n],enumerable:!(i=GqB(t,n))||i.enumerable});return e},FC=e=>$qB(Trl({},"__esModule",{value:!0}),e);function JqB(...e){let t=new String(e);return U0u.set(t,e),t}function R0u(e){return e instanceof String&&U0u.has(e)}function Y6h(e){return U0u.get(e)||[]}var U0u,xio=Ua({"src/lib/args/pathspec.ts"(){"use strict";U0u=new WeakMap}}),d8i,sen=Ua({"src/lib/errors/git-error.ts"(){"use strict";d8i=class extends Error{constructor(e,t){super(t),this.task=e,Object.setPrototypeOf(this,new.target.prototype)}}}}),Gio,Iya=Ua({"src/lib/errors/git-response-error.ts"(){"use strict";sen(),Gio=class extends d8i{constructor(e,t){super(void 0,t||String(e)),this.git=e}}}}),SGh,MGh=Ua({"src/lib/errors/task-configuration-error.ts"(){"use strict";sen(),SGh=class extends d8i{constructor(e){super(void 0,e)}}}});function BGh(e){return typeof e!="function"?G0n:e}function IGh(e){return typeof e=="function"&&e!==G0n}function CGh(e,t){let r=e.indexOf(t);return r<=0?[e,""]:[e.substr(0,r),e.substr(r+1)]}function qGh(e,t=0){return TGh(e)&&e.length>t?e[t]:void 0}function x0n(e,t=0){if(TGh(e)&&e.length>t)return e[e.length-1-t]}function TGh(e){return G0u(e)}function Hio(e="",t=!0,r=`
|
|
1588
1588
|
`){return e.split(r).reduce((i,n)=>{let a=t?n.trim():n;return a&&i.push(a),i},[])}function zrl(e,t){return Hio(e,!0).map(r=>t(r))}function Nrl(e){return(0,L0u.exists)(e,L0u.FOLDER)}function wP(e,t){return Array.isArray(e)?e.includes(t)||e.push(t):e.add(t),t}function RGh(e,t){return Array.isArray(e)&&!e.includes(t)&&e.push(t),e}function V0u(e,t){if(Array.isArray(e)){let r=e.indexOf(t);r>=0&&e.splice(r,1)}else e.delete(t);return t}function Ztr(e){return Array.isArray(e)?e:[e]}function zGh(e){return e.replace(/[\s-]+(.)/g,(t,r)=>r.toUpperCase())}function Cya(e){return Ztr(e).map(t=>t instanceof String?t:String(t))}function ES(e,t=0){if(e==null)return t;let r=parseInt(e,10);return Number.isNaN(r)?t:r}function Vio(e,t){let r=[];for(let i=0,n=e.length;i<n;i++)r.push(t,e[i]);return r}function Wio(e){return(Array.isArray(e)?DGh.Buffer.concat(e):e).toString("utf-8")}function NGh(e,t){let r={};return t.forEach(i=>{e[i]!==void 0&&(r[i]=e[i])}),r}function Orl(e=0){return new Promise(t=>setTimeout(t,e))}function mrl(e){if(e!==!1)return e}var Bya,G0n,Kio,W0u=Ua({"src/lib/utils/util.ts"(){"use strict";Frl(),Bya="\0",G0n=()=>{},Kio=Object.prototype.toString.call.bind(Object.prototype.toString)}});function bAe(e,t,r){return t(e)?e:arguments.length>2?r:void 0}function Arl(e,t){let r=R0u(e)?"string":typeof e;return/number|string|boolean/.test(r)&&(!t||!t.includes(r))}function x0u(e){return!!e&&Kio(e)==="[object Object]"}function FGh(e){return typeof e=="function"}var $io,QGh,CU,z0u,G0u,Frl=Ua({"src/lib/utils/argument-filters.ts"(){"use strict";xio(),W0u(),$io=e=>Array.isArray(e),QGh=e=>typeof e=="number",CU=e=>typeof e=="string",z0u=e=>CU(e)||Array.isArray(e)&&e.every(CU),G0u=e=>e==null||"number|boolean|function".includes(typeof e)?!1:typeof e.length=="number"}}),Prl,YqB=Ua({"src/lib/utils/exit-codes.ts"(){"use strict";Prl=(e=>(e[e.SUCCESS=0]="SUCCESS",e[e.ERROR=1]="ERROR",e[e.NOT_FOUND=-2]="NOT_FOUND",e[e.UNCLEAN=128]="UNCLEAN",e))(Prl||{})}}),N0u,XqB=Ua({"src/lib/utils/git-output-streams.ts"(){"use strict";N0u=class UGh{constructor(t,r){this.stdOut=t,this.stdErr=r}asStrings(){return new UGh(this.stdOut.toString("utf8"),this.stdErr.toString("utf8"))}}}});function ZqB(){throw new Error("LineParser:useMatches not implemented")}var l_,uen,kqB=Ua({"src/lib/utils/line-parser.ts"(){"use strict";l_=class{constructor(e,t){this.matches=[],this.useMatches=ZqB,this.parse=(r,i)=>(this.resetMatches(),this._regExp.every((n,a)=>this.addMatch(n,a,r(a)))?this.useMatches(i,this.prepareMatches())!==!1:!1),this._regExp=Array.isArray(e)?e:[e],t&&(this.useMatches=t)}resetMatches(){this.matches.length=0}prepareMatches(){return this.matches}addMatch(e,t,r){let i=r&&e.exec(r);return i&&this.pushMatch(t,i),!!i}pushMatch(e,t){this.matches.push(...t.slice(1))}},uen=class extends l_{addMatch(e,t,r){return/^remote:\s/.test(String(r))&&super.addMatch(e,t,r)}pushMatch(e,t){(e>0||t.length>1)&&super.pushMatch(e,t)}}}});function LGh(...e){let t=process.cwd(),r=Object.assign({baseDir:t,...VGh},...e.filter(i=>typeof i=="object"&&i));return r.baseDir=r.baseDir||t,r.trimmed=r.trimmed===!0,r}var VGh,e1B=Ua({"src/lib/utils/simple-git-options.ts"(){"use strict";VGh={binary:"git",maxConcurrentProcesses:5,config:[],trimmed:!1}}});function Qrl(e,t=[]){return x0u(e)?Object.keys(e).reduce((r,i)=>{let n=e[i];if(R0u(n))r.push(n);else if(Arl(n,["boolean"]))r.push(i+"="+n);else if(Array.isArray(n))for(let a of n)Arl(a,["string","number"])||r.push(i+"="+a);else r.push(i);return r},t):t}function v2(e,t=0,r=!1){let i=[];for(let n=0,a=t<0?e.length:t;n<a;n++)"string|number".includes(typeof e[n])&&i.push(String(e[n]));return Qrl(Url(e),i),r||i.push(...t1B(e)),i}function t1B(e){let t=typeof x0n(e)=="function";return Cya(bAe(x0n(e,t?1:0),$io,[]))}function Url(e){let t=FGh(x0n(e));return bAe(x0n(e,t?1:0),x0u)}function QC(e,t=!0){let r=BGh(x0n(e));return t||IGh(r)?r:void 0}var r1B=Ua({"src/lib/utils/task-options.ts"(){"use strict";Frl(),W0u(),xio()}});function jrl(e,t){return e(t.stdOut,t.stdErr)}function O2(e,t,r,i=!0){return Ztr(r).forEach(n=>{for(let a=Hio(n,i),o=0,c=a.length;o<c;o++){let d=(s=0)=>{if(!(o+s>=c))return a[o+s]};t.some(({parse:s})=>s(d,e))}}),e}var i1B=Ua({"src/lib/utils/task-parser.ts"(){"use strict";W0u()}}),WGh={};Xq(WGh,{ExitCodes:()=>Prl,GitOutputStreams:()=>N0u,LineParser:()=>l_,NOOP:()=>G0n,NULL:()=>Bya,RemoteLineParser:()=>uen,append:()=>wP,appendTaskOptions:()=>Qrl,asArray:()=>Ztr,asCamelCase:()=>zGh,asFunction:()=>BGh,asNumber:()=>ES,asStringArray:()=>Cya,bufferToString:()=>Wio,callTaskParser:()=>jrl,createInstanceConfig:()=>LGh,delay:()=>Orl,filterArray:()=>$io,filterFunction:()=>FGh,filterHasLength:()=>G0u,filterNumber:()=>QGh,filterPlainObject:()=>x0u,filterPrimitives:()=>Arl,filterString:()=>CU,filterStringOrStringArray:()=>z0u,filterType:()=>bAe,first:()=>qGh,folderExists:()=>Nrl,forEachLineWithContent:()=>zrl,getTrailingOptions:()=>v2,including:()=>RGh,isUserFunction:()=>IGh,last:()=>x0n,objectToString:()=>Kio,orVoid:()=>mrl,parseStringResponse:()=>O2,pick:()=>NGh,prefixedArray:()=>Vio,remove:()=>V0u,splitOn:()=>CGh,toLinesWithContent:()=>Hio,trailingFunctionArgument:()=>QC,trailingOptionsArgument:()=>Url});var Td=Ua({"src/lib/utils/index.ts"(){"use strict";Frl(),YqB(),XqB(),kqB(),e1B(),r1B(),i1B(),W0u()}}),xGh={};Xq(xGh,{CheckRepoActions:()=>wrl,checkIsBareRepoTask:()=>HGh,checkIsRepoRootTask:()=>GGh,checkIsRepoTask:()=>n1B});function n1B(e){switch(e){case"bare":return HGh();case"root":return GGh()}return{commands:["rev-parse","--is-inside-work-tree"],format:"utf-8",onError:H0u,parser:Lrl}}function GGh(){return{commands:["rev-parse","--git-dir"],format:"utf-8",onError:H0u,parser(t){return/^\.(git)?$/.test(t.trim())}}}function HGh(){return{commands:["rev-parse","--is-bare-repository"],format:"utf-8",onError:H0u,parser:Lrl}}function a1B(e){return/(Not a git repository|Kein Git-Repository)/i.test(String(e))}var wrl,H0u,Lrl,KGh=Ua({"src/lib/tasks/check-is-repo.ts"(){"use strict";Td(),wrl=(e=>(e.BARE="bare",e.IN_TREE="tree",e.IS_REPO_ROOT="root",e))(wrl||{}),H0u=({exitCode:e},t,r,i)=>{if(e===128&&a1B(t))return r(Buffer.from("false"));i(t)},Lrl=e=>e.trim()==="true"}});function o1B(e,t){let r=new $Gh(e),i=e?YGh:JGh;return Hio(t).forEach(n=>{let a=n.replace(i,"");r.paths.push(a),(XGh.test(a)?r.folders:r.files).push(a)}),r}var $Gh,JGh,YGh,XGh,u1B=Ua({"src/lib/responses/CleanSummary.ts"(){"use strict";Td(),$Gh=class{constructor(e){this.dryRun=e,this.paths=[],this.files=[],this.folders=[]}},JGh=/^[a-z]+\s*/i,YGh=/^[a-z]+\s+[a-z]+\s*/i,XGh=/\/$/}}),Erl={};Xq(Erl,{EMPTY_COMMANDS:()=>K0u,adhocExecTask:()=>ZGh,configurationErrorTask:()=>g2,isBufferTask:()=>e9h,isEmptyTask:()=>t9h,straightThroughBufferTask:()=>kGh,straightThroughStringTask:()=>K7});function ZGh(e){return{commands:K0u,format:"empty",parser:e}}function g2(e){return{commands:K0u,format:"empty",parser(){throw typeof e=="string"?new SGh(e):e}}}function K7(e,t=!1){return{commands:e,format:"utf-8",parser(r){return t?String(r).trim():r}}}function kGh(e){return{commands:e,format:"buffer",parser(t){return t}}}function e9h(e){return e.format==="buffer"}function t9h(e){return e.format==="empty"||!e.commands.length}var K0u,Yq=Ua({"src/lib/tasks/task.ts"(){"use strict";MGh(),K0u=[]}}),r9h={};Xq(r9h,{CONFIG_ERROR_INTERACTIVE_MODE:()=>Vrl,CONFIG_ERROR_MODE_REQUIRED:()=>Wrl,CONFIG_ERROR_UNKNOWN_OPTION:()=>xrl,CleanOptions:()=>I0u,cleanTask:()=>i9h,cleanWithOptionsTask:()=>s1B,isCleanOptionsArray:()=>c1B});function s1B(e,t){let{cleanMode:r,options:i,valid:n}=l1B(e);return r?n.options?(i.push(...t),i.some(p1B)?g2(Vrl):i9h(r,i)):g2(xrl+JSON.stringify(e)):g2(Wrl)}function i9h(e,t){return{commands:["clean",`-${e}`,...t],format:"utf-8",parser(i){return o1B(e==="n",i)}}}function c1B(e){return Array.isArray(e)&&e.every(t=>Grl.has(t))}function l1B(e){let t,r=[],i={cleanMode:!1,options:!0};return e.replace(/[^a-z]i/g,"").split("").forEach(n=>{f1B(n)?(t=n,i.cleanMode=!0):i.options=i.options&&d1B(r[r.length]=`-${n}`)}),{cleanMode:t,options:r,valid:i}}function f1B(e){return e==="f"||e==="n"}function d1B(e){return/^-[a-z]$/i.test(e)&&Grl.has(e.charAt(1))}function p1B(e){return/^-[^\-]/.test(e)?e.indexOf("i")>0:e==="--interactive"}var Vrl,Wrl,xrl,I0u,Grl,n9h=Ua({"src/lib/tasks/clean.ts"(){"use strict";u1B(),Td(),Yq(),Vrl="Git clean interactive mode is not supported",Wrl='Git clean mode parameter ("n" or "f") is required',xrl="Git clean unknown option found in: ",I0u=(e=>(e.DRY_RUN="n",e.FORCE="f",e.IGNORED_INCLUDED="x",e.IGNORED_ONLY="X",e.EXCLUDING="e",e.QUIET="q",e.RECURSIVE="d",e))(I0u||{}),Grl=new Set(["i",...Cya(Object.values(I0u))])}});function _1B(e){let t=new o9h;for(let r of a9h(e))t.addValue(r.file,String(r.key),r.value);return t}function h1B(e,t){let r=null,i=[],n=new Map;for(let a of a9h(e,t))a.key===t&&(i.push(r=a.value),n.has(a.file)||n.set(a.file,[]),n.get(a.file).push(r));return{key:t,paths:Array.from(n.keys()),scopes:n,value:r,values:i}}function y1B(e){return e.replace(/^(file):/,"")}function*a9h(e,t=null){let r=e.split("\0");for(let i=0,n=r.length-1;i<n;){let a=y1B(r[i++]),o=r[i++],c=t;if(o.includes(`
|
|
1589
1589
|
`)){let d=CGh(o,`
|
|
1590
1590
|
`);c=d[0],o=d[1]}yield{file:a,key:c,value:o}}}var o9h,b1B=Ua({"src/lib/responses/ConfigList.ts"(){"use strict";Td(),o9h=class{constructor(){this.files=[],this.values=Object.create(null)}get all(){return this._all||(this._all=this.files.reduce((e,t)=>Object.assign(e,this.values[t]),{})),this._all}addFile(e){if(!(e in this.values)){let t=x0n(this.files);this.values[e]=t?Object.create(this.values[t]):{},this.files.push(e)}return this.values[e]}addValue(e,t,r){let i=this.addFile(e);Object.hasOwn(i,t)?Array.isArray(i[t])?i[t].push(r):i[t]=[i[t],r]:i[t]=r,this._all=void 0}}}});function _rl(e,t){return typeof e=="string"&&Object.hasOwn(Srl,e)?e:t}function v1B(e,t,r,i){let n=["config",`--${i}`];return r&&n.push("--add"),n.push(e,t),{commands:n,format:"utf-8",parser(a){return a}}}function g1B(e,t){let r=["config","--null","--show-origin","--get-all",e];return t&&r.splice(1,0,`--${t}`),{commands:r,format:"utf-8",parser(i){return h1B(i,e)}}}function O1B(e){let t=["config","--list","--show-origin","--null"];return e&&t.push(`--${e}`),{commands:t,format:"utf-8",parser(r){return _1B(r)}}}function m1B(){return{addConfig(e,t,...r){return this._runTask(v1B(e,t,r[0]===!0,_rl(r[1],"local")),QC(arguments))},getConfig(e,t){return this._runTask(g1B(e,_rl(t,void 0)),QC(arguments))},listConfig(...e){return this._runTask(O1B(_rl(e[0],void 0)),QC(arguments))}}}var Srl,u9h=Ua({"src/lib/tasks/config.ts"(){"use strict";b1B(),Td(),Srl=(e=>(e.system="system",e.global="global",e.local="local",e.worktree="worktree",e))(Srl||{})}});function A1B(e){return s9h.has(e)}var hrl,s9h,c9h=Ua({"src/lib/tasks/diff-name-status.ts"(){"use strict";hrl=(e=>(e.ADDED="A",e.COPIED="C",e.DELETED="D",e.MODIFIED="M",e.RENAMED="R",e.CHANGED="T",e.UNMERGED="U",e.UNKNOWN="X",e.BROKEN="B",e))(hrl||{}),s9h=new Set(Object.values(hrl))}});function P1B(...e){return new f9h().param(...e)}function j1B(e){let t=new Set,r={};return zrl(e,i=>{let[n,a,o]=i.split(Bya);t.add(n),(r[n]=r[n]||[]).push({line:ES(a),path:n,preview:o})}),{paths:t,results:r}}function w1B(){return{grep(e){let t=QC(arguments),r=v2(arguments);for(let n of l9h)if(r.includes(n))return this._runTask(g2(`git.grep: use of "${n}" is not supported.`),t);typeof e=="string"&&(e=P1B().param(e));let i=["grep","--null","-n","--full-name",...r,...e];return this._runTask({commands:i,format:"utf-8",parser(n){return j1B(n)}},t)}}}var l9h,Lio,X6h,f9h,d9h=Ua({"src/lib/tasks/grep.ts"(){"use strict";Td(),Yq(),l9h=["-h"],Lio=Symbol("grepQuery"),f9h=class{constructor(){this[X6h]=[]}*[(X6h=Lio,Symbol.iterator)](){for(let e of this[Lio])yield e}and(...e){return e.length&&this[Lio].push("--and","(",...Vio(e,"-e"),")"),this}param(...e){return this[Lio].push(...Vio(e,"-e")),this}}}}),p9h={};Xq(p9h,{ResetMode:()=>C0u,getResetMode:()=>S1B,resetTask:()=>E1B});function E1B(e,t){let r=["reset"];return _9h(e)&&r.push(`--${e}`),r.push(...t),K7(r)}function S1B(e){if(_9h(e))return e;switch(typeof e){case"string":case"undefined":return"soft"}}function _9h(e){return typeof e=="string"&&h9h.includes(e)}var C0u,h9h,y9h=Ua({"src/lib/tasks/reset.ts"(){"use strict";Td(),Yq(),C0u=(e=>(e.MIXED="mixed",e.SOFT="soft",e.HARD="hard",e.MERGE="merge",e.KEEP="keep",e))(C0u||{}),h9h=Cya(Object.values(C0u))}});function M1B(){return(0,F0u.default)("simple-git")}function Z6h(e,t,r){return!t||!String(t).replace(/\s*/,"")?r?(i,...n)=>{e(i,...n),r(i,...n)}:e:(i,...n)=>{e(`%s ${i}`,t,...n),r&&r(i,...n)}}function D1B(e,t,{namespace:r}){if(typeof e=="string")return e;let i=t&&t.namespace||"";return i.startsWith(r)?i.substr(r.length+1):i||r}function Hrl(e,t,r,i=M1B()){let n=e&&`[${e}]`||"",a=[],o=typeof t=="string"?i.extend(t):t,c=D1B(bAe(t,CU),o,i);return s(r);function d(u,f){return wP(a,Hrl(e,c.replace(/^[^:]+/,u),f,i))}function s(u){let f=u&&`[${u}]`||"",p=o&&Z6h(o,f)||G0n,_=Z6h(i,`${n} ${f}`,p);return Object.assign(o?p:_,{label:e,sibling:d,info:_,step:s})}}var b9h=Ua({"src/lib/git-logger.ts"(){"use strict";Td(),F0u.default.formatters.L=e=>String(G0u(e)?e.length:"-"),F0u.default.formatters.B=e=>Buffer.isBuffer(e)?e.toString("utf8"):Kio(e)}}),v9h,B1B=Ua({"src/lib/runners/tasks-pending-queue.ts"(){"use strict";sen(),b9h(),v9h=class Mrl{constructor(t="GitExecutor"){this.logLabel=t,this._queue=new Map}withProgress(t){return this._queue.get(t)}createProgress(t){let r=Mrl.getName(t.commands[0]),i=Hrl(this.logLabel,r);return{task:t,logger:i,name:r}}push(t){let r=this.createProgress(t);return r.logger("Adding task to the queue, commands = %o",t.commands),this._queue.set(t,r),r}fatal(t){for(let[r,{logger:i}]of Array.from(this._queue.entries()))r===t.task?(i.info("Failed %o",t),i("Fatal exception, any as-yet un-started tasks run through this executor will not be attempted")):i.info("A fatal exception occurred in a previous task, the queue has been purged: %o",t.message),this.complete(r);if(this._queue.size!==0)throw new Error(`Queue size should be zero after fatal: ${this._queue.size}`)}complete(t){this.withProgress(t)&&this._queue.delete(t)}attempt(t){let r=this.withProgress(t);if(!r)throw new d8i(void 0,"TasksPendingQueue: attempt called for an unknown task");return r.logger("Starting task"),r}static getName(t="empty"){return`task:${t}:${++Mrl.counter}`}static{this.counter=0}}}});function W0n(e,t){return{method:qGh(e.commands)||"",commands:t}}function I1B(e,t){return r=>{t("[ERROR] child process exception %o",r),e.push(Buffer.from(String(r.stack),"ascii"))}}function k6h(e,t,r,i){return n=>{r("%s received %L bytes",t,n),i("%B",n),e.push(n)}}var Drl,C1B=Ua({"src/lib/runners/git-executor-chain.ts"(){"use strict";sen(),Yq(),Td(),B1B(),Drl=class{constructor(e,t,r){this._executor=e,this._scheduler=t,this._plugins=r,this._chain=Promise.resolve(),this._queue=new v9h}get cwd(){return this._cwd||this._executor.cwd}set cwd(e){this._cwd=e}get env(){return this._executor.env}get outputHandler(){return this._executor.outputHandler}chain(){return this}push(e){return this._queue.push(e),this._chain=this._chain.then(()=>this.attemptTask(e))}async attemptTask(e){let t=await this._scheduler.next(),r=()=>this._queue.complete(e);try{let{logger:i}=this._queue.attempt(e);return await(t9h(e)?this.attemptEmptyTask(e,i):this.attemptRemoteTask(e,i))}catch(i){throw this.onFatalException(e,i)}finally{r(),t()}}onFatalException(e,t){let r=t instanceof d8i?Object.assign(t,{task:e}):new d8i(e,t&&String(t));return this._chain=Promise.resolve(),this._queue.fatal(r),r}async attemptRemoteTask(e,t){let r=this._plugins.exec("spawn.binary","",W0n(e,e.commands)),i=this._plugins.exec("spawn.args",[...e.commands],W0n(e,e.commands)),n=await this.gitResponse(e,r,i,this.outputHandler,t.step("SPAWN")),a=await this.handleTaskData(e,i,n,t.step("HANDLE"));return t("passing response to task's parser as a %s",e.format),e9h(e)?jrl(e.parser,a):jrl(e.parser,a.asStrings())}async attemptEmptyTask(e,t){return t("empty task bypassing child process to call to task's parser"),e.parser(this)}handleTaskData(e,t,r,i){let{exitCode:n,rejection:a,stdOut:o,stdErr:c}=r;return new Promise((d,s)=>{i("Preparing to handle process response exitCode=%d stdOut=",n);let{error:u}=this._plugins.exec("task.error",{error:a},{...W0n(e,t),...r});if(u&&e.onError)return i.info("exitCode=%s handling with custom error handler"),e.onError(r,u,f=>{i.info("custom error handler treated as success"),i("custom error returned a %s",Kio(f)),d(new N0u(Array.isArray(f)?Buffer.concat(f):f,Buffer.concat(c)))},s);if(u)return i.info("handling as error: exitCode=%s stdErr=%s rejection=%o",n,c.length,a),s(u);i.info("retrieving task output complete"),d(new N0u(Buffer.concat(o),Buffer.concat(c)))})}async gitResponse(e,t,r,i,n){let a=n.sibling("output"),o=this._plugins.exec("spawn.options",{cwd:this.cwd,env:this.env,windowsHide:!0},W0n(e,e.commands));return new Promise(c=>{let d=[],s=[];n.info("%s %o",t,r),n("%O",o);let u=this._beforeSpawn(e,r);if(u)return c({stdOut:d,stdErr:s,exitCode:9901,rejection:u});this._plugins.exec("spawn.before",void 0,{...W0n(e,r),kill(p){u=p||u}});let f=(0,g9h.spawn)(t,r,o);f.stdout.on("data",k6h(d,"stdOut",n,a.step("stdOut"))),f.stderr.on("data",k6h(s,"stdErr",n,a.step("stdErr"))),f.on("error",I1B(s,n)),i&&(n("Passing child process stdOut/stdErr to custom outputHandler"),i(t,f.stdout,f.stderr,[...r])),this._plugins.exec("spawn.after",void 0,{...W0n(e,r),spawned:f,close(p,_){c({stdOut:d,stdErr:s,exitCode:p,rejection:u||_})},kill(p){f.killed||(u=p,f.kill("SIGINT"))}})})}_beforeSpawn(e,t){let r;return this._plugins.exec("spawn.before",void 0,{...W0n(e,t),kill(i){r=i||r}}),r}}}}),O9h={};Xq(O9h,{GitExecutor:()=>m9h});var m9h,q1B=Ua({"src/lib/runners/git-executor.ts"(){"use strict";C1B(),m9h=class{constructor(e,t,r){this.cwd=e,this._scheduler=t,this._plugins=r,this._chain=new Drl(this,this._scheduler,this._plugins)}chain(){return new Drl(this,this._scheduler,this._plugins)}push(e){return this._chain.push(e)}}}});function T1B(e,t,r=G0n){let i=a=>{r(null,a)},n=a=>{a?.task===e&&r(a instanceof Gio?R1B(a):a,void 0)};t.then(i,n)}function R1B(e){let t=i=>{console.warn(`simple-git deprecation notice: accessing GitResponseError.${i} should be GitResponseError.git.${i}, this will no longer be available in version 3`),t=G0n};return Object.create(e,Object.getOwnPropertyNames(e.git).reduce(r,{}));function r(i,n){return n in e||(i[n]={enumerable:!1,configurable:!1,get(){return t(n),e.git[n]}}),i}}var z1B=Ua({"src/lib/task-callback.ts"(){"use strict";Iya(),Td()}});function eGh(e,t){return ZGh(r=>{if(!Nrl(e))throw new Error(`Git.cwd: cannot change to non-directory "${e}"`);return(t||r).cwd=e})}var N1B=Ua({"src/lib/tasks/change-working-directory.ts"(){"use strict";Td(),Yq()}});function yrl(e){let t=["checkout",...e];return t[1]==="-b"&&t.includes("-B")&&(t[1]=V0u(t,"-B")),K7(t)}function F1B(){return{checkout(){return this._runTask(yrl(v2(arguments,1)),QC(arguments))},checkoutBranch(e,t){return this._runTask(yrl(["-b",e,t,...v2(arguments)]),QC(arguments))},checkoutLocalBranch(e){return this._runTask(yrl(["-b",e,...v2(arguments)]),QC(arguments))}}}var Q1B=Ua({"src/lib/tasks/checkout.ts"(){"use strict";Td(),Yq()}});function U1B(){return{count:0,garbage:0,inPack:0,packs:0,prunePackable:0,size:0,sizeGarbage:0,sizePack:0}}function L1B(){return{countObjects(){return this._runTask({commands:["count-objects","--verbose"],format:"utf-8",parser(e){return O2(U1B(),[A9h],e)}})}}}var A9h,V1B=Ua({"src/lib/tasks/count-objects.ts"(){"use strict";Td(),A9h=new l_(/([a-z-]+): (\d+)$/,(e,[t,r])=>{let i=zGh(t);Object.hasOwn(e,i)&&(e[i]=ES(r))})}});function W1B(e){return O2({author:null,branch:"",commit:"",root:!1,summary:{changes:0,insertions:0,deletions:0}},P9h,e)}var P9h,x1B=Ua({"src/lib/parsers/parse-commit.ts"(){"use strict";Td(),P9h=[new l_(/^\[([^\s]+)( \([^)]+\))? ([^\]]+)/,(e,[t,r,i])=>{e.branch=t,e.commit=i,e.root=!!r}),new l_(/\s*Author:\s(.+)/i,(e,[t])=>{let r=t.split("<"),i=r.pop();!i||!i.includes("@")||(e.author={email:i.substr(0,i.length-1),name:r.join("<").trim()})}),new l_(/(\d+)[^,]*(?:,\s*(\d+)[^,]*)(?:,\s*(\d+))/g,(e,[t,r,i])=>{e.summary.changes=parseInt(t,10)||0,e.summary.insertions=parseInt(r,10)||0,e.summary.deletions=parseInt(i,10)||0}),new l_(/^(\d+)[^,]*(?:,\s*(\d+)[^(]+\(([+-]))?/,(e,[t,r,i])=>{e.summary.changes=parseInt(t,10)||0;let n=parseInt(r,10)||0;i==="-"?e.summary.deletions=n:i==="+"&&(e.summary.insertions=n)})]}});function G1B(e,t,r){return{commands:["-c","core.abbrev=40","commit",...Vio(e,"-m"),...t,...r],format:"utf-8",parser:W1B}}function H1B(){return{commit(t,...r){let i=QC(arguments),n=e(t)||G1B(Ztr(t),Ztr(bAe(r[0],z0u,[])),[...Cya(bAe(r[1],$io,[])),...v2(arguments,0,!0)]);return this._runTask(n,i)}};function e(t){return!z0u(t)&&g2("git.commit: requires the commit message to be supplied as a string/string[]")}}var K1B=Ua({"src/lib/tasks/commit.ts"(){"use strict";x1B(),Td(),Yq()}});function $1B(){return{firstCommit(){return this._runTask(K7(["rev-list","--max-parents=0","HEAD"],!0),QC(arguments))}}}var J1B=Ua({"src/lib/tasks/first-commit.ts"(){"use strict";Td(),Yq()}});function Y1B(e,t){let r=["hash-object",e];return t&&r.push("-w"),K7(r,!0)}var X1B=Ua({"src/lib/tasks/hash-object.ts"(){"use strict";Yq()}});function Z1B(e,t,r){let i=String(r).trim(),n;if(n=j9h.exec(i))return new q0u(e,t,!1,n[1]);if(n=w9h.exec(i))return new q0u(e,t,!0,n[1]);let a="",o=i.split(" ");for(;o.length;)if(o.shift()==="in"){a=o.join(" ");break}return new q0u(e,t,/^re/i.test(i),a)}var q0u,j9h,w9h,k1B=Ua({"src/lib/responses/InitSummary.ts"(){"use strict";q0u=class{constructor(e,t,r,i){this.bare=e,this.path=t,this.existing=r,this.gitDir=i}},j9h=/^Init.+ repository in (.+)$/,w9h=/^Rein.+ in (.+)$/}});function eTB(e){return e.includes(Krl)}function tTB(e=!1,t,r){let i=["init",...r];return e&&!eTB(i)&&i.splice(1,0,Krl),{commands:i,format:"utf-8",parser(n){return Z1B(i.includes("--bare"),t,n)}}}var Krl,rTB=Ua({"src/lib/tasks/init.ts"(){"use strict";k1B(),Krl="--bare"}});function $rl(e){for(let t=0;t<e.length;t++){let r=Jrl.exec(e[t]);if(r)return`--${r[1]}`}return""}function iTB(e){return Jrl.test(e)}var Jrl,Jio=Ua({"src/lib/args/log-format.ts"(){"use strict";Jrl=/^--(stat|numstat|name-only|name-status)(=|$)/}}),E9h,nTB=Ua({"src/lib/responses/DiffSummary.ts"(){"use strict";E9h=class{constructor(){this.changed=0,this.deletions=0,this.insertions=0,this.files=[]}}}});function S9h(e=""){let t=M9h[e];return r=>O2(new E9h,t,r,!1)}var brl,tGh,rGh,iGh,M9h,D9h=Ua({"src/lib/parsers/parse-diff-summary.ts"(){"use strict";Jio(),nTB(),c9h(),Td(),brl=[new l_(/^(.+)\s+\|\s+(\d+)(\s+[+\-]+)?$/,(e,[t,r,i=""])=>{e.files.push({file:t.trim(),changes:ES(r),insertions:i.replace(/[^+]/g,"").length,deletions:i.replace(/[^-]/g,"").length,binary:!1})}),new l_(/^(.+) \|\s+Bin ([0-9.]+) -> ([0-9.]+) ([a-z]+)/,(e,[t,r,i])=>{e.files.push({file:t.trim(),before:ES(r),after:ES(i),binary:!0})}),new l_(/(\d+) files? changed\s*((?:, \d+ [^,]+){0,2})/,(e,[t,r])=>{let i=/(\d+) i/.exec(r),n=/(\d+) d/.exec(r);e.changed=ES(t),e.insertions=ES(i?.[1]),e.deletions=ES(n?.[1])})],tGh=[new l_(/(\d+)\t(\d+)\t(.+)$/,(e,[t,r,i])=>{let n=ES(t),a=ES(r);e.changed++,e.insertions+=n,e.deletions+=a,e.files.push({file:i,changes:n+a,insertions:n,deletions:a,binary:!1})}),new l_(/-\t-\t(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,after:0,before:0,binary:!0})})],rGh=[new l_(/(.+)$/,(e,[t])=>{e.changed++,e.files.push({file:t,changes:0,insertions:0,deletions:0,binary:!1})})],iGh=[new l_(/([ACDMRTUXB])([0-9]{0,3})\t(.[^\t]*)(\t(.[^\t]*))?$/,(e,[t,r,i,n,a])=>{e.changed++,e.files.push({file:a??i,changes:0,insertions:0,deletions:0,binary:!1,status:mrl(A1B(t)&&t),from:mrl(!!a&&i!==a&&i),similarity:ES(r)})})],M9h={"":brl,"--stat":brl,"--numstat":tGh,"--name-status":iGh,"--name-only":rGh}}});function aTB(e,t){return t.reduce((r,i,n)=>(r[i]=e[n]||"",r),Object.create({diff:null}))}function B9h(e=Zrl,t=I9h,r=""){let i=S9h(r);return function(n){let a=Hio(n.trim(),!1,Yrl).map(function(o){let c=o.split(Xrl),d=aTB(c[0].split(e),t);return c.length>1&&c[1].trim()&&(d.diff=i(c[1])),d});return{all:a,latest:a.length&&a[0]||null,total:a.length}}}var Yrl,Xrl,Zrl,I9h,C9h=Ua({"src/lib/parsers/parse-list-log-summary.ts"(){"use strict";Td(),D9h(),Jio(),Yrl="\xF2\xF2\xF2\xF2\xF2\xF2 ",Xrl=" \xF2\xF2",Zrl=" \xF2 ",I9h=["hash","date","message","refs","author_name","author_email"]}}),q9h={};Xq(q9h,{diffSummaryTask:()=>oTB,validateLogFormatConfig:()=>$0u});function oTB(e){let t=$rl(e),r=["diff"];return t===""&&(t="--stat",r.push("--stat=4096")),r.push(...e),$0u(r)||{commands:r,format:"utf-8",parser:S9h(t)}}function $0u(e){let t=e.filter(iTB);if(t.length>1)return g2(`Summary flags are mutually exclusive - pick one of ${t.join(",")}`);if(t.length&&e.includes("-z"))return g2(`Summary flag ${t} parsing is not compatible with null termination option '-z'`)}var krl=Ua({"src/lib/tasks/diff.ts"(){"use strict";Jio(),D9h(),Yq()}});function uTB(e,t){let r=[],i=[];return Object.keys(e).forEach(n=>{r.push(n),i.push(String(e[n]))}),[r,i.join(t)]}function sTB(e){return Object.keys(e).reduce((t,r)=>(r in Brl||(t[r]=e[r]),t),{})}function T9h(e={},t=[]){let r=bAe(e.splitter,CU,Zrl),i=x0u(e.format)?e.format:{hash:"%H",date:e.strictDate===!1?"%ai":"%aI",message:"%s",refs:"%D",body:e.multiLine?"%B":"%b",author_name:e.mailMap!==!1?"%aN":"%an",author_email:e.mailMap!==!1?"%aE":"%ae"},[n,a]=uTB(i,r),o=[],c=[`--pretty=format:${Yrl}${a}${Xrl}`,...t],d=e.n||e["max-count"]||e.maxCount;if(d&&c.push(`--max-count=${d}`),e.from||e.to){let s=e.symmetric!==!1?"...":"..";o.push(`${e.from||""}${s}${e.to||""}`)}return CU(e.file)&&c.push("--follow",JqB(e.file)),Qrl(sTB(e),c),{fields:n,splitter:r,commands:[...c,...o]}}function cTB(e,t,r){let i=B9h(e,t,$rl(r));return{commands:["log",...r],format:"utf-8",parser:i}}function lTB(){return{log(...r){let i=QC(arguments),n=T9h(Url(arguments),Cya(bAe(arguments[0],$io,[]))),a=t(...r)||$0u(n.commands)||e(n);return this._runTask(a,i)}};function e(r){return cTB(r.splitter,r.fields,r.commands)}function t(r,i){return CU(r)&&CU(i)&&g2("git.log(string, string) should be replaced with git.log({ from: string, to: string })")}}var Brl,R9h=Ua({"src/lib/tasks/log.ts"(){"use strict";Jio(),xio(),C9h(),Td(),Yq(),krl(),Brl=(e=>(e[e["--pretty"]=0]="--pretty",e[e["max-count"]=1]="max-count",e[e.maxCount=2]="maxCount",e[e.n=3]="n",e[e.file=4]="file",e[e.format=5]="format",e[e.from=6]="from",e[e.to=7]="to",e[e.splitter=8]="splitter",e[e.symmetric=9]="symmetric",e[e.mailMap=10]="mailMap",e[e.multiLine=11]="multiLine",e[e.strictDate=12]="strictDate",e))(Brl||{})}}),T0u,z9h,fTB=Ua({"src/lib/responses/MergeSummary.ts"(){"use strict";T0u=class{constructor(e,t=null,r){this.reason=e,this.file=t,this.meta=r}toString(){return`${this.file}:${this.reason}`}},z9h=class{constructor(){this.conflicts=[],this.merges=[],this.result="success"}get failed(){return this.conflicts.length>0}get reason(){return this.result}toString(){return this.conflicts.length?`CONFLICTS: ${this.conflicts.join(", ")}`:"OK"}}}}),Irl,N9h,dTB=Ua({"src/lib/responses/PullSummary.ts"(){"use strict";Irl=class{constructor(){this.remoteMessages={all:[]},this.created=[],this.deleted=[],this.files=[],this.deletions={},this.insertions={},this.summary={changes:0,deletions:0,insertions:0}}},N9h=class{constructor(){this.remote="",this.hash={local:"",remote:""},this.branch={local:"",remote:""},this.message=""}toString(){return this.message}}}});function vrl(e){return e.objects=e.objects||{compressing:0,counting:0,enumerating:0,packReused:0,reused:{count:0,delta:0},total:{count:0,delta:0}}}function nGh(e){let t=/^\s*(\d+)/.exec(e),r=/delta (\d+)/i.exec(e);return{count:ES(t&&t[1]||"0"),delta:ES(r&&r[1]||"0")}}var F9h,pTB=Ua({"src/lib/parsers/parse-remote-objects.ts"(){"use strict";Td(),F9h=[new uen(/^remote:\s*(enumerating|counting|compressing) objects: (\d+),/i,(e,[t,r])=>{let i=t.toLowerCase(),n=vrl(e.remoteMessages);Object.assign(n,{[i]:ES(r)})}),new uen(/^remote:\s*(enumerating|counting|compressing) objects: \d+% \(\d+\/(\d+)\),/i,(e,[t,r])=>{let i=t.toLowerCase(),n=vrl(e.remoteMessages);Object.assign(n,{[i]:ES(r)})}),new uen(/total ([^,]+), reused ([^,]+), pack-reused (\d+)/i,(e,[t,r,i])=>{let n=vrl(e.remoteMessages);n.total=nGh(t),n.reused=nGh(r),n.packReused=ES(i)})]}});function Q9h(e,t){return O2({remoteMessages:new L9h},U9h,t)}var U9h,L9h,V9h=Ua({"src/lib/parsers/parse-remote-messages.ts"(){"use strict";Td(),pTB(),U9h=[new uen(/^remote:\s*(.+)$/,(e,[t])=>(e.remoteMessages.all.push(t.trim()),!1)),...F9h,new uen([/create a (?:pull|merge) request/i,/\s(https?:\/\/\S+)$/],(e,[t])=>{e.remoteMessages.pullRequestUrl=t}),new uen([/found (\d+) vulnerabilities.+\(([^)]+)\)/i,/\s(https?:\/\/\S+)$/],(e,[t,r,i])=>{e.remoteMessages.vulnerabilities={count:ES(t),summary:r,url:i}})],L9h=class{constructor(){this.all=[]}}}});function _TB(e,t){let r=O2(new N9h,W9h,[e,t]);return r.message&&r}var aGh,oGh,uGh,sGh,W9h,cGh,eil,x9h=Ua({"src/lib/parsers/parse-pull.ts"(){"use strict";dTB(),Td(),V9h(),aGh=/^\s*(.+?)\s+\|\s+\d+\s*(\+*)(-*)/,oGh=/(\d+)\D+((\d+)\D+\(\+\))?(\D+(\d+)\D+\(-\))?/,uGh=/^(create|delete) mode \d+ (.+)/,sGh=[new l_(aGh,(e,[t,r,i])=>{e.files.push(t),r&&(e.insertions[t]=r.length),i&&(e.deletions[t]=i.length)}),new l_(oGh,(e,[t,,r,,i])=>r!==void 0||i!==void 0?(e.summary.changes=+t||0,e.summary.insertions=+r||0,e.summary.deletions=+i||0,!0):!1),new l_(uGh,(e,[t,r])=>{wP(e.files,r),wP(t==="create"?e.created:e.deleted,r)})],W9h=[new l_(/^from\s(.+)$/i,(e,[t])=>{e.remote=t}),new l_(/^fatal:\s(.+)$/,(e,[t])=>{e.message=t}),new l_(/([a-z0-9]+)\.\.([a-z0-9]+)\s+(\S+)\s+->\s+(\S+)$/,(e,[t,r,i,n])=>{e.branch.local=i,e.hash.local=t,e.branch.remote=n,e.hash.remote=r})],cGh=(e,t)=>O2(new Irl,sGh,[e,t]),eil=(e,t)=>Object.assign(new Irl,cGh(e,t),Q9h(e,t))}}),lGh,G9h,fGh,hTB=Ua({"src/lib/parsers/parse-merge.ts"(){"use strict";fTB(),Td(),x9h(),lGh=[new l_(/^Auto-merging\s+(.+)$/,(e,[t])=>{e.merges.push(t)}),new l_(/^CONFLICT\s+\((.+)\): Merge conflict in (.+)$/,(e,[t,r])=>{e.conflicts.push(new T0u(t,r))}),new l_(/^CONFLICT\s+\((.+\/delete)\): (.+) deleted in (.+) and/,(e,[t,r,i])=>{e.conflicts.push(new T0u(t,r,{deleteRef:i}))}),new l_(/^CONFLICT\s+\((.+)\):/,(e,[t])=>{e.conflicts.push(new T0u(t,null))}),new l_(/^Automatic merge failed;\s+(.+)$/,(e,[t])=>{e.result=t})],G9h=(e,t)=>Object.assign(fGh(e,t),eil(e,t)),fGh=e=>O2(new z9h,lGh,e)}});function dGh(e){return e.length?{commands:["merge",...e],format:"utf-8",parser(t,r){let i=G9h(t,r);if(i.failed)throw new Gio(i);return i}}:g2("Git.merge requires at least one option")}var yTB=Ua({"src/lib/tasks/merge.ts"(){"use strict";Iya(),hTB(),Yq()}});function bTB(e,t,r){let i=r.includes("deleted"),n=r.includes("tag")||/^refs\/tags/.test(e),a=!r.includes("new");return{deleted:i,tag:n,branch:!n,new:!a,alreadyUpdated:a,local:e,remote:t}}var pGh,H9h,_Gh,vTB=Ua({"src/lib/parsers/parse-push.ts"(){"use strict";Td(),V9h(),pGh=[new l_(/^Pushing to (.+)$/,(e,[t])=>{e.repo=t}),new l_(/^updating local tracking ref '(.+)'/,(e,[t])=>{e.ref={...e.ref||{},local:t}}),new l_(/^[=*-]\s+([^:]+):(\S+)\s+\[(.+)]$/,(e,[t,r,i])=>{e.pushed.push(bTB(t,r,i))}),new l_(/^Branch '([^']+)' set up to track remote branch '([^']+)' from '([^']+)'/,(e,[t,r,i])=>{e.branch={...e.branch||{},local:t,remote:r,remoteName:i}}),new l_(/^([^:]+):(\S+)\s+([a-z0-9]+)\.\.([a-z0-9]+)$/,(e,[t,r,i,n])=>{e.update={head:{local:t,remote:r},hash:{from:i,to:n}}})],H9h=(e,t)=>{let r=_Gh(e,t),i=Q9h(e,t);return{...r,...i}},_Gh=(e,t)=>O2({pushed:[]},pGh,[e,t])}}),K9h={};Xq(K9h,{pushTagsTask:()=>gTB,pushTask:()=>til});function gTB(e={},t){return wP(t,"--tags"),til(e,t)}function til(e={},t){let r=["push",...t];return e.branch&&r.splice(1,0,e.branch),e.remote&&r.splice(1,0,e.remote),V0u(r,"-v"),wP(r,"--verbose"),wP(r,"--porcelain"),{commands:r,format:"utf-8",parser:H9h}}var $9h=Ua({"src/lib/tasks/push.ts"(){"use strict";vTB(),Td()}});function OTB(){return{showBuffer(){let e=["show",...v2(arguments,1)];return e.includes("--binary")||e.splice(1,0,"--binary"),this._runTask(kGh(e),QC(arguments))},show(){let e=["show",...v2(arguments,1)];return this._runTask(K7(e),QC(arguments))}}}var mTB=Ua({"src/lib/tasks/show.ts"(){"use strict";Td(),Yq()}}),hGh,J9h,ATB=Ua({"src/lib/responses/FileStatusSummary.ts"(){"use strict";hGh=/^(.+)\0(.+)$/,J9h=class{constructor(e,t,r){if(this.path=e,this.index=t,this.working_dir=r,t==="R"||r==="R"){let i=hGh.exec(e)||[null,e,e];this.from=i[2]||"",this.path=i[1]||""}}}}});function yGh(e){let[t,r]=e.split(Bya);return{from:r||t,to:t}}function yAe(e,t,r){return[`${e}${t}`,r]}function grl(e,...t){return t.map(r=>yAe(e,r,(i,n)=>wP(i.conflicted,n)))}function PTB(e,t){let r=t.trim();switch(" "){case r.charAt(2):return i(r.charAt(0),r.charAt(1),r.substr(3));case r.charAt(1):return i(" ",r.charAt(0),r.substr(2));default:return}function i(n,a,o){let c=`${n}${a}`,d=Y9h.get(c);d&&d(e,o),c!=="##"&&c!=="!!"&&e.files.push(new J9h(o,n,a))}}var bGh,Y9h,X9h,jTB=Ua({"src/lib/responses/StatusSummary.ts"(){"use strict";Td(),ATB(),bGh=class{constructor(){this.not_added=[],this.conflicted=[],this.created=[],this.deleted=[],this.ignored=void 0,this.modified=[],this.renamed=[],this.files=[],this.staged=[],this.ahead=0,this.behind=0,this.current=null,this.tracking=null,this.detached=!1,this.isClean=()=>!this.files.length}},Y9h=new Map([yAe(" ","A",(e,t)=>wP(e.created,t)),yAe(" ","D",(e,t)=>wP(e.deleted,t)),yAe(" ","M",(e,t)=>wP(e.modified,t)),yAe("A"," ",(e,t)=>wP(e.created,t)&&wP(e.staged,t)),yAe("A","M",(e,t)=>wP(e.created,t)&&wP(e.staged,t)&&wP(e.modified,t)),yAe("D"," ",(e,t)=>wP(e.deleted,t)&&wP(e.staged,t)),yAe("M"," ",(e,t)=>wP(e.modified,t)&&wP(e.staged,t)),yAe("M","M",(e,t)=>wP(e.modified,t)&&wP(e.staged,t)),yAe("R"," ",(e,t)=>{wP(e.renamed,yGh(t))}),yAe("R","M",(e,t)=>{let r=yGh(t);wP(e.renamed,r),wP(e.modified,r.to)}),yAe("!","!",(e,t)=>{wP(e.ignored=e.ignored||[],t)}),yAe("?","?",(e,t)=>wP(e.not_added,t)),...grl("A","A","U"),...grl("D","D","U"),...grl("U","A","D","U"),["##",(e,t)=>{let r=/ahead (\d+)/,i=/behind (\d+)/,n=/^(.+?(?=(?:\.{3}|\s|$)))/,a=/\.{3}(\S*)/,o=/\son\s(\S+?)(?=\.{3}|$)/,c=r.exec(t);e.ahead=c&&+c[1]||0,c=i.exec(t),e.behind=c&&+c[1]||0,c=n.exec(t),e.current=bAe(c?.[1],CU,null),c=a.exec(t),e.tracking=bAe(c?.[1],CU,null),c=o.exec(t),c&&(e.current=bAe(c?.[1],CU,e.current)),e.detached=/\(no branch\)/.test(t)}]]),X9h=function(e){let t=e.split(Bya),r=new bGh;for(let i=0,n=t.length;i<n;){let a=t[i++].trim();a&&(a.charAt(0)==="R"&&(a+=Bya+(t[i++]||"")),PTB(r,a))}return r}}});function wTB(e){return{format:"utf-8",commands:["status","--porcelain","-b","-u","--null",...e.filter(r=>!Z9h.includes(r))],parser(r){return X9h(r)}}}var Z9h,ETB=Ua({"src/lib/tasks/status.ts"(){"use strict";jTB(),Z9h=["--null","-z"]}});function Q0u(e=0,t=0,r=0,i="",n=!0){return Object.defineProperty({major:e,minor:t,patch:r,agent:i,installed:n},"toString",{value(){return`${this.major}.${this.minor}.${this.patch}`},configurable:!1,enumerable:!1})}function STB(){return Q0u(0,0,0,"",!1)}function MTB(){return{version(){return this._runTask({commands:["--version"],format:"utf-8",parser:DTB,onError(e,t,r,i){if(e.exitCode===-2)return r(Buffer.from(ril));i(t)}})}}}function DTB(e){return e===ril?STB():O2(Q0u(0,0,0,e),k9h,e)}var ril,k9h,BTB=Ua({"src/lib/tasks/version.ts"(){"use strict";Td(),ril="installed=false",k9h=[new l_(/version (\d+)\.(\d+)\.(\d+)(?:\s*\((.+)\))?/,(e,[t,r,i,n=""])=>{Object.assign(e,Q0u(ES(t),ES(r),ES(i),n))}),new l_(/version (\d+)\.(\d+)\.(\D+)(.+)?$/,(e,[t,r,i,n=""])=>{Object.assign(e,Q0u(ES(t),ES(r),i,n))})]}}),eHh={};Xq(eHh,{SimpleGitApi:()=>Crl});var Crl,ITB=Ua({"src/lib/simple-git-api.ts"(){"use strict";z1B(),N1B(),Q1B(),V1B(),K1B(),u9h(),J1B(),d9h(),X1B(),rTB(),R9h(),yTB(),$9h(),mTB(),ETB(),Yq(),BTB(),Td(),Crl=class{constructor(e){this._executor=e}_runTask(e,t){let r=this._executor.chain(),i=r.push(e);return t&&T1B(e,i,t),Object.create(this,{then:{value:i.then.bind(i)},catch:{value:i.catch.bind(i)},_executor:{value:r}})}add(e){return this._runTask(K7(["add",...Ztr(e)]),QC(arguments))}cwd(e){let t=QC(arguments);return typeof e=="string"?this._runTask(eGh(e,this._executor),t):typeof e?.path=="string"?this._runTask(eGh(e.path,e.root&&this._executor||void 0),t):this._runTask(g2("Git.cwd: workingDirectory must be supplied as a string"),t)}hashObject(e,t){return this._runTask(Y1B(e,t===!0),QC(arguments))}init(e){return this._runTask(tTB(e===!0,this._executor.cwd,v2(arguments)),QC(arguments))}merge(){return this._runTask(dGh(v2(arguments)),QC(arguments))}mergeFromTo(e,t){return CU(e)&&CU(t)?this._runTask(dGh([e,t,...v2(arguments)]),QC(arguments,!1)):this._runTask(g2("Git.mergeFromTo requires that the 'remote' and 'branch' arguments are supplied as strings"))}outputHandler(e){return this._executor.outputHandler=e,this}push(){let e=til({remote:bAe(arguments[0],CU),branch:bAe(arguments[1],CU)},v2(arguments));return this._runTask(e,QC(arguments))}stash(){return this._runTask(K7(["stash",...v2(arguments)]),QC(arguments))}status(){return this._runTask(wTB(v2(arguments)),QC(arguments))}},Object.assign(Crl.prototype,F1B(),H1B(),m1B(),L1B(),$1B(),w1B(),lTB(),OTB(),MTB())}}),tHh={};Xq(tHh,{Scheduler:()=>iHh});var vGh,iHh,CTB=Ua({"src/lib/runners/scheduler.ts"(){"use strict";Td(),b9h(),vGh=(()=>{let e=0;return()=>{e++;let{promise:t,done:r}=(0,rHh.createDeferred)();return{promise:t,done:r,id:e}}})(),iHh=class{constructor(e=2){this.concurrency=e,this.logger=Hrl("","scheduler"),this.pending=[],this.running=[],this.logger("Constructed, concurrency=%s",e)}schedule(){if(!this.pending.length||this.running.length>=this.concurrency){this.logger("Schedule attempt ignored, pending=%s running=%s concurrency=%s",this.pending.length,this.running.length,this.concurrency);return}let e=wP(this.running,this.pending.shift());this.logger("Attempting id=%s",e.id),e.done(()=>{this.logger("Completing id=",e.id),V0u(this.running,e),this.schedule()})}next(){let{promise:e,id:t}=wP(this.pending,vGh());return this.logger("Scheduling id=%s",t),this.schedule(),e}}}}),nHh={};Xq(nHh,{applyPatchTask:()=>qTB});function qTB(e,t){return K7(["apply",...t,...e])}var TTB=Ua({"src/lib/tasks/apply-patch.ts"(){"use strict";Yq()}});function RTB(e,t){return{branch:e,hash:t,success:!0}}function zTB(e){return{branch:e,hash:null,success:!1}}var aHh,NTB=Ua({"src/lib/responses/BranchDeleteSummary.ts"(){"use strict";aHh=class{constructor(){this.all=[],this.branches={},this.errors=[]}get success(){return!this.errors.length}}}});function oHh(e,t){return t===1&&qrl.test(e)}var gGh,qrl,OGh,J0u,FTB=Ua({"src/lib/parsers/parse-branch-delete.ts"(){"use strict";NTB(),Td(),gGh=/(\S+)\s+\(\S+\s([^)]+)\)/,qrl=/^error[^']+'([^']+)'/m,OGh=[new l_(gGh,(e,[t,r])=>{let i=RTB(t,r);e.all.push(i),e.branches[t]=i}),new l_(qrl,(e,[t])=>{let r=zTB(t);e.errors.push(r),e.all.push(r),e.branches[t]=r})],J0u=(e,t)=>O2(new aHh,OGh,[e,t])}}),uHh,QTB=Ua({"src/lib/responses/BranchSummary.ts"(){"use strict";uHh=class{constructor(){this.all=[],this.branches={},this.current="",this.detached=!1}push(e,t,r,i,n){e==="*"&&(this.detached=t,this.current=r),this.all.push(r),this.branches[r]={current:e==="*",linkedWorkTree:e==="+",name:r,commit:i,label:n}}}}});function mGh(e){return e?e.charAt(0):""}function sHh(e,t=!1){return O2(new uHh,t?[lHh]:cHh,e)}var cHh,lHh,UTB=Ua({"src/lib/parsers/parse-branch.ts"(){"use strict";QTB(),Td(),cHh=[new l_(/^([*+]\s)?\((?:HEAD )?detached (?:from|at) (\S+)\)\s+([a-z0-9]+)\s(.*)$/,(e,[t,r,i,n])=>{e.push(mGh(t),!0,r,i,n)}),new l_(/^([*+]\s)?(\S+)\s+([a-z0-9]+)\s?(.*)$/s,(e,[t,r,i,n])=>{e.push(mGh(t),!1,r,i,n)})],lHh=new l_(/^(\S+)$/s,(e,[t])=>{e.push("*",!1,t,"","")})}}),fHh={};Xq(fHh,{branchLocalTask:()=>VTB,branchTask:()=>LTB,containsDeleteBranchCommand:()=>dHh,deleteBranchTask:()=>xTB,deleteBranchesTask:()=>WTB});function dHh(e){let t=["-d","-D","--delete"];return e.some(r=>t.includes(r))}function LTB(e){let t=dHh(e),r=e.includes("--show-current"),i=["branch",...e];return i.length===1&&i.push("-a"),i.includes("-v")||i.splice(1,0,"-v"),{format:"utf-8",commands:i,parser(n,a){return t?J0u(n,a).all[0]:sHh(n,r)}}}function VTB(){return{format:"utf-8",commands:["branch","-v"],parser(e){return sHh(e)}}}function WTB(e,t=!1){return{format:"utf-8",commands:["branch","-v",t?"-D":"-d",...e],parser(r,i){return J0u(r,i)},onError({exitCode:r,stdOut:i},n,a,o){if(!oHh(String(n),r))return o(n);a(i)}}}function xTB(e,t=!1){let r={format:"utf-8",commands:["branch","-v",t?"-D":"-d",e],parser(i,n){return J0u(i,n).branches[e]},onError({exitCode:i,stdErr:n,stdOut:a},o,c,d){if(!oHh(String(o),i))return d(o);throw new Gio(r.parser(Wio(a),Wio(n)),String(o))}};return r}var GTB=Ua({"src/lib/tasks/branch.ts"(){"use strict";Iya(),FTB(),UTB(),Td()}});function HTB(e){let t=e.trim().replace(/^["']|["']$/g,"");return t&&(0,pHh.normalize)(t)}var _Hh,KTB=Ua({"src/lib/responses/CheckIgnore.ts"(){"use strict";_Hh=e=>e.split(/\n/g).map(HTB).filter(Boolean)}}),hHh={};Xq(hHh,{checkIgnoreTask:()=>$TB});function $TB(e){return{commands:["check-ignore",...e],format:"utf-8",parser:_Hh}}var JTB=Ua({"src/lib/tasks/check-ignore.ts"(){"use strict";KTB()}}),yHh={};Xq(yHh,{cloneMirrorTask:()=>XTB,cloneTask:()=>bHh});function YTB(e){return/^--upload-pack(=|$)/.test(e)}function bHh(e,t,r){let i=["clone",...r];return CU(e)&&i.push(e),CU(t)&&i.push(t),i.find(YTB)?g2("git.fetch: potential exploit argument blocked."):K7(i)}function XTB(e,t,r){return wP(r,"--mirror"),bHh(e,t,r)}var ZTB=Ua({"src/lib/tasks/clone.ts"(){"use strict";Yq(),Td()}});function kTB(e,t){return O2({raw:e,remote:null,branches:[],tags:[],updated:[],deleted:[]},vHh,[e,t])}var vHh,eRB=Ua({"src/lib/parsers/parse-fetch.ts"(){"use strict";Td(),vHh=[new l_(/From (.+)$/,(e,[t])=>{e.remote=t}),new l_(/\* \[new branch]\s+(\S+)\s*-> (.+)$/,(e,[t,r])=>{e.branches.push({name:t,tracking:r})}),new l_(/\* \[new tag]\s+(\S+)\s*-> (.+)$/,(e,[t,r])=>{e.tags.push({name:t,tracking:r})}),new l_(/- \[deleted]\s+\S+\s*-> (.+)$/,(e,[t])=>{e.deleted.push({tracking:t})}),new l_(/\s*([^.]+)\.\.(\S+)\s+(\S+)\s*-> (.+)$/,(e,[t,r,i,n])=>{e.updated.push({name:i,tracking:n,to:r,from:t})})]}}),gHh={};Xq(gHh,{fetchTask:()=>rRB});function tRB(e){return/^--upload-pack(=|$)/.test(e)}function rRB(e,t,r){let i=["fetch",...r];return e&&t&&i.push(e,t),i.find(tRB)?g2("git.fetch: potential exploit argument blocked."):{commands:i,format:"utf-8",parser:kTB}}var iRB=Ua({"src/lib/tasks/fetch.ts"(){"use strict";eRB(),Yq()}});function nRB(e){return O2({moves:[]},OHh,e)}var OHh,aRB=Ua({"src/lib/parsers/parse-move.ts"(){"use strict";Td(),OHh=[new l_(/^Renaming (.+) to (.+)$/,(e,[t,r])=>{e.moves.push({from:t,to:r})})]}}),mHh={};Xq(mHh,{moveTask:()=>oRB});function oRB(e,t){return{commands:["mv","-v",...Ztr(e),t],format:"utf-8",parser:nRB}}var uRB=Ua({"src/lib/tasks/move.ts"(){"use strict";aRB(),Td()}}),AHh={};Xq(AHh,{pullTask:()=>sRB});function sRB(e,t,r){let i=["pull",...r];return e&&t&&i.splice(1,0,e,t),{commands:i,format:"utf-8",parser(n,a){return eil(n,a)},onError(n,a,o,c){let d=_TB(Wio(n.stdOut),Wio(n.stdErr));if(d)return c(new Gio(d));c(a)}}}var cRB=Ua({"src/lib/tasks/pull.ts"(){"use strict";Iya(),x9h(),Td()}});function lRB(e){let t={};return PHh(e,([r])=>t[r]={name:r}),Object.values(t)}function fRB(e){let t={};return PHh(e,([r,i,n])=>{Object.hasOwn(t,r)||(t[r]={name:r,refs:{fetch:"",push:""}}),n&&i&&(t[r].refs[n.replace(/[^a-z]/g,"")]=i)}),Object.values(t)}function PHh(e,t){zrl(e,r=>t(r.split(/\s+/)))}var dRB=Ua({"src/lib/responses/GetRemoteSummary.ts"(){"use strict";Td()}}),jHh={};Xq(jHh,{addRemoteTask:()=>pRB,getRemotesTask:()=>_RB,listRemotesTask:()=>hRB,remoteTask:()=>yRB,removeRemoteTask:()=>bRB});function pRB(e,t,r){return K7(["remote","add",...r,e,t])}function _RB(e){let t=["remote"];return e&&t.push("-v"),{commands:t,format:"utf-8",parser:e?fRB:lRB}}function hRB(e){let t=[...e];return t[0]!=="ls-remote"&&t.unshift("ls-remote"),K7(t)}function yRB(e){let t=[...e];return t[0]!=="remote"&&t.unshift("remote"),K7(t)}function bRB(e){return K7(["remote","remove",e])}var vRB=Ua({"src/lib/tasks/remote.ts"(){"use strict";dRB(),Yq()}}),wHh={};Xq(wHh,{stashListTask:()=>gRB});function gRB(e={},t){let r=T9h(e),i=["stash","list",...r.commands,...t],n=B9h(r.splitter,r.fields,$rl(i));return $0u(i)||{commands:i,format:"utf-8",parser:n}}var ORB=Ua({"src/lib/tasks/stash-list.ts"(){"use strict";Jio(),C9h(),krl(),R9h()}}),EHh={};Xq(EHh,{addSubModuleTask:()=>mRB,initSubModuleTask:()=>ARB,subModuleTask:()=>Y0u,updateSubModuleTask:()=>PRB});function mRB(e,t){return Y0u(["add",e,t])}function ARB(e){return Y0u(["init",...e])}function Y0u(e){let t=[...e];return t[0]!=="submodule"&&t.unshift("submodule"),K7(t)}function PRB(e){return Y0u(["update",...e])}var jRB=Ua({"src/lib/tasks/sub-module.ts"(){"use strict";Yq()}});function wRB(e,t){let r=Number.isNaN(e),i=Number.isNaN(t);return r!==i?r?1:-1:r?SHh(e,t):0}function SHh(e,t){return e===t?0:e>t?1:-1}function ERB(e){return e.trim()}function B0u(e){return typeof e=="string"&&parseInt(e.replace(/^\D+/g,""),10)||0}var AGh,MHh,SRB=Ua({"src/lib/responses/TagList.ts"(){"use strict";AGh=class{constructor(e,t){this.all=e,this.latest=t}},MHh=function(e,t=!1){let r=e.split(`
|
|
@@ -2237,7 +2237,7 @@ ${E3E.default.cursorShow}`)}releaseCursor(){this.extraLinesUnderPrompt>0&&$Pp(th
|
|
|
2237
2237
|
`+Mea.default.red(">> ")+t),this.screen.render(r,i)}getMaskedValue(t){return this.status==="answered"?this.opt.mask?Mea.default.cyan(R3E(t,this.opt.mask)):Mea.default.italic(Mea.default.dim("[hidden]")):this.opt.mask?R3E(t,this.opt.mask):Mea.default.italic(Mea.default.dim("[input is hidden] "))}getSpinningValue(t){return this.getMaskedValue(t)}filterInput(t){return t||(this.opt.default==null?"":this.opt.default)}onEnd(t){this.status="answered",this.answer=t.value,this.render(),this.screen.done(),this.done(t.value)}onError(t){this.render(t.isValid)}onKeypress(){this.opt.default&&=void 0,this.render()}};var noc=se(oQ(),1);var TWE=se(Djp(),1),roc=require("child_process"),Ixa=require("fs"),toc=se(require("path"),1),RWE=se(require("os"),1),zWE=require("crypto"),pwp=se(CWE(),1);var Zac=class extends Error{originalError;constructor(t){super(`Failed to create temporary file. ${t.message}`),this.originalError=t}};var m4o=class extends Error{originalError;constructor(t){super(`Failed to launch editor. ${t.message}`),this.originalError=t}};var kac=class extends Error{originalError;constructor(t){super(`Failed to read temporary file. ${t.message}`),this.originalError=t}};var eoc=class extends Error{originalError;constructor(t){super(`Failed to remove temporary file. ${t.message}`),this.originalError=t}};function ioc(e="",t,r){let i=new _wp(e,r);i.runAsync((n,a)=>{if(n)setImmediate(t,n,void 0);else try{i.cleanup(),setImmediate(t,void 0,a)}catch(o){setImmediate(t,o,void 0)}})}function qWE(e){return e?e.replace(/[^a-zA-Z0-9_.-]/g,"_"):""}function Yc5(e){let t=[],r="";for(let i=0;i<e.length;i++){let n=e.charAt(i);i>0&&n===" "&&e[i-1]!=="\\"&&r.length>0?(t.push(r),r=""):r=`${r}${n}`}return r.length>0&&t.push(r),t}var _wp=class{text="";tempFile;editor;lastExitStatus=0;fileOptions={};get temp_file(){return console.log("DEPRECATED: temp_file. Use tempFile moving forward."),this.tempFile}get last_exit_status(){return console.log("DEPRECATED: last_exit_status. Use lastExitStatus moving forward."),this.lastExitStatus}constructor(t="",r){this.text=t,r&&(this.fileOptions=r),this.determineEditor(),this.createTemporaryFile()}run(){return this.launchEditor(),this.readTemporaryFile(),this.text}runAsync(t){try{this.launchEditorAsync(()=>{try{this.readTemporaryFile(),setImmediate(t,void 0,this.text)}catch(r){setImmediate(t,r,void 0)}})}catch(r){setImmediate(t,r,void 0)}}cleanup(){this.removeTemporaryFile()}determineEditor(){let t=process.env.VISUAL?process.env.VISUAL:process.env.EDITOR?process.env.EDITOR:process.platform.startsWith("win")?"notepad":"vim",r=Yc5(t).map(n=>n.replace("\\ "," ")),i=r.shift();this.editor={args:r,bin:i}}createTemporaryFile(){try{let t=this.fileOptions.dir??RWE.default.tmpdir(),r=(0,zWE.randomUUID)(),i=qWE(this.fileOptions.prefix),n=qWE(this.fileOptions.postfix),a=`${i}${r}${n}`,o=toc.default.resolve(t,a),c=toc.default.resolve(t)+toc.default.sep;if(!o.startsWith(c))throw new Error("Resolved temporary file escaped the base directory");this.tempFile=o;let d={encoding:"utf8",flag:"wx"};Object.prototype.hasOwnProperty.call(this.fileOptions,"mode")&&(d.mode=this.fileOptions.mode),(0,Ixa.writeFileSync)(this.tempFile,this.text,d)}catch(t){throw new Zac(t)}}readTemporaryFile(){try{let t=(0,Ixa.readFileSync)(this.tempFile);if(t.length===0)this.text="";else{let r=(0,TWE.detect)(t)??"utf8";pwp.default.encodingExists(r)||(r="utf8"),this.text=pwp.default.decode(t,r)}}catch(t){throw new kac(t)}}removeTemporaryFile(){try{(0,Ixa.unlinkSync)(this.tempFile)}catch(t){throw new eoc(t)}}launchEditor(){try{let t=(0,roc.spawnSync)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"});this.lastExitStatus=t.status??0}catch(t){throw new m4o(t)}}launchEditorAsync(t){try{(0,roc.spawn)(this.editor.bin,this.editor.args.concat([this.tempFile]),{stdio:"inherit"}).on("exit",i=>{this.lastExitStatus=i,setImmediate(t)})}catch(r){throw new m4o(r)}}};var NWE=se(zEe(),1);var A4o=class extends uQ{_run(t){this.done=t,this.editorResult=new NWE.Subject;let r=Tx(this.rl);this.lineSubscription=r.line.subscribe(this.startExternalEditor.bind(this));let i=this.opt.waitUserInput===void 0?!0:this.opt.waitUserInput,n=this.handleSubmitEvents(this.editorResult);return n.success.forEach(this.onEnd.bind(this)),n.error.forEach(this.onError.bind(this)),this.currentText=this.opt.default,this.opt.default=null,i?this.render():this.startExternalEditor(),this}render(t){let r="",i=this.getQuestion();i+=this.status==="answered"?noc.default.dim("Received"):noc.default.dim("Press <enter> to launch your preferred editor."),t&&(r=noc.default.red(">> ")+t),this.screen.render(i,r)}startExternalEditor(){this.rl.pause(),ioc(this.currentText,this.endExternalEditor.bind(this),{postfix:this.opt.postfix??".txt"})}endExternalEditor(t,r){this.rl.resume(),t?this.editorResult.error(t):this.editorResult.next(r)}onEnd(t){this.editorResult.unsubscribe(),this.lineSubscription.unsubscribe(),this.answer=t.value,this.status="answered",this.render(),this.screen.done(),this.done(this.answer)}onError(t){this.render(t.isValid)}};var VWE=require("stream");var UWE=se(require("readline"),1),LWE=se(QWE(),1),Cea=class{constructor(t){this.rl||=UWE.default.createInterface(Zc5(t)),this.rl.resume(),this.onForceClose=this.onForceClose.bind(this),process.on("exit",this.onForceClose),this.rl.on("SIGINT",this.onForceClose)}onForceClose(){this.close(),process.kill(process.pid,"SIGINT"),console.log("")}close(){this.rl.removeListener("SIGINT",this.onForceClose),process.removeListener("exit",this.onForceClose),this.rl.output.unmute(),this.activePrompt&&typeof this.activePrompt.close=="function"&&this.activePrompt.close(),this.rl.output.end(),this.rl.pause(),this.rl.close()}};function Zc5(e={}){e.skipTTYChecks=e.skipTTYChecks===void 0?!0:e.skipTTYChecks;let t=e.input||process.stdin;if(!e.skipTTYChecks&&!t.isTTY){let n=new Error("Prompts can not be meaningfully rendered in non-TTY environments");throw n.isTtyError=!0,n}let r=new LWE.default;return r.pipe(e.output||process.stdout),{terminal:!0,...e,input:t,output:r}}var P4o=class extends Cea{constructor(t={}){super(t),this.log=new VWE.Writable({write:(r,i,n)=>{this.writeLog(r),n()}}),this.bottomBar=t.bottomBar||"",this.render()}render(){return this.write(this.bottomBar),this}clean(){return o4o(this.rl,this.bottomBar.split(`
|
|
2238
2238
|
`).length),this}updateBottomBar(t){return o4o(this.rl,1),this.rl.output.unmute(),this.clean(),this.bottomBar=t,this.render(),this.rl.output.mute(),this}writeLog(t){return this.rl.output.unmute(),this.clean(),this.rl.output.write(this.enforceLF(t.toString())),this.render(),this.rl.output.mute(),this}enforceLF(t){return/[\n\r]$/.test(t)?t:t+`
|
|
2239
2239
|
`}write(t){let r=t.split(/\n/);this.height=r.length,this.rl.setPrompt(r.at(-1)),this.rl.output.rows===0&&this.rl.output.columns===0&&Eac(this.rl,t.length+this.rl.line.length),this.rl.output.write(t)}};var AA=se(zEe(),1),GWE=se(NLo(),1);var aoc=se(zEe(),1),WWE=se(NLo(),1),ooc=function(e,t,r){return typeof e[t]!="function"?(0,aoc.of)(e):(0,aoc.from)((0,WWE.default)(e[t])(r).then(i=>(e[t]=i,e)))};var xWE={set:(e,t="",r)=>{let i=e;t.split(".").forEach((n,a,o)=>{n==="__proto__"||n==="constructor"||(a===o.length-1?i[n]=r:(!(n in i)||typeof i[n]!="object")&&(i[n]={}),i=i[n])})},get:(e,t="",r)=>{let i=a=>String.prototype.split.call(t,a).filter(Boolean).reduce((o,c)=>o!=null?o[c]:o,e),n=i(/[,[\]]+?/)||i(/[,.[\]]+?/);return n===void 0||n===e?r:n}},Cxa=class extends Cea{constructor(t,r){super(r),this.prompts=t}run(t,r){this.answers=typeof r=="object"?{...r}:{};let i;return Array.isArray(t)?i=(0,AA.from)(t):(0,AA.isObservable)(t)?i=t:Object.values(t).every(n=>typeof n=="object"&&!Array.isArray(n)&&n!=null)?i=(0,AA.from)(Object.entries(t).map(([n,a])=>({name:n,...a}))):i=(0,AA.from)([t]),this.process=i.pipe((0,AA.concatMap)(this.processQuestion.bind(this)),(0,AA.publish)()),this.process.connect(),this.process.pipe((0,AA.reduce)((n,a)=>(xWE.set(n,a.name,a.answer),n),this.answers)).toPromise(Promise).then(this.onCompletion.bind(this),this.onError.bind(this))}onCompletion(){return this.close(),this.answers}onError(t){return this.close(),Promise.reject(t)}processQuestion(t){return t={...t},(0,AA.defer)(()=>(0,AA.of)(t).pipe((0,AA.concatMap)(this.setDefaultType.bind(this)),(0,AA.concatMap)(this.filterIfRunnable.bind(this)),(0,AA.concatMap)(()=>ooc(t,"message",this.answers)),(0,AA.concatMap)(()=>ooc(t,"default",this.answers)),(0,AA.concatMap)(()=>ooc(t,"choices",this.answers)),(0,AA.concatMap)(this.fetchAnswer.bind(this))))}fetchAnswer(t){let r=this.prompts[t.type];return this.activePrompt=new r(t,this.rl,this.answers),(0,AA.defer)(()=>(0,AA.from)(this.activePrompt.run().then(i=>({name:t.name,answer:i}))))}setDefaultType(t){return this.prompts[t.type]||(t.type="input"),(0,AA.defer)(()=>(0,AA.of)(t))}filterIfRunnable(t){if(t.askAnswered!==!0&&xWE.get(this.answers,t.name)!==void 0)return AA.EMPTY;if(t.when===!1)return AA.EMPTY;if(typeof t.when!="function")return(0,AA.of)(t);let{answers:r}=this;return(0,AA.defer)(()=>(0,AA.from)((0,GWE.default)(t.when)(r).then(i=>{if(i)return t})).pipe((0,AA.filter)(i=>i!=null)))}};function HWE(e){let t=function(r,i){let n;try{n=new Cxa(t.prompts,e)}catch(o){return Promise.reject(o)}let a=n.run(r,i);return a.ui=n,a};return t.prompts={},t.registerPrompt=function(r,i){return t.prompts[r]=i,this},t.restoreDefaultPrompts=function(){this.registerPrompt("list",s4o),this.registerPrompt("input",Sea),this.registerPrompt("number",c4o),this.registerPrompt("confirm",l4o),this.registerPrompt("rawlist",f4o),this.registerPrompt("expand",d4o),this.registerPrompt("checkbox",p4o),this.registerPrompt("password",_4o),this.registerPrompt("editor",A4o)},t.restoreDefaultPrompts(),t}var ywp=HWE();function el5(e,t){ywp.registerPrompt(e,t)}function tl5(){ywp.restoreDefaultPrompts()}var rl5={prompt:ywp,ui:{BottomBar:P4o,Prompt:Cxa},createPromptModule:HWE,registerPrompt:el5,restoreDefaultPrompts:tl5,Separator:jOe},uoc=rl5;var qxa=require("path");function $WE(){let e=il5();return async t=>{for(let r of t)r.module=e(r.filename);return t}}function il5(e=process.argv[1]?(0,qxa.dirname)(process.argv[1]):process.cwd(),t=qxa.sep==="\\"){let r=t?KWE(e):e;return i=>{if(!i)return;let n=t?KWE(i):i,{dir:a,base:o,ext:c}=qxa.posix.parse(n);(c===".js"||c===".mjs"||c===".cjs")&&(o=o.slice(0,-1*c.length));let d=decodeURIComponent(o);a||(a=".");let s=a.lastIndexOf("/node_modules");if(s>-1)return`${a.slice(s+14).replace(/\//g,".")}:${d}`;if(a.startsWith(r)){let u=a.slice(r.length+1).replace(/\//g,".");return u?`${u}:${d}`:d}return d}}function KWE(e){return e.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}var bwp=e=>{if("flags"in e){let t=JWE(e.flags),r=YWE(e.flags);return{...e,featureFlags:t,featureFlagPayloads:r}}{let t=e.featureFlags??{},r=Object.fromEntries(Object.entries(e.featureFlagPayloads||{}).map(([n,a])=>[n,XWE(a)])),i=Object.fromEntries(Object.entries(t).map(([n,a])=>[n,nl5(n,a,r[n])]));return{...e,featureFlags:t,featureFlagPayloads:r,flags:i}}};function nl5(e,t,r){return{key:e,enabled:typeof t=="string"?!0:t,variant:typeof t=="string"?t:void 0,reason:void 0,metadata:{id:void 0,version:void 0,payload:r?JSON.stringify(r):void 0,description:void 0}}}var JWE=e=>Object.fromEntries(Object.entries(e??{}).map(([t,r])=>[t,j4o(r)]).filter(([,t])=>t!==void 0)),YWE=e=>{let t=e??{};return Object.fromEntries(Object.keys(t).filter(r=>{let i=t[r];return i.enabled&&i.metadata&&i.metadata.payload!==void 0}).map(r=>{let i=t[r].metadata?.payload;return[r,i?XWE(i):void 0]}))};var j4o=e=>e===void 0?void 0:e.variant??e.enabled,XWE=e=>{if(typeof e!="string")return e;try{return JSON.parse(e)}catch{return e}};var soc="0123456789abcdef",coc=class e{constructor(t){this.bytes=t}static ofInner(t){if(t.length===16)return new e(t);throw new TypeError("not 128-bit length")}static fromFieldsV7(t,r,i,n){if(!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||!Number.isInteger(n)||t<0||r<0||i<0||n<0||t>0xffffffffffff||r>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/256,a[5]=t,a[6]=112|r>>>8,a[7]=r,a[8]=128|i>>>24,a[9]=i>>>16,a[10]=i>>>8,a[11]=i,a[12]=n>>>24,a[13]=n>>>16,a[14]=n>>>8,a[15]=n,new e(a)}static parse(t){let r;switch(t.length){case 32:r=/^[0-9a-f]{32}$/i.exec(t)?.[0];break;case 36:r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;case 38:r=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)?.slice(1,6).join("");break;case 45:r=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)?.slice(1,6).join("");break;default:break}if(r){let i=new Uint8Array(16);for(let n=0;n<16;n+=4){let a=parseInt(r.substring(2*n,2*n+8),16);i[n+0]=a>>>24,i[n+1]=a>>>16,i[n+2]=a>>>8,i[n+3]=a}return new e(i)}throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let r=0;r<this.bytes.length;r++)t+=soc.charAt(this.bytes[r]>>>4),t+=soc.charAt(15&this.bytes[r]),(r===3||r===5||r===7||r===9)&&(t+="-");return t}toHex(){let t="";for(let r=0;r<this.bytes.length;r++)t+=soc.charAt(this.bytes[r]>>>4),t+=soc.charAt(15&this.bytes[r]);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(r=>r===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(r=>r===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new e(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let r=0;r<16;r++){let i=this.bytes[r]-t.bytes[r];if(i!==0)return Math.sign(i)}return 0}},vwp=class{constructor(t){this.timestamp=0,this.counter=0,this.random=t??al5()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(t,r){let i=this.generateOrAbortCore(t,r);return i===void 0&&(this.timestamp=0,i=this.generateOrAbortCore(t,r)),i}generateOrAbortCore(t,r){if(!Number.isInteger(t)||t<1||t>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit positive integer");if(r<0||r>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(t>this.timestamp)this.timestamp=t,this.resetCounter();else{if(!(t+r>=this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return coc.fromFieldsV7(this.timestamp,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}generateV4(){let t=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return t[6]=64|t[6]>>>4,t[8]=128|t[8]>>>2,coc.ofInner(t)}},al5=()=>({nextUint32:()=>65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random())}),ZWE,pLi=()=>ol5().toString(),ol5=()=>(ZWE||(ZWE=new vwp)).generate();var ul5=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],kWE=function(e,t=[]){if(!e)return!1;let r=e.toLowerCase();return ul5.concat(t).some(i=>{let n=i.toLowerCase();return r.indexOf(n)!==-1})};var EOe=(function(e){return e.AnonymousId="anonymous_id",e.DistinctId="distinct_id",e.Props="props",e.EnablePersonProcessing="enable_person_processing",e.PersonMode="person_mode",e.FeatureFlagDetails="feature_flag_details",e.FeatureFlags="feature_flags",e.FeatureFlagPayloads="feature_flag_payloads",e.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",e.BootstrapFeatureFlags="bootstrap_feature_flags",e.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",e.OverrideFeatureFlags="override_feature_flags",e.Queue="queue",e.OptedOut="opted_out",e.SessionId="session_id",e.SessionStartTimestamp="session_start_timestamp",e.SessionLastTimestamp="session_timestamp",e.PersonProperties="person_properties",e.GroupProperties="group_properties",e.InstalledAppBuild="installed_app_build",e.InstalledAppVersion="installed_app_version",e.SessionReplay="session_replay",e.SurveyLastSeenDate="survey_last_seen_date",e.SurveysSeen="surveys_seen",e.Surveys="surveys",e.RemoteConfig="remote_config",e.FlagsEndpointWasHit="flags_endpoint_was_hit",e})({});var cl5=Array.isArray,e8E=Object.prototype,Huk=e8E.hasOwnProperty,gwp=e8E.toString,Owp=cl5||function(e){return gwp.call(e)==="[object Array]"};var t8E=e=>e===Object(e)&&!Owp(e);var Txa=e=>e===void 0,w4o=e=>gwp.call(e)=="[object String]",r8E=e=>w4o(e)&&e.trim().length===0;var i8E=e=>gwp.call(e)=="[object Number]"&&e===e;var mwp=e=>e instanceof Error;function E4o(e){return e===null||typeof e!="object"}function qea(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function n8E(e){return qea(e,"ErrorEvent")}function loc(e){return!Txa(Event)&&ll5(e,Event)}function a8E(e){return qea(e,"Object")}function ll5(e,t){try{return e instanceof t}catch{return!1}}function S4o(e,t,r,i,n){return t>r&&(i.warn("min cannot be greater than max."),t=r),i8E(e)?e>r?(i.warn(" cannot be greater than max: "+r+". Using max value instead."),r):e<t?(i.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(i.warn(" must be a number. using max or fallback. max: "+r+", fallback: "+n),S4o(n||r,t,r,i))}var fl5=864e5,foc=class{constructor(t){this._buckets={},this._onBucketRateLimited=t._onBucketRateLimited,this._bucketSize=S4o(t.bucketSize,0,100,t._logger),this._refillRate=S4o(t.refillRate,0,this._bucketSize,t._logger),this._refillInterval=S4o(t.refillInterval,0,fl5,t._logger)}_applyRefill(t,r){let i=r-t.lastAccess,n=Math.floor(i/this._refillInterval);if(n>0){let a=n*this._refillRate;t.tokens=Math.min(t.tokens+a,this._bucketSize),t.lastAccess=t.lastAccess+n*this._refillInterval}}consumeRateLimit(t){let r=Date.now(),i=String(t),n=this._buckets[i];return n?this._applyRefill(n,r):(n={tokens:this._bucketSize,lastAccess:r},this._buckets[i]=n),n.tokens===0?!0:(n.tokens--,n.tokens===0&&this._onBucketRateLimited?.(t),n.tokens===0)}stop(){this._buckets={}}};var doc=class{add(t){let r=pLi();return this.promiseByIds[r]=t,t.catch(()=>{}).finally(()=>{delete this.promiseByIds[r]}),t}async join(){let t=Object.values(this.promiseByIds),r=t.length;for(;r>0;)await Promise.all(t),t=Object.values(this.promiseByIds),r=t.length}get length(){return Object.keys(this.promiseByIds).length}constructor(){this.promiseByIds={}}};function dl5(e=console){return{log:e.log.bind(e),warn:e.warn.bind(e),error:e.error.bind(e),debug:e.debug.bind(e)}}var o8E=(e,t,r)=>{function i(a,...o){t(()=>{let c=r[a];c(e,...o)})}return{info:(...a)=>{i("log",...a)},warn:(...a)=>{i("warn",...a)},error:(...a)=>{i("error",...a)},critical:(...a)=>{r.error(e,...a)},createLogger:a=>o8E(`${e} ${a}`,t,r)}},pl5=e=>e();function u8E(e,t=pl5){return o8E(e,t,dl5())}var zxa="Mobile",_oc="iOS",Rxa="Android",s8E="Tablet",nsk=Rxa+" "+s8E;var _l5="Apple",ask=_l5+" Watch",c8E="Safari",hoc="BlackBerry",l8E="Samsung",hl5=l8E+"Browser",yl5=l8E+" Internet",yoc="Chrome",bl5=yoc+" OS",vl5=yoc+" "+_oc,f8E="Internet Explorer",gl5=f8E+" "+zxa,Pwp="Opera",osk=Pwp+" Mini",d8E="Edge",Ol5="Microsoft "+d8E,jwp="Firefox",ml5=jwp+" "+_oc,wwp="Nintendo",Ewp="PlayStation",poc="Xbox",Al5=Rxa+" "+zxa,Pl5=zxa+" "+c8E,M4o="Windows",jl5=M4o+" Phone";var p8E="Generic",usk=p8E+" "+zxa.toLowerCase(),ssk=p8E+" "+s8E.toLowerCase(),wl5="Konqueror",GY="(\\d+(\\.\\d+)?)",Awp=new RegExp("Version/"+GY),csk=new RegExp(poc,"i"),lsk=new RegExp(Ewp+" \\w+","i"),fsk=new RegExp(wwp+" \\w+","i"),El5=new RegExp(hoc+"|PlayBook|BB10","i"),Sl5={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000","5.1":"XP","5.2":"XP","6.0":"Vista","6.1":"7","6.2":"8","6.3":"8.1","6.4":"10","10.0":"10"};var dsk={[gl5]:[new RegExp("rv:"+GY)],[Ol5]:[new RegExp(d8E+"?\\/"+GY)],[yoc]:[new RegExp("("+yoc+"|CrMo)\\/"+GY)],[vl5]:[new RegExp("CriOS\\/"+GY)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+GY)],[c8E]:[Awp],[Pl5]:[Awp],[Pwp]:[new RegExp("("+Pwp+"|OPR)\\/"+GY)],[jwp]:[new RegExp(jwp+"\\/"+GY)],[ml5]:[new RegExp("FxiOS\\/"+GY)],[wl5]:[new RegExp("Konqueror[:/]?"+GY,"i")],[hoc]:[new RegExp(hoc+" "+GY),Awp],[Al5]:[new RegExp("android\\s"+GY,"i")],[yl5]:[new RegExp(hl5+"\\/"+GY)],[f8E]:[new RegExp("(rv:|MSIE )"+GY)],Mozilla:[new RegExp("rv:"+GY)]};var psk=[[new RegExp(poc+"; "+poc+" (.*?)[);]","i"),e=>[poc,e&&e[1]||""]],[new RegExp(wwp,"i"),[wwp,""]],[new RegExp(Ewp,"i"),[Ewp,""]],[El5,[hoc,""]],[new RegExp(M4o,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[jl5,""];if(new RegExp(zxa).test(t)&&!/IEMobile\b/.test(t))return[M4o+" "+zxa,""];let r=/Windows NT ([0-9.]+)/i.exec(t);if(r&&r[1]){let i=r[1],n=Sl5[i]||"";return/arm/i.test(t)&&(n="RT"),[M4o,n]}return[M4o,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){let t=[e[3],e[4],e[5]||"0"];return[_oc,t.join(".")]}return[_oc,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{let t="";return e&&e.length>=3&&(t=Txa(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Rxa+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Rxa+")","i"),e=>{if(e&&e[2]){let t=[e[2],e[3],e[4]||"0"];return[Rxa,t.join(".")]}return[Rxa,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{let t=["Mac OS X",""];if(e&&e[1]){let r=[e[1],e[2],e[3]||"0"];t[1]=r.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[bl5,""]],[/Linux|debian/i,["Linux",""]]];var _8E="utf8";function h8E(e,t){if(!e||typeof e!="string"||Ml5(e))throw new Error(t)}function Ml5(e){return e.trim().length===0}function y8E(e){return e?.replace(/\/+$/,"")}async function b8E(e,t){let r=null;for(let i=0;i<t.retryCount+1;i++){i>0&&await new Promise(n=>setTimeout(n,t.retryDelay));try{return await e()}catch(n){if(r=n,!t.retryCheck(n))throw n}}throw r}function boc(){return new Date().toISOString()}function Tea(e,t){let r=setTimeout(e,t);return r?.unref&&r?.unref(),r}var v8E=e=>e instanceof Error;function Swp(e){return Promise.all(e.map(t=>(t??Promise.resolve()).then(r=>({status:"fulfilled",value:r}),r=>({status:"rejected",reason:r}))))}var voc=class{constructor(){this.events={},this.events={}}on(t,r){return this.events[t]||(this.events[t]=[]),this.events[t].push(r),()=>{this.events[t]=this.events[t].filter(i=>i!==r)}}emit(t,r){for(let i of this.events[t]||[])i(r);for(let i of this.events["*"]||[])i(t,r)}};function g8E(){return"CompressionStream"in globalThis}async function Mwp(e,t=!0){try{let i=new Blob([e],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return await new Response(i).blob()}catch(r){return t&&console.error("Failed to gzip compress data",r),null}}var Rea=class extends Error{constructor(t,r){super("HTTP error while fetching PostHog: status="+t.status+", reqByteLength="+r),this.response=t,this.reqByteLength=r,this.name="PostHogFetchHttpError"}get status(){return this.response.status}get text(){return this.response.text()}get json(){return this.response.json()}},Nxa=class extends Error{constructor(t){super("Network error while fetching PostHog",t instanceof Error?{cause:t}:{}),this.error=t,this.name="PostHogFetchNetworkError"}};async function O8E(e){if(e instanceof Rea){let t="";try{t=await e.text}catch{}console.error(`Error while flushing PostHog: message=${e.message}, response body=${t}`,e)}else console.error("Error while flushing PostHog",e);return Promise.resolve()}function Dwp(e){return typeof e=="object"&&(e instanceof Rea||e instanceof Nxa)}function m8E(e){return typeof e=="object"&&e instanceof Rea&&e.status===413}var D4o=class{constructor(t,r={}){this.flushPromise=null,this.shutdownPromise=null,this.promiseQueue=new doc,this._events=new voc,this._isInitialized=!1,h8E(t,"You must pass your PostHog project's api key."),this.apiKey=t,this.host=y8E(r.host||"https://us.i.posthog.com"),this.flushAt=r.flushAt?Math.max(r.flushAt,1):20,this.maxBatchSize=Math.max(this.flushAt,r.maxBatchSize??100),this.maxQueueSize=Math.max(this.flushAt,r.maxQueueSize??1e3),this.flushInterval=r.flushInterval??1e4,this.preloadFeatureFlags=r.preloadFeatureFlags??!0,this.defaultOptIn=r.defaultOptIn??!0,this.disableSurveys=r.disableSurveys??!1,this._retryOptions={retryCount:r.fetchRetryCount??3,retryDelay:r.fetchRetryDelay??3e3,retryCheck:Dwp},this.requestTimeout=r.requestTimeout??1e4,this.featureFlagsRequestTimeoutMs=r.featureFlagsRequestTimeoutMs??3e3,this.remoteConfigRequestTimeoutMs=r.remoteConfigRequestTimeoutMs??3e3,this.disableGeoip=r.disableGeoip??!0,this.disabled=r.disabled??!1,this.historicalMigration=r?.historicalMigration??!1,this._initPromise=Promise.resolve(),this._isInitialized=!0,this._logger=u8E("[PostHog]",this.logMsgIfDebug.bind(this)),this.evaluationContexts=r?.evaluationContexts??r?.evaluationEnvironments,r?.evaluationEnvironments&&!r?.evaluationContexts&&this._logger.warn("evaluationEnvironments is deprecated. Use evaluationContexts instead. This property will be removed in a future version."),this.disableCompression=!g8E()||(r?.disableCompression??!1)}logMsgIfDebug(t){this.isDebug&&t()}wrap(t){if(this.disabled)return void this._logger.warn("The client is disabled");if(this._isInitialized)return t();this._initPromise.then(()=>t())}getCommonEventProperties(){return{$lib:this.getLibraryId(),$lib_version:this.getLibraryVersion()}}get optedOut(){return this.getPersistedProperty(EOe.OptedOut)??!this.defaultOptIn}async optIn(){this.wrap(()=>{this.setPersistedProperty(EOe.OptedOut,!1)})}async optOut(){this.wrap(()=>{this.setPersistedProperty(EOe.OptedOut,!0)})}on(t,r){return this._events.on(t,r)}debug(t=!0){if(this.removeDebugCallback?.(),t){let r=this.on("*",(i,n)=>this._logger.info(i,n));this.removeDebugCallback=()=>{r(),this.removeDebugCallback=void 0}}}get isDebug(){return!!this.removeDebugCallback}get isDisabled(){return this.disabled}buildPayload(t){return{distinct_id:t.distinct_id,event:t.event,properties:{...t.properties||{},...this.getCommonEventProperties()}}}addPendingPromise(t){return this.promiseQueue.add(t)}identifyStateless(t,r,i){this.wrap(()=>{let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};this.enqueue("identify",n,i)})}async identifyStatelessImmediate(t,r,i){let n={...this.buildPayload({distinct_id:t,event:"$identify",properties:r})};await this.sendImmediate("identify",n,i)}captureStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({distinct_id:t,event:r,properties:i});this.enqueue("capture",a,n)})}async captureStatelessImmediate(t,r,i,n){let a=this.buildPayload({distinct_id:t,event:r,properties:i});await this.sendImmediate("capture",a,n)}aliasStateless(t,r,i,n){this.wrap(()=>{let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});this.enqueue("alias",a,n)})}async aliasStatelessImmediate(t,r,i,n){let a=this.buildPayload({event:"$create_alias",distinct_id:r,properties:{...i||{},distinct_id:r,alias:t}});await this.sendImmediate("alias",a,n)}groupIdentifyStateless(t,r,i,n,a,o){this.wrap(()=>{let c=this.buildPayload({distinct_id:a||`$${t}_${r}`,event:"$groupidentify",properties:{$group_type:t,$group_key:r,$group_set:i||{},...o||{}}});this.enqueue("capture",c,n)})}async getRemoteConfig(){await this._initPromise;let t=this.host;t==="https://us.i.posthog.com"?t="https://us-assets.i.posthog.com":t==="https://eu.i.posthog.com"&&(t="https://eu-assets.i.posthog.com");let r=`${t}/array/${this.apiKey}/config`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}};return this.fetchWithRetry(r,i,{retryCount:0},this.remoteConfigRequestTimeoutMs).then(n=>n.json()).catch(n=>{this._logger.error("Remote config could not be loaded",n),this._events.emit("error",n)})}async getFlags(t,r={},i={},n={},a={},o=!0){await this._initPromise;let c=o?"&config=true":"",d=`${this.host}/flags/?v=2${c}`,s={token:this.apiKey,distinct_id:t,groups:r,person_properties:i,group_properties:n,...a};this.evaluationContexts&&this.evaluationContexts.length>0&&(s.evaluation_contexts=this.evaluationContexts);let u={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"},body:JSON.stringify(s)};return this._logger.info("Flags URL",d),this.fetchWithRetry(d,u,{retryCount:0},this.featureFlagsRequestTimeoutMs).then(f=>f.json()).then(f=>({success:!0,response:bwp(f)})).catch(f=>(this._events.emit("error",f),{success:!1,error:this.categorizeRequestError(f)}))}categorizeRequestError(t){if(t instanceof Rea)return{type:"api_error",statusCode:t.status};if(t instanceof Nxa){let r=t.error;return r instanceof Error&&(r.name==="AbortError"||r.name==="TimeoutError")?{type:"timeout"}:{type:"connection_error"}}return{type:"unknown_error"}}async getFeatureFlagStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailStateless(t,r,i,n,a,o);if(c===void 0)return{response:void 0,requestId:void 0};let d=j4o(c.response);return d===void 0&&(d=!1),{response:d,requestId:c.requestId}}async getFeatureFlagDetailStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(r,i,n,a,o,[t]);return c===void 0?void 0:{response:c.flags[t],requestId:c.requestId,evaluatedAt:c.evaluatedAt}}async getFeatureFlagPayloadStateless(t,r,i={},n={},a={},o){await this._initPromise;let c=await this.getFeatureFlagPayloadsStateless(r,i,n,a,o,[t]);if(!c)return;let d=c[t];return d===void 0?null:d}async getFeatureFlagPayloadsStateless(t,r={},i={},n={},a,o){return await this._initPromise,(await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)).payloads}async getFeatureFlagsStateless(t,r={},i={},n={},a,o){return await this._initPromise,await this.getFeatureFlagsAndPayloadsStateless(t,r,i,n,a,o)}async getFeatureFlagsAndPayloadsStateless(t,r={},i={},n={},a,o){await this._initPromise;let c=await this.getFeatureFlagDetailsStateless(t,r,i,n,a,o);return c?{flags:c.featureFlags,payloads:c.featureFlagPayloads,requestId:c.requestId}:{flags:void 0,payloads:void 0,requestId:void 0}}async getFeatureFlagDetailsStateless(t,r={},i={},n={},a,o){await this._initPromise;let c={};(a??this.disableGeoip)&&(c.geoip_disable=!0),o&&(c.flag_keys_to_evaluate=o);let d=await this.getFlags(t,r,i,n,c);if(!d.success)return;let s=d.response;return s.errorsWhileComputingFlags&&console.error("[FEATURE FLAGS] Error while computing feature flags, some flags may be missing or incorrect. Learn more at https://posthog.com/docs/feature-flags/best-practices"),s.quotaLimited?.includes("feature_flags")?(console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - feature flags unavailable. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),{flags:{},featureFlags:{},featureFlagPayloads:{},requestId:s?.requestId,quotaLimited:s.quotaLimited}):s}async getSurveysStateless(){if(await this._initPromise,this.disableSurveys===!0)return this._logger.info("Loading surveys is disabled."),[];let t=`${this.host}/api/surveys/?token=${this.apiKey}`,r={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json"}},n=(await this.fetchWithRetry(t,r).then(a=>{if(a.status!==200||!a.json){let o=`Surveys API could not be loaded: ${a.status}`,c=new Error(o);this._logger.error(c),this._events.emit("error",new Error(o));return}return a.json()}).catch(a=>{this._logger.error("Surveys API could not be loaded",a),this._events.emit("error",a)}))?.surveys;return n&&this._logger.info("Surveys fetched from API: ",JSON.stringify(n)),n??[]}get props(){return this._props||(this._props=this.getPersistedProperty(EOe.Props)),this._props||{}}set props(t){this._props=t}async register(t){this.wrap(()=>{this.props={...this.props,...t},this.setPersistedProperty(EOe.Props,this.props)})}async unregister(t){this.wrap(()=>{delete this.props[t],this.setPersistedProperty(EOe.Props,this.props)})}processBeforeEnqueue(t){return t}enqueue(t,r,i){this.wrap(()=>{if(this.optedOut)return void this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");let n=this.prepareMessage(t,r,i);if(n=this.processBeforeEnqueue(n),n===null)return;let a=this.getPersistedProperty(EOe.Queue)||[];a.length>=this.maxQueueSize&&(a.shift(),this._logger.info("Queue is full, the oldest event is dropped.")),a.push({message:n}),this.setPersistedProperty(EOe.Queue,a),this._events.emit(t,n),a.length>=this.flushAt&&this.flushBackground(),this.flushInterval&&!this._flushTimer&&(this._flushTimer=Tea(()=>this.flushBackground(),this.flushInterval))})}async sendImmediate(t,r,i){if(this.disabled)return void this._logger.warn("The client is disabled");if(this._isInitialized||await this._initPromise,this.optedOut)return void this._events.emit(t,"Library is disabled. Not sending event. To re-enable, call posthog.optIn()");let n=this.prepareMessage(t,r,i);if(n=this.processBeforeEnqueue(n),n===null)return;let a={api_key:this.apiKey,batch:[n],sent_at:boc()};this.historicalMigration&&(a.historical_migration=!0);let o=JSON.stringify(a),c=`${this.host}/batch/`,d=this.disableCompression?null:await Mwp(o,this.isDebug),s={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...d!==null&&{"Content-Encoding":"gzip"}},body:d||o};try{await this.fetchWithRetry(c,s)}catch(u){this._events.emit("error",u)}}prepareMessage(t,r,i){let n={...r,type:t,library:this.getLibraryId(),library_version:this.getLibraryVersion(),timestamp:i?.timestamp?i?.timestamp:boc(),uuid:i?.uuid?i.uuid:pLi()};return(i?.disableGeoip??this.disableGeoip)&&(n.properties||(n.properties={}),n.properties.$geoip_disable=!0),n.distinctId&&(n.distinct_id=n.distinctId,delete n.distinctId),n}clearFlushTimer(){this._flushTimer&&(clearTimeout(this._flushTimer),this._flushTimer=void 0)}flushBackground(){this.flush().catch(async t=>{await O8E(t)})}async flush(){let t=Swp([this.flushPromise]).then(()=>this._flush());return this.flushPromise=t,this.addPendingPromise(t),Swp([t]).then(()=>{this.flushPromise===t&&(this.flushPromise=null)}),t}getCustomHeaders(){let t=this.getCustomUserAgent(),r={};return t&&t!==""&&(r["User-Agent"]=t),r}async _flush(){this.clearFlushTimer(),await this._initPromise;let t=this.getPersistedProperty(EOe.Queue)||[];if(!t.length)return;let r=[],i=t.length;for(;t.length>0&&r.length<i;){let n=t.slice(0,this.maxBatchSize),a=n.map(_=>_.message),o=()=>{let h=(this.getPersistedProperty(EOe.Queue)||[]).slice(n.length);this.setPersistedProperty(EOe.Queue,h),t=h},c={api_key:this.apiKey,batch:a,sent_at:boc()};this.historicalMigration&&(c.historical_migration=!0);let d=JSON.stringify(c),s=`${this.host}/batch/`,u=this.disableCompression?null:await Mwp(d,this.isDebug),f={method:"POST",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",...u!==null&&{"Content-Encoding":"gzip"}},body:u||d},p={retryCheck:_=>m8E(_)?!1:Dwp(_)};try{await this.fetchWithRetry(s,f,p)}catch(_){if(m8E(_)&&a.length>1){this.maxBatchSize=Math.max(1,Math.floor(a.length/2)),this._logger.warn(`Received 413 when sending batch of size ${a.length}, reducing batch size to ${this.maxBatchSize}`);continue}throw _ instanceof Nxa||o(),this._events.emit("error",_),_}o(),r.push(...a)}this._events.emit("flush",r)}async fetchWithRetry(t,r,i,n){AbortSignal.timeout??=function(c){let d=new AbortController;return setTimeout(()=>d.abort(),c),d.signal};let a=r.body?r.body:"",o=-1;try{o=a instanceof Blob?a.size:Buffer.byteLength(a,_8E)}catch{a instanceof Blob?o=a.size:o=new TextEncoder().encode(a).length}return await b8E(async()=>{let c=null;try{c=await this.fetch(t,{signal:AbortSignal.timeout(n??this.requestTimeout),...r})}catch(s){throw new Nxa(s)}if(!(r.mode==="no-cors")&&(c.status<200||c.status>=400))throw new Rea(c,o);return c},{...this._retryOptions,...i})}async _shutdown(t=3e4){await this._initPromise;let r=!1;this.clearFlushTimer();let i=async()=>{try{for(await this.promiseQueue.join();!((this.getPersistedProperty(EOe.Queue)||[]).length===0||(await this.flush(),r)););}catch(n){if(!Dwp(n))throw n;await O8E(n)}};return Promise.race([new Promise((n,a)=>{Tea(()=>{this._logger.error("Timed out while shutting down PostHog"),r=!0,a("Timeout while shutting down PostHog. Some events may not have been sent.")},t)}),i()])}async shutdown(t=3e4){return this.shutdownPromise?this._logger.warn("shutdown() called while already shutting down. shutdown() is meant to be called once before process exit - use flush() for per-request cleanup"):this.shutdownPromise=this._shutdown(t).finally(()=>{this.shutdownPromise=null}),this.shutdownPromise}};var SOe={};$t(SOe,{DOMExceptionCoercer:()=>qwp,ErrorCoercer:()=>Twp,ErrorEventCoercer:()=>Rwp,ErrorPropertiesBuilder:()=>Bwp,EventCoercer:()=>Fwp,ObjectCoercer:()=>Nwp,PrimitiveCoercer:()=>Qwp,PromiseRejectionEventCoercer:()=>Uwp,ReduceableCache:()=>Lwp,StringCoercer:()=>zwp,chromeStackLineParser:()=>Iwp,createDefaultStackParser:()=>Wl5,createStackParser:()=>C8E,geckoStackLineParser:()=>Cwp,nodeStackLineParser:()=>M8E,opera10StackLineParser:()=>w8E,opera11StackLineParser:()=>E8E,reverseAndStripFrames:()=>I8E,winjsStackLineParser:()=>j8E});var goc,A8E,Ooc;function P8E(e){let t=globalThis._posthogChunkIds;if(!t)return;let r=Object.keys(t);return Ooc&&r.length===A8E||(A8E=r.length,Ooc=r.reduce((i,n)=>{goc||(goc={});let a=goc[n];if(a)i[a[0]]=a[1];else{let o=e(n);for(let c=o.length-1;c>=0;c--){let s=o[c]?.filename,u=t[n];if(s&&u){i[s]=u,goc[n]=[s,u];break}}}return i},{})),Ooc}var Bl5=4,Bwp=class{constructor(t,r,i=[]){this.coercers=t,this.stackParser=r,this.modifiers=i}buildFromUnknown(t,r={}){let n=r&&r.mechanism||{handled:!0,type:"generic"},o=this.buildCoercingContext(n,r,0).apply(t),c=this.buildParsingContext(),d=this.parseStacktrace(o,c);return{$exception_list:this.convertToExceptionList(d,n),$exception_level:"error"}}async modifyFrames(t){for(let r of t)r.stacktrace&&r.stacktrace.frames&&Owp(r.stacktrace.frames)&&(r.stacktrace.frames=await this.applyModifiers(r.stacktrace.frames));return t}coerceFallback(t){return{type:"Error",value:"Unknown error",stack:t.syntheticException?.stack,synthetic:!0}}parseStacktrace(t,r){let i;t.cause!=null&&(i=this.parseStacktrace(t.cause,r));let n;return t.stack!=""&&t.stack!=null&&(n=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?1:0),r.chunkIdMap)),{...t,cause:i,stack:n}}applyChunkIds(t,r){return t.map(i=>(i.filename&&r&&(i.chunk_id=r[i.filename]),i))}applyCoercers(t,r){for(let i of this.coercers)if(i.match(t))return i.coerce(t,r);return this.coerceFallback(r)}async applyModifiers(t){let r=t;for(let i of this.modifiers)r=await i(r);return r}convertToExceptionList(t,r){let i={type:t.type,value:t.value,mechanism:{type:r.type??"generic",handled:r.handled??!0,synthetic:t.synthetic??!1}};t.stack&&(i.stacktrace={type:"raw",frames:t.stack});let n=[i];return t.cause!=null&&n.push(...this.convertToExceptionList(t.cause,{...r,handled:!0})),n}buildParsingContext(){return{chunkIdMap:P8E(this.stackParser)}}buildCoercingContext(t,r,i=0){let n=(o,c)=>{if(c<=Bl5){let d=this.buildCoercingContext(t,r,c);return this.applyCoercers(o,d)}};return{...r,syntheticException:i==0?r.syntheticException:void 0,mechanism:t,apply:o=>n(o,i),next:o=>n(o,i+1)}}};var zx="?";function _Li(e,t,r,i,n){let a={platform:e,filename:t,function:r==="<anonymous>"?zx:r,in_app:!0};return Txa(i)||(a.lineno=i),Txa(n)||(a.colno=n),a}var moc=(e,t)=>{let r=e.indexOf("safari-extension")!==-1,i=e.indexOf("safari-web-extension")!==-1;return r||i?[e.indexOf("@")!==-1?e.split("@")[0]:zx,r?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]};var Il5=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Cl5=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ql5=/\((\S*)(?::(\d+))(?::(\d+))\)/,Iwp=(e,t)=>{let r=Il5.exec(e);if(r){let[,n,a,o]=r;return _Li(t,n,zx,+a,+o)}let i=Cl5.exec(e);if(i){if(i[2]&&i[2].indexOf("eval")===0){let c=ql5.exec(i[2]);c&&(i[2]=c[1],i[3]=c[2],i[4]=c[3])}let[a,o]=moc(i[1]||zx,i[2]);return _Li(t,o,a,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}};var Tl5=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Rl5=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Cwp=(e,t)=>{let r=Tl5.exec(e);if(r){if(r[3]&&r[3].indexOf(" > eval")>-1){let o=Rl5.exec(r[3]);o&&(r[1]=r[1]||"eval",r[3]=o[1],r[4]=o[2],r[5]="")}let n=r[3],a=r[1]||zx;return[a,n]=moc(a,n),_Li(t,n,a,r[4]?+r[4]:void 0,r[5]?+r[5]:void 0)}};var zl5=/^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i,j8E=(e,t)=>{let r=zl5.exec(e);return r?_Li(t,r[2],r[1]||zx,+r[3],r[4]?+r[4]:void 0):void 0};var Nl5=/ line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i,w8E=(e,t)=>{let r=Nl5.exec(e);return r?_Li(t,r[2],r[3]||zx,+r[1]):void 0},Fl5=/ line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i,E8E=(e,t)=>{let r=Fl5.exec(e);return r?_Li(t,r[5],r[3]||r[4]||zx,+r[1],+r[2]):void 0};var Ql5=/^\s*[-]{4,}$/,Ul5=/at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/,M8E=(e,t)=>{let r=e.match(Ul5);if(r){let i,n,a,o,c;if(r[1]){a=r[1];let u=a.lastIndexOf(".");if(a[u-1]==="."&&u--,u>0){i=a.slice(0,u),n=a.slice(u+1);let f=i.indexOf(".Module");f>0&&(a=a.slice(f+1),i=i.slice(0,f))}o=void 0}n&&(o=i,c=n),n==="<anonymous>"&&(c=void 0,a=void 0),a===void 0&&(c=c||zx,a=o?`${o}.${c}`:c);let d=r[2]?.startsWith("file://")?r[2].slice(7):r[2],s=r[5]==="native";return d?.match(/\/[A-Z]:/)&&(d=d.slice(1)),!d&&r[5]&&!s&&(d=r[5]),{filename:d?decodeURI(d):void 0,module:void 0,function:a,lineno:S8E(r[3]),colno:S8E(r[4]),in_app:Ll5(d||"",s),platform:t}}if(e.match(Ql5))return{filename:e,platform:t}};function Ll5(e,t=!1){return!(t||e&&!e.startsWith("/")&&!e.match(/^[A-Z]:/)&&!e.startsWith(".")&&!e.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//))&&e!==void 0&&!e.includes("node_modules/")}function S8E(e){return parseInt(e||"",10)||void 0}var D8E=/\(error: (.*)\)/,B8E=50;function I8E(e){if(!e.length)return[];let t=Array.from(e);return t.reverse(),t.slice(0,B8E).map(r=>({...r,filename:r.filename||Vl5(t).filename,function:r.function||zx}))}function Vl5(e){return e[e.length-1]||{}}function Wl5(){return C8E("web:javascript",Iwp,Cwp)}function C8E(e,...t){return(r,i=0)=>{let n=[],a=r.split(`
|
|
2240
|
-
`);for(let o=i;o<a.length;o++){let c=a[o];if(c.length>1024)continue;let d=D8E.test(c)?c.replace(D8E,"$1"):c;if(!d.match(/\S*Error: /)){for(let s of t){let u=s(d,e);if(u){n.push(u);break}}if(n.length>=B8E)break}}return I8E(n)}}var qwp=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,r){let i=w4o(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?r.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){let r=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${r}: ${t.message}`:r}isDOMException(t){return qea(t,"DOMException")}isDOMError(t){return qea(t,"DOMError")}};var Twp=class{match(t){return mwp(t)}coerce(t,r){return{type:this.getType(t),value:this.getMessage(t,r),stack:this.getStack(t),cause:t.cause?r.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,r){let i=t.message;return i.error&&typeof i.error.message=="string"?String(i.error.message):String(i)}getStack(t){return t.stacktrace||t.stack||void 0}};var Rwp=class{constructor(){}match(t){return n8E(t)&&t.error!=null}coerce(t,r){let i=r.apply(t.error);return i||{type:"ErrorEvent",value:t.message,stack:r.syntheticException?.stack,synthetic:!0}}};var xl5=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,zwp=class{match(t){return typeof t=="string"}coerce(t,r){let[i,n]=this.getInfos(t);return{type:i??"Error",value:n??t,stack:r.syntheticException?.stack,synthetic:!0}}getInfos(t){let r="Error",i=t,n=t.match(xl5);return n&&(r=n[1],i=n[2]),[r,i]}};var q8E=["fatal","error","warning","log","info","debug"];function Aoc(e,t=40){let r=Object.keys(e);if(r.sort(),!r.length)return"[object has no keys]";for(let i=r.length;i>0;i--){let n=r.slice(0,i).join(", ");if(!(n.length>t))return i===r.length||n.length<=t?n:`${n.slice(0,t)}...`}return""}var Nwp=class{match(t){return typeof t=="object"&&t!==null}coerce(t,r){let i=this.getErrorPropertyFromObject(t);return i?r.apply(i):{type:this.getType(t),value:this.getValue(t),stack:r.syntheticException?.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return loc(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){let n=`'${t.name}' captured as exception`;return"message"in t&&typeof t.message=="string"&&(n+=` with message: '${t.message}'`),n}if("message"in t&&typeof t.message=="string")return t.message;let r=this.getObjectClassName(t),i=Aoc(t);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${i}`}isSeverityLevel(t){return w4o(t)&&!r8E(t)&&q8E.indexOf(t)>=0}getErrorPropertyFromObject(t){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(v8E(i))return i}}getObjectClassName(t){try{let r=Object.getPrototypeOf(t);return r?r.constructor.name:void 0}catch{return}}};var Fwp=class{match(t){return loc(t)}coerce(t,r){let i=t.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${Aoc(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var Qwp=class{match(t){return E4o(t)}coerce(t,r){return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var Uwp=class{match(t){return qea(t,"PromiseRejectionEvent")}coerce(t,r){let i=this.getUnhandledRejectionReason(t);return E4o(i)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`,stack:r.syntheticException?.stack,synthetic:!0}:r.apply(i)}getUnhandledRejectionReason(t){if(E4o(t))return t;try{if("reason"in t)return t.reason;if("detail"in t&&"reason"in t.detail)return t.detail.reason}catch{}return t}};var Lwp=class{constructor(t){this._maxSize=t,this._cache=new Map}get(t){let r=this._cache.get(t);if(r!==void 0)return this._cache.delete(t),this._cache.set(t,r),r}set(t,r){this._cache.set(t,r)}reduce(){for(;this._cache.size>=this._maxSize;){let t=this._cache.keys().next().value;t&&this._cache.delete(t)}}};var z8E=require("fs"),N8E=require("readline"),Poc=new SOe.ReduceableCache(25),F8E=new SOe.ReduceableCache(20),Vwp=7,Gl5=1e3,Hl5=1e4;async function Q8E(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||Yl5(o)||Xl5(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(F8E.get(n))continue;let a=t[n];if(!a)continue;a.sort((d,s)=>d-s);let o=kl5(a);if(o.every(d=>Zl5(n,d)))continue;let c=ef5(Poc,n,{});i.push(Kl5(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&$l5(e,Poc),Poc.reduce(),e}function Kl5(e,t,r){return new Promise(i=>{let n=(0,z8E.createReadStream)(e),a=(0,N8E.createInterface)({input:n});function o(){n.destroy(),i()}let c=0,d=0,s=t[d];if(s===void 0)return void o();let u=s[0],f=s[1];function p(){F8E.set(e,1),a.close(),a.removeAllListeners(),o()}n.on("error",p),a.on("error",p),a.on("close",o),a.on("line",_=>{if(c++,!(c<u)&&(r[c]=tf5(_,0),c>=f)){if(d===t.length-1){a.close(),a.removeAllListeners();return}d++;let h=t[d];if(h===void 0){a.close(),a.removeAllListeners();return}u=h[0],f=h[1]}})})}function $l5(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let i=t.get(r.filename);if(i===void 0)continue;Jl5(r.lineno,r,i)}}function Jl5(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=U8E(e);n<e;n++){let a=r[n];if(a===void 0)return void T8E(t);t.pre_context.push(a)}if(r[e]===void 0)return void T8E(t);t.context_line=r[e];let i=L8E(e);t.post_context=[];for(let n=e+1;n<=i;n++){let a=r[n];if(a===void 0)break;t.post_context.push(a)}}function T8E(e){delete e.pre_context,delete e.context_line,delete e.post_context}function Yl5(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function Xl5(e){return e.lineno!==void 0&&e.lineno>Hl5||e.colno!==void 0&&e.colno>Gl5}function Zl5(e,t){let r=Poc.get(e);if(r===void 0)return!1;for(let i=t[0];i<=t[1];i++)if(r[i]===void 0)return!1;return!0}function kl5(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=R8E(r),n=[];for(;;){if(t===e.length-1){n.push(i);break}let a=e[t+1];if(typeof a!="number")break;a<=i[1]?i[1]=a+Vwp:(n.push(i),i=R8E(a)),t++}return n}function R8E(e){return[U8E(e),L8E(e)]}function U8E(e){return Math.max(1,e-Vwp)}function L8E(e){return e+Vwp}function ef5(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function tf5(e,t){let r=e,i=r.length;if(i<=150)return r;t>i&&(t=i);let n=Math.max(t-60,0);n<5&&(n=0);let a=Math.min(n+140,i);return a>i-5&&(a=i),a===i&&(n=Math.max(a-140,0)),r=r.slice(n,a),n>0&&(r=`...${r}`),a<i&&(r+="..."),r}function rf5(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t(i))},{_posthogErrorHandler:!0})}function V8E(e,t){globalThis.process?.on("uncaughtException",rf5(e,t))}function W8E(e){globalThis.process?.on("unhandledRejection",t=>e(t,{mechanism:{type:"onunhandledrejection",handled:!1}}))}var if5=2e3,c$t=class e{constructor(t,r,i){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this._logger=i,this._rateLimiter=new foc({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(t){return t8E(t)&&"__posthog_previously_captured_error"in t&&t.__posthog_previously_captured_error===!0}static async buildEventMessage(t,r,i,n){let a={...n};i||(a.$process_person_profile=!1);let o=this.errorPropertiesBuilder.buildFromUnknown(t,r);return o.$exception_list=await this.errorPropertiesBuilder.modifyFrames(o.$exception_list),{event:"$exception",distinctId:i||pLi(),properties:{...o,...a}}}startAutocaptureIfEnabled(){this.isEnabled()&&(V8E(this.onException.bind(this),this.onFatalError.bind(this)),W8E(this.onException.bind(this)))}onException(t,r){this.client.addPendingPromise((async()=>{if(!e.isPreviouslyCapturedError(t)){let i=await e.buildEventMessage(t,r),a=i.properties?.$exception_list[0]?.type??"Exception";return this._rateLimiter.consumeRateLimit(a)?void this._logger.info("Skipping exception capture because of client rate limiting.",{exception:a}):this.client.capture(i)}})())}async onFatalError(t){console.error(t),await this.client.shutdown(if5),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};var x8E="5.24.7";var B4o={ERRORS_WHILE_COMPUTING:"errors_while_computing_flags",FLAG_MISSING:"flag_missing",QUOTA_LIMITED:"quota_limited",UNKNOWN_ERROR:"unknown_error"};async function G8E(e){let t=globalThis.crypto?.subtle;if(!t)throw new Error("SubtleCrypto API not available");let r=await t.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(r)).map(n=>n.toString(16).padStart(2,"0")).join("")}var nf5=6e4,af5=1152921504606847e3,of5=["is_not"],Fxa=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},uE=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},hLi=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},joc=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:o,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=c.fetch||fetch,this.onError=c.onError,this.customHeaders=o,this.onLoad=c.onLoad,this.cacheProvider=c.cacheProvider,this.strictLocalEvaluation=c.strictLocalEvaluation??!1,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;if(c=this.featureFlagsByKey[t],c!==void 0)try{o=(await this.computeFlagAndPayloadLocally(c,r,i,n,a)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(d){d instanceof hLi||d instanceof uE?this.logMsgIfDebug(()=>console.debug(`${d.name} when computing flag locally: ${t}: ${d.message}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return o}async getAllFlagsAndPayloads(t,r={},i={},n={},a){await this.loadFeatureFlags();let o={},c={},d=this.featureFlags.length==0,s=a?a.map(f=>this.featureFlagsByKey[f]).filter(Boolean):this.featureFlags,u={};return await Promise.all(s.map(async f=>{try{let{value:p,payload:_}=await this.computeFlagAndPayloadLocally(f,t,r,i,n,void 0,u);o[f.key]=p,_&&(c[f.key]=_)}catch(p){p instanceof hLi||p instanceof uE?this.logMsgIfDebug(()=>console.debug(`${p.name} when computing flag locally: ${f.key}: ${p.message}`)):p instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${p}`)),d=!0}})),{response:o,payloads:c,fallbackToFlags:d}}async computeFlagAndPayloadLocally(t,r,i={},n={},a={},o,c,d=!1){if(d||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};let s;s=o!==void 0?o:await this.computeFlagValueLocally(t,r,i,n,a,c);let u=this.getFeatureFlagPayload(t.key,s);return{value:s,payload:u}}async computeFlagValueLocally(t,r,i={},n={},a={},o={}){if(t.ensure_experience_continuity)throw new uE("Flag has experience continuity enabled");if(!t.active)return!1;let d=(t.filters||{}).aggregation_group_type_index;if(d==null)return await this.matchFeatureFlagProperties(t,r,n,o);{let s=this.groupTypeMapping[String(d)];if(!s)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${d} for feature flag ${t.key}`)),new uE("Flag has unknown group type index");if(!(s in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let u=a[s];return await this.matchFeatureFlagProperties(t,i[s],u,o)}}getFeatureFlagPayload(t,r){let i=null;if(r!==!1&&r!=null&&(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]||null:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]||null),i!=null)){if(typeof i=="object")return i;if(typeof i=="string")try{return JSON.parse(i)}catch{}return i}return null}async evaluateFlagDependency(t,r,i,n){let a=t.key;if(!this.featureFlagsByKey)throw new uE("Feature flags not available for dependency evaluation");if(!("dependency_chain"in t))throw new uE(`Flag dependency property for '${a}' is missing required 'dependency_chain' field`);let o=t.dependency_chain;if(!Array.isArray(o))throw new uE(`Flag dependency property for '${a}' has an invalid 'dependency_chain' (expected array, got ${typeof o})`);if(o.length===0)throw new uE(`Circular dependency detected for flag '${a}' (empty dependency chain)`);for(let d of o){if(!(d in n)){let u=this.featureFlagsByKey[d];if(u)if(u.active)try{let f=await this.matchFeatureFlagProperties(u,r,i,n);n[d]=f}catch(f){throw new uE(`Error evaluating flag dependency '${d}' for flag '${a}': ${f}`)}else n[d]=!1;else throw new uE(`Missing flag dependency '${d}' for flag '${a}'`)}if(n[d]==null)throw new uE(`Dependency '${d}' could not be evaluated`)}let c=n[a];return this.flagEvaluatesToExpectedValue(t.value,c)}flagEvaluatesToExpectedValue(t,r){return typeof t=="boolean"?t===r||typeof r=="string"&&r!==""&&t===!0:typeof t=="string"?r===t:!1}async matchFeatureFlagProperties(t,r,i,n={}){let a=t.filters||{},o=a.groups||[],c=!1,d;for(let s of o)try{if(await this.isConditionMatch(t,r,s,i,n)){let u=s.variant,f=a.multivariate?.variants||[];d=u&&f.some(p=>p.key===u)?u:await this.getMatchingVariant(t,r)||!0;break}}catch(u){if(u instanceof hLi)throw u;if(u instanceof uE)c=!0;else throw u}if(d!==void 0)return d;if(c)throw new uE("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,i,n,a={}){let o=i.rollout_percentage,c=d=>{this.logMsgIfDebug(()=>console.warn(d))};if((i.properties||[]).length>0){for(let d of i.properties){let s=d.type,u=!1;if(u=s==="cohort"?Y8E(d,n,this.cohorts,this.debugMode):s==="flag"?await this.evaluateFlagDependency(d,r,n,a):J8E(d,n,c),!u)return!1}if(o==null)return!0}return!(o!=null&&await H8E(t.key,r)>o/100)}async getMatchingVariant(t,r){let i=await H8E(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{n=i+c.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:c.key}),i=n}),r}updateFlagState(t){this.featureFlags=t.flags,this.featureFlagsByKey=t.flags.reduce((r,i)=>(r[i.key]=i,r),{}),this.groupTypeMapping=t.groupTypeMapping,this.cohorts=t.cohorts,this.loadedSuccessfullyOnce=!0}warnAboutExperienceContinuityFlags(t){if(this.strictLocalEvaluation)return;let r=t.filter(i=>i.ensure_experience_continuity);r.length>0&&console.warn(`[PostHog] You are using local evaluation but ${r.length} flag(s) have experience continuity enabled: ${r.map(i=>i.key).join(", ")}. Experience continuity is incompatible with local evaluation and will cause a server request on every flag evaluation, negating local evaluation cost savings. To avoid server requests and unexpected costs, either disable experience continuity on these flags in PostHog, use strictLocalEvaluation: true in client init, or pass onlyEvaluateLocally: true per flag call (flags that cannot be evaluated locally will return undefined).`)}async loadFromCache(t){if(!this.cacheProvider)return!1;try{let r=await this.cacheProvider.getFlagDefinitions();return r?(this.updateFlagState(r),this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${t} (${r.flags.length} flags)`)),this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(r.flags),!0):!1}catch(r){return this.onError?.(new Error(`Failed to load from cache: ${r}`)),!1}}async loadFeatureFlags(t=!1){if(!(this.loadedSuccessfullyOnce&&!t))return!t&&this.nextFetchAllowedAt&&Date.now()<this.nextFetchAllowedAt?void this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Skipping fetch, in backoff period")):(this.loadingPromise||(this.loadingPromise=this._loadFeatureFlags().catch(r=>this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Failed to load feature flags: ${r}`))).finally(()=>{this.loadingPromise=void 0})),this.loadingPromise)}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(nf5,this.pollingInterval*2**this.backOffCount):this.pollingInterval}beginBackoff(){this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,this.nextFetchAllowedAt=Date.now()+this.getPollingInterval()}clearBackoff(){this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.nextFetchAllowedAt=void 0}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this.loadFeatureFlags(!0),this.getPollingInterval());try{let t=!0;if(this.cacheProvider)try{t=await this.cacheProvider.shouldFetchFlagDefinitions()}catch(i){this.onError?.(new Error(`Error in shouldFetchFlagDefinitions: ${i}`))}if(!t&&(await this.loadFromCache("Loaded flags from cache (skipped fetch)")||this.loadedSuccessfullyOnce))return;let r=await this._requestFeatureFlagDefinitions();if(!r)return;switch(r.status){case 304:this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Flags not modified (304), using cached data")),this.flagsEtag=r.headers?.get("ETag")??this.flagsEtag,this.loadedSuccessfullyOnce=!0,this.clearBackoff();return;case 401:throw this.beginBackoff(),new Fxa(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.beginBackoff(),new Fxa(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.beginBackoff(),new Fxa(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let i=await r.json()??{};if(!("flags"in i))return void this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(i)}`));this.flagsEtag=r.headers?.get("ETag")??void 0;let n={flags:i.flags??[],groupTypeMapping:i.group_type_mapping||{},cohorts:i.cohorts||{}};if(this.updateFlagState(n),this.clearBackoff(),this.cacheProvider&&t)try{await this.cacheProvider.onFlagDefinitionsReceived(n)}catch(a){this.onError?.(new Error(`Failed to store in cache: ${a}`))}this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(n.flags);break}default:return}}catch(t){t instanceof Fxa&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET",r){let i={...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`};return r&&(i["If-None-Match"]=r),{method:t,headers:i}}_requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions("GET",this.flagsEtag),i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=Tea(()=>{n.abort()},this.timeout),r.signal=n.signal}try{let n=this.fetch;return n(t,r)}finally{clearTimeout(i)}}async stopPoller(t=3e4){if(clearTimeout(this.poller),this.cacheProvider)try{let r=this.cacheProvider.shutdown();r instanceof Promise&&await Promise.race([r,new Promise((i,n)=>setTimeout(()=>n(new Error(`Cache shutdown timeout after ${t}ms`)),t))])}catch(r){this.onError?.(new Error(`Error during cache shutdown: ${r}`))}}};async function H8E(e,t,r=""){let i=await G8E(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/af5}function J8E(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new uE("Operator is_not_set is not supported")}else throw new uE(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!of5.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,u){return Array.isArray(s)?s.map(f=>String(f).toLowerCase()).includes(String(u).toLowerCase()):String(s).toLowerCase()===String(u).toLowerCase()}function d(s,u,f){if(f==="gt")return s>u;if(f==="gte")return s>=u;if(f==="lt")return s<u;if(f==="lte")return s<=u;throw new Error(`Invalid operator: ${f}`)}switch(a){case"exact":return c(n,o);case"is_not":return!c(n,o);case"is_set":return i in t;case"icontains":return String(o).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(n).toLowerCase());case"regex":return K8E(String(n))&&String(o).match(String(n))!==null;case"not_regex":return K8E(String(n))&&String(o).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s==null||o==null?d(String(o),String(n),a):typeof o=="string"?d(o,String(n),a):d(o,s,a)}case"is_date_after":case"is_date_before":{if(typeof n=="boolean")throw new uE("Date operations cannot be performed on boolean values");let s=sf5(String(n));if(s==null&&(s=$8E(n)),s==null)throw new uE(`Invalid date: ${n}`);let u=$8E(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new uE(`Unknown operator: ${a}`)}}function uf5(e,t){if(!(e in t))throw new hLi(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function Y8E(e,t,r,i=!1){let n=String(e.value);uf5(n,r);let a=r[n];return X8E(a,t,r,i)}function X8E(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let d=X8E(c,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof hLi)throw d;if(d instanceof uE)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new uE("Can't match cohort without a given cohort property value");return n==="AND"}for(let c of a)try{let d;if(c.type==="cohort")d=Y8E(c,t,r,i);else if(c.type==="flag"){i&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${c.key||"unknown"}'`);continue}else d=J8E(c,t);let s=c.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof hLi)throw d;if(d instanceof uE)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new uE("can't match cohort without a given cohort property value");return n==="AND"}function K8E(e){try{return new RegExp(e),!0}catch{return!1}}function $8E(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new uE(`${e} is in an invalid date format`)}throw new uE(`The date provided ${e} must be a string, number, or date object`)}function sf5(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(!r)return null;{if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-7*n);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else{if(a!="y")return null;i.setUTCFullYear(i.getUTCFullYear()-n)}return i}}var woc=class{getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}constructor(){this._memoryStorage={}}};var cf5=100,Z8E=3e4,lf5=5e4,Eoc=class extends D4o{constructor(t,r={}){if(super(t,r),this._memoryStorage=new woc,this.options=r,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,cf5):Z8E,r.personalApiKey){if(r.personalApiKey.includes("phc_"))throw new Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');r.enableLocalEvaluation!==!1&&(this.featureFlagsPoller=new joc({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},onLoad:n=>{this._events.emit("localEvaluationFlagsLoaded",n)},customHeaders:this.getCustomHeaders(),cacheProvider:r.flagDefinitionCacheProvider,strictLocalEvaluation:r.strictLocalEvaluation}))}this.errorTracking=new c$t(this,r,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||lf5}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):fetch(t,r)}getLibraryVersion(){return x8E}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture(t){typeof t=="string"&&this._logger.warn("Called capture() with a string as the first argument when an object was expected."),this.addPendingPromise(this.prepareEventMessage(t).then(({distinctId:r,event:i,properties:n,options:a})=>super.captureStateless(r,i,n,{timestamp:a.timestamp,disableGeoip:a.disableGeoip,uuid:a.uuid})).catch(r=>{r&&console.error(r)}))}async captureImmediate(t){return typeof t=="string"&&this._logger.warn("Called captureImmediate() with a string as the first argument when an object was expected."),this.addPendingPromise(this.prepareEventMessage(t).then(({distinctId:r,event:i,properties:n,options:a})=>super.captureStatelessImmediate(r,i,n,{timestamp:a.timestamp,disableGeoip:a.disableGeoip,uuid:a.uuid})).catch(r=>{r&&console.error(r)}))}identify({distinctId:t,properties:r={},disableGeoip:i}){let{$set:n,$set_once:a,$anon_distinct_id:o,...c}=r,u={$set:n||c,$set_once:a||{},$anon_distinct_id:o??void 0};super.identifyStateless(t,u,{disableGeoip:i})}async identifyImmediate({distinctId:t,properties:r={},disableGeoip:i}){let{$set:n,$set_once:a,$anon_distinct_id:o,...c}=r,u={$set:n||c,$set_once:a||{},$anon_distinct_id:o??void 0};super.identifyStatelessImmediate(t,u,{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=Z8E){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let i=setTimeout(()=>{n(),r(!1)},t),n=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(i),n(),r(a>0)})})}async _getFeatureFlagResult(t,r,i={},n){let a=i.sendFeatureFlagEvents??!0;if(this._flagOverrides!==void 0&&t in this._flagOverrides){let A=this._flagOverrides[t];if(A===void 0)return;let j=this._payloadOverrides?.[t];return{key:t,enabled:A!==!1,variant:typeof A=="string"?A:void 0,payload:j}}let{groups:o,disableGeoip:c}=i,{onlyEvaluateLocally:d,personProperties:s,groupProperties:u}=i,f=this.addLocalPersonAndGroupProperties(r,o,s,u);s=f.allPersonProperties,u=f.allGroupProperties,d==null&&(d=this.options.strictLocalEvaluation??!1);let p,_=!1,h,y,b,v,O,m;if(this.featureFlagsPoller!==void 0){await this.featureFlagsPoller?.loadFeatureFlags();let A=this.featureFlagsPoller?.featureFlagsByKey[t];if(A)try{let j=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(A,r,o,s,u,n);if(j){_=!0;let M=j.value;v=A.id,m="Evaluated locally",p={key:t,enabled:M!==!1,variant:typeof M=="string"?M:void 0,payload:j.payload??void 0}}}catch(j){if(j instanceof hLi||j instanceof uE)this._logger?.info(`${j.name} when computing flag locally: ${t}: ${j.message}`);else throw j}}if(!_&&!d){let A=await super.getFeatureFlagDetailsStateless(r,o,s,u,c,[t]);if(A===void 0)b=B4o.UNKNOWN_ERROR;else{h=A.requestId,y=A.evaluatedAt;let j=[];A.errorsWhileComputingFlags&&j.push(B4o.ERRORS_WHILE_COMPUTING),A.quotaLimited?.includes("feature_flags")&&j.push(B4o.QUOTA_LIMITED);let M=A.flags[t];if(M===void 0)j.push(B4o.FLAG_MISSING);else{v=M.metadata?.id,O=M.metadata?.version,m=M.reason?.description??M.reason?.code;let w;if(M.metadata?.payload!==void 0)try{w=JSON.parse(M.metadata.payload)}catch{w=M.metadata.payload}p={key:t,enabled:M.enabled,variant:M.variant,payload:w}}j.length>0&&(b=j.join(","))}}if(a){let A=p===void 0?void 0:p.enabled===!1?!1:p.variant??!0,j=`${t}_${A}`;if(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(j)){Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(j):this.distinctIdHasSentFlagCalls[r]=[j];let M={$feature_flag:t,$feature_flag_response:A,$feature_flag_id:v,$feature_flag_version:O,$feature_flag_reason:m,locally_evaluated:_,[`$feature/${t}`]:A,$feature_flag_request_id:h,$feature_flag_evaluated_at:y};b&&(M.$feature_flag_error=b),this.capture({distinctId:r,event:"$feature_flag_called",properties:M,groups:o,disableGeoip:c})}}return p!==void 0&&this._payloadOverrides!==void 0&&t in this._payloadOverrides&&(p={...p,payload:this._payloadOverrides[t]}),p}async getFeatureFlag(t,r,i){let n=await this._getFeatureFlagResult(t,r,{...i,sendFeatureFlagEvents:i?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0});if(n!==void 0)return n.enabled===!1?!1:n.variant??!0}async getFeatureFlagPayload(t,r,i,n){if(this._payloadOverrides!==void 0&&t in this._payloadOverrides)return this._payloadOverrides[t];let a=await this._getFeatureFlagResult(t,r,{...n,sendFeatureFlagEvents:!1},i);if(a!==void 0)return a.payload??null}async getFeatureFlagResult(t,r,i){return this._getFeatureFlagResult(t,r,{...i,sendFeatureFlagEvents:i?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0})}async getRemoteConfigPayload(t){if(!this.options.personalApiKey)throw new Error("Personal API key is required for remote config payload decryption");let r=await this._requestRemoteConfigPayload(t);if(!r)return;let i=await r.json();if(typeof i=="string")try{return JSON.parse(i)}catch{}return i}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n,flagKeys:a}=r||{},{onlyEvaluateLocally:o,personProperties:c,groupProperties:d}=r||{},s=this.addLocalPersonAndGroupProperties(t,i,c,d);c=s.allPersonProperties,d=s.allGroupProperties,o==null&&(o=this.options.strictLocalEvaluation??!1);let u=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,c,d,a),f={},p={},_=!0;if(u&&(f=u.response,p=u.payloads,_=u.fallbackToFlags),_&&!o){let h=await super.getFeatureFlagsAndPayloadsStateless(t,i,c,d,n,a);f={...f,...h.flags||{}},p={...p,...h.payloads||{}}}return this._flagOverrides!==void 0&&(f={...f,...this._flagOverrides}),this._payloadOverrides!==void 0&&(p={...p,...this._payloadOverrides}),{featureFlags:f,featureFlagPayloads:p}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}overrideFeatureFlags(t){let r=i=>Object.fromEntries(i.map(n=>[n,!0]));if(t===!1){this._flagOverrides=void 0,this._payloadOverrides=void 0;return}if(Array.isArray(t)){this._flagOverrides=r(t);return}if(this._isFeatureFlagOverrideOptions(t)){"flags"in t&&(t.flags===!1?this._flagOverrides=void 0:Array.isArray(t.flags)?this._flagOverrides=r(t.flags):t.flags!==void 0&&(this._flagOverrides={...t.flags})),"payloads"in t&&(t.payloads===!1?this._payloadOverrides=void 0:t.payloads!==void 0&&(this._payloadOverrides={...t.payloads}));return}this._flagOverrides={...t}}_isFeatureFlagOverrideOptions(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let r=t;if("flags"in r){let i=r.flags;if(i===!1||Array.isArray(i)||typeof i=="object"&&i!==null)return!0}if("payloads"in r){let i=r.payloads;if(i===!1||typeof i=="object"&&i!==null)return!0}return!1}withContext(t,r,i){return this.context?this.context.run(t,r,i):r()}getContext(){return this.context?.get()}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(t),this.errorTracking.shutdown(),super._shutdown(t)}async _requestRemoteConfigPayload(t){if(!this.options.personalApiKey)return;let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config?token=${encodeURIComponent(this.apiKey)}`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",Authorization:`Bearer ${this.options.personalApiKey}`}},n=null;if(this.options.requestTimeout&&typeof this.options.requestTimeout=="number"){let a=new AbortController;n=Tea(()=>{a.abort()},this.options.requestTimeout),i.signal=a.signal}try{return await this.fetch(r,i)}catch(a){this._events.emit("error",a);return}finally{n&&clearTimeout(n)}}extractPropertiesFromEvent(t,r){if(!t)return{personProperties:{},groupProperties:{}};let i={},n={};for(let[a,o]of Object.entries(t))if(a8E(o)&&r&&a in r){let c={};for(let[d,s]of Object.entries(o))c[String(d)]=String(s);n[String(a)]=c}else i[String(a)]=String(o);return{personProperties:i,groupProperties:n}}async getFeatureFlagsForEvent(t,r,i,n){let a=n?.personProperties||{},o=n?.groupProperties||{},c=n?.flagKeys;if(n?.onlyEvaluateLocally??this.options.strictLocalEvaluation??!1)if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let s={};for(let[u,f]of Object.entries(r||{}))s[u]=String(f);return await this.getAllFlags(t,{groups:s,personProperties:a,groupProperties:o,disableGeoip:i,onlyEvaluateLocally:!0,flagKeys:c})}else return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let s={};for(let[u,f]of Object.entries(r||{}))s[u]=String(f);return await this.getAllFlags(t,{groups:s,personProperties:a,groupProperties:o,disableGeoip:i,onlyEvaluateLocally:!0,flagKeys:c})}return(await super.getFeatureFlagsStateless(t,r,a,o,i)).flags}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...n?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,i,n){if(!c$t.isPreviouslyCapturedError(t)){let a=new Error("PostHog syntheticException");this.addPendingPromise(c$t.buildEventMessage(t,{syntheticException:a},r,i).then(o=>this.capture({...o,uuid:n})))}}async captureExceptionImmediate(t,r,i){if(!c$t.isPreviouslyCapturedError(t)){let n=new Error("PostHog syntheticException");this.addPendingPromise(c$t.buildEventMessage(t,{syntheticException:n},r,i).then(a=>this.captureImmediate(a)))}}async prepareEventMessage(t){let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:d,uuid:s}=t,u=this.context?.get(),f=r||u?.distinctId,p={...u?.properties||{},...n||{}};f||(f=pLi(),p.$process_person_profile=!1),u?.sessionId&&!p.$session_id&&(p.$session_id=u.sessionId);let _=this._runBeforeSend({distinctId:f,event:i,properties:p,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:d,uuid:s});if(!_)return Promise.reject(null);let h=await Promise.resolve().then(async()=>{if(o){let y=typeof o=="object"?o:void 0;return await this.getFeatureFlagsForEvent(_.distinctId,a,d,y)}return _.event,{}}).then(y=>{let b={};if(y)for(let[O,m]of Object.entries(y))b[`$feature/${O}`]=m;let v=Object.keys(y||{}).filter(O=>y?.[O]!==!1).sort();return v.length>0&&(b.$active_feature_flags=v),b}).catch(()=>({})).then(y=>({...y,..._.properties||{},$groups:_.groups||a}));return _.event==="$pageview"&&this.options.__preview_capture_bot_pageviews&&typeof h.$raw_user_agent=="string"&&kWE(h.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(_.event="$bot_pageview",h.$browser_type="bot"),{distinctId:_.distinctId,event:_.event,properties:h,options:{timestamp:_.timestamp,disableGeoip:_.disableGeoip,uuid:_.uuid}}}_runBeforeSend(t){let r=this.options.before_send;if(!r)return t;let i=Array.isArray(r)?r:[r],n=t;for(let a of i){if(n=a(n),!n)return this._logger.info(`Event '${t.event}' was rejected in beforeSend function`),null;if(!n.properties||Object.keys(n.properties).length===0){let o=`Event '${n.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(o)}}return n}};var k8E=require("async_hooks"),Soc=class{constructor(){this.storage=new k8E.AsyncLocalStorage}get(){return this.storage.getStore()}run(t,r,i){if(i?.fresh===!0)return this.storage.run(t,r);{let a=this.get()||{},o={distinctId:t.distinctId??a.distinctId,sessionId:t.sessionId??a.sessionId,properties:{...a.properties||{},...t.properties||{}}};return this.storage.run(o,r)}}};var exE="posthog-node";function ff5(e,{organization:t,projectId:r,prefix:i,severityAllowList:n=["error"],sendExceptionsToPostHog:a=!0}={}){return o=>{if(!(n==="*"||n.includes(o.level)))return o;o.tags||(o.tags={});let d=o.tags[Wwp.POSTHOG_ID_TAG];if(d===void 0)return o;let s=e.options.host??"https://us.i.posthog.com",u=new URL(`/project/${e.apiKey}/person/${d}`,s).toString();o.tags["PostHog Person URL"]=u;let f=o.exception?.values||[],p=f.map(h=>({...h,stacktrace:h.stacktrace?{...h.stacktrace,type:"raw",frames:(h.stacktrace.frames||[]).map(y=>({...y,platform:"node:javascript"}))}:void 0})),_={$exception_message:f[0]?.value||o.message,$exception_type:f[0]?.type,$exception_level:o.level,$exception_list:p,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:f[0]?.value||o.message,$sentry_exception_type:f[0]?.type,$sentry_tags:o.tags};return t&&r&&(_.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+o.event_id),a&&e.capture({event:"$exception",distinctId:d,properties:_}),o}}var Wwp=class{static#e=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(t,r,i,n,a){this.name=exE,this.name=exE,this.setupOnce=function(o,c){let d=c()?.getClient()?.getDsn()?.projectId;o(ff5(t,{organization:r,projectId:d,prefix:i,severityAllowList:n,sendExceptionsToPostHog:a??!0}))}}};c$t.errorPropertiesBuilder=new SOe.ErrorPropertiesBuilder([new SOe.EventCoercer,new SOe.ErrorCoercer,new SOe.ObjectCoercer,new SOe.StringCoercer,new SOe.PrimitiveCoercer],SOe.createStackParser("node:javascript",SOe.nodeStackLineParser),[$WE(),Q8E]);var Qxa=class extends Eoc{getLibraryId(){return"posthog-node"}initializeContext(){return new Soc}};var Moc=class{posthog;constructor({posthogApiKey:t}){this.posthog=new Qxa(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.56.0",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var I4o=class{async sendEvent(){}async identify(){}async flush(){}};var Uxa=require("fs/promises"),txE=require("os"),rxE=require("path");var df5="id",pf5=".fern",C4o=class{posthog;userId;token;constructor({token:t,posthogApiKey:r}){this.posthog=new Qxa(r),this.userId=t==null?void 0:oFc(t),this.token=t}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){let r=await this.getUserEmail();this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"3.56.0",...t,...t.properties,usingAccessToken:!1,...r!=null?{userEmail:r}:{}}})}async flush(){await this.posthog.flush()}userEmail;async getUserEmail(){if(this.userEmail!==null){if(this.userEmail!=null)return this.userEmail;if(this.token==null){this.userEmail=null;return}try{let t=await d3({token:this.token.value}).user.getMyself();if(t.ok&&t.body.email!=null)return this.userEmail=t.body.email,this.userEmail}catch{}this.userEmail=null}}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=ot(mr.of((0,txE.homedir)()),Pe.of(pf5),Pe.of(df5));await ni(t)||(await(0,Uxa.mkdir)((0,rxE.dirname)(t),{recursive:!0}),await(0,Uxa.writeFile)(t,Xme())),this.persistedDistinctId=(await(0,Uxa.readFile)(t)).toString()}return this.persistedDistinctId}};var xwp;async function Lxa(){return xwp==null&&(xwp=await _f5()),xwp}async function _f5(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new I4o;let r=await dZo();return r!=null?new C4o({token:r,posthogApiKey:e}):await esa()!=null?new Moc({posthogApiKey:e}):new C4o({token:void 0,posthogApiKey:e})}catch{return new I4o}}var q4o=se(require("process"),1);var axE=se(lLc(),1),oxE=se(nxE(),1);function vV(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=L8t(e),e.length===0))return 0;e=e.replace((0,oxE.default)()," ");let r=t.ambiguousIsNarrow?1:2,i=0;for(let n of e){let a=n.codePointAt(0);if(a<=31||a>=127&&a<=159||a>=768&&a<=879)continue;switch(axE.default.eastAsianWidth(n)){case"F":case"W":i+=2;break;case"A":i+=r;break;default:i+=1}}return i}function Doc(e){let t=0;for(let r of e.split(`
|
|
2240
|
+
`);for(let o=i;o<a.length;o++){let c=a[o];if(c.length>1024)continue;let d=D8E.test(c)?c.replace(D8E,"$1"):c;if(!d.match(/\S*Error: /)){for(let s of t){let u=s(d,e);if(u){n.push(u);break}}if(n.length>=B8E)break}}return I8E(n)}}var qwp=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,r){let i=w4o(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?r.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){let r=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${r}: ${t.message}`:r}isDOMException(t){return qea(t,"DOMException")}isDOMError(t){return qea(t,"DOMError")}};var Twp=class{match(t){return mwp(t)}coerce(t,r){return{type:this.getType(t),value:this.getMessage(t,r),stack:this.getStack(t),cause:t.cause?r.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,r){let i=t.message;return i.error&&typeof i.error.message=="string"?String(i.error.message):String(i)}getStack(t){return t.stacktrace||t.stack||void 0}};var Rwp=class{constructor(){}match(t){return n8E(t)&&t.error!=null}coerce(t,r){let i=r.apply(t.error);return i||{type:"ErrorEvent",value:t.message,stack:r.syntheticException?.stack,synthetic:!0}}};var xl5=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,zwp=class{match(t){return typeof t=="string"}coerce(t,r){let[i,n]=this.getInfos(t);return{type:i??"Error",value:n??t,stack:r.syntheticException?.stack,synthetic:!0}}getInfos(t){let r="Error",i=t,n=t.match(xl5);return n&&(r=n[1],i=n[2]),[r,i]}};var q8E=["fatal","error","warning","log","info","debug"];function Aoc(e,t=40){let r=Object.keys(e);if(r.sort(),!r.length)return"[object has no keys]";for(let i=r.length;i>0;i--){let n=r.slice(0,i).join(", ");if(!(n.length>t))return i===r.length||n.length<=t?n:`${n.slice(0,t)}...`}return""}var Nwp=class{match(t){return typeof t=="object"&&t!==null}coerce(t,r){let i=this.getErrorPropertyFromObject(t);return i?r.apply(i):{type:this.getType(t),value:this.getValue(t),stack:r.syntheticException?.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return loc(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){let n=`'${t.name}' captured as exception`;return"message"in t&&typeof t.message=="string"&&(n+=` with message: '${t.message}'`),n}if("message"in t&&typeof t.message=="string")return t.message;let r=this.getObjectClassName(t),i=Aoc(t);return`${r&&r!=="Object"?`'${r}'`:"Object"} captured as exception with keys: ${i}`}isSeverityLevel(t){return w4o(t)&&!r8E(t)&&q8E.indexOf(t)>=0}getErrorPropertyFromObject(t){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(v8E(i))return i}}getObjectClassName(t){try{let r=Object.getPrototypeOf(t);return r?r.constructor.name:void 0}catch{return}}};var Fwp=class{match(t){return loc(t)}coerce(t,r){let i=t.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${Aoc(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var Qwp=class{match(t){return E4o(t)}coerce(t,r){return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:r.syntheticException?.stack,synthetic:!0}}};var Uwp=class{match(t){return qea(t,"PromiseRejectionEvent")}coerce(t,r){let i=this.getUnhandledRejectionReason(t);return E4o(i)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`,stack:r.syntheticException?.stack,synthetic:!0}:r.apply(i)}getUnhandledRejectionReason(t){if(E4o(t))return t;try{if("reason"in t)return t.reason;if("detail"in t&&"reason"in t.detail)return t.detail.reason}catch{}return t}};var Lwp=class{constructor(t){this._maxSize=t,this._cache=new Map}get(t){let r=this._cache.get(t);if(r!==void 0)return this._cache.delete(t),this._cache.set(t,r),r}set(t,r){this._cache.set(t,r)}reduce(){for(;this._cache.size>=this._maxSize;){let t=this._cache.keys().next().value;t&&this._cache.delete(t)}}};var z8E=require("fs"),N8E=require("readline"),Poc=new SOe.ReduceableCache(25),F8E=new SOe.ReduceableCache(20),Vwp=7,Gl5=1e3,Hl5=1e4;async function Q8E(e){let t={};for(let n=e.length-1;n>=0;n--){let a=e[n],o=a?.filename;if(!a||typeof o!="string"||typeof a.lineno!="number"||Yl5(o)||Xl5(a))continue;t[o]||(t[o]=[]),t[o].push(a.lineno)}let r=Object.keys(t);if(r.length==0)return e;let i=[];for(let n of r){if(F8E.get(n))continue;let a=t[n];if(!a)continue;a.sort((d,s)=>d-s);let o=kl5(a);if(o.every(d=>Zl5(n,d)))continue;let c=ef5(Poc,n,{});i.push(Kl5(n,o,c))}return await Promise.all(i).catch(()=>{}),e&&e.length>0&&$l5(e,Poc),Poc.reduce(),e}function Kl5(e,t,r){return new Promise(i=>{let n=(0,z8E.createReadStream)(e),a=(0,N8E.createInterface)({input:n});function o(){n.destroy(),i()}let c=0,d=0,s=t[d];if(s===void 0)return void o();let u=s[0],f=s[1];function p(){F8E.set(e,1),a.close(),a.removeAllListeners(),o()}n.on("error",p),a.on("error",p),a.on("close",o),a.on("line",_=>{if(c++,!(c<u)&&(r[c]=tf5(_,0),c>=f)){if(d===t.length-1){a.close(),a.removeAllListeners();return}d++;let h=t[d];if(h===void 0){a.close(),a.removeAllListeners();return}u=h[0],f=h[1]}})})}function $l5(e,t){for(let r of e)if(r.filename&&r.context_line===void 0&&typeof r.lineno=="number"){let i=t.get(r.filename);if(i===void 0)continue;Jl5(r.lineno,r,i)}}function Jl5(e,t,r){if(t.lineno===void 0||r===void 0)return;t.pre_context=[];for(let n=U8E(e);n<e;n++){let a=r[n];if(a===void 0)return void T8E(t);t.pre_context.push(a)}if(r[e]===void 0)return void T8E(t);t.context_line=r[e];let i=L8E(e);t.post_context=[];for(let n=e+1;n<=i;n++){let a=r[n];if(a===void 0)break;t.post_context.push(a)}}function T8E(e){delete e.pre_context,delete e.context_line,delete e.post_context}function Yl5(e){return e.startsWith("node:")||e.endsWith(".min.js")||e.endsWith(".min.cjs")||e.endsWith(".min.mjs")||e.startsWith("data:")}function Xl5(e){return e.lineno!==void 0&&e.lineno>Hl5||e.colno!==void 0&&e.colno>Gl5}function Zl5(e,t){let r=Poc.get(e);if(r===void 0)return!1;for(let i=t[0];i<=t[1];i++)if(r[i]===void 0)return!1;return!0}function kl5(e){if(!e.length)return[];let t=0,r=e[0];if(typeof r!="number")return[];let i=R8E(r),n=[];for(;;){if(t===e.length-1){n.push(i);break}let a=e[t+1];if(typeof a!="number")break;a<=i[1]?i[1]=a+Vwp:(n.push(i),i=R8E(a)),t++}return n}function R8E(e){return[U8E(e),L8E(e)]}function U8E(e){return Math.max(1,e-Vwp)}function L8E(e){return e+Vwp}function ef5(e,t,r){let i=e.get(t);return i===void 0?(e.set(t,r),r):i}function tf5(e,t){let r=e,i=r.length;if(i<=150)return r;t>i&&(t=i);let n=Math.max(t-60,0);n<5&&(n=0);let a=Math.min(n+140,i);return a>i-5&&(a=i),a===i&&(n=Math.max(a-140,0)),r=r.slice(n,a),n>0&&(r=`...${r}`),a<i&&(r+="..."),r}function rf5(e,t){let r=!1;return Object.assign(i=>{let a=global.process.listeners("uncaughtException").filter(o=>o.name!=="domainUncaughtExceptionClear"&&o._posthogErrorHandler!==!0).length===0;e(i,{mechanism:{type:"onuncaughtexception",handled:!1}}),!r&&a&&(r=!0,t(i))},{_posthogErrorHandler:!0})}function V8E(e,t){globalThis.process?.on("uncaughtException",rf5(e,t))}function W8E(e){globalThis.process?.on("unhandledRejection",t=>e(t,{mechanism:{type:"onunhandledrejection",handled:!1}}))}var if5=2e3,c$t=class e{constructor(t,r,i){this.client=t,this._exceptionAutocaptureEnabled=r.enableExceptionAutocapture||!1,this._logger=i,this._rateLimiter=new foc({refillRate:1,bucketSize:10,refillInterval:1e4,_logger:this._logger}),this.startAutocaptureIfEnabled()}static isPreviouslyCapturedError(t){return t8E(t)&&"__posthog_previously_captured_error"in t&&t.__posthog_previously_captured_error===!0}static async buildEventMessage(t,r,i,n){let a={...n};i||(a.$process_person_profile=!1);let o=this.errorPropertiesBuilder.buildFromUnknown(t,r);return o.$exception_list=await this.errorPropertiesBuilder.modifyFrames(o.$exception_list),{event:"$exception",distinctId:i||pLi(),properties:{...o,...a}}}startAutocaptureIfEnabled(){this.isEnabled()&&(V8E(this.onException.bind(this),this.onFatalError.bind(this)),W8E(this.onException.bind(this)))}onException(t,r){this.client.addPendingPromise((async()=>{if(!e.isPreviouslyCapturedError(t)){let i=await e.buildEventMessage(t,r),a=i.properties?.$exception_list[0]?.type??"Exception";return this._rateLimiter.consumeRateLimit(a)?void this._logger.info("Skipping exception capture because of client rate limiting.",{exception:a}):this.client.capture(i)}})())}async onFatalError(t){console.error(t),await this.client.shutdown(if5),process.exit(1)}isEnabled(){return!this.client.isDisabled&&this._exceptionAutocaptureEnabled}shutdown(){this._rateLimiter.stop()}};var x8E="5.24.7";var B4o={ERRORS_WHILE_COMPUTING:"errors_while_computing_flags",FLAG_MISSING:"flag_missing",QUOTA_LIMITED:"quota_limited",UNKNOWN_ERROR:"unknown_error"};async function G8E(e){let t=globalThis.crypto?.subtle;if(!t)throw new Error("SubtleCrypto API not available");let r=await t.digest("SHA-1",new TextEncoder().encode(e));return Array.from(new Uint8Array(r)).map(n=>n.toString(16).padStart(2,"0")).join("")}var nf5=6e4,af5=1152921504606847e3,of5=["is_not"],Fxa=class e extends Error{constructor(t){super(),Error.captureStackTrace(this,this.constructor),this.name="ClientError",this.message=t,Object.setPrototypeOf(this,e.prototype)}},uE=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},hLi=class e extends Error{constructor(t){super(t),this.name=this.constructor.name,Error.captureStackTrace(this,this.constructor),Object.setPrototypeOf(this,e.prototype)}},joc=class{constructor({pollingInterval:t,personalApiKey:r,projectApiKey:i,timeout:n,host:a,customHeaders:o,...c}){this.debugMode=!1,this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.pollingInterval=t,this.personalApiKey=r,this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={},this.loadedSuccessfullyOnce=!1,this.timeout=n,this.projectApiKey=i,this.host=a,this.poller=void 0,this.fetch=c.fetch||fetch,this.onError=c.onError,this.customHeaders=o,this.onLoad=c.onLoad,this.cacheProvider=c.cacheProvider,this.strictLocalEvaluation=c.strictLocalEvaluation??!1,this.loadFeatureFlags()}debug(t=!0){this.debugMode=t}logMsgIfDebug(t){this.debugMode&&t()}async getFeatureFlag(t,r,i={},n={},a={}){await this.loadFeatureFlags();let o,c;if(!this.loadedSuccessfullyOnce)return o;if(c=this.featureFlagsByKey[t],c!==void 0)try{o=(await this.computeFlagAndPayloadLocally(c,r,i,n,a)).value,this.logMsgIfDebug(()=>console.debug(`Successfully computed flag locally: ${t} -> ${o}`))}catch(d){d instanceof hLi||d instanceof uE?this.logMsgIfDebug(()=>console.debug(`${d.name} when computing flag locally: ${t}: ${d.message}`)):d instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${t}: ${d}`))}return o}async getAllFlagsAndPayloads(t,r={},i={},n={},a){await this.loadFeatureFlags();let o={},c={},d=this.featureFlags.length==0,s=a?a.map(f=>this.featureFlagsByKey[f]).filter(Boolean):this.featureFlags,u={};return await Promise.all(s.map(async f=>{try{let{value:p,payload:_}=await this.computeFlagAndPayloadLocally(f,t,r,i,n,void 0,u);o[f.key]=p,_&&(c[f.key]=_)}catch(p){p instanceof hLi||p instanceof uE?this.logMsgIfDebug(()=>console.debug(`${p.name} when computing flag locally: ${f.key}: ${p.message}`)):p instanceof Error&&this.onError?.(new Error(`Error computing flag locally: ${f.key}: ${p}`)),d=!0}})),{response:o,payloads:c,fallbackToFlags:d}}async computeFlagAndPayloadLocally(t,r,i={},n={},a={},o,c,d=!1){if(d||await this.loadFeatureFlags(),!this.loadedSuccessfullyOnce)return{value:!1,payload:null};let s;s=o!==void 0?o:await this.computeFlagValueLocally(t,r,i,n,a,c);let u=this.getFeatureFlagPayload(t.key,s);return{value:s,payload:u}}async computeFlagValueLocally(t,r,i={},n={},a={},o={}){if(t.ensure_experience_continuity)throw new uE("Flag has experience continuity enabled");if(!t.active)return!1;let d=(t.filters||{}).aggregation_group_type_index;if(d==null)return await this.matchFeatureFlagProperties(t,r,n,o);{let s=this.groupTypeMapping[String(d)];if(!s)throw this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Unknown group type index ${d} for feature flag ${t.key}`)),new uE("Flag has unknown group type index");if(!(s in i))return this.logMsgIfDebug(()=>console.warn(`[FEATURE FLAGS] Can't compute group feature flag: ${t.key} without group names passed in`)),!1;let u=a[s];return await this.matchFeatureFlagProperties(t,i[s],u,o)}}getFeatureFlagPayload(t,r){let i=null;if(r!==!1&&r!=null&&(typeof r=="boolean"?i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r.toString()]||null:typeof r=="string"&&(i=this.featureFlagsByKey?.[t]?.filters?.payloads?.[r]||null),i!=null)){if(typeof i=="object")return i;if(typeof i=="string")try{return JSON.parse(i)}catch{}return i}return null}async evaluateFlagDependency(t,r,i,n){let a=t.key;if(!this.featureFlagsByKey)throw new uE("Feature flags not available for dependency evaluation");if(!("dependency_chain"in t))throw new uE(`Flag dependency property for '${a}' is missing required 'dependency_chain' field`);let o=t.dependency_chain;if(!Array.isArray(o))throw new uE(`Flag dependency property for '${a}' has an invalid 'dependency_chain' (expected array, got ${typeof o})`);if(o.length===0)throw new uE(`Circular dependency detected for flag '${a}' (empty dependency chain)`);for(let d of o){if(!(d in n)){let u=this.featureFlagsByKey[d];if(u)if(u.active)try{let f=await this.matchFeatureFlagProperties(u,r,i,n);n[d]=f}catch(f){throw new uE(`Error evaluating flag dependency '${d}' for flag '${a}': ${f}`)}else n[d]=!1;else throw new uE(`Missing flag dependency '${d}' for flag '${a}'`)}if(n[d]==null)throw new uE(`Dependency '${d}' could not be evaluated`)}let c=n[a];return this.flagEvaluatesToExpectedValue(t.value,c)}flagEvaluatesToExpectedValue(t,r){return typeof t=="boolean"?t===r||typeof r=="string"&&r!==""&&t===!0:typeof t=="string"?r===t:!1}async matchFeatureFlagProperties(t,r,i,n={}){let a=t.filters||{},o=a.groups||[],c=!1,d;for(let s of o)try{if(await this.isConditionMatch(t,r,s,i,n)){let u=s.variant,f=a.multivariate?.variants||[];d=u&&f.some(p=>p.key===u)?u:await this.getMatchingVariant(t,r)||!0;break}}catch(u){if(u instanceof hLi)throw u;if(u instanceof uE)c=!0;else throw u}if(d!==void 0)return d;if(c)throw new uE("Can't determine if feature flag is enabled or not with given properties");return!1}async isConditionMatch(t,r,i,n,a={}){let o=i.rollout_percentage,c=d=>{this.logMsgIfDebug(()=>console.warn(d))};if((i.properties||[]).length>0){for(let d of i.properties){let s=d.type,u=!1;if(u=s==="cohort"?Y8E(d,n,this.cohorts,this.debugMode):s==="flag"?await this.evaluateFlagDependency(d,r,n,a):J8E(d,n,c),!u)return!1}if(o==null)return!0}return!(o!=null&&await H8E(t.key,r)>o/100)}async getMatchingVariant(t,r){let i=await H8E(t.key,r,"variant"),n=this.variantLookupTable(t).find(a=>i>=a.valueMin&&i<a.valueMax);if(n)return n.key}variantLookupTable(t){let r=[],i=0,n=0;return((t.filters||{}).multivariate?.variants||[]).forEach(c=>{n=i+c.rollout_percentage/100,r.push({valueMin:i,valueMax:n,key:c.key}),i=n}),r}updateFlagState(t){this.featureFlags=t.flags,this.featureFlagsByKey=t.flags.reduce((r,i)=>(r[i.key]=i,r),{}),this.groupTypeMapping=t.groupTypeMapping,this.cohorts=t.cohorts,this.loadedSuccessfullyOnce=!0}warnAboutExperienceContinuityFlags(t){if(this.strictLocalEvaluation)return;let r=t.filter(i=>i.ensure_experience_continuity);r.length>0&&console.warn(`[PostHog] You are using local evaluation but ${r.length} flag(s) have experience continuity enabled: ${r.map(i=>i.key).join(", ")}. Experience continuity is incompatible with local evaluation and will cause a server request on every flag evaluation, negating local evaluation cost savings. To avoid server requests and unexpected costs, either disable experience continuity on these flags in PostHog, use strictLocalEvaluation: true in client init, or pass onlyEvaluateLocally: true per flag call (flags that cannot be evaluated locally will return undefined).`)}async loadFromCache(t){if(!this.cacheProvider)return!1;try{let r=await this.cacheProvider.getFlagDefinitions();return r?(this.updateFlagState(r),this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] ${t} (${r.flags.length} flags)`)),this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(r.flags),!0):!1}catch(r){return this.onError?.(new Error(`Failed to load from cache: ${r}`)),!1}}async loadFeatureFlags(t=!1){if(!(this.loadedSuccessfullyOnce&&!t))return!t&&this.nextFetchAllowedAt&&Date.now()<this.nextFetchAllowedAt?void this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Skipping fetch, in backoff period")):(this.loadingPromise||(this.loadingPromise=this._loadFeatureFlags().catch(r=>this.logMsgIfDebug(()=>console.debug(`[FEATURE FLAGS] Failed to load feature flags: ${r}`))).finally(()=>{this.loadingPromise=void 0})),this.loadingPromise)}isLocalEvaluationReady(){return(this.loadedSuccessfullyOnce??!1)&&(this.featureFlags?.length??0)>0}getPollingInterval(){return this.shouldBeginExponentialBackoff?Math.min(nf5,this.pollingInterval*2**this.backOffCount):this.pollingInterval}beginBackoff(){this.shouldBeginExponentialBackoff=!0,this.backOffCount+=1,this.nextFetchAllowedAt=Date.now()+this.getPollingInterval()}clearBackoff(){this.shouldBeginExponentialBackoff=!1,this.backOffCount=0,this.nextFetchAllowedAt=void 0}async _loadFeatureFlags(){this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.poller=setTimeout(()=>this.loadFeatureFlags(!0),this.getPollingInterval());try{let t=!0;if(this.cacheProvider)try{t=await this.cacheProvider.shouldFetchFlagDefinitions()}catch(i){this.onError?.(new Error(`Error in shouldFetchFlagDefinitions: ${i}`))}if(!t&&(await this.loadFromCache("Loaded flags from cache (skipped fetch)")||this.loadedSuccessfullyOnce))return;let r=await this._requestFeatureFlagDefinitions();if(!r)return;switch(r.status){case 304:this.logMsgIfDebug(()=>console.debug("[FEATURE FLAGS] Flags not modified (304), using cached data")),this.flagsEtag=r.headers?.get("ETag")??this.flagsEtag,this.loadedSuccessfullyOnce=!0,this.clearBackoff();return;case 401:throw this.beginBackoff(),new Fxa(`Your project key or personal API key is invalid. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 402:console.warn("[FEATURE FLAGS] Feature flags quota limit exceeded - unsetting all local flags. Learn more about billing limits at https://posthog.com/docs/billing/limits-alerts"),this.featureFlags=[],this.featureFlagsByKey={},this.groupTypeMapping={},this.cohorts={};return;case 403:throw this.beginBackoff(),new Fxa(`Your personal API key does not have permission to fetch feature flag definitions for local evaluation. Setting next polling interval to ${this.getPollingInterval()}ms. Are you sure you're using the correct personal and Project API key pair? More information: https://posthog.com/docs/api/overview`);case 429:throw this.beginBackoff(),new Fxa(`You are being rate limited. Setting next polling interval to ${this.getPollingInterval()}ms. More information: https://posthog.com/docs/api#rate-limiting`);case 200:{let i=await r.json()??{};if(!("flags"in i))return void this.onError?.(new Error(`Invalid response when getting feature flags: ${JSON.stringify(i)}`));this.flagsEtag=r.headers?.get("ETag")??void 0;let n={flags:i.flags??[],groupTypeMapping:i.group_type_mapping||{},cohorts:i.cohorts||{}};if(this.updateFlagState(n),this.clearBackoff(),this.cacheProvider&&t)try{await this.cacheProvider.onFlagDefinitionsReceived(n)}catch(a){this.onError?.(new Error(`Failed to store in cache: ${a}`))}this.onLoad?.(this.featureFlags.length),this.warnAboutExperienceContinuityFlags(n.flags);break}default:return}}catch(t){t instanceof Fxa&&this.onError?.(t)}}getPersonalApiKeyRequestOptions(t="GET",r){let i={...this.customHeaders,"Content-Type":"application/json",Authorization:`Bearer ${this.personalApiKey}`};return r&&(i["If-None-Match"]=r),{method:t,headers:i}}_requestFeatureFlagDefinitions(){let t=`${this.host}/api/feature_flag/local_evaluation?token=${this.projectApiKey}&send_cohorts`,r=this.getPersonalApiKeyRequestOptions("GET",this.flagsEtag),i=null;if(this.timeout&&typeof this.timeout=="number"){let n=new AbortController;i=Tea(()=>{n.abort()},this.timeout),r.signal=n.signal}try{let n=this.fetch;return n(t,r)}finally{clearTimeout(i)}}async stopPoller(t=3e4){if(clearTimeout(this.poller),this.cacheProvider)try{let r=this.cacheProvider.shutdown();r instanceof Promise&&await Promise.race([r,new Promise((i,n)=>setTimeout(()=>n(new Error(`Cache shutdown timeout after ${t}ms`)),t))])}catch(r){this.onError?.(new Error(`Error during cache shutdown: ${r}`))}}};async function H8E(e,t,r=""){let i=await G8E(`${e}.${t}${r}`);return parseInt(i.slice(0,15),16)/af5}function J8E(e,t,r){let i=e.key,n=e.value,a=e.operator||"exact";if(i in t){if(a==="is_not_set")throw new uE("Operator is_not_set is not supported")}else throw new uE(`Property ${i} not found in propertyValues`);let o=t[i];if(o==null&&!of5.includes(a))return r&&r(`Property ${i} cannot have a value of null/undefined with the ${a} operator`),!1;function c(s,u){return Array.isArray(s)?s.map(f=>String(f).toLowerCase()).includes(String(u).toLowerCase()):String(s).toLowerCase()===String(u).toLowerCase()}function d(s,u,f){if(f==="gt")return s>u;if(f==="gte")return s>=u;if(f==="lt")return s<u;if(f==="lte")return s<=u;throw new Error(`Invalid operator: ${f}`)}switch(a){case"exact":return c(n,o);case"is_not":return!c(n,o);case"is_set":return i in t;case"icontains":return String(o).toLowerCase().includes(String(n).toLowerCase());case"not_icontains":return!String(o).toLowerCase().includes(String(n).toLowerCase());case"regex":return K8E(String(n))&&String(o).match(String(n))!==null;case"not_regex":return K8E(String(n))&&String(o).match(String(n))===null;case"gt":case"gte":case"lt":case"lte":{let s=typeof n=="number"?n:null;if(typeof n=="string")try{s=parseFloat(n)}catch{}return s==null||o==null?d(String(o),String(n),a):typeof o=="string"?d(o,String(n),a):d(o,s,a)}case"is_date_after":case"is_date_before":{if(typeof n=="boolean")throw new uE("Date operations cannot be performed on boolean values");let s=sf5(String(n));if(s==null&&(s=$8E(n)),s==null)throw new uE(`Invalid date: ${n}`);let u=$8E(o);return["is_date_before"].includes(a)?u<s:u>s}default:throw new uE(`Unknown operator: ${a}`)}}function uf5(e,t){if(!(e in t))throw new hLi(`cohort ${e} not found in local cohorts - likely a static cohort that requires server evaluation`)}function Y8E(e,t,r,i=!1){let n=String(e.value);uf5(n,r);let a=r[n];return X8E(a,t,r,i)}function X8E(e,t,r,i=!1){if(!e)return!0;let n=e.type,a=e.values;if(!a||a.length===0)return!0;let o=!1;if("values"in a[0]){for(let c of a)try{let d=X8E(c,t,r,i);if(n==="AND"){if(!d)return!1}else if(d)return!0}catch(d){if(d instanceof hLi)throw d;if(d instanceof uE)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new uE("Can't match cohort without a given cohort property value");return n==="AND"}for(let c of a)try{let d;if(c.type==="cohort")d=Y8E(c,t,r,i);else if(c.type==="flag"){i&&console.warn(`[FEATURE FLAGS] Flag dependency filters are not supported in local evaluation. Skipping condition with dependency on flag '${c.key||"unknown"}'`);continue}else d=J8E(c,t);let s=c.negation||!1;if(n==="AND"){if(!d&&!s||d&&s)return!1}else if(d&&!s||!d&&s)return!0}catch(d){if(d instanceof hLi)throw d;if(d instanceof uE)i&&console.debug(`Failed to compute property ${c} locally: ${d}`),o=!0;else throw d}if(o)throw new uE("can't match cohort without a given cohort property value");return n==="AND"}function K8E(e){try{return new RegExp(e),!0}catch{return!1}}function $8E(e){if(e instanceof Date)return e;if(typeof e=="string"||typeof e=="number"){let t=new Date(e);if(!isNaN(t.valueOf()))return t;throw new uE(`${e} is in an invalid date format`)}throw new uE(`The date provided ${e} must be a string, number, or date object`)}function sf5(e){let t=/^-?(?<number>[0-9]+)(?<interval>[a-z])$/,r=e.match(t),i=new Date(new Date().toISOString());if(!r)return null;{if(!r.groups)return null;let n=parseInt(r.groups.number);if(n>=1e4)return null;let a=r.groups.interval;if(a=="h")i.setUTCHours(i.getUTCHours()-n);else if(a=="d")i.setUTCDate(i.getUTCDate()-n);else if(a=="w")i.setUTCDate(i.getUTCDate()-7*n);else if(a=="m")i.setUTCMonth(i.getUTCMonth()-n);else{if(a!="y")return null;i.setUTCFullYear(i.getUTCFullYear()-n)}return i}}var woc=class{getProperty(t){return this._memoryStorage[t]}setProperty(t,r){this._memoryStorage[t]=r!==null?r:void 0}constructor(){this._memoryStorage={}}};var cf5=100,Z8E=3e4,lf5=5e4,Eoc=class extends D4o{constructor(t,r={}){if(super(t,r),this._memoryStorage=new woc,this.options=r,this.context=this.initializeContext(),this.options.featureFlagsPollingInterval=typeof r.featureFlagsPollingInterval=="number"?Math.max(r.featureFlagsPollingInterval,cf5):Z8E,r.personalApiKey){if(r.personalApiKey.includes("phc_"))throw new Error('Your Personal API key is invalid. These keys are prefixed with "phx_" and can be created in PostHog project settings.');r.enableLocalEvaluation!==!1&&(this.featureFlagsPoller=new joc({pollingInterval:this.options.featureFlagsPollingInterval,personalApiKey:r.personalApiKey,projectApiKey:t,timeout:r.requestTimeout??1e4,host:this.host,fetch:r.fetch,onError:n=>{this._events.emit("error",n)},onLoad:n=>{this._events.emit("localEvaluationFlagsLoaded",n)},customHeaders:this.getCustomHeaders(),cacheProvider:r.flagDefinitionCacheProvider,strictLocalEvaluation:r.strictLocalEvaluation}))}this.errorTracking=new c$t(this,r,this._logger),this.distinctIdHasSentFlagCalls={},this.maxCacheSize=r.maxCacheSize||lf5}getPersistedProperty(t){return this._memoryStorage.getProperty(t)}setPersistedProperty(t,r){return this._memoryStorage.setProperty(t,r)}fetch(t,r){return this.options.fetch?this.options.fetch(t,r):fetch(t,r)}getLibraryVersion(){return x8E}getCustomUserAgent(){return`${this.getLibraryId()}/${this.getLibraryVersion()}`}enable(){return super.optIn()}disable(){return super.optOut()}debug(t=!0){super.debug(t),this.featureFlagsPoller?.debug(t)}capture(t){typeof t=="string"&&this._logger.warn("Called capture() with a string as the first argument when an object was expected."),this.addPendingPromise(this.prepareEventMessage(t).then(({distinctId:r,event:i,properties:n,options:a})=>super.captureStateless(r,i,n,{timestamp:a.timestamp,disableGeoip:a.disableGeoip,uuid:a.uuid})).catch(r=>{r&&console.error(r)}))}async captureImmediate(t){return typeof t=="string"&&this._logger.warn("Called captureImmediate() with a string as the first argument when an object was expected."),this.addPendingPromise(this.prepareEventMessage(t).then(({distinctId:r,event:i,properties:n,options:a})=>super.captureStatelessImmediate(r,i,n,{timestamp:a.timestamp,disableGeoip:a.disableGeoip,uuid:a.uuid})).catch(r=>{r&&console.error(r)}))}identify({distinctId:t,properties:r={},disableGeoip:i}){let{$set:n,$set_once:a,$anon_distinct_id:o,...c}=r,u={$set:n||c,$set_once:a||{},$anon_distinct_id:o??void 0};super.identifyStateless(t,u,{disableGeoip:i})}async identifyImmediate({distinctId:t,properties:r={},disableGeoip:i}){let{$set:n,$set_once:a,$anon_distinct_id:o,...c}=r,u={$set:n||c,$set_once:a||{},$anon_distinct_id:o??void 0};super.identifyStatelessImmediate(t,u,{disableGeoip:i})}alias(t){super.aliasStateless(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}async aliasImmediate(t){await super.aliasStatelessImmediate(t.alias,t.distinctId,void 0,{disableGeoip:t.disableGeoip})}isLocalEvaluationReady(){return this.featureFlagsPoller?.isLocalEvaluationReady()??!1}async waitForLocalEvaluationReady(t=Z8E){return this.isLocalEvaluationReady()?!0:this.featureFlagsPoller===void 0?!1:new Promise(r=>{let i=setTimeout(()=>{n(),r(!1)},t),n=this._events.on("localEvaluationFlagsLoaded",a=>{clearTimeout(i),n(),r(a>0)})})}async _getFeatureFlagResult(t,r,i={},n){let a=i.sendFeatureFlagEvents??!0;if(this._flagOverrides!==void 0&&t in this._flagOverrides){let A=this._flagOverrides[t];if(A===void 0)return;let j=this._payloadOverrides?.[t];return{key:t,enabled:A!==!1,variant:typeof A=="string"?A:void 0,payload:j}}let{groups:o,disableGeoip:c}=i,{onlyEvaluateLocally:d,personProperties:s,groupProperties:u}=i,f=this.addLocalPersonAndGroupProperties(r,o,s,u);s=f.allPersonProperties,u=f.allGroupProperties,d==null&&(d=this.options.strictLocalEvaluation??!1);let p,_=!1,h,y,b,v,O,m;if(this.featureFlagsPoller!==void 0){await this.featureFlagsPoller?.loadFeatureFlags();let A=this.featureFlagsPoller?.featureFlagsByKey[t];if(A)try{let j=await this.featureFlagsPoller?.computeFlagAndPayloadLocally(A,r,o,s,u,n);if(j){_=!0;let M=j.value;v=A.id,m="Evaluated locally",p={key:t,enabled:M!==!1,variant:typeof M=="string"?M:void 0,payload:j.payload??void 0}}}catch(j){if(j instanceof hLi||j instanceof uE)this._logger?.info(`${j.name} when computing flag locally: ${t}: ${j.message}`);else throw j}}if(!_&&!d){let A=await super.getFeatureFlagDetailsStateless(r,o,s,u,c,[t]);if(A===void 0)b=B4o.UNKNOWN_ERROR;else{h=A.requestId,y=A.evaluatedAt;let j=[];A.errorsWhileComputingFlags&&j.push(B4o.ERRORS_WHILE_COMPUTING),A.quotaLimited?.includes("feature_flags")&&j.push(B4o.QUOTA_LIMITED);let M=A.flags[t];if(M===void 0)j.push(B4o.FLAG_MISSING);else{v=M.metadata?.id,O=M.metadata?.version,m=M.reason?.description??M.reason?.code;let w;if(M.metadata?.payload!==void 0)try{w=JSON.parse(M.metadata.payload)}catch{w=M.metadata.payload}p={key:t,enabled:M.enabled,variant:M.variant,payload:w}}j.length>0&&(b=j.join(","))}}if(a){let A=p===void 0?void 0:p.enabled===!1?!1:p.variant??!0,j=`${t}_${A}`;if(!(r in this.distinctIdHasSentFlagCalls)||!this.distinctIdHasSentFlagCalls[r].includes(j)){Object.keys(this.distinctIdHasSentFlagCalls).length>=this.maxCacheSize&&(this.distinctIdHasSentFlagCalls={}),Array.isArray(this.distinctIdHasSentFlagCalls[r])?this.distinctIdHasSentFlagCalls[r].push(j):this.distinctIdHasSentFlagCalls[r]=[j];let M={$feature_flag:t,$feature_flag_response:A,$feature_flag_id:v,$feature_flag_version:O,$feature_flag_reason:m,locally_evaluated:_,[`$feature/${t}`]:A,$feature_flag_request_id:h,$feature_flag_evaluated_at:y};b&&(M.$feature_flag_error=b),this.capture({distinctId:r,event:"$feature_flag_called",properties:M,groups:o,disableGeoip:c})}}return p!==void 0&&this._payloadOverrides!==void 0&&t in this._payloadOverrides&&(p={...p,payload:this._payloadOverrides[t]}),p}async getFeatureFlag(t,r,i){let n=await this._getFeatureFlagResult(t,r,{...i,sendFeatureFlagEvents:i?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0});if(n!==void 0)return n.enabled===!1?!1:n.variant??!0}async getFeatureFlagPayload(t,r,i,n){if(this._payloadOverrides!==void 0&&t in this._payloadOverrides)return this._payloadOverrides[t];let a=await this._getFeatureFlagResult(t,r,{...n,sendFeatureFlagEvents:!1},i);if(a!==void 0)return a.payload??null}async getFeatureFlagResult(t,r,i){return this._getFeatureFlagResult(t,r,{...i,sendFeatureFlagEvents:i?.sendFeatureFlagEvents??this.options.sendFeatureFlagEvent??!0})}async getRemoteConfigPayload(t){if(!this.options.personalApiKey)throw new Error("Personal API key is required for remote config payload decryption");let r=await this._requestRemoteConfigPayload(t);if(!r)return;let i=await r.json();if(typeof i=="string")try{return JSON.parse(i)}catch{}return i}async isFeatureEnabled(t,r,i){let n=await this.getFeatureFlag(t,r,i);if(n!==void 0)return!!n||!1}async getAllFlags(t,r){return(await this.getAllFlagsAndPayloads(t,r)).featureFlags||{}}async getAllFlagsAndPayloads(t,r){let{groups:i,disableGeoip:n,flagKeys:a}=r||{},{onlyEvaluateLocally:o,personProperties:c,groupProperties:d}=r||{},s=this.addLocalPersonAndGroupProperties(t,i,c,d);c=s.allPersonProperties,d=s.allGroupProperties,o==null&&(o=this.options.strictLocalEvaluation??!1);let u=await this.featureFlagsPoller?.getAllFlagsAndPayloads(t,i,c,d,a),f={},p={},_=!0;if(u&&(f=u.response,p=u.payloads,_=u.fallbackToFlags),_&&!o){let h=await super.getFeatureFlagsAndPayloadsStateless(t,i,c,d,n,a);f={...f,...h.flags||{}},p={...p,...h.payloads||{}}}return this._flagOverrides!==void 0&&(f={...f,...this._flagOverrides}),this._payloadOverrides!==void 0&&(p={...p,...this._payloadOverrides}),{featureFlags:f,featureFlagPayloads:p}}groupIdentify({groupType:t,groupKey:r,properties:i,distinctId:n,disableGeoip:a}){super.groupIdentifyStateless(t,r,i,{disableGeoip:a},n)}async reloadFeatureFlags(){await this.featureFlagsPoller?.loadFeatureFlags(!0)}overrideFeatureFlags(t){let r=i=>Object.fromEntries(i.map(n=>[n,!0]));if(t===!1){this._flagOverrides=void 0,this._payloadOverrides=void 0;return}if(Array.isArray(t)){this._flagOverrides=r(t);return}if(this._isFeatureFlagOverrideOptions(t)){"flags"in t&&(t.flags===!1?this._flagOverrides=void 0:Array.isArray(t.flags)?this._flagOverrides=r(t.flags):t.flags!==void 0&&(this._flagOverrides={...t.flags})),"payloads"in t&&(t.payloads===!1?this._payloadOverrides=void 0:t.payloads!==void 0&&(this._payloadOverrides={...t.payloads}));return}this._flagOverrides={...t}}_isFeatureFlagOverrideOptions(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let r=t;if("flags"in r){let i=r.flags;if(i===!1||Array.isArray(i)||typeof i=="object"&&i!==null)return!0}if("payloads"in r){let i=r.payloads;if(i===!1||typeof i=="object"&&i!==null)return!0}return!1}withContext(t,r,i){return this.context?this.context.run(t,r,i):r()}getContext(){return this.context?.get()}async _shutdown(t){return this.featureFlagsPoller?.stopPoller(t),this.errorTracking.shutdown(),super._shutdown(t)}async _requestRemoteConfigPayload(t){if(!this.options.personalApiKey)return;let r=`${this.host}/api/projects/@current/feature_flags/${t}/remote_config?token=${encodeURIComponent(this.apiKey)}`,i={method:"GET",headers:{...this.getCustomHeaders(),"Content-Type":"application/json",Authorization:`Bearer ${this.options.personalApiKey}`}},n=null;if(this.options.requestTimeout&&typeof this.options.requestTimeout=="number"){let a=new AbortController;n=Tea(()=>{a.abort()},this.options.requestTimeout),i.signal=a.signal}try{return await this.fetch(r,i)}catch(a){this._events.emit("error",a);return}finally{n&&clearTimeout(n)}}extractPropertiesFromEvent(t,r){if(!t)return{personProperties:{},groupProperties:{}};let i={},n={};for(let[a,o]of Object.entries(t))if(a8E(o)&&r&&a in r){let c={};for(let[d,s]of Object.entries(o))c[String(d)]=String(s);n[String(a)]=c}else i[String(a)]=String(o);return{personProperties:i,groupProperties:n}}async getFeatureFlagsForEvent(t,r,i,n){let a=n?.personProperties||{},o=n?.groupProperties||{},c=n?.flagKeys;if(n?.onlyEvaluateLocally??this.options.strictLocalEvaluation??!1)if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let s={};for(let[u,f]of Object.entries(r||{}))s[u]=String(f);return await this.getAllFlags(t,{groups:s,personProperties:a,groupProperties:o,disableGeoip:i,onlyEvaluateLocally:!0,flagKeys:c})}else return{};if((this.featureFlagsPoller?.featureFlags?.length||0)>0){let s={};for(let[u,f]of Object.entries(r||{}))s[u]=String(f);return await this.getAllFlags(t,{groups:s,personProperties:a,groupProperties:o,disableGeoip:i,onlyEvaluateLocally:!0,flagKeys:c})}return(await super.getFeatureFlagsStateless(t,r,a,o,i)).flags}addLocalPersonAndGroupProperties(t,r,i,n){let a={distinct_id:t,...i||{}},o={};if(r)for(let c of Object.keys(r))o[c]={$group_key:r[c],...n?.[c]||{}};return{allPersonProperties:a,allGroupProperties:o}}captureException(t,r,i,n){if(!c$t.isPreviouslyCapturedError(t)){let a=new Error("PostHog syntheticException");this.addPendingPromise(c$t.buildEventMessage(t,{syntheticException:a},r,i).then(o=>this.capture({...o,uuid:n})))}}async captureExceptionImmediate(t,r,i){if(!c$t.isPreviouslyCapturedError(t)){let n=new Error("PostHog syntheticException");this.addPendingPromise(c$t.buildEventMessage(t,{syntheticException:n},r,i).then(a=>this.captureImmediate(a)))}}async prepareEventMessage(t){let{distinctId:r,event:i,properties:n,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:d,uuid:s}=t,u=this.context?.get(),f=r||u?.distinctId,p={...u?.properties||{},...n||{}};f||(f=pLi(),p.$process_person_profile=!1),u?.sessionId&&!p.$session_id&&(p.$session_id=u.sessionId);let _=this._runBeforeSend({distinctId:f,event:i,properties:p,groups:a,sendFeatureFlags:o,timestamp:c,disableGeoip:d,uuid:s});if(!_)return Promise.reject(null);let h=await Promise.resolve().then(async()=>{if(o){let y=typeof o=="object"?o:void 0;return await this.getFeatureFlagsForEvent(_.distinctId,a,d,y)}return _.event,{}}).then(y=>{let b={};if(y)for(let[O,m]of Object.entries(y))b[`$feature/${O}`]=m;let v=Object.keys(y||{}).filter(O=>y?.[O]!==!1).sort();return v.length>0&&(b.$active_feature_flags=v),b}).catch(()=>({})).then(y=>({...y,..._.properties||{},$groups:_.groups||a}));return _.event==="$pageview"&&this.options.__preview_capture_bot_pageviews&&typeof h.$raw_user_agent=="string"&&kWE(h.$raw_user_agent,this.options.custom_blocked_useragents||[])&&(_.event="$bot_pageview",h.$browser_type="bot"),{distinctId:_.distinctId,event:_.event,properties:h,options:{timestamp:_.timestamp,disableGeoip:_.disableGeoip,uuid:_.uuid}}}_runBeforeSend(t){let r=this.options.before_send;if(!r)return t;let i=Array.isArray(r)?r:[r],n=t;for(let a of i){if(n=a(n),!n)return this._logger.info(`Event '${t.event}' was rejected in beforeSend function`),null;if(!n.properties||Object.keys(n.properties).length===0){let o=`Event '${n.event}' has no properties after beforeSend function, this is likely an error.`;this._logger.warn(o)}}return n}};var k8E=require("async_hooks"),Soc=class{constructor(){this.storage=new k8E.AsyncLocalStorage}get(){return this.storage.getStore()}run(t,r,i){if(i?.fresh===!0)return this.storage.run(t,r);{let a=this.get()||{},o={distinctId:t.distinctId??a.distinctId,sessionId:t.sessionId??a.sessionId,properties:{...a.properties||{},...t.properties||{}}};return this.storage.run(o,r)}}};var exE="posthog-node";function ff5(e,{organization:t,projectId:r,prefix:i,severityAllowList:n=["error"],sendExceptionsToPostHog:a=!0}={}){return o=>{if(!(n==="*"||n.includes(o.level)))return o;o.tags||(o.tags={});let d=o.tags[Wwp.POSTHOG_ID_TAG];if(d===void 0)return o;let s=e.options.host??"https://us.i.posthog.com",u=new URL(`/project/${e.apiKey}/person/${d}`,s).toString();o.tags["PostHog Person URL"]=u;let f=o.exception?.values||[],p=f.map(h=>({...h,stacktrace:h.stacktrace?{...h.stacktrace,type:"raw",frames:(h.stacktrace.frames||[]).map(y=>({...y,platform:"node:javascript"}))}:void 0})),_={$exception_message:f[0]?.value||o.message,$exception_type:f[0]?.type,$exception_level:o.level,$exception_list:p,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:f[0]?.value||o.message,$sentry_exception_type:f[0]?.type,$sentry_tags:o.tags};return t&&r&&(_.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+o.event_id),a&&e.capture({event:"$exception",distinctId:d,properties:_}),o}}var Wwp=class{static#e=this.POSTHOG_ID_TAG="posthog_distinct_id";constructor(t,r,i,n,a){this.name=exE,this.name=exE,this.setupOnce=function(o,c){let d=c()?.getClient()?.getDsn()?.projectId;o(ff5(t,{organization:r,projectId:d,prefix:i,severityAllowList:n,sendExceptionsToPostHog:a??!0}))}}};c$t.errorPropertiesBuilder=new SOe.ErrorPropertiesBuilder([new SOe.EventCoercer,new SOe.ErrorCoercer,new SOe.ObjectCoercer,new SOe.StringCoercer,new SOe.PrimitiveCoercer],SOe.createStackParser("node:javascript",SOe.nodeStackLineParser),[$WE(),Q8E]);var Qxa=class extends Eoc{getLibraryId(){return"posthog-node"}initializeContext(){return new Soc}};var Moc=class{posthog;constructor({posthogApiKey:t}){this.posthog=new Qxa(t)}async identify(){}async sendEvent(t){t.orgId!=null&&this.posthog.capture({distinctId:t.orgId,event:"CLI",properties:{...t,...t.properties,version:"3.56.10",usingAccessToken:!0}})}async flush(){await this.posthog.flush()}};var I4o=class{async sendEvent(){}async identify(){}async flush(){}};var Uxa=require("fs/promises"),txE=require("os"),rxE=require("path");var df5="id",pf5=".fern",C4o=class{posthog;userId;token;constructor({token:t,posthogApiKey:r}){this.posthog=new Qxa(r),this.userId=t==null?void 0:oFc(t),this.token=t}async identify(){this.userId!=null&&this.posthog.alias({distinctId:this.userId,alias:await this.getPersistedDistinctId()})}async sendEvent(t){let r=await this.getUserEmail();this.posthog.capture({distinctId:this.userId??await this.getPersistedDistinctId(),event:"CLI",properties:{version:"3.56.10",...t,...t.properties,usingAccessToken:!1,...r!=null?{userEmail:r}:{}}})}async flush(){await this.posthog.flush()}userEmail;async getUserEmail(){if(this.userEmail!==null){if(this.userEmail!=null)return this.userEmail;if(this.token==null){this.userEmail=null;return}try{let t=await d3({token:this.token.value}).user.getMyself();if(t.ok&&t.body.email!=null)return this.userEmail=t.body.email,this.userEmail}catch{}this.userEmail=null}}persistedDistinctId;async getPersistedDistinctId(){if(this.persistedDistinctId==null){let t=ot(mr.of((0,txE.homedir)()),Pe.of(pf5),Pe.of(df5));await ni(t)||(await(0,Uxa.mkdir)((0,rxE.dirname)(t),{recursive:!0}),await(0,Uxa.writeFile)(t,Xme())),this.persistedDistinctId=(await(0,Uxa.readFile)(t)).toString()}return this.persistedDistinctId}};var xwp;async function Lxa(){return xwp==null&&(xwp=await _f5()),xwp}async function _f5(){try{let e="phc_yQgAEdJJkVpI24NdSRID2mor1x1leRpDoC9yZ9mfXal",t=process.env.FERN_DISABLE_TELEMETRY==="true";if(e==null||t)return new I4o;let r=await dZo();return r!=null?new C4o({token:r,posthogApiKey:e}):await esa()!=null?new Moc({posthogApiKey:e}):new C4o({token:void 0,posthogApiKey:e})}catch{return new I4o}}var q4o=se(require("process"),1);var axE=se(lLc(),1),oxE=se(nxE(),1);function vV(e,t={}){if(typeof e!="string"||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=L8t(e),e.length===0))return 0;e=e.replace((0,oxE.default)()," ");let r=t.ambiguousIsNarrow?1:2,i=0;for(let n of e){let a=n.codePointAt(0);if(a<=31||a>=127&&a<=159||a>=768&&a<=879)continue;switch(axE.default.eastAsianWidth(n)){case"F":case"W":i+=2;break;case"A":i+=r;break;default:i+=1}}return i}function Doc(e){let t=0;for(let r of e.split(`
|
|
2241
2241
|
`))t=Math.max(t,vV(r));return t}var ExE=se(Hwp(),1);var yf5=/[\p{Lu}]/u,bf5=/[\p{Ll}]/u,cxE=/^[\p{Lu}](?![\p{Lu}])/gu,dxE=/([\p{Alpha}\p{N}_]|$)/u,Kwp=/[_.\- ]+/,vf5=new RegExp("^"+Kwp.source),lxE=new RegExp(Kwp.source+dxE.source,"gu"),fxE=new RegExp("\\d+"+dxE.source,"gu"),gf5=(e,t,r,i)=>{let n=!1,a=!1,o=!1,c=!1;for(let d=0;d<e.length;d++){let s=e[d];c=d>2?e[d-3]==="-":!0,n&&yf5.test(s)?(e=e.slice(0,d)+"-"+e.slice(d),n=!1,o=a,a=!0,d++):a&&o&&bf5.test(s)&&(!c||i)?(e=e.slice(0,d-1)+"-"+e.slice(d-1),o=a,a=!1,n=!0):(n=t(s)===s&&r(s)!==s,o=a,a=r(s)===s&&t(s)!==s)}return e},Of5=(e,t)=>(cxE.lastIndex=0,e.replace(cxE,r=>t(r))),mf5=(e,t)=>(lxE.lastIndex=0,fxE.lastIndex=0,e.replace(lxE,(r,i)=>t(i)).replace(fxE,r=>t(r)));function $wp(e,t){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},Array.isArray(e)?e=e.map(a=>a.trim()).filter(a=>a.length).join("-"):e=e.trim(),e.length===0)return"";let r=t.locale===!1?a=>a.toLowerCase():a=>a.toLocaleLowerCase(t.locale),i=t.locale===!1?a=>a.toUpperCase():a=>a.toLocaleUpperCase(t.locale);return e.length===1?Kwp.test(e)?"":t.pascalCase?i(e):r(e):(e!==r(e)&&(e=gf5(e,r,i,t.preserveConsecutiveUppercase)),e=e.replace(vf5,""),e=t.preserveConsecutiveUppercase?Of5(e,r):r(e),t.pascalCase&&(e=i(e.charAt(0))+e.slice(1)),mf5(e,i))}var Zwp=se(_xE(),1);var hxE=(e=0)=>t=>`\x1B[${t+e}m`,yxE=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,bxE=(e=0)=>(t,r,i)=>`\x1B[${38+e};2;${t};${r};${i}m`,qB={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},dfk=Object.keys(qB.modifier),wf5=Object.keys(qB.color),Ef5=Object.keys(qB.bgColor),pfk=[...wf5,...Ef5];function Sf5(){let e=new Map;for(let[t,r]of Object.entries(qB)){for(let[i,n]of Object.entries(r))qB[i]={open:`\x1B[${n[0]}m`,close:`\x1B[${n[1]}m`},r[i]=qB[i],e.set(n[0],n[1]);Object.defineProperty(qB,t,{value:r,enumerable:!1})}return Object.defineProperty(qB,"codes",{value:e,enumerable:!1}),qB.color.close="\x1B[39m",qB.bgColor.close="\x1B[49m",qB.color.ansi=hxE(),qB.color.ansi256=yxE(),qB.color.ansi16m=bxE(),qB.bgColor.ansi=hxE(10),qB.bgColor.ansi256=yxE(10),qB.bgColor.ansi16m=bxE(10),Object.defineProperties(qB,{rgbToAnsi256:{value(t,r,i){return t===r&&r===i?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(i/255*5)},enumerable:!1},hexToRgb:{value(t){let r=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!r)return[0,0,0];let[i]=r;i.length===3&&(i=[...i].map(a=>a+a).join(""));let n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,n&255]},enumerable:!1},hexToAnsi256:{value:t=>qB.rgbToAnsi256(...qB.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let r,i,n;if(t>=232)r=((t-232)*10+8)/255,i=r,n=r;else{t-=16;let c=t%36;r=Math.floor(t/36)/5,i=Math.floor(c/6)/5,n=c%6/5}let a=Math.max(r,i,n)*2;if(a===0)return 30;let o=30+(Math.round(n)<<2|Math.round(i)<<1|Math.round(r));return a===2&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(t,r,i)=>qB.ansi256ToAnsi(qB.rgbToAnsi256(t,r,i)),enumerable:!1},hexToAnsi:{value:t=>qB.ansi256ToAnsi(qB.hexToAnsi256(t)),enumerable:!1}}),qB}var Mf5=Sf5(),vxE=Mf5;var Boc=new Set(["\x1B","\x9B"]),Df5=39,Ywp="\x07",mxE="[",Bf5="]",AxE="m",Xwp=`${Bf5}8;;`,gxE=e=>`${Boc.values().next().value}${mxE}${e}${AxE}`,OxE=e=>`${Boc.values().next().value}${Xwp}${e}${Ywp}`,If5=e=>e.split(" ").map(t=>vV(t)),Jwp=(e,t,r)=>{let i=[...t],n=!1,a=!1,o=vV(L8t(e[e.length-1]));for(let[c,d]of i.entries()){let s=vV(d);if(o+s<=r?e[e.length-1]+=d:(e.push(d),o=0),Boc.has(d)&&(n=!0,a=i.slice(c+1).join("").startsWith(Xwp)),n){a?d===Ywp&&(n=!1,a=!1):d===AxE&&(n=!1);continue}o+=s,o===r&&c<i.length-1&&(e.push(""),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Cf5=e=>{let t=e.split(" "),r=t.length;for(;r>0&&!(vV(t[r-1])>0);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},qf5=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let i="",n,a,o=If5(e),c=[""];for(let[s,u]of e.split(" ").entries()){r.trim!==!1&&(c[c.length-1]=c[c.length-1].trimStart());let f=vV(c[c.length-1]);if(s!==0&&(f>=t&&(r.wordWrap===!1||r.trim===!1)&&(c.push(""),f=0),(f>0||r.trim===!1)&&(c[c.length-1]+=" ",f++)),r.hard&&o[s]>t){let p=t-f,_=1+Math.floor((o[s]-p-1)/t);Math.floor((o[s]-1)/t)<_&&c.push(""),Jwp(c,u,t);continue}if(f+o[s]>t&&f>0&&o[s]>0){if(r.wordWrap===!1&&f<t){Jwp(c,u,t);continue}c.push("")}if(f+o[s]>t&&r.wordWrap===!1){Jwp(c,u,t);continue}c[c.length-1]+=u}r.trim!==!1&&(c=c.map(s=>Cf5(s)));let d=[...c.join(`
|
|
2242
2242
|
`)];for(let[s,u]of d.entries()){if(i+=u,Boc.has(u)){let{groups:p}=new RegExp(`(?:\\${mxE}(?<code>\\d+)m|\\${Xwp}(?<uri>.*)${Ywp})`).exec(d.slice(s).join(""))||{groups:{}};if(p.code!==void 0){let _=Number.parseFloat(p.code);n=_===Df5?void 0:_}else p.uri!==void 0&&(a=p.uri.length===0?void 0:p.uri)}let f=vxE.codes.get(Number(n));d[s+1]===`
|
|
2243
2243
|
`?(a&&(i+=OxE("")),n&&f&&(i+=gxE(f))):u===`
|
|
@@ -2400,7 +2400,7 @@ For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides
|
|
|
2400
2400
|
Run ${Ot.cyan("fern generator upgrade")} to upgrade your generators.`),n.length>2&&(r+=`
|
|
2401
2401
|
Run ${Ot.cyan("fern generator upgrade --list")} to see the full list of generator upgrades available.`),Vxa(r,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"})}async function ZTp({generatorUpgradeInfo:e,header:t,limit:r,includeBoxen:i=!0}){if(!iaS(e))return;let n=t??"",a=e.filter(c=>c.isUpgradeAvailable);r!=null&&(a=a.slice(0,r+1));let o=a.sort((c,d)=>c.generatorName.localeCompare(d.generatorName)||c.currentVersion.localeCompare(d.currentVersion));for(let c of o)n+=`
|
|
2402
2402
|
${await zR5(c.generatorName)} (${c.apiName!=null?"API: "+c.apiName+", ":""}Group: ${c.generatorGroup}) `+Ot.dim(c.currentVersion)+Ot.reset(" \u2192 ")+Ot.green(c.latestVersion);return n+=`
|
|
2403
|
-
`,i?Vxa(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function zR5(e){let r=await new raS.FernRegistryClient({environment:"https://registry.buildwithfern.com"}).generators.getGeneratorByImage({dockerImage:e});if(!r.ok||r.body==null)throw new Error(`Generator ${e} not found`);return r.body.displayName}async function NR5({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await aaS({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,u,f)=>{c.versions[s]==null&&(c.versions[s]={});let p=oen(u.name,f),_=await l6t({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:f});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await aaS({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,d,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][d]==null&&(o.versions[c][d]={});let f=oen(s.name,u),p=await l6t({generatorName:f,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][d][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function aaS({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await vAe({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(c==null||c.groups==null)return;let d=i!=null?IU(i):void 0;for(let s of c.groups)if(!(n!=null&&s.groupName!==n))for(let u of s.generators)d!=null&&u.name!==d||await r(a.workspaceName,s.groupName,u,o)})}))}function oaS(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let d=A2(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function h_c({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await NR5({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[d,s]of Object.entries(c.versions))o.push(...oaS(s,d,t.logger));else o.push(...oaS(c.versions,void 0,t.logger))}return o}async function zbn({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:seo(e.packageName,{version:t?"prerelease":"latest"})}var uaS=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],y_c=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Ma.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new Wmn(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"3.56.
|
|
2403
|
+
`,i?Vxa(n,{padding:1,float:"center",textAlignment:"center",borderColor:"yellow",borderStyle:"round"}):n}async function zR5(e){let r=await new raS.FernRegistryClient({environment:"https://registry.buildwithfern.com"}).generators.getGeneratorByImage({dockerImage:e});if(!r.ok||r.body==null)throw new Error(`Generator ${e} not found`);return r.body.displayName}async function NR5({cliContext:e,project:{apiWorkspaces:t},generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){if(t.length===1){let c={type:"singleApi",versions:{}};return await aaS({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(d,s,u,f)=>{c.versions[s]==null&&(c.versions[s]={});let p=oen(u.name,f),_=await l6t({generatorName:p,cliVersion:e.environment.packageVersion,currentGeneratorVersion:u.version,channel:n,includeMajor:a,context:f});_!=null&&(c.versions[s][u.name]={previousVersion:u.version,latestVersion:_})},generatorFilter:r,groupFilter:i}),c}let o={type:"multiApi",versions:{}};return await aaS({cliContext:e,apiWorkspaces:t,perGeneratorAction:async(c,d,s,u)=>{if(c==null)return;o.versions[c]==null&&(o.versions[c]={}),o.versions[c][d]==null&&(o.versions[c][d]={});let f=oen(s.name,u),p=await l6t({generatorName:f,cliVersion:e.environment.packageVersion,currentGeneratorVersion:s.version,channel:n,includeMajor:a,context:u});p!=null&&(o.versions[c][d][s.name]={previousVersion:s.version,latestVersion:p})},generatorFilter:r,groupFilter:i}),o}async function aaS({cliContext:e,apiWorkspaces:t,perGeneratorAction:r,generatorFilter:i,groupFilter:n}){await Promise.all(t.map(async a=>{await e.runTaskForWorkspace(a,async o=>{let c=await vAe({absolutePathToWorkspace:a.absoluteFilePath,context:o});if(c==null||c.groups==null)return;let d=i!=null?IU(i):void 0;for(let s of c.groups)if(!(n!=null&&s.groupName!==n))for(let u of s.generators)d!=null&&u.name!==d||await r(a.workspaceName,s.groupName,u,o)})}))}function oaS(e,t,r){let i=[];for(let[n,a]of Object.entries(e))for(let[o,c]of Object.entries(a)){r.debug(`Checking if ${o} in group ${n} has an upgrade available...`);let d=A2(c.latestVersion,c.previousVersion);r.debug(`Latest version: ${c.latestVersion}. `+(d?"Upgrade available.":"No upgrade available.")),i.push({generatorName:o,generatorGroup:n,apiName:t,isUpgradeAvailable:d,currentVersion:c.previousVersion,latestVersion:c.latestVersion})}return i}async function h_c({project:e,cliContext:t,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a}){let o=[];if(e!=null){let c=await NR5({cliContext:t,project:e,generatorFilter:r,groupFilter:i,channel:n,includeMajor:a});if(c.type==="multiApi")for(let[d,s]of Object.entries(c.versions))o.push(...oaS(s,d,t.logger));else o.push(...oaS(c.versions,void 0,t.logger))}return o}async function zbn({cliEnvironment:e,includePreReleases:t=!1}){return e.packageName!=="fern-api"?e.packageVersion:seo(e.packageName,{version:t?"prerelease":"latest"})}var uaS=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],y_c=class{environment;didSucceed=!0;numTasks=0;ttyAwareLogger;logLevel=Ma.Info;isLocal;constructor(t,r,{isLocal:i}){this.ttyAwareLogger=new Wmn(t,r),this.isLocal=i??!1;let n=this.getPackageName(),a=this.getPackageVersion(),o=this.getCliName();(n==null||a==null||o==null)&&this.exitProgram(),this.environment={packageName:n,packageVersion:a,cliName:o}}getPackageName(){return"fern-api"}getPackageVersion(){return"3.56.10"}getCliName(){return"fern"}setLogLevel(t){this.logLevel=t}logFernVersionDebug(){this.logger.debug(`Running ${Ot.bold(`${this.environment.cliName}`)} (${this.environment.packageName}@${this.environment.packageVersion})`)}failAndThrow(t,r){throw this.failWithoutThrowing(t,r),new yS}failWithoutThrowing(t,r){this.didSucceed=!1,vZa({message:t,error:r,logger:this.logger})}async exit({code:t}={}){!this._suppressUpgradeMessage&&!this.isLocal&&await this.nudgeUpgradeIfAvailable(),this.ttyAwareLogger.finish(),await(await Lxa()).flush(),this.exitProgram({code:t})}async nudgeUpgradeIfAvailable(){try{let t=await Promise.race([this.isUpgradeAvailable(),new Promise((i,n)=>setTimeout(()=>n("Request timed out"),300))]),r=await naS({cliEnvironment:this.environment,upgradeInfo:t});r!=null&&(r.endsWith(`
|
|
2404
2404
|
`)||(r+=`
|
|
2405
2405
|
`),this.stderr.info(r))}catch{}}async exitIfFailed(){this.didSucceed||await this.exit()}exitProgram({code:t}={}){process.exit(t??(this.didSucceed?0:1))}longestWorkspaceName;registerWorkspaces(t){let r=sAc(t.map(i=>i.type==="docs"?"docs":i.workspaceName??"api"),i=>i.length);r!=null&&(this.longestWorkspaceName=r)}project;registerProject(t){this.project=t}runTask(t){return this.runTaskWithInit(this.constructTaskInit(),t)}addTask(){return this.addTaskWithInit(this.constructTaskInit())}async runTaskForWorkspace(t,r){await this.runTaskWithInit(this.constructTaskInitForWorkspace(t),r)}addTaskWithInit(t){let r=new zWo(t);return this.ttyAwareLogger.registerTask(r),r}USE_NODE_18_OR_ABOVE_MESSAGE="The Fern CLI requires Node 18+ or above.";async runTaskWithInit(t,r){let i=this.addTaskWithInit(t).start(),n;try{n=await r(i)}catch(a){throw a.message.includes("globalThis")?(i.logger.error(this.USE_NODE_18_OR_ABOVE_MESSAGE),i.failWithoutThrowing()):i.failWithoutThrowing(void 0,a),new yS}finally{i.finish()}return n}async instrumentPostHogEvent(t){this.isLocal||(await Lxa()).sendEvent(t)}logger=ome((t,...r)=>this.log(t,...r));stderr=ome((t,...r)=>this.logStderr(t,...r));constructTaskInitForWorkspace(t){let r=saS(t.type==="docs"?"docs":t.workspaceName??"api"),i=1+(this.longestWorkspaceName!=null?saS(this.longestWorkspaceName):r).length,n=r.padEnd(i),a=uaS[this.numTasks++%uaS.length],o=Ot.hex(a)(n);return{...this.constructTaskInit(),logPrefix:o}}constructTaskInit(){return{logImmediately:t=>this.logImmediately(t),takeOverTerminal:t=>this.ttyAwareLogger.takeOverTerminal(t),onResult:t=>{t===qA.Failure&&(this.didSucceed=!1)},instrumentPostHogEvent:async t=>{await this.instrumentPostHogEvent(t)},shouldBufferLogs:!1}}log(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}])}logStderr(t,...r){this.logImmediately([{parts:r,level:t,time:new Date}],{stderr:!0})}logImmediately(t,{stderr:r=!1}={}){let i=t.filter(n=>U8t.indexOf(n.level)>=U8t.indexOf(this.logLevel));this.ttyAwareLogger.log(i,{includeDebugInfo:this.logLevel===Ma.Debug,stderr:r})}_suppressUpgradeMessage=!1;suppressUpgradeMessage(){this._suppressUpgradeMessage=!0}_isUpgradeAvailable;async isUpgradeAvailable({includePreReleases:t=!1}={}){if(this._isUpgradeAvailable==null){this.logger.debug(`Checking if ${this.environment.packageName} upgrade is available...`);let r=await zbn({cliEnvironment:this.environment,includePreReleases:t}),i=A2(r,this.environment.packageVersion);this.logger.debug(`Latest version: ${r}. `+(i?"Upgrade available.":"No upgrade available."));let n={isUpgradeAvailable:i,latestVersion:r},a=await h_c({project:this.project,cliContext:this});this._isUpgradeAvailable={cliUpgradeInfo:n,generatorUpgradeInfo:a}}return this._isUpgradeAvailable}async confirmPrompt(t,r=!1){try{return await YTp({message:t,choices:[{name:"No",value:!1},{name:"Yes",value:!0}],default:r,theme:{prefix:Ot.yellow("?"),style:{answer:n=>Ot.cyan(n),message:n=>Ot.bold(n),highlight:n=>Ot.cyan(n)}}})}catch(i){throw i?.name==="ExitPromptError"?(this.logger.info(`
|
|
2406
2406
|
Cancelled by user.`),new yS):i}}async getInput(t){return await KTp({message:t.message,default:t.default})}};function saS(e){return`[${e}]:`}var caS=require("fs/promises");async function kTp({context:e,nameOverride:t,...r}){let i=await XM(t);return i==null?e.failAndThrow(`Directory "${t??mE}" not found.`):await laS({absolutePathToFernDirectory:i,context:e,nameOverride:t,...r})}async function laS({absolutePathToFernDirectory:e,cliName:t,cliVersion:r,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:n,context:a}){let o=[];(await ni(ot(e,Pe.of(m7)))||await ni(ot(e,Pe.of(WM)))||await ni(ot(e,Pe.of(xM)))||await ni(ot(e,Pe.of(Tca)))||await ni(ot(e,Pe.of(K2a)))||await ni(ot(e,Pe.of(Q5c))))&&(o=await faS({cliName:t,fernDirectory:e,cliVersion:r,context:a,commandLineApiWorkspace:i,defaultToAllApiWorkspaces:n}));let c=await pbp({fernDirectory:e,context:a});return o.length===0&&c==null?a.failAndThrow(`No SDK specifications or docs specifications found. Please ensure one of the following .yml (not .yaml) files is present:
|
|
@@ -2436,7 +2436,7 @@ The generator configuration must be an object with a 'name' property, but the cu
|
|
|
2436
2436
|
|
|
2437
2437
|
Please check your generators.yml file and ensure the generator is properly configured.`);let o=n,c=await gaS({generatorName:t,logger:a});if(c==null)return;let d=QR5({migrations:c.migrations,from:r,to:i,logger:a});if(d.length!==0)return OaS({migrations:d,config:o,logger:a})}function maS(e){return{"fernapi/fern-typescript-sdk":"https://buildwithfern.com/learn/sdks/generators/typescript/changelog","fernapi/fern-typescript-node-sdk":"https://buildwithfern.com/learn/sdks/generators/typescript/changelog","fernapi/fern-python-sdk":"https://buildwithfern.com/learn/sdks/generators/python/changelog","fernapi/fern-go-sdk":"https://buildwithfern.com/learn/sdks/generators/go/changelog","fernapi/fern-java-sdk":"https://buildwithfern.com/learn/sdks/generators/java/changelog","fernapi/fern-csharp-sdk":"https://buildwithfern.com/learn/sdks/generators/csharp/changelog","fernapi/fern-php-sdk":"https://buildwithfern.com/learn/sdks/generators/php/changelog","fernapi/fern-ruby-sdk":"https://buildwithfern.com/learn/sdks/generators/ruby/changelog","fernapi/fern-swift-sdk":"https://buildwithfern.com/learn/sdks/generators/swift/changelog"}[e]}async function LR5({absolutePathToWorkspace:e,context:t,generatorFilter:r,groupFilter:i,includeMajor:n,channel:a,cliVersion:o}){let c=await len({absolutePathToWorkspace:e});if(c==null||!await ni(c))return t.logger.debug("Generators configuration file was not found, no generators to upgrade."),{updatedConfiguration:void 0,skippedMajorUpgrades:[],appliedUpgrades:[],alreadyUpToDate:[]};let d=await(0,g_c.readFile)(c);t.logger.debug(`Found generators: ${d.toString()}`);let s=$Ga.default.parseDocument(d.toString()),u=s.get("groups");if(u==null)return t.logger.debug("No groups were found within the generators configuration, no generators to upgrade."),{updatedConfiguration:void 0,skippedMajorUpgrades:[],appliedUpgrades:[],alreadyUpToDate:[]};if(!$Ga.default.isMap(u))return t.failAndThrow(`Expected 'groups' to be a map in ${FWo.default.relative(process.cwd(),c)}`),{updatedConfiguration:void 0,skippedMajorUpgrades:[],appliedUpgrades:[],alreadyUpToDate:[]};t.logger.debug(`Groups found: ${u.toString()}`);let f=[],p=[],_=[];for(let h of u.items){let y=h.key.value,b=h.value;if(!$Ga.default.isMap(b)){t.failAndThrow(`Expected group ${y} to be a map in ${FWo.default.relative(process.cwd(),c)}`);continue}if(i!=null&&i!==y){t.logger.debug(`Skipping group ${y} as it does not match the filter: ${i}`);continue}let v=b.get("generators");if(!$Ga.default.isSeq(v)){t.failAndThrow(`Expected group ${y} to have a 'generators' key in ${FWo.default.relative(process.cwd(),c)}`);continue}t.logger.debug(`Generators found: ${v.toString()}`);for(let O of v.items){$Ga.default.isMap(O)||t.failAndThrow(`Expected generator in group ${y} to be a map in ${FWo.default.relative(process.cwd(),c)}`);let m=O.get("name"),g=oen(m,t),A=r!=null?IU(r):void 0;if(A!=null&&g!==A){t.logger.debug(`Skipping generator ${m} as it does not match the filter: ${r}`);continue}let j=O.get("version"),M=await l6t({generatorName:g,cliVersion:o,currentGeneratorVersion:j,channel:a,includeMajor:n,context:t}),w=M??j;if(M!=null)if(M!==j){t.logger.debug(Ot.green(`Upgrading ${m} from ${j} to ${M}`)),O.set("version",M);let E=0,B=[],q=O.toJSON(),R=await eRp({generatorName:g,from:j,to:M,config:q,logger:t.logger});if(R!=null){E=R.migrationsApplied,B=R.appliedVersions;let T=new Set(Object.keys(q)),K=new Set(Object.keys(R.config));for(let H of T)K.has(H)||O.delete(H);for(let[H,z]of Object.entries(R.config))O.set(H,z);t.logger.debug(Ot.dim(`Applied ${E} migration(s): ${B.join(", ")}`))}p.push({generatorName:m,groupName:y,previousVersion:j,newVersion:M,migrationsApplied:E>0?E:void 0,migrationVersions:B.length>0?B:void 0})}else t.logger.debug(Ot.gray(`${m} is already on the latest version: ${j}`)),_.push({generatorName:m,groupName:y,version:j});if(!n){let E=await l6t({generatorName:g,cliVersion:o,currentGeneratorVersion:w,channel:a,includeMajor:!0,context:t});if(E!=null){let B=tRp.default.parse(w),q=tRp.default.parse(E);B!=null&&q!=null&&q.major>B.major&&f.push({generatorName:m,currentVersion:w,latestMajorVersion:E})}}}}return{updatedConfiguration:s.toString(),skippedMajorUpgrades:f,appliedUpgrades:p,alreadyUpToDate:_}}async function AaS({cliContext:e,generator:t,group:r,project:{apiWorkspaces:i},includeMajor:n,channel:a}){let o=[],c=[],d=[];if(await Promise.all(i.map(async s=>{await e.runTaskForWorkspace(s,async u=>{let f=await qya({absolutePathToWorkspace:s.absoluteFilePath,context:u})??{};if(f==null||f.groups==null){u.logger.debug("No groups were found within the generators configuration, no generators to upgrade.");return}s.workspaceName==null?u.logger.info("Upgrading generators."):u.logger.info(`Upgrading generators in workspace: ${s.workspaceName}.`);let p=await LR5({absolutePathToWorkspace:s.absoluteFilePath,context:u,generatorFilter:t,groupFilter:r,includeMajor:n,channel:a,cliVersion:e.environment.packageVersion}),_=await len({absolutePathToWorkspace:s.absoluteFilePath});_!=null&&p.updatedConfiguration!=null&&await(0,g_c.writeFile)(_,p.updatedConfiguration),o.push(...p.skippedMajorUpgrades),p.appliedUpgrades.length>0&&c.push({workspace:s.workspaceName,upgrades:p.appliedUpgrades}),p.alreadyUpToDate.length>0&&d.push({workspace:s.workspaceName,upToDate:p.alreadyUpToDate})})})),c.length>0){e.logger.info(""),e.logger.info(Ot.green("Successfully upgraded generators:"));for(let{workspace:s,upgrades:u}of c){let f=new Map;for(let p of u){let _=f.get(p.groupName)??[];_.push(p),f.set(p.groupName,_)}for(let[p,_]of f){let h=s!=null?`[${s}] `:"";e.logger.info(Ot.green(`${h}Group ${p}:`));for(let y of _){e.logger.info(Ot.green(` - ${y.generatorName}: ${Ot.dim(y.previousVersion)} \u2192 ${y.newVersion}`)),y.migrationsApplied!=null&&y.migrationsApplied>0&&e.logger.info(Ot.dim(` Applied ${y.migrationsApplied} migration(s): ${y.migrationVersions?.join(", ")??""}`));let b=maS(IU(y.generatorName));b!=null&&e.logger.info(Ot.dim(` Changelog: ${b}`))}}}}if(d.length>0){e.logger.info(""),e.logger.info(Ot.dim("Generators already on latest version:"));for(let{workspace:s,upToDate:u}of d){let f=new Map;for(let p of u){let _=f.get(p.groupName)??[];_.push(p),f.set(p.groupName,_)}for(let[p,_]of f){let h=s!=null?`[${s}] `:"";e.logger.info(Ot.dim(`${h}Group ${p}:`));for(let y of _)e.logger.info(Ot.dim(` - ${y.generatorName}: ${y.version} (latest)`))}}}if(c.length===0&&d.length===0){let s=r!=null?` for group ${r}`:t!=null?` for generator ${t}`:"";e.logger.info(""),e.logger.info(Ot.gray(`No generators found${s}.`))}if(o.length>0){e.logger.info(""),e.logger.info(Ot.yellow("Major version upgrades available:"));for(let s of o){e.logger.info(Ot.yellow(` - ${s.generatorName}: ${s.currentVersion} \u2192 ${s.latestMajorVersion}`));let u=t!=null?`fern generator upgrade --generator ${s.generatorName} --include-major`:"fern generator upgrade --include-major";e.logger.info(Ot.yellow(` Run: ${u}`));let f=maS(IU(s.generatorName));f!=null&&e.logger.info(Ot.yellow(` Changelog: ${f}`))}}}function waS(e,t){e.command("organization",!1,r=>r.option("output",{string:!0,alias:"o",description:"The location to output the organization name as a text file, defaults to standard out."}),async r=>{await t.instrumentPostHogEvent({command:"fern organization",properties:{outputLocation:r.output}}),await baS({project:await jm(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),context:t,outputLocation:r.output})})}function EaS(e,t){e.command("generator","Operate on the generators within your Fern configuration",r=>{r.command("list",!1,i=>i.option("output",{string:!0,alias:"o",description:"The location to output the list as a text file, defaults to standard out."}).option("generators",{string:!0,type:"array",description:"The type of generator to include in the list, ex: `fern-typescript-node-sdk`. If omitted, all generators will be listed."}).option("groups",{type:"array",string:!0,description:"The groups to include generators from, if group is not specified, the all generators of the specified type will be listed."}).option("apis",{type:"array",string:!0,description:"The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."}).option("api-fallback",{string:!0,description:"The APIs to list the generators for. If not specified, the generator will be upgraded for all APIs."}).option("include-mode",{choices:Object.values(KGa),type:"array",description:"The generator output modes to include within the outputted list."}).option("exclude-mode",{choices:Object.values(KGa),type:"array",description:"The generator output modes to exclude within the outputted list."}),async i=>{await t.instrumentPostHogEvent({command:"fern generator list",properties:{outputLocation:i.output}}),await _aS({project:await jm(t,{commandLineApiWorkspace:void 0,defaultToAllApiWorkspaces:!0}),generatorFilter:i.generators?new Set(i.generators):void 0,groupFilter:i.groups?new Set(i.groups):void 0,apiFilter:i.apis?new Set(i.apis):void 0,apiKeyFallback:i.apiFallback,cliContext:t,outputLocation:i.output,includedModes:i["include-mode"]?new Set(i["include-mode"]):void 0,excludedModes:i["exclude-mode"]?new Set(i["exclude-mode"]):void 0})}).command("upgrade",`Upgrades the specified generator in ${xM} to the latest stable version.`,i=>i.option("generator",{string:!0,description:"The type of generator to upgrade, ex: `fern-typescript-node-sdk`."}).option("group",{string:!0,description:"The group in which the generator is located, if group is not specified, the all generators of the specified type will be upgraded."}).option("api",{string:!0,description:"The API to upgrade the generator for. If not specified, the generator will be upgraded for all APIs."}).option("yes",{alias:"y",boolean:!0,default:!1,description:"Automatically answer yes to any prompts that may appear during the upgrade process."}).option("include-major",{boolean:!0,default:!1,description:"Whether or not to include major versions within the upgrade. Defaults to false, meaning major versions will be skipped."}).option("channel",{demandOption:!1,choices:Object.values(PaS.FernRegistry.generators.ReleaseType)}).option("list",{demandOption:!1,boolean:!0,default:!1,description:"When specified, a list of available upgrades will be displayed, but no upgrade will be taken."}),async i=>{await t.instrumentPostHogEvent({command:"fern generator upgrade",properties:{generator:i.generator,version:i.version,api:i.api,group:i.group,includeMajor:i.includeMajor,rc:i.rc}});let n=await jm(t,{commandLineApiWorkspace:i.api,defaultToAllApiWorkspaces:!0});if(i.list){t.suppressUpgradeMessage();let a=await h_c({cliContext:t,project:n,generatorFilter:i.generator,groupFilter:i.group,includeMajor:i.includeMajor,channel:i.channel}),o=await ZTp({generatorUpgradeInfo:a,header:`Generator Upgrades
|
|
2438
2438
|
`,includeBoxen:!0});o!=null&&t.logger.info(o)}else await AaS({cliContext:t,generator:i.generator,group:i.group,project:await jm(t,{commandLineApiWorkspace:i.api,defaultToAllApiWorkspaces:!0}),includeMajor:i.includeMajor,channel:i.channel})}).command("get",!1,i=>i.option("output",{string:!0,alias:"o",description:"The location to output the list as a text file, defaults to standard out."}).option("generator",{string:!0,demandOption:!0,description:"The name of the generator to get, ex: `fern-typescript-node-sdk`."}).option("group",{string:!0,demandOption:!0,description:"The group in which the generator is located."}).option("api",{string:!0,description:"The API in which the generator is located."}).option("version",{boolean:!0,default:!1,description:"Get the version of the specified generator."}).option("language",{boolean:!0,default:!1,description:"Get the language of the specified generator."}).option("repository",{boolean:!0,default:!1,description:"Get repository for the generator invocation, if one is specified."}),async i=>{await t.instrumentPostHogEvent({command:"fern generator get",properties:{generator:i.generator,version:i.version,api:i.api,group:i.group,includeMajor:i.includeMajor}});let n=await haS({cliContext:t,generatorFilter:i.generator,groupFilter:i.group,apiFilter:i.api,project:await jm(t,{commandLineApiWorkspace:i.api,defaultToAllApiWorkspaces:!0})});if(n==null){let o=i.api?` for API ${i.api}`:"";t.failAndThrow(`Generator ${i.generator}, in group ${i.group}${o} was not found.`)}let a={};if(i.version&&(a.version=n.version,i.output==null)){process.stdout.write(n.version);return}if(i.language)if(n.language!=null){if(a.language=n.language,i.output==null){process.stdout.write(n.language);return}}else t.logger.warn(`Language information is not available for generator ${n.name} in group ${i.group}`);if(i.repository){let o=n.outputMode.type==="github"?n.outputMode.repo:n.outputMode.type==="githubV2"?n.outputMode.githubV2.repo:void 0;if(o!=null){if(a.repository=o,i.output==null){process.stdout.write(a.repository);return}}else t.logger.warn(`Repository information is not available for generator ${n.name} in group ${i.group}`)}if(i.output)try{await(0,jaS.writeFile)(i.output,JSON.stringify(a,null,2))}catch(o){t.failAndThrow(`Could not write file to the specified location: ${i.output}`,o)}})})}var SaS=require("fs/promises");async function MaS({project:{apiWorkspaces:e},generatorName:t,groupName:r,cliContext:i}){await Promise.all(e.map(async n=>{await i.runTaskForWorkspace(n,async a=>{let o=await qya({absolutePathToWorkspace:n.absoluteFilePath,context:a})??{},c=await frl({generatorName:t,generatorsConfiguration:o,groupName:r,context:a,cliVersion:i.environment.packageVersion}),d=n.generatorsConfiguration?.absolutePathToConfiguration??await len({absolutePathToWorkspace:n.absoluteFilePath});d!=null&&(await(0,SaS.writeFile)(d,`# yaml-language-server: $schema=https://schema.buildwithfern.dev/generators-yml.json
|
|
2439
|
-
`+qi.dump(c)),a.logger.info(Ot.green(`Added ${t} generator`)))})}))}var BaS=require("fs/promises"),IaS=se(OX(),1);async function CaS({context:e,from:t,to:r,fromVersion:i,generatorVersions:n}){let a=new Yka,o=VR5(await a.check({from:await DaS({context:e,filepath:t,flagName:"from"}),to:await DaS({context:e,filepath:r,flagName:"to"})})),c=GR5(e,n),{bump:d,errors:s}=WR5(o,c);if(i==null)return{bump:d??"patch",errors:s};if(d==="no_change")return{bump:"no_change",nextVersion:i,errors:s};let u=d??"patch",f=IaS.default.inc(i,u);if(!f)throw e.failWithoutThrowing(`Invalid current version: ${i}`),new yS;return{bump:u,nextVersion:f,errors:s}}async function DaS({context:e,filepath:t,flagName:r}){let i=mr.of(xo(OO(),t));if(!await ni(i,"file"))throw e.failWithoutThrowing(`File not found: ${i}`),new yS;let n=await(0,BaS.readFile)(i,"utf-8"),a=sa.IntermediateRepresentation.parse(JSON.parse(n));if(!a.ok)throw e.failWithoutThrowing(`Invalid --${r}; expected a filepath containing a valid IR`),new yS;return a.value}function VR5(e){return{bump:e.bump,errors:e.errors.map(t=>t.message)}}function WR5(e,t){return{bump:xR5(e.bump,t.bump),errors:[...e.errors,...t.errors]}}function xR5(e,t){if(!(e===void 0&&t===void 0))return e==="no_change"&&(t===void 0||t==="no_change")||t==="no_change"&&(e===void 0||e==="no_change")?"no_change":e===void 0?t:t===void 0?e:e==="no_change"?t:t==="no_change"?e:e==="major"||t==="major"?"major":e==="minor"||t==="minor"?"minor":"patch"}function GR5(e,t){if(t===void 0)return{bump:void 0,errors:[]};let{from:r,to:i}=t;try{let n=HR5(HAc(r,i)),a=[];return n==="major"&&a.push("Generator version changed by major version."),{bump:n,errors:a}}catch(n){throw e.failWithoutThrowing(`Error diffing generator versions ${r} and ${i}: ${n}`),new yS}}function HR5(e){if(e!==null)switch(e){case"major":case"minor":case"patch":return e;default:return}}bE();var KdS=se(nRp(),1),$dS=se(nhc(),1),Fhc=require("fs/promises"),JdS=se(require("http"),1),YdS=se(require("path"),1);var MlS=require("events"),chc=se(require("fs"),1),Mra=se(require("path"),1);var llS=se(require("os"),1),flS=300,Wbn=20,c8o=1e7,dlS=llS.default.platform();var iV5=dlS==="darwin",Pzp=dlS==="win32",xbn=iV5||Pzp,plS=3e3,_lS=2e4,jzp=1250;var $Li;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})($Li||($Li={}));var Sra;(function(e){e.CHANGE="change",e.RENAME="rename"})(Sra||(Sra={}));var l8o;(function(e){e.CHANGE="change",e.ERROR="error"})(l8o||(l8o={}));var Rf;(function(e){e.ADD="add",e.ADD_DIR="addDir",e.CHANGE="change",e.RENAME="rename",e.RENAME_DIR="renameDir",e.UNLINK="unlink",e.UNLINK_DIR="unlinkDir"})(Rf||(Rf={}));var oX;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(oX||(oX={}));var nV5=(e,t=1,r)=>{t=Math.max(1,t);let i=r?.leading??!1,n=r?.trailing??!0,a=Math.max(r?.maxWait??1/0,t),o,c,d=0,s=0,u=()=>{let g=Date.now(),A=g-d,j=g-s,M=A>=t||j>=a;return[g,M]},f=g=>{if(s=g,!o)return;let A=o;o=void 0,e.apply(void 0,A)},p=()=>{O(0)},_=()=>{c&&(p(),f(Date.now()))},h=g=>{if(s=g,i)return f(g)},y=g=>{if(n&&o)return f(g);o=void 0},b=()=>{c=void 0;let[g,A]=u();return A?y(g):v(g)},v=g=>{let A=g-d,j=g-s,M=t-A,w=a-j,E=Math.min(M,w);return O(E)},O=g=>{c&&clearTimeout(c),!(g<=0)&&(c=setTimeout(b,g))},m=(...g)=>{let[A,j]=u(),M=!!c;if(o=g,d=A,(j||!c)&&O(t),j)return M?f(A):h(A)};return m.cancel=p,m.flush=_,m},ahc=nV5;var Mzp=se(require("fs"),1),uhc=se(require("path"),1);var jA=se(require("fs"),1),Vx=require("util");var uJi=(e,t)=>function(...i){return e.apply(void 0,i).catch(t)},JLi=(e,t)=>function(...i){try{return e.apply(void 0,i)}catch(n){return t(n)}};var wzp=se(require("process"),1),hlS=wzp.default.getuid?!wzp.default.getuid():!1,ylS=1e4,VOe=()=>{};var f8o={isChangeErrorOk:e=>{if(!f8o.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!hlS&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!f8o.isNodeError(e))return!1;let{code:t}=e;return t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM"},onChangeError:e=>{if(!f8o.isNodeError(e))throw e;if(!f8o.isChangeErrorOk(e))throw e}},TT=f8o;var Ezp=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=ylS,this.queueActive=new Set,this.queueWaiting=new Set,this.init=()=>{this.intervalId||(this.intervalId=setInterval(this.tick,this.interval))},this.reset=()=>{this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId)},this.add=t=>{this.queueWaiting.add(t),this.queueActive.size<this.limit/2?this.tick():this.init()},this.remove=t=>{this.queueWaiting.delete(t),this.queueActive.delete(t)},this.schedule=()=>new Promise(t=>{let r=()=>this.remove(i),i=()=>t(r);this.add(i)}),this.tick=()=>{if(!(this.queueActive.size>=this.limit)){if(!this.queueWaiting.size)return this.reset();for(let t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t),this.queueActive.add(t),t()}}}}},blS=new Ezp;var sJi=(e,t)=>function(i){return function n(...a){return blS.schedule().then(o=>{let c=s=>(o(),s),d=s=>{if(o(),Date.now()>=i)throw s;if(t(s)){let u=Math.round(100*Math.random());return new Promise(p=>setTimeout(p,u)).then(()=>n.apply(void 0,a))}throw s};return e.apply(void 0,a).then(c,d)})}},cJi=(e,t)=>function(i){return function n(...a){try{return e.apply(void 0,a)}catch(o){if(Date.now()>i)throw o;if(t(o))return n.apply(void 0,a);throw o}}};var aV5={attempt:{chmod:uJi((0,Vx.promisify)(jA.default.chmod),TT.onChangeError),chown:uJi((0,Vx.promisify)(jA.default.chown),TT.onChangeError),close:uJi((0,Vx.promisify)(jA.default.close),VOe),fsync:uJi((0,Vx.promisify)(jA.default.fsync),VOe),mkdir:uJi((0,Vx.promisify)(jA.default.mkdir),VOe),realpath:uJi((0,Vx.promisify)(jA.default.realpath),VOe),stat:uJi((0,Vx.promisify)(jA.default.stat),VOe),unlink:uJi((0,Vx.promisify)(jA.default.unlink),VOe),chmodSync:JLi(jA.default.chmodSync,TT.onChangeError),chownSync:JLi(jA.default.chownSync,TT.onChangeError),closeSync:JLi(jA.default.closeSync,VOe),existsSync:JLi(jA.default.existsSync,VOe),fsyncSync:JLi(jA.default.fsync,VOe),mkdirSync:JLi(jA.default.mkdirSync,VOe),realpathSync:JLi(jA.default.realpathSync,VOe),statSync:JLi(jA.default.statSync,VOe),unlinkSync:JLi(jA.default.unlinkSync,VOe)},retry:{close:sJi((0,Vx.promisify)(jA.default.close),TT.isRetriableError),fsync:sJi((0,Vx.promisify)(jA.default.fsync),TT.isRetriableError),open:sJi((0,Vx.promisify)(jA.default.open),TT.isRetriableError),readFile:sJi((0,Vx.promisify)(jA.default.readFile),TT.isRetriableError),rename:sJi((0,Vx.promisify)(jA.default.rename),TT.isRetriableError),stat:sJi((0,Vx.promisify)(jA.default.stat),TT.isRetriableError),write:sJi((0,Vx.promisify)(jA.default.write),TT.isRetriableError),writeFile:sJi((0,Vx.promisify)(jA.default.writeFile),TT.isRetriableError),closeSync:cJi(jA.default.closeSync,TT.isRetriableError),fsyncSync:cJi(jA.default.fsyncSync,TT.isRetriableError),openSync:cJi(jA.default.openSync,TT.isRetriableError),readFileSync:cJi(jA.default.readFileSync,TT.isRetriableError),renameSync:cJi(jA.default.renameSync,TT.isRetriableError),statSync:cJi(jA.default.statSync,TT.isRetriableError),writeSync:cJi(jA.default.writeSync,TT.isRetriableError),writeFileSync:cJi(jA.default.writeFileSync,TT.isRetriableError)}},vlS=aV5;var ohc=se(require("fs"),1),d8o=se(require("path"),1);var Szp=()=>{};var oV5=()=>{let e=Szp,t=Szp,r=!1,i=!1;return{promise:new Promise((d,s)=>{e=u=>(r=!0,d(u)),t=u=>(i=!0,s(u))}),resolve:e,reject:t,isPending:()=>!r&&!i,isResolved:()=>r,isRejected:()=>i}},glS=oV5;var uV5=()=>{let{promise:e,resolve:t,isPending:r}=glS(),i=0,n=()=>{i+=1},a=()=>{i-=1,!i&&t()};return n(),queueMicrotask(a),{promise:e,isPending:r,increment:n,decrement:a}},OlS=uV5;var mlS={then:e=>{e()}};var AlS=e=>Array.isArray(e)?e:[e],PlS=e=>typeof e=="function";var sV5=(e,t)=>{let r=t?.followSymlinks??!1,i=t?.depth??1/0,n=t?.limit??1/0,a=t?.ignore??[],o=AlS(a).map(Q=>PlS(Q)?Q:U=>Q.test(U)),c=Q=>o.some(U=>U(Q)),d=t?.signal??{aborted:!1},s=t?.onDirents||(()=>{}),u=[],f=new Set,p={},_=[],h=new Set,y={},b=[],v=new Set,O={},m={},g=new Set,A={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},j={directories:u,directoriesNames:f,directoriesNamesToPaths:p,files:_,filesNames:h,filesNamesToPaths:y,symlinks:b,symlinksNames:v,symlinksNamesToPaths:O,map:m},{promise:M,increment:w,decrement:E}=OlS(),B=0,q=(Q,U,ce,ae)=>{g.has(U)||B>=n||(B+=1,Q.directories.push(U),Q.directoriesNames.add(ce),u.push(U),f.add(ce),p.propertyIsEnumerable(ce)||(p[ce]=[]),p[ce].push(U),g.add(U),!(ae>=i)&&(B>=n||W(U,ae+1)))},R=(Q,U,ce)=>{g.has(U)||B>=n||(B+=1,Q.files.push(U),Q.filesNames.add(ce),_.push(U),h.add(ce),y.propertyIsEnumerable(ce)||(y[ce]=[]),y[ce].push(U),g.add(U))},T=(Q,U,ce,ae)=>{g.has(U)||B>=n||(B+=1,Q.symlinks.push(U),Q.symlinksNames.add(ce),b.push(U),v.add(ce),O.propertyIsEnumerable(ce)||(O[ce]=[]),O[ce].push(U),g.add(U),r&&(ae>=i||B>=n||Oe(U,ae+1)))},K=(Q,U,ce,ae,fe)=>{d.aborted||c(U)||(ae.isDirectory()?q(Q,U,ce,fe):ae.isFile()?R(Q,U,ce):ae.isSymbolicLink()&&T(Q,U,ce,fe))},H=(Q,U,ce,ae)=>{if(d.aborted)return;let fe=U===d8o.default.sep?"":d8o.default.sep,ve=ce.name,re=`${U}${fe}${ve}`;c(re)||(ce.isDirectory()?q(Q,re,ve,ae):ce.isFile()?R(Q,re,ve):ce.isSymbolicLink()&&T(Q,re,ve,ae))},z=(Q,U,ce,ae)=>{for(let fe=0,ve=ce.length;fe<ve;fe++)H(Q,U,ce[fe],ae)},W=(Q,U)=>{d.aborted||U>i||B>=n||(w(),ohc.default.readdir(Q,{withFileTypes:!0},(ce,ae)=>{if(ce||d.aborted||!ae.length)return E();(s(ae)||mlS).then(()=>{let ve=m[Q]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};z(ve,Q,ae,U),E()})}))},Oe=(Q,U)=>{w(),ohc.default.realpath(Q,(ce,ae)=>{if(ce||d.aborted)return E();ohc.default.stat(ae,(fe,ve)=>{if(fe||d.aborted)return E();let re=d8o.default.basename(ae),X=m[Q]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};K(X,ae,re,ve,U),E()})})};return(async(Q,U=1)=>(Q=d8o.default.normalize(Q),g.add(Q),W(Q,U),await M,d.aborted?A:j))(e)},jlS=sV5;var YLi={lang:{debounce:ahc,attempt:e=>{try{return e()}catch(t){return YLi.lang.castError(t)}},castArray:e=>YLi.lang.isArray(e)?e:[e],castError:e=>YLi.lang.isError(e)?e:YLi.lang.isString(e)?new Error(e):new Error("Unknown error"),defer:e=>setTimeout(e,0),isArray:e=>Array.isArray(e),isError:e=>e instanceof Error,isFunction:e=>typeof e=="function",isNaN:e=>Number.isNaN(e),isNumber:e=>typeof e=="number",isPrimitive:e=>{if(e===null)return!0;let t=typeof e;return t!=="object"&&t!=="function"},isShallowEqual:(e,t)=>{if(e===t)return!0;if(YLi.lang.isNaN(e))return YLi.lang.isNaN(t);if(YLi.lang.isPrimitive(e)||YLi.lang.isPrimitive(t))return e===t;for(let r in e)if(!(r in t))return!1;for(let r in t)if(e[r]!==t[r])return!1;return!0},isSet:e=>e instanceof Set,isString:e=>typeof e=="string",isUndefined:e=>e===void 0,noop:()=>{},uniq:e=>e.length<2?e:Array.from(new Set(e))},fs:{getDepth:e=>Math.max(0,e.split(uhc.default.sep).length-1),getRealPath:(e,t)=>{try{return t?Mzp.default.realpathSync.native(e):Mzp.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===uhc.default.sep&&t.length-e.length>uhc.default.sep.length,poll:(e,t=_lS)=>vlS.retry.stat(t)(e,{bigint:!0}).catch(YLi.lang.noop),readdir:async(e,t,r=1/0,i=1/0,n,a)=>{if(a&&r===1&&e in a){let o=a[e];return[o.directories,o.files]}else{let o=await jlS(e,{depth:r,limit:i,ignore:t,signal:n});return[o.directories,o.files]}}}},Mh=YLi;var shc=se(require("path"),1);var Dzp=class{constructor(t,r,i){this.base=i,this.watcher=t,this.handler=r.handler,this.fswatcher=r.watcher,this.options=r.options,this.folderPath=r.folderPath,this.filePath=r.filePath,this.handlerBatched=this.base?this.base.onWatcherEvent.bind(this.base):this._makeHandlerBatched(this.options.debounce)}_isSubRoot(t){return this.filePath?t===this.filePath:t===this.folderPath||Mh.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=flS){return(()=>{let r=this.watcher._readyWait,i=[],n=new Set,a=async(c,d)=>{let s=this.options.ignoreInitial?[]:c,u=await this.eventsPopulate([...d]),f=this.eventsDeduplicate([...s,...u]);this.onTargetEvents(f)},o=Mh.lang.debounce(()=>{this.watcher.isClosed()||(r=a(i,n),i=[],n=new Set)},t);return async(c,d="",s=!1)=>{s?await this.eventsPopulate([d],i,!0):n.add(d),r.then(o)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((i,n)=>{let[a,o]=n,c=r[o];return a===c||a===Rf.CHANGE&&c===Rf.ADD||(r[o]=a,i.push(n)),i},[])}async eventsPopulate(t,r=[],i=!1){return await Promise.all(t.map(async n=>{let a=await this.watcher._poller.update(n,this.options.pollingTimeout);await Promise.all(a.map(async o=>{r.push([o,n]),o===Rf.ADD_DIR?await this.eventsPopulateAddDir(t,n,r,i):o===Rf.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,n,r,i)}))})),r}async eventsPopulateAddDir(t,r,i=[],n=!1){if(n)return i;let a=this.options.recursive?this.options.depth??Wbn:Math.min(1,this.options.depth??Wbn),o=this.options.limit??c8o,[c,d]=await Mh.fs.readdir(r,this.options.ignore,a,o,this.watcher._closeSignal),s=[...c,...d];return await Promise.all(s.map(u=>{if(!this.watcher.isIgnored(u,this.options.ignore)&&!t.includes(u))return this.eventsPopulate([u],i,!0)})),i}async eventsPopulateUnlinkDir(t,r,i=[],n=!1){if(n)return i;for(let a of this.watcher._poller.stats.keys())Mh.fs.isSubPath(r,a)&&(t.includes(a)||await this.eventsPopulate([a],i,!0));return i}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(Rf.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!xbn&&this.options.native!==!1&&this.watcher.watchDirectory(t,this.options,this.handler,void 0,this.base||this),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAddDir(t,this.options.renameTimeout):this.watcher.event(Rf.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(Rf.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(shc.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(Rf.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(shc.default.dirname(t),t,!1),this.watcher.watchersClose(t),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlinkDir(t,this.options.renameTimeout):this.watcher.event(Rf.UNLINK_DIR,t))}onTargetEvent(t){let[r,i]=t;r===Rf.ADD?this.onTargetAdd(i):r===Rf.ADD_DIR?this.onTargetAddDir(i):r===Rf.CHANGE?this.onTargetChange(i):r===Rf.UNLINK?this.onTargetUnlink(i):r===Rf.UNLINK_DIR&&this.onTargetUnlinkDir(i)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,i=!1){return this.handlerBatched(t,r,i)}onWatcherChange(t=Sra.CHANGE,r){if(this.watcher.isClosed())return;let i=shc.default.resolve(this.folderPath,r||"");this.filePath&&i!==this.folderPath&&i!==this.filePath||this.watcher.isIgnored(i,this.options.ignore)||this.onWatcherEvent(t,i)}onWatcherError(t){Pzp&&t.code==="EPERM"?this.onWatcherChange(Sra.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(l8o.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(l8o.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(Sra.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&xbn&&this.options.native!==!1?this.options.depth??Wbn:Math.min(1,this.options.depth??Wbn),i=this.options.limit??c8o,[n,a]=await Mh.fs.readdir(this.folderPath,this.options.ignore,r,i,this.watcher._closeSignal,this.options.readdirMap),o=[this.folderPath,...n,...a];await Promise.all(o.map(c=>{if(!this.watcher._poller.stats.has(c)&&!this.watcher.isIgnored(c,this.options.ignore))return this.onWatcherEvent(Sra.CHANGE,c,t)}))}}},wlS=Dzp;var uX={interval:100,intervalId:void 0,fns:new Map,init:()=>{uX.intervalId||(uX.intervalId=setInterval(uX.resolve,uX.interval))},reset:()=>{uX.intervalId&&(clearInterval(uX.intervalId),delete uX.intervalId)},add:(e,t)=>{uX.fns.set(e,Date.now()+t),uX.init()},remove:e=>{uX.fns.delete(e)},resolve:()=>{if(!uX.fns.size)return uX.reset();let e=Date.now();for(let[t,r]of uX.fns)r>=e||(uX.remove(t),t())}},p8o=uX;var _8o=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=jzp){let{ino:i,targetPath:n,events:a,locks:o}=t,c=()=>{let f=this._watcher._poller.paths.find(i||-1,p=>p!==n);if(f&&f!==n){if(Mh.fs.getRealPath(n,!0)===f)return;this._watcher.event(a.rename,f,n)}else this._watcher.event(a.add,n)};if(!i)return c();let d=()=>{o.add.delete(i),p8o.remove(s)},s=()=>{d(),c()};p8o.add(s,r);let u=()=>{let f=o.unlink.get(i);if(!f)return;d();let p=f();n===p?a.change&&this._watcher._poller.stats.has(n)&&this._watcher.event(a.change,n):this._watcher.event(a.rename,p,n)};o.add.set(i,u),u()}getLockUnlink(t,r=jzp){let{ino:i,targetPath:n,events:a,locks:o}=t,c=()=>{this._watcher.event(a.unlink,n)};if(!i)return c();let d=()=>{o.unlink.delete(i),p8o.remove(s)},s=()=>{d(),c()};p8o.add(s,r);let u=()=>(d(),n);o.unlink.set(i,u),o.add.get(i)?.()}getLockTargetAdd(t,r){let i=this._watcher._poller.getIno(t,Rf.ADD,$Li.FILE);return this.getLockAdd({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let i=this._watcher._poller.getIno(t,Rf.ADD_DIR,$Li.DIR);return this.getLockAdd({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let i=this._watcher._poller.getIno(t,Rf.UNLINK,$Li.FILE);return this.getLockUnlink({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let i=this._watcher._poller.getIno(t,Rf.UNLINK_DIR,$Li.DIR);return this.getLockUnlink({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}reset(){this._locksAdd=new Map,this._locksAddDir=new Map,this._locksUnlink=new Map,this._locksUnlinkDir=new Map,this._locksDir={add:this._locksAddDir,unlink:this._locksUnlinkDir},this._locksFile={add:this._locksAdd,unlink:this._locksUnlink}}};_8o.DIR_EVENTS={add:Rf.ADD_DIR,rename:Rf.RENAME_DIR,unlink:Rf.UNLINK_DIR};_8o.FILE_EVENTS={add:Rf.ADD,change:Rf.CHANGE,rename:Rf.RENAME,unlink:Rf.UNLINK};var ElS=_8o;var Bzp=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(Mh.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let i=this.map.get(t);if(Mh.lang.isSet(i)){let n=i.delete(r);return i.size||this.map.delete(t),n}else if(i===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let i=this.map.get(t);if(Mh.lang.isSet(i))return Array.from(i).find(r);if(r(i))return i}}get(t){return this.map.get(t)}has(t,r){if(Mh.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let i=this.map.get(t);return Mh.lang.isSet(i)?i.has(r):i===r}return!1}set(t,r){if(this.map.has(t)){let i=this.map.get(t);Mh.lang.isSet(i)?i.add(r):i!==r&&this.map.set(t,new Set([i,r]))}else this.map.set(t,r);return this}},Izp=Bzp;var Czp=class{constructor(t){this.ino=t.ino<=Number.MAX_SAFE_INTEGER?Number(t.ino):t.ino,this.size=Number(t.size),this.atimeMs=Number(t.atimeMs),this.mtimeMs=Number(t.mtimeMs),this.ctimeMs=Number(t.ctimeMs),this.birthtimeMs=Number(t.birthtimeMs),this._isFile=t.isFile(),this._isDirectory=t.isDirectory(),this._isSymbolicLink=t.isSymbolicLink()}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isSymbolicLink(){return this._isSymbolicLink}},SlS=Czp;var qzp=class{constructor(){this.inos={},this.paths=new Izp,this.stats=new Map}getIno(t,r,i){let n=this.inos[r];if(!n)return;let a=n[t];if(a&&!(i&&a[1]!==i))return a[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let i=await Mh.fs.poll(t,r);if(!(!i||!(i.isFile()||i.isDirectory())))return new SlS(i)}reset(){this.inos={},this.paths=new Izp,this.stats=new Map}async update(t,r){let i=this.getStats(t),n=await this.poll(t,r);if(this.updateStats(t,n),!i&&n){if(n.isFile())return this.updateIno(t,Rf.ADD,n),[Rf.ADD];if(n.isDirectory())return this.updateIno(t,Rf.ADD_DIR,n),[Rf.ADD_DIR]}else if(i&&!n){if(i.isFile())return this.updateIno(t,Rf.UNLINK,i),[Rf.UNLINK];if(i.isDirectory())return this.updateIno(t,Rf.UNLINK_DIR,i),[Rf.UNLINK_DIR]}else if(i&&n){if(i.isFile()){if(n.isFile())return i.ino===n.ino&&!i.size&&!n.size?[]:(this.updateIno(t,Rf.CHANGE,n),[Rf.CHANGE]);if(n.isDirectory())return this.updateIno(t,Rf.UNLINK,i),this.updateIno(t,Rf.ADD_DIR,n),[Rf.UNLINK,Rf.ADD_DIR]}else if(i.isDirectory()){if(n.isFile())return this.updateIno(t,Rf.UNLINK_DIR,i),this.updateIno(t,Rf.ADD,n),[Rf.UNLINK_DIR,Rf.ADD];if(n.isDirectory())return i.ino===n.ino?[]:(this.updateIno(t,Rf.UNLINK_DIR,i),this.updateIno(t,Rf.ADD_DIR,n),[Rf.UNLINK_DIR,Rf.ADD_DIR])}}return[]}updateIno(t,r,i){let n=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=i.isFile()?$Li.FILE:$Li.DIR;n[t]=[i.ino,a]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let i=this.stats.get(t)?.ino||-1;this.paths.delete(i,t),this.stats.delete(t)}}},Tzp=qzp;var Rzp=class e extends MlS.EventEmitter{constructor(t,r,i){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(oX.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(n=>this.on(oX.CLOSE,n)),this._readyWait=new Promise(n=>this.on(oX.READY,n)),this._locker=new ElS(this),this._roots=new Set,this._poller=new Tzp,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,i)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(Mh.lang.isFunction(r)?!!r(t):r.test(t))}isReady(){return this._ready}close(){return this._locker.reset(),this._poller.reset(),this._roots.clear(),this.watchersClose(),this.isClosed()?!1:(this._closed=!0,this.emit(oX.CLOSE))}error(t){if(this.isClosed())return!1;let r=Mh.lang.castError(t);return this.emit(oX.ERROR,r)}event(t,r,i){return this.isClosed()?!1:(this.emit(oX.ALL,t,r,i),this.emit(t,r,i))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(oX.READY))}pollerExists(t,r){for(let i of this._pollers)if(i.targetPath===t&&Mh.lang.isShallowEqual(i.options,r))return!0;return!1}subwatcherExists(t,r){for(let i of this._subwatchers)if(i.targetPath===t&&Mh.lang.isShallowEqual(i.options,r))return!0;return!1}watchersClose(t,r,i=!0){if(t){let n=this._watchers[t];if(n)for(let a of[...n])r&&a.filePath!==r||this.watcherClose(a);if(i)for(let a in this._watchers)Mh.fs.isSubPath(t,a)&&this.watchersClose(a,r,!1)}else for(let n in this._watchers)this.watchersClose(n,r,!1)}watchersLock(t){return this._watchersLock.then(()=>this._watchersLock=new Promise(async r=>{await t(),r()}))}watchersRestore(){delete this._watchersRestoreTimeout;let t=Object.entries(this._watchersRestorable);this._watchersRestorable={};for(let[r,i]of t)this.watchPath(r,i.options,i.handler)}async watcherAdd(t,r){let{folderPath:i}=t;(this._watchers[i]=this._watchers[i]||[]).push(t);let a=new wlS(this,t,r);return await a.init(),a}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let a=r.indexOf(t);r.splice(a,1),r.length||delete this._watchers[t.folderPath]}let i=t.filePath||t.folderPath;this._roots.has(i)&&(this._watchersRestorable[i]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=Mh.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,i,n){if(this._watchers[t]?.find(c=>c.handler===i&&(!c.filePath||c.filePath===n)&&c.options.ignore===r.ignore&&!!c.options.native==!!r.native&&(!r.recursive||c.options.recursive)))return!0;let o=Mra.default.dirname(t);for(let c=1;c<1/0;c++){if(this._watchers[o]?.find(u=>(c===1||u.options.recursive&&c<=(u.options.depth??Wbn))&&u.handler===i&&(!u.filePath||u.filePath===n)&&u.options.ignore===r.ignore&&!!u.options.native==!!r.native&&(!r.recursive||u.options.recursive&&xbn&&u.options.native!==!1)))return!0;if(!xbn)break;let s=Mra.default.dirname(t);if(o===s)break;o=s}return!1}async watchDirectories(t,r,i,n,a){if(this.isClosed())return;t=Mh.lang.uniq(t).sort();let o;for(let c of t)if(!this.isIgnored(c,r.ignore)&&!this.watcherExists(c,r,i,n))try{let d=!r.recursive||xbn&&r.native!==!1?r:{...r,recursive:!1},u={watcher:chc.default.watch(c,d),handler:i,options:r,folderPath:c,filePath:n},f=o=await this.watcherAdd(u,a);if(this._roots.has(n||c)){let _={...r,ignoreInitial:!0,recursive:!1},h=Mra.default.dirname(c),y=c;await this.watchDirectories([h],_,i,y,f)}}catch(d){this.error(d)}return o}async watchDirectory(t,r,i,n,a){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||xbn&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,i,n,a));{r={...r,recursive:!0};let o=r.depth??Wbn,c=r.limit??c8o,[d]=await Mh.fs.readdir(t,r.ignore,o,c,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let s=await this.watchDirectories([t],r,i,n,a);if(d.length){let u=Mh.fs.getDepth(t);for(let f of d){let p=Mh.fs.getDepth(f),_=Math.max(0,o-(p-u)),h={...r,depth:_};await this.watchDirectories([f],h,i,n,a||s)}}})}}}async watchFileOnce(t,r,i){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let n={targetPath:t,options:r},a=(s,u)=>{u===t&&(d(),i())},o=new e(a),c=()=>{this._subwatchers.add(n),this.on(oX.CLOSE,d),o.watchFile(t,r,a)},d=()=>{this._subwatchers.delete(n),this.removeListener(oX.CLOSE,d),o.close()};return c()}async watchFile(t,r,i){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let n=Mra.default.dirname(t);return this.watchDirectory(n,r,i,t)}async watchPollingOnce(t,r,i){if(this.isClosed())return;let n=!1,a=new Tzp,o=await this.watchPolling(t,r,async()=>{n||!(await a.update(t,r.pollingTimeout)).length||n||(n=!0,o(),i())})}async watchPolling(t,r,i){if(this.isClosed())return Mh.lang.noop;if(this.pollerExists(t,r))return Mh.lang.noop;let n={...r,interval:r.pollingInterval??plS},a={targetPath:t,options:r},o=()=>{this._pollers.add(a),this.on(oX.CLOSE,c),chc.default.watchFile(t,n,i)},c=()=>{this._pollers.delete(a),this.removeListener(oX.CLOSE,c),chc.default.unwatchFile(t,i)};return Mh.lang.attempt(o),()=>Mh.lang.attempt(c)}async watchUnknownChild(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchFileOnce(t,r,n)}async watchUnknownTarget(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchPollingOnce(t,r,n)}async watchPaths(t,r,i){if(this.isClosed())return;if(t=Mh.lang.uniq(t).sort(),t.every((a,o)=>t.every((c,d)=>d===o||!Mh.fs.isSubPath(a,c))))await Promise.all(t.map(a=>this.watchPath(a,r,i)));else for(let a of t)await this.watchPath(a,r,i)}async watchPath(t,r,i){if(this.isClosed()||(t=Mra.default.resolve(t),this.isIgnored(t,r.ignore)))return;let n=await Mh.fs.poll(t,r.pollingTimeout);if(n){if(n.isFile())return this.watchFile(t,r,i);if(n.isDirectory())return this.watchDirectory(t,r,i);this.error(`"${t}" is not supported`)}else{let a=Mra.default.dirname(t);return(await Mh.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,i):this.watchUnknownTarget(t,r,i)}}async watch(t,r,i=Mh.lang.noop){if(Mh.lang.isFunction(t))return this.watch([],{},t);if(Mh.lang.isUndefined(t))return this.watch([],r,i);if(Mh.lang.isFunction(r))return this.watch(t,{},r);if(Mh.lang.isUndefined(r))return this.watch(t,{},i);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let n=Mh.lang.castArray(t);n.forEach(a=>this._roots.add(a)),await this.watchPaths(n,r,i),!this.isClosed()&&(i!==Mh.lang.noop&&this.on(oX.ALL,i),r.readdirMap=void 0,this.ready())}},lhc=Rzp;xlc();var l9a=require("fs/promises"),DlS=require("os"),BlS=se(require("path"),1),cV5=".fern",lV5="logs";function fV5(){return"cli@3.56.0"}var h8o=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=ot(mr.of((0,DlS.homedir)()),Pe.of(cV5)),r=ot(t,Pe.of(lV5));await ni(r)||await(0,l9a.mkdir)(r,{recursive:!0});let n=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=ot(r,Pe.of(n));let a=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${BlS.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
2439
|
+
`+qi.dump(c)),a.logger.info(Ot.green(`Added ${t} generator`)))})}))}var BaS=require("fs/promises"),IaS=se(OX(),1);async function CaS({context:e,from:t,to:r,fromVersion:i,generatorVersions:n}){let a=new Yka,o=VR5(await a.check({from:await DaS({context:e,filepath:t,flagName:"from"}),to:await DaS({context:e,filepath:r,flagName:"to"})})),c=GR5(e,n),{bump:d,errors:s}=WR5(o,c);if(i==null)return{bump:d??"patch",errors:s};if(d==="no_change")return{bump:"no_change",nextVersion:i,errors:s};let u=d??"patch",f=IaS.default.inc(i,u);if(!f)throw e.failWithoutThrowing(`Invalid current version: ${i}`),new yS;return{bump:u,nextVersion:f,errors:s}}async function DaS({context:e,filepath:t,flagName:r}){let i=mr.of(xo(OO(),t));if(!await ni(i,"file"))throw e.failWithoutThrowing(`File not found: ${i}`),new yS;let n=await(0,BaS.readFile)(i,"utf-8"),a=sa.IntermediateRepresentation.parse(JSON.parse(n));if(!a.ok)throw e.failWithoutThrowing(`Invalid --${r}; expected a filepath containing a valid IR`),new yS;return a.value}function VR5(e){return{bump:e.bump,errors:e.errors.map(t=>t.message)}}function WR5(e,t){return{bump:xR5(e.bump,t.bump),errors:[...e.errors,...t.errors]}}function xR5(e,t){if(!(e===void 0&&t===void 0))return e==="no_change"&&(t===void 0||t==="no_change")||t==="no_change"&&(e===void 0||e==="no_change")?"no_change":e===void 0?t:t===void 0?e:e==="no_change"?t:t==="no_change"?e:e==="major"||t==="major"?"major":e==="minor"||t==="minor"?"minor":"patch"}function GR5(e,t){if(t===void 0)return{bump:void 0,errors:[]};let{from:r,to:i}=t;try{let n=HR5(HAc(r,i)),a=[];return n==="major"&&a.push("Generator version changed by major version."),{bump:n,errors:a}}catch(n){throw e.failWithoutThrowing(`Error diffing generator versions ${r} and ${i}: ${n}`),new yS}}function HR5(e){if(e!==null)switch(e){case"major":case"minor":case"patch":return e;default:return}}bE();var KdS=se(nRp(),1),$dS=se(nhc(),1),Fhc=require("fs/promises"),JdS=se(require("http"),1),YdS=se(require("path"),1);var MlS=require("events"),chc=se(require("fs"),1),Mra=se(require("path"),1);var llS=se(require("os"),1),flS=300,Wbn=20,c8o=1e7,dlS=llS.default.platform();var iV5=dlS==="darwin",Pzp=dlS==="win32",xbn=iV5||Pzp,plS=3e3,_lS=2e4,jzp=1250;var $Li;(function(e){e[e.DIR=1]="DIR",e[e.FILE=2]="FILE"})($Li||($Li={}));var Sra;(function(e){e.CHANGE="change",e.RENAME="rename"})(Sra||(Sra={}));var l8o;(function(e){e.CHANGE="change",e.ERROR="error"})(l8o||(l8o={}));var Rf;(function(e){e.ADD="add",e.ADD_DIR="addDir",e.CHANGE="change",e.RENAME="rename",e.RENAME_DIR="renameDir",e.UNLINK="unlink",e.UNLINK_DIR="unlinkDir"})(Rf||(Rf={}));var oX;(function(e){e.ALL="all",e.CLOSE="close",e.ERROR="error",e.READY="ready"})(oX||(oX={}));var nV5=(e,t=1,r)=>{t=Math.max(1,t);let i=r?.leading??!1,n=r?.trailing??!0,a=Math.max(r?.maxWait??1/0,t),o,c,d=0,s=0,u=()=>{let g=Date.now(),A=g-d,j=g-s,M=A>=t||j>=a;return[g,M]},f=g=>{if(s=g,!o)return;let A=o;o=void 0,e.apply(void 0,A)},p=()=>{O(0)},_=()=>{c&&(p(),f(Date.now()))},h=g=>{if(s=g,i)return f(g)},y=g=>{if(n&&o)return f(g);o=void 0},b=()=>{c=void 0;let[g,A]=u();return A?y(g):v(g)},v=g=>{let A=g-d,j=g-s,M=t-A,w=a-j,E=Math.min(M,w);return O(E)},O=g=>{c&&clearTimeout(c),!(g<=0)&&(c=setTimeout(b,g))},m=(...g)=>{let[A,j]=u(),M=!!c;if(o=g,d=A,(j||!c)&&O(t),j)return M?f(A):h(A)};return m.cancel=p,m.flush=_,m},ahc=nV5;var Mzp=se(require("fs"),1),uhc=se(require("path"),1);var jA=se(require("fs"),1),Vx=require("util");var uJi=(e,t)=>function(...i){return e.apply(void 0,i).catch(t)},JLi=(e,t)=>function(...i){try{return e.apply(void 0,i)}catch(n){return t(n)}};var wzp=se(require("process"),1),hlS=wzp.default.getuid?!wzp.default.getuid():!1,ylS=1e4,VOe=()=>{};var f8o={isChangeErrorOk:e=>{if(!f8o.isNodeError(e))return!1;let{code:t}=e;return t==="ENOSYS"||!hlS&&(t==="EINVAL"||t==="EPERM")},isNodeError:e=>e instanceof Error,isRetriableError:e=>{if(!f8o.isNodeError(e))return!1;let{code:t}=e;return t==="EMFILE"||t==="ENFILE"||t==="EAGAIN"||t==="EBUSY"||t==="EACCESS"||t==="EACCES"||t==="EACCS"||t==="EPERM"},onChangeError:e=>{if(!f8o.isNodeError(e))throw e;if(!f8o.isChangeErrorOk(e))throw e}},TT=f8o;var Ezp=class{constructor(){this.interval=25,this.intervalId=void 0,this.limit=ylS,this.queueActive=new Set,this.queueWaiting=new Set,this.init=()=>{this.intervalId||(this.intervalId=setInterval(this.tick,this.interval))},this.reset=()=>{this.intervalId&&(clearInterval(this.intervalId),delete this.intervalId)},this.add=t=>{this.queueWaiting.add(t),this.queueActive.size<this.limit/2?this.tick():this.init()},this.remove=t=>{this.queueWaiting.delete(t),this.queueActive.delete(t)},this.schedule=()=>new Promise(t=>{let r=()=>this.remove(i),i=()=>t(r);this.add(i)}),this.tick=()=>{if(!(this.queueActive.size>=this.limit)){if(!this.queueWaiting.size)return this.reset();for(let t of this.queueWaiting){if(this.queueActive.size>=this.limit)break;this.queueWaiting.delete(t),this.queueActive.add(t),t()}}}}},blS=new Ezp;var sJi=(e,t)=>function(i){return function n(...a){return blS.schedule().then(o=>{let c=s=>(o(),s),d=s=>{if(o(),Date.now()>=i)throw s;if(t(s)){let u=Math.round(100*Math.random());return new Promise(p=>setTimeout(p,u)).then(()=>n.apply(void 0,a))}throw s};return e.apply(void 0,a).then(c,d)})}},cJi=(e,t)=>function(i){return function n(...a){try{return e.apply(void 0,a)}catch(o){if(Date.now()>i)throw o;if(t(o))return n.apply(void 0,a);throw o}}};var aV5={attempt:{chmod:uJi((0,Vx.promisify)(jA.default.chmod),TT.onChangeError),chown:uJi((0,Vx.promisify)(jA.default.chown),TT.onChangeError),close:uJi((0,Vx.promisify)(jA.default.close),VOe),fsync:uJi((0,Vx.promisify)(jA.default.fsync),VOe),mkdir:uJi((0,Vx.promisify)(jA.default.mkdir),VOe),realpath:uJi((0,Vx.promisify)(jA.default.realpath),VOe),stat:uJi((0,Vx.promisify)(jA.default.stat),VOe),unlink:uJi((0,Vx.promisify)(jA.default.unlink),VOe),chmodSync:JLi(jA.default.chmodSync,TT.onChangeError),chownSync:JLi(jA.default.chownSync,TT.onChangeError),closeSync:JLi(jA.default.closeSync,VOe),existsSync:JLi(jA.default.existsSync,VOe),fsyncSync:JLi(jA.default.fsync,VOe),mkdirSync:JLi(jA.default.mkdirSync,VOe),realpathSync:JLi(jA.default.realpathSync,VOe),statSync:JLi(jA.default.statSync,VOe),unlinkSync:JLi(jA.default.unlinkSync,VOe)},retry:{close:sJi((0,Vx.promisify)(jA.default.close),TT.isRetriableError),fsync:sJi((0,Vx.promisify)(jA.default.fsync),TT.isRetriableError),open:sJi((0,Vx.promisify)(jA.default.open),TT.isRetriableError),readFile:sJi((0,Vx.promisify)(jA.default.readFile),TT.isRetriableError),rename:sJi((0,Vx.promisify)(jA.default.rename),TT.isRetriableError),stat:sJi((0,Vx.promisify)(jA.default.stat),TT.isRetriableError),write:sJi((0,Vx.promisify)(jA.default.write),TT.isRetriableError),writeFile:sJi((0,Vx.promisify)(jA.default.writeFile),TT.isRetriableError),closeSync:cJi(jA.default.closeSync,TT.isRetriableError),fsyncSync:cJi(jA.default.fsyncSync,TT.isRetriableError),openSync:cJi(jA.default.openSync,TT.isRetriableError),readFileSync:cJi(jA.default.readFileSync,TT.isRetriableError),renameSync:cJi(jA.default.renameSync,TT.isRetriableError),statSync:cJi(jA.default.statSync,TT.isRetriableError),writeSync:cJi(jA.default.writeSync,TT.isRetriableError),writeFileSync:cJi(jA.default.writeFileSync,TT.isRetriableError)}},vlS=aV5;var ohc=se(require("fs"),1),d8o=se(require("path"),1);var Szp=()=>{};var oV5=()=>{let e=Szp,t=Szp,r=!1,i=!1;return{promise:new Promise((d,s)=>{e=u=>(r=!0,d(u)),t=u=>(i=!0,s(u))}),resolve:e,reject:t,isPending:()=>!r&&!i,isResolved:()=>r,isRejected:()=>i}},glS=oV5;var uV5=()=>{let{promise:e,resolve:t,isPending:r}=glS(),i=0,n=()=>{i+=1},a=()=>{i-=1,!i&&t()};return n(),queueMicrotask(a),{promise:e,isPending:r,increment:n,decrement:a}},OlS=uV5;var mlS={then:e=>{e()}};var AlS=e=>Array.isArray(e)?e:[e],PlS=e=>typeof e=="function";var sV5=(e,t)=>{let r=t?.followSymlinks??!1,i=t?.depth??1/0,n=t?.limit??1/0,a=t?.ignore??[],o=AlS(a).map(Q=>PlS(Q)?Q:U=>Q.test(U)),c=Q=>o.some(U=>U(Q)),d=t?.signal??{aborted:!1},s=t?.onDirents||(()=>{}),u=[],f=new Set,p={},_=[],h=new Set,y={},b=[],v=new Set,O={},m={},g=new Set,A={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{},map:{}},j={directories:u,directoriesNames:f,directoriesNamesToPaths:p,files:_,filesNames:h,filesNamesToPaths:y,symlinks:b,symlinksNames:v,symlinksNamesToPaths:O,map:m},{promise:M,increment:w,decrement:E}=OlS(),B=0,q=(Q,U,ce,ae)=>{g.has(U)||B>=n||(B+=1,Q.directories.push(U),Q.directoriesNames.add(ce),u.push(U),f.add(ce),p.propertyIsEnumerable(ce)||(p[ce]=[]),p[ce].push(U),g.add(U),!(ae>=i)&&(B>=n||W(U,ae+1)))},R=(Q,U,ce)=>{g.has(U)||B>=n||(B+=1,Q.files.push(U),Q.filesNames.add(ce),_.push(U),h.add(ce),y.propertyIsEnumerable(ce)||(y[ce]=[]),y[ce].push(U),g.add(U))},T=(Q,U,ce,ae)=>{g.has(U)||B>=n||(B+=1,Q.symlinks.push(U),Q.symlinksNames.add(ce),b.push(U),v.add(ce),O.propertyIsEnumerable(ce)||(O[ce]=[]),O[ce].push(U),g.add(U),r&&(ae>=i||B>=n||Oe(U,ae+1)))},K=(Q,U,ce,ae,fe)=>{d.aborted||c(U)||(ae.isDirectory()?q(Q,U,ce,fe):ae.isFile()?R(Q,U,ce):ae.isSymbolicLink()&&T(Q,U,ce,fe))},H=(Q,U,ce,ae)=>{if(d.aborted)return;let fe=U===d8o.default.sep?"":d8o.default.sep,ve=ce.name,re=`${U}${fe}${ve}`;c(re)||(ce.isDirectory()?q(Q,re,ve,ae):ce.isFile()?R(Q,re,ve):ce.isSymbolicLink()&&T(Q,re,ve,ae))},z=(Q,U,ce,ae)=>{for(let fe=0,ve=ce.length;fe<ve;fe++)H(Q,U,ce[fe],ae)},W=(Q,U)=>{d.aborted||U>i||B>=n||(w(),ohc.default.readdir(Q,{withFileTypes:!0},(ce,ae)=>{if(ce||d.aborted||!ae.length)return E();(s(ae)||mlS).then(()=>{let ve=m[Q]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};z(ve,Q,ae,U),E()})}))},Oe=(Q,U)=>{w(),ohc.default.realpath(Q,(ce,ae)=>{if(ce||d.aborted)return E();ohc.default.stat(ae,(fe,ve)=>{if(fe||d.aborted)return E();let re=d8o.default.basename(ae),X=m[Q]={directories:[],directoriesNames:new Set,directoriesNamesToPaths:{},files:[],filesNames:new Set,filesNamesToPaths:{},symlinks:[],symlinksNames:new Set,symlinksNamesToPaths:{}};K(X,ae,re,ve,U),E()})})};return(async(Q,U=1)=>(Q=d8o.default.normalize(Q),g.add(Q),W(Q,U),await M,d.aborted?A:j))(e)},jlS=sV5;var YLi={lang:{debounce:ahc,attempt:e=>{try{return e()}catch(t){return YLi.lang.castError(t)}},castArray:e=>YLi.lang.isArray(e)?e:[e],castError:e=>YLi.lang.isError(e)?e:YLi.lang.isString(e)?new Error(e):new Error("Unknown error"),defer:e=>setTimeout(e,0),isArray:e=>Array.isArray(e),isError:e=>e instanceof Error,isFunction:e=>typeof e=="function",isNaN:e=>Number.isNaN(e),isNumber:e=>typeof e=="number",isPrimitive:e=>{if(e===null)return!0;let t=typeof e;return t!=="object"&&t!=="function"},isShallowEqual:(e,t)=>{if(e===t)return!0;if(YLi.lang.isNaN(e))return YLi.lang.isNaN(t);if(YLi.lang.isPrimitive(e)||YLi.lang.isPrimitive(t))return e===t;for(let r in e)if(!(r in t))return!1;for(let r in t)if(e[r]!==t[r])return!1;return!0},isSet:e=>e instanceof Set,isString:e=>typeof e=="string",isUndefined:e=>e===void 0,noop:()=>{},uniq:e=>e.length<2?e:Array.from(new Set(e))},fs:{getDepth:e=>Math.max(0,e.split(uhc.default.sep).length-1),getRealPath:(e,t)=>{try{return t?Mzp.default.realpathSync.native(e):Mzp.default.realpathSync(e)}catch{return}},isSubPath:(e,t)=>t.startsWith(e)&&t[e.length]===uhc.default.sep&&t.length-e.length>uhc.default.sep.length,poll:(e,t=_lS)=>vlS.retry.stat(t)(e,{bigint:!0}).catch(YLi.lang.noop),readdir:async(e,t,r=1/0,i=1/0,n,a)=>{if(a&&r===1&&e in a){let o=a[e];return[o.directories,o.files]}else{let o=await jlS(e,{depth:r,limit:i,ignore:t,signal:n});return[o.directories,o.files]}}}},Mh=YLi;var shc=se(require("path"),1);var Dzp=class{constructor(t,r,i){this.base=i,this.watcher=t,this.handler=r.handler,this.fswatcher=r.watcher,this.options=r.options,this.folderPath=r.folderPath,this.filePath=r.filePath,this.handlerBatched=this.base?this.base.onWatcherEvent.bind(this.base):this._makeHandlerBatched(this.options.debounce)}_isSubRoot(t){return this.filePath?t===this.filePath:t===this.folderPath||Mh.fs.isSubPath(this.folderPath,t)}_makeHandlerBatched(t=flS){return(()=>{let r=this.watcher._readyWait,i=[],n=new Set,a=async(c,d)=>{let s=this.options.ignoreInitial?[]:c,u=await this.eventsPopulate([...d]),f=this.eventsDeduplicate([...s,...u]);this.onTargetEvents(f)},o=Mh.lang.debounce(()=>{this.watcher.isClosed()||(r=a(i,n),i=[],n=new Set)},t);return async(c,d="",s=!1)=>{s?await this.eventsPopulate([d],i,!0):n.add(d),r.then(o)}})()}eventsDeduplicate(t){if(t.length<2)return t;let r={};return t.reduce((i,n)=>{let[a,o]=n,c=r[o];return a===c||a===Rf.CHANGE&&c===Rf.ADD||(r[o]=a,i.push(n)),i},[])}async eventsPopulate(t,r=[],i=!1){return await Promise.all(t.map(async n=>{let a=await this.watcher._poller.update(n,this.options.pollingTimeout);await Promise.all(a.map(async o=>{r.push([o,n]),o===Rf.ADD_DIR?await this.eventsPopulateAddDir(t,n,r,i):o===Rf.UNLINK_DIR&&await this.eventsPopulateUnlinkDir(t,n,r,i)}))})),r}async eventsPopulateAddDir(t,r,i=[],n=!1){if(n)return i;let a=this.options.recursive?this.options.depth??Wbn:Math.min(1,this.options.depth??Wbn),o=this.options.limit??c8o,[c,d]=await Mh.fs.readdir(r,this.options.ignore,a,o,this.watcher._closeSignal),s=[...c,...d];return await Promise.all(s.map(u=>{if(!this.watcher.isIgnored(u,this.options.ignore)&&!t.includes(u))return this.eventsPopulate([u],i,!0)})),i}async eventsPopulateUnlinkDir(t,r,i=[],n=!1){if(n)return i;for(let a of this.watcher._poller.stats.keys())Mh.fs.isSubPath(r,a)&&(t.includes(a)||await this.eventsPopulate([a],i,!0));return i}onTargetAdd(t){this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAdd(t,this.options.renameTimeout):this.watcher.event(Rf.ADD,t))}onTargetAddDir(t){t!==this.folderPath&&this.options.recursive&&!xbn&&this.options.native!==!1&&this.watcher.watchDirectory(t,this.options,this.handler,void 0,this.base||this),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetAddDir(t,this.options.renameTimeout):this.watcher.event(Rf.ADD_DIR,t))}onTargetChange(t){this._isSubRoot(t)&&this.watcher.event(Rf.CHANGE,t)}onTargetUnlink(t){this.watcher.watchersClose(shc.default.dirname(t),t,!1),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlink(t,this.options.renameTimeout):this.watcher.event(Rf.UNLINK,t))}onTargetUnlinkDir(t){this.watcher.watchersClose(shc.default.dirname(t),t,!1),this.watcher.watchersClose(t),this._isSubRoot(t)&&(this.options.renameDetection?this.watcher._locker.getLockTargetUnlinkDir(t,this.options.renameTimeout):this.watcher.event(Rf.UNLINK_DIR,t))}onTargetEvent(t){let[r,i]=t;r===Rf.ADD?this.onTargetAdd(i):r===Rf.ADD_DIR?this.onTargetAddDir(i):r===Rf.CHANGE?this.onTargetChange(i):r===Rf.UNLINK?this.onTargetUnlink(i):r===Rf.UNLINK_DIR&&this.onTargetUnlinkDir(i)}onTargetEvents(t){for(let r of t)this.onTargetEvent(r)}onWatcherEvent(t,r,i=!1){return this.handlerBatched(t,r,i)}onWatcherChange(t=Sra.CHANGE,r){if(this.watcher.isClosed())return;let i=shc.default.resolve(this.folderPath,r||"");this.filePath&&i!==this.folderPath&&i!==this.filePath||this.watcher.isIgnored(i,this.options.ignore)||this.onWatcherEvent(t,i)}onWatcherError(t){Pzp&&t.code==="EPERM"?this.onWatcherChange(Sra.CHANGE,""):this.watcher.error(t)}async init(){await this.initWatcherEvents(),await this.initInitialEvents()}async initWatcherEvents(){let t=this.onWatcherChange.bind(this);this.fswatcher.on(l8o.CHANGE,t);let r=this.onWatcherError.bind(this);this.fswatcher.on(l8o.ERROR,r)}async initInitialEvents(){let t=!this.watcher.isReady();if(this.filePath){if(this.watcher._poller.stats.has(this.filePath))return;await this.onWatcherEvent(Sra.CHANGE,this.filePath,t)}else{let r=this.options.recursive&&xbn&&this.options.native!==!1?this.options.depth??Wbn:Math.min(1,this.options.depth??Wbn),i=this.options.limit??c8o,[n,a]=await Mh.fs.readdir(this.folderPath,this.options.ignore,r,i,this.watcher._closeSignal,this.options.readdirMap),o=[this.folderPath,...n,...a];await Promise.all(o.map(c=>{if(!this.watcher._poller.stats.has(c)&&!this.watcher.isIgnored(c,this.options.ignore))return this.onWatcherEvent(Sra.CHANGE,c,t)}))}}},wlS=Dzp;var uX={interval:100,intervalId:void 0,fns:new Map,init:()=>{uX.intervalId||(uX.intervalId=setInterval(uX.resolve,uX.interval))},reset:()=>{uX.intervalId&&(clearInterval(uX.intervalId),delete uX.intervalId)},add:(e,t)=>{uX.fns.set(e,Date.now()+t),uX.init()},remove:e=>{uX.fns.delete(e)},resolve:()=>{if(!uX.fns.size)return uX.reset();let e=Date.now();for(let[t,r]of uX.fns)r>=e||(uX.remove(t),t())}},p8o=uX;var _8o=class e{constructor(t){this._watcher=t,this.reset()}getLockAdd(t,r=jzp){let{ino:i,targetPath:n,events:a,locks:o}=t,c=()=>{let f=this._watcher._poller.paths.find(i||-1,p=>p!==n);if(f&&f!==n){if(Mh.fs.getRealPath(n,!0)===f)return;this._watcher.event(a.rename,f,n)}else this._watcher.event(a.add,n)};if(!i)return c();let d=()=>{o.add.delete(i),p8o.remove(s)},s=()=>{d(),c()};p8o.add(s,r);let u=()=>{let f=o.unlink.get(i);if(!f)return;d();let p=f();n===p?a.change&&this._watcher._poller.stats.has(n)&&this._watcher.event(a.change,n):this._watcher.event(a.rename,p,n)};o.add.set(i,u),u()}getLockUnlink(t,r=jzp){let{ino:i,targetPath:n,events:a,locks:o}=t,c=()=>{this._watcher.event(a.unlink,n)};if(!i)return c();let d=()=>{o.unlink.delete(i),p8o.remove(s)},s=()=>{d(),c()};p8o.add(s,r);let u=()=>(d(),n);o.unlink.set(i,u),o.add.get(i)?.()}getLockTargetAdd(t,r){let i=this._watcher._poller.getIno(t,Rf.ADD,$Li.FILE);return this.getLockAdd({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetAddDir(t,r){let i=this._watcher._poller.getIno(t,Rf.ADD_DIR,$Li.DIR);return this.getLockAdd({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}getLockTargetUnlink(t,r){let i=this._watcher._poller.getIno(t,Rf.UNLINK,$Li.FILE);return this.getLockUnlink({ino:i,targetPath:t,events:e.FILE_EVENTS,locks:this._locksFile},r)}getLockTargetUnlinkDir(t,r){let i=this._watcher._poller.getIno(t,Rf.UNLINK_DIR,$Li.DIR);return this.getLockUnlink({ino:i,targetPath:t,events:e.DIR_EVENTS,locks:this._locksDir},r)}reset(){this._locksAdd=new Map,this._locksAddDir=new Map,this._locksUnlink=new Map,this._locksUnlinkDir=new Map,this._locksDir={add:this._locksAddDir,unlink:this._locksUnlinkDir},this._locksFile={add:this._locksAdd,unlink:this._locksUnlink}}};_8o.DIR_EVENTS={add:Rf.ADD_DIR,rename:Rf.RENAME_DIR,unlink:Rf.UNLINK_DIR};_8o.FILE_EVENTS={add:Rf.ADD,change:Rf.CHANGE,rename:Rf.RENAME,unlink:Rf.UNLINK};var ElS=_8o;var Bzp=class{constructor(){this.map=new Map}clear(){this.map.clear()}delete(t,r){if(Mh.lang.isUndefined(r))return this.map.delete(t);if(this.map.has(t)){let i=this.map.get(t);if(Mh.lang.isSet(i)){let n=i.delete(r);return i.size||this.map.delete(t),n}else if(i===r)return this.map.delete(t),!0}return!1}find(t,r){if(this.map.has(t)){let i=this.map.get(t);if(Mh.lang.isSet(i))return Array.from(i).find(r);if(r(i))return i}}get(t){return this.map.get(t)}has(t,r){if(Mh.lang.isUndefined(r))return this.map.has(t);if(this.map.has(t)){let i=this.map.get(t);return Mh.lang.isSet(i)?i.has(r):i===r}return!1}set(t,r){if(this.map.has(t)){let i=this.map.get(t);Mh.lang.isSet(i)?i.add(r):i!==r&&this.map.set(t,new Set([i,r]))}else this.map.set(t,r);return this}},Izp=Bzp;var Czp=class{constructor(t){this.ino=t.ino<=Number.MAX_SAFE_INTEGER?Number(t.ino):t.ino,this.size=Number(t.size),this.atimeMs=Number(t.atimeMs),this.mtimeMs=Number(t.mtimeMs),this.ctimeMs=Number(t.ctimeMs),this.birthtimeMs=Number(t.birthtimeMs),this._isFile=t.isFile(),this._isDirectory=t.isDirectory(),this._isSymbolicLink=t.isSymbolicLink()}isFile(){return this._isFile}isDirectory(){return this._isDirectory}isSymbolicLink(){return this._isSymbolicLink}},SlS=Czp;var qzp=class{constructor(){this.inos={},this.paths=new Izp,this.stats=new Map}getIno(t,r,i){let n=this.inos[r];if(!n)return;let a=n[t];if(a&&!(i&&a[1]!==i))return a[0]}getStats(t){return this.stats.get(t)}async poll(t,r){let i=await Mh.fs.poll(t,r);if(!(!i||!(i.isFile()||i.isDirectory())))return new SlS(i)}reset(){this.inos={},this.paths=new Izp,this.stats=new Map}async update(t,r){let i=this.getStats(t),n=await this.poll(t,r);if(this.updateStats(t,n),!i&&n){if(n.isFile())return this.updateIno(t,Rf.ADD,n),[Rf.ADD];if(n.isDirectory())return this.updateIno(t,Rf.ADD_DIR,n),[Rf.ADD_DIR]}else if(i&&!n){if(i.isFile())return this.updateIno(t,Rf.UNLINK,i),[Rf.UNLINK];if(i.isDirectory())return this.updateIno(t,Rf.UNLINK_DIR,i),[Rf.UNLINK_DIR]}else if(i&&n){if(i.isFile()){if(n.isFile())return i.ino===n.ino&&!i.size&&!n.size?[]:(this.updateIno(t,Rf.CHANGE,n),[Rf.CHANGE]);if(n.isDirectory())return this.updateIno(t,Rf.UNLINK,i),this.updateIno(t,Rf.ADD_DIR,n),[Rf.UNLINK,Rf.ADD_DIR]}else if(i.isDirectory()){if(n.isFile())return this.updateIno(t,Rf.UNLINK_DIR,i),this.updateIno(t,Rf.ADD,n),[Rf.UNLINK_DIR,Rf.ADD];if(n.isDirectory())return i.ino===n.ino?[]:(this.updateIno(t,Rf.UNLINK_DIR,i),this.updateIno(t,Rf.ADD_DIR,n),[Rf.UNLINK_DIR,Rf.ADD_DIR])}}return[]}updateIno(t,r,i){let n=this.inos[r]=this.inos[r]||(this.inos[r]={}),a=i.isFile()?$Li.FILE:$Li.DIR;n[t]=[i.ino,a]}updateStats(t,r){if(r)this.paths.set(r.ino,t),this.stats.set(t,r);else{let i=this.stats.get(t)?.ino||-1;this.paths.delete(i,t),this.stats.delete(t)}}},Tzp=qzp;var Rzp=class e extends MlS.EventEmitter{constructor(t,r,i){super(),this._closed=!1,this._ready=!1,this._closeAborter=new AbortController,this._closeSignal=this._closeAborter.signal,this.on(oX.CLOSE,()=>this._closeAborter.abort()),this._closeWait=new Promise(n=>this.on(oX.CLOSE,n)),this._readyWait=new Promise(n=>this.on(oX.READY,n)),this._locker=new ElS(this),this._roots=new Set,this._poller=new Tzp,this._pollers=new Set,this._subwatchers=new Set,this._watchers={},this._watchersLock=Promise.resolve(),this._watchersRestorable={},this.watch(t,r,i)}isClosed(){return this._closed}isIgnored(t,r){return!!r&&(Mh.lang.isFunction(r)?!!r(t):r.test(t))}isReady(){return this._ready}close(){return this._locker.reset(),this._poller.reset(),this._roots.clear(),this.watchersClose(),this.isClosed()?!1:(this._closed=!0,this.emit(oX.CLOSE))}error(t){if(this.isClosed())return!1;let r=Mh.lang.castError(t);return this.emit(oX.ERROR,r)}event(t,r,i){return this.isClosed()?!1:(this.emit(oX.ALL,t,r,i),this.emit(t,r,i))}ready(){return this.isClosed()||this.isReady()?!1:(this._ready=!0,this.emit(oX.READY))}pollerExists(t,r){for(let i of this._pollers)if(i.targetPath===t&&Mh.lang.isShallowEqual(i.options,r))return!0;return!1}subwatcherExists(t,r){for(let i of this._subwatchers)if(i.targetPath===t&&Mh.lang.isShallowEqual(i.options,r))return!0;return!1}watchersClose(t,r,i=!0){if(t){let n=this._watchers[t];if(n)for(let a of[...n])r&&a.filePath!==r||this.watcherClose(a);if(i)for(let a in this._watchers)Mh.fs.isSubPath(t,a)&&this.watchersClose(a,r,!1)}else for(let n in this._watchers)this.watchersClose(n,r,!1)}watchersLock(t){return this._watchersLock.then(()=>this._watchersLock=new Promise(async r=>{await t(),r()}))}watchersRestore(){delete this._watchersRestoreTimeout;let t=Object.entries(this._watchersRestorable);this._watchersRestorable={};for(let[r,i]of t)this.watchPath(r,i.options,i.handler)}async watcherAdd(t,r){let{folderPath:i}=t;(this._watchers[i]=this._watchers[i]||[]).push(t);let a=new wlS(this,t,r);return await a.init(),a}watcherClose(t){t.watcher.close();let r=this._watchers[t.folderPath];if(r){let a=r.indexOf(t);r.splice(a,1),r.length||delete this._watchers[t.folderPath]}let i=t.filePath||t.folderPath;this._roots.has(i)&&(this._watchersRestorable[i]=t,this._watchersRestoreTimeout||(this._watchersRestoreTimeout=Mh.lang.defer(()=>this.watchersRestore())))}watcherExists(t,r,i,n){if(this._watchers[t]?.find(c=>c.handler===i&&(!c.filePath||c.filePath===n)&&c.options.ignore===r.ignore&&!!c.options.native==!!r.native&&(!r.recursive||c.options.recursive)))return!0;let o=Mra.default.dirname(t);for(let c=1;c<1/0;c++){if(this._watchers[o]?.find(u=>(c===1||u.options.recursive&&c<=(u.options.depth??Wbn))&&u.handler===i&&(!u.filePath||u.filePath===n)&&u.options.ignore===r.ignore&&!!u.options.native==!!r.native&&(!r.recursive||u.options.recursive&&xbn&&u.options.native!==!1)))return!0;if(!xbn)break;let s=Mra.default.dirname(t);if(o===s)break;o=s}return!1}async watchDirectories(t,r,i,n,a){if(this.isClosed())return;t=Mh.lang.uniq(t).sort();let o;for(let c of t)if(!this.isIgnored(c,r.ignore)&&!this.watcherExists(c,r,i,n))try{let d=!r.recursive||xbn&&r.native!==!1?r:{...r,recursive:!1},u={watcher:chc.default.watch(c,d),handler:i,options:r,folderPath:c,filePath:n},f=o=await this.watcherAdd(u,a);if(this._roots.has(n||c)){let _={...r,ignoreInitial:!0,recursive:!1},h=Mra.default.dirname(c),y=c;await this.watchDirectories([h],_,i,y,f)}}catch(d){this.error(d)}return o}async watchDirectory(t,r,i,n,a){if(!this.isClosed()&&!this.isIgnored(t,r.ignore)){if(!r.recursive||xbn&&r.native!==!1)return this.watchersLock(()=>this.watchDirectories([t],r,i,n,a));{r={...r,recursive:!0};let o=r.depth??Wbn,c=r.limit??c8o,[d]=await Mh.fs.readdir(t,r.ignore,o,c,this._closeSignal,r.readdirMap);return this.watchersLock(async()=>{let s=await this.watchDirectories([t],r,i,n,a);if(d.length){let u=Mh.fs.getDepth(t);for(let f of d){let p=Mh.fs.getDepth(f),_=Math.max(0,o-(p-u)),h={...r,depth:_};await this.watchDirectories([f],h,i,n,a||s)}}})}}}async watchFileOnce(t,r,i){if(this.isClosed()||(r={...r,ignoreInitial:!1},this.subwatcherExists(t,r)))return;let n={targetPath:t,options:r},a=(s,u)=>{u===t&&(d(),i())},o=new e(a),c=()=>{this._subwatchers.add(n),this.on(oX.CLOSE,d),o.watchFile(t,r,a)},d=()=>{this._subwatchers.delete(n),this.removeListener(oX.CLOSE,d),o.close()};return c()}async watchFile(t,r,i){if(this.isClosed()||this.isIgnored(t,r.ignore))return;r={...r,recursive:!1};let n=Mra.default.dirname(t);return this.watchDirectory(n,r,i,t)}async watchPollingOnce(t,r,i){if(this.isClosed())return;let n=!1,a=new Tzp,o=await this.watchPolling(t,r,async()=>{n||!(await a.update(t,r.pollingTimeout)).length||n||(n=!0,o(),i())})}async watchPolling(t,r,i){if(this.isClosed())return Mh.lang.noop;if(this.pollerExists(t,r))return Mh.lang.noop;let n={...r,interval:r.pollingInterval??plS},a={targetPath:t,options:r},o=()=>{this._pollers.add(a),this.on(oX.CLOSE,c),chc.default.watchFile(t,n,i)},c=()=>{this._pollers.delete(a),this.removeListener(oX.CLOSE,c),chc.default.unwatchFile(t,i)};return Mh.lang.attempt(o),()=>Mh.lang.attempt(c)}async watchUnknownChild(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchFileOnce(t,r,n)}async watchUnknownTarget(t,r,i){if(this.isClosed())return;let n=()=>this.watchPath(t,r,i);return this.watchPollingOnce(t,r,n)}async watchPaths(t,r,i){if(this.isClosed())return;if(t=Mh.lang.uniq(t).sort(),t.every((a,o)=>t.every((c,d)=>d===o||!Mh.fs.isSubPath(a,c))))await Promise.all(t.map(a=>this.watchPath(a,r,i)));else for(let a of t)await this.watchPath(a,r,i)}async watchPath(t,r,i){if(this.isClosed()||(t=Mra.default.resolve(t),this.isIgnored(t,r.ignore)))return;let n=await Mh.fs.poll(t,r.pollingTimeout);if(n){if(n.isFile())return this.watchFile(t,r,i);if(n.isDirectory())return this.watchDirectory(t,r,i);this.error(`"${t}" is not supported`)}else{let a=Mra.default.dirname(t);return(await Mh.fs.poll(a,r.pollingTimeout))?.isDirectory()?this.watchUnknownChild(t,r,i):this.watchUnknownTarget(t,r,i)}}async watch(t,r,i=Mh.lang.noop){if(Mh.lang.isFunction(t))return this.watch([],{},t);if(Mh.lang.isUndefined(t))return this.watch([],r,i);if(Mh.lang.isFunction(r))return this.watch(t,{},r);if(Mh.lang.isUndefined(r))return this.watch(t,{},i);if(this.isClosed())return;this.isReady()&&(r.readdirMap=void 0);let n=Mh.lang.castArray(t);n.forEach(a=>this._roots.add(a)),await this.watchPaths(n,r,i),!this.isClosed()&&(i!==Mh.lang.noop&&this.on(oX.ALL,i),r.readdirMap=void 0,this.ready())}},lhc=Rzp;xlc();var l9a=require("fs/promises"),DlS=require("os"),BlS=se(require("path"),1),cV5=".fern",lV5="logs";function fV5(){return"cli@3.56.10"}var h8o=class{logFilePath=null;initialized=!1;sessionStartTime;constructor(){this.sessionStartTime=Date.now()}async initialize(){if(this.initialized)return;let t=ot(mr.of((0,DlS.homedir)()),Pe.of(cV5)),r=ot(t,Pe.of(lV5));await ni(r)||await(0,l9a.mkdir)(r,{recursive:!0});let n=`${new Date().toISOString().replace(/[:.]/g,"-")}.debug.log`;this.logFilePath=ot(r,Pe.of(n));let a=["================================================================================","Fern Docs Dev Debug Log",`Session started: ${new Date().toISOString()}`,`Log file: ${BlS.default.basename(this.logFilePath)}`,"================================================================================",""].join(`
|
|
2440
2440
|
`);await(0,l9a.writeFile)(this.logFilePath,a,"utf-8"),this.initialized=!0}getLogFilePath(){return this.logFilePath}async writeEntry(t){if(!this.initialized||!this.logFilePath)return;let r=JSON.stringify(t)+`
|
|
2441
2441
|
`;try{await(0,l9a.appendFile)(this.logFilePath,r,"utf-8")}catch{}}async logFrontendMetrics(t){let r={timestamp:t.timestamp,source:t.source,level:t.level,eventType:this.getEventType(t.payload,t.isAggregate),isAggregate:t.isAggregate,data:t.payload};await this.writeEntry(r)}async logCliMetric(t,r="info"){let i={timestamp:t.timestamp,source:fV5(),level:r,eventType:t.type,data:{durationMs:t.durationMs,metadata:t.metadata}};await this.writeEntry(i)}async logCliMemory(){let t=process.memoryUsage(),r={type:"cli_memory",timestamp:new Date().toISOString(),metadata:{heapUsed:t.heapUsed,heapTotal:t.heapTotal,external:t.external,rss:t.rss,heapUsedMB:Math.round(t.heapUsed/1024/1024*100)/100,heapTotalMB:Math.round(t.heapTotal/1024/1024*100)/100,rssMB:Math.round(t.rss/1024/1024*100)/100}};await this.logCliMetric(r)}async logCliReloadStart(){let t={type:"cli_reload_start",timestamp:new Date().toISOString()};await this.logCliMetric(t)}async logCliReloadFinish(t,r){let i={type:"cli_reload_finish",timestamp:new Date().toISOString(),durationMs:t,metadata:r};await this.logCliMetric(i)}async logCliDocsGeneration(t,r){let i={type:"cli_docs_generation",timestamp:new Date().toISOString(),durationMs:t,metadata:r};await this.logCliMetric(i)}async logCliValidation(t,r){let i={type:"cli_validation",timestamp:new Date().toISOString(),durationMs:t,metadata:{success:r}};await this.logCliMetric(i)}getEventType(t,r){return r?"aggregate_summary":"type"in t&&typeof t.type=="string"?t.type:"unknown"}static isMetricsMessage(t){if(typeof t!="object"||t===null)return!1;let r=t;return r.type==="metrics"&&typeof r.timestamp=="string"&&typeof r.source=="string"}};var rNp=se(xzp(),1),SdS=se(WJs(),1),WOe=require("fs/promises"),MdS=require("os"),DdS=se(VQ(),1),BdS=se(wdS(),1),Mhc=process.platform==="win32",tNp=Ot.cyan("[docs]:"),zV5="etag",NV5=23,EdS=e=>e.padEnd(NV5," "),FV5="preview",QV5="app-preview",UV5="bundle",LV5=".next",VV5="standalone",WV5=".fern",xV5="packages/fern-docs/bundle/.next/server/instrumentation.js",GV5=".npmrc",HV5=".pnpmfile.cjs",KV5="pnpm-workspace.yaml",$V5='Cannot find matching keyid: {"signatures":';function JV5(){return ot(mr.of((0,MdS.homedir)()),Pe.of(WV5))}function f9a({app:e=!1}){return ot(JV5(),Pe.of(e?QV5:FV5))}function Kbn({app:e=!1}){return ot(f9a({app:e}),Pe.of(e?LV5:UV5))}function v8o({app:e=!1}){return ot(Kbn({app:e}),Pe.of(VV5))}function YV5({app:e=!1}){return ot(v8o({app:e}),Pe.of(xV5))}function XV5({app:e=!1}){return ot(v8o({app:e}),Pe.of(KV5))}function ZV5({app:e=!1}){return ot(v8o({app:e}),Pe.of(HV5))}function kV5({app:e=!1}){return ot(v8o({app:e}),Pe.of(GV5))}function Ira(e){return new Error(`${e}. Please reach out to support@buildwithfern.com.`)}function e35({app:e=!1}){return ot(f9a({app:e}),Pe.of(zV5))}var t35=`module.exports = {
|
|
2442
2442
|
hooks: {
|
|
@@ -2522,7 +2522,7 @@ More information: https://mdxjs.com/docs/troubleshooting-mdx`);return n.stack=""
|
|
|
2522
2522
|
`)}function Ex5(e){return e.some(t=>t.severity==="fatal")?"fatal":e.some(t=>t.severity==="error")?"error":"warning"}function Sx5(e){switch(e){case"fatal":return Ma.Error;case"error":return Ma.Error;case"warning":return Ma.Warn;default:de(e)}}function Mx5(e){switch(e){case"fatal":return Ot.red("[error]");case"error":return Ot.red("[error]");case"warning":return Ot.yellow("[warning]");default:de(e)}}function Dx5({stats:e,context:t,logWarnings:r,elapsedMillis:i=0}){let{numFatal:n,numErrors:a,numWarnings:o}=e,c=i>0?` in ${(i/1e3).toFixed(3)} seconds.`:".",d=`Found ${n+a} errors and ${o} warnings`+c;!r&&o>0&&(d+=" Run fern check --warnings to print out the warnings not shown."),n+a>0?t.logger.error(d):o>0?t.logger.warn(d):t.logger.info(Ot.green("\u2713 All checks passed"))}function Bx5(e){let t=0,r=0,i=0;for(let n of e)switch(n.severity){case"fatal":t+=1;continue;case"error":r+=1;continue;case"warning":i+=1;continue;default:de(n.severity)}return{numFatal:t,numErrors:r,numWarnings:i}}async function DhS({workspace:e,apiWorkspaces:t,ossWorkspaces:r,context:i,errorOnBrokenLinks:n,excludeRules:a}){e.config.settings?.substituteEnvVars&&(e.config=kz(e.config,{onError:u=>i.failAndThrow(u)}));let o=performance.now(),c=await m9a(e,i,t,r,!1,a),d=performance.now()-o,s=c.some(u=>u.severity==="fatal"||u.severity==="error");return n&&(s=s||c.some(u=>u.name==="valid-markdown-links")),{violations:c,elapsedMillis:d,hasErrors:s}}async function P9a({workspace:e,apiWorkspaces:t,ossWorkspaces:r,context:i,logWarnings:n,errorOnBrokenLinks:a,logSummary:o=!0,excludeRules:c}){e.config.settings?.substituteEnvVars&&(e.config=kz(e.config,{onError:p=>i.failAndThrow(p)}));let d=performance.now(),s=await m9a(e,i,t,r,!1,c),u=performance.now()-d,{hasErrors:f}=A9a({violations:s,context:i,logWarnings:n,logSummary:o,logBreadcrumbs:!1,elapsedMillis:u});return a&&(f=f||s.some(p=>p.name==="valid-markdown-links")),{hasErrors:f}}async function BhS({workspace:e,apiWorkspaces:t,ossWorkspaces:r,context:i,logWarnings:n,errorOnBrokenLinks:a,excludeRules:o}){let{hasErrors:c}=await P9a({workspace:e,context:i,logWarnings:n,apiWorkspaces:t,ossWorkspaces:r,errorOnBrokenLinks:a,excludeRules:o});c&&i.failAndThrow()}async function IhS({loadProject:e,cliContext:t,port:r,bundlePath:i,brokenLinks:n,legacyPreview:a,backendPort:o,forceDownload:c}){let d=await e(),s=d.docsWorkspaces;s!=null&&(a&&(await t.instrumentPostHogEvent({orgId:d.config.organization,command:"fern docs dev --legacy"}),await t.runTaskForWorkspace(s,async u=>{u.logger.info(`Starting server on port ${r}`),await ONp({initialProject:d,reloadProject:e,validateProject:async f=>{let p=f.docsWorkspaces;if(p==null)return;let _=n?[]:["valid-markdown-links"],h=p.config.experimental?.openapiParserV3;h==null||h?await P9a({workspace:p,context:u,logWarnings:!0,logSummary:!1,apiWorkspaces:[],ossWorkspaces:await Dx(f),excludeRules:_}):await P9a({workspace:p,context:u,logWarnings:!0,logSummary:!1,apiWorkspaces:f.apiWorkspaces,ossWorkspaces:await Dx(f),excludeRules:_})},context:u,port:r,bundlePath:i})})),await t.instrumentPostHogEvent({orgId:d.config.organization,command:"fern docs dev --beta"}),await t.runTaskForWorkspace(s,async u=>{u.logger.info("Bootstrapping docs preview (this may take a few seconds)..."),await vNp({initialProject:d,reloadProject:e,validateProject:async f=>{let p=f.docsWorkspaces;if(p==null)return;let _=n?[]:["valid-markdown-links"],h=p.config.experimental?.openapiParserV3;h==null||h?await P9a({workspace:p,context:u,logWarnings:!0,logSummary:!1,apiWorkspaces:[],ossWorkspaces:await Dx(f),excludeRules:_}):await P9a({workspace:p,context:u,logWarnings:!0,logSummary:!1,apiWorkspaces:f.apiWorkspaces,ossWorkspaces:await Dx(f),excludeRules:_})},context:u,port:r,bundlePath:i,backendPort:o,forceDownload:c})}))}var Qra=require("fs/promises"),oSe=se(EyS(),1);async function R55({previewUrl:e,files:t,token:r}){let i=t.join(","),n=`https://${e}/api/fern-docs/get-slug-for-file?files=${encodeURIComponent(i)}`,a=await fetch(n,{method:"GET",headers:{FERN_TOKEN:r}});if(!a.ok){let o=await a.text();throw new Error(`Failed to get slugs for files: ${a.status} ${a.statusText} - ${o}`)}return await a.json()}async function SyS({browser:e,url:t,outputPath:r,token:i}){let n=await e.newPage();try{await n.setViewport({width:1440,height:900,deviceScaleFactor:2}),i&&await n.setExtraHTTPHeaders({FERN_TOKEN:i});let a=await n.goto(t,{waitUntil:"networkidle2",timeout:3e4});return!a||a.status()===404?(await n.close(),!1):(await n.screenshot({path:r,fullPage:!0}),await n.close(),!0)}catch{return await n.close(),!1}}function z55(e){return e.replace(/\//g,"-")}function CFp(e,t,r,i,n,a){for(let o=0;o<n;o++){let c=(r*n+o)*4,d=(i*n+o)*4,s=Math.abs((e[c]??0)-(t[d]??0)),u=Math.abs((e[c+1]??0)-(t[d+1]??0)),f=Math.abs((e[c+2]??0)-(t[d+2]??0));if(s>a||u>a||f>a)return!0}return!1}function N55(e,t,r,i,n,a,o=.1,c=5e3,d=100){let s=Math.floor(o*255),u=-1,f=Math.min(n,a);for(let j=0;j<f;j++)if(CFp(e,t,j,j,r,s)){u=j;break}if(u===-1)if(n!==a)u=f;else return[];let p=20,_=u,h=Math.max(n,a);for(let j=0;j<h;j++){let M=n-1-j,w=a-1-j;if(M<0||w<0){_=Math.max(n,a)-1-j+1;break}if(CFp(e,t,M,w,r,s)){let E=1;for(let B=j+1;B<Math.min(j+p,h);B++){let q=n-1-B,R=a-1-B;if(q<0||R<0){E++;continue}if(CFp(e,t,q,R,r,s))E++;else break}if(E>=p){_=Math.min(M,w);break}}}_<u&&(_=u);let y=Math.max(0,u-d),b=Math.min(i-1,_+d),v=100,O=r,m=0;for(let j=u;j<=Math.min(_,i-1);j++)for(let M=0;M<r;M++){let w=(j*r+M)*4,E=Math.abs((e[w]??0)-(t[w]??0)),B=Math.abs((e[w+1]??0)-(t[w+1]??0)),q=Math.abs((e[w+2]??0)-(t[w+2]??0));(E>s||B>s||q>s)&&(M<O&&(O=M),M>m&&(m=M))}O>m?(O=0,m=r-1):(O=Math.max(0,O-v),m=Math.min(r-1,m+v));let g={minX:O,minY:y,maxX:m,maxY:b};return(g.maxX-g.minX)*(g.maxY-g.minY)<c?[]:[g]}function MyS(e,t,r=50){let i=Math.max(0,t.minX-r),n=Math.max(0,t.minY-r),a=Math.min(e.width,t.maxX+r),o=Math.min(e.height,t.maxY+r),c=a-i,d=o-n,s=new oSe.PNG({width:c,height:d});return oSe.PNG.bitblt(e,s,i,n,c,d,0,0),s}function DyS(e,t,r,i,n,a,o){let[c,d,s,u]=a;for(let f=0;f<o;f++){for(let p=t;p<t+i;p++){let _=((r+f)*e.width+p)*4,h=((r+n-1-f)*e.width+p)*4;e.data[_]=c,e.data[_+1]=d,e.data[_+2]=s,e.data[_+3]=u,e.data[h]=c,e.data[h+1]=d,e.data[h+2]=s,e.data[h+3]=u}for(let p=r;p<r+n;p++){let _=(p*e.width+(t+f))*4,h=(p*e.width+(t+i-1-f))*4;e.data[_]=c,e.data[_+1]=d,e.data[_+2]=s,e.data[_+3]=u,e.data[h]=c,e.data[h+1]=d,e.data[h+2]=s,e.data[h+3]=u}}}function F55(e,t,r=20,i=!0){let n=e.width+r+t.width,a=Math.max(e.height,t.height),o=new oSe.PNG({width:n,height:a});if(o.data.fill(255),oSe.PNG.bitblt(e,o,0,0,e.width,e.height,0,0),oSe.PNG.bitblt(t,o,0,0,t.width,t.height,e.width+r,0),i){let c=[255,196,0,255],d=3;DyS(o,0,0,e.width,e.height,c,d),DyS(o,e.width+r,0,t.width,t.height,c,d)}return o}async function Q55({beforePath:e,afterPath:t,comparisonBasePath:r}){let i=oSe.PNG.sync.read(await(0,Qra.readFile)(e)),n=oSe.PNG.sync.read(await(0,Qra.readFile)(t)),a=i.height,o=n.height,c=Math.max(i.width,n.width),d=Math.max(i.height,n.height),s=new oSe.PNG({width:c,height:d}),u=new oSe.PNG({width:c,height:d});s.data.fill(255),u.data.fill(255),oSe.PNG.bitblt(i,s,0,0,i.width,i.height,0,0),oSe.PNG.bitblt(n,u,0,0,n.width,n.height,0,0);let f=new Uint8Array(s.data.buffer,s.data.byteOffset,s.data.length),p=new Uint8Array(u.data.buffer,u.data.byteOffset,u.data.length),_=N55(f,p,c,d,a,o),h=[];if(_.length===0)return h;let y=r.endsWith(".png")?r.slice(0,r.length-4):r;for(let b=0;b<_.length;b++){let v=_[b];if(v==null)continue;let O=v.maxX-v.minX,m=v.maxY-v.minY,g=O*m,A=c*d,j=g/A*100,M=MyS(s,v),w=MyS(u,v),E=F55(M,w,20,!0),B=`${y}-region-${b+1}.png`,q=oSe.PNG.sync.write(E);await(0,Qra.writeFile)(B,new Uint8Array(q)),h.push({changePercent:j,boundingBox:v,comparisonPath:B})}return h}function U55(e){if(e.instances==null||e.instances.length===0)throw new Error("No docs instances configured in docs.yml");let t=e.instances[0];if(t==null)throw new Error("No docs instances configured in docs.yml");let i=t["custom-domain"]??t.url;!i.startsWith("https://")&&!i.startsWith("http://")&&(i=`https://${i}`);try{let n=new URL(i),a=n.pathname!=="/"?n.pathname.replace(/\/$/,""):null;return{baseUrl:`${n.protocol}//${n.host}`,basePath:a}}catch{return{baseUrl:i,basePath:null}}}async function ByS({cliContext:e,project:t,previewUrl:r,files:i,outputDir:n}){let a=t.docsWorkspaces;if(a==null)return e.failAndThrow("No docs workspace found. Make sure you have a docs.yml file."),{diffs:[]};let o=await e.runTask(async h=>gV(h));if(o==null)return e.failAndThrow("Failed to authenticate. Please run 'fern login' first."),{diffs:[]};let c=process.env.FERN_TOKEN??o.value,d=U55(a.config),s=r;s.startsWith("https://")?s=s.slice(8):s.startsWith("http://")&&(s=s.slice(7));let u=s.indexOf("/");u!==-1&&(s=s.slice(0,u));let f=await e.runTask(async h=>(h.logger.info(`Resolving slugs for ${i.length} file(s)...`),R55({previewUrl:s,files:i,token:c})));f.authed&&e.logger.warn("The docs require authentication. Screenshots may not capture the full content without proper auth.");let p=mr.of(n.startsWith("/")?n:ot(OO(),Pe.of(n)));await ni(p)||await(0,Qra.mkdir)(p,{recursive:!0});let _=[];return await e.runTask(async h=>{h.logger.info("Starting browser for screenshot capture...");let y=await Cpc({headless:!0,args:["--ignore-certificate-errors","--no-sandbox","--disable-setuid-sandbox"]});try{for(let b of f.mappings){if(b.slug==null){h.logger.warn(`Could not find slug for file: ${b.filePath}`);continue}let v=b.slug,O=z55(v),m=ot(p,Pe.of(`${O}-before.png`)),g=ot(p,Pe.of(`${O}-after.png`)),A=ot(p,Pe.of(`${O}-comparison.png`)),j=`${d.baseUrl}/${v}`,M=`https://${s}/${v}`;h.logger.info(`Capturing screenshots for: ${v}`);let w=await SyS({browser:y,url:j,outputPath:m,token:c});if(!await SyS({browser:y,url:M,outputPath:g,token:c})){h.logger.warn(`Could not capture preview page for: ${v}`);continue}let B=!w;if(w){let q=await Q55({beforePath:m,afterPath:g,comparisonBasePath:A});q.length===0?(h.logger.info(" No visual changes detected"),_.push({file:b.filePath,slug:v,comparison:null,changePercent:0,isNewPage:B})):q.forEach((R,T)=>{h.logger.info(` Region ${T+1}: ${R.changePercent.toFixed(2)}% (split & cropped)`),_.push({file:b.filePath,slug:v,comparison:R.comparisonPath,changePercent:R.changePercent,isNewPage:B})})}else h.logger.info(" New page (no production version)"),_.push({file:b.filePath,slug:v,comparison:null,changePercent:null,isNewPage:B})}}finally{await y.close()}}),{diffs:_}}var L55=/^[a-z0-9-]+-preview-[a-z0-9-]+\.docs\.buildwithfern\.com$/i;function V55(e){let t=e.toLowerCase().trim();t.startsWith("https://")?t=t.slice(8):t.startsWith("http://")&&(t=t.slice(7));let r=t.indexOf("/");return r!==-1&&(t=t.slice(0,r)),L55.test(t)}async function IyS({cliContext:e,previewUrl:t}){if(!V55(t)){e.failAndThrow(`Invalid preview URL: ${t}
|
|
2523
2523
|
Only preview sites can be deleted with this command.
|
|
2524
2524
|
Preview URLs follow the pattern: {org}-preview-{hash}.docs.buildwithfern.com
|
|
2525
|
-
Example: acme-preview-abc123.docs.buildwithfern.com`);return}let r=await e.runTask(async i=>gV(i));if(r==null){e.failAndThrow("Failed to authenticate. Please run 'fern login' first.");return}await e.runTask(async i=>{i.logger.info(`Deleting preview site: ${t}`);let a=await xxt({token:r.value}).docs.v2.write.deleteDocsSite({url:t});if(a.ok)i.logger.info(Ot.green(`Successfully deleted preview site: ${t}`));else switch(a.error.error){case"UnauthorizedError":return i.failAndThrow("You do not have permissions to delete this preview site. Reach out to support@buildwithfern.com");case"DocsNotFoundError":return i.failAndThrow(`Preview site not found: ${t}`);default:return i.failAndThrow(`Failed to delete preview site: ${t}`,a.error)}})}async function CyS({cliContext:e,limit:t,page:r}){let i=await e.runTask(async n=>gV(n));if(i==null){e.failAndThrow("Failed to authenticate. Please run 'fern login' first.");return}await e.runTask(async n=>{n.logger.info("Fetching preview deployments...");let o=await xxt({token:i.value}).docs.v2.read.listAllDocsUrls({page:r,limit:t??100
|
|
2525
|
+
Example: acme-preview-abc123.docs.buildwithfern.com`);return}let r=await e.runTask(async i=>gV(i));if(r==null){e.failAndThrow("Failed to authenticate. Please run 'fern login' first.");return}await e.runTask(async i=>{i.logger.info(`Deleting preview site: ${t}`);let a=await xxt({token:r.value}).docs.v2.write.deleteDocsSite({url:t});if(a.ok)i.logger.info(Ot.green(`Successfully deleted preview site: ${t}`));else switch(a.error.error){case"UnauthorizedError":return i.failAndThrow("You do not have permissions to delete this preview site. Reach out to support@buildwithfern.com");case"DocsNotFoundError":return i.failAndThrow(`Preview site not found: ${t}`);default:return i.failAndThrow(`Failed to delete preview site: ${t}`,a.error)}})}async function CyS({cliContext:e,limit:t,page:r}){let i=await e.runTask(async n=>gV(n));if(i==null){e.failAndThrow("Failed to authenticate. Please run 'fern login' first.");return}await e.runTask(async n=>{n.logger.info("Fetching preview deployments...");let o=await xxt({token:i.value}).docs.v2.read.listAllDocsUrls({page:r,limit:t??100});if(!o.ok)return n.failAndThrow("Failed to fetch docs URLs",o.error);let c=/-preview-[a-f0-9-]+\.docs\.buildwithfern\.com$/,d=o.body.urls.filter(s=>c.test(s.domain)).map(s=>({url:s.basePath!=null?`${s.domain}${s.basePath}`:s.domain,organizationId:s.organizationId,updatedAt:s.updatedAt}));if(d.length===0){n.logger.info("No preview deployments found.");return}n.logger.info(Ot.bold(`
|
|
2526
2526
|
Found ${d.length} preview deployment(s):
|
|
2527
2527
|
`));for(let s of d){let u=new Date(s.updatedAt).toLocaleString();n.logger.info(` ${Ot.cyan(s.url)}`),n.logger.info(` Organization: ${s.organizationId}`),n.logger.info(` Updated: ${u}
|
|
2528
2528
|
`)}})}var GyS=require("fs/promises");var QyS=Symbol.for("immer-nothing"),qyS=Symbol.for("immer-draftable"),uSe=Symbol.for("immer-state"),W55=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function GOe(e,...t){if(process.env.NODE_ENV!=="production"){let r=W55[e],i=typeof r=="function"?r.apply(null,t):r;throw new Error(`[Immer] ${i}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var I8o=Object.getPrototypeOf;function S9a(e){return!!e&&!!e[uSe]}function Lra(e){return e?UyS(e)||Array.isArray(e)||!!e[qyS]||!!e.constructor?.[qyS]||T8o(e)||Byc(e):!1}var x55=Object.prototype.constructor.toString(),TyS=new WeakMap;function UyS(e){if(!e||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;let r=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;if(r===Object)return!0;if(typeof r!="function")return!1;let i=TyS.get(r);return i===void 0&&(i=Function.toString.call(r),TyS.set(r,i)),i===x55}function Eyc(e,t,r=!0){Dyc(e)===0?(r?Reflect.ownKeys(e):Object.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((i,n)=>t(n,i,e))}function Dyc(e){let t=e[uSe];return t?t.type_:Array.isArray(e)?1:T8o(e)?2:Byc(e)?3:0}function RFp(e,t){return Dyc(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function LyS(e,t,r){let i=Dyc(e);i===2?e.set(t,r):i===3?e.add(r):e[t]=r}function G55(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function T8o(e){return e instanceof Map}function Byc(e){return e instanceof Set}function Ura(e){return e.copy_||e.base_}function zFp(e,t){if(T8o(e))return new Map(e);if(Byc(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=UyS(e);if(t===!0||t==="class_only"&&!r){let i=Object.getOwnPropertyDescriptors(e);delete i[uSe];let n=Reflect.ownKeys(i);for(let a=0;a<n.length;a++){let o=n[a],c=i[o];c.writable===!1&&(c.writable=!0,c.configurable=!0),(c.get||c.set)&&(i[o]={configurable:!0,writable:!0,enumerable:c.enumerable,value:e[o]})}return Object.create(I8o(e),i)}else{let i=I8o(e);if(i!==null&&r)return{...e};let n=Object.create(i);return Object.assign(n,e)}}function LFp(e,t=!1){return Iyc(e)||S9a(e)||!Lra(e)||(Dyc(e)>1&&Object.defineProperties(e,{set:wyc,add:wyc,clear:wyc,delete:wyc}),Object.freeze(e),t&&Object.values(e).forEach(r=>LFp(r,!0))),e}function H55(){GOe(2)}var wyc={value:H55};function Iyc(e){return e===null||typeof e!="object"?!0:Object.isFrozen(e)}var K55={};function Vra(e){let t=K55[e];return t||GOe(0,e),t}var C8o;function VyS(){return C8o}function $55(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function RyS(e,t){t&&(Vra("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function NFp(e){FFp(e),e.drafts_.forEach(J55),e.drafts_=null}function FFp(e){e===C8o&&(C8o=e.parent_)}function zyS(e){return C8o=$55(C8o,e)}function J55(e){let t=e[uSe];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function NyS(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[uSe].modified_&&(NFp(t),GOe(4)),Lra(e)&&(e=Syc(t,e),t.parent_||Myc(t,e)),t.patches_&&Vra("Patches").generateReplacementPatches_(r[uSe].base_,e,t.patches_,t.inversePatches_)):e=Syc(t,r,[]),NFp(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==QyS?e:void 0}function Syc(e,t,r){if(Iyc(t))return t;let i=e.immer_.shouldUseStrictIteration(),n=t[uSe];if(!n)return Eyc(t,(a,o)=>FyS(e,n,t,a,o,r),i),t;if(n.scope_!==e)return t;if(!n.modified_)return Myc(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;let a=n.copy_,o=a,c=!1;n.type_===3&&(o=new Set(a),a.clear(),c=!0),Eyc(o,(d,s)=>FyS(e,n,a,d,s,r,c),i),Myc(e,a,!1),r&&e.patches_&&Vra("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function FyS(e,t,r,i,n,a,o){if(n==null||typeof n!="object"&&!o)return;let c=Iyc(n);if(!(c&&!o)){if(process.env.NODE_ENV!=="production"&&n===r&&GOe(5),S9a(n)){let d=a&&t&&t.type_!==3&&!RFp(t.assigned_,i)?a.concat(i):void 0,s=Syc(e,n,d);if(LyS(r,i,s),S9a(s))e.canAutoFreeze_=!1;else return}else o&&r.add(n);if(Lra(n)&&!c){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[i]===n&&c)return;Syc(e,n),(!t||!t.scope_.parent_)&&typeof i!="symbol"&&(T8o(r)?r.has(i):Object.prototype.propertyIsEnumerable.call(r,i))&&Myc(e,n)}}}function Myc(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&LFp(t,r)}function Y55(e,t){let r=Array.isArray(e),i={type_:r?1:0,scope_:t?t.scope_:VyS(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=i,a=VFp;r&&(n=[i],a=q8o);let{revoke:o,proxy:c}=Proxy.revocable(n,a);return i.draft_=c,i.revoke_=o,c}var VFp={get(e,t){if(t===uSe)return e;let r=Ura(e);if(!RFp(r,t))return X55(e,r,t);let i=r[t];return e.finalized_||!Lra(i)?i:i===qFp(e.base_,t)?(TFp(e),e.copy_[t]=UFp(i,e)):i},has(e,t){return t in Ura(e)},ownKeys(e){return Reflect.ownKeys(Ura(e))},set(e,t,r){let i=WyS(Ura(e),t);if(i?.set)return i.set.call(e.draft_,r),!0;if(!e.modified_){let n=qFp(Ura(e),t),a=n?.[uSe];if(a&&a.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(G55(r,n)&&(r!==void 0||RFp(e.base_,t)))return!0;TFp(e),QFp(e)}return e.copy_[t]===r&&(r!==void 0||t in e.copy_)||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_[t]=!0),!0},deleteProperty(e,t){return qFp(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,TFp(e),QFp(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=Ura(e),i=Reflect.getOwnPropertyDescriptor(r,t);return i&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:i.enumerable,value:r[t]}},defineProperty(){GOe(11)},getPrototypeOf(e){return I8o(e.base_)},setPrototypeOf(){GOe(12)}},q8o={};Eyc(VFp,(e,t)=>{q8o[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});q8o.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&GOe(13),q8o.set.call(this,e,t,void 0)};q8o.set=function(e,t,r){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&GOe(14),VFp.set.call(this,e[0],t,r,e[0])};function qFp(e,t){let r=e[uSe];return(r?Ura(r):e)[t]}function X55(e,t,r){let i=WyS(t,r);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}function WyS(e,t){if(!(t in e))return;let r=I8o(e);for(;r;){let i=Object.getOwnPropertyDescriptor(r,t);if(i)return i;r=I8o(r)}}function QFp(e){e.modified_||(e.modified_=!0,e.parent_&&QFp(e.parent_))}function TFp(e){e.copy_||(e.copy_=zFp(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Z55=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(t,r,i)=>{if(typeof t=="function"&&typeof r!="function"){let a=r;r=t;let o=this;return function(d=a,...s){return o.produce(d,u=>r.call(this,u,...s))}}typeof r!="function"&&GOe(6),i!==void 0&&typeof i!="function"&&GOe(7);let n;if(Lra(t)){let a=zyS(this),o=UFp(t,void 0),c=!0;try{n=r(o),c=!1}finally{c?NFp(a):FFp(a)}return RyS(a,i),NyS(n,a)}else if(!t||typeof t!="object"){if(n=r(t),n===void 0&&(n=t),n===QyS&&(n=void 0),this.autoFreeze_&&LFp(n,!0),i){let a=[],o=[];Vra("Patches").generateReplacementPatches_(t,n,a,o),i(a,o)}return n}else GOe(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(o,...c)=>this.produceWithPatches(o,d=>t(d,...c));let i,n;return[this.produce(t,r,(o,c)=>{i=o,n=c}),i,n]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof e?.useStrictIteration=="boolean"&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Lra(e)||GOe(8),S9a(e)&&(e=k55(e));let t=zyS(this),r=UFp(e,void 0);return r[uSe].isManual_=!0,FFp(t),r}finishDraft(e,t){let r=e&&e[uSe];(!r||!r.isManual_)&&GOe(9);let{scope_:i}=r;return RyS(i,t),NyS(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let n=t[r];if(n.path.length===0&&n.op==="replace"){e=n.value;break}}r>-1&&(t=t.slice(r+1));let i=Vra("Patches").applyPatches_;return S9a(e)?i(e,t):this.produce(e,n=>i(n,t))}};function UFp(e,t){let r=T8o(e)?Vra("MapSet").proxyMap_(e,t):Byc(e)?Vra("MapSet").proxySet_(e,t):Y55(e,t);return(t?t.scope_:VyS()).drafts_.push(r),r}function k55(e){return S9a(e)||GOe(10,e),xyS(e)}function xyS(e){if(!Lra(e)||Iyc(e))return e;let t=e[uSe],r,i=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=zFp(e,t.scope_.immer_.useStrictShallowCopy_),i=t.scope_.immer_.shouldUseStrictIteration()}else r=zFp(e,!0);return Eyc(r,(n,a)=>{LyS(r,n,xyS(a))},i),t&&(t.finalized_=!1),r}var e65=new Z55,Cyc=e65.produce;function t65(e){return e.endsWith(`
|